Skip to content

feat(coderd/x/chatd): map the execution ledger at interrupt, reconcile kills, and sweep stalled cancels - #27320

Closed
ibetitsmike wants to merge 1 commit into
mike/codagt-757/03-execute-lifecyclefrom
mike/codagt-757/04-interrupt-mapping
Closed

ibetitsmike wants to merge 1 commit into
mike/codagt-757/03-execute-lifecyclefrom
mike/codagt-757/04-interrupt-mapping

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

Maps the execution ledger at interrupt inside the cancellation commit, best-effort kills the interrupted processes after the commit, and adds the periodic sweep that retries anything the immediate pass could not resolve.

Part 4/9 of the CODAGT-757 execution ledger stack (base: #3, execute lifecycle).

Stack staging note for reviewers

One intentional cross-PR boundary remains: executions whose results live in an edit-deleted message suffix are mapped to cancel_requested by the next PR, #27321 (mapExecutionsForHistoryDelete, wired into Tx.EditMessage before the suffix soft-delete). Within this PR, edit-path suffix deletion does not yet map those rows; #27321 routes them into the sweep introduced here. Interrupts, new-message and queued-promotion cancellations, and all retry/convergence machinery are fully self-contained in this PR.

Changes

  • The interrupt commit maps unresolved calls' rows in the same transaction as the synthetic cancellation results: backgrounds with a handle become detached (spared; their synthetic result carries the process handle), reserved becomes canceled, dispatched foregrounds become cancel_requested.
  • Non-interrupt cancellation transitions (new user message during a run, queued-message promotion) map the ledger identically via mapCanceledExecutions.
  • Post-commit reconciliation kills cancel_requested processes: dial the recorded agent, signal kill, confirm via post-kill snapshot or a definitive 404/409. Unconfirmed kills keep cancel_requested with full process identity. Rows without recorded identity wait out the late-handle window (an in-flight recordProcessStart write can still land, anchored on the later of the claim and the cancellation commit) before resolving unknown, with a guarded write that loses to a late handle. A late handle whose agent row was deleted (FK nulls the column) resolves canceled through the shared reconcile dispatch.
  • A periodic per-replica sweep (executionSweepLoop, every ExecutionSweepInterval) claims stale cancel_requested rows one at a time (so an aborted pass never leases rows it did not attempt) and retries the same reconcile flow, guaranteeing convergence for rows the immediate pass abandoned (unreachable agent, server death) and for the non-interrupt mappings.
  • Give-up bound: a row unconfirmable for 24h terminalizes as unknown; agent-row-gone shapes resolve canceled (the process died with its workspace).
  • The immediate pass ignores task-context cancellation (the runner cancels it once the transition lands) but aborts on worker shutdown.

This PR was authored by Mux, an AI coding agent, on Mike's behalf. The stack recomposes the previously reviewed #27100/#27102/#27103 into reviewable pieces, plus fixes from subsequent review rounds.

@linear-code

linear-code Bot commented Jul 17, 2026

Copy link
Copy Markdown

CODAGT-757

@ibetitsmike

Copy link
Copy Markdown
Collaborator 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: 048be89e24

ℹ️ 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 coderd/x/chatd/tasks.go
@ibetitsmike
ibetitsmike force-pushed the mike/codagt-757/03-execute-lifecycle branch from c842b85 to 0f6a503 Compare July 17, 2026 18:59
@ibetitsmike
ibetitsmike force-pushed the mike/codagt-757/04-interrupt-mapping branch from 048be89 to 19ea79b Compare July 17, 2026 18:59
@ibetitsmike

Copy link
Copy Markdown
Collaborator 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: 19ea79be5d

ℹ️ 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 coderd/x/chatd/tasks.go
@ibetitsmike
ibetitsmike force-pushed the mike/codagt-757/03-execute-lifecycle branch from 0f6a503 to 5e22e54 Compare July 17, 2026 19:59
@ibetitsmike
ibetitsmike force-pushed the mike/codagt-757/04-interrupt-mapping branch from 19ea79b to a269eb8 Compare July 17, 2026 19:59
@ibetitsmike

Copy link
Copy Markdown
Collaborator 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: a269eb8de2

ℹ️ 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 coderd/x/chatd/tasks.go
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@ibetitsmike
ibetitsmike force-pushed the mike/codagt-757/03-execute-lifecycle branch from 7eaa0ae to cc4febb Compare July 17, 2026 21:48
@ibetitsmike
ibetitsmike force-pushed the mike/codagt-757/04-interrupt-mapping branch from ae41ee2 to 8811cc5 Compare July 17, 2026 21:48
@ibetitsmike

Copy link
Copy Markdown
Collaborator 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: 8811cc591c

ℹ️ 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 coderd/x/chatd/chatstate/synthetics.go
@ibetitsmike
ibetitsmike force-pushed the mike/codagt-757/04-interrupt-mapping branch from 8811cc5 to c658051 Compare July 17, 2026 22:37
@ibetitsmike
ibetitsmike force-pushed the mike/codagt-757/03-execute-lifecycle branch from cc4febb to 264bf9b Compare July 17, 2026 22:37
@ibetitsmike

Copy link
Copy Markdown
Collaborator 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: c658051ec6

ℹ️ 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 coderd/x/chatd/chatstate/synthetics.go
Comment thread coderd/x/chatd/chatstate/synthetics.go
@ibetitsmike
ibetitsmike force-pushed the mike/codagt-757/03-execute-lifecycle branch from 264bf9b to 850f888 Compare July 17, 2026 23:09
@ibetitsmike
ibetitsmike force-pushed the mike/codagt-757/04-interrupt-mapping branch from c658051 to 7e3d261 Compare July 17, 2026 23:09
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@ibetitsmike

Copy link
Copy Markdown
Collaborator 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: a5ed2aee7d

ℹ️ 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 coderd/x/chatd/chatstate/synthetics.go
Comment thread coderd/x/chatd/chatstate/synthetics.go
@ibetitsmike

Copy link
Copy Markdown
Collaborator 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: a5ed2aee7d

ℹ️ 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 coderd/x/chatd/tasks.go
@ibetitsmike

Copy link
Copy Markdown
Collaborator 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: a5ed2aee7d

ℹ️ 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 coderd/x/chatd/tasks.go Outdated
@ibetitsmike
ibetitsmike force-pushed the mike/codagt-757/04-interrupt-mapping branch from a5ed2ae to e67ff2a Compare July 18, 2026 03:49
@ibetitsmike

Copy link
Copy Markdown
Collaborator 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: e67ff2a1e9

ℹ️ 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 coderd/x/chatd/chatstate/synthetics.go
@ibetitsmike

Copy link
Copy Markdown
Collaborator 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: e67ff2a1e9

ℹ️ 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 coderd/x/chatd/chatstate/synthetics.go
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

Please account for the "Stack staging note" in the updated PR description. This is part 4 of a linear stack; #27321 wires the periodic sweep (chatWorker.executionSweepLoop -> ClaimStaleChatToolCallExecutionCancels) that consumes the non-interrupt cancel_requested rows mapped in this PR.

Reply from Mux, an AI coding agent, acting on Mike's behalf.

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

ℹ️ 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 coderd/x/chatd/chatstate/synthetics.go
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

The "Stack staging note" in the PR description now enumerates both intentional cross-PR boundaries: ClaimStaleChatToolCallExecutionCancels (periodic sweep) and MarkChatToolCallExecutionsCancelRequestedForHistoryDelete (edit-path mapping via mapExecutionsForHistoryDelete) both get their runtime consumers in #27321. These are the only two; please review this PR as part 4 of the linear stack.

Reply from Mux, an AI coding agent, acting on Mike's behalf.

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

ℹ️ 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 coderd/x/chatd/tasks.go Outdated
@ibetitsmike
ibetitsmike force-pushed the mike/codagt-757/04-interrupt-mapping branch from e67ff2a to bd4d2ca Compare July 18, 2026 04:36
@ibetitsmike

Copy link
Copy Markdown
Collaborator 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: bd4d2ca00e

ℹ️ 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 coderd/x/chatd/tasks.go Outdated
@ibetitsmike
ibetitsmike force-pushed the mike/codagt-757/04-interrupt-mapping branch from bd4d2ca to b7917b7 Compare July 18, 2026 04:57
@ibetitsmike

Copy link
Copy Markdown
Collaborator 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: b7917b7cfb

ℹ️ 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 coderd/x/chatd/tasks.go
@ibetitsmike
ibetitsmike force-pushed the mike/codagt-757/04-interrupt-mapping branch from b7917b7 to e4202b6 Compare July 18, 2026 05:57
@ibetitsmike ibetitsmike changed the title feat(coderd/x/chatd): map the execution ledger at interrupt and reconcile kills post-commit feat(coderd/x/chatd): map the execution ledger at interrupt, reconcile kills, and sweep stalled cancels Jul 18, 2026
@ibetitsmike

Copy link
Copy Markdown
Collaborator 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: e4202b694b

ℹ️ 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 coderd/x/chatd/chatstate/synthetics.go
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

The PR description's "Stack staging note" documents the single remaining cross-PR boundary: the edit-path history-delete mapping (mapExecutionsForHistoryDelete) is the content of the next PR, #27321, and routes edit-deleted executions into the sweep introduced here. Please review this PR as part 4 of the linear stack with that boundary in mind.

Reply from Mux, an AI coding agent, acting on Mike's behalf.

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: e4202b694b

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

@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

Superseded by a simplified, ledger-free cut of CODAGT-757: #27369, #27370, #27371, #27372.

The new stack drops the database execution ledger entirely and instead relies on agent-side idempotent start tokens with at-least-once semantics: replays attach to the original process when the agent still knows the token, and re-run otherwise. The branches of this stack are kept as the salvage reference until the new stack merges.

This comment was written by Mux, an AI coding agent, operating on Mike's behalf.

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