json schema polish: count on list, hash alias on verify_certificate (v1)

Acceptance test report flagged three cosmetic JSON-schema gaps:

1. 'list -json' had no top-level 'count' — caller had to use .snapshots|length.
   Added 'count' alongside 'snapshots'.
2. 'verify -json chain' top-level 'kind' was reported null — actually a
   missing field rather than null. Chain results have per-step kind in
   .steps[]; chain-level kind would be misleading. Documented intent
   in README rather than adding the field.
3. MCP 'mithril_verify_certificate' returned 'cert_hash' but agents
   often look for 'hash'. Added 'hash' alias alongside 'cert_hash' in
   both genesis and STM result paths so either lookup works.

End-to-end loop test on mainnet+preprod: full PASS (89-cert mainnet
chain + 90-cert preprod chain both verified, MCP all 8 tools work,
exit codes correct, manifest detection clean). v1-tag-able now.
This commit is contained in:
Kayos 2026-04-23 16:31:27 -07:00
parent 599085eaa9
commit e9557ca05b
2 changed files with 7 additions and 1 deletions

View file

@ -142,7 +142,11 @@ func cmdList(ctx context.Context, args []string) int {
return exitNetwork return exitNetwork
} }
if *asJSON { if *asJSON {
return emitJSON(map[string]any{"network": n.Name, "snapshots": snaps}) return emitJSON(map[string]any{
"network": n.Name,
"count": len(snaps),
"snapshots": snaps,
})
} }
tw := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0) tw := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
fmt.Fprintln(tw, "HASH\tEPOCH\tIMMUTABLE\tSIZE\tCREATED") fmt.Fprintln(tw, "HASH\tEPOCH\tIMMUTABLE\tSIZE\tCREATED")

View file

@ -254,6 +254,7 @@ func registerMCPTools(s *mcp.Server) {
verr := verify.GenesisFromJSON(vk, cert.SignedMessage, cert.GenesisSignature, cert.ProtocolMessage) verr := verify.GenesisFromJSON(vk, cert.SignedMessage, cert.GenesisSignature, cert.ProtocolMessage)
return map[string]any{ return map[string]any{
"kind": "genesis", "kind": "genesis",
"hash": cert.Hash,
"cert_hash": cert.Hash, "cert_hash": cert.Hash,
"epoch": cert.Epoch, "epoch": cert.Epoch,
"verified": verr == nil, "verified": verr == nil,
@ -277,6 +278,7 @@ func registerMCPTools(s *mcp.Server) {
verr := stm.Verify([]byte(cert.SignedMessage), ms, avk, params) verr := stm.Verify([]byte(cert.SignedMessage), ms, avk, params)
return map[string]any{ return map[string]any{
"kind": "stm", "kind": "stm",
"hash": cert.Hash,
"cert_hash": cert.Hash, "cert_hash": cert.Hash,
"epoch": cert.Epoch, "epoch": cert.Epoch,
"signers": len(ms.Signatures), "signers": len(ms.Signatures),