# Delegate prompt authoring and publication

**Last updated:** 2026-11-13T15:28:28-03:00 (UTC-3)

Give an existing team's named members explicit rights to author drafts, publish reviewed revisions or revert/delete prompts. Delegation does not create users, add team membership, change ownership or authorize inference. An optional custom role can narrow the delegated rights; it cannot supply a missing grant.

## Enable the boundary

The three new flags default to false:

| Flag | Purpose |
| --- | --- |
| `prompt_scoped_write` | Parent boundary for explicitly delegated scoped mutations |
| `prompt_scoped_publish` | Additional switch for publication and publication-affecting withdrawal |
| `prompt_delegation_management` | Global-administrator policy management and staging |

The existing `prompt_registry`, `prompt_management`, `prompt_scoped_read` and named-user/granular/team-console foundations remain required. Publication requires the parent operational switch even for a publisher who has no authoring right. Management may stage policy while scoped mutation is off. No flag supplies a role or team permission.

```yaml
prompt_delegations:
  - team: existing-generated-team-id
    actions: [prompts:write]
```

Replace the example team ID with a real active team's generated ID. Omission is the empty list; empty actions grant nothing. At most 500 distinct teams and three unique known actions per row are supported. Unknown actions, duplicate rows/actions, malformed types and invalid references are refused. Selecting an endpoint does not provision a team or transfer ownership.

| Field | Default and supported bounds |
| --- | --- |
| `prompt_delegations` | Empty list; at most 500 distinct team rows, bounded to 256 KiB JSON |
| `team` | Required existing generated ID, 2–64 lowercase ASCII characters matching `[a-z][a-z0-9_-]{1,63}` |
| `actions` | Required array; empty grants nothing; at most 3 unique known actions, no wildcard or arbitrary route |

## Separate the actions

| Action | What it permits |
| --- | --- |
| `prompts:write` | Create an active owned draft or append a draft; leaves the existing publication unchanged |
| `prompts:publish` | Select an existing owned revision, numbered 1 or higher |
| `prompts:delete` | Explicit owned revert/delete; withdrawal of a publication additionally requires publish authority |

An author cannot disable, resurrect or unpublish a template, reconcile operator YAML drift or turn a draft save into a deployment. Even an author who also has publication rights must use the separate publish operation. A publisher cannot edit content or create revision 0 implicitly. Deleted IDs retain history and ownership.

Supported scoped writer identities are existing user and team_admin named users in the active owner team. Every writer, including a team administrator, needs the explicit team grant. Team viewers and global viewers/operators do not inherit a writer. Organization membership alone grants none. Global administrator workflows remain available for recovery and deliberate operator changes.

When feature plans are active, team and applicable organization ceilings also need the relevant mutation/publication rights. Typed prompts retain the separate `prompt_json_schema` profile flag/right. A grant never bypasses a license, model policy or existing identity restriction.

## Console workflow

In **Prompt registry**, global administrators use **Prompt authoring delegations**. Choose **Add prompt team delegation**, enter the actual **Owner team ID** and select the individual action checkboxes; **Save prompt delegations** replaces the complete override. The declared and effective rows are shown separately. **Revert prompt delegations** removes the override; **Adopt reviewed prompt YAML** reviews and admits a changed base. These are separate, confirmed operations.

Scoped authors choose only currently admitted owner-team IDs. Saving a draft, publishing a reviewed revision and deleting/reverting remain separate controls. Each entry returns optional `actions: {write, publish, delete}`; absent or malformed capability metadata is read only. Safe `prompt_author_teams` IDs do not grant a team inventory or content read. The console uses explicitly authorized prompt reads for content editing/history; action rights never silently grant content or inventory reads. Current per-owner permissions must enable each operation separately. Losing a right discards stale editing authority; a late response cannot restore it.

## YAML and overrides

The admitted declared policy is shared through an adopted base. Administrative changes require current version and base-fingerprint assertions, are audited and show their source. A console override, removing an override and adopting a reviewed YAML change are distinct operations. Drift or damaged authority denies scoped mutations until repaired; it never falls back to a more permissive policy.

The first admitted base is persisted. After changing YAML, review the declared/effective policy and current fingerprints before adoption. A mismatch denies scoped writes. If a proposed base cannot be adopted because its references are invalid, restore the last valid base, repair the affected references under ordinary administration, and then reapply/adopt the reviewed change. There is no force-adoption bypass.

## Administrative API

| Endpoint | Operation |
| --- | --- |
| `GET /api/v1/admin/prompt-delegations` | Inspect declared/effective/override rows, source, current version/base, action catalog, limits, flags and separate write/publication/adoption capabilities |
| `PUT /api/v1/admin/prompt-delegations` | Replace the complete override |
| `DELETE /api/v1/admin/prompt-delegations` | Remove the override and restore the admitted declared policy |
| `POST /api/v1/admin/prompt-delegations/adopt-base` | Admit the reviewed declared base |

Every writer supplies current `version` and `expected_base_fingerprint` from GET. PUT additionally supplies `prompt_delegations`, the complete array of `{team, actions}` rows. Successful writers return 204; fetch a fresh catalog before another mutation. Never reuse an old global version after a publication or another configuration change. **API access** provides runnable session/CSRF and curl examples that obtain live guards; the contract is in [OpenAPI](/docs/api/).

Malformed/unknown fields are 400, unauthorized callers 401/403, disabled writers or missing overrides 404, stale versions/base or unsafe publication transitions 409, invalid references 422 and storage/synchronization failures 503. A synchronization error after commit explicitly reports that the change was stored: reload before retrying. No response includes a credential or prompt content in this policy catalog.

The catalog's `access.write` controls management/parent authoring; `access.publish` additionally controls editing publication grants. A publication grant that is read only cannot be toggled, moved to another team or removed through the console. Unchanged publication grants can be preserved during a permitted author-only edit. `access.adopt` is computed against the actual stored transition, including a base hidden by an override; the browser does not guess those rights from visible rows. Every mutation is revalidated server-side.

## Protected operator bindings and concurrency

**Deployment prerequisite:** replicas sharing this control/delegation database use the same boot `models` YAML and operator system-prompt bindings. Stop delegated mutations while rolling out a changed model base, finish the rollout on every replica, then resume them. Managed model changes use the shared transaction/version fence below. That fence does not attest another replica's different boot YAML; heterogeneous per-replica model catalogs are outside this validated profile.

Draft-only append can coexist with a pinned operator system prompt because it leaves the publication unchanged. Scoped publication/revert/delete cannot invalidate an effective operator `system_prompt` reference, including a staged or disabled alias. Exact pinned revisions are never silently retargeted. Global administrators retain deliberate recovery/configuration workflows.

Role, custom ceiling, membership, delegation, owner activity, plan and license are checked with current SQL authority under mutation locks. A writer waiting behind a revocation cannot commit an old grant. Foreign prompt identifiers remain404 before version/fingerprint diagnostics; ordinary same-owner conflicts are409 and require review/reload.

Scoped availability changes also atomically advance the shared configuration version. A model writer admitted against the older publication receives its existing version conflict after waiting, rather than installing an obsolete pin. An unchanged-revision republish does not create that transition. Audit records contain action, actor, requestID and version, never prompt text, variables or rendered content.

## Scope and upgrade

No new preview permission, provider execution, external registry synchronization or automatic injection is implied. Existing published-prompt bearer and local-render contracts remain unchanged. Migration 127 stores the initialized adopted policy and optional override. Back up PostgreSQL and use the existing [migration procedure](/docs/operate/operations/). Upgrade all replicas before enabling the new flags or creating custom-role prompt actions; old binaries do not implement this authority profile. The schema migration itself creates no delegated writer. Roll back through the documented backup/configuration procedure, not a mixed-version claim based on a successful YAML parse.

See [prompt registry](/docs/features/prompt-registry/) for template/revision semantics, [custom permission ceilings](/docs/features/custom-roles/) for the additional named-user restriction, and [enforced system prompts](/docs/features/enforced-system-prompt/) for the operator policy boundary.
