feat(eligibility): API-first 270/271 eligibility waterfall (Stedi client, payer route map, document-hash verified artifacts)#147
Conversation
|
Holding this PR in draft after independent review. The API-first eligibility thesis is sound, but this exact implementation is a contract spike rather than a safe production fulfillment path. Before it can return to ready:
Current CI is green and the code appears MIT-compatible; the hold is about silent-wrong-answer, PHI, effect-verification, and fulfillment completeness—not general code quality. |
|
Status refresh (2026-07-19): the MIT-only release boundary is restored, so the remaining hold is the production contract described above. This stays a useful API-first spike but not a merge candidate until exact payer routing, benefit/time/network interpretation, error taxonomy, atomic normalized/raw artifacts, PHI retention/egress, and >=3 effect-oracled integration trials are implemented on current released main. The staff-first attended path and UI execution layer remain the launch critical path; this PR should integrate with them if resumed, not become a parallel fulfillment runtime. |
b21725c to
1b597dd
Compare
…ent, payer route map, document-hash verified artifacts) The API tier of the dental eligibility offer: where a payer exposes a sanctioned real-time 270/271 route through a clearinghouse API, the check hits that route first and compiled portal replay becomes the fallback. - eligibility/client.py: StediEligibilityClient against Stedi's documented JSON endpoint (Authorization: Key header, tradingPartnerServiceId / subscriber / encounter.serviceTypeCodes request, benefitsInformation + AAA-error response). Normalized EligibilityResult with the raw 271 retained byte-exact plus its SHA-256 wire digest. parse_271 fails CLOSED: malformed or signal-free responses are indeterminate, never a guessed benefits answer. Secret-isolated auth per the effect kit convention (env-var references only; construction fails loud). - eligibility/waterfall.py + payer_routes.yaml: the committed per-payer capability map (payer -> api | portal | excluded) and the resolver the fulfillment loop calls, so route choice is reviewed data, not code. Six confirmed dental payers route api-first; Availity is excluded + portal_banned with the sanctioned-API conversion path documented; unknown payers default to portal. Fallback rule is explicit: a 270 is an idempotent READ so no-answer API attempts fall through safely (the opposite of ApiActuator's write-path HALT), except banned portals which land in the practice queue. - eligibility/artifact.py: results land in the same practice-local artifact set as portal replay (eligibility_results.csv row + byte-exact 271_<digest16>.json) and are certified by the document-hash verifier (record_written + sha256 field_equals against the wire digest) -- effect verification is source-agnostic. - docs/ELIGIBILITY_API_WATERFALL.md: honest proof labels (contract-proven vs live-proven), practice-held account / click-through BAA model, per-check cost, activation steps, backup clearinghouse. Contract-proven against faithful fakes of Stedi's documented shapes (including their published dental mock catalog); an env-gated live smoke test (STEDI_API_KEY, test mode, mock checks are free) graduates the mocked path to live-proven. Purely additive: no existing file modified, no new dependencies (httpx and PyYAML are already core), nothing on the replay hot path. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2f77c90 to
69460be
Compare
|
Re-audited exact head
Local verification: |
What
Adds the public mechanism for a sanctioned API-first 270/271 eligibility path beneath OpenAdapt's governed execution layer:
AuthorizationAPI-key contract;STEDI_API_KEY.This remains a component of the existing staff-first attended flow, not a second fulfillment runtime.
Independent safety repairs through
dd07fa2Exact-head audit and adversarial repair closed the false-success and evidence-boundary paths in the original spike:
EligibilityResult.is_answerrequires an actual application mode plus the exact raw bytes/digest, so a constructed or deserialized raw-less result cannot complete the waterfall;PracticeArtifactPolicyrequires TEST or PRODUCTION mode. The mode and exact retention interval are bound intoboundary.json, manifest, normalized JSON, and CSV; malformed or policy-mismatched expiry denies consumption/purge;committed_atis writer-derived; caller-mutated observation timestamps are not stored as audit truth;The committed registry is synthetic mechanism data only; production route recipes remain practice-scoped deployment data.
Evidence
101 passed, 3 skippedacross the eligibility client, routing, artifact, waterfall, and env-gated live-test modules. The skips explicitly report that no live evidence was collected without a Stedi test key.130 passedacross the final eligibility and release-contract gate set.1.19.0wheel and sdist build passes the archive license/source/private-corpus boundary validator; the wheel import exposes the retention-purge API.Merge safety versus deployment activation
This draft adds a dormant, lazily imported mechanism and does not activate a provider integration. Production activation remains fail-closed and requires the private reviewed practice/account/payer registry, attended-queue and system-of-record integration, and at least three live Stedi TEST-mode trials under the deployment's reviewed BAA and PHI controls. Those live trials have not been collected in this PR.
Primary provider references: