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

# Registry Scheduling security model

> What Registry Scheduling's security controls guarantee, the obligations that stay with the operator, and the residual risks a deployment accepts, each with its stable identifier.

This page states what Registry Scheduling's security controls guarantee, what they do not, and what
you must do for the guarantees to hold.
The invariants themselves, each with its threat, enforcement point, refusal and test, are rows
`SCHEDULING-SEC-01` to `SCHEDULING-SEC-43` in the
[security invariant matrix](https://github.com/registrystack/registry-stack/blob/v0.46.0/products/scheduling/contracts/security-invariant-matrix.yaml),
which a contract validator checks; this page does not copy them.
Configuration members are described in
[Registry Scheduling configuration reference](../../reference/scheduling-configuration/), and
task-grant handling in [Registry Scheduling task grants](../../reference/scheduling-task-grants/).

## Scope and trust boundaries

Scheduling commits capacity (holds, appointments, windows) inside PostgreSQL transactions, for
callers holding bearer tokens from a configured issuer.

- Callers are untrusted until the token verifies against the configured key source and carries a
  complete scheduling task grant (service, location, actions).
  A partial grant is refused, never honoured partially (SCHEDULING-SEC-04, SCHEDULING-SEC-05).
- The issuer and task-grant authorities are trusted to say who a caller is and whether a grant is
  still live.
  Declared issuer and key addresses are trusted on the operator's word (SCHEDULING-RES-10).
  Scheduling checks a grant's status with its authority before every capacity commitment and every
  receipt replay when `taskGrantStatus` lists authorities (SCHEDULING-SEC-03).
- The migration credential holder is trusted to activate a package.
  The activation ledger records that an apply happened, which package, and under which role mode.
  It is not a signed approval (SCHEDULING-SEC-29 to SCHEDULING-SEC-32).
- The runtime database credential is trusted to serve, not to change activation state.
  In split role mode `apply` revokes ledger writes from it; in single role mode that separation does
  not hold, and `plan`, `apply` and `status` say so (SCHEDULING-SEC-30).
- The database superuser and anyone who can read Scheduling tables are outside the model.
  A table reader sees what the tables hold (see SCHEDULING-RES-04 and SCHEDULING-RES-05).
- Host users who can write the audit destination can alter audit history.
  Entries are not chained; tamper evidence belongs to the destination and the collection pipeline
  (SCHEDULING-SEC-14).
- The clock: the edge, the store and the workers read one store clock.
  The OIDC verifier and the grant expiry check at the door read the system clock.
  Hook delivery uses PostgreSQL `transaction_timestamp()`.
  The clock pin used in tests exists only in `postgres-test` builds (SCHEDULING-SEC-23).

{/* Evidence: products/scheduling/contracts/security-invariant-matrix.yaml SCHEDULING-SEC-03,
    SCHEDULING-SEC-04, SCHEDULING-SEC-05, SCHEDULING-SEC-14, SCHEDULING-SEC-23, SCHEDULING-SEC-29,
    SCHEDULING-SEC-30, SCHEDULING-SEC-31, SCHEDULING-SEC-32;
    crates/registry-scheduling/src/auth.rs a_partial_grant_is_refused_as_invalid_claims,
    a_grant_naming_another_resource_is_a_profile_refusal,
    an_unreadable_clock_refuses_to_judge_an_expiry_rather_than_passing_it;
    crates/registry-scheduling/tests/postgres_commitments.rs
    configured_task_status_is_fresh_for_a_capacity_commit_and_its_replay;
    crates/registry-schedulingctl/tests/activation_postgres.rs
    split_roles_deny_the_runtime_a_ledger_write_and_the_service_still_serves. */}

### Accountability

A commitment writes its audit `request` entry before its transaction opens and its `response` entry
after the transaction ends.
If either entry is refused, the caller gets `service.unavailable` instead of an unaudited answer.
A refused `request` entry opens no transaction; a refused `response` entry after the commit answers
`service.unavailable` with the commitment in place.
`/readyz` follows the audit writer.

{/* Evidence: crates/registry-scheduling/tests/postgres_commitments.rs
    a_refused_request_entry_opens_no_capacity_transaction,
    a_failed_capacity_transaction_pairs_its_request_entry,
    a_replayed_receipt_is_released_only_after_its_response_entry_is_accepted;
    crates/registry-scheduling/src/http.rs readyz;
    crates/registry-scheduling/src/service.rs audit_ready. */}

## Operator obligations

The guarantees hold only when you meet these obligations.

1. Run PostgreSQL 17 or newer.
   Activation and startup refuse older servers.
2. Reach PostgreSQL over TLS.
   The runtime requires it; `database.testOnlyPlaintext` is honoured only in `postgres-test` builds,
   and the shipped runtime refuses it with `scheduling.runtime.plaintext-database`.
3. Bind the listener to a loopback or private address, or declare
   `networkExposure: container-private`.
   Anything else refuses to start.
4. Terminate TLS in front of the runtime.
   Scheduling sets `Cache-Control: no-store`, security headers (without HSTS) and a 1 MiB body
   ceiling, and leaves TLS and HSTS to you.
5. Use two database roles in production (migration and runtime) so the runtime cannot rewrite the
   activation ledger.
   Revoke any `TRIGGER` privilege the runtime role holds; `apply` refuses it and names the statement
   to run.
6. Put any second approver for a package in front of `schedulingctl apply`, in the pipeline that
   holds the migration credential.
   Nothing in Scheduling signs an activation.
7. Write `taskGrantStatus` explicitly.
   Omitting it is refused at startup.
   If you accept deferred grants, list at least one status authority (SCHEDULING-RES-02).
8. Grant `appointment.read` only to services whose workflow already selects the appointment
   (SCHEDULING-RES-01), and configure `authentication.oidc.appointmentReadProfiles` only for the
   cross-owner work lists you intend to expose (SCHEDULING-RES-03).
9. Send audit to storage that is append-only or otherwise tamper evident, and monitor it.
   Scheduling does not chain entries.
   Collect the `schedulingctl` sibling stream of `audit.path` too: `apply` and `records apply` write
   there, not into the runtime file.
   When a response entry is refused after an activation commits, `schedulingctl` exits 3 with
   `schedulingctl.activation.applied-unaudited`; the package is active, so restore the destination
   and confirm with `schedulingctl status`.
10. Set retention deliberately.
    The defaults (`retention.claimOwnerRetentionDays` of 7, `audit.retentionDays` of 90,
    `retention.receiptRetentionDays`) are placeholders, not a jurisdictional recommendation.
    See SCHEDULING-DEF-06.
11. Bound request rates at your ingress.
    Scheduling keeps no request budget of its own (SCHEDULING-RES-06).
12. Make your hook receivers tolerate duplicate events; delivery is at-least-once
    (SCHEDULING-RES-07).
13. Apply a new package to a new database when a refusal reports a pre-1.0 schema.
    No release upgrades that state in place.
14. Use an HTTPS issuer and leave `authentication.oidc.allowInsecureHttp` unset.
    Declare only issuer and JWKS addresses you intend Scheduling to reach (SCHEDULING-RES-10).

{/* Evidence: crates/registry-scheduling/src/store.rs refuse_pre_1_0_schema, UnsupportedPostgres;
    crates/registry-scheduling/src/config.rs plaintext_postgres_is_refused_outside_the_test_suite,
    listener_requires_a_private_address_or_explicit_container_network, task_grant_status_refused,
    retention_days, default_claim_owner_retention_days, DEFAULT_RECEIPT_RETENTION_DAYS,
    insecure_http_startup_diagnostic;
    crates/registry-scheduling/tests/plaintext_config.rs
    the_default_feature_runtime_refuses_test_only_plaintext;
    crates/registry-scheduling/src/http.rs request_body_limit_default, without_hsts, no-store;
    crates/registry-scheduling/src/store/activation.rs TriggerPrivilege;
    crates/registry-schedulingctl/src/lib.rs schedulingctl.activation.applied-unaudited;
    crates/registry-schedulingctl/tests/activation_postgres.rs
    an_apply_whose_response_audit_entry_is_refused_reports_it_applied_unaudited. */}

## Accepted residuals

Each residual names the condition under which it applies, its consequence, the operator
mitigation, and the related matrix rows.
`SCHEDULING-DEF-04` and `SCHEDULING-DEF-06` are deferred controls: no control closes them yet, so a
deployment carries them today, and they are listed here as residuals.
`SCHEDULING-DEF-05` is a deferred control with a compensating control, the offering's supply lock;
it is listed with them.

### SCHEDULING-RES-01: a self-booked appointment is readable by id within the granted service and location

- Condition: the caller holds a current online `appointment.read` task grant for the appointment's
  service and location, and the appointment is self-booked (not source-managed).
  A caller that holds the reads scope also reads what it owns; a caller admitted only through its
  grant is held to the grant even for an appointment it owns.
- Consequence: the caller can read any appointment it names by id at that service and location.
  The grant does not bind an appointment id.
  For source-managed appointments the exact retained manager and source issuer are also required.
  The grant opens no list, history, catalogue or operational route.
- Operator mitigation: issue the action only to services whose workflow already selects the
  appointment.
- Related: SCHEDULING-SEC-05, SCHEDULING-SEC-08, SCHEDULING-SEC-36.

{/* Evidence: products/scheduling/contracts/security-invariant-matrix.yaml SCHEDULING-SEC-05,
    SCHEDULING-SEC-08, SCHEDULING-SEC-36;
    crates/registry-scheduling/tests/postgres_commitments/booking_party.rs
    an_assisted_manager_is_selected_only_from_fresh_exact_source_authority. */}

### SCHEDULING-RES-02: the final fifteen minutes of a deferred grant are not revocation-checked

- Condition: the deployment writes `taskGrantStatus: unchecked-final-fifteen-minutes`.
  The signed token does not say whether the grant was issued in immediate or deferred mode.
- Consequence: a grant with 900 seconds or less remaining qualifies for the bounded offline path
  with no revocation check.
  Even with status checks, a withdrawal that follows a positive status answer can race the
  in-flight local commit; the interval is bounded by the short execution credential and by deadline
  re-checks after every lock wait and before commit.
- Operator mitigation: list at least one status authority.
  That disables the offline path for every grant, including sources not listed.
- Related: SCHEDULING-SEC-03.

{/* Evidence: crates/registry-scheduling/src/config.rs UncheckedFinalFifteenMinutes,
    task_grant_status_refused;
    products/scheduling/contracts/security-invariant-matrix.yaml SCHEDULING-SEC-03. */}

### SCHEDULING-RES-03: operational profiles disclose cross-owner bookings by design

- Condition: the operator configures an `appointmentReadProfiles` entry.
- Consequence: holders of that profile see other owners' bookings within the profile's service,
  location, resource set and time bounds.
  An explicit `unrestricted` resource scope covers every resource at that one service and location.
  Detail readers also receive the current attendance observation; operational readers receive it
  only if the profile selects attendance.
- Operator mitigation: keep profiles narrow, and do not select attendance unless needed.
- Related: SCHEDULING-SEC-37, SCHEDULING-SEC-42.

{/* Evidence: products/scheduling/contracts/security-invariant-matrix.yaml SCHEDULING-SEC-37,
    SCHEDULING-SEC-42;
    crates/registry-scheduling/tests/postgres_commitments/operational_reads.rs
    operational_pages_require_one_profile_and_bind_every_authority_dimension. */}

### SCHEDULING-RES-04: the spent-key reference is an unkeyed digest kept indefinitely

- Condition: an idempotency attempt exists.
  Its reference is a digest of the caller scope and key.
- Consequence: anyone who can read the table and already knows a caller's issuer, subject and exact
  key can confirm the attempt was made; guessable keys make that cheap.
  The row also keeps the command scope, request hash, outcome status and timestamps.
  The digest is not keyed with the audit key because rotating that key would free every spent key
  and allow double booking.
- Operator mitigation: restrict database read access; have callers use unguessable keys.
  Receipt expiry clears the raw caller and key.
- Related: SCHEDULING-SEC-09, SCHEDULING-SEC-33.

{/* Evidence: products/scheduling/contracts/security-invariant-matrix.yaml SCHEDULING-SEC-09,
    SCHEDULING-SEC-33;
    crates/registry-scheduling/tests/postgres_commitments.rs
    a_spent_key_forgets_its_raw_caller_after_the_receipt_horizon_and_stays_spent. */}

### SCHEDULING-RES-05: the erased claim owner digest is pseudonymous, not anonymous

- Condition: the retention worker has cleared a claim's raw issuer and subject after
  `claimOwnerRetentionDays` (1 to 365, default 7).
- Consequence: a holder of candidate issuer and subject values and the claim UUID can test guesses
  against the stored digest.
  The keyed actor pseudonym remains in claim history and audit, whose retention is separate.
  Erasure needs a running runtime; the pass is idempotent.
  Once erased, the owner can no longer read, list or replay that claim's receipts, and receipt
  lookups answer `receipt.unresolved`, which does not prove no effect occurred.
- Operator mitigation: choose the window with your records policy; keep the runtime running; treat
  history and audit retention as a separate decision.
- Related: SCHEDULING-SEC-34, SCHEDULING-DEF-06.

{/* Evidence: products/scheduling/contracts/security-invariant-matrix.yaml SCHEDULING-SEC-34;
    crates/registry-scheduling/src/config.rs default_claim_owner_retention_days;
    crates/registry-scheduling/tests/postgres_commitments.rs
    rotating_the_audit_key_keeps_existing_claims_with_their_owner. */}

### SCHEDULING-RES-06: no request throttling

- Condition: an authenticated caller repeats a route, including receipt observation.
- Consequence: each request costs one bounded indexed lookup and its audit records.
  Scheduling applies no read budget.
- Operator mitigation: bound authenticated floods at the deployment ingress.
- Related: SCHEDULING-SEC-14.

{/* Evidence: products/scheduling/contracts/security-invariant-matrix.yaml SCHEDULING-SEC-14. */}

### SCHEDULING-RES-07: hook delivery is at-least-once

- Condition: a send's response is lost, or a reminder's appointment is cancelled or moved while a
  dispatcher holds the reminder.
- Consequence: a destination that ignores the envelope `id` may see an event twice.
  A cancel or reschedule committed between the liveness check and the send can still send a stale
  reminder, and receivers get no ordering across processes.
  One worker serves each runtime process.
- Operator mitigation: deduplicate on the envelope `id` and treat reminders as advisory.
- Related: SCHEDULING-SEC-24, SCHEDULING-SEC-38.

{/* Evidence: products/scheduling/contracts/security-invariant-matrix.yaml SCHEDULING-SEC-24,
    SCHEDULING-SEC-38;
    crates/registry-scheduling/tests/postgres_commitments.rs
    a_signed_reminder_uses_the_shared_event_delivery_contract. */}

### SCHEDULING-RES-08: an open activation race fails closed with an availability cost

- Condition: an earlier runtime appends a delivery between the retained binding check and the
  activation locks, bound to a destination the new package rebinds.
  The check runs on its own connection before the locks, not inside the activation transaction.
- Consequence: `apply` does not see that delivery.
  No payload reaches the rebound destination: delivery re-checks each binding, and startup verifies
  retained bindings again and refuses to serve until the delivery drains or its binding is kept.
- Operator mitigation: drain hook deliveries before applying a package that rebinds a destination;
  if startup refuses, wait for the delivery to drain or keep the binding.
- Related: SCHEDULING-SEC-29, SCHEDULING-SEC-32.

{/* Evidence: products/scheduling/contracts/security-invariant-matrix.yaml SCHEDULING-SEC-29,
    SCHEDULING-SEC-32;
    crates/registry-schedulingctl/tests/activation_postgres.rs
    startup_refuses_a_database_the_ledger_does_not_name_for_this_package. */}

### SCHEDULING-RES-09: older input meets a less specific refusal

- Condition: configuration or state from before the current baseline.
- Consequence: the usage error does not name `schedulingctl plan` and `apply`, and a
  corrupt-database refusal does not say to start from a new database.
  Schema versions below the version 200 baseline are refused as pre-1.0 and are not upgraded in
  place.
- Operator mitigation: apply to a new database, as the release notes for the releases that made
  each break instruct.
- Related: SCHEDULING-SEC-29.

{/* Evidence: crates/registry-scheduling/src/store.rs refuse_pre_1_0_schema;
    products/scheduling/contracts/security-invariant-matrix.yaml SCHEDULING-SEC-29. */}

### SCHEDULING-RES-10: declared issuer and key endpoints are trusted

- Condition: the runtime file names an issuer or JWKS URI, or sets
  `authentication.oidc.allowInsecureHttp: true`.
- Consequence: Scheduling trusts a declared issuer or JWKS URI on the operator's word.
  Under `allowInsecureHttp: true`, an attacker on the network path to the issuer can substitute
  keys and mint tokens Scheduling accepts.
  Startup logs a fixed warning when the setting is on.
  The residual is shared across products and set out in [Token issuer and key endpoints](../#token-issuer-and-key-endpoints).
- Operator mitigation: use an HTTPS issuer; leave `allowInsecureHttp` unset; or pin keys with a
  static `jwksSource`.
- Related: SCHEDULING-SEC-04, SCHEDULING-SEC-16.

{/* Evidence: crates/registry-scheduling/src/config.rs insecure_http_startup_diagnostic,
    static_jwks_requires_unique_named_asymmetric_keys;
    crates/registry-platform-oidc/src/lib.rs
    a_cross_origin_jwks_must_use_https_even_under_the_http_opt_in,
    cloud_metadata_is_refused_for_declared_and_discovered_key_endpoints;
    products/scheduling/contracts/security-invariant-matrix.yaml SCHEDULING-SEC-04,
    SCHEDULING-SEC-16. */}

### SCHEDULING-DEF-04: the channel is not bound to the verified caller

This control is deferred, so a deployment carries the risk today.

The channel that selects a window subquota is asserted by the caller and persisted verbatim.
It is not derived from the verified client or the grant, so a caller entitled to book may choose
which subquota it draws from.
The policy declares a closed channel set, an undeclared channel is refused with a typed code, and
every subquota is a ceiling inside the one published total, so a mis-chosen channel cannot oversell
the window.
Scheduling does not bind the channel to the verified client.

{/* Evidence: products/scheduling/contracts/security-invariant-matrix.yaml SCHEDULING-DEF-04. */}

### SCHEDULING-DEF-05: no database backstop under the duplicate-key guard

This control is deferred.

The duplicate guard reads active bookings across the offering inside the same capacity transaction
as the claim it protects.
The supporting index is partial and not unique, so the guard rests on the transaction and not on a
database constraint.
The offering's supply lock serialises the guard and the claim, so a concurrent pair cannot straddle
it, even when their intervals lie under different published opening revisions.

{/* Evidence: products/scheduling/contracts/security-invariant-matrix.yaml SCHEDULING-DEF-05;
    crates/registry-scheduling/src/store.rs include_active_duplicate;
    crates/registry-scheduling/tests/postgres_commitments.rs
    the_duplicate_guard_is_indexed_on_the_whole_predicate_it_filters. */}

### SCHEDULING-DEF-06: retention of committed scheduling data

This control is deferred, so a deployment carries the risk today.

Scheduling sets no retention windows for committed claims, history and actionable or uncertain
outbox rows.
Idempotency receipts expire and tombstone, clearing the raw caller and key (SCHEDULING-SEC-33).
The claim owner's raw issuer and subject expire under `claimOwnerRetentionDays`
(SCHEDULING-SEC-34).
Delivered outbox intents of every purpose, reminders cancelled before any attempt or set aside as
superseded, and terminal hook metadata are removed on `receiptRetentionDays` in bounded
transactions (256 rows per table family), preserving replay through payload expiry.
Pending, leased, retryable and uncertain work remains.
Rotated audit files are removed after `audit.retentionDays`.
[Registry Scheduling configuration reference](../../reference/scheduling-configuration/) states
what each sweep covers.

{/* Evidence: products/scheduling/contracts/security-invariant-matrix.yaml SCHEDULING-DEF-06,
    SCHEDULING-SEC-33, SCHEDULING-SEC-34;
    crates/registry-scheduling/src/config.rs receipt_retention_days, claim_owner_retention_days. */}

## Report a vulnerability

Report a suspected vulnerability through the process in
[Report a vulnerability](../report-a-vulnerability/).

## Next

- [Security](../)
- [Deploy and operate Registry Scheduling](../../operate/scheduling/)
- [Registry Scheduling configuration reference](../../reference/scheduling-configuration/)
- [Registry Scheduling task grants](../../reference/scheduling-task-grants/)
- [Registry Scheduling](../../start/scheduling/)