Skip to content

fix(runtime): pin the wire identity into Codex checkpoints so a re-login stops replaying the previous account state - #6386

Open
ggbdpq wants to merge 1 commit into
apache:mainfrom
ggbdpq:fix/6385-checkpoint-credential-identity
Open

ggbdpq wants to merge 1 commit into
apache:mainfrom
ggbdpq:fix/6385-checkpoint-credential-identity

Conversation

@ggbdpq

@ggbdpq ggbdpq commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

Summary

The cross-model Codex checkpoint gate (canReplayHistoryCompactCheckpointForModel, #6362) compared only connectionId + compaction hash. Re-authenticating the same connection with a different account kept replaying the previous account's encrypted compaction context (encryptedContent/itemId) on the new account's wire. Capture now pins the route's authoritative providerStateIdentity (connectionId + providerType + endpoint + credentialId + revision — the same identity the reasoning replay gate already binds) into the checkpoint's provider state; both replay gates reject a pinned checkpoint unless the current route states the exact same identity, failing closed when a route cannot state one. Pre-existing checkpoints without the pinned identity keep the legacy same-model/hash path, as declared in the issue. Compaction-hash and same-model checks are unchanged and compose with the identity match.

Fixes #6385

Verification

Check Result
New failing-before-fix tests (credential rotation rejected; same identity + hash still replays; legacy checkpoints unchanged; fail-closed on unstated identity; shape validation; compactor capture) red before → green after; ablation (identity comparison removed) returns red (1 fail = the mutation point), restored green
history-compact-checkpoint + openai-codex-history-compactor suites 59 pass / 0 fail
tsc -p tsconfig.json --noEmit (runtime, runtime-host) pass ×2
npm run format:check (2582 files) pass
npm run check:asf-headers (4706 files) pass

AI use

Implemented with GLM-5.3-Flash (ZCode); the identity definition, the gate comparison, and the rotation path were re-verified line by line before filing #6385.

Checklist

  • All five gate call sites wired (compactor reuse/capture, ai-sdk-compaction reuse/replay, ai-sdk-turn mid-turn seed) — the identity already existed at every point, no new data channel
  • Legacy checkpoints (no pinned identity) keep their exact prior behavior, pinned by test
  • The reasoning replay gate already bound this identity; this fix brings the checkpoint gates to the same discipline

@github-actions github-actions Bot added the effort/M Under 500 readable lines label Oct 27, 2026
…ntity

The cross-model Codex checkpoint gate compared only connectionId plus the
compaction hash, so a connection re-authenticated with a different account
(rotation without changing connectionId) kept replaying the previous
account's encrypted compaction context (encryptedContent/itemId) on the new
account's wire.

Capture now pins the route's authoritative providerStateIdentity
(connectionId + providerType + endpoint + credentialId + revision, the same
identity the reasoning replay gate already binds) into the checkpoint's
provider state next to codexCompactionHash, and both replay gates reject a
pinned checkpoint unless the current route states the exact same identity —
a route that cannot state one fails closed. The compaction hash and
same-model checks are unchanged and still compose with the identity match.

Checkpoints minted before this change carry no identity and keep the legacy
same-model/hash path, as the issue declares.

Fixes apache#6385

Generated-by: GLM-5.3-Flash (ZCode)
@ggbdpq

ggbdpq commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

Rebase & full-chain verification refresh (2026-11-25)

Context: upstream main switched to the native/rust-preview line after 9175a2b8 (2026-11-22), removing the TypeScript app stack this fix targets. Per contributor decision, this PR is re-verified against the last TypeScript main tip 9175a2b8fc04edeac87423d90ff637bbdf4ad45d (2026-11-22) so it stays reviewable/mergeable when the TypeScript line returns.

Rebased onto 9175a2b8, 70cb8e648a298e960a31d36aab1095d46c63268b → ef5457be594c9511120bd6e36f0e81dd5ef7fc6b, force-pushed to the fork.

Check Result
Branch fix/6385-checkpoint-credential-identity
Rebase clean (1 commit replayed onto 9175a2b)
git am 1 patch applies cleanly onto 9175a2b (throwaway worktree)
Tests history-compact-checkpoint 45/45 + openai-codex-history-compactor 14/14 (59 total, 0 fail) (node --test packages/runtime/dist/__tests__/{history-compact-checkpoint,openai-codex-history-compactor}.test.js)
Ablation the four product files reverted, tests kept → history-compact-checkpoint 43/45 with rejects provider-native state replay after a credential rotation on the same connection (#6385) red (rotation still replayed) plus the malformed-state subtest, and openai-codex-history-compactor 13/14 with captures the wire identity alongside the compatibility hash red → fix re-applied → 45/45 + 14/14 green
Sibling sweep the identity wiring re-checked: authoritative providerStateIdentity held on AgentRun (agent-run.ts :293/:514-518, already bound by the reasoning replay gate), threaded via backend.providerStateIdentity (ai-sdk-turn.ts :1279/:1459/:2933), captured into checkpoint provider state (openai-codex-history-compactor.ts :355), enforced in both replay gates (history-compact-checkpoint.ts :476-477) with fail-closed on unstated identity (:987-991 shape validation) — the identity existed at every point, no new data channel
Real-path repro the regression tests drive the real checkpoint gates over real captured Codex compaction state with a rotated credential identity; ablation red = previous account's encrypted context replayed on the new wire, fixed = rejected

Not verified: live Codex re-login end-to-end locally; covered by the gate-level suites over real captured state, CI runs the same files.

Attribution: original fix by @ggbdpq; rebase & verification refresh by GLM-5.3-Flash (ZCode).

@ggbdpq
ggbdpq force-pushed the fix/6385-checkpoint-credential-identity branch from 70cb8e6 to ef5457b Compare November 24, 2026 17:49

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

effort/M Under 500 readable lines

Projects

None yet

1 participant