@rackrot/pi-memory2.3.0
Long-term agent memory as Markdown notes in a git-managed, Obsidian-compatible vault
Untested on omp
This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.
Reports 0
No reports yet.
Readme
@rackrot/pi-memory
Long-term memory for the pi agent: Markdown notes with YAML frontmatter in a git repo that doubles as an Obsidian vault. The agent searches, reads, writes and archives notes with tools; humans edit the same files.
Setup
1. Install
pi install npm:@rackrot/pi-memory
2. Choose a root
memory.root is the directory the agent searches and (under <agentDir>/) writes. Pick one of three cases.
A new, dedicated vault. Any empty directory, e.g. ~/Vault. /memory-init creates the git repo and the agent folder. Open it in Obsidian later if you like.
An existing Obsidian vault, e.g. ~/Documents/Obsidian/MyVault.
- The agent can search and read every
.mdin it (not.obsidian,.git,.trash,node_modules, or the archive). - It writes only under
<root>/Agent/(theagentDir)..obsidian/is never created or modified, and pi's built-inwrite/editare blocked for.git,.obsidianand the archive. Shell commands are not inspected. - In Obsidian you will see an
Agent/folder. Its notes are normal Markdown with frontmatter and relative markdown links ([Title](../Decisions/Title.md)), so graph view and Dataview queries work on them. - You and the agent edit the same files. The agent only stages the paths it wrote (never
git add -A), so your uncommitted edits are never swept into its commits. If you change a note the agent has read, its next write to it is refused until it re-reads it (the stale-write guard).
A parent folder of several vaults, e.g. ~/Documents/Obsidian. This works, but Agent/ is created at the parent, outside every vault, and the whole tree is indexed. /memory-init warns about this; usually it is better to point root at one vault.
3. Configure
memory.root, agentDir and projects are read from the global config only (a project config can never redirect where the agent writes); ~ is expanded. The file is <agentDir>/rackrot/config.json (or .jsonc), where <agentDir> is pi's agent dir (~/.pi/agent). Create it with /rackrot-init or edit it with /rackrot-config memory. All other keys may also go in <cwd>/.pi/rackrot.json(c); the project layer wins.
{
"memory": {
"root": "~/Documents/Obsidian/MyVault", // required, global config only
"agentDir": "Agent", // folder under root the agent writes to; global config only
"projects": "Projects", // folder under agentDir, one subfolder per project; global config only
"project": "my-app", // optional: override the slug derived from the git remote
"autoInject": true, // add overview, open handoffs and pinned notes to the system prompt
"commitIntervalMinutes": 5, // 0 = commit only at session end
"push": "session", // "session" pushes at session end; "never" keeps it local
"injectBudgetChars": 12000,
"embedding": { "provider": "onnx", "model": "Xenova/bge-small-en-v1.5" }, // {"provider": "none"} = BM25 only
"summary": {
"model": "anthropic/claude-haiku-5-5", // no default: unset skips the summary worker
"enabled": true,
"minChanges": 3,
"timeoutSeconds": 60
}
}
}
embedding, reranker and decision default to the shared retrieval block in the global config (see pi-core), and the memory block overrides any field of it. All three are read from the global layer only: they name endpoints that receive note text and the environment variable whose key is sent there, so a checked-in project config cannot set them (earlier versions honoured a project-level memory.embedding / memory.reranker). Memory does not rerank unless retrieval.reranker or memory.reranker sets one. Earlier versions fell back to skillIndex.embedding / skillIndex.reranker; move those to retrieval to keep sharing them. Without memory.root the package does nothing except offer /memory-init.
4. Run /memory-init
One command for the whole setup; safe to re-run.
memory.rootunset: prints the config path and a JSON snippet, nothing else.- Checks the root: offers to create it if missing, rejects a file. Reports whether it is an existing Obsidian vault (only
Agent/is written) or a parent of several vaults. - Warns when the root sits in iCloud (
Mobile Documents), Dropbox, OneDrive or Google Drive, where.gitis known to corrupt. When creating a new repo there it asks whether to keep the git data outside the folder (git init --separate-git-dir, stored under<agentDir>/rackrot/memory/git/); default is no. An existing.gitis never moved. - Not a git repo: asks, then
git init -b main. Global git config is never changed. - Creates
<agentDir>/and<agentDir>/<projects>/, and appends missing lines to.gitignoreand.gitattributes(existing lines are never rewritten). - Commits only
.gitignore/.gitattributesasmemory: initialize agent folder(explicit paths). Your notes are not committed. If git has nouser.name/user.emailthe commit is skipped and the exactgit configcommands are printed; run/memory-initagain afterwards. - Prints next steps based on the real state (no remote, remote without upstream, or sync active). Re-running on a set-up vault makes no new commit.
5. Add a remote and push
Optional; without a remote the agent still commits locally.
git -C "<root>" remote add origin <url>
git -C "<root>" push -u origin main
Create an empty, private repo first (Forgejo, GitHub, ...): vault notes are private data. Review git status and commit the notes you want in the repo yourself before the first push, since init does not. Once the branch has an upstream, the agent pushes at session end (push: "session"). If the root is in a synced folder, see the warning above and do not put .git there.
6. Several devices
On each device clone the repo, set memory.root to the clone, and run /memory-init. At session start the agent runs git pull --rebase --autostash (needs an upstream), and again at session end before pushing. On a conflict the rebase is aborted, you are notified, and auto-commit and push are disabled for that session. Resolve it by hand in the vault (git pull --rebase, fix, git push); the next session syncs again. Pushes are never forced.
7. Obsidian git plugin and mobile
Don't run obsidian-git's auto-commit/auto-push on the same device while the agent's commit timer is active, unless you accept that both of them commit and pull in the same repo (they serialise only on the agent's own lock). On mobile, sync through whatever you already use; the agent only needs the files and, on desktop, the git repo.
8. Troubleshooting
| Symptom | Cause / fix |
|---|---|
Nothing happens, only /memory-init exists |
memory.root is unset in the global config. Run /memory-init for the exact steps. |
| "is not a git repo; notes are not versioned" | Run /memory-init, or git init yourself. Notes still work without versioning. |
| "git sync disabled for this session" after a push | Push rejected (no upstream, remote ahead, auth). Fix in the vault with git pull --rebase / git push -u origin main; restart the session. |
| First search is slow, or downloads files | The onnx embedding model downloads on first use. Set embedding.provider to none to skip it. |
| Search says it fell back to BM25 | Embeddings failed or are off (provider: none); results are keyword-only. Check the embedding config and network. |
memory_write refuses to update a note |
It was not read in this session, or the file changed since it was read. memory_read it again, then write. |
Layout
<root>/<agentDir>/Global/ tools and environment facts (every project)
<root>/<agentDir>/User/ the user's preferences (every project)
<root>/<agentDir>/ loose notes from older versions, read as Global
<root>/<agentDir>/archive/ archived notes (read-only)
<root>/<agentDir>/<projects>/<slug>/ Overview.md, Decisions/, Log/, Handoffs/
The slug is the repo name from the origin remote, else the git top-level folder, else the cwd folder. Overview.md
records the remote; if a different remote already owns that slug, <org>-<repo> is used. Local paths are never
stored, so project notes work across machines. Notes have type, created, updated, source, and optionally
pin, status (handoffs) and confidence.
Upgrading to 2.0
Agent notes used to live loose in <agentDir>/. On the next session start (or pi-memory migrate) they are moved once into
User/ (preferences) or Global/ (tools and environment), keeping subfolders, in one commit migrate memory layout v2.
With a decision model, a note goes to User/ at p >= 0.9 and to Global/ otherwise; without one everything goes to
Global/. Uncertain notes are listed in Global/Inbox/Migration <date>.md to re-tier by hand. Links are by title, so none
break. Progress is recorded as layoutVersion in <agentDir>/.consolidate/state.json; a run skips while a consolidation holds the lease.
OKF alignment (layout 3). The Agent/ folder is an Open Knowledge Format v0.3 bundle. Notes link with relative markdown links (spaces as %20); old [[Title]] links are still read. A superseded note gets status: deprecated and superseded_by: <relative path>; a handoff's open/done state is x-pi-status (the tool parameter is still status; legacy status: open|done still reads). New notes get a description from their first line. index.md files (root one with okf_version: "0.3") are generated and never treated as notes; a note titled index or log is written as index (note).md. The first run after upgrading rewrites existing [[links]] and statuses under Agent/ once (commit migrate memory layout v3, layoutVersion: 3, same lease; pi-memory migrate); links to unknown titles are left as written, files outside Agent/ are never touched.
Tools
memory_search (project, user, global, vault or all; BM25 plus vectors, optional reranker), memory_read, memory_write,
memory_archive, memory_sync. memory_write:
- refuses to create a note whose title and body are at least 60% word-similar (Jaccard) to an existing one in the same folder;
- refuses to update a note that was not read in this session, or whose file changed since it was read;
- refuses bodies that look like secrets (AWS keys, GitHub tokens, private keys,
sk-keys,password|secret|token = ...); - only writes under
<agentDir>/; - takes
supersedes: [paths]for notes it replaces: they getstatus: supersededandsuperseded_byin frontmatter, stay searchable (marked[superseded by ...], ranked after current notes) and are left out of the injection. The new note recordssupersedes.
Search indexes every .md under the root (not .obsidian, .git, .trash, node_modules, or the archive) in an
SQLite database at <agentDir of pi>/rackrot/memory/index.db, outside the vault. Embeddings are built in the
background; if they fail, search falls back to BM25 and says so.
Each project's Overview.md ends with an auto-generated note index between <!-- memory:index:start --> and <!-- memory:index:end --> (Decisions, Log newest first, Handoffs, other; summary from frontmatter summary or the first body line). It is rebuilt without an LLM after every project memory_write and memory_archive (which also bumps the frontmatter counter summary-changes), and nothing outside the markers is touched.
Importance and tags
Notes may carry importance (integer 1-5; missing means 3) and tags (up to 5, kebab-case; c++ and c# become cpp and csharp), extra_tags (up to 10 free-form search keywords such as synonyms or product names; they sit in the frontmatter, so BM25 matches them, but they are not counted, merged or capped as tags) and lifecycle (draft, active, deprecated or archived; metadata only, a note without it is active). Scale: 1 = specifics of code that changes often, 2 = short-lived task context, 3 = project decision or fact, 4 = durable convention or constraint, 5 = user preference stated repeatedly. memory_write takes both; an update that omits them keeps the old values. The capture worker proposes a tier (project, user or global), importance and tags (reusing the vault's most used tags); user and global captures are always written to that tier's Inbox/ for review, whatever capture.mode is. The search index (outside the vault) gains a tags column on first start of this version, filled in place from the files.
Validation
Notes are written as OKF v0.3 concepts (type required). Reading is lenient: human notes and older layouts load whatever they contain. Writing is strict: memory_write and the code-built notes check the frontmatter against MemoryNote (the OKF schema plus importance 1-5, tags, extra_tags, lifecycle, x-pi-status, pin, and type from the note types). A write that fails is refused with the list of bad fields. An existing note keeps the problems it already had, so only new ones block an update.
Model replies (capture, merge, topic, tags, validator) are requested against a schema (src/schemas.ts): the model gets it as a submit tool and in the prompt, and an answer that does not match is sent back with the errors, twice at most. An answer that still fails is read leniently as before: invalid capture entries are dropped. Agent/.consolidate/state.json, the lease, the git journal and usage lines are checked against schemas too; a corrupt state.json reads as empty but is never overwritten.
The /memory command
/memory <sub> runs every maintenance step by hand, with tab completion for subcommands and flags. /memory-init and /memory-summarize remain as aliases.
| Subcommand | What it does |
|---|---|
consolidate [--dry-run] [--all] [--full] |
Consolidation in this process, with the configured models; refuses while another run holds the lease |
review |
Walks every pending review item (all tiers, plus the migration checklist): Approve, Reject or Skip each. Approving applies it (verdicts, archive, delete batch, promotion, tier move, tags, topic merge); rejecting marks it so it is not asked again; migration lines offer "Move to User" or "Keep in Global". Ticks the review files and makes one commit review memory: N approved, M rejected. Needs the interactive UI; without one it lists the items |
prune |
The deterministic steps only (decay, archive, delete, usage rules), no model |
sync |
Commit, pull and push now |
reindex |
Rebuild the search index from the files |
capture |
Run the capture worker over this session now |
status |
Notes by tier and effective importance, pending review items, notes that will archive next run, schedule, last run, timer |
migrate |
The layout migration |
timer install|remove |
The systemd timer for scheduled consolidation |
init, summarize |
Vault setup; rewrite this project's Overview prose |
Summary worker
The prose above the markers is kept up to date by a one-shot, tool-less model call (callModel from @rackrot/pi-core/model-call, the same mechanism as pi-council). At session end, before the final commit, if the project has at least summary.minChanges (default 3) note writes/archives since the last summary, the worker sends the current prose, the note list and the bodies of notes changed since summarized (1500 chars each, 12000 total) and replaces the prose, keeping the marker block and frontmatter, resetting summary-changes and setting summarized. Output is dropped if empty, over ~3000 characters, containing the markers, or matching the secret scan; it is also skipped when a human edited Overview.md since the session last saw it or while the call ran. Any failure (timeout, auth, model) is reported and never blocks the final commit or push. A lone Overview commit reads refresh summary.
Config under memory.summary (either layer): model (provider/id or {model, thinking}; no default — unset skips the worker, and the session's own model is never used, to avoid surprise cost), enabled (default true), minChanges (3), timeoutSeconds (60). /memory-summarize runs it now for the current project, ignoring minChanges and enabled. At most one call per project per session.
Capture worker
Notes are also written for the agent. Every capture.everyTurns (default 10) finished agent runs (one per user message), before pi compacts the context, and at session end, a one-shot model call reads the transcript since its last run (user and assistant prose only) and the project's existing note list, and proposes at most capture.maxNotes (3) decisions, lessons, rules or facts. Status, progress and anything already noted are excluded by the prompt. Each proposal goes through the same path as memory_write: secret scan, near-duplicate refusal, the decision-model injection check when enabled, and a title that already exists is never overwritten. A proposal may name an existing note it replaces, which is then marked superseded. Notes get source: session and session: frontmatter. It runs in the background after agent_end, at most one at a time, and any failure is silent; if the call fails the next run retries the same stretch. A short info message says what was written.
Tags are steered by a built-in vocabulary (content type, domain, the TIOBE top 50 languages, web and app frameworks, ORMs, auth libraries and common tech; see src/tags.ts) that capture and tag backfill show the model first; new tags stay allowed. memory.tags.vocabulary (JSON only, a list of strings) adds your own.
Config under memory.capture (either layer): enabled (default true), model (provider/id; falls back to summary.model, and with neither capture is skipped, never the session model), everyTurns (10), maxNotes (3), mode (auto writes notes; stage writes them to the project's Inbox/ with the same frontmatter so you can review and move them, and proposes no supersession), timeoutSeconds (60). Everything is also in /rackrot-config under Memory. Under Magic Context, which drops tool output without an event pi exposes, there is no trigger for that drop; the every-N-turns run is what limits loss.
Session digests
At session end the same model that refreshes the Overview (memory.summary.model; unset skips this too) also writes Agent/Projects/<slug>/Log/<date> <session>.md: a digest of the session's user and assistant prose (tool calls and results are not sent; the last 24000 characters are kept), saying what was asked, what was decided and why, and what was left open. Sessions with fewer than 3 user messages are skipped; output that is empty, over 6000 characters or matching the secret scan is dropped. Notes written during the session carry its id in session: frontmatter. Digests are ordinary log notes: searchable, never injected. They answer "why did we decide X" when the decision note alone does not. The transcript is sent to the summary model, so pick one you are happy to show session text to.
Decision model (optional)
memory.decision (global layer only, since it names an endpoint that receives note text) enables a System One model, the same shape as retrieval.decision (which it overrides): enabled (default false), provider (typesafe for any /v1/systemone endpoint, or laya for local ONNX), baseUrl, model, apiKeyEnv, threshold (default 0.5), injectionThreshold (default 0.7; blocking a write needs more certainty than advice does). It answers yes/no questions with a probability:
- On
memory_write(one batched call): a note that looks like instructions aimed at an AI agent is not written; a note that looks like current status gets a hint to write it as a handoff; neighbours the note seems to outdate are named so it can be rewritten withsupersedes. - On
memory_search: results the model judges unrelated to the query are dropped; when none remain the answer says memory likely does not cover it.
Both fail open: if the model errors, the write or search goes through with a line saying the check was skipped. node eval/decision.ts --base-url ... --model ... --api-key-env ... prints precision and recall per question at several thresholds on a small labelled synthetic set (eval/decision.json); calibrate on your own notes before relying on a threshold, since cutoffs differ per model. Relevance filtering can drop a useful note the model misjudges; if search seems to miss things, lower threshold or turn the decision model off.
With autoInject, each turn's system prompt gets the project Overview (skipped while it has no prose and no notes; the index is cut first when over budget), open handoffs, User-tier notes with effective importance of at least 4 (highest first, pinned or not) and the other pinned notes, cut to
injectBudgetChars. Effective importance is the stored importance minus a decay for the days since the note was last read, found by search or cited (the usage log; else its updated/mtime): memory.consolidate.decay maps days unused to points lost, default {"7": 1, "30": 2, "90": 3, "180": 4}, the largest threshold reached applies (JSON files only, not in /rackrot-config). Stored 5 and pinned notes never fall below 4; handoffs and the Overview do not decay. The section is built on the first turn and returned unchanged until the next compaction, so notes written or edited mid-session (including in Obsidian) show up after compaction or in the next session. A section that changed every write would change the system prompt each time and break prompt caching and Magic Context's cache-aware deferral. It sits under its own memory section key, so it does not collide with Magic Context's magic_context one, and memory_* tools do not overlap its ctx_* tools (its own ctx_memory store is separate from this vault).
Consolidation
pi-memory consolidate [--project <slug>] [--all] [--full] [--scheduled] [--dry-run] cleans up agent notes. Nothing is ever deleted: notes are archived or superseded, so git revert of the single consolidate memory commit (its message lists every change) undoes a run. It needs the same git, config and memory.root as the session; without --project it covers every project folder, and --all adds the Global/ and User/ tiers after them, all under one lease and one commit. Each scope keeps its own .consolidate/ (change logs, state.json) and its review files in its own Inbox/; loose root-level notes are not consolidated. Model-judged changes to User and Global notes are never applied automatically: they are always listed for review. Each step is independent and fails open: an error is logged and the run goes on.
Lifecycle (no model). Every run's deterministic step ages notes by importance (see the injection section for effective importance):
| Situation | What happens |
|---|---|
| Effective importance below 1 | archived (the archived note gets an archived: date) |
Same, stored importance 4, any User-tier note, a rule or human-written note, or maxChanges reached |
listed for review as archive-important |
Stored 5, pinned, handoffs, Overview, Inbox/ notes |
never archived by decay |
Archived note older than lifecycle.deleteAfterDays (importance 1: 30 days, 2: 90, 3: 180; 4 and 5 never) |
deleted by git rm (history keeps it), logged and named in the commit message; an archive without archived: counts from its file mtime |
| First deletion ever | nothing is deleted: one delete-batch item in Global/Inbox/Consolidation <date>.md lists everything due; approving it sets deleteConfirmed in the vault state and deletes those notes, after which deletions are automatic |
Tags and topics (writer model, needs consolidate.model). In each scope, untagged notes (up to 30, one model call) get up to 5 kebab-case tags, the vault's most used tags offered first; tags are written directly (they do not count toward maxChanges or reset updated), but in User/ they are listed as tags review items. In a full --all run one more call maps near-duplicate tags (test to testing) and the renames are applied across notes the same way. Then small notes (body under topic.smallChars 400, or effective importance 2 or less; never handoffs, Overview, Inbox/, superseded notes or topic notes) that share a tag, at least topic.minNotes (3) of them, are combined by the model into one sectioned note with topic: <tag>, the tag, the highest source importance and the most common source type (rule if any is one); the originals are superseded. If a note with topic: <tag> already exists in the scope it is updated in place instead. This is applied automatically only for project notes of importance 3 or less, none a rule or otherwise protected, a result within topic.maxChars (4000), outside review mode and under maxChanges; otherwise the proposed note is staged in the scope's Inbox/ and a topic-merge item lists it, so you can read or edit the text before approving. Incremental runs only look at tags touched by changed or used notes. topic keys are JSON-only.
Usage rules (no model). From the usage log, per note: a session counts as having used it when its weighted uses reach 1 (read and cited 1, search hit 0.25, so four search hits equal one read). Used in usage.promoteSessions (3) sessions within usage.promoteWindowDays (7), counted from the last promotion (promoted: in frontmatter), the stored importance goes up by 1, applied automatically unless the new value is 4 or more, the note is in User/, or it is a rule or human-written (then a promote review item). Used from usage.tierUpProjects (2) projects within usage.tierUpWindowDays (30), a project note gets a tier-move review item to User/ (rules and lessons) or Global/ (others) with importance raised to at least 4; a User/ note used from exactly one project within usage.tierDownDays (30) is proposed for that project. Tier moves are never automatic. Not using a note is not written to frontmatter: decay is computed (see above). The usage keys are JSON-only.
Deleting runs with --all only. lifecycle.delete (default true) turns it off, lifecycle.deleteAfterDays changes the table (JSON files only). The validator model never sees lifecycle items. Each run also drops this host's usage-log lines older than 180 days.
Schedule. memory.consolidate.schedule is manual (default), daily, weekly or monthly, with scheduleTime (local HH:MM, default 03:00), scheduleDay (mon–sun, weekly, default mon) and scheduleDayOfMonth (1–28, monthly, default 1). When it is not manual, enabled is true and a model is set, each session start and end spawns a detached pi-memory consolidate --all --scheduled if the last run predates the latest scheduled slot (local time); a --scheduled run re-checks this under the lease, so two triggers never double-run. Agent/.consolidate/state.json (vault-wide, next to layoutVersion) records lastRun and lastFull. A whole-vault run is full (the model reviews every note) with --full, on the monthly schedule, or when no full run has happened yet this calendar month; otherwise it is incremental: only notes changed or used since lastRun, plus notes sharing a tag with them, go to the model. The deterministic steps always see every note. pi-memory timer install writes ~/.config/systemd/user/pi-memory.service and pi-memory.timer (OnCalendar built from the same settings, e.g. Mon *-*-* 03:00:00, Persistent=true, working directory the vault) and runs systemctl --user daemon-reload and enable --now pi-memory.timer; pi-memory timer remove undoes it. It refuses while the schedule is manual.
- Deterministic, no model: notes superseded for more than
supersededDays(by file mtime) are archived; session digests inLog/older thanlogDaysare archived; asuperseded_bythat points at no note is cleared so the note is current again. - Decision model (
memory.decision, required for this step; without it only step 1 runs): for each note, most recently changed first, it asks whether a BM25 neighbour that is newer makes it outdated, whether a neighbour is a duplicate, and, for notes with astatus, whether it is stale. - Merge (duplicate): the consolidate model writes one merged note with
supersedes: [a, b]andsource: consolidate; both originals are archived. The text must pass the secret scan, a 4000-character cap and the injection check (decisionenabled and not skipped); otherwise both originals stay and the verdict is listed for review. Without a model, duplicates are only listed. - Apply by confidence. In
automode (default) a verdict at or aboveautoThresholdis applied (outdated: superseded; duplicate: merged; stale: archived). A verdict fromreviewThresholdup toautoThresholdis written toInbox/Consolidation <date>.mdin the project folder. Inreviewmode nothing is applied and every verdict goes there. Inautomode notes of typehandofforrule, notes whosesourceis notagent,sessionorconsolidate(human-written), and notes modified in the last 24 hours are never changed, only listed. Each change checks the note's content hash again right before writing.maxChangesis opt-in: unset means uncapped; past the cap, verdicts are listed. - Validate (opt-in,
consolidate.validate.enabled, not inreviewmode). A second, separate model re-checks every pending verdict in the project'sInbox/Consolidation *.mdfiles, this run's and earlier ones. Each review line ends in an HTML comment (<!-- consolidate: {...} -->, hidden in Obsidian's reading view) holding the kind, probability, note paths, their content hashes and astatus. A verdict whose note no longer exists or whose hash differs is markedexpiredwithout a model call. Otherwise the validator gets the notes (4000 characters each), argues for and against and answersact,rejectorunsure:actapplies the change through the same code as step 4 (merge keeps the secret scan, length cap and injection check) and ticks the line;rejectmarks itrejectedand it is never asked again;unsurekeeps itpendingwith the reason noted, so it is asked again next run. The step never acts onhandoff/rulenotes, human-written notes or notes modified in the last 24 hours (they stay pending, no model call);maxChangescounts validator changes too, andvalidate.maxPerRunlimits the calls. In a dry run the validator may be called but nothing is applied or marked. Errors leave the item pending. Each outcome is avalidateline in the change log (result:act,reject,unsure,expired, orpendingwhen blocked; reason and hashes, no bodies) andrun-endcarriesvalidatedcounts. - The index is rebuilt and, when something changed, the Overview prose is refreshed (consolidate model), then one commit
consolidate memoryand, withpush: session, a push.
Only one run per vault: a lease file Agent/.consolidate/lease.json (holder, timestamp, 10-minute TTL, refreshed per note) is taken with an exclusive create; a second run exits with a message.
Change log. Agent/Projects/<slug>/.consolidate/changes-YYYY-MM-DD.jsonl, append-only, one file per day, committed with the run; files older than logRetentionDays are deleted at the start of the next run. One JSON line per event: ts, runId, project, mode, action (supersede, archive, merge, prune-log, fix-link, skip, queue-review, validate, run-start, run-end), notes, result, reason (rule text, or decider question with probability and thresholds), before / after content hashes, applied, error. run-end has counts, capped and base (the commit HEAD was at before the run; the new commit is the one after it). Note bodies are never logged. A dry run writes the same lines with applied: false, changes no note, and does not pull or commit. state.json next to the log records the last run.
Config under memory.consolidate (either layer; also in /rackrot-config under Memory): enabled (false), model (provider/id or {model, thinking}; falls back to summary.model, never the session model; scheduled runs also need one), mode (auto | review, default auto), schedule (manual), scheduleTime, scheduleDay, scheduleDayOfMonth, autoThreshold (0.9), reviewThreshold (0.6, at most autoThreshold), maxChanges (unset), supersededDays (30), logDays (90), logRetentionDays (15), timeoutSeconds (120, per model call), validate (enabled false, model with no default and no fallback, not even to consolidate.model, so the check stays independent; maxPerRun 20; timeoutSeconds 120). The decision model's own threshold is not used here. Probabilities are model-specific: start with mode: "review" and --dry-run, and calibrate the thresholds on your own notes.
Several agents at once
Any number of pi sessions can use one vault. Git work (commit, pull, push) is serialised across processes by <git dir>/pi-memory.lock; a session that finds it busy skips that run and tries again later instead of disabling sync. Each session commits only the paths it wrote (commit --only), and before a final sync or memory_sync it also adopts paths other sessions journalled but never committed, so little is left uncommitted when pull --rebase --autostash runs. Notes are written to a temp file and renamed; creating a note uses an exclusive link, so two sessions creating the same title cannot overwrite each other (the second is told to memory_read and update), and updating a note re-checks its hash at write time. memory_write syncs the shared search index first, so near-duplicate refusal sees notes other sessions wrote seconds ago. The Overview index is rebuilt again under the git lock just before each commit, so the committed index lists every session's notes. Not handled: two sessions editing the same note's body at nearly the same moment still end with a refusal for one of them, not a merge.
Git
All git runs through git -C <root> without a shell. Only the files the agent wrote are staged (git add -- <paths>,
never -A), so your uncommitted work in the vault is never swept into agent commits. Commits are
memory(<slug|global>): add X; update Y; archive Z, made every commitIntervalMinutes (0 = only at session end). At session start and end:
pull --rebase --autostash; at the end, push when push is session. Never force. A pull conflict aborts the
rebase, notifies you and disables auto-commit and push for the session; a push failure does the same. Git work is
serialised with <root>/.git/pi-memory.lock. A root that is not a git repo still works, without versioning.
The paths a session wrote are also listed in <root>/.git/pi-memory-dirty-*.json until they are committed. If pi
is killed, or sync was disabled, the next session commits them at start. When the pull re-applies your own
uncommitted edits and they conflict with what came in, git leaves conflict markers in those files: you are told
which files, sync stops for the session, and your edits are also kept in git stash list. At session end the
summary worker, final sync and embeddings get 30 seconds in total; what is left is committed by the next session.
Limits
- Notes are never deleted; archive only moves them.
- Duplicate detection is lexical, not semantic.
- Markdown only; attachments are ignored.
- Concurrent sessions on one vault serialise on the lock but can still produce rebase conflicts.