Repository navigation
Conversation
…anxianglei#5952) The relay settle read the shared prepare slot, which records text + image reserve under a TextEstimate name, so image-bearing usage trained the text-only multiplier and a concurrent request could overwrite the estimate a settle read. Note the final wire estimate and image reserve per request at the send chokepoint, settle from that pair, skip image-bearing samples, and only apply a factor whose ring is entirely text-only.
(ai: vllm-qwen/qwen3.8-27b) 查重:不重复,但 issue 链接填错。 检索 open+closed,无其他针对「校准乘数被图片用量污染」的在途 PR/issue,本 PR 是唯一校准修复。但 PR 正文与 commit 都写 标签判定: bug / scope/wiring / p2(校准乘数污染是真实机制缺陷,影响限于上下文估算精度,非可用性;loop/plugin 车道回归见第 5 问)。镜像 label API 未实现,在此报备。 结构化八问
收工判定:不可按现状合并
代码本身质量高(每请求 capture 对、provenance 戳、持久化向后兼容、并发竞态测试都有),方向对了就能用;卡点是 issue 链接 + loop/plugin 回归确认。 |
[bot] 重启后已完成 PR #6545 审核,完整八问结论见上一条评论。核心两点:
代码质量本身没问题(每请求 capture 对 + provenance 戳 + 持久化向后兼容 + 并发测试齐全),方向对了就能用,卡点是上面两点。PR 分支落后 master,合并前需 rebase。 |
[bot] 🏷 Conflict resolution: done and verified locally; delivery is blocked on the fork head. What I did this run:
The blocker:
How to land the resolved conflict (options + recommendation):
Note: the earlier review (floor 9) flagged two separate open items that are not part of conflict resolution and remain for the owner — (1) the PR body's |
(ai: vllm-qwen/qwen3.8-27b) Conflict resolved — PR #6545 is now 1. What was the problem? 2. What did I do? 3. How were the conflicts resolved? 4. How was it verified (targeted, local)? 5. How did it land? 6. Current state (verified live this run): 7. Open items (owner's, not mine): No new issues opened, no PR-body edits, no force-push. |
[ework] CI fix verified green ✓ |
ranxianglei
left a comment
There was a problem hiding this comment.
APPROVE — clean, correct fix for #5952 (image usage contaminating text calibration; concurrent settlement reading shared prepare facts).
The fix (verified against #5952's mechanism):
- Per-request capture pair:
noteCalibrationPair(src/cache-ledger.ts:872) stores the final wire estimate + image tokens + origin + model in the request's AsyncLocalStorage capture; the relay main-lane send chokepoint (src/server/relay.ts:1193) calls it withest.textOverhead,upstreamUrl, and the sent model. - Image exclusion:
ingestCalibrationPair(src/cache-ledger.ts,ingestCalibrationPair) returns early if the capture pair hasimageTokens > 0— image samples never train the text multiplier. - Strict gate:
currentCalibrationFactor(src/util.ts:156) now requires thetext-only-v1stamp; legacy (no-stamp) factors are inert.
Both prior "blocking items" are false alarms (verified independently against GitHub, not the mirror namespace):
- "Issue link wrong" — FALSE. GitHub issue #5952 is titled "[Bug][DSH] Image usage contaminates text calibration; concurrent settlement reads shared prepare facts (0.1.212)" — exactly what this PR fixes. Its body describes the same mechanism (
ingestCalibrationPairtraining from the sharedlastLocalTextEstimateslot with an image reserve;currentCalibrationFactoraccepting legacy multipliers without text-only provenance), and its "Narrow local mitigation" section is this PR's fix. The "502 retryability question" the PR defers is genuinely in #5952 (the "Related deterministic-error issue" section). SoFixes #5952is correct. Prior reviews resolved#5952against the mirror namespace, not GitHub. - "loop/plugin regression" — FALSE.
currentCalibrationFactoris consumed only in the relay/proxy lane (src/server/relay.ts:1180, src/server/prepare-google.ts:403, src/server/prepare-responses.ts:655, src/server/prepare-openai.ts:589, src/server.ts:3936, src/server/preflight.ts:1775). The loop lane (src/loop/core.ts:538) and plugin lane (src/plugin.ts:2708) callsettleUsageReportbut do NOT consume the multiplier (nocurrentCalibrationFactor/preflightCompresscalls). Sessions are mode-sticky (KDD #7), so there's no cross-lane sharing. Making the loop/plugin settle emit an inert (no-provenance) estimate changes no observable behavior — the multiplier was never applied on those lanes, before or after.
Behavior change (disclosed, deliberate):
- Old:
currentCalibrationFactorapplied a factor on route+model match (no provenance check). - New: it also requires the
text-only-v1stamp; legacy (no-stamp) factors are inert until re-trained within two fresh text-only settles. - Why: to prevent stale mixed-modal multipliers (trained from image-contaminated samples) from rejecting fitting payloads. This is the core of the fix.
- Impact: after upgrading, the relay lane's calibration factor is inert until re-trained (self-healing). Affects only the relay lane (the sole consumer of the multiplier).
Tests (8 cases, real teeth): image exclusion, per-request pair (not shared slot), interleaved concurrency, strict gate (both directions), incident repro (stale k̂=4 no-provenance doesn't reject a fitting 262144-window payload), proven factor still decides, overflow provenance inheritance, reload round-trip. Uses the real functions (settleUsageReport, settleOverflowCalibration, noteCalibrationPair, withCacheCapture, preflightCompress, currentCalibrationFactor). Modified tests correctly add the text-only-v1 stamp to seeded factors so the strict gate doesn't inert them.
Risks: no security surface; persistence backward-compatible (legacy files restore unchanged, new fields additive); no kernel/ files touched. CI green (30 checks, 0 failed).
8问
- 是什么问题: 图片用量污染了文本校准乘数,并发结算还会读到别的请求的 prepare 事实;陈旧的多模态乘数在模型切换后误拒本可放入窗口的 payload。
- 什么原因导致的:
ingestCalibrationPair从共享的lastLocalTextEstimate(含图片预留)训练,且currentCalibrationFactor接受无 text-only 来源戳的陈旧乘数。 - 影响范围与严重程度: 仅 relay(代理)车道(乘数的唯一消费者);特定条件——升级后前两次纯文本 settle 之前,校准乘数暂时失效(自愈);体验瑕疵级,非可用性缺陷。
- 怎么修复的: 在请求的 AsyncLocalStorage capture 里记录最终 wire 估计+图片 token+origin+model;图片样本永不训练;
currentCalibrationFactor强制要求 text-only-v1 来源戳(无戳/未知戳失效,两次纯文本 settle 内重训练)。 - 是否有回归问题: 审过 relay/loop/plugin 三条车道的既有行为——relay 纯文本校准保持(带戳),图片样本不再污染(修复目标);loop/plugin 车道不消费乘数(无 preflight),清空其 factor 无观测行为变化;持久化向后兼容(旧文件原样恢复,新字段增量)。无回归。
- 是否破坏缓存: 不涉及 prompt cache;校准 ring 的 provenance 与 values 同步推进,不破坏任何缓存/游标/去重键。
- 是否改了设计方向: 否。校准输入来源从「共享 prepare 统计」改为「per-request capture」,是修复而非转向;不触碰内容投影/图片变换/fold 协调/模型窗口/溢出保护。
- 是否引入了新的配置: 否。无新 env/config/默认值。
判定: APPROVE — 修复正确、测试有牙、CI 绿(30 checks 0 failed)、无 kernel 变更、两个先前「阻塞项」均为误报(已独立核实)。
[ework] CI fix verified green ✓ |
[bot] 🏷 PR #6545 review complete — APPROVED (GitHub review id 5941121874, submitted 2026-11-17T15:14:15Z). What I did:
Key findings:
No small findings to fix on spot — the one double-normalize in Coordination issue: I could not identify the coordination issue number from the task prompt or searches (tried "coordination", "review lane", "CI 总控 4599", "review 总控", "PR review 协调" — no match). The full review is posted on the PR thread itself. If the coordination issue is a specific known issue, point me to it and I'll add the one-line report. |
…on persist conflicts (r3) Union resolution of the two calibration-provenance facets that master and the PR both added to the same persist surface: master's per-model ring key (calibratedEstimateModel / calibrationRing.model, ranxianglei#2141) and the PR's text-only provenance stamp (calibratedEstimateProvenance / calibrationRing.provenances, ranxianglei#5952). restoreCalibrationRing keeps the PR's aligned (value, provenance) filter/slice and re-adds master's model restore; buildSession restores both fields. storage-render goldens regenerated from the merged tree; persist-calibration-model fixture stamped text-only-v1 (same pattern the PR applied to its four sibling calibration tests) so its seeded factor is valid under the PR's strict provenance gate.
(ai: vllm-qwen/qwen3.8-27b) Conflict resolved and pushed — final head What happened: master and this PR both extended the same calibration-persist surface on the same lines — master added the per-model ring key ( Resolution (union — both facets keep working, the auto-merged
Local verification on the merged head: typecheck clean, build clean; targeted suites green — golden-storage-render 5/5, calibration suites 64/64 (incl. issue5952 + persist-calibration-model), cache-ledger 54/54, persist-* 86/89. The 3 CI status (mirror cache, live this run): head 八问
判定:冲突已解,最终 head 已推(未带 ci-held 标记,即本分支唯一一次全量 CI);等 shards 跑完即绿,CI 结果以远程为准。 |
(ai: vllm-qwen/qwen3.8-27b) This wake carried a stale blocker — the conflict was already resolved in my previous run minutes ago. Live-verified in this run, nothing left to do on this lane. Live state verified this run (not from memory):
So: conflict resolved, CI green, no 八问(本轮无新改动,均为对上一轮交付的在位复核)
判定:冲突已解、CI 全绿、head 无 ci-held 标记;本车道无事可做,等人工 review/merge。 |
ranxianglei
left a comment
There was a problem hiding this comment.
(APPROVE — re-review after merge commit 5c5f75048)
What changed since the first review (head 7280566dd → 5c5f75048): a single merge commit 5c5f75048 ("Merge origin/master into PR #6545 head — resolve calibration persist conflicts (r3)") merged master a446a3c1 into the PR branch. It brought in 144 files of master's other work. The PR's own source changes are byte-identical to the first review (per-file line counts unchanged: cache-ledger +64/-7, persist +22/-7, relay +12/-1, session +20/-2, util +17/-2). No kernel/ files. The only new PR-side artifact is tests/persist-calibration-model.test.ts (+82).
The critical part — the union conflict resolution. Master's per-model ring key (calibratedEstimateModel / calibrationRing.model, #2141) and this PR's text-only provenance stamp (calibratedEstimateProvenance / calibrationRing.provenances, #5952) both touched the same persist surface, so the merge had to union them. I verified the union is clean and non-losing:
src/persist.ts— thecalibrationRingpersisted type now carries bothmodel?: string(master) andprovenances?: (string|undefined)[](PR).restoreCalibrationRingkeeps the PR's aligned(value, provenance)filter/slice (in-band filter → slice to window → provenance mapped in lockstep, counting only exacttext-only-v1) and re-adds master'smodelrestore (a single value for the whole ring, restored independently since the ring is per-model).buildSessionrestores bothcalibratedEstimateModel(master) andcalibratedEstimateProvenance(PR, exacttext-only-v1match only). No facet was dropped.src/util.ts:156-160—currentCalibrationFactornow checks both gates in the correct order: (1) finite-number check oncalibratedEstimate, (2) the PR's strict provenance gateif (stats.calibratedEstimateProvenance !== CALIBRATION_PROVENANCE_TEXT_ONLY) return undefined;, (3) master's model matchif (stats.calibratedEstimateModel !== undefined && typeof lastModel === "string" && lastModel !== "" && stats.calibratedEstimateModel !== lastModel) return undefined;. A factor only applies when it is text-only-provenanced and (if model-stamped) matches the current model. Correct composition of the two facets.src/session.ts—Sessiontype carries bothcalibratedEstimateProvenance?andcalibrationRing.provenances?(PR) alongside master'scalibratedEstimateModel?;resetSessionCompressionclears the provenance field. Consistent.
New test tests/persist-calibration-model.test.ts (+82) — good teeth. It verifies: (a) provenance survives cold load in both legacy and full modes, with and without a model stamp; (b) a known-model factor does not cross a model switch (the model gate in currentCalibrationFactor), while an unknown/legacy model retains existing behavior; (c) invalid persisted model values (123, " ", {}, null) are rejected on restore. The fixture is stamped text-only-v1 (the same pattern the PR applied to its four sibling calibration tests) so its seeded factor is valid under the strict provenance gate. This is exactly the coverage the union resolution needs.
Master's changes merged in (not PR regressions). The merge brought in master's own work, including two src/cache-ledger.ts changes: (1) messagesArrayCloseOffset perf (hop-to-next-quote instead of byte-by-byte scan) and (2) settleUsageReport's curLine.bs classification changed from an impossible range (calibratedEstimate >= 1.0001 && calibratedEstimate <= 0.9999 — no finite value satisfies both, so it never classified "calibrated") to a finite-number check. That second one is a master-side bug fix (the old predicate was dead), not something this PR introduced — flagging it only so the record shows I read it and it is master's, not a behavior drift from this PR.
Behavior change (carried from the first review, still accurate). currentCalibrationFactor old → new: OLD applied a factor on route+model match with no provenance check; NEW additionally requires the text-only-v1 stamp (and, per master's #2141, a model match when the factor is model-stamped). Legacy (un-stamped) factors are inert until re-trained by two fresh text-only settles. Affects only the relay/proxy lane (the sole consumer of the multiplier; loop/plugin lanes call settleUsageReport but never consume the factor — verified in the first review). Self-healing. Disclosed in the PR body.
Tests. The PR's own 8-case suite (tests/issue5952-image-calibration-contamination.test.ts) plus the new cold-load suite (tests/persist-calibration-model.test.ts) cover both directions of every gate (image never trains / text-only trains; no-provenance inert / text-only applies; cross-model isolation; persistence round-trip). Modified sibling tests correctly stamp text-only-v1 so the strict gate doesn't inert their seeded factors. Real teeth throughout.
Risks. No security surface. Persistence is backward-compatible (legacy files keep their exact restored shape; the new fields are additive and only honored on exact text-only-v1 match). No data loss. The union resolution is non-losing (both facets survive). No kernel/ files → the kernel-authorization hard rule does not apply.
CI. At review time the mirror cache shows 12 test lanes still in_progress (0 failed, 3 ok, 15 skipped) — the merge commit re-triggered the full matrix, so the "green" state in the trigger is from the pre-merge head. The code is verified correct by inspection; the final green is the CI run on 5c5f75048, which is in flight. No findings block the merge.
Verdict: APPROVE. The merge is a clean, non-losing union of master's per-model ring key and the PR's text-only provenance stamp; the PR's own fix is unchanged from the first review; the new cold-load test pins the union. No small findings to fix on spot (the union is already correct; master's settleUsageReport fix is master's, not this PR's to touch).
8问(中文,供人工复审):
- 是什么问题:图片用量会污染文本校准乘数;并发结算时会读到共享的 prepare 事实(共享槽里的 image reserve),导致文本校准被图片样本带偏。
- 什么原因导致的:结算走共享槽(而非每请求私有对),且旧
currentCalibrationFactor不校验 provenance,任何(含图片污染的)乘数都会被应用。 - 影响范围与严重程度:仅 relay/proxy 车道(乘数唯一消费方);loop/plugin 车道只调
settleUsageReport不消费乘数,不受影响。特定条件下有问题(有图片 + 有文本校准),非全局不可用。 - 怎么修复的:每请求私有对(AsyncLocalStorage
Capture.calibration)替代共享槽;图片样本永不训练(imageTokens>0 早退);currentCalibrationFactor加严格 provenance 门(仅text-only-v1生效);ring 的 provenances 与 values 锁步。 - 是否有回归问题:审过既有行为——乘数消费路径(relay/prepare-*/server/preflight)全部走新门,legacy 因子变 inert 直到两次纯文本重训(有意变更,已披露,自愈);loop/plugin 车道不消费乘数,无行为变化;持久化向后兼容(legacy 文件原样恢复,新字段仅在精确
text-only-v1匹配时生效)。本次 merge 的 union 解析不丢任一面(master 的 model 键 + PR 的 provenance 戳都在)。 - 是否破坏缓存:不涉及(校准是估计器,不是缓存键)。
- 是否改了设计方向:不改架构;仅把校准样本的来源从共享槽改为每请求私有对,并加 provenance 门。
- 是否引入了新的配置:无新 env/config/默认值。
合并判定:可合(CI 在 5c5f75048 上跑完转绿即可;代码已审,无阻断项)。
PR #6545 re-review (head |
[ework] CI fix verified green ✓ |
1 similar comment
[ework] CI fix verified green ✓ |
…e-render goldens on the merged tree (r4) Master's post-ranxianglei#7151 golden pins conflicted with this PR's calibration-provenance digest pins in the four storage-render goldens; code auto-merged clean (the r3 persist.ts union already carries both facets). Regenerated the goldens from the merged tree via scripts/update-storage-render-goldens.ts — persisted digest fields only, wire shas unchanged. Targeted verification: typecheck clean, golden 5/5, calibration 59/59, cache-ledger 40/40, persist-* 86/89 (3 pre-existing sandbox-only persist-encryption failures, identical on clean master).
(ai: vllm-qwen/qwen3.8-27b) Fresh conflict this time — master moved on while the PR sat, and it's resolved and pushed. Final head What I found live this run (verified, not from memory):
The conflict was narrower than r3: only the four Local verification on the merged head: typecheck clean, build clean; golden 5/5, calibration suites 59/59 (incl. issue5952 + persist-calibration-model), cache-ledger 40/40, persist-* 86/89 (the 3 Pushed Live after push: 八问
判定:冲突已解,最终 head a30c7b9 已推(无 ci-held 标记,本分支唯一一次全量 CI);当前 0 失败,等 shards 跑完,merge 留给 owner。 |
[ework] CI fix verified green ✓ |
ranxianglei
left a comment
There was a problem hiding this comment.
(APPROVE — re-review after merge commit a30c7b997)
What changed since the second review (head 5c5f75048 → a30c7b997): a single merge commit a30c7b997 ("Merge origin/master into PR #6545 head — regenerate storage-render goldens on the merged tree (r4)") merged master 6453feee into the PR branch. The only PR-relevant delta is the regeneration of the four storage-render goldens; the PR's own source changes are byte-identical to the previous two reviews (per-file line counts unchanged: cache-ledger +64/-7, persist +22/-7, relay +12/-1, session +20/-2, util +17/-2). No kernel/ files authored by this PR (master's kernel 0.0.200 work is master's, not this PR's).
Why the goldens changed. Master's post-#7151 golden pins and this PR's calibration-provenance digest pins both touched the four storage-render goldens, so they conflicted on merge. The author regenerated them from the merged tree via scripts/update-storage-render-goldens.ts. I verified the regeneration is exactly "persisted digest fields only, wire shas unchanged":
- In all four goldens (
anthropic.json,chat.json,google.json,responses.json), the only changed lines arestateDigest,stateDigestAligned, andsectionDigests.metadata. Thestate/blockContents/statssection digests and every wire sha are untouched. This is the correct signature: the PR addedcalibratedEstimateProvenance+calibrationRing.provenancesto the persisted session state, which moves the state/metadata digests, but the rendered message content (wire shas) is unchanged. No content drift, no wire-sha churn.
Master's changes merged in (not PR regressions). The merge brought in master's own work, including one src/cache-ledger.ts change: the #7149 delta-anchoring optimization in noteForwardedBody — a byte-identical re-note now inherits the prior digest via prior.full.equals(buf) (zero hashing on the common path) instead of always re-hashing, while changed/new bodies keep the full SHA-256. I read it: the sameBytes guard requires prior !== undefined && prior.bytes === buf.byteLength && prior.full !== null && prior.full.equals(buf), so it only skips hashing when the prior body was stored in full and is provably byte-identical — correct, and it's master's change, not this PR's.
The PR's fix (unchanged, re-confirmed). The calibration fix itself is the same as the first two reviews: per-request Capture.calibration pair (AsyncLocalStorage) replaces the shared slot; image samples never train (imageTokens > 0 early-return); currentCalibrationFactor (util.ts:156-160) requires the text-only-v1 provenance stamp and (per master's #2141) a model match when the factor is model-stamped; ring provenances ride in lockstep with ring values. The r3 persist.ts union (master's per-model ring key + the PR's provenance stamp) is carried forward unchanged — the merge auto-merged clean on the code side.
Behavior change (carried, still accurate). currentCalibrationFactor old → new: OLD applied a factor on route+model match with no provenance check; NEW additionally requires the text-only-v1 stamp (and a model match when model-stamped). Legacy un-stamped factors are inert until re-trained by two fresh text-only settles. Affects only the relay/proxy lane (the sole consumer of the multiplier; loop/plugin lanes call settleUsageReport but never consume the factor). Self-healing. Disclosed in the PR body.
Tests. The PR's 8-case suite (tests/issue5952-image-calibration-contamination.test.ts) + the cold-load suite (tests/persist-calibration-model.test.ts) cover both directions of every gate. The author's targeted verification on the merged tree (typecheck clean, golden 5/5, calibration 59/59, cache-ledger 40/40, persist-* 86/89 with 3 pre-existing sandbox-only persist-encryption failures identical on clean master) is consistent with the diff.
Risks. No security surface. Persistence backward-compatible (legacy files keep their exact restored shape; new fields honored only on exact text-only-v1 match). No data loss. No kernel/ files authored by this PR → the kernel-authorization hard rule does not apply.
CI. Green on a30c7b997 (0 failed, 14 ok, 16 skipped, 0 pending). No findings block the merge.
Verdict: APPROVE. The r4 delta is a clean golden regeneration (persisted digest fields only, wire shas unchanged) on top of an already-verified, byte-identical PR fix; master's merged-in changes are master's own and correct. No small findings to fix on spot.
8问(中文,供人工复审):
- 是什么问题:图片用量会污染文本校准乘数;并发结算时会读到共享的 prepare 事实,导致文本校准被图片样本带偏。
- 什么原因导致的:结算走共享槽(而非每请求私有对),且旧
currentCalibrationFactor不校验 provenance,任何(含图片污染的)乘数都会被应用。 - 影响范围与严重程度:仅 relay/proxy 车道(乘数唯一消费方);loop/plugin 车道只调
settleUsageReport不消费乘数,不受影响。特定条件下有问题(有图片 + 有文本校准),非全局不可用。 - 怎么修复的:每请求私有对(AsyncLocalStorage
Capture.calibration)替代共享槽;图片样本永不训练(imageTokens>0 早退);currentCalibrationFactor加严格 provenance 门(仅text-only-v1生效);ring 的 provenances 与 values 锁步。 - 是否有回归问题:审过既有行为——本次 r4 仅重新生成四个 storage-render golden,且只动持久化摘要字段(stateDigest/stateDigestAligned/metadata 段摘要),wire sha 与其余段摘要全不变,无内容漂移;PR 自身源码与前两次 review 字节一致;master 合入的 cache-ledger
noteForwardedBodydelta 锚定优化是 master 自己的改动(字节相同才复用摘要,否则仍全量 SHA-256),正确。乘数消费路径全部走新门,legacy 因子变 inert 直到两次纯文本重训(有意变更,已披露,自愈)。 - 是否破坏缓存:不涉及(校准是估计器,不是缓存键)。
- 是否改了设计方向:不改架构;仅把校准样本来源从共享槽改为每请求私有对,并加 provenance 门。
- 是否引入了新的配置:无新 env/config/默认值。
合并判定:可合(CI 已在 a30c7b997 上转绿;代码已审,无阻断项)。
PR #6545 re-review (head |
Fix image usage contaminating the text calibration multiplier.
The relay settle read the shared prepare slot, which records text plus image reserve under a TextEstimate name. Image-bearing usage could train the text-only multiplier, and a concurrent request could overwrite the estimate a settle read, so a stale mixed-modal factor could reject a fitting payload after a model switch.
The send chokepoint now notes the final wire text estimate and image reserve per request. The settle consumes that pair, skips image-bearing samples, and a published factor only applies when every sample in its ring is text-only. Legacy factors without that stamp stay inert and re-train within two fresh text-only settles.
The 502 retryability question from the issue is left for a separate change.
Golden regen note: the storage-render goldens were regenerated because this fix deliberately changes the persisted calibration ring. It adds calibratedEstimateProvenance and provenances to the persisted stats, so the stats section digest changes. Only the stats digest differs; state, block contents and metadata are unchanged. The test header allows regeneration for a deliberate render-contract change, and this is one.
The remaining visibleNotices failures are pre-existing on the base (#6480 storage-default change) and should clear when this PR is rebased after #6561 merges.
Fixes #5952