Commit dcbfe2a
authored
fix(stats): derive the published totals from the ledger instead of publishing a false zero (#9967)
An Orb reported `totals.handled: 0` beside a `reviewParity` block describing
2,123 verdicts from the same deployment's ledger. The public verifier caught it
within minutes of the flag going on.
The cause is NOT the D1/Postgres store split the issue hypothesised -- I traced
it end to end on edge-nl-01 and the store is fine. `totals.*` is gated on
LOOPOVER_PUBLIC_STATS_REPOS, which is unset there, so `projects` is empty and
getPublicStats takes its own early-return branch and sums nothing. The
ledger-derived blocks (reviewParity, automation-rate) honour no such allowlist.
Two halves of one payload, two different gates.
Ruled out both portability traps that produce the same symptom: `instr()` does
fail on Postgres, but pg-dialect.ts rewrites it (verified by running the real
translator over PUBLISHED_PR_KEYS), and PG16 accepts the unaliased subquery. The
disposition query returns 9,657 against the live store.
Publishing a number known to be false is the one option that is definitely
wrong, so the aggregate now comes from the SAME ledger the parity block reads
when no repo is allowlisted. The privacy intent is untouched, because it is
about NAMING repos: `byProject` still requires the allowlist and stays empty, so
no repo that was not opted in is identified. `totals` carries no repo identity.
DISTINCT (repo, number) deliberately -- decision_records holds one row per
VERDICT, 2,354 rows over 987 pull requests on the production Orb, so counting
rows would overstate `handled` by more than 2x and reintroduce the same class of
cross-surface disagreement this removes.
The pre-existing "must not query an unscoped own-ledger" test encoded the old
contract and passed only because safeAll swallowed its throw. Narrowed honestly:
the per-PROJECT queries still must not run, and the aggregate read is asserted
to carry no GROUP BY.
Closes #99631 parent 43c7b0f commit dcbfe2a
2 files changed
Lines changed: 162 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
323 | 323 | | |
324 | 324 | | |
325 | 325 | | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
326 | 359 | | |
327 | 360 | | |
328 | 361 | | |
| |||
331 | 364 | | |
332 | 365 | | |
333 | 366 | | |
334 | | - | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
335 | 379 | | |
336 | 380 | | |
337 | 381 | | |
| |||
532 | 576 | | |
533 | 577 | | |
534 | 578 | | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
535 | 589 | | |
536 | 590 | | |
537 | 591 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
916 | 916 | | |
917 | 917 | | |
918 | 918 | | |
919 | | - | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
920 | 924 | | |
921 | 925 | | |
922 | 926 | | |
923 | 927 | | |
924 | 928 | | |
925 | | - | |
926 | | - | |
927 | | - | |
| 929 | + | |
928 | 930 | | |
929 | | - | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
930 | 937 | | |
931 | 938 | | |
932 | 939 | | |
| |||
938 | 945 | | |
939 | 946 | | |
940 | 947 | | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
941 | 1043 | | |
942 | 1044 | | |
943 | 1045 | | |
| |||
0 commit comments