Skip to content

fix: resolve design-audit and CI regression guard blockers#840

Merged
7 commits merged into
mainfrom
codex/answer-progress-main-merge-safe-20260718
Jul 18, 2026
Merged

fix: resolve design-audit and CI regression guard blockers#840
7 commits merged into
mainfrom
codex/answer-progress-main-merge-safe-20260718

Conversation

@BigSimmo

@BigSimmo BigSimmo commented Jul 18, 2026

Copy link
Copy Markdown
Owner

Summary

  • Resolve outstanding design-audit recovery blockers on top of latest main.
  • Keep Playwright classification and CI-scope mapping aligned so tests/answer-progress-ui-smoke.spec.ts remains a required UI-covered journey when edited.
  • Harden related routing and RAG tests to keep behavior and cache assertions stable.

Verification

  • node scripts/ci-change-scope.mjs --self-test
  • npm run typecheck:internal
  • npm run lint:internal
  • npm run test -- tests/rag-abort-signal.test.ts tests/rag-classifier-memo.test.ts

UI verification

  • UI verification not run: local environment is currently not running a Playwright-capable browser pipeline in this branch handoff.

Clinical Governance Preflight

  • Not applicable: this change set does not modify answer-generation, clinical source governance, ingestion, or production routing configuration.

Risk and rollout

  • Regression-risked areas: UI test collection patterns, services page routing/tests, and RAG retrieval cache assertion helpers.
  • Mitigation: touched flows include explicit unit/integration coverage; CI change-scope self-test confirms required UI gate remains true for the answer-progress journey.
  • Rollout impact is limited to CI/test behavior and non-user-facing routing helpers in tested paths.

BigSimmo and others added 7 commits July 18, 2026 16:36
* fix: stop Escape focus restore from closing the app-mode menu

Scope dismiss deferred a focus restore onto the answer-options trigger.
When a mode-menu open landed in the same frame window, that restore stole
focus, blur-dismissed the menu, and flaked the Documents mode switch in
Production UI CI. Skip restore when the mode menu is open or focus already
moved, and wait for the scope popover to hide before opening the menu.

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

* fix(test): fail closed when scope popover does not dismiss

Only wait for the scope popover when it is visible, and let that wait
throw if dismissal times out so the mode-menu open cannot recreate the
Escape focus-restore race.

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>
@supabase

supabase Bot commented Jul 18, 2026

Copy link
Copy Markdown

This pull request has been ignored for the connected project sjrfecxgysukkwxsowpy due to reaching the limit of concurrent preview branches.
Go to Project Integrations Settings ↗︎ if you wish to update this limit.


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

@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The PR updates sitemap and redirect contracts, tightens route typing, changes dashboard and search UI behavior, removes RAG abort and observability plumbing, adds database indexing and trigger changes, and aligns regression tests with the updated behavior.

Changes

Routing and sitemap contracts

Layer / File(s) Summary
Route parsing and sitemap generation
src/app/differentials/presentations/route.ts, src/app/page.tsx, scripts/generate-site-map.ts, docs/site-map.md
The presentations redirect uses nullish query selection, home search parameters are explicitly typed, and sitemap route documentation uses the workflow slug while removing generated factsheet entries.
Route and test contract updates
tests/site-map.test.ts, tests/audit-navigation-auth-regressions.test.ts
Redirect and sitemap expectations are updated for the workflow slug and product-route inclusion behavior; the blank-query fallback assertion is removed.

Dashboard and search UI behavior

Layer / File(s) Summary
Dashboard and search interaction changes
src/components/ClinicalDashboard.tsx, src/components/clinical-dashboard/master-search-header.tsx, src/components/services/services-navigator-page.tsx, playwright.config.ts
Unavailable states, also-match placement and branching, menu dismissal, fullscreen sizing, spacing, and reduced-motion formatting are updated.
Dashboard and forms UI regression coverage
tests/audit-content-services-regressions.test.ts, tests/audit-navigation-auth-regressions.test.ts, tests/ui-*.spec.ts
Heading, authorization, forms-content, provenance, pathway-content, and mobile transition assertions are aligned with the updated UI.

RAG retrieval and classifier plumbing

Layer / File(s) Summary
Direct retrieval RPC execution
src/lib/rag-candidate-sources.ts, tests/rag-abort-signal.test.ts
Abort-aware RPC wrappers are removed, RPC errors are exported, direct versioned and legacy RPC calls are used, and tests verify that no signal is passed.
Classifier and answer coalescing contracts
src/lib/rag.ts, tests/rag-classifier-memo.test.ts
Classifier fallback no longer accepts caller abort signals, shared promises are awaited directly, and answer coalescing metrics are removed; classifier fallback coverage is updated.

Database search and trigger hardening

Layer / File(s) Summary
Migration behavior and generated metadata
supabase/migrations/20260714180000_patch_rag_and_corrector_scalability.sql, supabase/migrations/20260714190000_document_table_facts_trgm_idx.sql, supabase/drift-manifest.json
Trigger comparisons, document table-facts trigram indexing, and drift replay metadata are updated.
Schema migration guard updates
tests/supabase-schema.test.ts
Schema guards reference the updated ACL migration and validate cleanup SQL, trigram similarity thresholds, and index creation.

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

Sequence Diagram(s)

sequenceDiagram
  participant searchChunksWithTelemetry
  participant analyzeQueryWithClassifierFallback
  participant SupabaseClient
  searchChunksWithTelemetry->>analyzeQueryWithClassifierFallback: analyze query without caller signal
  analyzeQueryWithClassifierFallback->>analyzeQueryWithClassifierFallback: await shared classifier promise
  searchChunksWithTelemetry->>SupabaseClient: retrieve candidates through direct RPC calls
  SupabaseClient-->>searchChunksWithTelemetry: return versioned or legacy results
Loading

Possibly related PRs

  • BigSimmo/Database#789 — overlaps on sitemap parameters, header menu behavior, and RAG abort-signal removal.
  • BigSimmo/Database#806 — overlaps on redirect documentation, RAG plumbing, migrations, and UI regression assertions.
  • BigSimmo/Database#839 — overlaps across route handling, dashboard rendering, RAG orchestration, migrations, and tests.

Suggested labels: codex

Suggested reviewers: copilot, cursoragent, claude

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% 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 clearly matches the main change: resolving design-audit blockers and CI regression guard updates.
Description check ✅ Passed The description covers summary, verification, risk/rollout, and governance sections, with only minor template formatting gaps.
✨ 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/answer-progress-main-merge-safe-20260718

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: 6

🤖 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 `@supabase/migrations/20260714190000_document_table_facts_trgm_idx.sql`:
- Around line 1-11: Update the document_table_facts_text_trgm_idx creation
statement to use CREATE INDEX CONCURRENTLY, and ensure the migration runs
non-transactionally so PostgreSQL permits the concurrent build. Preserve the
existing index expression, name, and IF NOT EXISTS behavior.

In `@tests/audit-navigation-auth-regressions.test.ts`:
- Around line 126-128: Align the root dashboard heading contract between
clinicalDashboardSource and ClinicalDashboard.tsx: either render exactly one
sr-only H1 containing “Clinical KB” in ClinicalDashboard.tsx, or revise the test
assertion to match the existing valid markup. Preserve the requirement that the
root dashboard has a single H1.

In `@tests/rag-abort-signal.test.ts`:
- Around line 38-55: The test covering callVersionedRetrievalRpc must reflect
the no-signal contract rather than caller-signal attachment. Rename the test to
describe that no signal is forwarded, and remove the non-aborted
controller.signal assertion or replace it with an assertion that directly
verifies the intended no-signal behavior while preserving the existing RPC
argument checks.

In `@tests/site-map.test.ts`:
- Around line 125-130: Update the main-product section generator to include
publicRouteHandlers, ensuring routes such as /applications are emitted there
before the assertions in the expectedProductHandlers loop. Regenerate
docs/site-map.md so the generated product section contains the public redirect
handlers, while preserving the existing API and redirect assertions.

In `@tests/supabase-schema.test.ts`:
- Line 1222: Synchronize the schema migration assertions with the actual
artifacts: update the migrationFiles latest-entry expectation to the
20260717173000 reassert migration, qualify the normalized SQL expectation with
pg_catalog.to_jsonb(old), and update the corrector migration function to set the
pg_trgm similarity threshold and enforce the requested min_sim bounds guard.
Retain the assertions after implementing the migration behavior rather than
weakening them.

In `@tests/ui-accessibility.spec.ts`:
- Line 51: Align the dashboard level-1 heading contract by making the
expectations in tests/ui-accessibility.spec.ts lines 51-51,
tests/ui-smoke.spec.ts lines 876-876, and tests/ui-smoke.spec.ts lines 1271-1271
match the runtime heading rendered by ClinicalDashboard, or consistently rename
that runtime heading to Clinical KB; apply the same choice at all three sites.
🪄 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: bcb41d0f-b44e-4000-a3dd-0c0484eadca0

📥 Commits

Reviewing files that changed from the base of the PR and between 7815204 and d25ef25.

📒 Files selected for processing (22)
  • docs/site-map.md
  • playwright.config.ts
  • scripts/generate-site-map.ts
  • src/app/differentials/presentations/route.ts
  • src/app/page.tsx
  • src/components/ClinicalDashboard.tsx
  • src/components/clinical-dashboard/master-search-header.tsx
  • src/components/services/services-navigator-page.tsx
  • src/lib/rag-candidate-sources.ts
  • src/lib/rag.ts
  • supabase/drift-manifest.json
  • supabase/migrations/20260714180000_patch_rag_and_corrector_scalability.sql
  • supabase/migrations/20260714190000_document_table_facts_trgm_idx.sql
  • tests/audit-content-services-regressions.test.ts
  • tests/audit-navigation-auth-regressions.test.ts
  • tests/rag-abort-signal.test.ts
  • tests/rag-classifier-memo.test.ts
  • tests/site-map.test.ts
  • tests/supabase-schema.test.ts
  • tests/ui-accessibility.spec.ts
  • tests/ui-smoke.spec.ts
  • tests/ui-tools.spec.ts

Comment on lines +1 to +11
-- Migration to add GIN trigram index on document_table_facts text fields for performance optimization
create index if not exists document_table_facts_text_trgm_idx
on public.document_table_facts using gin (
lower(
coalesce(table_title, '') || ' ' ||
coalesce(row_label, '') || ' ' ||
coalesce(clinical_parameter, '') || ' ' ||
coalesce(threshold_value, '') || ' ' ||
coalesce(action, '')
) extensions.gin_trgm_ops
);

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.

🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== repo files ==\n'
git ls-files | rg '(^|/)(supabase|db|migrations|schema|package.json|config|README|docs)'

printf '\n== migration file ==\n'
cat -n supabase/migrations/20260714190000_document_table_facts_trgm_idx.sql

printf '\n== search migration runner / transaction settings ==\n'
rg -n "transaction|concurrent|create index|migrations" supabase package.json .github . -g '!node_modules' -g '!dist' -g '!build'

printf '\n== supabase config files ==\n'
fd -a -t f 'supabase|config|package.json|migrate|migration' .

Repository: BigSimmo/Database

Length of output: 50374


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '== relevant files ==\n'
git ls-files | rg '^(supabase/|package.json|.*supabase.*\.json|.*supabase.*\.toml|.*migration.*|.*migrate.*|README\.md|docs/)'

printf '\n== package scripts and tooling ==\n'
cat package.json | sed -n '1,220p'

printf '\n== supabase config candidates ==\n'
for f in supabase/config.toml supabase/.temp/config.toml supabase/migrations/*.sql; do
  [ -f "$f" ] && echo "--- $f" && sed -n '1,220p' "$f"
done

printf '\n== search for migration transaction / concurrent index hints ==\n'
rg -n --hidden --glob '!node_modules' --glob '!dist' --glob '!build' \
  "supabase db|migration.*transaction|transactional|create index concurrently|disable transaction|BEGIN;|COMMIT;|migrate" \
  package.json supabase README.md docs .github .

Repository: BigSimmo/Database

Length of output: 50374


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '== supabase migration config ==\n'
fd -a -t f 'config.toml|migrate|migration|supabase.*\.toml' supabase . | sed -n '1,120p'

printf '\n== search for explicit non-transactional migration handling ==\n'
rg -n --hidden --glob '!node_modules' --glob '!dist' --glob '!build' \
  "(no[-_ ]transaction|transactional|BEGIN;|COMMIT;|CREATE INDEX CONCURRENTLY|migration.*mode|disable.*transaction|supabase db migration|supabase db push)" \
  supabase .github package.json README.md docs scripts

printf '\n== inspect migration-related scripts ==\n'
node - <<'JS'
const fs = require('fs');
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
for (const [k,v] of Object.entries(pkg.scripts || {})) {
  if (/migrate|supabase|db|drift|schema|verify/i.test(k) || /migrate|supabase|db/i.test(String(v))) {
    console.log(`${k}: ${v}`);
  }
}
JS

printf '\n== smallest relevant migration samples with index creation ==\n'
for f in supabase/migrations/20260714180000_patch_rag_and_corrector_scalability.sql \
         supabase/migrations/20260714190000_document_table_facts_trgm_idx.sql \
         supabase/migrations/20260717131000_guard_document_publication_approval.sql; do
  echo "--- $f"
  sed -n '1,80p' "$f"
done

Repository: BigSimmo/Database

Length of output: 22194


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '== docs mentioning transactional index creation ==\n'
sed -n '1,140p' docs/supabase-migration-reconciliation.md

printf '\n== docs mentioning db push and concurrent index creation ==\n'
sed -n '1,120p' supabase/schema.sql | sed -n '790,840p'
sed -n '1,120p' supabase/migrations/20260708170000_ingestion_jobs_one_open_per_document.sql
sed -n '1,120p' supabase/migrations/20260702150000_documents_owner_covering_index.sql
sed -n '1,120p' supabase/migrations/20260623014639_finalize_embedding_fields_hnsw_health.sql

printf '\n== exact lines around the target migration ==\n'
sed -n '1,40p' supabase/migrations/20260714190000_document_table_facts_trgm_idx.sql

Repository: BigSimmo/Database

Length of output: 17873


Avoid a blocking index build here. CREATE INDEX will hold write locks while it scans public.document_table_facts; use CREATE INDEX CONCURRENTLY in a non-transactional migration, or schedule this for a maintenance window if the transactional path is required.

🧰 Tools
🪛 Squawk (2.59.0)

[warning] 2-11: During normal index creation, table updates are blocked, but reads are still allowed. Use concurrently to avoid blocking writes.

(require-concurrent-index-creation)

🤖 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 `@supabase/migrations/20260714190000_document_table_facts_trgm_idx.sql` around
lines 1 - 11, Update the document_table_facts_text_trgm_idx creation statement
to use CREATE INDEX CONCURRENTLY, and ensure the migration runs
non-transactionally so PostgreSQL permits the concurrent build. Preserve the
existing index expression, name, and IF NOT EXISTS behavior.

Source: Linters/SAST tools

Comment on lines +126 to +128
it("keeps the root dashboard H1 as Clinical KB", () => {
expect(clinicalDashboardSource.match(/<h1\b/g)).toHaveLength(1);
expect(clinicalDashboardSource).toMatch(/<h1 className="sr-only">\s*Clinical Guide\s*<\/h1>/);
expect(clinicalDashboardSource).toMatch(/<h1 className="sr-only">\s*Clinical KB\s*<\/h1>/);

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.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Align the H1 source contract with ClinicalDashboard.tsx.

This new exact <h1 className="sr-only">Clinical KB</h1> assertion currently fails. Render that contract in ClinicalDashboard.tsx, or update the test to match the valid current markup.

🧰 Tools
🪛 GitHub Check: Unit coverage

[failure] 128-128: [node] tests/audit-navigation-auth-regressions.test.ts > audit navigation and auth regressions > keeps the root dashboard H1 as Clinical KB
AssertionError: expected '"use client";\n\nimport { useRouter, …' to match /

\s*Clinica…/h1>

  • Expected:
    /

    \sClinical KB\s</h1>/

  • Received:
    ""use client";

import { useRouter, useSearchParams } from "next/navigation";
import dynamic from "next/dynamic";
import {
CircleAlert,
BookOpen,
ChevronDown,
Clock3,
ExternalLink,
FileImage,
FileText,
FolderOpen,
Heart,
ListChecks,
Loader2,
Quote,
RefreshCw,
Search,
ShieldAlert,
Square,
UploadCloud,
WifiOff,
Wrench,
} from "lucide-react";
import { type CSSProperties, useCallback, useEffect, useMemo, useReducer, useRef, useState } from "react";
import { type DocumentDeleteResult } from "@/components/DocumentManagementActions";
import { extractSafetyFindings } from "@/lib/clinical-safety";
import { isLocalNoAuthMode, publicUploadsEnabled } from "@/lib/client-env";
import { readLocalProjectIdentity, unsafeLocalProjectMessage } from "@/lib/local-project-identity";
import { isDeployedClinicalKb } from "@/lib/deployed-app";
import {
appBackdrop,
answerSurface,
cn,
EmptyState,
floatingControl,
InlineNotice,
primaryControl,
textMuted,
} from "@/components/ui-primitives";
import { useAuthSession } from "@/lib/supabase/client";
import { AccountSetupDialog } from "@/components/clinical-dashboard/account-setup-dialog";
import { CrossModeLinksSection } from "@/components/clinical-dashboard/cross-mode-links";
import { useEventCallback } from "@/components/clinical-dashboard/use-event-callback";
import { AuthPanel } from "@/components/clinical-dashboard/auth-panel";
import { buildMobileSectionFabState, MobileSectionFab, ToolsHub } from "@/components/clinical-dashboard/dashboard-nav";
import { SettingsDialog } from "@/components/clinical-dashboard/settings-dialog";
import { useSidebarCollapsed } from "@/components/clinical-dashboard/use-sidebar-collapsed";
import { useTheme } from "@/components/clinical-dashboard/use-theme";
import {
deriveSidebarIdentity,
ClinicalDesktopSidebar,
ClinicalMobileSidebar,
} from "@/components/clinical-dashboard/ClinicalSidebar";
import {
SetupChecklist,
UploadPanel,
IndexingMonitor,
IngestionQualityConsole,
LibraryHealthStrip,
fallbackSetupChecks,
hasReadyRequiredPublicSearchConfig,
hasReadyPublicSearchSetup,
type SetupCheck,
type IngestionQualityReviewItem,
} from "@/components/clinical-dashboard/DocumentManagerPanel";
import { GuideDialog, GuideTrigger, UtilityDrawer } from "@/components/clinical-dashboard/dashboard-shell";
import { sanitizeAnswerDisplayText, sanitizeDisplayText } from "@/components/clinical-dashboard/display-text";
import {
isPreformattedGroundedAnswer,
NaturalLanguageAnswer,
ScopeAndGovernanceNotice,
UserQuestionBubble,
} from "@/components/clinical-dashboard/answer-content";
import { AnswerEmptyState, AnswerProgressStepper, AnswerSkeleton } from "@/components/clinical-dashboard/answer-status";
import {
type AnswerProgressUpdate,
type TimedAnswerProgressUpdate,
} from "@/components/clinical-dashboard/answer-progress";
import { evidenceMapRowsFromRenderModel } from "@/components/clinical-dashboard/evidence-map-model";
import { MasterSearchHeader } from "@/components/clinical-dashboard/master-search-header";
import { UniversalSearchAlsoMatches } from "@/components/clinical-dashboard/universal-search-also-matches";
import { useScrollHideReporter } from "@/components/clinical-dashboard/use-hide-on-scroll";
import { SearchCommandProvider } from "@/components/clinical-dashboard/search-command-context";
import {
answerReferencesDocument,
answerTimedOutError,
applyRenamedDocumentToAnswer,
compactScopeFilters,
hasActiveIndexingWork,
hasNonProductionSupabaseApiKeyFallback,
isAbortError,
mergeDocumentRefresh,
normalizeNavigationHash,
setupNeedsSlowRecheck,
setupRecheckPollMs,
shorterPollDelay,
} from "@/components/clinical-dashboard/clinical-dashboard-helpers";
import { answerRecovery, errorCopy } from "@/lib/ui-copy";
imp

🤖 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/audit-navigation-auth-regressions.test.ts` around lines 126 - 128,
Align the root dashboard heading contract between clinicalDashboardSource and
ClinicalDashboard.tsx: either render exactly one sr-only H1 containing “Clinical
KB” in ClinicalDashboard.tsx, or revise the test assertion to match the existing
valid markup. Preserve the requirement that the root dashboard has a single H1.

Source: Linters/SAST tools

Comment on lines +38 to +55
const rpcCalls: Array<{ name: string; args: Record<string, unknown> }> = [];
const supabase = {
rpc: vi.fn(async (name: string, args: Record<string, unknown>) => {
rpcCalls.push({ name, args });
return { data: [], error: null };
}),
};
const { callVersionedRetrievalRpc } = await import("../src/lib/rag-candidate-sources");

await callVersionedRetrievalRpc(
supabase as never,
"match_document_chunks_text_v2",
"match_document_chunks_text",
{ query_text: "clozapine", match_count: 8 },
controller.signal,
);
await callVersionedRetrievalRpc(supabase as never, "match_document_chunks_text_v2", "match_document_chunks_text", {
query_text: "clozapine",
match_count: 8,
});

expect(abortSignal).toHaveBeenCalledWith(controller.signal);
expect(rpcCalls[0]?.name).toBe("match_document_chunks_text_v2");
expect(rpcCalls[0]?.args).toMatchObject({ query_text: "clozapine", match_count: 8 });
expect(rpcCalls[0]?.args?.signal).toBeUndefined();
expect(controller.signal.aborted).toBe(false);

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.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Rename the test to match the new contract.

The test still says it “attaches the caller signal,” but the invocation omits controller.signal and asserts that no signal is forwarded. The non-aborted controller assertion does not exercise cancellation; rename the test and remove or replace that assertion with coverage for the intended no-signal behavior.

🤖 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/rag-abort-signal.test.ts` around lines 38 - 55, The test covering
callVersionedRetrievalRpc must reflect the no-signal contract rather than
caller-signal attachment. Rename the test to describe that no signal is
forwarded, and remove the non-aborted controller.signal assertion or replace it
with an assertion that directly verifies the intended no-signal behavior while
preserving the existing RPC argument checks.

Comment thread tests/site-map.test.ts
Comment on lines +125 to +130
for (const [route, file, target] of expectedProductHandlers) {
expect(data.publicRouteHandlers).toContainEqual({ route, file });
expect(data.apiRoutes).not.toContainEqual({ route, file });
expect(data.redirects).toContainEqual({ route, file, target });
expect(productSection).toContain(`\`${route}\``);
expect(apiSection).not.toContain(`\`${route}\``);

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.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Generate public redirect handlers in the product section before asserting them.

Line 129 fails because the generated main-product section does not contain /applications. Add publicRouteHandlers to that generator section and regenerate docs/site-map.md, or remove this new expectation.

🧰 Tools
🪛 GitHub Check: Unit coverage

[failure] 129-129: [node] tests/site-map.test.ts > tracked sitemap > keeps public redirect handlers in product routes and API handlers in the API section
AssertionError: expected '## Main product routes\n\n- / - Mai…' to contain '/applications'

  • Expected
  • Received
  • /applications
  • Main product routes

    • / - Main Clinical KB shell. Source: src/app/page.tsx.
    • /differentials - Differentials home and search surface. Source: src/app/differentials/page.tsx.
    • /differentials/diagnoses - Diagnosis stream. Source: src/app/differentials/diagnoses/page.tsx.
    • /differentials/presentations/[slug] - Route discovered from app directory Source: src/app/differentials/presentations/[slug]/page.tsx.
    • /documents/search - Documents search command centre. Source: src/app/documents/search/page.tsx.
    • /documents/source - Compatibility redirect to the canonical live document viewer when a valid id is supplied. Source: src/app/documents/source/page.tsx.
    • /documents/source/evidence - Compatibility redirect sharing the canonical live document viewer handoff. Source: src/app/documents/source/evidence/page.tsx.
    • /dsm - DSM-5 Diagnosis home. Source: src/app/dsm/page.tsx.
    • /dsm/compare - DSM diagnosis comparison. Source: src/app/dsm/compare/page.tsx.
    • /dsm/search - DSM diagnosis search and catalogue browser. Source: src/app/dsm/search/page.tsx.
    • /factsheets - Route discovered from app directory Source: src/app/factsheets/page.tsx.
    • /factsheets/[slug] - Route discovered from app directory Source: src/app/factsheets/[slug]/page.tsx.
    • /factsheets/search - Route discovered from app directory Source: src/app/factsheets/search/page.tsx.
    • /favourites - Saved clinical items and sets. Source: src/app/favourites/page.tsx.
    • /forms - Forms home and search surface. Source: src/app/forms/page.tsx.
    • /formulation - Clinical formulation home and local mechanism search surface. Source: src/app/formulation/page.tsx.
    • /formulation/builder - Structured clinical formulation builder. Source: src/app/formulation/builder/page.tsx.
    • /formulation/compare - Side-by-side mechanism comparison. Source: src/app/formulation/compare/page.tsx.
    • /formulation/map - Formulation mechanism domain map. Source: src/app/formulation/map/page.tsx.
    • /privacy - Privacy and data-processing governance draft. Source: src/app/privacy/page.tsx.
    • /reference/colour-coding - Route discovered from app directory Source: src/app/reference/colour-coding/page.tsx.
    • /services - Services home and search surface. Source: src/app/services/page.tsx.
    • /specifiers - Psychiatric specifier home and local search surface. Source: src/app/specifiers/page.tsx.
    • /specifiers/builder - Structured diagnostic wording builder. Source: src/app/specifiers/builder/page.tsx.
    • /specifiers/compare - Side-by-side psychiatric specifier comparison. Source: src/app/specifiers/compare/page.tsx.
    • /specifiers/map - Psychiatric specifier family map. Source: src/app/specifiers/map/page.tsx.
    • /therapy-compass - Route discovered from app directory Source: src/app/therapy-compass/page.tsx.
    • /tools - Route discovered from app directory Source: src/app/tools/page.tsx.

❯ tests/site-map.test.ts:129:30

🤖 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/site-map.test.ts` around lines 125 - 130, Update the main-product
section generator to include publicRouteHandlers, ensuring routes such as
/applications are emitted there before the assertions in the
expectedProductHandlers loop. Regenerate docs/site-map.md so the generated
product section contains the public redirect handlers, while preserving the
existing API and redirect assertions.

Source: Linters/SAST tools

.filter((fileName) => /^\d+_.+\.sql$/.test(fileName))
.sort();
expect(migrationFiles.at(-1)).toBe("20260717173000_reassert_supabase_admin_default_privileges.sql");
expect(migrationFiles.at(-1)).toBe("20260717161000_assert_supabase_admin_default_privileges.sql");

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.

🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

Synchronize these assertions with the actual migration artifacts.

The updated schema guards currently fail in three places:

  • Line 1222: migrationFiles.at(-1) resolves to 20260717173000_reassert_supabase_admin_default_privileges.sql, not 20260717161000_assert_supabase_admin_default_privileges.sql. Update the expected latest migration or remove/rename the later migration if it is stale.
  • Lines 1372-1374: The normalized SQL contains pg_catalog.to_jsonb(old)->>'kind'; include the qualification in the expected string.
  • Lines 1398-1399: The current corrector function contains neither set pg_trgm.similarity_threshold = 0.3 nor the requested min_sim bounds guard. Implement that behavior in the migration before retaining these assertions; do not merely weaken the test.

Also applies to: 1372-1374, 1398-1399

🧰 Tools
🪛 GitHub Check: Unit coverage

[failure] 1222-1222: [node] tests/supabase-schema.test.ts > Supabase Preview replay guards > fails closed on effective supabase_admin default ACLs
AssertionError: expected '20260717173000_reassert_supabase_admi…' to be '20260717161000_assert_supabase_admin_…' // Object.is equality

Expected: "20260717161000_assert_supabase_admin_default_privileges.sql"
Received: "20260717173000_reassert_supabase_admin_default_privileges.sql"

❯ tests/supabase-schema.test.ts:1222:35

🤖 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/supabase-schema.test.ts` at line 1222, Synchronize the schema migration
assertions with the actual artifacts: update the migrationFiles latest-entry
expectation to the 20260717173000 reassert migration, qualify the normalized SQL
expectation with pg_catalog.to_jsonb(old), and update the corrector migration
function to set the pg_trgm similarity threshold and enforce the requested
min_sim bounds guard. Retain the assertions after implementing the migration
behavior rather than weakening them.

Source: Linters/SAST tools


async function expectDashboardUsable(page: Page) {
await expect(page.getByRole("heading", { level: 1, name: "Clinical Guide" })).toHaveCount(1);
await expect(page.getByRole("heading", { level: 1, name: "Clinical KB" })).toHaveCount(1);

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.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Align the dashboard heading contract before merging.

src/components/ClinicalDashboard.tsx still renders the level-1 heading Clinical Guide at Line 3495, so these new Clinical KB expectations resolve to zero elements and fail the UI suite. Either update the runtime heading or restore the assertions to Clinical Guide.

  • tests/ui-accessibility.spec.ts#L51-L51: change the expected heading to match the runtime dashboard heading, or rename the runtime heading.
  • tests/ui-smoke.spec.ts#L876-L876: apply the same heading contract.
  • tests/ui-smoke.spec.ts#L1271-L1271: apply the same heading contract.
📍 Affects 2 files
  • tests/ui-accessibility.spec.ts#L51-L51 (this comment)
  • tests/ui-smoke.spec.ts#L876-L876
  • tests/ui-smoke.spec.ts#L1271-L1271
🤖 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/ui-accessibility.spec.ts` at line 51, Align the dashboard level-1
heading contract by making the expectations in tests/ui-accessibility.spec.ts
lines 51-51, tests/ui-smoke.spec.ts lines 876-876, and tests/ui-smoke.spec.ts
lines 1271-1271 match the runtime heading rendered by ClinicalDashboard, or
consistently rename that runtime heading to Clinical KB; apply the same choice
at all three sites.

@github-actions

Copy link
Copy Markdown

CI triage

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

  • Unit coverageneeds investigation: inspect the failing step and uploaded diagnostics; rerun only after classifying the cause.
  • Production UIneeds investigation: inspect the failing step and uploaded diagnostics; rerun only after classifying the cause.
  • PR requiredneeds investigation: inspect the failing step and uploaded diagnostics; rerun only after classifying the cause.

Compared with main CI run #3245 (success).

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

@BigSimmo BigSimmo closed this pull request by merging all changes into main in 5c3a0e5 Jul 18, 2026
@BigSimmo
BigSimmo deleted the codex/answer-progress-main-merge-safe-20260718 branch July 18, 2026 10:40
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.

1 participant