r/AIMemory • • Oct 21 '26

Discussion My agents' memory branches with the code.

Enable HLS to view with audio, or disable this notification

I put my project knowledge in its own repo and made it snapshot code movements. It ties code, tests and whatever proof you have to invariants and their families, right at implementation time. That connects parts of the codebase grep would miss.

So an agent can later ask: what else breaks across the codebase (or beyond) when I touch this symbol? Which designs were tried here before, why were they rejected, and under which conditions can they come back on the table?

Memory curation isn't a one-time effort or an afterthought. It's a byproduct of getting work done. It informs the intended changes at the start and the intent review at the end, with a strict pipeline connecting both ends.

Lots still has to land on main. But I use it daily, for dogfooding and at work, where I keep tabs on several repos that revolve around one product.

Too early to say if the benefits outweigh the obvious costs. Housekeeping first, then a ton of benchmarks.

It may all be for naught. The memories we made along the way. Or it turns out actually useful. Who knows. What's certain is my stubbornness to see it to the end. ^^

Where am at it currently, if you want to poke at it:
https://github.com/Foxfire1st/agents-remember/tree/ar/260928_maintained-invariant-knowledge

194 Upvotes

23 comments sorted by

8

u/jackalop211 Oct 21 '26

Nice to see someone else converging on claims and evidence instead of flat notes. Recording rejected designs with the conditions under which they'd come back is exactly what flat memory loses. The next step is making that structure compute: when one claim changes, what else should change? A rejected design coming back should shift the tradeoffs downstream automatically. I work on Tortoise, which does this. It's a graph of claims with support/contradiction links to evidence, resolved with a custom algorithm based on prediction markets, so every claim carries a confidence and beliefs propagate through dependencies. Curious how you handle two invariants that contradict each other across branches.

3

u/FoxFire17739 Oct 21 '26 edited Oct 21 '26

And I thought I am getting crazy in my isolated isle. Cool to see others venture into this. The way it computes for me is that the git primitives do a lot of the lifting. Code moves, so the agent looks at the mirror structures in the memory. So that part is path based. The invariants that attribute to code know when they get stale when the code they are subbed to moves. So they track git hashes and my detection focuses on the symbol that changed instead of the whole file.

Once I have one invariant I move up within the memories subtree to the family which resides at that sub trees root. It is a functional guarantee or register that lists the invariants below it that it governs. This family can have other expressions in other places of the memory which like said mimicks the structure of the code base. Those expressions have their own invariant lists in other sub trees. This is what gives me the code graph.

If I find one invariant I find them all. And with all attributed code expressions. So in my case this becomes deterministic.

My tasks are grouped into epics. An epic is represented as an integration branch. Each task creates a branch of it. Then builds a dual work tree where code gets one and memory gets its own. They live in their own workspace. Every workspace gets their own coder, reviewer, and a curator. They get their task and document cut out and passed into their workspace. And from their they organise mostly themselfs. There is a manager agent sitting above them that helps them when they have trouble.

So tasks are isolated. Memory gets same isolation as code does. So the git workflow that you can understand as a dance of 2.

With an epic the Architect produces an execution graph. It knows which tasks are dependend and which not. So the ones running in parallel share little common surface.

The moment one task wants to integrate back its code and memory changes it has to check if both branches lineage is still correct. So if the parent moved. The manager agent syncs the parents changes into the workspace and the assigned coder, reviewer, and curator agents for that task have to resolve code any potential code or memory issues. Only after resolving those, their changes can be integrated into the parent. Their notes and traces get evacuated and attached to the tasks attachment. Agents retired. Workspace gets dissolved.

So you can work in parallel but you can't integrate simulatanously. Doing it this way though keeps work of sibling tasks non blocking.

7

u/jonah_omninode Oct 21 '26

We’re working on similar ideas in OmniNode: connecting invariants to contracts, code changes, and verification evidence, then turning failures into checks that prevent recurrence. Happy to share notes if you’re interested.
Here’s a relevant design from our public knowledge base: Drift Control and Contract-Gated PRs.

1

u/FoxFire17739 Oct 21 '26

Interesting to see you also work on that system. For agents-remember it runs its own repo which is also on my github: https://github.com/Foxfire1st/ar-agents-remember/tree/ar/260928_maintained-invariant-knowledge

I see some of the primitives you mention in my own system as well. What my repo can do right now is:
- giving agents a workflow to process invariants alongside the code
- orchestration that coordinates the agents for this specific workflow
- different roles that teach each agent for their part and how to do their part on the pipeline
- specific branch and merge strategies and deterministic checks to safeguard
- intent reviews by curators
- knowledge retrieval to inform new tasks
- my own task system that supports the workflow
- memory invariants & families with facets, code/test/proof attribution

too much for one comment. But what I have allows for me to work on tasks end-to-end with knowledge maintenance being part of the work getting done.

I have also some things to ask to understand your concept better. I have briefly went over the document.

2

u/jonah_omninode Oct 21 '26

Happy to compare notes. How do you handle two branches changing the same invariant in different ways? A Git merge can be clean even when the code, tests and remembered rule no longer agree. I'd want the merge to keep both sets of evidence and make the disagreement visible, rather than silently choose one. That's the case I'm most interested in here. Send over your questions about the OmniNode design as well.

1

u/FoxFire17739 Oct 21 '26

So they are multiple aspects to it. My task management has epics as you have seen in the video. They get an execution graph by the architect. It knows which tasks share depencies or shold build sequentially. So the ones running in parallel do already share no or little common surfaces.

The architect when it designs requirments uses its search + my knowledge tool. The seeds from search put into the knowledge tool uses the invariants system to get all or most code attributions. Search still helps to fill gaps which do also get plannes into the task and ammended later by the curator.

Now the execution graph is not perfect. But it helps already to untangle things.

Another layer is that the epic is an integration branch. And each task gets code and memory worktrees into their own workspace. Each with their own set of task agent.

Now if they want their work to integrate back to the integration branch it is being checked before wether the lineage changed. For example the parent moved.

In that case the changes have be synced into their workspace. Code conflicts get resolved and reviewed.

For the curator also sees for its memory branch what got merged into it. So besides obvious merge conflicts, or staleness detection from code that changed on the attributed invariants, the curator does on top its own judgement. So if 2 information touch the same invariant without causing a merge conflict it can still where it is coming from as it compares it with the requirments of both tasks. It raises the issue so I get know it via the architect. If it is obvious it handles it. If not it turns into a discussion as this can point at a product gap like in the screenshot I posted in this thread.

The curators main job is not just writing stuff down but also reviewing intent between task intent, what actually landed, and is in the memory. A threeway merge so to speak.

1

u/jonah_omninode Oct 21 '26

The curator comparing the requirements of both tasks answers what I was asking. You're checking whether the merged rule still makes sense, even when Git sees no conflict. Does the curator save the reason for resolving it one way with the invariant itself, or only in the task history? I'd want a later agent to find that explanation when it retrieves the rule, especially if a rejected alternative becomes relevant again. We have that distinction in the OmniNode memory design, but the pieces aren't integrated end to end yet.

1

u/FoxFire17739 Oct 21 '26

It does. Invariants do have their own history tables. So you can go back and see what happened to them. It is its own primitive. Same as decisions are. In a way my mix of json and markdowns is like a database without being one. The dbms logic around it and models were shaped for psql db but then I swapped it back to what I have now simply because else I throw away the advantages of git. So yeah each invariant needs its revision history.

1

u/FoxFire17739 Oct 22 '26

Also one good thing that makes things easy to test is to checkout agents-remember, install the AR MCP and then download its memory. With that you don't need to painfully build the memory. You have it right there and can use the agent to ask it targeted questions about every detail you want. There are a lot of suddleties that are hard to explain in just comments alone.

1

u/jonah_omninode Oct 22 '26

Using AR's own memory sounds like a good place to start. I'd like to try a small integration with OmniNode: an effect-node adapter that reads from your MCP server and supplies that memory to our coding tasks. We already have a context-source interface with explicit revisions and source references, so there's a place for it without replacing either system's workflow. Our pieces aren't fully connected end to end yet; this would give us a concrete integration to test.

I'd keep the first version read-only, using one public repo and a pinned copy of its memory. The test would be whether a task can retrieve an invariant or decision, trace it to the source, and distinguish a superseded record from a current one where AR provides that information. Missing records and an unavailable server should be explicit rather than look like successful retrievals. AR would continue to own its memory and curation; OmniNode would handle its own tasks. Writes and coordination between the two workflows can wait.

I looked through the MCP interface. `knowledge_read` returns record locations rather than their text, so we'd need to settle how the adapter reads those files against the pinned memory revision. Which build and tool path would you recommend for retrieving an invariant's history? Would you be interested in trying that first slice together?

1

u/FoxFire17739 Oct 23 '26

Hey Jonah — I'd definitely be up for trying that first read-only slice together. Your boundary (OmniNode owning its task/effect node, AR owning the memory and derived index at a pinned revision) fits how AR is structured.

You were looking at the right place on the ar/260928_maintained-invariant-knowledge branch. Here is what I'd recommend for the build, the tool path, and reading the pinned files:

1. Build & Public Repo + Pinned Memory Pair

- Code repo: Foxfire1st/agents-remember on branch ar/260928_maintained-invariant-knowledge (use commit b45795d2a or newer, where L73 landed the record view and direct text-ID lookups).

- Memory repo: Foxfire1st/ar-agents-remember on branch ar/260928_maintained-invariant-knowledge (this is the converted ar-memory-layout/v2 text tree with knowledge/layout.json, knowledge/{invariants,families,decisions,history}/, and onboarding/). Every memory commit carries a Code-Commit: trailer (and memory.md ledger mapping) so you can pin an exact (code_commit, memory_commit) pair.

2. Recommended Tool Path for Record Retrieval, Source Trace, Supersession & History

Use knowledge_read with view="record" and pass the text ID in recordId (INV-…, DEC-…, FAM-…, WKN-…):

{

memoryRoot: /abs/path/to/ar-agents-remember,

view: record,

recordId: INV-03M6ZA,

repositoryRoot: /abs/path/to/agents-remember,

codeTreeId: <pinned-code-commit-or-tree-sha>

}

By design (MIK-R109), knowledge_read returns what no single file holds—the computed graph and currentness—while naming file paths rather than carrying raw file text:

- Record & Location: record.path (e.g. knowledge/invariants/INV-03M6ZA-....json), record.revision, record.status, plus memoryCommit and memoryTree.treeKey.

- Source & Proof Trace: realizations[] (RLZ-… entries with source path, symbol/line locator, role, and live anchor state current | stale | unverifiable evaluated against codeTreeId) and proofs[] (PRF-… test symbols).

- Invariant History: timeline.events[] aggregates every curator judgment row about that invariant across all per-leaf knowledge/history/<leaf>.json files (disposition: changed | moved | deleted | extended | no_impact, effect: strengthen | weaken | clarify | replace | split | merge | retire, revision, reason, and the history file path). If you also want raw Git patches of the record file between two memory revisions, knowledge_diff(memoryRoot=..., before=..., after=..., recordId="INV-...") generates a diff report.

- Current vs. Superseded:

- For DEC-… decisions, view="record" returns both storedStatus and derivedStatus: "superseded" + supersededBy[] whenever a newer decision's supersedes[] points to it.

- For INV-… / FAM-…, retired/replaced records carry status: "retired" (with effect: "retire" | "replace" | "merge" in timeline), and the replacing record lists the old ID in supersedes[] (surfaced in incoming / outgoing links).

3. Reading the Record Text Against the Pinned Memory Revision

Since knowledge_read returns memoryRoot, memoryCommit (or memoryTree.treeKey), and the relative record.path (plus sidecar paths for RLZ-…/PRF-…), your effect-node adapter can either:

- Read <memoryRoot>/<record.path> directly from the pinned checkout (if the checkout moves mid-read, knowledge_read refuses with refusalCode: "snapshot_unavailable"), or

- Read straight from Git object storage via git -C <memoryRoot> show <memoryCommit>:<record.path> so it's strictly bound to the commit hash.

4. Explicit Refusals

Missing records and invalid trees never return empty "success" views—they return "state": "refused" with typed codes:

- Unknown ID $\rightarrow$ refusalCode: "selector_absent"

- Missing/unreadable root $\rightarrow$ refusalCode: "selected_input_unavailable" / "snapshot_unavailable"

- Unconverted tree $\rightarrow$ refusalCode: "legacy-format"

If you have a repo link or spec for OmniNode's context-source interface, share it—happy to map the exact fields or test the first slice with you.

1

u/jonah_omninode Oct 23 '26

The record view gives us a concrete place to start. Our public context-source protocol is here: https://github.com/OmniNode-ai/omnibase_spi/blob/dev/src/omnibase_spi/protocols/intelligence/protocol_context_source.py

The entry model is here: https://github.com/OmniNode-ai/omnibase_core/blob/dev/src/omnibase_core/models/context/model_context_source_entry.py

It carries the source reference, text hash, source time and supersession status. I'd have the effect-node adapter read the text from the pinned Git object, retain your record and code/memory references, and keep a missing record distinct from an unavailable snapshot. One current record, one superseded record and one absent ID would be a useful first test. This would be a new integration, not something we already have wired together.

1

u/FoxFire17739 Oct 23 '26

I will check it out tomorrow in more detail. By the way my MCP has a Dashboard. And I think this view could be in particular useful. It allows you to click more comfortably through the cards. Recently I added a "weakness" category where agents can document weaknesses they observed in the codebase. Could probably also be helpful for code optimization, debugging, and potentially cybersecurity. It produces claims that can be verified in a later "dream" session. What I also like about this is that it removes the pressure to either fix right away and produce scope creep or to defer and risk forgetting about it. It allows you to come back at a later time and revisit those issues. I have only recently added this and didn't expect after a brief time to see already so many entries.

→ More replies

1

u/FoxFire17739 Oct 27 '26

Thanks, this maps more cleanly than I expected. A few things that should save you time:

- Each record is a plain JSON file in the memory repo ([`knowledge/<kind>/<ID>-<slug>.json`](knowledge/\<kind\>/\<ID\>-\<slug\>.json), prose in a [`.md`](.md) beside it, schema-tagged `ar-invariant/v1`, `ar-decision/v1`, …), so your adapter can read straight from the pinned Git object with nothing of mine running. Landing commits carry a `Code-Commit:` trailer naming the code commit they were checked against, which is your code reference. Merge commits don't carry it, so pin the landing commit.

- Missing vs unavailable: my record view already keeps them apart. "Not found" means the tree holds no record with that ID. "Unavailable" means the read failed, and it says why. Same rule as yours: absence is never an empty success.

- One catch on supersession: "superseded" is never stored on the old record. The newer record names what it replaces in its `supersedes` list. Read the old blob alone and it looks current, so you need the whole tree at that commit (or my reader, which derives it). Statuses also don't map one to one: invariants are [proposed/accepted/retired](proposed/accepted/retired), decisions active/under_reconsideration. A retired record with no successor isn't really SUPERSEDED. How would you want that one?

- `revision` only goes up when a record's meaning changes, so AMENDED can come from comparing two commits.

- For invariants I also check each code location and proof against the paired code commit ([current/stale/unverifiable](current/stale/unverifiable)). That might fit your STALE: the record still exists, but the code under it moved.

For your first test, from my public memory repo (Foxfire1st/ar-agents-remember, MIK branch), commit a33aa5a43fb513153a26ba3a5529eccc39d88961: current `DEC-8326MP`, superseded `DEC-KV4ASN` (replaced by `DEC-8326MP`, while its own file still says active, which is exactly the catch), absent `DEC-000000`.

Caveat: this all lives on the MIK branch and isn't on main yet. The reader's JSON isn't a versioned contract yet, so I'd build against the files in Git.

3

u/Primary_Form4396 Oct 22 '26

Docops aproch literally

1

u/FoxFire17739 Oct 22 '26

I don't know it.

1

u/FoxFire17739 Oct 21 '26

This is an example for a curator bringing up an earlier design decision on its own. It highlighted the accepted design and its rejected alternatives for a feature and in the process also discovered a product gap. It brought that to the developer facing "architect" that then helped me understand the situation. The condition was in the end improved but not all the way, so the alternative design remains rejected. But the gap was real. And it found another gap soon after.

1

u/stianhoiland Oct 26 '26

I cannot express my disdain of this hyperinflation of significance and emotionality enough. Chill the fuck down.

1

u/FoxFire17739 Oct 26 '26

what? can you speak human please?

1

u/stianhoiland Oct 26 '26

It's funny because my comment is actually 100% human-made, by a fluent second-language speaker. Unlike your post and video. I'm not lying. Think about your response to that for a minute.

1

u/FoxFire17739 Oct 26 '26

True AI these days have gotten good enough not to forget to fill humans in on the context. You though barge in throw words around and expect everyone to get what your problem is. Now tell me why I should entertain your idiocy any second longer. So far you haven't added anything of substance to this thread.

2

u/Zero_resonance Oct 23 '26

Cool ❤‍🔥