feat(memory): reconcile stale exact-lock updates#2335
Conversation
PR Reviewer Guide 🔍(Review updated until commit 20ca50e)Here are some key observations to aid the review process:
|
PR Code Suggestions ✨No code suggestions found for the PR. |
…-patch-rewrite-pr1
|
Landing update for PR-1 (2026-06-02): refreshed the PR body for head |
|
Persistent review updated to latest commit 217fba1 |
PR Code Suggestions ✨No code suggestions found for the PR. |
|
Draft-state correction: I moved #2335 back to draft because review should include a rigorous speed + quality analysis, not just code/CI readiness. Current quality gates and full r4 non-regression evidence are already summarized in the PR body; the missing piece is the same-concurrency tree C4 wall-time baseline. A fresh tree C4 run is still in progress, so the PR should stay draft until the final speed table / claim boundary is updated. |
…-patch-rewrite-pr1 # Conflicts: # tests/client/test_rebuild_clients.py
|
Persistent review updated to latest commit 20ca50e |
PR Code Suggestions ✨No code suggestions found for the PR. |
|
Follow-up to my earlier draft-state note: the final review-facing speed denominator and quality/health/eval evidence are now in the PR body, head |
Summary
This PR adds an opt-in exact file-lock apply path for concurrent OpenViking Memory V2 writes. The validated PR-1 scope is agent memory extraction for
trajectoriesandexperiences.The goal is to let memory extraction run concurrently without relying on broad schema tree locks, while keeping write correctness at apply time:
The new behavior is disabled by default behind:
memory.memory_apply_exact_file_lock_enabledmemory.stale_patch_rewrite_enabledWhat Changed
Runtime memory apply:
StrPatchWithBaseandReplaceValueWithBase.StrPatchSEARCH/REPLACE patches against the latest field value.replaceproposals against the latest field value.patchin the agent exact path as a base-aware full replacement, not as a substring patch.apply_tracerows with URI, field, merge op, input shape, wrapper shape, stale/rewrite status, and applied/failed/skipped status.Scope gates and validation plumbing:
trajectories/experiences.session_skillson the existing tree-lock path.Scope
Included:
StrPatchrewrite for string SEARCH/REPLACE patches.trajectories/experiences.SUMcounter deltas as supporting cleanup.memory_diff_<phase>.jsonarchives with apply traces.Not included:
session_skills.Validation
Current pushed head:
20ca50ed.Local targeted validation:
Result:
166 passed, 1 deselected, 6 warningsgit diff --check: passedClient regeneration check:
.venv/bin/python -m pytest -q -o addopts='' tests/client/test_rebuild_clients.pyResult:
16 passed, 5 warningsGitHub checks on
20ca50ed:check-deps: passlint / lint: passAPI & CLI Integration Tests (ubuntu-24.04): passpr_review: passbuild: skippedCorpus Build Speed
The clean review-facing denominator is exact C4 vs safe serial tree C1. A same-concurrency tree C4 run was attempted but failed the strict write gate before producing valid manifests, so this PR does not claim exact C4 vs tree C4 speedup.
Both valid runs used the same cached train results and produced valid retail + airline corpus manifests. The comparison is conservative: it measures the PR-1 concurrent exact path against the safe serial tree-lock baseline, not a lock-manager microbenchmark.
Full-Train Corpus Health
All four full-train corpora passed
strict_corpus_gatewithclaim_valid=true.Hard gates were clean in all four corpora:
000000session_skills_extracted_total:0Corpus shape:
Quality boundary:
Full Held-Out Eval Gate
Protocol:
Same-protocol exact vs tree:
-0.00420.0This supports no catastrophic corpus, retrieval, or scoreboard regression for the exact path. It does not claim reward uplift or semantic relevance for every retrieved memory.
Apply Trace / Stale Handling
Full-train archive traces:
The exact path records stale and delete conflicts explicitly. These rows are not hidden as successful writes.
Claim Boundary
This PR is a common server-side write-safety primitive for agent memory. It validates exact file-lock apply, stale rewrite/synthesis, graph/schema health, retrieval plumbing, and non-catastrophic full-eval regression for agent
trajectories/experiences.It does not claim:
session_skills