Writing a Partner Crate

A partner crate is the code for one outside system: how CRAIG speaks to it and what its answers mean. It is written against a specification the product owns (ADR-089), so that the exchange service can run any partner without knowing it. The specification has three parts:

  • The contracts: traits and types in craig-exchange-contracts.

  • The partner set: the one value craig-exchange boots on (craig-state-bundle’s `PartnerSet), which the module host builds from a jurisdiction’s partner-set module.

  • The conformance kit: checks a partner crate runs against itself (craig-partner-test-harness).

A partner crate depends on the specification’s crates (craig-exchange-contracts, craig-exchange-transport, craig-partner-sdk, craig-state-bundle, craig-validation) and on no other part of CRAIG.

A jurisdiction’s partner code is not in this repository (ADR-090): its partner crates are built into WebAssembly modules that live in its configuration layer. Partner modules below says what a module is, what it may touch, and how it is built and checked. craig-exchange loads a layer’s partner set at boot, and the mock server its simulators. No build compiles a partner in.

The exchange service runs whatever its layer’s partner set registers: it holds no leg, record, acknowledgement, collection or inquiry of its own, links no partner crate, and names no partner in its source. Georgia’s partners are written this way and live in Georgia’s configuration repository (craig-config-georgia, partners/src): its eleven partner crates, the crate that exports them as a partner set and the one that exports their mocks, with the two built modules committed beside them. The one partner crate in this repository is the reference partner. The plan that delivered the specification is archived: the partner specification.

The reference partner

crates/craig-partner-testonia-registry is the specification’s own implementation: the resident registry of Testonia, the fixture jurisdiction, under the adapter kind testonia_registry. It is nobody’s partner and holds no real jurisdiction’s rules. Read a new partner crate against it:

File What it shows

src/types.rs

The wire: one record type and one acknowledgement type, with length caps.

src/error.rs

The error enum, stamped by partner_error!.

src/adapter.rs

The manual-send adapter over the shared HTTP-JSON core.

src/legs.rs

Thirteen triggered-send legs that between them declare every shape a leg can take.

src/collection.rs

The school roll: a collection that reports each attributed pupil’s school.

src/inquiry.rs

The benefit desk: the SSA benefit inquiry, non-authoritative by construction.

src/index.rs

The registry as a person index: find, register and participate.

src/mock.rs

A closed-world simulator, behind the mock feature; src/mock/index.rs is its person index.

src/lib.rs

partner_set(): what the crate registers.

tests/kit/round_trip.rs

The kit’s manual-send checks.

tests/kit/conformance.rs

The kit’s leg, simulator and set checks.

tests/kit/native.rs

The subject of those checks: the crate itself. tests/round_trip.rs and tests/conformance.rs run the two files on it.

tests/kit/modules.rs

The other subject: the crate built into modules and loaded by craig-partner-host. tests/as_modules.rs runs the same two files on it (Partner modules).

tests/parse_never_panics.rs

The property tests of the acknowledgement’s parse and of the index’s answers'.

No service or tool links the reference partner. It is a development dependency wherever it is used. The dispatch host’s own unit tests drive its legs, each by name (RegistryLeg::STAGE_OPENED and its twelve siblings). Its rules are small on purpose, and a residence entry reports the stay’s dates and status as the stage view held them, so that what such a test observes on the wire is the host’s doing.

The manual send

An adapter implements ExchangeAdapter: a typed Outbound, a typed Inbound and an Error, with send and test_connectivity. impl_erased_adapter! generates the object-safe form the exchange service’s registry holds, under the adapter’s kind token. The kind token is open snake_case text; it is stored on partner rows and transactions, so it never changes once used.

The shared plumbing is JsonAdapterCore (the health probe, the JSON POST, the transport-error mapping). Every call goes through the service-wide OutboundTransport, never a client of the crate’s own.

Every string field of a wire type carries a length cap (cargo xtask lints dto-length), and the erased seam validates an outbound record before it is sent.

The failure view

A partner’s error type never leaves its crate, but the exchange service has to tell a timeout from a refusal. So every adapter and collection error implements PartnerFailureView:

  • failure() reduces the error to one of four meanings: Transport, Timeout, Malformed, or BadStatus with the status and the bounded body.

  • digests_body() says whether a refused body may contribute a short digest to the failure the service stores. Answer false when the partner’s bodies can echo an identifier: the digest is unsalted and would give the value away by enumeration.

partner_error! stamps the usual five-variant enum with the view. Its body_digest = keep | omit argument is required and has no default.

A triggered-send leg

A leg turns one kind of domain event into one partner record per person. It implements TriggerLeg (craig_exchange_contracts::trigger): a LegSpec, which is data, and three pure rules.

LegSpec field Meaning

interface, leg

The stored tokens: the adapter’s kind and the leg’s name within it.

entity

What an admission keys on: a case, an investigation, a report, a custody episode or a person identifier.

stage

Which entity plays the stage the leg acts on: a case, an investigation or a custody episode.

rule

What the leg’s resolve does: AdmitNew, CloseExisting, RetireSubject, RemoveAndSend or ResendClose.

opens_stage

The leg a catch-up walk raises for an open stage. At most one per interface and stage kind.

discriminator

For an event that announces several kinds of change, the one value the leg follows.

scope

Stage, or Person when the partner keeps one listing per person across that person’s stages.

reentry_gated, settles_listing

The two gates that order a person’s listings. Person-scoped legs only.

The three rules:

  • admits(stage, principal, today): whether the leg admits this person to the partner’s listing. It fails closed: a person whose record cannot show that they qualify is not admitted. A leg whose rule admits nobody answers false.

  • assemble(ctx): the record for one admitted person. It is a pure function of its RecordContext, so a retried job sends the same bytes. The correlation goes into the record’s own identity field. A leg refuses (AssemblyRefusal) rather than guess a required value.

  • classify_ack(sent, response): what the partner’s answer meant. Accepted only when the answer identifies the record that was sent; otherwise Rejected (with the partner’s code), Mismatch or Malformed. The body kept with Accepted is an allow-list: nothing the service must not store.

A leg reads the stage and its people through the specification’s own view types (StageView, PrincipalView), not through another service’s wire. A person’s identifier arrives as an IdentifierView with its kind; its Debug prints no value, and a leg puts the value in the record and nowhere else.

LegSpec::fault() names a spec whose fields contradict each other: an entity that reaches another kind of stage, an opening leg that is not an admission keyed on its stage, or a listing gate on a stage-scoped leg.

The events a leg may be bound to

A jurisdiction’s trigger matrix (bundle/outbound_triggers.toml) binds an event to a leg. How an event identifies its occurrence is the product’s knowledge, held once in the exchange service’s event catalogue (services/craig-exchange/src/triggers/events.rs); a leg never reads a payload. The leg’s entity must be the entity its event names, and a leg that declares a discriminator must be bound to an event that announces kinds.

Event Entity it names Subject Revision Kinds

case.created, case.closed

case

none

once

none

case.screening_cohort_changed

case

none

the cohort revision

change

case.intake_created, case.investigation_closed

investigation

none

once

none

case.report_person_linked, case.report_person_unlinked

report

the person

the link’s id

none

case.custody_opened, case.custody_closed, case.custody_retracted

custody episode

the child

once

none

case.custody_close_corrected

custody episode

the child

the correcting act’s id

none

case.person_identifier_recorded, case.person_identifier_ended

person identifier

the person

once

kind

case.medicaid_application_submitted

Medicaid application

the child

once

none

An event that happens once per entity collapses a re-emission onto its first admission. A row that binds a leg to an event outside the catalogue, or to one that names another entity than the leg keys on, refuses boot (What boot checks); a delivery that reaches admission that way regardless dead-letters by name. An event of another kind than the leg follows is simply not an occurrence of the leg.

One listing per person

A partner that keeps one listing per person across that person’s stages (a custody list, say) declares scope: Person. The exchange service then orders the person’s records, holds each resolve under the person’s lock, and reads a closing or a removal under the identifier the listing was pinned to. Two more facts order the listings themselves:

  • reentry_gated: a newer listing of the same person supersedes an occurrence of this leg, which is dismissed.

  • settles_listing: the leg ends a listing. An opening of a later listing waits while an earlier one has not been settled.

The mechanism is the service’s (triggers/listing_passes.rs) and reads only the spec.

A collection

A collection is a leg in which the product fetches what a partner published, and turns it into the product’s own records (craig_exchange_contracts::collection). A partner crate implements CollectionAdapter:

  • interface() and leg(): the adapter-kind token of the partner row that holds the endpoint, and the collection’s name among the interface’s legs. A run’s transaction is stored under <interface>.<leg>.

  • collect(endpoint, auth): a Collected, which is the reports the document held (PartnerReport, today Education) and a count of the records that name nobody the product can identify. A document that does not exist yet is an empty Collected, not an error. A document that cannot be fetched or read is the crate’s error, with its failure view, and nothing of it is answered.

The crate attributes a record to a person only by an id the product gave the partner and the partner echoed; it never guesses from a name. The service admits a report only for a person it currently lists with that interface, posts each admitted report to the service that owns the fact, and stores none of the reported values itself. Georgia’s is the education agency’s weekly student file (in its layer’s craig-partner-doe-slds); the reference partner’s is its school roll.

An inquiry

An inquiry is a question the product asks an outside source about one person, and the source’s answer, both in the product’s words (craig_exchange_contracts::inquiry). A partner crate implements Inquiry<Q, A> for the source a jurisdiction has a contract with:

  • interface(): the adapter-kind token of the partner row that holds the source’s endpoint.

  • authority(): Authoritative, NonAuthoritative, or None when no contract with the source exists. With None nothing may be sent and the service holds every question. A crate answers from what it was built with, never from configuration: activating a source is a change to the crate’s registration.

  • ask(endpoint, auth, question): the answer, or an InquiryFailure. The failure is a closed set that carries nothing the source said; its token() is the class the service stores on the job. A crate decides identifier-unusable itself, before anything is sent.

The first pair is the SSA benefit screening: SsaBenefitQuestion (the released identifier, held as a secret, and the request date) and SsaBenefitAnswer (Found with the month and the benefits, or NoRecord). The service keeps the screening’s pipeline (runs, members, jobs, the lease, the call that records the outcome) and asks the one inquiry its partner set registers, under its own send deadline. Georgia’s is Gateway’s income inquiry (in its layer’s craig-partner-gateway-income), registered with no send authority. The reference partner’s benefit desk is non-authoritative by construction, so its answers exercise the path and are never recorded as fact.

A person index

A person index is a jurisdiction’s register of people across agencies, and the product holds one conversation with it, in the product’s words (craig_exchange_contracts::person_index). A partner crate implements PersonIndex for the index its jurisdiction has an agreement with:

  • interface(): the adapter-kind token of the partner row that holds the index’s endpoint.

  • find(endpoint, auth, subject): the people the index offers as possible matches for an IndexSubject, best first. The subject is a first name, a last name, a sex and, when known, a date of birth; a find sends nothing else (the_subject_carries_name_sex_and_birth_date_only). Each IndexCandidate carries the index’s id for the person (an IndexId: 1 to 64 printable ASCII bytes), a score from 0 to 100, and what a worker is shown to choose by: names, date of birth, sex, the last four digits of the SSN and one line of residence. An index that knows nobody like the subject answers an empty list, which is an answer and not a failure.

  • register(endpoint, auth, registration): creates the person and answers the id the index gave them. After any failure the caller does not know whether the person exists, and finds out by asking again; so a registered person must be found from then on.

  • participate(endpoint, auth, participation): tells the index the product now holds a person it knows. An id the index does not know is Refused.

Each call fails with an InquiryFailure, as an inquiry does. An index has no authority(): it is gated as a send is, by an active partner row, an agreement that admits it and the deployment’s consent.

person_index::admitted holds a find’s answer to the contract’s bounds: at most 250 candidates, each text within its cap, a score of at most 100, and SSN digits that are exactly four digits. An answer that breaks one is Malformed as a whole (no_candidate_exceeds_its_caps). The module host passes every module’s answer through it, and the kit passes a crate’s own.

No Debug of these types prints what describes a person (a name, a date of birth, a sex, an id an index gave, SSN digits, a residence): a candidate’s shows its score and a participation’s the product’s own person id, and nothing else (no_debug_prints_a_persons_value).

The reference partner’s is the registry itself (src/index.rs): its id for a person is their Testonia identifier. Its simulator offers the residents and the people it enrolled whose names, and date of birth when asked, are the subject’s. How well a resident is said to match is their standing, which a test sets through PUT _sim/residents/{person_id}/standing (known is a full match, near 95, weak 60), so a test can meet every kind of answer a worker’s choices depend on.

A referral leg

A referral is a triggered send of one record for one application, with one thing a plain triggered send lacks: the partner’s answer carries the partner’s own reference for the application, and the product keeps it (craig_exchange_contracts::referral, ADR-091). A partner crate implements ReferralLeg:

  • interface() and leg(): the adapter-kind token and the leg’s name. The pair is stored as a triggered-send leg’s is, so the two kinds share one namespace within a set.

  • assemble(ctx): the referral record as the adapter’s JSON payload, a pure function of a ReferralContext. The context is the application (ApplicationView: its id, the day it was submitted, the citizenship-status and prior-medical-assistance tokens and the legal administrative unit), the child as a PrincipalView whose identifier is the one the jurisdiction’s configuration names for an application, the custody episode as a CustodyView, the case number and the correlation id. A child the partner could not key is refused.

  • classify(sent, response): a ReferralVerdict. Accepted carries a ReferralReceipt, the partner’s reference: 1 to 64 printable ASCII bytes, none a space, whose Debug prints nothing of it. Rejected, Mismatch and Malformed mean what they mean for a leg; an acceptance with no reference a receipt can hold is Malformed.

A referral leg declares nothing else. What a triggered-send leg states about itself (what its admission keys on, which stage it acts on, by which rule) is the same for every referral, so the dispatch host fixes it (services/craig-exchange/src/triggers/referral.rs): the admission keys on the application, the application is the stage, the leg admits anew and is the one that opens its stage. The host runs the leg as a triggered send:

  • A row of the trigger matrix binds case.medicaid_application_submitted to the leg’s <interface>.<leg>, and the interface’s send consent (CRAIG_EXCHANGETRIGGERS<INTERFACE>__ENABLED) admits it, as for any leg. An interface whose only send is a referral may be consented.

  • The child of a submitted application is admitted when the child carries a live identifier of the kind the jurisdiction names for an application. A retracted application admits nobody (a_retracted_application_is_not_referred), and one retracted after it was admitted is not sent.

  • The operator’s catch-up walk, with kind = medicaid_application, refers the submitted applications that hold no receipt (the_catch_up_walk_refers_a_submitted_application_no_event_admitted).

  • On an accepted answer the host posts the receipt to craig-cases, which owns the application, before the record settles, and stores a marker as the transaction’s response ({"receipt":"applied"}, or "withdrawn" when the application was retracted in the meantime), never the reference. A receipt that could not be handed over leaves the record to be sent again under the same correlation id, as the class receipt-unapplied (a_receipt_that_was_not_applied_is_sent_again_under_one_identity). A partner must therefore answer a repeated correlation id with the reference it gave first. When craig-cases already holds another reference for the application, the record ends under receipt-conflict and is not sent again (a_second_reference_for_one_application_ends_the_referral).

The reference partner’s is src/referral.rs: one more entry on the registry’s wire, with the notice referred and the application’s facts, answered with the reference of the registry’s assistance desk.

A return

A return is the leg in which the partner starts the conversation: it calls CRAIG and says what became of something CRAIG sent it (craig_exchange_contracts::returns, ADR-091). The dispatch host owns the listener, who the caller is, the agreement and the consent, and handing each record to the service that owns the fact. A partner crate implements ReturnLeg, whose rules read and write and reach nobody:

  • interface() and leg(): the adapter-kind token and the leg’s name. A partner calls the leg by that pair.

  • max_bytes(): the largest body the leg reads. A longer one is TooLarge.

  • decode(content_type, body): a Collected, the product records the call holds (PartnerReport, here MedicaidReferral) and a count of the records the leg could not read. A body that is not the partner’s document is Malformed, and nothing of it is answered. A record the leg cannot read (a status outside the partner’s vocabulary, say) is counted and the rest are answered.

  • acknowledge(run): the answer the partner gets, as an HTTP status, a content type and a body in the partner’s own wire. A ReturnRun is either Completed, with each report beside what became of it (ReportOutcome: applied, replayed, unknown, withdrawn or failed) and the unread count, or Refused with a ReturnRefusal (Malformed, TooLarge, or Busy, which only the host says). A leg is called afresh for the acknowledgement and holds nothing of the body, which is why the reports come back to it.

A MedicaidReferralReport names no person of CRAIG’s. It carries the kind and value of the identifier the partner keys the person on, the partner’s reference for the application, and, where the partner states them, its case, the id its program gave the person, a ReferralStatus (pending, approved, denied, closed) and a date. Each text is 1 to 64 printable ASCII bytes, none a space (is_report_text); its Debug prints none of the four texts the partner reported. PartnerReport::subject() says how a report names its subject: Person(id) for a report that echoes CRAIG’s id, Reference for this one. A collection run admits by the people it listed, so it counts a Reference report with the records it cannot attribute.

returns::admitted holds what a leg decoded to the contract’s bounds: at most 500 reports a call, each within its caps. A call that breaks one is refused whole (no_report_field_exceeds_its_cap). The module host passes every module’s decode through it.

The reference partner’s is src/outcomes.rs: a JSON document of the assistance desk’s outcomes, answered with each outcome’s result under its reference.

How the host runs a return

craig-exchange serves returns on a listener of its own (services/craig-exchange/src/returns/), apart from its API port. The listener is bound only when an interface consents to a partner’s calls (CRAIG_EXCHANGERETURNS<INTERFACE>ENABLED, default off; no_listener_is_bound_when_no_interface_consents). Once one does, the service refuses to start unless CRAIG_EXCHANGERETURNSPORT, TLS_CERT_FILE, TLS_KEY_FILE and CLIENT_CA_FILE are set and usable: a missing port, an unreadable file, an issuer bundle with no certificate and a key that is not the certificate’s each refuse the start. The files are read once; a changed file takes effect at the next start.

The listener ends TLS itself (rustls on aws-lc-rs) and requires a client certificate that chains to an issuer of the bundle and is within its validity. A caller with no certificate, one from another issuer or an expired one fails the handshake and reaches no route (a_caller_without_a_certificate_is_refused_at_the_handshake, a_certificate_from_an_unknown_issuer_is_refused_at_the_handshake, an_expired_certificate_is_refused_at_the_handshake). It serves POST /returns/{interface}/{leg} and nothing else (the_listener_serves_no_other_route), the API port serves no return (the_api_port_serves_no_return), and no token is read: the certificate is the caller. A call is cut at ninety seconds and answered 503, which tells the partner to call again; a run whose body was read goes on without the caller and closes (a_call_that_outlasts_its_cut_is_answered_and_its_run_still_closes).

One call is one run:

  1. The caller. The certificate’s SHA-256 fingerprint is looked up in craig-security, on every call, and nothing of the answer is kept (a_certificate_revoked_between_two_calls_is_refused_on_the_second). Nothing admitting it is a 403; a lookup that could not be made is a 503 (a_registry_that_cannot_be_asked_refuses_the_call).

  2. What it may use. The run resolves the active partner row of the called interface whose caller_partner_id is the looked-up partner, then that partner’s agreement on the jurisdiction’s business date, the deployment’s consent for the interface and the leg the path names. Each that does not hold is the same bare 403, so a caller cannot tell an interface that is another caller’s from one that does not exist. The path’s two segments are taken as written, undecoded; one that is no token, or is longer than one, names nothing and is refused the same way (a_caller_may_use_only_its_own_interfaces_legs, a_return_without_an_agreement_is_refused, a_return_without_consent_is_refused).

  3. The body. It is read up to the leg’s max_bytes, and never past one mebibyte; a longer one is refused before the leg is asked to decode it (a_body_over_the_cap_is_refused_before_it_is_decoded). The leg decodes it, and what it decoded is held to the contract’s bounds. A body the leg refuses, one over the bounds (more than 500 reports, a_call_with_more_reports_than_a_run_takes_is_refused_whole) and one holding a report of a kind no return carries are refused whole: nothing is posted and the leg acknowledges the refusal.

  4. The reports. Each is posted to craig-cases, which owns the application, as the outcome body of POST /v1/cases/medicaid-applications/partner-reports under a three-second budget, in the order the leg decoded them. The posting stops after three failures in a row that say craig-cases is unwell (a 409 or a 422 about one report does not count), after sixty seconds in all, or when the service is shutting down; the reports not yet posted are counted failed (a_run_past_its_deadline_counts_the_rest_failed, three_failures_in_a_row_of_an_unwell_owner_end_the_posting).

  5. The record. One exchange_transactions row (origin return, no payload) and one exchange.return_completed event are written in one transaction, and the leg’s acknowledge writes the partner’s answer from each report’s outcome. The row’s id is minted before the first post and each report carries it to craig-cases. Nothing the partner reported rests in craig-exchange (no_reported_value_rests_in_exchange).

One run at a time per interface: a call that arrives while another is being applied is acknowledged Busy by the leg and posts nothing (a_second_call_during_a_run_is_acknowledged_busy). Once its body is read a run no longer depends on the caller’s connection, so a partner that hangs up mid-run still leaves the row (a_run_outlives_its_callers_connection).

Every call that completes the handshake and is not applied stages exchange.return_refused with the certificate’s fingerprint, the refusal’s class and what was known of the caller by then (a_refused_call_is_recorded_with_its_fingerprint_and_class):

Class Answer When

lookup-unavailable

503

craig-security could not be asked about the certificate.

unknown-caller

403

Nothing in craig-security admits the certificate: it is not registered, not approved, revoked, or its partner is not active.

not-callers-interface

403

The caller has no active partner row for the called interface, or the path names no interface.

agreement-does-not-admit

403

The partner’s agreement does not admit today.

no-consent

403

The deployment does not consent to the interface’s calls.

no-leg

403

The interface holds no return leg of the called name.

unread

400

The body could not be read to its end.

store-unavailable

503

craig-exchange’s own database failed while it was deciding.

malformed, too-large, busy

the leg’s

The leg acknowledges the refusal in its partner’s wire.

The event names the interface and the leg only as tokens the deployment’s own partner set holds, never the text of the path that was called. exchange_return_calls_total{outcome} counts each such call by its class, and each call that was read as completed or failed.

Two ends leave no event, because what would hold it is what failed: the database failing after the caller was admitted (under the run’s lease, or when the run is recorded) is answered 503 and counted store-unavailable, and a run whose task died is answered 500 and counted run-failed. Both are logged as errors. A call cut at ninety seconds is not a refusal: its run goes on, and is recorded and counted when it closes.

The simulator

A partner’s mock is a simulator when it keeps state: a stand-in for the partner that answers about a person only from what it holds (Partner simulators). It implements PartnerSimulator (load and clear), lives in the partner crate behind its mock feature, and returns its router and itself as MockRoutes. The partner’s own control routes sit under _sim/ in that router. Both types, and the SimPerson a simulator is told about, are `craig-partner-sdk’s.

A simulator that stands for a partner with a return is also a PartnerCaller, set as MockRoutes::caller: due() answers the calls its partner would make now (each a DueCall: the return leg, a content type and a body), and answered(leg, status, body) gives it what CRAIG answered. Asking changes nothing; a call stays due until an answer says it was taken. The simulator decides what its partner says and whoever hosts it makes the calls. The reference partner’s assistance desk grants every referred application unless a test says otherwise (PUT _sim/residents/{person_id}/decision), and holds an outcome due until CRAIG answers that it stored it, already held it or found the application withdrawn (an_outcome_answered_unknown_is_due_again).

The mock server is that host. POST /_sim/partners/{kind}/run makes every call the simulator of kind says is due, over mutual TLS with that simulator’s own client certificate, hands each answer back and answers what each call came to; GET /_sim/partners/{kind}/caller-certificate answers the certificate, which a test registers in craig-security as the partner’s (Partner simulators). Nothing runs on a timer: a test says when the partner’s scheduled work happens.

The partner set

craig-exchange boots on one PartnerSet: each adapter and each collection as a factory under its interface token, each leg (triggered-send, referral and return), and at most one SSA benefit inquiry (ssa_benefits) as a factory under the token of the interface it belongs to. A jurisdiction does not write that value. Its partner-set crate says which adapters, legs, collections and inquiry it holds (PartnerSetSource; Partner modules, § Writing the two crates), and the host builds the set from the loaded module (PartnerModules::partner_set()). A partner crate’s own tests build one natively, as the reference partner’s partner_set() does. PartnerSet::validate() refuses:

  • a leg of any kind, a collection or an inquiry whose interface has no adapter in the set;

  • a leg whose spec has a fault;

  • one (interface, leg) pair registered twice among the triggered-send and referral legs, which are stored alike, or twice among the return legs;

  • two opening legs for one interface and stage kind.

It builds nothing, so it runs wherever the set is in reach. PartnerSet::manifest() lists what the set provides (each interface with its dispatch class and its legs of each kind) from the registered parts themselves; there is no manifest to write.

What boot checks

craig-exchange boots on the one set its configuration layer’s modules provide and refuses to start, naming the offender, when the set, the configuration and the environment disagree:

Checked Refused

The set alone

Whatever validate() refuses.

bundle/adapters.toml

A listed adapter the set lacks.

A collection

One that answers another interface than its registration; one (interface, leg) built twice.

The SSA inquiry

One that answers another interface than its registration. One registered under an interface the configuration does not list is not built: the deployment then has no SSA source, stages no screening run and holds every job contract-pending.

Each bundle/outbound_triggers.toml row

A leg the set does not provide; an adapter that is not listed, or not generically dispatchable; an event outside the catalogue; an event that names another entity than the leg keys on; a leg that follows a kind on an event that announces none; the same row twice.

Each consent variable (CRAIG_EXCHANGETRIGGERS<INTERFACE>__ENABLED, and the COLLECTIONS and RETURNS twins)

An interface the set has no triggered-send leg (or no collection, or no return leg) for, whichever way the variable is set.

The return listener’s settings, once an interface consents to returns

A port that is not set, a certificate, key or issuer file that is not set or cannot be read, an issuer bundle that holds no certificate, a key that is not the certificate’s.

Legs are registered whether or not their adapter is listed, so a stored admission still resolves its leg after a configuration stops listing the partner. A leg’s (interface, leg) pair is stored on admissions, jobs and transactions: renaming one orphans those rows.

The conformance kit

craig-partner-test-harness holds the checks. A crate supplies fixtures and a small descriptor; each check panics with the name of what failed.

Module What it holds a crate to

(root)

The manual send: the round trip against the crate’s mock, the exact request handed to the transport, the bounded refused body, three injected faults read through the failure view, the wire-contract refusal at the erased seam, the correlation carrier and the forwarded credential.

leg

A LegCase per leg: the spec is coherent; only an admitting leg admits; two assemblies of one context are the same record; a subject the leg must not send for yields no record; the record, sent to the crate’s own simulator, is accepted, and the same answer read against another correlation is a mismatch; a non-answer is malformed; no generated JSON is accepted.

simulator

The same people make the same world; a person not given is not known; a person out of the partner’s reach changes nothing; clear forgets everyone.

set

The set validates, and what it registers matches what the crate described (Described): leg for leg, the inquiry by its interface, and the collections of each interface by count (a registered collection names its leg only once built, and the check builds nothing). A part the kit was not told of fails the check, and so does a case that names nothing registered or is given twice.

collection

A CollectionCase (the collection over a real transport, a simulator that published nothing and one that published a known document): nothing published is an empty answer, never a failure; what was published comes back with each named person reported once and the rest counted; an injected latency, 503 or garbled body reads as its failure; the set registers a collection under the interface it names.

inquiry

An InquiryCase (the inquiry over a real transport, the simulator’s endpoint and three identifiers): a person the source holds is found; one it does not hold is NoRecord, never a failure; an identifier the source cannot be asked about is refused before anything is sent; a question the source refuses is partner-refused; a source that cannot be reached is a failure the host asks again; an injected latency, 503 or garbled body reads as its failure; the set registers the inquiry under the interface it names.

person_index

A PersonIndexCase (the index over a real transport, the simulator’s endpoint, a person the simulator holds, one it does not, a registration, and a way to ask the simulator whether it holds a participation): a person the index holds leads at a full score, in an answer within the contract’s bounds and ordered best first; a person it does not hold is an empty answer, never a failure; a registered person is then found in full under the id the registration answered; a participation is held by the index, and one for an id it does not know is refused; an injected latency, 503 or garbled body reads as its failure; the set registers the index under the interface it names.

referral_leg

A ReferralCase (the leg, an application with its child and custody episode, the texts of the application the crate’s wire carries, and a child the simulator does not hold): the record is the same every time and carries the identifier and those texts, and a child with no identifier is not referred; sent through the crate’s adapter to its simulator the record is accepted with a reference, with the same reference when it is sent again, and the answer read against another record is a mismatch; a referral the partner refuses yields no receipt, and neither does any answer that is not the partner’s acknowledgement.

return_leg

A ReturnCase (the leg, a well-formed call and how many reports it holds, a call with records the leg cannot read, and a body that is not the partner’s document): the call decodes to its reports, within the contract’s bounds and the same every time; what is not the partner’s document is refused, and no body at all panics the leg or is refused as busy; a record the leg cannot read is counted and the rest decode; a body over the leg’s cap is refused; the acknowledgement differs for each report whose outcome differs, answers a read run 2xx and a refused one not.

To run it, give the crate a tests/ file per group, as the reference partner has, and run the crate’s tests:

cargo nextest run -p craig-partner-testonia-registry

No build of the mock server compiles a mock in, so a crate’s tests hand its own routes to craig_mock_server::spawn_for_routes, which puts the host a devstack’s simulators run in around them.

The same cases on the built modules

A jurisdiction ships its partner crates as two modules (Partner modules), and a case that passes on the crate and fails on the module is a difference the build made: other features of a dependency, other bytes on the wire. The kit’s modules feature takes each part of a case from the built modules (craig_partner_test_harness::modules), so a crate states its fixture once and each check twice:

  • BuiltModules::of_layer(<the layer’s partners/>) loads the committed manifest, partner set and simulators with the module host; a test file keeps one behind a OnceLock and names it through the Built trait.

  • OnModule<P, M> is a PartnerUnderTest: P’s payloads and assertions, with the module’s adapter of `P’s kind in place of the crate’s. Every manual-send leg takes it where it takes `P (harness::accepted_round_trip::<OnModule<Caps, Layer>>).

  • leg(interface, leg), collection(interface, transport, ceiling) and inquiry(transport, ceiling) give the module’s parts in the shapes LegCase, CollectionCase and InquiryCase take; erased_adapter(kind, …) is what leg::the_record_is_acknowledged sends through. The inquiry is granted the standing its module reports; shipped_set() is the set as a boot takes it, with the inquiry granted nothing.

  • mock(kind) is a MockRouteFactory over that interface’s mock inside the simulators module, for spawn_for_routes, each call a world of its own; simulator(kind) is a ModuleSimulator for the simulator checks, and mock_kinds() lists what the module holds.

The modules read are the committed ones, the files CRAIG loads. A source change shows in these cases only after cargo xtask partners build --write, and partners check is what refuses a commit where the two differ. The reference partner runs its whole kit on its modules through these (tests/kit/modules.rs), and its typed legs through OnModule beside their native run (tests/round_trip.rs, through_the_kits_wrapper). A workspace whose tests load modules wants the WebAssembly compiler optimised in its dev profile, as CRAIG’s own is: unoptimised, each test waits seconds on the compile.

Three gates also hold a partner crate in this repository, which since ADR-090 is the reference partner: the fault registry (cargo xtask contested-census: the adapter needs its three fault tests registered in xtask/baselines/contested-surfaces.toml), the parse property census (cargo xtask lints parse-prop-coverage) and the length-cap lint (cargo xtask lints dto-length). A jurisdiction’s crates are held to the last two by cargo xtask partners check (Partner modules, § Building and checking), and run the kit’s fault legs in their own pipeline.

Two pins hold the exchange service to the specification rather than to any partner. It links no partner crate, and nor does anything else that ships: no_manifest_links_a_partner_crate reads every workspace member’s [dependencies] and refuses a craig-partner- or craig-partners- crate there (the kit, the SDK and the module host are not partner code), and holds the reference partner to being the only partner crate in the tree. Its production source names no partner: cargo xtask lints jurisdiction-literals refuses a string literal in services/craig-exchange/src/ that equals a partner’s kind token, the tokens being the interfaces each pinned layer’s partner manifest lists and the reference partner’s own (the_partner_kinds_are_the_layers_interfaces_and_the_partner_crates).

Two more hold the reference partner to it, as the crate a jurisdiction’s are written after. A partner crate is written against the specification alone: partner_crates_depend_only_on_the_specification reads its manifest, and of the workspace’s crates its [dependencies] may name only craig-exchange-contracts, craig-exchange-transport, craig-partner-sdk, craig-state-bundle and craig-validation, which is what lets a jurisdiction’s crates live in its own repository. And the reference partner ships nowhere: cargo xtask release-artifact-gate walks every release unit’s graph and refuses one that reaches craig-partner-testonia-registry (the_reference_partner_reaches_no_release_image).

The specification builds for WebAssembly

A partner module is built for wasm32-unknown-unknown, where there is no socket, no clock and no source of randomness (ADR-090). So the crates a module is built against must compile there with nothing that needs one:

  • craig-exchange-transport keeps its wire-backed transports, with reqwest and tokio, behind a host feature. The workspace dependency switches it on, so every service and tool has them; a module’s build leaves it off and keeps the trait, the request types, JsonAdapterCore and partner_error!.

  • craig-exchange-contracts and craig-partner-sdk name their own feature sets for that target: chrono without its clock, uuid without a random version, axum without its server. A member cannot drop a feature of a [workspace.dependencies] entry, so each states them under [target.'cfg(target_arch = "wasm32")'.dependencies], beside the workspace entry it inherits for every other target.

Two tests in xtask/src/cmd/feature_matrix.rs hold this:

  • the_specification_builds_for_webassembly runs cargo clippy --target wasm32-unknown-unknown with warnings denied over the four crates and the reference partner with its simulator, each with only its own features, and then refuses a resolve that holds JavaScript glue (wasm-bindgen, js-sys, which chrono’s default features bring for this target) or the socket-bound runtime (tokio, mio, reqwest). A module is wrapped as a component whose only imports are the contract’s, so glue that compiles would still leave an import nothing satisfies. This is the only lint of the code that exists inside a module alone (craig_partner_sdk::guest).

    One lint is let through, for craig-partner-sdk alone: clippy::same_length_and_capacity. The bindings wit-bindgen generates there rebuild a list from the pointer and length the contract’s ABI hands them, and no attribute can let generated code through: the output is one macro call, and the lint regime takes no suppression on a module (Quality gates, § Lint regimes). So the flag is on this one clippy call (maintainer ruling, 2026-12-01, #3200). Hand-written code cannot hide behind it: the flagged call is unsafe, unsafe_code is denied, and the_generated_bindings_lint_covers_generated_code_only refuses any unsafe written in that crate.

  • a_wasm_twin_asks_for_the_workspace_version holds each target-specific entry’s version equal to the workspace entry’s, so the second copy cannot drift.

rust-toolchain.toml lists the target, and the CI image and craig-tools install it when they are built (each_image_adds_every_target_the_toolchain_pins), so rustup downloads nothing in a job.

Partner modules

A jurisdiction’s partner crates are compiled into two WebAssembly modules, which its configuration layer holds beside their source (ADR-090):

partners/
  manifest.toml      what the modules are and provide
  partner-set.wasm   the adapters, legs, collections and inquiry: what craig-exchange loads
  simulators.wasm    the partners' simulators: what the mock server loads (optional)
  src/               the Cargo workspace both are built from, with its own Cargo.lock and rust-toolchain.toml

The partner crates are used as they are: a module’s crate names them and invokes one macro. Nothing of a jurisdiction’s is compiled into a CRAIG binary, so a partner’s wire change is a change to the layer.

The manifest

partners/manifest.toml says what the modules are, so that everything which must know it without running a module reads it there. craig_partner_host::Manifest::parse refuses an unknown key, a text over its length bound or more than 128 interfaces, a name that is not 1 to 64 of a-z, 0-9, _ and -, a limit above the host’s ceiling, an interface listed twice, a manifest with no interface, and a seed on a typed-only interface.

[modules]
name = "testonia"          # the jurisdiction's, by convention
version = "1.0.0"          # the modules' own, as their author states it
contract = "1.0"           # the module contract they were built for

[limits]                    # for one call into the partner set
fuel = 2000000000          # about one unit a WebAssembly instruction; at most 10^10
memory_bytes = 67108864    # at most 256 MiB

[build]                     # the packages in partners/src
partner_set = "reference-set"
simulators = "reference-simulators"   # optional

[[interface]]               # one per interface kind the set's adapters hold
kind = "testonia_registry"
seed = { partner_type = "education", label = "Mock: the Testonia resident registry" }

[[interface]]
kind = "testonia_desk"
typed_only = true           # never dispatched to by the generic pipeline, and never seeded

The contract

crates/craig-partner-host/wit/craig-partner.wit is the contract between CRAIG and a module: the specification’s contracts as data (package craig:partner@1.2.0). A module is one of two worlds.

World Imports Exports

partner-set

host: send, fetch and probe, the transport and nothing else.

adapters (the manual send), legs (a leg’s three rules), collections, ssa-benefits (the inquiry), since 1.1 person-index, and since 1.2 referral-legs and returns.

simulator-set

clock: the host’s time.

simulators: each mock’s routes as one handle call, and load, clear and holds for one that keeps state; since 1.2 callers: the kinds whose simulators make calls, and due and answered for each.

A date crosses as its day number, an instant as seconds and nanoseconds, an id as its two halves, and a record or an acknowledgement as JSON text. A person index’s subject, candidates, registration and participation cross as records of the product’s own fields, as do a referral’s application, a return’s reports and the run a return leg acknowledges. A failure crosses as data with its class, so the dispatch code reads a module’s failure exactly as it reads a compiled crate’s.

craig_partner_sdk::boundary holds each value’s conversion once (module_conversions!, and person_index_conversions! for the person index, referral_conversions! and return_conversions! for what 1.2 added), and the host and the guest both expand it, so the two sides cannot disagree about a value’s form.

One product value has no form in the interface it would cross. A Medicaid application is a stage kind (StageKind::MedicaidApplication) that the legs interface, published with 1.0 and never changed, has no word for. A stage, a leg’s facts or a record context of that kind therefore converts towards legs with an error (boundary::NotCarried): the host’s leg admits nobody for such a stage and refuses to assemble for it (a_leg_is_not_asked_about_a_stage_its_interface_cannot_name), and a partner set that states a triggered-send leg of an application fails its validation (PartnerSetError::ApplicationLeg). An application reaches a partner through a referral leg, whose interface carries it.

Versions

The package version is the contract version, and a layer’s manifest states the one its modules were built for. A host loads modules built for its own major version at its own minor version or an earlier one, and refuses any other (another_contract_major_refuses_boot, a_newer_minor_refuses_boot).

A committed module outlives the host it was built for, so a minor version only adds interfaces:

  • No published interface changes. A host and a module of different minors are matched by the interfaces' names alone, so an edited interface would be read as the one the other side was built against. crates/craig-partner-host/tests/wit-1.0/craig-partner.wit and tests/wit-1.1/craig-partner.wit are versions 1.0 and 1.1 as they were published (each pinned by its digest, the_published_copy_is_version_1_0 and the_published_copy_is_version_1_1), and no_published_interface_changed has wit-component’s own check compare what a module of each provides with what this host requires, structure by structure, the person index of 1.1 included.

  • The host requires the exports of 1.0 and binds a later one only where it is there. The contract file states that as two more worlds: partner-set-core (the four exports of 1.0, which the host requires of every partner set) and partner-set-person-index (the export 1.1 added). The host asks a module whether it exports person-index before it binds that world, so a module built for 1.0 loads unchanged and provides no person index (a_module_built_for_1_0_provides_no_person_index). Contract 1.2 added partner-set-referral-legs and partner-set-returns the same way, and for simulators simulator-set-core (what every simulator module exports) beside simulator-set-callers: a module built for 1.1 refers nothing, takes no partner’s call and makes none (a_module_built_for_1_1_provides_no_return, a_simulator_module_built_for_1_1_makes_no_call).

  • The SDK defaults what is new. PartnerSetSource::person_index answers none unless a set’s source defines it, as referral_legs and returns answer none, so a source written for an earlier minor builds against a later SDK as it stands.

A jurisdiction therefore takes an addition when it next rebuilds, and not before (ADR-090).

What a module may touch

A module has its world’s imports and nothing else: no WASI, so no file, socket, clock, environment or randomness of its own. For a partner set the host enforces the rest on every call (crates/craig-partner-host/tests/boundary.rs):

Rule Held by

A module sends only to the partner row’s endpoint, or a path or query under it. A longer host name, another scheme, a climb out of the path (plain, percent-encoded, behind a backslash or a ; parameter) and a fragment are refused unsent.

a_module_cannot_reach_another_endpoint

No credential enters a module. The contract has no credential type, and the host puts the row’s credential on the request itself.

a_module_is_given_no_credential, the_host_adds_the_partner_rows_credential

A module sets no credential, host or framing header (Authorization, Cookie, Host, Content-Length, Transfer-Encoding and the like, and the header a row’s API key rides in).

a_module_sets_no_credential_header

The host waits no longer than its own ceiling, whatever timeout a module asks for.

the_hosts_deadline_caps_a_modules

Each call runs in a fresh instance under the manifest’s fuel and memory. A module that spins, grows or panics fails that one call, as a malformed exchange, and the next call is served.

a_module_out_of_fuel_fails_its_call, a_module_over_its_memory_fails_its_call, a_trap_fails_one_call_and_the_next_succeeds, calls_at_once_share_no_instance

One call makes at most 2,048 requests of the transport; past that each is refused unsent. Fuel bounds what a module computes, and a module that asks its partner in a loop computes almost nothing.

a_module_that_sends_without_end_is_stopped

A leg’s rules reach no partner: they are called for no partner row.

a_leg_reaches_no_partner

A failure’s text and a refused body are cut to the bound a partner crate’s own error holds a body to.

a_modules_message_is_cut_to_the_bound

A module that imports anything the contract does not lend is refused when it is loaded.

a_module_that_imports_anything_else_is_refused

A typed-only adapter refuses a generic send before the module is asked.

a_typed_only_adapter_refuses_a_generic_send_unasked

The SSA benefit inquiry sends nothing. Sending a released identifier to a source takes a contract with that source, which a module cannot prove. PartnerModules::partner_set(), the set craig-exchange registers, grants the inquiry no authority and refuses a question before the module runs (a_shipped_set_grants_no_authority). The most a module can report of its source is that it stands in for one: the contract has no other case (no_module_report_reads_as_authoritative). partner_set_as_reported() grants a stand-in what it reports, for the conformance kit and craig-exchange’s SSA worker suite; it exists only under the host’s test-only stand-in-sources feature, which no release graph may hold (stand_in_sources_reaches_no_release_graph).

Writing the two crates

partners/src is a Cargo workspace of the jurisdiction’s partner crates and two small cdylib crates that name them. The reference partner’s are crates/craig-partner-host/tests/modules/reference/partners/src/:

// The partner set: set/src/lib.rs
#![cfg(target_arch = "wasm32")]

struct Reference;

impl PartnerSetSource for Reference {
    fn adapters(transport: Arc<dyn OutboundTransport>) -> Vec<Box<dyn ErasedAdapter>> {
        vec![Box::new(TestoniaRegistryAdapter::new(transport))]
    }
    fn legs() -> Vec<Arc<dyn TriggerLeg>> {
        legs::legs()
    }
    fn collections(transport: Arc<dyn OutboundTransport>) -> Vec<Box<dyn ErasedCollection>> {
        vec![Box::new(RegistrySchoolRoll::new(transport))]
    }
    fn ssa_benefits(transport: Arc<dyn OutboundTransport>) -> Option<Box<SsaBenefitInquiry>> {
        Some(Box::new(RegistryBenefitInquiry::new(transport)))
    }
    fn referral_legs() -> Vec<Arc<dyn ReferralLeg>> {
        vec![Arc::new(RegistryReferral)]
    }
    fn returns() -> Vec<Arc<dyn ReturnLeg>> {
        vec![Arc::new(RegistryOutcomes)]
    }
}

craig_partner_sdk::export_partner_set!(Reference);

The transport is the host’s, as an OutboundTransport: an adapter built over it works unchanged. A partner crate’s async fn needs no runtime inside a module, since every import returns its answer before it returns. The simulators' crate implements SimulatorSetSource (one Mock per interface kind, with the partner’s router and, for a simulator, what it holds about a person as text) and invokes export_simulators!. Inside a module a simulator reads the time with craig_partner_sdk::now() and makes ids with IdSource; both work natively too.

A jurisdiction’s workspace names CRAIG’s crates by git revision and picks its dependencies' features freely (chrono without its clock, uuid without a random version, axum without its server). The release profile is part of what a module’s bytes are; the fixtures' is the one to copy (opt-level = "s", lto = true, codegen-units = 1, panic = "abort", strip = true).

Building and checking

cargo xtask partners build --layer-path <layer>           # build, and say what was built
cargo xtask partners build --layer-path <layer> --write   # replace partners/*.wasm with the result
cargo xtask partners check --layer-path <layer>           # the source's rules, then build and refuse modules that differ
cargo xtask partners check --pinned                       # the same, for every fetched layer config-sources.lock pins

The committed modules are what CRAIG loads, so they must be their source and nothing else. check builds the source again and fails when a committed module is missing or differs by a byte, naming the file and both SHA-256 digests; a jurisdiction’s pipeline runs it at its pinned CRAIG version, beside config check-bundle. For that the build must give the same bytes wherever it runs, so one recipe fixes what would vary (xtask/src/cmd/partners/recipe.rs):

  • The toolchain is the layer’s own (partners/src/rust-toolchain.toml), and must be one CRAIG’s images carry: ci/guest-toolchains lists them, and a layer on any other is refused by name before anything is built (a_layer_on_an_unlisted_toolchain_is_named). A toolchain is added there, and to both images, in a change to CRAIG (each_image_installs_every_guest_toolchain).

  • The dependency versions are the layer’s Cargo.lock, held with --locked.

  • The profile and flags are the layer’s: every variable that would override a profile, the flags, the compiler or the target is removed from the build’s environment (the_build_drops_what_would_change_its_bytes).

  • The paths the compiler writes into a module (a panic’s location) are remapped to fixed names: the layer’s source, cargo’s home, the build directory and the standard library’s source. The last is where a developer’s machine and an image differ: with the toolchain’s rust-src component installed the compiler names the standard library’s files by where they lie on that machine, and without it by /rustc/<commit>, so the recipe gives the first the second’s name. the_same_source_builds_the_same_bytes_from_another_directory builds one layer in two directories and refuses a module that names any directory of the machine.

The recipe was checked across machines by hand when it landed (2026-12-01): one layer that names CRAIG by git revision built the same bytes on a developer’s machine (CachyOS, with rust-src), in the CI image (Debian 12) and in craig-tools (Ubuntu 24.04), each with its own cargo home and build directory. All three were x86_64-unknown-linux-gnu hosts; another host platform is not checked.

One thing the recipe cannot fix: a dependency named by path outside the layer’s workspace. Cargo hashes such a package’s absolute path into its symbols, so the module differs from one checkout to the next. A layer names CRAIG’s SDK by git revision. A layer built against a local CRAIG checkout by path is fine for development and will not pass check.

check also holds the source itself to the two rules that partner code in this repository is held to by a lint, since a jurisdiction’s partner code decodes what its partners send (xtask/src/cmd/partners/source_rules.rs):

  • Parsing never panics. Every adapter’s type Inbound has a property test, in a file its own crate’s tests compile, that feeds arbitrary bytes to from_slice for that type (cargo xtask lints parse-prop-coverage describes the rule; an_inbound_type_no_compiled_property_parses_is_a_finding). The declaration is found wherever a crate keeps its adapter, in the source a build compiles outside its tests (an_adapter_only_a_test_build_compiles_is_no_target). A layer whose source declares no adapter has nothing to cover.

  • Every string a partner sends has a length cap. Each string-shaped field of a type the source decodes, and each string taken straight from a request, declares its cap, read as cargo xtask lints dto-length reads it, the layer’s own type aliases expanded (a_string_a_partner_sends_with_no_cap_is_a_finding).

Both read partners/src as a Cargo workspace whose [workspace].members are written out, one directory each: a member glob is refused. A layer has no ledger, so nothing CRAIG’s own ledger admits passes there, and a finding is fixed in the source. What a rule lets the source itself excuse stays: #[garde(skip)] on a field that is no partner’s input, and an // allow-no-parse-prop: <reason, with its issue> comment on the line above an adapter’s type Inbound. The source is checked before the build and the bytes after it, and one run reports both (the_check_refuses_a_source_finding_and_a_byte_difference_alike). A check that passes prints each module’s SHA-256, so a pipeline’s log says which bytes passed.

CRAIG’s own battery runs check --pinned: every layer config-sources.lock pins that holds partner modules is checked against CRAIG as it is now, so a change to the recipe or to the guest toolchains that would build a pinned layer other bytes fails in CRAIG’s pipeline and not in a deployment. A layer commit’s files do not change, so a commit that passed is remembered under target/partner-checks/ with a digest of the recipe and is not built again until either changes (a_pass_is_remembered_for_its_commit_and_its_recipe_only); a layer given as a working copy is checked every time.

A jurisdiction’s pipeline needs room for more than the modules. Georgia’s job builds CRAIG’s task runner (about 3.4 GB), then its workspace’s tests, each test binary linking the module host (about 11 GB in a debug build); on a 2 vCPU shared runner the linker died for want of disk. Give the job a runner with tens of gigabytes free.

No Rust toolchain is needed where CRAIG is deployed: the host wraps the committed module as a component when it loads it.

The host

crates/craig-partner-host loads a layer’s modules. Its features keep the WebAssembly runtime out of whatever does not need it:

Feature What it adds

(none)

The manifest’s reader. The task runner and the seed use it without linking a runtime.

runtime

wasmtime, and PartnerModules: from_snapshot(&ConfigSnapshot) and from_parts(manifest, bytes) load a partner set, partner_set() presents it as the PartnerSet any other set is, and partner_set_digest() is the SHA-256 of the loaded file, for a boot log.

simulators

SimulatorModule and its SimulatorSet, for the mock server alone (only_the_mock_server_enables_simulators): one long-lived instance per started world, called one request at a time, with the host’s clock as its one import.

stand-in-sources

Test only: partner_set_as_reported().

The workspace’s lint passes build the host once, under the union of the features the selected targets ask for, and an image’s build of one service links it under that service’s set alone. So the_module_host_lints_under_each_of_its_feature_sets lints it alone under each set a consumer links it with: none, runtime, and simulators.

A layer’s modules are refused, and the service refuses to boot, when (crates/craig-partner-host/tests/load.rs):

  • the manifest names another major version of the contract (another_contract_major_refuses_boot);

  • the module’s adapters are not exactly the manifest’s interfaces, each under the manifest’s dispatch class (a_module_that_differs_from_its_manifest_refuses_boot);

  • the module holds a leg, a collection or an inquiry of an interface it has no adapter for (a_part_of_an_interface_the_module_does_not_hold_is_named);

  • the layer holds a manifest and no module, or a module and no manifest (a_manifest_with_no_module_refuses_boot);

  • more than one layer holds partners/ (two_layers_with_partner_modules_refuse_boot);

  • the file is not a module of the contract (a_file_that_is_no_module_of_the_contract_is_refused);

  • the simulators hold a mock for a kind the manifest does not list (simulators_load_for_the_manifests_interfaces_only).

A snapshot whose layers hold no partners/ has no modules, which is no error.

craig-exchange boots on them. It loads the snapshot’s partner set before it builds its registries (services/craig-exchange/src/partner_modules_tests.rs):

  • What the modules provide is the deployment’s partner set, and the configuration’s adapter list narrows it (a_layers_modules_are_the_partner_set). No build compiles a partner in, so a configuration that lists an adapter and whose layers hold no modules is refused for naming an adapter nothing provides.

  • The set must stand on its own: a leg, collection or inquiry that names an interface the set has no adapter for is refused.

  • Every layer this repository pins loads and boots its own configuration (every_pinned_layers_modules_load), and none is granted send authority (no_pinned_layer_claims_send_authority).

  • A layer whose modules are refused refuses the boot, and the refusal says what is wrong with the layer (a_refused_layer_refuses_boot).

  • The boot log names the modules: modules (their name), version, contract and partner_set_sha256, the SHA-256 of the loaded file, which is the committed partners/partner-set.wasm (the_boot_log_names_the_modules). A deployment with none logs that no configuration layer holds partner modules.

The mock server serves their simulators. Given the configuration layers (CRAIG_CONFIG_SOURCE, as the devstack gives it), craig-mock-server starts the layer’s simulators once, as one world that lives as long as the host, and mounts each under /partner/<kind>; it compiles no mock in (tools/craig-mock-server/src/layer_tests.rs):

  • A request under a kind’s mount is answered inside the module, and the control surface’s people load reaches the simulator there (the_mock_server_serves_a_partner_from_the_layer).

  • A kind mounted twice refuses the host, by name (a_kind_mounted_twice_refuses_the_host), and so does a layer whose simulators the host refuses (a_layer_with_refused_simulators_refuses_the_host).

  • A host given no layer, or a layer with no simulators, serves no partner (a_host_without_a_layers_simulators_serves_no_partner).

The fixture modules

crates/craig-partner-host/tests/modules/ holds this repository’s own modules, each laid out as a layer’s partners/:

Fixture What it is for

reference

The reference partner’s set and simulator. The reference partner’s tests/as_modules.rs runs the conformance kit on them: its own cases, the same two files it runs on the crate, with the built modules as their subject. A case that passes on the crate and fails there is a difference the module boundary made. A jurisdiction’s partner crates run their kit cases on their built modules through the kit’s modules feature (The same cases on the built modules).

echo

A set that answers what it was given and fails as it is told, so a test reads what crossed the boundary.

hostile

A set that tries each thing a module may not do.

greedy

A set that imports a function the contract does not lend.

legacy

A set built for contract 1.0: its bindings are generated from the published 1.0 file, with none of this repository’s SDK, and its one adapter sends through the host’s transport. It stands for a module a jurisdiction committed before the host learned a later minor version.

legacy-1-1

A set and a simulator module built for contract 1.1 in the same way, from the published 1.1 file. The set holds an adapter and a person index that knows nobody; the simulators hold one mock without state. They stand for the modules a jurisdiction committed before the host learned of 1.2.

Nothing built is committed here (no_built_module_is_tracked). cargo xtask partners build --fixtures builds them into target/partner-fixtures/, and every test lane runs it before its tests (the fixture modules). The fixtures name CRAIG’s crates by path, so their bytes differ between checkouts, which is one more reason they are never committed.

Edit this page · latest