@astram/core 0.1.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 (259) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +47 -0
  3. package/dist/admin/admin-service.d.ts +221 -0
  4. package/dist/admin/admin-service.d.ts.map +1 -0
  5. package/dist/admin/admin-service.js +155 -0
  6. package/dist/admin/admin-service.js.map +1 -0
  7. package/dist/admin/command/grants.d.ts +40 -0
  8. package/dist/admin/command/grants.d.ts.map +1 -0
  9. package/dist/admin/command/grants.js +196 -0
  10. package/dist/admin/command/grants.js.map +1 -0
  11. package/dist/admin/command/index.d.ts +23 -0
  12. package/dist/admin/command/index.d.ts.map +1 -0
  13. package/dist/admin/command/index.js +23 -0
  14. package/dist/admin/command/index.js.map +1 -0
  15. package/dist/admin/command/invitations.d.ts +72 -0
  16. package/dist/admin/command/invitations.d.ts.map +1 -0
  17. package/dist/admin/command/invitations.js +241 -0
  18. package/dist/admin/command/invitations.js.map +1 -0
  19. package/dist/admin/command/permissions.d.ts +33 -0
  20. package/dist/admin/command/permissions.d.ts.map +1 -0
  21. package/dist/admin/command/permissions.js +67 -0
  22. package/dist/admin/command/permissions.js.map +1 -0
  23. package/dist/admin/command/pipeline.d.ts +79 -0
  24. package/dist/admin/command/pipeline.d.ts.map +1 -0
  25. package/dist/admin/command/pipeline.js +106 -0
  26. package/dist/admin/command/pipeline.js.map +1 -0
  27. package/dist/admin/command/policies.d.ts +50 -0
  28. package/dist/admin/command/policies.d.ts.map +1 -0
  29. package/dist/admin/command/policies.js +219 -0
  30. package/dist/admin/command/policies.js.map +1 -0
  31. package/dist/admin/command/service-accounts.d.ts +58 -0
  32. package/dist/admin/command/service-accounts.d.ts.map +1 -0
  33. package/dist/admin/command/service-accounts.js +272 -0
  34. package/dist/admin/command/service-accounts.js.map +1 -0
  35. package/dist/admin/command/service.d.ts +65 -0
  36. package/dist/admin/command/service.d.ts.map +1 -0
  37. package/dist/admin/command/service.js +128 -0
  38. package/dist/admin/command/service.js.map +1 -0
  39. package/dist/admin/command/tiers.d.ts +40 -0
  40. package/dist/admin/command/tiers.d.ts.map +1 -0
  41. package/dist/admin/command/tiers.js +79 -0
  42. package/dist/admin/command/tiers.js.map +1 -0
  43. package/dist/admin/index.d.ts +36 -0
  44. package/dist/admin/index.d.ts.map +1 -0
  45. package/dist/admin/index.js +63 -0
  46. package/dist/admin/index.js.map +1 -0
  47. package/dist/admin/ports.d.ts +288 -0
  48. package/dist/admin/ports.d.ts.map +1 -0
  49. package/dist/admin/ports.js +39 -0
  50. package/dist/admin/ports.js.map +1 -0
  51. package/dist/admin/query/audit-view.d.ts +52 -0
  52. package/dist/admin/query/audit-view.d.ts.map +1 -0
  53. package/dist/admin/query/audit-view.js +84 -0
  54. package/dist/admin/query/audit-view.js.map +1 -0
  55. package/dist/admin/query/catalog.d.ts +70 -0
  56. package/dist/admin/query/catalog.d.ts.map +1 -0
  57. package/dist/admin/query/catalog.js +169 -0
  58. package/dist/admin/query/catalog.js.map +1 -0
  59. package/dist/admin/query/explain.d.ts +52 -0
  60. package/dist/admin/query/explain.d.ts.map +1 -0
  61. package/dist/admin/query/explain.js +145 -0
  62. package/dist/admin/query/explain.js.map +1 -0
  63. package/dist/admin/query/index.d.ts +45 -0
  64. package/dist/admin/query/index.d.ts.map +1 -0
  65. package/dist/admin/query/index.js +58 -0
  66. package/dist/admin/query/index.js.map +1 -0
  67. package/dist/admin/query/simulate.d.ts +42 -0
  68. package/dist/admin/query/simulate.d.ts.map +1 -0
  69. package/dist/admin/query/simulate.js +91 -0
  70. package/dist/admin/query/simulate.js.map +1 -0
  71. package/dist/admin/safeguards-impl.d.ts +67 -0
  72. package/dist/admin/safeguards-impl.d.ts.map +1 -0
  73. package/dist/admin/safeguards-impl.js +318 -0
  74. package/dist/admin/safeguards-impl.js.map +1 -0
  75. package/dist/admin/safeguards.d.ts +89 -0
  76. package/dist/admin/safeguards.d.ts.map +1 -0
  77. package/dist/admin/safeguards.js +91 -0
  78. package/dist/admin/safeguards.js.map +1 -0
  79. package/dist/admin/types.d.ts +485 -0
  80. package/dist/admin/types.d.ts.map +1 -0
  81. package/dist/admin/types.js +38 -0
  82. package/dist/admin/types.js.map +1 -0
  83. package/dist/audit/audit-recorder.d.ts +129 -0
  84. package/dist/audit/audit-recorder.d.ts.map +1 -0
  85. package/dist/audit/audit-recorder.js +265 -0
  86. package/dist/audit/audit-recorder.js.map +1 -0
  87. package/dist/audit/canonicalize.d.ts +38 -0
  88. package/dist/audit/canonicalize.d.ts.map +1 -0
  89. package/dist/audit/canonicalize.js +174 -0
  90. package/dist/audit/canonicalize.js.map +1 -0
  91. package/dist/audit/errors.d.ts +56 -0
  92. package/dist/audit/errors.d.ts.map +1 -0
  93. package/dist/audit/errors.js +41 -0
  94. package/dist/audit/errors.js.map +1 -0
  95. package/dist/audit/index.d.ts +45 -0
  96. package/dist/audit/index.d.ts.map +1 -0
  97. package/dist/audit/index.js +24 -0
  98. package/dist/audit/index.js.map +1 -0
  99. package/dist/audit/ports.d.ts +131 -0
  100. package/dist/audit/ports.d.ts.map +1 -0
  101. package/dist/audit/ports.js +27 -0
  102. package/dist/audit/ports.js.map +1 -0
  103. package/dist/audit/sensitive.d.ts +68 -0
  104. package/dist/audit/sensitive.d.ts.map +1 -0
  105. package/dist/audit/sensitive.js +159 -0
  106. package/dist/audit/sensitive.js.map +1 -0
  107. package/dist/audit/walk.d.ts +109 -0
  108. package/dist/audit/walk.d.ts.map +1 -0
  109. package/dist/audit/walk.js +117 -0
  110. package/dist/audit/walk.js.map +1 -0
  111. package/dist/authentication/authenticator.d.ts +74 -0
  112. package/dist/authentication/authenticator.d.ts.map +1 -0
  113. package/dist/authentication/authenticator.js +208 -0
  114. package/dist/authentication/authenticator.js.map +1 -0
  115. package/dist/authentication/credential-resolver.d.ts +76 -0
  116. package/dist/authentication/credential-resolver.d.ts.map +1 -0
  117. package/dist/authentication/credential-resolver.js +21 -0
  118. package/dist/authentication/credential-resolver.js.map +1 -0
  119. package/dist/authentication/index.d.ts +52 -0
  120. package/dist/authentication/index.d.ts.map +1 -0
  121. package/dist/authentication/index.js +27 -0
  122. package/dist/authentication/index.js.map +1 -0
  123. package/dist/authentication/password-hasher.d.ts +41 -0
  124. package/dist/authentication/password-hasher.d.ts.map +1 -0
  125. package/dist/authentication/password-hasher.js +21 -0
  126. package/dist/authentication/password-hasher.js.map +1 -0
  127. package/dist/authentication/totp.d.ts +101 -0
  128. package/dist/authentication/totp.d.ts.map +1 -0
  129. package/dist/authentication/totp.js +151 -0
  130. package/dist/authentication/totp.js.map +1 -0
  131. package/dist/authorization/cross-tenant/grant-evaluator.d.ts +90 -0
  132. package/dist/authorization/cross-tenant/grant-evaluator.d.ts.map +1 -0
  133. package/dist/authorization/cross-tenant/grant-evaluator.js +165 -0
  134. package/dist/authorization/cross-tenant/grant-evaluator.js.map +1 -0
  135. package/dist/authorization/decision-authority.d.ts +212 -0
  136. package/dist/authorization/decision-authority.d.ts.map +1 -0
  137. package/dist/authorization/decision-authority.js +200 -0
  138. package/dist/authorization/decision-authority.js.map +1 -0
  139. package/dist/authorization/default-gates.d.ts +41 -0
  140. package/dist/authorization/default-gates.d.ts.map +1 -0
  141. package/dist/authorization/default-gates.js +47 -0
  142. package/dist/authorization/default-gates.js.map +1 -0
  143. package/dist/authorization/delegation/operation-identity.d.ts +132 -0
  144. package/dist/authorization/delegation/operation-identity.d.ts.map +1 -0
  145. package/dist/authorization/delegation/operation-identity.js +220 -0
  146. package/dist/authorization/delegation/operation-identity.js.map +1 -0
  147. package/dist/authorization/errors.d.ts +54 -0
  148. package/dist/authorization/errors.d.ts.map +1 -0
  149. package/dist/authorization/errors.js +63 -0
  150. package/dist/authorization/errors.js.map +1 -0
  151. package/dist/authorization/gates/object-type.d.ts +63 -0
  152. package/dist/authorization/gates/object-type.d.ts.map +1 -0
  153. package/dist/authorization/gates/object-type.js +177 -0
  154. package/dist/authorization/gates/object-type.js.map +1 -0
  155. package/dist/authorization/gates/tenant.d.ts +50 -0
  156. package/dist/authorization/gates/tenant.d.ts.map +1 -0
  157. package/dist/authorization/gates/tenant.js +87 -0
  158. package/dist/authorization/gates/tenant.js.map +1 -0
  159. package/dist/authorization/gates/wiring.d.ts +57 -0
  160. package/dist/authorization/gates/wiring.d.ts.map +1 -0
  161. package/dist/authorization/gates/wiring.js +56 -0
  162. package/dist/authorization/gates/wiring.js.map +1 -0
  163. package/dist/authorization/index.d.ts +136 -0
  164. package/dist/authorization/index.d.ts.map +1 -0
  165. package/dist/authorization/index.js +82 -0
  166. package/dist/authorization/index.js.map +1 -0
  167. package/dist/authorization/ports.d.ts +271 -0
  168. package/dist/authorization/ports.d.ts.map +1 -0
  169. package/dist/authorization/ports.js +36 -0
  170. package/dist/authorization/ports.js.map +1 -0
  171. package/dist/authorization/reason-codes.d.ts +75 -0
  172. package/dist/authorization/reason-codes.d.ts.map +1 -0
  173. package/dist/authorization/reason-codes.js +98 -0
  174. package/dist/authorization/reason-codes.js.map +1 -0
  175. package/dist/authorization/record/permit-tier.d.ts +57 -0
  176. package/dist/authorization/record/permit-tier.d.ts.map +1 -0
  177. package/dist/authorization/record/permit-tier.js +79 -0
  178. package/dist/authorization/record/permit-tier.js.map +1 -0
  179. package/dist/authorization/record/rule-evaluator.d.ts +116 -0
  180. package/dist/authorization/record/rule-evaluator.d.ts.map +1 -0
  181. package/dist/authorization/record/rule-evaluator.js +125 -0
  182. package/dist/authorization/record/rule-evaluator.js.map +1 -0
  183. package/dist/authorization/record/shares.d.ts +70 -0
  184. package/dist/authorization/record/shares.d.ts.map +1 -0
  185. package/dist/authorization/record/shares.js +107 -0
  186. package/dist/authorization/record/shares.js.map +1 -0
  187. package/dist/identity/broker.d.ts +59 -0
  188. package/dist/identity/broker.d.ts.map +1 -0
  189. package/dist/identity/broker.js +135 -0
  190. package/dist/identity/broker.js.map +1 -0
  191. package/dist/identity/claim-mapper.d.ts +84 -0
  192. package/dist/identity/claim-mapper.d.ts.map +1 -0
  193. package/dist/identity/claim-mapper.js +48 -0
  194. package/dist/identity/claim-mapper.js.map +1 -0
  195. package/dist/identity/index.d.ts +60 -0
  196. package/dist/identity/index.d.ts.map +1 -0
  197. package/dist/identity/index.js +24 -0
  198. package/dist/identity/index.js.map +1 -0
  199. package/dist/identity/internal-adapter.d.ts +54 -0
  200. package/dist/identity/internal-adapter.d.ts.map +1 -0
  201. package/dist/identity/internal-adapter.js +88 -0
  202. package/dist/identity/internal-adapter.js.map +1 -0
  203. package/dist/index.d.ts +43 -0
  204. package/dist/index.d.ts.map +1 -0
  205. package/dist/index.js +48 -0
  206. package/dist/index.js.map +1 -0
  207. package/dist/metadata/completeness.d.ts +136 -0
  208. package/dist/metadata/completeness.d.ts.map +1 -0
  209. package/dist/metadata/completeness.js +106 -0
  210. package/dist/metadata/completeness.js.map +1 -0
  211. package/dist/metadata/dependencies.d.ts +114 -0
  212. package/dist/metadata/dependencies.d.ts.map +1 -0
  213. package/dist/metadata/dependencies.js +105 -0
  214. package/dist/metadata/dependencies.js.map +1 -0
  215. package/dist/metadata/index.d.ts +153 -0
  216. package/dist/metadata/index.d.ts.map +1 -0
  217. package/dist/metadata/index.js +51 -0
  218. package/dist/metadata/index.js.map +1 -0
  219. package/dist/metadata/registry.d.ts +23 -0
  220. package/dist/metadata/registry.d.ts.map +1 -0
  221. package/dist/metadata/registry.js +204 -0
  222. package/dist/metadata/registry.js.map +1 -0
  223. package/dist/risk/evaluator.d.ts +76 -0
  224. package/dist/risk/evaluator.d.ts.map +1 -0
  225. package/dist/risk/evaluator.js +59 -0
  226. package/dist/risk/evaluator.js.map +1 -0
  227. package/dist/risk/index.d.ts +40 -0
  228. package/dist/risk/index.d.ts.map +1 -0
  229. package/dist/risk/index.js +20 -0
  230. package/dist/risk/index.js.map +1 -0
  231. package/dist/risk/risk-engine.d.ts +76 -0
  232. package/dist/risk/risk-engine.d.ts.map +1 -0
  233. package/dist/risk/risk-engine.js +287 -0
  234. package/dist/risk/risk-engine.js.map +1 -0
  235. package/dist/risk/signals.d.ts +60 -0
  236. package/dist/risk/signals.d.ts.map +1 -0
  237. package/dist/risk/signals.js +104 -0
  238. package/dist/risk/signals.js.map +1 -0
  239. package/dist/risk/thresholds.d.ts +54 -0
  240. package/dist/risk/thresholds.d.ts.map +1 -0
  241. package/dist/risk/thresholds.js +60 -0
  242. package/dist/risk/thresholds.js.map +1 -0
  243. package/dist/session/index.d.ts +47 -0
  244. package/dist/session/index.d.ts.map +1 -0
  245. package/dist/session/index.js +20 -0
  246. package/dist/session/index.js.map +1 -0
  247. package/dist/session/lifetimes.d.ts +50 -0
  248. package/dist/session/lifetimes.d.ts.map +1 -0
  249. package/dist/session/lifetimes.js +67 -0
  250. package/dist/session/lifetimes.js.map +1 -0
  251. package/dist/session/ports.d.ts +266 -0
  252. package/dist/session/ports.d.ts.map +1 -0
  253. package/dist/session/ports.js +23 -0
  254. package/dist/session/ports.js.map +1 -0
  255. package/dist/session/session-authority.d.ts +97 -0
  256. package/dist/session/session-authority.d.ts.map +1 -0
  257. package/dist/session/session-authority.js +393 -0
  258. package/dist/session/session-authority.js.map +1 -0
  259. package/package.json +32 -0
@@ -0,0 +1,91 @@
1
+ /**
2
+ * The §11.3 admin **SAFEGUARDS** — the security core of Layer 10.
3
+ *
4
+ * ⛔ TEAM-B-OWNED. The PRELUDE freezes only the SIGNATURES + FAIL-CLOSED DEFAULTS
5
+ * here so the command engine skeleton and Team B compile against a stable seam.
6
+ * Team B REPLACES each default body with the real logic. The defaults are
7
+ * deliberately the MOST-RESTRICTIVE outcome, so a not-yet-implemented safeguard
8
+ * DENIES / over-warns / demands confirmation — never opens (invariant #2/#7).
9
+ *
10
+ * The three safeguards (§11.3 / §3.2, §3.5):
11
+ * 1. {@link checkDelegatedAdmin} — a non-superuser admin cannot grant beyond
12
+ * their OWN authority, and cannot UNILATERALLY cross tenants. Verified by
13
+ * REUSING the injected {@link DecisionAuthority.decide} (ADR-0001 — never a
14
+ * second decision path). Default: DENY (fail-closed).
15
+ * 2. {@link computeBlastRadius} — how many principals/records a change affects,
16
+ * communicated before apply. Default: conservative `high` severity.
17
+ * 3. {@link requiresConfirm} — whether a command is destructive/high-blast and
18
+ * thus needs a confirm token. Default: `true` (conservative).
19
+ *
20
+ * ADR-0003: framework-agnostic — no framework / HTTP / DB / node imports.
21
+ */
22
+ /**
23
+ * ⛔ SAFEGUARD 1 — the DELEGATED-ADMINISTRATION constraint (§11.3 / §3.2 / AC 4).
24
+ *
25
+ * Every grant/tier/policy/cross-tenant command by a NON-superuser admin is itself
26
+ * authorization-checked: the admin cannot grant an action/scope they do not
27
+ * themselves hold, cannot escalate, and cannot UNILATERALLY cross tenants (a
28
+ * non-superuser's ONLY cross-tenant path is the consent invitation). A platform
29
+ * superuser passes. This MUST run in the command engine BEFORE any mutation and
30
+ * MUST fail closed.
31
+ *
32
+ * ⛔ ONE DECISION PATH (ADR-0001): Team B verifies "does the admin hold what they
33
+ * are granting" by REUSING the injected `decide` — it NEVER re-implements the
34
+ * verdict. The `decide` parameter is threaded in for exactly that reuse.
35
+ *
36
+ * PRELUDE DEFAULT: returns a `delegated_admin_exceeds_authority` DENY for every
37
+ * input, so a missing Team-B implementation fails CLOSED (no admin command can
38
+ * mutate until the real check is wired). Team B replaces this body.
39
+ *
40
+ * @param admin The acting admin (the subject of the self-check).
41
+ * @param command The tagged mutation being attempted.
42
+ * @param decide The ONE decision authority — REUSED, never re-implemented.
43
+ */
44
+ export async function checkDelegatedAdmin(admin, command, decide) {
45
+ // Params named for the real signature but unused in the fail-closed stub.
46
+ void admin;
47
+ void command;
48
+ void decide;
49
+ // FAIL CLOSED: until Team B implements the real §11.3 constraint, deny.
50
+ return { ok: false, reason: 'delegated_admin_exceeds_authority' };
51
+ }
52
+ /**
53
+ * ⛔ SAFEGUARD 2 — BLAST-RADIUS computation (§11.3 / §3.5 / AC 7).
54
+ *
55
+ * Compute how many principals/records a mutating command affects, communicated
56
+ * BEFORE apply. Team B implements the real counting over the stores.
57
+ *
58
+ * PRELUDE DEFAULT: returns a conservative `high`-severity radius with an
59
+ * unknown/large description, so a missing implementation OVER-warns (and, via
60
+ * {@link requiresConfirm}, forces a confirm token) rather than under-warning.
61
+ * Team B replaces this body.
62
+ */
63
+ export async function computeBlastRadius(command, deps) {
64
+ void command;
65
+ void deps;
66
+ // CONSERVATIVE DEFAULT: assume high impact until Team B computes the real one.
67
+ return {
68
+ affectedPrincipalCount: Number.POSITIVE_INFINITY,
69
+ description: 'Blast radius not yet computed — treated as high-impact (fail-closed default).',
70
+ severity: 'high',
71
+ };
72
+ }
73
+ /**
74
+ * ⛔ SAFEGUARD 3 — CONFIRM-REQUIRED classification (§11.3 / §3.5 / AC 7).
75
+ *
76
+ * Decide whether a command is destructive/high-blast and therefore needs a
77
+ * {@link import('./types.js').ConfirmToken}. Destructive kinds (revoke a
78
+ * widely-held permission, tier change, delete role, whole-object-type cross-tenant
79
+ * grant) return `true`. Team B implements the real classification (by kind +
80
+ * blast severity).
81
+ *
82
+ * PRELUDE DEFAULT: returns `true` for EVERY command — the conservative outcome, so
83
+ * a missing implementation demands confirmation rather than skipping it. Team B
84
+ * replaces this body.
85
+ */
86
+ export function requiresConfirm(command) {
87
+ void command;
88
+ // CONSERVATIVE DEFAULT: require confirmation until Team B classifies precisely.
89
+ return true;
90
+ }
91
+ //# sourceMappingURL=safeguards.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"safeguards.js","sourceRoot":"","sources":["../../src/admin/safeguards.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAuBH;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,KAA6B,EAC7B,OAAsB,EACtB,MAAyB;IAEzB,0EAA0E;IAC1E,KAAK,KAAK,CAAC;IACX,KAAK,OAAO,CAAC;IACb,KAAK,MAAM,CAAC;IACZ,wEAAwE;IACxE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,mCAAmC,EAAE,CAAC;AACpE,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,OAAsB,EACtB,IAAqB;IAErB,KAAK,OAAO,CAAC;IACb,KAAK,IAAI,CAAC;IACV,+EAA+E;IAC/E,OAAO;QACL,sBAAsB,EAAE,MAAM,CAAC,iBAAiB;QAChD,WAAW,EACT,+EAA+E;QACjF,QAAQ,EAAE,MAAM;KACjB,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,eAAe,CAAC,OAAsB;IACpD,KAAK,OAAO,CAAC;IACb,gFAAgF;IAChF,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,485 @@
1
+ /**
2
+ * Admin Console — the shared **query + command types** (Layer 10).
3
+ *
4
+ * These are the types the admin QUERY engine (Team A), the admin COMMAND engine
5
+ * (Team B), the SDK admin surface, and the React console (Team C) all speak. The
6
+ * prelude freezes them; the teams fill the engine bodies against them.
7
+ *
8
+ * ⛔ TWO INVARIANTS ARE BAKED INTO THESE SHAPES (ADR-0012 / §13.4, §3):
9
+ * 1. **No raw identifiers in any query OUTPUT.** Every user-facing field carries
10
+ * a resolved human **label**, never a route/path/uuid. Opaque ids appear only
11
+ * in command INPUTS and non-user-facing correlation fields (documented as
12
+ * such). The {@link import('./ports.js').LabelResolver} port is the
13
+ * id→label chokepoint; output types below carry the label, not the id.
14
+ * 2. **Guided builder only — no raw expressions.** A policy is authored as a
15
+ * structured {@link GuidedPolicy} (field → operator → value); there is NO
16
+ * raw-string / raw-expression field ANYWHERE in these types by design, so a
17
+ * raw condition literally cannot be represented (ADR-0012 / §3.4).
18
+ *
19
+ * The **one decision path** is preserved by shape too: {@link SimulateResult}
20
+ * WRAPS the real {@link Decision} produced by the injected
21
+ * {@link DecisionAuthority.decide} — the admin layer never re-derives a verdict
22
+ * (ADR-0001 / §3.1).
23
+ *
24
+ * ADR-0003: framework-agnostic — no framework / HTTP / DB / node imports.
25
+ */
26
+ import type { AuditEvent } from '../audit/index.js';
27
+ import type { Action, AccessTier, Decision, DecisionContext, PermissionKey, Resource } from '../authorization/index.js';
28
+ import type { Principal } from '../identity/index.js';
29
+ /**
30
+ * How an action appears in the catalog, resolved to a label + its own tier.
31
+ * The `label` is the curated-or-registry human label — NEVER a route/id (ADR-0012).
32
+ */
33
+ export interface ActionEntry {
34
+ /** Stable action key — used for command inputs, NOT rendered as the display text. */
35
+ readonly actionKey: string;
36
+ /** Human-readable action label (curated override or the registry label). */
37
+ readonly label: string;
38
+ /** This action's baseline tier (resolved, never undefined). */
39
+ readonly tier: AccessTier;
40
+ }
41
+ /**
42
+ * A permission's classification state in the catalog completeness view (§5.4):
43
+ * - `classified` — seeded from the registry with a live action + tier.
44
+ * - `unclassified` — a newly-discovered permission that needs admin attention;
45
+ * surfaced as "needs attention," NEVER silently open (AC 1).
46
+ * - `orphaned` — a grant references a permission key no live action derives
47
+ * (the operation was removed); flagged for cleanup (§5.4).
48
+ */
49
+ export type CatalogClassification = 'classified' | 'unclassified' | 'orphaned';
50
+ /**
51
+ * One catalog entry — a permission resolved to human-readable terms (AC 1 / §2).
52
+ *
53
+ * ⛔ `label`/`group` are the curated-or-registry LABELS; this type carries NO
54
+ * route/path/uuid (ADR-0012). `permissionKey` is the stable identity (ADR-0010)
55
+ * used for command inputs/correlation, not intended as user-facing display text.
56
+ */
57
+ export interface CatalogEntry {
58
+ /** Stable permission identity (ADR-0010) — for command inputs, not display. */
59
+ readonly permissionKey: PermissionKey;
60
+ /** Human-readable permission label (curation override or registry label). */
61
+ readonly label: string;
62
+ /** Optional human-readable grouping label the admin curated. */
63
+ readonly group?: string;
64
+ /** The permission's baseline access tier (resolved). */
65
+ readonly tier: AccessTier;
66
+ /** The actions this permission spans, each label-resolved. */
67
+ readonly actions: readonly ActionEntry[];
68
+ /** Completeness state — drives the "needs attention" surfacing (§5.4). */
69
+ readonly classification: CatalogClassification;
70
+ }
71
+ /**
72
+ * One resolved grant in a principal's effective-access explanation. Every field
73
+ * is human-readable — labels, not ids (ADR-0012). `conditionsSummary` is a
74
+ * prose "why", not a raw expression.
75
+ */
76
+ export interface EffectiveGrant {
77
+ /** Human-readable label of the granted permission/scope. */
78
+ readonly label: string;
79
+ /** The action keys this grant confers (the subset actually granted). */
80
+ readonly actions: readonly string[];
81
+ /** Optional human-readable summary of any conditions ("only records they own"). */
82
+ readonly conditionsSummary?: string;
83
+ }
84
+ /**
85
+ * Effective-access explain result for a principal (AC 3). The explanation MUST
86
+ * match what {@link DecisionAuthority.decide} would actually allow — explain
87
+ * enumerates facts, simulate delegates the verdict; neither diverges (ADR-0001).
88
+ */
89
+ export interface EffectiveAccess {
90
+ /** Human-readable label of the principal (never their raw id) (ADR-0012). */
91
+ readonly principalLabel: string;
92
+ /** The principal's effective grants, each in human terms. */
93
+ readonly grants: readonly EffectiveGrant[];
94
+ }
95
+ /**
96
+ * A simulate request — the exact inputs handed to the ONE
97
+ * {@link DecisionAuthority.decide} (ADR-0001 / §3.1). The admin layer NEVER
98
+ * re-implements the verdict; it forwards these to `decide()`.
99
+ */
100
+ export interface SimulateRequest {
101
+ readonly principal: Principal;
102
+ readonly action: Action;
103
+ readonly resource: Resource;
104
+ readonly context: DecisionContext;
105
+ }
106
+ /**
107
+ * A simulate result — WRAPS the real {@link Decision} from `decide()` (never a
108
+ * second decision path, ADR-0001 / AC 2) with an admin-facing explanation.
109
+ *
110
+ * `decidingGate` names the gate/reason that settled the verdict (for
111
+ * troubleshooting); `explanation` is human-readable prose. `decision` is the
112
+ * verbatim `decide()` output — the authoritative verdict this result exposes.
113
+ */
114
+ export interface SimulateResult {
115
+ /** The verbatim decision from the ONE decision authority (ADR-0001). */
116
+ readonly decision: Decision;
117
+ /** Convenience mirror of `decision.effect` for the UI (allow | deny). */
118
+ readonly effect: Decision['effect'];
119
+ /** Convenience mirror of `decision.reason` — the machine reason code. */
120
+ readonly reason: Decision['reason'];
121
+ /** Which gate/step settled this verdict (human-readable, for troubleshooting). */
122
+ readonly decidingGate: string;
123
+ /** Human-readable "why" (no raw ids / no leak of resources P can't see). */
124
+ readonly explanation: string;
125
+ }
126
+ /**
127
+ * The closed set of operators the guided policy builder allows (ADR-0012 / §3.4).
128
+ * A closed union is load-bearing: there is NO raw-expression escape — a policy
129
+ * condition can only be expressed with one of these known operators, which the
130
+ * command engine VALIDATES against the field's type.
131
+ */
132
+ export type PolicyOperator = 'eq' | 'ne' | 'in' | 'not_in' | 'gt' | 'lt' | 'gte' | 'lte' | 'contains' | 'not_contains' | 'is_null' | 'is_not_null' | 'is_owner' | 'is_not_owner';
133
+ /**
134
+ * One structured condition of a guided policy: a known `field` compared by a
135
+ * known {@link PolicyOperator} to a `value` (ADR-0012). The command engine
136
+ * validates: known field, operator valid for that field's type, well-formed
137
+ * value. `value` is `unknown` (the validator narrows it per field type); operators
138
+ * that take no operand (`is_null`, `is_owner`, …) ignore it.
139
+ *
140
+ * ⛔ There is deliberately NO raw-expression field — a raw string condition cannot
141
+ * be represented, which is the point (§3.4 / AC 5).
142
+ */
143
+ export interface PolicyCondition {
144
+ /** Stable field key on the target object type (validated against the registry). */
145
+ readonly field: string;
146
+ /** The comparison operator (closed set — no raw expression). */
147
+ readonly operator: PolicyOperator;
148
+ /** The comparand — narrowed by the validator per the field's type. */
149
+ readonly value: unknown;
150
+ }
151
+ /** A guided policy's effect — allow or deny (deny-wins is the engine's concern). */
152
+ export type PolicyEffect = 'allow' | 'deny';
153
+ /**
154
+ * A record-access policy authored via the guided builder (ADR-0012 / AC 5).
155
+ * Structured field→operator→value conditions + an action + an allow/deny effect;
156
+ * NO raw expression anywhere. The command engine validates the whole structure
157
+ * before persisting via {@link import('./ports.js').PolicyStore}.
158
+ */
159
+ export interface GuidedPolicy {
160
+ /** Stable object-type key this policy governs. */
161
+ readonly typeKey: string;
162
+ /** The action key the policy applies to. */
163
+ readonly action: string;
164
+ /** allow or deny. */
165
+ readonly effect: PolicyEffect;
166
+ /** The structured conditions (AND-composed; the evaluator is Team B/Authz). */
167
+ readonly conditions: readonly PolicyCondition[];
168
+ }
169
+ /**
170
+ * A persisted policy row (what {@link import('./ports.js').PolicyStore} stores).
171
+ * A stable `policyId` + its owning tenant + the authored {@link GuidedPolicy}.
172
+ * `policyId`/`tenantId` are opaque correlation ids (command-input / storage
173
+ * scope), never user-facing display text.
174
+ */
175
+ export interface Policy {
176
+ /** Opaque stable id (storage/command correlation — not display text). */
177
+ readonly policyId: string;
178
+ /** Owning tenant (storage scope). */
179
+ readonly tenantId: string;
180
+ /** The authored guided policy. */
181
+ readonly policy: GuidedPolicy;
182
+ }
183
+ /**
184
+ * The admin-authored CURATION overlaid on the registry-seeded catalog: a custom
185
+ * human label and/or group for a permission (ADR-0012, AC 1). The BASE catalog is
186
+ * the ModuleRegistry; curation is the admin overlay layered on top. Both fields
187
+ * are human-readable labels — never ids/routes.
188
+ */
189
+ export interface CatalogCuration {
190
+ /** The permission this curation applies to (stable identity, ADR-0010). */
191
+ readonly permissionKey: PermissionKey;
192
+ /** Custom human label (overrides the registry label when present). */
193
+ readonly label?: string;
194
+ /** Custom human group label. */
195
+ readonly group?: string;
196
+ }
197
+ /**
198
+ * A grant binding a principal to a permission with an action subset + optional
199
+ * conditions, scoped to a tenant. `grantId`/`principalId`/`tenantId` are opaque
200
+ * ids (command-input / correlation), never user-facing display text — the query
201
+ * side resolves them to labels via {@link import('./ports.js').LabelResolver}.
202
+ */
203
+ export interface Grant {
204
+ /** Opaque stable id (command correlation / revoke handle — not display text). */
205
+ readonly grantId: string;
206
+ /** The principal this grant is bound to (opaque id — resolved to a label for display). */
207
+ readonly principalId: string;
208
+ /** The permission granted (stable identity, ADR-0010). */
209
+ readonly permissionKey: PermissionKey;
210
+ /** The subset of the permission's actions actually granted. */
211
+ readonly actions: readonly string[];
212
+ /** Optional structured conditions narrowing the grant (guided form only). */
213
+ readonly conditions?: readonly PolicyCondition[];
214
+ /** Tenant this grant is scoped to. */
215
+ readonly tenantId: string;
216
+ }
217
+ /** Severity band of a change's blast-radius — drives confirm-required. */
218
+ export type BlastSeverity = 'low' | 'medium' | 'high';
219
+ /**
220
+ * The computed blast-radius of a mutating command (§11.3 / AC 7): how many
221
+ * principals/records it affects, a human description, and a severity band. Shown
222
+ * BEFORE apply; high severity / destructive kinds require a confirm token.
223
+ *
224
+ * ⛔ The prelude's default (Team-B-owned {@link import('./safeguards.js').computeBlastRadius})
225
+ * is conservatively `high` so a missing implementation fails CLOSED (over-warns),
226
+ * never under-warns.
227
+ */
228
+ export interface BlastRadius {
229
+ /** How many principals the change affects. */
230
+ readonly affectedPrincipalCount: number;
231
+ /** Optional estimate of affected records (may be unknown / omitted). */
232
+ readonly affectedRecordEstimate?: number;
233
+ /** Human-readable description of what the change touches (no raw ids). */
234
+ readonly description: string;
235
+ /** Severity band — `high` triggers confirm-required. */
236
+ readonly severity: BlastSeverity;
237
+ }
238
+ /**
239
+ * An opaque confirm marker the caller must present for a destructive/high-blast
240
+ * command (§11.3 / AC 7). Branded so a bare `{ confirmed: true }` object can't be
241
+ * forged in a typed caller without going through the confirm flow that produced
242
+ * it. Carries a human `actionSummary` (what was confirmed) for the audit trail.
243
+ */
244
+ export interface ConfirmToken {
245
+ /** Always `true` — the token only exists once the user has confirmed. */
246
+ readonly confirmed: true;
247
+ /** Human-readable summary of the exact action confirmed (for audit). */
248
+ readonly actionSummary: string;
249
+ /** Brand — prevents an arbitrary object from being passed as a confirm token. */
250
+ readonly __brand: 'ShieldAdminConfirmToken';
251
+ }
252
+ /**
253
+ * A command input wrapper for a DESTRUCTIVE command: the payload PLUS the required
254
+ * {@link ConfirmToken}. The command engine refuses a destructive command whose
255
+ * `confirm` is absent (§3.5 / AC 7) — the type makes the token non-optional.
256
+ */
257
+ export interface Destructive<T> {
258
+ /** The command payload. */
259
+ readonly payload: T;
260
+ /** REQUIRED confirm token — the engine rejects the command without it. */
261
+ readonly confirm: ConfirmToken;
262
+ }
263
+ /**
264
+ * The lifecycle states of a cross-tenant invitation (§10bis / AC 9).
265
+ *
266
+ * ⛔ An invitation confers NOTHING until `accepted`; `denied`/`expired`/`revoked`
267
+ * confer nothing; either side revokes with immediate effect (§3.7).
268
+ *
269
+ * Allowed transitions (the engine is the state machine — Team B enforces):
270
+ * - `pending` → `accepted` | `denied` | `expired` | `revoked`
271
+ * - `accepted` → `revoked` | `expired`
272
+ * - `denied` / `expired` / `revoked` are TERMINAL (no outgoing transitions).
273
+ */
274
+ export type InvitationState = 'pending' | 'accepted' | 'denied' | 'expired' | 'revoked';
275
+ /**
276
+ * The allowed invitation state transitions (§10bis) — the single source of truth
277
+ * the command engine's transition validator checks against, so the state machine
278
+ * can't drift. A transition NOT listed here is rejected `invalid_transition`.
279
+ */
280
+ export declare const INVITATION_TRANSITIONS: Readonly<Record<InvitationState, readonly InvitationState[]>>;
281
+ /**
282
+ * A cross-tenant collaboration invitation (§10bis / AC 9). Carries the owning
283
+ * tenant, the grantee tenant addressed by EMAIL (the grantee tenant may not be
284
+ * known by id yet), the object-type(s) offered, the scope + action subset, an
285
+ * expiry, and the current state.
286
+ *
287
+ * ⛔ `id`/`owningTenantId` are opaque correlation ids (not display text);
288
+ * `granteeTenantEmail` is an email address the inbox shows, not a raw internal id.
289
+ * The scope + actions + expiry are the CEILING; the applicable grant is bounded by
290
+ * L8 Team-C's `isCrossTenantGrantApplicable` — the command engine REUSES that
291
+ * ceiling, never re-derives it (§3.7).
292
+ */
293
+ export interface CrossTenantInvitation {
294
+ /** Opaque stable id (correlation / state-transition handle — not display text). */
295
+ readonly id: string;
296
+ /** The tenant offering the access (owner side). */
297
+ readonly owningTenantId: string;
298
+ /** The grantee tenant addressed by email (may not be known by id yet). */
299
+ readonly granteeTenantEmail: string;
300
+ /** The object-type key(s) the invitation offers access to. */
301
+ readonly objectTypeKeys: readonly string[];
302
+ /** Human-readable scope descriptor (guided; never a raw expression). */
303
+ readonly scope: string;
304
+ /** The action subset offered (the ceiling's action half). */
305
+ readonly actions: readonly string[];
306
+ /** Absolute expiry — UTC epoch ms (the platform sets UTC explicitly). */
307
+ readonly expiresAtMs: number;
308
+ /** Current lifecycle state. */
309
+ readonly state: InvitationState;
310
+ }
311
+ /**
312
+ * A service-account principal record (AC 10). Least-privilege scoped +
313
+ * tenant-bound; credential crypto is the Auth layer's hasher port (never here).
314
+ * `id`/`tenantId` are opaque correlation/scope ids; `label` is the human display.
315
+ */
316
+ export interface ServiceAccount {
317
+ /** Opaque stable id (correlation / lifecycle handle — not display text). */
318
+ readonly id: string;
319
+ /** Tenant this account is bound to (tenant isolation, invariant #4). */
320
+ readonly tenantId: string;
321
+ /** Human-readable label (the display name — never surface the raw id). */
322
+ readonly label: string;
323
+ /** Human-readable least-privilege scope descriptor. */
324
+ readonly scope: string;
325
+ /** Optional absolute expiry — UTC epoch ms. */
326
+ readonly expiresAtMs?: number;
327
+ /** Whether the account has been revoked (revocation is immediate, AC 10). */
328
+ readonly revoked: boolean;
329
+ }
330
+ /** Command input: create a service account (least-privilege, tenant-bound). */
331
+ export interface CreateServiceAccountInput {
332
+ readonly tenantId: string;
333
+ readonly label: string;
334
+ readonly scope: string;
335
+ readonly expiresAtMs?: number;
336
+ }
337
+ /** Command input: re-scope a service account (must stay within admin authority). */
338
+ export interface ScopeServiceAccountInput {
339
+ readonly id: string;
340
+ readonly scope: string;
341
+ }
342
+ /**
343
+ * Command input: rotate a service account's credential. The engine mints/hashes
344
+ * via the Auth layer's hasher port (never here); this input only names the target.
345
+ */
346
+ export interface RotateServiceAccountCredentialInput {
347
+ readonly id: string;
348
+ }
349
+ /** Command input: set/clear a service account's absolute expiry (UTC epoch ms). */
350
+ export interface SetServiceAccountExpiryInput {
351
+ readonly id: string;
352
+ /** New absolute expiry, or `null` to clear it. */
353
+ readonly expiresAtMs: number | null;
354
+ }
355
+ /**
356
+ * The closed set of reasons a command is DENIED. A closed union means an
357
+ * unhandled path can't silently succeed — every deny is one of these named,
358
+ * fail-closed reasons (invariant #2/#7).
359
+ */
360
+ export type AdminDenyReason =
361
+ /** Delegated-admin constraint: the admin would grant beyond their own authority (§11.3). */
362
+ 'delegated_admin_exceeds_authority'
363
+ /** A non-superuser attempted a unilateral cross-tenant grant (only path is consent, §11.3). */
364
+ | 'unilateral_cross_tenant'
365
+ /** A destructive/high-blast command arrived without the required confirm token (§3.5). */
366
+ | 'confirm_required'
367
+ /** The tier command tried to set `public` — code-only, never console-settable (§3.6). */
368
+ | 'public_not_settable'
369
+ /** The guided policy failed structural validation (unknown field / bad operator / value). */
370
+ | 'invalid_policy'
371
+ /** An invitation state transition not permitted by {@link INVITATION_TRANSITIONS}. */
372
+ | 'invalid_transition'
373
+ /** The referenced permission has no live action (orphaned) — nothing to gate. */
374
+ | 'orphaned_permission'
375
+ /** The referenced entity (grant/policy/account/invitation) does not exist. */
376
+ | 'not_found'
377
+ /** A required upstream port/dependency could not answer (fail-closed, ADR-0016). */
378
+ | 'unavailable'
379
+ /** The command method has no team implementation yet — fail-closed default (prelude). */
380
+ | 'not_implemented';
381
+ /**
382
+ * The result of a mutating admin command — a discriminated union so callers MUST
383
+ * branch (never assume success). `ok: false` carries a closed
384
+ * {@link AdminDenyReason}. Fail-closed: the prelude's default method bodies return
385
+ * `{ ok: false, reason: 'not_implemented' }` so a missing team impl DENIES.
386
+ */
387
+ export type CommandResult<T> = {
388
+ readonly ok: true;
389
+ readonly value: T;
390
+ } | {
391
+ readonly ok: false;
392
+ readonly reason: AdminDenyReason;
393
+ };
394
+ /**
395
+ * The discriminated KINDS of mutating admin command — used by the safeguards
396
+ * ({@link import('./safeguards.js')}) to classify delegated-admin scope, blast
397
+ * radius, and confirm-required, without each safeguard re-deriving "what kind of
398
+ * command is this". Team B refines the payloads; the prelude names the taxonomy.
399
+ */
400
+ export type AdminMutationKind = 'curate_permission' | 'grant' | 'revoke' | 'author_policy' | 'set_tier' | 'service_account_create' | 'service_account_scope' | 'service_account_rotate' | 'service_account_revoke' | 'service_account_expiry' | 'invitation_create' | 'invitation_transition';
401
+ /**
402
+ * A tagged mutating-command descriptor the SAFEGUARDS reason about (§11.3). The
403
+ * prelude freezes the discriminant + the acting admin + tenant context; Team B
404
+ * fills the per-kind payload. `admin` is the acting principal (the subject of the
405
+ * delegated-admin self-check); `targetTenantId` names the tenant the mutation
406
+ * lands in (drives the unilateral-cross-tenant check).
407
+ */
408
+ export interface AdminMutation {
409
+ /** Which command this is (drives per-kind safeguard logic). */
410
+ readonly kind: AdminMutationKind;
411
+ /** The acting admin — subject of the delegated-admin constraint (§11.3). */
412
+ readonly admin: Principal;
413
+ /** The tenant this mutation targets (cross-tenant check compares to admin.tenantId). */
414
+ readonly targetTenantId: string;
415
+ /**
416
+ * The command-specific payload (grant/policy/tier/etc.). Team B narrows this per
417
+ * `kind`; the prelude keeps it opaque so the safeguard SIGNATURES compile.
418
+ */
419
+ readonly payload?: unknown;
420
+ }
421
+ /** Command input: grant a permission (action subset + conditions) to a principal. */
422
+ export interface GrantCommand {
423
+ /** The principal to grant to (opaque id — input position, not display). */
424
+ readonly principalId: string;
425
+ /** The permission to grant (stable identity, ADR-0010). */
426
+ readonly permissionKey: PermissionKey;
427
+ /** The subset of the permission's actions to grant. */
428
+ readonly actions: readonly string[];
429
+ /** Optional structured conditions (guided form only — no raw expression). */
430
+ readonly conditions?: readonly PolicyCondition[];
431
+ /** Tenant to scope the grant to. */
432
+ readonly tenantId: string;
433
+ }
434
+ /** Command input: create a cross-tenant invitation (§10bis). */
435
+ export interface CreateInvitationCommand {
436
+ /** The tenant offering the access (owner side). */
437
+ readonly owningTenantId: string;
438
+ /** The grantee tenant addressed by email. */
439
+ readonly granteeTenantEmail: string;
440
+ /** The object-type key(s) offered. */
441
+ readonly objectTypeKeys: readonly string[];
442
+ /** Human-readable scope descriptor (guided; never a raw expression). */
443
+ readonly scope: string;
444
+ /** The action subset offered (the ceiling's action half). */
445
+ readonly actions: readonly string[];
446
+ /** Absolute expiry — UTC epoch ms. */
447
+ readonly expiresAtMs: number;
448
+ }
449
+ /** Command input: transition an invitation to a new state (§10bis). */
450
+ export interface InvitationTransitionCommand {
451
+ /** The invitation to transition (opaque id — input position). */
452
+ readonly invitationId: string;
453
+ /** The target state — validated against {@link INVITATION_TRANSITIONS}. */
454
+ readonly newState: InvitationState;
455
+ }
456
+ /**
457
+ * One audit event as the VIEWER renders it — the raw {@link AuditEvent} PLUS the
458
+ * actor resolved to a human LABEL (ADR-0012 / §13.4). The viewer shows
459
+ * `actorLabel`, NEVER `event.actorId`.
460
+ */
461
+ export interface AuditViewEvent {
462
+ /** The underlying audit event (its `actorId` is NOT rendered to the UI). */
463
+ readonly event: AuditEvent;
464
+ /** The actor resolved to a human label (fallback for deleted, never the id). */
465
+ readonly actorLabel: string;
466
+ }
467
+ /**
468
+ * The audit viewer read-model result (§13) — a page of label-resolved events +
469
+ * the echoed query (for cursor continuity) + the next-page cursor if any.
470
+ */
471
+ export interface AuditReadResult {
472
+ /** The query this page answered (echoed for pagination continuity). */
473
+ readonly query: {
474
+ readonly tenantId: string;
475
+ readonly type?: AuditEvent['type'];
476
+ readonly actorId?: string;
477
+ readonly limit?: number;
478
+ readonly before?: string;
479
+ };
480
+ /** The page of events, each with its actor label resolved (no raw ids). */
481
+ readonly events: readonly AuditViewEvent[];
482
+ /** Opaque cursor for the next page, or `null` when this is the last page. */
483
+ readonly nextCursor: string | null;
484
+ }
485
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/admin/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EACV,MAAM,EACN,UAAU,EACV,QAAQ,EACR,eAAe,EACf,aAAa,EACb,QAAQ,EACT,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAMtD;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B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C,6EAA6E;IAC7E,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CACpC"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Admin Console — the shared **query + command types** (Layer 10).
3
+ *
4
+ * These are the types the admin QUERY engine (Team A), the admin COMMAND engine
5
+ * (Team B), the SDK admin surface, and the React console (Team C) all speak. The
6
+ * prelude freezes them; the teams fill the engine bodies against them.
7
+ *
8
+ * ⛔ TWO INVARIANTS ARE BAKED INTO THESE SHAPES (ADR-0012 / §13.4, §3):
9
+ * 1. **No raw identifiers in any query OUTPUT.** Every user-facing field carries
10
+ * a resolved human **label**, never a route/path/uuid. Opaque ids appear only
11
+ * in command INPUTS and non-user-facing correlation fields (documented as
12
+ * such). The {@link import('./ports.js').LabelResolver} port is the
13
+ * id→label chokepoint; output types below carry the label, not the id.
14
+ * 2. **Guided builder only — no raw expressions.** A policy is authored as a
15
+ * structured {@link GuidedPolicy} (field → operator → value); there is NO
16
+ * raw-string / raw-expression field ANYWHERE in these types by design, so a
17
+ * raw condition literally cannot be represented (ADR-0012 / §3.4).
18
+ *
19
+ * The **one decision path** is preserved by shape too: {@link SimulateResult}
20
+ * WRAPS the real {@link Decision} produced by the injected
21
+ * {@link DecisionAuthority.decide} — the admin layer never re-derives a verdict
22
+ * (ADR-0001 / §3.1).
23
+ *
24
+ * ADR-0003: framework-agnostic — no framework / HTTP / DB / node imports.
25
+ */
26
+ /**
27
+ * The allowed invitation state transitions (§10bis) — the single source of truth
28
+ * the command engine's transition validator checks against, so the state machine
29
+ * can't drift. A transition NOT listed here is rejected `invalid_transition`.
30
+ */
31
+ export const INVITATION_TRANSITIONS = {
32
+ pending: ['accepted', 'denied', 'expired', 'revoked'],
33
+ accepted: ['revoked', 'expired'],
34
+ denied: [],
35
+ expired: [],
36
+ revoked: [],
37
+ };
38
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/admin/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AA6UH;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAE/B;IACF,OAAO,EAAE,CAAC,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,CAAC;IACrD,QAAQ,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC;IAChC,MAAM,EAAE,EAAE;IACV,OAAO,EAAE,EAAE;IACX,OAAO,EAAE,EAAE;CACH,CAAC"}