What
Add a --format json flag to cmd/agentgate-verify that emits the verification result as a single machine-readable JSON object on stdout, instead of (or as an alternative to) the current human-readable text lines.
Why
Today agentgate-verify's output (PASS: %d receipts verified, head seq=%d hash=%x, completeness: ..., range: ..., or FAIL: seq=%d reason=%s (...)) is designed to be read by a person, not parsed by a script or CI pipeline. A --format json option lets an auditor's tooling consume the result programmatically without scraping text.
Files to touch
cmd/agentgate-verify/main.go — add a --format flag (text default, json alternative) to the run() function's flag set; when json is selected, marshal a small result struct instead of the current fmt.Fprintf calls.
cmd/agentgate-verify/main_test.go — add test coverage for the new flag.
Suggested JSON shape
Something close to:
{
"ok": true,
"verified_count": 5,
"head_seq": 5,
"head_entry_hash": "a1b2c3...",
"complete": true,
"reason": "",
"range": "full"
}
For a failure:
{
"ok": false,
"failed_at_seq": 3,
"reason": "entry_hash_mismatch",
"verified_count": 2,
"total_receipts": 5
}
Match the existing receipt.VerifyResult struct's fields (internal/receipt/verifier.go) rather than inventing new field names where one already exists.
Exit codes must not change: 0 pass, 1 chain/signature mismatch, 2 I/O or config error — the same rule applies whether --format text or --format json is selected.
Acceptance checks
agentgate-verify --format json (with a valid, passing chain) exits 0 and prints one valid JSON object with "ok": true.
agentgate-verify --format json against a tampered chain exits 1 and prints one valid JSON object with "ok": false and the correct "reason".
- The default (no
--format flag, or --format text) behavior is byte-for-byte unchanged from today.
--format with an unrecognized value exits 2 with a clear stderr message, matching the existing pattern for other flag validation errors in run().
Test path (no secrets needed)
go test ./cmd/agentgate-verify/... -race -count=1 -v
The existing test helpers (buildTestChain, writeJSONLFile) already build real signed receipt chains in a temp SQLite database — no live AgentGate instance, network access, or secrets are needed.
What
Add a
--format jsonflag tocmd/agentgate-verifythat emits the verification result as a single machine-readable JSON object on stdout, instead of (or as an alternative to) the current human-readable text lines.Why
Today
agentgate-verify's output (PASS: %d receipts verified, head seq=%d hash=%x,completeness: ...,range: ..., orFAIL: seq=%d reason=%s (...)) is designed to be read by a person, not parsed by a script or CI pipeline. A--format jsonoption lets an auditor's tooling consume the result programmatically without scraping text.Files to touch
cmd/agentgate-verify/main.go— add a--formatflag (textdefault,jsonalternative) to therun()function's flag set; whenjsonis selected, marshal a small result struct instead of the currentfmt.Fprintfcalls.cmd/agentgate-verify/main_test.go— add test coverage for the new flag.Suggested JSON shape
Something close to:
{ "ok": true, "verified_count": 5, "head_seq": 5, "head_entry_hash": "a1b2c3...", "complete": true, "reason": "", "range": "full" }For a failure:
{ "ok": false, "failed_at_seq": 3, "reason": "entry_hash_mismatch", "verified_count": 2, "total_receipts": 5 }Match the existing
receipt.VerifyResultstruct's fields (internal/receipt/verifier.go) rather than inventing new field names where one already exists.Exit codes must not change:
0pass,1chain/signature mismatch,2I/O or config error — the same rule applies whether--format textor--format jsonis selected.Acceptance checks
agentgate-verify --format json(with a valid, passing chain) exits0and prints one valid JSON object with"ok": true.agentgate-verify --format jsonagainst a tampered chain exits1and prints one valid JSON object with"ok": falseand the correct"reason".--formatflag, or--format text) behavior is byte-for-byte unchanged from today.--formatwith an unrecognized value exits2with a clear stderr message, matching the existing pattern for other flag validation errors inrun().Test path (no secrets needed)
go test ./cmd/agentgate-verify/... -race -count=1 -vThe existing test helpers (
buildTestChain,writeJSONLFile) already build real signed receipt chains in a temp SQLite database — no live AgentGate instance, network access, or secrets are needed.