Skip to content

fix(cli): include cache writes in app-server freshness - #617

Open
luvs01 wants to merge 1 commit into
devfrom
codex/propose-fix-for-stale-app-server-warnings
Open

luvs01 wants to merge 1 commit into
devfrom
codex/propose-fix-for-stale-app-server-warnings

Conversation

@luvs01

@luvs01 luvs01 commented Sep 22, 2026

Copy link
Copy Markdown
Owner

Motivation

  • A cache-only write to models_cache.json could leave a running Codex app-server with an in-memory model list that is newer than the on-disk catalog, but the advisory logic previously compared only the catalog mtime and missed those cases.

Description

  • Include models_cache.json mtime in the post-write freshness boundary by importing activeCodexModelsCachePath and adding a modelsCacheMtimeMs seam to CodexAppServerProcessIo so tests can inject a cache clock.
  • Compute writeMtimeMs as the newest of the catalog mtime and models-cache mtime and use it for the stale-vs-fresh comparison in afterCatalogWriteHandleAppServers.
  • Add a production helper defaultModelsCacheMtimeMs() that reads the active cache file mtime when an injected seam is not provided.
  • Update the unit test tests/codex-integration/codex-app-server-processes.test.ts to cover the cache-only timing window and update structure/runtime.md to document that advisory guidance compares against the newest catalog or models-cache mtime.

Testing

  • Ran bun test tests/codex-integration/codex-app-server-processes.test.ts with Bun v1.4.0 and the focused suite passed (59 passed, 1 skip).
  • Ran bun run typecheck and bun run structure:check, both succeeded.
  • Ran bun test tests/ci-workflows/file-size-ratchet.test.ts and bun test tests/ci-workflows/repo-hygiene.test.ts, both succeeded.
  • Attempted broader bun run test for full suite; unrelated shared-state failures surfaced outside the changed subsystem while the focused tests for this change passed. The test:changed wrapper could not run due to no resolvable comparison ref in the checkout environment.

Codex Task


Devin Review

@coderabbitai

coderabbitai Bot commented Sep 22, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Repository: luvs01/opencodex/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 8ce692dd-3cc1-4467-86e7-1bedda1ebe2a


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 22, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-22T11:51:42.575415Z 6457ad9 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

Copy link
Copy Markdown

Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Sep 22, 2026

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Devin Review found 2 potential issues.

Devin Review

Comment on lines +1264 to +1268
const cacheMtimeMs = options.io?.modelsCacheMtimeMs
? options.io.modelsCacheMtimeMs()
: options.io?.catalogMtimeMs ? null : defaultModelsCacheMtimeMs();
const writeMtimeMs = catalogMtimeMs === null ? cacheMtimeMs
: cacheMtimeMs === null ? catalogMtimeMs : Math.max(catalogMtimeMs, cacheMtimeMs);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Startup cache-only writes still miss stale app-servers

Startup cache-only writes call warnIfStaleCodexAppServersAfterStartupWrite, which still compares only the catalog mtime. An app-server started after the catalog but before the cache rewrite receives no stale warning.

Learn more

The CLI startup path explicitly invokes the startup warning after either consumeStartupCacheInvalidationWrite() or startupSync.cacheSynced reports a cache write in handleStart. That warning delegates to the catalog-only collector, so the newly added models-cache boundary applies to interactive post-write handling but not startup cache writes.

Example: The catalog mtime is 1,000 ms, the app-server starts at 2,000 ms, and startup rewrites models_cache.json at 3,000 ms. The startup collector reports fresh from 2,000 > 1,000, although the process predates the cache write and retains the old model list.

Recommended fix: Share the maximum catalog/cache mtime calculation with warnIfStaleCodexAppServersAfterStartupWrite, while preserving its cache reset and no-signal behavior. Add a startup regression test with the catalog older than the process and the models cache newer than it.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Comment thread structure/runtime.md
Comment on lines 67 to 70
After a CLI catalog/cache write, advisory restart guidance compares each running Codex app-server's
start time with the written catalog mtime. It reports only processes proven stale; a fresh or
start time with the newest catalog or models-cache mtime. It reports only processes proven stale; a fresh or
unreadable observation does not claim that another restart is required. Explicit
`--restart-codex` and `--restart-app-server-only` retain their operator-consent semantics and act on

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔍 Public stale-state documentation remains catalog-only

The public sub-agent guide defines freshness only against the catalog. If cache writes belong to the global contract, update that page and its translations.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

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

aardvark bug Something isn't working codex

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant