Skip to content

Commit 084ab6b

Browse files
fahchenclaude
andauthored
feat(examples): pi-agent livemd — coding agent as CPN (#93)
## Summary Adds `examples/pi_agent.livemd` modeling a [pi.dev](https://pi.dev)-style coding agent as a Coloured Petri Net, in three progressive sections that share state, runtime, and a left/right Kino UI. | | Adds | CPN feature | |---|---|---| | **A** | minimal ReAct cycle | deferred choice, free output bindings, self-driving via `action` | | **B** | risky-tool human gate | union colour set, workitem held in `:enabled` until human fires | | **C** | provider race + steering + plan-then-act gate | concurrent enabled workitems, externally-fed input place, three-way human review | Section C plan gate exposes three exits — Approve / Reject / Manual override — each landing a `{:user, _}` line in the dialog so the next planning round (`MockLLM.proposal_text/2`) quotes the human's note back into the proposal. The right column shows the runner's `Occurrence` history live (via `Storage.occurrences_stream/2`); controls only appear when their target gate is open and clear when the enactment terminates. Drive-by lib fix: `ColouredFlow.Definition.Presentation.to_mermaid/1` switched from the dash arc form (`A --label--> B`) to the pipe form with quoted labels (`A -->|"label"| B`) so labels containing `[`, `{`, `"`, etc. — common in CPN inscriptions like `{1, d ++ [tool: tr]}` — render in mermaid without parser errors. Existing presentation tests updated to match. ## Test plan - [x] `mix test test/coloured_flow/definition/presentation_test.exs` (3 tests, 0 failures) - [x] `mix compile --warnings-as-errors` clean - [x] Smoke run via `mix run`: A terminates with answer; C runs 13-event sequence covering propose → manual_input → reject → approve → run → merge → answer - [x] End-to-end via Livebook: open `examples/pi_agent.livemd`, all 3 sections render dialog (left top), controls (left bottom, only when actionable), event history (right); ✅ done footer + cleared controls on termination - [x] Mermaid arc labels with brackets / quotes / `<>` render without "Syntax error in text" iframe --------- Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
1 parent f3f0d73 commit 084ab6b

3 files changed

Lines changed: 1230 additions & 23 deletions

File tree

0 commit comments

Comments
 (0)