Repository navigation
[PR] fix(kernel): fold plain-text developer items carrying Codex metadata fields (#6949) - #6952
ranxianglei wants to merge 8 commits into
Conversation
Codex Desktop stamps mid-history developer items with top-level id + internal_chat_message_metadata_passthrough (per-message bookkeeping: turn_id, content_item_kinds, provenance). The #4166 plain-text check only admitted type/role/content, so those plain-text items were classified unrecoverable, got a BLOCKED ref and were permanently un-foldable; their BLOCKED rows also poisoned the acp_status range view (billion-context #6949). Admit the two known-harmless keys with strict shape checks (id must be a string, the passthrough must be a plain object); any other unknown top-level key still pins. The plain-text rewrite path (wire/responses.ts) already re-emits plain-text items without these fields, so the kernel already treated them as disposable for plain-text items. kernel-change: #6949 — isPlainTextResponsesSystemItem over-rejected plain-text developer items carrying Codex id + metadata passthrough; admit the two known-harmless keys, regression test kernel/tests/issue6949-codex-developer-metadata.test.ts.
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.11013-pr.6952.07e2a87This exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr6952.tgz
npm install -g packageInstall instructions are refreshed on each push. |
The 0.0.199 bump in kernel/package.json (commit 7606a19) left the kernel lockfile at 0.0.198, so the lock-sync lane (npm install --package-lock-only + git diff --exit-code) fails on every run of this head and — because the test matrix job needs lock-sync — the full test suite never runs on this PR. Small in-pass fix found during PR review: two version fields, no other content. Verified idempotent: kernel/ npm install --package-lock-only makes no further change.
…developer-metadata-foldable
(ai: vllm-qwen/qwen3.8-27b) 查重: 不重复 — no other open [PR] row targets this thread; this is the only PR fixing #6949. Review verdict: positive — code correct, claims verified, tests realCode review (independent, all verified in-tree):
Defect found & fixed in review (small in-pass fix, labeled commit):
CI state (verified live on original head 7606a19):
结构化八问
判定:代码可合并(kernel 变更,人工评审档仍适用)。CI:新 head |
Second half of the lock-sync fix (6356ee8 covered kernel/package-lock.json): the root lockfile records the file: dependency's version under the 'kernel' folder key, which the 0.0.199 bump in kernel/package.json left stale. Same lock-sync lane, same root cause (version bump without lockfile sync). Verified: root npm install --package-lock-only produces exactly this one-line change and nothing else; kernel/ side already idempotent.
(ai: vllm-qwen/qwen3.8-27b) Follow-up — first re-run exposed a second lockfile drift; fixed and pushed (new head First re-run on
Fix: The new run on |
(ai: vllm-qwen/qwen3.8-27b) Final CI verdict (head
Final verdict: merge-ready. The code fix is correct and now fully verified by a real full-suite run on the rebased head; the only residual red is inherited and outside this PR's scope. The human-only review tier applies (kernel change). |
…olving closeLogger resolved when the FINAL stream ended, but rotated-out streams are end()-ed asynchronously and their flush can still be in flight. On a loaded Windows runner a slow replaced flush let the shutdown read a sealed generation before its tail was written, losing a rotated record (logger-rotate 'successive rotations retain distinct payloads' red on windows-22 shard 2, PR #6952). Track the in-flight replaced streams with a drain-waiter list: settle() already decrements pendingRetentionDrains and now notifies waiters at zero, and closeLogger waits for BOTH the final stream and pendingRetentionDrains === 0, honoring its documented contract ('resolves once every buffered line has drained to disk'). 'close' always fires, so the counter always settles — no new hang path.
(ai: vllm-qwen/qwen3.8-27b) CI re-verification + fix (this run — head now Re-verified the live state first: the 3 failing shards the event reported (ubuntu-24-3, ubuntu-22-3, windows-22-4) were ALL the inherited The post-merge head ( Fix (on the PR branch, labeled commit Note: the logger fix is technically outside this PR's primary scope (the kernel fold fix) but was required to clear the red CI; I flagged it on #4599. The new head 结构化八问
判定:红 CI 已修 —— 3 个继承 #2929 经 ci-fixes 收敛,1 个 logger-rotate 竞态在 PR 分支修(commit |
kernel-change: #6949 — acceptance follow-up requested in the issue thread (field audit, Codex CLI 0.169.0): pin the three observed plain-text classes (host_skills.instructions / tools.deferred_namespaces / generic.turn_aborted) with valid id + metadata object, and pin the stale-BLOCKED migration so pre-existing mislabeled sessions recover on re-assignment without a new session.
…sion Master advanced kernel 0.0.198->0.0.199->0.0.200 (its own changes: #6709, compress-receipt, #7252); the PR independently bumped 0.0.198->0.0.199 for the #6949 protected.ts fix. The merged kernel tree carries BOTH, so the version must move above master's 0.0.200 -> 0.0.201 (required by kernel-guard rule 2: SRC_CHANGED via protected.ts implies BUMPED). Lockfiles regenerated idempotent (root + kernel).
(ai: vllm-qwen/qwen3.8-27b) Conflict resolved + pushed (new head The PR was in a dirty merge state because master advanced 135 commits past the branch's base (merge-base What I did this run:
State: master is now an ancestor of the head, so the PR is mergeable/clean. The mirror cache is stale (fetched 2026-11-17, still showing the old sha 结构化八问
判定:冲突已解决并推送(新 head |
Fixes #6949
Problem
Codex Desktop stamps mid-history developer items with top-level
id+internal_chat_message_metadata_passthrough(per-message bookkeeping: turn_id, content_item_kinds, provenance). The kernel's plain-text checkisPlainTextResponsesSystemItem(kernel/src/protected.ts) only admitted the top-level keystype/role/content, so those plain-text items were classified "unrecoverable" ->assignRefsmintedBLOCKED_REF-> the messages were permanently un-foldable, and their BLOCKED rows also poisoned theacp_statusuncompressed range view (mNNNNN–BLOCKED ⚠ not foldable: refs unresolvable).Reproduced on master before the fix: with the two fields -> unrecoverable=true; without -> false (matches the issue's "0 of 30 raw pass, 30 of 30 pass after stripping the fields").
Fix
kernel/src/protected.ts: admit two known-harmless top-level keys inisPlainTextResponsesSystemItem, with strict shape checks:id— must be a string (standard Responses item id; the plain-text rewrite path in kernel/src/wire/responses.ts already re-emits plain-text items without it);internal_chat_message_metadata_passthrough— must be a plain object (Codex per-message bookkeeping; the model never reads it and it dies with the message on fold).Any OTHER unknown top-level key still pins (the conservative #4166 fallback is unchanged). Content-parts check, the verbatim re-emit path, and the report layer are untouched.
kernel/package.json0.0.198 -> 0.0.199 (CI-enforced version discipline).Behavior change (disclosed)
Plain-text developer/system items carrying these two fields: permanently un-foldable (BLOCKED) -> foldable (numeric ref). Why: the fields carry no model-visible payload and the kernel's own plain-text rewrite path already drops them. Previously-BLOCKED sessions migrate to numeric refs on the next ref-assignment pass via the existing #2607/#3945 migration path (fresh number minted, carrier re-render deferred to the next fold boundary — no mid-turn cached-prefix rewrite).
kernel-change: #6949
isPlainTextResponsesSystemItemover-rejected plain-text developer items carrying Codex's id + metadata passthrough (provably-false guard: the kernel's own plain-text rewrite path already treats these fields as disposable for plain-text items). Filed under the 2026-11-06 mechanical-bug exemption (no separate pre-approval issue); the human-only review tier still applies — please review.Tests
kernel/tests/issue6949-codex-developer-metadata.test.ts— reproduces the bug (with fields: was BLOCKED, now foldable), negative gates (other unknown key / wrong value shapes / structured content still pin), byte-exact verbatim re-emit INCLUDING the fields, and numeric ref minting viaassignRefs.Related