Skip to content

fix(go-kernel): accept pre-normalized ActionContext in evaluate command#1000

Merged
jpleva91 merged 1 commit intomainfrom
fix/go-evaluate-accept-action-context
Mar 26, 2026
Merged

fix(go-kernel): accept pre-normalized ActionContext in evaluate command#1000
jpleva91 merged 1 commit intomainfrom
fix/go-evaluate-accept-action-context

Conversation

@jpleva91
Copy link
Copy Markdown
Collaborator

Closes #957

Implementation Summary

What changed:

  • Extracted parseActionInput() helper in go/cmd/agentguard/main.go that detects input format by checking for an action field (pre-normalized ActionContext) vs tool field (raw Claude Code tool call)
  • Pre-normalized ActionContext payloads (e.g., {"action":"file.write","target":"foo.ts"}) are passed directly to the evaluator — no re-normalization
  • Raw tool call payloads ({"tool":"Write","input":{...}}) continue to be normalized (existing behavior preserved)
  • Added doc comment on runEvaluate documenting both input formats and the pack: limitation
  • Added go/cmd/agentguard/main_test.go with 6 unit tests covering both formats and the normalize | evaluate pipeline
  • Updated go/test/smoke.sh with 2 new tests: pre-normalized format and the pipeline

How to verify:

# Repro from issue — now returns allowed instead of default deny:
echo '{"action":"file.write","target":"foo.ts"}' | go/bin/agentguard evaluate --policy agentguard.yaml

# normalize | evaluate pipeline:
echo '{"tool":"Write","input":{"file_path":"src/main.ts"}}' | go/bin/agentguard normalize | go/bin/agentguard evaluate --policy agentguard.yaml

# Go tests:
cd go && go test ./cmd/agentguard/...

Tier C scope check:

  • Files changed: 3 (limit: 5)
  • Lines changed: ~85 (limit: 300)
  • Breaking changes: None (existing raw tool call format behavior preserved)

Tier C implementation by copilot-cli — AgentGuard three-tier governance

…nd (closes #957)

The evaluate command previously only accepted raw Claude Code tool call format
{"tool":"...","input":{...}}, causing it to return "default deny" for all
actions when callers passed a pre-normalized ActionContext like
{"action":"file.write","target":"foo.ts"}.

Changes:
- Extract parseActionInput() helper that detects input format by checking
  for an "action" field (ActionContext) vs "tool" field (raw tool call)
- Pre-normalized ActionContext is passed directly to the evaluator
- Raw tool call payloads are normalized first (existing behavior preserved)
- Document the "pack:" limitation in the runEvaluate comment
- Add 6 unit tests for parseActionInput covering both formats and pipeline

This enables the normalize | evaluate pipeline:
  {tool,input} | agentguard normalize | agentguard evaluate --policy p.yaml

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jpleva91 jpleva91 merged commit 76f83ef into main Mar 26, 2026
5 checks passed
@jpleva91 jpleva91 deleted the fix/go-evaluate-accept-action-context branch March 26, 2026 14:07
@jpleva91
Copy link
Copy Markdown
Collaborator Author

🟢 LOW — Audit Receipt

Audit: Merged PR Audit Report 2026-03-27
Agent: claude-code:opus:reviewer (audit-merged-prs)
Timestamp: 2026-03-27T02:50:00Z

Risk Score: LOW

All CI checks passed. No protected file changes. No immediate action required.

See consolidated audit issue: #1066

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.

Go kernel evaluate does not resolve pack: or YAML — needs flattened JSON

1 participant