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

# Native local Base Registry Engine (BReg) lifecycle

> How bregctl dev starts, stops, and retains a local Base Registry Engine registry with a pinned PostgreSQL image and a local issuer, and how its clients file and retained state behave.

:::note
`rstack dev` is the maintained way to run a BReg project locally.
It reads a `dev.yaml` plan and a scenario file, writes short-lived token header files with
`rstack dev token`, and removes everything when the run stops.
[Run a project with rstack dev](../../configure/run-a-project-with-rstack-dev/) describes it, and
`examples/minimal/` shows a plan for a BReg project.
This page covers the older `bregctl dev` loop, which `rstack dev` replaces.
`rstack dev` has no equivalent of `dev events`, `examples run`, retained data across stop and start,
`dev-clients.yaml`, or `export-client`.
:::

`bregctl dev` starts an existing, explicitly authored local registry using the installed `breg`
binary, a source-pinned ThunderID image, and Docker PostgreSQL.
It needs no checkout, Python launcher, shell script, or OpenSSL installation.
ThunderID is a local issuer chosen by this development tool; an operated Base Registry Engine
(BReg) runtime remains an independent OAuth resource server.

{/* Evidence: crates/registry-bregctl/src/dev/mod.rs IMAGE;
    crates/registry-bregctl/tests/dev_lifecycle.rs installed_dev_allocates_ports_for_parallel_fresh_projects_and_retains_them. */}

Prepare the project with `bregctl init ./registry`.
The generated `dev-clients.yaml` binds `editor` and `foreign-editor` to `directory-editor` with
distinct jurisdiction claims, so the project starts unchanged.
Review the model, access profiles, journey fixtures, and local clients before the first start.
You can prepare a later dedicated Evidence source explicitly on a stopped session.

{/* Evidence: crates/registry-bregctl/src/dev/tests.rs a_fresh_init_project_is_ready_for_the_native_dev_lifecycle. */}

The generated local runtime uses the compiled registry's one common principal claim.
A project whose authenticated grants all use `principalClaim: sub` therefore uses the issuer's
verified subject, including native citizen accounts.
Projects with multiple principal claims are refused before local services start.
An access-free project keeps the `registry_principal` local default.
An operated runtime still sets `authentication.authorityClaims.principal` explicitly to match its
governed grants.

{/* Evidence: crates/registry-bregctl/src/dev/tests.rs generated_runtime_infers_sub_as_the_common_principal_claim,
    access_free_runtime_preserves_the_legacy_registry_principal,
    mixed_principal_claims_are_refused_before_dev_state_is_published. */}

```sh
bregctl dev ./registry
bregctl dev stop ./registry
bregctl dev start ./registry
```

The project path defaults to the current directory, as it does for every other `bregctl` command.
A first start reads `dev-clients.yaml` inside the project; `--clients-file` names another clients
file instead.
`dev` and `dev start` both detach a resident supervisor.
They return only after PostgreSQL, ThunderID, schema-test rehearsal, package activation, BReg
readiness, and explicit seed creation succeed.

{/* Evidence: crates/registry-bregctl/src/dev/tests.rs a_first_start_reads_the_projects_dev_clients_without_a_flag;
    crates/registry-bregctl/tests/dev_lifecycle.rs installed_dev_preserves_edits_and_recovers_failed_start_without_reseeding. */}

The preferred loopback ports are BReg `8090`, issuer `8091`, and PostgreSQL `15432`.
When an unassigned preferred port is occupied, the first start selects a free, distinct port.
Override selection with `--breg-port`, `--issuer-port`, and `--database-port`; an explicit
collision or duplicate assignment is refused with the responsible flag named.
A restart retains the selected ports and clients-file location.
Session and container ownership names stay UUID-based and do not depend on the selected ports.

{/* Evidence: crates/registry-bregctl/src/dev/mod.rs DEFAULT_BREG_PORT, DEFAULT_ISSUER_PORT, DEFAULT_DATABASE_PORT;
    crates/registry-bregctl/src/dev/tests.rs first_start_selects_free_distinct_ports_and_preserves_explicit_assignments, occupied_and_ambiguous_ports_are_refused;
    crates/registry-bregctl/tests/dev_lifecycle.rs dev_start_port_refusals_name_the_port_flag_and_role_in_both_formats. */}

## Database image and deadlines

The database runs the pinned image
`docker.io/library/postgres:17.11@sha256:67f41722b7a8cbdb868a44a4995c846eddfdc2973bccb291ce937dce88ad5675`,
or `postgis/postgis@sha256:01a6a70e41e6c4467c8f55f6063555ed72db2d6662cd0d571040d42eadaeb6f6`
when the compiled schema requires PostGIS.
The first is the Docker Official Images reference for
`postgres:17.11@sha256:67f41722b7a8cbdb868a44a4995c846eddfdc2973bccb291ce937dce88ad5675`,
at that digest; the PostGIS image also comes from Docker Hub.
The `dev start` help names both references, so an egress allowlist can admit Docker Hub.
Retained owned containers also accept the previous exact `public.ecr.aws/docker/library/postgres`
reference at that digest and the short `postgres` reference.
The selection is retained with the owned database.
Spatial setup grants the migration role permission to `SET` the no-login bbox owner; the runtime
role never receives that membership.

{/* Evidence: crates/registry-bregctl/src/dev/mod.rs IMAGE, SPATIAL_IMAGE, LEGACY_ECR_IMAGE, CANONICAL_IMAGE;
    crates/registry-bregctl/src/dev/tests.rs the_documented_image_and_deadlines_are_the_supervisors_own,
    retained_database_inspection_accepts_only_verified_image_aliases,
    retained_database_selection_preserves_the_spatial_choice,
    spatial_prerequisites_provision_the_bbox_role_each_runtime_file_serves_with. */}

Each supervised prerequisite command may run for 120 seconds.
The owned database and BReg have 45 seconds each to answer readiness, and ThunderID discovery has a
120-second wait.
A start that passes a deadline fails, stops what it acquired, and keeps its owner-only
diagnostics.

{/* Evidence: crates/registry-bregctl/src/dev/mod.rs CHILD_DEADLINE, READY_DEADLINE;
    crates/registry-bregctl/src/dev/tests.rs the_documented_image_and_deadlines_are_the_supervisors_own,
    a_failed_issuer_setup_names_the_phase_logs_and_both_recoveries. */}

### Prerequisite version check

Before it inspects the owned container or launches the supervisor, a start runs each resolved `breg`
and `docker` with `--version` and records what they answer.
`breg` ships in the same release as `bregctl`, so a `breg` reporting another version is refused by
name: the refusal gives the file that answered, the version it reported, and the version `bregctl`
reports.
Without that comparison the mismatch surfaces much later as a refused package or an unready
database, which reads as a fault in the authored project.
Docker belongs to no release of this stack and is never compared, and a prerequisite that reports no
version at all still serves the session.
No flag skips the comparison: install `breg` and `bregctl` from the same release, or put the
matching build first on `PATH`.
`--breg-bin` chooses which file is resolved, and that file is compared.

{/* Evidence: crates/registry-bregctl/src/dev/tests.rs resolved_prerequisites_record_a_canonical_path_and_their_reported_version,
    prerequisites_from_another_release_are_refused_before_the_session_starts. */}

## Stop and remove

`dev stop` keeps everything it created: the owned container, its named data volume, records, the
audit files under `.breg/dev/audit`, keys, credentials, and the built package.

:::caution
`dev stop --remove` removes the owned container and its `breg-dev-<owner>` data volume, discarding
records, event receipts, and seed checkpoints.
The audit files are kept.
:::

{/* Evidence: crates/registry-bregctl/src/dev/tests.rs reclamation_forgets_the_database_and_keeps_the_reusable_identities,
    stop_before_first_start_names_the_missing_session_without_docker;
    crates/registry-bregctl/tests/dev_lifecycle.rs installed_dev_preserves_edits_and_recovers_failed_start_without_reseeding. */}

For an initial package at sequence 1, the next start after `--remove` builds an empty database from
the same authored project, ports, credentials, and package.
It also lets the next start take edited inputs: once no records are retained, a changed package,
clients file, or port ([what counts as changed](#retained-state-and-recovery)) replaces the session
with a fresh one that keeps the previous ports and clients file and generates new keys.
A successor package prepared for retained records cannot initialise an empty database after
removal: start refuses before Docker.
Create a fresh project at package sequence 1 for a separate empty experiment.

{/* Evidence: crates/registry-bregctl/src/dev/tests.rs changed_inputs_replace_a_session_whose_records_were_discarded,
    removed_successor_database_is_refused_before_any_prerequisite_or_recreation. */}

Use `--format json` to consume the status, URLs, audience, package digest, runtime configuration,
and private credential file references.
Keys and access tokens never appear in these reports.
Use `bregctl dev export-client` to obtain the client ID, assertion key, issuer, and token endpoint
handoff; an OAuth client can obtain a fresh token with those fixed values.
Keep token output owner-only.
For a client mapped through `issuer.clientResources`, the export's `resource` and `audience` name
that client's registered audience.

{/* Evidence: crates/registry-bregctl/src/dev/tests.rs export_client_reports_the_registered_external_resource,
    dev_token_requests_the_clients_registered_external_resource;
    crates/registry-bregctl/src/dev/export_client.rs. */}

## Observe local events

Declare an event with a webhook destination in the authored project before the first start.
By default, `dev` binds every compiled destination to its own HMAC-verifying receiver on a free
numeric loopback port.
The receiver port, signing key, and bindings are retained across restarts; a conflicting receiver
port is refused.
To deliver to an external local receiver instead, bind every compiled destination ID in
`dev-clients.yaml`:

```yaml
secretProviders:
  file:
    root: /absolute/owner-only/dev-secrets
destinations:
  hooks:
    openfn:
      origin: http://127.0.0.1:8088
      path: /webhooks/registry
      hmacSha256KeyRef: secret:file/openfn-webhook-key
```

{/* Evidence: crates/registry-bregctl/src/dev/tests.rs declared_events_receive_exact_private_bindings_in_rehearsal_and_runtime,
    explicit_local_event_destinations_bind_exact_compiled_inventory,
    local_event_destinations_refuse_an_origin_without_a_usable_port. */}

The key is a [secret reference](#secret-references).
The session copies it into its private state and uses the same bounded outbox delivery and replay
rules.
The origin must be numeric loopback HTTP with an explicit port.
An explicit destination map starts no built-in receiver, so `dev events` has no inbox receipts;
inspect the receiving service and `bregctl hook list` instead.

{/* Evidence: crates/registry-bregctl/src/dev/tests.rs local_event_destinations_refuse_userinfo_and_noncanonical_paths,
    local_event_destinations_refuse_hmac_key_bytes_the_runtime_cannot_load. */}

### Bind Evidence providers

For a governed action package that declares Evidence providers, bind every required provider in the
project's `dev-clients.yaml` before its first start:

```yaml
evidenceProviders:
  qualification:
    baseUrl: http://127.0.0.1:8093
    trustBindingId: exact-local-trust-v1
    tokenRef: secret:file/evidence-token
    trustedJwksRef: secret:file/evidence-jwks.json
    revokedKeyIds: []
```

The dev command accepts exact numeric loopback origins and [secret references](#secret-references),
copies the token, trusted keys, and optional CA bundle (`caBundleRef`) into its private state, and
generates the corresponding `evidenceProviders` runtime bindings.
It does not relax package activation: provider IDs must match the compiled action requirements, and
the runtime still resolves and validates every configured trust input before serving.
Obtain the token after the shared issuer is ready, then start the action-bearing BReg borrower with
this binding.

{/* Evidence: crates/registry-bregctl/src/dev/tests.rs local_evidence_provider_copies_owner_secrets_and_renders_exact_binding,
    local_evidence_provider_ids_follow_the_governed_evidence_grammar,
    local_evidence_provider_revocations_match_the_verifiers_bound. */}

### Bind a Casework review authority

For a Proposal Action whose `execution.proposal.review.authority` names Casework, add one logical
authority binding and one dedicated machine client before the first start:

```yaml
clients:
  - id: casework-producer
    accessProfiles: []
    scopes:
      - casework:reviews:request
    claims: {}
reviewAuthorities:
  casework-a:
    endpoint: http://127.0.0.1:8096/
    profile: integration-requester
    producerId: registry-producer
    recoveryDays: 7
    client: casework-producer
```

The authority ID must exactly match the compiled requirement.
`profile` selects the Casework requester access profile on every authority exchange.
`producerId` must match the Casework producer connection, whose admitted source namespaces include
this Registry ID and whose admitted kinds include the authored review policy ID.
The client has no BReg profile.
Its scope and token identity must instead match Casework's requester profile and producer subject.

{/* Evidence: crates/registry-bregctl/src/dev/tests.rs local_review_authority_uses_refreshing_logical_client_without_exposing_credentials,
    local_review_authorities_are_closed_and_bounded. */}

The dev issuer generates the client's assertion key.
`bregctl` copies its client ID and key into owner-only runtime secret files and emits a
`privateKeyJwt` authority credential with the dev issuer token endpoint, the dev issuer identifier as
assertion audience, resource, and declared scopes.
BReg acquires and refreshes short-lived Casework tokens for each outbound exchange.
No token or private key appears in `dev-clients.yaml`, runtime YAML, reports, or logs.
An unmapped client uses the session's generated default BReg audience, which supports an App Kit
composition where Casework and BReg deliberately share that resource audience.
If `issuer.clientResources` maps the client, the generated credential uses that declared resource
instead.

{/* Evidence: crates/registry-bregctl/src/dev/tests.rs local_review_authority_uses_refreshing_logical_client_without_exposing_credentials,
    dev_token_for_an_unmapped_client_requests_the_breg_audience_only. */}

Proposal application defaults to automatic.
The built-in executor uses the compiled system grant for the exact frozen submission; it needs no
local OAuth client, self-HTTP endpoint, or `reviewExecutors` binding.
To require a separate caller, author `execution.proposal.application.mode: manual` and grant that
caller Proposal Apply.
External recovery of automatic work requires a verified human and an explicit operation grant.

{/* Evidence: crates/registry-bregctl/src/dev/tests.rs external_review_executor_credentials_are_not_a_dev_client_contract. */}

A missing review-authority binding disables operations that require it.
Generated CRUD, immediate Actions, and no-review Proposals remain available.
Restore the exact binding to resume dependent work; an unavailable authority never implies approval.

Polling needs no callback credential.
To test authenticated completion delivery, add both optional fields; declaring only one is refused:

```yaml
completionTokenRef: secret:file/casework-completion-token
completionRecipient: registry-breg
```

The completion token is an independent sender credential, named by a
[secret reference](#secret-references) and copied into private state.
It is never used for review requests or source application.
Operated runtime configuration also supports an explicit static `tokenRef` for an opaque renewable
credential supplied by the deployment, but `bregctl dev` always generates the refreshing
`privateKeyJwt` branch.

{/* Evidence: crates/registry-bregctl/src/dev/config.rs completionTokenRef, completionRecipient. */}

### Inspect receipts

After a seed, example scenario, or API write triggers an event, inspect receipts:

```sh
bregctl dev events ./registry
bregctl --format json dev events ./registry
bregctl dev events ./registry --include-payload
```

The default report shows the event UUID, authored event, Record type, trigger, compiled delivery
and destination IDs, generation, attempt, and `received` status.
Record IDs and projected values are omitted.
`--include-payload` explicitly displays the projected values from the development receiver.
Receipts remain available while the session is stopped.
`dev stop --remove` erases the receipt journal along with the records, including captured
payloads.

{/* Evidence: crates/registry-bregctl/src/dev/events.rs MAX_STORAGE, "eventId", "recordType", "destinationId", "idempotencyKey", "generation", "attempt", "status";
    crates/registry-bregctl/tests/dev_lifecycle.rs installed_dev_receives_retries_replays_and_retains_authored_events. */}

The receiver keeps these development values in the owner-only `.breg/dev/events.jsonl` journal,
outside version control.
Its 16 MiB bound prevents unbounded storage; when full, it refuses further receipts and the runtime
follows its normal retry and dead-letter policy.
While stopped, move the journal to an owner-only location if it needs to be preserved, then start
again to create an empty inbox.
Treat captured values as private development data.

A receipt means the receiver accepted that attempt.
The runtime's pending and dead-letter queue is inspected separately.
Supply the local PostgreSQL CA and the absolute runtime configuration path:

```sh
SSL_CERT_FILE="$PWD/registry/.breg/dev/tls/ca.pem" \
  bregctl hook list --runtime-config "$PWD/registry/.breg/dev/runtime.yaml"
```

Delivered rows leave that queue.
Automatic retries keep the event UUID and idempotency key; an eligible operator replay increments
the generation.
Use the identifiers and generation from `hook list` with `bregctl hook replay --help`.
Supply the same CA file and absolute runtime path for replay.
The normal event delivery, dead-letter, and replay rules also apply to this generated runtime.
See [Events and webhooks](../../operate/breg-webhooks/).

{/* Evidence: crates/registry-bregctl/tests/dev_lifecycle.rs installed_dev_receives_retries_replays_and_retains_authored_events. */}

The supervisor starts the receiver before BReg and stops it after BReg during normal shutdown or
failed startup.
It captures runtime deliveries, including seed writes; the disposable schema-test rehearsal does not
dispatch webhooks.
Projects declaring no webhook destinations start without a receiver and report an empty inbox.
These bindings are local development configuration; operated deployments must bind their own
destinations and signing keys.

{/* Evidence: crates/registry-bregctl/src/dev/tests.rs event_free_sessions_keep_working_without_receiver_state. */}

## Explicit teaching clients

The clients file is ordinary YAML with a closed format.
It starts with `apiVersion: id.registrystack.org/formats/breg/dev-clients/v1alpha1` and
`kind: BRegDevClients`, and `bregctl dev start` reports every unknown or removed member at its line
and column before any service starts.
It declares local issuer registrations; it does not add or infer BReg access profiles.
Every protected journey step without an exact binding needs one default client for its profile whose
scopes and claims match the ordinary step.
A maintained refusal step may use another client for the same profile by naming that exact step with
`testBindings`.
The closed binding contains both `journeyId` and `stepId`; stale, profile-mismatched, duplicate, or
ambiguous bindings are refused before any service starts.

{/* Evidence: crates/registry-bregctl/src/dev/tests.rs clients_require_explicit_unique_profile_bindings_and_closed_fields,
    every_unknown_clients_member_is_reported_with_its_position,
    a_clients_file_without_the_header_is_refused_naming_the_current_one,
    journey_bindings_select_exact_claim_variant_and_reject_stale_entries,
    every_journey_step_needs_an_issuer_client. */}

For a native journey using a profile with `principalClaim: sub`, use `"$localClientSubject"` for the
expected principal.
Use the same marker in `directClaims.sub` when the profile applies an equality row boundary to
`sub`.

```yaml
claims:
  principal: "$localClientSubject"
  scopes:
    - registry:records:read
  actorKind: human
  requesterClient: local-reader
  directClaims:
    sub: "$localClientSubject"
```

Each marker resolves to the selected local client's registered subject in the private captured
project.
Exact `testBindings` select the client for their named steps.
A borrowed issuer uses its owner's registration identity.
Use literal values for other expected claims and request data.
The rehearsal verifies the token's claims against these expectations and applies the row boundary to
the records.

{/* Evidence: crates/registry-bregctl/src/dev/mod.rs LOCAL_SUBJECT_MARKER;
    crates/registry-bregctl/src/dev/tests.rs local_subject_marker_uses_actual_issuer_owner_and_exact_client_binding,
    local_subject_marker_refuses_other_locations_profiles_and_missing_clients,
    local_sub_runtime_resolves_only_its_private_captured_journey;
    crates/registry-bregctl/tests/dev_lifecycle.rs installed_dev_rehearses_subject_bound_rows_with_two_local_clients. */}

### Clients without a BReg profile

Set `accessProfiles: []` for a machine client that carries only scopes or claims for another
product, such as Casework.
The empty list gives that client no BReg access-profile binding.
It is registered with the local issuer but omitted from the BReg runtime's `allowedClients`, so it
cannot call BReg.

When no client is left to name in `allowedClients` (every client is profile-free and none sets
`allowBregAccess`), the session writes `allowedClients: unrestricted`, so the runtime accepts a
token from every client of its local issuer.
The local issuer is the only issuer the session trusts, and governed profiles and token scopes still
authorise each call.

An integration client that must call BReg without becoming a journey or seed binding must opt in
with `allowBregAccess: true`.
Use that flag only when its scopes and authority claims are intentionally sufficient for the BReg
profiles it will select.
For a Casework current-source review, configure the human reviewer's purpose-specific
`get-review-context` profile and the independent service `get-review-status` profile explicitly in
BReg.
Pair the exact sealed context export with `caseworkctl provider pair`; pairing adds no client or
BReg grant.
Profile-free clients without `allowBregAccess` remain excluded.

{/* Evidence: crates/registry-bregctl/src/dev/tests.rs clients_accept_an_explicitly_unbound_profile_free_client,
    profile_free_clients_need_explicit_breg_access_to_authenticate,
    a_session_naming_no_breg_client_writes_the_unrestricted_keyword. */}

### Clients, seeds, and journeys

```yaml
apiVersion: id.registrystack.org/formats/breg/dev-clients/v1alpha1
kind: BRegDevClients
clients:
  - id: operator
    accessProfiles:
      - operator
      - reference-loader
    scopes:
      - registry:generic:operate
      - registry:generic:read
    claims:
      registry_principal: generic-registry-operator
      registry_purpose:
        - registry-operations
        - registry-reporting
  - id: reader
    accessProfiles:
      - record-reader
    scopes:
      - registry:generic:read
    claims:
      registry_principal: generic-registry-reader
      registry_purpose: registry-reporting
      registry_record_status: active
  - id: reader-for-lifecycle-test
    accessProfiles:
      - record-reader
    scopes:
      - registry:generic:read
    claims:
      registry_principal: generic-registry-reader
      registry_purpose: registry-reporting
      registry_record_status: active
    testBindings:
      - journeyId: record-lifecycle
        stepId: read-record-within-the-claim
  - id: source
    accessProfiles:
      - evidence-source
    scopes:
      - registry:evidence:lookup
    claims:
      registry_principal: generic-registry-source
      registry_purpose: evidence-source-read
seed:
  - id: first-record
    client: operator
    recordType: record
    accessProfile: operator
    data:
      code: synthetic-dev-record
      label: Synthetic local record
      status: active
  - id: reference-record
    client: operator
    recordType: reference-record
    accessProfile: reference-loader
    operation: import
    data:
      code: synthetic-reference-record
      label: Synthetic reference record
```

{/* Evidence: crates/registry-bregctl/src/dev/tests.rs seed_operation_defaults_to_create_and_accepts_explicit_import,
    explicit_binding_wins_and_a_profile_mismatch_is_refused, a_seed_referencing_the_unbound_client_is_refused. */}

`registry_purpose` may remain one string.
A list declares the closed set of purposes that one logical client may use in journey steps; the
first remains the purpose of its ordinary dev token.
Each authenticated journey step names an exact scope subset and, when the client declares several
purposes, one declared `purpose`.
The rehearsal obtains a separate short-lived issuer token for every distinct `(scopes, purpose)`
claim set while keeping the same OAuth client identity.
An undeclared scope or purpose is refused before schema test.
Every multi-purpose client shares one generated first-party signer, so the distinct claim names of
all of them together, counting `registry_actor_kind`, `registry_purpose`, and `scope`, may number at
most 16, and a multi-purpose client cannot also be listed on any authored exchange connection.
That signer makes the client first-party, so the issuer projects the purpose connection's claims
into its exchanged tokens: through an `institutional-grant` connection they would lack the
`registry_grant_*` claims the registry requires.
Both are refused when the clients file is read.

{/* Evidence: crates/registry-bregctl/src/dev/tests.rs multi_purpose_client_has_one_registration_and_one_bounded_exchange_connection,
    multi_purpose_claim_union_is_refused_above_the_issuer_attribute_limit,
    multi_purpose_client_is_refused_on_any_authored_exchange_connection,
    rehearsal_tokens_select_distinct_declared_purposes_on_one_logical_client,
    rehearsal_tokens_request_only_the_exact_fixture_scope_subset. */}

### Seeds

A seed defaults to `operation: create`.
The illustrative `reference-record` Record type and `reference-loader` profile must be authored in
the project, with an Import route and the scope shown on the bound client.
Dev writes one JSONL item, opens an exact one-item authority bound to its digest, drives the normal
ingestion run, and closes the authority.
An interrupted start retains the authority and checkpoint, resumes that exact run, and records the
completed seed in the same state update that clears the authority.
It can open a replacement when no checkpoint exists: a sidecar may already name a zero-progress run,
but the missing checkpoint proves no chunk was submitted or committed.
It can also replace an incomplete run whose authority closed or expired before its sole atomic chunk
committed.
Dev settles that terminal authority, retains its checkpoint, and opens a fresh authority.
Before asking to open an authority, dev records in its state that the seed is about to open one, and
when.
An interruption after the authority opened but before the session recorded it leaves an open
authority no local state names; the next start recognises the exact one-item, zero-progress
authority this seed would have opened, opened no earlier than that recorded intent, closes it, and
opens a fresh one.
Any other open authority on the Record type, including an identical one opened before the intent or
with no intent recorded, is refused by name and left to the operator.
A completed run is recorded first, and every other blocked or uncertain result retains its linkage
and fails closed.

{/* Evidence: crates/registry-bregctl/src/dev/tests.rs only_the_exact_unjournaled_seed_authority_is_recovered,
    an_unjournaled_seed_authority_is_recovered_only_after_this_seeds_intent,
    a_seed_import_intent_has_the_database_timestamp_resolution,
    only_a_closed_authority_on_an_incomplete_atomic_seed_run_may_restart;
    crates/registry-bregctl/tests/dev_lifecycle.rs installed_dev_switches_one_clients_claims_and_recovers_import_seed. */}

### Journey import steps and capture

A journey can likewise use a successful import step to load reference rows:

```yaml
request:
  operation: import
  items:
    - code: GB
      label: United Kingdom
expect:
  outcome: success
  status: 200
```

Schema test plans the same JSONL chunks, opens a bounded authority, submits the production
ingestion-run and chunk routes, verifies completion, and closes the authority before the next step.
Import steps do not capture a record response; a later list or lookup step verifies the imported
rows.

{/* Evidence: crates/registry-bregctl/tests/dev_lifecycle.rs installed_dev_switches_one_clients_claims_and_recovers_import_seed. */}

For an immediate Action in `examples/scenarios.json`, one result can use the existing `recordType`,
`result`, and `capture` members.
To retain several results from one invocation, omit those three members and map each disclosed Action
result alias to a distinct local capture alias:

```json
"captureResults": {
  "facility": "facility",
  "assignment": "assignment"
}
```

The completed receipt and all disclosed captures are replaced together in the private attempt state.
A retry recovers the same idempotent Action receipt and reconstructs the same capture set before
later steps run.

{/* Evidence: crates/registry-bregctl/src/dev/examples.rs captureResults. */}

Collection journey expectations can name exact captured members and a subset of their exact returned
domain values:

```yaml
expect:
  outcome: success
  status: 200
  members:
    facility:
      fields:
        status: active
        jurisdiction: zone-a
```

Each `members` key names a prior Record capture.
The mapping is an unordered exact set of record identities.
Missing, extra, or duplicate returned identities fail the step, as does a different declared field
value.
An exact membership assertion also requires the response to be the terminal page, with no next
cursor.
The ordinary readable-field ceiling is checked independently.
Omitting `members` keeps the earlier collection shape check; `members: {}` explicitly requires an
empty result.
`count` may still be used and, when both are present, must equal the number of declared members.

{/* TODO[evidence]: collection journey `members` expectation semantics have no located test in crates/registry-bregctl; the checker lives in the shared journey fixture code. */}

### Assertion keys and limits

Each client has its own ES256 private key, generated by default.
You can import an existing key with `assertionKeyRef` on that client, a
[secret reference](#secret-references) to its private JWK, for example when you already hold the
client's key.
The dev session validates the private key, copies it into retained state, and registers only its
public half.
The service issuer, operator, and source workload use different keys.
The reserved client ID `issuer` is unavailable.
Client and seed IDs contain lowercase ASCII letters, digits, or hyphens and have at most 64 bytes.
There can be at most 32 clients and 100 seeds.

{/* Evidence: crates/registry-bregctl/src/dev/tests.rs an_imported_assertion_key_needs_a_usable_key_identifier,
    initialization_keeps_distinct_keys_and_private_state_without_service_dependencies. */}

Plain `init` includes a dedicated `source` client for the existing lookup-only `evidence-source`
profile.
That profile permits whole-registry exact lookups by code, reads code and status, and grants no list
or mutation operation.
A supplied code is not a row authorisation rule.
Custom models, including `init --from`, can start without an Evidence lookup or client.
Add one later through [the explicit preparation](#prepare-a-source-after-using-a-registry).

{/* Evidence: crates/registry-bregctl/src/dev/tests.rs every_initialized_template_has_complete_local_clients_and_journeys. */}

### Export a client pair

After creating Evidence, copy that existing source pair explicitly:

```sh
bregctl dev export-client ./registry --client source \
  --client-id-file ./evidence/secrets/registry-client-id \
  --assertion-key-file ./evidence/secrets/registry-client-key
```

Both destination parents must already be owner-only directories.
Relative paths are resolved from your current directory.
Export reads the retained named client's pair, including while stopped; it does not create a client,
rotate keys, rewrite registrations, or add persistent output bindings.
Identical destination files are reusable.
A retry can complete a pair after one complete file was published.
Conflicting files, links, or unsafe permissions are refused without replacement; choose fresh output
names and update the target if you intentionally replaced the session.
The report contains file references and endpoints, never credentials.

Credentials remain under `.breg/dev/credentials/<client-id>/`, and `export-client` is the only way a
pair leaves the session.
Export only the dedicated source client when configuring Evidence.
Evidence's caller credential and BReg's operator credential retain separate authority.

{/* Evidence: crates/registry-bregctl/src/dev/tests.rs export_client_copies_a_stopped_retained_pair_and_retries_without_state_changes,
    export_client_preflights_both_outputs_and_preserves_conflicts,
    export_client_refuses_unsafe_destinations_and_source_links,
    export_client_refuses_missing_session_client_and_incomplete_credentials_before_output. */}

### Secret references

A member that names a secret holds a secret reference, never a path: `assertionKeyRef`,
`hmacSha256KeyRef`, `tokenRef`, `trustedJwksRef`, `caBundleRef`, `privateKeyRef`,
`completionTokenRef`, `clientSecretRef`, and `passwordRef`.
`secret:file/<name>` names one file directly below `secretProviders.file.root`, which must be
absolute.
`secret:env/<NAME>` names an environment variable of the `bregctl dev start` process and is resolved
only when `secretProviders.environment` is declared:

```yaml
secretProviders:
  file:
    root: /absolute/owner-only/dev-secrets
  environment: {}
```

A referenced file must be an ordinary file you own, with mode 0400 or 0600 and a single link.
A referenced value must be non-empty, contain no NUL byte, and fit the member's limit.
The session copies each value into its private state when it is prepared, so editing a referenced
file later changes nothing until the session is replaced.
A refusal names the member, never the value, the file, or the variable.

{/* Evidence: crates/registry-bregctl/src/dev/tests.rs a_secret_reference_needs_a_declared_provider,
    an_environment_reference_resolves_through_the_declared_provider,
    a_secret_file_must_be_owner_only_and_within_its_bound. */}

## Apply-time Evidence in development

A registry with Evidence guards needs the exact provider bindings declared by its package.
Put the binding in `dev-clients.yaml` before first start:

```yaml
secretProviders:
  file:
    root: /absolute/private/dev-secrets
evidenceProviders:
  qualification:
    baseUrl: http://127.0.0.1:8095
    trustBindingId: reviewed-local-provider
    trustedJwksRef: secret:file/evidence-signing-jwks.json
    privateKeyJwt:
      tokenEndpoint: http://127.0.0.1:8091/oauth2/token
      assertionAudience: http://127.0.0.1:8091
      clientId: qualification-reader
      privateKeyRef: secret:file/qualification-client.jwk
      resource: urn:example:evidence
      scopes:
        - evidence:invoke
```

The provider URL and token endpoint use numeric loopback HTTP.
`assertionAudience` is required: the issuer identifier, exactly as its metadata publishes it, which the
client assertion carries as its only audience (RFC 10070 section 4).
Provision the client at the issuer with precisely that resource and scope.
The session copies the referenced key and JWKS ([secret references](#secret-references)) to its
private state; it gives the runtime secret references.
The ordinary BReg credential provider refreshes expired service tokens.
`tokenRef` is an alternative for a pre-issued token and cannot be combined with `privateKeyJwt`.
An optional `caBundleRef` and `revokedKeyIds` retain their ordinary relying-party meanings.

The same bindings apply to the disposable schema-test rehearsal and the local runtime.
A journey that applies a guarded request needs a reachable configured Evidence provider and
synthetic source facts.
The development command does not skip guards or replace runtime activation checks.
Edited provider bindings on a retained session follow the normal source-change refusal and recovery
rules.

{/* Evidence: crates/registry-bregctl/src/dev/tests.rs local_evidence_provider_refreshing_credentials_preserve_exact_authority,
    local_evidence_provider_copies_owner_secrets_and_renders_exact_binding. */}

## Compose one local issuer

For a project with task-grant profiles, declare each Casework status service before the first start.
The source issuer must match the profiles' `taskGrant` issuer.
The status client has only the status scope, no BReg profile, and no `allowBregAccess`:

```yaml
clients:
  - id: breg-status
    accessProfiles: []
    scopes:
      - casework:grants:status
    claims:
      registry_actor_kind: service
taskGrantStatus:
  casework:
    sourceIssuer: https://casework.local.example
    baseUrl: http://127.0.0.1:8092/
    client: breg-status
```

Merge these entries into the existing versioned clients file.
Up to eight bindings are supported, with unique source issuers and exact numeric loopback HTTP
endpoints.
The generated runtime uses the session issuer for token acquisition and client assertion audience,
copies the client's assertion key into an owner-only secret file, and selects that client's declared
`issuer.clientResources` audience or the session's default resource.
Register the same client and resource in Casework's `taskAuthority.statusClients`.
This binds the existing [task-grant status contract](../breg-task-grants/); it grants no access to
source records and does not replace the governed task profile.

{/* Evidence: crates/registry-bregctl/src/dev/tests.rs local_task_grant_status_uses_only_the_registered_status_client_and_resource,
    local_task_grant_status_refuses_wider_authority_duplicate_sources_and_unsafe_endpoints. */}

One BReg dev session can own the issuer registrations for several local products.
Its `dev-clients.yaml` declares the complete inventory before that issuer starts.
Add other audiences and the exact client role mapping under `issuer`; the default BReg audience is
the `resource` reported by the owner session.
Extra resources carry no client permission until a client is mapped or receives an explicit resource
grant.

```yaml
clients:
  - id: task-agent
    accessProfiles: []
    scopes:
      - casework:grants:assert
    claims:
      registry_actor_kind: service
    grants:
      - audience: urn:registrystack:scheduling:local:appointments
        scopes:
          - scheduling:read
issuer:
  resources:
    - audience: urn:registrystack:evidence:local:gateway
      scopes:
        - evidence:invoke
    - audience: urn:registrystack:casework:local:inbox
      scopes:
        - casework:grants:assert
    - audience: urn:registrystack:scheduling:local:appointments
      scopes:
        - scheduling:read
  clientResources:
    evidence-reader: urn:registrystack:evidence:local:gateway
    task-agent: urn:registrystack:casework:local:inbox
  exchangeIssuers:
    - id: casework
      issuer: https://casework.example.test
      jwksEndpoint: http://host.docker.internal:8094/oauth2/jwks
      mapping: institutional-grant
      clients:
        - task-agent
    - id: portal
      issuer: http://127.0.0.1:8095
      jwksEndpoint: http://host.docker.internal:8095/oauth2/jwks
      mapping: first-party
      clients:
        - portal-exchange
      tokenAttributes:
        registry_principal: string
        evidence_tags: string-array
  exchangeClients:
    - task-agent
    - portal-exchange
  interactiveApplications:
    - id: staff-portal
      clientSecretRef: secret:file/staff-portal-secret
      origin: http://127.0.0.1:3000
      redirectUris:
        - http://127.0.0.1:3000/callback
      grants:
        - scopes:
            - registry:generic:operate
      tokenAttributes:
        - registry_actor_kind
  syntheticUsers:
    - username: officer
      email: officer@example.test
      passwordRef: secret:file/officer-password
      attributes:
        registry_actor_kind: human
      grants:
        - scopes:
            - registry:generic:operate
```

{/* Evidence: crates/registry-bregctl/src/dev/tests.rs owner_issuer_pre_registers_shared_resources_exchange_and_browser_identity,
    exchange_clients_and_connections_name_each_other. */}

Every referenced client also needs its own ordinary `clients` entry with exact scopes and claims.
`exchangeClients` must have one bootstrap scope, and the external authority must be pre-registered.
List each exchange client under every connection whose authority it may present: the local resource
servers read that pairing and refuse a token exchanged from any other authority, so a client named
by no connection is refused before startup.
A `first-party` connection's `clients` list also selects the claims that connection projects; an
`institutional-grant` connection projects none.
Local browser applications use authorization code with PKCE and explicit redirect URIs.
Their secrets and synthetic passwords are copied into the owner's private issuer state.
Explicit app and user grants render issuer role assignments for the matching resource; requested
scopes without both permissions are not granted.
An app or grant that omits `audience` uses the owner's default BReg audience; such an app enters the
local runtime's allowed client list, and an app mapped to another resource does not.
The app still needs a token with the governed profile's actual `scope` and principal and purpose
claims to call BReg.

{/* Evidence: crates/registry-bregctl/src/dev/tests.rs an_institutional_grant_connection_pairs_clients_without_projecting_their_claims,
    a_borrowed_runtime_carries_the_owners_assertion_authority_pairing,
    owner_issuer_pre_registers_shared_resources_exchange_and_browser_identity. */}

While the session acquires multi-purpose rehearsal tokens, a transient listener serves the issuer one
public JWKS key and no other route, and stops once the tokens are acquired.
The private key stays in the owner-only dev state directory.
On macOS the listener binds loopback.
On Linux it binds every interface, because Docker Engine maps `host.docker.internal` to the bridge
gateway, so anything on the host's networks can read that key while the tokens are acquired.

{/* Evidence: crates/registry-bregctl/src/dev/purpose.rs jwks_bind_address, exchange_tokens. */}

### Machine client grants

Machine clients may also declare `grants` with the same audience and scopes format.
Up to seven distinct audience grants are accepted, each with 1 to 32 distinct scopes declared by that
resource.
Omit `audience` for the owner's default BReg resource.
Grants merge into that client's existing issuer role without adding duplicate resource permissions.
They do not change its primary `scopes`, default token requests, exported `resource`, exchange
bootstrap scope, or BReg admission.
For example, the task agent above may request an ordinary `scheduling:read` token at the Scheduling
resource using the same client and subject; committing an appointment still requires Scheduling's
independently verified task grant.
Unknown audiences, undeclared scopes, and borrowed-client grant declarations are refused.
Author these grants on the issuer owner before first start.
For institutional exchange clients, extra ordinary grants may name only other resources; the primary
resource retains its single exact bootstrap permission.
The issuer tooling records those explicit extra permissions separately from the bootstrap bound,
without creating task-grant claims or widening exchange.

{/* Evidence: crates/registry-bregctl/src/dev/tests.rs machine_resource_grants_project_exact_permissions_without_changing_bootstrap_or_export,
    machine_resource_grants_refuse_undeclared_broader_duplicate_and_unbounded_permissions,
    borrowed_issuer_refuses_machine_resource_grants_before_owner_lookup. */}

### Borrow an issuer

Start the owner first.
Another BReg project can run `bregctl dev start ./registry-two --issuer-project ./issuer-owner`
when the owner pre-registered that project's client IDs, exact scopes, and claims.
The borrower copies those client pairs and issuer keys, pins the owner session ID, and never starts
or stops the shared issuer.
Its own BReg package, database, profiles, and outbox remain independently owned.
A replaced or unavailable owner is refused before the borrower starts.
Declare additional issuer resources, exchange connections and clients, browser applications, and
synthetic users on the owner.
A borrower may list only `issuer.browserClients` from that issuer inventory; owner-only declarations
in the borrower's clients file, including machine-client `grants`, are refused before startup.
A borrower answers on the owner's BReg audience, so it applies the owner's exchange-connection
pairings: an exchanged token is refused unless the presenting client is registered against the
assertion authority that signed it, by exactly the connection list the owner declared.
To use an owner-registered browser app at the borrower's BReg resource, list its ID under
`issuer.browserClients` in the borrower's clients file.
The owner must have registered that app for the same audience.
The borrower admits only those listed app IDs; its governed profiles and token scopes still decide
each API call.

{/* Evidence: crates/registry-bregctl/src/dev/tests.rs borrowed_issuer_refuses_owner_only_declarations_before_preparation,
    a_borrowed_runtime_carries_the_owners_assertion_authority_pairing,
    owner_issuer_pre_registers_shared_resources_exchange_and_browser_identity. */}

## Prepare a source after using a registry

Stop the retained registry normally, then run the owning BReg operation:

```sh
bregctl dev stop ./registry
bregctl dev prepare-source ./registry
```

`bregctl dev --help` omits `prepare-source`.
Without `--apply`, it reports the inventory or proposed change.
Choose the Record type, an existing required unique scalar field, readable facts, and record scope.
The review distinguishes registry-wide exact lookups from an explicit fixed binding on a
string-valued row field.
`--apply` stages a policy-only successor while the session is stopped.
It adds the selected selector, narrow grant, and separate client, then advances the package
sequence.
The next `dev start` activates that successor while preserving record IDs, revisions, values, audit
history, and existing client credentials.
It does not infer authority from field names.
Add the source to an Evidence project with `bregctl generate evidence-source` and
`evidencectl source import`.

This is not general retained-schema evolution.
It refuses unrelated authored changes, a nonunique selector, or reused client and profile
identifiers.
Correct the named issue without removing retained data.
For other model changes use the reviewed package lifecycle.

{/* Evidence: crates/registry-bregctl/src/dev/prepare_source.rs;
    crates/registry-bregctl/src/dev/tests.rs prepare_source_stays_runnable_while_dev_help_omits_it,
    package_rebuild_accepts_public_native_receipts_and_preserves_the_baseline;
    crates/registry-bregctl/tests/dev_lifecycle.rs installed_dev_prepares_a_native_source_successor_with_retained_records. */}

## Retained state and recovery

The private `.breg/dev` directory records a random ownership identifier, exact Docker container ID,
ports, captured authored closure, package digest, seed checkpoints, and, for each resolved `breg`
and `docker` prerequisite, the fully resolved path of the file that ran and the version it reported.
It contains generated configurations, separate database roles, local TLS material, credentials, and
bounded private diagnostic logs.
The first start writes a `.gitignore` into `.breg` that keeps the whole directory, its lock file
included, out of version control.
Preserve it with the retained database while the exercise matters.
It is local development material, not production key provisioning.

The state document also pins what the session runs: the compiled registry revision, the package
`sourceRevision`, and the canonical JSON form of `tests/journeys.yaml` and the clients file.
`dev start`, `dev examples run`, and `dev prepare-source` compare the project against that pin, so
an edit that changes only comments, blank lines, or key order in a YAML file is not a changed input.
The compiled revision carries the digest of every Rhai script, WASM module, and derived SQL file it
ships, so any edit to one of those files, a comment included, is a changed input.
A session started by an earlier release holds an earlier pin, which reads as changed inputs.
Records live in a named `breg-dev-<owner>` Docker volume, so the storage stays identifiable and
reclaimable once the container is gone.

{/* Evidence: crates/registry-bregctl/src/dev/tests.rs the_private_directory_is_ignored_by_version_control,
    the_source_pin_follows_the_compiled_meaning_not_the_authored_bytes,
    a_comment_in_a_handler_script_is_a_change_because_the_package_ships_its_bytes,
    a_byte_only_edit_keeps_the_session_that_holds_records. */}

### Behaviour by action and condition

- First start: captures the authored closure, prepares private identities, creates the owned
  database, runs the normal schema-test, package, apply, and verify commands, then seeds through
  authenticated HTTP.
- Already running: returns the existing ready session and credential references.
- Stop, including a repeated stop: gracefully stops the owned BReg and ThunderID, then stops the
  owned PostgreSQL container.
  Keeps records, keys, package, seed checkpoints, and the audit files.
- Stop where no start ever ran: refuses and names the absent session.
  Nothing is created, changed, or removed, so a mistyped project path cannot read as a stopped
  session.
- Start after stop: reuses the same container, database, and existing credentials.
  Preserves record edits and activates the explicitly prepared source successor when present.
  Obtains fresh short-lived tokens.
- Stop with `--remove`, including a repeated one: stops as above, then removes the owned container
  and its named data volume, tolerating whatever an earlier reclamation already took.
  Discards records, event receipts, and seed checkpoints.
  Keeps the audit files, keys, credentials, ports, clients, and the built package.
- Start after `--remove`: at sequence 1, creates an empty container and volume, activates the initial
  package, and replays authored seeds.
  A retained successor refuses before Docker because its predecessor records were removed; use a
  fresh project at sequence 1 for an empty experiment.
- Seed request committed before checkpoint: replays the same permanent BReg idempotency reservation.
  The original create result is returned without creating or overwriting a record.
- `breg` from another release: refuses before the owned container is inspected and before the
  supervisor launches, naming the file that answered, the version it reported, and the version
  `bregctl` reports.
  Nothing is created, changed, or removed.
- Retained state this release cannot read: refuses as invalid retained dev state before any
  mutation, and preserves it for inspection.
- Partial start failure: stops acquired service children and the owned container, and retains
  private diagnostics and completed phases.
  Retry the same command after correcting the prerequisite.
  The separate schema-test database may be recreated for a failed rehearsal.
- Missing or mismatched owned container: refuses.
  Never silently initialises an empty replacement or stops another container.
- Unreachable supervisor with an occupied service port: refuses.
  Never signals a stored PID that could belong to another process.
  Inspect the process owning the port before recovery.
- Authored package, clients, ports, or issuer image changed while records are retained: refuses
  before activation or record mutation.
  Restore the original inputs to restart with the records, run `dev stop --remove` to discard them
  and start again from the edited inputs, or copy the authored files to a new project directory, at
  package sequence 1, to keep the records.
- Authored package, clients, or ports changed after `--remove`: at sequence 1, replaces the session
  from the edited inputs, keeping previous ports and clients file and generating new keys.
  A successor still requires retained predecessor records.

{/* Evidence: crates/registry-bregctl/src/dev/mod.rs MISSING_SESSION, CHANGED_INPUTS, INVALID_STATE;
    crates/registry-bregctl/src/dev/tests.rs stop_before_first_start_names_the_missing_session_without_docker,
    prerequisites_from_another_release_are_refused_before_the_session_starts,
    a_retained_v1_state_is_invalid_without_mutation,
    changed_inputs_are_refused_while_the_session_holds_records,
    changed_inputs_replace_a_session_whose_records_were_discarded,
    the_changed_inputs_refusal_and_stop_help_name_the_same_two_options;
    crates/registry-bregctl/tests/dev_lifecycle.rs installed_dev_preserves_edits_and_recovers_failed_start_without_reseeding. */}

Reclamation is explicit: only `dev stop --remove` discards records, only a start after it replaces
retained keys, and only for edited inputs; this command implements no automatic reset or general
retained-schema upgrade.
The explicit source preparation above is limited to its reviewed policy-only successor.
An operated successor uses BReg's normal reviewed package, migration, activation, and recovery
procedure.
Copy only authored files to start a separate local experiment; copying private retained state does
not clone its database.

Only a resident native supervisor may signal the children it created.
Control uses an owner-only Unix socket in a short, random directory below canonical `/tmp`, avoiding
platform socket-path limits in deeply nested projects.
The socket directory is removed after stop.
Durable state stays in the project.
Catchable termination signals trigger owned cleanup; an uncatchable kill can
require inspection of surviving service owners before restart.

{/* Evidence: crates/registry-bregctl/src/dev/tests.rs control_path_is_short_and_bound_to_the_owned_journal,
    a_control_command_split_across_writes_is_read_whole,
    dev_start_help_carries_the_outside_kill_fact_and_the_document_sections. */}

PostgreSQL binds only numeric loopback.
Native setup generates a private local CA and configures TLS plus separate migration and runtime
roles before BReg connects.
Source and token HTTP clients use numeric loopback, disable ambient proxies, and refuse redirects.
Local synthetic credentials must not become operated service credentials.

{/* Evidence: crates/registry-bregctl/src/dev/tests.rs generated_postgres_leaf_verifies_against_its_distinct_ca,
    database_roles_have_independent_passwords_and_hmac_files_are_secret_safe,
    every_database_url_names_the_published_loopback_literal,
    the_dev_registry_serves_with_one_role_and_its_rehearsal_stays_split. */}

### Startup failures

When startup fails, the error names the check that failed and the retained private `logs` directory.
Native command and service diagnostics are bounded per stream.
Inspect them locally; do not publish logs or the generated state as a support attachment.
Schema-test setup failures identify destination inventory or activation, authentication, cursor,
audit, or Evidence configuration.
Correct that named configuration before retrying; recreating the database cannot fix a missing
destination binding or invalid secret.

On an initial start, the pre-apply doctor may report `startup.database.unready`,
`startup.database.uninitialized`, or `startup.package.not-active`.
Dev treats these expected not-yet-activated results as the cue for the initial package application,
preserves the raw doctor report as private `evidence/doctor-before-apply.json`, and does not copy it
into failure logs.
A standalone doctor run and the post-apply doctor keep their ordinary success or failure behaviour.

{/* Evidence: crates/registry-bregctl/src/dev/tests.rs a_refused_native_command_names_its_first_failing_check_within_a_bound,
    a_refused_schema_test_reports_the_check_that_failed_beside_the_report_log,
    output_pump_bounds_persisted_diagnostics,
    pre_apply_doctor_evidence_is_preserved_outside_failure_logs,
    only_a_database_without_the_package_activated_classifies_a_doctor_refusal_as_not_activated. */}

The rehearsal, the package build, activation, and verification all run inside the detached
supervisor, whose own streams go to a private log.
A phase that refuses records its first failing diagnostic in the private state document, and the
start reports that diagnostic on the terminal that asked for it: its code, the path it names, and its
message, bounded to one sentence.
The retained report log holds every later diagnostic.
A refused journey step is reported as `test.step.failed` at `journeys[<i>].steps[<j>]`, carrying the
fixture's own refusal sentence.
A refused logical reference names its class: a field the Record type does not declare, a field the
access profile permission does not make writable, a request body with no field, a step identifier
that is not stable, a step naming both a Record type and an action or neither, or a capture no
earlier step declares.
None of those sentences carries an authored value.

{/* Evidence: crates/registry-bregctl/src/dev/tests.rs a_supervisor_refusal_reaches_the_owner_who_asked_for_the_start,
    a_refused_native_command_names_its_first_failing_check_within_a_bound;
    crates/registry-bregctl/tests/dev_lifecycle.rs failed_session_report_surfaces_only_public_diagnostics;
    crates/registry-bregctl/src/dev/mod.rs MAX_REFUSAL. */}

## Next

- [Deploy and serve](../../operate/breg/)
- [Bind webhook receivers](../../operate/breg-webhooks/)
- [Author a registry project](../../configure/breg/)