You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[PR] fix: keep unified session ingestion current with retained originals - #4218
When a reap removes a compression block while retaining its original text, UnifiedShadow.record() journals the originals and returns before ingesting the rest of the session. Every later save repeats that return. An existing unified row can remain hours behind the JSON envelope, and an eviction/restart then reloads old folds, messages and usage. The reported session had 876 requests in JSON but only 390 in SQLite.
Carry retained originals in the existing sessions.orphans_json field on every full/delta ingest, atomically with session metadata, message pointers and the authoritative block set. Remove the sync/queued save and organic-import skip paths. SQLite and MySQL both persist the journal; planner-supplied {} clears removed originals, while low-level callers omitting the optional field retain their existing journal. Keep the writer-off compatibility envelope and legacy status counter.
Fixes#4216. Follow-up to #3911 / #3841. No schema, config, kernel, or package-version change. This repairs persistence shared by proxy and plugin modes; it does not alter either mode's wire rendering or the separate learned-image-cost issue #4153.
Validation:
Regression was red before the fix on both sync and queued facades (390 !== 876); now passes, including watermark delta ingestion, retained-original imports, and cold reload.
Private offline replay: all 60 existing original views retained; serialized state/stats/metadata/tail and completed original views round-trip exactly; cold load returns 876 requests, 87,866 input tokens, 59 blocks (5 active). No private conversation fixture is committed.
Typecheck, build, unused-export and test-import gates pass. MySQL SQL is covered by the DSN-enabled contract test in CI.
GitHub CI on this head: all three Ubuntu/Node 22 test shards, the real MySQL contract lane, both Linux/Windows static-gate lanes, and all repository guards passed. Still running at this update: test (windows-latest, 22, 1); test (ubuntu-latest, 24, 1); test (windows-latest, 22, 2). No completed check has failed.
ranxianglei
changed the title
fix: keep unified session ingestion current with retained originals
[PR] fix: keep unified session ingestion current with retained originals
Oct 21, 2026
契约测试(sqlite + mysql 两 lane):round-trip 等价 + 原文变更可见 + 清空语义钉死(blockContents.clear() 后重摄入,size === 0,「removed originals must not reappear from an old journal」)——把「权威替换」这个关键决策变成了回归资产。
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
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.
When a reap removes a compression block while retaining its original text,
UnifiedShadow.record()journals the originals and returns before ingesting the rest of the session. Every later save repeats that return. An existing unified row can remain hours behind the JSON envelope, and an eviction/restart then reloads old folds, messages and usage. The reported session had 876 requests in JSON but only 390 in SQLite.Carry retained originals in the existing
sessions.orphans_jsonfield on every full/delta ingest, atomically with session metadata, message pointers and the authoritative block set. Remove the sync/queued save and organic-import skip paths. SQLite and MySQL both persist the journal; planner-supplied{}clears removed originals, while low-level callers omitting the optional field retain their existing journal. Keep the writer-off compatibility envelope and legacy status counter.Fixes #4216. Follow-up to #3911 / #3841. No schema, config, kernel, or package-version change. This repairs persistence shared by proxy and plugin modes; it does not alter either mode's wire rendering or the separate learned-image-cost issue #4153.
Validation:
390 !== 876); now passes, including watermark delta ingestion, retained-original imports, and cold reload.