Skip to content

🤖 fix: admit fresh automatic input after settled Stop - #4209

Open
ThomasK33 wants to merge 4 commits into
codex/effect-compaction-cancellation-runtimefrom
codex/effect-compaction-settled-stop
Open

🤖 fix: admit fresh automatic input after settled Stop#4209
ThomasK33 wants to merge 4 commits into
codex/effect-compaction-cancellation-runtimefrom
codex/effect-compaction-settled-stop

Conversation

@ThomasK33

@ThomasK33 ThomasK33 commented Sep 11, 2026

Copy link
Copy Markdown
Member

After an ordinary Stop settles, fresh automatic monitor or family input can start a new turn without reopening the canceled continuation. This layer restores that existing behavior above #4191's V1 deferral, using V2 settlement proof.

V2 replacement authority waits for the captured producer and exact outer workspace cleanup: monitor retirement, auto-retry/withdrawn work, descendants and queued-input handling. Unresolved foreign V1 without a summary blocks automatic admission. Existing scoped-V1 ordinary preserve-mode admission remains supported; this is not a universal ban on automatic input behind every scoped record.

A failed physical Stop returns its error promptly while supervised completion can observe that exact producer finishing naturally. Retryable monitor retirement keeps its original obligation and completion receipt. Initial cancellation I/O failure does not erase physical completion; an exact cleanup retry can later qualify V2. Supersession and disposal release the owned wait without affecting a newer Stop. Failed descendant cleanup grants no V2 proof; existing logged/API behavior remains, with a later explicit Stop or manual replacement as recovery.

Fresh reset heartbeats stamp the captured compactionPublicationGeneration with the existing boundary occurrence ID. Matching eligible V2 provenance permits immediate or restarted follow-up recovery even when the optional sidecar is absent or failed to write. Legacy unmarked/stale generations grant no permission. The actual follow-up user row still owns original nonce/generation CAS and replacement retirement; a summary is not a replacement witness.

Automatic batches retain ordinary rollback accounting. Real V2 acceptance becomes irrevocable at durable trigger publication, before fallible callbacks; observer errors cannot refund persisted rows.

Validation: independent source/delta review passes. The combined candidate passed 1,077 tests / 4,472 assertions across 11 suites. Its final cleanup-handler and test-typing delta passed 39 focused cases / 169 assertions, and canonical static checks passed on that reviewed candidate. Risk: ownership/cleanup mistakes can resume canceled work or strand legitimate wakes, so held-cleanup, cross-instance, restart, failed-I/O and shutdown cases are included.

Successful physical Stop also waits for the originally captured startup producer before granting V2 authority. Fast and deferred settlement share a notification guarded by an exact V2 publication receipt, successful durable completion and current nonce/generation. This wakes monitor output deferred during cleanup without notifying for a superseded or failed Stop. The reported startup/monitor races and a foreign-supersession notification race were reproduced before the fix; 765 affected tests / 3,058 assertions and canonical static checks pass afterward.

Final phase integration on main ad8a01b: independent composition review and full canonical static checks pass on tree 3ed04896. Across 35 affected files, 2,549 tests / 28,590 assertions pass: 34 files passed before a test-only lifecycle repair, then all 28 pinned-budget tests passed after it. Two final-flush fixtures now complete their fake stream on Stop instead of waiting for later disposal; their original assertions and production behavior are unchanged.

The complete cancellation phase is ordered #4214#4215#4219#4221#4182#4187#4191#4209. The reader prerequisites and runtime changes merge together only after every member has current-head approval and green CI.


Generated with xum • Model: unavailable • Thinking: unavailable • Cost: $unavailable

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 11, 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 🔄 Running since 2026-09-11T14:24:13.454496Z 4454aeb New commits
🔒 Security Review 🔄 Running since 2026-09-11T14:24:13.378287Z 4454aeb New commits

Security findings

Advisory findings (1)

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

@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

Please review current head 8aab3bd7b3265715fa3cd1b716b3b58d52742f65. The phase has been reconciled with the actual merged pending-state base, all known findings have published fixes or a tracked phase-layer split and replies, and the split passed independent review. The new V1 intermediate tree passed 257 tests and canonical static checks. The final top exactly preserves the complete implementation with its prior static/backend/IPC/UI evidence, plus main’s documentation-only update; see the PR bodies for the precise validation scope.


Generated with xum • Model: unavailable • Thinking: unavailable • Cost: $unavailable

@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: 8aab3bd7b3

ℹ️ 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 src/node/services/agentSession.ts Outdated
Comment thread src/node/services/agentSession.ts Outdated
Comment thread src/node/services/agentSession.ts
@ThomasK33
ThomasK33 force-pushed the codex/effect-compaction-settled-stop branch from 8aab3bd to 463d635 Compare September 11, 2026 11:51
@ThomasK33

Copy link
Copy Markdown
Member Author

Addressed all three findings in 463d63508d6b63de803e3c0b672bbf48e7f930f7:

  • Foreign Stop admission: retain the original persisted nonce/generation through preparation and enforce it under the history publication lock. Ordinary automatic prefixes stage with their trigger and use 🤖 feat: record durable history acceptance for compaction replacement #4182’s preserve-cancellation mode. Regressions hold the request after the second early read and immediately before publication, from both absent and scoped V1 frontiers; a later fresh request still succeeds.
  • Pre-turn persistence accounting: actual V2 acceptance marks durable pre-turn rows before a fallible acceptance observer. Ordinary automatic appends retain rollback ownership; if rollback fails, surviving rows are marked durable before refund-capable callbacks. Canceled-before-CAS requests still invoke existing cancellation cleanup.
  • Stale V2 generation: the admission getter reports mismatched settled generations as blocked, so real monitor reconciliation defers owed attention instead of repeatedly scheduling an impossible idle wake.

Validation: 923 tests across eight suites, 240 budget tests covering the final test-seam adjustment, and canonical static on final tree 15fdba9fe60dd4053f334770c1071d60335f8ebd. Independent review approved the final publication, rollback and callback boundaries. The separate oversized-history scanner finding on #4182 remains open and blocks the phase merge.


Generated with xum • Model: unavailable • Thinking: unavailable • Cost: $unavailable

@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

Please review current head 463d63508d6b63de803e3c0b672bbf48e7f930f7. The latest review fixes are published in their owning layers, with replies and qualified validation in the PR descriptions. Both integrated runtime candidates passed canonical static checks. The whole cancellation phase will remain unmerged until every prerequisite and member is ready.


Generated with xum • Model: unavailable • Thinking: unavailable • Cost: $unavailable

@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: 463d63508d

ℹ️ 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 src/node/services/agentSession.ts Outdated

@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 Security Review · Automatically triggered

Here are some automated security review suggestions for this pull request.

Reviewed commit: 463d63508d

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

Comment thread src/node/services/agentSession.ts
@ThomasK33

Copy link
Copy Markdown
Member Author

The failed unit job on463d635 exposed14 obsolete test-seam cases after automatic publication moved to guarded batch acceptance. The fixtures now inject failure/cancellation at the real HistoryService acceptance boundary. Per-prefix failure/cancellation states no longer exist in this layer, so two batch cases replace seven old parameter cases while checking durable receipt, own-row rollback and foreign-row preservation. Five affected suites62/432 and canonical static pass; the composed lower-plus-top suite145/870 passes. Runtime Stop-cleanup review findings remain open and are being addressed separately.


Generated with xum • Model: unavailable • Thinking: unavailable • Cost: $unavailable

@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review


Generated with xum • Model: unavailable • Thinking: unavailable • Cost: $unavailable

@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: 2f0a66a0f1

ℹ️ 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 src/node/services/agentSession.ts
@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: 2f0a66a0f1

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@ThomasK33

Copy link
Copy Markdown
Member Author

Responses to all current findings:

  • 3988920128: session Stop now supplies an idempotent exact-owner finalizer to the workspace path. V2 waits for physical/policy completion and the actual outer cleanup. Held monitor-retirement/descendant tests verify V1 remains, and a foreign newer Stop survives unchanged. Failed physical completion and retryable retirement preserve eventual fresh-wake behavior; initial cleanup errors retain truthful physical completion for exact retry.
  • 3989137828: unresolved foreign V1 with no summary now blocks automatic admission. Intended scoped-V1 ordinary preserve-mode behavior remains unchanged, as the review explicitly permits.
  • 3988933696 (security policy): fresh monitor wakes after completed Stop are an existing product contract, not a newly introduced permission. Main already tests that Stop retires owed attention without disarming future wakes. This phase preserves that approved behavior; requiring a manual Resume or terminating every monitor would change it. The actionable early-settlement race is corrected above, and the original captured frontier remains enforced at real trigger publication. We are not relying on an untrusted-output label as the cancellation ownership check.

Fresh reset heartbeat recovery also retains durable generation provenance through restart and optional-sidecar failure, while the real follow-up input remains the replacement witness. The combined candidate passed 1,077 tests / 4,472 assertions, followed by 39 focused cases / 169 assertions for the final cleanup-handler/test-typing delta. Canonical static checks passed on the final composed tree, and independent source/delta reviews are clean.


Generated with xum • Model: unavailable • Thinking: unavailable • Cost: $unavailable

@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review


Generated with xum • Model: unavailable • Thinking: unavailable • Cost: $unavailable

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: 9c3904c24c

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@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: 9c3904c24c

ℹ️ 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 src/node/services/agentSession.ts Outdated
Comment thread src/node/services/agentSession.ts Outdated
Replay the existing reviewed B layer on its corrected prerequisites: versioned settlement proof, original automatic admission CAS, guarded batch publication, and receipt-based budget and rollback accounting. Its existing CI fixtures remain part of this layer.

Signed-off-by: Thomas Kosiewski <tk@coder.com>

---

_Generated with `xum` • Model: `unavailable` • Thinking: `unavailable` • Cost: `$unavailable`_

<!-- mux-attribution: model=unavailable thinking=unavailable costs=unavailable -->
Wait for the captured producer and exact outer cleanup before V2 replacement authority. Preserve eventual wake after failed physical Stop or retryable monitor retirement, keep unresolved foreign V1 blocked, and retain legacy scoped-V1 ordinary admission. Stamp heartbeat boundary generation for safe fresh follow-up recovery after restart without an optional sidecar; actual input still owns replacement CAS.

Signed-off-by: Thomas Kosiewski <tk@coder.com>

---

_Generated with `xum` • Model: `unavailable` • Thinking: `unavailable` • Cost: `$unavailable`_

<!-- mux-attribution: model=unavailable thinking=unavailable costs=unavailable -->
Signed-off-by: Thomas Kosiewski <tk@coder.com>

---

_Generated with `xum` • Model: `unavailable` • Thinking: `unavailable` • Cost: `$unavailable`_

<!-- mux-attribution: model=unavailable thinking=unavailable costs=unavailable -->

Change-Id: Ib96dfe46e536ed66daacef4347f6aca478a9102b
Change-Id: I654ec5bc5ef9b25c54bc9d294e1db0714ed0713f
Signed-off-by: Thomas Kosiewski <tk@coder.com>
@ThomasK33
ThomasK33 force-pushed the codex/effect-compaction-settled-stop branch from 9c3904c to 4454aeb Compare September 11, 2026 14:23
@ThomasK33
ThomasK33 removed this pull request from stack #4188 September 11, 2026 14:24
@ThomasK33
ThomasK33 added this pull request to stack #4222 September 11, 2026 14:24
@ThomasK33

Copy link
Copy Markdown
Member Author

Addressed both current findings:

  • 3989621864: fast and deferred settlement now share notification after exact V2 publication and successful durable completion, with current local and persisted nonce/generation checks. Monitor output arriving after retirement but before settlement is retried after V2. Foreign/superseded or failed publications do not notify; throwing observers do not change the Stop result.
  • 3989621877: V2 qualification always includes the originally captured producer, including startup even when physical Stop succeeds. The existing supervised wait preserves prompt physical Stop return, releases on supersession/disposal, and never captures a successor producer.

The reported races plus the foreign-supersession notification race failed before the fix. All 765 affected tests / 3,058 assertions, canonical static and independent review pass afterward.

Final phase integration on main ad8a01b: independent composition review and full canonical static checks pass on tree 3ed04896. Across 35 affected files, 2,549 tests / 28,590 assertions pass: 34 files passed before a test-only lifecycle repair, then all 28 pinned-budget tests passed after it. Two final-flush fixtures now complete their fake stream on Stop instead of waiting for later disposal; their original assertions and production behavior are unchanged.


Generated with xum • Model: unavailable • Thinking: unavailable • Cost: $unavailable

@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

Please review the current head after the complete phase was composed on current main. All known findings have fixes and replies in their owning layers; the eight-member phase stays held until all members are approved and green.


Generated with xum • Model: unavailable • Thinking: unavailable • Cost: $unavailable

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