Skip to content

feat(review): --export-tribunal-ledger flag#65

Merged
steipete merged 3 commits into
openclaw:mainfrom
dpdanpittman:feat/export-tribunal-ledger
May 18, 2026
Merged

feat(review): --export-tribunal-ledger flag#65
steipete merged 3 commits into
openclaw:mainfrom
dpdanpittman:feat/export-tribunal-ledger

Conversation

@dpdanpittman
Copy link
Copy Markdown
Contributor

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

  • Flag omitted: nothing is written. The review result object does not contain an `exportTribunalLedger` key (omitted via conditional spread, so existing consumers see the same shape).
  • Flag provided: file is written once via `writeFile`, path resolved against cwd, included in the review result as `exportTribunalLedger`. Empty findings → zero-byte file.
  • Flag with empty string: rejected with exit 2 / `invalid-usage`.

Tests

Three new cases in `workflow.test.ts`:

  1. `writes a tribunal-shaped JSONL ledger when --export-tribunal-ledger is set` — end-to-end review with the mock provider; verifies the file exists, parses, and matches the documented shape.
  2. `omits exportTribunalLedger from the result when the flag is absent` — verifies the result key is not present when the flag is omitted.
  3. `parses --export-tribunal-ledger as a review value flag` — argv parsing.

Full suite: 463 passing locally.

Notes

  • Opt-in only. No behavior change for any existing user.
  • Schema is documented inline at the helper.
  • Composes cleanly with all other review flags.
  • Independent of feat(review): --prompt-file flag #64 (`--prompt-file`); both can land in either order.

dpdanpittman and others added 3 commits May 17, 2026 18:48
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.
@steipete steipete merged commit 24b95fe into openclaw:main May 18, 2026
6 checks passed
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