Skip to content

fix(#030, #075): eval alias disjointness + search-scope label pagination#1177

Open
BigSimmo wants to merge 16 commits into
mainfrom
cursor/search-correctness-030-075-6273
Open

fix(#030, #075): eval alias disjointness + search-scope label pagination#1177
BigSimmo wants to merge 16 commits into
mainfrom
cursor/search-correctness-030-075-6273

Conversation

@BigSimmo

@BigSimmo BigSimmo commented Jul 24, 2026

Copy link
Copy Markdown
Owner

Summary

Two search-correctness fixes in separate commits (no ranking/retrieval behaviour change):

  1. Potential fix for code scanning alert no. 1: Workflow does not contain permissions #30 — Remove dual-listed Admission-to-Discharge titles from the wide-tier AdmissionCommunityPts alias list so one retrieved document cannot make allHit true for both admission and discharge comparison slots. Fail-closed contracts plus distinct-source matching in tests/eval-document-matching.test.ts.
  2. Refresh dependencies #75 — Add bounded deterministic pagination for document_labels in resolveSearchScope (loadScopeLabels) so matches past the Supabase 1,000-row response cap are not silently dropped. Multi-page >1000 contracts and fail-closed page-budget guard in tests/search-scope.test.ts. Isolated from mixed PR Next security patch + search-scope batching, telemetry & DOM teardown guards #1132.
  3. Cleanup — Remove stale PR_POLICY_BODY.md leftover that was overwriting unrelated PR descriptions via Sync PR policy body.

RAG impact: no retrieval behaviour change — eval matching / label pagination only.

Verification

  • Focused Vitest: tests/eval-document-matching.test.ts, tests/eval-search.test.ts, tests/eval-utils.test.ts, tests/search-scope.test.ts (32/32)
  • npm run verify:cheap
  • npm run verify:pr-local — runtime, format, lint, typecheck, full unit suite (3326), production build, client-bundle secret scan, offline RAG fixtures 36/36
  • UI verification not run: no UI/routing/styling changes
  • Live retrieval/ranking evals not run: no protected ranking surfaces touched
  • npm run check:production-readiness — expected FAIL in secretless demo VM (missing Supabase/OpenAI env); Node 24 boot guards passed

Risk and rollout

  • Risk: Low — eval matching tables and scope label loading only; released search order and ranking scores unchanged
  • Rollback: revert the fix commits on this branch
  • Provider or production effects: None

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

  • Ledger: #030 and #075 archived in docs/outstanding-issues.md; recommended-queue order 4 removed (gap intentional).
  • Stop rules honored: no alias-tier bulk merges into strict golden aliases, no comparator/clamp/rerank changes, no live canaries.
  • Branch synced with origin/main. This file is a temporary CI body-sync template and must be deleted before merge so it does not pollute later PRs.

cursoragent and others added 3 commits July 24, 2026 17:31
A single Admission-to-Discharge document was listed under both
AdmissionCommunityPts and Discharge, so expectedFileCoverage could set
allHit true from one retrieved source. Drop those titles from the
admission side and add fail-closed contract tests.

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
A single document_labels query could silently drop matches beyond the
Supabase 1,000-row response cap. Load labels in deterministic
document-batched pages with stable ordering and abort propagation, and
cover multi-page >1000 enumeration in unit contracts.

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
Archive the wide-tier dual-alias false-pass and search-scope 1k label
truncation fixes; remove the composite recommended-queue row.

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

supabase Bot commented Jul 24, 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 24, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

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

Next review available in: 40 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: 55e43ba3-529e-41f0-93fc-aed193101aeb

📥 Commits

Reviewing files that changed from the base of the PR and between c4ed151 and 0743d55.

📒 Files selected for processing (7)
  • PR_POLICY_BODY.md
  • docs/branch-review-ledger.md
  • docs/outstanding-issues.md
  • src/lib/eval-document-matching.ts
  • src/lib/search-scope.ts
  • tests/eval-document-matching.test.ts
  • tests/search-scope.test.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cursor/search-correctness-030-075-6273

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.

…ness-030-075-6273

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

cursor Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Correction: PR description was overwritten

This PR is not the search-performance work. Diff vs main is only:

  • #030 eval wide-tier Admission/Discharge alias disjointness (src/lib/eval-document-matching.ts + contracts)
  • #075 search-scope document_labels pagination past the 1k Supabase cap (src/lib/search-scope.ts + contracts)
  • ledger archive of those two issues

RAG impact: no retrieval behaviour change — eval matching / label pagination only.

Follow-up in progress: harden expectedFileCoverage so one retrieved source cannot fill multiple expected-file slots (distinct source identities), then run verify:pr-local.

cursoragent and others added 6 commits July 24, 2026 17:42
expectedFileCoverage now consumes each retrieved top-file at most once
so a combo-titled source cannot false-pass multi-slot allHit. Label
enumeration fails closed after a bounded page budget instead of looping
forever on a stuck full-page API response.

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
Replace the stale search-performance PR_POLICY_BODY.md leftover on
main so Sync PR policy body stops overwriting this PR with unrelated
summary text. Template will be deleted in a follow-up commit after
the sync job applies it.

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
Temporary template so Sync PR policy body replaces the stale
search-performance description. Delete in the next commit before merge.

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
Keep the corrected GitHub PR description without leaving a template
on main that would overwrite later PR bodies (same cleanup pattern
as #942 / #953).

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
Append branch-review-ledger entry for the #30/#75 assessment,
distinct-slot/page-budget fixes, and PR_POLICY_BODY cleanup.

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

cursor Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Review assessment + follow-up (complete)

Findings fixed on this tip

  1. P2 — Potential fix for code scanning alert no. 1: Workflow does not contain permissions #30 residual: a single combo-titled source (e.g. “Admission of Community Patients and Discharge Planning”) could still make allHit true. Fixed by distinct-source assignment in expectedFileCoverage (each top-file fills at most one expected slot).
  2. P2 — Refresh dependencies #75 residual: unbounded pagination could loop forever if every page returned a full 1000 rows. Added fail-closed page budget per document batch + contract.
  3. P2 process: stale PR_POLICY_BODY.md on main (search-performance leftover) was overwriting this PR’s description via Sync PR policy body. Synced the correct body, then deleted the template so it cannot pollute later PRs.

Verification

  • Focused contracts 32/32
  • verify:cheap green
  • verify:pr-local green (lint/typecheck/3326 unit/build/client-bundle/offline RAG fixtures 36/36)

RAG impact: no retrieval behaviour change — eval matching / label pagination only.

No remaining high-confidence P0–P1 in product scope. Residual: human approving review once required CI finishes on tip d7fc1a93.

cursoragent and others added 4 commits July 24, 2026 17:48
Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
…ness-030-075-6273

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
Add a main-push workflow and local helper that update behind PR heads so
GitHub stops falsely marking the queue CONFLICTING/DIRTY after each land.
Bump postcss to a non-vulnerable release so Safety npm audit stays green.
@cursor
cursor Bot marked this pull request as ready for review July 24, 2026 19:15
@cursor
cursor Bot enabled auto-merge (squash) July 24, 2026 19:17
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