Friday, November 27, 2026

Memento: A Mental Model for AI (and Finding Its main())

Author's note: Claude was used to scaffold and review this post

Intro: looking for main()

For a long time, I've struggled to form a mental model around AI. In many previous technologies I've encountered, I have a "where is the main()?" quest. Nothing is magic (or everything is, but that's another discussion), so I should be able to understand how this stuff works well enough for a technical deep dive.

AI's "main()" has eluded me up to this week, I think. But now, I think I get it.

Memento should be required viewing

Hear me out - Christopher Nolan's early film Memento was my epiphany.

In the film, protagonist Leonard Shelby has amnesia from an injury and is trying to solve his wife's murder. He starts each scene in the nonlinear narrative with a baseline of knowledge, but temporary and permanent memory are achieved by photos, notes and tattoos.

It's a great film - one that I watched many years ago and has stuck with me, due to the inventive storyline.

And reflecting on it helped me "find main()" with AI.

  • Leonard's training data is everything before his injury.
  • Each few minute scene is his context window.
  • His photos, notes and tattoos are system prompts, memory files, CLAUDE.md / AGENTS.md / etc.

No spoilers, because you really should watch it, but I will say that false information supplied with prompts and memory files can affect the system adversely. Garbage In / Garbage Out (especially if the garbage is deliberate misinformation by people with bad intent).

This is merely a mental model to better understand how to use the tool. In reality, an AI system rereads the whole conversation from the top for every word it writes. Leonard keeps a few minutes in his head; the AI keeps nothing between words.

Found it: the main loop

Claude was nice enough to write this out as pseudocode for me

tokens = system_prompt + memory_files + conversation;
while (!stop) {
    logits = forward(weights, tokens);   // pure function, weights frozen
    next   = sample(logits);
    tokens.push_back(next);
}

For any non-programmers, read it like this:

  • The system starts at the trained state
  • Add in a system prompt, and memory (Leonard's tattoos), and the conversations between you and the AI system so far.
  • To generate a response, the AI system keeps generating words (tokens - not exactly, but good enough for our discussion) until it says "yeah, enough. Your turn, user".

How this helps

  • What's important gets written in "tattoos" - permanent memory files.
  • Try to be judicious about use of space. Leonard only had so much skin and didn't want to waste time with excessive re-reading for context.
  • Other inputs (web sites visited during a session) get added to the pile of words as well. And those words are reprocessed for output words. Be wary of bad actors.
So that's main(): a short loop, a very large function, and a pile of words. The rest is tattoos.

Tuesday, November 24, 2026

A 7 Point Case for Rust AI Coding

Author’s note: human written

“and our love turns to rust.” - U2

When picking the right tool (language) for the job, you frequently have your all-things-being-equal choice. Sometimes tools are unequal and you have to go in a direction. Front end requires JS, mssql requires (duh) SQL, etc.

All-things-being-equal, I’m leaning towards Rust as my target of choice for AI driven coding projects for nontrivial production systems.

My reasons, some having to do with AI, and some having to do with the quality of the generated code:

1. It’s fast, with no garbage collection. Generated code is not starting at a performance or scalability disadvantage.

2. It’s type safe, which is helpful for human readers, and helpful for eliminating a large class of errors.

3. Variables are default read only (which is the way it always should have been, imho).

4. Strict data ownership enforced by compile time checking, via the borrow checker, making it more difficult to create or introduce later data alias mistakes.

5. Code can be tiered, where a DSL can be developed from an application core, and use of that DSL alone (with no native “low level” Rust) can be enforced at the higher level tiers, restricting AI from weaving low level and high level constructs in confusing manners. 

6. Integrates well with other languages, so Rust can serve as the performant "glue" to other right-for-the job languages.

7. A decent set of packages (this is getting better - other languages beat it here currently, but momentum is on the side of Rust)

 

If this is interesting, please let me know how, and I will gladly elaborate on any of these points.

Postscript: I did do an AI review, and was told that I missed Rust's very precise error messages helping fix its own mistakes.  

Thursday, April 18, 2024

Pickled hard eggs


  1. Get yer eggs
  2. Boil. I say 8 minutes
  3. Put in cold bath so they peel easier
  4. Brine is 3 cups vinegar to 2 cups water, plus 1/4 cup pickling salt.
  5. Add some fun stuff to the brine. I used dill, chives, capers, garlic.
  6. Let sit for a few days to soak the goodness. Enjoy!












Thursday, May 25, 2023

Potatoes-and-kale

"It's easy." "It's good." "It's easy!" "It's good!"

Laides, please - it's BOTH!

Potatoes and kale, two great tastes that taste great together.

Ingredients:

  1. oil
  2. little potatoes, like fingerling
  3. bunch of kale, coarsely chopped, remove stems
  4. garlic and/or onions
  5. salt, pepper
  6. (optional) sour cream
Directions
  1. blanche potatoes, should take about 8-10m
  2. While blanching, heat up oil to med/low and sauté some coarsely chopped kale. Throw in some garlic and/or onions. Toss around a bit while potatoes are blanching
  3. drain blanched potatoes
  4. add to kale, sauté some more, mix around a bit. Bump the heat up a bit to get things a little crispy
  5. salt & pepper to taste
  6. Can serve with some sour cream for extra yum (but not vegan)
I challenge anybody that dumps on kale to try this.

Thursday, May 4, 2023

Kimchi Egg Breakfast Sammie

 I threw this together as a "don't waste food" and omg is it so good. This is going to be part of my regular rotation.


Ingredients

  1. oil / butter
  2. diced potatoes
  3. onion
  4. 1 egg
  5. salt / pepper
  6. english muffin
  7. kimchi
  8. swiss cheese slice
  9. mayo
Steps
  1. oil / butter in a pan
  2. fry diced potatoes
  3. add diced onions near end so the onions don't burn
  4. scramble and fry egg to make a small omelette
  5. salt & pepper to taste
  6. english muffin, add mayo, omelette, kimchi (get some big pieces on there), swiss cheese slice
  7. grill both sides until done
  8. salt and pepper more to taste
yum! almost a mustard-y flavor

Saturday, April 1, 2023

Kimchi noodles


Ingredients:

  1. Garlic
  2. Ginger (I will use both garlic & ginger from a jar when I'm lazy. which is often)
  3. Cooking oil
  4. Sesame oil
  5. 3 eggs
  6. 3 bricks of dried noodles
  7. Miso paste
  8. Chicken or veggie bullion (I'm veg, but I eat chicken broth. I should turn in my membership card)

    NOTE: I recently tried dashi powder (which is used in miso soup stock), and I'm 100% a convert. Only dashi now.
  9. Chopped various veggies that fry well (I use this as an opportunity to clean out the fridge. Onions, bok choi, cabbage, peppers, etc.  Don't go to heavy on veggies so you don't overpower the kimchi)

    I sometimes add some fried or extra firm tofu here.
  10. Rice wine vinegar or mirin
  11. Chopped kimchi
  12. Chopped hot pepper, whatever is available (I like Thai chili)
  13. MSG
  14. Chopped green onion
  15. Chopped seaweed
  16. Sesamee seeds

Steps (do as much in parallel as possible)

  1. Garlic & ginger in cooking oil on lowest heat to sweat.
  2. Whisk eggs and add some sesame oil. Start making an omelette. Don't fully cook it, leave a bit runny.  Remove runny omelette from pan.
  3. Turn up heat on garlic & ginger, add chopped veggies & optional tofu. Stir fry.
  4. Boil water, miso paste and bullion / dashi. Add noodles when you've got about 3m left with the veggies. You'll want to almost, but not fully cook the noodles, so they can stir fry and not go mushy.

    Watch your miso - it'll want to clump in the boiling water. You might want to whisk your miso separately in a small dish of cold water before you boil it.
  5. Add some rice wine vinegar / mirin to the veggies / tofu and cover, steam a bit to make sure fully cooked through.
  6. Add chopped kimchi, and get as much of the sauce as you can with the veggies. It'll get a bit runny when you chop it.
  7. Add chopped hot pepper. Stir fry just a touch.
  8. Sprinkle some msg.
  9. Add runny omellete, chop it up with the veggies.
  10. Add almost fully cooked noodles.
  11. Stir fry.
  12. Turn off heat
  13. Add chopped seaweed, green onion and sesamee seeds
  14. Salt to taste


Tofu eggs

Ingredients
  1. 3 Eggs
  2. Sesame oil
  3. Packaged Fried tofu (Kalamazoo's Pacific Rim sells some lovely stuff)
  4. Little bit of garlic 
  5. Cooking oil
  6. Green onion
Steps
  1. Heat cooking oil in egg pan
  2. Whisk 3 eggs
  3. Add drop of sesame oil 
  4. Add garlic
  5. Add a few (4) wedges of sliced fried tofu, combine
  6. Make an omelette, sprinkle a little MSG near the end
  7. When done, top with green onion. Salt & pepper to taste