Commit Graph
36 Commits
Author SHA1 Message Date
cgalo5758 257955c9d3 Add operator list-scale contract and People directory
Governed operator lists (organizations, grants, people, billing×4) gain
server-side search, status filters, and 50-row pages with true totals
from count(*) OVER(); state is URL-addressable, out-of-range pages
clamp,
and no-match is distinct from true-empty.

People is the eighth flat sidebar entry: /operator/persons lists persons
newest-joined first (excluding the reserved system person), rows linking
to the existing detail.

Billing gains an operator invoice detail at
/operator/billing/invoices/{invoiceID} reusing the member projection;
open invoices past due present as Overdue (derived, filterable, stored
status untouched); all four views lead with the linked organization and
mute object IDs.

Grants filter over the derived Live/Superseded/Inactive state, the SQL
HAVING predicate pinned to the Go derivation by test. Embedded lists
(org composite ledger, Tier changes) adopt the shared controls under
namespaced params with sibling-state-preserving URLs and scoped htmx
swaps that hold the viewport.

Review corrections: blocked ladder Delete renders disabled with tooltip
and mutations fire toasts; collapse triggers paint their open state;
sections use outside headings; plan topology drops the orphan-product
check; domains policy collapses behind a disclosure.
2026-08-24 03:58:18 -05:00
cgalo5758 9b96e9c9e9 Rework operator IA and unify UI vocabulary
- Restructure operator sidebar into a flat task list with indented
  children; fold plan topology into plan ladders
- Expand member catalog non-plan section to all published non-tier
  products; require recurring Stripe-mapped prices for purchase
- Add operator domains placements and terminal-claims ledger; redirect
  /domains to the FedWiki Sites Domains anchor
- Apply canonical vocabulary and chrome/form conventions; migrate seeded
  FedWiki Sites display name
2026-08-23 17:12:42 -05:00
cgalo5758 71818de0bd Add setup checklist and empty-state guidance
Implement the ux-first-run change: a state-derived setup checklist on
/operator/setup with a landing region that recedes once required steps
are done, and empty states that distinguish blocked from empty across
operator and member surfaces. Also add production deployment and
environment reference docs, plus a config-key completeness test.
2026-08-23 03:06:11 -05:00
cgalo5758 efe3f1528d Restrict member surfaces to published products
Add lifecycle_status = 'published' to the public-catalog queries
(plans and add-ons listings) and reject checkout before any Stripe
call unless the product behind the price clears the shared member
gate (published + active + public). The currently-enrolled ladder
rung stays renderable even if its product is later drafted or
retired, fetched directly so members keep seeing what they are on.

Introduce a single evaluateMemberGate definition shared by the
catalog paths and the operator readiness panel so the surfaces
cannot disagree about what is publishable for members.
2026-08-22 12:58:05 -05:00
cgalo5758 ce3668d59e Refine operator overview metrics and styling
Replace domain claims with open invoices, show monthly recurring
revenue,
count team organizations, and add more informative trend captions.

Use standard bordered cards and add a README screenshot with reversible
sample-data tooling.
2026-07-27 02:44:55 -05:00
cgalo5758 56a743fb32 Add overview counts and system-health queries
Back the operator landing surface with live deployment counts and
integration health signals, one sqlc query per owning module.

CountDeliveringGrants joins core.pool_provisions rather than filtering
grants.status: grants.status is an issuance ledger recording what was
written down and whether it was later revoked, not whether service is
flowing. The current-delivery fact lives on pool_provisions.status, and a
grant can sit at status='active' with every provision ended. Counting the
ledger alone would overstate delivery.

CountClaimsByLifecycle and CountOutboxByStatus each return their buckets
in a single row, so the halves that get printed together are read at the
same instant and the landing surface pays one round trip rather than one
per bucket.
2026-07-25 15:44:21 -05:00
cgalo5758 1a19ebe971 Implement uniform conferral semantics
Replace product-kind branching and direct position writes with enclosed
database functions driven by structural product shape.

Migrate grant and provision data, unify operator issuance, update
subscription and expiry flows, and add migration and integration proofs.
2026-07-11 13:05:53 -05:00
cgalo5758 b0072d8971 Consolidate domain tables into core schema
Squash the pre-production migration history into fresh core, fedwiki,
and stripe baselines and reduce the canonical source list to those
three streams.

Update sqlc configs, generated queries, raw SQL, tests, and docs while
keeping provider tables schema-qualified.

BREAKING: existing local database volumes must be wiped because goose
version history restarts from the new baselines.
2026-07-05 20:10:23 -05:00
cgalo5758 fa420ee197 Preserve broken org default ladders
Show ladders that lost their rank-0 tier as broken instead of dropping
them from org type forms. Reject selecting them as new defaults while
allowing existing saved defaults to be re-saved safely.
2026-07-03 13:12:45 -05:00
cgalo5758 9d7569f1e9 multi-price-support: default-price model, per-row price affordances, price-aware sync
Add first-class default-price support: a product has a single default price
that readiness, the member catalog, and checkout all track.

- Migration 00016: is_default column + partial unique index (one default per
  product) + backfill (oldest active price per product).
- New queries: GetDefaultPriceByProduct, ClearDefaultPrice, MarkDefaultPrice,
  DeactivatePrice (guarded by is_default = FALSE).
- CreatePrice: first price for a product auto-becomes default (NOT EXISTS probe);
  success copy differentiates auto-default from subsequent non-default prices.
- Per-row price affordances: Sync (posts price_id, hx-vals), Make default
  (clear-then-set transaction), Deactivate (default-price guard).
- computePriceReadiness tracks the default price; resolvePurchasable documented
  as the shared purchasability gate.
- SyncProductToStripe: selectable price (explicit price_id or default);
  product-idempotent — product-synced guard prevents duplicate Stripe products.
- All error paths route through web.FieldErrorsFromDB (422) or slog+generic text,
  never err.Error().
- Render tests for default badge, per-row affordance visibility, form-level
  FieldErrors alert.

Closes: openspec/changes/multi-price-support
2026-07-02 16:20:30 -05:00
cgalo5758 710b44c21c ladder-tier-append: rank self-assigns at end, renumber-on-delete, friendly 422s
Fix the rank-collision UX bug at the source.

- Append-at-end: CreatePlanLadderTier INSERT uses COALESCE(MAX(rank)+1, 0);
  handler drops the rank input and template shows a drag-to-position hint.
- Renumber-on-delete: DeletePlanLadderTier renumbers remaining tiers inline
  so ranks stay contiguous after deletion.
- Confirm dialog copy is now honest: deleting the top tier explicitly
  promotes the next tier to the new-org default.
- Friendly errors: map duplicate-product and rank-collision constraints
  to 422 field errors via web.FieldErrorsFromDB.
- All fixtures updated for append-at-end order.

Closes: openspec/changes/ladder-tier-append
2026-07-02 16:19:30 -05:00
cgalo5758 23ecf2ba87 Implement drag-and-drop plan ladder reordering
- Add SortableJS drag-to-reorder for ladder columns on the topology
  overview page
- Remove the manual "Sort order" input from the ladder edit form
- Add SetPlanLadderSortOrder SQL query and remove sort_order from
  UpdatePlanLadder
- Update templates, CSS, specs, and tests to support the new flow
2026-06-30 02:23:45 -05:00
cgalo5758 d0b6a1d54b Add operator plan topology overview
Add a read-only operator surface at GET /operator/plan-topology with a
server-rendered cross-ladder grid (ladders by sort_order × ranks).
Include
shared-product detection via a new sqlc query (ListSharedTierProducts),
sticky rank-column CSS, add-on strip, org-type provisioning summary, and
a
reverse index of shared memberships. Register route/nav, add handler,
template, tests, specs, and docs.
2026-05-30 23:18:46 -05:00
cgalo5758 bca60f7c79 Add member plan switch and cancel flows
Introduce fulfillment.SwitchPlan, CancelSubscription and
SweepDueScheduledChanges. Add
ApplyScheduledChangesForSubscription DB helper and call it from
reconcile's terminal
branch so webhook-driven period-end deletions close out pending
scheduled changes
idempotently. Wire HTMX partials (#member-plans, switch/cancel buttons)
and update tests.
2026-05-30 01:00:33 -05:00
cgalo5758 c77715a785 Converge in-place subscription item price swaps
Update subscription model and SQL to include commitment fields. Add
SubscriptionScheduledChange types and queries, implement
UpdateSubscriptionItemPriceProduct, and adjust reconciliation and tests
to update core item rows when a Stripe item retains its ID but its
price/product/quantity changes.
2026-05-30 00:39:03 -05:00
cgalo5758 c409da9df2 Make member catalog ladder-aware
Add sort_order to billing.plan_ladders and a migration.

Reshape models, queries, handlers and templates to group plans by
plan ladder (service axis) in rank order. Track the current rung per
ladder and render per-tier move affordances; only the free→paid path
is enabled, other moves render disabled with an explanatory reason.
Include operator sort_order edit, tests, docs and image assets.
2026-05-24 19:59:45 -05:00
cgalo5758 38b703c1cf Add recent activity queries and operator timeline 2026-05-16 04:13:05 -05:00
cgalo5758 b43c15473e Add billing summary and grant form split 2026-05-16 03:55:07 -05:00
cgalo5758 751bae7768 Use plan ladder for org defaults
Add default_plan_ladder_id with a forward data migration and update
the runtime to resolve the ladder's rank-0 tier at use-time. Regenerate
sqlc, update auto-provisioning, ReapplyDefaultsForPool, operator UI and
tests; add GetTierByLadderRank and pool/provision query helpers. Add a
CSP-safe confirm-action modal and wire operator actions to it. Close
plan-sole-writer safety gaps and serialize IssueGrant with a FOR UPDATE
pool lock to prevent ladder races.
2026-04-27 01:57:17 -05:00
cgalo5758 720e546d16 Add operator plan ladder management UI and backend 2026-04-20 19:52:42 -05:00
cgalo5758 667e9ffe24 Add plan ladders and pool provision transitions
Introduce DB migrations for ladder and pool-attachment tables and an
audit log for provision transitions. Make product_type nullable and add
lifecycle_status plus a product_kinds view. Implement Transition and
ReapplyDefaultsForPool primitives, SQLC queries/models, webhook and
Temporal workflow integration, and accompanying unit/integration tests.
2026-04-19 20:45:56 -05:00
cgalo5758 bafa42b9a9 Use Product as Org Type Default 2026-04-12 16:56:25 -05:00
cgalo5758 1a89bbd292 Products page done. 2026-04-11 20:40:36 -05:00
cgalo5758 9f719f263e Remove DB seed migrations for products and prices 2026-04-07 03:47:50 -05:00
cgalo5758 64ced89432 Stripe Integration Price creation. 2026-04-07 03:24:12 -05:00
cgalo5758 be91b73dbd Stripe Operator UI 2026-04-06 03:15:20 -05:00
cgalo5758 1f1540d7e0 Use plain DB connection for migrations
Add ConnectPlain to open the DB without the custom search_path and
switch migration and CLI flows to run on that plain connection.
Wrap multi-statement goose migrations with StatementBegin/End to
ensure statements are executed atomically. Move Stripe price outbox
seeding into a dedicated stripe migration.
2026-04-05 18:25:05 -05:00
cgalo5758 18a0969ad3 Stripe invoice payment projections. 2026-04-05 03:51:31 -05:00
cgalo5758 f23a84999c sqlc: standardize generated type names across all modules
Drop redundant schema prefixes from all sqlc-generated Go types. Since
each module generates into its own package, the package already provides
the namespace — billing.Account is unambiguous without
billing.BillingAccount.

Changes:
- Add rename: blocks to all 6 sqlc.yaml files mapping schema-prefixed
  names to clean idiomatic names (e.g. BillingBillingAccount → Account,
  IdentityPerson → Person, OrganizationOrganization → Organization)
- Rename billing.billing_accounts → billing.accounts (table name
  repeated
  the schema; the schema already provides that context)
- Rename integration.integration_outbox → integration.outbox (same
  reason)
- Regenerate all sqlc output across billing, identity, organization,
  entitlements, stripe, and fedwiki modules
- Update all calling code (server, workflows, provisioning, tests) to
  use
  the new names
- Add internal/db/sqlc_schemas.sql — sqlc-only schema declarations so
  every module can resolve schema-qualified names without including the
  full db migrations
- Update docs/database-management.md with the naming convention and
  standard sqlc.yaml template

Convention going forward: table names must not repeat the schema name;
generated types carry no schema prefix; the Go package provides the
namespace (like http.Request, not http.HttpRequest).
2026-04-05 02:35:36 -05:00
cgalo5758 7ef1d32529 Stripe subcription creation 2026-04-05 02:00:07 -05:00
cgalo5758 e5698d5fcc Stripe product catalog sync. 2026-04-04 14:58:18 -05:00
cgalo5758 3d602c0601 Add billing accounts and Stripe customer sync 2026-04-04 04:08:23 -05:00
cgalo5758 cd232130f2 Introduce per-module PostgreSQL schemas 2026-04-03 03:27:48 -05:00
cgalo5758 47a75e0873 Add products, entitlement sets, and workspace support
- Add SQL queries and generated methods for Create/List/Update products
- Add CountWorkspacesByOrgID and ListResourceKeys querier methods
- Register workspace partials and operator routes for products and sets
- Add workspace UI section and operator tabs; tweak grant/site forms
- Replace isValidDNSLabel with validateDNSLabel for site validation
2026-03-27 10:55:03 -05:00
cgalo5758 15e1a59fe7 Introduce entitlement sets and migrations
Add entitlement_sets and entitlement_set_rules with seed data and a
migration that backfills products, grants, and pool_provisions, then
removes product_entitlement_rules. Update Go models, sqlc queries,
materialization, and grant/provision flows to use entitlement_set_id.
Fix assembleMigrations to assign stable per-module numeric namespaces.
Move DB docs to docs/database-management.md and add design/specs/tests.
2026-03-26 18:19:19 -05:00
cgalo5758 6330ae7a42 Grants management! 2026-03-24 17:35:14 -05:00