Skip to content

feat: expose the inspector rule packs to automation - #363

Merged
YoungJinJung merged 1 commit into
mainfrom
feature/issue-360-inspect-agent-surface
Sep 14, 2026
Merged

YoungJinJung merged 1 commit into
mainfrom
feature/issue-360-inspect-agent-surface

Conversation

@YoungJinJung

Copy link
Copy Markdown
Contributor

Summary

unic inspect --json and the run_security_inspector MCP tool — the first fill from #360's coverage list, picked because it has the best ratio of agent value to surface area: ten rule packs collapse into one call, and the failure-first findings view is exactly what a raw AWS API bridge cannot reproduce.

$ unic inspect --json
{"schema_version":"v1","data":{"scanned_at":"2026-09-14T03:04:05Z","scanner_count":11,
 "finding_count":3,"severity_counts":{"HIGH":1,"MEDIUM":2},"findings":[...]},
 "warnings":["cost-waste: AccessDenied"],"pagination":{"complete":true}}

Reuses the existing jsonEnvelope[T] and writeResourceJSON, and resolves its AWS context through resourceRepository so it behaves like every other automation command.

Three deliberate contract decisions

Scanner warnings reach the agent. RunSecurityScan already collects per-scanner failures into report.Warnings; those map onto the envelope's warnings. A scan where the cost pack was denied must not look identical to a clean scan.

Findings serialize as [], not null. An empty slice is pre-allocated so agents never have to branch on null-vs-empty. Covered by a test.

--checklist is rejected, not ignored. It is a root persistent flag, so it is inherited by this command and shows up in unic schema inspect:

$ unic schema inspect --json | jq '.flags[].name'
"checklist"  "json"  "profile"  "region"  "verbose"

An agent reading that schema would reasonably pass --checklist and expect a checklist run. Checklist Inspector produces a different report shape (ChecklistReport) with no agent contract yet, so honoring the flag is out of scope — but silently ignoring it would hand back security findings as if the checklist had run. It fails loudly instead, with a message saying why.

Relationship to #361

Inspector is a workflow, not a domain.Catalog() feature — grep -c Inspector internal/domain/{model,catalog}.go returns 0 — so the parity guard merged in #361 does not and cannot cover it. This PR therefore:

  • keeps the tool outside the unic.resources.* namespace the parity test walks, using unic.inspect.v1
  • adds TestSecurityInspectorToolIsReadOnlyAndNotAResourceContract to pin that boundary
  • documents the limitation in both architecture docs, so "the guard is green" is not mistaken for "everything is covered"

Validation

  • go build ./..., go vet ./..., go test ./... — all packages pass, including test: guard agent surface parity #361's parity test
  • CLI tests: envelope shape and severity counts, warnings surviving, empty-vs-null findings, scan failure surfacing as a command error, --json=false rejected, --checklist rejected with no partial output, read-only/v1 annotations present
  • MCP tests: dispatch with and without profile/region, read-only hint, output contract, and the not-a-resource-contract boundary
  • Verified end to end that unic capabilities --json and unic schema inspect --json both pick the command up

Refs #360 — the remaining checklist items (ElastiCache, SNS, CloudFormation, Step Functions fills) stay open.

Adds `unic inspect --json` and the `run_security_inspector` MCP tool,
the first fill from #360's coverage list. Ten rule packs collapse into
one call, which is the curated view a raw AWS API bridge cannot
reproduce.

Returns the shared v1 envelope; `data` carries scanned_at,
scanner_count, finding_count, severity_counts, and findings. Per-scanner
failures land in `warnings` instead of being dropped, so a partially
denied scan is never reported as a clean one. Findings serialize as an
empty array rather than null so agents need not branch on both.

`--checklist` is a root persistent flag, so it is inherited here and
advertised by `unic schema inspect`. Running the security packs while
silently ignoring it would hand back the wrong report, so it is rejected
explicitly until the checklist output contract is defined.

Inspector is a workflow rather than a catalog feature, so it sits
outside `unic resources` and outside the catalog parity test added in
#361; the docs now say so.

Refs #360

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P2bi5Xga4wU5hDPgNPd4mv
@coderabbitai

coderabbitai Bot commented Sep 14, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 59 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 81041c08-d45a-47a7-9f81-72e5033eae27

📥 Commits

Reviewing files that changed from the base of the PR and between 8deced7 and 47a72a0.

📒 Files selected for processing (8)
  • README.md
  • docs/architecture.en.md
  • docs/architecture.ko.md
  • internal/cli/inspect.go
  • internal/cli/inspect_test.go
  • internal/cli/root.go
  • internal/mcp/server.go
  • internal/mcp/server_test.go

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@amazon-q-developer amazon-q-developer Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

I've completed a thorough review of PR #363, which exposes the security inspector rule packs to automation via the unic inspect --json CLI command and the run_security_inspector MCP tool.

Key Changes Reviewed

  • New inspect command with JSON-only output and proper contract versioning
  • Integration with existing resourceRepository for consistent AWS context resolution
  • MCP tool registration with unic.inspect.v1 contract (correctly outside the unic.resources.* namespace)
  • Comprehensive test coverage for CLI and MCP integration
  • Proper handling of scanner warnings, empty findings, and checklist flag inheritance

Assessment

The implementation is well-designed and ready to merge. The code demonstrates strong engineering practices with proper error handling, comprehensive test coverage, and thoughtful contract design decisions. No blocking issues were identified during this review.


You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.

@YoungJinJung
YoungJinJung merged commit 141d12e into main Sep 14, 2026
4 checks passed
@YoungJinJung
YoungJinJung deleted the feature/issue-360-inspect-agent-surface branch September 14, 2026 00:33
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