📚Grammar (EBNF/Sketch)
Program := Stmt*;
Stmt := Spawn | Route | Gather | WithSLA | Contract | Blackboard | Event;
Spawn := "spawn" Identifier CapabilityList? Options?;
Route := "route" Task "to" AgentRef Options?;
Gather := "gather" "{" Route+ "}" Reducer?;
WithSLA := "with_sla" "{" Constraint+ "}" Stmt+ "end";
Contract := "contract" PartyList ObligationList;
Blackboard := "blackboard" ("put" | "get" | "del") Key Value?;
Event := ("on" EventName Block) | ("emit" EventName Payload?);
🧩spawn
Create an agent with declared capabilities and policies.
spawn vision_agent id=V1 caps=["detect","track"] policy={retry:2,timeout:2s}
spawn master_agent id=M caps=["plan","allocate"]
spawn action_agent id=A1 caps=["evacuate","medic"]
Pre: id ∉ Agents
Post: Agents' := Agents ∪ {⟨id,caps,policy⟩}
➡️route
Send a task to a target agent (capability-aware), honoring policy.
route task detect_hotspots(area=S2) to V1 {deadline:1.0s}
route task plan_evac(zone=Z1) to M
Effect: Queue[target] := Queue[target] ⧺ ⟨task,deadline,caller⟩
Failure: if timeout→ emit timeout(task,target)
🔗gather
Fan-out multiple routes and reduce results.
gather {
route task scan(tile=1) to V1
route task scan(tile=2) to V1
} reduce=concat
Wait for all subtasks or SLA window; apply reducer R over results.
⏱️with_sla
Constrain blocks with deadlines, budgets, retries; violations emit events.
with_sla { deadline:2s, budget: $0.10, retry:1 }
route task triage(patient=P1) to M
end
Decorator installs monitors; on breach → emit sla_violation(meta)
📜contract
Specify obligations between parties; runtime checks assertions.
contract parties [M, A1] {
obligation A1: ack within 500ms
obligation M : provide route within 1s
}
Adds guards to message handlers; violations raise contract_violation.
🗂️blackboard
Shared knowledge store for publish/lookup across agents.
blackboard put risk_map@t := compute_risk(S2)
route task plan with map=blackboard get risk_map@t to M
Map K→V; put overwrites; get yields ⟨val,ts⟩ or ⊥.
📡on / emit
Event-driven coordination: agents subscribe with on, others emit.
on timeout(t): route task retry(t) to M
emit incident_detected { loc:S2, severity:HIGH }
Append handler to dispatch table; emit enqueues event for subscribers.
[00:00] Primitives viewer ready. Choose an example to render an execution trace.