Commit Graph

92 Commits

Author SHA1 Message Date
9d11ee0328 Add member-console demo seeder with person seeding
Add a `seed-demo` subcommand (cmd/seed_demo.go + internal/demoseed/)
that inserts a fixed reference catalog into the member-console DB so
the operator panel has rows to walk through for UX research. Catalog:
6 demo-* products (4 by product_type + 2 extra plans), 1 plan ladder
with 3 tiers, 1 entitlement set with 2 rules (limit + boolean), and 1
grant on Alice's personal org (once she's logged in).

Person rows for bob/carlos/diana are seeded via provisioning.AutoProvision
keyed on the pinned Keycloak UUIDs — no longer fragile now that
seed-keycloak.sh's partialImport switch preserves the pinned id. Alice
is intentionally NOT pre-seeded so the lazy-creation OIDC flow stays
exercised on every fresh stack.

Idempotency: list+filter by `name` for catalog rows, by `oidc_subject`
for persons. Re-running is a no-op for created rows; warns + skips
the grant if alice hasn't logged in yet.

Host-side invocation only — run `./test/seed-demo.sh` after
bootstrap-stack.sh. Mirrors how member-console itself runs on the
host (config + secrets live under test/).

Two OpenSpec changes folded in: 2026-05-10-member-console-demo-seeder
(the seeder) and 2026-05-11-demo-seeder-persons (the persons follow-up
unlocked by the Keycloak fix).
2026-05-11 10:55:14 -05:00
66c8d84a2c worktree test stacks isolation. 2026-04-29 03:28:43 -05:00
690c70b113 Add cross-tab HTMX triggers and planLadderMutation
Signal dependent tabs to re-fetch when plan ladders change.
operator_plan_ladders handlers set HX-Trigger: planLadderMutation on
create/update/delete and tier operations so Org Types' plan dropdowns
refresh. operator.html adds explanatory comments and hx-trigger attrs
so Org Types, Grants, and Products panes listen for productMutation,
planLadderMutation, and entitlementMutation
2026-04-27 02:05:59 -05:00
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
7a7f5975eb Track grant lineage and add Extend transition
Introduce extends_grant_id on grants (models, CreateGrant param and
SQL), add
GetGrantLineage recursive query, and enforce same-org/immutability
guards via
migration triggers. Implement TransitionTarget.Extend with validation
and an
extend path that issues a chained grant + provision. Update docs, specs
and
tests accordingly.
2026-04-26 02:38:46 -05:00
beab142582 Mark entitlements package-boundary tasks complete 2026-04-25 03:46:22 -05:00
8f6a93f74d Add operator enrollment UI and plan docs
Introduce operator enrollment partials and handlers that route plan-tier
granting and revocation through entitlements.Transition(). Add
member-facing
tier labels, plan architecture and grant-plan-safety documentation, plus
unit and e2e tests. Also add small querier helpers and wire Temporal
client
hooks for trial expiration scheduling.
2026-04-24 12:28:00 -05:00
720e546d16 Add operator plan ladder management UI and backend 2026-04-20 19:52:42 -05:00
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
24465c52a8 Fix margins inconsistency between pages. 2026-04-13 02:40:15 -05:00
cdd075dc0b fix meter in products page. 2026-04-13 02:36:02 -05:00
25a206e371 Fix operator panel tabs 2026-04-13 02:22:49 -05:00
bafa42b9a9 Use Product as Org Type Default 2026-04-12 16:56:25 -05:00
1a89bbd292 Products page done. 2026-04-11 20:40:36 -05:00
6f2788b9a0 Enable auto-provision of default entitlements. 2026-04-10 14:15:13 -05:00
ac83638852 Auto-provision default billing account 2026-04-07 08:14:35 -05:00
9f719f263e Remove DB seed migrations for products and prices 2026-04-07 03:47:50 -05:00
64ced89432 Stripe Integration Price creation. 2026-04-07 03:24:12 -05:00
be91b73dbd Stripe Operator UI 2026-04-06 03:15:20 -05:00
786657eea3 Start Stripe workflows and handle webhooks
Expose /webhooks/stripe as a public path (signature-verified)

Verify webhook signatures with ConstructEventWithOptions and
IgnoreAPIVersionMismatch=true, and log API version mismatches.
Start two Temporal workflows: stripe-webhook-processor and
stripe-outbox-poller; workflow start failures are non-fatal.
2026-04-05 21:25:26 -05:00
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
18a0969ad3 Stripe invoice payment projections. 2026-04-05 03:51:31 -05:00
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
7ef1d32529 Stripe subcription creation 2026-04-05 02:00:07 -05:00
e5698d5fcc Stripe product catalog sync. 2026-04-04 14:58:18 -05:00
3d602c0601 Add billing accounts and Stripe customer sync 2026-04-04 04:08:23 -05:00
3aad9268df Stripe Billing Plumbing 2026-04-03 19:25:24 -05:00
cd232130f2 Introduce per-module PostgreSQL schemas 2026-04-03 03:27:48 -05:00
fb02411f35 Introduce DB schema separation (core and fedwiki)
Add a goose migration to create core and fedwiki schemas and move
existing
domain tables using ALTER TABLE IF EXISTS. Set connection search_path to
"core, public" after successful DB ping. Update FedWiki SQL and
sqlc.yaml to
use fedwiki.sites and include db migrations for schema awareness. Add
design
docs, specs, and tasks for schema-namespacing and the migration plan.
2026-03-30 15:16:43 -05:00
675a4d93a3 Buffer template rendering and fix FedWiki sync
Introduce SafeTemplates.Render to execute templates into a buffer and
prevent partial HTML on errors. Replace direct ExecuteTemplate calls in
partial handlers and add a make lint-templates target to catch bypasses.
Update operator sites template/view model to use OwnerOrgName. Guard the
FedWiki sync by skipping inserts when DefaultWorkspaceID is empty and
scope deletes to the configured default workspace only.
2026-03-29 04:58:02 -05:00
60c275e512 Add HTMX docs and exempt /static/ from auth 2026-03-27 16:15:55 -05:00
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
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
5a3bcf7553 Add DNS label validator for site domains
Implement isValidDNSLabel (RFC 1035/1123) in validate.go. Normalize
domain input (trim, lowercase) and enforce validation in CreateSite
handlers, returning 400 with explanatory error messages when invalid.
2026-03-26 03:52:55 -05:00
6330ae7a42 Grants management! 2026-03-24 17:35:14 -05:00
f737dd0314 Identity and organization modules. 2026-03-23 17:28:14 -05:00
5b7c2c6d2d Use session key constants and typed accessors. Fixes issues with
previous commit.
2026-02-02 22:37:06 -06:00
ddb206f7ac Use Valkey for server-side session storage with SCS. 2026-02-02 22:19:22 -06:00
2d579b377c Move from sqlite to postgres. 2026-02-02 22:19:16 -06:00
1860ec6068 feat: Implement operator dashboard with user, site, and payment management views. 2026-01-17 15:56:22 -06:00
b1282c7488 Make site ownership work correctly for fucks sake. 2026-01-01 22:07:11 -06:00
c07487e324 Implement FedWiki site synchronization workflow and related configurations 2025-12-29 19:24:52 -06:00
6ef8ef7782 Update site deletion methods to use hard delete in FarmManager API 2025-12-29 18:44:31 -06:00
0751e71f3c Add error handling for HTMX requests with toast notifications 2025-12-28 16:16:37 -06:00
98b5cee5a7 Create site flow now assigns ownership correctly. FedWiki access token issues are now not retryable. 2025-12-27 17:57:21 -06:00
8512f368fb Implement Temporal OAuth2 authentication support and configuration 2025-12-24 16:46:54 -06:00
cc30219e1c Documentation 2025-12-19 15:47:32 -06:00
b9ccae5929 Refactor FedWiki site management UI and error handling; enhance user feedback for site creation and deletion processes. 2025-12-18 16:09:58 -06:00
74002e424f Rough FedWiki Site management through temporal workflows! 2025-12-18 01:05:55 -06:00
5efa9ba71a database creation was acting weird. Now works fine? 2025-12-14 05:01:03 -06:00