Commit 7ffb51e
* feat(proof): public per-repo proof summary, endpoint and README badge (#9569)
The shareable, unauthenticated twin of the in-app trust panel. One
composition serves both, so the public page and #9193's panel cannot
disagree about a figure -- which is the property the page exists to
demonstrate.
THE PRIVACY BOUNDARY IS STRUCTURAL. Every field is built by NAMING it,
never by filtering a wider object. A blocklist has to anticipate every
field a future upstream type might grow and silently leaks the one it did
not; an allowlisted shape cannot leak a field nobody wrote down. Tested by
feeding hostile records carrying hotkey/wallet/reward/trust-score/private-
rank and asserting none of it reaches the serialized page -- while the
named fields do, so the test proves allowlisting rather than an empty
object.
NEVER A BARE SCALAR. Any accuracy figure carries its coverage and a Wilson
interval; below a 20-decision floor there is no rate at all, only an
explicit insufficient_data state that still publishes the count. A perfect
record over 19 decisions must not render as 100%. Wilson rather than Wald
because a gate metric lives near p->1, exactly where Wald claims
impossible certainty.
HONEST BOUNDARY STATES. An empty ledger is `empty`, not `verified` --
different claims. A failed read is `unavailable`, not `broken`, which
would accuse the operator of tampering. A FAILED anchor attempt is not an
anchor: the public attempt log is where failures are legible, and
presenting one here would claim corroboration that does not exist. The
verification-contract boundary statement travels IN the payload, so a
screenshot or embed cannot shed it the way a footer caption can.
The badge reports the LEDGER's state rather than an accuracy percentage: a
badge is a one-glance claim, and an accuracy number without the interval
that makes it honest does not fit in one. Disabled and errored both render
a neutral SVG -- a broken image in a README is worse than an honest
"unavailable".
DECISION (requirement 6), recorded beside the code that implements it: the
page is opt-OUT per repo, default ON once the operator's fleet-wide flag
(default OFF) is on. Every figure is already publicly fetchable through
the ledger-verify / anchors / decision-record endpoints, so gating a page
over it would add friction without privacy. The per-repo switch still
exists because a page is a different artifact from an API -- discoverable,
linkable, and it markets a repo's numbers whether or not the maintainer
wants that. A repo can opt out but cannot opt IN when the operator has
not, which keeps the fleet switch a real switch.
Found and fixed while testing: `DB.prepare()` throws SYNCHRONOUSLY on a
driver-level failure, so the `.catch()` chain never ran and a D1 outage
would have 503'd the whole public page instead of degrading. Each section
is now a real try/catch, which is the difference between the
fail-safe-per-section contract being documented and being true.
Backend half of #9569; the /proof/:owner/:repo UI route renders this
payload and lands separately.
* fix(proof): actually wire the per-repo opt-out the routes only claimed to honor (#9569)
Review caught the real defect: both handlers called
isProofPageEnabledForRepo(c.env) with no second argument, so the
ProofPageRepoOverride documented at length in proof-summary.ts and in the
PR body was never loaded or passed. Every repo was effectively
opt-out-less once the fleet flag was on -- a gate that is described,
typed, and unit-tested as a pure function, but never reachable from the
surface it governs. That is the registered-but-unreachable class, and the
long comment made it worse rather than better by making it look done.
- Adds a real `publicProof:` focus-manifest block (engine parser + toJson
+ loader snapshot), mirroring `publicStats:`/`ops:`. Precedence is
deliberately the opposite of those two: read from the TARGET repo's
manifest rather than the operator's self-repo, because the thing being
opted out of is that repo's own page.
- loadProofPageRepoOverride resolves it, degrading a failed manifest load
to "no override" -- a broken manifest never takes a page DOWN, which is
the failure direction worth accepting here and is now stated in the
doc comment rather than left implicit.
- Both routes load the override BEFORE anything else, so a repo that
turned its page off does not have its decision records queried to build
a summary that will be discarded.
- Documents the block in .loopover.yml.example, including the precedence
and the opt-out default.
Tests that would have caught it: a repo opting out in its manifest now
gets 404 from BOTH routes with the fleet flag on, while a different repo
in the same fleet still serves 200 (the opt-out is per repo, not a kill
switch); explicit opt-in and no-block-at-all both serve; and the resolver
is covered across absent/explicit/failing loads.
* fix(build): build @loopover/contract in ui:build, unbreaking the Cloudflare Workers build
The Workers build for loopover-ui has been failing on every PR since #9521
(merged as #9590) made src/openapi/schemas.ts import
@loopover/contract/public-api:
Cannot find module '.../node_modules/@loopover/contract/dist/public-api.js'
imported from /opt/buildhome/repo/src/openapi/schemas.ts
ui:build builds ui-kit and engine, then runs ui:openapi -- but never builds
the contract package, so the import resolves to a dist/ that does not
exist. CI did not catch it because the GitHub workflow has its own
separate "Build contract package" step (ci.yml:361) before the drift
checks; the Cloudflare build runs npm run build:cloudflare -> ui:build
directly and gets no such step. The two paths had silently diverged.
Add @loopover/contract to the same turbo invocation that already builds
the engine, so the one script both paths share produces everything
ui:openapi imports.
Reproduced locally by deleting packages/loopover-contract/dist and running
ui:openapi (identical ERR_MODULE_NOT_FOUND), then confirmed the fixed
chain builds the package and writes the spec with no drift.
* fix(manifest): register publicProof as a known top-level field, and sync the example template
Two failures from the #9569 manifest block, both mine.
1. The unknown-top-level-field validator never learned about `publicProof`,
so every manifest carrying it warned "Manifest contains unknown
top-level field: publicProof." That was invisible on the first pass and
appeared on every LATER one, because the first pass parses a manifest
with no such key while later passes reload the persisted snapshot --
which my loader change now serializes the field into. The warning lands
in the published review comment, so an unchanged PR got a fresh comment
PATCH on every regate sweep: exactly the #3379 churn that test exists to
prevent, reintroduced by a field the writer knew about and the reader
did not.
Found by instrumenting the test's PATCH interception to diff the two
comment bodies rather than guessing at the cause; the added line named
itself.
2. config/examples/loopover.full.yml must mirror .loopover.yml.example
from "WHERE IT LIVES" onward, and I documented the block in only one of
the two.
Verified against origin/main first to confirm both were regressions from
this branch rather than pre-existing.
* test(proof): close the patch-coverage gaps, and fix a second sync-throw the gap exposed
Codecov flagged 8 uncovered changed lines across focus-manifest.ts and
routes.ts. I had measured coverage on proof-summary.ts and proof-badge.ts
only, and never on the two files the manifest block and the routes
actually touched -- so the gap was in my own verification, not just the
tests.
Closing it turned up a real defect rather than only missing assertions:
loadProofPageRepoOverride used `.catch()` on the injected manifest loader,
so a loader throwing SYNCHRONOUSLY (a driver-level failure before it ever
returns a promise) skipped the handler entirely and would have escaped to
the route -- 503ing a public page over a manifest read that is supposed to
be optional. That is the same defect this file already had in
loadProofSummary's section reads, which I fixed there and then
reintroduced here. Now a real try/catch, with a regression test using a
synchronously-throwing loader.
Coverage:
- parsePublicProofConfig / publicProofConfigToJson: explicit on/off, a
present-but-empty block (present-but-false, which the resolver keys on),
absence, three non-mapping shapes warning rather than throwing, and a
snapshot round-trip.
- A regression test asserting publicProof is a KNOWN top-level field, so
the writer/reader split behind the #3379 regate churn cannot return.
- The two route 503 arms are unreachable today (every inner read is
individually fail-safe), so they are excluded with the house v8 pragma
and a note on why they are kept: a future unguarded read should degrade
to 503 rather than 500 on an unauthenticated public route. The badge arm
uses ignore start/stop -- `next 2` miscounts across a multi-line comment
and left the return uncovered.
All three changed files now report zero uncovered changed lines.
* refactor(proof): one shared resolver for both surfaces, and delete the unreachable arms
Replaces the coverage pragmas with the fix they were papering over.
The gate, the read and the outcome now live in ONE resolver
(resolveProofPage) that both handlers render. That is not tidiness: the
gate previously lived inline in both route bodies and exactly one of them
was wired to the per-repo opt-out, which is the defect review caught. A
shared resolver makes "the page and the badge agree about whether this
repo is published" true by construction instead of by two call sites
remembering the same thing.
With that in place the two 503 arms were provably unreachable, because
loadProofSummary is TOTAL -- every read is wrapped per section, so a
failing ledger/anchor/record read degrades to that section's honest
neutral state and the page still composes. Rather than excluding dead
branches from coverage, the outcome is gone from the type: ProofPageResult
is `ok | disabled`. A test asserts the totality directly -- every
dependency failing at once, including a DB binding that throws on property
access, still resolves to a rendered page in its neutral states.
Same treatment for buildProofAccuracy's `!interval` guard: wilsonInterval
returns null exactly when there are no trials, which IS the
nothing-decided case, so one reachable guard covers both reasons a rate is
unpublishable instead of a dead branch behind a pragma.
Net: no `v8 ignore` pragmas anywhere in the #9569 code, and zero
uncovered changed lines or branches across proof-summary.ts, routes.ts and
focus-manifest.ts.
---------
Co-authored-by: loopover-orb[bot] <296761690+loopover-orb[bot]@users.noreply.github.com>
1 parent e95afc0 commit 7ffb51e
14 files changed
Lines changed: 1136 additions & 1 deletion
File tree
- apps/loopover-ui/public
- config/examples
- packages/loopover-engine/src
- src
- api
- auth
- openapi
- review
- signals
- test/unit
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1493 | 1493 | | |
1494 | 1494 | | |
1495 | 1495 | | |
| 1496 | + | |
| 1497 | + | |
| 1498 | + | |
| 1499 | + | |
| 1500 | + | |
| 1501 | + | |
| 1502 | + | |
| 1503 | + | |
| 1504 | + | |
| 1505 | + | |
| 1506 | + | |
| 1507 | + | |
| 1508 | + | |
| 1509 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26299 | 26299 | | |
26300 | 26300 | | |
26301 | 26301 | | |
| 26302 | + | |
| 26303 | + | |
| 26304 | + | |
| 26305 | + | |
| 26306 | + | |
| 26307 | + | |
| 26308 | + | |
| 26309 | + | |
| 26310 | + | |
| 26311 | + | |
| 26312 | + | |
| 26313 | + | |
| 26314 | + | |
| 26315 | + | |
| 26316 | + | |
| 26317 | + | |
| 26318 | + | |
| 26319 | + | |
| 26320 | + | |
| 26321 | + | |
| 26322 | + | |
| 26323 | + | |
| 26324 | + | |
| 26325 | + | |
| 26326 | + | |
| 26327 | + | |
| 26328 | + | |
| 26329 | + | |
| 26330 | + | |
| 26331 | + | |
| 26332 | + | |
| 26333 | + | |
| 26334 | + | |
| 26335 | + | |
| 26336 | + | |
| 26337 | + | |
| 26338 | + | |
| 26339 | + | |
| 26340 | + | |
| 26341 | + | |
| 26342 | + | |
| 26343 | + | |
| 26344 | + | |
| 26345 | + | |
| 26346 | + | |
| 26347 | + | |
| 26348 | + | |
| 26349 | + | |
| 26350 | + | |
| 26351 | + | |
| 26352 | + | |
| 26353 | + | |
| 26354 | + | |
| 26355 | + | |
| 26356 | + | |
| 26357 | + | |
| 26358 | + | |
| 26359 | + | |
| 26360 | + | |
| 26361 | + | |
| 26362 | + | |
| 26363 | + | |
| 26364 | + | |
| 26365 | + | |
| 26366 | + | |
| 26367 | + | |
| 26368 | + | |
| 26369 | + | |
| 26370 | + | |
| 26371 | + | |
| 26372 | + | |
| 26373 | + | |
| 26374 | + | |
| 26375 | + | |
| 26376 | + | |
| 26377 | + | |
26302 | 26378 | | |
26303 | 26379 | | |
26304 | 26380 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1507 | 1507 | | |
1508 | 1508 | | |
1509 | 1509 | | |
| 1510 | + | |
| 1511 | + | |
| 1512 | + | |
| 1513 | + | |
| 1514 | + | |
| 1515 | + | |
| 1516 | + | |
| 1517 | + | |
| 1518 | + | |
| 1519 | + | |
| 1520 | + | |
| 1521 | + | |
| 1522 | + | |
| 1523 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
440 | 440 | | |
441 | 441 | | |
442 | 442 | | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
443 | 458 | | |
444 | 459 | | |
445 | 460 | | |
| |||
1249 | 1264 | | |
1250 | 1265 | | |
1251 | 1266 | | |
| 1267 | + | |
1252 | 1268 | | |
1253 | 1269 | | |
1254 | 1270 | | |
| |||
1413 | 1429 | | |
1414 | 1430 | | |
1415 | 1431 | | |
| 1432 | + | |
| 1433 | + | |
| 1434 | + | |
| 1435 | + | |
| 1436 | + | |
| 1437 | + | |
| 1438 | + | |
1416 | 1439 | | |
1417 | 1440 | | |
1418 | 1441 | | |
| |||
1478 | 1501 | | |
1479 | 1502 | | |
1480 | 1503 | | |
| 1504 | + | |
1481 | 1505 | | |
1482 | 1506 | | |
1483 | 1507 | | |
| |||
1520 | 1544 | | |
1521 | 1545 | | |
1522 | 1546 | | |
| 1547 | + | |
1523 | 1548 | | |
1524 | 1549 | | |
1525 | 1550 | | |
| |||
2356 | 2381 | | |
2357 | 2382 | | |
2358 | 2383 | | |
| 2384 | + | |
| 2385 | + | |
| 2386 | + | |
| 2387 | + | |
| 2388 | + | |
| 2389 | + | |
| 2390 | + | |
| 2391 | + | |
| 2392 | + | |
| 2393 | + | |
| 2394 | + | |
| 2395 | + | |
| 2396 | + | |
| 2397 | + | |
| 2398 | + | |
| 2399 | + | |
| 2400 | + | |
| 2401 | + | |
2359 | 2402 | | |
2360 | 2403 | | |
2361 | 2404 | | |
| |||
4247 | 4290 | | |
4248 | 4291 | | |
4249 | 4292 | | |
| 4293 | + | |
4250 | 4294 | | |
4251 | 4295 | | |
4252 | 4296 | | |
| |||
4326 | 4370 | | |
4327 | 4371 | | |
4328 | 4372 | | |
| 4373 | + | |
4329 | 4374 | | |
4330 | 4375 | | |
4331 | 4376 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
306 | 306 | | |
307 | 307 | | |
308 | 308 | | |
| 309 | + | |
| 310 | + | |
309 | 311 | | |
310 | 312 | | |
311 | 313 | | |
| |||
1366 | 1368 | | |
1367 | 1369 | | |
1368 | 1370 | | |
| 1371 | + | |
| 1372 | + | |
| 1373 | + | |
| 1374 | + | |
| 1375 | + | |
| 1376 | + | |
| 1377 | + | |
| 1378 | + | |
| 1379 | + | |
| 1380 | + | |
| 1381 | + | |
| 1382 | + | |
| 1383 | + | |
| 1384 | + | |
| 1385 | + | |
| 1386 | + | |
| 1387 | + | |
| 1388 | + | |
| 1389 | + | |
| 1390 | + | |
| 1391 | + | |
| 1392 | + | |
| 1393 | + | |
| 1394 | + | |
| 1395 | + | |
| 1396 | + | |
| 1397 | + | |
| 1398 | + | |
| 1399 | + | |
| 1400 | + | |
| 1401 | + | |
| 1402 | + | |
| 1403 | + | |
| 1404 | + | |
| 1405 | + | |
1369 | 1406 | | |
1370 | 1407 | | |
1371 | 1408 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
51 | 56 | | |
52 | 57 | | |
53 | 58 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
609 | 609 | | |
610 | 610 | | |
611 | 611 | | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
612 | 616 | | |
613 | 617 | | |
614 | 618 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1909 | 1909 | | |
1910 | 1910 | | |
1911 | 1911 | | |
| 1912 | + | |
| 1913 | + | |
| 1914 | + | |
| 1915 | + | |
| 1916 | + | |
| 1917 | + | |
| 1918 | + | |
| 1919 | + | |
| 1920 | + | |
| 1921 | + | |
| 1922 | + | |
| 1923 | + | |
| 1924 | + | |
| 1925 | + | |
| 1926 | + | |
| 1927 | + | |
| 1928 | + | |
| 1929 | + | |
| 1930 | + | |
| 1931 | + | |
| 1932 | + | |
| 1933 | + | |
| 1934 | + | |
| 1935 | + | |
| 1936 | + | |
| 1937 | + | |
1912 | 1938 | | |
1913 | 1939 | | |
1914 | 1940 | | |
| |||
0 commit comments