Repository navigation
fix: drop mid-chain adoption from anonymous prefix affinity (#1115) - #1163
Conversation
📦 Built Package ArtifactBranch: Option A — Install from npm PR tag (recommended)npm install -g billion-context@pr-1163Each push to this PR publishes a new version under the Option B — Download artifact
tar xzf billion-context-pr1163.tgz
npm install -g packageInstall instructions are refreshed on each push. |
[bot] 🏷 Review complete — I pulled branch Diff cleanliness7 files, every one purpose-related: resolver, one log branch in Regression review — existing behaviors on touched pathsI read the pre-change code (not just the diff) and walked each behavior the touched paths carry:
Code-level checks: Pre-flight (independently re-run on
|
Tail-window reattach (#316) adopted a stored session when the incoming's leading 8 per-item hashes hit ANY mid-chain offset of a tracked chain. A mid-chain contiguous match is symmetric evidence, not an ownership proof: it cannot distinguish 'same conversation, truncated replay' from 'a different conversation quoting shared content' (templated tool outputs, standard files, stock errors - parallel agents on one codebase produce these naturally), and adoption was bidirectionally harmful (folded-summary leak to the adopter, context pollution of the victim). The #1072 interim mitigation (full-8 window instead of 3) closed sub-8 crafted windows but not the symmetry. Three days of production logs (~11.5k anonymous resolutions) showed zero tail-window reattaches and zero near-misses, so mid-chain adoption is removed entirely (direction 3 of #1115): truncated replays now fork into a fresh session. The truncated-run scan survives as lineage attribution only (never matching): leading TRUNCATION_LINEAGE_WINDOW=8 run strictly inside a tracked chain records lineage.reason='truncated' with all hit parents; a shared leading prefix (LCP >= MIN_FORK_PREFIX=3) records 'forked' and takes precedence. via narrows to 'prefix' | 'new'; the server tail-window log branch is deleted. Cost accepted: one raw resend + ladder restart per truncation (same cost class as instruction-drift forks, #1106); opt-in block adoption (#629) still carries fully-present blocks, kernel reconcile stays sound (deactivate/revive pinned). Tests: tail-window-reconcile.test.ts renamed truncation-fork.test.ts and rewritten (reattach assertions -> fork assertions; ambiguous multi-parent case asserts attribution with both parents). New design record SESSION-IDENTITY.md (+ .zh-CN): identity principles, threat model, measurement, rejected alternatives, three-layer framework, future client-side identity signal.
60eedc7 to
efb52fa
Compare
Closes #1115
What changed
The anonymous prefix-affinity resolver's second matching path (tail-window reattach, #316) slid the incoming's leading 8 per-item hashes against any mid-chain offset of every tracked chain and adopted the stored session on a contiguous hit. A mid-chain contiguous match is symmetric evidence, not an ownership proof: it cannot distinguish "same conversation, truncated replay" from "a different conversation quoting shared content" (templated tool outputs, standard files, stock errors — parallel agents on one codebase produce identical mid-chain slices with no attacker involved). Adoption was bidirectionally harmful either way: the adopter's rebuilt wire received the victim session's folded summary blocks (leak), and the adopter's new turns were recorded into the victim's session (pollution). The #1072 interim mitigation (full-8 window instead of 3) closed sub-8 crafted windows but did not break the symmetry.
Per the issue's direction 3 (owner-approved in-thread), mid-chain adoption is removed entirely:
src/prefix-affinity.ts: step-2 scan deleted;vianarrows to"prefix" | "new";TAIL_WINDOW→TRUNCATION_LINEAGE_WINDOW = 8used for lineage attribution only (leading run strictly inside a tracked chain at offset ≥ 1 →lineage.reason = "truncated"with all hit parents; shared leading prefix LCP ≥MIN_FORK_PREFIX = 3records"forked"and takes precedence). Lineage never affects matching.src/server.ts: tail-window log branch deleted.tests/tail-window-reconcile.test.ts→tests/truncation-fork.test.ts, rewritten (reattach assertions → fork assertions; ambiguous multi-parent case now asserts attribution with both parents; append-only / brand-new / templated-head regressions kept; kernel reconcile test kept). The 发现一些bug #1064 fix: cache health — remove condense, fix isTitleGen, preserve cache_control #13 crafted-window regression passes unchanged — mid-chain adoption no longer exists at any window size.SESSION-IDENTITY.md(+.zh-CN) (requested in-thread): identity principles (会话身份不稳定:credential/upstream 维度导致长会话状态孤儿化(sessions 缺失) #286), why full-prefix matching stays sound, threat model, measurement data, rejected alternatives (suffix-anchored / depth-scaled / kernel-verified / tail-anchored-run+floor), three-layer identity framework, future client-side identity signal.CHANGELOG.mdentry.Behavior change (disclosure)
via: "tail-window"; compression ladder continuous)via: "new",lineage.reason = "truncated"recorded for UI/debug); ladder restarts on that truncationWhy: symmetric evidence ≠ ownership (threat model above), and three days of production logs on this daemon's deployment (~11.5k anonymous resolutions, 2026-09-19 → 2026-09-22) showed 0 tail-window reattaches and 0 near-misses — the removed path had no observed users. Cost accepted: one raw resend + ladder restart per truncation, the same cost class instruction-drift forks already accept (#1106); opt-in block adoption (#629, raw-id SET semantics) still carries blocks whose sources remain fully present in the replay, and kernel reconciliation of truncated replays stays sound (deactivate/revive pinned in tests).
Full-prefix matching (the sound path) is untouched. Client-provided ids are untouched. No config schema, persistence format, or cross-repo dependency changes.
Coordination
TAIL_WINDOW) is superseded by this PR — the gate it tightened no longer exists; noted in that thread.messages[0]system prompt bakes into identity — asymmetric with other protocols).Pre-flight (on rebased head e28fdfa)
npm run typecheck— cleannpm test— 2245 pass / 0 fail / 2 skipped (E2E-gated)npm run build— successE2E (
tests/e2e/e2e-codex.test.ts) not run locally: it needs a live upstream reachable from this environment (E2E_UPSTREAM_URL); the change touches only the anonymous-resolution branch ofserver.tsand the resolver, both covered by the unit suites above. Happy to trigger the manual-dispatch CI E2E if desired.