Skip to content

Forms: publish complete WA MHA catalog for shared access#712

Merged
BigSimmo merged 4 commits into
mainfrom
codex/chat-forms-import-6914
Jul 17, 2026
Merged

Forms: publish complete WA MHA catalog for shared access#712
BigSimmo merged 4 commits into
mainfrom
codex/chat-forms-import-6914

Conversation

@BigSimmo

@BigSimmo BigSimmo commented Jul 17, 2026

Copy link
Copy Markdown
Owner

Summary

  • publish the complete imported WA Mental Health Act forms catalog and 51 official public PDF assets
  • make baseline forms and services automatically available to every user while preserving owner-specific overrides
  • wire the catalog through forms pages, registry APIs, universal search, navigation metadata, and supporting documentation
  • validate LOCAL_NO_AUTH_OWNER_ID as a UUID and document the local shared-content setup

Why

The forms experience previously depended on owner-scoped seed records and did not expose the imported WA MHA catalog consistently to all users. This change establishes an application-owned baseline catalog that is available immediately, with private user overrides remaining isolated.

Areas touched

  • forms catalog data and source PDF assets
  • forms UI and search integration
  • registry record APIs and shared baseline composition
  • environment validation and setup documentation
  • focused unit, route, logging, and UI coverage

Verification

  • focused forms tests: passed
  • registry route tests: 17/17 passed
  • registry/logging focused tests: 23/23 passed
  • TypeScript typecheck: passed
  • scoped lint: passed
  • git diff --check: passed
  • earlier broad Vitest run: 2,588 tests passed; one stale logging guard was then fixed and its focused rerun passed
  • post-main integration npm run verify:pr-local: not run because the repository heavyweight-test lock is held by another active Database worktree; hosted exact-head checks are required before merge

Clinical and production governance

  • source PDFs are the official public WA Office of the Chief Psychiatrist forms available at import time
  • Forms 4D and 4E were not publicly downloadable; Form 13 is represented as contact-only rather than fabricating a document
  • no OpenAI embedding/provider call is introduced or authorized by this PR
  • the live Supabase catalog seed was completed separately with 54 records and embeddings disabled; this PR does not perform a schema migration or live provider mutation
  • imported form content is reference material and remains subject to clinical/legal source review and future source refreshes

Known risks and follow-up

  • hosted CI is the final integrated verification gate because another worktree owns the local heavyweight lock
  • official form sources can change; the catalog records source metadata and should be periodically revalidated

Summary by CodeRabbit

  • New Features
    • Added a complete WA Mental Health Act 2014 forms catalogue dataset (including pathways, checklist groups, source snapshots, and downloadable PDF manifest/snapshots).
    • Updated form detail and search to be fully catalogue-driven (dynamic codes, decision-context steps, and official-source links).
  • Bug Fixes
    • Prevented authenticated reads from creating unintended private catalogue copies; registry reads now consistently merge shared defaults with owner overrides.
  • Documentation
    • Refreshed multi-user auth isolation guidance, sitemap entries, and review/ledger notes.
  • Tests
    • Expanded catalogue, registry API, and UI tests; updated mocks and added shared-read safety assertions.

BigSimmo added 2 commits July 17, 2026 18:48
Import the reviewed WA forms catalog and current public PDFs, wire the Forms UI and registry payloads, and make the shared Forms/Services baseline available without per-user seed writes. Preserve private owner overrides and governance.
…rt-6914

# Conflicts:
#	docs/branch-review-ledger.md
@supabase

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

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 2ecc72fc-3f2d-4925-9b1b-4a32f766d1bb

📥 Commits

Reviewing files that changed from the base of the PR and between dcb2468 and b05da82.

📒 Files selected for processing (6)
  • src/app/api/registry/records/[slug]/route.ts
  • src/components/forms/form-detail-page.tsx
  • src/components/forms/forms-home-page.tsx
  • src/lib/registry-seed.ts
  • tests/forms.test.ts
  • tests/registry-records-route.test.ts
🚧 Files skipped from review as they are similar to previous changes (5)
  • src/components/forms/forms-home-page.tsx
  • src/lib/registry-seed.ts
  • tests/registry-records-route.test.ts
  • tests/forms.test.ts
  • src/components/forms/form-detail-page.tsx

📝 Walkthrough

Walkthrough

The PR adds a complete Forms catalogue and PDF manifest, generates catalogue-backed records and search metadata, changes registry reads to merge shared defaults with private overrides without auto-seeding, and updates Forms UI, documentation, and tests.

Changes

Forms catalogue and shared registry

Layer / File(s) Summary
Forms catalogue data and asset manifests
data/forms-catalog.json, data/forms-page-snapshot.json, data/forms-pdf-manifest.json, .env.example, docs/site-map.md
Adds structured form workflows, pathways, checklists, source metadata, PDF manifests, UUID guidance, and expanded seeded form slugs.
Catalogue-to-record model
src/lib/form-catalog.ts, src/lib/forms.ts, src/lib/services.ts, src/lib/registry-records.ts, src/lib/env.ts
Generates ServiceRecord entries from catalogue data, expands search indexing, retains catalogPayload, and validates the local owner ID as a UUID.
Shared registry merge flow
src/lib/registry-seed.ts, src/app/api/registry/records/..., src/lib/universal-search.ts, docs/*
Reads private rows without seeding, merges shared defaults with owner overrides, preserves shared metadata, and serves shared detail records without private materialization.
Forms catalogue UI integration
src/components/forms/*
Uses catalogue details for form codes, pathway context, source availability, official links, and Forms page messaging.
Catalogue and registry validation
tests/forms.test.ts, tests/registry-records-route.test.ts, tests/ui-tools.spec.ts, tests/worker-safe-logging.test.ts
Validates catalogue coverage, PDF metadata, payload preservation, shared registry responses, UI route mocks, and seed-free registry reads.

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

Sequence Diagram(s)

sequenceDiagram
  participant FormsClient
  participant RegistryRecordsRoute
  participant RegistrySeed
  participant SharedFormRecords
  FormsClient->>RegistryRecordsRoute: request registry records
  RegistryRecordsRoute->>RegistrySeed: fetchOwnerRegistryRows
  RegistrySeed-->>RegistryRecordsRoute: private owner rows
  RegistryRecordsRoute->>RegistrySeed: mergeRegistryRecordsWithDefaults
  RegistrySeed->>SharedFormRecords: read shared defaults
  SharedFormRecords-->>RegistrySeed: shared catalogue records
  RegistrySeed-->>RegistryRecordsRoute: merged records and governance
  RegistryRecordsRoute-->>FormsClient: shared catalogue with owner overrides
Loading

Possibly related PRs

Suggested reviewers: claude

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 11.90% 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
Title check ✅ Passed The title clearly summarizes the main change: publishing the WA MHA catalog for shared access.
Description check ✅ Passed The description covers summary, rationale, touched areas, verification, and governance, though it uses custom wording instead of the exact template.
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.
✨ 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/chat-forms-import-6914

Comment @coderabbitai help to get the list of available commands.

@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

return registryResponse({
record: rowToServiceRecord(row),
governance: rowGovernance(row),
linkedDocuments,

P1 Badge Merge owner detail rows with shared defaults

For any authenticated user who already has a legacy seeded row for a baseline form (for example transport-crisis-form), this detail route returns that raw pre-catalogue row instead of the baseline-plus-override record used by the list and universal-search paths. Navigating from the new catalogue to such a form therefore drops the newly published official-source/PDF metadata and can display the old, less reliable legal guidance; merge this row with the matching default before returning it, while keeping its owner governance and linked documents.

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

@github-actions

Copy link
Copy Markdown

CI triage

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

  • Static PR checksneeds investigation.
  • Production UIneeds investigation: use the uploaded JUnit classification and trace; job type alone is not evidence of a known flake.
  • PR requiredneeds investigation: use the uploaded JUnit classification and trace; job type alone is not evidence of a known flake.

Heuristic only — a main-side or flake label is a starting point, not a verdict.

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

🧹 Nitpick comments (1)
src/lib/form-catalog.ts (1)

138-140: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

No-op transform in formSlug.

.replace(/attachment/g, "attachment") replaces the token with itself and does nothing — slugging already works via the subsequent [^a-z0-9]+ → "-" (e.g. "6b attachment"form-6b-attachment). Please confirm this wasn't meant to be a different transformation (e.g. special-casing attachments) and drop it if not.

♻️ Suggested cleanup
   return (
     legacySlugs[code] ??
     `form-${normalizeCode(code)
-      .replace(/attachment/g, "attachment")
       .replace(/[^a-z0-9]+/g, "-")}`
   );
🤖 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 `@src/lib/form-catalog.ts` around lines 138 - 140, Remove the no-op
replace(/attachment/g, "attachment") call from formSlug’s slug construction
after confirming no attachment-specific transformation is required; retain
normalizeCode and the subsequent non-alphanumeric replacement so values like “6b
attachment” still produce the expected slug.
🤖 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 `@src/components/forms/form-detail-page.tsx`:
- Around line 614-617: Update the source button in the form detail component to
be disabled whenever form.source?.url is absent, while preserving the existing
window.open behavior for available URLs. Ensure its accessible state reflects
the nullable source and the button no longer appears actionable for contact-only
forms.

In `@src/components/forms/forms-home-page.tsx`:
- Around line 128-129: Update the label near the “Official-source MHA 2014
forms” body to avoid claiming governance review is complete; use wording that
accurately indicates the forms are pending or subject to clinical/legal review,
while preserving the existing body text.

In `@src/lib/registry-seed.ts`:
- Around line 43-67: Update src/lib/registry-seed.ts lines 43-67 to merge owner
fields using raw row null semantics, ensuring only explicitly populated values
override baseline defaults rather than relying on rowToServiceRecord’s []
conversions; preserve catalogPayload merging. Update
src/app/api/registry/records/[slug]/route.ts lines 105-109 to merge an existing
owner row over the shared baseline record using the same logic instead of
returning the mapped owner record directly.

In `@tests/forms.test.ts`:
- Around line 1-2: Update the PDF validation logic around the test at lines
52–57 to read each stored PDF’s bytes, compute its SHA-256 digest, and compare
that digest with the declared localPdfSha256 value. Keep the existing existence,
checksum-format, and minimum-size checks, but ensure validation fails when the
file contents do not match the declared hash.

---

Nitpick comments:
In `@src/lib/form-catalog.ts`:
- Around line 138-140: Remove the no-op replace(/attachment/g, "attachment")
call from formSlug’s slug construction after confirming no attachment-specific
transformation is required; retain normalizeCode and the subsequent
non-alphanumeric replacement so values like “6b attachment” still produce the
expected slug.
🪄 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: 42d65178-7c1e-4387-83b0-0daf835b5020

📥 Commits

Reviewing files that changed from the base of the PR and between 2d1fd1b and 80594de.

⛔ Files ignored due to path filters (51)
  • public/forms-pdf/form-10a.pdf is excluded by !**/*.pdf
  • public/forms-pdf/form-10b.pdf is excluded by !**/*.pdf
  • public/forms-pdf/form-10c.pdf is excluded by !**/*.pdf
  • public/forms-pdf/form-10d.pdf is excluded by !**/*.pdf
  • public/forms-pdf/form-10e.pdf is excluded by !**/*.pdf
  • public/forms-pdf/form-10f.pdf is excluded by !**/*.pdf
  • public/forms-pdf/form-10g.pdf is excluded by !**/*.pdf
  • public/forms-pdf/form-10h.pdf is excluded by !**/*.pdf
  • public/forms-pdf/form-10i.pdf is excluded by !**/*.pdf
  • public/forms-pdf/form-11a.pdf is excluded by !**/*.pdf
  • public/forms-pdf/form-11b.pdf is excluded by !**/*.pdf
  • public/forms-pdf/form-11c.pdf is excluded by !**/*.pdf
  • public/forms-pdf/form-11d.pdf is excluded by !**/*.pdf
  • public/forms-pdf/form-11e.pdf is excluded by !**/*.pdf
  • public/forms-pdf/form-11f.pdf is excluded by !**/*.pdf
  • public/forms-pdf/form-11g.pdf is excluded by !**/*.pdf
  • public/forms-pdf/form-12a.pdf is excluded by !**/*.pdf
  • public/forms-pdf/form-12b.pdf is excluded by !**/*.pdf
  • public/forms-pdf/form-12c-attachment.pdf is excluded by !**/*.pdf
  • public/forms-pdf/form-12c.pdf is excluded by !**/*.pdf
  • public/forms-pdf/form-1a-attachment.pdf is excluded by !**/*.pdf
  • public/forms-pdf/form-1a.pdf is excluded by !**/*.pdf
  • public/forms-pdf/form-1b.pdf is excluded by !**/*.pdf
  • public/forms-pdf/form-2.pdf is excluded by !**/*.pdf
  • public/forms-pdf/form-3a.pdf is excluded by !**/*.pdf
  • public/forms-pdf/form-3b.pdf is excluded by !**/*.pdf
  • public/forms-pdf/form-3c.pdf is excluded by !**/*.pdf
  • public/forms-pdf/form-3d.pdf is excluded by !**/*.pdf
  • public/forms-pdf/form-3e.pdf is excluded by !**/*.pdf
  • public/forms-pdf/form-4a.pdf is excluded by !**/*.pdf
  • public/forms-pdf/form-4b.pdf is excluded by !**/*.pdf
  • public/forms-pdf/form-4c.pdf is excluded by !**/*.pdf
  • public/forms-pdf/form-5a.pdf is excluded by !**/*.pdf
  • public/forms-pdf/form-5b.pdf is excluded by !**/*.pdf
  • public/forms-pdf/form-5c.pdf is excluded by !**/*.pdf
  • public/forms-pdf/form-5d.pdf is excluded by !**/*.pdf
  • public/forms-pdf/form-5e.pdf is excluded by !**/*.pdf
  • public/forms-pdf/form-5f.pdf is excluded by !**/*.pdf
  • public/forms-pdf/form-6a.pdf is excluded by !**/*.pdf
  • public/forms-pdf/form-6b-attachment.pdf is excluded by !**/*.pdf
  • public/forms-pdf/form-6b.pdf is excluded by !**/*.pdf
  • public/forms-pdf/form-6c.pdf is excluded by !**/*.pdf
  • public/forms-pdf/form-6d.pdf is excluded by !**/*.pdf
  • public/forms-pdf/form-7a.pdf is excluded by !**/*.pdf
  • public/forms-pdf/form-7b.pdf is excluded by !**/*.pdf
  • public/forms-pdf/form-7c.pdf is excluded by !**/*.pdf
  • public/forms-pdf/form-7d.pdf is excluded by !**/*.pdf
  • public/forms-pdf/form-8a.pdf is excluded by !**/*.pdf
  • public/forms-pdf/form-8b.pdf is excluded by !**/*.pdf
  • public/forms-pdf/form-9a.pdf is excluded by !**/*.pdf
  • public/forms-pdf/form-9b.pdf is excluded by !**/*.pdf
📒 Files selected for processing (24)
  • .env.example
  • data/forms-catalog.json
  • data/forms-page-snapshot.json
  • data/forms-pdf-manifest.json
  • docs/branch-review-ledger.md
  • docs/codebase-index.md
  • docs/multi-user-auth-setup.md
  • docs/site-map.md
  • src/app/api/registry/records/[slug]/route.ts
  • src/app/api/registry/records/route.ts
  • src/components/forms/form-detail-page.tsx
  • src/components/forms/forms-home-page.tsx
  • src/components/forms/forms-search-results-page.tsx
  • src/lib/env.ts
  • src/lib/form-catalog.ts
  • src/lib/forms.ts
  • src/lib/registry-records.ts
  • src/lib/registry-seed.ts
  • src/lib/services.ts
  • src/lib/universal-search.ts
  • tests/forms.test.ts
  • tests/registry-records-route.test.ts
  • tests/ui-tools.spec.ts
  • tests/worker-safe-logging.test.ts

Comment thread src/components/forms/form-detail-page.tsx Outdated
Comment thread src/components/forms/forms-home-page.tsx Outdated
Comment thread src/lib/registry-seed.ts Outdated
Comment thread tests/forms.test.ts Outdated

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

ℹ️ 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/registry-seed.ts Outdated
@BigSimmo

Copy link
Copy Markdown
Owner Author

@codex resolve actionable Codex review findings for this pull request and current head using the repository instructions. This is the pull request's single automatic repair pass: do not perform a fresh review, create new standalone findings, or request another review. Work only the existing unresolved Codex threads on the current head. Always fix P0 and P1 findings. For P2 and lower findings, fix only clear, scoped, low-risk issues; otherwise disposition them with a concise reason. After fixing or dispositioning a thread, reply in that thread with as the first line, followed by a concise summary; that marker authorizes the workflow to close that exact thread. If human input or new authorization is required, do not use the marker and leave the thread open with the blocker. Finish only after every actionable thread is fixed or dispositioned and closed, or explicitly left open for a human decision. Do not update the branch from main, address unrelated reviews, broaden scope, or create more than one scoped fix commit. Do not use external APIs, paid services, credentials, dependency changes, or broad refactors unless explicitly authorized. Add targeted tests where behavior changes and run the narrowest relevant validation.

@BigSimmo
BigSimmo merged commit e0af860 into main Jul 17, 2026
42 checks passed
@BigSimmo
BigSimmo deleted the codex/chat-forms-import-6914 branch July 17, 2026 14:36
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