Skip to content

feat(audit): add to_json() dashboard export method#15

Open
blut-agent wants to merge 2 commits into
agentguard-ai:mainfrom
blut-agent:feat/tealaudit-to-json
Open

feat(audit): add to_json() dashboard export method#15
blut-agent wants to merge 2 commits into
agentguard-ai:mainfrom
blut-agent:feat/tealaudit-to-json

Conversation

@blut-agent

Copy link
Copy Markdown
Contributor

Summary

  • Adds TealAudit.to_json() method for simple JSON array output
  • Outputs flat decision objects with fields: decision_id, timestamp, agent_id, action, tool_name, reason_codes, risk_score, evaluation_time_ms
  • Maps DecisionAction enum to lowercase strings (allow/deny/monitor)
  • Converts risk_score to int, handles None values gracefully
  • Returns empty array when no events stored
  • Fixes CLI entry point from tealtiger.cli.test:cli to tealtiger.cli:cli (function was named test, not cli)

Changes

  • src/tealtiger/core/audit/teal_audit.py: Added to_json() method
  • tests/core/audit/test_to_json.py: 9 unit tests
  • src/tealtiger/cli/__init__.py: Refactored to Click group with test and validate subcommands
  • src/tealtiger/cli/validate.py: Added policy validation CLI command
  • tests/test_cli_validate.py: 21 unit tests for CLI validation
  • pyproject.toml: Fixed entry point to tealtiger.cli:cli

Test Plan

  • 9 new unit tests for to_json() pass
  • All 97 audit tests pass (including existing tests)
  • 21 CLI validation tests pass

Closes agentguard-ai/tealtiger#310

- Add 'tealtiger validate <path>' CLI command for validating policy files
- Validates required fields (name, description, rules)
- Validates action types (allow/deny/transform)
- Validates rule structure and detects unknown fields
- Supports JSON and YAML file formats
- Fixes entry point to use Click group with both test and validate commands
- Add 21 unit tests covering load, validate, and error cases
- Add TealAudit.to_json() for simple JSON array output
- Outputs flat decision objects with fields: decision_id, timestamp,
  agent_id, action, tool_name, reason_codes, risk_score, evaluation_time_ms
- Maps DecisionAction enum to lowercase strings (allow/deny/monitor)
- Converts risk_score to int, handles None values
- Empty array when no events stored
- Add 9 unit tests covering all edge cases
@nagasatish007

Copy link
Copy Markdown
Contributor

@blut-agent Thanks. There are merge conflicts. If needed, please rebase and fix.

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.

[Good First Issue]: Add JSON export format for TealAudit decision logs

2 participants