<!-- SPDX-FileCopyrightText: Copyright (c) RapierCraft Studios -->
<!-- SPDX-License-Identifier: AGPL-3.0-or-later -->

# forgedock stats

A deterministic, version-over-version report. No model is involved: code reads records and counts them.

```bash
npx forgedock stats [--since <version|date>] [--repo <owner/repo>] [--json] [--refresh]
                    [--compact] [--no-local] [--no-cache] [--min-n N] [--release-times FILE]
```

`--repo` defaults to `project.owner`/`project.repo` in `forge.yaml`, else the `origin` remote. `--since 1.16.0` keeps
versions at or above it; `--since 2026-10-01` keeps activity on or after the date. `--compact` prints one row per
version (the table embedded in the staging review summary). `--json` is machine-readable.

`--since` also bounds the GitHub crawl: only issues and comments updated on or after the window start are read (a version
is resolved to its tag time minus one day; an unknown tag falls back to a full crawl and says so on stderr). Progress is
printed to stderr while crawling, so `--json` stdout stays parseable.

## Feature scoreboard (`--milestone <id|title>`, forge#5341)

`forgedock stats --milestone <number|title> [--repo <owner/repo>] [--json]` grades a whole milestone from GitHub (its issues, PRs and
epic FORGE:ACCEPTANCE comments) and the local run logs, with no manual input. Columns: journey status at ship (pass, fail or
never-ran, per epic with head and time); minutes from the first lane merge to the first green journey; defects created after the last
planned child closed, by class (`release-review`, `post-deploy`, `hotfix`, `other`, from labels or title); rework share (issues whose body
says fix/redo/rework/follow-up of a sibling `#N`, or labelled `rework`); operator interventions (hand PRs whose head branch is not a
`<type>/issue-N` lane branch, PRs labelled `manual-merge`, plus `needs-human` issues); cost from the run logs. A signal that cannot be read prints n/a. `--json`
keeps the earlier verdict mix under `query.mix` and adds `query.scoreboard`. The feature benchmark is in `docs/eval/feature-bench.md`.

## Sources

1. **GitHub (primary).** Issues, PRs and labels of the target repo, plus trusted `<!-- FORGE:TELEMETRY v1 -->` comments
   (`docs/TELEMETRY.md`). Only comments from OWNER/MEMBER/COLLABORATOR or a Bot are read (same predicate as
   `scripts/trusted-comments.sh`); `part=N` comments are concatenated and records are deduped on `eid`. All `gh` calls
   are argv-based. Needs an authenticated `gh`.
2. **Local cache (optional).** `~/.forge/stats-cache/<owner>_<repo>/cache.json` (`FORGE_STATS_CACHE_DIR`) holds what was
   fetched, an `updated_at` watermark (the next run only re-reads items updated since) and a `coveredFrom` floor (the
   oldest window start crawled, so a later, wider `--since` crawls the uncovered gap instead of under-reporting). It is
   safe to delete (the cost is one full re-fetch); a corrupt cache is treated as empty. `--refresh` ignores it, `--no-cache` never touches it.
3. **Local run logs (optional).** `~/.forge/runs/*.jsonl` (`FORGE_RUNS_DIR`) for runs that predate the engine's
   `phase_attempt` / `run_terminal` records. A run already present on GitHub is not counted twice. Only runs whose
   `RUN_START.repo` equals the target repo are used. `--no-local` skips them.

With no local state at all, `forgedock stats --repo <r>` reproduces the report from GitHub alone.

## Shareable card (`--card`, forge#5291)

`forgedock stats --card [--week|--month] [--include-repo-names] [--public-repo] [--out <dir>] [--repo <owner/repo>]` prints a Markdown
card and, with `--out`, also writes `stats-card.svg`, `stats-card.png` and `stats-card.md`. It reuses the normal stats crawl (no extra
network calls) and shows aggregates only: PRs merged, issues completed, cost per merge, issues closed before code
(invalid or duplicate), release-gate catches (blocked acceptance, diff-size, CI and liveness gates) and a time-saved
estimate (1.5 h per merged PR, labelled as an estimate). `--week` and `--month` bound the window to 7 or 30 days.
Issue titles are never included, and the repo name only with `--include-repo-names`. The footer link follows
`branding.show_attribution` in `forge.yaml` (default on). `--public-repo` asserts the repo is public: it names the repo and adds a link to its merged-PR history (no network lookup is made to verify visibility). The PNG is rendered by a built-in dependency-free encoder (`node:zlib` and a 5x7 bitmap font, upper-case text), so it looks plainer than the SVG.

## Efficiency (`--efficiency`, forge#4402)

```bash
npx forgedock stats --efficiency [--batch <id>] [--window 7d,30d] [--compare <date|version>] [--offline] [--repo <owner/repo>] [--json]
```

Per batch (`--batch`, a dir under `~/.forge/batches`, `FORGEDOCK_BATCH_DIR`) and over trailing windows (`--window`,
default `7d,30d`: the union of the repo's batches whose `plan.created` falls in the window, where an issue in several
batches counts once with its latest row). The orchestrate batch report prints the same lines for the batch it just ran.
The code is in `bin/stats/efficiency.mjs`.

- **Cohort and cost to merge.** A merged issue counts every `RUN_START..RUN_TERMINAL` slice of its run log
  (`~/.forge/runs/<issue>.jsonl`) that started at or before its settle time (its latest batch `log.jsonl` row) and
  belongs to the repo. Earlier failed lanes from other batches or ad-hoc runs count too. Attempt cost is
  `cost_usd_delta`, else `cost_usd`.
- **$/merge, turns/merge, context/turn**: all-phase cost ÷ merged, with implement and review totals; implement turns ÷
  merged; implement cache-read ÷ implement turns. These are also split by size (the merging run's `turns.size`, else a
  `size:` label, else `unknown`) and by model (the implement attempt's `model`).
- **Retries/merge by cause.** For builder attempts, the trigger decides the cause:

  | Cause | Triggers |
  | --- | --- |
  | env | `ci_unavailable` |
  | engine | `timeout_restart`, `context_restart`, `budget_wrapup`, `recovery` |
  | code | `precheck`, `structure`, `docs`, `enumerating`, `sequence`, `ci_red`, `conformance`, `merge_ci`, `block_correction`, `contract_correction` |
  | review | `review` |

  `plan`, `build` and `verifier` are not retries. A lane rerun (every run slice of a merged issue but the last) counts
  by the code that ended it: `env.*` is env; `engine.*`, `run.*`, `followup.*`, `base.*`, `dependency.*` are engine;
  `ci.*`, `conformance.*`, `precheck.*`, `budget.*`, `builder.*`, `contract.*` are code; `review.*` is review; anything
  else is unknown.
- **No action**: rows parked by the pre-filter (`awaiting-promotion`, `awaiting-precondition`) and lanes that ended
  `builder.blocked` with `Builder is blocked (promotion)`, with their count and cost.
- **Issue quality vs. cost**: each merged issue's body is tagged `full` (a root-cause heading, a `file:line` and a
  fix/design/approach/proposal heading), `partial` (some of these) or `none`, and n, $/merge and turns/merge are
  compared per tag.
- **Acceptance (7d after promotion)**: from trusted `FORGE:PROBE` comments (#4399). An issue whose first record is
  under 7 days old is pending. After that it passes when every record within 7 days of the first one passed. The
  first record is the observed promotion, because a probe runs only once the fix is on the default branch.

Limits: logs written before #4362 carry no trigger, so implement attempts beyond the plan and build calls count as
`unknown`. Logs written before #4407 sum running session totals. Lanes run outside a batch are in no window. `gh` (for
merged issues only) is the one network call; when it fails, quality and acceptance print `n/a` with the reason.

Every scope also prints, as its last line (forge#4491):

- **Implement wall p50**: the median over merged lanes of the summed `duration_ms` of their implement attempts, in
  minutes.
- **Merge rate**: merged ÷ the cohort's issue rows.
- **Conformance pass**: the share of rows whose lanes logged a `CONFORMANCE` verdict and whose last verdict is
  `conforms`.

`--repo` matches batch plans case-insensitively, as GitHub slugs are. Run logs are read under the plans' spelling.
`--offline` skips the GitHub crawl, so issue quality and acceptance print `n/a`. The crawl is two `gh` calls per merged
issue, which can take minutes over a large window.

### Before/after A/B (`--compare`, forge#4491)

`--compare <date|version>` compares two cohorts of the repo's batches around a deploy. The pivot is a date or ISO time,
or a release version resolved to its exact tag time (`--release-times`, else the checkout's `v*` tags).

- **post**: batches created from the pivot to now.
- **pre**: batches created in the same span before the pivot. Both sides are equally long.

It prints for each cohort turns/merge, implement wall p50, implement calls/turn p50, re-reads/merge, merge rate and
conformance pass, and then the post − pre delta.

`matched` repeats the comparison on full-shape merged lanes only, per size bucket present on both sides. Light lanes
(#4452) cut turns on their own, so the unmatched delta mixes the lane mix into any prompt or tool change. With `--json`
the result is under `query.efficiency.compare`. Cohorts are split by batch `plan.created`, as `--window` is; a lane run
outside a batch is in neither.

## Lane depth (`--depth`, forge#5209)

`forgedock stats --depth [--since <version|date>] [--min-n N] [--offline] [--repo <owner/repo>] [--json]` reads the local
run logs (`~/.forge/runs/*.jsonl`, every RUN_START..RUN_TERMINAL slice that logged `LIGHT_ELIGIBILITY`) and uses gh only
for post-merge defect signals; `--offline` skips that crawl (defects print n/a, as does a gh failure).

Columns per cell: n, merge rate, first-pass rate, needs-human rate, median cost, median wall minutes, median wall/model
time, review findings per lane (conformance failures + verifier findings) and the share of lanes with any, conformance
failure rate, and the post-merge defect rate over merged lanes with known defect data. A defect is any of the
`--conformance-outcomes` signals within 7 days (#5364): reverted, reopened, cited (a later PR names the PR or issue as
the cause), or `same_hunks` (a later fix PR's old-side lines git-blame to the lane's merge commit). `same_hunks` needs a
local clone of the repo (run from it); without one a lane with no other signal is n/a, counted as unresolved. Each fix PR
is blamed once per run (`same-hunks i/N` progress goes to stderr).

Cells are grouped by verdict (eligible, ambiguous, ineligible) and by every reason and signal code (`hotspot`,
`churn_high`, `label_docs`, `size_S`, ...), so outcomes can be attributed to each signal.

Promotion (#5052): treatment = light-shaped lanes (light or upgraded), control = full lanes the gate rated eligible, in the
size buckets both have. Met when median cost ratio <= 1.2x, median wall/model <= 1.3x and the treatment defect rate is no
worse than the control's; a cell under `--min-n` (default 10) is `insufficient data`, with n per cell printed. Flipping
`lean.light.mode: on` stays a config decision.

## Pool utilisation (`--pool`, forge#4549)

`forgedock stats --pool [--window 7d,30d] [--json]` reads the repo's local batch `report.json` rows and prints, per window,
remote lane minutes, lanes and share of the pool per agent (`sandbox.by_agent`). Rows without agent data print `n/a`.
The same per-agent minutes appear in the batch report's `sandbox:` line as `by agent: <name> <min> min, ...`.
Live capacity is `forgedock pool status`.

## Compounding (`--compounding`, forge#4696)

`forgedock stats --compounding [--window 30d] [--bucket 100,500] [--since <date>] [--min-n N] [--json]` answers "does the repo
get safer the longer ForgeDock works on it". No model: FORGE:GUARD comments (#4692, `forgedock guards list`), `reopened` issue
events (one paginated `gh api repos/<repo>/issues/events`), `git blame` and `git diff` of the current clone, and the repo's
FORGE:TELEMETRY gate events. Output: a rolling window (default 30d), per release and per lane-age bucket (merge order of the
repo's lanes: 1-100, 101-500, 501+, `unranked` for guards without a merged run).

- **reintroduction**: guarded fixes whose issue was reopened after the lane closed it, or whose merge commit is the blame of the
  old-side lines of a later guarded fix within 90 days (the guard's `merge_sha` is the commit, as for squash and rebase merges).
  Rate = reintroduced / guarded. A guard whose sha is not in the clone is counted under `blame_unresolved`, never as 0.
- **reopen-after-close**: merged (lane-closed) issues reopened afterwards / merged lanes.
- **guard activity**: counts of `guard_run`, `guard_broken` (pre-merge saves) and `supersedes_accepted` events (#4693).
- **decision churn**: `decision_superseded` vs `decision_violation` events (#4695).
- Event kinds a repo has never recorded print `n/a`, not 0. Groups under `--min-n` lanes are flagged `low n`.

Efficiency next to quality: run `forgedock stats --efficiency --compare <date|version>` around each child's deploy for
$/merge, turns/merge and wall p50. Baseline before #4693 enforces: run `forgedock stats --compounding --json --since <date>` in
a full clone of this repo and one other and keep the output with the #4697 tracker.

## Conformance outcomes (`--conformance-outcomes`, forge#5210)

`forgedock stats --conformance-outcomes [--repo R] [--since <date>] [--window-days 7] [--min-n 20] [--json]` asks whether conformance
blocks predict post-merge defects. Read only, no model and no GitHub writes. GitHub reads are one `gh api graphql` search per
page of 100 merged PRs (`repo:R is:pr is:merged merged:>=<since>`, `--since` defaults to 30 days ago; GitHub search stops at
1000 results, flagged `capped`) plus the usual FORGE:TELEMETRY crawl. Verdicts also come from the local run logs and batch
reports unless `--no-local`.

- **lane PR**: a merged PR with a conformance verdict (`query.mjs` `conformanceVerdicts`; the latest of the telemetry
  `run_terminal`/`conformance_shadow`, run-log `RUN_TERMINAL`/`CONFORMANCE_SHADOW`/`CONFORMANCE` and batch-row `conformance`
  wins). `shadow_would: conforms` conforms. Any other `would` is nonconforming, and its failure codes are the kinds. An
  enforce merge with no `would` passed the enforced gate and conforms. A merged PR without a verdict counts under `unjoined`.
- **signals** inside `--window-days` after the merge:
  - `reverted`: a later merged `Revert ...` PR naming `#N`, `Reverts R#N` or the title.
  - `reopened`: a closing issue was reopened.
  - `cited`: a later merged PR says `fix ... #N` or `review-finding ... #N` for the PR or its issue on one line.
  - `same_hunks`: a later `fix`/`revert` PR whose old-side lines `git blame` to this PR's merge commit. Only in a clone of R.
    Otherwise it is `null` and counted under `same_hunks_unresolved`.
  - A PR is defective when any signal is true. A PR whose window has not elapsed is `pending` and is not counted.
- **cells**: per repo, then the same split per mode and per failure kind. Each cell is `defects/n rate [Wilson 95% interval]`
  for nonconforming-merged vs conforming-merged, `n/a` under `--min-n` (default 20 per cell).
- **conclusion** (last line): `nonconforming merges show a higher defect rate` when the nonconforming interval lies wholly
  above the conforming one, `no higher defect rate shown for nonconforming merges` otherwise, and `insufficient data` when
  either overall cell is under min n.

## Explorer A/B (`--explore-ab`, forge#4418)

Compares lanes run with forge.yaml `lean.explore: on` against `off` (#4391), from the local run logs only (no GitHub
crawl). Every RUN_START slice of each log counts, so re-running an issue with the other mode adds a second lane.

- Rows per size bucket (`S`, `M`, `L` from the lane's turn record, else `unsized`) and mode: n, mean builder (plan +
  build) turns, mean builder `cache_read_input_tokens`, merge rate (merged / finished) and conformance rate (lanes that
  reached review with no conformance/review fix round and no shadow would-block, over reviewed; same as `--tiers`).
- A paired table restricted to issues with a finished lane in both modes.
- Finished lanes without an `explore` tag (before #4391) are counted and left out.

`--json` prints the same data as `query.explore_ab`.

## Issue origin (`--origin`, forge#5294)

`forgedock stats --origin [--repo owner/repo] [--since <date>] [--json]` splits the issues opened in the window (default: last 30 days) into requested (human author), production (`FORGE:PRODWATCH` marker or `prod-watch` label), review-finding (`review-finding`/`staging-review` labels), follow-up (`FORGE:DEFERRED_FROM`, rollup markers) and unknown (no positive evidence; never assumed requested). For each origin it prints the count, the cost from trusted `FORGE:TELEMETRY` runs and how many issues have no recorded cost (counted apart, never as $0). Outcomes are merged, closed-invalid (not planned, duplicate, `invalid`/`duplicate`/`wontfix` label), other-closed and open. The last line gives the pipeline-originated share of recorded cost.

## Sections (per version and repo)

- **Cost**: cache-read tokens per issue (mean, median), per phase (mean over all runs, so phases add up to the per-issue
  mean), per merged issue, output tokens, USD where recorded.
- **Time**: p50 and p90 duration per phase and wall time per issue.
- **Flow**: merged %, needs-human %, remediation rate, outcome-code distribution (`docs/OUTCOME-CODES.md`), and the
  **first-pass rate** (#4362): the share of lanes that reached the build (a `build` attempt, or the `timeout_restart` of
  one) with no rework attempt after it, with the count (`k/n lanes`) and how many lanes are `unknown` (their attempts
  carry no `trigger`: logs written before the field). Rework triggers: `precheck`, `structure`, `docs`, `enumerating`,
  `sequence`, `ci_red`, `conformance`, `review`, `merge_ci` (`bin/lean/fixround.mjs` `REWORK_TRIGGERS`); a timeout
  restart, a base-sync `recovery`, a `ci_unavailable` fallback or a `block_correction` does not break first pass.
- **Rework by trigger** (#4362): count and USD of the builder (`implement`) attempts with a rework trigger, per trigger,
  plus a total. Attempts without a `trigger` are counted as `unknown`, never dropped. JSON also carries every builder
  attempt by trigger (`rework.attempts`).
- **Review funnel**: findings per review by severity, then ISSUE / NOTE / in-PR fix, plus `validated` and `false-positive` issues.
- **Gates**: block rate per gate (acceptance, diff size OVER, CI, liveness), malformed-check rate, COHESIVE and OVER counts.
- **Issue flow**: issues created by source (review-finding, pipeline bot, human), closed by kind, net flow, findings per merged issue.

Each group shows a delta against the previous version of the same repo and is flagged `low-n` below `--min-n`
(default 10 finished runs).

## Counting rules

They match `scripts/cost-report.sh`, so the two reports agree on the same logs: only finished runs count; hydrated runs
and runs with no usage events are excluded; tokens are cache-read tokens; `PHASE_ATTEMPT_USAGE` supersedes the cumulative
`PHASE_COMMIT` usage of the same phase. On GitHub a run is the set of `phase_attempt` records sharing a `run` id and it is
finished once a `run_terminal` record exists. On GitHub stats count one run per issue: the latest by start timestamp wins and earlier attempts (for example before a
`--retry`) are discarded, as in `scripts/cost-report.sh`. Wall time covers the winning engine process only.

## Versions and n/a

Records carry `forge_version`. Records without one (older runs, issues with no telemetry) are placed by release time:
`--release-times FILE` (`<version> <epoch-seconds>` lines), else the git tags of the ForgeDock checkout, shown with a `~`
suffix; otherwise `unknown`. Anything that cannot be computed (no timestamps, no outcome codes, no records) prints `n/a`
instead of failing.

## Limits

Comments are read from the repo-wide `issues/comments?since=` endpoint (a few paginated calls); only issues with a trusted
telemetry comment in the window get their full comment list re-read (6 in parallel, backing off when the API rate limit is
low). A run with no `--since` and no cache still walks the whole history once. Telemetry comments are edited in place, which
the comment window catches; if a cached item still looks stale, run with `--refresh`.

## Release ledger (`--release-ledger`, forge#5718)

```bash
npx forgedock stats --release-ledger [--repo <owner/repo>] [--since <date|21d>] [--json]
npx forgedock stats --release-ledger --baseline save      # freeze today's numbers
npx forgedock stats --release-ledger --baseline compare   # before/after, measured the same way
```

One table of what a release costs today against the targets, read from the GitHub Actions runs, jobs and steps API plus
release state. Nothing is estimated: a metric without a sample prints `n/a`. The window defaults to the last 21 days.

| Row | How it is measured |
|-----|--------------------|
| Mechanical failure surfaced | Failed CI runs whose first failed step is a checkout, toolchain, dependency or lint step: run start to run end (when the failure is visible today), p50 |
| Job setup (self-hosted, hosted) | Per job, seconds in checkout, toolchain and dependency-install steps (classified by step name, any ecosystem); the p50 of each class, summed |
| CI wall time per round | A round is every CI run of one head sha of a release PR: first run created to last run finished (first attempt), p50; cancelled rounds are left out |
| Pushes per release PR | Distinct head shas with CI runs per release PR, p50 (and max) |
| Deploy pre-gate | Live deploys: run start to the start of the deploy job, p50 |
| Image build | Per job, minutes in image-build steps, p50 |
| Deploy job (rollout) | Live deploys: the deploy job's minutes, p50; the report lists its ten longest steps |
| Release PR opened -> live | PR creation to the end of the first deploy that reached live for its merge commit: median and p90; `clean` = live on the first deploy attempt |
| Queue time | Job created to job started, p90 |
| CI minutes in failed / cancelled jobs | Share of job time by job conclusion |
| CI rounds that fail | Share of judged rounds with a failed run |
| Deploy attempts that reached live | Deploy runs in which a job ran, and the share whose deploy job succeeded |

The report also prints the critical-path jobs (the job that ends last in a round, with its p50 and failure rate).

What counts as a release PR, CI run and deploy is generic and can be pinned in forge.yaml (`stats.ledger_*`, see
[CONFIG.md](CONFIG.md#stats-optional)): a release PR is a PR into the default branch (from `branches.staging` when set); its
CI runs are the pull-request runs that name it (push runs of the head branch when the repo has none); the deploy workflow is
the push/dispatch workflow on the default branch whose name says deploy, publish or release with the most runs.
`--deploy-workflow <name|file>` and `--release-head <branch|any>` override per call. With `release.managed: true` the
managed ledger's deploy attempt counts are merged in.

Cost: one runs query per branch and event (the runs API takes seconds per page), then one jobs call per run, 4 at a time.
Jobs of completed runs are cached in `~/.forge/stats-cache/<owner>_<repo>/actions-jobs.json`, so a weekly re-read only
fetches new runs (`--no-cache` skips it). Every read is paginated and retried on transient GitHub errors.

`--baseline save` writes the metrics to `release-ledger-baseline.json` next to that cache (`--baseline-file <path>` for a
file you commit). `--baseline compare` prints each metric before and after with a verdict `improved|regressed|flat|n/a`
(flat is within 5%, or 2 points for a share) and exits 2 when there is no baseline.

## Per-release regression rule (`--by version`, forge#4628)

```bash
npx forgedock stats --by version [--post-metrics <pr>] [--min-n N] [--repo <owner/repo>] [--json]
```

Median cost per run, wall p50, first-pass rate and needs-human rate of each release against the previous known one.
A metric whose own sample is under `--min-n` (default 10) is null, and so is its verdict; verdicts are
`regressed|improved|flat|null`, never a pass. `--post-metrics <pr>` posts (or updates) a `<!-- FORGE:METRICS v1 -->`
comment on that release PR with the table and the snapshot as JSON; without it nothing is written to GitHub.

## Live A/B experiments (`--experiment <id>`, forge#4629)

Declare one experiment in forge.yaml (flat keys under `experiment:`):

```yaml
experiment:
  id: light-vs-full
  arms: light,full          # at least two
  ratio: 1,1                # integer weights, default equal
  metrics: usd_median,wall_p50_ms,first_pass_rate,needs_human_rate   # default all four
  targets: light.usd_median<=1.2xfull,light.first_pass_rate>=0.8     # arm.metric<=|>=limit, optionally x<other arm>
  min_n: 10
```

The lean lane assigns each issue an arm (sha1 of id and issue number over the ratio, so a re-run keeps its arm) and tags
`experiment` and `arm` on `phase_attempt` and `run_terminal`. `forgedock stats --experiment <id>` reports the finished
runs per arm with the metrics of `--by version`; a metric under min n is null and so is any target that needs it, never a
pass. `targets_met` is true only when every target is met. `--require-met` (with `--experiment`) prints the same report but exits 1 unless `targets_met` is true (0 otherwise; 2 without `--experiment`), so a post-deploy check can gate on it (#4634). The report, `scripts/bench-lightlane.mjs aggregate` and
`scripts/eval-gate-scorecard.mjs` share one record: `{schema: "forge.bench.v1", source, arms, targets}`.

## Per-release scorecard (`forgedock scorecard`, forge#6084)

`forgedock scorecard --repo owner/repo --release vX [--json] [--min-n N]` prints a per-release table computed from the
GitHub register (telemetry records; no LLM, no network beyond `gh`), compared with the previous known release. The
release flow appends the same table, with a `Regressions vs <prev>: ...` line, to the release PR body; if the scorecard
cannot be computed the section is left out and the PR is still created.

Metrics (each `n/a` when its source is absent or its sample is below min n, default 10; verdicts reuse the `--by version`
rule and tolerances): first-pass merge rate (merged runs with no remediation and at most one builder attempt),
operator interventions per batch (batch rows), needs-human by LANE_AUDIT class (genuine vs pipeline), queue, active and
wait minutes per merged lane, minutes (wall p50) and $ per merge, revert rate, rework rate (merged runs that needed
remediation), share of requirements covered by tests (merged runs whose requirements were all verified) and stuck issues
(runs with more than one builder attempt).

Batch rows are read from the local batch logs (`~/.forge/batches/*/state.json`, interventions = applied requeues of the repo's batches). The scorecard is published in the release PR body (the release notes). LANE_AUDIT and failure-census are read from trusted issue comments that start with `<!-- FORGE:LANE_AUDIT v1 -->` or `<!-- FORGE:FAILURE_CENSUS v1 -->` and carry a fenced `json` block (one object or an array): LANE_AUDIT `{issue, release?, class: genuine|pipeline}`, failure-census `{issue, release?, class?, reverted?}` (`reverted` feeds the revert rate; a census `class` counts as an audit when no LANE_AUDIT covers the issue). They are optional inputs: they are not on every base, so without them
the dependent metrics report `n/a` rather than a guess.
