Skip to content

revert(S13b): Risk rubric reverted + samuel-wright seed enriched - #21

Merged
manjula25 merged 1 commit into
mainfrom
fix/s13-samuel-wright-seed-evidence
Jul 8, 2026
Merged

revert(S13b): Risk rubric reverted + samuel-wright seed enriched#21
manjula25 merged 1 commit into
mainfrom
fix/s13-samuel-wright-seed-evidence

Conversation

@manjula25

Copy link
Copy Markdown
Collaborator

Summary

This follow-up to PR #19 (the original S13 Risk-prompt calibration) reverts the rubric after live re-eval revealed an unexpected LLM-side regression, and ships a seed-data fix for the patient whose label-evidence gap was the original motivation for the calibration.

What happened

PR #19 was authored to fix the rubric-analyzer's biggest gap (9 FPs / 13 TNs → specificity 30.8%). Live re-eval on it showed a regression that the original design didn't anticipate:

MetricPre-S13PR #19 (rubric in prompt)Pre-S13 retry (post-revert)
Specificity30.8%0%0%
FPs (out of 13 TNs)91313
Sensitivity100%100%100%

The post-revert column is the key finding: re-running the original pre-S13 code (no rubric) reproduces the same specificity 0%. So the rubric isn't the cause — the LLM API has changed baseline behavior between 2026-07-07 (date of the committed pre-S13 report) and 2026-07-08 (today). Today's LLM calls every patient with active Conditions riskLevel: 'critical' regardless of bundle evidence.

This PR:

  1. Reverts the rubric to the original 1-paragraph form (with export retained for TDD + a JSDoc noting the reversion).
  2. Trims the 4 rubric-pin tests to 2 — keeps the citation requirement guard (GD11) and the bundle grounding guard, removes the rubric-anchor and threshold-text tests.
  3. Rewrites the eval-report disclosures from "rubric-mirrors-seed" to "S13b = reversion + seed enrichment".
  4. Enriches samuel-wright's seed with Encounter + Observations — the single data fix the rubric-mirrors-seed analysis identified as the actual gap.

What this PR does NOT do

  • Does not regenerate docs/eval-report.{md,json}. Today's fresh-cache eval reports specificity 0% — a regression that is not caused by this PR (verified above) and would mislead any downstream reader. The 2026-07-07 pre-S13 committed reports stay as the canonical artifact. The live-eval data point + the LLM-variance diagnosis are recorded in verification-s13.md §4.
  • Does not address the broader LLM-side variance — that's cross-slice follow-up (feat(S1): Walking Skeleton — login, My Patient Panel, live FHIR reads #1 below).

Verification

CheckResult
npx jest src/agents/riskAgent.test.ts7/7 passed (5 pre-existing + 2 surviving regression guards)
npx jest src/eval/ src/agents/43/43 passed, 8/8 suites
npx tsc --noEmitexit 0
npm run import (idempotent PUT)2393 resources re-imported (no schema change, no new fields)

Cross-slice follow-up (verification-s13.md §6)

  1. LLM-side variance investigation — determine why the API state changed between 2026-07-07 and 2026-07-08. Same investigation needed for Care Gap (now FN=10) and SDOH (now 93.75% agreement, down from 100%) — all three specialists regressed in the same way today. Tracks to a model-version / system-prompt / temperature-default change.
  2. A v2 Risk rubric with few-shot examples instead of abstract anchors (the v1 rubric's negative-instruction phrasing ("Do not call a patient high or critical when fewer than 2 anchors are met") lost to the LLM's clinical-judgment instinct in practice).
  3. Clinician validation of labels via npm run review:render (long-term path to a real-clinical rubric regardless of LLM variance).
  4. Re-run eval after (1) confirms the rubric's intended effect on stable LLM-side behavior.

Audit trail

  • docs/plans/caresync-ai/design-risk-calibration.md — full S13 design rationale + why the rubric failed (retained as historical)
  • docs/plans/caresync-ai/implementation-plan-risk-calibration.md — original phases A-E + S13b additions
  • docs/plans/caresync-ai/verification-s13.md — active post-mortem with the failure-mode trigger, live-eval data, and the full LLM-variance diagnosis
  • docs/plans/caresync-ai/review-s13.md — S13b two-axis review

🤖 Generated with Claude Code

Co-Authored-By: Claude noreply@anthropic.com

Follow-up to PR #19 (the original S13 Risk-prompt calibration). Live re-eval
on PR #19 produced a regression the original design didn't anticipate:
| Metric | Pre-S13 | PR #19 (rubric) | Pre-S13 retry (post-revert) |
| Specificity | 30.8% | 0% | 0% |
| FPs (out of 13 TNs) | 9 | 13 | 13 |
| Sensitivity | 100% | 100% | 100% |
The pre-S13 retry column is the key finding: reverting the rubric to the
original 1-paragraph form reproduces the same specificity 0% the rubric did.
The LLM API has changed baseline behavior between 2026-07-07 (date of the
committed pre-S13 report) and 2026-07-08 (today) — it now calls every patient
with active Conditions `riskLevel: 'critical'` regardless of bundle evidence.
This is *not* caused by the S13 PR; the trigger is upstream of this code.
Actions in this PR:
1. Revert the S13 rubric prompt to the prior 1-paragraph form. The `export`
of `buildPrompt` is kept (TDD surface) and a JSDoc paragraph documents the
reversion + points at design-risk-calibration.md for the audit trail.
2. Trim the 4 rubric-pinning tests to 2: kept the citation requirement
regression guard (GD11) and the bundle grounding guard. Removed the
rubric-anchor and threshold-text tests (the rubric they pinned is gone).
7/7 riskAgent.test.ts green; 43/43 across src/eval/ + src/agents/ green.
3. Rewrite the S13 disclosures in `apps/api/src/scripts/eval.ts`'s
`renderMarkdown()` from "rubric-mirrors-seed" to "S13b = reversion +
seed enrichment" — both at the Methodology banner and above the Risk-FP
list. The next `npm run eval` will print the rewritten disclosures.
4. Enrich `apps/api/src/fhir-data/seed-patients.ts`'s `samuel-wright` with
an Encounter (CHF inpatient, discharged 36h ago) + 2 Observations
(BNP 380 pg/mL — well above the 200 threshold — and K+ 3.5). His `riskScore: 79`
plus the post-discharge tasks ("Daily weight monitoring", "Sodium-restricted
diet education") implied a CHF admit with BNP evidence; the bundle
previously didn't carry the evidence. Re-import FHIR (idempotent PUT)
propagated the change.
5. Refresh the 4 plan/verification/review docs:
- design-risk-calibration.md = historical (rubric reverted)
- implementation-plan-risk-calibration.md = historical + S13b additions
- verification-s13.md = active post-mortem (failure-mode trigger,
live-eval data, LLM-variance diagnosis)
- review-s13.md = S13b two-axis review
NOT in this commit:
- docs/eval-report.{md,json} NOT regenerated. The fresh-cache eval reports
a specificity regression (0%) that's not caused by this PR and would
mislead any downstream reader. The pre-S13 committed reports (2026-07-07
timestamps) stay as the canonical artifact. The follow-up live-eval data
point is recorded in verification-s13.md §4.
Cross-slice follow-up (verification-s13.md §6):
1. LLM-side variance investigation — determine why the API state changed
between 2026-07-07 and 2026-07-08 (model version, system prompt, defaults).
2. v2 Risk rubric with few-shot examples instead of abstract anchors.
3. Clinician validation of labels via `npm run review:render`.
4. Re-run eval after (1) to confirm the calibration gains are reproducible.
Co-Authored-By: Claude <noreply@anthropic.com>
@manjula25
manjula25 merged commit 06b095c into mainJul 8, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@manjula25