Skip to content

Operations Ledger

Norn records long-running and externally triggered work in a durable PostgreSQL operations ledger. The ledger is separate from saga events: saga events are the detailed timeline, while operations are the compact status index used for drain checks, dashboards, metrics, and CLI summaries.

Surfaces

bash
norn operations
norn operations --active
norn operations <operation-id>
norn events
norn events show <event-id>
norn events ack <event-id>
norn alerts
norn smoke platform
norn platform smoke
norn webhooks
norn webhooks replay <delivery-id>
norn webhooks replay <delivery-id> --preflight
norn ops platform
norn observability bundle
norn observability install
norn secrets migrate-plan
norn network

API endpoints:

MethodPathPurpose
GET/api/operationsRecent operations, filterable by app, kind, status, and active state
GET/api/operations/activeQueued/running operations for drain gates
GET/api/v1/operations/{id}Authoritative status and receipt for one durable operation
GET/api/v1/capabilitiesProtocol version, supported features, endpoints, and token scopes
POST/api/v1/platform/preflightsQueue a candidate platform build and health check
POST/api/v1/platform/upgradesQueue a restart-safe platform upgrade
POST/api/v1/platform/smokeQueue authenticated platform smoke
POST/api/v1/host/assurancesQueue host assurance
GET, POST/api/v1/apps/{id}/snapshotsList snapshots or queue a manual snapshot
POST/api/v1/apps/{id}/snapshots/retentionQueue reviewed newest-N pruning
POST/api/v1/apps/{id}/snapshots/{snapshot}/restoreQueue an exact inventory-filename restore with mandatory safety snapshot; unique legacy timestamps remain compatible
POST/api/v1/apps/{id}/migrationsQueue the declared schema migration independently of deploy
POST/api/v1/apps/{id}/rollbacksQueue rollback to the previous successful deployment
WS/api/v1/events?after=<cursor>Authenticated durable control events with cursor replay
GET/api/deployments/{id}/stepsDurable deploy or rollback stage checkpoints
GET/api/eventsRecent Beacon events, filterable by app, type, and severity
GET/api/events/{id}Beacon event detail with operator state and metadata
POST/api/events/{id}/ackAcknowledge a Beacon event
POST/api/events/{id}/snoozeSnooze a Beacon event until a duration or timestamp
POST/api/events/{id}/openReopen a Beacon event
GET/api/alerts/rulesBuilt-in alert rule catalogue derived from Beacon event types
GET/api/observability/bundlePrometheus, alert, Grafana, and service bundle
GET/api/observability/alerts.ymlPrometheus alert rules from the observability bundle
POST/api/observability/services/installInstall generated observability app directories
GET/api/access/patternsHosted-service access pattern rollups and idle candidate hints
POST/api/access/observationsRecord aggregate hosted-service access observations
GET/api/tuning/recommendationsAdvisory resource tuning recommendations from live signals
GET/api/secrets/migration-planValue-safe plaintext secret migration plan
GET/api/webhooks/deliveriesRecent webhook delivery inbox
POST/api/webhooks/deliveries/{id}/replayReplay a delivery as a deploy or preflight
GET/metricsPrometheus counters for operations and webhooks

Recorded Operations

The current release records these operation kinds:

KindSourceRisk
app.preflightnorn preflight / API preflightread-only
app.deploynorn deploy, webhook auto-deploy, API deployapp rolling update
app.rollbacknorn rollback / API rollbackapp rolling update
app.snapshotweb, macOS, or versioned control APIdatabase snapshot
app.snapshot-pruneweb, macOS, or versioned control APIdestructive snapshot retention
app.snapshot-restoreweb, macOS, or versioned control APIdestructive restore with safety snapshot
app.migrateweb, macOS, or versioned control APIschema mutation with pre-migration snapshot
platform.preflightversioned control API / platform queue-preflightread-only candidate build
platform.upgradeversioned control API / platform queue-upgradecontrol-plane replacement
platform.rollbackversioned control API / platform queue-rollbackcontrol-plane replacement
platform.smokeversioned control API / platform queue-smokeread-only platform assurance
host.assureversioned control API / host queue-assurebounded host repair and endpoint probes

App preflights, deploys, rollbacks, snapshots, pruning, restores, and standalone migrations are queued in the operations table and claimed by the API worker with FOR UPDATE SKIP LOCKED. A PostgreSQL advisory lock serializes all work for one app across API replicas. Queue rows include payload, attempt count, max attempts, lease owner, lease expiry, next attempt, and last error.

Configure at least four PostgreSQL pool connections per Norn API replica. The API validates this at startup because one worker may simultaneously hold its app advisory lock, execute pipeline SQL, renew its lease, and serve control/recovery traffic.

Platform and host operations are claimed by norn-host-agent, an independent process installed as com.norn.host-agent. The API process never executes arbitrary shell input: the agent maps the five known operation kinds to fixed script subcommands, validates refs and modes again, renews its lease, and stores a bounded output receipt. Because the agent is not the API process, it remains alive while an upgrade restarts Norn.

Deploy and rollback stages are written to deployment_steps. Read-only preflights can retry safely. App deploys are queued and visible to drain gates; after an API restart, a running deploy can be requeued only if no mutable stage checkpoint has started. If interruption happens during or after snapshot, migration, submit, health, forge, or cleanup, the operation fails visibly for manual review rather than replaying side effects blindly.

Operators can inspect checkpoint evidence with:

bash
norn deploy steps <deployment-id>

This is the supported pre-resume surface. Automatic mutable-stage resume remains intentionally disabled until each mutable stage records enough receipt data for safe operator confirmation.

Event Operations

Beacon events now carry operator state:

StateMeaning
openEvent is active or a previous snooze has expired
snoozedEvent is hidden from immediate attention until snoozedUntil
acknowledgedAn operator has accepted/handled the event

Acknowledgement and snooze metadata is stored beside the immutable event payload. The Platform tab and norn events expose the same state. Related saga, deployment, operation, service, process, and cron ids are carried through event metadata when available.

Webhook Inbox

Webhook deliveries are recorded before validation decisions. The inbox captures provider, event type, delivery id, repository, ref, matched app, saga id, final status, and ignored/failed reason. This makes webhook auto-deploy behavior inspectable without scraping API logs.

Delivery statuses include:

StatusMeaning
receivedDelivery row was created
ignoredValid delivery, but Norn intentionally ignored it
failedValidation, parsing, or discovery failed
deployingDelivery matched an app and queued an app deploy
replayedOperator replayed the delivery as a deploy or preflight

Replay uses the normal authenticated API path:

bash
norn webhooks replay <delivery-id>
norn webhooks replay <delivery-id> --preflight

Platform Drains

Direct norn platform upgrade and rollback commands still call the local platform script. The preferred remote/operator path is norn platform queue-upgrade, which creates a durable operation and waits for the independent host agent. The script excludes that operation's own ID from the drain query, so it still blocks on unrelated app or maintenance work without deadlocking on itself.

norn platform upgrade --proxy uses the same drain gate before switching the managed reverse-proxy upstream on hosts that are intentionally proxy-fronted.

Set NORN_DRAIN_MODE to choose behavior:

ModeBehavior
failDefault. Refuse to upgrade while operations are active
waitPoll until active operations finish
forceSkip the drain check

If the current API is too old to expose the operations endpoint, or auth is unavailable, the script logs a warning and continues. This keeps bootstrap upgrades possible.

Metrics

The metrics endpoint exports:

MetricMeaning
norn_operations_totalOperation count by kind and status
norn_operation_duration_seconds_countCompleted operation duration sample count
norn_operation_duration_seconds_sumTotal completed operation duration
norn_operation_last_started_timestamp_secondsLast operation start time
norn_webhook_deliveries_totalWebhook delivery count by provider and status
norn_webhook_last_received_timestamp_secondsLast webhook delivery time
norn_service_statusLive service status by app/process/service/status
norn_snapshot_over_limit_totalSnapshot retention pressure
norn_beacon_events_totalBeacon events by type and severity
norn_beacon_last_occurred_timestamp_secondsLast Beacon event time by type and severity
norn_host_disk_free_bytesHost disk free space visible to the API process

Platform Rollup

norn ops platform includes assurance fields alongside the existing service, deployment, access, and release summaries:

FieldMeaning
secrets.migrationItemsCount of plaintext secret-like env keys that have a migration plan action
observability.bundleAvailableWhether the API can generate the local observability bundle
observability.retentionRecommended local Prometheus retention target

Next Step

Add deeper stage-level resume data for mutable app stages before enabling automatic retries after snapshot, migration, submit, or route changes.