feat(review): --export-tribunal-ledger flag#65
Merged
steipete merged 3 commits intoMay 18, 2026
Conversation
After a review completes, emit a single JSONL file with one entry per
finding shaped for downstream Tribunal-style signed-ledger ingest.
Each line is a self-describing record:
kind literal "clawpatch-review" — discriminates from
Tribunal's own "finding" / "resolution" kinds
finding_id the clawpatch finding ID (stable across runs)
plan_id null (clawpatch has no Tribunal plan concept)
round 1 (this is the first lens-pass)
agent_pubkey null (Tribunal signs on ingest, not clawpatch)
agent_label clawpatch-<provider> — stable source attribution
severity clawpatch's 4-tier severity
category clawpatch's category
claim_hash the clawpatch finding signature (stable dedup key)
claim_uri null
stake null
timestamp finding.updatedAt
signature null
run_id the clawpatch run ID
Why: downstream consumers that ingest clawpatch findings into a
separate signed ledger currently read .clawpatch/findings/<id>.json
one file per finding after the review completes. For 100+ findings
on a large repo that's measurable I/O. This flag skips the per-file
round trip and emits the data shaped for direct ingest.
Behavior:
- Flag omitted: nothing is written, no extra work, and the result
object does not contain an exportTribunalLedger key (omitted via
conditional spread).
- Flag with a non-empty path: file is written via writeFile in the
same run, path resolved against cwd. Empty findings array writes
a zero-byte file.
- Flag with empty string: ClawpatchError (exit 2 / invalid-usage).
Tests: three new cases in workflow.test.ts covering presence,
absence (no key in result), and argv parsing of the flag.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add a `--export-tribunal-ledger ` flag to `clawpatch review` that emits a single JSONL file at the end of the run, with one line per finding shaped for downstream Tribunal-style signed-ledger ingest.
Why
Some downstream consumers ingest clawpatch findings into a separate signed ledger (Tribunal does this, but the shape is generic). Today they read `.clawpatch/findings/.json` one file per finding after the review completes — for 100+ findings on a large repo that's measurable I/O. This flag skips the per-file round-trip and emits the data shaped for direct ingest.
Schema
Each JSONL line:
```json
{
"kind": "clawpatch-review",
"finding_id": "fnd_...",
"plan_id": null,
"round": 1,
"agent_pubkey": null,
"agent_label": "clawpatch-",
"severity": "critical|high|medium|low",
"category": "bug|security|...",
"claim_hash": "<finding.signature>",
"claim_uri": null,
"stake": null,
"timestamp": "<finding.updatedAt>",
"signature": null,
"run_id": ""
}
```
The schema is documented inline at the helper so future readers don't have to chase the spec.
Behavior
Tests
Three new cases in `workflow.test.ts`:
Full suite: 463 passing locally.
Notes