Skip to content

[PR] fix(cache): make fold re-pay attribution (#3307 P2-A) work on the relay lane it was built for - #4751

Open
ranxianglei wants to merge 7 commits into
masterfrom
2026-10-25_fold-repay-evidence-slot
Open

ranxianglei wants to merge 7 commits into
masterfrom
2026-10-25_fold-repay-evidence-slot

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Closes #4731

What

#3307 P2-A (de193f4) added wire-measured fold attribution to recordCacheSample: when a big unexplained miss coincides with a pending fold, pair this request's outbound body against the previous settled one, take the byte-LCP, and min() the measured pre-fold prefix into firstFoldStartTokens so the re-pay credits the fold instead of falling into the unattributed seam bucket.

The block read its pending evidence straight off session.transient. But #4430 moved the relay-lane pending evidence into the per-request AsyncLocalStorage capture — noteForwardedBody/noteInboundMessages write via pendingCapture(session), which returns the ALS capture when one is active for this session. So on every wrapped lane the transient slot was always undefined and the compensation block silently never ran — exactly on its target lane (stateless proxy clients resending full history through the relay). The sibling reads #4430 migrated (detectSeam's sent/in slots, settleUsageReport's keyFp/effFp/slot) all use pendingCapture; these two lines were the only stragglers.

Fix

Two lines in src/cache-ledger.ts (recordCacheSample): read curB/curIn through pendingCapture(session) instead of session.transient. Both must move together: with only curB fixed, the clientBreak guard (#3023) would see an undefined curIn and be bypassed on wrapped lanes, mis-crediting client-side rewrites. The settled baselines (prevB/prevIn = settledBody/settledInBody) stay on transient by design — settleUsageReport moves them there.

Side effect (the issue's secondary risk, resolved by the same change): a mixed wrapped/unwrapped session can no longer pair a stale body left in transient by an earlier unwrapped call with the current usage — each settle now reads only its own scope's slot.

Behavior change (intended)

On ALL relay-driven traffic (streaming, loop rounds, non-streaming — runCompressLoop runs inside forwardCaptured, so loop rounds are wrapped too):

  • old: under the P2-A gate conditions (rawMissed > 8192 and > 0.3 × input, pending fold), fold re-pay was booked into the unattributed seam bucket because the correction never fired;
  • new: a genuine bili-side mid-history break attributes to the fold again (firstFoldStartTokens lowered to the wire-measured value); tail-appends and client-side inbound rewrites still do NOT credit the fold (guards unchanged).

Unwrapped lanes (plugin pipe) already worked and are byte-for-byte unchanged (pendingCapture falls back to session.transient there).

No billing or cache behavior changes — attribution/reporting only. No config surface touched.

Tests

New tests/issue4731-fold-attribution-relay-lane.test.ts mirrors the existing #3307 suite but drives each request cycle through its OWN withCacheCapture scope (exactly what relay.ts forward() does per request):

  • positive: wrapped-lane mid-history break credits the fold — fails pre-fix (verified by reverting the two lines), passes post-fix;
  • negative 1: client-side inbound rewrite still blocks the credit on the wrapped lane — pins that curIn comes from the same capture (a curB-only fix would fail this);
  • negative 2: pure tail-append is not credited on the wrapped lane.

Existing suites re-run green: issue3307-fold-attribution-wire, issue3307-seam-suspect-vs-client, cache-capture-pairing, cache-seam-detector, cache-ledger, issue2202-coverage-accrual (78/78). Typecheck clean.

…3307 P2-A works on wrapped lanes

#3307 P2-A measured the stable prefix off the wire inside recordCacheSample
by pairing this request's outbound body with the previous settled one. It
read both pending slots straight off session.transient, but #4430 moved the
relay-lane pending evidence into the per-request AsyncLocalStorage capture
(noteForwardedBody/noteInboundMessages write via pendingCapture). On every
wrapped lane - streaming, loop rounds, non-streaming - the transient slot
was always undefined, so the whole compensation block silently died exactly
on its target lane: stateless proxy clients resending full history kept
booking fold re-pay into the unattributed seam bucket.

Read curB/curIn through pendingCapture (same scope as their writers); the
settled baselines (prevB/prevIn) stay on transient by design. Reading both
together keeps the #3023 clientBreak guard effective on wrapped lanes.

Regression tests drive each request cycle through its own withCacheCapture
scope, mirroring relay.ts forward(); the positive case fails pre-fix.
@ranxianglei ranxianglei changed the title fix(cache): make fold re-pay attribution (#3307 P2-A) work on the relay lane it was built for [PR] fix(cache): make fold re-pay attribution (#3307 P2-A) work on the relay lane it was built for Oct 25, 2026
@github-actions

github-actions Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-25_fold-repay-evidence-slot (146e928)

Latest build — install this exact version

npm install -g billion-context@0.0.9436-pr.4751.21e0d04

This exact version is immutable and reproducible. The rolling pr tag tracks the newest test build across all PRs.

Recent builds (commit → version)

commit version build
146e928 billion-context@0.0.9436-pr.4751.21e0d04 build
13f7358 billion-context@0.0.9430-pr.4751.2f37c74 build
b21cb76 billion-context@0.0.9423-pr.4751.382d49f build
afff49b billion-context@0.0.5956-pr.4751.62eacd2 build
d59fbf1 billion-context@0.0.5901-pr.4751.ee945a6 build
2d7a674 billion-context@0.0.5833-pr.4751.a0e3cae build
603609d billion-context@0.0.5778-pr.4751.2b7b015 build

Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr4751.tgz
npm install -g package

Install instructions are refreshed on each push.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

查重:不重复。 按失败签名检索 open+closed issue/PR(#3307 P2-A 机制家族:recordCacheSample fold re-pay 归因、pendingCapture vs transient 证据槽),唯一命中是本 PR。本 PR 即 #4731 的修复,同机制家族无并行条目。

标签:bug, scope/wiring, p2(缺陷为真 bug——P2-A 补偿块在 relay 车道一直是死代码;改动位于请求管道/relay 捕获槽;严重度 p2=归因报表失真、有绕行、非缓存泄露、不影响计费)。

八问

  1. 是什么问题:[cache] Similar cache seams still detectable after #1548 / #1551 / #1554: v0.1.197, 21 samples / 1.14M tok | [cache] #1548 / #1551 / #1554 之后仍可测到同类缓存接缝:v0.1.197,21 样本 / 1.14M tok #3307 P2-A 加的 fold re-pay 归因(大 unexplained miss 与 pending fold 重合时,用 wire 字节 LCP 把重付成本记给 fold 而不是落进不可归因的 seam 桶)从 session.transient 读 pending 证据;[PR] fix(cache): pair overlapping forwards with their own request evidence #4430 把 relay 车道的 pending 证据搬进 per-request ALS 捕获(pendingCapture)后,该槽在每条 wrapped lane 上恒为 undefined——恰是目标车道(stateless proxy 客户端经 relay 重发全量历史)——补偿块从未运行,静默失效。
  2. 什么原因导致的:[PR] fix(cache): pair overlapping forwards with their own request evidence #4430 迁移时逐点改读 pendingCapture,漏了这两行(curB/curIn)。兄弟读取(detectSeam 的 sent/in 槽、settleUsageReport 的 keyFp/effFp/slot)全部已迁,这两行是唯一漏网。迁移遗漏,非设计缺陷。
  3. 影响范围与严重程度:所有 relay 驱动流量(streaming/loop 轮次/non-streaming——runCompressLoop 跑在 forwardCaptured 内,loop 轮次也被 wrap)。在 P2-A 门控条件(rawMissed>8192 且 >0.3×input 且存在 pending fold)下,fold 重付被记入不可归因 seam 桶。纯归因/报表失真:计费金额不变、缓存行为不变、无数据丢失;unwrapped 车道(plugin pipe)不受影响。
  4. 怎么修复的:两行改经 pendingCapture(session) 读取(有活跃 ALS 捕获取之,否则回退 session.transient——unwrapped 车道因此逐字节不变)。两行必须一起动:只修 curB 会让 clientBreak 守卫([Enhancement][cache-ledger] attribute client-side mid-history insertions to a client bucket — seam forensics currently blame bili for host churn (found in #2997) #3023)看到 undefined 的 curIn 而被绕过,把客户端侧改写误记给 fold。settled 基线(prevB/prevIn)按设计留在 transient(settleUsageReport 把它们移过去)。副作用解决:mixed wrapped/unwrapped 会话不再可能拿 transient 里早前 unwrapped 调用留下的陈旧 body 与当前 usage 配对——每次 settle 只读本作用域的槽。
  5. 是否有回归问题:逐项审了触碰路径的既有行为——① unwrapped 车道:pendingCapture 回退 transient(src/cache-ledger.ts:531),行为逐字节不变✓;② 配对时序:settleUsageReport 先调 recordCacheSample(L1860)再移动 pending→settled(L1922+),读取时刻 curB/curIn 仍在捕获内、prevB/prevIn 已在 transient,配对方向正确✓;③ clientBreak 守卫:语义未变,双输入要求使守卫在 wrapped 车道上从「被绕过」变为生效(属 bug 的一部分,非漂移)✓;④ tail-append 排除、mid-break 判定、min() 封顶:全部未动,仅证据来源变化✓;⑤ 无 fail-fast 变吞错、无阈值/时序/输出格式漂移,归因面 only,计费与缓存行为零变化✓。未发现回归。
  6. 是否破坏缓存:不涉及。不触碰任何缓存失效策略——只决定一次已测得的 miss 记入哪个归因桶。
  7. 是否改了设计方向:没有。仍是 [cache] Similar cache seams still detectable after #1548 / #1551 / #1554: v0.1.197, 21 samples / 1.14M tok | [cache] #1548 / #1551 / #1554 之后仍可测到同类缓存接缝:v0.1.197,21 样本 / 1.14M tok #3307 P2-A 框架(wire 测量 + min() 封顶 + 双守卫),只是把证据槽放回 [PR] fix(cache): pair overlapping forwards with their own request evidence #4430 之后它本应在的作用域。
  8. 是否引入新配置:没有。

测试有效性

新套件让每个请求周期走自己的 withCacheCapture 作用域(正是 relay.ts forward() 每请求所做的事),三个测试都有牙:

  • 正向(mid-history break 记给 fold):本地实测 pre-fix(master bb7c249)红、post-fix 绿——我独立复现,确认测试钉住本 bug;
  • 负一(client 侧 inbound rewrite 仍拦截记账):钉住 curIn 来自同一捕获——curB-only 修法会挂此测试,两行耦合被钉死;
  • 负二(纯 tail-append 不记账):钉住 lcp.msgIndex < lcp.prevMsgs 门。
    非假测试:断言有牙,bug 回归时抓得住。

本地验证(定向,未跑全量)

  • PR 分支(603609d):新套件 3/3 绿;六个兄弟套件(issue3307-fold-attribution-wire、issue3307-seam-suspect-vs-client、cache-capture-pairing、cache-seam-detector、cache-ledger、issue2202-coverage-accrual)合计 75/75 绿(+3 新 = 78,与 PR 描述一致);typecheck clean。
  • pre-fix 基线(master bb7c249 + 本测试文件):正向红、两个负向平凡绿(block 整体死)——与 PR 声明一致。

CI 状态与已执行动作(请注意)

判定

代码审查通过:根因定位准确、修法最小(两行 + 注释)、测试双向钉住机制、无回归、无配置面变更。待新 head 2d7a674 的 CI 全绿即可合并(预期由 ci-fixes 覆盖在册簇;若残留红,继续走 #4599 跟踪,不另开 issue)。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

收工摘要(完整八问审查见上一条回复):

  1. 审查结论:通过。两行修法(curB/curIn 改经 pendingCapture)根因定位准确、最小、无回归、无配置面变更;测试双向有牙——正向用例我独立复现了 pre-fix(master bb7c249)红 / post-fix 绿,六个兄弟套件 75/75,typecheck clean。
  2. 已执行动作:标签已打(bug/scope/wiring/p2);原 head 的 5 个红分片全部落在 master 自身 born-red 簇(与本 PR diff 零交集),已把 ci-fixes(081206e)merge 进分支并推送,新 head 2d7a674,CI Control Center: Centralized CI Failure Handling & Status Sync (Comment all CI issues here; do not open new issues) | CI 总控: CI 失败集中处理与状态同步(所有 CI 问题在此评论, 勿开新 issue) #4599 留有记录。
  3. 当前卡点:新 head 的 CI 重跑陷入连环顶替——约每 4–6 分钟一个新的 queued run 顶掉前一个(五个 run id 已列在 CI Control Center: Centralized CI Failure Handling & Status Sync (Comment all CI issues here; do not open new issues) | CI 总控: CI 失败集中处理与状态同步(所有 CI 问题在此评论, 勿开新 issue) #4599),没有任何一次真正起跑,必需检查出不了判定。已在 CI Control Center: Centralized CI Failure Handling & Status Sync (Comment all CI issues here; do not open new issues) | CI 总控: CI 失败集中处理与状态同步(所有 CI 问题在此评论, 勿开新 issue) #4599 升级请哨兵/owner 确认是否有自动化在周期性重触发该 commit。
  4. 判定不变:代码侧可合;等 2d7a674 上第一次真实跑完的 CI 全绿即可由你合并。若残留红,按 CI Control Center: Centralized CI Failure Handling & Status Sync (Comment all CI issues here; do not open new issues) | CI 总控: CI 失败集中处理与状态同步(所有 CI 问题在此评论, 勿开新 issue) #4599 协议跟踪,不另开 issue。

ci-check added 2 commits October 26, 2026 10:15
…onflict resolution)

Resolves the single conflict in src/cache-ledger.ts: master already landed a
cleaner #4731 fix (e253a29) that reads the pending evidence pair through the
pendingEvidencePair helper. Take master's version for the conflicting hunk so the
canonical fix wins; this PR's net contribution is now its regression test
tests/issue4731-fold-attribution-relay-lane.test.ts (relay-lane fold attribution,
#3023 client-rewrite guard, tail-append negative), which passes alongside
master's issue4731-cache-capture-pair.test.ts (8/8).
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

Conflict resolved and pushed. PR #4751 was dirty against master. I merged origin/master into the PR branch 2026-10-25_fold-repay-evidence-slot, resolved the single conflict, and pushed (afff49b331..b21cb76847, a normal merge push — no force). The PR is now mergeable (no conflicts; mergeable_state: blocked just means awaiting review).

What the conflict actually was. Master already landed a cleaner fix for the same issue #4731 — commit e253a29d55 ("read the wire fold-attribution pair from the ALS capture on the relay lane"), which reads the pending evidence through a pendingEvidencePair() helper. The PR's own fix (603609d41c) solved the same bug the same way but read the two slots inline via pendingCapture(). Both sides of the conflict were the same fix; master's is the canonical, cleaner one (it centralizes the "both sides from ONE source" invariant in a helper, which is exactly the #3023 mis-pair guard).

Resolution. I took master's version for the conflicting hunk in src/cache-ledger.ts, so the canonical fix wins (git diff upstream/master -- src/cache-ledger.ts is now empty). The PR's net contribution against master is now just its regression test tests/issue4731-fold-attribution-relay-lane.test.ts (relay-lane fold attribution, the #3023 client-rewrite guard, and a tail-append negative). I verified both #4731 test files pass together against the merged code: 8/8 (master's issue4731-cache-capture-pair.test.ts 5 + this PR's 3).

Disposition note (your call). Since master already fixed #4731 more completely — its issue4731-cache-capture-pair.test.ts is a superset except for this PR's tail-append negative case — this PR is effectively now "add one extra regression test." You can merge it for the added coverage or close it as redundant. I did not close it (agents don't close issues/PRs).


结构化八问:

  1. 是什么问题:PR [PR] fix(cache): make fold re-pay attribution (#3307 P2-A) work on the relay lane it was built for #4751 与 master 冲突(merge state dirty),无法合并。
  2. 什么原因导致的:master 已用更干净的方案(pendingEvidencePair helper,commit e253a29d55)修了同一个 Fold re-pay attribution fix (#3307) reads the wrong evidence slot — completely dead on the relay lane it was built for #4731;PR 自己的修复(603609d41c)用 pendingCapture 内联读两个 slot。两边改的是同一处代码、同一个 bug——本质是重复修复,PR 是后到的旧版,产生文本冲突。
  3. 影响范围与严重程度:仅 src/cache-ledger.ts 一处 hunk 冲突;不修则 PR 阻塞无法合并。代码行为无影响——两边修复行为等价,master 版更优。
  4. 怎么修复的:merge origin/master 进 PR 分支;冲突 hunk 取 master 版(规范修复胜出);保留 PR 新增的测试文件;普通 push(merge,非 force)。
  5. 是否有回归问题:无。取 master 版后该文件与 master 字节一致;两个 Fold re-pay attribution fix (#3307) reads the wrong evidence slot — completely dead on the relay lane it was built for #4731 测试文件合并后 8/8 通过(含 [Enhancement][cache-ledger] attribute client-side mid-history insertions to a client bucket — seam forensics currently blame bili for host churn (found in #2997) #3023 client-rewrite 守卫、tail-append 负例)。
  6. 是否破坏缓存:不涉及(纯归因/报告逻辑,无缓存/重试/增量游标/去重键变更)。
  7. 是否改了设计方向:不涉及(沿用 master 既定的 pendingEvidencePair 设计,未引入新方向)。
  8. 是否引入了新的配置:不涉及(无新 env/config/默认值)。

判定:冲突已解决并推送,PR 现可合并(mergeable, 待 review)。因 master 已更完整修复 #4731,此 PR 现仅剩一个额外回归测试,建议 owner 决定合并(补测试)或关闭(重复)。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[ework] CI fix verified green ✓

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

This re-trigger was stale — the conflict was already resolved in my previous run. I verified the live state first: the PR was mergeable: True with mergeable_state: behind (NOT dirty). There was no merge conflict; master had simply advanced 18 commits (all docs / Japanese-translation from #6076 / #6072) since my last merge.

What I did this run: brought the PR fully up to date so the "behind" state is cleared and the blocker can't re-fire.

  • Fetched origin/master (now dd0ef22aea) and the PR branch head (still b21cb76847, no concurrent work).
  • Confirmed the 18 new master commits are docs-only and touch none of the PR's files (src/cache-ledger.ts / tests/issue4731-fold-attribution-relay-lane.test.ts).
  • Merged origin/master into the branch — clean, no conflict (13f735862e).
  • Pushed b21cb76847..13f735862e (normal merge push, no force).

Live state after push: head_sha 13f735862e, base_sha dd0ef22aea (== current master head), mergeable: True, mergeable_state: blocked (awaiting review — not a conflict, not behind). The PR's net contribution against master is unchanged: just the regression test tests/issue4731-fold-attribution-relay-lane.test.ts (master already fixed #4731 more completely via pendingEvidencePair, commit e253a29d55). Disposition (merge for the extra test, or close as redundant) is still yours.


结构化八问:

  1. 是什么问题:系统再次报 PR [PR] fix(cache): make fold re-pay attribution (#3307 P2-A) work on the relay lane it was built for #4751 与 master 冲突(dirty),需解冲突。
  2. 什么原因导致的:实为陈旧触发——上一轮已解掉冲突;本轮 live 状态是 mergeable: True + behind(非 dirty),只是 master 又前进了 18 个提交(全是 [PR] docs: add Japanese versions of repository documentation (#6072) #6076/All repository documentation is available in Japanese. | 仓库所有文档都提供日文版本 #6072 的文档/日文翻译)。
  3. 影响范围与严重程度:无冲突、无代码影响;仅 PR 落后 master 18 个文档提交(非阻塞,但会反复触发告警)。
  4. 怎么修复的:fetch 最新 master → 确认 18 个新提交均为 docs、不碰 PR 文件 → merge 进 PR 分支(干净无冲突)→ 普通 push。
  5. 是否有回归问题:无。干净 merge,src/cache-ledger.ts 仍与 master 字节一致;PR 贡献仍仅一个测试文件;未触碰任何逻辑。
  6. 是否破坏缓存:不涉及(纯 merge 同步,无缓存/重试/游标/去重键变更)。
  7. 是否改了设计方向:不涉及。
  8. 是否引入了新的配置:不涉及。

判定:冲突早已解决(上一轮);本轮把 PR 同步到最新 master,现已 mergeable 且不再 behind,阻塞清除。PR 现仅剩一个额外回归测试,合并/关闭由 owner 定。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[ework] CI fix verified green ✓

…suite

The #4731 source fix (fold re-pay attribution reading the #4430 ALS capture
on the relay lane) is already on master (e253a29) with its own regression
suite (issue4731-cache-capture-pair.test.ts). This file's positive
mid-history-break and #3023 client-rewrite cases are strict subsets of that
suite's; only the tail-append guard on the wrapped lane is new here. Drop the
two near-duplicates and the now-unused CoreMessage/noteInboundMessages imports.

@ranxianglei ranxianglei left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(ai: vllm-qwen/qwen3.8-27b)

Verdict: APPROVE — the PR is now a clean, minimal, test-only addition.

Key finding: the source fix is already on master

The fix this PR describes (fold re-pay attribution reading the #4430 ALS capture on the relay lane) was already merged to master by a parallel agent as e253a29d55 ("fix(cache-ledger): read the wire fold-attribution pair from the ALS capture on the relay lane (#4731)"), and issue #4731 is closed.

After this branch merged master (13f735862), the PR's source diff is empty — src/cache-ledger.ts is byte-identical to master. The only remaining diff is the regression test file tests/issue4731-fold-attribution-relay-lane.test.ts.

What I did (fix on the spot)

The test file's 3 cases were 2/3 duplicate of master's existing tests/issue4731-cache-capture-pair.test.ts:

  • the positive mid-history-break case — a strict subset of master's test 1 (master's also asserts cr > 0 + the transient sanity);
  • the #3023 client-rewrite negative — a strict subset of master's test 2 (master's also asserts clientInserts === 1);
  • the tail-append guard on the wrapped lane — unique (master's relay-lane suite has no tail-append; the loop-lane twin lives in issue3307-fold-attribution-wire.test.ts).

已顺手修:trimmed the test file to the one unique tail-append guard (dropped the two near-duplicates + the now-unused CoreMessage/noteInboundMessages imports) + commit 146e928

Verified at the new head: all 9 tests green (the trimmed file + master's 5 capture-pair + 3 wire tests); typecheck clean. The positive case has teeth — reverting the pendingEvidencePair read back to session.transient?.sentBody makes it fail.

8问

  1. 是什么问题:#3307 P2-A 的折叠 re-pay 归因在 relay 车道上失效——recordCacheSample 读的是 session.transient?.sentBody,但 #4430 已把 relay 车道的 pending 证据挪进 ALS capture,该槽位在 wrapped 车道恒为 undefined,整个补偿块在目标车道上死掉,re-pay 一直记进未归因 seam 桶。
  2. 什么原因导致的:#4430 把 relay 车道证据迁移进 ALS 后,#3307 的归因块没跟着改读路径,仍直读 transient(curB/curIn 同病)。
  3. 影响范围与严重程度:仅 relay(wrapped)车道——无状态代理客户端重发全量历史的场景。属观测/归因精度问题(acp_cache 折叠经济学失真),不影响压缩正确性,p2 级体验/观测瑕疵。
  4. 怎么修复的:新增 pendingEvidencePair(session) 访问器,从单一来源(ALS capture 活跃取 capture,否则 transient)同时取 {sentBody, inBody};curB/curIn 必须一起改(只改 curB 会在 wrapped 车道旁路 #3023 clientBreak 守卫);prevB/prevIn 留在 transient(settled 基线住那里)。
  5. 是否有回归问题:无。loop 车道(不走 ALS)行为字节级不变;stale transient body 不再误配对;#3023 client-rewrite 守卫在 wrapped 车道仍生效——master 的 issue4731-cache-capture-pair.test.ts 5 个 case 全部钉住。
  6. 是否破坏缓存:不涉及。只改归因读取来源,不动缓存键/重试/增量游标/去重键。
  7. 是否改了设计方向:不涉及。只是把归因块的证据读取对齐到 #4430 的 capture 架构,无转向。
  8. 是否引入了新的配置:不涉及。

Note: the PR body's "Fix"/"Behavior change" sections are now partially stale (the fix already shipped via e253a29d55), but the described behavior is correct and verified. Safe to merge — it only adds the one unique regression test.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 PR #4751 review — done. Verdict: APPROVE (posted as a review comment; see PR thread).

Key finding — the source fix is already on master. The fix this PR describes (fold re-pay attribution reading the #4430 ALS capture on the relay lane) was already merged by a parallel agent as e253a29d55, and issue #4731 is closed. After the branch merged master, the PR's source diff is empty — src/cache-ledger.ts is byte-identical to master. The only remaining diff was the regression test file.

Fix on the spot: the test file's 3 cases were 2/3 duplicate of master's existing tests/issue4731-cache-capture-pair.test.ts (the positive mid-history-break and the #3023 client-rewrite negative are strict subsets of master's, which assert more). Only the tail-append guard on the wrapped lane was unique. Trimmed the file to that one test, dropped the two near-duplicates + the now-unused CoreMessage/noteInboundMessages imports. Verified 9/9 green + typecheck clean at the new head; the positive case has teeth (reverting the pendingEvidencePair read to session.transient?.sentBody makes it fail). Pushed commit 146e928 to the branch.

已顺手修:trimmed the test file to the one unique tail-append guard + commit 146e928

Review posting note: a formal APPROVE is rejected by GitHub with "Can not approve your own pull request" (the PR is authored by the same ranxianglei account the bot posts as), so the full review went up as a COMMENT review with the verdict stated up front: #4751 (review)

PR state: head 146e928; mergeable_state moved from blocked (awaiting review) to behind (master advanced again after the conflict-rebase) — not a review blocker. Safe to merge: it now only adds one unique regression test.

8问

  1. 是什么问题:[cache] Similar cache seams still detectable after #1548 / #1551 / #1554: v0.1.197, 21 samples / 1.14M tok | [cache] #1548 / #1551 / #1554 之后仍可测到同类缓存接缝:v0.1.197,21 样本 / 1.14M tok #3307 P2-A 的折叠 re-pay 归因在 relay 车道上失效——recordCacheSample 读的是 session.transient?.sentBody,但 [PR] fix(cache): pair overlapping forwards with their own request evidence #4430 已把 relay 车道的 pending 证据挪进 ALS capture,该槽位在 wrapped 车道恒为 undefined,整个补偿块在目标车道上死掉,re-pay 一直记进未归因 seam 桶。
  2. 什么原因导致的:[PR] fix(cache): pair overlapping forwards with their own request evidence #4430 把 relay 车道证据迁移进 ALS 后,[cache] Similar cache seams still detectable after #1548 / #1551 / #1554: v0.1.197, 21 samples / 1.14M tok | [cache] #1548 / #1551 / #1554 之后仍可测到同类缓存接缝:v0.1.197,21 样本 / 1.14M tok #3307 的归因块没跟着改读路径,仍直读 transient(curB/curIn 同病)。
  3. 影响范围与严重程度:仅 relay(wrapped)车道——无状态代理客户端重发全量历史的场景。属观测/归因精度问题(acp_cache 折叠经济学失真),不影响压缩正确性,p2 级体验/观测瑕疵。
  4. 怎么修复的:新增 pendingEvidencePair(session) 访问器,从单一来源(ALS capture 活跃取 capture,否则 transient)同时取 {sentBody, inBody};curB/curIn 必须一起改(只改 curB 会在 wrapped 车道旁路 [Enhancement][cache-ledger] attribute client-side mid-history insertions to a client bucket — seam forensics currently blame bili for host churn (found in #2997) #3023 clientBreak 守卫);prevB/prevIn 留在 transient(settled 基线住那里)。
  5. 是否有回归问题:无。loop 车道(不走 ALS)行为字节级不变;stale transient body 不再误配对;[Enhancement][cache-ledger] attribute client-side mid-history insertions to a client bucket — seam forensics currently blame bili for host churn (found in #2997) #3023 client-rewrite 守卫在 wrapped 车道仍生效——master 的 issue4731-cache-capture-pair.test.ts 5 个 case 全部钉住。
  6. 是否破坏缓存:不涉及。只改归因读取来源,不动缓存键/重试/增量游标/去重键。
  7. 是否改了设计方向:不涉及。只是把归因块的证据读取对齐到 [PR] fix(cache): pair overlapping forwards with their own request evidence #4430 的 capture 架构,无转向。
  8. 是否引入了新的配置:不涉及。

Coordination issue: I searched open issues/PRs for a review-lane coordination hub and couldn't identify a specific one with confidence — the only coordination hub named in AGENTS.md is #4599 (CI 总控), which is for CI failures (this PR's CI is green), not review status. Point me at the exact coordination issue number and I'll post the one-line report there.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working p2 scope/wiring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fold re-pay attribution fix (#3307) reads the wrong evidence slot — completely dead on the relay lane it was built for

1 participant