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 task grants

> How Registry Scheduling admits task grants for commitments, the scheduling bounds, how a permission matches, the grant status check, source-managed bookings, and what the audit records.

A task grant gives an institutional agent bounded authority to commit Registry Scheduling capacity under its own principal.
It does not make the agent the human who approved the task, it carries no catalogue or availability read authority, and it never decides eligibility.
Whether a party may hold a service remains with the source system that owns the rule.

The route-specific authorities are disjoint.
A token carrying a product scope does not gain a commitment path, and a task grant does not grant a catalogue read.
Scopes authorise reads, and the separately configured explain scope authorises the diagnostic read.
Every commitment takes its authority from the grant alone.
One access token may carry both profiles, but each operation checks only its own authority.

## Claim set

A commitment requires no product scope.
Its authority is the grant inside the access token, whether or not that token also carries read scopes.
The grant is the six `registry_grant_*` members plus `registry_purpose` and `registry_approver`:

- `registry_grant_id`
- `registry_grant_source_issuer`
- `registry_grant_client`
- `registry_grant_resource`
- `registry_grant_exp`
- `registry_grant_bounds`

A token carrying none of them is an ordinary standing token.
A token carrying some of them is refused as a malformed credential rather than honoured partially.

Before the caller reaches the service, the runtime binds the grant to two facts it verified itself.
The grant's client must equal the client the deployment verified (`azp` or `client_id`).
The grant's resource must equal the deployment's configured OIDC audience.
A grant minted for another product's resource is a profile refusal, and the closed union of bounds makes it one in every verifier: an unknown bounds tag is a malformed claim, so a grant minted for one product is never interpreted by another product's runtime.

{/* Evidence: crates/registry-scheduling/src/auth.rs a_grant_naming_another_resource_is_a_profile_refusal, grant_claims_value;
    crates/registry-platform-oidc/src/authorization_claims.rs any_partial_core_grant_set_is_rejected. */}

## Scheduling bounds

The bounds are `{"type": "scheduling", "permissions": [...]}`.
One permission names a service, a location, and the actions it allows there:

```yaml
type: scheduling
permissions:
  - service: registry-update
    location: bangkok-counter
    actions:
      - appointment.create
      - appointment.reschedule
```

The action vocabulary is closed:

- `hold.create` and `hold.release`
- `appointment.create`, `appointment.reschedule`, and `appointment.cancel`
- `hold.create-for` and `appointment.create-for` for source-managed bookings
- `appointment.read` for one appointment's current detail, read by id
- `attendance.record` for recording an attendance observation

The bounds a signed claim carries are limited:

- At most 64 permissions, each a unique `(service, location)` pair.
- At most 32 actions per permission, each at most 128 bytes.
- Service and location values of at most 512 bytes, without whitespace, control characters, or a `*`.

Wildcards are refused, unknown members are refused at every level rather than ignored, and duplicate actions or duplicate pairs are refused.
Nothing about a permission is optional: an empty `actions` list is malformed, not a grant to read.

An issuer mints the `scheduling` tag only once every verifier it targets understands it.
A verifier built before the tag existed rejects the whole grant as malformed, which is the intended fail-closed direction.
An operator who rolls a verifier back past that point needs to know it.

{/* Evidence: crates/registry-platform-oidc/src/authorization_claims.rs MAX_SCHEDULING_PERMISSIONS,
    MAX_SCHEDULING_ACTIONS, scheduling_permission_cardinality_bounds_are_enforced,
    scheduling_value_boundaries_and_unknown_fields_are_enforced;
    crates/registry-scheduling/src/service.rs HOLD_CREATE_FOR_ACTION, ATTENDANCE_RECORD_ACTION. */}

## How a permission matches

A permission matches an offering only when its service equals the offering's service, its location equals the offering's location, and its action list names the operation the route performs.
The match is exact: a broader service or location never covers a narrower one, and no rule maps one location onto another.
A grant that does not cover the request answers `operation.not-authorized` and nothing is written.

The bounds are matched at the service before the capacity transaction opens.
Inside the transaction, after every lock wait and immediately before commit, Registry Scheduling checks the earlier of the verified access token deadline and the grant deadline against the transaction clock.
A credential that expires after the status answer cannot take capacity through a delayed transaction.

{/* Evidence: crates/registry-scheduling/src/service.rs
    the_offline_path_accepts_only_an_unexpired_grant_with_at_most_fifteen_minutes_left;
    crates/registry-platform-oidc/src/authorization_claims.rs
    expiry_uses_earlier_token_or_grant_deadline_and_refuses_exact_deadline;
    crates/registry-scheduling/tests/postgres_commitments.rs
    inactive_mismatched_and_unavailable_task_status_commit_no_capacity. */}

## Grant status

Every runtime file states `taskGrantStatus`, either as a list of task authorities or as the keyword `unchecked-final-fifteen-minutes`.
A file that omits it is refused at startup with `scheduling.runtime.missing-task-grant-status`.
[Registry Scheduling configuration reference](../scheduling-configuration/#task-grant-status) lists the keys.

When `taskGrantStatus` lists authorities, Registry Scheduling first obtains a fresh answer from the authority selected by the signed grant's source issuer.
The answer must say the grant is active and must reproduce the exact grant id, source issuer, principal, client, resource, purpose, bounds, signed subject values, and deadline.
Registry Scheduling does not cache a positive answer.
It checks again for an idempotent receipt replay, so revocation also closes that path.

The complete status attempt, including acquisition of the service credential, is limited to ten seconds.
These outcomes follow:

- An inactive, unlisted, mismatched, or incompletely bound grant answers `operation.not-authorized`.
- An authority or service credential outage, including an unusable authority response, answers `service.unavailable`.
- HTTP 401 or 403 from the status endpoint means the service credential was rejected, so the observation is unavailable; it does not establish inactive task authority.
- HTTP 404 remains a grant refusal.

The status call happens before the capacity transaction opens, so no capacity lock is held while Registry Scheduling waits on another product.
The answer is a fresh observation, not a distributed transaction with the authority: a withdrawal after a positive answer can race the in-flight local commit.

`taskGrantStatus: unchecked-final-fifteen-minutes` selects the offline path.
No authority is asked, no revocation is observed, and Registry Scheduling accepts a grant only while it is unexpired with no more than 900 seconds remaining at request entry.
A list of authorities disables that path for every source, including an unlisted one, which is refused even with less than 15 minutes left.
The token does not name its authorisation mode, so the final 15 minutes of an originally deferred grant can use the offline path on a deployment that writes the keyword.
List the task authorities for every deployment that accepts deferred grants.

{/* Evidence: crates/registry-scheduling/src/service.rs
    listed_authorities_refuse_an_unlisted_source_and_an_unbound_grant_without_the_offline_path,
    the_offline_path_accepts_only_an_unexpired_grant_with_at_most_fifteen_minutes_left;
    crates/registry-scheduling/src/config.rs a_missing_task_grant_status_is_refused_naming_both_choices;
    crates/registry-scheduling/tests/postgres_commitments.rs
    configured_task_status_is_fresh_for_a_capacity_commit_and_its_replay,
    inactive_and_unavailable_task_status_refuse_every_mutation_without_changing_capacity;
    crates/registry-platform-oidc/src/task_grant.rs. */}
{/* TODO[evidence]: no named test asserts the HTTP 401, 403, and 404 status-endpoint mapping individually; the ten-second limit is a literal in the shared task-grant client. */}

## Source-managed assisted bookings

Omitting `manager` from admission keeps the ordinary path, where the booking is owned by the agent's verified issuer and subject.
An explicit `manager: schedulingManager` selects the fixed `schedulingManager` string in the grant's signed `identity` object.
The request carries no manager identifier.
Registry Scheduling binds that value to the grant's source issuer and retains it separately from the actor that submitted the command.
The source issuer must guarantee that its manager identifiers are stable and never reassigned.
Beneficiary and organisation references are booking data and never substitute for this verified binding.

Grant `subjects` are compared only for the task-grant status check and for the `schedulingManager` selector.
External references, party references, and `duplicateKey` values are caller booking data and are never compared with them, so a grant for one person does not stop its holder from booking with another person's references.

Creating an assisted hold requires `hold.create-for`.
Direct creation and confirmation of an assisted hold require `appointment.create-for`.
Release, reschedule, and cancellation use their existing actions.
Every assisted operation requires an online configured status authority, a fresh exact grant status match, and the same source-manager binding as the claim.
The offline final-fifteen-minutes path cannot authorise it.
A hold's manager is retained through confirmation, and rescheduling cannot transfer management authority.

The appointment detail route accepts `appointment.read` under the appointment's actual service and location bounds.
For a source-managed appointment the caller must be the matching source manager.
For a self-booked appointment, a caller holding a current online `appointment.read` task grant for that service and location can read any appointment it names by id.
This is an accepted residual risk, so grant the action only to services whose workflow already selects the appointment.
The action grants no list, history, catalogue, or unrelated appointment authority.
The original actor's ordinary read scope does not make it the assisted appointment's manager.
Separately configured operational readers stay governed by their own bounded profile.

Idempotency stays actor-scoped.
An exact retry can recover its original receipt under the fresh-status rules, and that receipt is not current-detail authority.
Identity retention erases the raw source-manager binding alongside the ordinary ownership fields, which closes this management path after expiry.

{/* Evidence: crates/registry-scheduling/tests/postgres_commitments/booking_party.rs
    an_assisted_manager_is_selected_only_from_fresh_exact_source_authority,
    a_current_appointment_read_grant_reads_a_self_booked_appointment_only_within_its_bounds,
    assisted_manager_authority_is_bound_into_idempotency_and_retention. */}

## What the audit records

Every commitment writes a `request` entry before its capacity transaction opens.
It writes a `response` entry carrying its authorisation decision, under `authorization.allowed` or `authorization.refused`, once the transaction commits or rolls back.
A permission the service refuses before any commitment is reached writes one `response` entry.
The principal, client, grant, and approver are keyed pseudonyms scoped to the request's reference class, and the purpose is recorded as presence only, never as a value.
The record adds the grant's source issuer and its deadline.
No bound value, service, location, or action appears in the audit.

{/* Evidence: crates/registry-scheduling/src/audit.rs;
    crates/registry-scheduling/tests/postgres_commitments.rs
    inactive_and_unavailable_task_status_refuse_every_mutation_without_changing_capacity. */}
{/* TODO[evidence]: no test asserts that no bound value, service, location, or action appears in the audit entry. */}

## Where a grant comes from

Registry Scheduling verifies grants; it does not approve them.
The token-exchange issuer mints a grant from a template a current human holder approved, and the approver's identity travels in the claim.
Registry Casework's task authority accepts Scheduling bounds directly, and stock ThunderID's institutional grant exchange copies those verified bounds into the access token.
Registry Scheduling is a relying party of that authority and inherits no Casework authorisation.

The Casework project declares the exact destination in a governed template:

```yaml
taskTemplates:
  schedule-registry-update:
    version: "1"
    label: Book a registry update
    eligibleTeams:
      - registry-review
    eligibleProfiles:
      - staff
    source: registry-requests
    itemKinds:
      - request
    itemStates:
      - claimed
    agent:
      issuer: https://identity.example.test/realms/registry
      subject: scheduling-agent-service-account
    client: scheduling-agent
    resource: urn:example:scheduling
    scopes:
      - scheduling:read
      - scheduling:commit
    purpose: schedule-registry-update
    bounds:
      type: scheduling
      permissions:
        - service: registry-update
          location: bangkok-counter
          actions:
            - appointment.create
    subjects:
      subject_reference: subject-reference
    authorizationMode: deferred
    # Deferred grants choose an explicit lifetime, up to seven days.
    # Immediate grants retain their 900-second maximum.
    lifetimeSeconds: 86400
```

`scheduling:commit` is an explicit scope registered at the exchange issuer.
The Registry Scheduling runtime derives mutation authority from the grant bounds rather than that scope.
The native exchange uses the issuer-compatible `scheduling:read` handle, which is the runtime's default `readsScope`.
The read scope lets the same short-lived token select a currently published free start.

Register `scheduling-agent` as a Casework `taskExchange` service client, and register `urn:example:scheduling` plus those scopes at the shared issuer.
In the Registry Scheduling runtime, use that issuer and audience, admit the client, and bind it to the Casework task authority:

```yaml
authentication:
  oidc:
    issuer: https://identity.example.test/realms/registry
    audience: urn:example:scheduling
    scopeClaim: scope
    readsScope: scheduling:read
    allowedClients:
      - scheduling-agent
    assertionIssuers:
      scheduling-agent:
        - https://casework.example.test/task-authority

taskGrantStatus:
  - sourceIssuer: https://casework.example.test/task-authority
    baseUrl: https://casework.example.test
    tokenEndpoint: https://identity.example.test/realms/registry/protocol/openid-connect/token
    clientAssertionAudience: https://identity.example.test/realms/registry
    clientId: scheduling-task-status
    privateKeyRef: secret:file/scheduling-task-status-private-jwk
    statusResource: urn:example:casework
```

Register `scheduling-task-status` with the identity provider for private-key JWT client authentication, and as a Casework client allowed to read grant status with the `casework:grants:status` scope.
`privateKeyRef` resolves its private JWK.
Add `caBundleRef` when the token endpoint or Casework uses a private CA.
Each configured source issuer is pinned to its own endpoint and service credential, and duplicate sources are a startup refusal.

After a current holder previews and approves the template, the agent exchanges the approved grant UUID against the shared issuer.
It follows the sequence in [Casework task grants](../casework-task-grants/#configure-the-authority): a client-credentials bootstrap for Casework's signed assertion, then a token exchange at the issuer for `urn:example:scheduling` and the grant's scopes, both with the agent's `private_key_jwt` credential.
The result is a Scheduling access token that carries the grant's bounds and expires no later than the immutable grant deadline.
Write the token to an owner-only header file and name it `HEADER_FILE`.
Use the `rstack` installation whose Scheduling component matches the runtime to read the active policy revision, select a free start, then book it.
Set `POLICY_REVISION` from the service document and `START` from the availability response.
`--header @FILE` reads the grant header without putting its value on the command line:

```sh
rstack scheduling api /v1/scheduling \
  --url "$SCHEDULING_URL" \
  --header @"$HEADER_FILE"

rstack scheduling api '/v1/availability?offering=registry-update-30' \
  --url "$SCHEDULING_URL" \
  --header @"$HEADER_FILE"

rstack scheduling api /v1/appointments \
  --url "$SCHEDULING_URL" \
  --header @"$HEADER_FILE" \
  --idempotency-key approved-registry-update-1 \
  --input - <<JSON
{"admission":{"offering":"registry-update-30","start":"$START","party":{"recipients":1,"attendees":1},"duplicateKey":"subject:approved-request","policyRevision":$POLICY_REVISION,"capabilities":[],"prerequisites":[]}}
JSON
```

[Registry Casework task grants](../casework-task-grants/) covers the approval surface, the template grammar, the exchange setup, and revocation.
A standalone external authority can issue the same closed claim contract; Casework is the maintained in-stack approval path rather than a required Scheduling runtime dependency.

Registry Scheduling has no route that books on another party's behalf, and a grant does not create one.
Guest booking, where a holder books for someone else, is an explicit exclusion from the product scope.

{/* Evidence: crates/registry-scheduling/src/config.rs a_task_grant_status_authority_loads_with_literal_secret_references,
    a_task_status_casework_resource_is_refused_naming_status_resource;
    crates/registry-platform-oidc/src/task_grant/config.rs
    configured_status_clients_pin_source_issuer_and_refuse_unsafe_or_duplicate_bindings. */}
{/* TODO[evidence]: no test runs the token exchange and rstack commands as written; the native boundary fixture exercises the authenticator with a stock-issued bearer. */}

## Next

- [Registry Scheduling configuration reference](../scheduling-configuration/)
- [Registry Casework task grants](../casework-task-grants/)
- [Deploy and operate Registry Scheduling](../../operate/scheduling/)
- [Request an access token from your own code](../../configure/request-an-access-token/)