Context
Account model mirrors loghq: a user owns projects; collaborators are invited by email (so invites work pre-signup) with token-based acceptance. loghq's project_members / project_invites are raw SQL tables without models because the migration generator renumbered when models were added - that workaround is banned here. Every table comes from a model; the generator gap is fixed in #5 first.
Reference: loghq app/Models/{User,Project}.ts, app/Invites/invites.ts, app/Support/access.ts, routes/{auth,projects,users}.ts. Stacks ships Team/TeamMember/TeamInvitation default models in storage/framework/defaults/app/Models/ - evaluate whether overriding those beats bespoke ProjectMember/ProjectInvite models; pick one and document why in AGENTS.md.
Scope
Usermodel withuseAuth+billabletraits (billing itself lands in #17).Projectmodel: owner-scoped, unique revocable write-onlyingest_key(rhq_...prefix), deliberately nouseApitrait (loghq skips it on Project to avoid unscoped CRUD; same here). Owner-scoped CRUD actions + routes instead.ProjectMember+ProjectInviteas real models (email-keyed membership, tokened invites, expiry, revocation) - requires #5.- Two token kinds, cleanly separated: public ingest key (write-only) vs bearer token (read/manage), with loghq's cookie + localStorage SSR-aware session pattern (
resources/stores/session.ts). - Auth flows: register, login, logout, password reset; social login via
@stacksjs/socials(port loghq'sAuth/Social{Redirect,Callback}Action); passkeys/2FA if theuseAuthtrait gives them cheaply. - Auth + settings UI: sign-in/sign-up pages, account page, project settings (members, invites, key rotation) - follow the tokens/utilities from #3 and the
AuthGuardpartial pattern. - Factories, seeders, and feature tests: authz matrix (owner vs member vs stranger), invite lifecycle, key rotation.
Acceptance
buddy generate:migrations && buddy migrateproduces the full schema from models alone; zero.sqlfiles written by hand.- Feature tests cover the authz matrix and pass.
Depends on #2, #5. Part of #1 (M2 Accounts and data). Ground rules: see #1.