Skip to content

Headless-permissions cluster: child-scoped rules (#32), LLM ask-reviewer (#31), model-backed guardrails (#27) - #57

Merged
JAORMX merged 4 commits into
mainfrom
feat/headless-permissions
Jun 13, 2026
Merged

JAORMX merged 4 commits into
mainfrom
feat/headless-permissions

Conversation

@JAORMX

@JAORMX JAORMX commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

The lane-2 headless-permissions cluster — three issues, each run through the full dev pipeline (architect plan → separate implementer → spec/standards/security/architecture/QA + UX + DevEx review panel → findings fixed, ~3 iterations each), committed per iteration, plus a consolidated docs-coherence pass.

#32 — child-scoped permission config axis (fcfe16c)

permissions.subagent.{allow,ask,deny} in .mecatl/settings.yaml tunes delegated children separately from the main session — the operator's knob between "interactive ask" and "auto-deny". governance.Audience on rules + WithAudience evaluator pin; child policies over AllowAllFloorRules() at ScopeBuiltinDefault; trust-gated project allows; strict unknown-key parse.

  • Security ship-blocker caught + fixed: a configured child-allow could auto-run arbitrary commands hidden in $(…). The fix (flooredAllowSafe) requires every substitution inner to independently classify read-only — the configured Allow vouches only for the outer literal.

#31 — headless LLM ask-reviewer (1b774d4)

When a headless deployment has no human to answer a subagent's borderline ask, an optional bounded quarantined LLM adjudicates instead of blanket auto-deny: fail-safe, allow-once, per-run deny circuit-breaker, whole-output verdict parse. Off by default; --subagent-ask-reviewer + --headless.

  • UX caught it was dead config on stock mecated (every session interactive → reviewer never fires) → added --headless; and a latent bug where mecatui auto-denied a human's child asks → embedded server now Interactive: true, child asks surface to the modal.

#27 — model-backed guardrails (a032412)

A modelhook port.HookRunner drives a quarantined checker model over tool I/O: PostToolUse for prompt-injection in inbound web/MCP results, PreToolUse for secret/exfil in outbound args — block / sanitize / advisory. Dual-LLM quarantine (tool-less, one-turn, no-recursion). Default advisory set for web/MCP when a model is configured; operator-tier-only config; --guardrails-model / --guardrails=off.

  • Security panel caught + fixed: sanitize-laundering (sanitized content re-entering unbounded), PostToolUse Block being inert (the tool already ran — enforce-block rewrites via Mutated-to-error), induced fail-open, and a cost-skip silently weakening exfil detection on the outbound direction. New docs/design/GUARDRAILS.md documents the threat model + residuals.

Docs (db9f789)

Consolidated coherence pass: README safety bullets + architecture adapter diagram / HookRunner port now name all three features (each issue's per-feature docs landed in its own commit).

All three are model-/operator-facing security features: every one is driven through the real harness with adversarial/uncooperative mocks (forged verdicts, prompt-injection in inspected content, garbage/empty checker turns), and the security findings were re-verified after each fix. Offline suite (task lint && task test, -race) green throughout. Label e2e-live applied to exercise the live lane.

🤖 Generated with Claude Code

JAORMX and others added 4 commits June 12, 2026 23:21
Closes issue #32. Operators tuning headless deployments now have a knob
between "interactive ask" and "auto-deny" for delegated children: a
permissions.subagent.{allow,ask,deny} block in .mecatl/settings.yaml.

Domain (engine/governance):
- governance.Rule gains Audience (AudienceAll zero-value / Main /
  Subagent); the evaluator's ruleMatches is symmetric-permissive so a
  subagent-tagged rule never binds a main-session decision and the main
  policy is pinned AudienceMain
- PermissionDecision.ConfiguredAsk (a configured-rule Ask is never
  isolation-auto-approved) and FlooredConfiguredAllow (a configured
  Allow clears a substitution-floored child ask ONLY when every
  recursively-extracted inner is independently read-only — the
  configured Allow vouches for the outer, never a hidden inner)
- flooredAllowSafe replaces the blocklist-only bound: positive
  inner-read-only contract + retained escape rejections as
  defense-in-depth; segmentIsolationApprovable now delegates to the one
  shared escapeRejectionsFree path (no list drift); A2/IsolationApprovable
  and all fuzzers byte-for-byte unchanged in outcome

Application (engine/agent): resolveChildAsk consumes the two bits — both
fail SAFE (ConfiguredAsk gated first), childAutoDenyMessage is
rule-oriented and accurate, surfaced asks now carry the policy reason so
an operator can tell a configured ask from a substitution-floor ask.

Adapter/composition: permconfig parses the subagent block with strict
unknown-key validation (typo'd keys skip the file with a WARN naming the
lost per-effect counts); project-tier subagent allows are trust-gated;
child policies are built over the canonical permpolicy.AllowAllFloorRules()
floor + a session-root-pinned resolver (fork-root settings never read) +
AudienceSubagent; --yolo stays main-only.

Tests: audience matrix, ConfiguredAsk/FlooredConfiguredAllow truth tables
incl. compound mixes and escape bounds, FuzzFlooredConfiguredAllow
positive-soundness, hidden-inner adversarial gating through the real
engine, both-bits fail-safe, cancel-while-parked on a configured ask,
team-member parity, strict-YAML arms, trust gate, per-session pin,
file-backed allow+deny e2e through the real wiring, main-pin kill test.

Docs: CLAUDE.md 4-step paragraph, usage.md schema + audience table +
baseline/cross-links, IMPLEMENTATION-NOTES, ALLOW-ALL-POSTURE, harnesses/09.

Co-Authored-By: Claude Fable 5 <[email protected]>
Closes issue #31. When a headless deployment has no human to answer a
subagent's borderline Bash ask (one that isn't read-only, isn't
isolation-auto-approvable, and isn't resolved by a configured #32 rule),
an optional bounded LLM reviewer adjudicates it instead of blanket
auto-denying — the dual-LLM quarantine pattern, off by default.

Placement: a new step in resolveChildAsk AFTER configured-rule
resolution + isolation auto-approve + the interactive surface check,
BEFORE the headless auto-deny; gated !ConfiguredAsk (a configured Ask
still demands a human, never an LLM) and headless-only. Shared across all
three delegation families (Subagent/Team/Parallel) via the one chokepoint.

Quarantine + safety:
- the reviewer is a tool-less, one-turn, no-hooks, no-nesting engine
  (child deps force the reviewer field nil); the asked command is fenced
  UNTRUSTED + neutraliseFraming'd (it's model-authored — it must not be
  able to prompt the judge), the policy/context is trusted-in-the-clear
- verdict parse requires the whole output to BE one {"allow":bool,
  "reason":string} object (a lone ```json fence tolerated) — a
  verdict-shaped object echoed inside the fenced command cannot be lifted
  out as the verdict
- allow -> VerdictAllowOnce (never learned); deny/error/timeout/ambiguity/
  breaker-open all fail SAFE to the existing auto-deny; a per-run deny
  circuit-breaker (default 3 consecutive non-allows, allow resets) bounds
  cost; 30s wall-clock per call; hardAbort treated as breaker-open
- the reviewer engine disables the no-progress nudge so an empty turn is
  exactly one model call, not a retry

Reachability: mecated gains --headless (sets Interactive=false) so the
reviewer/auto-deny path actually engages; normalizeAskReviewerModel
fail-fast-validates the model then WARNs INERT (not a misleading ACTIVE)
when configured on an interactive deployment. mecatui's embedded server
is now explicitly Interactive=true — child asks surface to the human's
approval modal (fixing a latent posture bug where they were auto-denied)
and the reviewer is correctly inert there. gRPC RunTeam-direct stays
zero-caps (no reviewer), documented.

API: ChildAskReviewer interface + ChildAskReviewRequest{Ask, Isolated}
(struct param so it can evolve additively) + ChildAskReview + an
ErrNotReviewable sentinel (abstain without tripping the breaker) +
NewEngineAskReviewer; Deps.ChildAskReviewer / .ChildAskReviewMaxDenies.
Config flags on mecated + mecatui embedded; reviewer model re-derived per
provider through the engine factory, never clone-and-swap.

Diagnostics: allow/deny/reviewer-failure/breaker-opened all ride the
existing child-ask INFO chokepoint (the three-line loop invariant holds);
the allow line carries the clamped command so the audit says what ran.

Tests: forged-verdict-echo + fail-safe matrix + prompt-injection-defanged
+ tolerant-parse, breaker open/reset, configured-rules-still-win,
interactive-not-consulted, off-by-default byte-identical, one-call-max,
abstain-doesn't-trip-breaker, surfaced-child-ask approve over the wire,
headless flag drives Interactive, e2e through the real engine+supervisor.

Co-Authored-By: Claude Fable 5 <[email protected]>
Closes issue #27. A new internal/adapter/modelhook port.HookRunner that,
for configured (phase, tool-matcher) pairs, drives a one-shot quarantined
checker model over tool I/O and maps a {safe,reason,sanitized_content}
verdict onto the existing HookOutcome — block / mutate-sanitize / advisory
pass-through. Pure adapter + composition; no core loop changes.

The complementary defense to the <<<UNTRUSTED fence: a quarantined model
INSPECTS tool boundaries. PostToolUse inspects inbound results (prompt
injection in web/MCP content); PreToolUse inspects outbound args
(exfiltration — secrets steered into a query / MCP body / issue comment).

Quarantine (the dual-LLM pattern): the checker is a tool-less, one-turn,
no-hooks, no-nesting child engine (built via childEngineDepsForProvider,
inert hooks — so a checker call can never re-trigger modelhook). The
inspected content is fenced UNTRUSTED + neutraliseFraming'd; the verdict
must be a single whole-output JSON object (the #31 ParseVerdict discipline,
shared via the now-exported agent.StripLoneCodeFence), so a verdict-shaped
object embedded in attacker content can't be lifted out. A fooled checker
degrades to "no checker" — it can never be escalated into an action.

Safety bounds (all fail toward block, never toward the unsafe original):
- enforce on a PostToolUse RESULT rewrites to {is_error, "blocked by
  guardrail: <reason>"} via Mutated — PostToolUse Block is INERT (the tool
  already ran), so Block is used only for PreToolUse vetoes
- sanitize: nil / oversized (>64KiB) / Pre-invalid-JSON sanitized_content
  all fall back to block; Post-sanitize prepends a redaction marker so the
  model knows content was altered; the re-entering content is size-bounded
- oversized content (>256KiB) never silently fails open in enforce
- MinContentBytes cost-skip applies to PostToolUse only — outbound args are
  always inspected (a short Pre arg can carry a whole exfil credential)
- fail-open by default on checker error/timeout with a loud, sticky
  "checker DOWN — tool I/O is UNGUARDED" WARN after N consecutive failures;
  per-rule fail_closed opt-in blocks on error instead
- per-session check budget (default 200 when default rules are in force)

Config: a guardrails: section in .mecatl/settings.yaml (rules list +
per-rule mode/phases/prompt/fail_closed) + --guardrails-model /
--guardrails=off flags. OPERATOR-TIER ONLY — a project-tier guardrails
block is ignored with a WARN (disabling a checker is a security downgrade,
so the usual permconfig tighten-only gate is inverted here). Strict
unknown-key parse; checker model fail-fast-validated. A configured model
with no explicit rules ships the default advisory set (WebSearch,
WebFetch, mcp__*); no model → no runner → byte-identical to today.

Observability: advisory findings ride port.Diagnostics correlated by
session + call id (operator-log-only; the loop's three-line invariant
holds); enforce block/sanitize ride the existing EvHook events.

Also exports agent.UntrustedFence / NeutraliseFraming / WriteUntrustedBlock
/ StripLoneCodeFence into a new engine/agent/fence.go (single source of
truth for fencing untrusted content, shared by the ask-reviewer and the
guardrail checker); adds governance.HookEvent.CallID.

Co-Authored-By: Claude Fable 5 <[email protected]>
The three permissions/guardrails features (#32 child-scoped config axis,
#31 headless ask-reviewer, #27 model-backed guardrails) each landed their
own per-feature docs; this reconciles the cross-cutting capability lists
that none of them owned individually:

- README "Safety & governance" bullets now name the child-scoped
  permission axis, the headless LLM ask-reviewer, and the model-backed
  guardrails (the permission/hooks bullets were stale capability claims)
- architecture.md: modelhook joins the adapter diagram; the HookRunner
  port description now covers both outcome mappings (hookexec exit code
  vs modelhook verdict), not just exit codes

Co-Authored-By: Claude Fable 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

e2e-live Run the live e2e suite on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant