Repository navigation
feat(sources): a manifest source loaded by the FHIR server through $bulk-submit - #45
Open
Gordex2014 wants to merge 8 commits into
Open
Gordex2014 wants to merge 8 commits into
Gordex2014 wants to merge 8 commits into
Conversation
…e FHIR server
A new source type, manifest: POST /api/sources/{id}/manifests takes a FHIR
Bulk Data manifest by URL (forwarded unchanged) or uploaded (stored and
served at /bulk/{token}/manifest.json while its load is open), and hands it
to the FHIR server with $bulk-submit, one submission per send. The load is
recorded, unlisted, before the kick-off; a refusal comes back with the
server's status and body and leaves no load; a lost answer is kept as
unconfirmed and confirmed with $bulk-submit-status (and a status-only
kick-off when the final status lists no file). The source's runner polls
the status pages and settles each load from the receipts: counts by type,
deletions, failing outcomes grouped by their first error issue.
The definition is checked on what it holds and written in one canonical
form; the source is born without a rule, refuses Retry and the connection
test, and keeps no per-line rows. The outbound bulk_submit path is
unchanged.
…ter review
- A definite refusal is marked before it is answered and never becomes a
load; the runner removes what a failed removal left, and a replay of its
request_id is sent again.
- The kick-off runs in phases under one deadline from the admission: the
token in its own share (a failure is destination_auth), a dispatch claim
right before sending, a 10 s connect timeout (destination_unreachable),
and a refusal body that stalls is destination_answer_too_large.
- After a status-only kick-off answers 409 the status is read once more.
- Receipt read failures are counted per page, apart from failed polls; the
lease is renewed and ownership, pause and stop are checked between
requests, and no runner write lands while the source is paused.
- 501 from the status endpoints is terminal; status pages are capped and
checked; receipt files are read with an idle timeout.
- Checks count and list the loads listed by their cutoff.
- Token-endpoint failures are logged as a fixed sentence; secrets are
redacted from the 401/403 issue log before it is cut.
- Manifest traffic feeds the destination observer and the stamping read.
- delivery {} and null source members are refused; a manifest YAML is read
strictly; uploaded output URLs have no length cap.
- The source view's records are all zeros and its last_received_at is its
own; monitoring gains last_24h.by_source_type; a manifest never received
is kickoff not_received.
- A check's count and pages use one strict cutoff on when a manifest load was listed, taken under the lock a listing takes. - Monitoring's files, sent and failing come from the same read as by_source_type. - The kick-off deadline runs from when the load was recorded. - Receipt read failures are counted per receipt file. - A request_id replay that loses the listing race answers from the row. - Forgetting a refused token waits no longer than the kick-off deadline. - Kick-offs are observed by the destination as outbound requests are. - A manifest source's 24-hour and daily figures are its receipts only. - A store read error around the dispatch claim does not answer 500.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #42.
A new source type,
manifest: a user hands the engine a FHIR Bulk Data manifest, by URL or by uploading its JSON, and the engine passes it to the FHIR server with$bulk-submit. The FHIR server is the Data Consumer: it fetches the manifest and the NDJSON from the provider. The engine never downloads the NDJSON. It polls$bulk-submit-statusand records each manifest the server accepts as one load, from the server's receipts.What changes
The source (
src/config.rs,src/manager.rs).source: {type: manifest, poll_seconds?, oauth_metadata_url?}.transform, aformatother thanndjson, anydeliverybut{method: bulk_submit},expect_every, and aPUTthat changes the type to or frommanifest.PUTaccepts back as it is.silencerule.POST /api/sources/testanswers400 not_supported.Sending a manifest:
POST /api/sources/{id}/manifests(src/api/manifests.rs,src/manifest.rs).{"manifest_url"}or{"manifest", "file_name"?}, plus an optionalrequest_id. It is JSON only, at most 4 MiB, and needshie/manage.submissionIdishie-manifest-and a hash of the source, the load and a random token. The same URL or file sent twice loads twice.2xx→201with the load.4xxother than401/403/408, or501→ the FHIR server's status and body, byte for byte, withX-HIE-Refused-By: destination. No load is left.401/403, or a token the engine cannot get →502 destination_auth. Awarnlog keeps the status and each issue's severity, code and text, with URLs cut to their origin, secrets redacted and text cut to 500 characters.502 destination_unreachable.408, a5xxother than501, a3xx) →202with an unconfirmed load.{public_url}/bulk/{token}/manifest.jsonwhile its load is open, then404.request_idmakes a resend after a lost answer safe:200);409 request_id_conflict;409 request_in_progress.Recovery and polling (
src/pipeline/manifest.rs,src/db/manifest.rs).$bulk-submit-statusabout an unconfirmed load. A404counts only after a grace period.submissionStatus: in-progress, which changes nothing at HFS 0.2.8):409means it completed: the status is read once more, and the load is settled from it;200after the grace period meansunreadable, withmanifest.kickoff: "not_received".Retry-Afterand resume from the throttled page.501on the status endpoints, or a malformed status page, makes the loadunreadable.The load (
src/api.rs,src/api/loads.rs,src/db.rs).sent: the reference receipts.rejectedandfailing:OperationOutcomes with anerrororfatalissue.failuresare grouped by severity, code and reason.manifestmember on every load:null, or{by, request_id, submission_id, kickoff, sent_by_type, deleted}.409 not_retryable./stats, come from its receipts;GET /api/monitoring/statuslast_24hgainsby_source_type, whose members add up to the totals;direct_bulkand counts manifest submissions.Store. New columns on
files(manifest,request_id,listed,listed_at, receipt counts and groups),submissions(load_id, manifest-onlym_*statuses) andchecks(cutoff_at), plus indexes. They are added in place on SQLite and PostgreSQL, and an existing store reopens.Unchanged: the outbound
delivery.method: bulk_submitpath.src/bulk.rsis not touched. A409there is still a repeat of the same drop, andtests/bulk_submit.rsis untouched and passing.Docs.
docs/sources.mdhas a Manifest section: the definition and its canonical form, the two calls, the answers, lost answers and what recovery can prove, receipts, and the limits.docs/api.mdadds the route's table, themanifestload member,by_source_typeand the auth scope.docs/development.mdcovers building a local image (docker build -t hie:local .).README.mdandROADMAP.mdupdated.In plain words
A user can load a Bulk Data export through the engine instead of straight into the FHIR server. Each manifest they send shows up as a load with what the server wrote and what it refused. A manifest the server refuses comes back with the server's own answer, and leaves nothing behind.
Side effects checked
manifestmember on every load (nullfor other loads), andby_source_typein monitoring. No existing member changes meaning.listeddefaults to 1). Checks answered before this version keep unfiltered pages.docs/sources.md:not_received.724baba,743905f), checked by the gate, double runs, PostgreSQL and the end-to-end run below:by_source_type;request_idreplay race re-reads the row;How to verify
The CI commands, with
CI=trueand default parallelism, on this tree (Linux):tests/manifest_source.rs: 31 tests, run twice on SQLite and once against a throwaway PostgreSQL 16. All passed.tests/bulk_submit.rs: 14 tests, run twice. All passed.ghcr.io/heliossoftware/hfs:0.2.8, with a static provider serving a 2-Patient manifest (as in hfsdocker/bulk-submit/provider) and the engine image built from this branch. Nine scenarios passed:404after);HFS_BULK_SUBMIT_ENABLED=false(501, same body andContent-Type,X-HIE-Refused-By, no load);test/Retry/records refusals;by_source_typesums;request_idreplay and conflict.To try it locally:
Links
manifestsource (a FHIR Bulk Data manifest, by URL or uploaded, loaded by the FHIR server through$bulk-submit) #42 (the API contract)$bulk-submit(Data Consumer):crates/rest/src/handlers/bulk_submit.rsatv0.2.8