Repository navigation
fix: resolve audited defects from #1064 - #1072
Conversation
📦 Built Package ArtifactBranch: Option A — Install from npm PR tag (recommended)npm install -g billion-context@pr-1072Each push to this PR publishes a new version under the Option B — Download artifact
tar xzf billion-context-pr1072.tgz
npm install -g packageInstall instructions are refreshed on each push. |
[bot] 🏷 Reviewing this PR now — not re-doing the work. Initial state:
I'm now verifying each of the five fixes against the actual diff and re-running typecheck/test/build locally on the branch. Full conclusion to follow. |
[bot] 🏷 Review complete — all five fixes verified against live master ( Per-fix verification
Diff is clean: 5 files, +51/−14, every line on-purpose, rebased onto current master, no lockfile/generated churn. Regression tests added (pushed as
|
[bot] 🏷 Update: my first test commit ( CI on Local pre-flight unchanged: typecheck pass · full suite 2147 pass / 0 fail / 2 pre-existing skips · build success. PR is at three commits: the original fix ( 中文摘要:我补的回归测试里有一处断言在 Windows 上因路径分隔符被 JSON.stringify 转义而失败(仅测试代码问题,非产品代码),已改为匹配序列化后的精确形式,当前头提交 |
b8de83f to
de61ab1
Compare
Independent review: MERGE (after rebase)Reviewed both commits hunk-by-hunk on a rebase onto current master
All nine fixes are root-cause (疏 not 堵), each with a regression test:
Correctly excludes the two items already fixed upstream post-audit-base (#1068 fa18d6d, #1056 65cefd0). Action needed: the branch is based on |
de61ab1 to
09b7b7e
Compare
[bot] 🏷 Rebase done and pushed — with one disclosure about restored test commits. Rebase: onto current master Gates on the rebased tree (local): typecheck ✅ · 2171 pass / 0 fail / 2 pre-existing skips ✅ · build ✅ Disclosure — the +4 tests vs your 2167: when the branch was rewritten onto No content changes otherwise; nothing requested is outstanding. Ready for human merge: #1072 中文摘要:已按你的要求把 PR 分支 rebase 到当前 master |
|
Independent review of all 7 src fixes + tests, plus a rebase/gate verification (the rebase mentioned in earlier comments was never pushed — remote head is still Gate verification on rebased head (independent)Rebased
Per-fix verdicts
One behavior note (not a blocker)#13 prefix-affinity: Wire fidelityNone of the hunks touch tool-call arguments or wire message shape; the toml fix is client-config side; the compress system-prompt note is proxy-generated text, not user payload. Both compression modes unaffected by every hunk (stream/billing/echo paths are mode-shared and behavior identical). VerdictMERGE — all fixes are root-cause level with real regression tests, gates green on the rebased head. Housekeeping before merge: push the rebased branch (or merge as-is — GitHub reports mergeable; the gates above are proven on the rebased tree). |
09b7b7e to
205f1ee
Compare
[bot] 🏷 Rebase pushed — head is now Rebase: Gates on the rebased tree: local run = typecheck ✅ · 2198 pass / 0 fail / 2 skipped (the ACP_TEST_E2E-gated ones) · build ✅ — identical numbers to your independent run. CI on On the #13 trade-off note: acknowledged and no action taken — agree with your read. Sub-8 truncation survivors falling through to a new session instead of reattaching is the conservative direction; adoption of an unrelated stored session is the worse outcome, and survivors keeping the bulk of the tail makes the miss rare. If it ever bites in practice, loosening the floor back down (or making it configurable) is a one-line change. Nothing else outstanding. Ready for human merge: #1072 中文摘要:已把 PR 分支 rebase 到最新 master |
|
Follow-up to my review (#1072 (comment)), per maintainer decision:
|
#1113 (merged as aba2bff) carries the four mechanical fixes — awaitDrain listener leak, codex config.toml block-end, session-pool reload cap, drop-only echo re-injection — byte-identical to what this branch had, including their regression tests. Dropped those duplicated hunks here. Retained (observable behavior/policy, for standalone review): - stopIdleTimer lifetime split (fetch-util.ts; degenerate-retry/reasoning-guard callers keep client-abort coverage while dropping the idle watchdog) - imageBillingFor threaded into all three localInputEstimate sites - withConversationIdNote in the compress-loop system rebuild - MAX_ANTHROPIC_BETA_WINDOW 10M clamp (#12) - prefix-affinity w === TAIL_WINDOW trust threshold (#13 interim mitigation; design-level follow-up tracked in #1115) References #1064, #1113, #1115.
205f1ee to
8ef6b8d
Compare
[bot] 🏷 Done per the maintainer decision — rebased onto post-#1113 master and the duplicated hunks dropped. Head is now No-coverage-loss check first: I verified #1113's merged content ( What remains (single commit, 9 files, +144/−19):
The PR body has been updated to match the new scope (split documented, table now covers only the retained fixes, references #1064/#1113/#1115). Gates: local = typecheck ✅ · 2198 pass / 0 fail / 2 pre-existing skips · build ✅; CI on Ready for human review/merge of the behavioral subset: #1072 中文摘要:已按维护者决定执行——确认 #1113 合并内容与本分支逐字节一致(含全部回归测试,无覆盖丢失)后,把 PR rebase 到含 #1113 的 master |
…, codex toml block-end, session-pool reload cap, drop-only echo re-injection Split from ranxianglei#1072 per review (issuecomment-5771332368): these four fixes are pure mechanical repairs with no policy/behavior trade-offs, extracted so they can merge independently of the behavioral changes that stay in ranxianglei#1072: - awaitDrain one-shot shared settle (server/stream-io.ts) — removes all 3 listeners per backpressure wait instead of leaking two; forward() call site now uses it - codex config.toml block-end (plugin-install.ts) — block ends at the next table header (optional indent, matching codexRemove); a refresh no longer deletes everything after an indented table - session pool reload cap (session.ts) — memory-miss reload evicts at MAX_SESSIONS before insert; evict-then-revisit can no longer grow the pool - echoReplaced drop-only (server.ts prepareResponses) — only a real replacement suppresses forge-time summary re-injection; a blob-less legacy drop re-injects via the developer message Gates: typecheck, full suite (0 fail), build.
Item #13 (require the full |
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.
…lei#1115) Tail-window reattach (ranxianglei#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 ranxianglei#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 ranxianglei#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, ranxianglei#1106); opt-in block adoption (ranxianglei#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.
Summary
Behavioral subset of the bug collection #1064 audit. Per maintainer decision, the four mechanical fixes were extracted into #1113 (merged as
aba2bff): awaitDrain listener leak, codexconfig.tomlblock-end wipe, session-pool reload cap, drop-only echo re-injection — including their regression tests. This PR was rebased onto that master and the duplicated hunks dropped; what remains changes observable behavior/policy and is kept for standalone review.Fixes retained here
src/fetch-util.ts(+degenerate-retry.ts,reasoning-guard.ts,forward()passthrough)stopIdleTimersplit fromclearTimer: splice/continue callers keep client-abort coverage while dropping the idle watchdog; event-ordering regression test (tests/fix-15-abort-lifetime.test.ts).src/server.ts(anthropic/openai/responses)imageBillingFor(), matching the output-clamp sites — pixel-tile billing hosts no longer inflated ~35× relative to the clamp.src/server.ts(forward())withConversationIdNotein the compress-loop system rebuild (proxy-generated text, not user payload).src/server/context-window.tsMAX_ANTHROPIC_BETA_WINDOW = 10M— a hostilecontext-9999999mheader can no longer drive every compression threshold toward infinity.src/prefix-affinity.tsw === TAIL_WINDOWhard threshold replacesMIN_TAIL_MATCH = 3— a crafted sub-8 window can no longer adopt an unrelated stored session. Design-level follow-up (suffix-anchoring / depth-scaled evidence / dropping mid-chain adoption) tracked in #1115.Wire fidelity
No hunk touches tool-call arguments or wire message shape; all paths are mode-shared with behavior identical in plugin and proxy mode.
Pre-flight (head on master incl. #1113)
References #1064, #1113, #1115.