Files
T
cgalo5758 3727ff31d8 Add entitlement set rule change ledger and preview flow
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.
2026-09-15 03:53:28 -05:00

125 lines
5.5 KiB
YAML

version: "2"
sql:
- engine: "postgresql"
schema:
- "../db/migrations/"
- "../db/sqlc_schemas.sql"
queries: "queries/"
gen:
go:
package: "entitlements"
out: "."
sql_package: "database/sql"
emit_json_tags: true
emit_prepared_queries: false
emit_interface: true
emit_exact_table_names: false
emit_empty_slices: true
omit_unused_structs: true
rename:
# Identity
core_person: Person
core_persons: Person
core_user: User
core_users: User
# Organization
core_organization: Organization
core_organizations: Organization
core_workspace: Workspace
core_workspaces: Workspace
core_role: Role
core_roles: Role
core_role_assignment: RoleAssignment
core_role_assignments: RoleAssignment
core_org_member: OrgMember
core_org_members: OrgMember
# org_types was never explicitly renamed pre-consolidation (old
# schema "organization"); preserve its old default-computed name
# verbatim now that the schema prefix is "core" instead.
core_org_type: OrganizationOrgType
core_org_types: OrganizationOrgType
# Billing
core_account: Account
core_accounts: Account
core_price: Price
core_prices: Price
core_product: Product
core_products: Product
core_subscription: Subscription
core_subscriptions: Subscription
core_subscription_item: SubscriptionItem
core_subscription_items: SubscriptionItem
core_subscription_change: SubscriptionChange
core_subscription_changes: SubscriptionChange
core_plan_ladder: PlanLadder
core_plan_ladders: PlanLadder
core_plan_ladder_tier: PlanLadderTier
core_plan_ladder_tiers: PlanLadderTier
# invoices/payments/payment_methods/product_kinds were never
# explicitly renamed pre-consolidation (old schema "billing");
# preserve their old default-computed Billing*-prefixed names
# verbatim.
core_invoice: BillingInvoice
core_invoices: BillingInvoice
core_invoice_line_item: BillingInvoiceLineItem
core_invoice_line_items: BillingInvoiceLineItem
core_payment: BillingPayment
core_payments: BillingPayment
core_payment_method: BillingPaymentMethod
core_payment_methods: BillingPaymentMethod
core_product_kind: BillingProductKind
core_product_kinds: BillingProductKind
# Entitlements (own domain)
core_pool_provision_ladder: PoolProvisionLadder
core_pool_provision_ladders: PoolProvisionLadder
core_pool_provision_transition: PoolProvisionTransition
core_pool_provision_transitions: PoolProvisionTransition
core_grant: Grant
core_grants: Grant
core_resource_pool: ResourcePool
core_resource_pools: ResourcePool
core_resource_key: ResourceKey
core_resource_keys: ResourceKey
core_pool_assignment: PoolAssignment
core_pool_assignments: PoolAssignment
core_pool_provision: PoolProvision
core_pool_provisions: PoolProvision
core_entitlement_set: EntitlementSet
core_entitlement_sets: EntitlementSet
core_entitlement_set_rule: EntitlementSetRule
core_entitlement_set_rules: EntitlementSetRule
core_numeric_entitlement: NumericEntitlement
core_numeric_entitlements: NumericEntitlement
core_numeric_entitlement_contribution: NumericEntitlementContribution
core_numeric_entitlement_contributions: NumericEntitlementContribution
core_numeric_entitlement_usage: NumericEntitlementUsage
core_boolean_entitlement: BooleanEntitlement
core_boolean_entitlements: BooleanEntitlement
core_numeric_entitlement_usages: NumericEntitlementUsage
core_entitlement_set_change: EntitlementSetChange
core_entitlement_set_changes: EntitlementSetChange
core_entitlement_set_change_obligation: EntitlementSetChangeObligation
core_entitlement_set_change_obligations: EntitlementSetChangeObligation
core_entitlement_set_change_effect: EntitlementSetChangeEffect
core_entitlement_set_change_effects: EntitlementSetChangeEffect
core_subscription_scheduled_change: BillingSubscriptionScheduledChange
core_subscription_scheduled_changes: BillingSubscriptionScheduledChange
# Spillover tables pulled in because ../db/migrations/ declares the
# whole "core" schema (integration's domain; entitlements did not
# pull these in pre-consolidation). Renamed to match the exact
# pre-consolidation type names -- see internal/integration/sqlc.yaml
# for the canonical mapping this list is drawn from.
core_provider: Provider
core_providers: Provider
core_provider_operation: ProviderOperation
core_provider_operations: ProviderOperation
core_provider_state: IntegrationProviderState
core_provider_states: IntegrationProviderState
core_outbox: IntegrationOutbox
core_outboxes: IntegrationOutbox
core_webhook_event: IntegrationWebhookEvent
core_webhook_events: IntegrationWebhookEvent
overrides:
- db_type: "uuid"
go_type: "string"