@astram/core 1.10.0 → 1.12.0

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.
Files changed (47) hide show
  1. package/dist/authentication/captcha.d.ts +58 -0
  2. package/dist/authentication/captcha.d.ts.map +1 -0
  3. package/dist/authentication/captcha.js +37 -0
  4. package/dist/authentication/captcha.js.map +1 -0
  5. package/dist/authentication/index.d.ts +3 -0
  6. package/dist/authentication/index.d.ts.map +1 -1
  7. package/dist/authentication/index.js +6 -0
  8. package/dist/authentication/index.js.map +1 -1
  9. package/dist/authentication/login-name.d.ts +22 -0
  10. package/dist/authentication/login-name.d.ts.map +1 -0
  11. package/dist/authentication/login-name.js +35 -0
  12. package/dist/authentication/login-name.js.map +1 -0
  13. package/dist/authentication/mfa-requirement.d.ts +156 -0
  14. package/dist/authentication/mfa-requirement.d.ts.map +1 -0
  15. package/dist/authentication/mfa-requirement.js +122 -0
  16. package/dist/authentication/mfa-requirement.js.map +1 -0
  17. package/dist/authorization/delegation/operation-identity.d.ts.map +1 -1
  18. package/dist/authorization/delegation/operation-identity.js +19 -1
  19. package/dist/authorization/delegation/operation-identity.js.map +1 -1
  20. package/dist/authorization/index.d.ts +1 -0
  21. package/dist/authorization/index.d.ts.map +1 -1
  22. package/dist/authorization/index.js +2 -0
  23. package/dist/authorization/index.js.map +1 -1
  24. package/dist/authorization/record/permit-tier.d.ts +4 -0
  25. package/dist/authorization/record/permit-tier.d.ts.map +1 -1
  26. package/dist/authorization/record/permit-tier.js +13 -0
  27. package/dist/authorization/record/permit-tier.js.map +1 -1
  28. package/dist/authorization/record/separation-of-duties.d.ts +45 -0
  29. package/dist/authorization/record/separation-of-duties.d.ts.map +1 -0
  30. package/dist/authorization/record/separation-of-duties.js +72 -0
  31. package/dist/authorization/record/separation-of-duties.js.map +1 -0
  32. package/dist/database/framework-tables.d.ts.map +1 -1
  33. package/dist/database/framework-tables.js +2 -0
  34. package/dist/database/framework-tables.js.map +1 -1
  35. package/dist/metadata/index.d.ts +11 -0
  36. package/dist/metadata/index.d.ts.map +1 -1
  37. package/dist/metadata/index.js.map +1 -1
  38. package/dist-cjs/authentication/captcha.js +40 -0
  39. package/dist-cjs/authentication/index.js +6 -0
  40. package/dist-cjs/authentication/login-name.js +39 -0
  41. package/dist-cjs/authentication/mfa-requirement.js +127 -0
  42. package/dist-cjs/authorization/delegation/operation-identity.js +18 -0
  43. package/dist-cjs/authorization/index.js +2 -0
  44. package/dist-cjs/authorization/record/permit-tier.js +13 -0
  45. package/dist-cjs/authorization/record/separation-of-duties.js +76 -0
  46. package/dist-cjs/database/framework-tables.js +2 -0
  47. package/package.json +1 -1
@@ -13,6 +13,10 @@
13
13
  * ── THE ONE COMPOSER (B's & C's DONE.md snippets were proven equivalent by a
14
14
  * reviewer; this is that single agreed composer):
15
15
  *
16
+ * 0. SEPARATION OF DUTIES (`evaluateSeparationOfDuties`), BEFORE the policy: a
17
+ * principal bound to the record for a declared action ⇒ `deny(explicit_deny_policy,
18
+ * 'separation_of_duties')`; unverifiable facts ⇒ `'separation_of_duties_unverified'`.
19
+ * Neither policy, baseline nor share is consulted.
16
20
  * 1. Evaluate the POLICY (TEAM B `evaluateRecordPolicy`).
17
21
  * 2. `policy.explicitDeny` ⇒ `deny(explicit_deny_policy)` — DENY-WINS, and it
18
22
  * SHORT-CIRCUITS *before* the share is ever consulted. A share can NEVER beat
@@ -1 +1 @@
1
- {"version":3,"file":"permit-tier.d.ts","sourceRoot":"","sources":["../../../src/authorization/record/permit-tier.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAEH,OAAO,KAAK,EAA4B,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAMzF,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,oCAAoC,CAAC;AAEtF;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,GAAE,2BAAgC,GAAG,cAAc,CAkChG"}
1
+ {"version":3,"file":"permit-tier.d.ts","sourceRoot":"","sources":["../../../src/authorization/record/permit-tier.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAEH,OAAO,KAAK,EAA4B,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAWzF,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,oCAAoC,CAAC;AAEtF;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,GAAE,2BAAgC,GAAG,cAAc,CA2ChG"}
@@ -13,6 +13,10 @@
13
13
  * ── THE ONE COMPOSER (B's & C's DONE.md snippets were proven equivalent by a
14
14
  * reviewer; this is that single agreed composer):
15
15
  *
16
+ * 0. SEPARATION OF DUTIES (`evaluateSeparationOfDuties`), BEFORE the policy: a
17
+ * principal bound to the record for a declared action ⇒ `deny(explicit_deny_policy,
18
+ * 'separation_of_duties')`; unverifiable facts ⇒ `'separation_of_duties_unverified'`.
19
+ * Neither policy, baseline nor share is consulted.
16
20
  * 1. Evaluate the POLICY (TEAM B `evaluateRecordPolicy`).
17
21
  * 2. `policy.explicitDeny` ⇒ `deny(explicit_deny_policy)` — DENY-WINS, and it
18
22
  * SHORT-CIRCUITS *before* the share is ever consulted. A share can NEVER beat
@@ -43,6 +47,7 @@
43
47
  import { gateAllow, gateDeny } from '../decision-authority.js';
44
48
  import { denyExplicitPolicy, denyNoRecordPermit } from '../reason-codes.js';
45
49
  import { evaluateRecordPolicy } from './rule-evaluator.js';
50
+ import { SEPARATION_OF_DUTIES_DENY_DETAIL, SEPARATION_OF_DUTIES_UNVERIFIED_DETAIL, evaluateSeparationOfDuties, } from './separation-of-duties.js';
46
51
  import { evaluateOwnerBaseline } from './owner-baseline.js';
47
52
  import { evaluateRecordShare } from './shares.js';
48
53
  /**
@@ -58,6 +63,14 @@ import { evaluateRecordShare } from './shares.js';
58
63
  */
59
64
  export function createRecordPermitGate(options = {}) {
60
65
  return async function recordPermit(ctx) {
66
+ // 0. SEPARATION OF DUTIES — before the policy; deny-only, fails closed when unverifiable.
67
+ const sod = evaluateSeparationOfDuties(ctx);
68
+ if (sod === 'bound_principal') {
69
+ return gateDeny(denyExplicitPolicy(SEPARATION_OF_DUTIES_DENY_DETAIL));
70
+ }
71
+ if (sod === 'unverified') {
72
+ return gateDeny(denyExplicitPolicy(SEPARATION_OF_DUTIES_UNVERIFIED_DETAIL));
73
+ }
61
74
  // 1. POLICY (TEAM B). Deny-wins is resolved inside `evaluateRecordPolicy` under
62
75
  // strict `=== true`; a transient throw PROPAGATES (not caught).
63
76
  const policy = await evaluateRecordPolicy(ctx);
@@ -1 +1 @@
1
- {"version":3,"file":"permit-tier.js","sourceRoot":"","sources":["../../../src/authorization/record/permit-tier.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAGH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAGlD;;;;;;;;;;GAUG;AACH,MAAM,UAAU,sBAAsB,CAAC,UAAuC,EAAE;IAC9E,OAAO,KAAK,UAAU,YAAY,CAAC,GAAgB;QACjD,gFAAgF;QAChF,mEAAmE;QACnE,MAAM,MAAM,GAAG,MAAM,oBAAoB,CAAC,GAAG,CAAC,CAAC;QAE/C,8EAA8E;QAC9E,wEAAwE;QACxE,IAAI,MAAM,CAAC,YAAY,EAAE,CAAC;YACxB,OAAO,QAAQ,CAAC,kBAAkB,EAAE,CAAC,CAAC;QACxC,CAAC;QAED,mFAAmF;QACnF,qFA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KAAK,iBAAiB,EAAE,CAAC;YAC9B,OAAO,QAAQ,CAAC,kBAAkB,CAAC,gCAAgC,CAAC,CAAC,CAAC;QACxE,CAAC;QACD,IAAI,GAAG,KAAK,YAAY,EAAE,CAAC;YACzB,OAAO,QAAQ,CAAC,kBAAkB,CAAC,sCAAsC,CAAC,CAAC,CAAC;QAC9E,CAAC;QAED,gFAAgF;QAChF,mEAAmE;QACnE,MAAM,MAAM,GAAG,MAAM,oBAAoB,CAAC,GAAG,CAAC,CAAC;QAE/C,8EAA8E;QAC9E,wEAAwE;QACxE,IAAI,MAAM,CAAC,YAAY,EAAE,CAAC;YACxB,OAAO,QAAQ,CAAC,kBAAkB,EAAE,CAAC,CAAC;QACxC,CAAC;QAED,mFAAmF;QACnF,qFAAqF;QACrF,sFAAsF;QACtF,mFAAmF;QACnF,mBAAmB;QACnB,MAAM,QAAQ,GAAG,qBAAqB,CAAC,GAAG,CAAC,CAAC;QAC5C,IAAI,MAAM,CAAC,KAAK,IAAI,QAAQ,EAAE,CAAC;YAC7B,OAAO,SAAS,EAAE,CAAC;QACrB,CAAC;QAED,qFAAqF;QACrF,oFAAoF;QACpF,iFAAiF;QACjF,8BAA8B;QAC9B,MAAM,KAAK,GAAG,MAAM,mBAAmB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QACtD,IAAI,KAAK,EAAE,CAAC;YACV,OAAO,SAAS,EAAE,CAAC;QACrB,CAAC;QAED,yEAAyE;QACzE,OAAO,QAAQ,CAAC,kBAAkB,EAAE,CAAC,CAAC;IACxC,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Separation of duties (SoD) evaluator for gate 6 — docs/features/separation-of-duties/SPEC.md
3
+ * (R4, R5, R7, D-4, D-7).
4
+ *
5
+ * A type declares `separationOfDuties: [{ actions: [...] }]`; the ENGINE supplies the facts
6
+ * (the record's `shield.separationOfDuties` attribute, `{ actorIds }`); gate 6 enforces,
7
+ * BEFORE the policy is consulted. A principal named in `actorIds` is denied a listed action;
8
+ * a declared action whose attribute is missing or malformed is unverifiable and fails closed.
9
+ *
10
+ * PURE + zero-dep (ADR-0003): reads only the resolved descriptor, the principal and
11
+ * `ctx.context.attributes`. Never throws on odd attribute shapes.
12
+ */
13
+ import type { GateContext } from '../decision-authority.js';
14
+ /** Decision-attribute key under which the engine supplies the SoD facts. */
15
+ export declare const SEPARATION_OF_DUTIES_ATTRIBUTE: "shield.separationOfDuties";
16
+ /** Deny detail when the principal is named in the record's facts. */
17
+ export declare const SEPARATION_OF_DUTIES_DENY_DETAIL: "separation_of_duties";
18
+ /** Deny detail when a bound action arrives without valid facts (fail closed). */
19
+ export declare const SEPARATION_OF_DUTIES_UNVERIFIED_DETAIL: "separation_of_duties_unverified";
20
+ /**
21
+ * Whether a decision is a separation-of-duties deny. Gate 7 (delegation) must never override
22
+ * one: a delegated operation is bound by the rule like any other principal (ADR-0048).
23
+ */
24
+ export declare function isSeparationOfDutiesDeny(decision: {
25
+ readonly effect: string;
26
+ readonly reason: string;
27
+ readonly detail?: string;
28
+ }): boolean;
29
+ /** Shape of the {@link SEPARATION_OF_DUTIES_ATTRIBUTE} value. */
30
+ export interface SeparationOfDutiesAttribute {
31
+ /** Ids of the principals who previously acted on the record (strict string equality). */
32
+ readonly actorIds: readonly string[];
33
+ }
34
+ /** Outcome of {@link evaluateSeparationOfDuties}. */
35
+ export type SeparationOfDutiesOutcome = 'unbound' | 'bound_principal' | 'unverified' | 'clear';
36
+ /**
37
+ * - `unbound`: the type does not declare SoD for this action (nothing to enforce).
38
+ * - `unverified`: declared, but the engine facts are absent or malformed (fail closed).
39
+ * - `bound_principal`: the principal appears in `actorIds` (deny).
40
+ * - `clear`: declared, verified, principal not named.
41
+ *
42
+ * A registry throw propagates, as in the other gate-6 evaluators.
43
+ */
44
+ export declare function evaluateSeparationOfDuties(ctx: GateContext): SeparationOfDutiesOutcome;
45
+ //# sourceMappingURL=separation-of-duties.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"separation-of-duties.d.ts","sourceRoot":"","sources":["../../../src/authorization/record/separation-of-duties.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAE5D,4EAA4E;AAC5E,eAAO,MAAM,8BAA8B,EAAG,2BAAoC,CAAC;AAEnF,qEAAqE;AACrE,eAAO,MAAM,gCAAgC,EAAG,sBAA+B,CAAC;AAEhF,iFAAiF;AACjF,eAAO,MAAM,sCAAsC,EAAG,iCAA0C,CAAC;AAEjG;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE;IACjD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B,GAAG,OAAO,CAOV;AAED,iEAAiE;AACjE,MAAM,WAAW,2BAA2B;IAC1C,yFAAyF;IACzF,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;CACtC;AAED,qDAAqD;AACrD,MAAM,MAAM,yBAAyB,GAAG,SAAS,GAAG,iBAAiB,GAAG,YAAY,GAAG,OAAO,CAAC;AAE/F;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CAAC,GAAG,EAAE,WAAW,GAAG,yBAAyB,CAgCtF"}
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Separation of duties (SoD) evaluator for gate 6 — docs/features/separation-of-duties/SPEC.md
3
+ * (R4, R5, R7, D-4, D-7).
4
+ *
5
+ * A type declares `separationOfDuties: [{ actions: [...] }]`; the ENGINE supplies the facts
6
+ * (the record's `shield.separationOfDuties` attribute, `{ actorIds }`); gate 6 enforces,
7
+ * BEFORE the policy is consulted. A principal named in `actorIds` is denied a listed action;
8
+ * a declared action whose attribute is missing or malformed is unverifiable and fails closed.
9
+ *
10
+ * PURE + zero-dep (ADR-0003): reads only the resolved descriptor, the principal and
11
+ * `ctx.context.attributes`. Never throws on odd attribute shapes.
12
+ */
13
+ /** Decision-attribute key under which the engine supplies the SoD facts. */
14
+ export const SEPARATION_OF_DUTIES_ATTRIBUTE = 'shield.separationOfDuties';
15
+ /** Deny detail when the principal is named in the record's facts. */
16
+ export const SEPARATION_OF_DUTIES_DENY_DETAIL = 'separation_of_duties';
17
+ /** Deny detail when a bound action arrives without valid facts (fail closed). */
18
+ export const SEPARATION_OF_DUTIES_UNVERIFIED_DETAIL = 'separation_of_duties_unverified';
19
+ /**
20
+ * Whether a decision is a separation-of-duties deny. Gate 7 (delegation) must never override
21
+ * one: a delegated operation is bound by the rule like any other principal (ADR-0048).
22
+ */
23
+ export function isSeparationOfDutiesDeny(decision) {
24
+ return (decision.effect === 'deny' &&
25
+ decision.reason === 'explicit_deny_policy' &&
26
+ (decision.detail === SEPARATION_OF_DUTIES_DENY_DETAIL ||
27
+ decision.detail === SEPARATION_OF_DUTIES_UNVERIFIED_DETAIL));
28
+ }
29
+ /**
30
+ * - `unbound`: the type does not declare SoD for this action (nothing to enforce).
31
+ * - `unverified`: declared, but the engine facts are absent or malformed (fail closed).
32
+ * - `bound_principal`: the principal appears in `actorIds` (deny).
33
+ * - `clear`: declared, verified, principal not named.
34
+ *
35
+ * A registry throw propagates, as in the other gate-6 evaluators.
36
+ */
37
+ export function evaluateSeparationOfDuties(ctx) {
38
+ const descriptor = ctx.deps.registry.resolveObjectType(ctx.resource.typeKey);
39
+ const declarations = descriptor?.separationOfDuties;
40
+ if (!Array.isArray(declarations))
41
+ return 'unbound';
42
+ const declared = declarations.some((d) => d !== null &&
43
+ typeof d === 'object' &&
44
+ Array.isArray(d.actions) &&
45
+ d.actions.includes(ctx.action.key));
46
+ if (!declared)
47
+ return 'unbound';
48
+ const attributes = ctx.context.attributes;
49
+ if (attributes === undefined || attributes === null)
50
+ return 'unverified';
51
+ if (!Object.prototype.hasOwnProperty.call(attributes, SEPARATION_OF_DUTIES_ATTRIBUTE)) {
52
+ return 'unverified';
53
+ }
54
+ const value = attributes[SEPARATION_OF_DUTIES_ATTRIBUTE];
55
+ if (value === null || typeof value !== 'object' || Array.isArray(value))
56
+ return 'unverified';
57
+ if (!Object.prototype.hasOwnProperty.call(value, 'actorIds'))
58
+ return 'unverified';
59
+ const actorIds = value.actorIds;
60
+ if (!Array.isArray(actorIds))
61
+ return 'unverified';
62
+ for (const id of actorIds) {
63
+ if (typeof id !== 'string')
64
+ return 'unverified';
65
+ }
66
+ const principalId = ctx.principal.id;
67
+ if (typeof principalId === 'string' && principalId.length > 0 && actorIds.includes(principalId)) {
68
+ return 'bound_principal';
69
+ }
70
+ return 'clear';
71
+ }
72
+ //# sourceMappingURL=separation-of-duties.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"separation-of-duties.js","sourceRoot":"","sources":["../../../src/authorization/record/separation-of-duties.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,4EAA4E;AAC5E,MAAM,CAAC,MAAM,8BAA8B,GAAG,2BAAoC,CAAC;AAEnF,qEAAqE;AACrE,MAAM,CAAC,MAAM,gCAAgC,GAAG,sBAA+B,CAAC;AAEhF,iFAAiF;AACjF,MAAM,CAAC,MAAM,sCAAsC,GAAG,iCAA0C,CAAC;AAEjG;;;GAGG;AACH,MAAM,UAAU,wBAAwB,CAAC,QAIxC;IACC,OAAO,CACL,QAAQ,CAAC,MAAM,KAAK,MAAM;QAC1B,QAAQ,CAAC,MAAM,KAAK,sBAAsB;QAC1C,CAAC,QAAQ,CAAC,MAAM,KAAK,gCAAgC;YACnD,QAAQ,CAAC,MAAM,KAAK,sCAAsC,CAAC,CAC9D,CAAC;AACJ,CAAC;AAWD;;;;;;;GAOG;AACH,MAAM,UAAU,0BAA0B,CAAC,GAAgB;IACzD,MAAM,UAAU,GAAG,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,iBAAiB,CAAC,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC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,KAAK,QAAQ;YAAE,OAAO,YAAY,CAAC;IAClD,CAAC;IAED,MAAM,WAAW,GAAG,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;IACrC,IAAI,OAAO,WAAW,KAAK,QAAQ,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,IAAI,QAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;QAChG,OAAO,iBAAiB,CAAC;IAC3B,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"framework-tables.d.ts","sourceRoot":"","sources":["../../src/database/framework-tables.ts"],"names":[],"mappings":"AASA,yGAAyG;AACzG,eAAO,MAAM,gBAAgB;;;;;EAqC3B,CAAC;AAEH,iCAAiC;AACjC,eAAO,MAAM,kBAAkB,EAAE,SAAS,MAAM,EAAmC,CAAC;AAIpF;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,MAAM,EACZ,WAAW,GAAE,MAAuC,GACnD,OAAO,CAGT"}
1
+ {"version":3,"file":"framework-tables.d.ts","sourceRoot":"","sources":["../../src/database/framework-tables.ts"],"names":[],"mappings":"AASA,yGAAyG;AACzG,eAAO,MAAM,gBAAgB;;;;;EAuC3B,CAAC;AAEH,iCAAiC;AACjC,eAAO,MAAM,kBAAkB,EAAE,SAAS,MAAM,EAAmC,CAAC;AAIpF;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,MAAM,EACZ,WAAW,GAAE,MAAuC,GACnD,OAAO,CAGT"}
@@ -21,6 +21,7 @@ export const FRAMEWORK_TABLES = Object.freeze({
21
21
  'shared_resource',
22
22
  'service_account',
23
23
  'stored_file',
24
+ 'security_policy',
24
25
  ]),
25
26
  identity: Object.freeze([
26
27
  'identity_credential',
@@ -30,6 +31,7 @@ export const FRAMEWORK_TABLES = Object.freeze({
30
31
  'password_reset_token',
31
32
  'mfa_recovery_code',
32
33
  'email_change_token',
34
+ 'mfa_requirement_state',
33
35
  ]),
34
36
  authz: Object.freeze([
35
37
  'permission',
@@ -1 +1 @@
1
- {"version":3,"file":"framework-tables.js","sourceRoot":"","sources":["../../src/database/framework-tables.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,8BAA8B,EAAE,MAAM,wBAAwB,CAAC;AAExE,yGAAyG;AACzG,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC;IAC5C,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC;QACjB,WAAW;QACX,OAAO;QACP,OAAO;QACP,aAAa;QACb,UAAU;QACV,oBAAoB;QACpB,oBAAoB;QACpB,qBAAqB;QACrB,kBAAkB;QAClB,iBAAiB;QACjB,iBAAiB;QACjB,aAAa;KACd,CAAC;IACF,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC;QACtB,qBAAqB;QACrB,SAAS;QACT,eAAe;QACf,YAAY;QACZ,sBAAsB;QACtB,mBAAmB;QACnB,oBAAoB;KACrB,CAAC;IACF,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC;QACnB,YAAY;QACZ,iBAAiB;QACjB,0BAA0B;QAC1B,eAAe;QACf,0BAA0B;QAC1B,wBAAwB;QACxB,cAAc;QACd,eAAe;QACf,qBAAqB;QACrB,oBAAoB;KACrB,CAAC;IACF,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,aAAa,EAAE,wBAAwB,CAAC,CAAC;CAC7E,CAAC,CAAC;AAEH,iCAAiC;AACjC,MAAM,CAAC,MAAM,kBAAkB,GAAsB,MAAM,CAAC,MAAM,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC;AAEpF,MAAM,QAAQ,GAAwB,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;AAEtF;;;;GAIG;AACH,MAAM,UAAU,wBAAwB,CACtC,IAAY,EACZ,cAAsB,8BAA8B;IAEpD,MAAM,CAAC,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;IAC7B,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,WAAW,CAAC,WAAW,EAAE,CAAC;AAC5D,CAAC"}
1
+ {"version":3,"file":"framework-tables.js","sourceRoot":"","sources":["../../src/database/framework-tables.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,8BAA8B,EAAE,MAAM,wBAAwB,CAAC;AAExE,yGAAyG;AACzG,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC;IAC5C,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC;QACjB,WAAW;QACX,OAAO;QACP,OAAO;QACP,aAAa;QACb,UAAU;QACV,oBAAoB;QACpB,oBAAoB;QACpB,qBAAqB;QACrB,kBAAkB;QAClB,iBAAiB;QACjB,iBAAiB;QACjB,aAAa;QACb,iBAAiB;KAClB,CAAC;IACF,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC;QACtB,qBAAqB;QACrB,SAAS;QACT,eAAe;QACf,YAAY;QACZ,sBAAsB;QACtB,mBAAmB;QACnB,oBAAoB;QACpB,uBAAuB;KACxB,CAAC;IACF,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC;QACnB,YAAY;QACZ,iBAAiB;QACjB,0BAA0B;QAC1B,eAAe;QACf,0BAA0B;QAC1B,wBAAwB;QACxB,cAAc;QACd,eAAe;QACf,qBAAqB;QACrB,oBAAoB;KACrB,CAAC;IACF,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,aAAa,EAAE,wBAAwB,CAAC,CAAC;CAC7E,CAAC,CAAC;AAEH,iCAAiC;AACjC,MAAM,CAAC,MAAM,kBAAkB,GAAsB,MAAM,CAAC,MAAM,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC;AAEpF,MAAM,QAAQ,GAAwB,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;AAEtF;;;;GAIG;AACH,MAAM,UAAU,wBAAwB,CACtC,IAAY,EACZ,cAAsB,8BAA8B;IAEpD,MAAM,CAAC,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;IAC7B,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,WAAW,CAAC,WAAW,EAAE,CAAC;AAC5D,CAAC"}
@@ -66,6 +66,17 @@ export interface ObjectTypeDescriptor {
66
66
  * type (fail-closed — a rule/share must permit; the baseline never owner/system-allows).
67
67
  */
68
68
  readonly access?: RecordAccessPosture;
69
+ /**
70
+ * OPTIONAL separation-of-duties declarations (docs/features/separation-of-duties).
71
+ * Declared on the type in code; the engine supplies the facts (the record's
72
+ * `shield.separationOfDuties` attribute) and gate 6 enforces: a principal named there is
73
+ * denied the listed actions. Never `read`/`create` (validated by the engine). Absent ⇒ none.
74
+ */
75
+ readonly separationOfDuties?: readonly SeparationOfDutiesDeclaration[];
76
+ }
77
+ /** One separation-of-duties declaration: actions barred to principals already bound to the record. */
78
+ export interface SeparationOfDutiesDeclaration {
79
+ readonly actions: readonly string[];
69
80
  }
70
81
  /**
71
82
  * A supporting read-only dependency (§5.3): a subordinate lookup auto-permitted
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/metadata/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAGL,KAAK,UAAU,EACf,KAAK,aAAa,EACnB,MAAM,2BAA2B,CAAC;AAGnC,cAAc,mBAAmB,CAAC;AAKlC,cAAc,eAAe,CAAC;AAK9B,cAAc,mBAAmB,CAAC;AAElC,8EAA8E;AAC9E,MAAM,WAAW,eAAe;IAC9B,iEAAiE;IACjE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB;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AQ,CAAC,aAAa,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IACpD,CAAC;IACD,IAAI,KAAmC,CAAC;IACxC,KAAK,MAAM,CAAC,IAAI,QAAQ,CAAC,WAAW,EAAE,EAAE,CAAC;QACvC,IAAI,CAAC,CAAC,MAAM,CAAC,OAAO,KAAK,OAAO,IAAI,CAAC,CAAC,MAAM,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;YACrE,IAAI,KAAK,KAAK,SAAS;gBAAE,OAAO,SAAS,CAAC,CAAC,0BAA0B;YACrE,KAAK,GAAG,CAAC,CAAC;QACZ,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ /**
3
+ * CAPTCHA verification port (auth capabilities R7.1, R7.4, R7.5; G-017).
4
+ *
5
+ * Core names the contract only; the Turnstile and reCAPTCHA adapters live in `@astram/guard`
6
+ * (D-4: `fetch`, no new dependency). A verifier checks one client token with the provider and
7
+ * answers one of three outcomes:
8
+ * - passed: the provider accepted the token AND its hostname is expected, its action matches the
9
+ * endpoint and (reCAPTCHA v3) its score reaches the minimum;
10
+ * - rejected (`reason`): the token is missing, invalid, from another hostname, for another action,
11
+ * below the score, or already used (`timeout-or-duplicate`);
12
+ * - unavailable: the provider could not answer (network error, timeout, 5xx, unreadable body).
13
+ * This is NOT a rejection: the caller applies its fail mode (closed by default, R7.5).
14
+ *
15
+ * A verifier never logs or returns the secret or the token.
16
+ *
17
+ * ADR-0003: framework-agnostic, no I/O here.
18
+ */
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.CAPTCHA_FAILURE_REASONS = exports.CAPTCHA_PROVIDERS = void 0;
21
+ exports.isCaptchaUnavailable = isCaptchaUnavailable;
22
+ /** The CAPTCHA providers the framework ships adapters for (`CAPTCHA_PROVIDER`). */
23
+ exports.CAPTCHA_PROVIDERS = Object.freeze([
24
+ 'turnstile',
25
+ 'recaptcha-v3',
26
+ 'recaptcha-v2',
27
+ ]);
28
+ /** Why a token was rejected. Never carries provider text. */
29
+ exports.CAPTCHA_FAILURE_REASONS = Object.freeze([
30
+ 'invalid',
31
+ 'hostname',
32
+ 'action',
33
+ 'score',
34
+ 'reused',
35
+ 'missing',
36
+ ]);
37
+ /** True for the provider-outage outcome. */
38
+ function isCaptchaUnavailable(result) {
39
+ return result.ok === false && result.reason === 'unavailable';
40
+ }
@@ -42,3 +42,9 @@ __exportStar(require("./totp.js"), exports);
42
42
  __exportStar(require("./authenticator.js"), exports);
43
43
  // Service-account API-key authentication (ADR-0033) — the machine/agent/MCP auth path:
44
44
  __exportStar(require("./service-account-authenticator.js"), exports);
45
+ // Login name (sign-in handle) rule: normalise + validate (auth capabilities R1.3, B-4):
46
+ __exportStar(require("./login-name.js"), exports);
47
+ // Mandatory 2FA requirement rule + `MfaRequirementSource` port (auth capabilities R2, B-1, B-2):
48
+ __exportStar(require("./mfa-requirement.js"), exports);
49
+ // CAPTCHA verifier port (auth capabilities R7.1; adapters live in guard, D-4):
50
+ __exportStar(require("./captcha.js"), exports);
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ /**
3
+ * Login name (the sign-in handle, `users.u_login_name`; auth capabilities R1.3, B-4).
4
+ *
5
+ * One rule shared by guard (login lookup), identity (admin create/update) and `bootstrap:org`:
6
+ * `[a-z0-9._-]`, 3–64 characters, stored lower-case. ASCII input is trimmed and lower-cased,
7
+ * nothing else. Input holding any non-ASCII character is returned as typed (not trimmed, not
8
+ * lower-cased) and so is never valid: the check runs BEFORE lower-casing, because Unicode case
9
+ * mapping can land on ASCII (KELVIN SIGN U+212A lower-cases to `k`). A valid login name never
10
+ * contains `@`, so it can never equal an email address.
11
+ *
12
+ * ADR-0003: framework-agnostic, no I/O.
13
+ */
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.normalizeLoginName = normalizeLoginName;
16
+ exports.isValidLoginName = isValidLoginName;
17
+ exports.looksLikeEmail = looksLikeEmail;
18
+ /** The stored form: lower-case `[a-z0-9._-]`, 3–64 characters (never `@`). */
19
+ const LOGIN_NAME_PATTERN = /^[a-z0-9._-]{3,64}$/;
20
+ /** Any character outside 7-bit ASCII (astral characters are surrogate pairs, in range). */
21
+ const NON_ASCII = /[\u0080-\uffff]/;
22
+ /**
23
+ * Trim and lower-case typed ASCII input; no other transformation. Non-ASCII input comes back
24
+ * unchanged, so `isValidLoginName(normalizeLoginName(x))` is false for it.
25
+ */
26
+ function normalizeLoginName(input) {
27
+ const typed = String(input);
28
+ if (NON_ASCII.test(typed))
29
+ return typed;
30
+ return typed.trim().toLowerCase();
31
+ }
32
+ /** True when `value` (already normalized) is an allowed login name. Never throws. */
33
+ function isValidLoginName(value) {
34
+ return typeof value === 'string' && LOGIN_NAME_PATTERN.test(value);
35
+ }
36
+ /** True when a typed sign-in hint is an email form (contains `@`); otherwise it may be a handle. */
37
+ function looksLikeEmail(hint) {
38
+ return typeof hint === 'string' && hint.includes('@');
39
+ }
@@ -0,0 +1,127 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MFA_REQUIREMENT_FACTORS = exports.MS_PER_DAY = exports.MAX_MFA_GRACE_DAYS = exports.SECURITY_POLICY_TARGET_KINDS = void 0;
4
+ exports.permissionKeysOverlap = permissionKeysOverlap;
5
+ exports.isSecurityPolicyPermissionTarget = isSecurityPolicyPermissionTarget;
6
+ exports.evaluateMfaRequirement = evaluateMfaRequirement;
7
+ /** The target kinds, in their stable order. */
8
+ exports.SECURITY_POLICY_TARGET_KINDS = Object.freeze([
9
+ 'tenant',
10
+ 'role',
11
+ 'permission',
12
+ ]);
13
+ /** Longest grace a policy may give (R2.4). */
14
+ exports.MAX_MFA_GRACE_DAYS = 14;
15
+ /** One day in milliseconds (grace days → deadline). */
16
+ exports.MS_PER_DAY = 24 * 60 * 60 * 1000;
17
+ /**
18
+ * Factors that satisfy a mandatory-2FA policy (R2.8): TOTP today; passkey and email code join when
19
+ * they ship. Recovery codes never satisfy enrolment.
20
+ */
21
+ exports.MFA_REQUIREMENT_FACTORS = Object.freeze(['totp']);
22
+ /** The prefix a wildcard key covers (`identity:*` and bare `identity` → `identity:`), else null. */
23
+ function wildcardPrefix(key) {
24
+ if (key.endsWith(':*'))
25
+ return key.slice(0, -1);
26
+ if (!key.includes(':'))
27
+ return `${key}:`;
28
+ return null;
29
+ }
30
+ /**
31
+ * Whether two permission keys overlap under the grant wildcard forms (`module`, `module:*`,
32
+ * `module:type:*`), in either direction: exact = exact, a wildcard covers keys under its prefix,
33
+ * two wildcards overlap when one prefix contains the other. Empty or `*` keys match nothing.
34
+ */
35
+ function permissionKeysOverlap(a, b) {
36
+ if (typeof a !== 'string' || typeof b !== 'string')
37
+ return false;
38
+ if (a === '' || b === '' || a === '*' || b === '*')
39
+ return false;
40
+ const pa = wildcardPrefix(a);
41
+ const pb = wildcardPrefix(b);
42
+ if (pa === null && pb === null)
43
+ return a === b;
44
+ if (pa !== null && pb === null)
45
+ return b.startsWith(pa);
46
+ if (pa === null && pb !== null)
47
+ return a.startsWith(pb);
48
+ return pa.startsWith(pb) || pb.startsWith(pa);
49
+ }
50
+ const SEGMENT = '[a-z][a-z0-9_]*';
51
+ const PERMISSION_TARGET = new RegExp(`^${SEGMENT}(?::\\*|:${SEGMENT}:\\*|:${SEGMENT}:${SEGMENT})?$`);
52
+ /**
53
+ * True when `key` may be named by a `permission` policy: an exact `module:type:action` key or a
54
+ * grant wildcard (`module`, `module:*`, `module:type:*`), segments `^[a-z][a-z0-9_]*$`, at most 255
55
+ * characters (the column width).
56
+ */
57
+ function isSecurityPolicyPermissionTarget(key) {
58
+ return typeof key === 'string' && key.length <= 255 && PERMISSION_TARGET.test(key);
59
+ }
60
+ function graceOf(p) {
61
+ const g = p.graceDays;
62
+ return typeof g === 'number' && Number.isInteger(g) && g >= 0 && g <= exports.MAX_MFA_GRACE_DAYS ? g : 0;
63
+ }
64
+ function strings(xs) {
65
+ return Array.isArray(xs) ? xs.filter((x) => typeof x === 'string') : [];
66
+ }
67
+ function applies(p, subject, nodes) {
68
+ const platform = p.platform === true;
69
+ if (subject.isRoot === true && !platform)
70
+ return false; // D-11
71
+ if (!platform) {
72
+ if (typeof p.scopeNodeId !== 'string' || !nodes.has(p.scopeNodeId))
73
+ return false;
74
+ }
75
+ switch (p.kind) {
76
+ case 'tenant':
77
+ return true;
78
+ case 'role':
79
+ return (typeof p.target === 'string' &&
80
+ p.target !== '' &&
81
+ strings(subject.roleIds).includes(p.target));
82
+ case 'permission':
83
+ return (typeof p.target === 'string' &&
84
+ strings(subject.permissionKeys).some((k) => permissionKeysOverlap(p.target, k)));
85
+ default:
86
+ // An unknown kind is never silently ignored: it applies to its scope (fail closed).
87
+ return true;
88
+ }
89
+ }
90
+ /** Evaluate the mandatory-2FA requirement for one principal at one instant (see file header). */
91
+ function evaluateMfaRequirement(input) {
92
+ const { subject, nowMs } = input;
93
+ const nodes = new Set(strings(subject.nodeIds));
94
+ const applying = (Array.isArray(input.policies) ? input.policies : []).filter((p) => applies(p, subject, nodes));
95
+ const applied = Object.freeze({
96
+ kinds: Object.freeze([...new Set(applying.map((p) => p.kind))].sort()),
97
+ platformFloor: applying.some((p) => p.platform === true),
98
+ policyIds: Object.freeze([
99
+ ...new Set(applying.map((p) => p.id).filter((id) => typeof id === 'string')),
100
+ ].sort()),
101
+ });
102
+ const stored = typeof input.requiredSinceMs === 'number' &&
103
+ Number.isFinite(input.requiredSinceMs) &&
104
+ input.requiredSinceMs >= 0
105
+ ? input.requiredSinceMs
106
+ : null;
107
+ const hadClock = input.requiredSinceMs !== null && input.requiredSinceMs !== undefined;
108
+ if (applying.length === 0) {
109
+ // Review round 1, item E: "no policy at the current node" never clears the clock (only
110
+ // enrolment does), so switching scope away and back cannot restart a grace period.
111
+ return Object.freeze({ status: 'not_required', clock: hadClock ? 'keep' : 'none', applied });
112
+ }
113
+ if (input.hasConfirmedFactor === true) {
114
+ return Object.freeze({ status: 'enrolled', clock: hadClock ? 'clear' : 'none', applied });
115
+ }
116
+ // A stored clock in the future (clock skew) cannot push the deadline out: it restarts at now,
117
+ // and `setRequiredSince` keeps the earlier of the two values.
118
+ const usable = stored !== null && stored <= nowMs;
119
+ const clock = usable ? 'keep' : 'start';
120
+ const requiredSinceMs = usable ? stored : nowMs;
121
+ const grace = Math.min(...applying.map(graceOf));
122
+ const deadlineMs = requiredSinceMs + grace * exports.MS_PER_DAY;
123
+ if (nowMs < deadlineMs) {
124
+ return Object.freeze({ status: 'grace', requiredSinceMs, deadlineMs, clock, applied });
125
+ }
126
+ return Object.freeze({ status: 'required', requiredSinceMs, clock, applied });
127
+ }
@@ -66,6 +66,7 @@ exports.isActionInScope = isActionInScope;
66
66
  exports.createDelegationOverlay = createDelegationOverlay;
67
67
  const decision_authority_js_1 = require("../decision-authority.js");
68
68
  const reason_codes_js_1 = require("../reason-codes.js");
69
+ const separation_of_duties_js_1 = require("../record/separation-of-duties.js");
69
70
  /**
70
71
  * The FROZEN `DecisionContext.attributes` bag key under which the enforcement
71
72
  * adapter marks a decision as a DELEGATED internal step and names its operation +
@@ -141,11 +142,16 @@ function isActionInScope(authority, actionKey) {
141
142
  * Note: `explicit_deny_policy` (a deny-wins record-rule deny) IS a permission-tier
142
143
  * deny and MAY be overridden by a valid in-scope delegated authority — the operation
143
144
  * acts under its OWN identity, for which the caller-scoped rule deny is irrelevant.
145
+ * EXCEPT a separation-of-duties deny (G-025, ADR-0048): it binds the principal, delegated
146
+ * or not, so it is never overridable.
144
147
  */
145
148
  function isOverridablePermissionDeny(baseline) {
146
149
  if (baseline.effect !== 'deny') {
147
150
  return false;
148
151
  }
152
+ if ((0, separation_of_duties_js_1.isSeparationOfDutiesDeny)(baseline)) {
153
+ return false;
154
+ }
149
155
  switch (baseline.reason) {
150
156
  case 'tenant_mismatch':
151
157
  case 'resource_not_registered':
@@ -213,6 +219,18 @@ function createDelegationOverlay(_options = {}) {
213
219
  !isActionInScope(authority, ctx.action.key)) {
214
220
  return (0, decision_authority_js_1.gateDeny)((0, reason_codes_js_1.denyMissingObjectTypeGrant)());
215
221
  }
222
+ // (4b) SEPARATION OF DUTIES (G-025, ADR-0048). A delegated step is bound like any other
223
+ // principal. When gate 5 denied (no grant), gate 6 never ran, so the rule is checked here
224
+ // before the override; the same evaluator, so the outcome equals gate 6's.
225
+ if (ctx.resource.level === 'record') {
226
+ const sod = (0, separation_of_duties_js_1.evaluateSeparationOfDuties)(ctx);
227
+ if (sod === 'bound_principal') {
228
+ return (0, decision_authority_js_1.gateDeny)((0, reason_codes_js_1.denyExplicitPolicy)(separation_of_duties_js_1.SEPARATION_OF_DUTIES_DENY_DETAIL));
229
+ }
230
+ if (sod === 'unverified') {
231
+ return (0, decision_authority_js_1.gateDeny)((0, reason_codes_js_1.denyExplicitPolicy)(separation_of_duties_js_1.SEPARATION_OF_DUTIES_UNVERIFIED_DETAIL));
232
+ }
233
+ }
216
234
  // (5) In-scope AND tenant OK. The step runs under the OPERATION's own declared,
217
235
  // scoped, least-privilege authority — overriding the caller's permission-deny
218
236
  // baseline. (The "on behalf of" audit — §10.5 — is the enforcement adapter's job,
@@ -130,6 +130,8 @@ __exportStar(require("./delegation/operation-identity.js"), exports);
130
130
  __exportStar(require("./record/owner-baseline.js"), exports);
131
131
  // - INTEGRATION: the composed gate-6 record permit tier (baseline ∪ policy ∪ share, deny-wins):
132
132
  __exportStar(require("./record/permit-tier.js"), exports);
133
+ // - SEPARATION OF DUTIES: attribute name + pure evaluator (gate 6 step 0):
134
+ __exportStar(require("./record/separation-of-duties.js"), exports);
133
135
  // - LIST SCOPE: the decision-derived visible-set spec — sibling to decide() (Phase 1):
134
136
  __exportStar(require("./record/list-scope.js"), exports);
135
137
  // - INTEGRATION: the production gate-set wiring + fully-wired DecisionAuthority factory:
@@ -14,6 +14,10 @@
14
14
  * ── THE ONE COMPOSER (B's & C's DONE.md snippets were proven equivalent by a
15
15
  * reviewer; this is that single agreed composer):
16
16
  *
17
+ * 0. SEPARATION OF DUTIES (`evaluateSeparationOfDuties`), BEFORE the policy: a
18
+ * principal bound to the record for a declared action ⇒ `deny(explicit_deny_policy,
19
+ * 'separation_of_duties')`; unverifiable facts ⇒ `'separation_of_duties_unverified'`.
20
+ * Neither policy, baseline nor share is consulted.
17
21
  * 1. Evaluate the POLICY (TEAM B `evaluateRecordPolicy`).
18
22
  * 2. `policy.explicitDeny` ⇒ `deny(explicit_deny_policy)` — DENY-WINS, and it
19
23
  * SHORT-CIRCUITS *before* the share is ever consulted. A share can NEVER beat
@@ -46,6 +50,7 @@ exports.createRecordPermitGate = createRecordPermitGate;
46
50
  const decision_authority_js_1 = require("../decision-authority.js");
47
51
  const reason_codes_js_1 = require("../reason-codes.js");
48
52
  const rule_evaluator_js_1 = require("./rule-evaluator.js");
53
+ const separation_of_duties_js_1 = require("./separation-of-duties.js");
49
54
  const owner_baseline_js_1 = require("./owner-baseline.js");
50
55
  const shares_js_1 = require("./shares.js");
51
56
  /**
@@ -61,6 +66,14 @@ const shares_js_1 = require("./shares.js");
61
66
  */
62
67
  function createRecordPermitGate(options = {}) {
63
68
  return async function recordPermit(ctx) {
69
+ // 0. SEPARATION OF DUTIES — before the policy; deny-only, fails closed when unverifiable.
70
+ const sod = (0, separation_of_duties_js_1.evaluateSeparationOfDuties)(ctx);
71
+ if (sod === 'bound_principal') {
72
+ return (0, decision_authority_js_1.gateDeny)((0, reason_codes_js_1.denyExplicitPolicy)(separation_of_duties_js_1.SEPARATION_OF_DUTIES_DENY_DETAIL));
73
+ }
74
+ if (sod === 'unverified') {
75
+ return (0, decision_authority_js_1.gateDeny)((0, reason_codes_js_1.denyExplicitPolicy)(separation_of_duties_js_1.SEPARATION_OF_DUTIES_UNVERIFIED_DETAIL));
76
+ }
64
77
  // 1. POLICY (TEAM B). Deny-wins is resolved inside `evaluateRecordPolicy` under
65
78
  // strict `=== true`; a transient throw PROPAGATES (not caught).
66
79
  const policy = await (0, rule_evaluator_js_1.evaluateRecordPolicy)(ctx);