Skip to content

Extend intent-gap patch-restore re-drive to the sweep workflow #75

Description

@pbean

Summary

The intent-gap patch-restore re-drive (added for story runs) should be extended to the sweep workflow (SweepEngine deferred-work bundles).

Background

BMAD-METHOD PR #2564 ("preserve the attempted change on intent-gap halts") makes bmad-dev-auto save the reverted attempt as a patch file before halting on an intent gap at the review step. The orchestrator now has a sanctioned recovery for story escalations: bmad-loop resolve (interactive, or --no-interactive --restore-patch <path>) re-arms the escalated spec to in-review, latches the patch onto the task, and the engine re-applies it onto the baseline after every reset of the re-drive — so the re-driven dev session resumes review on the restored diff instead of re-implementing from scratch.

This landed on branch feat/intent-gap-patch-restore (plan: i-received-a-message-unified-journal.md). Scope was deliberately limited to story runs; sweep-bundle escalations still take a from-scratch re-drive.

What's missing

SweepEngine bundle escalations should honor a restore_patch latch the same way story runs do:

  • re-arm the bundle spec to in-review (mirroring runs.rearm_escalation's restore branch), rather than the bundle's from-scratch equivalent;
  • re-apply the saved patch after the bundle's baseline reset, before dispatching the bundle dev session (mirroring Engine._restore_patch, called from the dev loop on feedback is None);
  • clear the latch on the bundle commit (mirroring Engine._commit clearing task.restore_patch = None next to resolved_redrive = False).

Note the sweep path has its own _drive_story / _rollback_or_pause / _safe_reset call sites (sweep.py), and bundles have no sprint-status entry, so the story-run wiring can't just be inherited unchanged — the seams need porting.

Design references

  • model.StoryTask.restore_patch — the persisted latch (already exists; bundle tasks reuse StoryTask).
  • verify.apply_patch(repo, patch_path) — the git apply helper (already exists; reusable as-is).
  • Engine._restore_patch — the apply/journal/escalate-on-failure helper and its feedback is None gating in _dev_phase (the pattern to mirror in the sweep dev loop).
  • runs.rearm_escalation(..., restore_patch=...) — the in-review vs ready-for-dev re-arm branch (the sweep bundle re-arm needs the equivalent).

The sweep resolve/re-arm entry point (however bundle escalations are resolved) would need a restore_patch passthrough analogous to cli.cmd_resolve.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions