Skip to content

feat: handle touchSet violations with accept, relaunch, and fixed retry paths#64

Merged
nigel-dev merged 7 commits intomainfrom
feat/touchset-violation-handling
Feb 14, 2026
Merged

feat: handle touchSet violations with accept, relaunch, and fixed retry paths#64
nigel-dev merged 7 commits intomainfrom
feat/touchset-violation-handling

Conversation

@nigel-dev
Copy link
Owner

Summary

When a plan job completes but modifies files outside its touchSet, users now have three clear options instead of a single ambiguous "retry" that silently bypassed validation.

Closes #61

Changes

  • Structured checkpoint contextCheckpointContext type with failureKind and violation metadata replaces error-string parsing for decision-making
  • State machine fixescompleted → failed and failed → running added to VALID_JOB_TRANSITIONS to support the detection and relaunch flows
  • Accept pathmc_plan_approve(checkpoint: "on_error") without retry/relaunch accepts touchSet violations and moves the job to ready_to_merge
  • Relaunch pathmc_plan_approve(checkpoint: "on_error", relaunch: "jobName") spawns a new agent in the existing worktree with a correction prompt containing the original task, violation list, and allowed patterns
  • Fixed retry pathmc_plan_approve(checkpoint: "on_error", retry: "jobName") now re-validates touchSet before proceeding, fixing the bug where retry silently skipped validation
  • Updated notifications — touchSet violation messages now present all three options clearly
  • Context stored on all checkpoints — all on_error checkpoints (touchset, merge conflict, test failure, job failure) now store structured context

Files modified

File Change
src/lib/plan-types.ts CheckpointContext, FailureKind types; state machine transitions
src/lib/schemas.ts Zod schemas for CheckpointContext on PlanSpec
src/lib/orchestrator.ts relaunchJobForCorrection method; checkpoint context on all setCheckpoint calls; updated notifications
src/tools/plan-approve.ts Three-path approve logic: accept, relaunch, retry with re-validation
tests/tools/plan-approve.test.ts Updated assertions for new output format

Testing

  • bun run build passes
  • bun test passes (600/600)
  • Manual testing done (if applicable) — requires tmux + plan execution environment

Notes

  • The relaunchJobForCorrection method reuses the existing worktree and branch. It kills any stale tmux session, writes a correction prompt, and creates a fresh tmux session + job entry. The agent sees the full git history and can selectively revert violating files.
  • Retry now re-validates touchSet when the checkpoint was caused by a touchSet violation. Previously, retry set the job to ready_to_merge which bypassed validation entirely (since validation only runs on completed jobs in the reconciler).
  • retry and relaunch are mutually exclusive. retry = "I fixed it manually, re-check." relaunch = "spawn an agent to fix it."

Add structured CheckpointContext with failureKind and touchSet violation
metadata to replace error-string parsing. Add completed->failed and
failed->running to VALID_JOB_TRANSITIONS to support touchSet violation
detection and agent relaunch flows.

Closes #61
Record failureKind and metadata (touchSetViolations, touchSetPatterns)
when setting on_error checkpoints. This replaces error-string parsing
with structured data for accept/relaunch/retry decision-making.

Update touchSet violation notification to present all three options:
accept, relaunch (agent fixes), or retry (user fixes, re-validate).
New method relaunches a failed job in its existing worktree with a
correction prompt containing the original task, touchSet violations,
and allowed patterns. Reuses branch/worktree, kills stale tmux session,
creates fresh tmux + job entry, and lets the agent fix violations
before touchSet re-validates on completion.
…prove

Three distinct actions for touchSet violations:
- Accept (no params): moves checkpoint job to ready_to_merge
- Relaunch (relaunch param): spawns agent in existing worktree
  with correction prompt to fix violations
- Retry (retry param): re-validates touchSet before proceeding,
  fixing the bug where retry silently skipped validation

Update test assertions to match new output format.
…prove

Add TouchSet Enforcement section explaining the three violation options.
Update mc_plan_approve reference with retry and relaunch parameters.
Expand touchSet field description in JobSpec table.
Add touchSet validation step to Merge Train flow.
Add FAQ entry for touchSet violations.
… paths

The accept and retry paths in mc_plan_approve called updatePlanJob()
to set the job to ready_to_merge, then immediately called savePlan()
with the stale in-memory plan object — overwriting the update and
leaving the job stuck in failed state.

Fix by updating the in-memory plan.jobs directly before savePlan(),
removing the now-unnecessary updatePlanJob import. Also adds
checkpointContext assertions to the orchestrator touchSet test.
Adds Phase 5G with 47 tests covering touchSet violation detection,
accept path, relaunch path, retry with re-validation, mutual
exclusion, and non-touchset relaunch rejection. Updates job states
reference, state transition maps, coverage matrix, results tracking
(276 → 323 tests), quick smoke test, and key risks.
@nigel-dev nigel-dev merged commit a991d64 into main Feb 14, 2026
4 checks passed
@nigel-dev nigel-dev deleted the feat/touchset-violation-handling branch February 14, 2026 12:23
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.

feat: Handle touchSet violations with accept and correct paths

1 participant