fix: remediate P2 audit findings (Phases 1 and 2) [Antigravity) - #1298
Conversation
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
️✅ There are no secrets present in this pull request anymore.If these secrets were true positive and are still valid, we highly recommend you to revoke them. 🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request. |
This pull request has been ignored for the connected project Preview Branches by Supabase. |
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThe changes refine Sheet keyboard focus handling, adjust document-search navigation state, expand retrieval and route-budget tests, verify Playwright service-worker isolation, scope a privacy assertion, and append PR review lifecycle records. ChangesUI behavior and browser isolation
Evaluation and deadline assertions
Review ledger synchronization
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested labels: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Comment |
BigSimmo
commented
Jul 28, 2026
@cursoragent please resolve all CI failing tests after understanding the issue. Please also fix any comments and resolve them and also ensure that you fix with smallest required fix with best coding practice and u derstabding the fix rather than simple patch. Please fix any merge conflicts and ensure any issues are found. Please resolve any issues you find. Please also run bugbot. Please mark comments resolved also once you resolve them. |
BigSimmo
commented
Jul 28, 2026
@cursoragent please resolve all CI failing tests after understanding the issue. Please also fix any comments and resolve them and also ensure that you fix with smallest required fix with best coding practice and u derstabding the fix rather than simple patch. Please fix any merge conflicts and ensure any issues are found. Please resolve any issues you find. Please also run bugbot. Please mark comments resolved also once you resolve them. |
PR #1298 is green and mergeable. Tip: What was broken and fixed
Hosted checks (current tip)PR required, Build, Unit coverage, Production UI, Static PR, Safety, PR policy, Semgrep, Gitleaks, GitGuardian — all pass. Residual: human approving review before merge. |
BigSimmo
commented
Jul 28, 2026
@codex review PR |
There was a problem hiding this comment.
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 `@playwright.config.ts`:
- Around line 49-52: Remove the duplicate serviceWorkers property from the
Playwright configuration, retaining a single effective setting. Consolidate the
explanatory comments around the remaining serviceWorkers entry so the
configuration continues to block workers for deterministic API mocks.
In `@src/components/ui/sheet.tsx`:
- Around line 218-223: Update the focusable-element filter in the sheet focus
trap to exclude elements with an ancestor marked aria-hidden="true" or inert,
while preserving the existing disabled and visible-layout checks. Apply the
ancestor-aware filtering directly in the filter callback around the existing
element checks.
In `@src/lib/rag/rag-retrieval-variants.ts`:
- Around line 219-223: Update the hasClozapineBloodIntent gate to recognize
“wcc” alongside ANC, FBC, and WBC in both the acronym check and query keyword
pattern, preserving the existing clozapine medication/term requirement and
blood-intent behavior.
In `@tests/ui-formulation.spec.ts`:
- Around line 113-116: Update the navigation test around the “Open Worry” link
so the click occurs only once outside the retryable toPass callback. Use toPass
solely to retry the page URL assertion, preserving the existing timeout and
expected /formulation/worry URL.
🪄 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
Run ID: 7f623667-0424-49cd-b820-963dd759e1c2
📒 Files selected for processing (14)
docs/branch-review-ledger.mdplaywright.config.tssrc/components/ClinicalDashboard.tsxsrc/components/ui/sheet.tsxsrc/lib/clinical-search.tssrc/lib/rag/rag-retrieval-variants.tstests/clinical-search.test.tstests/eval-retrieval.test.tstests/eval-utils.test.tstests/playwright-project-isolation.test.tstests/rag-route-budget.test.tstests/retrieval-query-variants.test.tstests/ui-formulation.spec.tstests/ui-pwa.spec.ts
💤 Files with no reviewable changes (1)
- src/components/ClinicalDashboard.tsx
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:f2664e7544
ℹ️ 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".
Uh oh!
There was an error while loading. Please reload this page.
BigSimmo
commented
Jul 28, 2026
@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. |
@cursor review Please run Bugbot on the current head ( |
Rebuild the unique delta from codex/fix-p2-audit-20260719 onto current main without the historical offline Postgres URI / test-fixture secret scanner false positives. Keeps clinical-search brand-alias ranking, neuroleptic query-class ordering, sheet focus-trap hardening, Playwright service-worker blocking, WCC blood-intent variants, and PR policy body.
8e7673f to
4265b3eCompareCodex Review: Didn't find any major issues. More of your lovely PRs please. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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 1216: Correct the typo in the changelog entry by changing “Prefered main”
to “Preferred main”; leave the rest of the entry unchanged.
In `@src/lib/clinical-search.ts`:
- Around line 1440-1467: Update the alias matching in the
evidenceHasSubjectToken flow so each queried medication’s tokens are matched
only against that medication’s own aliases, rather than one combined
namedMedicationAliasTokens set. Preserve direct token and monitor matching,
ensure hasNamedMedication checks the queried medications appropriately, and add
a regression test covering a query with multiple medications where evidence for
only one must not satisfy the other.
🪄 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
Run ID: cb060b82-d4d3-4047-9543-d5a923ce9101
📒 Files selected for processing (13)
docs/branch-review-ledger.mdplaywright.config.tssrc/components/ClinicalDashboard.tsxsrc/components/ui/sheet.tsxsrc/lib/clinical-search.tssrc/lib/rag/rag-retrieval-variants.tstests/clinical-search.test.tstests/eval-retrieval.test.tstests/eval-utils.test.tstests/playwright-project-isolation.test.tstests/rag-route-budget.test.tstests/retrieval-query-variants.test.tstests/ui-formulation.spec.ts
💤 Files with no reviewable changes (1)
- src/components/ClinicalDashboard.tsx
🚧 Files skipped from review as they are similar to previous changes (9)
- tests/rag-route-budget.test.ts
- tests/ui-formulation.spec.ts
- tests/playwright-project-isolation.test.ts
- tests/retrieval-query-variants.test.ts
- src/components/ui/sheet.tsx
- tests/eval-utils.test.ts
- src/lib/rag/rag-retrieval-variants.ts
- tests/eval-retrieval.test.ts
- tests/clinical-search.test.ts
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
GitHub-hosted runners can report ~7–8 GiB while still completing next build with the CI heap; keep the local low-RAM hard stop but warn-and- continue under CI/GITHUB_ACTIONS. Also remove the neuroleptic title short-circuit that forced document_lookup and broke the title-supported escalation rescue (medication_dose_risk + escalation_risk) used by main.
CodeRabbit found that a combined brand/generic alias set let one medication's evidence satisfy another subject token in multi-drug queries. Keep alias equivalence per medication, require every named medication for context match, and add a Clozaril/olanzapine regression. Also corrects a Prefered→Preferred typo in the #1298 ledger row.
@cursor review |
Buildx on GitHub runners reports ~7.8 GiB inside the build container, so guard-next-build hard-stopped npm run build. Pass CI=true from the Docker image workflow and accept it as an ARG/ENV in the Dockerfile so hosted image builds warn-and-continue while local Docker Desktop keeps the stop.
There was a problem hiding this comment.
Pull request overview
This PR remediates and stabilizes previously identified P2 audit findings while preserving a small set of functional deltas vs main, notably around clinical search/query-variant behavior, sheet focus trapping, and Playwright service worker isolation (with added regression coverage).
Changes:
- Refines clinical search normalization/ranking to better handle clozapine monitoring (incl. ANC/FBC/WBC/WCC intent) and neuroleptic side-effect queries, including brand/generic alias handling.
- Hardens the Sheet keyboard focus trap to avoid hidden/inert elements and to provide consistent cross-browser Tab cycling.
- Tightens Playwright isolation by blocking service workers by default while explicitly allowing them in the PWA suite, plus supporting tests and minor UI test stabilization.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/ui-tools.spec.ts | Avoids Playwright strict-locator issues by scoping visibility assertions to the first matching results root. |
| tests/ui-formulation.spec.ts | Stabilizes a URL assertion after navigation by retrying via expect().toPass. |
| tests/retrieval-query-variants.test.ts | Adds regression coverage for clozapine blood-intent variants (incl. WCC). |
| tests/rag-route-budget.test.ts | Extends deadline tests to cover generation-time budget behavior. |
| tests/playwright-project-isolation.test.ts | Asserts SWs are blocked for mock journeys and allowed for the PWA suite. |
| tests/eval-utils.test.ts | Updates expected file coverage mapping for legacy vs combined policy expectations. |
| tests/eval-retrieval.test.ts | Adds golden retrieval helper coverage for updated/recognized document titles. |
| tests/clinical-search.test.ts | Adds regression tests for neuroleptic side-effect anchoring and clozapine monitoring/alias ranking behavior. |
| src/lib/rag/rag-retrieval-variants.ts | Improves clozapine blood-intent detection using query analysis (medications/acronyms) to emit better variants. |
| src/lib/clinical-search.ts | Adds per-medication alias equivalence in subject matching; improves clozapine monitoring token retention and alias-aware boost/penalty. |
| src/components/ui/sheet.tsx | Reworks Tab trapping to filter hidden/inert elements and to cycle deterministically across browsers. |
| src/components/ClinicalDashboard.tsx | Adjusts documents search navigation by removing the focus flag from the generated href. |
| playwright.config.ts | Blocks service workers by default with updated rationale; PWA suite opts back in. |
| docs/branch-review-ledger.md | Appends review/CI babysit records for this PR’s iterations and closeout. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:439dbebc67
ℹ️ 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".
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:29e30d9d23
ℹ️ 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".
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:1b8b57a941
ℹ️ 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".
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
tests/sheet-focus.dom.test.tsx (1)
259-293: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winCover the reverse and wrap-around paths.
This test proves that
tabIndex={-1}is skipped, but it does not directly verifyShift+Tabor wrapping from the last eligible control back to the first. Add focused assertions for those paths to protect the new focus-trap contract.🤖 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 `@tests/sheet-focus.dom.test.tsx` around lines 259 - 293, Add assertions to the “Sheet Tab cycle” test covering reverse traversal with Shift+Tab and wrap-around from the last eligible control to the first. Reuse the existing first, excluded, and last elements, dispatch the appropriate keyboard events after focusing each endpoint, and verify the excluded control is never selected while focus returns to the expected eligible control.
🤖 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 `@tests/sheet-focus.dom.test.tsx`:
- Around line 261-294: Ensure the getClientRects spy created in the focus test
is always restored, including when rendering or assertions throw. Move cleanup
for the rects spy into an afterEach hook or a finally block surrounding the test
body, while preserving the existing assertions and focus behavior.
---
Nitpick comments:
In `@tests/sheet-focus.dom.test.tsx`:
- Around line 259-293: Add assertions to the “Sheet Tab cycle” test covering
reverse traversal with Shift+Tab and wrap-around from the last eligible control
to the first. Reuse the existing first, excluded, and last elements, dispatch
the appropriate keyboard events after focusing each endpoint, and verify the
excluded control is never selected while focus returns to the expected eligible
control.
🪄 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
Run ID: 44bd31d3-f8b5-4f1b-8311-169705c61647
📒 Files selected for processing (5)
docs/branch-review-ledger.mdsrc/components/ClinicalDashboard.tsxsrc/components/ui/sheet.tsxtests/sheet-focus.dom.test.tsxtests/ui-tools.spec.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- src/components/ClinicalDashboard.tsx
- src/components/ui/sheet.tsx
Uh oh!
There was an error while loading. Please reload this page.


Summary
mainand resolved the merge conflict without discarding main-side fixes.src/lib/clinical-search.tsandsrc/lib/rag/rag-retrieval-variants.tsnow match currentmainexactly..first().RAG impact: no retrieval behaviour change — protected clinical-search and retrieval-variant production files are identical to current main; remaining protected-surface changes are tests only.
Verification
git merge-treeagainst currentorigin/mainnpm run check:branch-review-ledgergit diff --checkorigin/mainnpm run verify:pr-local -- --dry-run --files ...selected runtime, installed-lock parity, format, lint, typecheck, full unit suite, build, and RAG fixture checksnode_modulesRisk and rollout
Clinical Governance Preflight
Summary by CodeRabbit
Accessibility
Search
Tests