Skip to content

FE-745: Epic-scoped sandbox merge for verify-epic#152

Open
kostandinang wants to merge 10 commits into
ka/fe-743-petri-parallel-executionfrom
ka/fe-745-petri-epic-verification-merge
Open

FE-745: Epic-scoped sandbox merge for verify-epic#152
kostandinang wants to merge 10 commits into
ka/fe-743-petri-parallel-executionfrom
ka/fe-745-petri-epic-verification-merge

Conversation

@kostandinang
Copy link
Copy Markdown
Contributor

@kostandinang kostandinang commented May 22, 2026

Summary

  • verify-epic now runs in a merged tree at <parentSandbox>/__epic__/<epicId>/ built from completed slice sandboxes, following plan order (later slice wins on duplicate relative paths).
  • Adds epic-sandbox-merge handler/transition and epic-sandbox-merged report event; SPEC invariant I124-K captures merge semantics for reviewers and future automation.

Context

  • FE-743 gave each slice an isolated sandbox and enabled parallel firing. Epic integration tests that span multiple slices previously executed in an empty parent sandbox, so multi-slice plans with cross-slice checks could not pass honestly.
  • Merge order follows plan topology so dependency direction is reflected in which slice artifacts land in the epic tree when paths collide.
  • Follow-up fixes in this branch address parallel races, rework orphans, and dependency seeding so merge does not overwrite in-flight slice work.

What changed

  • epic-sandbox-merge: assembles slice outputs into an epic-scoped directory immediately before verify-epic runs.
  • Dependency-aware seeding and pruning so parallel rework and cross-epic dependencies preserve completed slice artifacts and do not leave orphan sandboxes.
  • Reserved __epic__ slice id rejected at validation time to prevent merge namespace poisoning.

Verification

  • Five focused merger unit tests plus updated engine contract coverage on the epic verification path.
  • npm run verify green.

Out of scope

  • Declarative conditional output arcs and static reachability (FE-747).
  • Promoting cook branches or merging run results back to the user’s main branch (artifact lifecycle frontier).

Traceability

  • Requirement 49; decision D159-K; invariant I124-K; frontier petri-epic-verification-merge in memory/PLAN.md; umbrella H-6476.

@cursor
Copy link
Copy Markdown

cursor Bot commented May 22, 2026

PR Summary

Medium Risk
Changes orchestrator filesystem layout and merge semantics on the critical cook/verify path; mistakes could hide missing slice artifacts or corrupt parallel slice sandboxes, though coverage is strong.

Overview
Epic verify-epic no longer runs in the empty parent worktree. Before verify-epic, the orchestrator rebuilds <parentSandboxDir>/__epic__/<epicId>/ by merging completed slice worktrees (dependency epics and cross-epic slice deps included, in plan declaration order). Colliding paths keep the later slice’s file; conflicts are recorded and emitted as an epic-sandbox-merged report event. Slice worktrees are not modified by the merge.

Per-slice execution now seeds each slice sandbox from completed dependency worktrees (seedSliceSandboxFromDeps), with preserveExisting on actions/tests so parallel runs and rework do not blindly overwrite in-flight edits; full re-seed can prune orphans on rework reset.

New module epic-sandbox-merge plus broad unit/contract tests; memory/SPEC.md adds invariant I124-K; memory/PLAN.md marks petri-epic-verification-merge done. The txt fixture plan shifts epic integration tests to text-ops and defers scaffolding epic verify until more slices exist.

Also in the diff: brunch --version / -V (from package.json) with tests/version.test.ts.

Reviewed by Cursor Bugbot for commit 78bf6ee. Bugbot is set up for automated code reviews on this repo. Configure here.

@kostandinang kostandinang changed the title FE-745: merge slice worktrees into epic-scoped dir for verify-epic FE-745: Merge slice worktrees into epic-scoped dir for verify-epic May 22, 2026
@augmentcode
Copy link
Copy Markdown

augmentcode Bot commented May 22, 2026

🤖 Augment PR Summary

Summary: This PR fixes multi-slice epic verification by running verify-epic against a deterministic, freshly-merged epic-scoped sandbox directory.

Changes:

  • Added mergeSlicesIntoEpicSandbox to materialize <parentSandboxDir>/__epic__/<epicId>/ from completed slice worktrees, with last-wins collision handling.
  • Updated the Petri net compiler’s verify-epic wiring to invoke the merger and emit a new epic-sandbox-merged report event.
  • Extended contract coverage to assert verify-epic receives the merged epic sandbox and that the merge event is logged.
  • Documented the new invariant (I124-K) and marked the related plan frontier item as completed.

Technical Notes: Merge order follows slice declaration order; later slices overwrite earlier paths and conflicts are surfaced in the event payload. Per-slice worktrees remain unmodified and the epic sandbox is rebuilt on each verification run.

🤖 Was this summary useful? React with 👍 or 👎

Copy link
Copy Markdown

@augmentcode augmentcode Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 1 suggestion posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

Comment thread src/orchestrator/src/epic-sandbox-merge.ts Outdated
Comment thread src/orchestrator/src/epic-sandbox-merge.ts Outdated
Comment thread src/orchestrator/src/epic-sandbox-merge.ts
Comment thread src/server/cli.ts
Comment thread src/orchestrator/src/epic-sandbox-merge.ts Outdated
@kostandinang kostandinang force-pushed the ka/fe-743-petri-parallel-execution branch from 0f5cdbf to 9e6a0e8 Compare May 25, 2026 10:20
@kostandinang kostandinang force-pushed the ka/fe-745-petri-epic-verification-merge branch from 701c569 to 257e1e0 Compare May 25, 2026 10:26
Comment thread src/orchestrator/src/epic-sandbox-merge.ts
@kostandinang kostandinang force-pushed the ka/fe-745-petri-epic-verification-merge branch from 1b11685 to ad5652f Compare May 25, 2026 11:02
@kostandinang kostandinang force-pushed the ka/fe-743-petri-parallel-execution branch from 97540d6 to 2f0aba4 Compare May 25, 2026 11:02
@kostandinang kostandinang force-pushed the ka/fe-745-petri-epic-verification-merge branch from ad5652f to fb39377 Compare May 25, 2026 11:05
@kostandinang kostandinang force-pushed the ka/fe-743-petri-parallel-execution branch 2 times, most recently from f1ff792 to 33a84c1 Compare May 25, 2026 11:17
@kostandinang kostandinang force-pushed the ka/fe-745-petri-epic-verification-merge branch from fb39377 to 2436dd5 Compare May 25, 2026 11:17
@kostandinang kostandinang force-pushed the ka/fe-743-petri-parallel-execution branch from 33a84c1 to 71a21e2 Compare May 25, 2026 11:23
@kostandinang kostandinang force-pushed the ka/fe-745-petri-epic-verification-merge branch from 2436dd5 to 46fe008 Compare May 25, 2026 11:23
Comment thread src/orchestrator/src/net-compiler.ts Outdated
Comment thread src/orchestrator/src/epic-sandbox-merge.ts
Comment thread src/orchestrator/src/epic-sandbox-merge.ts
Comment thread src/orchestrator/src/epic-sandbox-merge.ts
Comment thread src/orchestrator/src/net-compiler.ts
Comment thread src/orchestrator/src/epic-sandbox-merge.ts
Comment thread src/orchestrator/src/net-compiler.ts
Comment thread src/orchestrator/src/net-compiler.ts Outdated
@kostandinang kostandinang self-assigned this May 26, 2026
Comment thread src/orchestrator/src/epic-sandbox-merge.ts
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 22167d1. Configure here.

Comment thread src/orchestrator/src/epic-sandbox-merge.ts
@kostandinang kostandinang changed the title FE-745: Merge slice worktrees into epic-scoped dir for verify-epic FE-745: Epic-scoped sandbox merge for verify-epic May 27, 2026
@kostandinang kostandinang force-pushed the ka/fe-745-petri-epic-verification-merge branch from b5c8c77 to 9ea1a4d Compare May 27, 2026 23:16
@kostandinang kostandinang force-pushed the ka/fe-743-petri-parallel-execution branch from 71a21e2 to 6f78604 Compare May 27, 2026 23:16
kostandinang and others added 10 commits May 28, 2026 01:20
verify-epic now runs against a freshly-merged <parentSandboxDir>/__epic__/<epicId>/
built from the epic's completed slice worktrees. Slices apply in plan declaration
order; later slices overwrite earlier ones on the same path and the collision is
reported via the new epic-sandbox-merged event. Per-slice worktrees are not mutated.

Unblocks multi-slice cook runs (verify-epic previously fell back to the empty
parent worktree root, halting every multi-slice plan).

- new src/orchestrator/src/epic-sandbox-merge.{ts,test.ts}
- net-compiler.ts verify-epic case wires the merger + emits epic-sandbox-merged
- engine-contract.test.ts: 'verify-epic receives parent sandboxDir' assertion
  updated to pin the new __epic__/<epicId>/ invariant
- memory/SPEC.md: new I124-K invariant alongside I123-K
- memory/PLAN.md: petri-epic-verification-merge → Recently Completed; bullet
  retired from petri-graph-compilation (no longer blocked on FE-700)
Validate epic/slice ids and relative paths, skip symlinks during merge walks, handle file/directory collisions safely, and only honor --version as a top-level flag.

Co-authored-by: Cursor <cursoragent@cursor.com>
Slice sandboxes must not collide with the epic merge root; skip any
accidental epic-root paths during merge and mirror the guard in net-compiler.

Co-authored-by: Cursor <cursoragent@cursor.com>
Defer scaffolding epic verify in fixtures/txt plan and move CLI integration
tests to text-ops. Merge verify-epic from worktree/<epicId>/ trees in plan
order (target plus transitive deps) so slice work accumulates per epic
instead of per-slice last-winner overwrites such as cli.ts.

Co-authored-by: Cursor <cursoragent@cursor.com>
Restore per-slice runtime sandboxes with dependency seeding so parallel
slices do not corrupt a shared epic worktree. verify-epic merges completed
slice worktrees and follows slice depends_on across epics, not just epic
depends_on.

Co-authored-by: Cursor <cursoragent@cursor.com>
…rphans.

Use preserveExisting for post-action test/assess passes; on action/rework reset, drop paths outside the dependency baseline before overlaying deps.

Co-authored-by: Cursor <cursoragent@cursor.com>
The generic action transition was calling seedSliceSandboxFromDeps without preserveExisting, wiping files from prior steps in dependent slices.

Co-authored-by: Cursor <cursoragent@cursor.com>
Seed dependency files in plan declaration order, always drop paths
outside dep trees even when preserveExisting is set, and reuse
resolveSliceWorktreeDir from net-compiler.

Co-authored-by: Cursor <cursoragent@cursor.com>
Re-seeding before assess/run-tests must not delete slice-owned artifacts
that are absent from dependency worktrees.

Co-authored-by: Cursor <cursoragent@cursor.com>
visitSliceDeps now tracks visited slice ids so malformed plans
with circular slice.depends_on cannot blow the stack.

Co-authored-by: Cursor <cursoragent@cursor.com>
@kostandinang kostandinang force-pushed the ka/fe-743-petri-parallel-execution branch from 6f78604 to 421f18b Compare May 27, 2026 23:21
@kostandinang kostandinang force-pushed the ka/fe-745-petri-epic-verification-merge branch from 9ea1a4d to 78bf6ee Compare May 27, 2026 23:21
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