Skip to content

Answer safety hardening: source tier rule, superseded sources out of evidence, national guidance line, tests and ledger - #3743

Merged
BigSimmo merged 9 commits into
mainfrom
claude/project-thread-elv1q7
Oct 22, 2026
Merged

BigSimmo merged 9 commits into
mainfrom
claude/project-thread-elv1q7

Conversation

@BigSimmo

@BigSimmo BigSimmo commented Oct 21, 2026 •

Copy link
Copy Markdown
Owner

Requested by Josh · project thread

Summary

  • tests/australian-source-priority.test.ts: pins the owner tier rule from #BFCTST. At equal relevance the order is WA validated, then Australian national, then other states, then supplementary. Relevance always wins across bands. Supplementary padding is dropped once two Australian documents suffice.
  • tests/registered-public-answer-options.test.ts (new): synthetic gating tests for src/lib/registered-public-answer-options.ts (audit DOC-18).
  • Superseded sources out of evidence (owner rule 2026-09-25, approved for build 2026-10-21):
    • src/lib/rag/superseded-evidence.ts removes document_status: "outdated" rows once in src/lib/rag/rag.ts, before every answer route.
    • review_due and unknown are unchanged.
    • A read-only live count on 2026-10-21 found 0 indexed documents marked outdated (2185 current, 588 review_due, 80 unknown), so no current answer should change.
    • Two fallback tests used an outdated row only to trigger the governance-gap marker. They now use poor extraction, which raises the same marker.
  • National guidance line (owner decision 2026-10-21; mockup approved on the owner's PC, Live site visual checks item 8):
    • When a WA guideline and a national guideline differ on a point, the answer still follows WA. One plain grey line under the prose reads "National guidance differs on this point. See <title>, , p .", and the source name links to the national source's page.
    • src/lib/rag/guidance-difference-note.ts attaches it in src/lib/answer-response.ts. It is passed through clientAnswerFieldsSchema and rendered by NaturalLanguageAnswer.
    • The line only comes from an owner-signed entry in src/data/reviewed-guidance-differences.json. That file ships empty, so no live answer changes until the owner signs off a difference.
    • Partial support, refusals, ungrounded answers and expired entries never show the line.
  • tests/fixtures/kemh-lithium-breastfeeding-live-excerpt.json: KEMH passage captured read-only for #ZZ4RAP case breastfeeding-lithium. It is not wired yet because the owner is correcting the draft.
  • Ledger inbox:
    • Done: #HD1C6W, #F3B2XC (cloZAPine exception confirmed by the owner), #VXB8XA, #E6142T (owner: won't fix).
    • Updated: #ZZ4RAP, #BFCTST.
    • New item for the missing WA valproate guideline.

RAG impact: behaviour change. Superseded (outdated) sources leave the answer evidence set, and the live corpus has none today. The guidance line has no retrieval effect and ships with an empty list. Canary pair: owner-approved, capped at US$4. The baseline is the 2026-10-21 14:09Z main canary (run 39614340500). The after run is post-merge.

Verification

  • Checks run:
    • tests/guidance-difference-note.dom.test.tsx: 7 passed.
    • Every unit test touching the answer payload or answer UI (36 files): Tests 845 passed (845).
    • rag-answer-fallback: 179 passed. Tier and loader tests: 23 passed.
    • npm run eval:rag:offline: 984 passed. npm run eval:rag:adversarial:offline: 25 passed.
    • tsc --noEmit clean, eslint clean, prettier applied.

Risk and rollout

  • Risk: low.
    • The outdated filter affects only documents marked outdated, and there are none live.
    • The guidance line is inert until an owner-signed entry exists.
  • Rollback: revert the individual commits.
  • Provider or production effects: none from this PR. Two read-only Supabase reads were made with owner approval.

Notes

  • Run npm run issues:reconcile after merge.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Jchk5iTkeUyPRUoCHyWei6

…answer loader

Tier-rule tests for #BFCTST (WA, national, other states, supplementary within a
relevance band) and synthetic gating tests for registered-public-answer-options.ts
(audit DOC-18). Ledger inbox: close #HD1C6W, #F3B2XC and #VXB8XA as already fixed
on main, and bring #ZZ4RAP and #BFCTST up to date. No answer behaviour change.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Jchk5iTkeUyPRUoCHyWei6
@BigSimmo BigSimmo self-assigned this Oct 21, 2026
@coderabbitai

coderabbitai Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Your organization has reached its usage spending cap. Adjust your spending cap in the billing tab.

Next included review available in 14 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 91 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository: BigSimmo/PsychSift/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Team
  • Run ID: 13954bd8-2cff-4237-bc28-3151306868c1
📥 Commits

Reviewing files that changed from the base of the PR and between 92d37ba and 410c02d.

📒 Files selected for processing: 25
  • docs/outstanding-issues-inbox/4f15ebaf-d311-4971-a52f-46e26a2a963d.json
  • docs/outstanding-issues-inbox/62c5cf9f-95c6-4a40-9112-6f63ac631d9b.json
  • docs/outstanding-issues-inbox/d7678153-b6d7-4571-8f46-48f4a59ca47a.json
  • docs/outstanding-issues-inbox/e9b59bb8-6de5-4041-a086-c6d01bae8593.json
  • docs/outstanding-issues-inbox/eed86710-2875-44cf-80bf-8a79dc8fe069.json
  • docs/outstanding-issues-inbox/f2e5b2bc-8d0d-4b8c-86a6-a93dfa6cdc7e.json
  • docs/outstanding-issues-inbox/f4f9f0cd-7579-4f7e-8beb-6c30ee1fc5cb.json
  • src/components/clinical-dashboard/answer-content.tsx
  • src/components/clinical-dashboard/answer-copy-payload.ts
  • src/components/clinical-dashboard/answer-result-surface.tsx
  • src/components/clinical-dashboard/answer-thread-turn.tsx
  • src/data/reviewed-guidance-differences.json
  • src/lib/answer-client-fields.ts
  • src/lib/answer-response.ts
  • src/lib/rag/guidance-difference-note.ts
  • src/lib/rag/rag-document-summary-context.ts
  • src/lib/rag/rag.ts
  • src/lib/rag/superseded-evidence.ts
  • tests/australian-source-priority.test.ts
  • tests/fixtures/kemh-lithium-breastfeeding-live-excerpt.json
  • tests/guidance-difference-note.dom.test.tsx
  • tests/rag-answer-fallback.test.ts
  • tests/rag-document-summary.test.ts
  • tests/rag-superseded-evidence.test.ts
  • tests/registered-public-answer-options.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@supabase

supabase Bot commented Oct 21, 2026

Copy link
Copy Markdown

This pull request has been ignored for the connected project sjrfecxgysukkwxsowpy because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

gitar-bot[bot]
gitar-bot Bot previously approved these changes Oct 21, 2026

@gitar-bot gitar-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gitar has auto-approved this PR (configure)

Owner rule of 2026-09-25 (#BFCTST), approved for build 2026-10-21. Outdated
documents are removed once, before every answer route sees the ranked results,
instead of only being penalised in ranking. review_due and unknown sources are
unchanged. A read-only live count on 2026-10-21 found no indexed document marked
outdated, so no current answer should change. Two fallback tests that used an
outdated row only as a convenient governance-gap trigger now use poor extraction,
which raises the same marker.

Also: capture the KEMH lithium breastfeeding passage for #ZZ4RAP, close #E6142T,
record the owner's cloZAPine decision, and log the missing WA valproate guideline.

RAG impact: behaviour change - outdated sources leave the evidence set; canary pair pending

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Jchk5iTkeUyPRUoCHyWei6
@BigSimmo BigSimmo changed the title Answer safety hardening: source tier rule tests, public answer loader tests, ledger tidy-up Answer safety hardening: source tier rule, superseded sources out of evidence, tests and ledger Oct 21, 2026
gitar-bot[bot]
gitar-bot Bot previously approved these changes Oct 21, 2026

@gitar-bot gitar-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gitar has auto-approved this PR (configure)

Owner decision 2026-10-21 (mockup approved, Live site visual checks item 8):
when a WA guideline and a national guideline differ on a point, the answer
still follows WA and one plain line under the prose names the national source,
linking to its page.

The line only comes from an owner-signed entry in
src/data/reviewed-guidance-differences.json, which ships empty, so no live
answer changes until the owner signs off a difference. Partial support,
refusals, ungrounded answers and expired entries never show it.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Jchk5iTkeUyPRUoCHyWei6
@BigSimmo BigSimmo changed the title Answer safety hardening: source tier rule, superseded sources out of evidence, tests and ledger Answer safety hardening: source tier rule, superseded sources out of evidence, national guidance line, tests and ledger Oct 21, 2026
Comment thread src/lib/rag/guidance-difference-note.ts Resolved
…ld reject

A signed entry with an out-of-range year or overlong title would have built a
note that fails clientAnswerFieldsSchema, and the client rejects the whole
answer in that case. Entries are now active only when their note already
passes that schema, so a bad entry is dropped, as documented.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Jchk5iTkeUyPRUoCHyWei6
gitar-bot[bot]
gitar-bot Bot previously approved these changes Oct 21, 2026

@gitar-bot gitar-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gitar has auto-approved this PR (configure)

@gitar-bot

gitar-bot Bot commented Oct 21, 2026

Copy link
Copy Markdown
Contributor
Code Review ✅ Approved 1 closed / 1 findings

🔴 High risk · Filtering outdated documents from the shared RAG evidence set changes clinical answer grounding across routes and could leave queries without usable evidence.

Adds a superseded-source filter so outdated documents leave answer evidence, a national guidance difference line under answers, and tests for source tier ordering and the answer loader. The registry validator mismatch that could drop whole answers over one bad entry was addressed. No open issues found.

✅ 1 closed
✅ Bug: Registry validator is looser than client schema, so one bad entry drops the whole answer

📄 src/lib/rag/guidance-difference-note.ts:40-54 📄 src/lib/answer-client-fields.ts:163-172 📄 src/lib/answer-response.ts:19-22
isReviewedDifference accepts any integer year, any positive page, a title of any length, and ids of any length. clientAnswerFieldsSchema.guidanceDifference is stricter: year must be 1900–2100, page at most 10,000, title at most 300 characters, and ids at most 500. When the client restores the payload, answer-client-payload.ts runs clientAnswerFieldsSchema.safeParse(value) and returns null if it fails. So a signed entry with a typo, for example year 20233 or a long title, would not be dropped as the doc comment promises. It would instead cause the client to reject every answer that cites that WA chunk. Fix: apply the same bounds in isReviewedDifference, or validate the built note against the schema field before attaching it in withGuidanceDifference.

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Approved

For more verification details, comment gitar display:verbose.

Options

Auto-apply is off → Gitar will not commit updates to this branch.
Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Auto-apply Compact
gitar auto-apply:on         
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

@BigSimmo
BigSimmo marked this pull request as ready for review October 22, 2026 01:04

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BigSimmo has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-22T01:07:00.417910Z 622432d Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@claude

claude Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Claude encountered an error after 2s —— View job


I'll analyze this and get back to you.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 622432df21

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/lib/rag/rag.ts Resolved
Comment thread src/lib/rag/rag.ts Resolved
…idance line in copies

Review follow-ups on the superseded-source rule and the national guidance line:
- Drop outdated rows before every text and memory-card fast-path selection, so an
  outdated lexical match cannot short-circuit the lanes that would find current guidance.
- Refuse to summarise a document marked outdated instead of generating from it.
- Copied answers carry the national guidance line directly after the answer text.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Jchk5iTkeUyPRUoCHyWei6
@BigSimmo
BigSimmo enabled auto-merge October 22, 2026 01:39
…ts within budget

rag.ts had grown past its 4362-line no-growth budget. The not-indexed and
superseded-document refusals now come from documentSummaryUnavailableAnswer
in rag-document-summary-context.ts; behaviour is unchanged.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Jchk5iTkeUyPRUoCHyWei6

Copy link
Copy Markdown
Owner Author

Lighthouse budget is red on 410c02d. I think the cause is outside this PR.

  • What fails: desktop-root TBT is 139 ms against a baseline of 64 ms. That is 3 of 3 samples, and it failed again on one re-run. Every other cell is within budget.
  • Why I think it is not this PR:
  • What would confirm it: main's own CI on a9d596d and later is still queued. If its Lighthouse also shows desktop-root TBT over budget, the regression came in with main.
  • Next: I am not changing this PR's UI to chase it. I'll recheck once main's Lighthouse result lands.

Generated by Claude Code

@cubic-dev-ai

cubic-dev-ai Bot commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Auto-fix isn't included in your plan ↗

Upgrade to Team

Sign up for free to 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.

2 participants