Skip to content

Fix scoped-label pagination and stabilize reconciliation preflight test#1191

Merged
BigSimmo merged 10 commits into
mainfrom
codex/complete-all-pending-tasks
Jul 25, 2026
Merged

Fix scoped-label pagination and stabilize reconciliation preflight test#1191
BigSimmo merged 10 commits into
mainfrom
codex/complete-all-pending-tasks

Conversation

@BigSimmo

@BigSimmo BigSimmo commented Jul 25, 2026

Copy link
Copy Markdown
Owner

Summary

  • Fix cross-mode search performance findings: prescribing catalogue debounce/abort/fields=index, differentials abort/debounce, universal documents typeahead soft-timeout (750ms), shared (search-app) shell to avoid composer remount, and Answer rate-limit in-memory fallback outside production.
  • Fix Bugbot regressions: shared-shell pathname navigation (/services/dsm) syncs searchMode during render (no stale-mode paint) even when the query string is unchanged; extracted ClinicalDashboard lazy imports to stay under the maintainability budget.

RAG impact: no retrieval behaviour change — typeahead documents domain timeout and shell URL sync only; ranking formulas and full /api/search retrieval path unchanged.

Verification

  • npm run verify:pr-local — focused Vitest on touched sources (362) plus api-rate-limit / search-shell / universal / route / site-map suites green; docs:check-index OK
  • UI verification not run: full verify:ui not required for this pass; mode-home smoke via npm run ensure returned HTTP 200 for /, /services, /dsm, /documents/search, /therapy-compass, /?mode=prescribing, and /api/answer/stream returned 200 after the rate-limit fallback fix
  • Verification not run: eval:retrieval:latency / soak / live OpenAI canary — approval-gated provider work; not needed for timeout-only typeahead change

Risk and rollout

  • Risk: medium — shared layout remount change and rate-limit fallback behaviour in non-production; production Answer/upload still fail closed when the durable limiter is unavailable
  • Rollback: revert this PR; mode routes return to per-segment GlobalSearchShell layouts and prior timeout/fallback behaviour
  • 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 [REDACTED] ([REDACTED])
  • 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

  • Prescribing list rows keep the full catalogue payload so Safety/Monitoring filters and patient alerts still see section-derived signals; keystroke storms are controlled by debounce + abort. fields=index remains for identity-only consumers (cross-mode links).
  • Live hybrid RPC cold tails remain a separate approval-gated follow-up.

Summary by CodeRabbit

  • Bug Fixes
    • Improved label-based search filtering to deterministically paginate label lookups, avoiding issues when more than 1,000 labels match.
    • Ensured consistent, stable label-scoped results by using repeatable ordering and merging across pages.
  • Tests
    • Added coverage to confirm label pagination behavior when large label sets are present.
    • Updated reconciliation preflight tests to run in-process and validate metadata-only output (no command-line data).

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@supabase

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

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

resolveSearchScope now paginates deterministic document-label queries, with tests covering rows beyond the 1,000-row limit. A reconciliation preflight test now collects and validates metadata in-process instead of spawning a Node process.

Changes

Search-scope label pagination

Layer / File(s) Summary
Ordered label paging
src/lib/search-scope.ts
Label rows now include id and are fetched in stable, abortable ranges until the final page.
Pagination validation
tests/search-scope.test.ts
Mocks paginated label responses and verifies matching document IDs and the 0–999 and 1,000–1,999 ranges.

Reconciliation preflight testing

Layer / File(s) Summary
In-process preflight validation
tests/reconciliation-preflight.test.ts
The test calls collectReconciliationState() directly and validates the metadata-only serialized output without spawning a process.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

  • BigSimmo/Database#912: Both changes modify resolveSearchScope and involve abortable document-scope querying.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 is concise and matches the main changes around scoped-label pagination and the reconciliation preflight test.
Description check ✅ Passed The description follows the required template and includes summary, verification, risk/rollback, governance, and notes sections.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/complete-all-pending-tasks

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.

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

🧹 Nitpick comments (1)
tests/reconciliation-preflight.test.ts (1)

105-114: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Add CLI-level coverage for the preflight command.

The reconciliation-preflight test file has no subprocess/smoke coverage for the executable; the existing line only covers collectReconciliationState() plus JSON.stringify, so argument handling, stdout vs stderr, and exit-code regressions can still pass unnoticed. Keep a small node scripts/reconciliation-preflight.mjs [--json] subprocess test alongside the in-process test unless equivalent coverage already exists elsewhere.

🤖 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/reconciliation-preflight.test.ts` around lines 105 - 114, Add a focused
subprocess smoke test alongside the existing collectReconciliationState test in
reconciliation-preflight.test.ts, invoking node
scripts/reconciliation-preflight.mjs with and without --json as appropriate.
Assert argument handling, valid stdout JSON versus stderr behavior, and
successful exit status, while preserving the existing in-process coverage.
🤖 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/search-scope.test.ts`:
- Around line 25-35: Update the mock query builder in the test to record calls
to order(), specifically the document_labels ordering request, and assert that
order("id", { ascending: true }) is made. Apply the same verification to the
additional affected range, while preserving the existing pagination assertions.

---

Nitpick comments:
In `@tests/reconciliation-preflight.test.ts`:
- Around line 105-114: Add a focused subprocess smoke test alongside the
existing collectReconciliationState test in reconciliation-preflight.test.ts,
invoking node scripts/reconciliation-preflight.mjs with and without --json as
appropriate. Assert argument handling, valid stdout JSON versus stderr behavior,
and successful exit status, while preserving the existing in-process coverage.
🪄 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: bf759243-2fbc-44e8-bf53-0da4eb35b7cc

📥 Commits

Reviewing files that changed from the base of the PR and between e966b5a and 6636478.

📒 Files selected for processing (3)
  • src/lib/search-scope.ts
  • tests/reconciliation-preflight.test.ts
  • tests/search-scope.test.ts

Comment thread tests/search-scope.test.ts Outdated
@BigSimmo
BigSimmo enabled auto-merge (squash) July 25, 2026 05:26
@BigSimmo
BigSimmo merged commit e2488db into main Jul 25, 2026
26 checks passed
@BigSimmo
BigSimmo deleted the codex/complete-all-pending-tasks branch July 25, 2026 05:29
cursor Bot pushed a commit that referenced this pull request Jul 25, 2026
* docs(issues): close stale #66/#67 after main landings

#66 is on origin/main via PR #1174; #67 was fixed in PR #1191 by
running the preflight JSON contract in-process. Also drop already-
resolved #30/#75 from the recommended queue and renumber.

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

* docs: pin branch-review ledger SHA for #66/#67 closeout

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant