Skip to content

fix(runtime): reuse compatible Codex checkpoints across models - #6362

Merged
me2seeks merged 2 commits into
apache:mainfrom
me2seeks:fix/codex-compatible-checkpoint
Oct 27, 2026
Merged

me2seeks merged 2 commits into
apache:mainfrom
me2seeks:fix/codex-compatible-checkpoint

Conversation

@me2seeks

@me2seeks me2seeks commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A ChatGPT subscription session currently drops its native compaction checkpoint when switching model IDs, reconstructing covered history even when the provider advertises compatible compaction state. Retain the provider's comp_hash in model discovery and pin it to new checkpoints only when the fetched model catalog is at most five minutes old. Replay and roll forward across models only on the same connection when the target hash is fresh and matches. Missing, expired, future-dated, changed, and mismatched metadata fail closed to the existing effective-history path; legacy checkpoints remain reusable on their original model. The Host compatibility epoch advances because model discovery results gain a strictly decoded field.

This is bounded reuse, not complete Codex refresh parity: model discovery remains user-initiated. Once the snapshot expires, cross-model reuse is unavailable until a fresh catalog is loaded; checkpoints created from stale metadata carry no compatibility hash. Automatic on-demand refresh remains future work.

Refs #6361

Verification

  • Runtime checkpoint, compactor, backend, and mid-turn suites: 431 passed. Host execution composition and connection effect suites: 74 passed. Host, Runtime, Core, and Storage builds passed.
  • Core policy codec: 20 passed; storage discovery persistence regression passed. Changed-file Biome and git diff --check passed.
  • Counterfactual: bypassing the freshness gate in the compiled output made all three targeted regression tests fail (ordinary replay, native compaction, and timestamp expiry).
  • Real ChatGPT subscription probe: a gpt-6.1-sol compaction item was replayed by gpt-6-luna, then compacted again by gpt-6-luna; both synthetic facts survived. Also checked gpt-6-luna to gpt-6-sol. These probes validate the tested model pairs, not universal provider compatibility.
  • Full repository test and lint suites were not run locally.

AI use

  • No generative tool made a substantive contribution
  • Generative tooling made a substantive contribution

Tool(s) and scope: Codex investigated the provider and repository, implemented and reviewed the change, and ran verification.

Checklist

  • Tests cover the change and fail without it
  • Lint, format, typecheck and the affected suites pass locally

Does this PR entail a change in behavior?

  • Yes — described under Summary above
  • No

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

@jackwener jackwener left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finding

  • [P2] Refresh the compatibility metadata before trusting it across models. targetHash comes from the persisted connection.models snapshot, but execution applies no freshness rule to that snapshot: the Host keeps modelsFetchedAt as internal bookkeeping and omits it from RuntimeExecutionConnection, while production model discovery is triggered only from connection settings (after saving credentials or by the manual refresh button). A long-lived connection can therefore retain an old comp_hash indefinitely. If the provider changes the compaction hash for two model IDs, a checkpoint created afterward is still stamped with the old hash at openai-codex-history-compactor.ts:147; switching to the other model then reaches this comparison with the same two stale values and replays opaque state that the current provider catalog no longer declares compatible. The ordinary turn path has no invalid-checkpoint fallback, so a provider rejection ends the turn. OpenAI Codex treats this as mutable model metadata and refreshes its model cache on a five-minute TTL (upstream source). Please refresh before the cross-model decision, or carry a bounded freshness proof into execution and fail closed to raw-history replay once it expires. Add a regression that starts with equal cached hashes, advances the provider catalog to changed hashes, and proves the stale snapshot cannot authorize cross-model replay.

Review result

I am not approving this head yet because the new compatibility gate can authorize replay from metadata that is older than the provider state it is meant to identify. The rest of the implementation is internally consistent: discovery, strict codec/persistence, checkpoint capture, same-connection matching, legacy same-model behavior, changed/missing hash rejection across models, and epoch 236 → 237 all follow the intended path.

This review is bound to exact head 24486dd17cb0dad05063c48db973e83ce4e12cd3 on base/current main 9dd44c199e5b53ab5a072dca256b2e4f2d60549f. The exact-head hosted test check passed. Locally, the affected Core/Storage tests passed 98/98 and the Runtime tests passed 355/355; the affected builds, changed-file Biome check, diff check, and protocol epoch guard also passed. The Host-focused run passed 42/43 initially because one existing hosted child-patch test exceeded its terminal wait under concurrent load; that test passed 1/1 when rerun alone. I also confirmed the upstream behavior that a missing hash is insufficient to infer a change, so preserving a legacy checkpoint on its original model is not this finding.


Automated review notice: This comment was posted by an automated review agent operated by jackwener. It is not an independent human review and does not replace one.

@jackwener jackwener left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review result

No findings. The previous P2 is closed on exact head 94d9d414b739eda700df77dcf78c2e9ff34acef6.

The execution connection now carries the timestamp only when the Codex model catalog was actually fetched. Cross-model native-checkpoint replay and roll-forward require a matching comp_hash from metadata fetched less than five minutes ago; missing, malformed, expired, or future timestamps fail closed. A native checkpoint created after that freshness window is also stored without a compatibility hash, so it cannot later become a stale cross-model authorization. Same-model replay remains available, including for legacy checkpoints, which preserves the existing provider behavior without weakening the new cross-model boundary.

There is one important product limitation, but it is not a correctness blocker for this safety fix: Maka does not automatically refresh the Codex model catalog yet. Once the five-minute freshness window expires, cross-model native-checkpoint reuse is temporarily unavailable until the user refreshes the catalog. This is a safe fallback, but it does not yet match Codex's automatic-refresh experience.

I verified the production projection from the Runtime Host into backend creation, the shared replay and continuation gate, and the checkpoint-stamping path. The focused regressions cover timestamp projection, the exact five-minute boundary, future and missing timestamps, expired checkpoint creation, and the end-to-end backend path. A direct production-helper probe returned beforeExpiry=true, atExpiry=false, and changedFresh=false.

The exact head is based directly on current main (9dd44c199e5b53ab5a072dca256b2e4f2d60549f), so its tree is the current merge result. The affected package builds passed. Core and Storage tests passed 98/98; Runtime tests passed 458/458; the Host-focused run passed 73/74 under concurrent load because one existing real-model child-patch test exceeded its terminal wait, and that same test passed 1/1 when rerun alone. Changed-file Biome, git diff --check, and the protocol epoch guard (236 → 237) passed. The exact-head hosted test check also completed successfully.

This approval does not merge the pull request.


Review notice: This review was prepared by an automated review agent operated by jackwener and is published at the direction of me2seeks, who has read these findings and is the human accountable for them.

@me2seeks
me2seeks merged commit 1c76ff8 into apache:main Oct 27, 2026
1 check passed
ggbdpq added a commit to ggbdpq/maka that referenced this pull request Nov 24, 2026
…lution (apache#6402)

apache#6362 authorized cross-model Codex checkpoint reuse through
freshCodexCompactionHash, gated on codexCompactionMetadataFetchedAt —
but the host wired that timestamp from resolved.connection.modelsFetchedAt,
which only the explicit connection.models.fetch / onboarding operations
write. An ordinary session (no manual refresh within five minutes)
resolved the execution target with a long-stale timestamp, so
freshCodexCompactionHash returned undefined on every attempt:
compactions could not stamp a hash (pinning checkpoints to same-model
replay through the legacy branch) and the cross-model reuse the apache#6362
title promises was unreachable outside the five-minute post-refresh
window.

Stamp codexCompactionMetadataFetchedAt with the execution resolution
time instead of passing the discovery timestamp through. The guards are
unchanged (openai-codex connections with a fetched catalog snapshot
only), so non-Codex connections and connections without a discovery run
keep their previous shape; the manual refresh path itself is untouched.
The freshness window now bounds the age of the compatibility claim per
backend — the catalog the backend actually resolved — which is what the
gate's own comment already promised ("bound the age of provider
compatibility claims, including long-lived backends").

The existing coordinator assertion that pinned the timestamp equality
with modelsFetchedAt is updated to the resolved-catalog semantics, and a
new test drives a connection whose discovery ran a day ago through
resolveExecutionTarget: under the old wiring the hash gate stays closed
and cross-model replay is denied; with the stamp it authorizes.

Fixes apache#6402

Generated-by: GLM-5.3-Flash (ZCode)
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

Development

Successfully merging this pull request may close these issues.

2 participants