Skip to content

Own prepared runtime generations - #133

Closed
lynnswap wants to merge 3 commits into
mainfrom
codex/prepared-runtime-generation-pr
Closed

Own prepared runtime generations#133
lynnswap wants to merge 3 commits into
mainfrom
codex/prepared-runtime-generation-pr

Conversation

@lynnswap

@lynnswap lynnswap commented Aug 21, 2026

Copy link
Copy Markdown
Owner

Purpose

Prevent stale runtime preparation from publishing after stop or restart, while replacing only AppServer state during same-account restart and retaining the MCP listener generation and URL.

Changes

  • Add Store-owned monotonic runtime generations and inert prepared runtime handles.
  • Split MCP prepare and activate with exact-generation validation and deterministic stale cleanup.
  • Close Live and Direct request admission before teardown while preserving owned cleanup paths.
  • Preserve auth notification readiness, account persistence, and joined initial rate-limit work.
  • Add deterministic Store and Host lifecycle race coverage.

Testing

  • swift test --build-system swiftbuild --no-parallel
  • scripts/check-compatibility.sh
  • ReviewMonitor xcodebuild test (15 tests)
  • Focused lifecycle race suite repeated 10 times
  • Two independent exact-diff audits

Screenshots

Not applicable.

@lynnswap lynnswap changed the title refactor(runtime): own prepared runtime generations Own prepared runtime generations Aug 21, 2026
@lynnswap

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e74c6e3b3c

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread Sources/CodexReview/Store/CodexReviewStore.swift Outdated

@lynnswap lynnswap left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

@codex review

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ad1d873d8f

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread Sources/CodexReview/Settings/CodexReviewSettingsService.swift
Comment thread Sources/CodexReview/Store/CodexReviewStore.swift Outdated
@lynnswap

Copy link
Copy Markdown
Owner Author

@codex review

Please review commit 3b9f790.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3b9f790634

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

previous: previous,
candidate: candidate
)
if mutationRevision == revision {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Reconcile writes that finish after runtime publication

When a runtime snapshot advances mutationRevision while persistSelection is already in flight, this guard suppresses only the local baseline update; it cannot prevent the backend request from committing after the new runtime has read its snapshot. Fresh evidence beyond the resolved thread is that FakeCodexReviewBackend.applySettings applies the stale change after its gate opens (Sources/CodexReviewTesting/TestSupport.swift lines 468-475), and the new regression test manually restores freshSnapshot at line 285 before continuing, masking the resulting backend/UI divergence. In this race the UI shows fresh-runtime-model while persisted configuration contains stale-model, so a subsequent review or restart can use the wrong settings; runtime publication must wait for the write or reconcile the current backend after a stale success.

Useful? React with 👍 / 👎.

await self?.performRuntimeStop(
previousState: previousState,
invalidatedGeneration: invalidatedGeneration,
purpose: .runtimeFailure

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve the failure reason when tearing down reviews

When the auth notification stream fails while reviews are active, routing teardown through .runtimeFailure loses the failure message before review cleanup: performRuntimeStop calls the ordinary stopPublishedRuntimeSemantics, and LiveCodexReviewStoreBackend.stop hardcodes ReviewCancellation.system(message: "Review runtime stopped."). The previous failure path passed "Review runtime stopped unexpectedly: …" into cancelActiveReviewsForRuntimeTeardown, so this change now records an intentional-stop reason on jobs that were actually interrupted by a runtime failure; pass the failure cancellation reason through the new teardown path.

Useful? React with 👍 / 👎.

@lynnswap

Copy link
Copy Markdown
Owner Author

Superseded by prerequisite PRs #134, #135, #136, and #138 plus final successor #139. Settings cutover ownership, typed teardown intent, intentional cancellation, and commit replay landed separately; #139 contains only the prepared-runtime generation integration.

@lynnswap

Copy link
Copy Markdown
Owner Author

Closing without merge. The corrected prepared-runtime generation implementation continues in #139 on top of the merged owner prerequisites.

@lynnswap lynnswap closed this Aug 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant