# Enterprise license activation

**Last updated:** 2026-11-12T17:21:09-03:00 (UTC-3)

A definitive enterprise license is a vendor-signed, canonical payload and Ed25519 signature verified locally. Verification makes no network call. The vendor compiles its public-key catalog before building; the default catalog is empty. Private signing keys stay outside the repository, runtime configuration, images and provider credential files.

Enable `enterprise_license` at boot and provide `license.key` or `license.key_env` in YAML. An absent license supplies no enterprise availability. A valid license supplies availability without enabling operational flags, assigning roles, granting route access or weakening budgets. Commercial free/enterprise allocation and plan ceilings are a separate contract; activation metadata alone does not implement them.

With `license_management`, UI, PostgreSQL and the existing control encryption key configured, a global administrator can activate a key in Settings or use the versioned `/api/v1/admin/license` API. Mutations require the current configuration version, administrative session and CSRF token. Keys are encrypted with a distinct authentication domain before persistence; GET returns status and a fingerprint, never the token. A DELETE removes the override and restores YAML. Invalid or future activation requests, and expired definitive keys, fail before configuration changes. Re-presenting a terminal trial follows the retained-state behavior described below.

A signed YAML or existing key can become expired without stopping existing authorized traffic. There is no paid-license grace period. Authentication, authorization and quota failures still deny requests. The separately enabled fourteen-day trial uses the same verifier plus a durable PostgreSQL activation ledger, as described below. Offline signatures cannot prevent an administrator from modifying the binary or manipulating the host clock; no such guarantee is made.

## Configuration defaults

| Parameter | Default | Behavior |
|---|---|---|
| `features.enterprise_license` | `false` | Boot opt-in; changing it requires a restart |
| `features.enterprise_trial` | `false` | Boot opt-in for durable fourteen-day activation; requires parent and PostgreSQL |
| `features.license_management` | `false` | Enables the versioned writer for a global administrator; requires parent/UI/PostgreSQL/control encryption |
| `license.key` | empty | Explicit signed YAML activation; mutually exclusive with `key_env` |
| `license.key_env` | empty | Environment reference for the signed activation, never an added trust key |

Authorized configuration readers see safe status without activation inputs when management is unavailable. Enabling a flag supplies no administrative permission. The vendor trust catalog starts empty, so production activation requires a vendor public-key build; private signing keys never belong in that catalog.

Use the offline vendor tool with explicit outside-repository files:

```sh
go run ./cmd/license keygen -kid vendor-2026 -private-key /secure/vendor.key -public-key /secure/public-keys.json
go run ./cmd/license issue -kid vendor-2026 -license-id customer-001 -private-key /secure/vendor.key -out /secure/customer.license
```

Outputs are created with mode0600 and never overwrite files. Copy only the public catalog to `internal/license/trust-keys.json` before building. For rotation, overlap old and new public keys until customers have replacement licenses, then build and roll out a catalog without the retired key. Offline verification has no remote revocation service.

## Fourteen-day trial

A vendor issues `kind: trial` using the same protected signing tool. Its signed token has a `temp-` prefix; adding or removing the prefix invalidates the kind/signature contract. A trial has no editable duration or absolute expiry claim: its product policy is exactly 1,209,600 seconds from first successful durable activation. `not_before` can constrain earliest activation. A definitive key keeps its unprefixed format.

```sh
go run ./cmd/license issue -kind trial -kid vendor-2026 -license-id trial-customer-001 \
  -private-key /secure/vendor.key -out /secure/customer-trial.license
```

Enable `features.enterprise_license` and `features.enterprise_trial` at boot. The trial flag defaults to `false`, requires PostgreSQL and initializes storage even without console management. Use the existing private YAML `license.key`/`key_env`, or the same versioned activation API and console. API activation additionally requires `license_management`, its existing UI/encryption prerequisites, session/CSRF and administrator permission. The operational flags themselves do not turn on because a trial was activated.

The first successful activation inserts one ledger row keyed by the signed license ID. Trial-writing transactions force local `synchronous_commit=on`, even when the connection default is off; PostgreSQL server/storage durability remains an operator responsibility. Managed activation, encrypted override, optimistic version and audit commit together. A stale version or late transaction failure cannot consume a new trial. YAML activation occurs during the initial control refresh before serving. Signature verification alone reports `activation_required` and grants no availability.

Replaying a token, restoring YAML, restarting the process or switching to a definitive key and back reuses the original activation/expiry. The trial row is never removed by the activation API. Re-signing different claims under the same trial ID is rejected; a vendor that intentionally issues another trial must use a new ID. Re-presenting an already activated terminal trial may save its override but does not restore availability or extend the period. Definitive expired activation requests remain invalid.

### Clock, expiry and restore boundary

PostgreSQL supplies the shared activation/observation clock. Row locking serializes replicas; time is sampled again after the lock so waiting behind another replica is not mistaken for a rollback. Refresh observes trial state even when configuration version did not change. First activation and terminal expiry/rollback transitions are audited atomically, with the request ID when observed by an HTTP request and a system actor for background work.

An observation at or after expiry persists `expired`. An observed database clock earlier than its durable high-water persists `clock_rollback`. Both states are terminal for that token. Correcting the clock, replaying the token or restarting cannot revive the row. Protected configuration changes recheck current durable state; a database failure denies those changes. Existing inference does not gain a licensing database lookup or lose its authentication, quota and authorization checks.

The backwards-clock rule deliberately favors safe denial: a real database clock correction can end a trial early. Diagnose time synchronization and install a definitive license; no hidden grace period or automatic ledger reset is provided. There is no paid-license grace period either.

An offline process cannot detect every action by an administrator who controls the binary, database, clock and backups. Moving the signed token to a fresh database or restoring the entire database to an earlier state can discard its history; preventing that requires an external authority or protected monotonic hardware, neither claimed here. Keep trial state in normal database backups and restore it together with configuration/audit. Local validation does not certify managed hosting or resistance to a hostile platform owner.

## Enterprise classification at build time

`internal/config/edition/enterprise.json` is a separate vendor build input. Its default is `{"version":1,"features":{}}`: **no free/enterprise cutoff has been chosen**. This catalog does not enable flags, grant identity or alter team plans. It is distinct from `edition/defaults.json`, which selects operational defaults, and from the public signing-key catalog.

Each selected feature names the existing administrative mutation permissions that belong to its commercial package. The vendor must use known feature IDs and actual registered mutation actions; malformed, duplicate or unknown actions are rejected. One action may cover several routes, so review that scope before classifying it. Example of a deliberately classified test edition:

```json
{"version":1,"features":{"prompt_management":["prompts:manage"]}}
```

With such classification, an absent/disabled/expired license or terminal trial makes those administrative actions read-only. Reads stay available under existing permissions. License replacement/reversion, emergency stop and explicit identity revocation/deletion remain available for recovery; creating a new identity is not a revocation exception. A disabled licensing flag cannot bypass a compiled classification. The shipped empty catalog changes no current feature's commercial availability.

This is a control-plane mutation boundary. It neither edits YAML files outside the process nor turns an ordinary runtime setting into vendor licensing authority. Inference continues with its existing captured configuration and controls; complete per-feature plan/organization ceilings remain their separate delivery task.

## Safe status and operations

The existing `/api/v1/admin/license` GET/PUT/DELETE and configuration summary expose safe additive trial fields: `kind: trial`, `activated_at`, effective `expires_at`, and `configuration_read_only` on a terminal trial. `valid` means availability; `activation_required`, `expired` and `clock_rollback` do not. Old definitive status fields retain their format. The console shows the trial period and terminal explanation while preserving renewal/reversion controls. No response returns the signed token.

Migration102 adds `gateway_license_trials` without rewriting earlier history. Back up before upgrade and roll out compatible binaries to every replica before enabling trials. Older binaries refuse newer migration history; no automatic schema downgrade or cross-engine migration is provided. Keep the vendor public trust catalog available for every build; never add private signing keys or customer tokens to images/source/evidence.

The existing flag catalog/API/console shows `enterprise_trial` as a boot option; changing it requires rollout. No new HTTP path, hosted licensing service, paid provider call or production rollout is introduced.

## Classified feature and plan activation

The empty-by-default vendor catalog also classifies new plan grants and operational activation. Its feature IDs do not grant a tenant role; operator and tenant applicability are explicit in the [plan catalog](/docs/features/entitlements/#feature-applicability).

New classified plan rights, assignments, broadening reverts and removal of organization ceilings require available activation at the locked transaction boundary. A shared control-version guard serializes against managed license changes; terminal trial state is locked too. Free/restrictive actions are not blocked by this new-grant check; the existing classified administrative permission policy still applies.

Migration104 stores approved effective YAML plan bases and active classified flag IDs. Unchanged approved activation survives license expiry/restart; new activation is checked first. Dormant YAML plans stay dormant while plan enforcement is off. Feature activation, YAML approval, version and request-correlated audit commit together, so a refusal cannot leave an unusable override that prevents renewal. A nonempty classified edition needs PostgreSQL approval storage even when classified flags are off; the shipped empty classification changes no default behavior. This is offline verification with durable local state, not a network licensing dependency or protection against an operator restoring the entire database/binary.

The license never becomes a per-request availability dependency for established inference. Plan revocation and ordinary scopes, ownership, quotas and security checks still take effect. [Operational profile and recovery](/docs/features/entitlements/#license-and-activation).

## Field-scoped provider pool configuration

The optional provider pool/cooldown classifications use their feature IDs inside the whole-provider transaction, rather than classifying every scalar provider through a shared permission. Parent availability bounds any pool mutation; child additionally protects effective custom cooldown/status changes and new/enabled entries while cooldown is active. Equivalent duration spelling, status ordering or unchanged child settings do not block free weight/secret/primary edits. Other existing classifications, including `provider_management`, keep their broad permission policy. PUT and delete/revert use the existing version/trial lock order and readonly/recovery rules; established inference never depends on license availability. The console receives only two additional write-capability booleans, not a new licensing authority or a chosen commercial cutoff. See [provider pools](/docs/features/provider-credentials/).
