Skip to content

feat(json): write JSON report artefacts as I-JSON/JCS - #237

Merged
hyperpolymath merged 2 commits into
mainfrom
claude/gallant-bell-4bo4oy-c-jcs-reports
Oct 20, 2026
Merged

hyperpolymath merged 2 commits into
mainfrom
claude/gallant-bell-4bo4oy-c-jcs-reports

Conversation

@hyperpolymath

Copy link
Copy Markdown
Owner

Part of the KYAML / I-JSON-JCS follow-up stack to #234. Independent of #235 and #236, so it is based on main.

Summary

The estate JSON policy (hyperpolymath/standards 3-practice/JSON-POLICY.adoc, rule J-1) requires authored JSON to be I-JSON (RFC 7493), serialised as JCS (RFC 8785), with exactly one final LF. panic-attack wrote every report with to_string_pretty, so none of its output was canonical.

  • New crate::json::to_canonical_string. It serialises through serde_json::Value and canonicalises with ijson-jcs, the tool behind the estate gate, so output passes ijson-jcs check by construction. ijson-jcs isn't on crates.io, so it is a git dependency pinned to a full commit SHA (3a9a4ee). panic-attack doesn't publish to crates.io, and the shared CI runs no cargo-deny, so a git source is allowed.
  • These report artefacts now go through it:
    • --output-format json (save_report, storage)
    • assail --output and its --quiet / --headless stdout form
    • the amuck, abduct, axial, adjudicate, assay, aggregate and assemblyline reports (plus the assemblyline storage copy) and ReportFormatter::save
    • the patch-bridge triage report and its mitigation registry (.machine_readable/patch-bridge/registry.json)
  • Attestation. assail --attest already seals report_json.as_bytes(), so the report hash is now taken over canonical bytes. The stdout paths use print!, because the canonical string already ends in its one LF.

Consumer check (in this repo)

  • Workflows read reports with jq (bridge-gate, scan-and-report), which parses. chapel-ci greps a value (repo-alpha), which compaction keeps.
  • Tests parse the JSON; none relies on pretty-print spacing or line structure.
  • Not checked here: panicbot (gitbot-fleet), VeriSimDB and Hypatia, which consume panic-attack JSON in other repos. JSON-POLICY §6 asks that each consumer is confirmed to parse before conversion. Please confirm, or I can audit them in a follow-up.

Deliberately left alone

These have separate consumers and should be follow-ups if wanted:

  • VeriSimDB hexads
  • SARIF (its own format and extension)
  • PanLL exports
  • the attestation envelope (next PR in the stack)
  • ad-hoc CLI JSON such as query hits

Found while testing (not fixed here)

Two assail runs on the same input give different reports: recommended_attacks, frameworks and the taint-matrix rows come from HashSet/HashMap iteration order. JCS sorts object keys, but by design it leaves array order alone. So until this is fixed, "equal input gives equal bytes" doesn't hold for the report itself. The fix (derive Ord, use BTreeSet/BTreeMap) is the next small PR.

Verification

  • cargo fmt --check: clean.
  • cargo build --locked: no warnings, on stable and on 1.89.0.
  • cargo clippy --locked --all-features --all-targets -- -D warnings: clean.
  • cargo test --locked --all-features --no-fail-fast: 662 passed, 0 failed.
  • New tests:
    • RFC 8785 essentials: sorted keys, 1e+21, -0 → 0, \u0001, one LF.
    • The I-JSON bound ±(2^53−1).
    • Idempotence and lossless round trip on a real assail report.
  • End to end: assail --output x.json and --quiet stdout both pass ijson-jcs check.

Generated by Claude Code

The estate JSON policy (standards 3-practice/JSON-POLICY.adoc, rule J-1)
makes authored JSON I-JSON (RFC 7493) serialised as JCS (RFC 8785) with
one final line feed. panic-attack wrote every report with
to_string_pretty, so none of it was canonical.

Add crate::json::to_canonical_string, which serialises through
serde_json::Value and canonicalises with ijson-jcs (the tool behind the
estate gate, pinned to a full commit SHA because it is not on
crates.io), so output passes `ijson-jcs check` by construction. Route
the report artefacts through it:

- ReportOutputFormat::Json (--output-format json, save_report, storage)
- assail --output and its --quiet/--headless stdout form
- the amuck, abduct, axial, adjudicate, assay, aggregate and
  assemblyline reports, the assemblyline storage copy and
  ReportFormatter::save
- the patch-bridge triage report and mitigation registry

The assail --attest seal already hashes report_json.as_bytes(), so it
now hashes canonical bytes. Stdout prints use print!, because the
canonical string already ends in its one LF.

Left alone, with separate consumers: VeriSimDB hexads, SARIF, PanLL
exports, the attestation envelope (next PR) and ad-hoc CLI JSON.

Checks: build on stable and on 1.89.0 --locked, clippy -D warnings
--all-features, 662 tests pass. New tests cover the RFC 8785 rules
(sorted keys, 1e+21, -0, \u0001, one LF), the I-JSON ±(2^53-1) bound,
and idempotence on a real report. `assail --output` and stdout outputs
both pass `ijson-jcs check`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PFaqv6iBXrt3W5Akd1Fq5k
@coderabbitai

coderabbitai Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

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

Next included review available in 31 minutes.

Check out review usage here.

View limit details

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

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 55c5f5b7-0c0e-4dd2-8395-9a9499d3ed7e
📥 Commits

Reviewing files that changed from the base of the PR and between 2d118b0 and 66db11b.

⛔ Files ignored due to path filters: 1
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing: 15
  • Cargo.toml
  • src/abduct/mod.rs
  • src/adjudicate/mod.rs
  • src/aggregate/mod.rs
  • src/amuck/mod.rs
  • src/assay/mod.rs
  • src/assemblyline.rs
  • src/axial/mod.rs
  • src/bridge/registry.rs
  • src/json.rs
  • src/lib.rs
  • src/main.rs
  • src/report/formatter.rs
  • src/report/output.rs
  • src/storage/mod.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@hyperpolymath
hyperpolymath marked this pull request as ready for review October 20, 2026 14:25
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-20T14:25:32.631030Z 8603d8d Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@hyperpolymath
hyperpolymath enabled auto-merge (squash) October 20, 2026 14:28
Signed-off-by: Jonathan D.A. Jewell <6759885+hyperpolymath@users.noreply.github.com>
@hyperpolymath
hyperpolymath merged commit e1c9a2b into main Oct 20, 2026
44 of 45 checks passed
@hyperpolymath
hyperpolymath deleted the claude/gallant-bell-4bo4oy-c-jcs-reports branch October 20, 2026 14:31
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.

2 participants