Skip to content

fix(runtime-host): stamp Codex compaction freshness at execution resolution - #6405

Open
ggbdpq wants to merge 1 commit into
apache:mainfrom
ggbdpq:fix/6402-compaction-freshness
Open

ggbdpq wants to merge 1 commit into
apache:mainfrom
ggbdpq:fix/6402-compaction-freshness

Conversation

@ggbdpq

@ggbdpq ggbdpq commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

Summary

#6362's cross-model Codex checkpoint reuse is authorized by freshCodexCompactionHash, whose five-minute freshness window depends on codexCompactionMetadataFetchedAt — wired on the host side only from modelsFetchedAt, which only the explicit connection.models.fetch/onboarding operation writes. Ordinary sessions (no manual refresh) resolved execution targets carrying a stale discovery timestamp, so compaction could not stamp a hash (checkpoints were permanently pinned to same-model via the legacy branch) and cross-model reuse was unreachable — the capability the #6362 title promises was dead code in normal sessions.

The fix stamps the execution-resolution time (Date.now()) into codexCompactionMetadataFetchedAt when the backend resolves its execution target: the freshness window now measures "the catalog this backend is actually using" rather than "the last time the user clicked refresh", matching the gate's own comment ("Bound the age of provider compatibility claims, including long-lived backends"). The manual-fetch path, non-codex connections, and connections without a fetched catalog snapshot are unchanged; the three guards (codex / modelSource==='fetched' / timestamp present) are untouched.

Fixes #6402

Verification

Check Result
New regression (codex execution targets authorize compaction hashes from the resolved catalog without a recent manual refresh, seeded with a 24h-old discovery timestamp), red on parent 31 pass / 1 fail on the freshness-window assertion; green after
Ablation (stamp reverted to modelsFetchedAt passthrough, tests kept) re-reds at the same assertion; restored → 32/32
history-compact-checkpoint / openai-codex-history-compactor 43/43 + 13/13
ai-sdk-backend 288/288
workhub-target-execution-authority 3/3
execution-model-composition 43/43 final (one waitFor timeout on first run — flaky, single-run green and parent-commit baseline green)
runtime + runtime-host tsc / biome (changed files) / check:asf-headers all clean

Known residual boundary

The catalog data a windowed authorization relies on may itself predate the window (provider rotates comp_hash after discovery without another refresh → an authorization can still reach a provider rejection). That residual exists in the current design (five minutes after fetch) too; this fix only widens the exposure from "after fetch" to "after backend creation". Failure mode is a provider rejection → the existing text-summary fallback, never a wrong prefix.

AI use

Implemented and verified by GLM-5.3-Flash (ZCode); the wiring point, the gate, and the consumer chain were re-verified line by line before filing #6402.

Checklist

  • Manual-fetch path and non-codex connections unchanged; the three guards preserved
  • Claim lifetime semantics now per-backend, consistent with the gate's own comment
  • The residual stale-snapshot boundary is documented in the PR and issue rather than silently widened

@github-actions github-actions Bot added the effort/M Under 500 readable lines label Oct 27, 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)
@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, 327f6a1e73b07964ec066055581e616d5f1aa686 → 57eb3e91a483077779b9d3e9739d6f7f82c9ab7e, force-pushed to the fork.

Check Result
Branch fix/6402-compaction-freshness
Rebase clean (no conflicts)
git am 1 patch applies cleanly onto 9175a2b (throwaway worktree)
Tests history-compact-checkpoint + openai-codex-history-compactor: 56/56 (node --test, 43+13 as delivered); ai-sdk-backend: 288/288; connection-effect-coordinator (hosts the new regression): 30/32 pass, 2 win32-skipped, 0 fail; core + runtime-host tsc: pass
Ablation stamping reverted to the modelsFetchedAt passthrough (tests kept), rebuilt → exactly the new regression red (codex execution targets authorize compaction hashes from the resolved catalog without a recent manual refresh (#6402)), 29 pass → restored, rebuilt → 30/32 green
Sibling sweep the stamp site is the backend execution-resolution path in execution-model-authority.ts; the manual-fetch writer in llm-connections.ts and the three guards (codex / modelSource==='fetched' / timestamp present) are untouched, non-codex connections unchanged
Real-path repro covered by the new regression itself, which seeds a 24h-old discovery timestamp and asserts the freshness-window authorisation end-to-end (red on parent, green with fix)

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

@ggbdpq
ggbdpq force-pushed the fix/6402-compaction-freshness branch from 327f6a1 to 57eb3e9 Compare November 24, 2026 17:30

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

Development

Successfully merging this pull request may close these issues.

bug(runtime): cross-model Codex checkpoint reuse is unreachable — the freshness timestamp only updates on a manual model refresh

1 participant