Skip to content

Latest commit

 

History

History
86 lines (69 loc) · 4.99 KB

File metadata and controls

86 lines (69 loc) · 4.99 KB
name memory-consolidator
description The consolidation ("lint") pass of the agent-memory wiki - merge raw RESEARCH-NOTE memories into a verified artifact on Filecoin Onchain Cloud and replace them with a compact cross-referenced receipt. Use on a consolidation cron, when someone says "consolidate memories", "archive the research", "clean up memory", "store the session summary on Filecoin", or when memory_search returns many raw notes on one topic. Requires the clawdi skill (memory tools) and foc-cli wired to the vault-held key; writes FILECOIN-MEMORY receipts that tell every agent which knowledge is already durably archived and verifiable.
license Apache-2.0 OR MIT

memory-consolidator — from notes to provable knowledge

Raw notes pile up; consolidation is the wiki's lint pass (Karpathy: contradictions resolved, stale claims superseded, synthesis kept current). The twist here: the consolidated artifact goes to Filecoin — content-addressed (PieceCID = hash of the bytes) and continuously proven (PDP) — and Clawdi memory keeps only a small receipt. Index stays curated; the warehouse is durable and verifiable; deleting a raw note loses nothing because the blob supersedes it.

Prereqs: the clawdi skill (already installed everywhere) and foc-cli wired to the vault-held key — foc-cli wallet init --keyRef clawdi:FILECOIN_PRIVATE_KEY, see fleet-setup/references/storage-vault.md. There are no helper scripts: storage is plain foc-cli, the index is plain clawdi memory.

The pass (one topic at a time)

  1. Gather: memory_search "RESEARCH-NOTE <topic>" → collect every raw note. Also memory_search "FILECOIN-MEMORY <topic>" → if a prior receipt exists, foc-cli download <its pieceCid> and treat that blob as the base — this pass produces its next version, with the old CID in parents.
  2. Merge: write ONE consolidated artifact — resolve flagged contradictions (newest well-sourced claim wins; note what was superseded), dedupe, keep every load-bearing fact. Format (JSON file, unified fields — this is the blob, depth lives here):
{
  "kind": "consolidated-memory",
  "topic": "<kebab-topic>",
  "created": "<YYYY-MM-DD>",
  "author_agent": "<who ran this pass>",
  "summary": "<the synthesis, 3-6 sentences, standalone>",
  "facts": ["<every surviving fact, full sentences>"],
  "superseded": ["<claims resolved away, with why>"],
  "sessions": "<1-3 sentence summary of the sessions/notes this consolidates>",
  "refs": ["<related-topics>"],
  "parents": ["<pieceCid of the prior consolidated blob, if any>"]
}
  1. Store the blob (signs with the vault-held key — no wrapper, no key at rest):
foc-cli upload /tmp/<topic>-consolidated.json --copies 1 --json
#   → pieceCid, dataSetId, size, retrieveUrl. Confirm a pieceCid came back BEFORE
#     writing anything to the index: a receipt for a failed upload poisons every recall.
  1. Enrich the receipt's cross-refs: the receipt is what tells every agent this knowledge is archived. memory_add (category fact) one line — copy pieceCid and retrieveUrl from the store output:
FILECOIN-MEMORY consolidated | topic: <topic> | tags: filecoin-memory,receipt,topic:<topic>,dataset:<id>,chain:314159,status:consolidated | pieceCid: <cid> | dataSetId: <id> | parents: <old-cid or none> | consolidates: <memory-ids of the raw notes> | supersedes: <old receipt memory-id or none> | retrieveUrl: <provider piece url> | date: <YYYY-MM-DD>

retrieveUrl is the provider's direct piece URL (from the upload's copy results): a plain HTTP GET returns the exact original bytes, so anyone can verify the memory with curl — foc-cli download <pieceCid> validates the same bytes against the content address.

  1. Prune the index: clawdi memory rm <id> each raw note listed in consolidates, the superseded old receipt (keep exactly one receipt per topic — the one step 4 wrote). This is safe — their content now lives in the blob, retrievable by hash and provably stored — and it is the point: shared memory stays small and curated ("forgetting is a feature"; the warehouse remembers).

Verification is the contract

Recall (foc-cli download <pieceCid>) validates the downloaded bytes against the PieceCID — if it passes, the knowledge is intact; if the index and blob ever disagree, the blob wins (it's the hash-addressed source of truth). Never mark anything consolidated without a successful store: a receipt pointing at a failed upload poisons every agent's recall, so never index one.

Demo cron (every 5 minutes)

For the live demo, pair with memory-researcher: researcher cron files raw notes; this cron (also 5 min, offset a couple of minutes) consolidates any topic with ≥2 raw notes. After the demo, slow to hourly/daily — consolidation cadence should track note volume, not the clock.

Safety: testnet by default; the wallet never appears — see fleet-setup/references/storage-vault.md. One topic per tick; never blind-retry a failed upload without checking wallet balance first.