Skip to content

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

Open
kostandinang wants to merge 11 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 11 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
Filesystem merge and sandbox path rules affect cook correctness and parallel slice isolation; mistakes could leak wrong artifacts into epic integration tests or overwrite in-flight slice work.

Overview
Epic verification no longer runs against the empty parent worktree. The Petri compiler rebuilds <parentSandboxDir>/__epic__/<epicId>/ from completed slice sandboxes (plan order; later slice wins on path clashes) immediately before verify-epic, logs an epic-sandbox-merged report with conflicts, and passes that merged tree to the handler. Per-slice worktrees stay untouched.

A new epic-sandbox-merge module centralizes merge logic, dependency-aware seedSliceSandboxFromDeps (preserve vs reset for parallel/rework), path-safety checks, and helpers to pick epic/slice ids for merge (including cross-epic slice deps). Slice actions/tests/assess now seed deps at fire time with preserveExisting: true instead of relying on a static per-slice dir only.

SPEC adds invariant I124-K; PLAN marks petri-epic-verification-merge done and drops the open “epic verification sandbox scope” note from graph-compilation. Contract tests assert merged epic dirs and the merge event; a large dedicated unit suite covers merge/seed edge cases.

Collateral: fixtures/txt/plan.yaml defers scaffolding epic verify and moves cli-scaffolding integration to text-ops; brunch --version / tests/version.test.ts ship the scaffolding slice behavior.

Reviewed by Cursor Bugbot for commit 72abdb1. 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
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 2 times, most recently from 6f78604 to 421f18b Compare May 27, 2026 23:21
@kostandinang kostandinang force-pushed the ka/fe-745-petri-epic-verification-merge branch 2 times, most recently from 78bf6ee to 98729e9 Compare May 28, 2026 10:34
@kostandinang kostandinang force-pushed the ka/fe-743-petri-parallel-execution branch from 421f18b to 9878f8c Compare May 28, 2026 10:34
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 98729e9. Configure here.

Comment thread src/orchestrator/src/epic-sandbox-merge.ts
@kostandinang kostandinang force-pushed the ka/fe-745-petri-epic-verification-merge branch from 7cc596c to b8a1514 Compare May 28, 2026 12:59
@kostandinang kostandinang force-pushed the ka/fe-743-petri-parallel-execution branch from 9878f8c to 1de40c9 Compare May 28, 2026 12:59
kostandinang and others added 11 commits May 29, 2026 14:25
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>
Mark epics before recursing into depends_on so cyclic epic graphs cannot blow the stack; add regression test.

Co-authored-by: Cursor <cursoragent@cursor.com>
@kostandinang kostandinang force-pushed the ka/fe-743-petri-parallel-execution branch from 1de40c9 to 8e41132 Compare May 29, 2026 12:27
@kostandinang kostandinang force-pushed the ka/fe-745-petri-epic-verification-merge branch from b8a1514 to 72abdb1 Compare May 29, 2026 12:27
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