provisioning

package
v0.12.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 21, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package provisioning is the framework's sanctioned composition layer for registration-time provisioning (ADR 0016): identity + workspace + quota composed into one wiring line. It is a top-level package — NOT inside identity — because composing sibling business domains inside one of them would violate the lateral-import rule (same shape as admin/adapters/bridge, docs/adr/0004).

PersonalWorkspace returns identity hooks that ensure every user ends up with exactly one personal workspace, the owner membership, and the configured onboarding credits. Idempotency is a database invariant (the partial unique index uq_workspace_personal), not code discipline, and every login re-ensures (one indexed lookup) so half-provisioned accounts — JIT failures, crashes mid-provision, lost races — converge on the next login without a retry table or a pending-flag column.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PersonalWorkspace

func PersonalWorkspace(cfg PersonalConfig) identity.IdentityHooks

PersonalWorkspace builds the ADR 0016 hooks. OnRegisterTx stays nil on purpose: the personal workspace is NOT must-succeed-with-the-user state — a failed workspace insert must never roll a registration back, so provisioning runs post-commit and converges at the next login instead.

Types

type Credit

type Credit struct {
	Key    string
	Amount int
}

Credit is one onboarding quota grant, applied inside the provisioning transaction via quota.Service.GrantTx.

type PersonalConfig

type PersonalConfig struct {
	Pool       *pgxpool.Pool
	Workspaces workspaceapp.Repo
	Quota      *quota.Service // required iff Credits is non-empty
	Credits    []Credit       // onboarding grants; optional
	Log        *slog.Logger
}

PersonalConfig wires the dependencies PersonalWorkspace needs. Workspaces is the workspace domain's app.Repo port (pass the pgrepo adapter). Quota is required IFF Credits is non-empty — products running their own credit ledger leave Credits (and Quota) empty and provision the workspace + membership only. Adoption with pre-existing users: migration 048 marks every legacy workspace 'team', so ensure would provision a NEW personal workspace for existing users — classify legacy personal workspaces via a product migration (UPDATE … SET kind='personal' WHERE <product predicate>) BEFORE wiring the factory, or accept the second workspace deliberately (see ADR 0016, "Adoption with existing users").

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL