provisioning

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 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
	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 the quota service whose pool-backed Grant stays available to the rest of the product.

Jump to

Keyboard shortcuts

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