Repository navigation
Name every implicit state machine once; load the vector matrix one kind at a time - #18
Open
MakerViking wants to merge 2 commits into
Open
MakerViking wants to merge 2 commits into
MakerViking wants to merge 2 commits into
Conversation
…e place Every state the app moves through (a memory's lifecycle, a project's graph freshness, a session's handoff, a sync conflict, a hook install) now has one name, one function that derives it, and every surface (CLI, MCP, daemon, hooks, dashboard) prints that name. The map is in docs/design/state-machines.md; the user-facing list is CHANGELOG [Unreleased]. No schema change: the store stays at v14. Sync - replicate::Standing is the one total order of two versions of a memory: when its text was decided, forgotten over live, last write, digest. A pin, tag or anchor made after an unseen forget no longer brings the memory back, and same-second writes settle the same way on every machine (random three-store histories converge). - text_clock (meta.text_clock) records when a memory's text was decided, apart from updated_at; every write that only annotates calls keep(). The brief's age tag and the rules-pack choice read it. - Supersession, pins, anchors and expiry replicate; the hub relays by arrival time. Worktrees - A git linked worktree keeps its own code graph but files and reads memories under the main checkout's project (scope::Checkout, search::Reach). Only memories newer than the worktree move, and only on memory commands and MCP start, never from hooks, status or doctor. - A directory counts as a worktree only when the repository names it back in <gitdir>/gitdir. - Handoffs are tied to their checkout. - project prune re-links a pruned worktree's memories to the same code in the main checkout, keeps a main project a live worktree files under, and runs in 250 ms transactions with pauses so writers are not blocked (rehearsed on a 3.7M-row store: 953 concurrent writes, 0 failed, slowest 1.24 s). Store - Project registration is atomic; a directory with several rows resolves to the oldest. - Opening a store never queues behind a writer to build an index. Contributors - tests/one_definition.rs fails when production code spells a state outside the file that owns it.
The warm daemon kept every embedding in one in-memory matrix and reread all of it whenever another process committed. On a store holding the code graphs of many projects that is 2.9 GB of symbol vectors (1.97M rows) to answer the prompt hook, which searches 1,814 memories: 13 to 99 s per prompt, so the hook timed out and fell back to the cold path. The cache now holds one matrix per kind, loaded from the node side the first time a search asks for that kind. A memory recall reads memory vectors only. Measured on the real store after the fix: warm /inject 0.1 to 0.66 s, the hook 0.17 s end to end, daemon resident memory 3.3 GB -> 250 MB. A search that includes code still reloads the symbol vectors after a commit elsewhere.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two commits. No schema change: the store stays at v14.
1. Name every implicit state machine once (
e2c5e3e)Every state the app moves through (a memory's lifecycle, a project's graph freshness, a session's handoff, a sync conflict, a hook install) now has one name and one function that derives it, and every surface (CLI, MCP, daemon, hooks, dashboard) prints that name. Map:
docs/design/state-machines.md. User-facing list:CHANGELOG.md[Unreleased].What changes for a user:
replicate::Standingis the one total order of two versions of a memory: when its text was decided, then forgotten over live, then last write, then digest. A pin, tag or anchor made after a forget the machine had not seen yet no longer brings the memory back. Writes in the same second settle the same way on every machine.meta.text_clockrecords when a memory's text was decided, separately fromupdated_at. Random histories across three stores converge in the tests.statusordoctor. A directory counts as a worktree only when the repository names it back (<gitdir>/gitdir). Handoffs are tied to the checkout that wrote them.project prunestays out of the way. It runs in 250 ms transactions with pauses. It re-links a pruned worktree's memories to the same code in the main checkout. It keeps a main project while a live worktree still files memories under it.tests/one_definition.rsfails when production code spells a state outside the file that owns it.Rehearsed on a copy of a real store (3.7M rows, 8.1 GB):
2. Load the vector matrix one kind at a time (
fabca8b)Found while installing. The bug predates this branch, and the old binary was just as slow.
The warm daemon kept every embedding in one in-memory matrix and reread all of it whenever another process committed. With large code graphs that is 2.9 GB of symbol vectors read to search 1,814 memories. Each prompt took 13 to 99 s, so the hook gave up and fell back to the cold path.
The cache now holds one matrix per kind, loaded the first time a search asks for that kind. Measured on the real store:
/injectUpgrade order
mimir mcpservers.mimir init --hooks.mimir sync push --full, thenmimir sync pull --full, once on each machine.mimir project prune, then--apply.Checks
clippy -D warningsandcargo fmt --checkare clean.