Skip to content

Memory conflicts are judged in the background, every automatic retirement can be listed and undone, and graph facts follow the rows that state them - #26

Merged
zlareb1 merged 797 commits into
mainfrom
fix/same-key-cross-session-revision
Oct 21, 2026
Merged

zlareb1 merged 797 commits into
mainfrom
fix/same-key-cross-session-revision

Conversation

@zlareb1

@zlareb1 zlareb1 commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Backward Incompatible Change

Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):

Memory conflicts are judged by a background worker instead of an LLM call on each write. Under auto_reinforce (the default) and newest_wins it retires the older row of an update it is sure of; otherwise it flags a real conflict or clears a false one, and the Review queue's Auto-resolved tab lists every automatic retirement with an Undo. Removed: the LOOM_MEMORY_CONFLICT_JUDGE* settings, the memory.set field await_verdict (the Python SDK keyword now raises TypeError), the response field verdict_at, the pending verdict and the conflict_sweep worker.

Why

The conflict check decides whether a write adds a memory or revises one. The per-write judge was slow and often wrong:

  • A judge accurate enough to act on (all peers in one call, gpt-6.1-sol) takes 5.6 s p50 and 10.3 s p95, on every write that has a peer.
  • Between cosine 0.70 and 0.816 its update precision was 0.35–0.44, and 96% of its answers came at confidence 0.95 or more, so no threshold separated right from wrong.
  • In a sample of an agent-notes namespace, 231 pairs were conflicted on its word alone; 48 of them (21%) were real.

Two more problems showed up in the same paths:

  • Rows of one key written from different sessions stayed live side by side, because the session is part of the row identity and the check skipped same-key peers. "Asian American" and, later, "a mix of Irish and Italian" were both current under user_ethnicity. Retiring every same-key row is not a fix: of 60 sampled cross-session same-key pairs, 1 was an update.
  • Loom already retired rows on its own (newest_wins, templated substitutions, value updates), with no record anyone could see or undo.

Judging after the write removes the latency limit, so the judge can use the stronger model and see all peers at once. It also removes the code the deferred judge needed: the pending verdict, the conflict_sweep worker and await_verdict.

What changes

Marking. A write no longer calls an LLM for conflicts (bulk contextualize and message extraction still do). It marks its row owed (memory_embeddings.conflict_checked_at) when a live peer of the same memory_type and subject is at cosine 0.60 or more, when the row is flagged conflicted, when an earlier row of the same bulk batch is that close, or, outside newest_wins, when another session of the subject holds the key. A subject is (org, namespace, user_id), plus the agent for the anonymous user (- or an empty user_id, which are treated as the same user). append_only marks nothing.

The worker (server/memory/workers/conflict_resolver.py, leader only). Each pass takes up to 40 owed rows, newest first, round-robin across (org, namespace), plus 8 old conflicted rows, and judges 8 at a time. A full batch without errors is followed by the next one for up to 300 s; otherwise it waits 10 s. Each call sends the row and up to 8 peers (its flagged peers, up to 4 same-key rows from other sessions, then the nearest) to gpt-6.1-sol at reasoning effort low, and gets back one strict-JSON verdict per peer. The resolver spends at most 25% of the namespace's daily LLM cap, counted over its own calls, and stops when requests have used the whole cap. A row owed for more than 30 days is dropped.

What a verdict does (server/memory/domain/conflict_resolution.py, action_for):

Verdict Confidence Action
update / contradiction about a different entity or attribute any nothing
update / contradiction across sessions of the anonymous user any nothing
any < 0.90 nothing
update / contradiction < 0.95 nothing
update under auto_reinforce or newest_wins ≥ 0.98 retire the peer if it was stated first, else flag
other update (0.95–0.98, or manual_review), contradiction ≥ 0.95 flag both rows
elaboration, restatement, related, unrelated ≥ 0.90 clear the pair's flag

The settings reject thresholds unless clear ≤ flag ≤ retire. Two rows whose writers dated the fact (valid_at) on the same day are flagged, never retired, since they have no order.

Locking. Before acting, both rows are re-read under their key write locks (taken in lock-name order). The resolver acts only if both are still live, unexpired, unpinned, not high and hold the hash it judged, and it decides which row is older from those re-read rows. Its writes land at the read version + 1, so a user write that started after the read stays newest. Orgs with an erasure queued, running or due a retry are skipped, and erasure state is read again before each write. memory.pin and unpin now take the key lock (409 while it is held, 503 when Keeper is down).

Failures. A row is stamped judged only after its actions, and repeating an action changes nothing. A 429, 5xx or timeout leaves the row owed without counting an attempt, and three in a row end the pass. A malformed answer is retried once; after 3 unusable answers the row is stamped errored. A 4xx refusal is stamped, unless it repeats on three rows of a namespace in a row, which pauses that namespace for 5 minutes. A pass that cannot run at all (no key, refused model, outage, locks down) pauses the worker for 5 minutes.

Records, Auto-resolved and Undo (server/memory/app/auto_resolution.py, frontend/src/views/admin/ReviewQueue.tsx).

  • Every path that retires a row writes a memory.auto_supersede audit record (ids and keys, no values) with reason conflict_resolver, same_key_newest_wins, newest_wins_contradiction or value_update. Resolver records also carry the verdict, confidence, model and prompt version (v3).
  • The record and the graph update are queued as a triples_follow_owed intent before the retirement commits, so a crash leaves them to the projection repair.
  • The Auto-resolved tab lists the last 30 days through the new op memory.auto_retirements, filtered to the caller's read scope, and shows each row's current status through the new op memory.statuses.
  • Undo calls memory.restore with the new if_superseded_by, so it restores only a row still retired behind that memory. Under the key lock it first writes a memory.unsupersede record; if that write fails it answers 503 and restores nothing. The resolver then leaves the pair alone until one of the rows is written again. Retrying an Undo whose answer was lost finishes it without writing anything twice.

Graph facts follow rows (server/memory/app/{set_entities,graph_holders,edge_links,edge_repair,triple_projections,triple_follow,graph_undo}.py). A row holds graph facts only while it is live, unexpired, inside its valid_to and not high. Retirements, revisions that drop a fact and Undos close or reopen the triples and edges that depend on it. The new tables entity_triple_rows and entity_edge_rows record which row and content hash stated each fact. A single-valued relation keeps one current value, ordered the same way by racing writers and replays. Point writes accept relations (up to 8). A delete closes no facts.

High rows. A high row is never a peer, so its value is never sent to the LLM (labels are checked again before the prompt). It keeps only the edges of the entities its writer declared. When a row becomes high, or is re-set naming fewer entities, its other links are deleted and their edges end unless another live row holds them. A write that lands during that drop keeps its links: the drop reads the rows again after its DELETE and writes back what they still hold. If that restore fails, it is recorded as entity_edges_restore and replayed by the projection repair; a row made high again in the meantime gets its links back and is dropped again. memory.get_by_id takes omit_high_value, which the Review queue uses for peers.

Other fixes in the same paths:

  • task.create with an idempotency key holds a Keeper lease from lookup to insert, so concurrent creates store one task. A retry finishes a create that was cut off after its row was written.
  • Coalesced SDK sets raise the same errors as memory.set (422, 409, 423). Bulk results carry memory_id, pinned_blocker_id, refusal verdicts and skipped_blacklisted, and set_from_messages returns refused.
  • Templated substitutions ("ends in 2025" → "2027") retire under newest_wins again; preserves_quantities, which kept both rows, is removed.
  • Batched peer lookups bind each vector separately: four 3072-d vectors in one parameter went over ClickHouse's 128 KiB limit.
  • An audit-log page no longer ends in the middle of one write's records.
  • Erasure covers the new link tables (saga and census) and the projection failures that name the erased user. loom erasure-re-verify --completed-since re-checks erasures that an older build completed during a rollout.

Results

Long-session benchmark (bench/conflict_resolver_long_session.py --variant both): one user, 12 sessions, six attributes that change over time. 5 runs per arm, each on its own ClickHouse; a run fails if the resolver does not drain. Rubric v3, thresholds 0.90 / 0.95 / 0.98, owed floor 0.60. Mean [min–max]:

Arm Variant Updates caught Stale top hit False flags Newer retired $/run Verdict p50 / p95
Resolver off set 0 1.00 2 0 0 –
newest_wins set 0.36 [0.33–0.44] 0.47 [0.33–0.50] 0 0 0.012 [0.010–0.018] 9.4 / 15.5 s
auto_reinforce set 0.38 [0.33–0.44] 0.43 [0.33–0.50] 0 0 0.014 [0.010–0.030] 8.3 / 18.2 s
Resolver off messages 0 0.77 [0.67–0.83] 1.2 [0–2] 0 0 –
newest_wins messages 0.87 [0.78–1.00] 0.07 [0–0.17] 0 0 0.024 [0.017–0.041] 10.3 / 14.9 s
auto_reinforce messages 0.89 [0.78–1.00] 0.03 [0–0.17] 0 0 0.040 [0.032–0.051] 10.0 / 17.9 s

No run retired the wrong row. The updates missed in the set variant are pairs below the 0.60 floor (cosine 0.39–0.59). With a 0.70 floor the same runs caught 0.11 / 0.18 (set) and 0.69 / 0.73 (messages) with 40% fewer calls; two real updates sit at cosine 0.696.

LongMemEval-S, 30 questions, seeds 42 and 7, memory.ask and a reader arm (gpt-5, k=200), asked again after a full drain:

Build ask, ingest ask, drained reader, ingest reader, drained
This branch (v2 rubric, retire 0.95) 58/60 57/60 50/60 50/60
main 58/60 58/60 55/60 56/60

Re-run from the same start with the resolver off on both builds, the reader scored 56/60 here and 53/60 on main, and all five questions that flipped had the same answer in context on both. Every knowledge-update miss in the drained run was in a namespace the resolver never acted on, so the reader gap is extraction and dedup variance. A drained run on the final rubric (v3, retire 0.98, seed 42) scored ask 29/30 (main 28–29) and reader 27/30 (main 26–28). Ingest and search latency match main within noise.

Precision on agent notes, held-out half (384 rows, 2,927 pairs), hand-labelled. Most retirements there replace a running tally; the second column leaves those out:

Rubric, thresholds Retire Retire, excluding tallies Flag
v1, retire 0.95 376/391 = 96.2% 13/24 439/444
v2, retire 0.95 375/377 = 99.5% 16/16 438/443
v3, retire 0.95 373/377 = 98.9% 14/16 440/442
v3, retire 0.98, flag 0.95 366/369 = 99.2% [97.6–99.7] 9/10 444/444

Assistant chat. The v2 drained LongMemEval run retired 63 rows, 49 of them correctly. The 13 wrong ones were additions (a substitution retiring the base recipe), items of one kind (two rides), successive events (chess moves) and two same-day pairs in reverse order; they led to the v3 rubric, the 0.98 threshold and the same-day rule. The v3 drained run judged 17,078 rows and retired 1, wrongly: extraction had put event dates in valid_at.

Thresholds:

  • Owed floor 0.60: a 0.70 floor saves 15–40% of calls but misses short personal-fact updates, which this embedder places at 0.60–0.70. Spend is already bounded by the cap share.
  • Clear 0.90: compatible verdicts at 0.90 or more were right 2,069 of 2,076 times on held-out agent notes.
  • Flag 0.95: raising it from 0.90 took flag precision from 57% to 76% on the drained chat run and to 100% (444/444) on held-out agent notes, losing 4–5 real conflicts per half.
  • Retire 0.98: 8 of the 13 wrong retirements across the labelled sets were below 0.98. About 1.5% of true updates fall below it and become flags instead.

Cost. A judged row costs $0.005–0.006 on chat and $0.008–0.009 on longer agent notes. About 80% of chat writes get marked, so 1,000 chat writes cost $3.94–4.92. One leader judges 54–60 rows a minute. Under the default $1 daily cap the resolver gets $0.25, about 40–50 rows a day per namespace, newest first:

New rows a day Judged (80%) Resolver $/day Cap needed at share 0.25
100 80 $0.49 $2
1,000 800 $4.90 $20
10,000 8,000 $49 $196

The share exists because an earlier run let the resolver use the whole cap, and memory.ask dropped from 58/60 to 4/60.

The default and how to opt out

The old per-write judge was off by default. The resolver is on unless LOOM_LLM_PROVIDER or the resolver model's provider is fake, and it retires at 0.98 under auto_reinforce (the default) and newest_wins. In agent use nobody works the Review queue, so a flagged update leaves search serving the stale value; a retirement is recorded, can be undone, and the old row stays readable with include_superseded and as_of.

To keep a person in the loop, register the namespace with default_conflict_policy: manual_review, so updates are only flagged. To turn judging off, set LOOM_MEMORY_CONFLICT_RESOLVER_ENABLED=false; writes are then not marked.

Scope and risk

This touches every memory write path (memory.set, bulk_set, update, update_by_id, restore, pin, unpin), adds a leader-only worker that writes memory rows, and changes the triple and edge projections, audit records, the Review queue, erasure and task.create. The identity tuple, audit hashing and read responses are unchanged apart from the added fields.

What covers the main risks:

  • Retiring the wrong row: the 0.98 threshold, a strictly older peer, the same-day rule, and both rows re-checked under their locks. Tests cover same-second pairs, a value that came back, and a peer edited during the call.
  • Races on one key: barrier tests on real ClickHouse and Keeper, and a randomized invariants test (6 seeds) that runs writes, pins, deletes, retirements, Undo and an erasure together.
  • Reads across users or tenants: peers come only from the row's subject; the leakage and read-scope suites pass.
  • Spend: the cap share is checked before the queue and before each call, so a pass overshoots by at most the calls in flight.
  • CI time: the integration job grows from about 30 to about 46 minutes; its timeout is now 60.

Known limitations:

  • On assistant chat about a quarter of flags at 0.95 are wrong.
  • A busy namespace builds a backlog under the default cap share; raise the cap or the share.
  • Updates across sessions of user - are never acted on.
  • An Undo made on the old build, or before the upgrade, is not visible to the resolver, so it may retire the memory again. Pin it, or Undo again on the new build.
  • Undo records live in loom.audit_log. If LOOM_RETENTION_AUDIT_LOG_DAYS is shorter than a pair's life, the record ages out and the pair can be retired again.
  • A mined projection that passed its fence just before a same-value re-set to high can leave one link.
  • A row with more flagged peers than fit one call is stamped after 3 attempts; the rest stay for review. A key held in more than 4 other sessions is judged 4 sessions per call.
  • Search does not return a retired value; memory.history does.
  • Left for a follow-up (the first five behave the same on main): search dedups by (namespace, memory_key), hiding a second live same-key row from another session; the duplicate gate can mark a later knowledge update as a duplicate; the credential check misses a password inside a JSON value; an entity name over 128 KiB fails the request; 25 erasure mutations use subqueries, which replicated tables refuse; and the bulk path's in-batch replay of a repeated key needs restructuring.

Compatibility, rollout and rollback

  • Wire, removed: the memory.set field await_verdict (accepted and listed in ignored_args), the response field verdict_at, and the pending value of conflict_verdict. Break: the Python SDK's memory.set(await_verdict=...) keyword is gone and raises TypeError.
  • Wire, added:
    • ops memory.statuses (status and superseded_by for up to 5,000 ids) and memory.auto_retirements (the automatic retirements in the caller's read scope), both experimental, viewer and read-only;
    • memory.restore takes if_superseded_by and only_if_superseded; memory.get_by_id takes omit_high_value; memory.set, update and update_by_id take relations; MemoryGetOutput carries user_id and session_id; bulk results gain the fields above and set_from_messages returns refused;
    • audit events memory.auto_supersede and memory.conflict_resolver;
    • projection-failure kinds triples_follow_owed, triples_reopen, triples_reconcile, entity_edges_close, entity_edges_drop_undeclared and entity_edges_restore, and an abandoned status.
  • Behaviour: relation verbs keep letters of every script (possède is stored as possèd; владеет and 所有 are accepted). Break: a relation an older build stored with those letters dropped (poss_d) no longer matches the same verb written now, so revising that fact leaves the old triple open next to the new one until it is restated.
  • Behaviour: with a real provider the resolver is on by default, so an upgrade starts paying for its calls, within the cap share. auto_reinforce now retires rows without a person. Retirements write no key-level memory.link edge (refines or supersedes), so memory.backlinks no longer shows them; use superseded_by and the audit record.
  • Webhooks: the resolver's retirements and flags send no event, the same as other supersessions; a receiver mirroring Loom reads memory.auto_retirements.
  • Settings removed: LOOM_MEMORY_CONFLICT_JUDGE, _MAX_PEERS and _MIN_SIMILARITY. One still set is logged as an unknown key at boot.
  • Settings added, all in server/settings/catalog.py (LOOM_MEMORY_CONFLICT_RESOLVER_* unless named): ENABLED, MIN_SIMILARITY 0.60, MAX_PEERS 8, RETIRE_CONFIDENCE 0.98, FLAG_CONFIDENCE 0.95, CLEAR_CONFIDENCE 0.90, BATCH 40, RECHECK_BATCH 8, CAP_SHARE 0.25, MAX_OWED_AGE_DAYS 30, CONCURRENCY 8, INTERVAL_SECONDS 10, MAX_PASS_SECONDS 600, BURST_SECONDS 300 (at most half of MAX_PASS_SECONDS), MAX_ATTEMPTS 3, PAUSE_AFTER_STOP_SECONDS 300, RECHECK_IDLE_SECONDS 300, LOOM_MEMORY_BULK_FOLLOW_MAX_PAIRS 1024 and LOOM_CONFLICT_RESOLVER_MODEL gpt-6.1-sol. MAX_PEERS, BATCH, RECHECK_BATCH, CAP_SHARE, MAX_OWED_AGE_DAYS, MAX_ATTEMPTS, PAUSE_AFTER_STOP_SECONDS, RECHECK_IDLE_SECONDS and the bulk follow cap can be overridden live.
  • Migrations 065–071, all additive: 065_entity_triple_rows, 066_projection_failure_abandoned, 067_entity_triple_seen_at, 068_graph_restore_id, 069_entity_edge_rows, 070_entity_edge_close_id, 071_projection_failure_ttl (resolved failures are deleted after 30 days).
  • Old and new builds side by side (docs/architecture/rolling-upgrades.md, rules 10–17): task-dedup leases hold only among new replicas; the old build ignores the new request fields, writes no row links and misses the link tables in erasure; its per-write judge, if on, can overwrite the new build's mark, and its pin takes no lock; it leaves the new projection-failure kinds to the new build's repair. While an old replica leads the workers, marked rows wait.
  • Operator steps:
    1. Remove LOOM_MEMORY_CONFLICT_JUDGE* from the environment.
    2. Make the resolver's model reachable: an OpenAI key for gpt-6.1-sol, or the inference gateway's route for it where calls must go through the gateway (LOOM_INFERENCE_GATEWAY_REQUIRED, or LOOM_INFERENCE_TOKEN_URL set). Each call names the row's org in LOOM_INFERENCE_CUSTOMER_HEADER and the feature conflict_resolver. Until the model answers, marked rows wait, as do rows of an org whose model calls are switched off.
    3. Check the budget. The share is per namespace, so a large LOOM_DEFAULT_DAILY_COST_CAP_USD bounds very little; lower LOOM_MEMORY_CONFLICT_RESOLVER_CAP_SHARE or set per-namespace caps.
    4. After the rollout, run loom erasure-re-verify --completed-since <rollout start> --resume.
    5. Rows the old judge left conflicted need no manual allow; the resolver re-checks 8 per pass. To keep that drain from retiring anything, use manual_review until it is done.
    6. Pin any memory restored with Undo on the old build during the rollout.
  • Rollback: the new tables and columns, link rows, audit records and judged marks stay. The old build reads the marks as settled and ignores the links. Retired rows stay retired; memory.restore brings one back.

Reading guide

306 files. Read in this order; each part builds on the previous one:

  1. Write path, tasks, audit and erasure: server/memory/app/{bulk_rows,bulk_set,bulk_verdicts,pipeline,pipeline_state,ops,write}.py, server/memory/api/models_bulk.py, server/memory/store/{conflict_candidates,lifecycle,embeddings}.py, sdk/python/loom/memory.py, server/tasks/, server/insights/{app,store}/audit.py; rolling-upgrades rule 10.
  2. Graph facts follow rows: migrations 065–071; server/memory/domain/{triples_follow_rows,graph_quality,temporal_sql}.py; server/memory/app/{set_entities,graph_holders,edge_links,edge_repair,triple_projections,triple_follow,graph_undo,projections,projection_failures}.py; server/memory/workers/projection_repair.py; server/erasure/; docs/features/entity-graph.md; rules 11–14, 16 and 17.
  3. The resolver, records and Undo: server/memory/domain/conflict_resolution.py, then server/memory/store/conflict_resolver.py, server/memory/app/conflict_resolver.py and the worker; server/memory/app/{auto_resolution,intent_marks,key_supersession,restore,conflicts,set_commit,update,value_updates}.py; the deleted conflict_judge.py, conflict_deferred.py, store/conflict_marks.py and workers/conflict_sweep.py; server/settings/catalog.py; frontend/src/views/admin/ReviewQueue.tsx; bench/conflict_resolver_*; docs/features/memory/conflicts-and-refusal.md; rule 15.

Tests

  • Integration, on a private ClickHouse and Keeper: test_conflict_resolver_ch.py (118), test_conflict_resolver_invariants_ch.py (6 seeds), test_conflict_resolver_long_session_ch.py, tests/integration/same_key/ (290, run in random order), test_task_create_dedup_live_ch.py, test_cross_principal_leakage.py, test_read_scope_isolation.py, the erasure files and the search analyzer corpus.
  • Unit: test_conflict_resolver.py, test_auto_resolution.py, test_restore_unsupersede.py, test_intent_marks.py, test_triples_follow_rows.py, test_triple_row_links.py, test_projection_failures.py. Frontend: ReviewQueue.test.tsx, api.autoResolved.test.ts.
  • Full unit suite: 23,179 passed, 18 skipped, 1 xfailed, on the head before the last two main merges. Format, lint, typecheck and the generator checks pass on the final head.

AI assistance in the code (leave one; writing this description with AI is fine):

  • AI-generated (an agent wrote most of the diff): Claude Code. Each fix started from a reproduced failure and a test that failed first against real ClickHouse. A separate reviewer agent reviewed every push. The last completed review found one P2 (a failed link restore on a row made high again before the repair ran) and five P3s, all fixed in this PR. The owner made the design calls: dropping the per-write judge, the thresholds, retiring by default under auto_reinforce, row-level fact links, task dedup, and keeping this as one PR.

  • I can explain every line of this diff and how it interacts with the rest of Loom.

Checklist

  • make format-check, make lint, make typecheck and make test-unit pass; the integration suite passes if server behaviour changed.
  • Generated files are regenerated in this PR, not by hand: the SDK op tables, docs/reference/configuration.md and the docs/reference/ tables (python scripts/codegen/docs_reference.py), the reach manifest, schemas/schema.sql (make schema-dump) and the Codex plugin copies (python3 scripts/codegen/agent_plugin_sync.py).
  • A new migration is additive and numbered after the latest on main; no merged migration is edited.
  • (n/a: no plugin file changes) A behaviour change to any file a plugin ships (hooks/, lib/, bin/, skills/, .mcp.json, the Codex plugin-defaults.json) bumps both plugin manifests' version, and no other open PR uses that version.
  • The frontend builds (npm --prefix frontend run build) and its tests pass, if frontend/ changed.
  • Docs under docs/ describe the system as it now is, and this description names any operator steps and wire changes.
  • Repository text has no dates, people, host names, internal namespaces, ticket or decision numbers; the history goes in this description (tests/unit/test_public_copy.py).
  • Commits are signed off (git commit -s), as CONTRIBUTING.md asks. A few early commits lack it; the squash commit carries it.

🤖 Generated with Claude Code

@zlareb1
zlareb1 force-pushed the fix/same-key-cross-session-revision branch from fa91cab to 7f82a64 Compare October 13, 2026 15:14
@zlareb1 zlareb1 changed the title Memory: a later session's restatement of an attribute retires the earlier one under the default policy Memory: with the conflict judge on, a later session's restatement of an attribute retires the earlier one Oct 13, 2026
@zlareb1 zlareb1 changed the title Memory: with the conflict judge on, a later session's restatement of an attribute retires the earlier one Memory: a later session's restatement retires the earlier one, Loom shows what it retired and lets people undo it, and the conflict judge is on by default Oct 13, 2026
@zlareb1
zlareb1 force-pushed the fix/same-key-cross-session-revision branch from b50e29c to c199b56 Compare October 15, 2026 07:55
@zlareb1 zlareb1 changed the title Memory: a later session's restatement retires the earlier one, Loom shows what it retired and lets people undo it, and the conflict judge is on by default Memory: a later session's restatement retires the earlier one, and Loom shows what it retired and lets people undo it Oct 16, 2026
@zlareb1 zlareb1 changed the title Memory: a later session's restatement retires the earlier one, and Loom shows what it retired and lets people undo it Memory: a background conflict resolver replaces the per-write conflict judge, and every automatic retirement is recorded and can be undone Oct 18, 2026
@zlareb1 zlareb1 changed the title Memory: a background conflict resolver replaces the per-write conflict judge, and every automatic retirement is recorded and can be undone Memory conflicts are judged by a background resolver, and every automatic retirement can be undone Oct 18, 2026
zlareb1 and others added 19 commits October 18, 2026 23:45
…le rule

The budget module says a background spender reads a failed read as over;
_cap_share says the resolver also stops at the whole cap; and the docs say the
30-day owed age is the vector row's, the write time of the revision owed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
… handler now passes

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…sserted-versions statement

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…fails with 503 when it cannot

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…ed by the restore version in its record

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…conflict resolver

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…he two heads together

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…t keeps the earlier ones

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…ed restore after its record answers 503

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…d that a pin prevents it

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…_versions

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…t Undo record stops holding

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…ement, not a new statement

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
… answers restored

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…, by the audit log's ts key

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
@zlareb1 zlareb1 changed the title Memory conflicts are judged by a background resolver, and every automatic retirement can be undone A background conflict resolver replaces the per-write judge; every automatic retirement is recorded and undoable, and graph facts follow their rows Oct 20, 2026
zlareb1 and others added 22 commits October 20, 2026 08:23
Co-Authored-By: Claude Opus 5.5 <[email protected]>

# Conflicts:
#	docs/reference/operations.md
#	sdk/typescript/src/generated/ops.ts
…e repair scan skips failures a retry would leave pending, and graph reads see pending closes

- cluster_peers keeps another session of the anonymous user only when one side flags
  the other, so such rows take no place from a same-session peer
- the projection repair scan leaves out orgs under erasure and follow intents within
  their grace, so they cannot hold every pass
- reads after a triple close apply pending mutations on the fly
- a relation verb keeps letters of every script
- the supersede re-reads the winner, as the comment now says

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
- PR 26's migrations follow main's last: 046-052 become 062-068.
- The resolver's settings live in server/settings/catalog.py (main's one catalog):
  call-time knobs are LIVE, and the worker's pass budget, burst, attempts, pause
  and recheck pacing, and the bulk follow cap are settings instead of module
  constants.
- The resolver's model calls name the row's org, an org whose model calls are
  switched off takes no place in the queue, and a held call leaves its row owed
  with no attempt or error (main's org attribution and switch for the per-write
  judge and conflict sweep this PR removes).
- The projection repair names each failure's org and skips switched-off orgs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…cope

The Auto-resolved tab read memory.auto_supersede records through
audit.list, which scopes by namespace only, so a token narrowed to one
user or session saw every user's retired keys and ids. The new viewer op
flattens the records server-side, keeps each entry only when
row_in_read_scope holds, and pages by retired memories with a keyset
cursor that never splits a record. The dashboard reads it instead of
audit.list.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
_resolve_one passed the 50-statement gate once it handled a held model call.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
- PR 26's migrations follow main's 062_extraction_policies: 062-068 become 063-069.
- set_from_messages' bulk write records its result in its own function, keeping
  _step_bulk_write under the 200-line gate with main's extraction policy step.
- The resolver's high-shape check and the security page name every high shape
  main's detector reads (cards, SSNs, stated PINs), not credentials only.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…and round-147 fixes

- The cluster's nearest read takes only the anonymous user's own session and skips the
  other-session same-key branch for it, so forty such rows no longer fill its places;
  the duplicate filter in _judge_and_act and the row_id parameter go.
- The race test compares superseded_by to "" (the column is not Nullable).
- memory_conflict_resolver_burst_seconds is checked to be at most half the pass
  deadline, and is no longer LIVE so the check holds.
- The projection repair scan reads erasing orgs as a subquery.
- A wide character (CJK) counts twice toward the 2-character minimum of a fact's
  subject, relation and object: one is a whole word.
- The sidebar's call budget names memory.auto_retirements.
- The bulk 'high' drop test asserts each row was rewritten and owes a drop before it
  checks the links, so a failure tells the two apart.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
Main's sensitivity sweep made sort_key a required field of SweepCandidate.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…ents test

- A fact's subject, relation and object need two characters again, as the triple
  writer requires: a wide character counted twice let one-character CJK copulas
  through, and the triple writer then dropped what it accepted.
- The env contract test leaves the cross-checked burst and pass deadline alone.
- The burst validator test writes its accepted case directly.
- The repair scan reads with sequential consistency, so an erasure queued a moment
  ago is seen.
- The sidebar asks memory.auto_retirements for the 50 newest records in its one call;
  the docstring says what a narrowed token can miss.
- An HTTP test: under newest_wins, V's retired key is listed to V's narrowed token and
  never to U's.
- The gaps ledger drops a setting a test now names.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…nd-149 nits

- canCall knows memory.auto_retirements; the sidebar's probe asks it, and the Review
  queue's Auto-resolved tab needs it and audit.list (its Undo records).
- The sidebar comment points at hasAutoResolved instead of a stale record count.
- The env contract test leaves out only the burst, so the pass deadline's variable is
  still checked to reach its field.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…eue's tab needs

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
- PR 26's migrations follow main's 063_memory_webhooks: 063-069 become 064-070.
- A restore of a tombstoned row announces memory.restored right after its insert, and
  the sensitivity sweep announces its relabels and still closes a relabelled row's mined
  facts.
- The task dedup test stubs webhook delivery at server.core.webhooks.post.
- Round 151: ERASING_ORGS_SQL's comment names its second reader and it is exported;
  _nearest_sql says a one-sided flag from another anonymous session waits for a person.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…vent list, and same-key tests drain their side effects

- docs/features/memory/writing.md names what the conflict resolver lands after the write
  (retirements, its conflicted flags) among the changes that send no webhook event, as
  write-time supersessions are, and points a mirroring receiver at
  memory.auto_retirements; the bullet that named the removed deferred judge is gone.
- The webhook rule in rolling-upgrades.md is rule 22, not a second rule 14, and the
  memory architecture page links it.
- The same_key `ch` fixture drains after-write tasks, intent marks and graph write marks
  before it disconnects, so one test's side effects no longer land in the next test.
- A plain restore whose key lock is busy says "retry the restore", not "retry the Undo".

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…er, and the auto_retirements pointer covers every supersession

A hook installed with monkeypatch.context() put the real end_edges back through the outer
monkeypatch, so the outer teardown reinstalled the hook and later tests ran it inside their
drops. The hook now restores through the context patcher. The teardown drain added for
the same symptom is removed: it was not the cause.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>

# Conflicts:
#	tests/analyzer/shapes.txt
…in during the drop gets its links back

A same-value plain re-set landing between the drop's last read and its DELETE loses its
links to the DELETE, and only the restore brings them back. A failed restore was recorded
as the drop, whose replay skips a row no longer 'high', so the links stayed gone and the
row's next drop found nothing to end its undeclared edges by. The restore now records its
own projection, entity_edges_restore, with the links and closes it owes; the repair
replays it against the rows as they are then.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
Main's 064_learnings_agent_and_supporters takes 064: this branch's migrations move to 065-071, and main's rolling-upgrade rule 15 becomes 23 after this branch's 10-22.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…inks and drops them again

The restore's replay skipped a row made 'high' again before the repair ran, but that
row's own drop had found none of the links the DELETE took and ended none of their
edges. The replay now writes those links back for a row still holding the same value
and runs its drop again. The restore failure names its op, its payload holds each link
once with whether the DELETE took it, and the warning counts the links owed back.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
@zlareb1
zlareb1 merged commit d5aaf4f into main Oct 21, 2026
19 of 22 checks passed
@zlareb1 zlareb1 changed the title A background conflict resolver replaces the per-write judge; every automatic retirement is recorded and undoable, and graph facts follow their rows Memory conflicts are judged in the background, every automatic retirement can be listed and undone, and graph facts follow the rows that state them Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant