graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs
Python
Keep fork routing guards aligned with the shared runner
Rach Pradhan01839583b0e0
diff --git a/src/pipeline_score.zig b/src/pipeline_score.zigindex 04ed8986..8db31c59 100644--- a/src/pipeline_score.zig+++ b/src/pipeline_score.zig@@ -182,5 +182,5 @@ test "#296/#290 firewall: capture is per STAGE after the join, and every item ruconst seat_at = std.mem.indexOf(u8, src, "sp.seat = route_phase.forPhase(").?;try std.testing.expect(seat_at < std.mem.indexOf(u8, src, "ctx.io.async(pipelineChain").?);// Both spawn attempts — first try and retry — receive that seat verbatim.- try std.testing.expectEqual(@as(usize, 2), std.mem.count(u8, src, "st.isolation_fallback, st.seat.pin, null)"));+ try std.testing.expectEqual(@as(usize, 2), std.mem.count(u8, src, "st.isolation_fallback, st.seat.pin)"));}diff --git a/src/route_policy_tests.zig b/src/route_policy_tests.zigindex ca38a4bc..e9873c1d 100644--- a/src/route_policy_tests.zig+++ b/src/route_policy_tests.zig@@ -328,8 +328,9 @@ test "#372/#376 firewall: a phase task takes the PHASE's seat, and still no per-// The trace makes routing VISIBLE; #376 lets the policy make it VARY —// but only per PHASE, never per task inside one. workflowTask and// workflowRetryTask are the only doors a phase task goes through, and- // both hand runSub the `seat` their caller resolved once for the whole- // phase (route_phase.forPhase), plus a null EFFORT: no axis of a phase+ // both hand runWorkflow the `seat` their caller resolved once for the whole+ // phase (route_phase.forPhase). Both wrapper paths pass null EFFORT:+ // no axis of a phase// task's configuration is readable off the task itself, so scoreVariants// keeps ranking prompt genomes that ran on one identical configuration.// Pinned as source text because the property is about the call site, not@@ -337,10 +338,15 @@ test "#372/#376 firewall: a phase task takes the PHASE's seat, and still no per-const src = @embedFile("subagent.zig");const wf = std.mem.indexOf(u8, src, "pub fn workflowTask(").?;const wf_end = std.mem.indexOf(u8, src[wf..], "\n}").?;- try std.testing.expect(std.mem.indexOf(u8, src[wf .. wf + wf_end], "isolation_fallback, seat, null)") != null);+ try std.testing.expect(std.mem.indexOf(u8, src[wf .. wf + wf_end], "runWorkflow(ctx, \"workflow_task\", label, prompt, sys_override, niche, isolation, isolation_fallback, seat)") != null);const rt = std.mem.indexOf(u8, src, "pub fn workflowRetryTask(").?;const rt_end = std.mem.indexOf(u8, src[rt..], "\n}").?;- try std.testing.expect(std.mem.indexOf(u8, src[rt .. rt + rt_end], "isolation_fallback, seat, null)") != null);+ try std.testing.expect(std.mem.indexOf(u8, src[rt .. rt + rt_end], "runWorkflow(ctx, \"workflow_retry\", label, prompt, sys_override, niche, isolation, isolation_fallback, seat)") != null);+ const wrapper = std.mem.indexOf(u8, src, "pub fn runWorkflow(").?;+ const wrapper_end = std.mem.indexOf(u8, src[wrapper..], "\n}").?;+ const wrapper_src = src[wrapper .. wrapper + wrapper_end];+ try std.testing.expect(std.mem.indexOf(u8, wrapper_src, "foregroundKind(ctx, kind, label, prompt, system, niche, isolation, fallback, seat, null)") != null);+ try std.testing.expect(std.mem.indexOf(u8, wrapper_src, "runSub(ctx, kind, label, prompt, system, niche, isolation, fallback, seat, null)") != null);// `seat` is a parameter of both, never derived from the task's own fields.try std.testing.expect(std.mem.indexOf(u8, src[wf .. wf + wf_end], "isolation_fallback: bool, seat: ?Provider)") != null);try std.testing.expect(std.mem.indexOf(u8, src[rt .. rt + rt_end], "isolation_fallback: bool, seat: ?Provider)") != null);diff --git a/src/schema_agents.zig b/src/schema_agents.zigindex 240531ec..4e0874a7 100644--- a/src/schema_agents.zig+++ b/src/schema_agents.zig@@ -3,7 +3,7 @@ const ToolSpec = @import("schema.zig").ToolSpec;pub const subagent_spec = ToolSpec{.name = "subagent",- .desc = "Delegate a sidecar task; children have file, shell, codedb and skill tools and cannot spawn children. By default they get the user's request, not full history; fork_from explicitly copies a conversation. Brief once with context, prompt, established_facts, scope and deliverable. Keep critical-path work local; use disjoint write sets for parallel tasks. Do not set model without a user request or task-specific reason. agent selects a persona; system_prompt overrides it. retained=true preserves history and workspace for follow-up; otherwise the worker is ephemeral. Interactive calls run in background by default; run_in_background=false waits for the child's report on every surface. Headless calls wait by default. agent_message queues feedback without starting a turn; subagent_resume continues a completed worker. agent_output fetches background results; wait_ms>0 waits in headless mode. Do not poll.",+ .desc = "Delegate a sidecar task with file, shell, codedb and skill tools; children cannot spawn children. Default context is the user's request; fork_from opts into full history. Brief once with context, prompt, established_facts, scope and deliverable. Keep critical-path work local; use disjoint write sets for parallel tasks. Do not set model without a user request or task-specific reason. agent selects a persona; system_prompt overrides it. retained=true preserves history and workspace for follow-up; otherwise the worker is ephemeral. Interactive calls run in background by default; run_in_background=false waits for the child's report on every surface. Headless calls wait by default. agent_message queues feedback without starting a turn; subagent_resume continues a completed worker. agent_output fetches background results; wait_ms>0 waits in headless mode. Do not poll.",.schema =\\{"type": "object", "properties": {"description": {"type": "string", "description": "Short label for logs, 3-5 words"}, "prompt": {"type": "string", "description": "Numbered steps and search hints; the complete task. Optional context/established_facts/scope/deliverable render as headed sections around this"}, "context": {"type": "string", "description": "Optional: repo and hard constraints the child must not re-derive"}, "established_facts": {"type": "string", "description": "Optional: observed facts, paths, and line numbers the child must treat as given"}, "scope": {"type": "string", "description": "Optional: what not to touch or broaden into"}, "deliverable": {"type": "string", "description": "Optional: required report shape; default is files changed, verified, skipped, open questions"}, "agent": {"type": "string", "description": "Optional: a named agent type (reviewer, researcher, implementer, skeptic, or a .harness/agents/ name) whose persona the child runs with"}, "system_prompt": {"type": "string", "description": "Optional: replace the child's system prompt with a custom one (overrides agent)"}, "model": {"type": "string", "description": "Optional: run THIS child on an exact model name available on the current provider (e.g. \"gpt-6-luna\"). Highest precedence — beats the persona's own pin and the session default. Ignored (spawn still runs on the session default, with a trace note) if the name is unknown, ambiguous, or not served by this provider — except that a logged-in flat-rate subscription serving the exact name honors it (sub-first routing; the login is the standing consent). For a portable 'cheapest seat' ask, tier is still the better lever."}, "tier": {"type": "string", "enum": ["frontier", "mid", "small"], "description": "Optional: run THIS child on a rung of the current provider's model ladder instead of an exact name — frontier (planner/judge class), mid (reviewers, implementers, researchers), small (mechanical transform/extract/label). Prefer this over model: it stays correct when the root model changes. If the provider has no ladder or no model at that rung, sub-first routing seats the child on a logged-in flat-rate subscription's rung when one exists (no login → the pin is ignored); model wins if both are given."}, "effort": {"type": "string", "enum": ["low", "medium", "high", "xhigh", "max", "none"], "description": "Optional: reasoning effort for THIS child — beats the persona's effort: frontmatter; unpinned children run at medium. An axis independent of model/tier: an effort-only override keeps the persona's model pin. none disables thinking only on supported binary-thinking routes and is rejected before child inference elsewhere. An off-vocabulary value is ignored with a trace note."}, "isolation": {"type": "string", "enum": ["shared_cwd", "worktree"], "description": "Optional: independent / fan-out children default to \"worktree\" (own branch + checkout; clean unchanged trees are removed unless retained=true; dirty or uniquely committed trees are kept + reported). Use \"shared_cwd\" only for same-branch collaboration (review + fix, a pipeline). isolation_fallback:true is the only way a failed git worktree add may share the caller tree."}, "isolation_fallback": {"type": "boolean", "description": "Optional: if isolation:\"worktree\" fails to set up (not a git repo, git error), run in the shared working tree instead of failing the spawn. Default false (fails the spawn on setup failure)."}, "fork_from": {"type": "string", "description": "Optional: fork conversation history from current, session:<project-local saved name>, or worker:<owned retained task_id>. Source stays unchanged. Child keeps its own tools, instructions and selected workspace. Cross-wire text/tool evidence transfers; opaque compaction requires the original model and images require the original wire. Use retained:true to continue the new child later."}, "retained": {"type": "boolean", "description": "Optional: persist conversation and workspace for subagent_resume (default false)."}, "run_in_background": {"type": "boolean", "description": "Optional: true starts asynchronously and immediately returns an agent id; false explicitly waits for the child report on every surface. Defaults to true in interactive sessions and false in headless sessions. Do not poll; agent_output(wait_ms>0) blocks until it finishes. A spawn at the live concurrency cap is refused; do not spawn a child to clean up a finished worktree."}}, "required": ["description", "prompt"]},