Give memories a working tier, a long-term tier, and a record of what disagrees
A memory used to have one state: present. A session could not be reloaded
without searching, nothing separated what a person said today from what the
store ingested a year ago, and two statements that disagree about a number
were both handed to the reader as if the store believed both.
Schema v10. Atoms gain session_id, importance, recall_count, last_recalled_at
and archived_at; two tables arrive beside them — consolidations (one watermark
per holder+scenario lane) and conflicts (a pair, the term they disagree on,
both values, and whether anyone has settled it). v_atoms_current now also
hides archived rows, and apply() drops the view before rebuilding it because
CREATE VIEW IF NOT EXISTS would keep the old body and ignore the archive.
Working memory is a read, not a store: `working <holder> <session>` returns
what that session recorded, in order, with no search involved. Consolidation
rolls a lane's new memories into one standing summary and moves the watermark
to the newest memory actually rolled up — not to the clock of the pass, which
made a second pass count the same memories twice. The archive rule is stated
in the command that runs it (recorded before N days, never returned by a
search, importance at or under a floor) rather than hidden in a decay formula
nobody measured; --dry-run names the victims first.
A conflict is recorded when a new memory repeats a label with a different
number in the same holder's same scenario. Retrieval drops the older side
while the conflict is open and both sides answer again once it is settled:
settling is not superseding, and a word-only disagreement is left alone
because a reworded sentence would fire on every paraphrase. Numbers are keyed
to both the memory's subject and the nearest preceding label, measured: the
two thermostat sentences share only their subject, so a nearest-word-only rule
found nothing.
Search now counts the memories it handed back, which is the only use estimate
the store has, and the archive rule reads it. The dense index applies the same
currency rules as the view, so an archived memory cannot stay findable through
one leg while the other hides it.
Two reads over HTTP (working, conflicts) and two tools over MCP
(working_set, memory_conflicts); curation stays with the operator because an
agent should not decide what its own past is worth. remember and supersede
carry a session id; importance does not cross MCP, because recall_count is
observed and importance is stated.
Gates: 366 passed; ruff clean; mypy 24 errors in 9 files, the recorded 9cb46c1
baseline, net 0; pyright 0 on the touched files; go build/vet/test and gofmt
clean; mcp_write_smoke PASS.
This commit is contained in:
1 parent
4c6af87fe0
commit
dc9cfb5a30
30 files changed
+1814
-229
No files matched your search
@@ -166,7 +166,7 @@ send({"jsonrpc": "2.0", "method": "notifications/initialized"})
|
||||
names = [item["name"] for item in call(2, "tools/list", {})["tools"]]
|
||||
for required in ("remember", "supersede_memory", "forget_memory", "mounted_cartridges",
|
||||
"mount_cartridge", "switch_cartridge", "unmount_cartridge", "append_to_cartridge",
|
||||
"who_knows", "ask", "list_holders"):
|
||||
"who_knows", "ask", "list_holders", "working_set", "memory_conflicts"):
|
||||
if required not in names:
|
||||
raise SystemExit(f"FAIL: {required} is not registered; tools are {names}")
|
||||
|
||||
@@ -273,5 +273,30 @@ nobody = tool("ask", {"question": "潜水镜", "as_holder": "local"})["answer"]
|
||||
if nobody["status"] != "no_holder_knows" or nobody.get("answer"):
|
||||
raise SystemExit(f"FAIL: nobody knowing was reported as an answer: {nobody}")
|
||||
|
||||
print("PASS: remember, supersede, search, forget, cartridge mounting and the transactive referral work through MCP")
|
||||
# The tier proof. A session is what makes working memory a thing you can reload in
|
||||
# order, and a disagreement is what makes an answer a choice rather than a coincidence.
|
||||
session = "cooking-2026-10"
|
||||
first = tool("remember", {"text": "the oven needs descaling", "session_id": session})["atom"]
|
||||
second = tool("remember", {"text": "the pantry shelf holds flour", "session_id": session})["atom"]
|
||||
if first["session_id"] != session:
|
||||
raise SystemExit(f"FAIL: the server dropped the session: {first}")
|
||||
reloaded = tool("working_set", {"holder": "local", "session": session})["atoms"]
|
||||
if [item["atom_id"] for item in reloaded] != [first["atom_id"], second["atom_id"]]:
|
||||
raise SystemExit(f"FAIL: the session did not reload in the order it was recorded: {reloaded}")
|
||||
if tool("working_set", {"holder": "local", "session": "never-opened"})["atoms"]:
|
||||
raise SystemExit("FAIL: a session nobody recorded answered with somebody else's memories")
|
||||
|
||||
older = tool("remember", {"text": "the thermostat is set to 24 degrees", "scenario": "home"})["atom"]
|
||||
newer = tool("remember", {"text": "the thermostat is set to 22 degrees", "scenario": "home"})["atom"]
|
||||
clashes = tool("memory_conflicts", {"holder": "local"})["conflicts"]
|
||||
if not any(item["older_atom_id"] == older["atom_id"] and item["newer_atom_id"] == newer["atom_id"]
|
||||
and item["older_value"] == "24" and item["newer_value"] == "22" for item in clashes):
|
||||
raise SystemExit(f"FAIL: the store never noticed that 24 degrees and 22 degrees cannot both hold: {clashes}")
|
||||
settled = tool("search_atoms", {"query": "thermostat"})["hits"]
|
||||
if any(hit["atom"]["atom_id"] == older["atom_id"] for hit in settled):
|
||||
raise SystemExit(f"FAIL: an unsettled conflict let the older side answer: {settled}")
|
||||
if not any(hit["atom"]["atom_id"] == newer["atom_id"] for hit in settled):
|
||||
raise SystemExit(f"FAIL: the newer side of the conflict went missing: {settled}")
|
||||
|
||||
print("PASS: remember, supersede, search, forget, cartridge mounting, the transactive referral and the memory tiers work through MCP")
|
||||
PY
|
||||
Reference in new issue
Block a user