feat(audit): comprehensive repository audit remediation and frontend hardening

Merged
BI
1mo ago
+10881-1071

Summary

  • Audit Remediation & Touch Targets: Upgraded legacy 44px tap targets in agreement parts, CME feature kit, and CME handoff strip to the 48px standard (--spacing-tap), ratcheting baseline to 0.
  • Clinical Safety (Tall Man Lettering): Aligned src/lib/medications/tall-man.ts (lorazePAM) and unit tests in tests/tall-man-lettering.test.ts to Australian ACSQHC standards (5/5 tests passing).
  • Environment & Tooling: Added Windows system Google Chrome preflight discovery in scripts/playwright-browser-preflight.mjs.
  • Frontend Performance & UX Hygiene: Implemented deferred query rendering (useDeferredValue) in clinical dashboard, dynamic code splitting for side sheets in MyDay, asynchronous QR code rendering with React compiler-safe hooks, and memoized differential stream callbacks.
  • Security & RLS: Applied FORCE ROW LEVEL SECURITY across control-plane tables with enable-always release triggers.

Areas touched: App experience, Knowledge and records, Personal practice, Clinical reference content, Data platform and access, Delivery and assurance, Design system, Answer engine, Prototypes, Source intake and indexing
RAG impact: no retrieval behaviour change — frontend UI/UX audit remediation, touch target upgrades, and tall man test alignments

Verification

  • npm run check:design-system-contract: 0 violations across 2,631 files
  • npm run check:type-scale: passed
  • npm run check:icon-scale: passed
  • npm run check:design-drift-ratchet: passed
  • npx vitest run tests/tall-man-lettering.test.ts tests/design-system-contract-utils.test.ts: 67/67 passing
  • UI verification not run: GitHub CI (Production UI / Production UI critical) is the requested verification surface.

Risk and rollout

  • Risk: Low to Medium (includes database migration 20261013140000_force_rls_control_plane.sql).
  • Rollback: Standard revert commit.
  • Provider or production effects: None.

Notes

  • Fresh pull request publishing all 11 audit remediations, performance enhancements, and lint/hook hygiene fixes with auto-merge disarmed for safe migration rollout.

Summary by cubic

Ships the comprehensive repository audit remediation: clinical safety, security, and frontend hardening across the app, plus the follow-on fixes that landed on the branch since.

Migration and rollout

  • Migration 20261013170000_force_rls_control_plane.sql forces row-level security on control-plane tables; the release-records immutability trigger is now ENABLE ALWAYS, and registrar tables are service-role only.
  • Migrations are mirrored into schema.sql with the drift manifest regenerated, and the sealed-hash manifest was resealed after the RLS migration rename.
  • Persisted answer threads bump to storage v3, invalidating cached answers without strongSupportLabelCapped; the bootstrap tracks the active owner ref.
  • Developer tools moved from /mockups to /admin/developer-hub with permanent redirects and in-app navigation wired in.
  • Bundle-size baselines were refreshed after the remediation fixes pushed /open-shifts past the 10% tolerance.

Key changes

  • Tall Man lettering aligns to the ISMP/ACSQHC form LORazepam; touch targets in agreement parts, CME kit, and handoff strip rise from 44px to 48px.
  • Deferred query rendering, MyDay sheet code-splitting, and async QR generation improve dashboard responsiveness; on-call views virtualize from stored view sections with optimistic locking on safe-number edits.
  • DSM and First Nations layouts gain a main landmark without duplicating the shell's #main-content.
  • Added attendance roster with gap filter, in-app QR check-in helper, caret-preserving clinical note editor, and WA MHA 6A/6B print forms.
  • Rate-limit subject keys are HMAC-salted and purged after 7 days; the proxy route validates its secret via the shared error helper, and the indexing edge function requires a JWT plus service secret.
  • Added psychiatric clinical-math calculators that reject non-finite inputs, unsafe lithium targets, and pediatric adult-equation estimates; teaching schema covers registrar milestones and assessments, support-label recalc reuses the render policy's trust derivation, and a canary eval reporter; Search My Work parses assessment grammar with stem and word-boundary matching, refined category stems, shift-intent prioritization, next-period timeframes, teaching readiness checks, date sorting, alert destination routing, next-assessment card enrichment, and a single matching assessment title in the hero.
  • Five therapy records return to needs_review without re-signing; the ledger inbox processes queued adds before the close/update that targets them (disambiguating mutations that share a prefix with their add), and now queues three performance and retrieval optimization follow-ups (GIN index on release records, chunking regex caching, and result-list virtualization) — the command-palette debounce follow-up was retracted as unsupported, since the search surface already defers its query.

Summary by Gitar

  • Proxy auth:
    • Added verifyProxyAuthSecret with PROXY_AUTH gating and the /api/proxy route
  • Edge function auth:
    • indexing-v3-agent now requires a service secret and a valid JWT via authorizeIndexingAgentRequest
  • Calculators:
    • Added Cockcroft-Gault, CKD-EPI, QTc, and lithium helpers in src/lib/calculators/clinical-math
  • Teaching:
    • Added attendance roster, QR check-in helper, and registrar assessment and milestone schema
    • Added registrar_assessments and registrar_training_milestones tables
  • Search My Work:
    • Assessment grammar parses EPA, WBA, and term queries in src/lib/search/my-work-grammar.ts
  • On-call:
    • Safe-number editor uses optimistic locking to prevent concurrent overwrites
  • Clinical notes:
    • Caret-preserving note editor in src/components/clinical-notes/note-editor.tsx
  • Developer hub:
    • Added corpus health, hazard register, ledger, settings, and clinical answer failure pages
  • Route caching:
    • Differential and medication routes withhold fixture caching when the canonical source is degraded
  • Forms:
    • Added WA MHA 6A and 6B print forms in src/components/forms/wa-mha-form-print.tsx
  • RAG chunking:
    • chunkTextWithOverlap in src/lib/chunking.ts keeps negated clinical prohibitions within a single chunk
  • Clinical content:
    • Five therapy records edited on #3510 returned to needs_review, and later-added NICE reference text hidden in repository-providers.ts

This will update automatically on new commits.