Skip to content

feat: redact tool output + securitylog/verify/governance/learn CLI - #181

Open
Patel230 wants to merge 1 commit into
feat/resilience-governance-auditfrom
feat/security-hygiene-cli
Open

feat: redact tool output + securitylog/verify/governance/learn CLI#181
Patel230 wants to merge 1 commit into
feat/resilience-governance-auditfrom
feat/security-hygiene-cli

Conversation

@Patel230

@Patel230 Patel230 commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Follow-on to #180, implementing the four self-contained recommendations from the KiroCrew comparison:

1. Tool-output redaction (HIGH — confirmed gap)

hawk only redacted the final assistant response (PostResponse). Tool results fed
back to the model were un-redacted (stream.go), leaking any secret echoed by a
tool call back to the LLM. Now redactToolResult runs tool output through
OutputRedactor (25+ patterns) + env-var secrets + home-path collapsing before
it is appended to RawMessages (the model round-trip). OutputRedactor.RegisterEnvSecrets
import process env values of secret-named env vars (ghp_, sk-, etc.) so
echoed credentials are scrubbed.

2. securitylog CLI + SEL wiring (MED-HIGH)

PR #180 shipped the hash-chained SEL package but nothing wrote to it. Now:

  • internal/engine/security_events.go: permission/approval denials are appended
    to the tamper-evident log via recordPolicyObservation.
  • securitylog.DefaultDir() / Entries() expose the log for inspection.
  • hawk securitylog show|verify and hawk verify (self-check: SEL chain
    integrity + managed governance policy validity, folded in as requested).

4. governance CLI (MEDIUM)

hawk governance show|validate|explain <tool> surfaces the POLICY ∩ PROFILE
engine. explain runs Evaluate and prints the deny/allow decision + reason.
LoadLayer is exposed as a stable entry point.

5. lessons wiring + CLI (MEDIUM)

  • LearnPrompt is now the canonical failure-analysis prompt used by
    buildReflectionPrompt (was dead code with zero callers; output format
    aligns with the existing WHAT_FAILED/WHY_FAILED/WHAT_TO_DO parser).
  • SelfImprover.Learn now deduplicates exact repeats.
  • SelfImprover.Clear() added; hawk learn list|add|prompt|clear CLI mirrors
    KiroCrew's kirocrew learn.

Verified: go build ./..., go vet, golangci-lint, boundary scripts, and
go test ./internal/engine/... ./internal/securitylog/... ./internal/governance/... ./cmd/
all green; manual binary smoke-test of each new command.

Note: #3 (background task executor) was scoped out of this PR — KiroCrew's
TaskRunner actually runs tasks, but hawk's TaskStore is store-only. Happy to
take that on separately as a larger feature.

…vernance/learn CLI

- Redact tool results before they reach the model (closes confirmed
  exfiltration gap: hawk only redacted the final assistant response).
  OutputRedactor.RegisterEnvSecrets imports process env secrets; tool
  output is redacted via Redact/RedactEnvVars/RedactPaths at the model
  round-trip chokepoint in stream.go.
- Wire the tamper-evident security event log (securitylog) into the engine:
  permission/approval denials are recorded to the hash-chained SEL
  (internal/engine/security_events.go). Add securitylog.DefaultDir/Entries.
- Add CLI: hawk securitylog show|verify, hawk verify (self-check: SEL
  chain integrity + managed governance policy validity), hawk governance
  show|validate|explain, hawk learn list|add|prompt|clear.
- Wire LearnPrompt into buildReflectionPrompt (single source of truth for
  the failure-analysis prompt) so it is no longer dead code; add dedup +
  Clear to SelfImprover.
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.

1 participant