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

# Task grants and standing agents

> How Base Registry Engine admits Casework task grants and standing native agents, which ceilings the compiler enforces, the taskGrantStatus runtime entry, and what the audit records.

A Casework task grant gives an institutional agent bounded authority under its own principal.
It does not make the agent the human who approved the task.
Base Registry Engine (BReg) verifies the exchanged access token and the selected access profile, then checks current Casework status before each new governed mutation.
Task agents use named Actions and Proposals within their exact signed and compiled bounds.
Direct target CRUD, imports, batches, and tombstones remain forbidden.
A task grant cannot acquire an operation or target the profile does not grant.

## Author the access profile

The authored access profile selects `actorKind: agent`, exact `requesterClients`, `requiredPurposes`, and a `taskGrant` containing the exact `sourceIssuer`.
The token must match that profile, the configured BReg audience, and the compiled collection and operation bounds.
The grant must name the request's own principal, the value of the configured principal claim, and its own purpose, the value of the configured purpose claim.
Record reads, read paths, statistics, Actions and Proposals refuse a grant that names another.
The exchanged token therefore carries the claims the profile names: when `authorityClaims.principal` is `registry_principal`, BReg compares the grant with that claim, not with `sub`.
A task token cannot fall back to a standing access profile, and ordinary profiles retain their own authority.

A token that carries a task grant must carry `iat` and be issued for at most 900 seconds (`exp - iat`), whatever the deployment's ordinary `authentication.oidc.maximumTokenLifetimeSeconds`.
BReg refuses a longer one at authentication, even in its last minutes.
It also refuses a task-grant token whose `iat` is later than BReg's clock plus `authentication.oidc.leewayMilliseconds`, the leeway already applied to `exp` and `nbf`, so the issued lifetime bounds how long BReg honours the token.
Reads check no live Casework status, so this bound, with the grant deadline, is what ends reading after Casework revokes a grant.
A `taskGrant` is authored only in project `accessProfiles`.
A module cannot contribute a task-grant profile, and the compiler refuses one with `breg.access-profile.task-grant-module-forbidden`.

An authored `permissions` entry is the registry's governed ceiling for a profile.
A delegated `taskGrant` is signed, short-lived authority for one task inside that ceiling, and it never adds an operation or field.
BReg requires the profile's compiled collections and operations to be a subset of the grant's BReg permission bounds, so a grant missing one is refused.
A grant that names more is admitted, and Record routes still use only the profile's fields and operations; the extra bounds add nothing there.
Action and Proposal routes check their own `action:` and `proposal:` bounds against the matching permission.
BReg refuses wrong-resource and partial bounds.

For a task-grant token, row-boundary claims other than `sub` resolve only from the grant's signed `identity` object; a flat token claim of the same name is ignored.
To pin a grant to its subject, author a row boundary on that subject key, in the profile and in each Action or Proposal target.
Otherwise the profile's ceiling applies to every row, as for standing agents, whatever subject the grant names.
The compiler reports a profile or target that binds no rows as `breg.access-profile.task-grant-rows-unbound`.

{/* Evidence: crates/registry-breg/tests/standing_agent_ceiling.rs module_contributed_profiles_cannot_declare_a_task_grant;
    crates/registry-breg/tests/task_grant_row_findings.rs
    scoped_task_grant_profile_without_row_boundaries_is_flagged_everywhere,
    task_grant_profile_with_row_boundaries_draws_no_finding;
    crates/registry-breg/src/task_grant/tests.rs a_scheduling_grant_is_refused_by_the_breg_binding;
    crates/registry-breg/tests/postgres_action_task_grants.rs. */}
{/* TODO[evidence]: no named test asserts that a flat token claim is ignored in favor of the signed identity object, or that a grant naming more bounds than the profile is admitted. */}

## Configure standing native agents

Standing native citizen agents use the same `actorKind: agent` and `requesterClients` binding without a `taskGrant`.
Configure the exact native actor identity for each such client under `authentication.authorityClaims`:

```yaml
authentication:
  authorityClaims:
    principal: sub
    purpose: registry_purpose
    trustedActors:
      citizen-self-service-agent: 00000000-0000-4000-8000-000000000001
```

The access token keeps the citizen in `sub`.
Its `act.sub` must equal the configured actor for the verified `azp` or `client_id`; BReg does not accept a caller-supplied actor alias.
`act` is exactly `{sub}` or exactly `{sub, iss}`, and `iss`, when present, must be a string equal to the verified token issuer.
Any other member, a different issuer, or a nested `act` refuses the token.
A token carrying a verified trusted actor is an agent token whatever its `registry_actor_kind` claim says, because a token exchange copies that claim from the subject token, so it describes the citizen, not the caller.
Such a token is admitted only by an access profile, or an immediate-action permission, that declares `actorKind: agent`; a profile that declares another kind or no `actorKind` refuses it.
A token without `act` is unaffected: a profile without `actorKind` still accepts every kind of direct token.
Custom contextual claim names, when an existing issuer needs them, are configured together in the closed `contextual` object.

A standing agent without a task grant can read, start an authorised Proposal, edit its own draft, and use `get-review-context`, when an explicit agent profile independently grants that bounded disclosure.
This is agent disclosure, not human viewing or approval.
BReg requires an exact nonempty requester-client ceiling and a verified trusted actor.
The profile independently determines readable fields, Record rows, Proposal targets, scopes, and purposes where configured.
Missing or unrestricted constraints do not become an intersection with the represented person's own BReg permissions.
This read can disclose a submitted Proposal; it grants no submitted lifecycle decision or mutation.
Approve the profile's reviewer population and disclosure ceiling before enabling it.
The agent still cannot commit immediate effects, and a separately authorised human confirms the draft.
Start, Proposal draft management, disclosure, and committed transitions remain separate grants.
`permissions.actions` and `permissions.proposals` never confer direct Record CRUD.
Modules remain subject to the same ceiling.

{/* Evidence: crates/registry-breg/src/auth.rs trusted_actors;
    crates/registry-breg/tests/standing_agent_ceiling.rs
    standing_agent_may_read_and_author_caller_owned_proposal_drafts,
    standing_agent_may_hold_only_bounded_review_context_disclosure,
    standing_agent_review_context_requires_an_exact_requester_client,
    standing_agent_cannot_hold_a_proposal_lifecycle_decision,
    standing_agent_cannot_hold_a_direct_target_mutation,
    standing_agent_cannot_batch_record_writes,
    standing_agent_cannot_hold_an_immediate_action,
    module_contributed_standing_agent_profiles_meet_the_same_ceiling. */}
{/* TODO[evidence]: no named test shows the `act` shape rules (`{sub}` or `{sub, iss}`, nested `act` refused) or that a trusted-actor token is an agent token regardless of registry_actor_kind. */}

### Statistical publication

Publishing or withdrawing a statistical release commits at once in the same way, so the compiler refuses a standing agent profile that holds `publish` on a statistical dataset, with `breg.access-profile.standing-agent-publish-forbidden`.
Both operations are authorised through the publisher's profile on the dataset's unit Record type, so that profile meets the ceiling too, including one a module contributes under the publisher's ID.
A standing agent keeps `read-live` and `read-releases`.
It cannot hold `read-exact`, which serves exact values to a named consumer.
A standing agent profile cannot be a dataset's `exactReads` profile either.
Give `publish` to a profile a person or a service uses directly.

A task grant authorises no publication either.
A task-grant profile always declares `requiredPurposes`, and a publisher's access to the dataset's Record types admits none, so the compiler refuses one that grants any of those Record types, with `breg.statistical-dataset.publisher-caller-dependent`.
One that grants none leaves a module to contribute the Record-type profiles under its ID.
A module profile carries no task grant, and the runtime refuses a task-grant token on a profile without one.

{/* Evidence: crates/registry-breg/src/compiler/statistics.rs standing-agent-publish-forbidden, publisher-caller-dependent;
    crates/registry-breg/tests/standing_agent_ceiling.rs
    standing_agent_cannot_publish_a_statistical_release,
    standing_agent_may_read_statistical_counts_and_releases,
    human_service_and_unspecified_profiles_keep_publish,
    task_grant_profile_cannot_be_a_dataset_publisher;
    crates/registry-breg/tests/compiler_statistics.rs
    a_standing_agent_cannot_read_exact_or_anchor_exact_reads. */}

## Configure current status

Configure the BReg runtime with one `taskGrantStatus` entry for each original source issuer used by its task profiles:

```yaml
taskGrantStatus:
  - sourceIssuer: https://casework.example.gov
    baseUrl: https://casework.example.gov
    tokenEndpoint: https://identity.example.gov/oauth2/token
    clientAssertionAudience: https://identity.example.gov
    clientId: breg-task-status
    privateKeyRef: secret:file/breg-task-status-private-jwk
    statusResource: urn:casework:case-management
```

Use a lowercase `https://` source identifier in each BReg task profile and copy it exactly into the matching runtime entry.
The shared runtime format also accepts other absolute issuer identifiers, such as URNs; this does not make them valid BReg profile issuers or grant authority.
A source identifier selects a configured service and is never used as an outbound URL.

`statusScope` and `statusPath` are optional.
Omitted, BReg requests the `casework:grants:status` scope and calls Casework's `/v1/task-grants/{grantId}/status` route under `baseUrl`.
Set them only for a task authority that answers under another scope or route.
`statusScope` is one scope token, and `statusPath` starts with `/` and holds exactly one whole `{grantId}` segment.

Runtime configuration parsing checks the status registry's nonsecret structure:
at most 32 entries, distinct absolute source issuers, safe service and token URLs, nonempty client and assertion audience, absolute resource identifiers, one status scope token, and a status path with one `{grantId}` segment.
Parsing does not resolve status signer or CA material or contact its endpoints; startup repeats these checks and verifies the credential material.

Register this client for client credentials with the exact Casework resource and its status scope.
Register the same client in Casework's status client mapping for this BReg resource.
BReg supplies its configured OIDC audience as that resource; neither a caller nor the grant chooses an outbound endpoint.
`clientAssertionAudience` is required: the identity provider's issuer identifier, exactly as its metadata publishes it, which the signed client assertion carries as its only audience (RFC 10070 section 4).
Stock ThunderID uses its issuer URL.
The private JWK must include its registered key identifier.
`caBundleRef` can refer to a private CA PEM bundle for both outbound connections.
Production endpoints use HTTPS; loopback HTTP is available for local development.

Startup refuses a task profile without its configured source-issuer mapping.
A failed status request refuses the mutation, and BReg caches no positive status result.
BReg compares all retained authorisation fields, including the original principal, client, resource, purpose, bounds, subjects, and deadline.

{/* Evidence: crates/registry-breg/src/task_grant/config.rs "casework:grants:status", "/v1/task-grants/{grantId}/status";
    crates/registry-breg/src/task_grant/tests.rs binding;
    crates/registry-breg/src/runtime_config.rs task_grant_status. */}
{/* TODO[evidence]: the 32-entry limit and the startup refusal for a task profile without a status mapping are not asserted by a test I could name. */}

## Approval, retries, and expiry

Submission freezes the original task authority alongside the Proposal version and its immutable effects.
A later human reviewer remains a separate actor.
Before applying a submitted Proposal, BReg checks the original grant in addition to the current executor's authority, including for automatic application and separately authorised manual Apply.
Every new application attempt makes a fresh status check.

An exact completed retry recovers the existing receipt under current disclosure authority.
It does not perform a new mutation or require a new positive status check.
BReg holds the receipt for `retention.receiptRetentionDays` after the commit (7 days by default).
Past that horizon the exact retry answers `410 idempotency.expired`, still performs no new mutation, and the caller reads the Proposal or Record to learn the outcome.
Reusing the idempotency key with a different grant conflicts.
An expired or revoked task requires an explicit new authorised submission; refreshing an access token cannot extend the original grant deadline.

Status refusal returns a failed precondition; status service failure returns unavailable.
HTTP 401 or 403 from the status endpoint means its service credential was rejected and therefore returns unavailable; it does not establish that the task grant is inactive.
A concealed or missing grant (HTTP 404) remains a failed precondition.
Human rejection and owner cancellation keep their existing permissions, and they do not require the old submitter grant to remain active.
Read cursors and representation ETags do not incorporate grant IDs.

The bounded status check uses the shared platform exact-status transport outside the mutation transaction, after preflight identifies the exact retained submission.
Its total five-second bound includes obtaining the status service credential.
The mutation transaction reloads the retained binding and checks equality and local expiry before effects, and checks expiry again before commit.
BReg keeps its own persisted binding and BReg-only bounds validation.
Deferred Casework grants use the same status contract and original deadline, without changing BReg's write or human approval permissions.
Casework revocation can still occur between that check and the local commit, because BReg and Casework do not share a distributed transaction.
Proposal-detail erasure also removes its retained task subjects, under the existing operator retention boundary.

{/* Evidence: crates/registry-breg/tests/postgres_proposal_task_authority.rs
    automatic_apply_requires_active_retained_task_authority,
    separately_authorized_manual_apply_requires_active_retained_task_authority,
    automatic_apply_rechecks_status_for_each_retry,
    automatic_apply_rechecks_retained_deadline_before_effects,
    retained_deadline_is_rechecked_after_live_status_before_effects,
    exact_retained_binding_is_rechecked_after_live_status;
    crates/registry-breg/src/task_grant/tests.rs write_idempotency_separates_grants_without_changing_read_authority;
    crates/registry-breg/src/runtime_config.rs receipt_retention_days;
    crates/registry-breg/src/problem.rs idempotency.expired. */}
{/* TODO[evidence]: the five-second total bound, the 401/403 to unavailable mapping and the 404 to failed precondition mapping are not asserted by a test I could name. */}

## Audit

Request audit records include an activation-scoped keyed `clientReference` when the bearer verifier matches an allowed OAuth client.
It uses the same pseudonym as `authorization.clientPseudonym` and distinguishes two clients acting for the same principal.
An unrestricted verifier has no matched client to record.
Client identifiers and tokens stay out of the journal.

Terminal and refusal records for a request carrying a verified task grant include an `authorization` object using the shared authorisation audit fields.
Grant, principal, client, and approver identifiers are keyed pseudonyms, scoped to the activation that serves the request.
The object also records the source issuer and grant deadline.
It contains no subjects, bounds values, or purpose value, and BReg continues to record purpose presence separately.
Later human review remains a separate actor, and the retained original grant continues to govern status checks.

A request carrying a verified trusted actor records the same `authorization` object on the same records, with `actorKind: agent` and an `actorPseudonym`.
That is the keyed pseudonym of `act.sub`, scoped to the package revision like the other identifiers.
`principalPseudonym` then names the person the agent acts for and `clientPseudonym` names the agent's client.
A standing agent carries no grant, so its object has no grant, approver, source issuer, or deadline.
The raw actor identifier never reaches the journal.
A task-grant token without `act` keeps the same `authorization` fields.

Both kinds of token also carry the object on a read's terminal record: Record reads, lists and lookups, revision reads, and history and snapshot reads.
Neither kind adds the object to a pre-I/O attempt record or to the refusal record a read or revision read writes.
A direct token records no `authorization` object anywhere.

A task-grant token is admitted to an immediate Action only when the profile's Action permission declares the same `taskGrant` with `actorKind: agent`, and the grant bounds `action:<id>` with `invoke`, under the grant's client, principal, purpose, and an unexpired deadline.
BReg refuses any other task-grant token.
A standing agent profile cannot hold an action permission, and a permission on a profile without `actorKind: agent` refuses a token carrying a trusted actor.
The refusal record carries the object.

{/* Evidence: crates/registry-breg/src/audit.rs client_reference, pseudonym;
    crates/registry-breg/tests/postgres_access_log.rs clientReference;
    crates/registry-breg/tests/postgres_action_task_grants.rs;
    crates/registry-breg/tests/standing_agent_ceiling.rs standing_agent_cannot_hold_an_immediate_action. */}
{/* TODO[evidence]: no test I could name asserts which terminal and refusal records carry the authorization object, or that a read's refusal record omits it. */}

## Next

- [Control access and reads](../../configure/breg-access/)
- [Actions and Proposals](../../configure/breg-actions/)
- [Citizen chat assistant](../../configure/breg-mcp/)
- [Base Registry Engine configuration reference](../breg-configuration/)