Repository navigation
Description
The problem
Advisory-mode guardrail findings are invisible to the TUI. An operator who enables guardrails in advisory mode cannot see that the checker fired — the finding goes only to the operator log (stderr/journald/file), never to the client event stream, so the TUI renders nothing.
This defeats the stated purpose of advisory mode. ADR 0021 (docs/adr/0021-guardrails.md) says advisory exists "so the operator measures the false-positive rate before promoting a rule to block/sanitize." You cannot measure what you cannot see. If the operator has to leave the TUI mid-session and grep guardrail-finding a log file to discover the checker flagged three mcp__* calls, they won't do it — advisory mode becomes a black hole that never gets promoted because the signal never surfaces.
What happens today
internal/adapter/modelhook/modelhook.go:305(enforce,ModeAdvisoryarm): callsr.diag.Log(...)(operator log) and returnsgovernance.HookOutcome{}— an empty outcome.engine/agent/dispatch.goonly emits anEvHookevent when a hook outcome actually does something —HookBlocked(dispatch.go:637/1048) orHookModified(dispatch.go:646/1057). An empty HookOutcome = "hook did nothing" → no event emitted.- So: advisory finding → operator log only → TUI sees nothing, model sees nothing. The
EvHook+HookPayloadchannel (which the TUI already renders as notices on tool cards viaHookPayload.CallID) never fires for an advisory finding.
Proposed change
Emit an EvHook for advisory findings, client-visible, model-invisible.
- Add a new
HookDecisionvalueHookAdvisory(engine/session/event.go, alongsideHookInfo/HookBlocked/HookModified). It's a string passthrough on the wire (prototype/stopare strings, notask generate). - In the
ModeAdvisoryarm ofenforce(modelhook.go:305), return a non-emptyHookOutcomecarrying the advisory reason (or add a dedicated advisory-outcome path), so dispatch emits anEvHookwithDecision: HookAdvisory.- The runner already has the
governance.HookEvent(Phase/Tool/CallID/SessionID), so theEvHookcan carry the fullHookPayloadand pin the notice to the exact tool card.
- The runner already has the
- The TUI renders an advisory notice in a warning colour (distinct from the error colour used for
HookBlocked), addressed to the originating tool card viaCallID. - Keep the diag log — headless deployments (
mecated --headless,mecatequi) have no TUI, and theguardrail-findinggrep marker is the right correlation channel for post-hoc log analysis. The change is "ALSO emit anEvHook," not "replace the log with an event."
The visibility split
The current contract bundles two claims: "the client sees nothing" and "the model sees nothing." This issue splits them:
- Client (TUI): yes, show it. This is the fix.
- Model: no, keep it invisible. Advisory means the tool result is unaltered — the model sees the byte-identical result, no annotation. Making the model aware that a guardrail flagged something risks injection: a malicious tool result that trips a spurious advisory finding could steer the model's behaviour ("the guardrail said this was unsafe, so treat it as suspicious"). Client-visible, model-invisible is the safe split.
Considerations
- Noise: an MCP-heavy session under the default rule set could fire a finding per
mcp__*call. If each becomes a TUI notice, scrollback gets loud. This is a rendering problem (a count badge on the tool card, a collapsible guardrails notice, a status-line summary), not a reason to stay invisible. - ADR 0021 wording: the "client and model see nothing on an advisory finding" line needs amending, but the ADR's intent (don't disrupt the agent, measure before promoting) is better served by TUI visibility. The amendment strengthens the stated goal rather than contradicting it.
EvHookis already client-relayed — it is NOT in the log-only set (EvApproval/EvCompactionArchive/EvUserPrompt), so no relay change is needed.
Scope
- New
HookAdvisorydecision inengine/session/event.go. - Advisory arm in
modelhook.enforcereturns a non-empty outcome (or a dedicated advisory-emission path) so dispatch emits theEvHook. - TUI rendering of the advisory notice (warning colour, pinned to tool card via
CallID). - ADR 0021 +
docs/architecture.mdamendment. - Tests: advisory finding emits an
EvHookwithHookAdvisory; model sees unaltered result; TUI golden update.
Out of scope
- Making advisory findings model-visible (separate, injection-implications decision).
- The default-mode flip (advisory → block) — that's #NNN.
Ref: #168 (remove maxChecks), #169 (checker-down posture toggle).
Activity
feat(guardrails): surface advisory findings to the TUI (#170) (#180)
feat(guardrails): flip default mode from advisory to block (#171) (#182)