Skip to content

feat(guardrails): surface advisory findings to the TUI (#170) - #180

Merged
JAORMX merged 1 commit into
mainfrom
feat/guardrails-advisory-tui-170
Jun 24, 2026
Merged

JAORMX merged 1 commit into
mainfrom
feat/guardrails-advisory-tui-170

Conversation

@JAORMX

@JAORMX JAORMX commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

What

Advisory-mode guardrail findings now emit a client-visible EvHook (with HookAdvisory decision, warning-coloured ⚠ in the TUI) in addition to the operator diag log. The model sees nothing — the tool result is byte-unchanged.

Why

Advisory findings went only to the operator log and returned an empty HookOutcome — dispatch only emits EvHook on Block/Mutated, so the TUI never saw them. This defeated advisory mode's stated purpose (measure the false-positive rate before promoting to block): the operator could not see what the checker flagged without leaving the TUI and grepping a log file.

Changes

  • engine/session/event.go — new HookAdvisory HookDecision = "advisory" (client-visible, model-invisible).
  • contracts/proto/mecatl/v1/harness.proto — new HOOK_DECISION_ADVISORY = 4 enum value.
  • internal/adapter/modelhook/modelhook.go — advisory arm returns HookOutcome{Message:...} instead of empty; diag log stays.
  • engine/agent/dispatch.go — recognises the message-only shape (Message!="" && !Block && len(Mutated)==0) and emits EvHook with HookAdvisory (both Pre and Post phases).
  • internal/adapter/server/mapper.go — maps HookAdvisory → HOOK_DECISION_ADVISORY.
  • TUI — client/msgs.go (HookAdvisory const + hookDecisionFrom), theme/theme.go (hookAdvisory warning style), ui/render.go (⚠ glyph arm in renderHook).
  • ADR 0051 (new) — supersedes ADR 0021's advisory-visibility clause.
  • Docs — usage.md, AGENTS.md, PRODUCTION-READINESS, ADR README, ADR 0021 header (Superseded by line). API-compat gate updated (session.txt + CHANGELOG).
  • Tests — loop-level integration test (TestAdvisoryHookEmitsEvHookAndLeavesResultUnchanged), TUI render test (TestRenderHookAdvisory), mapper + client round-trip tests, ACP projector test.

Closes #170.

Advisory-mode guardrail findings went only to the operator log and returned
an empty HookOutcome — dispatch only emits EvHook on Block/Mutated, so the
TUI never saw advisory findings. This defeated advisory mode's stated purpose
(measure the false-positive rate before promoting to block): the operator
could not see what the checker flagged without leaving the TUI and grepping
a log file.

The advisory arm now returns HookOutcome{Message:...} (no Block, no Mutated).
Dispatch recognises the message-only shape (a previously-unreachable state)
and emits an EvHook with HookAdvisory — a new HookDecision value, warning-
coloured in the TUI (⚠ glyph). The tool result is byte-unchanged
(model-invisible). The operator diag log stays for headless deployments.

New: session.HookAdvisory const + HOOK_DECISION_ADVISORY proto enum value.
governance.HookOutcome is NOT widened (Message is the signal). ADR 0021's
advisory-visibility clause superseded by ADR 0051.

Tests: loop-level TestAdvisoryHookEmitsEvHookAndLeavesResultUnchanged proves
EvHook+HookAdvisory emitted + result unchanged (model-invisible). TUI
TestRenderHookAdvisory proves ⚠ glyph + warning style. Mapper + client
round-trip tests for the new enum value. API-compat gate updated
(engine/api/session.txt + CHANGELOG).

Closes #170.
@JAORMX
JAORMX merged commit 617f760 into main Jun 24, 2026
12 of 13 checks passed
@JAORMX
JAORMX deleted the feat/guardrails-advisory-tui-170 branch June 24, 2026 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

guardrails: surface advisory findings to the TUI (client-visible, model-invisible)

1 participant