Authoritative directory import
importDirectory is upsert-only by default. That is safe for partial snapshots and exactly wrong for offboarding: a user who disappears from the directory keeps active: true, their memberships, and their reporting edge until someone notices. { authoritative: true } makes the snapshot the truth of every dataset it carries:
Datasets the snapshot omits are untouched in either mode, groups are never deleted here (a vanished directory group may still be referenced by grants, and that finding belongs to the reconciliation below), and every deprovisioning action is audited with its reason.
Wire your SCIM endpoint or HRIS export to produce a
DirectorySnapshot and run authoritative imports on a schedule; the warnings array is your sync-health signal, and a growing deactivatedUsers count with an empty directory diff is the classic sign the mapping broke.
Row reconciliation
Grants and revokes reference subjects and scopes as opaque strings, by design, since your users and resources live in your tables. The database therefore offers no referential backstop. The documented discipline is callingdeleteSubject / deleteScope / notifyScopeMoved alongside your own deletions and moves; reconcileRows is the detection that discipline used to lack:
directs:x, orgof:x) check the user behind them.
Detection is write-free, so run it nightly and alert on non-empty. Then sweep deliberately:
danglingRoleGrants are reported and never swept, because the row’s subject and scope are real and deleting it could mask a role-sync bug. And a sweep without provenance is rejected before anything is touched.
How the three layers fit
- The write-path discipline (
deleteSubject,deleteScope,notifyScopeMoved) is the design: cleanup in the same code path as the deletion. - Authoritative sync keeps the organizational data (users, memberships, edges) true to the directory on a cadence.
- Reconciliation is the backstop that finds what both missed, with a paper trail when it sweeps.