shepherd-compiler 6.6.0

Pure, deterministic Shepherd content compiler and prompt-budget engine.
# dispatch-scope — governs which role may dispatch which other role. The flock is closed
# at nine (content/skills/shepherd/SKILL.md §The flock is closed); this predicate is what
# a compiler reads to refuse an off-flock or wrong-tier dispatch attempt before it fires,
# on any harness's own dispatch primitive (Agent()/Workflow's agent() on Claude, spawn_agent
# on Codex, a subprocess invocation on Pi — the predicate is the same, the verb differs).
#
# JURISDICTION. Target-keyed rules govern dispatches ADDRESSED TO THIS FLOCK, and only
# those: a carrier address (`shepherd:coder`) or a bare flock role id (`coder`, for
# harnesses that do not prefix). A host agent (`general-purpose`, `Explore`) or another
# plugin's agent is not a tenth flock role — it is not a role at all, and refusing it
# would annex the harness's own dispatch primitive on behalf of a sprint contract the
# caller never entered. "Never invent a tenth role" forbids minting `shepherd:reviewer`;
# it does not forbid a session from using the agents its harness already ships.
# Dispatcher-keyed rules are unaffected and still evaluate for every target: an
# implementer may not fan out to anything, flock or not.

[predicate]
id = "dispatch-scope"
version = 3
description = "A dispatch is denied unless the target role is inside the closed flock AND the dispatching role's native edge permits that exact target: Conductor children are exactly Coder, Worker, and Auditor; Discovery is Engineer-owned; Conductor and Worker never receive external-research authority."

[[rule]]
id = "closed-flock-only"
description = "A dispatch addressed to this flock MUST name one of the nine content/roles/*.md role ids; a carrier-addressed target that is not a role id (`shepherd:reviewer`) is an invented tenth role and is refused. A target that is not addressed to this flock at all — a host agent, another plugin's agent — is outside this predicate's jurisdiction and is not its to refuse."
subject = "dispatch.target_role"
action = "dispatch"
effect = "deny_if_target_outside_flock"

[[rule]]
id = "root-profiles-are-never-dispatched"
description = "`planter` and `shepherd` are profiles the ROOT session adopts, not subagents. No role dispatches either one, root included: a root that needs the planter perspective adopts it in place, and dispatching one would mint a second root for a session that already has one."
subject = "dispatch.target_role"
action = "dispatch"
effect = "deny_if_target_is_root_profile"

[[rule]]
id = "plan-authorship-and-gating-are-root-tier-exclusive"
description = "A lane-executor lead (conductor) may not dispatch the plan-author (engineer), the gating role (critic), or another conductor; plan authorship, gating, and lane singleton ownership are reserved to the owning tier. The root profiles are covered by `root-profiles-are-never-dispatched`, which refuses them for every dispatcher rather than only for a lane lead."
subject = "dispatch.dispatcher_tier"
action = "dispatch"
effect = "deny_if_dispatcher_is_lane_lead_and_target_is_plan_or_gate_role"

[[rule]]
id = "implementer-roles-never-dispatch"
description = "An implementer role (coder, worker, discovery, auditor, critic) never dispatches any other role at all — a missing dependency is a scope-amendment request or a close-time finding on that same dispatch, never a nested dispatch."
subject = "role.tier"
action = "dispatch"
effect = "deny_if_dispatcher_is_implementer"

[[example]]
name = "root-dispatches-engineer-at-plan-authorship"
kind = "allow"
role = "shepherd"
action = "dispatch"
target_role = "engineer"
context = { dispatcher_tier = "root" }
result = "allow"

[[example]]
name = "conductor-dispatches-coder-inside-its-own-lane"
kind = "allow"
role = "conductor"
action = "dispatch"
target_role = "coder"
context = { dispatcher_tier = "lane-lead" }
result = "allow"

[[example]]
name = "conductor-attempts-to-dispatch-engineer"
kind = "deny"
role = "conductor"
action = "dispatch"
target_role = "engineer"
context = { dispatcher_tier = "lane-lead" }
result = "deny"
halt_code = "WRONG-TIER-DISPATCH"

[[example]]
name = "conductor-attempts-to-dispatch-the-planter"
kind = "deny"
role = "conductor"
action = "dispatch"
target_role = "planter"
context = { dispatcher_tier = "lane-lead" }
result = "deny"
halt_code = "DISPATCH-ROOT-PROFILE"

[[example]]
name = "conductor-attempts-to-dispatch-another-conductor"
kind = "deny"
role = "conductor"
action = "dispatch"
target_role = "conductor"
context = { dispatcher_tier = "lane-lead" }
result = "deny"
halt_code = "WRONG-TIER-DISPATCH"

[[example]]
name = "conductor-dispatches-worker-inside-its-own-lane"
kind = "allow"
role = "conductor"
action = "dispatch"
target_role = "worker"
context = { dispatcher_tier = "lane-lead" }
result = "allow"

[[example]]
name = "conductor-dispatches-auditor-inside-its-own-lane"
kind = "allow"
role = "conductor"
action = "dispatch"
target_role = "auditor"
context = { dispatcher_tier = "lane-lead" }
result = "allow"

[[example]]
name = "engineer-dispatches-discovery-for-orientation"
kind = "allow"
role = "engineer"
action = "dispatch"
target_role = "discovery"
context = { dispatcher_tier = "plan-author" }
result = "allow"

[[example]]
name = "conductor-attempts-to-dispatch-discovery"
kind = "deny"
role = "conductor"
action = "dispatch"
target_role = "discovery"
context = { dispatcher_tier = "lane-lead" }
result = "deny"
halt_code = "WRONG-TIER-DISPATCH"

[[example]]
name = "coder-attempts-to-dispatch-worker-for-a-missing-dependency"
kind = "deny"
role = "coder"
action = "dispatch"
target_role = "worker"
context = { dispatcher_tier = "implementer" }
result = "deny"
note = "a coder blocked on a missing dependency files a scope-amendment request on its OWN dispatch, it never dispatches another role to unblock itself."

[[example]]
name = "dispatch-outside-the-closed-flock"
kind = "deny"
role = "shepherd"
action = "dispatch"
target_role = "shepherd:reviewer"
context = { dispatcher_tier = "root" }
result = "deny"
halt_code = "DISPATCH-OFF-FLOCK"
note = "carrier-addressed to this flock but not one of the nine — the invented tenth role this rule exists to catch."

[[example]]
name = "root-attempts-to-dispatch-a-root-profile"
kind = "deny"
role = "shepherd"
action = "dispatch"
target_role = "planter"
context = { dispatcher_tier = "root" }
result = "deny"
halt_code = "DISPATCH-ROOT-PROFILE"
note = "the tier rules stop a LANE LEAD reaching upward; this stops anyone, root included, from spawning a second root."

[[example]]
name = "root-dispatches-a-host-agent-outside-this-predicate's-jurisdiction"
kind = "allow"
role = "shepherd"
action = "dispatch"
target_role = "general-purpose"
context = { dispatcher_tier = "root" }
result = "allow"
note = "a host agent is not a tenth flock role, it is not a role at all. Refusing it would take authority over the harness's own dispatch primitive, which this predicate does not have and was never granted."