Skip to content

Save Codex local changes - #50

Merged
BigSimmo merged 3 commits into
mainfrom
codex/database-safe-save
Jun 23, 2026
Merged

Save Codex local changes#50
BigSimmo merged 3 commits into
mainfrom
codex/database-safe-save

Conversation

@BigSimmo

Copy link
Copy Markdown
Owner

Saves local Codex changes for review.

CopilotAI review requested due to automatic review settings June 23, 2026 02:24
@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.

@BigSimmo
BigSimmo merged commit e980404 into mainJun 23, 2026
6 of 8 checks passed
@BigSimmo
BigSimmo deleted the codex/database-safe-save branch June 23, 2026 02:24

CopilotAI 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.

Pull request overview

This PR aggregates a broad set of “local Codex changes” spanning worker ingestion/indexing behavior, Supabase schema hardening (health checks, indexes, dedup), clinical output formatting, UI accessibility/table rendering, and process/CI guardrails (verification scripts + Playwright coverage + production readiness preflight).

Changes:

  • Add embedding-field dedup support (content_hash + trigger + unique index), expand schema health/index validation, and refresh table stats post-ingestion.
  • Improve RAG/clinical UX output: smarter bottom-line selection, clipboard/note formatting, evidence passage compaction, and safety finding text cleanup.
  • Harden process: new verification commands, CI Playwright Chromium smoke, production-readiness preflight, security headers, and new Playwright UI/accessibility tests.

Reviewed changes

Copilot reviewed 107 out of 120 changed files in this pull request and generated 3 comments.

Show a summary per file
FileDescription
worker/main.tsAdds embedding-field content_hash, larger insert batching, and post-job analyze_rag_tables refresh.
worker/embedding-fields.tsFormatting-only adjustment to addField call.
tests/ward-output.test.tsUpdates assertions for new clipboard/ward-note formatting and section merging behavior.
tests/ui-tools.spec.tsAdds Playwright coverage for /tools launcher usability.
tests/ui-smoke.spec.tsStabilizes selectors and updates upload drawer interactions for new UI structure.
tests/ui-accessibility.spec.tsAdds reduced-motion + forced-colors Playwright smoke coverage.
tests/supabase-schema.test.tsLoosens grants regex to accommodate new schema items.
tests/private-access-routes.test.tsFormatting-only change to route handler invocation.
tests/ingestion.test.tsFormatting-only change to long error string literal.
tests/evidence.test.tsFormatting-only change to array expectation.
tests/embed-texts-integrity.test.tsFormatting-only change to mock embedding data creation.
tests/deep-memory.test.tsFormatting-only tweaks; removes stray whitespace.
tests/clinical-safety.test.tsUpdates expectations for cleaned safety finding labels/text; adds new test.
tests/bulk-import.test.tsFormatting-only tweak to expected array literal.
tests/answer-verification.test.tsFormatting-only change to function call layout.
tests/accessible-table-normalization.test.tsAdds a source-based regression test for updated AccessibleTable structure.
supabase/migrations/20260623014639_finalize_embedding_fields_hnsw_health.sqlFinalizes schema-health expectations and adds embedding-fields HNSW index + health RPC update.
supabase/migrations/20260622000000_reconcile_schema_health_vector_privileges.sqlAdds index reconciliation, embedding-field hash trigger + dedup index, RPC hardening, and analyze_rag_tables.
src/lib/ward-output.tsMajor rework of clipboard/ward-note output structure and bottom-line selection logic.
src/lib/supabase/health.tsFormatting-only adjustments in type signatures and HTML title extraction.
src/lib/rag.tsAdds additional retrieval telemetry counters and minor formatting fixes.
src/lib/openai.tsFormatting-only adjustment to PublicApiError construction.
src/lib/ingestion.tsFormatting-only refactor of retryable-error regex check.
src/lib/ingestion-recovery.tsFormatting-only change to boolean expression layout.
src/lib/image-filtering.tsFormatting-only refactor of condition wrapping.
src/lib/extractors/document.tsFormatting-only change to warning string push.
src/lib/env.tsChanges default worker runtime parameters (polling, batch size, concurrency, attempts, stale window).
src/lib/deep-memory.tsIncreases batch sizes for deep-memory inserts and minor formatting.
src/lib/clinical-vocabulary.tsExpands formatting for readability of vocabulary entries.
src/lib/clinical-safety.tsCleans/compacts extracted safety finding text using sanitizer helpers.
src/lib/bulk-import.tsFormatting-only change to normalized key assignment.
src/lib/answer-ranking.tsComment whitespace cleanup.
src/lib/answer-formatting.tsAdds semicolon-list splitter helper and standardizes fallback text.
src/components/DocumentViewer.tsxImproves mobile actions UX (sheet), table rendering behavior, and copy changes (“Open source”).
src/components/DashboardFloatingFab.tsxMinor string quoting and SR live-region formatting adjustments.
src/components/clinical-dashboard/use-theme.tsAdds a client theme hook using useSyncExternalStore.
src/components/clinical-dashboard/source-actions.tsxAdds source action row + link helpers for dashboard usage.
src/components/clinical-dashboard/relevance.tsxAdds relevance badges/chips utilities and components.
src/components/clinical-dashboard/index.tsExports the clinical-dashboard module surface.
src/components/clinical-dashboard/ClinicalDashboard.tsxProvides compatibility export for ClinicalDashboard.
src/components/clinical-dashboard/badges.tsxAdds status/strength badge components.
src/components/clinical-dashboard/answer-status.tsxAdds empty/skeleton/copy UI helpers for dashboard answer states.
src/components/AccessibleTable.tsxReworks mobile table presentation to keep a single semantic table + adds expand dialog + row actions.
src/app/page.tsxSwitches to importing ClinicalDashboard from the new module entrypoint.
src/app/api/search/route.tsAdds rag_retrieval_logs insert diagnostics with failure metrics tracking.
src/app/api/ingestion/jobs/[id]/retry/route.tsFormatting-only change to JSON error field layout.
scripts/supabase-recovery-status.tsFormatting-only refactor of safeCount calls.
scripts/reindex-health.tsFormatting-only refactor of safeCount calls.
scripts/production-readiness.tsAdds an executable production readiness preflight script.
scripts/playwright-base-url.tsIncreases local identity probe timeout.
scripts/import-documents.tsFormatting-only console.log line wrapping changes.
scripts/eval-search.tsAdds retry/backoff on rate limits + spacing delay between cases.
scripts/eval-retrieval.tsFormatting-only change to a long numeric expression.
scripts/ensure-local-server.mjsImproves project identity probing robustness (retries + timeout).
scripts/enrich-documents.tsAdds retry/backoff on rate limits and better enrichment completion stamping.
scripts/check-indexing.tsAdds paginated document loading + ordering and more readiness reporting.
scripts/backfill-smart-index.tsAdds embedding-field md5 hash inclusion and small formatting fixes.
scripts/audit-tables.tsFormatting-only change to .or(...) usage.
scratch/update-health-check.sqlAdds a scratch SQL version of search_schema_health updates.
scratch/show-samples.tsAdds a scratch script to print sample documents.
scratch/queue-queued-docs.tsAdds a scratch script to enqueue ingestion jobs for queued documents.
scratch/fix-indexes.tsAdds a scratch script stub for index fixes.
scratch/create-hnsw-indexes.sqlAdds scratch SQL for creating HNSW indexes via dashboard/editor.
scratch/count-status.tsAdds scratch script to count document/job statuses.
scratch/count-files.tsAdds scratch script with local Windows paths for file counting.
scratch/check-queued-docs.tsAdds scratch script to inspect active ingestion jobs.
scratch/check-indexes.tsAdds scratch script attempting to query system indexes via Supabase.
scratch/audit-guidelines.tsAdds scratch script with local Windows paths for auditing guideline coverage.
README.mdDocuments new verification/readiness commands.
playwright.config.tsExpands test match to include accessibility/tools and increases timeout.
package.jsonAdds verify and production-readiness scripts plus workflow helpers.
next.config.tsAdds security headers (CSP, COOP/COEP, HSTS, etc.) and disables powered-by header.
eslint.config.mjsIgnores scratch/**.
docs/redesign/06-verification.mdRecords verification steps and results for redesign/process pass.
docs/redesign/05-changelog.mdAdds June 23 process hardening notes.
docs/redesign/04-deferred.mdUpdates deferred items to reflect tools page coverage resolution.
docs/redesign/03-decision-log.mdAdds decisions D7–D10 related to scope, upload drawer, viewer actions, evidence hint.
docs/redesign/02-design-direction.mdAdds June 20 scoped direction notes.
docs/redesign/01-audit.mdAdds audit notes emphasizing scoped run exclusions.
docs/production-readiness-checklist.mdAdds executable production readiness checklist/runbook.
docs/process-hardening.mdAdds verification gating plan and phases.
docs/clinical-governance.mdAdds PR preflight guidance for governance-sensitive changes.
AGENTS.mdAdds process-hardening guidance and verification gates for future agents.
.vscode/extensions.jsonAdds recommended dev extensions.
.tmp-visual/stream-headers.mjsAdds local visual/debug helper script (repo-local).
.tmp-visual/stream-capture.mjsAdds local visual/debug helper script (repo-local).
.tmp-visual/query-smoke.mjsAdds local visual/debug helper script (repo-local).
.tmp-visual/query-final.mjsAdds local visual/debug helper script (repo-local).
.tmp-visual/query-disabled-state.mjsAdds local visual/debug helper script (repo-local).
.tmp-visual/query-ask.mjsAdds local visual/debug helper script (repo-local).
.tmp-visual/query-ask-submit.mjsAdds local visual/debug helper script (repo-local).
.tmp-visual/query-api-trace.mjsAdds local visual/debug helper script (repo-local).
.tmp-visual/query-answer-stream.mjsAdds local visual/debug helper script (repo-local).
.tmp-visual/inspect-home.mjsAdds local visual/debug helper script (repo-local).
.tmp-visual/inspect-ask-controls.mjsAdds local visual/debug helper script (repo-local).
.tmp-visual/check-search-api.mjsAdds local visual/debug helper script (repo-local).
.tmp-visual/capture.mjsAdds local visual/debug helper script (repo-local).
.prettierignoreIgnores .tmp-visual/ and scratch/.
.github/workflows/codeql.ymlFormatting-only YAML cleanup.
.github/workflows/ci.ymlAdds production-readiness CI check + installs/runs Playwright Chromium smoke.
.github/pull_request_template.mdAdds verification checklist + clinical governance preflight section.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +437 to +439
top_rrf_score: topResult?.rrf_score ?? null,
mean_hybrid_score: meanScore || null,
selected_chunk_ids: args.results
Comment on lines +439 to +446
selected_chunk_ids: args.results
.slice(0, 12)
.map((r) => r.id)
.filter((id) => /^[0-9a-f-]{36}$/i.test(id)),
selected_document_ids: Array.from(new Set(args.results.slice(0, 12).map((r) => r.document_id))).filter((id) =>
/^[0-9a-f-]{36}$/i.test(id),
),
selected_count: Math.min(args.results.length, 12),
Comment threadsrc/lib/env.ts
Comment on lines +64 to +68
WORKER_POLL_MS: z.coerce.number().int().positive().default(1500),
WORKER_BATCH_SIZE: z.coerce.number().int().positive().default(25),
WORKER_CONCURRENCY: z.coerce.number().int().positive().default(8),
WORKER_MAX_ATTEMPTS: z.coerce.number().int().positive().default(5),
WORKER_STALE_AFTER_MINUTES: z.coerce.number().int().positive().default(5),
BigSimmo pushed a commit that referenced this pull request Jul 20, 2026
…rank score
The 2026-07-20 post-merge golden run (eval-canary #50, 35/36) showed the
#982 tie-break regressing alcohol-ciwa-threshold: keying saturated ties on
the boost-laden rankScore let generic clinicalSignalBoost stacking promote
screening/monitoring chunks over the chunk containing the queried terms —
the same failure mode the clamped-score contract exists to prevent. The
tie-break key is now the clinical rank's lexicalCoverageScore (query-term
coverage, immune to boost stacking), renamed contentCoverageScore; ties on
coverage still fall back to the stable chunk-id order. The saturated-tie
contract test now pins coverage winning against a HIGHER rankScore, and
the fast-path CIWA guard adds the screening-chunk shape from run #50.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EXsJcLrbZUXwnBeG91cVo9
BigSimmo pushed a commit that referenced this pull request Jul 20, 2026
BigSimmo added a commit that referenced this pull request Jul 20, 2026
…rank score (#987)
* fix(rag): break saturated selection ties by query-term coverage, not rank score
The 2026-07-20 post-merge golden run (eval-canary #50, 35/36) showed the
#982 tie-break regressing alcohol-ciwa-threshold: keying saturated ties on
the boost-laden rankScore let generic clinicalSignalBoost stacking promote
screening/monitoring chunks over the chunk containing the queried terms —
the same failure mode the clamped-score contract exists to prevent. The
tie-break key is now the clinical rank's lexicalCoverageScore (query-term
coverage, immune to boost stacking), renamed contentCoverageScore; ties on
coverage still fall back to the stable chunk-id order. The saturated-tie
contract test now pins coverage winning against a HIGHER rankScore, and
the fast-path CIWA guard adds the screening-chunk shape from run #50.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EXsJcLrbZUXwnBeG91cVo9
* docs(ledger): record run-#50 finding and coverage tie-break review row
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EXsJcLrbZUXwnBeG91cVo9
---------
Co-authored-by: Claude <noreply@anthropic.com>
BigSimmo pushed a commit that referenced this pull request Jul 20, 2026
…ck, WebKit focus/forced-colors/stale-style, Firefox tab order, CIWA term alias
Seven fixes from the run-4012 triage, each root-caused:
- playwright.config.ts: serviceWorkers 'block' suite-wide (+ ui-pwa.spec.ts
'allow' opt-in). In production builds public/sw.js registers in every
test, claims the page (clients.claim) and serves every navigation —
probe-proven to bypass route interception for navigations on Chromium
and to wedge Playwright-Firefox's reload path under an active route
(both ui-smoke reload hangs). Only ui-pwa exercises the worker itself;
its offline/CacheStorage journey passes under the opt-in.
- master-search-header.tsx: close the desktop mode menu on Tab from the
trigger (APG menu-button pattern). WebKit's sequential focus navigation
can fail to deliver a wrapper-escaping focusout (links excluded from
its Tab order; backward wrap into the menu), leaving the menu open.
- ui-accessibility.spec.ts: webkit skip for the forced-colors token test —
WebKit has no forced-colors implementation, so the media remap under
test cannot engage there.
- ui-formulation.spec.ts: pin the step-nav Previous button enabled with
opacity 1 before the axe scan — WebKit can serve a stale :disabled
computed style whose 0.4 opacity axe folds into a phantom contrast
violation for a WCAG-1.4.3-exempt state.
- ui-smoke.spec.ts: step over Firefox's scrollable-container tab stop
(the sheet body sits between Close and 'New chat' in DOM order).
- scripts/eval-retrieval.ts: ciwa -> ciwa-ar content alias. The matcher
is whitespace-delimited, so the bare fixture term can never match the
scale's hyphenated written name; canary runs #50/#51 ranked the
CIWA-Ar dosing-table region top-5 yet the gate reported a miss.
- tests/helpers/zero-touch.ts: shared stubZeroTouchPoints helper
replacing the six inline copies from #995 (review follow-up).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EXsJcLrbZUXwnBeG91cVo9
Sign up for freeto 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

@BigSimmo