feat(memory): reconcile stale exact-lock updates#2335
Draft
huangruiteng wants to merge 24 commits into
Draft
Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨No code suggestions found for the PR. |
…-patch-rewrite-pr1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds a narrow, opt-in write path for concurrent memory updates:
StrPatchvalues with the field value they were generated against (StrPatchWithBase)ReplaceValueWithBase)It also carries the minimal validation surface needed to run this end to end:
/api/v1/stats/memory-graph, exposed through local/http sync/async clientsScope boundary
Included in this PR:
patch + StrPatchstale SEARCH/REPLACE rewrite primitivereplacestale synthesis primitive; stale full-value proposals must be synthesized against latest content or fail fasttrajectoriesandexperiencespatchin the agent exact path interpreted as a base-aware full replacement, not as substring patchmemory.long_term_extraction_enabled=false,memory.agent_memory_enabled=true, and default/offmemory.session_skill_extraction_enabled=falseSUMcountersStoredLinkcleanup for peer links/backlinksmemory_diff_<phase>.jsonarchives withapply_tracefields (uri,field,merge_op, input/wrapper shape, stale/rewrite status, applied/failed status)Not included here:
session_skillsreplacesynthesis / typed schema mergeThe new memory-write behavior is off by default behind:
memory.memory_apply_exact_file_lock_enabledmemory.stale_patch_rewrite_enabledTAU corpus commit concurrency also defaults to serial (
1) unless explicitly configured.Validation
Latest GitHub checks at head
9c22aebe:check-deps: passedlint / lint: passedAPI & CLI Integration Tests (ubuntu-24.04): passedpr_review: passedbuild: skippedTargeted local validation on this branch includes:
tests/session/memory/test_memory_timestamp_parsing.py tests/session/memory/test_memory_updater.py tests/session/memory/test_merge_ops.py109 passedtests/session/memory/test_memory_updater.pyandtests/session/memory/test_merge_ops.pyuvx ruffandgit diff --checkon touched runtime/test files: passed in the final local validation sequenceFull-train corpus gate at head
9c22aebe:/private/tmp/pr2335_9ef7e46d_full_train_exact_c4_deleteskip_20260602_010530/private/tmp/pr2335_fe114b20_full_train_tree_c1_20260601_231521strict_corpus_gatewithclaim_valid=true0Full-train corpus shape:
Weighted source-density read:
5.30/ single-source31.1%5.63/ single-source39.4%Read: source-density and near-dup are measured and did not hit graph/schema hard failures. They are still a quality boundary, especially for exact-retail semantic fragmentation / create-new consolidation. This PR should not be read as semantic applicability parity.
Full held-out r4 eval using the frozen full-train corpora:
/private/tmp/pr2335_9c22aebe_full_eval_plan_20260602_032646/exact_result/exact_full_eval_r4_exec_20260602_033640/private/tmp/pr2335_9c22aebe_full_eval_plan_20260602_032646/tree_result/tree_full_eval_r4_exec_20260602_041900Same-protocol exact vs tree:
-0.00420.00.025reward/DB0.0375reward and0.05DBcorpus_evidence.claim_valid=trueandeffect_evidence.claim_valid=trueRead: this supports no catastrophic scoreboard/corpus/retrieval-plumbing regression for the PR-1 exact path. It does not claim reward uplift or semantic relevance of every retrieved memory.
Apply trace summary on full-train corpus writes:
Read: stale/delete behavior is recorded explicitly instead of being hidden as success. Rewrite latency/cost and full-C10 stress rewrite rate remain follow-up telemetry, not claims in this PR.
Claim boundary
This is a common server-side write-safety primitive, not a TAU reward claim. The validated runtime scope is agent
trajectories/experiencesunder the agent-only extraction config. The full-train and full held-out r4 evidence supports corpus health, graph/schema health, retrieval plumbing, and non-catastrophic score regression versus the frozen tree-lock baseline. It does not claim exact-file-lock coverage for standard long-term user memory, tools/skills, orsession_skills; it does not solve cross-URI create-new duplicates or experience granularity drift; and it does not claim full-C10 wall-time linear improvement.