FE-743: Petri parallel execution — concurrent firing, resource pools, worktree-per-slice#149
Conversation
PR SummaryMedium Risk Overview The interpreter adds The compiler moves CLI: Reviewed by Cursor Bugbot for commit 71a21e2. Bugbot is set up for automated code reviews on this repo. Configure here. |
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
🤖 Augment PR SummarySummary: This PR completes FE-743 by adding true parallel Petri-net execution, shared agent resource pools, and per-slice worktree isolation to reduce wall-clock time on multi-slice plans. Changes:
Technical Notes: Parallel execution aims for serial parity while allowing bounded concurrency via shared pool tokens. 🤖 Was this summary useful? React with 👍 or 👎 |
6ff7563 to
d4e9d95
Compare
d4e9d95 to
d43222e
Compare
8e56a7c to
f959557
Compare
d43222e to
55945f9
Compare
13953ca to
386c3cf
Compare
386c3cf to
0f5cdbf
Compare
f959557 to
1747538
Compare
0f5cdbf to
9e6a0e8
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 9e6a0e8. Configure here.
da2bb0d to
6c4fd65
Compare
2f0aba4 to
f1ff792
Compare
6c4fd65 to
c51fdb7
Compare
f1ff792 to
33a84c1
Compare
c51fdb7 to
e76b68a
Compare
Co-authored-by: Amp <amp@ampcode.com>
Parallel firing policy (petri-net.ts): - FiringPolicy = 'serial' | 'parallel' - runParallel: greedy token claiming + Promise.allSettled concurrent fire - Extracted isEnabled() private helper Shared resource pools (net-compiler.ts): - pool:test-agent / pool:code-agent replace per-slice agent places - agentPoolSize on RunPolicy bounds global concurrency - Worktree-per-slice: join(worktreeDir, sliceId) for all action contexts CLI (cook-cli.ts): - Retired dead --engine=proc|petri flag - Added --policy=serial|parallel wired to createOrchestrator Tests (engine-contract.test.ts): - Parallel added to all engines arrays (serial parity) - Concurrency proof, wall-clock benchmark, pool-bounded tests - Extracted withConcurrencyTracking() helper - Worktree isolation adapter test Decision gate passed: parallel measurably beats serial on wall clock. Co-authored-by: Amp <amp@ampcode.com>
Deposit fulfilled transition outputs even when a sibling sets ctx.halted in the same batch, matching serial commit semantics while still rolling back on handler rejection. Co-authored-by: Cursor <cursoragent@cursor.com>
e76b68a to
745c45a
Compare
33a84c1 to
71a21e2
Compare


TL;DR. Phase 2 of the Petri orchestrator arc: parallel firing policy with greedy token claiming, shared resource-pool tokens that cap global concurrency, and per-slice worktrees. Decision gate passed — parallel measurably beats serial on multi-slice plans.
What changed
Interpreter (
petri-net.ts)FiringPolicy = 'serial' | 'parallel'.runParallel()— greedy token claiming in registration order +Promise.allSettledconcurrent fire.isEnabled()helper (was inlined 3×); removed unusedhasTokens().Compiler (
net-compiler.ts)pool:test-agent/pool:code-agentplaces replace per-slice agent places.agentPoolSizeonRunPolicycaps global concurrency (default = slice count = unbounded).join(sandboxDir, sliceId)for all action contexts.CLI (
cook-cli.ts)--engine=proc|petriflag (proc engine deleted in FE-730).--policy=serial|parallelwired tocreateOrchestrator().Naming
worktreeDir→sandboxDiracross orchestrator files — disambiguates from git worktrees.Why now
Parallelism is the primary value claim for Petri over proc. Without it, both engines are serial and proc wins on simplicity. Decision gate: if parallel didn't beat proc on wall clock for a representative multi-slice fixture, the substrate commitment would have paused. It does.
Verification
serialandparallel.maxConcurrent > 1under parallel.agentPoolSize=1→ 1;=2→ 2; default → 3.npm run verifyclean.Traceability
Requirements 46–50; spec §3 (token taxonomy — resource tokens), §4 (canonical slice-net terminal join). Frontier
petri-parallel-executioninmemory/PLAN.md. Under umbrella H-6476.