Commit 776c414
authored
fix(review): persist AI review diagnostics into cache metadata on degraded runs (#9447)
* fix(review): persist AI review diagnostics into cache metadata on degraded runs
`ai_review_cache.metadata_json` records `inconclusive` — that a review degraded, but never why.
The per-attempt `AiReviewDiagnostic` values that carry the answer were only ever sent to PostHog
as a capture property, so the 2026-07-27 investigation into missing review summaries could not
distinguish the failure classes from the database or the container logs, and reaching PostHog
needs an interactive OAuth an incident responder may not have.
Persist the compact `model#attempt:status[:error]` strings alongside `inconclusive`, so
`missing_assessment` (the model returned no narrative), `unparseable_output`/`empty_output`
(it returned something parseModelReview could not read) and `provider_error` are separable at
read time — three different bugs with three different fixes.
Written on the degraded paths only, never on the healthy one: every byte lands in a D1 row and
this database hit its 10 GB ceiling on 2026-07-26, so this buys diagnosability for the reviews
that actually failed rather than growing all of them. The strings come from
formatReviewDiagnosticsForCapture, whose `error` field is errorMessage() output and never raw
provider text, so the public/private boundary is unchanged.
Refs #9432
* fix(review): move the v8 ignore hint onto its own line so the type-level nullish arm is excluded
codecov/patch flagged the `?? []` on the diagnostics spread as a partial: the ignore comment
shared a line with the ternary's `?`, where the v8 provider does not register it. Match the
working precedent at the PostHog capture site -- comment on its own line directly above the
property -- and the branch drops out of the report. No behavior change.1 parent 49b7ada commit 776c414
2 files changed
Lines changed: 64 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
987 | 987 | | |
988 | 988 | | |
989 | 989 | | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
990 | 1004 | | |
991 | 1005 | | |
992 | 1006 | | |
| 1007 | + | |
993 | 1008 | | |
994 | 1009 | | |
995 | 1010 | | |
996 | 1011 | | |
997 | 1012 | | |
998 | 1013 | | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
999 | 1020 | | |
1000 | 1021 | | |
1001 | 1022 | | |
1002 | 1023 | | |
1003 | 1024 | | |
1004 | 1025 | | |
1005 | 1026 | | |
1006 | | - | |
| 1027 | + | |
1007 | 1028 | | |
1008 | 1029 | | |
1009 | 1030 | | |
| |||
1026 | 1047 | | |
1027 | 1048 | | |
1028 | 1049 | | |
1029 | | - | |
| 1050 | + | |
1030 | 1051 | | |
1031 | 1052 | | |
1032 | 1053 | | |
| |||
1068 | 1089 | | |
1069 | 1090 | | |
1070 | 1091 | | |
1071 | | - | |
| 1092 | + | |
1072 | 1093 | | |
1073 | 1094 | | |
1074 | 1095 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
814 | 814 | | |
815 | 815 | | |
816 | 816 | | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
817 | 857 | | |
818 | 858 | | |
819 | 859 | | |
| |||
0 commit comments