Skip to content

[PR] fix: verify the cached catalog matches a 304 validator - #6145

Closed
Afloat16 wants to merge 1 commit into
ranxianglei:masterfrom
Afloat16:2026-11-10_validate-catalog-revalidation
Closed

Afloat16 wants to merge 1 commit into
ranxianglei:masterfrom
Afloat16:2026-11-10_validate-catalog-revalidation

Conversation

@Afloat16

Copy link
Copy Markdown
Contributor

Problem

A conditional 304 for client catalog B currently renews and replays proxy catalog A, restoring stale model capabilities. The same occurs if the cached response never supplied a validator.

Changes

Persist ETag and Last-Modified with complete catalogs. Require evidence that the 304 identifies the cached representation: its response ETag, a single matching request ETag under weak comparison, or stored Last-Modified. Respect If-None-Match precedence. Without a response ETag, ambiguous lists/wildcards pass through as 304 after cache invalidation. Older disk entries remain available for offline fallback without claiming validator-based renewal.

Validation

  • 17 catalog tests passed; five new regressions fail against unchanged source.
  • Cases cover mismatched/missing validators, weak tags, ambiguous lists/wildcards, response-tag disagreement, date validation, ETag precedence and disk-cache restart.
  • Final-code typecheck, npm production build with dist checks and git diff --check passed. Full suite remains with CI.

Checked #4864, catalog/304/validator history and Afloat16 contributions. This concerns conditional responses identifying another representation.

Base: e1e33a9.

Closes #6144

@ranxianglei ranxianglei changed the title fix: verify the cached catalog matches a 304 validator [PR] fix: verify the cached catalog matches a 304 validator Nov 10, 2026
@ranxianglei ranxianglei added bug Something isn't working codex p2 scope/wiring labels Nov 10, 2026
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b)

Dedupe: not a duplicate. Searched open issues/PRs for catalog/304/validator — the only related items are this PR and its source issue #6144; #4864 (unconditional 304) is a different mechanism as the author noted. No parallel PR targets this thread on the mirror either.

Labels applied to this PR from its own diff: bug, codex, scope/wiring, p2 — it changes 304-revalidation behavior in the Codex model-catalog offline cache only; p2 because it needs the end client to send its own validator AND upstream to 304 for a different representation before stale capabilities surface (usable, specific conditions).

Review in progress: verifying the repro against unchanged source, running the targeted catalog suites locally, then full regression verdict via CI on the pushed head. Full structured conclusion follows in a second comment.

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b)

Review verdict: the fix is correct and hits the root cause at the decision point; no code changes requested. Mergeable once the full-suite re-run I triggered goes green (state below).

What I verified live on PR head 70bc835daf:

  • Bug is real. The 304 branch of src/server/codex-catalog-cache.ts accepted any conditional 304 as proof the cached representation was still current: when the client's validator pointed at a different representation, bili replayed the stale catalog body as 200 and renewed its 6h TTL (options.maxAgeMs ?? 6 * 60 * 60 * 1000, line 118); a cached response that never carried validators renewed just the same.
  • Fix approach. Requires positive identity evidence before replay/renew: response ETag match first (authoritative), else single-tag weak comparison of request If-None-Match vs the stored etag, else Last-Modified equality (stored value, plus response value if present); RFC 9110 If-None-Match-before-If-Modified-Since precedence respected. No evidence → invalidate + pass the 304 through. The deliberately conservative choices are sound: ambiguous lists/wildcards without a response ETag invalidate instead of renewing; pre-upgrade disk entries without stored validators serve offline fallback only until a fresh 200 lands.
  • Regression pinning confirmed. I ran the new test file against unchanged master source: exactly 5 of 7 fail there (the weak-tag-match and disk-restart cases pass on both sides, as expected — master already handled those shapes), matching the author's claim. On PR head all 17 catalog tests pass. Local typecheck, production build (+dist checks), and git diff --check are clean.
  • Existing-behavior audit. The unconditional off-spec-304 passthrough gate is untouched and still runs first; offline fallback is intact (invalidation stops claiming renewal but keeps the disk entry); the one edit to an existing test (tests/codex-catalog-cache.test.ts:132, seed gains an etag) strengthens rather than weakens it; all 10 pre-existing tests pass; the sole production consumer (src/server/relay.ts:1271) is signature-unchanged.
  • Dedupe: not a duplicate (checked [PR] fix(server): unconditional 304 from the codex catalog endpoint no longer manufactures a phantom cache hit #4864, the catalog/304 history, and open issues/PRs — only the [Bug] Conditional catalog 304 can replay and renew a different cached representation #6144/[PR] fix: verify the cached catalog matches a 304 validator #6145 pair exists).

Behavior changes (all intended, old → new):

  1. Conditional 304 whose validator does not identify the cached representation: replay stale catalog as 200 + renew 6h TTL → invalidate cache + pass the 304 through so the client refetches.
  2. Disk entries written before this upgrade (no stored validators): could renew on any 304 → can no longer claim validator-based renewal until a fresh 200 lands; offline fallback unaffected.
  3. Ambiguous conditions (lists/wildcards) with no response ETag: renewed → now invalidate + pass through.

CI state (verified live today, not from memory):

  • Guards: green on this sha. All e2e lanes (real codex, Windows overlay, dsh/pi/opencode lanes, registry, persona): green on the original push (2026-11-10T15:32Z).
  • Core test matrix: the push-time run was cancelled mid-flight at 15:52:47Z (~20 min in, after all guards had passed; the cancellation actor is not recorded in the API). One side effect of mine to disclose: applying this PR's labels at 17:59Z fired labeled events whose skip-scoped runs now dominate the latest-per-name check view, so the legs currently display SKIPPED on the PR page even though guards+e2e genuinely ran green. Branch protection accepts the current state (mergeable_state=behind, not blocked).
  • Action taken: I re-ran the cancelled core-matrix run (same sha 70bc835daf, now queued as attempt 2). Full-suite verdict pending; nothing needed from anyone unless it goes red.

结构化八问(中文)

  1. 是什么问题:codex catalog 缓存把「上游返回 304」直接当作「缓存的目录仍然有效」的证据——客户端带的是另一个(更新的)表示的校验器时,bili 把旧目录当 200 回放并续期 6h,恢复过期模型能力;缓存响应本身没带校验器时同样续期。
  2. 什么原因导致的:304 分支缺少身份证据检查——没有验证这个 304 指认的就是本地缓存的那份表示(存的是 A、客户端问的是 B,304 只说明 B 没变,不能推出 A 没变)。
  3. 影响范围与严重程度:仅 codex 车道离线目录缓存;触发条件窄(终端客户端自带校验器 + 上游对另一表示回 304);后果是短暂恢复过期模型能力,直到下一次新鲜 200 落盘。p2(能用,特定条件下有问题)。
  4. 怎么修复的:在既有决策点要求正向身份证据——响应 ETag 匹配优先(权威),其次请求 INM 单标签弱比较对存储 etag,再次 Last-Modified 相等(含响应值比对);无证据则失效缓存并放行 304。完整目录落盘时同时持久化 etag/last-modified。
  5. 是否有回归问题:审过的既有行为均保持——无条件 304 直通门未动且仍最先执行;离线回退不受影响(失效只停止续期声明,磁盘条目仍在);既有 10 个测试全部通过,唯一改动的既有测试是加固不是削弱;唯一生产消费点签名未变。三处行为变更(见上 old→new)均为有意并已披露。
  6. 是否破坏缓存:本 PR 就是修缓存判定本身的;失效路径正确清内存续期声明、保留磁盘条目供离线回退;不影响其他缓存/重试/游标机制。
  7. 是否改了设计方向:否——在既有决策点收紧校验,无架构/数据流变化。
  8. 是否引入了新的配置:无。

判定:可合 —— 待我触发的核心矩阵重跑(同 sha,已排队转 running)转绿即可合入;代码层面没有任何修改要求。

@ranxianglei

Copy link
Copy Markdown
Owner

Landed via batch PR #6439 (merged) — closing as superseded.

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b)

Acknowledged — verified live: #6145 is closed (not merged directly), and batch PR #6439 is merged with per-commit cherry picked from provenance, so this fix landed there. One closing note: the core-matrix re-run I triggered on this head (70bc835daf) completed green (full test matrix + static gates), so the full-suite verdict this review was waiting on is also in — the change is verified end-to-end. Nothing further pending on this thread.

@ranxianglei ranxianglei reopened this Nov 14, 2026
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b)

Re-wake check (verified live, no new input on the thread): this thread is complete — PR #6145 is closed as superseded, the fix landed via merged batch PR #6439 (per-commit cherry picked from provenance), and the full core-matrix re-run on head 70bc835daf finished green. No code changes were requested in review; nothing is pending on this thread.

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

Labels

bug Something isn't working codex p2 scope/wiring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Conditional catalog 304 can replay and renew a different cached representation

2 participants