Skip to content

FE-745: Merge slice worktrees into epic-scoped dir for verify-epic#152

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

FE-745: Merge slice worktrees into epic-scoped dir for verify-epic#152
kostandinang wants to merge 8 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

TL;DR. verify-epic now runs against a freshly-rebuilt <parentSandboxDir>/__epic__/<epicId>/ produced by merging the epic's completed slice worktrees in plan declaration order. Unblocks multi-slice cook runs end-to-end.

What changed

  • New epic-sandbox-merge.{ts,test.ts} — union of completed slice worktrees in plan declaration order; later slices overwrite earlier on path collisions; collisions surfaced via the new epic-sandbox-merged event; per-slice worktrees not mutated.
  • net-compiler.tsverify-epic case wires the merger and emits epic-sandbox-merged before invoking the action.
  • engine-contract.test.ts — pins the __epic__/<epicId>/ invariant.
  • memory/SPEC.md — adds invariant I124-K.
  • memory/PLAN.mdpetri-epic-verification-merge moved to Recently Completed.

Why now

verify-epic previously fell back to the empty parent worktree root, halting every multi-slice plan with cross-slice integration verification. Closes the last gap from the FE-730 → FE-738 → FE-743 PoC arc — the orchestrator now finishes a real multi-slice plan end-to-end.

Verification

5 new unit tests for the merger + updated engine contract test pin the new sandbox layout. npm run verify green.

Traceability

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

@cursor
Copy link
Copy Markdown

cursor Bot commented May 22, 2026

PR Summary

Medium Risk
Changes orchestrator filesystem layout and verify-epic inputs; behavior is heavily tested but affects multi-slice cook correctness.

Overview
Epic verification no longer runs against the empty parent worktree. Before verify-epic, the Petri compiler rebuilds <parentSandboxDir>/__epic__/<epicId>/ by merging completed slice worktrees (dependency epics and cross-epic slice deps included, plan declaration order; later slice wins on path clashes). Collisions are recorded on a new epic-sandbox-merged report; source slice dirs are not modified.

New epic-sandbox-merge module covers merge, path safety, and seedSliceSandboxFromDeps (dependency files into per-slice sandboxes at action/test fire time, with optional preserveExisting). net-compiler wires merge + event emission and drops the old parent-sandbox fallback.

engine-contract and dedicated merge tests lock the layout and merge behavior. memory/SPEC.md adds invariant I124-K; memory/PLAN.md marks petri-epic-verification-merge done and drops the open “epic verification sandbox” note from graph-compilation.

Fixture plan (fixtures/txt/plan.yaml): scaffolding epic verify deferred; text-ops epic gains the cli-scaffolding integration target. CLI: --version / -V prints package.json version (tests/version.test.ts).

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

Copy link
Copy Markdown
Contributor Author

kostandinang commented May 22, 2026

@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 and others added 3 commits May 25, 2026 13:23
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>
@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
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>
Comment thread src/orchestrator/src/net-compiler.ts Outdated
Comment thread src/orchestrator/src/epic-sandbox-merge.ts
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>
Comment thread src/orchestrator/src/epic-sandbox-merge.ts
Comment thread src/orchestrator/src/epic-sandbox-merge.ts
…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>
Comment thread src/orchestrator/src/net-compiler.ts
@kostandinang kostandinang requested a review from lunelson May 26, 2026 07:54
The generic action transition was calling seedSliceSandboxFromDeps without preserveExisting, wiping files from prior steps in dependent slices.

Co-authored-by: Cursor <cursoragent@cursor.com>
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
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>
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 485f88e. Configure here.

}
}
pruneEmptyDirs(sliceDir);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

preserveExisting seed deletes slice files

High Severity

The seedSliceSandboxFromDeps function, even with preserveExisting: true, removes files from the slice sandbox that are not provided by its dependencies. This unintended pruning deletes slice-owned artifacts before critical processing steps, breaking slices that rely on their own files.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 485f88e. Configure here.

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