Skip to content

Fix type-honesty gaps from PR #131 typed-client migration - #174

Merged
BigSimmo merged 8 commits into
mainfrom
claude/pr131-review-fixes
Jul 2, 2026
Merged

Fix type-honesty gaps from PR #131 typed-client migration#174
BigSimmo merged 8 commits into
mainfrom
claude/pr131-review-fixes

Conversation

@BigSimmo

@BigSimmo BigSimmo commented Jul 2, 2026

Copy link
Copy Markdown
Owner

Summary

Post-merge review of #131 (typed Supabase client / generated DB types). Three gaps patched, plus a broken verification gate restored:

  • planDocumentName never fetched metadata, so the smart_title_group_key written by the upload route and import script for duplicate-title grouping was silently ignored on the DB-backed path. The select now includes metadata.
  • RagQueryInsert diverged from the real schema: it allowed source_chunk_ids: null (column is NOT NULL) and the whole-row as cast at the insert would hide future column mismatches. It is now derived from the generated rag_queries Insert type; the only remaining cast is the narrow one on the merged privacy metadata object.
  • document_images.bbox was blind-cast from untyped jsonb to the new [x0,y0,x1,y1] tuple type. It is now validated at the read boundary (chunkImageBbox) and falls back to null for malformed values.
  • npm run format:check failed on main: the generated database.types.ts (from Tighten TypeScript: generated DB types, typed Supabase client, strict env #131) is now prettier-ignored (regeneration would keep fighting the formatter), and document-viewer-lazy.tsx (from perf: SSR-safe lazy loading, loading skeletons, and SourceImage memo #147) is formatted.

Reviewed and cleared without changes: extraction_mode union narrowing (verified against live data — only the three union values exist), indexingVersion narrowing (only assigned from the ragDeepMemoryVersion constant), requireServerEnv typed return, typed admin client, generated types freshness (spot-checked against the six newest migration RPCs), noImplicitReturns.

Verification

  • npm run verify:cheap — check:runtime, lint, typecheck, vitest: 98 files / 821 tests passed (2 skipped, pre-existing)
  • npm run verify:ui — N/A: no UI, routing, or styling behavior changed (viewer file change is prettier whitespace only)
  • npm run verify:release — not run; not a release/handoff claim
  • npm run format:check — passes after this PR (failed on main)
  • npm run check:production-readiness:ci mode: READY, no blocking failures (env-less scratch worktree, missing-env checks downgraded as designed)
  • npm run check:deployment-readiness — N/A: no deployment startup/hosting change

Clinical Governance Preflight

  • Source-backed claims still require linked source verification before clinical use — answer generation and source rendering behavior unchanged
  • No patient-identifiable document workflow was introduced or expanded — query-log privacy redaction path (queryTextForStorage / queryPrivacyMetadata) unchanged
  • 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 — malformed bbox now degrades to null instead of a lying cast
  • Deployment classification/TGA SaMD impact — no clinical decision-support behavior changed

Notes

  • A related pre-existing risk outside this diff (unguarded bbox array-destructure in scripts/enrich-documents.tsimage-filtering.ts) is being handled in a separate session.

🤖 Generated with Claude Code

BigSimmo and others added 2 commits July 2, 2026 18:20
- planDocumentName: select the metadata column so the stored
  smart_title_group_key actually participates in duplicate-title
  grouping (the typed select silently dropped it, leaving the
  metadata branch dead on the DB-backed path)
- rag.ts: derive RagQueryInsert from the generated rag_queries Insert
  type instead of a hand-written interface, removing the whole-row
  cast and the source_chunk_ids null lie (column is NOT NULL)
- rag.ts: validate document_images.bbox jsonb as a [x0,y0,x1,y1]
  tuple at the read boundary instead of blind-casting Json

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
PR #131's generated database.types.ts and PR #147's
document-viewer-lazy.tsx both fail the prettier gate on main.
Ignore the generated Supabase types file (regeneration would keep
fighting prettier) and format the lazy viewer wrapper.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 45a0d3c874

ℹ️ 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".

Comment thread src/lib/document-naming.ts
Comment thread src/lib/rag.ts Outdated
Drops the branch-local chunkImageBbox in favour of the shared helper
that landed on main with the same semantics.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@BigSimmo
BigSimmo enabled auto-merge (squash) July 2, 2026 11:51
Whitespace/wrapping only; keeps npm run format:check green after
merging origin/main.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@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 and others added 4 commits July 2, 2026 20:00
…oke)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- document-naming: also match a renamed document by its current title, not
  only the stored smart_title_group_key (renames update title but preserve
  metadata, so the stored key can be stale and miss a duplicate)
- image-filtering: normalizeImageBbox rejects non-numeric coordinates
  (null/""/false) instead of Number()-coercing them to a bogus 0
- tests: cover stale-group-key rename matching and non-numeric bbox entries

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@BigSimmo
BigSimmo merged commit 269c9c7 into main Jul 2, 2026
4 checks passed
BigSimmo added a commit that referenced this pull request Jul 2, 2026
…yInsert

- Run prettier --write to clear the format:check gate (20 files: mockup
  components, governance scripts, rag.ts, ui-smoke.spec.ts, etc.). No trap
  files touched (worker/main.ts and database.types.ts stay .prettierignore'd).
- Fix a latent typecheck error the format gate was masking: the main-merge
  kept logRagQuery(row: Record<string, unknown>) while #174 tightened
  insertRagQuery to require RagQueryInsert (mandatory query). Align the
  signature to main's logRagQuery(row: RagQueryInsert).

Local: format:check, typecheck, lint (0 errors), and unit tests (863) all green.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@BigSimmo
BigSimmo deleted the claude/pr131-review-fixes branch July 2, 2026 16:31
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