Add an append-only ledger of entitlement set rule changes with per-pool effect rows, a preview-and-commit rule change flow, and an automatic drain that settles deferred recomputations. Rules gain a tier reduction policy, resource keys declare over-limit behavior, and the materializer now lowers limits when a rule stops applying. Add entitlement set rule change ledger and preview flow Add an append-only ledger of entitlement set rule changes with a preview-and-commit operator flow. Rule writes now go through an enclosed `core.commit_rule_change` function that files an act row and one obligation per carrying pool, with a drain workflow settling deferred recomputations. The preview dry-runs the materializer with a rule overlay and renders per-pool buckets, reduction-policy disclosures, and provider over-limit consequences. Materializing transactions take a shared advisory rendezvous that rule changes hold exclusively, enforced by a possession assertion. Add History and Entitlement changes surfaces, a rule-less warning on five product-selection surfaces, and a `tier_reduction_policy` column that gates FedWiki parking.
41 lines
1.7 KiB
SQL
41 lines
1.7 KiB
SQL
-- name: UpsertProvider :one
|
|
-- Boot-time capability registration. On re-registration, capability fields
|
|
-- (kind, display_name) are refreshed; operational `status` is preserved.
|
|
INSERT INTO core.providers (provider, provider_kind, display_name, operator_surface_path)
|
|
VALUES ($1, $2, $3, $4)
|
|
ON CONFLICT (provider) DO UPDATE
|
|
SET provider_kind = EXCLUDED.provider_kind,
|
|
display_name = EXCLUDED.display_name,
|
|
operator_surface_path = EXCLUDED.operator_surface_path,
|
|
updated_at = NOW()
|
|
RETURNING *;
|
|
|
|
-- name: GetProvider :one
|
|
SELECT * FROM core.providers WHERE provider = $1;
|
|
|
|
-- name: ListProviders :many
|
|
SELECT * FROM core.providers ORDER BY provider;
|
|
|
|
-- name: ListProvidersByKind :many
|
|
SELECT * FROM core.providers WHERE provider_kind = $1 ORDER BY provider;
|
|
|
|
-- name: SetProviderStatus :exec
|
|
-- Operational mutation (operator-editable), distinct from capability registration.
|
|
UPDATE core.providers SET status = $2, updated_at = NOW() WHERE provider = $1;
|
|
|
|
-- name: ListPlatformResourceKeys :many
|
|
-- Platform-owned (unprefixed) resource keys, for the provider-key hygiene
|
|
-- nesting check.
|
|
SELECT resource_key FROM core.resource_keys WHERE provider IS NULL ORDER BY resource_key;
|
|
|
|
-- name: SetResourceKeyProvider :execrows
|
|
-- Stamp provider ownership on a resource key (cross-schema write, enabled by the
|
|
-- resource_keys.provider FK + this package's core_writer grant on the core
|
|
-- schema). Returns rows affected so a manifest referencing a non-existent key
|
|
-- can be detected at registration.
|
|
UPDATE core.resource_keys
|
|
SET provider = $2,
|
|
over_limit_behavior = sqlc.arg(over_limit_behavior),
|
|
over_limit_consequence = sqlc.arg(over_limit_consequence)
|
|
WHERE resource_key = $1;
|