Skip to content

Generate Loom FHIR code from pinned R5 definitions - #214

Merged
matthewpeterkort merged 5 commits into
mainfrom
fhir/own-generation
Nov 18, 2026
Merged

matthewpeterkort merged 5 commits into
mainfrom
fhir/own-generation

Conversation

@matthewpeterkort

@matthewpeterkort matthewpeterkort commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Why

Keep Loom’s fast generated FHIR ingest path and use official HL7 R5 assets as the source for resource definitions and reference targets.

Changes

  • Check in the official R5 JSON Schema and 61 upstream StructureDefinitions. Normal generation reads the files offline.
  • Remove edge-policy.json, graph-fhir.json, the generic loader, and both BMEG schema modules. OpenAPI retains its independent indirect JSON Schema dependency.
  • Generate forward edges from official reference paths and target types. Generate direct checks for the pinned primitive patterns.
  • Remove --schema and server.schema. New publications record the source digest. Existing publications retain their schema identity. Cross-schema partial updates require a full reload.

Verification

  • Offline regeneration matched the checked-in generated Go files.
  • Go tests, comment lint, compiler conformance, and isolated locked-cohort Docker and Chrome acceptance passed.
  • Five alternating single-core runs on 48,000 accepted records measured 7.67 µs per record with direct checks versus 16.70 µs with regex checks for the same official patterns. Both variants emitted 96,557 edges with matching document digests.
  • The full 70,000-record fixture exposed two upstream data issues. The new schema rejects 20,000 DocumentReferences with numeric Attachment.size and 2,000 ImagingStudies with whitespace in Coding.system.

Remove the BMEG schema modules and generic ingestion fallback. Generate
the model, validators, extractors, and compiler metadata from the pinned
HL7 R5 package and Loom-owned edge and validation rules. Preserve the
configured resource allowlist and existing publication schema identity.

Verified generation is reproducible. The generated model, validators,
and edge extractors match main byte for byte. Across 70,000 META_SMALL
records, accept/reject counts and canonical edge document digests match.
The Go suite, Go comment lint, and isolated locked-cohort Docker and
Chrome acceptance passed. Acceptance run f39518fab9172bd5 was cleaned up.

Same-model adversarial reviews covered runtime schema membership,
publication and uploads, and generator metadata. Regression tests cover
the local and absolute JSON Pointer references and nested anyOf rules
found in review. The repeated-reference metadata fix passed the existing
Explorer negative test and an independent regeneration.

Reviewed runtime diff SHA-256:
bbf96193e229bb18630dde707901c52469997564056e43171e86aed9f70db6a4
Reviewed generated metadata SHA-256:
3bf5a764c523a323af0b91f10595d96c343349aae789712e92eed5c819055adf
Check in the official JSON Schema and selected StructureDefinitions. Derive
supported models and forward reference edges from those files. Remove the
legacy graph schema, compatibility snapshot, and runtime schema settings.

Compile the pinned primitive patterns into direct lexical checks. Five
single-core runs over 48,000 shared accepted records measured 7.67 us per
record median for direct checks versus 16.70 us for regex checks. Both
variants emitted 96,557 edges and matched canonical edge digests. The full
70,000-record fixture rejects 20,000 DocumentReferences with numeric
Attachment.size and 2,000 ImagingStudies with whitespace in Coding.system.

New publications record the official input digest. Cross-schema partial
updates require a reload so old edges cannot be copied into a new generation.

Validated with the Go suite, direct pattern tests, compiler conformance,
Go comment lint, and isolated Docker and Chrome acceptance run
6e428a0ee3da3756. Same-model adversarial review covered primitive pattern
equivalence, FHIR edges and metadata, and schema identity migration.
Final metadata SHA-256:
485fbfd84469f7777414eed51ece8f41687458bc054f3bcf16b2af1711fc8156
Check calendar dates, base64 content, and signed integer64 strings. Normalize legacy numeric integer64 values at ingest while preserving strict Coding.system validation and the conforming decode path.

Verification: generator, model, FHIR schema, and ingest tests; Go comment lint; read-only primitive and compatibility reviews.
Update Sonic to v1.15.3 and its loader to v0.5.2 for native Go 1.27 support. Keep the existing error coverage under Go 1.27 vet and apply the new gofmt indentation.

Verification: root and client Go suites passed on Go 1.27.4, including formatting and vet gates. Native Sonic decode verified on Darwin arm64.
Go 1.27 changes the DEFLATE output embedded by oapi-codegen. Verified both blobs decode to identical OpenAPI JSON. FHIR and OpenAPI regeneration, route ownership checks, and API tests pass.
@matthewpeterkort
matthewpeterkort merged commit c90ccc2 into main Nov 18, 2026
11 checks passed
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