Skip to content

🤖 refactor: centralize prepared history publication and origin - #4187

Open
ThomasK33 wants to merge 2 commits into
codex/effect-replacement-acceptancefrom
codex/effect-prepared-history-publication
Open

🤖 refactor: centralize prepared history publication and origin#4187
ThomasK33 wants to merge 2 commits into
codex/effect-replacement-acceptancefrom
codex/effect-prepared-history-publication

Conversation

@ThomasK33

@ThomasK33 ThomasK33 commented Sep 9, 2026

Copy link
Copy Markdown
Member

Centralizes prepared history publication so manual triggers and their prefixes share one publication boundary, while preserving manual/automatic origin across preparation. Runtime layers consume receipts and rollback facts instead of inferring acceptance from a successful send result.

Publication uses #4182's guarded history operations. Origin stays independent of visibility and billing. Failure tests use a real HistoryService: successful prefixes and a foreign row persist normally, a service spy returns the public failure Result, and rollback must preserve the foreign row.

This update only advances the prerequisite base. The owned prepared-publication change is unchanged. Its 11 tests / 61 assertions and canonical static checks passed; propagated runtime tests cover guarded batches and actual receipt ordering.

Risk: publication callbacks affect queue and budget accounting. Real disk-state and foreign-writer assertions protect against lost or duplicated history.

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 9, 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-11T14:31:09.595870Z fe7f0e7 Manual request
🔒 Security Review Completed 2026-09-11T14:31:05.549318Z fe7f0e7 Manual request
ℹ️ 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
ThomasK33 added this pull request to stack #4188 September 9, 2026 14:03
@ThomasK33
ThomasK33 force-pushed the codex/effect-prepared-history-publication branch 3 times, most recently from 1512246 to 41f5ab3 Compare September 9, 2026 14:52
@ThomasK33
ThomasK33 force-pushed the codex/effect-prepared-history-publication branch from 41f5ab3 to 04977de Compare September 9, 2026 17:46
@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

Please review current head 04977dee3b07940f4fda84da1bcce3f5c64d2f26. The preceding attempt failed while resolving the Git ref; a newer code review in the companion phase has now completed, so this is a retry after that recovery evidence.


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

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: 04977dee3b

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

@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: 04977dee3b

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

@codex review

Please review current head 2f180b0c3d9a066cdf9196c51b13a0fa4e5bd0f7. The complete description records the final validated layer and integration; addressed findings have replies and are resolved.


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

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: 2f180b0c3d

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

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

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
ThomasK33 force-pushed the codex/effect-prepared-history-publication branch from 2f180b0 to 7235c68 Compare September 10, 2026 15:48
@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

Please review current head 7235c68bc0e902a68eaf73aebe143737933ab156. The complete phase has been reconciled with current main and passes 1,884 focused tests and full static checks. The PR description records the final layer scope and validation; the runtime malformed-partial finding has a published fix and reply.


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: 7235c68bc0

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: 7235c68bc0

ℹ️ 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.preparedHistory.test.ts Outdated
@ThomasK33

Copy link
Copy Markdown
Member Author

Addressed PRRT_kwDOPxxmWM6hM7oo (finding) in a54cba5f5ba57429ac2e3cac092102ee5a2f5bab. The fixture now tracks the real HistoryService append without replacing its implementation. A selected underlying filesystem append uses mockRejectedValueOnce, so the real HistoryService catches the I/O error and returns Err to the rollback branch. Rejecting appendToHistory itself would test a different exception path.

The foreign row still lands after the first owned prefix and before the failing write. Exact call order and persisted sequence assertions prove interleaving; rollback must preserve that row and start no provider. All 11 isolated middle tests and 15 integrated runtime tests pass, as do canonical static checks. No production change was needed for this finding.


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

@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

Please review current head a54cba5f5ba57429ac2e3cac092102ee5a2f5bab. 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

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: a54cba5f5b

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

@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: a54cba5f5b

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
ThomasK33 force-pushed the codex/effect-prepared-history-publication branch from a54cba5 to 2c8c781 Compare September 11, 2026 11:51
@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

Please review current head 2c8c7818a68ba91fcfc1df3ea187c77c7b37aa7f. 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: 2c8c7818a6

ℹ️ 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.preparedHistory.test.ts Outdated
@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: 2c8c7818a6

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

Addressed 3988873763 at the HistoryService seam. The real service still writes successful prefixes and a foreign row. A spy returns the normal Err result for the failing append, and actual disk-backed rollback preserves only the foreign row. Returning Err preserves the API contract exercised here; throwing would test a different exceptional path. Filesystem append mocking was removed. All11 prepared-publication tests and canonical static checks pass; the propagated V1 tests also pass.


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 Review: Didn't find any major issues. Nice work!

Reviewed commit: 7f26d64d3a

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

@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: 7f26d64d3a

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

@codex review


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

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: 1a5231b629

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

@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: 1a5231b629

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.

Keep prepared publication and manual/automatic origin at one shared boundary. Rebased unchanged owned layer onto durable acceptance review fixes.

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 -->
Preserve real successful prefixes, foreign writes and rollback assertions while injecting the normal returned failure at the HistoryService boundary.

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 -->
@ThomasK33
ThomasK33 force-pushed the codex/effect-prepared-history-publication branch from 1a5231b to fe7f0e7 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

@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

@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: fe7f0e7618

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: fe7f0e7618

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

for (const _row of earlier.slice(1)) appends.mockImplementationOnce(append);
// HistoryService reports write failures as Err. Inject that public contract rather than
// a thrown exception, which would exercise a different preparation failure path.
appends.mockResolvedValueOnce(Err("injected write failure"));

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 Inject the failure with mockRejectedValueOnce

Fresh evidence in the current head is that the failure is now injected with mockResolvedValueOnce(Err(...)), so these cases still do not exercise a rejected HistoryService call and can miss cleanup failures that occur when publication throws after earlier prefixes were persisted. Use the prescribed real-service spy with mockRejectedValueOnce(...) and arrange the successful/foreign writes around that rejection.

AGENTS.md reference: AGENTS.md:L117-L117

Useful? React with 👍 / 👎.

Comment on lines +3434 to +3438
messages.length === 1
? await this.historyService.appendToHistory(this.workspaceId, messages[0])
: await this.historyService.appendManyToHistory(this.workspaceId, messages);
if (result.success) persistedCancelableMessageIds.push(...messages.map((row) => row.id));
return result;

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 Route manual triggers through replacement acceptance

When a retained compaction cancellation exists, this shared trigger path still calls the ordinary append methods regardless of attempt.acceptanceOrigin; a repo-wide search finds no production callers of captureCompactionReplacement or acceptCompactionReplacement. Consequently a later manual send is never stamped as the durable replacement and cannot retire the retained Stop, while the newly propagated origin has no runtime effect. Route manual trigger publication (and the corresponding Resume path) through the replacement-acceptance API, preserving cancellation only for automatic work.

Useful? React with 👍 / 👎.

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