Skip to content

fix(coding-agent): make apply_patch aborts atomic - #1670

Open
asdfqwerzxcc wants to merge 5 commits into
code-yeongyu:mainfrom
asdfqwerzxcc:fix/apply-patch-atomic-abort-8246
Open

asdfqwerzxcc wants to merge 5 commits into
code-yeongyu:mainfrom
asdfqwerzxcc:fix/apply-patch-atomic-abort-8246

Conversation

@asdfqwerzxcc

@asdfqwerzxcc asdfqwerzxcc commented Sep 13, 2026

Copy link
Copy Markdown

Summary\n\nMake registered multi-file apply_patch cancellation transactional. The tool now holds canonical mutation queues across byte-exact rollback, and its awaited result hook prevents the generic abort result from becoming observable before cleanup finishes.\n\nThis fixes the native Senpi implementation behind oh-my-openagent #8246.\n\n## Changes\n\n- reserve all canonical mutation paths together, deduplicating case and symlink aliases\n- split per-operation patch I/O from result orchestration and add raw-byte/symlink snapshots for cancellation rollback\n- forward the tool AbortSignal and keep an extension-instance execution registry until tool_result consumes settlement\n- preserve successful patches and the existing non-abort structured partial-failure contract\n- document the fork behavior and add a release note\n\n## QA & Evidence\n\n- Issue regression: 3/3 pass after reproducing 3/3 RED failures on upstream (issue-8246-apply-patch-atomic-abort.test.ts)\n- Focused neighbors: 26/26 pass across rollback, partial-failure, backport, and queue tests\n- Broader apply-patch set: 77 pass, 8 skip; 2 Windows /tmp permission-parser failures reproduce unchanged on clean upstream 92db3be54\n- Static/build: changed-file Biome pass; root TypeScript no-emit pass; full build exit 0; changelog gate pass\n- Manual source driver: abort rollback is byte-identical, pre-aborted input makes no mutation, and a successful three-file patch applies every operation\n- Isolated Senpi QA: common self-check 10/10, CLI smoke 8/8, narrow mock-loop 4/4; real auth unchanged\n- Artifact: local-ignore/qa-evidence/20260913-apply-patch-atomic-abort/README.md in the task worktree (ignored by repository policy)\n\n## Risks & Residuals\n\n- Rollback is process-local; process termination or power loss cannot be recovered by an in-memory journal.\n- Rollback preserves file bytes, existence, and symlink targets. It does not restore timestamps or ACL metadata.\n- Repository-wide Windows suites have pre-existing path, release-script, and native-prebuild fixture failures; none references a changed path. GitHub CI is authoritative for the supported matrix.\n- The local gate-review agent remained non-terminal in two bounded attempts, so no local reviewer approval is claimed; GitHub CI and repository review remain required.\n\n## Related Issues\n\n- Fixes https://github.com/code-yeongyu/oh-my-openagent/issues/8246\n


Summary by cubic

Fixes cancelled apply_patch runs leaving partial edits by rolling back every affected file before the abort result is published (#8246). Direct calls without an AbortSignal keep the existing partial-failure behavior.

Transactional aborts

  • Snapshots all files and symlinks before applying and restores byte-exact state on cancellation.
  • Holds the final tool result until rollback finishes so the agent loop can't observe a settled abort early.
  • Adds regression coverage for CRLF bytes, pre-aborted signals, and the agent-loop abort race.

Queue reservations

  • Adds withFileMutationQueues() to reserve every canonical path in a multi-file transaction at once.
  • Deduplicates symlink and case aliases so a patch touching the same file through different paths can't deadlock.

Written for commit 1883816. Summary will update on new commits.

Review in cubic

asdfqwerzxcc and others added 5 commits September 14, 2026 00:21
Ultraworked with [omo](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: sisyphus-dev-ai <sisyphus-dev-ai@users.noreply.github.com>
Ultraworked with [omo](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: sisyphus-dev-ai <sisyphus-dev-ai@users.noreply.github.com>
Fixes code-yeongyu/oh-my-openagent#8246.

Ultraworked with [omo](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: sisyphus-dev-ai <sisyphus-dev-ai@users.noreply.github.com>
Ultraworked with [omo](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: sisyphus-dev-ai <sisyphus-dev-ai@users.noreply.github.com>
Ultraworked with [omo](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: sisyphus-dev-ai <sisyphus-dev-ai@users.noreply.github.com>
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.

[Bug]: apply_patch can partially mutate files before returning Tool execution aborted

1 participant