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.
16 lines
643 B
SQL
16 lines
643 B
SQL
-- name: CreateNumericEntitlementContribution :one
|
|
INSERT INTO core.numeric_entitlement_contributions (entitlement_id, provision_id, contributed_value, stacking_policy)
|
|
VALUES ($1, $2, $3, $4)
|
|
RETURNING *;
|
|
|
|
-- name: DeleteContributionsByProvisionID :exec
|
|
-- Scoped to one entitlement: a provision that funds several resource keys
|
|
-- keeps its rows on the keys the caller is not rebuilding.
|
|
DELETE FROM core.numeric_entitlement_contributions
|
|
WHERE entitlement_id = $1 AND provision_id = $2;
|
|
|
|
-- name: ListContributionsByEntitlementID :many
|
|
SELECT * FROM core.numeric_entitlement_contributions
|
|
WHERE entitlement_id = $1
|
|
ORDER BY created_at ASC;
|