Registry stack documentation: machine-readable Markdown.
Index of all pages: https://docs.registrystack.org/dev/llms.txt
Full corpus: https://docs.registrystack.org/dev/llms-full.txt

# Configure an Adapter project

> Write the artifacts that make an Adapter project, the facade contract and exchange contract between routes and profile, writes, authorisation, audit, mapping and external projection acquisition.

import ConfigurationFormatChecks from '../../../components/ConfigurationFormatChecks.astro';

The Registry Adapter runs reviewed integration routes over a source system.
Its live facade serves a declared API by translating each request.
Its ingestion jobs read bounded source pages and deliver a reviewed projection to a destination.
This page covers the artifacts you write, the contract between a route and a facade profile, writes, authorisation, audit, field mapping and external projection acquisition.

[Adapter route language](../adapter-routes/) covers the routes themselves.
[Adapter ingestion jobs](../adapter-jobs/) covers jobs and the webhook trigger.

## Artifacts

{/* Evidence: products/adapter/schemas/profile.v1alpha1.schema.json AdapterProfile */}
{/* Evidence: crates/registry-adapter-core/src/profile.rs AdapterProfile */}
{/* Evidence: crates/registry-adapter-core/src/pack.rs AdapterPack */}
{/* Evidence: crates/registry-adapter-core/src/project.rs AdapterProject */}
{/* Evidence: crates/registry-adapter-core/src/job.rs AdapterJob */}

An Adapter deployment is made of these artifacts, each in a registered `v1alpha1` platform YAML format:

- `AdapterProfile` is authored, versioned and maintained with the product. It holds the operation set by id, methods and paths, request and response envelope templates, pagination parameters, the problem envelope, and the `problems` list that maps error classes to problems. It also names the parts the deployment parameterises. The first profile is `breg-records` v1.
- `AdapterPack` is authored, versioned and reviewed, one per source system, in the Kamelet style. It holds endpoint declarations (component, authentication kind, tested upstream versions), route templates with typed template parameters, internal `direct:` routes, code maps, script references (own files, digest-pinned) and the required engine capabilities.
- `AdapterProject` is the top-level authored artifact. It holds a `project` block (identity `id` and `version`), declared record types and fields, profile and pack references pinned by version and digest, `templatedRoutes` that instantiate pack templates, bindings of concrete contract operations to route ids, and access profiles.
- `AdapterRuntimeConfig` belongs to the operator. It holds environment bindings: endpoint base URLs and TLS, secret references (credentials and the cursor key `cursorKeyRef`), optional explicit `secretProviders` (environment only when omitted), `allowedPrivateCidrs`, the listener, an optional `metricsListener` (off when omitted, see [Scrape metrics](../../operate/adapter/#scrape-metrics)), the database, OIDC and audit retention.
- `AdapterJobRuntimeConfig` belongs to the operator and is the job host's own runtime document. It has its own kind and apiVersion, the shared `endpoints` bindings and `allowedPrivateCidrs`, plus `sources`, the job `store`, host-owned `destinations`, `secretProviders`, `hookIngress` and an optional `metricsListener` that `pass --loop` serves. It carries no facade listener, database or OIDC block. A facade `AdapterRuntimeConfig` is refused as the wrong kind, and the refusal names this document.
- `AdapterJob` is an authored, versioned, reviewed ingestion job definition. [Adapter ingestion jobs](../adapter-jobs/) describes it.
- `AdapterFixture` is an authored suite per pack: recorded upstream exchanges with expected facade responses, each with provenance.
- `AdapterMapping` and `AdapterPreviewExpectations` hold field mapping and its sample expectations (see [Field mapping](#field-mapping)).
- `AdapterEffectiveContract` is the generated effective contract of a deployment.

The generated outputs are build artifacts.
`adapterctl compile` emits the per-deployment facade OpenAPI document and computed schemas into the built package.

{/* Evidence: crates/registry-adapter-core/src/runtime.rs AdapterRuntimeConfig */}
{/* Evidence: crates/registry-adapter-core/src/fixture.rs AdapterFixture */}
{/* Evidence: crates/registry-adapter-core/src/mapping.rs AdapterMapping */}
{/* Evidence: crates/registry-adapterctl/tests/check.rs schemas_writes_thirteen_files_into_the_given_directory */}

Projects reference packs and profiles as plain identifiers, resolved and digest-checked by `adapterctl check`.
A pack declares the engine capabilities it requires (components, languages and EIPs).
`adapterctl` refuses a pack that the binary cannot run, and the runtime refuses it at startup with a bounded problem.
Access profiles live in the project because they are reviewed deployment policy.
The OIDC issuer that authenticates callers lives in the runtime config because it is environment.

{/* Evidence: crates/registry-adapterctl/tests/check.rs a_tampered_profile_refuses_with_the_pin_digest_code */}
{/* Evidence: crates/registry-adapterctl/tests/check.rs a_wrong_pinned_profile_version_refuses_with_the_pin_version_code */}
{/* Evidence: crates/registry-adapterctl/tests/check.rs an_altered_pinned_script_refuses_with_the_digest_pin_code */}

### Check each artifact

Check each artifact before you deploy it, as
[Check a file before you deploy it](../../reference/configuration-files/#check-a-file-before-you-deploy-it)
describes.

<ConfigurationFormatChecks product="adapter" />

## Facade contract

An authored profile declares an operation set with paths, methods, request and response envelopes, pagination parameters and problem codes.
It also declares which parts the deployment parameterises.
The built-in Consultation target is the exception: the product owns its standard wire behaviour, while project artifacts own its source bindings and public data views.
See [Adapter Consultation](../adapter-consultation/).

The first profile, `breg-records` v1, is a starting target, not the only one.
It mirrors the Base Registry Engine (BReg) public read surface, `/v1/records/{type}` and `/v1/records/{type}/{record_id}`, with the operations `records-search` and `records-get`.
It adds write operations `records-create`, `records-update` and `records-patch`, and answers in the Registry Record v1 shape.
A contract that a ministry already publishes can use another profile file.

{/* Evidence: products/adapter/profiles/breg-records/profile.yaml records-search */}
{/* Evidence: crates/registry-adapterctl/tests/compile.rs breg_records_envelopes_match_registry_record_goldens */}
{/* Evidence: crates/registry-adapterctl/tests/compile.rs the_case_api_corpus_base_compiles_with_foreign_names */}

### Operation paths

{/* Evidence: crates/registry-adapter-core/src/profile.rs ProfileOperation */}
{/* Evidence: crates/registry-adapterctl/tests/compile.rs an_unbound_profile_operation_emits_no_path */}
{/* Evidence: crates/registry-adapterctl/tests/compile.rs colliding_concrete_paths_refuse */}

Facade operation paths are single-brace `{name}` templates, the path templating of Camel's REST DSL and OpenAPI.
`{{name}}` is the pack layer's substitution syntax.
The profile check resolves each `{name}` in an operation path against that operation's path parameters.

An operation names, among its path parameters, the one that carries the record type (`recordTypeParameter`).
When the operation declares a path parameter beyond that one, it also names the one that carries the record identifier (`recordIdParameter`).
For `breg-records`, those are the get, update and patch operations.
The facade places the `recordId` input where `recordIdParameter` is declared, and no rule reads meaning from a parameter's position.

`adapterctl compile` substitutes the bound record type into the path, so the contract carries concrete paths such as `/v1/records/persons`, as BReg's per-package OpenAPI does.

An operation also declares its `successStatus`, default 200.
The `breg-records` create answers 201.
`successStatus: 202` and `asyncCompletion` come together, on a non-read write only.
A read (a safe method or `readOnly`) never answers 202, because it has no completion to recover.

### Envelopes

{/* Evidence: crates/registry-adapter-core/src/profile.rs EnvelopeTemplate */}
{/* Evidence: crates/registry-adapter-core/src/model.rs Envelope */}
{/* Evidence: crates/registry-adapterctl/tests/compile.rs error_responses_come_from_the_profile_problems_list */}

An envelope is a JSON template in the profile with slots from a closed vocabulary that the engine fills:

- `record`: one validated route result.
- `records`: the validated result list.
- `recordType` and `recordId`.
- `nextCursor`.
- `requestId`.
- In the problem envelope: `problemCode`, `problemTitle`, `problemDetail`, the optional whole-value `problemData`, and `status`.

Request envelopes name where the writable record sits in an incoming body.
Pagination parameters name the cursor and page-size query parameters and their bounds.

The profile's `problems` list declares each problem a caller can receive: `code`, `status`, `title`, and the error `classes` it answers.
A pack raises error classes and never names a profile's problem codes or builds a problem body.

`adapterctl check` refuses:

- an unknown slot,
- a response envelope without its result slot,
- a problem envelope without its code slot,
- a profile under which some error class resolves to no problem or to more than one.

The engine owns the mechanism (filling slots, encoding cursors, setting the status), and the profile owns every name and shape a caller sees.

### Source, transformation and protocol

Source acquisition, deployment transformation and outward protocol are separate responsibilities.
A pack knows a source system.
Project-selected transformations map its bounded results into declared schema-bound views or facts.
A generic profile or the built-in target owns the outward wire contract.
The same source pack can serve the facade and Evidence without a GovStack Record becoming an Evidence prerequisite.

### Dynamic payloads

{/* Evidence: crates/registry-adapterctl/tests/compile.rs two_runs_are_byte_identical_and_pretty_sorted */}
{/* Evidence: crates/registry-adapterctl/tests/compile.rs check_refuses_a_one_byte_change */}
{/* Evidence: crates/registry-adapterctl/tests/check.rs an_expected_body_with_a_wrong_typed_member_refuses_with_the_response_schema_code */}

Payload content is dynamic.
Request and response schemas and search parameters are computed per deployment from the declared model, the same way BReg computes its per-package OpenAPI from a registry project.
The compiled contract is concrete per record type: one concrete operation per (profile operation, record type) pair that the project binds, with `operationId` `<operation>.<recordType>`.
A parameterised part is a deployment value the contract cannot know, so the schema types it as a string, never as the stand-in literal.

Serving follows Camel's contract-first REST DSL.
The generated OpenAPI document is the specification the consumer reads at startup.
Every concrete operation dispatches to the route its binding names.
Request validation against the contract is always on.
An operation with no route is a startup failure.
Because the generated contract holds only bound operations, the deployment serves exactly its contract.

Route output is checked twice.
`adapterctl check` validates every fixture's facade response against the generated schema.
The runtime validates the final exchange body of every route against the closed per-operation result schema before the engine places it in the profile's envelope.
Fixture values are checked against declared field types at check time.

`adapterctl compile` emits the deployment's concrete OpenAPI document into the built package.
By default it writes `<project-dir>/generated/openapi.json`, for any project directory.
The file is pretty-printed with sorted keys and a trailing newline, so its diff is the contract review.
A drift gate holds it byte-identical.
The built-in Consultation target publishes only its enabled capabilities.

## Exchange contract

Facade inputs, continuation, scripts, headers, links and errors have fixed places on the exchange, so a pack written against them runs under any profile.

### Facade inputs

{/* Evidence: crates/registry-adapter-core/src/route.rs recordType */}
{/* Evidence: crates/registry-adapter/tests/camel_processors.rs header_writes_refuse_the_read_only_targets_at_load */}
{/* Evidence: crates/registry-adapter/tests/camel_processors.rs script_writes_the_next_continuation_and_no_other_reserved_property */}

The `rest` consumer turns the validated request into headers and a body under closed, profile-neutral names.
A pack never learns a profile's path or parameter names.

- Record type: header `recordType`, on every operation.
- Record identifier: header `recordId`, on get, update and patch.
- Page size: header `pageSize`, on search. It is an integer inside the profile's bounds, and the profile's default when absent. The sealed cursor binds the effective page size, so an omitted `pageSize` on a continued request reuses the cursor's, and a different one is refused with `facade.invalid-cursor`.
- Filters: property `AdapterFilters`, on search. It is an object from declared field name to typed value and holds only the filters the caller sent.
- Continuation: property `AdapterContinuation`, on search. It is absent on the first page.
- Request record: the body, on create, update and patch. It is extracted through the profile's request envelope and validated against the declared model.
- Idempotency key: header `Idempotency-Key`, on write operations, read by `idempotentConsumer`. It is the one caller header that enters.

A search binding declares the fields it filters on (`filters`).
The contract offers exactly those as typed equality query parameters, and request validation refuses any other query parameter, so a route never silently ignores a filter.
A filter never reuses the bound operation's cursor, page-size or path parameter name (`adapter.project.filter-parameter-collision`), so one caller-facing name means one thing.
Every filter that a binding declares is required, and a request that misses one is refused with `facade.invalid-field` (422).

Reads start with a `null` body.
No other caller header, cookie, query parameter or token ever enters the exchange.
These headers and properties are read-only.
`adapterctl check` refuses a `setHeader`, `removeHeader`, `setProperty` or `removeProperty` that names them, except `AdapterNextContinuation`, which exists to be set.

{/* Evidence: crates/registry-adapter-core/src/project.rs Binding */}
{/* TODO[evidence]: no test located for facade.invalid-field (422) on a missing required filter; adapter.project.filter-parameter-collision is the code, not a test */}

### Continuation

{/* Evidence: crates/registry-adapter/tests/adapter_continuation.rs the_ttl_is_bounded_60_to_86400_with_a_default_of_900 */}
{/* Evidence: crates/registry-adapter/tests/adapter_continuation.rs a_cursor_key_is_exactly_32_bytes */}
{/* Evidence: crates/registry-adapter/tests/adapter_continuation.rs a_cursor_sealed_under_the_previous_key_opens_after_rotation */}
{/* Evidence: crates/registry-adapter/tests/adapter_continuation.rs sealing_never_uses_the_previous_key */}
{/* Evidence: crates/registry-adapter/tests/adapter_continuation.rs a_cursor_replayed_with_other_filters_is_refused */}
{/* Evidence: crates/registry-adapter/tests/adapter_continuation.rs a_cursor_minted_before_a_redeploy_is_refused_by_the_new_deployment */}
{/* Evidence: crates/registry-adapter/tests/adapter_continuation.rs a_continuation_at_the_bound_seals_and_one_byte_over_is_refused */}
{/* Evidence: crates/registry-adapter/tests/adapter_continuation.rs the_filter_digest_ignores_member_order */}
{/* Evidence: crates/registry-adapter/tests/postgres_security_boundaries.rs a_continuation_replayed_with_other_filters_never_runs_the_route */}

The route owns the upstream position, and the engine owns the caller's cursor.

A search route that can return more sets the property `AdapterNextContinuation` to a JSON value: an upstream cursor, an offset, an origin-pinned next link, or an object of these.
The value is at most 2 KiB serialised.
Absent or `null` at the end of the route means the last page.

The engine encodes the value as the opaque `nextCursor` slot, using authenticated encryption under the runtime secret `cursorKeyRef`.
The cursor is bound to:

- the concrete operation and the binding id,
- the caller's subject (the authenticated issuer and `sub`) and acting client (the verified `azp` or `client_id` that the runtime admitted through `allowedClients`),
- the deployment the runtime serves, expressed as a SHA-256 over the project, profile and pack bytes the runtime loaded, so a redeploy that changes route meaning invalidates outstanding cursors,
- a digest of the filters and page size, computed as SHA-256 over the RFC 8785 canonical JSON of the validated facade inputs without the cursor, plus the page size,
- an expiry, `cursorTtlSeconds`.

The token instance is not bound, so a refreshed token continues a traversal.

`cursorTtlSeconds` is bounded from 60 to 86400 and defaults to 900.
`cursorKeyRef` resolves to exactly 32 bytes, or the runtime refuses to start.
An optional `previousCursorKeyRef` keeps cursors valid across one key rotation, and it only decrypts.

On the next request the engine verifies and decrypts the cursor and places the value as `AdapterContinuation`.
A cursor that fails authentication, has expired, or was minted for another operation, caller, client or filter set raises `facade.invalid-cursor` before any route step runs.
An oversize cursor raises `facade.invalid-cursor` too.
The cursor is verified after authentication and authorisation, so an unauthenticated caller with a forged cursor gets `facade.unauthenticated`.

The cursor uses XChaCha20-Poly1305 with a random 192-bit nonce.
The key is derived from `cursorKeyRef` by HKDF-Expand under a domain label.
The binding sits in the associated data, so a mismatch is an authentication failure, and a version byte travels on the wire.
ChaCha20-Poly1305 is not FIPS-approved.
The cursor is an engine-internal token that only this engine opens.
A deployment that requires approved algorithms for internal tokens needs AES-256-GCM with per-cursor subkeys, which is a wire-version change.

The caller can neither read nor forge an upstream position.
A next link the source returned comes back to the route only as the route handed it out, and it is still subject to the [origin pinning](#origin-pinned-links) rules.

### Script ABI

{/* Evidence: crates/registry-adapter-engine/tests/mapping_generated.rs every_entrypoint_the_check_accepts_compiles_and_runs_in_the_sandbox */}
{/* Evidence: crates/registry-adapter/tests/camel_processors.rs script_returning_no_map_fails_the_exchange */}
{/* Evidence: crates/registry-adapter/tests/camel_conversion.rs rhai_code_map_takes_the_same_lookup */}
{/* Evidence: crates/registry-adapter-core/src/model.rs RhaiExpression */}

Every `rhai` entrypoint receives one argument, `exchange`, a read-only map `#{ body, headers, properties }`.
`body` is the current body, `headers` holds the current headers with lowercased names, and `properties` holds the current properties.

JSON maps to Rhai as objects to maps, arrays to arrays, strings to strings, integers to `i64`, other numbers to `f64`, booleans to `bool`, and `null` to `()`.
The reverse applies on return.
A number outside `i64` that is not integral stays `f64`.
An integer outside `i64` raises `script`.
Typed template parameters keep their type when instantiated into a script argument or expression.

What an entrypoint returns depends on its slot:

- `setBody`, `transform` or an expression value (`setHeader`, `setProperty`, `query`, `body`, `pathParameters`, `httpUri`, a `split` expression or a `loop` count): the value.
- A predicate (`when`, `filter`, `validate`, `onWhen`, `retryWhile`, `doWhile`): a `bool`. Anything else raises `script`.
- The `script` EIP: a map of property names to values, set on the exchange. The body is unchanged.
- A custom aggregation strategy (`split`, `enrich`): `fn(oldExchange, newExchange)`, with `oldExchange` as `()` on the first call of a split. It returns `#{ body, properties }`, where `body` is required and `properties` names the property writes. An absent selection clears the property.

`oldExchange` and `newExchange` carry Camel's own `AggregationStrategy.aggregate` names.
`new` alone is a reserved word in the pinned engine, so the shorter spelling cannot compile.

Each script file is its own compilation unit.
An entrypoint may call functions defined in the same file only, and `adapterctl check` refuses a call to a function the file does not define.
There is no `import` and no shared prelude.
Budgets come from the platform script engine, and exceeding one raises the uncatchable `script.budget-exceeded`.

{/* Evidence: crates/registry-adapterctl/tests/check.rs an_entrypoint_whose_parameter_is_not_exchange_refuses_with_the_signature_code */}

### Headers on the wire

{/* Evidence: crates/registry-adapter/tests/camel_header_filter.rs every_reserved_name_is_refused_in_either_list */}
{/* Evidence: crates/registry-adapter/tests/camel_header_filter.rs the_endpoint_api_key_header_is_refused_in_either_list */}
{/* Evidence: crates/registry-adapter/tests/camel_header_filter.rs a_header_name_that_is_not_a_token_is_refused */}
{/* Evidence: crates/registry-adapter/tests/camel_header_filter.rs a_name_listed_twice_in_any_case_is_refused */}
{/* Evidence: crates/registry-adapter/tests/camel_header_filter.rs a_camel_engine_header_is_refused_as_a_response_header */}
{/* Evidence: crates/registry-adapter/tests/camel_header_filter.rs a_facade_input_is_refused_as_a_response_header */}
{/* Evidence: crates/registry-adapter/tests/camel_header_filter.rs a_request_header_value_with_a_control_is_refused_as_egress */}
{/* Evidence: crates/registry-adapter/tests/camel_header_filter.rs two_exchange_entries_for_one_listed_name_are_refused */}
{/* Evidence: crates/registry-adapter/tests/camel_header_filter.rs a_repeated_declared_response_header_is_upstream_malformed */}
{/* Evidence: crates/registry-adapter/tests/camel_header_filter.rs an_absent_declared_response_header_is_not_copied */}
{/* Evidence: crates/registry-adapter/tests/camel_header_filter.rs check_pack_and_the_filter_build_refuse_the_same_allowlists */}
{/* Evidence: crates/registry-adapter/tests/camel_header_filter.rs an_empty_allowlist_sends_nothing */}

The endpoint declares two allowlists, Camel's `HeaderFilterStrategy` in both directions:

- `responseHeaders`: upstream response headers copied onto the exchange and read by `header` under their declared names.
- `requestHeaders`: exchange headers sent upstream on every send to the endpoint, by name (`Accept`, `Prefer`, `If-None-Exist`). A header in the list that is absent from the exchange is not sent. Camel engine headers and the facade inputs are never sent unless listed.

Neither list can include `Authorization`, `Proxy-Authorization`, `Cookie`, `Set-Cookie`, `Host`, `Content-Length`, `Transfer-Encoding`, `Connection`, `Upgrade`, `TE`, `Trailer`, `Keep-Alive`, `Expect`, the hop-by-hop `Proxy-*` headers, or the endpoint's own API key header.
Credentials are injected after the allowlist is applied, so no exchange header can replace or shadow one.
Header names are RFC 9110 tokens, compared without case.
The same names are refused as a `static-api-key` `headerName`.
A key sent in `Authorization` uses the `static-authorization` kind.

`requestHeaders` also refuses the names the platform transport owns on a request.
Those are `Content-Type`, which belongs to the body codec, and the forwarding, encoding and signing headers.
`responseHeaders` refuses `Camel*` names, the facade inputs (an upstream value never stands in for a validated caller input), and the authentication-challenge, infrastructure and tracing headers that the transport owns on a response.
A name listed twice, compared without case, is refused.
A list holds at most the transport's 32 names.
`adapterctl check` and the runtime's filter build refuse the same names, so a pack that passes `check` never fails on these rules at load.

On a send, an exchange value that is not a strict RFC 9110 field value, or that exceeds the transport's value bound, raises the uncatchable `egress.refused`.
It is never trimmed or re-encoded.
An exchange that holds two entries for one listed name (compared without case) also raises `egress.refused`.
Neither entry is picked, where Camel's `HttpProducer` would join them.
A declared response header that the upstream repeats, or sends with a value that is not visible ASCII, raises `upstream.malformed`.
Errors name the list position, never the value.

A `header` expression may read only:

- a facade input header,
- a declared response header,
- a Camel engine header the engine sets (`CamelHttpResponseCode` and the redelivery headers),
- a header an earlier step set.

Split and loop metadata is read through exchange-property expressions.
Because `to: direct:` shares the exchange, "an earlier step" reaches across it both ways.
After a `to: direct:` step the caller may read any header the target route sets, transitively through its own `direct:` calls.
A target route may read a header that every one of its call sites sets before the call.
An `enrich` resource route runs on a copy, so its headers never come back.
`adapterctl check` refuses any other read, so a pack cannot depend on a header that is never there.

### Origin-pinned links

{/* Evidence: crates/registry-adapter/tests/camel_http_uri.rs a_dot_segment_is_refused_on_the_raw_text */}
{/* Evidence: crates/registry-adapter/tests/camel_http_uri.rs userinfo_in_any_form_is_refused */}
{/* Evidence: crates/registry-adapter/tests/camel_http_uri.rs a_trailing_dot_host_is_refused */}
{/* Evidence: crates/registry-adapter/tests/camel_http_uri.rs the_query_is_sent_as_written */}
{/* Evidence: crates/registry-adapter/tests/camel_origin_link.rs a_path_and_an_http_uri_together_are_not_served */}
{/* Evidence: crates/registry-adapter/tests/camel_origin_link.rs a_query_beside_an_http_uri_is_not_served */}
{/* Evidence: crates/registry-adapter/tests/camel_origin_link.rs a_link_the_parser_would_repair_is_refused */}
{/* Evidence: crates/registry-adapter/tests/camel_origin_link.rs a_non_string_link_fails_the_exchange_as_validation */}
{/* Evidence: crates/registry-adapter/tests/postgres_security_boundaries.rs off_origin_and_outside_base_links_are_refused_without_any_send */}

Sources page and link by URL: FHIR `link[relation=next]`, HAL and JSON:API.
Camel follows such a link with `toD` or the `CamelHttpUri` header.
The Adapter uses the `httpUri` parameter on an `http` send: exactly one of `path` and `httpUri`, with no `query` beside it.

At send time the engine parses the value as an absolute URL and refuses it with the uncatchable `egress.refused` unless all of these hold:

- its scheme, host and port equal the endpoint's configured origin,
- its path stays under the endpoint's base path after normalisation,
- it carries no userinfo or fragment,
- it fits the URL length bound.

The link is parsed once, and the parsed value is what the engine sends, never a reparse.
A link the parser would silently repair is refused rather than rewritten.
That covers tabs, newlines, `\` read as `/`, and a missing `//`.
A link whose path is not canonical under the transport's fixed-destination rule is refused too.
A trailing-dot host is a different host.
The query string the source wrote is sent as written.
`toD` is not ported, and redirects are never followed.

### Errors become problems

{/* Evidence: crates/registry-adapter/tests/problem_data.rs declared_closed_typed_problem_data_is_rendered */}
{/* Evidence: crates/registry-adapter/tests/problem_data.rs throw_exception_applies_the_serialized_byte_cap_before_the_facade */}
{/* Evidence: crates/registry-adapter/tests/problem_data.rs data_for_a_problem_without_a_declaration_is_a_disclosure_violation */}
{/* Evidence: crates/registry-adapter/tests/problem_data.rs invalid_problem_data_fails_closed_without_value_or_detail_fallback */}
{/* Evidence: crates/registry-adapter-core/src/profile.rs Problem */}
{/* Evidence: crates/registry-adapter-core/src/problem.rs ProblemCode */}

A pack never writes a problem body and never names a profile's problem code.
It raises error classes, and the profile decides what the caller sees.

`throwException` takes an `exceptionType` that names a catchable class, typically an `outcome.*` class.
Its `message` is an optional constant of at most 512 UTF-8 bytes, which fills the profile's `problemDetail` slot when the problem's envelope has one.
Raised inside a route, it is handled by the route's clauses like any error.
Raised inside an `onException` clause, it is the exchange's final failure.

Optional `data` is an expression that supplies only the resolved profile problem's declared `dataFields`.
The data is a closed object of at most 16 required scalar fields and at most 2048 serialised JSON bytes.
It fills the optional whole-value `{{?problemData}}` member.
Unknown, missing, mistyped, undeclared or oversized data becomes a value-free `disclosure.violation`.
It never falls back into `problemDetail`.

The profile's `problems` list maps classes to problems, with `code`, `status`, `title` and `classes` on each entry.
The problem for an error is the entry whose class is closest to the error's class, uncatchable and facade classes included.
`adapterctl check` requires every class in the hierarchy to resolve to exactly one entry, so listing the roots is enough and nothing is ever unmapped.
It refuses a class listed twice, an unknown class, and a status outside 400 to 599.

The authored status governs route and profile failures.
Facade admission failures keep their fixed engine statuses, including 422 for invalid fields and idempotency mismatch.
Their code and title still come from the closest profile problem.
Correlated problem schemas include only that authored status and the fixed class and status pairs that resolve to the same problem.
Another code's status or data shape is not admitted.

The engine fills the problem envelope from the resolved entry, and the journal records the class and the code.
Problem data stays out of logs and the journal.
Profiles that use data publish correlated per-problem schemas, so a code cannot admit another problem's data shape.
Other failures may omit the optional data member.

### direct and enrich

{/* Evidence: crates/registry-adapter/tests/camel_direct.rs the_targets_own_clauses_handle_the_target_first */}
{/* Evidence: crates/registry-adapter/tests/camel_split_loop.rs direct_enrich_runs_the_resource_route_on_a_copy */}
{/* Evidence: crates/registry-adapter/tests/camel_split_loop.rs enrich_merges_the_resource_reply_through_its_strategy */}

`to: direct:<routeId>` runs the target route on the same exchange, as Camel's `direct` does.
Body, headers and properties flow in and come back changed.
Errors raised in the target are offered first to the target's own clauses.
An unhandled error propagates unchanged to the caller's clauses.
A `to: direct:` send is never redelivered, so the target's own sends carry their redelivery.

`enrich` runs its resource send on a copy of the exchange and merges the reply back through its strategy.
The built-in strategies merge bodies only, and properties that the resource route sets are discarded unless the strategy names them.
`json-array-append` and `json-merge` accept `properties`, a map from property name to a JSONPath on the reply, so a pagination loop carries the next cursor or link out of each page.

### JSONPath results

{/* Evidence: crates/registry-adapter/tests/camel_processors.rs jsonpath_yields_its_singular_value_or_its_node_list */}
{/* Evidence: crates/registry-adapter/tests/camel_processors.rs a_non_boolean_predicate_fails_and_a_non_singular_one_never_loads */}

A singular query (RFC 9535 section 2.3.5, a path of name and index selectors only) yields its one value, or absent when nothing matches.
Any other query yields the node list as a JSON array, empty when nothing matches.
Absent raises `validation` where a value is required, as in `setBody` or a `pathParameters` entry.
As a predicate, a singular query must yield a boolean, and absent counts as `false`.
That is the one place where absence has a meaning.
`adapterctl check` refuses a non-singular query as a predicate.
Media types counted as JSON are `application/json` and any `application/*+json`.

## Writes and idempotency

{/* Evidence: crates/registry-adapter-core/src/route.rs IdempotentConsumerStep */}
{/* Evidence: crates/registry-adapter/tests/camel_idempotent_consumer.rs eager_false_defers_eip_membership_until_successful_completion */}
{/* Evidence: crates/registry-adapter/tests/camel_idempotent_consumer.rs remove_on_failure_false_is_applied_at_the_selected_completion_scope */}
{/* Evidence: crates/registry-adapter/tests/postgres_idempotent_modes_authored.rs authored_nondefault_modes_retry_replay_refuse_and_reserve_atomically */}

The profile carries create, update and partial-update operations, and a project binds them per record type, optionally.
A write is a route like any other.
A DHIS2 create is one `to` POST whose import summary the route reads with `choice` and `validate`.
An OpenCRVS registration follows the source's real process (draft, declare) as several `to` steps in sequence.

### Idempotent consumer

Every route bound to a write operation must be wrapped in `idempotentConsumer`, and `adapterctl check` refuses one that is not.
The options ported from Camel are:

- `expression`: the caller's `Idempotency-Key` header.
- `eager`: default true.
- `removeOnFailure`: default true.
- `completionEager`: default false.

The Adapter differs from Camel where HTTP idempotency semantics require it:

- The key is namespaced by the verified issuer, subject, acting client, logical deployment (`runtime.id`) and concrete operation.
- The request digest binds the exact project, profile and pack revision and the request bytes. The same key with a different body or artifact revision is a 422.
- A duplicate replays the recorded facade response instead of being dropped. `skipDuplicate` is not ported.
- The facade atomically reserves the key before guarded work in every mode, including `eager: false`. `eager` still selects Camel's repository-membership timing, but it never opens Camel's non-eager check-then-add race across facade requests.
- A duplicate that arrives while the first is in flight answers 409.
- A reservation that never reached its effect mark (the attempt crashed, panicked or lost its database before sending) is leased for one exchange deadline of 60 seconds. After that, the same request takes it over and runs, and the abandoned attempt can no longer mark, release or finish it. Once an effect is marked, the key never reopens this way.

A facade 409 that the same key can still turn into an answer carries `Retry-After: 5`.
That covers a duplicate within one exchange deadline of the first attempt's claim or effect mark, resumable progress, and an uncertain outcome that a declared safe uncertainty route may still prove.
A 409 without `Retry-After` means the key is spent.
Retrying it cannot succeed, so the caller checks the source for the outcome and sends any new request under a new key.

`removeOnFailure` before any upstream effect removes the key, as in Camel.
A failure after a non-safe `to` has been sent keeps the key in a failed state and replays the recorded problem.
It never re-executes a sent effect.

{/* Evidence: crates/registry-adapter/tests/camel_idempotent_consumer.rs handled_downstream_failure_respects_completion_scope_and_removal_mode */}
{/* TODO[evidence]: no test located for the 60-second reservation lease takeover or the Retry-After: 5 header value; both are stated in the product source only */}

### Response custody

{/* Evidence: crates/registry-adapter/tests/postgres_idempotent_store.rs */}
{/* TODO[evidence]: the response-retention sweep and the legacy-namespace migration refusal have no test anchor located; postgres_idempotent_store.rs is the nearest test file */}

The idempotency store is PostgreSQL, separate from the audit journal.
It is the only place the Adapter retains a response body: the exact facade response, for a retention window the deployment configures, then erased by a supervised sweep.
Deployment identifiers must remain stable across artifact upgrades and distinct for deployments that share a database.
The logical-deployment migration refuses any legacy artifact-namespaced entries, and it preserves their responses and spent keys for operator reconciliation.
It never clears opaque legacy keys or treats them as fresh work.

Exact response replay preserves the original Adapter-minted response request ID in its body and header.
Each physical retry has a fresh journal attempt ID.
A response-custody upgrade that cannot recover a legacy response's original ID refuses migration while that replayable custody remains.
It neither invents an ID nor erases a spent key.

### Write resume

{/* Evidence: crates/registry-adapter-core/src/route.rs ResumeBinding */}
{/* Evidence: crates/registry-adapter/tests/postgres_async_status_link.rs a_linear_write_restarts_at_the_first_unfinished_native_effect */}
{/* Evidence: crates/registry-adapter/tests/postgres_async_status_link.rs a_linear_write_retries_an_uncertain_step_without_repeating_prior_effects */}
{/* Evidence: crates/registry-adapter/tests/postgres_async_status_link.rs a_linear_write_keeps_a_source_202_at_the_same_unfinished_step */}
{/* Evidence: crates/registry-adapter/tests/postgres_async_status_link.rs a_linear_write_can_resume_after_a_malformed_final_source_result_is_repaired */}

Write resume has no Camel equivalent, and its served subset is closed.
One outer `idempotentConsumer` contains a flat sequence of two or more non-safe HTTP `to` steps and nothing else.
Every step names a source operation with the reviewed `idempotentUpstream` assumption.
That assumption means the provider gives repeated identical requests the same logical effect for its documented window.
It is not a claim of general exactly-once delivery or indefinite cached idempotency.

Each successful non-final `to` may declare `resumeBindings`: route-wide unique names and singular RFC 9535 selectors for the bounded source-native identifiers that later steps reference as read-only `AdapterResume.<name>` exchange properties.
A step may declare none.
The final step declares none, because terminal response custody closes it.
Only those identifier strings are retained, never a source response, prepared request body, caller body, headers or credentials.
The first step may derive its body from the admitted caller record.
Every later body, path parameter and query value is reconstructible from governed constants and earlier resume bindings.
Branches, loops, scripts, exception bodies, redelivery, `direct` and nested EIPs are refused in this subset.

The outer consumer reads the facade's `Idempotency-Key`.
Every source send keeps the default non-2xx failure classification and targets an endpoint with no `requestHeaders`.
Neither a permissive status range nor an unstored response header can then change an unfinished request after a retry.
The configured response-retention window must not exceed the provider's documented idempotency window, because the Adapter cannot extend that source-owned guarantee.

Before each physical send, the host durably marks that exact ordinal under a finite lease and the active artifact fence.
After a non-final success it atomically stores the declared identifiers and advances the ordinal.
A same-body, same-key retry by the same caller, logical deployment, concrete operation and current artifact skips committed ordinals and resumes the first unfinished one.
A cleanly returned failed attempt releases its exact lease for immediate repair and retry.
Cancellation or process loss retains the lease until its finite expiry.

Leases and expiries are compared against the clock of the replica that asks, not the database's.
Replicas that share one store must keep their clocks synchronised (NTP).
A replica running fast sees another's lease expire early by its skew, and the required reviewed `idempotentUpstream` assumption is what absorbs the overlapping resend.

Authentication, credential, TLS, transport, HTTP, protocol, validation and checkpoint failures all keep resumable progress and answer the facade's bounded 409.
A generic source 4xx is not silently classified as a terminal business rejection.
A source 202 does not checkpoint or advance the ordinal, because this closed form declares no source status operation.
Expiry erases identifiers and authority but leaves the key spent, so it can never reopen an effect.
A write that expires before its first step is marked attempted sent nothing, so its expiry frees the key instead.

Ingestion jobs do not lift this rule.
A job's source route only reads, and the direct destination sends one BReg operation per item through the BReg client outside the route engine.
No ingestion path hides an import inside a route.

### Batch acceptance, conflicts and recovery

{/* Evidence: crates/registry-adapter/tests/problem_data.rs whole_problem_data_remains_optional_and_plain_problems_are_unchanged */}
{/* TODO[evidence]: no test located for the DHIS2 partial-acceptance 409 carrying only the four counts; the dhis2-tracker pack is the nearest artifact */}

- Batch acceptance, as in DHIS2 import summaries: success requires full acceptance. Partial acceptance maps to a bounded 409 problem that carries the counts alone (imported, updated, ignored, rejected), never the raw upstream summary.
- Conflicts, such as DHIS2 import conflicts or GraphQL error arrays, are raised as `outcome.conflict` or `outcome.rejected` with `throwException`, directly or from an `onException` clause. The profile maps them to its bounded problems with declared detail only.
- There is no compensation and no rollback across upstream calls. Recovery is the source system's native process surface, and the Adapter reports exactly where a sequence stopped.
- Unknown upstream errors never leak. They surface as the profile's problem for their class, at worst the one for the `upstream` root, with no upstream content. `adapterctl check` proves that every class maps.

### Asynchronous writes

{/* Evidence: crates/registry-adapter-core/src/profile.rs ProfileAsyncCompletion */}
{/* Evidence: crates/registry-adapter-core/src/project.rs BindingAsyncCompletion */}
{/* Evidence: crates/registry-adapter-core/src/pack.rs EndpointAsyncCompletion */}
{/* Evidence: crates/registry-adapter/tests/postgres_async_status_link.rs a_status_link_mode_returns_and_replays_202_without_repeating_the_effect */}
{/* Evidence: crates/registry-adapter/tests/postgres_async_status_link.rs bounded_wait_returns_the_committed_202_after_its_poll_count_is_spent */}
{/* Evidence: crates/registry-adapter/tests/postgres_async_status_link.rs bounded_wait_cancels_a_slow_poll_at_its_deadline_and_returns_the_committed_202 */}
{/* Evidence: crates/registry-adapter/tests/postgres_async_status_link.rs status_get_reauthenticates_the_original_caller_and_current_write_scope */}
{/* Evidence: crates/registry-adapter/tests/postgres_async_status_link.rs an_expired_status_link_is_hidden_and_the_write_key_stays_spent */}
{/* Evidence: crates/registry-adapter/tests/postgres_async_status_link.rs an_uncertain_effect_can_be_proved_terminal_without_repeating_the_mutation */}
{/* Evidence: crates/registry-adapter/tests/postgres_async_status_link.rs an_unknown_effect_without_source_recovery_stays_spent_and_never_repeats */}
{/* Evidence: crates/registry-adapter/tests/postgres_async_status_link.rs an_acceptance_journal_fault_commits_neither_202_nor_false_acceptance */}

A source-native asynchronous write is declared in all three artifacts together.

- The profile operation has `successStatus: 202` and `asyncCompletion` with `completedStatus`, a profile-owned `statusPath` whose whole `{statusId}` segment is opaque, and an `acceptedEnvelope` that uses exactly `statusLink`, `statusExpiresAt` and `requestId`.
- The project binding selects `asyncCompletion.type: status-link` or `bounded-wait`. Bounded wait also declares `waitTimeoutMilliseconds`, `pollIntervalMilliseconds` and `maximumPolls`.
- The bound source operation declares `asyncCompletion` with a singular `acceptedId.jsonpath` and a safe `statusRoute`. It may also declare `uncertaintyRecovery.requestHeader` and its safe `statusRoute`.

Both modes first commit, in one PostgreSQL transaction, the exact profile-rendered 202, its expiry, the source identifier, the original caller and artifact authority, and the value-free `exchangeAccepted` journal event.
Status-link returns that response immediately.
Bounded-wait performs no more than its three authored time, interval and poll bounds, then returns a proven terminal response or the same committed 202 byte for byte.
Its timeout must be strictly below `idempotency.responseRetentionSeconds` converted to milliseconds, so the returned link keeps its original acceptance-anchored expiry.
It never receives a fresh retention window because the caller waited.

A status GET reauthenticates the original caller against the initiating operation and record type under the current access profile.
The opaque handle grants no independent authority.
One non-blocking, deployment-bounded safe poll runs over a fresh value-free exchange.
Pending or uncertain checks return the exact stored 202.
Terminal proof is disclosure-checked and committed atomically with its journal.
Terminal lookup remains available until the original accepted expiry, even though source identifiers are erased at the terminal transition.
No raw source `Location` or authority is followed.

Before the non-safe send, an optional source-native uncertainty correlation is generated by the host and committed with the finite effect deadline.
It is installed only under the source operation's reviewed request header, after authored header filtering.
A safe uncertainty route may prove a terminal outcome on the initial call or on a same-key retry.
Pending or unproved outcomes remain spent and answer 409 with `Retry-After` until the effect deadline.
Past the deadline, or when no such proof path is declared, they remain spent permanently and the 409 carries no `Retry-After`.
Recovery never grants authority to repeat the mutation.

Recovery is also bound to the source origin the write reached.
The precommit pins a digest of the configured `baseUrl` of every endpoint the write, status and uncertainty routes reach.
Credentials are outside it, so a credential rotation keeps recovery.
Every poll, whether a status GET, a bounded wait or a same-key retry's uncertainty check, runs only while the current runtime configuration yields the same digest.
A row whose pin differs, or that carries none, is never polled.
Its status link answers the exact stored 202, a bounded wait returns the committed 202, and a retry answers 409 without `Retry-After`, until the accepted expiry or the effect deadline ends it.
Restoring the original `baseUrl` lets that work finish.
Each held poll logs a value-free warning and adds no journal event kind.

### Artifact fence

{/* Evidence: crates/registry-adapter/tests/postgres_async_status_link.rs an_asynchronous_hotfix_is_refused_while_the_older_artifacts_write_is_unfinished */}
{/* Evidence: crates/registry-adapter/tests/postgres_async_status_link.rs a_synchronous_successor_starts_and_answers_the_older_artifacts_status_link_as_unknown */}
{/* Evidence: crates/registry-adapter/tests/postgres_async_status_link.rs a_status_link_survives_restart_under_the_same_artifact_and_caller */}

The artifact fence binds recovery authority to one artifact (the digest of the project, profile and pack bytes) per `runtime.id`.
Only a deployment that declares an asynchronous or resumable write activates it.
Activation advances the fence, and every async or resume precommit checks it, so an older artifact cannot start a fresh effect once a successor has activated.

Activation is refused only while another artifact still holds unfinished work for that deployment: an attempted or accepted async write, or an unexpired resume of two or more steps.
An interrupted single-step write never blocks.
A retry under another artifact or another source origin answers effect-unknown and never resends.
A single-step write whose step never started is reclaimed once its lease lapses.
Terminal rows never block, so a hotfix or a rollback starts once the older artifact's unfinished work has finished or expired.

The refusal names the count and the instant the last of that work expires.
The operator either redeploys the previous artifact bytes so the work can finish under them, or waits until that instant.
A synchronous or read-only successor never touches the fence and starts at once.
Each row is bound to its own artifact digest, so the successor answers the older artifact's status links as unknown, and the older artifact answers them again if it is redeployed.

### Fixed GovStack direct write

{/* Evidence: crates/registry-adapter-core/src/write.rs SourceWriteSupport */}
{/* Evidence: crates/registry-adapterctl/tests/compile.rs the_real_unified_breg_govstack_project_compiles_create_and_update */}
{/* Evidence: crates/registry-adapterctl/tests/compile.rs missing_unified_create_ingress_refuses_check_and_compile */}
{/* Evidence: crates/registry-adapterctl/tests/check.rs a_real_write_only_breg_govstack_project_checks_with_the_fixed_target */}

The maintained GovStack host selects synchronous Create and conditional Update without an authored facade profile.
[Adapter Consultation](../adapter-consultation/) describes the selected wire surface.

A project declares a domain input schema and a pinned ingress transformation per write binding.
The public input and the source's private route input are separate.
The source template declares `writeSupport` explicitly: `create-one` (source-assigned Create identity) or `conditional-update-one` (atomic conditional Update), each with its exact native replay window.
These declarations require source-specific proof; neither an HTTP success nor a transformation creates those guarantees.

This target's idempotency key is a bounded quoted Structured Field String.
Its fingerprint binds canonical JSON, method, canonical public URI, media type and semantic `If-Match`, rather than the generic profile's exact request bytes.
Public mutation guards reuse `cursorKeyRef` through a separately derived authenticated opaque codec.
They bind the source, read and access context, and never expose the native validator as reversible plain encoding.

Caller identity and logical deployment stay in the key namespace.
The upstream key is independently derived from that trusted namespace, a random generation drawn when the claim is inserted, and the source step ordinal, so a shared service credential cannot collapse callers.
Every resend of one claim repeats its upstream key.
Once the replay window has passed, a reused key is processed as a new request under a new generation, so the source never replays or refuses it under an earlier claim.

The target opts one deterministic, source-idempotent POST into the resumable custody plan.
Recovery keeps typed progress and source identity only, requires the same request to be resubmitted, and depends on the native provider returning the original committed receipt within its declared replay window.
The facade refuses a retention window longer than that source guarantee.

Terminal response custody includes only the closed semantic headers `Content-Type`, `Location` and `ETag`, the exact status and body, and the original response id.
`Content-Type` is optional for an empty response, and 204 is bodyless and has none.
Fresh problems receive their effective trace before terminal storage.
Replay keeps their body unchanged while per-attempt trace headers are regenerated.
Response custody and terminal audit remain one PostgreSQL transaction.

## Authorisation and secrets

### Facade callers

{/* Evidence: crates/registry-adapter-core/src/project.rs AccessProfile */}
{/* Evidence: crates/registry-adapter/tests/postgres_security_boundaries.rs expired_and_wrong_audience_tokens_are_refused_before_source_io */}
{/* Evidence: crates/registry-adapter/tests/oauth_served_route.rs */}
{/* TODO[evidence]: allowedClients admission and the required non-empty list have no test located by symbol in the files searched */}

Every facade call is authenticated with an OIDC bearer token through the platform block, as in every Registry Stack product.
It is authorised by the Adapter's own access profiles: named bindings of scopes to concrete facade operations and record types, declared in the project.
The facade accepts no API keys, no Basic authentication and no anonymous calls.
The Adapter inherits no authorisation from any product and grants none to any source.

The caller's token is never forwarded upstream.
Upstream calls run under the deployment's own credential for that source, or without a source credential only under the explicit anonymous HTTPS admission described below.
The journal records which caller asked.

The runtime config's required, non-empty `allowedClients` list names the OAuth clients the deployment admits.
A token from any other client is refused even when its scopes match an access profile.

Client admission is not record-level authorisation.
The facade serves trusted machine clients only.
Any admitted client with a matching scope sees every record that the deployment's configured source access reaches, because scopes gate operations and record types, not individual records.
Record-level authorisation is not built.
Admitting a client means trusting it with the full reach of the deployment credential.

### Upstream authentication

{/* Evidence: crates/registry-adapter-core/src/auth.rs EndpointAuthentication */}
{/* Evidence: crates/registry-adapter-core/src/auth.rs RuntimeCredential */}
{/* Evidence: crates/registry-adapter-core/src/runtime.rs AnonymousHttpsAcknowledgement */}
{/* Evidence: crates/registry-adapter/tests/camel_http_authentication.rs basic_sends_one_preemptive_header */}
{/* Evidence: crates/registry-adapter/tests/camel_http_authentication.rs static_authorization_presents_the_declared_scheme */}
{/* Evidence: crates/registry-adapter/tests/camel_http_authentication.rs static_api_key_uses_the_declared_header */}
{/* Evidence: crates/registry-adapter/tests/camel_http_authentication.rs the_assertion_travels_bound_to_the_token_endpoint */}
{/* Evidence: crates/registry-adapter/tests/camel_http_authentication.rs none_sends_nothing_and_stays_loopbound */}
{/* Evidence: crates/registry-adapter/tests/camel_http_authentication.rs the_budget_holds_two_sends */}
{/* Evidence: crates/registry-adapter/tests/camel_http_authentication.rs the_401_rule_runs_over_the_issued_credential */}
{/* Evidence: crates/registry-adapter/tests/camel_http_authentication.rs a_401_with_an_unparseable_body_is_still_rejected */}
{/* Evidence: crates/registry-adapter/tests/camel_http_authentication.rs the_cache_answers_and_refusals_name_only_the_code */}
{/* Evidence: crates/registry-adapter/tests/camel_http_authentication.rs trust_material_resolves_or_refuses_value_free */}
{/* Evidence: crates/registry-adapter/tests/camel_http_authentication.rs both_placements_carry_the_secret_once */}

The pack endpoint declares one `authentication` kind from a closed list, and the runtime config binds its credentials as `secret:` references.
The kinds and their fields are spelled as Evidence spells them for fixed sources, so an operator who configured an Evidence source configures an Adapter endpoint the same way.

- `none` sends nothing. It requires an explicit runtime `credential: {type: none}`. It is admitted only for numeric loopback, for an endpoint with an mTLS client identity over HTTPS, or for a fixed HTTPS source that carries `anonymousHttps: operator-approved`. Typical uses are tests, mTLS-only sources and reviewed public APIs.
- `basic` sends `Authorization: Basic` from `usernameRef` and `passwordRef`, for example for DHIS2 user accounts. It is sent preemptively, with no challenge round trip.
- `static-authorization` sends `Authorization: <scheme> <token>` from `tokenRef`, with `scheme` defaulting to `Bearer`. Typical uses are DHIS2 personal access tokens (`ApiToken`) and static bearer tokens.
- `static-api-key` sends one declared header (`headerName`) from `valueRef`. Reserved header names are refused. A typical use is a gateway keyed by an API-key header.
- `oauth2-client-credentials` sends a bearer token from the RFC 6749 client-credentials grant with a shared secret. Its fields are `credentialPlacement`, `scope`, `audience`, `resource` and a bounded cache. Typical uses are OpenCRVS-style integration clients and Keycloak-fronted APIs.
- `oauth2-private-key-jwt` sends a bearer token from the client-credentials grant, authenticated by an RFC 7523 signed assertion. Typical uses are SMART on FHIR Backend Services and high-assurance gateways.

Independent of the kind, the runtime config may give an endpoint a private CA and an mTLS client identity, so mutual TLS combines with any kind.
The private CA is `outboundTls.trustProfiles.<id>.caBundleFile` in the runtime config, named by the endpoint binding's `tlsTrustProfile`.
A CA bundle is not a secret.

A pack `authentication.type: none` with an explicit runtime `credential.type: none` may reach a fixed non-loopback HTTPS source only when the same binding says `anonymousHttps: operator-approved`.
The acknowledgement is a named operator decision, not a boolean, and omission stays closed.
It is refused on HTTP or with any other authentication pairing.
It is harmlessly redundant on an admitted `none` plus mTLS HTTPS binding.
TLS certificate verification, the fixed destination policy, facade authentication, and the rule that caller tokens never travel upstream remain unchanged.
`none` never falls back from a failed Basic, static or OAuth credential.
The acknowledgement selects no destination and supplies no credential, and the binding's fixed `baseUrl` and normal TLS trust remain authoritative.

Field bounds follow Evidence:

- `scheme`: 1 to 32 HTTP token bytes.
- `headerName`: at most 64 bytes.
- `tokenEndpoint`: ASCII URI bytes with complete percent escapes, and without query or fragment.
- `clientAssertionAudience`: 1 to 512 non-blank bytes. It is required for `oauth2-private-key-jwt` and has no default.
- `scope`, `audience` and `resource`: Evidence's bounds and validators.

The rules for credentials are:

- The token endpoint of an OAuth2 kind is itself a fixed destination bound in the runtime config, never derived from a response. Token requests are engine sends outside `maximumUpstreamCalls`, bounded separately at two per endpoint per exchange.
- The `oauth2-private-key-jwt` assertion carries `clientAssertionAudience` as its only audience and has the header `typ: client-authentication+jwt` (RFC 10070 section 4). The member is the authorization server's issuer identifier, exactly as its metadata publishes it, and a runtime credential without it is refused when the configuration is read.
- The token request goes through the endpoint's own outbound client, with the same trust profile and the same mTLS identity.
- Key material loads when the deployment loads. A client identity, a CA bundle or a signing key that cannot be read refuses startup, never the first caller's request.
- Token responses require `token_type` `Bearer` in any case. A missing `expires_in` takes the operator's `assumedLifetimeSeconds` and, without one, fails as a credential error. The lifetime is anchored when the request is sent, not when the reply arrives. The cache is clamped to `maximumCacheSeconds`, unknown members are ignored, and refresh is single-flight.
- Under the `basic-header` placement, the client id and secret are base64 encoded as written, without the form-encoding step of RFC 6749 section 2.3.1. A strict server mis-decodes a secret that contains `%`, `+` or non-ASCII bytes, and such a client uses the `form-body` placement.
- For an OAuth2 kind, an upstream 401 invalidates the cached token and the send is repeated once with a fresh one. This is safe for writes too, because a 401 means the request was not processed. A 401 after that, or any 401 under a static kind, raises the uncatchable `credential.rejected`. A route cannot repair a credential, and a fallback must not mask one. A 403 stays `upstream.http`, because it answers about the request, not the credential. The 401 rule holds whatever `okStatusCodeRange` and `throwExceptionOnFailure` say, and `adapterctl check` refuses an `okStatusCodeRange` that covers 401 on an endpoint whose kind is not `none`.
- Tokens and secrets live in zeroising buffers inside the `http` and `graphql` components only. The exchange, scripts, packs, fixtures, diagnostics and the audit journal never see them. The journal records the endpoint's kind and token-request outcomes, never a value.
- Fixture replay intercepts the token endpoint like any other send, so packs are replayable without a credential.

Camel's NTLM and Digest methods, API keys in the query string (they leak into upstream and proxy access logs), and caller token exchange are not ported.

## Audit and data minimisation

{/* Evidence: crates/registry-adapter/tests/postgres_journal.rs the_journal_refuses_unknown_kinds_and_oversized_details */}
{/* Evidence: crates/registry-adapter/tests/postgres_journal.rs retention_deletes_expired_rows_in_bounded_oldest_first_batches */}
{/* Evidence: crates/registry-adapter/tests/postgres_journal.rs append_stamps_occurred_at_from_the_runtime_clock */}
{/* Evidence: crates/registry-adapter/tests/postgres_journal.rs the_runtime_role_needs_insert_select_and_delete_on_the_journal */}
{/* Evidence: crates/registry-adapter/tests/postgres_security_boundaries.rs assert_no_markers */}

The audit journal is Camel's event notifier, ported as a synchronous, value-free PostgreSQL journal that is written before the response is sent.
Event kinds follow Camel's:

- `exchangeCreated`.
- `exchangeSending` and `exchangeSent`, with endpoint id, method, path template, status, duration, response size and digest.
- `exchangeRedelivery`.
- `exchangeFailureHandled`.
- `breakerRefused`, with the closed breaker state.
- `breakerFallback`, with the closed error class and fixed authentication-event metadata.
- `exchangeCompleted`.
- `exchangeFailed`, with the error class and problem code.

A linear resumed write also records `resumeStepStarted` (the zero-based ordinal after its durable pre-send mark) and `resumeStepCheckpointed` (the completed and next ordinals plus the binding count).
It never records binding names or values.
These buffered lifecycle events are flushed before a normal response and can be absent after cancellation or a process crash.
The durable `exchangeCreated` intent and the idempotency premark remain the recovery authority.

A verified caller's refused call is one `callRefused` row: the 403 of an access profile and the 404 of a wrong record type.
Probing is therefore auditable.
A 401 is logged and not journaled, because no verified caller exists to name.

Each row carries the exchange id, the concrete operation, the caller identity, the route id, and `occurred_at` (`timestamptz NOT NULL`, from the runtime clock at the event, indexed for retention deletes).
It records no bodies: no request payloads, no response payloads, no field values and no filled query strings.
Retention follows the shared `audit.retentionDays` block.
The idempotency store is the one retained body, and it has its own retention.
Diagnostics are value-free.

## Field mapping

{/* Evidence: crates/registry-adapter-core/src/mapping.rs AdapterMapping */}
{/* Evidence: crates/registry-adapter-core/src/preview_expectations.rs AdapterPreviewExpectations */}
{/* Evidence: crates/registry-adapterctl/tests/mapping.rs check_reports_the_target_tree_the_checker_reads */}
{/* Evidence: crates/registry-adapterctl/tests/mapping.rs generate_twice_reports_unchanged_with_identical_bytes */}
{/* Evidence: crates/registry-adapterctl/tests/mapping.rs generate_refuses_to_overwrite_a_handwritten_script_unless_forced */}
{/* Evidence: crates/registry-adapterctl/tests/mapping.rs preview_names_the_failing_field_without_the_value */}
{/* Evidence: products/adapter/examples/kobotoolbox-job/mappings/register-household.mapping.yaml AdapterMapping */}

An `AdapterMapping` file describes how source fields fill a target schema.
`adapterctl mapping generate` writes an ordinary Rhai script from it, and the script is what the runtime executes.
Generation changes no transformation semantics and no deployed runtime format.
The mapping format covers Consultation data, Evidence facts and the input of an ingestion direct destination.

### Commands

- `adapterctl mapping check` validates the model and reports the target tree.
- `adapterctl mapping generate` writes the script and reports its digest.
- `adapterctl mapping preview` runs the generated script over sample source items.
- `adapterctl project lock` updates a project's script and schema pins and binding references.
- `adapterctl job lock` rewrites a job's mapping digest from the generated script's bytes. With `--pack` it also rewrites the pack pin.

Each generated script begins with a header that names its model file and the digest of the model's parsed content.
A layout-only edit (comments, a byte order mark, line endings, document markers) does not change the digest.
Generation refuses to overwrite a handwritten script or another model's script unless you pass `--force`, and it preserves existing files when a conflict or an invalid export stops it.
The model sits inside the directory tree of the document that owns the script.
Paths in the model (`targetSchema`, `script`) resolve against the model file.

The marker on the header's first line is what makes a script generated, so a script without it is handwritten.

When a script no longer matches its model, `adapterctl check`, `adapterctl job check` and `adapterctl mapping check` warn with `adapter.mapping.script-drift`.
The warning is not blocking, because a handwritten script is a supported state.
Regenerating discards hand edits.
Removing the whole generated header keeps a handwritten script.

{/* Evidence: crates/registry-adapterctl/src/mapping.rs script_drift */}
{/* Evidence: crates/registry-adapterctl/src/check.rs verify_pack_mapping_drift */}

The drift check covers these scripts:

- the scripts a project inventories;
- the scripts a pack inventories, where the model must lie inside the pack's directory;
- in `adapterctl job check`, the job's direct destination mapping and its pack's scripts.

From the model's side, `adapterctl mapping check` warns when the script at `mapping.script` is not what the model generates now, including when that script is handwritten or another model's.
A missing script is not a finding.

{/* Evidence: crates/registry-adapterctl/src/mapping.rs Annotation */}

Only the warning from `adapterctl mapping check` carries a `cause`.
It is `model-changed` when the header's model digest is not the model's digest now, and `script-differs` when the digest matches but the bytes differ.
`script-differs` covers a hand edit, an edited header and a script that another adapterctl version generated.
The header records only the model's digest, so a changed model does not rule out hand edits as well.
Warnings from `adapterctl check` and `adapterctl job check` carry no `cause`, so their cause is undetermined.

### What the format expresses

The format supports:

- scalar copies and constants;
- nested target objects;
- exact keyed selection from a bounded array;
- explicit string-to-integer and integer-to-string conversion;
- canonical `YYYY-MM-DD` date validation.

Conversions do not guess formats.
Keyed selection requires one match and rejects duplicates.
Missing values fail by default, and explicit omission is allowed only for optional target fields.
Required unmapped fields, conflicting assignments, invalid selectors and unsupported operations block export, with errors addressed to the assignment.
General loops, general conditions, arbitrary code nodes, XML and XSLT, import of handwritten Rhai and live-source preview are not supported.

A selector is dotted segments.
A segment is a plain name (`[A-Za-z_][A-Za-z0-9_]*`) or a quoted key, and may carry one exact filter, `[name = "value"]`.
A quoted key or filter value holds 1 to 128 characters.
It may not contain a control character, a text-direction control (U+061C, U+200E, U+200F, U+202A to U+202E, U+2066 to U+2069) or a line or paragraph separator (U+2028, U+2029).
`'"prénom"'` and `'places[name = "Saint-Étienne"].code'` are valid.
`\"` and `\\` are the only escapes, and any other backslash is refused.
Keys and values are compared byte for byte with no Unicode normalisation, so a letter written as one character and the same letter written as a base letter plus a combining accent are different keys.

The `AdapterMapping` example for the KoboToolbox job has these shapes:

```yaml
apiVersion: id.registrystack.org/formats/adapter/mapping/v1alpha1
kind: AdapterMapping
mapping:
  id: register-household
  target: ingestion
  ingestionMode: proposal
  targetSchema: register-household-input.schema.json
  script: register-household.rhai
  entrypoint: map_submission
assignments:
  - target: sourceSubmissionId
    from: _id
    convert: text
  - target: respondentName
    from: respondent_name
  - target: householdSize
    from: '"household.household_size"'
    convert: integer
```

For a read mapping, a documented synthetic fixture has these assignments:

| Source selection | Target | Rule |
| --- | --- | --- |
| `orgUnit` | `registration.organisationUnit` | Copy string |
| `updatedAt` | `registration.lastChangedAt` | Copy string |
| `attributes[attribute = "Dob00000001"].value` | `person.dateOfBirth` | Exactly one match; validate date |

The closed target schema requires those strings, with `format: date` on `dateOfBirth`.
Attribute selection is generic keyed-array selection, with no engine operator specific to the source.
A field mapping does not establish programme membership or enable API operations.

### Targets

- A Consultation mapping reads one source item from a pack read route and fills the project's data schema, excluding protocol envelopes.
- An Evidence mapping reads matched native facts and fills the Evidence Source's facts schema.
- An ingestion direct destination mapping reads one source item and fills the destination BReg operation's input, or yields an item-scoped refusal. The generator wraps the mapped input in the job's destination shape (for a Proposal, `startInput` and `submitBody`).

A failed required value, conversion or validation in an ingestion mapping becomes an item-scoped refusal under the profile's mapping problem, never a deployment-level stop.
Mapping for a Coordinator event destination runs in a Coordinator Function and is outside this format.
The write direction (a record mapped to a source request body) uses the same model with the source request schema as the target, and is generated and checked only.

### Source fields

The model stores no source schema.
Source fields come from the sample items and from the model's existing selectors.
For an ingestion job the samples are the files in its `preview/` directory.
The job's `projection.fields` must also name the answer, and a dotted path reaches the mapping as one literal key, which the model quotes (`'"household.village"'`).
Removed identifiers and incompatible schema changes require explicit correction.

### Check report

`adapterctl mapping check --format json` reports the target as it reads it.

- `targetTree` lists the target schema's properties, each with `path`, `key`, `required` and `mappable`, and, when known, `type`, `format`, `const` and `enum`. A mappable leaf lists the `conversions` the checker accepts for it, and an object lists its `children`.
- `mappable` means an assignment can target the node: a scalar leaf whose path the target-path grammar can express. An object is never mappable, though its children may be. An array, a node that uses a reference or composition keyword, and a key or depth the grammar cannot write (an empty key, a refused character, more than 16 segments or 256 characters) are not mappable and carry no `conversions`.
- The order within a level is unspecified (currently alphabetical by key).
- `targetTitle` is the `title` of the target schema's root, for display only. It is absent when the root has no title or an empty one, and when the schema cannot be read. The text form leaves it out.
- `required` means required by the parent object. A required field under an optional object that nothing fills is not left to do. The to-do list is the `adapter.mapping.required-unmapped` findings, read by their `target`.
- A finding's `target` is the field's canonical path (a quoted `'"householdSize"'` reports as `householdSize`) and joins `targetTree[].path`. For `adapter.mapping.target-unknown` it names a path that is not in the tree. A finding about an assignment's `from`, `convert` or `whenMissing` carries that assignment's `target`.
- `adapterctl job check` warns with `adapter.job.mapping-unprojected` for each assignment of a current generated destination mapping whose source key the job's `projection.fields` does not list. The source key is the first segment of `from`, unquoted. The warning's `path` is `/assignments/<i>/from` in the model and it carries `target`. `--deny-warnings` turns the warning into a refusal. Nothing is reported when the model is missing, invalid or has drifted from its script.

The report keeps its members, `targetTree` included, when `--deny-warnings` turns a warning into a refusal.
`targetTitle` and `targetTree` are also present on a refusal.
Clients ignore members they do not know.

### Preview

Preview runs the generated script through the Rust transformation API on source items you supply and shows its validated result or a value-free refusal.
It performs no source acquisition, credential resolution, signing or activation.
Pack fixtures hold upstream exchanges rather than source items, so for Consultation the end-to-end proof over them stays with `adapterctl fixtures replay`.
The ingestion target previews the operation input inside the destination shape.
For ingestion, preview validates the output against an authored mirror of the destination operation input, which you keep in sync with the operation by hand.
Preview does not apply uniform native input-schema validation.

For a generated script, a refusal names the target field and the reason (`mapping.missing`, `mapping.duplicate` or `mapping.conversion`), never the value.
`mapping check` and `generate` apply the same compile acceptance as the runtime, so a target schema the runtime would refuse (`adapterctl.mapping-schema-not-public`) fails before preview.

### Expected results

An optional `expected.yaml` beside the samples (for the KoboToolbox job, `preview/expected.yaml`) is an `AdapterPreviewExpectations` document that states what each sample should give.

```yaml
apiVersion: id.registrystack.org/formats/adapter/preview-expectations/v1alpha1
kind: AdapterPreviewExpectations
samples:
  accepted-integer-id:
    type: accepted
  missing-respondent:
    type: refused
    target: respondentName
```

- A sample is named by its file name without the extension, and the sample files stay plain source items.
- `type: accepted` expects the mapping to accept the sample.
- `type: refused` expects the mapping to refuse it, for any reason. The optional `target` also requires the refusal to name that target field. The target is written as in an assignment's `target`, and must be the target of an assignment that has a `from`.
- A refusal matches when any finding of the refusal names the target. Preview currently reports one finding per refused sample, the first field that failed.
- A sample that could not be read as a source value (`input-unreadable`, `input-too-large`) matches no expectation.
- A name in the file with no sample file beside it is refused with `adapter.mapping.expectation-sample-unknown`. A target no assignment reads from the source is refused with `adapter.mapping.expectation-target-unknown`. A sample the file does not list has no expectation.
- `adapterctl mapping preview` reads the `expected.yaml` in the directory of its `--input` files, so no flag is needed. The file itself is never a sample, so `--input preview/*` leaves it out, and a run left with no sample fails like a missing input. A sample is any file passed as an input or any `.json`, `.yaml` or `.yml` file in that directory, whatever the case of its extension. Inputs from several directories each read their own file, once.
- The JSON report gives each judged result `expected` (`{outcome: accepted}`, `{outcome: refused}`, or `{outcome: refused, field}`) and `matched`, and the run a `mismatched` count. A mismatch raises `adapterctl.mapping-preview-mismatch` at `/samples/<name>`, naming both results and never a source value, and the run exits 1 with the report still carrying every result. The text form shows the expectation on each line, on a refused run as on a passing one.

## Fixture replay

{/* Evidence: crates/registry-adapter-core/src/checks.rs FixtureCredentialRecorded */}
{/* Evidence: crates/registry-adapter-core/src/fixture.rs answer_send */}

A recorded token exchange is replayed as written, and the checks do not inspect the token in its reply.
Before you commit a fixture that you captured from a live instance, you must replace the token in the recorded token reply with a synthetic value.
`adapterctl check` refuses a recorded credential header on either side of an exchange and a recorded token request body (`adapter.fixture.credential-recorded`).
It does not read the token reply.

Every maintained pack ships recorded upstream exchanges with expected facade responses, and each fixture entry names the facade operation it exercises.
`adapterctl fixtures replay` and `adapterctl check` run them offline.
Every `http` and `graphql` send is intercepted and answered from the fixture in order.

{/* Evidence: crates/registry-adapter-core/src/fixture.rs ReplayMismatch */}
{/* Evidence: crates/registry-adapterctl/tests/fixtures_replay.rs an_exact_facade_mismatch_names_the_structural_member */}

- The outgoing request must match the recorded method, path, query and body digest.
- The facade response must equal the expected one byte for byte and validate against the generated schema.
- An error fixture must map to the expected problem codes.

{/* Evidence: crates/registry-adapter-core/src/fixture.rs token_requests_answer_under_the_token_intercept */}

A token request matches by endpoint, method and path alone, because replay runs without a credential.
A recorded token exchange carries no credential header or body.

{/* Evidence: crates/registry-adapterctl/src/lib.rs fixtures_command */}
{/* Evidence: crates/registry-adapterctl/tests/fixtures_replay.rs the_minimal_suite_replays_against_its_compiled_contract */}

`fixtures replay` runs the route interpreter through an offline transcript transport and shares the facade's disclosure and response rendering.
It reports `drive: completed` only after the ordered sends and the expected facade result match, with no unexpected or leftover exchanges.
No live credential, source, listener, database or journal is used.
Writes report `writesSimulated` and `journalDurability: not-run`, so a passing replay does not establish durable write behaviour.
Replay cursors use a fixed synthetic context with the production codec; live cursor sealing continues to use fresh randomness.

{/* Evidence: crates/registry-adapter-core/src/fixture.rs FixtureProvenance */}
{/* Evidence: crates/registry-adapter-core/src/fixture.rs provenance_kinds_are_closed */}

Provenance is mandatory.
Each fixture records a `type`, the upstream version (`upstreamVersion`) and a `reference`.
The `type` is `captured` (recorded from a running instance, with the instance version string as the reference) or `documented` (synthesised from the source's published API documentation, with the documentation URL as the reference).
A pack declares its tested versions.
A fixture without provenance fails check, and a `documented` fixture never claims capture.

## External projection acquisition

{/* Evidence: crates/registry-adapter-core/src/projection.rs ProjectionResult */}
{/* Evidence: crates/registry-adapter-core/src/pack.rs SourceRouteDecl */}
{/* Evidence: crates/registry-adapter-engine/tests/projection_acquisition.rs a_present_record_must_include_every_requested_field */}
{/* Evidence: crates/registry-adapter-engine/tests/projection_acquisition.rs a_fields_schema_cannot_constrain_which_fields_are_present */}
{/* Evidence: crates/registry-adapter-engine/tests/projection_acquisition.rs keyed_absence_is_distinct_from_ambiguous_or_wrong_identity */}
{/* Evidence: crates/registry-adapter-engine/tests/projection_acquisition.rs native_batch_requires_exactly_one_outcome_for_each_requested_key */}
{/* Evidence: crates/registry-adapter-engine/tests/projection_acquisition.rs a_collection_is_released_only_as_one_complete_parent_snapshot */}
{/* Evidence: crates/registry-adapter-engine/tests/projection_acquisition.rs governed_retention_and_raw_response_restrictions_are_independent */}

A pack can declare a `sourceRoutes[].projection` for a host that reads a reviewed subset of records for a named purpose.
This is a separate source entry point.
The facade, ingestion jobs and Evidence cannot bind it as one of their own operations.
The source authority's operation version, purpose, eligible scope, selector scheme and record-key scheme must agree with the host's governed project and operator binding.
The host establishes the current grant and the requested keys and fields before acquisition, and it is responsible for terminal audit and any retained data.
The operation must declare `localDisclosure: host-profiles` for the host to disclose under its local profiles when using the shared service identity.
A route marked `acquisition-only` provides no such authority.

The acquisition uses the listener-free engine, existing endpoint bindings, a reviewed connection policy and a service credential.
The operation is read-only: HTTP GET or a named, reviewed safe POST.
The pack may map source protocols with its digest-pinned scripts.
The host supplies a finite operation, response-byte and deadline budget that spans all pages and physical calls.
The route declares limits on batch keys, collection pages and total collection rows.

Every source invocation receives a JSON object with `type` and `fields`.
An `exact` invocation supplies `key`.
A `batch` supplies unique `keys`.
A `by-parent` invocation supplies `parentKey` and, after the first page, the previous page's opaque `cursor`.
Route results have these closed shapes:

| Type | Members |
| --- | --- |
| `exact` | `record`, one keyed outcome for the requested key |
| `batch` | `records`, exactly one keyed outcome per requested key |
| `by-parent` | `parentKey`, `snapshot`, `rows`, `complete` and optional `nextCursor` |
| `unavailable` | No data members |

An exact or batch record carries `key` and an `outcome`.
`present` includes `fields` and optional `sourceRevision`.
`authoritative-absent` may include `sourceRevision`.
`unavailable` carries only the key.
Authoritative absence requires a source contract that permits it and a successful source response that explicitly confirms absence for that key.
Ambiguous matches, protected existence, HTTP denial and transport faults cannot establish absence.

The engine validates every returned field against the digest-pinned closed JSON Schema and refuses fields the host did not request.
Each view requests its own fields and every requested field must be returned, so the schema describes each field and must not require fields at the top level.
A pack whose `fieldsSchema` uses `required`, `minProperties`, `maxProperties`, `dependentRequired`, `dependentSchemas` or a composition keyword at the top level is refused when the projection compiles.

A collection row carries a stable unique `key`, the requested `parentKey`, `fields`, and an optional `sourceRevision`.
A snapshot preserves one parent and snapshot identity across every page, terminates with explicit `complete: true`, and never repeats a cursor or row key.
A completed empty snapshot is a result.
An interruption yields no collection to the host.

Live acquisitions have no storage in the Adapter.
Indexed acquisitions require an explicit `retention: retain` operation before any source call.
The engine also checks the raw `Cache-Control` header on every data response before any pack mapping.
A `no-store` response leaves the acquisition usable for live reads and unavailable for retention.
That restriction survives mapping and paging.
Consultation's protected response headers stay unchanged.

## Typed payment hosting

The optional payment module in `registry-adapter` mounts dedicated collection, disbursement, observation and reporting operations on the Adapter listener, outside the generic record routes.
Registry Coordinator exposes them as native typed steps.
A workflow supplies the bill or instruction record identity and version, then uses the accepted attempt identifier for observation and reporting.
Tenant, biller, provider origins, credentials, currency policy and the restricted BReg Actions are operator-owned connection configuration, and a payment-only deployment needs no record project.

Base Registry Engine (BReg) owns the authoritative bills and fee policy, the approved disbursement instructions, the recorded receipts and provider confirmations, and the service's paid or unused issuance guard.
The payment host owns durable attempts, the original provider and registry binding snapshots, the exact prepared commands, correlation and verified observations.
Coordinator owns workflow progress and waits, and the provider owns the financial transaction.

The payment host is a scoped exception to two facade rules.
It retains exact bill snapshots, original connection bindings, prepared restricted BReg commands and verified provider observations for recovery, which the record facade never does, and those bounded payment facts never enter the generic route engine.
It also links the public BReg client for restricted bill-binding and receipt Actions, a payment protocol crate and its provider connectors.
The Adapter core and the shared engine keep their source-neutral dependency boundary, and the dependency gate enforces that split.

### Collection

Collections run only against the synthetic payment simulator.
A collection connection must use the `simulator` provider with `simulation: true`; any other collection provider is refused at load with `adapter.payment.collection-simulation-only`, by both `adapter serve` and `adapterctl payments check`.

Before any provider send, PostgreSQL reserves one attempt per institution, service, bill and bill version across workflow command keys.
The host persists the exact bind Action and key, invokes that restricted Action, and verifies the frozen authoritative bill binding.
It then persists the first dispatch time before sending the original exact provider command.
An accepted response means the provider accepted the request, not merely that a local row exists, and an unknown outcome stays unresolved.
The simulator allows an exact same-command resend inside the original connection's declared replay window.

Provider identifiers derive from a domain-separated digest of the full immutable bill and the provider origin, producer identity, tenant and biller, so independent Adapter databases do not allocate overlapping identities.
Disjoint digest portions fit the provider's request, request-to-pay and bill fields, and the provider must reject a reused request identifier with a different body.
Stored commands are checked against that derivation and replayed exactly.

The original-command receipt lookup is a database read.
Collection reads may observe the provider but never bind, dispatch or record a receipt.
A confirmed provider observation must match the complete saved request, transfer, bill, amount and currency tuple, and a pending state, including the simulator's `COM/PENDING`, never authorises a receipt.

The receipt step accepts only a collection identifier.
The host derives the receipt from its confirmed observation and frozen bill, persists the exact restricted BReg report Action and key, and verifies the authoritative readback.
A lost bind or report acknowledgement recovers from the saved command or exact readback.
The numeric-loopback simulator preserves exact decimal JSON and requires synthetic response provenance before it authorises a synthetic fee receipt.

### Disbursement

The Adapter reads the approved instruction from BReg, including the exact money, the recipient destination and the funding account.
It prepares the exact provider command under the pinned binding and reserves one attempt for the authoritative source, instruction identity and version.
It commits the restricted BReg binding Action and records the first dispatch before sending.
An uncertain submission stays held, and Coordinator can reconcile the original acceptance only through a read-only lookup for the saved key and instruction.

The `mifos-legacy-signature` host profile signs the exact Bulk request and verifies the raw acknowledgement and the expected tenant before interpreting it.
Request signing and response verification use separate pinned Transit keys, and Operations status reads use a separate bearer credential.

A disbursement connection pins its provider pack by id, version and digest.
Pass that pack to the host with `--payment-provider-pack`, and repeat the option for every pack an active connection or a retained attempt still pins:

```sh
adapter serve --runtime-config /absolute/path/runtime.yaml \
  --payments-config /absolute/path/payments.yaml \
  --payment-provider-pack /absolute/path/mifos-payment-hub/pack.yaml
```

Registry Stack does not publish a Mifos Payment Hub EE pack yet, so the operator supplies a reviewed pack whose bytes match the pin.
`adapterctl payments check` takes the same pack with `--provider-pack` and checks the pin offline.

Before a Mifos disbursement connection goes live, set up its signing and the provider's access control.
Create the request-signing key inside Transit, so it is non-exportable and service-created, and import only the provider's public key as the separate response-verification key; the Adapter pins each key's SPKI digest and version and refuses other custody.
The released Payment Hub EE channel and operations apps ship with authorisation turned off, so enable bearer authorisation on them, or enforce it at a trusted gateway, before the Adapter's Operations credential means anything.
An attempt reaches `Bound` before it is signed and sent, so let every `Bound` disbursement attempt dispatch before you raise the signing key's `min_encryption_version`; a raised minimum otherwise holds those attempts.
The [Mifos connector README](https://github.com/registrystack/registry-stack/blob/main/crates/registry-payment-mifos-connector/README.md) and the [platform crypto README](https://github.com/registrystack/registry-stack/blob/main/crates/registry-platform-crypto/README.md) carry the exact profile and Transit details.
Full Linux CI exercises the signing and acknowledgement checks with OpenBao Transit over its Unix proxy.
The test uses a synthetic provider.
Run a sandbox disbursement with your pinned Mifos deployment and its configured Transit proxy before enabling live transfers.

The separate confirmation operation accepts only a disbursement identifier.
The Adapter reports verified provider completion through its restricted BReg Action, using the original instruction facts and a separately keyed exact command.
The resulting confirmation records what the provider reported; credit to the recipient and settlement require separate authoritative evidence.

### Authorisation and retained attempts

Every lookup rechecks the current caller, connection and service scope.
The Adapter identity holds the restricted BReg grants that bind and report attempts.
A connection configuration change affects new attempts only.
A retained attempt uses its original provider origins, tenant and party bindings, credential identities, exact pack pin and registry binding.
Load the original provider pack alongside the active pack to resume retained work; a missing pack holds the attempt before provider I/O.
Bearer credentials can rotate at the same configured reference.

Payment attempts and command receipts stay durable without automatic expiry.
They include the restricted bill and instruction facts needed for recovery, so protect their PostgreSQL storage and backups.
Generic facade response-retention sweeps do not delete payment attempts.
Payment audit events carry no values and commit before an effect or a response is released.

{/* Evidence: crates/registry-adapter/src/payments/config.rs COLLECTION_SIMULATION_ONLY;
    crates/registry-adapter/tests/payment_config.rs live_mifos_collections_are_refused_as_simulation_only;
    crates/registry-adapter/src/payments/service.rs;
    crates/registry-adapter/src/payments/g2p_model.rs mifos-legacy-signature;
    crates/registry-adapter/tests/g2p_provider.rs real_openbao_transit_signs_requests_and_refuses_a_changed_response;
    products/adapter/scripts/test-payments-openbao.sh;
    crates/registry-adapter/tests/payment_service.rs;
    crates/registry-adapter/tests/payment_store.rs;
    products/adapter/scripts/check_dependency_direction.py. */}

## Next

- [adapter route language](../adapter-routes/)
- [adapter ingestion jobs](../adapter-jobs/)