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

# Adapter effective operation contract

> The effective operation contract a Registry Adapter exports for an external gateway, its digest, the protected runtime readback, the per-request contract pin, and the request identity the Adapter mints.

If you put a gateway in front of a Registry Adapter, the effective operation contract tells the
gateway which read operations one loaded Adapter process can expose.
It is generated from the same validated plan that `adapter serve` uses.
It is not an authorization grant, an embedded MCP server, or personal-data delegation.
Authored or executable operations that the gateway surface excludes stay listed as unserved with a
stable reason code.

## Export

```console
adapter effective-contract \
  --runtime-config /absolute/path/runtime.yaml \
  --project /absolute/path/project-directory \
  --profile /absolute/path/profile.yaml \
  --pack /absolute/path/pack.yaml
```

`--profile` and `--pack` have the same beside-the-project defaults as `adapter serve`.
The command validates and loads the artifacts and the runtime binding without opening a listener,
connecting to the journal database, or probing an upstream source.
Secret references that the loader normally resolves, including static upstream credentials, must still
resolve.

The JSON envelope is:

```text
apiVersion: id.registrystack.org/formats/adapter/effective-contract/v1alpha1
kind: AdapterEffectiveContract
digest: sha256:<RFC 8785 digest of contract>
contract:
  schemaDialect
  project: { id, version }
  profileVersion
  artifactDeploymentDigest
  authentication: { scheme, audience, clientAdmission }
  authority
  operations[]
  unserved[]
  problemSchema
  protocolProblems
```

{/* Evidence: crates/registry-adapter-engine/src/effective_contract.rs API_VERSION, KIND,
    EffectiveContract, EffectiveContractBody;
    crates/registry-adapter/tests/effective_contract.rs
    export_and_runtime_readback_match_the_registered_closed_schema. */}

## Served operations

Each served operation carries these members:

- Its stable concrete id and version.
- Its binding and profile-operation ids.
- The method and the concrete path.
- `support: served` and `effect: read`.
- Any request-body byte limit.
- Closed path, query, and body schemas.
- The exact derived output schema.
- The alternative all-of scope sets that admit the call.

Only GET reads and profile-declared read-only POST operations enter the served gateway surface.
A runtime-served write stays unserved here with `adapter.operation.gateway-write-disabled`.
Effect classification is explicit, so a future write cannot be mislabeled as a read.
Pagination schemas preserve the runtime page-size and cursor bounds, and paginated output arrays
preserve the maximum page size.
Request-body bounds are applied by the envelope's actual slots, not by guessing property names.

An unserved entry carries the same identities, its classified effect, `support: unserved`, and a
stable reason code with a value-free operator reason.
Its effect is `unknown` only when the referenced profile operation is itself missing, so no method
semantics exist to classify.
A consumer must never turn an unserved entry into a tool or an HTTP call.

{/* Evidence: crates/registry-adapter-engine/src/effective_contract.rs EffectiveOperation,
    UnservedOperation;
    crates/registry-adapter/tests/effective_contract.rs
    export_contains_only_effectively_served_reads_and_names_unserved_writes,
    native_put_is_schema_valid_unserved_gateway_metadata,
    post_read_contract_carries_closed_body_and_pagination_bounds. */}

## Digest

`digest` is SHA-256 over RFC 8785 canonical JSON containing a fixed digest domain, `apiVersion`,
`kind`, and the complete `contract` member.
Runtime readiness and the digest field itself are outside that digest.
One whole-contract digest is pinned on every operation request; there is no separate per-operation
digest.
The `artifactDeploymentDigest` separately identifies the exact project, profile, and pack bytes that
the Adapter loaded.

The export includes the resource audience, the generic allowlist admission mode, and the operation
scope requirements, because a machine client needs them to request and present the right bearer
token.
It deliberately excludes OAuth client ids, secret references and values, database configuration,
upstream origins, private network declarations, and source credentials.

{/* Evidence: crates/registry-adapter-engine/src/effective_contract.rs DIGEST_DOMAIN,
    AuthenticationRequirement, EffectiveContract. */}

## Authority

The authority block fixes the limit of this contract in machine-readable form.
The admitted caller is a trusted machine.
Represented-subject and personal delegation are unsupported, target binding is unsupported, and the
contract grants no row-level or field-level disclosure authority.
Operation and record-type scopes do not become personal disclosure authority.

{/* Evidence: crates/registry-adapter-engine/src/effective_contract.rs AuthorityBoundary. */}

## Problems

`problemSchema` remains the profile's problem envelope for ordinary operation failures, including the
resolved profile code and title with the engine's fixed facade admission statuses.
Profiles that declare typed problem data keep each code, title, allowed status set, and data shape
correlated.

`protocolProblems` separately binds a closed problem envelope and two code and status pairs that this
protocol owns:

- `adapter.contract.precondition-failed`, HTTP 412.
- `adapter.contract.unavailable`, HTTP 503.

The Adapter never changes a profile problem's declared HTTP status to produce one of these protocol
failures.

{/* Evidence: crates/registry-adapter-engine/src/effective_contract.rs PIN_PROBLEM_CODE,
    UNAVAILABLE_PROBLEM_CODE, ProtocolProblems. */}

## Runtime readback and readiness

An Adapter that has completed startup serves:

```text
GET /.well-known/registry-adapter/effective-contract
Authorization: Bearer <admitted machine token>
```

The endpoint requires the existing OIDC audience and client allowlist.
It does not require a data-operation scope, create a new grant, or make contract metadata anonymous.
A successful response is the export envelope plus:

```json
{"readiness":{"ready":true,"configuration":"ready","journal":"ready"}}
```

The endpoint returns `adapter.contract.unavailable` when it cannot query the journal or when the live
migration set differs from the set the binary supports.
A gateway pins the expected `digest` and reads the protected runtime document when it establishes
catalogue readiness.
A mismatch or unavailable readiness prevents the catalogue from being served.
A separate metadata read before every invocation is not required.
Readiness does not probe the upstream source, so do not present it as a source-health or end-to-end
facade check.

{/* Evidence: crates/registry-adapter-engine/src/effective_contract.rs WELL_KNOWN_PATH,
    RuntimeContractResponse, RuntimeReadiness;
    crates/registry-adapter/tests/effective_contract_live.rs
    protected_readback_is_the_cached_offline_contract_and_checks_journal_readiness. */}

## Per-request contract pin

To bind each invocation to the reviewed contract, a gateway sends the pinned digest on every operation
request:

```text
x-registry-adapter-contract: sha256:<effective contract digest>
```

After the Adapter authenticates the machine client, it requires an exact, single header match before
it creates an exchange, reads a body, or calls the source.
A mismatch or a repeated header receives `adapter.contract.precondition-failed` with HTTP 412.
The refusal is durably audit-journaled before the response, but no body is read, no exchange is
created, and no source I/O occurs.
If the journal cannot record the refusal, the Adapter returns `adapter.contract.unavailable` with
HTTP 503 instead of claiming a durable 412.
Omitting the header preserves existing clients; a gateway that uses effective discovery must always
send it.

{/* Evidence: crates/registry-adapter-engine/src/effective_contract.rs PIN_HEADER;
    crates/registry-adapter/tests/effective_contract_live.rs
    authentication_and_admission_precede_the_pin_which_precedes_body_and_source. */}

## Request identity

Every facade success and problem carries `x-registry-request-id`, minted by the Adapter.
The protocol problems carry the same request id in their closed body.
When the profile's problem envelope exposes its request-id slot, that body value and the header are
identical.
The Adapter accepts no caller-supplied correlation header and records no reversible digest of caller
correlation data.

Native write replays retain the original Adapter-minted response id in both body and header, so the
cached response stays byte-identical.
Their physical retry attempts have distinct journal ids.
Native writes stay unserved in the external gateway contract.

{/* Evidence: crates/registry-adapter-engine/src/effective_contract.rs REQUEST_ID_PATTERN;
    crates/registry-adapter/tests/effective_contract_live.rs assert_profile_problem_request_id,
    assert_protocol_problem. */}

{/* TODO[evidence]: no test names the replay behavior that retains the original response id across
    physical retry attempts. */}

## Next

- [govstack consultation and write](../../configure/adapter-consultation/)
- [operate the adapter](../../operate/adapter/)
- [adapter job packs](../../configure/adapter-packs/)