Skip to content

feat(auth): onInvitationAccepted host seam — afterAcceptInvitation forwarded to the host (ADR-0105 D8 prerequisite) - #3645

Merged
os-zhuang merged 1 commit into
mainfrom
claude/adr-0105-group-tenancy-posture-5womi2
Jul 27, 2026
Merged

feat(auth): onInvitationAccepted host seam — afterAcceptInvitation forwarded to the host (ADR-0105 D8 prerequisite)#3645
os-zhuang merged 1 commit into
mainfrom
claude/adr-0105-group-tenancy-posture-5womi2

Conversation

@os-zhuang

Copy link
Copy Markdown
Contributor

Unblocks ADR-0105 D8 (scoped invitations)#3541's Phase 2 note called this out: "there is no afterAcceptInvitation hook today — atomic placement needs one".

What

AuthManagerConfig.onInvitationAccepted, mirroring the existing onOrganizationCreated seam (same rationale: better-auth's org-plugin models don't fire core databaseHooks, so organizationHooks is the only server-side seam for accept-time side effects):

  • Wired from organizationHooks.afterAcceptInvitation (native in the pinned better-auth 1.7) with the mapped ids — invitationId, organizationId, userId, memberId, role, emailplus the raw invitation / member rows, so a host reads its own extension columns (the D8 placement intent: target business unit + positions, carried on sys_invitation per the ADR-0092 whitelist) without a second query.
  • Failure-isolated: acceptance never rolls back on a side-effect miss (same contract as the sibling hook). A host that needs placement to be effectively atomic makes the callback idempotent and reconciles on retry — stated in the doc comment.

Cloud's D8 scoped-invitation UX (objectstack-ai/cloud#874 checklist) builds on this: issue the invitation with placement intent under the existing adminScope anti-escalation gate, apply placement in this callback.

Verification

  • New tests: payload mapping + raw-row pass-through; failure isolation (callback throws ⇒ hook resolves, warn logged); no-op when unconfigured.
  • @objectstack/plugin-auth: 508/508 tests green.
  • Repo grep guards clean; changeset included (minor — feature).

🤖 Generated with Claude Code

https://claude.ai/code/session_015FebXPaaGrLhGKw1LHPbpL


Generated by Claude Code

…rwarded to the host (ADR-0105 D8 prerequisite)

An invitation may carry placement intent (target BU + positions, extension
fields on sys_invitation per the ADR-0092 whitelist), but there was no
server-side seam to apply it at accept time — better-auth's org-plugin
models don't fire core databaseHooks (#3541 D8 note: 'there is no
afterAcceptInvitation hook today').

AuthManagerConfig.onInvitationAccepted mirrors onOrganizationCreated:
invoked from organizationHooks.afterAcceptInvitation with mapped ids
(invitationId, organizationId, userId, memberId, role, email) plus the RAW
invitation/member rows so a host reads its own extension columns without a
second query. Failure-isolated — acceptance never rolls back on a
side-effect miss; hosts needing effectively-atomic placement make the
callback idempotent and reconcile on retry.

Tests: payload mapping + raw-row pass-through, failure isolation, no-op
without the callback. plugin-auth 508/508; guards clean; changeset (minor).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015FebXPaaGrLhGKw1LHPbpL
@vercel

vercel Bot commented Jul 27, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
objectstack Ignored Ignored Jul 27, 2026 12:32pm

Request Review

@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation tests tooling labels Jul 27, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/plugin-auth.

9 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:

  • content/docs/deployment/cli.mdx (via @objectstack/plugin-auth)
  • content/docs/deployment/production-readiness.mdx (via @objectstack/plugin-auth)
  • content/docs/kernel/services-checklist.mdx (via @objectstack/plugin-auth)
  • content/docs/permissions/authentication.mdx (via @objectstack/plugin-auth)
  • content/docs/permissions/sso.mdx (via @objectstack/plugin-auth)
  • content/docs/plugins/index.mdx (via @objectstack/plugin-auth)
  • content/docs/plugins/packages.mdx (via @objectstack/plugin-auth)
  • content/docs/releases/implementation-status.mdx (via @objectstack/plugin-auth)
  • content/docs/releases/v9.mdx (via @objectstack/plugin-auth)

Advisory only. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs origin/main → pass the list as args.docs.

@os-zhuang
os-zhuang marked this pull request as ready for review July 27, 2026 12:45
@os-zhuang
os-zhuang merged commit 313d7be into main Jul 27, 2026
17 checks passed
@os-zhuang
os-zhuang deleted the claude/adr-0105-group-tenancy-posture-5womi2 branch July 27, 2026 12:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tests tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants