Skip to content

Implement Audit Recommendations for Provenance and Safety - #1254

Merged
cursor[bot] merged 17 commits into
mainfrom
apply-audit-remediation-fixes
Jul 26, 2026
Merged

Implement Audit Recommendations for Provenance and Safety#1254
cursor[bot] merged 17 commits into
mainfrom
apply-audit-remediation-fixes

Conversation

@BigSimmo

@BigSimmo BigSimmo commented Jul 26, 2026

Copy link
Copy Markdown
Owner

Summary

  • Implements audit remediation for provenance and safety: locality metadata verification tooling, centralized source-governance codes/UI tokens, expanded threshold disagreement handling, and citation/source-open telemetry.
  • Keeps live Supabase locality auditing explicit via check:locality-metadata and out of the unconditional offline verify:pr-local base script.
  • Follow-up babysit fixes preserve threshold comparator direction and inclusivity, harden false-positive source-governance threshold extraction, and stabilize PR-scoped UI assertions.

RAG impact: no retrieval behaviour change — provenance/governance UI tokens, citation telemetry, and locality audit only; ranking/imputation formulas untouched

Verification

  • npm run test -- tests/evidence.test.ts — PASS (26/26) after threshold false-positive hardening.
  • Focused Vitest evidence/source metadata — PASS (67/67) after inclusivity/source telemetry fixes.
  • npm run typecheck — PASS.
  • npm run format:check — PASS.
  • npm run lint — PASS.
  • npm run build — PASS.
  • npm run check:rag:fixtures — PASS.
  • npm run check:branch-review-ledger — PASS after the append-only ledger clarification.
  • Focused Production UI reruns for tests/ui-tools.spec.ts — PASS for the PR-scoped strict-locator failures.
  • Hosted CI on head a4c5f286: Static PR, Safety and config, Unit coverage, Build, app image, Production UI, Migration replay, SAST, and secret scans passed.
  • npm run verify:pr-local — not rerun after the latest docs-only ledger clarification; narrower checks above cover the touched file.
  • npm run verify:ui — not rerun as the full local gate; focused production UI reruns and hosted Production UI passed.
  • UI verification not run: full local npm run verify:ui was not rerun after the docs-only ledger clarification; focused production UI reruns and hosted Production UI passed.
  • npm run verify:release — not run; release gate is out of scope for PR babysitting and includes provider-backed checks.
  • npm run eval:retrieval:quality — not run; no retrieval/ranking behaviour change is intended and live provider-backed eval was not authorized.
  • npm run check:production-readiness — attempted earlier and blocked by missing local Supabase/OpenAI env secrets; no live provider-backed rerun performed.

Risk and rollout

  • Risk: clinical/source-governance metadata changes can affect warnings and telemetry presentation; comparator parsing changes are covered by focused regressions and do not alter RAG ranking/imputation formulas.
  • Rollback: revert the PR commits; the live locality audit remains an explicit script and is not part of offline PR-local verification.
  • Provider or production effects: No OpenAI calls, live Supabase mutations, provider-backed evals, deployments, or production data changes were performed.

Clinical Governance Preflight

  • Source-backed claims still require linked source verification before clinical use
  • No patient-identifiable document workflow was introduced or expanded without explicit governance approval
  • Supabase target remains Clinical KB Database (sjrfecxgysukkwxsowpy)
  • Service-role keys and private document access remain server-only
  • Demo/synthetic content remains clearly separated from real clinical sources
  • Source metadata, review status, and outdated/unknown-source behavior remain conservative
  • Deployment classification/TGA SaMD impact was checked when clinical decision-support behavior changed

Notes

  • Remaining merge blockers at the time this body was prepared: direct review-thread reply/resolution was unavailable in this Cursor run, and the prior hosted worker-image failure was a Docker Hub/BuildKit timeout rather than a code failure.

@supabase

supabase Bot commented Jul 26, 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 ↗︎.

@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@cursor[bot], you've reached your PR review limit, so we couldn't start this review.

Next review available in: 11 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: bb13cc9e-288d-4a34-8a54-0226d0f0cc0e

📥 Commits

Reviewing files that changed from the base of the PR and between 7c5a31b and b5aa92f.

📒 Files selected for processing (4)
  • docs/branch-review-ledger.md
  • src/lib/evidence.ts
  • tests/evidence.test.ts
  • tests/ui-tools.spec.ts
📝 Walkthrough

Walkthrough

Changes

The PR adds a locality metadata verification command, propagates query context for citation telemetry, updates citation and evidence processing, and centralizes source governance codes, severity mappings, UI tokens, and metadata enum validation.

Locality verification

Layer / File(s) Summary
Locality audit command and verification wiring
scripts/verify-locality-metadata.ts, package.json, scripts/verify-pr-local.mjs
Adds paginated indexed-document auditing with PASS/FAIL reporting and command wiring.

Citation-open telemetry

Layer / File(s) Summary
Citation telemetry request and source action handling
src/components/clinical-dashboard/source-actions.tsx, src/app/api/search/interaction/route.ts
Adds source-open callbacks, citation telemetry validation, and persistence of telemetry metadata.
Query propagation through evidence surfaces
src/components/clinical-dashboard/answer-content.tsx, src/components/clinical-dashboard/evidence-panels.tsx, src/components/clinical-dashboard/answer-result-surface.tsx, src/components/clinical-dashboard/answer-thread-turn.tsx, src/components/clinical-dashboard/prior-answer-turn-surface.tsx
Passes query context through answer and evidence components and logs source or citation opens.

Citation and evidence processing

Layer / File(s) Summary
Citation normalization and identity handling
src/lib/source-text-sanitizer.ts, src/lib/citations.ts
Exports shared whitespace normalization, enforces single-line citation titles, and de-duplicates citations by citation identity.
Expanded threshold disagreement detection
src/lib/evidence.ts, tests/evidence.test.ts
Adds clinical threshold parameters, comparator-aware parsing, and tests for directional and inclusive-bound conflicts.
Precompiled authority matchers
src/lib/source-authority-metadata.ts
Reuses compiled token-boundary regular expressions for registered authority codes.

Source governance metadata

Layer / File(s) Summary
Centralized governance contracts
src/lib/types.ts
Adds centralized governance codes, derived code types, UI token types, and optional warning UI tokens.
Governance warning generation and grouping
src/lib/source-governance.ts
Uses centralized code and severity matrices, updates weak-evidence danger handling, and preserves UI tokens in grouped warnings.
Validated source metadata enums
src/lib/source-metadata.ts
Validates source and registry record kinds against allowlists and falls back to null for unknown values.

Review ledger updates

Layer / File(s) Summary
Branch review ledger entries
docs/branch-review-ledger.md
Adds append-only records for the authorized sweep and subsequent verification status.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant AnswerSurface
  participant SourcePreview
  participant SourceActions
  participant InteractionAPI
  AnswerSurface->>SourcePreview: pass query context
  SourcePreview->>SourceActions: log source open
  SourceActions->>InteractionAPI: submit citation telemetry
  InteractionAPI-->>SourceActions: record interaction result
Loading

Possibly related PRs

Suggested reviewers: claude

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 18.92% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title matches the main change: audit remediation for provenance and safety.
Description check ✅ Passed The description follows the template with Summary, Verification, Risk and rollout, Clinical Governance Preflight, and Notes.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch apply-audit-remediation-fixes

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@github-actions

github-actions Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

CI triage

CI failed on this PR. Automated classification of the 2 failed job(s):

  • Container images / worker-imageneeds investigation: inspect the failing step and uploaded diagnostics; rerun only after classifying the cause.
  • PR requiredmain-side: the same job also failed on the latest completed main CI run.

Compared with main CI run #5872 (failure).

Classification is evidence routing, not permission to ignore a failure. Exact quarantined Playwright identities remain governed by the flake ledger.

@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: 748b8530ac

ℹ️ 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/evidence.ts Outdated
Comment thread scripts/verify-pr-local.mjs Outdated
Comment thread src/lib/evidence.ts Outdated
Comment thread src/components/clinical-dashboard/evidence-panels.tsx
@BigSimmo

Copy link
Copy Markdown
Owner Author

@codex resolve actionable Codex review findings for this pull request and current head using the repository instructions. This is the pull request's single automatic repair pass: do not perform a fresh review, create new standalone findings, or request another review. Work only the existing unresolved Codex threads on the current head. Always fix P0 and P1 findings. For P2 and lower findings, fix only clear, scoped, low-risk issues; otherwise disposition them with a concise reason. After fixing or dispositioning a thread, reply in that thread with as the first line, followed by a concise summary; that marker authorizes the workflow to close that exact thread. If human input or new authorization is required, do not use the marker and leave the thread open with the blocker. Finish only after every actionable thread is fixed or dispositioned and closed, or explicitly left open for a human decision. Do not update the branch from main, address unrelated reviews, broaden scope, or create more than one scoped fix commit. Do not use external APIs, paid services, credentials, dependency changes, or broad refactors unless explicitly authorized. Add targeted tests where behavior changes and run the narrowest relevant validation.

@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: be03131eaf

ℹ️ 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 scripts/verify-pr-local.mjs Outdated
Comment thread src/lib/evidence.ts Outdated

@coderabbitai coderabbitai 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.

Actionable comments posted: 4

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/components/clinical-dashboard/evidence-panels.tsx (1)

933-967: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Thread the active query through every evidence-panel caller.

These handlers only log when query is present, but answer-result-surface.tsx renders MobileEvidenceSheetContent without a query at Lines 325-340 and renders SafetyFindingsListContent without query at Line 369. As a result, safety-finding opens—and the nested quote-card path unless the intermediate prop is threaded—produce no citation telemetry on this surface.

Pass query through MobileEvidenceSheetContent, then into QuoteCards and SafetyFindingsListContent, and add coverage for both paths.

Also applies to: 1313-1381

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/clinical-dashboard/evidence-panels.tsx` around lines 933 -
967, Thread the active query from answer-result-surface.tsx through
MobileEvidenceSheetContent into QuoteCards and SafetyFindingsListContent. Update
each component’s props and call sites so both direct safety-finding links and
nested quote-card links receive the query and trigger citation telemetry, then
add coverage for both paths.
🧹 Nitpick comments (1)
src/lib/source-governance.ts (1)

15-39: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Matrix typing forces unsafe as casts at every call site.

GOVERNANCE_SEVERITY_MATRIX/GOVERNANCE_UI_TOKEN_MATRIX are annotated as Record<SourceGovernanceCode, X | "dynamic">, so indexing with any specific code still types as the full union, forcing every consumer (Lines 116-211) to as-cast away the "dynamic" branch. WEAK_EVIDENCE never actually reads these maps today (it's special-cased at Lines 98-106), so this is latent — but if a future change reads GOVERNANCE_SEVERITY_MATRIX[SOURCE_GOVERNANCE_CODES.WEAK_EVIDENCE] and casts it like the others, it will silently produce the literal "dynamic" as a severity/uiToken, which isn't a member of either union and would break the severityRank[...] sort at Lines 215/270.

Using satisfies instead of an explicit Record<...> annotation preserves per-key literal types, removes the need for casts on the safe codes, and turns any accidental WEAK_EVIDENCE lookup into a compile error instead of a silent bad value.

♻️ Proposed fix
-export const GOVERNANCE_SEVERITY_MATRIX: Record<SourceGovernanceCode, SourceGovernanceWarning["severity"] | "dynamic"> = {
+export const GOVERNANCE_SEVERITY_MATRIX = {
   [SOURCE_GOVERNANCE_CODES.OUTDATED]: "danger",
   [SOURCE_GOVERNANCE_CODES.POOR_EXTRACTION]: "danger",
   [SOURCE_GOVERNANCE_CODES.REVIEW_DUE]: "warning",
   [SOURCE_GOVERNANCE_CODES.UNVERIFIED]: "warning",
   [SOURCE_GOVERNANCE_CODES.PARTIAL_EXTRACTION]: "warning",
   [SOURCE_GOVERNANCE_CODES.LOW_INDEX_QUALITY]: "warning",
   [SOURCE_GOVERNANCE_CODES.WEAK_TABLE_EXTRACTION]: "warning",
   [SOURCE_GOVERNANCE_CODES.NON_LOCAL]: "info",
   [SOURCE_GOVERNANCE_CODES.REGISTRY_RECORD]: "info",
   [SOURCE_GOVERNANCE_CODES.WEAK_EVIDENCE]: "dynamic",
-} as const;
+} as const satisfies Record<SourceGovernanceCode, SourceGovernanceWarning["severity"] | "dynamic">;

-export const GOVERNANCE_UI_TOKEN_MATRIX: Record<SourceGovernanceCode, SourceGovernanceUiToken | "dynamic"> = {
+export const GOVERNANCE_UI_TOKEN_MATRIX = {
   [SOURCE_GOVERNANCE_CODES.OUTDATED]: "destructive",
   [SOURCE_GOVERNANCE_CODES.POOR_EXTRACTION]: "destructive",
   [SOURCE_GOVERNANCE_CODES.REVIEW_DUE]: "warning",
   [SOURCE_GOVERNANCE_CODES.UNVERIFIED]: "warning",
   [SOURCE_GOVERNANCE_CODES.PARTIAL_EXTRACTION]: "caution",
   [SOURCE_GOVERNANCE_CODES.LOW_INDEX_QUALITY]: "caution",
   [SOURCE_GOVERNANCE_CODES.WEAK_TABLE_EXTRACTION]: "caution",
   [SOURCE_GOVERNANCE_CODES.NON_LOCAL]: "neutral",
   [SOURCE_GOVERNANCE_CODES.REGISTRY_RECORD]: "muted",
   [SOURCE_GOVERNANCE_CODES.WEAK_EVIDENCE]: "dynamic",
-} as const;
+} as const satisfies Record<SourceGovernanceCode, SourceGovernanceUiToken | "dynamic">;

With satisfies, GOVERNANCE_SEVERITY_MATRIX[SOURCE_GOVERNANCE_CODES.OUTDATED] now types as the literal "danger", so the as SourceGovernanceWarning["severity"] casts at each call site can be dropped for the non-dynamic codes.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/lib/source-governance.ts` around lines 15 - 39, Replace the explicit
Record annotations on GOVERNANCE_SEVERITY_MATRIX and GOVERNANCE_UI_TOKEN_MATRIX
with satisfies-based validation that includes only the safe governance codes and
preserves per-key literal types. Remove the corresponding as casts in the
consumers around the governance warning/token handling, while retaining the
existing WEAK_EVIDENCE special case so that direct lookups cannot yield
"dynamic".
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@scripts/verify-locality-metadata.ts`:
- Line 19: The documents accumulator in the locality metadata verification flow
must not use explicit any. Update documents near auditSourceAuthorityDocuments
to use the function’s expected SourceAuthorityDocument[] type or the canonical
generated row type, and explicitly normalize Supabase query results before
passing them to the audit function.

In `@src/app/api/search/interaction/route.ts`:
- Around line 33-38: Harden the citationTelemetry schema before it reaches
rag_query_misses.metadata: reject unknown keys, trim and cap
provenance/source_strength/document_status, validate them against their allowed
domains or enums, and constrain similarity to the documented retrieval-score
range. Ensure safeTelemetryText does not replace schema validation. Run the
required RAG/search domain check, npm run check:production-readiness, and the
route-level UI gates.

In `@src/lib/evidence.ts`:
- Around line 513-517: Update THRESHOLD_SPAN_PATTERN and the
threshold-observation parsing flow to capture and normalize the comparator
alongside the numeric threshold, then retain that comparator in
ThresholdObservation. Update conflict evaluation to compare comparator direction
as well as the numeric value, so opposite constraints such as QTc > 500 and QTc
< 500 are treated as conflicting.
- Around line 502-505: Update the clozapine pattern in the evidence catalog to
match dosage expressions such as “clozapine > 600 mg/day” without requiring the
literal word “dose,” while preserving the existing comparator and numeric-dose
captures used by the surrounding span matcher. Apply the same adjustment to the
related clozapine entry around the alternate referenced range.

---

Outside diff comments:
In `@src/components/clinical-dashboard/evidence-panels.tsx`:
- Around line 933-967: Thread the active query from answer-result-surface.tsx
through MobileEvidenceSheetContent into QuoteCards and
SafetyFindingsListContent. Update each component’s props and call sites so both
direct safety-finding links and nested quote-card links receive the query and
trigger citation telemetry, then add coverage for both paths.

---

Nitpick comments:
In `@src/lib/source-governance.ts`:
- Around line 15-39: Replace the explicit Record annotations on
GOVERNANCE_SEVERITY_MATRIX and GOVERNANCE_UI_TOKEN_MATRIX with satisfies-based
validation that includes only the safe governance codes and preserves per-key
literal types. Remove the corresponding as casts in the consumers around the
governance warning/token handling, while retaining the existing WEAK_EVIDENCE
special case so that direct lookups cannot yield "dynamic".
🪄 Autofix (Beta)

❌ Autofix failed (check again to retry)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 80c2f57e-a501-4bc6-9253-08272dba2336

📥 Commits

Reviewing files that changed from the base of the PR and between 2a96c1e and be03131.

📒 Files selected for processing (17)
  • package.json
  • scripts/verify-locality-metadata.ts
  • scripts/verify-pr-local.mjs
  • src/app/api/search/interaction/route.ts
  • src/components/clinical-dashboard/answer-content.tsx
  • src/components/clinical-dashboard/answer-result-surface.tsx
  • src/components/clinical-dashboard/answer-thread-turn.tsx
  • src/components/clinical-dashboard/evidence-panels.tsx
  • src/components/clinical-dashboard/prior-answer-turn-surface.tsx
  • src/components/clinical-dashboard/source-actions.tsx
  • src/lib/citations.ts
  • src/lib/evidence.ts
  • src/lib/source-authority-metadata.ts
  • src/lib/source-governance.ts
  • src/lib/source-metadata.ts
  • src/lib/source-text-sanitizer.ts
  • src/lib/types.ts

Comment thread scripts/verify-locality-metadata.ts Outdated
Comment thread src/app/api/search/interaction/route.ts Outdated
Comment thread src/lib/evidence.ts
Comment thread src/lib/evidence.ts
@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Note

Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.

⚠️ Branch updated during autofix.

The branch was updated while autofix was in progress. Please try again.

github-actions Bot and others added 5 commits July 26, 2026 03:26
…rators

Remove the live Supabase locality metadata check from unconditional verify:pr-local, capture comparator direction in withholding-threshold conflicts, harden citation telemetry validation, and type the locality audit accumulator.

@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: 91aeb19d4d

ℹ️ 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/evidence.ts Outdated
@cursor

cursor Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

PR policy blockers: hosted check needs both ## Clinical Governance Preflight and an explicit RAG impact: line. Attempted to update the body via tooling; if that fails because the description is not agent-managed, paste:

## Clinical Governance Preflight

- [x] Source-backed claims still require linked source verification before clinical use
- [x] No patient-identifiable document workflow was introduced or expanded without explicit governance approval
- [x] Supabase target remains `Clinical KB Database` (`sjrfecxgysukkwxsowpy`)
- [x] Service-role keys and private document access remain server-only
- [x] Demo/synthetic content remains clearly separated from real clinical sources
- [x] Source metadata, review status, and outdated/unknown-source behavior remain conservative
- [x] Deployment classification/TGA SaMD impact was checked when clinical decision-support behavior changed

RAG impact: no retrieval behaviour change — source governance metadata/UI matrices, locality verification, and citation telemetry only; ranking/comparator formulas and retrieval RPCs unchanged.

@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Note

Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.

Autofix skipped. No unresolved CodeRabbit review comments with fix instructions found.

cursor Bot pushed a commit that referenced this pull request Jul 26, 2026
* fix: stop choppy screen resize when switching modes

Mode switches animated phone composer reserve because searchMode updated
before the pathname landed, briefly leaving isStandaloneModeHome false and
running the 200ms padding transition. Detect mode homes from pathname only,
navigate without optimistic mode state, and limit padding transitions to
scroll-hide.

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>

* test: align therapy-compass wiring with pathname mode-home gate

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>

* docs(ledger): record mode-switch lag same-class bug hunt

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>

* fix: close same-class mode-switch layout thrash bugs

After the reserve-flip fix, related choppiness remained from eager
crossModeSearch chrome updates, inherited phone scroll/hide across mode
homes, a hero-portal null gap while slots rebound, a taller mode-home
loading skeleton, and services/forms contentAlign jumping after registry
load. Navigate out of the dashboard without rewriting chrome, reset
scroll-hide on pathname change, keep the default composer until the
portal attaches, align the skeleton to the shell header token, and keep
loading homes top-aligned on phone.

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>

* docs(ledger): record mode-switch thrash review fixes

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>

* fix: satisfy lint for mode-switch scroll and portal cleanup

Reset bottom-composer hidden state during render on pathname change
instead of setState-in-effect, and drop the unused hero-portal fallback
flag now that the default composer stays mounted until the host attaches.

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>

* docs(ledger): record mode-switch thrash lint closeout

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>

* docs(ledger): record frontend-architecture loading/nav review

Append review of mode/page loading and navigation architecture at HEAD
0ef62ff: P1 shell bundle + hydration blanking; residual remount/tools dual.

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>

* fix: reduce mode/page loading blanking and layout rework

Parallel loading review found hard-load blanking from ClientHydrationBoundary,
mismatched/missing mode-home loading skeletons, forms catalog in the client
chunk, ClinicalDashboard static weight on namespaced routes, sidebar column
animation on remount, forms query remounts, and document viewer remounts on
page flips. Paint RSC children immediately, align ModeHomeRouteLoading, wire
mode-home loading.tsx files, server-pass the default form slug, dynamic-import
ClinicalDashboard, gate sidebar transitions after mount, and stop unnecessary
remount keys.

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>

* docs(ledger): record parallel loading behaviour review fixes

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>

* refactor: extract sidebar transition hook and private-scope URL helper

Keeps ClinicalDashboard inside the maintainability budget after the
loading-performance pass, and shares the remount-safe sidebar transition
gate with GlobalSearchShell.

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>

* test: allow DocumentViewer identity-only remount key

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>

* test: align chrome contracts with pathname reset and gated padding

After merging main's cross-breakpoint scroll-hide wiring, update static
contracts for resetKey=pathname, and keep phone padding transitions gated
to scroll-hide only so mode switches still snap.

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>

* fix: clear CI hydration and phone-scroll failures

Gate desktop composer portal adoption until page-owned slots mark
themselves ready after hydration, so hard-loads no longer inject a
display:contents host into still-unhydrated RSC HTML (React #418).
Update phone-scroll expectations for scroll-hide-only reserve transitions.

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>

* style: prettier-format portal ready-gate files

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>

* fix: keep document searches dashboard-owned and animate reserve reveal

Treat /documents/search as in-shell for cross-mode sync, keep a short-lived reserve-transition marker through hide and reveal, omit readiness cards without a default slug, and preserve URL hashes when clearing private scope refs.

* fix: stop duplicate page-root testids from searchParams Suspense

Nesting route children inside the shell's useSearchParams Suspense left a
hidden Next streaming S: clone of forms/favourites/presentation roots under
CI load. Gate always-standalone paths off that boundary and bridge params
beside the shell body so mode-home RSC paint stays.

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>

* style: prettier format DocumentViewer reserve-transition import

* docs: record babysit sweep ledger rows for #1241/#1248/#1254/#1257/#1253/#1255

* refactor: extract DocumentViewer/Dashboard helpers under budgets

Pull PDF viewer mode helpers and document chrome scroll wiring into
focused modules, and isolate the dashboard desktop result composer slot,
so maintainability no-growth budgets pass after the reserve-transition
and portal ready-gate work.

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>

* test: align desktop page-slot contract with extracted helper

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>

* fix: satisfy hooks lint for searchParams Suspense bridge

Use useSyncExternalStore for the client-only gate and call the param
callback from layout effect deps instead of updating a ref during render.

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>

* fix: seed standalone submitted search params

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>

* test: stabilize phone-scroll and presentation page assertions

Drop the settled-bottom 0.24s reserve check (transition is short-lived on
data-reserve-transitioning), and scope differential presentation lookups to
the live shell scrollport so hidden Next streaming clones cannot fail strict
mode under CI load.

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>

* fix: narrow submitted search param seeding

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
cursoragent and others added 3 commits July 26, 2026 04:58
…on-fixes

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>

@coderabbitai coderabbitai 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.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/branch-review-ledger.md`:
- Line 1072: Update the ledger entry identified by PR `#1254` and commit
b3b1eb7e7084859cd18c05152be1b9f8968592ff to explicitly state that it is a
clarification or superseding record for the earlier duplicate entry on Line
1070, while preserving the existing audit details.

In `@src/lib/evidence.ts`:
- Around line 648-650: Update the distinct-key construction in the observation
comparison flow around thresholdObservationKey so an unknown comparator is
compatible with any known comparator at the same numeric threshold, rather than
creating a disagreement; continue treating observations with genuinely different
numeric values as distinct conflicts.
- Line 518: Update the evidence-matching regex so the bare clozapine alternative
only matches when its captured threshold is followed by a dosage unit such as
mg, preventing the lookahead from consuming an incidental dose before a later
QTc comparator. Preserve independent QTc extraction for text like “Withhold
clozapine 300 mg daily if QTc > 500 ms,” and add this case to the existing
regression tests.
- Around line 652-655: Update the conflict-detection logic around the
distinctKeys/distinctDocuments checks to track comparator-value keys per
document and only emit a cross-source conflict when differing keys are
represented by separate documents, not when one document contains both
conflicting observations. Add a regression test covering one document with both
QTc observations and a second document repeating only one of them, ensuring no
cross-source conflict is emitted.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 1e4942e0-1fb5-4750-a476-374b9bc2d509

📥 Commits

Reviewing files that changed from the base of the PR and between be03131 and 7c5a31b.

📒 Files selected for processing (13)
  • docs/branch-review-ledger.md
  • package.json
  • scripts/verify-locality-metadata.ts
  • scripts/verify-pr-local.mjs
  • src/app/api/search/interaction/route.ts
  • src/components/clinical-dashboard/answer-content.tsx
  • src/components/clinical-dashboard/source-actions.tsx
  • src/lib/evidence.ts
  • src/lib/source-authority-metadata.ts
  • src/lib/source-governance.ts
  • src/lib/source-metadata.ts
  • src/lib/types.ts
  • tests/evidence.test.ts
🚧 Files skipped from review as they are similar to previous changes (7)
  • package.json
  • src/lib/types.ts
  • src/app/api/search/interaction/route.ts
  • src/lib/source-authority-metadata.ts
  • src/lib/source-metadata.ts
  • src/components/clinical-dashboard/source-actions.tsx
  • src/lib/source-governance.ts

Comment thread docs/branch-review-ledger.md
Comment thread src/lib/evidence.ts Outdated
Comment thread src/lib/evidence.ts
Comment thread src/lib/evidence.ts Outdated
cursoragent and others added 4 commits July 26, 2026 05:19
Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
@cursor
cursor Bot merged commit 4d54abf into main Jul 26, 2026
25 checks passed
@cursor
cursor Bot deleted the apply-audit-remediation-fixes branch July 26, 2026 06:06
cursor Bot pushed a commit that referenced this pull request Jul 26, 2026
Append final land/close rows for the authorized open-PR triage:
closed unsafe audit tips #1255/#1253, and prlanded #1257/#1212/#1241/#1248/#1254/#1259.

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
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