core/workbench-ui/src/app/LeewayEvidenceCard.tsx
Shay bdb294eac3 feat(workbench): land B3.5-b/c/d/e — calibration evidence subject, B4a leeway gate, docs; runner-reproducible practice artifact
Completes the Wave M B3.5 consolidation slice (b–e), built on #728.

B3.5-b — calibration as a first-class evidence subject (`calibration_class`,
address `calibration:<class_name>`): RightInspector projection + Evidence
Chain Rail semantics (serving-discipline evidence, not runtime truth).

B3.5-c / B4a — nullable `LeewayEvidence` read model threaded through turn,
replay, cognition-proposal, and math-proposal surfaces, with a shared
absence-honest card. B4 is gated correctly: the tuple exists in typed data but
no producer populates it, so the card renders absence (verified: no non-null
producer in workbench/core/chat).

B3.5-d/e — UI-UX-GUIDE.md, b4-leeway-feasibility-gate.md, phase-a-residue-ledger.md.

Practice artifact — earn-it-for-real (runner-reproducible). The committed
`report.json` (additive earns PROPOSE @0.861, 95/5/50) is now emitted by a
deterministic runner rather than copied from the queue. `propose_runner`
gains `regenerate_practice_artifacts()`, which runs ONE sealed `resolve_pooled`
practice pass and writes BOTH report.json (the per-class ledger the calibration
reader consumes) and ratification_queue.json — two projections of one ledger,
coherent by construction and byte-reproducible. `runner.main()` delegates to
it (lazy import, no cycle), so both entry points produce the identical pair.
This closes the gap where a hand-copied report.json agreed with the queue but
no runner produced it. `resolve_pooled` is the aggressive sealed PROPOSE-regime
scorer (proposal-only/HITL, unsafe for serving, legitimate for
attempt-and-eliminate); wrong=5 is the sealed-practice learning signal, NOT the
serving wrong=0. No serving/derivation/reliability_gate source touched; the
practice lane is not in the serving-frozen SHA gate.

Validated:
- python -m pytest tests/test_workbench_{calibration,journal,replay,schemas}.py -> 31 passed
- python -m pytest tests/ -k "workbench or propose or learning_arena or practice"
  -> 190 passed (3 failing tests in test_adr_0175_phase2_practice_lane.py are
  PRE-EXISTING reds on clean origin/main: stale 4/0/46 assertions on build_report,
  which this change does not touch)
- report.json + ratification_queue.json: deterministic (run1==run2) and
  reproduced byte-identically by both `python -m ...runner` and `...propose_runner`
- pnpm build green; 144 UI tests across calibration/leeway/evidence/replay/
  doctrine-gates/routes-docs-drift all pass
2026-06-13 07:36:44 -07:00

89 lines
3.2 KiB
TypeScript

import type { LeewayEvidence } from "../types/api";
import { DigestBadge } from "../design/components/DigestBadge/DigestBadge";
function pct(value: number): string {
return `${(value * 100).toFixed(1)}%`;
}
function calibrationHref(ref: string | null | undefined): string | null {
if (!ref?.startsWith("calibration:")) return null;
return `/calibration?inspect=${encodeURIComponent(ref)}`;
}
export function LeewayEvidenceCard({
evidence,
title = "Leeway evidence",
}: {
evidence?: LeewayEvidence | null;
title?: string;
}) {
if (!evidence) {
return (
<section className="rounded-md border border-[var(--color-border-subtle)] bg-[var(--color-surface-inset)] p-3">
<h3 className="m-0 text-xs font-semibold text-[var(--color-text-secondary)]">
{title}
</h3>
<p className="mt-1 mb-0 text-xs text-[var(--color-text-muted)]">
No leeway evidence recorded.
</p>
</section>
);
}
const href = calibrationHref(evidence.calibration_evidence_ref);
return (
<section className="rounded-md border border-[var(--color-state-warning-border)] bg-[var(--color-surface-inset)] p-3">
<div className="flex flex-wrap items-center gap-2">
<h3 className="m-0 text-xs font-semibold text-[var(--color-text-secondary)]">
{title}
</h3>
<span className="rounded border border-[var(--color-state-warning-border)] px-2 py-0.5 font-mono text-[10px] text-[var(--color-state-warning-text)]">
{evidence.claim_disclosure}
</span>
</div>
<dl className="mt-3 grid gap-2 text-xs">
<div className="grid grid-cols-[7rem_1fr] gap-2">
<dt className="text-[var(--color-text-muted)]">class</dt>
<dd className="m-0 font-mono text-[var(--color-text-primary)]">
{evidence.class_name}
</dd>
</div>
<div className="grid grid-cols-[7rem_1fr] gap-2">
<dt className="text-[var(--color-text-muted)]">license</dt>
<dd className="m-0 font-mono text-[var(--color-text-primary)]">
{evidence.license}
{evidence.theta === null ? "" : ` · θ ${pct(evidence.theta)}`}
</dd>
</div>
<div className="grid grid-cols-[7rem_1fr] gap-2">
<dt className="text-[var(--color-text-muted)]">calibration</dt>
<dd className="m-0 min-w-0">
{href ? (
<a
href={href}
className="font-mono text-[var(--color-link)] underline-offset-2 hover:underline"
>
{evidence.calibration_evidence_ref}
</a>
) : (
<span className="text-[var(--color-text-muted)]">not recorded</span>
)}
</dd>
</div>
<div className="grid grid-cols-[7rem_1fr] gap-2">
<dt className="text-[var(--color-text-muted)]">source</dt>
<dd className="m-0">
{evidence.source_digest ? (
<DigestBadge
digest={evidence.source_digest.replace(/^sha256:/, "")}
truncate={12}
/>
) : (
<span className="text-[var(--color-text-muted)]">not recorded</span>
)}
</dd>
</div>
</dl>
</section>
);
}