FE-738: Petri semantic lanes with two-lane subnet and engine factory#148
FE-738: Petri semantic lanes with two-lane subnet and engine factory#148kostandinang wants to merge 7 commits into
Conversation
|
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. |
PR SummaryMedium Risk Overview Each slice now has a mechanical lane (evaluate → write-tests → write-code → run-tests → Compiler refactor: Interpreter: optional Planning docs: Reviewed by Cursor Bugbot for commit 78706a2. Bugbot is set up for automated code reviews on this repo. Configure here. |
🤖 Augment PR SummarySummary: This PR evolves the Petri-net orchestrator by introducing distinct mechanical vs semantic completion lanes, and refactors compilation/execution so the net shape is testable as pure data. Changes:
Technical Notes: Topology-only adapter tests no longer require action handlers/test runners, and runtime wiring now interprets declarative handler descriptors from the blueprint. 🤖 Was this summary useful? React with 👍 or 👎 |
b72d1ad to
934ea57
Compare
8e56a7c to
f959557
Compare
f959557 to
1747538
Compare
da2bb0d to
6c4fd65
Compare
934ea57 to
ab20ef2
Compare
ab20ef2 to
5585e4e
Compare
e76b68a to
745c45a
Compare
745c45a to
78b15a6
Compare
44300a6 to
052f6e7
Compare
- Add semantic-gate and semantic-satisfied places per slice - Add assess-semantic transition joining done-spec + semantic-gate - On pass: produces semantic-satisfied → return-done proceeds - On fail: routes to needs-more, forcing another TDD rework cycle - return-done now consumes semantic-satisfied (not done-spec directly) - PlanDoneAccepted is topologically unreachable without semantic satisfaction - New contract test #10: semantic gate rejects then accepts - Updated all call-order assertions and adapter test counts Co-authored-by: Amp <amp@ampcode.com>
- Define TransitionContract type (kind, lane, actor, guard) in petri-net.ts - Add contract field to TransitionDef (optional, no behavioral change) - Populate contract metadata for all compiled transitions: mechanical-lane (evaluate, write-tests, write-code, run-tests), semantic-lane (assess-semantic, return-done), structural (slice-ready, epic-complete, epic-deps-met) - Add getTransitions() accessor on PetriNet for inspection - New adapter test verifies contract metadata classification Co-authored-by: Amp <amp@ampcode.com>
- Define NetEvent, NetEventKind, NetEventSink types in petri-net.ts - PetriNet.run() accepts optional event sink (backward compatible) - Emits transition_fired with id, contract, consumed/produced places - Emits net_halted when shouldHalt() triggers - Emits net_deadlocked when no transition enabled but tokens remain - New adapter tests: happy-path event capture + retry-exhaustion halt - Note: deadlock detection is coarse (leftover resource tokens trigger it on clean completion); refined detection is future work Co-authored-by: Amp <amp@ampcode.com>
Co-authored-by: Amp <amp@ampcode.com>
…dget - Split compilePlan into compileTopology (pure data → NetBlueprint) and wireHandlers (attaches fire closures). Adapter tests use topology-only. - Consolidate identical PetriOrchestrator/ProceduralOrchestrator into createOrchestrator(policy) factory. Delete engine-petri.ts/engine-proc.ts. - Move RunCtx from net-compiler.ts to types.ts (compiler is context-free). - Add semantic-budget place + reworkCount token to prevent infinite rework loops when assess-semantic always rejects (Finding #8 correctness fix). - HandlerDescriptor discriminated union (7 kinds) makes transition routing declarative in the blueprint. All descriptors carry actionKey explicitly. - New net-blueprint.ts for NetBlueprint/TransitionSkeleton/HandlerDescriptor types. - 1378 tests pass across 120 files. Co-authored-by: Amp <amp@ampcode.com>
…compilation Co-authored-by: Amp <amp@ampcode.com>
…ion. Register assess-semantic in createPiActions, replace the obsolete --engine flag with --policy wired to createOrchestrator, and skip net_deadlocked when only resource or completion tokens remain. Co-authored-by: Cursor <cursoragent@cursor.com>
052f6e7 to
6d35473
Compare
78b15a6 to
78706a2
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 78706a2. Configure here.
| expect(net.transitionCount).toBe(13); | ||
| // Should have a net_halted event (ctx.halted becomes true after retry exhaustion) | ||
| const halted = events.filter((e) => e.kind === 'net_halted'); | ||
| expect(halted.length).toBe(1); |
There was a problem hiding this comment.
Test name says "net_deadlocked" but asserts "net_halted"
Medium Severity
The test is named "retry exhaustion emits net_deadlocked" but the assertion on line 827 checks for net_halted events, not net_deadlocked. These are semantically distinct §7 events: net_halted fires when shouldHalt() returns true (external halt signal from ctx.halted), while net_deadlocked fires when no transition is enabled but work-bearing tokens remain. Retry exhaustion sets ctx.halted = true, triggering net_halted on the next loop iteration — it never produces a net_deadlocked event. The test name misrepresents what behavior is actually being verified, which could mislead developers reasoning about the event model.
Reviewed by Cursor Bugbot for commit 78706a2. Configure here.



Summary
Context
RunPolicy.maxSemanticReworks, so assess/eval cycles cannot run unbounded when the evaluator never marks a slice satisfied.What changed
evaluate → write-tests → write-code → run-tests; semantic pathassess-semantic → semantic-satisfied; completion requires progress on both lanes.TransitionContractmetadata on transitions plus §7 event vocabulary (transition_fired,net_halted,net_deadlocked) with enough structure for contract tests and future tooling.HandlerDescriptorunion and typed handler wiring at the subnet boundary instead of growing ad-hoc closure dispatch.compileTopologyproducesNetBlueprint;wireHandlersmaterializesPetriNet;createOrchestrator(policy)replaces duplicated orchestrator setup.Verification
npm run verify(fmt/lint check, test, build).Out of scope
Traceability
petri-semantic-lanesinmemory/PLAN.md; umbrella H-6476.