Repository navigation
[PR] fix(server): unconditional 304 from the codex catalog endpoint no longer manufactures a phantom cache hit - #4864
Conversation
…r a send-failure give-up (#4599) #4516 (bc50f1a) replaced the post-give-up warn log with a state write that clobbered the 'send-failed' register value, breaking #4125's pinned contract (the register must stay 'send-failed' after a send-failure give-up). The user-facing intent of #4516 — accurate oversized-refusal wording — is kept by mapping 'send-failed' onto the dead-equivalent sentence in fallbackOversizeRefusal.
…ec — no phantom hit The catalog cache replayed its cached 200 on ANY 304 and extended freshness by another maxAge. That is correct only when the request was conditional (the end client sent if-none-match / if-modified- since; the wrapper itself never sends a validator). A 304 answered to an UNCONDITIONAL GET is off-spec — some transparent middleboxes do it anyway — and treating it as a hit manufactured a phantom success: six more hours of freshness, all real response headers discarded, and the relay billing it as a genuine catalog fetch. Gate the 304 branch on the request having carried a conditional header; otherwise invalidate the cache and pass the odd response through, same as any other unexpected status. The existing revalidation test now models the conditional header its name always implied; a new test pins the off-spec passthrough plus cache invalidation.
(ai: vllm-qwen/qwen3.8-27b) 查重: 不重复。 open+closed issue 与在途 PR 均无同主题条目(按「codex catalog 304 / 幻影缓存」检索)。唯一相关项是今天刚合入 master 的 标签: bug / codex / scope/wiring / p3(请求管道层缺陷;p3:触发条件是 off-spec 中间盒对无条件 GET 答 304,无已确认的生产事故记录,后果有界)。 审核进行中,初步结论(独立核验过,非复读 PR 描述):
CI 尚未开始(head |
Conflict in src/server/codex-catalog-cache.ts (the 304 branch): master added a once-per-credential warn log while KEEPING the replay (availability-first stopgap, 1b8a0ab from the #4801 review); this branch replaces the replay with invalidate()+passthrough for off-spec unconditional 304s. Resolved by union of intent: - Unconditional 304 (no if-none-match/if-modified-since on the request): invalidate() + pass the raw response through (this PR's fix), plus master's once-per-credential warn so a gateway looping on the off-spec answer stays visible in the logs. - Conditional 304 (client sent a validator): unchanged negotiated revalidation — replay cached 200 and extend freshness. - Renamed replayNoted -> offSpec304Noted: nothing is replayed on the off-spec path anymore, the old name would lie. Behavior change vs current master (intended, this PR's purpose): an unconditional 304 previously replayed the cached catalog as a full 200 and extended its freshness; now the cache entry is dropped and the 304 is forwarded as-is, same treatment as every other unexpected status. Verified locally: npm run typecheck clean; targeted node --import tsx --test tests/codex-catalog-cache.test.ts 10/10 pass (includes both 304 case pins). Full-suite verdict = remote CI.
(ai: vllm-qwen/qwen3.8-27b) 冲突已解决并推送(merge commit 冲突怎么解的——取两边意图的并集,不是二选一: master 在完全相同的位置单独合过一个止血提交(
结构化八问:
验证:typecheck 干净;定向 你贴的链(#4801 → #4852 → #4823 → #4834 → #4863 → #4864 → #4866)收到;核过链尾 #4866(thinking forms 单源化 + 死 import 清理)与本 PR 文件零重叠,无热文件竞争。 判定:冲突已解、已推送,PR 回到干净状态,待 CI 与 review/合并。 |
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.6314-pr.4864.38f4b16This exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr4864.tgz
npm install -g packageInstall instructions are refreshed on each push. |
(ai: vllm-qwen/qwen3.8-27b) 审核完成 — 结构化八问:
验证(独立复现,非复读 PR 描述):
暂不合并的两个阻塞项:
判定:修法质量本身过审——机制正确、测试有牙、diff 干净(2 文件、无无关改动、未动 version);hold 等 owner 对 #4870 的方向拍板,拍板后收敛(rebase+跟进)+ 远程 CI 绿即可合。 |
(ai: vllm-qwen/qwen3.8-27b) 第二次同步完成:master 又前进了 2 个提交(#4871 文档 PR + #4834 的 MESSAGE-IDENTITY.md 文档更新,均为纯文档),干净合入本分支(merge commit 八问速答(本轮无实质变化,细节见上一条完整八问):
判定:冲突已再解、分支已对齐最新 master,待 CI 绿与 review/合并。 |
(ai: vllm-qwen/qwen3.8-27b) 跟进:冲突已被 lane 自行解决,我已对新 head 复核 审核期间分支推进了两轮 merge master( d465a62 独立复核:
唯一余项:owner 对 #4870 拍板——认可 A(现状零改动,CI 全绿即可合)或改走 C(重放但不续期+标 offline-cache,我的推荐,需再改一处小 diff)。八问结论见上条评论,对新 head 全部仍然成立(冲突解决未改变任何已审行为面)。 |
# Conflicts: # kernel/package-lock.json # package-lock.json
…al' into pr4864-ci-converge
(ai: vllm-qwen/qwen3.8-27b) CI 收敛跟进:d465a62 上 e2e-native-pi / e2e-native-opencode / e2e-pi-codex-ws 三车道红。判定为继承性/环境性(同窗口另两个分支 head 同名车道同红;本 PR diff 与这三条车道零交集)。已按 CI 协调纪律把 origin/ci-fixes(f5939a1 intercept 修复)与最新 master(23158db,#4873/#4835/#4839 等)merge 进分支,新 head |
(ai: vllm-qwen/qwen3.8-27b) 进度汇报(会话曾被守护进程重启,补报状态): 已完成:
进行中:等 |
(ai: vllm-qwen/qwen3.8-27b) 最终判定:CI 全绿,可合(待 owner 在 #4870 拍板方向)
收工八问(简表,详版见本线程前一条):
行为变更披露(旧→新):无条件 304 旧=重放缓存+续期 6h+丢真实响应头;新=丢缓存+透传 304。原因:无条件 304 是 off-spec 应答,重放等于伪造成功。 合并建议:代码与 CI 均已就绪。唯一余项是 #4870 的方向拍板——当前分支实现的是选项 A(+warn);owner 认可 A 即可直接合,若改走 C(重放但不续期+标 offline-cache)我再补一处小 diff。 |
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.867-master.7cc6df5 # this exact build
npm install -g billion-context@master # always the newest merged build
|
这是啥问题
模型目录缓存(codex-catalog-cache)对任何 304 都当作"缓存仍新鲜":重放缓存的完整 200 目录、把新鲜期再续 6 小时。但 304 只有在请求带了条件头(If-None-Match / If-Modified-Since)时才合法——wrapper 自己从不发条件头,客户端带了的场景重放是正确的;问题是无条件请求也收到 304(某些透明中间盒会乱答):这时重放等于凭空造了一次成功——幻影新鲜 6 小时、真实响应头全丢、relay 还把这当真实拉取记账。
根因(代码坐标)
src/server/codex-catalog-cache.ts304 分支(原 :214-219):if (status === 304) { if (!entry) return result; remember({...entry, savedAt: clock()}); return replay(entry, false); }——不看请求是否带过条件头,一律按命中续期。改动
304 分支加一道条件头门:
headers(请求头,new Headers(init.headers)已在作用域)带过if-none-match或if-modified-since才重放+续期;否则与其它非预期状态同样处理——invalidate()丢缓存,把怪响应原样透传给调用方。验证
if-none-match),行为不变关联
精读块 C 结论之二(其一为 #4863 msgIds 烧号)