@happyvertical/smrt-users 0.70.0 → 0.70.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,7 +2,7 @@
2
2
  "version": "1.0.0",
3
3
  "timestamp": 0,
4
4
  "packageName": "@happyvertical/smrt-users",
5
- "packageVersion": "0.70.0",
5
+ "packageVersion": "0.70.1",
6
6
  "objects": {
7
7
  "@happyvertical/smrt-users:AccessRequestCollection": {
8
8
  "name": "accessrequestcollection",
package/dist/operator.js CHANGED
@@ -1,4 +1,4 @@
1
- import { At as normalizeEmail, I as UserCollection, P as verifySecretHash, U as TenantCollection, _ as PermissionResolver, ct as UsersPasswordCredentialCollection, f as PasswordCredentialService, ft as MembershipCollection, jt as normalizeUsername, kt as isValidEmail, ot as RoleCollection } from "./chunks/PasswordCredentialService-Dec3bz4G.js";
1
+ import { Ct as normalizeEmail, I as UserCollection, P as verifySecretHash, St as isValidEmail, U as TenantCollection, _ as PermissionResolver, at as MembershipCollection, et as RoleCollection, f as PasswordCredentialService, tt as UsersPasswordCredentialCollection, wt as normalizeUsername } from "./chunks/PasswordCredentialService-BjobA5uG.js";
2
2
  import { a as MembershipStatus, l as TenantStatus, u as UserStatus } from "./chunks/types-DqUZxluX.js";
3
3
  import { isPostgresDatabase, withEmbeddedWriteTransaction } from "@happyvertical/smrt-core";
4
4
  import { withSystemContext } from "@happyvertical/smrt-tenancy";
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Postgres policy generation, without the rest of the package. A host that
3
+ * keeps run-time models in an app schema loads this subpath to generate and
4
+ * apply their row-level-security policies.
5
+ * @packageDocumentation
6
+ */
7
+ export { applyScopedPostgresPermissionPolicies, type GeneratePostgresPermissionSqlResult, generatePostgresPermissionSql, type PostgresPolicyScope, } from './services/PostgresPermissionPolicies.js';
8
+ //# sourceMappingURL=postgres-policies.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres-policies.d.ts","sourceRoot":"","sources":["../src/postgres-policies.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,qCAAqC,EACrC,KAAK,mCAAmC,EACxC,6BAA6B,EAC7B,KAAK,mBAAmB,GACzB,MAAM,0CAA0C,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { n as applyScopedPostgresPermissionPolicies, r as generatePostgresPermissionSql } from "./chunks/PostgresPermissionPolicies-RzCLuARk.js";
2
+ export { applyScopedPostgresPermissionPolicies, generatePostgresPermissionSql };
@@ -4,6 +4,36 @@
4
4
  */
5
5
  import { type SmrtClassOptions } from '@happyvertical/smrt-core';
6
6
  import { type PostgresPermissionAction, type PostgresPermissionBinding } from './PermissionCatalogService.js';
7
+ /**
8
+ * Narrows policy generation to one application schema, for a host that holds
9
+ * a registry of run-time models (an app's tables are addressed unqualified
10
+ * through a transaction-local `search_path`).
11
+ *
12
+ * With a scope the generator never falls back to `public`: every table is
13
+ * addressed in `schemaName`, the `smrt_*` helper functions are created there
14
+ * (policies call them unqualified, through that same `search_path`, so a
15
+ * schema copied or renamed whole keeps its own helpers), only the registered classes
16
+ * `includeClass` accepts get policies, and explicit catalog or config bindings
17
+ * (which name tables of the deployment's own schema) are not applied.
18
+ */
19
+ export interface PostgresPolicyScope {
20
+ /** The schema the scoped tables and helper functions live in. */
21
+ schemaName: string;
22
+ /** Which registered classes get policies (default: none). */
23
+ includeClass: (info: {
24
+ className: string;
25
+ qualifiedName?: string;
26
+ }) => boolean;
27
+ /**
28
+ * The permission slugs that allow each action on a table, for a host whose
29
+ * slugs are not the `<collection>.read|create|update|delete` default.
30
+ */
31
+ permissionsFor?: (info: {
32
+ className: string;
33
+ collection: string;
34
+ tableName: string;
35
+ }) => Partial<Record<PostgresPermissionAction, string[]>> | undefined;
36
+ }
7
37
  export interface PostgresPermissionPolicyReportItem {
8
38
  className?: string;
9
39
  collection?: string;
@@ -28,6 +58,15 @@ export interface GeneratePostgresPermissionSqlResult {
28
58
  statements: string[];
29
59
  targets: PostgresPermissionPolicyTarget[];
30
60
  }
31
- export declare function generatePostgresPermissionSql(options?: SmrtClassOptions): GeneratePostgresPermissionSqlResult;
61
+ export declare function generatePostgresPermissionSql(options?: SmrtClassOptions, scope?: PostgresPolicyScope): GeneratePostgresPermissionSqlResult;
32
62
  export declare function applyPostgresPermissionPolicies(options?: SmrtClassOptions): Promise<GeneratePostgresPermissionSqlResult>;
63
+ /**
64
+ * Apply the policies of one scoped schema through a handle the caller already
65
+ * holds, so they commit or roll back with the caller's own DDL (an app's
66
+ * tables are created in the same transaction). The scope is required: nothing
67
+ * here falls back to `public`. The handle must be a PostgreSQL one.
68
+ */
69
+ export declare function applyScopedPostgresPermissionPolicies(db: {
70
+ query: (sql: string, ...params: unknown[]) => Promise<unknown>;
71
+ }, scope: PostgresPolicyScope, options?: SmrtClassOptions): Promise<GeneratePostgresPermissionSqlResult>;
33
72
  //# sourceMappingURL=PostgresPermissionPolicies.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PostgresPermissionPolicies.d.ts","sourceRoot":"","sources":["../../src/services/PostgresPermissionPolicies.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAGL,KAAK,gBAAgB,EACtB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAEL,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,EAC/B,MAAM,+BAA+B,CAAC;AAmBvC,MAAM,WAAW,kCAAkC;IACjD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,8BAA8B;IAC7C,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,wBAAwB,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;IAC7D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,mCAAmC;IAClD,QAAQ,EAAE,yBAAyB,EAAE,CAAC;IACtC,OAAO,EAAE,kCAAkC,EAAE,CAAC;IAC9C,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,OAAO,EAAE,8BAA8B,EAAE,CAAC;CAC3C;AAuQD,wBAAgB,6BAA6B,CAC3C,OAAO,GAAE,gBAAqB,GAC7B,mCAAmC,CAgOrC;AAED,wBAAsB,+BAA+B,CACnD,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC,mCAAmC,CAAC,CA0B9C"}
1
+ {"version":3,"file":"PostgresPermissionPolicies.d.ts","sourceRoot":"","sources":["../../src/services/PostgresPermissionPolicies.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAGL,KAAK,gBAAgB,EACtB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAEL,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,EAC/B,MAAM,+BAA+B,CAAC;AASvC;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,mBAAmB;IAClC,iEAAiE;IACjE,UAAU,EAAE,MAAM,CAAC;IACnB,6DAA6D;IAC7D,YAAY,EAAE,CAAC,IAAI,EAAE;QACnB,SAAS,EAAE,MAAM,CAAC;QAClB,aAAa,CAAC,EAAE,MAAM,CAAC;KACxB,KAAK,OAAO,CAAC;IACd;;;OAGG;IACH,cAAc,CAAC,EAAE,CAAC,IAAI,EAAE;QACtB,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,EAAE,MAAM,CAAC;QACnB,SAAS,EAAE,MAAM,CAAC;KACnB,KAAK,OAAO,CAAC,MAAM,CAAC,wBAAwB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B,EAC1B,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC,mCAAmC,CAAC,CAa9C"}
@@ -18,7 +18,7 @@ export { type BeginPasskeyRegistrationInput, DEFAULT_MAX_PASSKEYS_PER_USER, DEFA
18
18
  export { type ChangePasswordInput, type ClearPasswordInput, DEFAULT_PASSWORD_DENYLIST, DEFAULT_PASSWORD_MANAGE_PERMISSION, DEFAULT_PASSWORD_MAX_LENGTH, DEFAULT_PASSWORD_MIN_LENGTH, DEFAULT_PASSWORD_RECOVERY_MAX_AGE_SECONDS, ensurePasswordPermissionsRegistered, outOfBandProofSessionData, PASSWORD_LOGIN_KIND, PASSWORD_MAX_LENGTH_CEILING, PASSWORD_PERMISSION_DEFINITIONS, PASSWORD_RECOVERY_MAX_AGE_CEILING_SECONDS, PasswordCredentialError, PasswordCredentialForbiddenError, PasswordCredentialService, type PasswordCredentialServiceOptions, type PasswordPolicyContext, PasswordPolicyError, type PasswordPolicyOptions, type PasswordRecoveryOptions, type PasswordRecoveryProofContext, type PasswordSignInInput, type PasswordSignInResult, type PasswordStepUpInput, type PasswordStepUpResult, type ReplaceForgottenPasswordInput, type ResetPasswordInput, type SetPasswordInput, } from './PasswordCredentialService.js';
19
19
  export { deriveOperationPermissionCollectionName, deriveOperationPermissionSlug, normalizeOperationPermissionAction, type OperationPermissionCollectionInput, type PermissionCatalog, PermissionCatalogService, type PermissionCatalogSource, type PermissionCatalogSyncResult, type PermissionDefinition, type PostgresPermissionAction, type PostgresPermissionBinding, registerPermissionDefinitions, syncPermissionCatalog, type UsersConfig, } from './PermissionCatalogService.js';
20
20
  export { type PermissionResolutionOptions, type PermissionResolutionResult, PermissionResolver, type PermissionResolverOptions, type TenantPermissionInheritanceResult, } from './PermissionResolver.js';
21
- export { applyPostgresPermissionPolicies, type GeneratePostgresPermissionSqlResult, generatePostgresPermissionSql, type PostgresPermissionPolicyReportItem, type PostgresPermissionPolicyTarget, } from './PostgresPermissionPolicies.js';
21
+ export { applyPostgresPermissionPolicies, applyScopedPostgresPermissionPolicies, type GeneratePostgresPermissionSqlResult, generatePostgresPermissionSql, type PostgresPermissionPolicyReportItem, type PostgresPermissionPolicyTarget, type PostgresPolicyScope, } from './PostgresPermissionPolicies.js';
22
22
  export { type CreateResourceGrantOptions, checkResourceOperationPermission, MAX_RESOURCE_GRANT_DELEGATION_DEPTH, type ResourceGrantDecision, ResourceGrantService, type ResourceIdentity, type ResourceIdentityVerifier, type ResourceOperationPermissionOptions, type RevokeResourceGrantOptions, } from './ResourceGrantService.js';
23
23
  export { type CreatedServicePrincipal, type CreateServicePrincipalInput, type ServicePrincipalRecord, ServicePrincipalService, type ServicePrincipalServiceOptions, } from './ServicePrincipalService.js';
24
24
  export { getCurrentSessionPermissionContext, getRequestScopedDatabase, type PrincipalPermissionRuntimeOptions, type SessionPermissionRuntimeContext, type SessionPermissionRuntimeOptions, withPrincipalPermissionContext, withSessionPermissionContext, } from './SessionPermissionContext.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,2BAA2B,EAC3B,KAAK,iCAAiC,EACtC,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAC5B,kBAAkB,EAClB,KAAK,sBAAsB,EAC3B,KAAK,kBAAkB,EACvB,KAAK,yBAAyB,EAC9B,KAAK,sBAAsB,EAC3B,oBAAoB,EACpB,KAAK,2BAA2B,EAChC,KAAK,2BAA2B,EAChC,KAAK,0BAA0B,EAC/B,KAAK,wBAAwB,EAC7B,KAAK,2BAA2B,EAChC,KAAK,4BAA4B,EACjC,KAAK,2BAA2B,EAChC,KAAK,4BAA4B,EACjC,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EACzB,KAAK,wBAAwB,GAC9B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,oBAAoB,EACpB,KAAK,yBAAyB,EAC9B,KAAK,kBAAkB,EACvB,+BAA+B,EAC/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K,kBAAkB,EACvB,aAAa,EACb,KAAK,yBAAyB,GAC/B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,KAAK,0BAA0B,EAC/B,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,+CAA+C,EAC/C,qCAAqC,EACrC,sCAAsC,EACtC,oCAAoC,EACpC,+BAA+B,EAC/B,2BAA2B,EAC3B,iBAAiB,EACjB,0BAA0B,EAC1B,mBAAmB,EACnB,KAAK,0BAA0B,GAChC,MAAM,0BAA0B,CAAC"}
@@ -3,14 +3,14 @@
3
3
  "sensitiveFieldsExcluded": true,
4
4
  "generatedAt": "1970-01-01T00:00:00.000Z",
5
5
  "packageName": "@happyvertical/smrt-users",
6
- "packageVersion": "0.70.0",
6
+ "packageVersion": "0.70.1",
7
7
  "sourceManifestPath": "dist/manifest.json",
8
8
  "agentDocPath": "AGENTS.md",
9
9
  "sourceHashes": {
10
- "manifest": "e7515dafab370c09e3dd7df44a070297bf4b443e68014f9d5cafbef96317e0dc",
11
- "packageJson": "55618a39f50ab9228c3c3d1b1e1935147eb74c81c19cf8cff5124e0647bf54b8",
10
+ "manifest": "9065120c8d85f23622b13fd8e6bc924c5fd41d1aa26aeee293020fabf3155cfc",
11
+ "packageJson": "57eb3ded0e217050dbad73f26cbade2d54b073ad7fd52e0940179b21851c8634",
12
12
  "agents": "b6ae65770f9d085554ccb058f5f87f88132df9dfba3a80f311cb6bb029de9c23",
13
- "moduleDoc:agents/permissions.md": "d3b6ccc182260bac087ac7e281e4b58bb87077fdab47ba114ea1b70a9bedd3ec",
13
+ "moduleDoc:agents/permissions.md": "12514e331691ea98c7f6b0e6a7596cd4beee7a784cba16927959056565cfad78",
14
14
  "moduleDoc:agents/oidc-provisioning.md": "8408153424b22c6648f062151e261fe4b72271d5c0812b55e6d09a558a4386fd",
15
15
  "moduleDoc:agents/mobile-auth.md": "25e85e83f43e3a46383a92fa809f3a003b4545c3026e78dbe1bccbbc35161e18",
16
16
  "moduleDoc:agents/terminal-auth-testing.md": "ca6bdf325fe4edc3c875e6da38e3f5b4ae287bc0e7035002d275cf15de36e906",
@@ -27,6 +27,7 @@
27
27
  "./operator",
28
28
  "./permission-registry",
29
29
  "./playground",
30
+ "./postgres-policies",
30
31
  "./postgres-settings",
31
32
  "./step-up",
32
33
  "./svelte",
@@ -8451,7 +8452,7 @@
8451
8452
  {
8452
8453
  "path": "agents/permissions.md",
8453
8454
  "module": "permissions",
8454
- "content": "# Permissions and tenant inheritance\n\nRead for `src/services/PermissionResolver.ts`, operation guards, role seeding,\nRLS, and tenant-hierarchy changes. Integration examples live in README's\nmanifest-derived permission catalog and PostgreSQL RLS sections.\n\n## Membership selection\n\n1. A direct target-tenant membership pins resolution: active resolves normally;\n pending/suspended returns empty. Never union direct and ancestor roles.\n2. Otherwise walk hierarchyPath nearest-first for the nearest active ancestor\n membership whose role has inheritsToDescendants. Skip inactive/unflagged\n ancestors; they neither grant nor block. No qualifying ancestor means empty.\n3. Run later layers against the target tenant. Only target-tenant groups apply;\n membership overrides travel with the chosen ancestor membership.\n inheritedFromTenantId reports that ancestor, null for direct resolution.\n\nVerify hierarchyPath link-by-link against loaded parentTenantId rows before\ntrusting it: excess depth, self-reference, duplicates or inconsistent paths\nfail closed. Bound traversal by MAX_TENANT_HIERARCHY_DEPTH. Tenant status is not\nconsulted, matching direct resolution. Long-lived user/tenant caches must\ninvalidate ancestor membership changes and inheritsToDescendants flips;\nrequest-scoped caches do not survive those requests.\n\n`loadSessionContext().tenantAuthorization` is authoritative for required-tenant\nconsumers; membership null can mean inherited authority.\n\n4. If no membership resolved at all, apply the opt-in ancestor-read policy\n (smrt#2939): the user's ACTIVE memberships on VERIFIED DESCENDANTS of the\n target, whose role slug is declared in `permissions.ancestorRead.roles` and\n within `maxDepth` hops, contribute `<collection>.read` for declared\n collections, intersected with BOTH that role's own catalog grants (so a\n descendant-side tenant GRANT, group role, or membership GRANT cannot widen\n it) AND the principal's effective permissions in that descendant (so its\n DENY cascade and membership DENY apply). Only a SYSTEM\n role (`tenantId` null, `isSystem: true`) matches a declared slug: slugs are\n not unique across a hierarchy, so a tenant-scoped custom role of the same\n name must not opt its tenant in. Off by default;\n read-only; never lateral; never reached when a direct or inherited\n membership already decided. The target tenant's DENY still subtracts.\n `ancestorReadFromTenantIds` reports the contributing descendants. The grant\n carries no membership, so `membershipId`/`tenantAuthorization.membershipId`\n stay null and a consumer requiring a non-empty membership still refuses.\n\n## Permission precedence\n\nApply these layers in order, later layers overriding earlier ones:\n\n1. Ancestor TenantPermissionOverride cascade (GRANT adds, DENY removes).\n2. Selected membership role permissions.\n3. Target-tenant group-role permissions.\n4. Tenant cascade's net DENY removes role/group grants.\n5. Membership GRANT may re-add a tenant-denied slug.\n6. Membership DENY removes last and always wins.\n\nThe tenant block is the cascade's net result, not the union of historical DENYs:\na child's more-specific GRANT can override a parent DENY. Use a direct child\nmembership or tenant DENY to attenuate inherited role authority.\n`getGroupIdsForTenant(userId, tenantId)` is required; getGroupIds is cross-tenant.\n\n## Hierarchies and seeding\n\n- `Tenant.save()` derives hierarchyPath/hierarchyLevel from the REAL\n parentTenantId chain on every save (never from an ancestor's stored path),\n refuses missing parents, cycles and over-depth before writing, and\n re-materializes descendants by raw column update (so STI subclass columns\n are never clobbered). createChild/moveToParent/makeRoot are thin wrappers.\n `materializeTenantHierarchy(db, { dryRun })` / `smrt\n db:materialize-tenant-hierarchy` backfills legacy rows: idempotent, one\n transaction, refuses a broken chain without writing (#3036). A NEW or\n CHANGED parent link is authority-bearing, so `Tenant.save()` first loads the\n parent through TenantCollection (the caller's tenancy scope) and refuses an\n invisible one on every path — helpers, `create({ parentTenantId })`, or a\n plain assignment + save; system context bypasses as usual, and an unchanged\n link is never re-checked. getTree(rootId?)\n returns UI structure. Maximum depth is 10.\n- Tenant override cascade requires parent cascadePermissions and child\n inheritPermissions. These flags do not gate the independent, per-role\n inheritsToDescendants membership flow.\n- `permissions.ancestorRead` in the `users` package config declares upward,\n read-only visibility: `{ roles, collections, maxDepth? }`. Both lists are\n required and non-empty and `maxDepth >= 1`, else the policy is OFF — there is\n no partially valid declaration. `isAncestorReadableSlug()` is the single place\n the read-only bound is enforced; only a two-segment `<collection>.<action>`\n slug whose action normalizes to `read` on a declared collection passes.\n `PermissionResolver.create(options, { ancestorReadPolicy })` binds one\n resolver; `null` forces it off. It grants the OPERATION at the ancestor, never\n row visibility — sibling rows stay scoped by the tenancy interceptor and RLS.\n- seedSystemRoles({ inheritsToDescendants: ['owner', 'admin'] }) flags listed\n slugs additively, never unflags omitted ones, and rejects unknown slugs.\n Default seeds are exact-tenant.\n- RolePermissionCollection.seedRolePermissions() or\n seedSystemRoles({ seedPermissions: true }) maps owner/admin to all catalog\n permissions, member to ordinary-resource read/create, viewer to read. Member\n create excludes identity/RBAC/security resources and their joins/overrides.\n Seeding is additive/idempotent; removal requires prune: true. Catalog sync\n and grants plan from one read, then commit in `SEEDING_BATCH_SIZE` batches\n (#3323): never one durable commit per row (an fsync each on local SQLite),\n and never one catalog-wide transaction (`@happyvertical/sql` transaction\n scopes cost superlinearly per statement). Pass a caller transaction's handle.\n- When a package adds built-in self-personalization permissions after role\n creation, explicitly call seedDefaultRolePersonalizationPermissions(). It\n upgrades owner/admin/member/viewer idempotently and never grants custom roles.\n The built-in self-personalization slugs are `fields.policy.personalize`,\n `overviews.personalize` and `shell.personalize`, each seeded only once its\n package registered it.\n\n## Guards and RLS\n\nPermissionCatalogService derives collection.action slugs from manifests,\nincluding custom actions; list/get map to read. Guards derive a class's slug\nthrough the same resolution (explicit `collection`, manifest entry, then its\nSTI base's), so an STI subtype resolves its STI base's collection\n(`Network extends Tenant` -> `tenants.update`) in every build, including a\nbundle decorated before its manifest loads (#3125). Hand-written mutations in form\nhandlers, endpoints, CLI and jobs use assertOperationPermission(). It requires\ncatalog presence then resolves permissions, throwing fail-closed by default.\nShared STI CRUD catalog entries name the effective base model, independent of\nregistration order. Subtypes cannot overwrite `profiles.create` (formerly Bot\nwhen Bot registered last). An explicit child collection keeps its own CRUD,\nand deeper descendants sharing that namespace cannot replace its owner;\nchild custom actions and field permissions are still catalogued. Same-name app\nreplacements supply the effective base identity through the public registry.\n`sti-create-dispatch.test.ts` exercises real Profile/Bot and a generic family\nthrough REST, MCP, CLI's create handler and assistant manifest dispatch on SQLite;\n`permission-catalog.test.ts` checks reversed order and app replacement metadata.\nUse onDeny: 'return', checkOperationPermission or hasOperationPermission only\nwhen the caller handles a structured/boolean denial.\n\nInside a runtime REST request acting for a host-resolved principal\n(`getRequestPrincipal()` from core, #5195), `checkOperationPermission` and\nits siblings are capped by that principal: a slug it lacks is denied\nwhichever branch would grant it (system context, super-admin bypass, live\nrole, explicit `permissionSet`). For the principal's own user and tenant its\npermissions stand in for resolution (an explicit set is intersected); for\nanother subject a transaction-scoped request denies with `subject_mismatch`\nand any other request resolves that subject live, still capped. Outside such\na request the gate is unchanged. Test: `src/__tests__/rest-request-scope.test.ts`.\n\nGenerated SvelteKit write routes (POST/PUT/PATCH/DELETE CRUD and mutating\ncustom actions) enforce the same `collection.action` slug (custom actions use\n`collection.<method>`; actions hosted on a collection class use the item collection, which the catalog now emits) after authentication: the slug must be in the request's\nsession permission snapshot (`locals.permissions`/`permissionSet`/\n`smrtPermissions` or `locals.tenantContext.permissions`), otherwise 403. Only\n`locals.tenantContext.superAdminBypass` skips it; `api.public: true` stays open.\n\nResource-anchored guards receive the resource tenant ID. When it differs from\nthe session tenant, omit the session membership so the resolver selects the\nappropriate authority; mismatched supplied membership/tenant fails closed.\nInherited root-admin authority can then authorize descendant resources without\napplication-side membership fan-out.\n\nResolution cost must not scale with catalog size in objects (#3047): role →\npermission ids and ids → slugs are `list({ select })` projection reads (the\ncollections' beforeList interceptors still run; no RolePermission/Permission\nis hydrated), so an owner mapped to the whole catalog costs two queries and\nno per-permission objects. Keep new resolver reads projections when only ids\nor slugs are needed, and do not add public collection methods for them — each\nbecomes a custom-action slug in the manifest-derived catalog. The resolver's\ncollections never inherit `defaultListLimit`/`maxListLimit` from the caller's\noptions, and id-list reads chunk at `IN_LIST_CHUNK_SIZE` with an explicit\nlimit: a truncated authorization read would narrow the result silently.\n`issue-3047-permission-resolution-cost-postgres.test.ts` pins the hydration\nbudget and a golden equivalence matrix recorded on the hydrating resolver.\n\nThe same rule holds for every framework-internal authorization read (#3048):\ncollections that back a decision — the resolver's, the ResourceGrant exact-tuple\nread in `checkResourceOperationPermission()` (DENY wins only if every row is\nread), and TenantService's owned-tenant quota count — are created through\n`withoutListBounds()` (`src/services/authorization-read-options.ts`), which\nstrips only the caller's list bounds. Use it for any new decision read;\n`issue-3048-authorization-list-bounds-postgres.test.ts` pins it.\n\nPermissionResolver runs every resolution inside smrt-tenancy's system context\n(#3036). Its reads are deliberately cross-tenant and framework-owned — the\nancestor TenantPermissionOverride batch, ancestor memberships for\ninheritsToDescendants, descendant memberships for ancestor-read — and are keyed\nby the explicit (userId, tenantId); with those classes registered tenant-scoped\n(`autoFilter`) the consumer's filter otherwise threw TenantIsolationError or\nsilently narrowed them. It returns slugs and ids only, never rows, and the\ncaller's own reads stay filtered. Do not move a resolver read back under the\nambient tenant; the Postgres regression suite\n`issue-3036-hierarchy-resolution-postgres.test.ts` pins this. Because nothing\nbackstops those reads any more, the tenant-override cascade verifies its chain\ntoo: it uses hierarchyPath only when it agrees link-by-link with\nparentTenantId, otherwise walks the real parent links (so a forged path cannot\ncascade an unrelated tenant in, and a never-materialized row still gets its real\nancestors' DENYs — and GRANTs), and throws TenantHierarchyError on a broken\nreal chain: a per-request failure for that tenant's whole subtree, which\n`smrt db:materialize-tenant-hierarchy --dry-run` reports ahead of time (see\nREADME \"Upgrading an existing fleet\").\n`getTenantInheritanceChain()` returns Tenant rows, so it is NOT run in system\ncontext; it reports the same verified chain the cascade applies when the\ncaller can read every ancestor. Otherwise it never reports PARENT_NOT_FOUND\nfor a row the caller simply cannot see: an interceptor refusal surfaces as\nTenantIsolationError, and a silently filtered row (e.g. RLS) ends the chain at\nthe nearest readable ancestor. Descendant path rewrites are raw column updates recorded through\n`bumpChangeFeed`; `updated_at` is intentionally not bumped (derived columns;\nevery save recomputes them). They are not atomic with the moving row's save —\nan interrupted subtree fails closed until re-saved or backfilled.\n\nSystem context and super-admin bypass are honored. Pass\nallowSuperAdminBypass: false for money or separation-of-duties operations that\nrequire an explicit grant.\n\ngeneratePostgresPermissionSql/applyPostgresPermissionPolicies enforce generated\nRLS using smrt.permissions and smrt.tenant_id, installed with set_config by\nwithSessionPermissionContext. This bounds REST, MCP and in-process database\naccess once principal context is set. Child-tenant sessions receive resolved\ninherited permissions automatically, but RLS row filtering remains bound to the\nsession tenant: a root session's app-level guard authorization does not itself\npermit child rows through RLS. Preserve this distinction.\n\nRolePermission's natural key is `(role_id, permission_id)` (#3329); repeated or\nconcurrent inserts converge without changing the grant ID. Existing deployments\nmust run `deduplicateRolePermissions()` with stopped writers before ordinary\nschema migration; see README's \"Upgrade duplicate role grants\". It keeps the\noldest row and installs uniqueness atomically. Runtime seeding never performs\nthis schema repair.\n\nMembershipOverride `(membership_id, permission_id)`, TenantPermissionOverride\n`(tenant_id, permission_id)` and GroupMember `(group_id, user_id)` are natural\nkeys too (#3375): `setOverride()` upserts (last effect wins), removal deletes by\nthe pair, and their FKs declare `onDelete: 'NO ACTION'` so the natural key does\nnot turn them into CASCADE. Existing deployments run\n`deduplicateAuthorityPairs()` in the same stopped-writer window; it keeps the\neffective override (DENY > GRANT > INHERIT) so authority never widens.\n\nCustom methods can declare `operationPermissions` aliases to the same\ncollection's CRUD grants (#3878); `deriveOperationPermissionSlug()` resolves\nthem for class and catalog-slug callers. Catalog generation merges optional\n`databaseActions` into the target grant's PostgreSQL bindings. CRUD grants\ncannot themselves be aliased. See core's [generator contract](../../core/agents/generators.md#custom-action-permission-aliases-3878).\n\n## Portable metadata registry (#4765)\n\nBrowser-safe packages import `registerPermissionDefinitions` and its existing\n`PermissionDefinition` / PostgreSQL binding types from\n`@happyvertical/smrt-users/permission-registry`. This entry imports only shared\nmetadata storage. It does not load Users models, catalog database sync, operator\nservices, PostgreSQL policy generation or Core filesystem discovery.\n\nThe old package-root and PermissionCatalogService exports re-export the exact\nsame function. Both paths share the existing process-global Map/counter; each\nreturned disposer removes only its own registration and may be called repeatedly.\nDefinitions retain their original references and normalization/conflict rules\nremain in the server catalog. No second catalog or no-op browser registration is\nintroduced. Metadata registration and catalog sync do not grant a user, role,\ntenant or resource permission. Existing persisted grants/current authority checks\nremain required. Use the public portable entry rather than private service paths\nwhen a model package needs declarations without the server runtime.\n\n### Runtime resource discovery imports\n\n`src/sveltekit/resource-list-handler.ts` imports shared action/name policy from\n`@happyvertical/smrt-core/api-actions`, not the Vite-plugin barrel. This is the\nsame implementation re-exported by the route generator; permissions, wireability,\ncustom-action receiver resolution and paths are unchanged. The existing resource\nhandler suite retains positive and refusal coverage, and its fresh-Node published\nentry guard rejects Vite route-emitter/activation-generator loads. No SQL executor,\ntransaction, authentication or tenant-boundary behavior changes in this import fix.\n\n## Agent users (#5086)\n\nThere is no agent column on `User`. A user is an agent when its linked\n`Profile` has the `bot` profile type (`resolveAgentProfile` /\n`AGENT_PROFILE_TYPE_SLUG` in `@happyvertical/smrt-profiles`); give it a\nmembership with a limited custom role like any member. MCP classifies the\nprincipal from that live profile (`kind: 'agent'`), the default MCP policy\naccepts the kind only when `principalKinds` lists it, and the role's\npermissions cap what its tokens can do on every request. The profile models\nrefuse an unprivileged principal changing whether a profile is `bot` typed\n(including by create or natural-key upsert) or creating/renaming the type, so an agent cannot relabel itself. See\n`packages/app-runtime/agents/self-issuer-mcp.md`.\n"
8455
+ "content": "# Permissions and tenant inheritance\n\nRead for `src/services/PermissionResolver.ts`, operation guards, role seeding,\nRLS, and tenant-hierarchy changes. Integration examples live in README's\nmanifest-derived permission catalog and PostgreSQL RLS sections.\n\n## Membership selection\n\n1. A direct target-tenant membership pins resolution: active resolves normally;\n pending/suspended returns empty. Never union direct and ancestor roles.\n2. Otherwise walk hierarchyPath nearest-first for the nearest active ancestor\n membership whose role has inheritsToDescendants. Skip inactive/unflagged\n ancestors; they neither grant nor block. No qualifying ancestor means empty.\n3. Run later layers against the target tenant. Only target-tenant groups apply;\n membership overrides travel with the chosen ancestor membership.\n inheritedFromTenantId reports that ancestor, null for direct resolution.\n\nVerify hierarchyPath link-by-link against loaded parentTenantId rows before\ntrusting it: excess depth, self-reference, duplicates or inconsistent paths\nfail closed. Bound traversal by MAX_TENANT_HIERARCHY_DEPTH. Tenant status is not\nconsulted, matching direct resolution. Long-lived user/tenant caches must\ninvalidate ancestor membership changes and inheritsToDescendants flips;\nrequest-scoped caches do not survive those requests.\n\n`loadSessionContext().tenantAuthorization` is authoritative for required-tenant\nconsumers; membership null can mean inherited authority.\n\n4. If no membership resolved at all, apply the opt-in ancestor-read policy\n (smrt#2939): the user's ACTIVE memberships on VERIFIED DESCENDANTS of the\n target, whose role slug is declared in `permissions.ancestorRead.roles` and\n within `maxDepth` hops, contribute `<collection>.read` for declared\n collections, intersected with BOTH that role's own catalog grants (so a\n descendant-side tenant GRANT, group role, or membership GRANT cannot widen\n it) AND the principal's effective permissions in that descendant (so its\n DENY cascade and membership DENY apply). Only a SYSTEM\n role (`tenantId` null, `isSystem: true`) matches a declared slug: slugs are\n not unique across a hierarchy, so a tenant-scoped custom role of the same\n name must not opt its tenant in. Off by default;\n read-only; never lateral; never reached when a direct or inherited\n membership already decided. The target tenant's DENY still subtracts.\n `ancestorReadFromTenantIds` reports the contributing descendants. The grant\n carries no membership, so `membershipId`/`tenantAuthorization.membershipId`\n stay null and a consumer requiring a non-empty membership still refuses.\n\n## Permission precedence\n\nApply these layers in order, later layers overriding earlier ones:\n\n1. Ancestor TenantPermissionOverride cascade (GRANT adds, DENY removes).\n2. Selected membership role permissions.\n3. Target-tenant group-role permissions.\n4. Tenant cascade's net DENY removes role/group grants.\n5. Membership GRANT may re-add a tenant-denied slug.\n6. Membership DENY removes last and always wins.\n\nThe tenant block is the cascade's net result, not the union of historical DENYs:\na child's more-specific GRANT can override a parent DENY. Use a direct child\nmembership or tenant DENY to attenuate inherited role authority.\n`getGroupIdsForTenant(userId, tenantId)` is required; getGroupIds is cross-tenant.\n\n## Hierarchies and seeding\n\n- `Tenant.save()` derives hierarchyPath/hierarchyLevel from the REAL\n parentTenantId chain on every save (never from an ancestor's stored path),\n refuses missing parents, cycles and over-depth before writing, and\n re-materializes descendants by raw column update (so STI subclass columns\n are never clobbered). createChild/moveToParent/makeRoot are thin wrappers.\n `materializeTenantHierarchy(db, { dryRun })` / `smrt\n db:materialize-tenant-hierarchy` backfills legacy rows: idempotent, one\n transaction, refuses a broken chain without writing (#3036). A NEW or\n CHANGED parent link is authority-bearing, so `Tenant.save()` first loads the\n parent through TenantCollection (the caller's tenancy scope) and refuses an\n invisible one on every path — helpers, `create({ parentTenantId })`, or a\n plain assignment + save; system context bypasses as usual, and an unchanged\n link is never re-checked. getTree(rootId?)\n returns UI structure. Maximum depth is 10.\n- Tenant override cascade requires parent cascadePermissions and child\n inheritPermissions. These flags do not gate the independent, per-role\n inheritsToDescendants membership flow.\n- `permissions.ancestorRead` in the `users` package config declares upward,\n read-only visibility: `{ roles, collections, maxDepth? }`. Both lists are\n required and non-empty and `maxDepth >= 1`, else the policy is OFF — there is\n no partially valid declaration. `isAncestorReadableSlug()` is the single place\n the read-only bound is enforced; only a two-segment `<collection>.<action>`\n slug whose action normalizes to `read` on a declared collection passes.\n `PermissionResolver.create(options, { ancestorReadPolicy })` binds one\n resolver; `null` forces it off. It grants the OPERATION at the ancestor, never\n row visibility — sibling rows stay scoped by the tenancy interceptor and RLS.\n- seedSystemRoles({ inheritsToDescendants: ['owner', 'admin'] }) flags listed\n slugs additively, never unflags omitted ones, and rejects unknown slugs.\n Default seeds are exact-tenant.\n- RolePermissionCollection.seedRolePermissions() or\n seedSystemRoles({ seedPermissions: true }) maps owner/admin to all catalog\n permissions, member to ordinary-resource read/create, viewer to read. Member\n create excludes identity/RBAC/security resources and their joins/overrides.\n Seeding is additive/idempotent; removal requires prune: true. Catalog sync\n and grants plan from one read, then commit in `SEEDING_BATCH_SIZE` batches\n (#3323): never one durable commit per row (an fsync each on local SQLite),\n and never one catalog-wide transaction (`@happyvertical/sql` transaction\n scopes cost superlinearly per statement). Pass a caller transaction's handle.\n- When a package adds built-in self-personalization permissions after role\n creation, explicitly call seedDefaultRolePersonalizationPermissions(). It\n upgrades owner/admin/member/viewer idempotently and never grants custom roles.\n The built-in self-personalization slugs are `fields.policy.personalize`,\n `overviews.personalize` and `shell.personalize`, each seeded only once its\n package registered it.\n\n## Guards and RLS\n\nPermissionCatalogService derives collection.action slugs from manifests,\nincluding custom actions; list/get map to read. Guards derive a class's slug\nthrough the same resolution (explicit `collection`, manifest entry, then its\nSTI base's), so an STI subtype resolves its STI base's collection\n(`Network extends Tenant` -> `tenants.update`) in every build, including a\nbundle decorated before its manifest loads (#3125). Hand-written mutations in form\nhandlers, endpoints, CLI and jobs use assertOperationPermission(). It requires\ncatalog presence then resolves permissions, throwing fail-closed by default.\nShared STI CRUD catalog entries name the effective base model, independent of\nregistration order. Subtypes cannot overwrite `profiles.create` (formerly Bot\nwhen Bot registered last). An explicit child collection keeps its own CRUD,\nand deeper descendants sharing that namespace cannot replace its owner;\nchild custom actions and field permissions are still catalogued. Same-name app\nreplacements supply the effective base identity through the public registry.\n`sti-create-dispatch.test.ts` exercises real Profile/Bot and a generic family\nthrough REST, MCP, CLI's create handler and assistant manifest dispatch on SQLite;\n`permission-catalog.test.ts` checks reversed order and app replacement metadata.\nUse onDeny: 'return', checkOperationPermission or hasOperationPermission only\nwhen the caller handles a structured/boolean denial.\n\nInside a runtime REST request acting for a host-resolved principal\n(`getRequestPrincipal()` from core, #5195), `checkOperationPermission` and\nits siblings are capped by that principal: a slug it lacks is denied\nwhichever branch would grant it (system context, super-admin bypass, live\nrole, explicit `permissionSet`). For the principal's own user and tenant its\npermissions stand in for resolution (an explicit set is intersected); for\nanother subject a transaction-scoped request denies with `subject_mismatch`\nand any other request resolves that subject live, still capped. Outside such\na request the gate is unchanged. Test: `src/__tests__/rest-request-scope.test.ts`.\n\nGenerated SvelteKit write routes (POST/PUT/PATCH/DELETE CRUD and mutating\ncustom actions) enforce the same `collection.action` slug (custom actions use\n`collection.<method>`; actions hosted on a collection class use the item collection, which the catalog now emits) after authentication: the slug must be in the request's\nsession permission snapshot (`locals.permissions`/`permissionSet`/\n`smrtPermissions` or `locals.tenantContext.permissions`), otherwise 403. Only\n`locals.tenantContext.superAdminBypass` skips it; `api.public: true` stays open.\n\nResource-anchored guards receive the resource tenant ID. When it differs from\nthe session tenant, omit the session membership so the resolver selects the\nappropriate authority; mismatched supplied membership/tenant fails closed.\nInherited root-admin authority can then authorize descendant resources without\napplication-side membership fan-out.\n\nResolution cost must not scale with catalog size in objects (#3047): role →\npermission ids and ids → slugs are `list({ select })` projection reads (the\ncollections' beforeList interceptors still run; no RolePermission/Permission\nis hydrated), so an owner mapped to the whole catalog costs two queries and\nno per-permission objects. Keep new resolver reads projections when only ids\nor slugs are needed, and do not add public collection methods for them — each\nbecomes a custom-action slug in the manifest-derived catalog. The resolver's\ncollections never inherit `defaultListLimit`/`maxListLimit` from the caller's\noptions, and id-list reads chunk at `IN_LIST_CHUNK_SIZE` with an explicit\nlimit: a truncated authorization read would narrow the result silently.\n`issue-3047-permission-resolution-cost-postgres.test.ts` pins the hydration\nbudget and a golden equivalence matrix recorded on the hydrating resolver.\n\nThe same rule holds for every framework-internal authorization read (#3048):\ncollections that back a decision — the resolver's, the ResourceGrant exact-tuple\nread in `checkResourceOperationPermission()` (DENY wins only if every row is\nread), and TenantService's owned-tenant quota count — are created through\n`withoutListBounds()` (`src/services/authorization-read-options.ts`), which\nstrips only the caller's list bounds. Use it for any new decision read;\n`issue-3048-authorization-list-bounds-postgres.test.ts` pins it.\n\nPermissionResolver runs every resolution inside smrt-tenancy's system context\n(#3036). Its reads are deliberately cross-tenant and framework-owned — the\nancestor TenantPermissionOverride batch, ancestor memberships for\ninheritsToDescendants, descendant memberships for ancestor-read — and are keyed\nby the explicit (userId, tenantId); with those classes registered tenant-scoped\n(`autoFilter`) the consumer's filter otherwise threw TenantIsolationError or\nsilently narrowed them. It returns slugs and ids only, never rows, and the\ncaller's own reads stay filtered. Do not move a resolver read back under the\nambient tenant; the Postgres regression suite\n`issue-3036-hierarchy-resolution-postgres.test.ts` pins this. Because nothing\nbackstops those reads any more, the tenant-override cascade verifies its chain\ntoo: it uses hierarchyPath only when it agrees link-by-link with\nparentTenantId, otherwise walks the real parent links (so a forged path cannot\ncascade an unrelated tenant in, and a never-materialized row still gets its real\nancestors' DENYs — and GRANTs), and throws TenantHierarchyError on a broken\nreal chain: a per-request failure for that tenant's whole subtree, which\n`smrt db:materialize-tenant-hierarchy --dry-run` reports ahead of time (see\nREADME \"Upgrading an existing fleet\").\n`getTenantInheritanceChain()` returns Tenant rows, so it is NOT run in system\ncontext; it reports the same verified chain the cascade applies when the\ncaller can read every ancestor. Otherwise it never reports PARENT_NOT_FOUND\nfor a row the caller simply cannot see: an interceptor refusal surfaces as\nTenantIsolationError, and a silently filtered row (e.g. RLS) ends the chain at\nthe nearest readable ancestor. Descendant path rewrites are raw column updates recorded through\n`bumpChangeFeed`; `updated_at` is intentionally not bumped (derived columns;\nevery save recomputes them). They are not atomic with the moving row's save —\nan interrupted subtree fails closed until re-saved or backfilled.\n\nSystem context and super-admin bypass are honored. Pass\nallowSuperAdminBypass: false for money or separation-of-duties operations that\nrequire an explicit grant.\n\ngeneratePostgresPermissionSql/applyPostgresPermissionPolicies enforce generated\nRLS using smrt.permissions and smrt.tenant_id, installed with set_config by\nwithSessionPermissionContext. This bounds REST, MCP and in-process database\naccess once principal context is set. Child-tenant sessions receive resolved\ninherited permissions automatically, but RLS row filtering remains bound to the\nsession tenant: a root session's app-level guard authorization does not itself\npermit child rows through RLS. Preserve this distinction.\n\nA host with run-time models in an app schema passes a `PostgresPolicyScope` (second\nargument; `@happyvertical/smrt-users/postgres-policies`, `applyScopedPostgresPermissionPolicies`\non a handle it already holds): tables and the `smrt_*` helpers live in\n`schemaName`, never `public`; only `includeClass` classes get policies;\n`permissionsFor` names the slugs; explicit bindings are not applied. Helper bodies\nnever call each other (a schema copied whole creates functions in name order).\n\nRolePermission's natural key is `(role_id, permission_id)` (#3329); repeated or\nconcurrent inserts converge without changing the grant ID. Existing deployments\nmust run `deduplicateRolePermissions()` with stopped writers before ordinary\nschema migration; see README's \"Upgrade duplicate role grants\". It keeps the\noldest row and installs uniqueness atomically. Runtime seeding never performs\nthis schema repair.\n\nMembershipOverride `(membership_id, permission_id)`, TenantPermissionOverride\n`(tenant_id, permission_id)` and GroupMember `(group_id, user_id)` are natural\nkeys too (#3375): `setOverride()` upserts (last effect wins), removal deletes by\nthe pair, and their FKs declare `onDelete: 'NO ACTION'` so the natural key does\nnot turn them into CASCADE. Existing deployments run\n`deduplicateAuthorityPairs()` in the same stopped-writer window; it keeps the\neffective override (DENY > GRANT > INHERIT) so authority never widens.\n\nCustom methods can declare `operationPermissions` aliases to the same\ncollection's CRUD grants (#3878); `deriveOperationPermissionSlug()` resolves\nthem for class and catalog-slug callers. Catalog generation merges optional\n`databaseActions` into the target grant's PostgreSQL bindings. CRUD grants\ncannot themselves be aliased. See core's [generator contract](../../core/agents/generators.md#custom-action-permission-aliases-3878).\n\n## Portable metadata registry (#4765)\n\nBrowser-safe packages import `registerPermissionDefinitions` and its existing\n`PermissionDefinition` / PostgreSQL binding types from\n`@happyvertical/smrt-users/permission-registry`. This entry imports only shared\nmetadata storage. It does not load Users models, catalog database sync, operator\nservices, PostgreSQL policy generation or Core filesystem discovery.\n\nThe old package-root and PermissionCatalogService exports re-export the exact\nsame function. Both paths share the existing process-global Map/counter; each\nreturned disposer removes only its own registration and may be called repeatedly.\nDefinitions retain their original references and normalization/conflict rules\nremain in the server catalog. No second catalog or no-op browser registration is\nintroduced. Metadata registration and catalog sync do not grant a user, role,\ntenant or resource permission. Existing persisted grants/current authority checks\nremain required. Use the public portable entry rather than private service paths\nwhen a model package needs declarations without the server runtime.\n\n### Runtime resource discovery imports\n\n`src/sveltekit/resource-list-handler.ts` imports shared action/name policy from\n`@happyvertical/smrt-core/api-actions`, not the Vite-plugin barrel. This is the\nsame implementation re-exported by the route generator; permissions, wireability,\ncustom-action receiver resolution and paths are unchanged. The existing resource\nhandler suite retains positive and refusal coverage, and its fresh-Node published\nentry guard rejects Vite route-emitter/activation-generator loads. No SQL executor,\ntransaction, authentication or tenant-boundary behavior changes in this import fix.\n\n## Agent users (#5086)\n\nThere is no agent column on `User`. A user is an agent when its linked\n`Profile` has the `bot` profile type (`resolveAgentProfile` /\n`AGENT_PROFILE_TYPE_SLUG` in `@happyvertical/smrt-profiles`); give it a\nmembership with a limited custom role like any member. MCP classifies the\nprincipal from that live profile (`kind: 'agent'`), the default MCP policy\naccepts the kind only when `principalKinds` lists it, and the role's\npermissions cap what its tokens can do on every request. The profile models\nrefuse an unprivileged principal changing whether a profile is `bot` typed\n(including by create or natural-key upsert) or creating/renaming the type, so an agent cannot relabel itself. See\n`packages/app-runtime/agents/self-issuer-mcp.md`.\n"
8455
8456
  },
8456
8457
  {
8457
8458
  "path": "agents/oidc-provisioning.md",
@@ -5,10 +5,10 @@ description: "Multi-tenant user management for the SMRT framework - users, tenan
5
5
  status: "stable"
6
6
  generated:
7
7
  by: "smrt/scripts/generate-knowledge-okf.ts"
8
- at: "2026-11-23T02:20:34Z"
8
+ at: "2026-11-23T17:57:32Z"
9
9
  audience: "internal"
10
10
  evidence_level: "source-inspected"
11
- source_revision: "sha256:8787ec1a3e53a5706850e42f545402c1b6ea624cff9654a73b6ae68416f090b9"
11
+ source_revision: "sha256:a66a4907c7ceadf06c8039bb2a04a786e77ccc3ecf50aa596de3b2c4b46fcbf8"
12
12
  sources:
13
13
  - id: "manifest"
14
14
  resource: "https://github.com/happyvertical/smrt/blob/main/packages/users/package.json"
@@ -88,6 +88,7 @@ sources:
88
88
  - `./operator`
89
89
  - `./permission-registry`
90
90
  - `./playground`
91
+ - `./postgres-policies`
91
92
  - `./postgres-settings`
92
93
  - `./step-up`
93
94
  - `./svelte`
package/dist/sveltekit.js CHANGED
@@ -1,5 +1,5 @@
1
- import { M as LoginRateLimitError, d as PasswordCredentialForbiddenError, f as PasswordCredentialService, g as SessionService, p as PasswordPolicyError, u as PasswordCredentialError } from "./chunks/PasswordCredentialService-Dec3bz4G.js";
2
- import { B as OidcLoginService, C as PasskeyCredentialService, D as OperationPermissionError, F as MobileAuthError, H as encodeOidcTransaction, I as MobileAuthService, J as DeviceCredentialError, L as readMobileBearerToken, P as withSessionPermissionContext, R as validateMobileRedirectUri, S as PasskeyCredentialForbiddenError, T as PasskeyRegistrationError, U as getUsersOidcConfig, V as decodeOidcTransaction, W as resolveOidcProviderConfig, X as DeviceCredentialPolicyError, Y as DeviceCredentialForbiddenError, Z as DeviceCredentialService, a as TerminalAuthError, o as TerminalAuthRateLimitError, s as TerminalAuthService, w as PasskeyReauthenticationRequiredError, x as PasskeyCredentialError, z as OidcLoginError } from "./chunks/TerminalAuthService-BCem_pDy.js";
1
+ import { M as LoginRateLimitError, d as PasswordCredentialForbiddenError, f as PasswordCredentialService, g as SessionService, p as PasswordPolicyError, u as PasswordCredentialError } from "./chunks/PasswordCredentialService-BjobA5uG.js";
2
+ import { B as OidcLoginService, C as PasskeyCredentialService, D as OperationPermissionError, F as MobileAuthError, H as encodeOidcTransaction, I as MobileAuthService, J as DeviceCredentialError, L as readMobileBearerToken, P as withSessionPermissionContext, R as validateMobileRedirectUri, S as PasskeyCredentialForbiddenError, T as PasskeyRegistrationError, U as getUsersOidcConfig, V as decodeOidcTransaction, W as resolveOidcProviderConfig, X as DeviceCredentialPolicyError, Y as DeviceCredentialForbiddenError, Z as DeviceCredentialService, a as TerminalAuthError, o as TerminalAuthRateLimitError, s as TerminalAuthService, w as PasskeyReauthenticationRequiredError, x as PasskeyCredentialError, z as OidcLoginError } from "./chunks/TerminalAuthService-CIdx-ed9.js";
3
3
  import { DiscoveryArtifactValidationError, SMRT_APP_RESULT_CONTRACT, SMRT_APP_RESULT_SCHEMA, SMRT_APP_RESULT_VERSION, SMRT_DISCOVERY_CONFORMANCE_ARTIFACT_SCHEMA, SMRT_DISCOVERY_CONFORMANCE_SCHEMA, SMRT_DISCOVERY_CONFORMANCE_VERSION, SMRT_MCP_RESULT_METADATA_KEY, canonicalizeDiscoveryArtifact, createDiscoveryConformanceArtifact, deriveCommandRequirements, validateDiscoveryConformanceArtifact } from "./app-contract.js";
4
4
  import { ObjectRegistry, createClassNamePredicate, resolveCustomActionMetadata, resolveEffectiveActionMetadata } from "@happyvertical/smrt-core";
5
5
  import { createLogger } from "@happyvertical/logger";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@happyvertical/smrt-users",
3
- "version": "0.70.0",
3
+ "version": "0.70.1",
4
4
  "smrtJsdoc": "strict",
5
5
  "description": "Multi-tenant user management for the SMRT framework - users, tenants, roles, permissions, groups",
6
6
  "type": "module",
@@ -43,6 +43,10 @@
43
43
  "types": "./dist/postgres-settings.d.ts",
44
44
  "import": "./dist/postgres-settings.js"
45
45
  },
46
+ "./postgres-policies": {
47
+ "types": "./dist/postgres-policies.d.ts",
48
+ "import": "./dist/postgres-policies.js"
49
+ },
46
50
  "./step-up": {
47
51
  "types": "./dist/step-up.d.ts",
48
52
  "import": "./dist/step-up.js"
@@ -65,20 +69,20 @@
65
69
  "dependencies": {
66
70
  "@happyvertical/auth": "^0.116.6",
67
71
  "@happyvertical/logger": "^0.116.6",
68
- "@happyvertical/smrt-config": "0.70.0",
69
- "@happyvertical/smrt-core": "0.70.0",
70
- "@happyvertical/smrt-mobile-contract": "0.70.0",
71
- "@happyvertical/smrt-profiles": "0.70.0",
72
- "@happyvertical/smrt-tenancy": "0.70.0",
73
- "@happyvertical/smrt-types": "0.70.0",
74
- "@happyvertical/smrt-ui": "0.70.0",
72
+ "@happyvertical/smrt-config": "0.70.1",
73
+ "@happyvertical/smrt-core": "0.70.1",
74
+ "@happyvertical/smrt-mobile-contract": "0.70.1",
75
+ "@happyvertical/smrt-profiles": "0.70.1",
76
+ "@happyvertical/smrt-tenancy": "0.70.1",
77
+ "@happyvertical/smrt-types": "0.70.1",
78
+ "@happyvertical/smrt-ui": "0.70.1",
75
79
  "@happyvertical/sql": "^0.116.6",
76
80
  "@simplewebauthn/browser": "^14.0.0",
77
81
  "@simplewebauthn/server": "^14.0.3",
78
82
  "jose": "^6.2.12"
79
83
  },
80
84
  "devDependencies": {
81
- "@happyvertical/smrt-vitest": "0.70.0",
85
+ "@happyvertical/smrt-vitest": "0.70.1",
82
86
  "@sveltejs/package": "^2.5.8",
83
87
  "@sveltejs/vite-plugin-svelte": "^7.3.0",
84
88
  "@types/node": "24.13.6",