@vorionsys/atsf-core 0.2.3 → 0.3.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 (437) hide show
  1. package/CHANGELOG.md +1 -0
  2. package/LICENSE +1 -1
  3. package/README.md +82 -29
  4. package/dist/adapters/base-adapter.d.ts +94 -0
  5. package/dist/adapters/base-adapter.d.ts.map +1 -0
  6. package/dist/adapters/base-adapter.js +233 -0
  7. package/dist/adapters/base-adapter.js.map +1 -0
  8. package/dist/adapters/index.d.ts +9 -0
  9. package/dist/adapters/index.d.ts.map +1 -0
  10. package/dist/adapters/index.js +5 -0
  11. package/dist/adapters/index.js.map +1 -0
  12. package/dist/adapters/types.d.ts +83 -0
  13. package/dist/adapters/types.d.ts.map +1 -0
  14. package/dist/adapters/types.js +4 -0
  15. package/dist/adapters/types.js.map +1 -0
  16. package/dist/adapters/webhook-handler.d.ts +64 -0
  17. package/dist/adapters/webhook-handler.d.ts.map +1 -0
  18. package/dist/adapters/webhook-handler.js +170 -0
  19. package/dist/adapters/webhook-handler.js.map +1 -0
  20. package/dist/api/index.d.ts +1 -1
  21. package/dist/api/index.d.ts.map +1 -1
  22. package/dist/api/index.js +3 -1
  23. package/dist/api/index.js.map +1 -1
  24. package/dist/api/server.d.ts +2 -2
  25. package/dist/api/server.d.ts.map +1 -1
  26. package/dist/api/server.js +149 -184
  27. package/dist/api/server.js.map +1 -1
  28. package/dist/arbitration/index.d.ts +4 -12
  29. package/dist/arbitration/index.d.ts.map +1 -1
  30. package/dist/arbitration/index.js +43 -46
  31. package/dist/arbitration/index.js.map +1 -1
  32. package/dist/arbitration/types.d.ts +10 -10
  33. package/dist/arbitration/types.d.ts.map +1 -1
  34. package/dist/arbitration/types.js +2 -8
  35. package/dist/arbitration/types.js.map +1 -1
  36. package/dist/basis/evaluator.d.ts +1 -6
  37. package/dist/basis/evaluator.d.ts.map +1 -1
  38. package/dist/basis/evaluator.js +56 -56
  39. package/dist/basis/evaluator.js.map +1 -1
  40. package/dist/basis/index.d.ts +3 -3
  41. package/dist/basis/index.d.ts.map +1 -1
  42. package/dist/basis/index.js +5 -3
  43. package/dist/basis/index.js.map +1 -1
  44. package/dist/basis/parser.d.ts +30 -30
  45. package/dist/basis/parser.d.ts.map +1 -1
  46. package/dist/basis/parser.js +27 -32
  47. package/dist/basis/parser.js.map +1 -1
  48. package/dist/basis/types.d.ts +2 -2
  49. package/dist/basis/types.d.ts.map +1 -1
  50. package/dist/basis/types.js +2 -3
  51. package/dist/basis/types.js.map +1 -1
  52. package/dist/chain/index.d.ts +0 -8
  53. package/dist/chain/index.d.ts.map +1 -1
  54. package/dist/chain/index.js +18 -16
  55. package/dist/chain/index.js.map +1 -1
  56. package/dist/cognigate/index.d.ts +1 -9
  57. package/dist/cognigate/index.d.ts.map +1 -1
  58. package/dist/cognigate/index.js +35 -44
  59. package/dist/cognigate/index.js.map +1 -1
  60. package/dist/common/adapters.d.ts +4 -4
  61. package/dist/common/adapters.d.ts.map +1 -1
  62. package/dist/common/adapters.js +54 -70
  63. package/dist/common/adapters.js.map +1 -1
  64. package/dist/common/config.d.ts +69 -68
  65. package/dist/common/config.d.ts.map +1 -1
  66. package/dist/common/config.js +52 -50
  67. package/dist/common/config.js.map +1 -1
  68. package/dist/common/index.d.ts +4 -4
  69. package/dist/common/index.d.ts.map +1 -1
  70. package/dist/common/index.js +6 -4
  71. package/dist/common/index.js.map +1 -1
  72. package/dist/common/logger.d.ts +1 -1
  73. package/dist/common/logger.d.ts.map +1 -1
  74. package/dist/common/logger.js +10 -8
  75. package/dist/common/logger.js.map +1 -1
  76. package/dist/common/types.d.ts +12 -12
  77. package/dist/common/types.d.ts.map +1 -1
  78. package/dist/common/types.js +7 -14
  79. package/dist/common/types.js.map +1 -1
  80. package/dist/containment/index.d.ts +3 -11
  81. package/dist/containment/index.d.ts.map +1 -1
  82. package/dist/containment/index.js +107 -119
  83. package/dist/containment/index.js.map +1 -1
  84. package/dist/containment/types.d.ts +11 -11
  85. package/dist/containment/types.d.ts.map +1 -1
  86. package/dist/containment/types.js +2 -8
  87. package/dist/containment/types.js.map +1 -1
  88. package/dist/contracts/index.d.ts +9 -17
  89. package/dist/contracts/index.d.ts.map +1 -1
  90. package/dist/contracts/index.js +56 -59
  91. package/dist/contracts/index.js.map +1 -1
  92. package/dist/contracts/types.d.ts +12 -12
  93. package/dist/contracts/types.d.ts.map +1 -1
  94. package/dist/contracts/types.js +2 -8
  95. package/dist/contracts/types.js.map +1 -1
  96. package/dist/crewai/callback.d.ts +2 -9
  97. package/dist/crewai/callback.d.ts.map +1 -1
  98. package/dist/crewai/callback.js +29 -27
  99. package/dist/crewai/callback.js.map +1 -1
  100. package/dist/crewai/executor.d.ts +95 -11
  101. package/dist/crewai/executor.d.ts.map +1 -1
  102. package/dist/crewai/executor.js +459 -16
  103. package/dist/crewai/executor.js.map +1 -1
  104. package/dist/crewai/index.d.ts +4 -4
  105. package/dist/crewai/index.d.ts.map +1 -1
  106. package/dist/crewai/index.js +6 -4
  107. package/dist/crewai/index.js.map +1 -1
  108. package/dist/crewai/tools.d.ts +1 -1
  109. package/dist/crewai/tools.d.ts.map +1 -1
  110. package/dist/crewai/tools.js +40 -46
  111. package/dist/crewai/tools.js.map +1 -1
  112. package/dist/crewai/types.d.ts +66 -3
  113. package/dist/crewai/types.d.ts.map +1 -1
  114. package/dist/crewai/types.js +2 -7
  115. package/dist/crewai/types.js.map +1 -1
  116. package/dist/enforce/index.d.ts +226 -19
  117. package/dist/enforce/index.d.ts.map +1 -1
  118. package/dist/enforce/index.js +55 -81
  119. package/dist/enforce/index.js.map +1 -1
  120. package/dist/enforce/trust-aware-enforcement-service.d.ts +8 -23
  121. package/dist/enforce/trust-aware-enforcement-service.d.ts.map +1 -1
  122. package/dist/enforce/trust-aware-enforcement-service.js +109 -125
  123. package/dist/enforce/trust-aware-enforcement-service.js.map +1 -1
  124. package/dist/governance/fluid-workflow.d.ts +8 -16
  125. package/dist/governance/fluid-workflow.d.ts.map +1 -1
  126. package/dist/governance/fluid-workflow.js +88 -114
  127. package/dist/governance/fluid-workflow.js.map +1 -1
  128. package/dist/governance/index.d.ts +7 -15
  129. package/dist/governance/index.d.ts.map +1 -1
  130. package/dist/governance/index.js +76 -81
  131. package/dist/governance/index.js.map +1 -1
  132. package/dist/governance/proof-bridge.d.ts +6 -6
  133. package/dist/governance/proof-bridge.d.ts.map +1 -1
  134. package/dist/governance/proof-bridge.js +6 -16
  135. package/dist/governance/proof-bridge.js.map +1 -1
  136. package/dist/governance/types.d.ts +9 -16
  137. package/dist/governance/types.d.ts.map +1 -1
  138. package/dist/governance/types.js +2 -8
  139. package/dist/governance/types.js.map +1 -1
  140. package/dist/index.d.ts +30 -29
  141. package/dist/index.d.ts.map +1 -1
  142. package/dist/index.js +33 -31
  143. package/dist/index.js.map +1 -1
  144. package/dist/intent/index.d.ts +55 -18
  145. package/dist/intent/index.d.ts.map +1 -1
  146. package/dist/intent/index.js +25 -26
  147. package/dist/intent/index.js.map +1 -1
  148. package/dist/intent/persistent-intent-service.d.ts +2 -17
  149. package/dist/intent/persistent-intent-service.d.ts.map +1 -1
  150. package/dist/intent/persistent-intent-service.js +33 -43
  151. package/dist/intent/persistent-intent-service.js.map +1 -1
  152. package/dist/intent/supabase-intent-repository.d.ts +107 -0
  153. package/dist/intent/supabase-intent-repository.d.ts.map +1 -0
  154. package/dist/intent/supabase-intent-repository.js +406 -0
  155. package/dist/intent/supabase-intent-repository.js.map +1 -0
  156. package/dist/intent-gateway/index.d.ts +5 -28
  157. package/dist/intent-gateway/index.d.ts.map +1 -1
  158. package/dist/intent-gateway/index.js +341 -508
  159. package/dist/intent-gateway/index.js.map +1 -1
  160. package/dist/langchain/callback.d.ts +2 -9
  161. package/dist/langchain/callback.d.ts.map +1 -1
  162. package/dist/langchain/callback.js +32 -30
  163. package/dist/langchain/callback.js.map +1 -1
  164. package/dist/langchain/executor.d.ts +4 -11
  165. package/dist/langchain/executor.d.ts.map +1 -1
  166. package/dist/langchain/executor.js +82 -82
  167. package/dist/langchain/executor.js.map +1 -1
  168. package/dist/langchain/index.d.ts +5 -5
  169. package/dist/langchain/index.d.ts.map +1 -1
  170. package/dist/langchain/index.js +7 -5
  171. package/dist/langchain/index.js.map +1 -1
  172. package/dist/langchain/tools.d.ts +1 -1
  173. package/dist/langchain/tools.d.ts.map +1 -1
  174. package/dist/langchain/tools.js +36 -43
  175. package/dist/langchain/tools.js.map +1 -1
  176. package/dist/langchain/types.d.ts +3 -3
  177. package/dist/langchain/types.d.ts.map +1 -1
  178. package/dist/langchain/types.js +2 -7
  179. package/dist/langchain/types.js.map +1 -1
  180. package/dist/layers/implementations/L0-request-format.d.ts +2 -2
  181. package/dist/layers/implementations/L0-request-format.d.ts.map +1 -1
  182. package/dist/layers/implementations/L0-request-format.js +54 -54
  183. package/dist/layers/implementations/L0-request-format.js.map +1 -1
  184. package/dist/layers/implementations/L1-input-size.d.ts +2 -2
  185. package/dist/layers/implementations/L1-input-size.d.ts.map +1 -1
  186. package/dist/layers/implementations/L1-input-size.js +41 -49
  187. package/dist/layers/implementations/L1-input-size.js.map +1 -1
  188. package/dist/layers/implementations/L2-charset-sanitizer.d.ts +2 -2
  189. package/dist/layers/implementations/L2-charset-sanitizer.d.ts.map +1 -1
  190. package/dist/layers/implementations/L2-charset-sanitizer.js +73 -81
  191. package/dist/layers/implementations/L2-charset-sanitizer.js.map +1 -1
  192. package/dist/layers/implementations/L3-schema-conformance.d.ts +3 -3
  193. package/dist/layers/implementations/L3-schema-conformance.d.ts.map +1 -1
  194. package/dist/layers/implementations/L3-schema-conformance.js +75 -82
  195. package/dist/layers/implementations/L3-schema-conformance.js.map +1 -1
  196. package/dist/layers/implementations/L4-injection-detector.d.ts +4 -4
  197. package/dist/layers/implementations/L4-injection-detector.d.ts.map +1 -1
  198. package/dist/layers/implementations/L4-injection-detector.js +83 -85
  199. package/dist/layers/implementations/L4-injection-detector.js.map +1 -1
  200. package/dist/layers/implementations/L5-rate-limiter.d.ts +2 -2
  201. package/dist/layers/implementations/L5-rate-limiter.d.ts.map +1 -1
  202. package/dist/layers/implementations/L5-rate-limiter.js +22 -20
  203. package/dist/layers/implementations/L5-rate-limiter.js.map +1 -1
  204. package/dist/layers/implementations/index.d.ts +6 -6
  205. package/dist/layers/implementations/index.d.ts.map +1 -1
  206. package/dist/layers/implementations/index.js +8 -6
  207. package/dist/layers/implementations/index.js.map +1 -1
  208. package/dist/layers/index.d.ts +3 -11
  209. package/dist/layers/index.d.ts.map +1 -1
  210. package/dist/layers/index.js +73 -99
  211. package/dist/layers/index.js.map +1 -1
  212. package/dist/layers/types.d.ts +16 -16
  213. package/dist/layers/types.d.ts.map +1 -1
  214. package/dist/layers/types.js +2 -8
  215. package/dist/layers/types.js.map +1 -1
  216. package/dist/paramesphere/activation-collector.d.ts +128 -0
  217. package/dist/paramesphere/activation-collector.d.ts.map +1 -0
  218. package/dist/paramesphere/activation-collector.js +260 -0
  219. package/dist/paramesphere/activation-collector.js.map +1 -0
  220. package/dist/paramesphere/cognitive-envelope.d.ts +73 -0
  221. package/dist/paramesphere/cognitive-envelope.d.ts.map +1 -0
  222. package/dist/paramesphere/cognitive-envelope.js +209 -0
  223. package/dist/paramesphere/cognitive-envelope.js.map +1 -0
  224. package/dist/paramesphere/envelope-integration.d.ts +60 -0
  225. package/dist/paramesphere/envelope-integration.d.ts.map +1 -0
  226. package/dist/paramesphere/envelope-integration.js +93 -0
  227. package/dist/paramesphere/envelope-integration.js.map +1 -0
  228. package/dist/paramesphere/fingerprint-monitor.d.ts +136 -0
  229. package/dist/paramesphere/fingerprint-monitor.d.ts.map +1 -0
  230. package/dist/paramesphere/fingerprint-monitor.js +212 -0
  231. package/dist/paramesphere/fingerprint-monitor.js.map +1 -0
  232. package/dist/paramesphere/fingerprint-store.d.ts +85 -0
  233. package/dist/paramesphere/fingerprint-store.d.ts.map +1 -0
  234. package/dist/paramesphere/fingerprint-store.js +68 -0
  235. package/dist/paramesphere/fingerprint-store.js.map +1 -0
  236. package/dist/paramesphere/index.d.ts +21 -0
  237. package/dist/paramesphere/index.d.ts.map +1 -0
  238. package/dist/paramesphere/index.js +18 -0
  239. package/dist/paramesphere/index.js.map +1 -0
  240. package/dist/paramesphere/monitor-integration.d.ts +37 -0
  241. package/dist/paramesphere/monitor-integration.d.ts.map +1 -0
  242. package/dist/paramesphere/monitor-integration.js +81 -0
  243. package/dist/paramesphere/monitor-integration.js.map +1 -0
  244. package/dist/paramesphere/paramesphere-engine.d.ts +111 -0
  245. package/dist/paramesphere/paramesphere-engine.d.ts.map +1 -0
  246. package/dist/paramesphere/paramesphere-engine.js +542 -0
  247. package/dist/paramesphere/paramesphere-engine.js.map +1 -0
  248. package/dist/paramesphere/types.d.ts +142 -0
  249. package/dist/paramesphere/types.d.ts.map +1 -0
  250. package/dist/paramesphere/types.js +4 -0
  251. package/dist/paramesphere/types.js.map +1 -0
  252. package/dist/persistence/file.d.ts +3 -10
  253. package/dist/persistence/file.d.ts.map +1 -1
  254. package/dist/persistence/file.js +30 -32
  255. package/dist/persistence/file.js.map +1 -1
  256. package/dist/persistence/index.d.ts +7 -7
  257. package/dist/persistence/index.d.ts.map +1 -1
  258. package/dist/persistence/index.js +20 -18
  259. package/dist/persistence/index.js.map +1 -1
  260. package/dist/persistence/memory.d.ts +3 -3
  261. package/dist/persistence/memory.d.ts.map +1 -1
  262. package/dist/persistence/memory.js +10 -17
  263. package/dist/persistence/memory.js.map +1 -1
  264. package/dist/persistence/sqlite.d.ts +3 -11
  265. package/dist/persistence/sqlite.d.ts.map +1 -1
  266. package/dist/persistence/sqlite.js +42 -39
  267. package/dist/persistence/sqlite.js.map +1 -1
  268. package/dist/persistence/supabase.d.ts +3 -3
  269. package/dist/persistence/supabase.d.ts.map +1 -1
  270. package/dist/persistence/supabase.js +46 -49
  271. package/dist/persistence/supabase.js.map +1 -1
  272. package/dist/persistence/types.d.ts +5 -5
  273. package/dist/persistence/types.d.ts.map +1 -1
  274. package/dist/persistence/types.js +2 -7
  275. package/dist/persistence/types.js.map +1 -1
  276. package/dist/phase6/ceiling.d.ts +5 -21
  277. package/dist/phase6/ceiling.d.ts.map +1 -1
  278. package/dist/phase6/ceiling.js +38 -69
  279. package/dist/phase6/ceiling.js.map +1 -1
  280. package/dist/phase6/context.d.ts +3 -20
  281. package/dist/phase6/context.d.ts.map +1 -1
  282. package/dist/phase6/context.js +49 -93
  283. package/dist/phase6/context.js.map +1 -1
  284. package/dist/phase6/index.d.ts +12 -12
  285. package/dist/phase6/index.d.ts.map +1 -1
  286. package/dist/phase6/index.js +17 -15
  287. package/dist/phase6/index.js.map +1 -1
  288. package/dist/phase6/presets.d.ts +2 -18
  289. package/dist/phase6/presets.d.ts.map +1 -1
  290. package/dist/phase6/presets.js +35 -39
  291. package/dist/phase6/presets.js.map +1 -1
  292. package/dist/phase6/provenance.d.ts +4 -19
  293. package/dist/phase6/provenance.d.ts.map +1 -1
  294. package/dist/phase6/provenance.js +37 -42
  295. package/dist/phase6/provenance.js.map +1 -1
  296. package/dist/phase6/role-gates/index.d.ts +2 -2
  297. package/dist/phase6/role-gates/index.d.ts.map +1 -1
  298. package/dist/phase6/role-gates/index.js +4 -2
  299. package/dist/phase6/role-gates/index.js.map +1 -1
  300. package/dist/phase6/role-gates/kernel.d.ts.map +1 -1
  301. package/dist/phase6/role-gates/kernel.js +18 -16
  302. package/dist/phase6/role-gates/kernel.js.map +1 -1
  303. package/dist/phase6/role-gates/policy.d.ts +2 -2
  304. package/dist/phase6/role-gates/policy.d.ts.map +1 -1
  305. package/dist/phase6/role-gates/policy.js +8 -17
  306. package/dist/phase6/role-gates/policy.js.map +1 -1
  307. package/dist/phase6/role-gates.d.ts +4 -20
  308. package/dist/phase6/role-gates.d.ts.map +1 -1
  309. package/dist/phase6/role-gates.js +60 -80
  310. package/dist/phase6/role-gates.js.map +1 -1
  311. package/dist/phase6/types.d.ts +53 -23
  312. package/dist/phase6/types.d.ts.map +1 -1
  313. package/dist/phase6/types.js +131 -177
  314. package/dist/phase6/types.js.map +1 -1
  315. package/dist/phase6/weight-presets/canonical.d.ts.map +1 -1
  316. package/dist/phase6/weight-presets/canonical.js +12 -10
  317. package/dist/phase6/weight-presets/canonical.js.map +1 -1
  318. package/dist/phase6/weight-presets/deltas.d.ts +2 -2
  319. package/dist/phase6/weight-presets/deltas.d.ts.map +1 -1
  320. package/dist/phase6/weight-presets/deltas.js +29 -37
  321. package/dist/phase6/weight-presets/deltas.js.map +1 -1
  322. package/dist/phase6/weight-presets/index.d.ts +3 -3
  323. package/dist/phase6/weight-presets/index.d.ts.map +1 -1
  324. package/dist/phase6/weight-presets/index.js +5 -3
  325. package/dist/phase6/weight-presets/index.js.map +1 -1
  326. package/dist/phase6/weight-presets/merger.d.ts +2 -12
  327. package/dist/phase6/weight-presets/merger.d.ts.map +1 -1
  328. package/dist/phase6/weight-presets/merger.js +45 -39
  329. package/dist/phase6/weight-presets/merger.js.map +1 -1
  330. package/dist/proof/index.d.ts +6 -13
  331. package/dist/proof/index.d.ts.map +1 -1
  332. package/dist/proof/index.js +63 -51
  333. package/dist/proof/index.js.map +1 -1
  334. package/dist/proof/merkle.d.ts +24 -19
  335. package/dist/proof/merkle.d.ts.map +1 -1
  336. package/dist/proof/merkle.js +118 -32
  337. package/dist/proof/merkle.js.map +1 -1
  338. package/dist/proof/zk-proofs.d.ts +6 -24
  339. package/dist/proof/zk-proofs.d.ts.map +1 -1
  340. package/dist/proof/zk-proofs.js +45 -42
  341. package/dist/proof/zk-proofs.js.map +1 -1
  342. package/dist/provenance/index.d.ts +3 -11
  343. package/dist/provenance/index.d.ts.map +1 -1
  344. package/dist/provenance/index.js +19 -19
  345. package/dist/provenance/index.js.map +1 -1
  346. package/dist/provenance/types.d.ts +4 -4
  347. package/dist/provenance/types.d.ts.map +1 -1
  348. package/dist/provenance/types.js +2 -8
  349. package/dist/provenance/types.js.map +1 -1
  350. package/dist/sandbox-training/challenges.d.ts +1 -1
  351. package/dist/sandbox-training/challenges.d.ts.map +1 -1
  352. package/dist/sandbox-training/challenges.js +230 -236
  353. package/dist/sandbox-training/challenges.js.map +1 -1
  354. package/dist/sandbox-training/graduation.d.ts +1 -1
  355. package/dist/sandbox-training/graduation.d.ts.map +1 -1
  356. package/dist/sandbox-training/graduation.js +17 -22
  357. package/dist/sandbox-training/graduation.js.map +1 -1
  358. package/dist/sandbox-training/index.d.ts +9 -9
  359. package/dist/sandbox-training/index.d.ts.map +1 -1
  360. package/dist/sandbox-training/index.js +8 -6
  361. package/dist/sandbox-training/index.js.map +1 -1
  362. package/dist/sandbox-training/promotion-service.d.ts +4 -4
  363. package/dist/sandbox-training/promotion-service.d.ts.map +1 -1
  364. package/dist/sandbox-training/promotion-service.js +7 -16
  365. package/dist/sandbox-training/promotion-service.js.map +1 -1
  366. package/dist/sandbox-training/runner.d.ts +1 -1
  367. package/dist/sandbox-training/runner.d.ts.map +1 -1
  368. package/dist/sandbox-training/runner.js +75 -82
  369. package/dist/sandbox-training/runner.js.map +1 -1
  370. package/dist/sandbox-training/scorer.d.ts +4 -4
  371. package/dist/sandbox-training/scorer.d.ts.map +1 -1
  372. package/dist/sandbox-training/scorer.js +7 -13
  373. package/dist/sandbox-training/scorer.js.map +1 -1
  374. package/dist/sandbox-training/types.d.ts +4 -4
  375. package/dist/sandbox-training/types.d.ts.map +1 -1
  376. package/dist/sandbox-training/types.js +9 -19
  377. package/dist/sandbox-training/types.js.map +1 -1
  378. package/dist/trust-engine/ceiling-enforcement/audit.d.ts +1 -9
  379. package/dist/trust-engine/ceiling-enforcement/audit.d.ts.map +1 -1
  380. package/dist/trust-engine/ceiling-enforcement/audit.js +6 -11
  381. package/dist/trust-engine/ceiling-enforcement/audit.js.map +1 -1
  382. package/dist/trust-engine/ceiling-enforcement/index.d.ts +2 -2
  383. package/dist/trust-engine/ceiling-enforcement/index.d.ts.map +1 -1
  384. package/dist/trust-engine/ceiling-enforcement/index.js +4 -2
  385. package/dist/trust-engine/ceiling-enforcement/index.js.map +1 -1
  386. package/dist/trust-engine/ceiling-enforcement/kernel.d.ts +12 -10
  387. package/dist/trust-engine/ceiling-enforcement/kernel.d.ts.map +1 -1
  388. package/dist/trust-engine/ceiling-enforcement/kernel.js +28 -20
  389. package/dist/trust-engine/ceiling-enforcement/kernel.js.map +1 -1
  390. package/dist/trust-engine/context-policy/enforcement.d.ts +0 -9
  391. package/dist/trust-engine/context-policy/enforcement.d.ts.map +1 -1
  392. package/dist/trust-engine/context-policy/enforcement.js +2 -9
  393. package/dist/trust-engine/context-policy/enforcement.js.map +1 -1
  394. package/dist/trust-engine/context-policy/factory.d.ts +1 -1
  395. package/dist/trust-engine/context-policy/factory.d.ts.map +1 -1
  396. package/dist/trust-engine/context-policy/factory.js +3 -1
  397. package/dist/trust-engine/context-policy/factory.js.map +1 -1
  398. package/dist/trust-engine/context-policy/index.d.ts +2 -2
  399. package/dist/trust-engine/context-policy/index.d.ts.map +1 -1
  400. package/dist/trust-engine/context-policy/index.js +4 -2
  401. package/dist/trust-engine/context-policy/index.js.map +1 -1
  402. package/dist/trust-engine/creation-modifiers/index.d.ts +1 -1
  403. package/dist/trust-engine/creation-modifiers/index.d.ts.map +1 -1
  404. package/dist/trust-engine/creation-modifiers/index.js +3 -1
  405. package/dist/trust-engine/creation-modifiers/index.js.map +1 -1
  406. package/dist/trust-engine/creation-modifiers/types.d.ts.map +1 -1
  407. package/dist/trust-engine/creation-modifiers/types.js +5 -2
  408. package/dist/trust-engine/creation-modifiers/types.js.map +1 -1
  409. package/dist/trust-engine/decay-profiles.d.ts +37 -136
  410. package/dist/trust-engine/decay-profiles.d.ts.map +1 -1
  411. package/dist/trust-engine/decay-profiles.js +61 -183
  412. package/dist/trust-engine/decay-profiles.js.map +1 -1
  413. package/dist/trust-engine/index.d.ts +327 -22
  414. package/dist/trust-engine/index.d.ts.map +1 -1
  415. package/dist/trust-engine/index.js +706 -130
  416. package/dist/trust-engine/index.js.map +1 -1
  417. package/dist/trust-engine/phase6-types.d.ts +15 -18
  418. package/dist/trust-engine/phase6-types.d.ts.map +1 -1
  419. package/dist/trust-engine/phase6-types.js +32 -36
  420. package/dist/trust-engine/phase6-types.js.map +1 -1
  421. package/dist/trust-engine/trust-verifier.d.ts +121 -0
  422. package/dist/trust-engine/trust-verifier.d.ts.map +1 -0
  423. package/dist/trust-engine/trust-verifier.js +226 -0
  424. package/dist/trust-engine/trust-verifier.js.map +1 -0
  425. package/package.json +140 -135
  426. package/dist/enforce/types.d.ts +0 -234
  427. package/dist/enforce/types.d.ts.map +0 -1
  428. package/dist/enforce/types.js +0 -10
  429. package/dist/enforce/types.js.map +0 -1
  430. package/dist/intent/types.d.ts +0 -69
  431. package/dist/intent/types.d.ts.map +0 -1
  432. package/dist/intent/types.js +0 -10
  433. package/dist/intent/types.js.map +0 -1
  434. package/dist/trust-engine/types.d.ts +0 -77
  435. package/dist/trust-engine/types.d.ts.map +0 -1
  436. package/dist/trust-engine/types.js +0 -20
  437. package/dist/trust-engine/types.js.map +0 -1
@@ -1,3 +1,5 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // Copyright 2024-2026 Vorion LLC
1
3
  /**
2
4
  * INTENT GATEWAY - Jurisdictional Router & Governance Topology Selector
3
5
  *
@@ -21,89 +23,61 @@
21
23
  *
22
24
  * @packageDocumentation
23
25
  */
24
- import { createLogger } from "../common/logger.js";
26
+ import { createLogger } from '../common/logger.js';
25
27
  // ---------------------------------------------------------------------------
26
28
  // Logger
27
29
  // ---------------------------------------------------------------------------
28
- const logger = createLogger({ component: "intent-gateway" });
30
+ const logger = createLogger({ component: 'intent-gateway' });
29
31
  // ---------------------------------------------------------------------------
30
32
  // Constants & Union Types
31
33
  // ---------------------------------------------------------------------------
32
34
  /** Supported jurisdictional scopes. */
33
35
  export const JURISDICTIONS = [
34
- "GLOBAL",
35
- "EU",
36
- "US",
37
- "APAC",
38
- "UK",
39
- "CA",
40
- "AU",
41
- "JP",
42
- "SG",
43
- "CH",
36
+ 'GLOBAL', 'EU', 'US', 'APAC', 'UK', 'CA', 'AU', 'JP', 'SG', 'CH',
44
37
  ];
45
38
  /** Industry verticals that affect policy selection. */
46
39
  export const INDUSTRIES = [
47
- "general",
48
- "healthcare",
49
- "finance",
50
- "defense",
51
- "government",
52
- "education",
53
- "energy",
40
+ 'general', 'healthcare', 'finance', 'defense', 'government',
41
+ 'education', 'energy',
54
42
  ];
55
43
  /** Cryptographic suite requirements, ordered by strictness. */
56
44
  export const CRYPTO_SUITES = [
57
- "standard",
58
- "fips-140-2",
59
- "post-quantum",
45
+ 'standard', 'fips-140-2', 'post-quantum',
60
46
  ];
61
47
  /** Proof anchoring methods, ordered by assurance level. */
62
48
  export const PROOF_ANCHORING_METHODS = [
63
- "database",
64
- "merkle-tree",
65
- "blockchain-l2",
66
- "tsa-rfc3161",
49
+ 'database', 'merkle-tree', 'blockchain-l2', 'tsa-rfc3161',
67
50
  ];
68
51
  /** Consent models, ordered by strictness. */
69
52
  export const CONSENT_MODELS = [
70
- "implicit",
71
- "opt-out",
72
- "opt-in",
73
- "explicit-granular",
53
+ 'implicit', 'opt-out', 'opt-in', 'explicit-granular',
74
54
  ];
75
55
  /** Escalation modes, ordered by severity. */
76
56
  export const ESCALATION_MODES = [
77
- "log-only",
78
- "flag-review",
79
- "block-escalate",
80
- "hard-block",
57
+ 'log-only', 'flag-review', 'block-escalate', 'hard-block',
81
58
  ];
82
59
  /** EU AI Act risk classification tiers. */
83
60
  export const AI_ACT_CLASSIFICATIONS = [
84
- "unacceptable",
85
- "high-risk",
86
- "limited-risk",
87
- "minimal-risk",
61
+ 'unacceptable', 'high-risk', 'limited-risk', 'minimal-risk',
88
62
  ];
89
63
  /** High-risk categories under Annex III of the EU AI Act. */
90
64
  export const AI_ACT_HIGH_RISK_CATEGORIES = [
91
- "biometric-identification",
92
- "critical-infrastructure",
93
- "education-vocational",
94
- "employment-worker-management",
95
- "essential-services",
96
- "law-enforcement",
97
- "migration-asylum-border",
98
- "justice-democratic",
65
+ 'biometric-identification',
66
+ 'critical-infrastructure',
67
+ 'education-vocational',
68
+ 'employment-worker-management',
69
+ 'essential-services',
70
+ 'law-enforcement',
71
+ 'migration-asylum-border',
72
+ 'justice-democratic',
99
73
  ];
100
74
  // ---------------------------------------------------------------------------
101
75
  // Default Configuration
102
76
  // ---------------------------------------------------------------------------
103
77
  export const DEFAULT_GATEWAY_CONFIG = {
104
78
  enabled: true,
105
- defaultJurisdiction: "GLOBAL",
106
- defaultIndustry: "general",
79
+ defaultJurisdiction: 'GLOBAL',
80
+ defaultIndustry: 'general',
107
81
  regimeCacheTtlMs: 5 * 60 * 1000, // 5 minutes
108
82
  blockOnConflicts: true,
109
83
  logRegimeDecisions: true,
@@ -115,75 +89,36 @@ export const DEFAULT_GATEWAY_CONFIG = {
115
89
  * Data residency zones mapped to each jurisdiction.
116
90
  */
117
91
  export const JURISDICTION_RESIDENCY_ZONES = {
118
- GLOBAL: "global",
119
- EU: "eu-west",
120
- US: "us-east",
121
- APAC: "ap-southeast-1",
122
- UK: "uk-south",
123
- CA: "ca-central",
124
- AU: "au-southeast",
125
- JP: "ap-northeast-1",
126
- SG: "ap-southeast-1",
127
- CH: "eu-central",
92
+ GLOBAL: 'global',
93
+ EU: 'eu-west',
94
+ US: 'us-east',
95
+ APAC: 'ap-southeast-1',
96
+ UK: 'uk-south',
97
+ CA: 'ca-central',
98
+ AU: 'au-southeast',
99
+ JP: 'ap-northeast-1',
100
+ SG: 'ap-southeast-1',
101
+ CH: 'eu-central',
128
102
  };
129
103
  /** EU/EEA member state ISO 3166-1 alpha-2 codes. */
130
104
  const EU_MEMBER_STATE_CODES = new Set([
131
- "AT",
132
- "BE",
133
- "BG",
134
- "HR",
135
- "CY",
136
- "CZ",
137
- "DK",
138
- "EE",
139
- "FI",
140
- "FR",
141
- "DE",
142
- "GR",
143
- "HU",
144
- "IE",
145
- "IT",
146
- "LV",
147
- "LT",
148
- "LU",
149
- "MT",
150
- "NL",
151
- "PL",
152
- "PT",
153
- "RO",
154
- "SK",
155
- "SI",
156
- "ES",
157
- "SE",
158
- "IS",
159
- "LI",
160
- "NO",
105
+ 'AT', 'BE', 'BG', 'HR', 'CY', 'CZ', 'DK', 'EE', 'FI', 'FR',
106
+ 'DE', 'GR', 'HU', 'IE', 'IT', 'LV', 'LT', 'LU', 'MT', 'NL',
107
+ 'PL', 'PT', 'RO', 'SK', 'SI', 'ES', 'SE', 'IS', 'LI', 'NO',
161
108
  ]);
162
109
  /** APAC country codes for regional mapping. */
163
110
  const APAC_COUNTRY_CODES = new Set([
164
- "JP",
165
- "KR",
166
- "SG",
167
- "AU",
168
- "NZ",
169
- "IN",
170
- "TH",
171
- "MY",
172
- "ID",
173
- "PH",
174
- "VN",
175
- "TW",
176
- "HK",
111
+ 'JP', 'KR', 'SG', 'AU', 'NZ', 'IN', 'TH', 'MY', 'ID', 'PH', 'VN', 'TW', 'HK',
177
112
  ]);
178
113
  /** Direct country-to-jurisdiction mapping for countries with specific regimes. */
179
114
  const COUNTRY_JURISDICTION_MAP = {
180
- US: "US",
181
- GB: "UK",
182
- CA: "CA",
183
- AU: "AU",
184
- JP: "JP",
185
- SG: "SG",
186
- CH: "CH",
115
+ US: 'US',
116
+ GB: 'UK',
117
+ CA: 'CA',
118
+ AU: 'AU',
119
+ JP: 'JP',
120
+ SG: 'SG',
121
+ CH: 'CH',
187
122
  };
188
123
  /**
189
124
  * Resolves jurisdictional context from tenant configuration, intent metadata,
@@ -207,17 +142,17 @@ export class JurisdictionResolver {
207
142
  // Tier 1: Explicit tenant configuration
208
143
  const tenantResult = this.resolveFromTenantConfig(tenantId);
209
144
  if (tenantResult) {
210
- logger.debug({ tenantId, source: "tenant-config" }, "Jurisdiction from tenant config");
145
+ logger.debug({ tenantId, source: 'tenant-config' }, 'Jurisdiction from tenant config');
211
146
  return tenantResult;
212
147
  }
213
148
  // Tier 2: Infer from intent metadata
214
149
  const metadataResult = this.resolveFromMetadata(intentMetadata);
215
150
  if (metadataResult) {
216
- logger.debug({ tenantId, source: "metadata" }, "Jurisdiction from metadata");
151
+ logger.debug({ tenantId, source: 'metadata' }, 'Jurisdiction from metadata');
217
152
  return metadataResult;
218
153
  }
219
154
  // Tier 3: Gateway defaults
220
- logger.debug({ tenantId, source: "default" }, "Jurisdiction from defaults");
155
+ logger.debug({ tenantId, source: 'default' }, 'Jurisdiction from defaults');
221
156
  return this.resolveDefault();
222
157
  }
223
158
  /**
@@ -225,7 +160,7 @@ export class JurisdictionResolver {
225
160
  */
226
161
  registerTenantConfig(tenantId, config) {
227
162
  this.tenantConfigs.set(tenantId, config);
228
- logger.info({ tenantId, jurisdictions: config.jurisdictions }, "Tenant config registered");
163
+ logger.info({ tenantId, jurisdictions: config.jurisdictions }, 'Tenant config registered');
229
164
  }
230
165
  /**
231
166
  * Retrieve a tenant's jurisdiction configuration.
@@ -240,7 +175,7 @@ export class JurisdictionResolver {
240
175
  detectCrossBorderTransfer(jurisdictions) {
241
176
  if (jurisdictions.length <= 1)
242
177
  return false;
243
- const zones = new Set(jurisdictions.map((j) => JURISDICTION_RESIDENCY_ZONES[j]));
178
+ const zones = new Set(jurisdictions.map(j => JURISDICTION_RESIDENCY_ZONES[j]));
244
179
  return zones.size > 1;
245
180
  }
246
181
  resolveFromTenantConfig(tenantId) {
@@ -252,9 +187,9 @@ export class JurisdictionResolver {
252
187
  industry: config.industry,
253
188
  dataResidency: config.dataResidency ??
254
189
  JURISDICTION_RESIDENCY_ZONES[config.jurisdictions[0]] ??
255
- "global",
190
+ 'global',
256
191
  crossBorderTransfer: this.detectCrossBorderTransfer(config.jurisdictions),
257
- source: "tenant-config",
192
+ source: 'tenant-config',
258
193
  };
259
194
  }
260
195
  resolveFromMetadata(metadata) {
@@ -263,31 +198,27 @@ export class JurisdictionResolver {
263
198
  const jurisdictions = this.extractJurisdictionsFromMetadata(metadata);
264
199
  if (jurisdictions.length === 0)
265
200
  return null;
266
- const industry = typeof metadata.industry === "string" &&
267
- this.isValidIndustry(metadata.industry)
201
+ const industry = typeof metadata.industry === 'string' && this.isValidIndustry(metadata.industry)
268
202
  ? metadata.industry
269
203
  : this.config.defaultIndustry;
270
- const dataResidency = (typeof metadata.dataResidency === "string"
271
- ? metadata.dataResidency
272
- : undefined) ??
204
+ const dataResidency = (typeof metadata.dataResidency === 'string' ? metadata.dataResidency : undefined) ??
273
205
  JURISDICTION_RESIDENCY_ZONES[jurisdictions[0]] ??
274
- "global";
206
+ 'global';
275
207
  return {
276
208
  primaryJurisdictions: jurisdictions,
277
209
  industry,
278
210
  dataResidency,
279
211
  crossBorderTransfer: this.detectCrossBorderTransfer(jurisdictions),
280
- source: "metadata-inference",
212
+ source: 'metadata-inference',
281
213
  };
282
214
  }
283
215
  resolveDefault() {
284
216
  return {
285
217
  primaryJurisdictions: [this.config.defaultJurisdiction],
286
218
  industry: this.config.defaultIndustry,
287
- dataResidency: JURISDICTION_RESIDENCY_ZONES[this.config.defaultJurisdiction] ??
288
- "global",
219
+ dataResidency: JURISDICTION_RESIDENCY_ZONES[this.config.defaultJurisdiction] ?? 'global',
289
220
  crossBorderTransfer: false,
290
- source: "default",
221
+ source: 'default',
291
222
  };
292
223
  }
293
224
  /**
@@ -298,7 +229,7 @@ export class JurisdictionResolver {
298
229
  extractJurisdictionsFromMetadata(metadata) {
299
230
  const jurisdictions = [];
300
231
  // Direct jurisdiction field
301
- if (typeof metadata.jurisdiction === "string") {
232
+ if (typeof metadata.jurisdiction === 'string') {
302
233
  const j = metadata.jurisdiction.toUpperCase();
303
234
  if (this.isValidJurisdiction(j))
304
235
  jurisdictions.push(j);
@@ -306,7 +237,7 @@ export class JurisdictionResolver {
306
237
  // Jurisdictions array
307
238
  if (Array.isArray(metadata.jurisdictions)) {
308
239
  for (const item of metadata.jurisdictions) {
309
- if (typeof item === "string") {
240
+ if (typeof item === 'string') {
310
241
  const j = item.toUpperCase();
311
242
  if (this.isValidJurisdiction(j) && !jurisdictions.includes(j)) {
312
243
  jurisdictions.push(j);
@@ -315,11 +246,11 @@ export class JurisdictionResolver {
315
246
  }
316
247
  }
317
248
  // Country code inference
318
- if (typeof metadata.countryCode === "string") {
249
+ if (typeof metadata.countryCode === 'string') {
319
250
  const code = metadata.countryCode.toUpperCase();
320
251
  if (EU_MEMBER_STATE_CODES.has(code)) {
321
- if (!jurisdictions.includes("EU"))
322
- jurisdictions.push("EU");
252
+ if (!jurisdictions.includes('EU'))
253
+ jurisdictions.push('EU');
323
254
  }
324
255
  else if (COUNTRY_JURISDICTION_MAP[code]) {
325
256
  const j = COUNTRY_JURISDICTION_MAP[code];
@@ -327,24 +258,24 @@ export class JurisdictionResolver {
327
258
  jurisdictions.push(j);
328
259
  }
329
260
  else if (APAC_COUNTRY_CODES.has(code)) {
330
- if (!jurisdictions.includes("APAC"))
331
- jurisdictions.push("APAC");
261
+ if (!jurisdictions.includes('APAC'))
262
+ jurisdictions.push('APAC');
332
263
  }
333
264
  }
334
265
  // Region string inference
335
- if (typeof metadata.region === "string") {
266
+ if (typeof metadata.region === 'string') {
336
267
  const region = metadata.region.toUpperCase();
337
- if (["EU", "EUROPE", "EEA"].includes(region)) {
338
- if (!jurisdictions.includes("EU"))
339
- jurisdictions.push("EU");
268
+ if (['EU', 'EUROPE', 'EEA'].includes(region)) {
269
+ if (!jurisdictions.includes('EU'))
270
+ jurisdictions.push('EU');
340
271
  }
341
- else if (["US", "UNITED STATES", "NORTH AMERICA"].includes(region)) {
342
- if (!jurisdictions.includes("US"))
343
- jurisdictions.push("US");
272
+ else if (['US', 'UNITED STATES', 'NORTH AMERICA'].includes(region)) {
273
+ if (!jurisdictions.includes('US'))
274
+ jurisdictions.push('US');
344
275
  }
345
- else if (["APAC", "ASIA", "ASIA-PACIFIC"].includes(region)) {
346
- if (!jurisdictions.includes("APAC"))
347
- jurisdictions.push("APAC");
276
+ else if (['APAC', 'ASIA', 'ASIA-PACIFIC'].includes(region)) {
277
+ if (!jurisdictions.includes('APAC'))
278
+ jurisdictions.push('APAC');
348
279
  }
349
280
  }
350
281
  return jurisdictions;
@@ -365,47 +296,39 @@ export class JurisdictionResolver {
365
296
  * the strictest value wins.
366
297
  */
367
298
  const CRYPTO_SUITE_STRICTNESS = {
368
- standard: 0,
369
- "fips-140-2": 1,
370
- "post-quantum": 2,
299
+ 'standard': 0,
300
+ 'fips-140-2': 1,
301
+ 'post-quantum': 2,
371
302
  };
372
303
  const CONSENT_STRICTNESS = {
373
- implicit: 0,
374
- "opt-out": 1,
375
- "opt-in": 2,
376
- "explicit-granular": 3,
304
+ 'implicit': 0,
305
+ 'opt-out': 1,
306
+ 'opt-in': 2,
307
+ 'explicit-granular': 3,
377
308
  };
378
309
  const ESCALATION_STRICTNESS = {
379
- "log-only": 0,
380
- "flag-review": 1,
381
- "block-escalate": 2,
382
- "hard-block": 3,
310
+ 'log-only': 0,
311
+ 'flag-review': 1,
312
+ 'block-escalate': 2,
313
+ 'hard-block': 3,
383
314
  };
384
315
  const PROOF_ANCHORING_STRICTNESS = {
385
- database: 0,
386
- "merkle-tree": 1,
387
- "blockchain-l2": 2,
388
- "tsa-rfc3161": 3,
316
+ 'database': 0,
317
+ 'merkle-tree': 1,
318
+ 'blockchain-l2': 2,
319
+ 'tsa-rfc3161': 3,
389
320
  };
390
321
  const ENFORCEMENT_ORDER = {
391
- advisory: 0,
392
- required: 1,
393
- mandatory: 2,
394
- blocking: 3,
322
+ 'advisory': 0,
323
+ 'required': 1,
324
+ 'mandatory': 2,
325
+ 'blocking': 3,
395
326
  };
396
327
  /**
397
328
  * Helper to create a PolicyConstraint with less boilerplate.
398
329
  */
399
330
  function constraint(id, type, rule, enforcement, bundleId, jurisdiction, value) {
400
- return {
401
- id,
402
- type,
403
- rule,
404
- enforcement,
405
- sourceBundleId: bundleId,
406
- sourceJurisdiction: jurisdiction,
407
- value,
408
- };
331
+ return { id, type, rule, enforcement, sourceBundleId: bundleId, sourceJurisdiction: jurisdiction, value };
409
332
  }
410
333
  /**
411
334
  * Built-in policy bundles covering the major jurisdictional scopes.
@@ -415,98 +338,98 @@ function createBuiltinBundles() {
415
338
  return [
416
339
  // -- GLOBAL DEFAULT --
417
340
  {
418
- id: "global-default",
419
- name: "Global Default",
420
- jurisdictions: ["GLOBAL"],
341
+ id: 'global-default',
342
+ name: 'Global Default',
343
+ jurisdictions: ['GLOBAL'],
421
344
  priority: 0,
422
345
  constraints: [
423
- constraint("global-retention", "retention", "Min 365-day audit retention", "required", "global-default", "GLOBAL", 365),
424
- constraint("global-crypto", "crypto", "Standard cryptographic suite", "required", "global-default", "GLOBAL", "standard"),
425
- constraint("global-consent", "consent", "Implicit consent model", "required", "global-default", "GLOBAL", "implicit"),
426
- constraint("global-escalation", "escalation", "Flag for human review", "required", "global-default", "GLOBAL", "flag-review"),
427
- constraint("global-trust", "trust-level", "Minimum trust T2 (Provisional)", "required", "global-default", "GLOBAL", 2),
428
- constraint("global-proof", "proof-anchoring", "Database proof anchoring", "required", "global-default", "GLOBAL", "database"),
429
- constraint("global-external", "external-services", "External services allowed", "advisory", "global-default", "GLOBAL", true),
346
+ constraint('global-retention', 'retention', 'Min 365-day audit retention', 'required', 'global-default', 'GLOBAL', 365),
347
+ constraint('global-crypto', 'crypto', 'Standard cryptographic suite', 'required', 'global-default', 'GLOBAL', 'standard'),
348
+ constraint('global-consent', 'consent', 'Implicit consent model', 'required', 'global-default', 'GLOBAL', 'implicit'),
349
+ constraint('global-escalation', 'escalation', 'Flag for human review', 'required', 'global-default', 'GLOBAL', 'flag-review'),
350
+ constraint('global-trust', 'trust-level', 'Minimum trust T2 (Provisional)', 'required', 'global-default', 'GLOBAL', 2),
351
+ constraint('global-proof', 'proof-anchoring', 'Database proof anchoring', 'required', 'global-default', 'GLOBAL', 'database'),
352
+ constraint('global-external', 'external-services', 'External services allowed', 'advisory', 'global-default', 'GLOBAL', true),
430
353
  ],
431
354
  },
432
355
  // -- EU (GDPR + AI Act) --
433
356
  {
434
- id: "eu-gdpr",
435
- name: "EU GDPR",
436
- jurisdictions: ["EU"],
357
+ id: 'eu-gdpr',
358
+ name: 'EU GDPR',
359
+ jurisdictions: ['EU'],
437
360
  priority: 10,
438
361
  constraints: [
439
- constraint("eu-retention", "retention", "GDPR: 5-year audit retention", "mandatory", "eu-gdpr", "EU", 1825),
440
- constraint("eu-consent", "consent", "GDPR: Explicit granular consent", "mandatory", "eu-gdpr", "EU", "explicit-granular"),
441
- constraint("eu-residency", "data-residency", "GDPR: EU data residency", "mandatory", "eu-gdpr", "EU", "eu-west"),
442
- constraint("eu-proof", "proof-anchoring", "GDPR: Merkle tree proof anchoring", "required", "eu-gdpr", "EU", "merkle-tree"),
443
- constraint("eu-trust", "trust-level", "GDPR: Minimum trust T3 (Monitored)", "required", "eu-gdpr", "EU", 3),
444
- constraint("eu-processing", "processing-restriction", "GDPR: Purpose limitation", "mandatory", "eu-gdpr", "EU", "purpose-limitation"),
445
- constraint("eu-audit", "audit-requirement", "GDPR: Full audit trail", "mandatory", "eu-gdpr", "EU", "full-audit-trail"),
362
+ constraint('eu-retention', 'retention', 'GDPR: 5-year audit retention', 'mandatory', 'eu-gdpr', 'EU', 1825),
363
+ constraint('eu-consent', 'consent', 'GDPR: Explicit granular consent', 'mandatory', 'eu-gdpr', 'EU', 'explicit-granular'),
364
+ constraint('eu-residency', 'data-residency', 'GDPR: EU data residency', 'mandatory', 'eu-gdpr', 'EU', 'eu-west'),
365
+ constraint('eu-proof', 'proof-anchoring', 'GDPR: Merkle tree proof anchoring', 'required', 'eu-gdpr', 'EU', 'merkle-tree'),
366
+ constraint('eu-trust', 'trust-level', 'GDPR: Minimum trust T3 (Monitored)', 'required', 'eu-gdpr', 'EU', 3),
367
+ constraint('eu-processing', 'processing-restriction', 'GDPR: Purpose limitation', 'mandatory', 'eu-gdpr', 'EU', 'purpose-limitation'),
368
+ constraint('eu-audit', 'audit-requirement', 'GDPR: Full audit trail', 'mandatory', 'eu-gdpr', 'EU', 'full-audit-trail'),
446
369
  ],
447
370
  },
448
371
  {
449
- id: "eu-ai-act",
450
- name: "EU AI Act",
451
- jurisdictions: ["EU"],
372
+ id: 'eu-ai-act',
373
+ name: 'EU AI Act',
374
+ jurisdictions: ['EU'],
452
375
  priority: 15,
453
376
  constraints: [
454
- constraint("euai-escalation", "escalation", "AI Act: Block and escalate on violations", "mandatory", "eu-ai-act", "EU", "block-escalate"),
455
- constraint("euai-audit", "audit-requirement", "AI Act: AI system audit trail", "mandatory", "eu-ai-act", "EU", "ai-system-audit"),
456
- constraint("euai-processing", "processing-restriction", "AI Act: Risk assessment required", "mandatory", "eu-ai-act", "EU", "risk-assessment-required"),
377
+ constraint('euai-escalation', 'escalation', 'AI Act: Block and escalate on violations', 'mandatory', 'eu-ai-act', 'EU', 'block-escalate'),
378
+ constraint('euai-audit', 'audit-requirement', 'AI Act: AI system audit trail', 'mandatory', 'eu-ai-act', 'EU', 'ai-system-audit'),
379
+ constraint('euai-processing', 'processing-restriction', 'AI Act: Risk assessment required', 'mandatory', 'eu-ai-act', 'EU', 'risk-assessment-required'),
457
380
  ],
458
381
  },
459
382
  // -- US --
460
383
  {
461
- id: "us-standard",
462
- name: "US Standard",
463
- jurisdictions: ["US"],
384
+ id: 'us-standard',
385
+ name: 'US Standard',
386
+ jurisdictions: ['US'],
464
387
  priority: 10,
465
388
  constraints: [
466
- constraint("us-retention", "retention", "US: 7-year audit retention", "mandatory", "us-standard", "US", 2555),
467
- constraint("us-crypto", "crypto", "US: FIPS 140-2 cryptographic suite", "mandatory", "us-standard", "US", "fips-140-2"),
468
- constraint("us-proof", "proof-anchoring", "US: TSA RFC 3161 proof anchoring", "required", "us-standard", "US", "tsa-rfc3161"),
469
- constraint("us-trust", "trust-level", "US: Minimum trust T3 (Monitored)", "required", "us-standard", "US", 3),
470
- constraint("us-escalation", "escalation", "US: Block and escalate", "mandatory", "us-standard", "US", "block-escalate"),
471
- constraint("us-consent", "consent", "US: Opt-out consent model", "required", "us-standard", "US", "opt-out"),
389
+ constraint('us-retention', 'retention', 'US: 7-year audit retention', 'mandatory', 'us-standard', 'US', 2555),
390
+ constraint('us-crypto', 'crypto', 'US: FIPS 140-2 cryptographic suite', 'mandatory', 'us-standard', 'US', 'fips-140-2'),
391
+ constraint('us-proof', 'proof-anchoring', 'US: TSA RFC 3161 proof anchoring', 'required', 'us-standard', 'US', 'tsa-rfc3161'),
392
+ constraint('us-trust', 'trust-level', 'US: Minimum trust T3 (Monitored)', 'required', 'us-standard', 'US', 3),
393
+ constraint('us-escalation', 'escalation', 'US: Block and escalate', 'mandatory', 'us-standard', 'US', 'block-escalate'),
394
+ constraint('us-consent', 'consent', 'US: Opt-out consent model', 'required', 'us-standard', 'US', 'opt-out'),
472
395
  ],
473
396
  },
474
397
  // -- APAC --
475
398
  {
476
- id: "apac-standard",
477
- name: "APAC Standard",
478
- jurisdictions: ["APAC"],
399
+ id: 'apac-standard',
400
+ name: 'APAC Standard',
401
+ jurisdictions: ['APAC'],
479
402
  priority: 8,
480
403
  constraints: [
481
- constraint("apac-retention", "retention", "APAC: 3-year audit retention", "required", "apac-standard", "APAC", 1095),
482
- constraint("apac-consent", "consent", "APAC: Opt-in consent model", "required", "apac-standard", "APAC", "opt-in"),
483
- constraint("apac-trust", "trust-level", "APAC: Minimum trust T2 (Provisional)", "required", "apac-standard", "APAC", 2),
484
- constraint("apac-proof", "proof-anchoring", "APAC: Merkle tree proof anchoring", "required", "apac-standard", "APAC", "merkle-tree"),
404
+ constraint('apac-retention', 'retention', 'APAC: 3-year audit retention', 'required', 'apac-standard', 'APAC', 1095),
405
+ constraint('apac-consent', 'consent', 'APAC: Opt-in consent model', 'required', 'apac-standard', 'APAC', 'opt-in'),
406
+ constraint('apac-trust', 'trust-level', 'APAC: Minimum trust T2 (Provisional)', 'required', 'apac-standard', 'APAC', 2),
407
+ constraint('apac-proof', 'proof-anchoring', 'APAC: Merkle tree proof anchoring', 'required', 'apac-standard', 'APAC', 'merkle-tree'),
485
408
  ],
486
409
  },
487
410
  // -- UK (post-Brexit, GDPR-adjacent) --
488
411
  {
489
- id: "uk-dpa",
490
- name: "UK Data Protection Act",
491
- jurisdictions: ["UK"],
412
+ id: 'uk-dpa',
413
+ name: 'UK Data Protection Act',
414
+ jurisdictions: ['UK'],
492
415
  priority: 10,
493
416
  constraints: [
494
- constraint("uk-retention", "retention", "UK DPA: 5-year retention", "mandatory", "uk-dpa", "UK", 1825),
495
- constraint("uk-consent", "consent", "UK DPA: Explicit granular consent", "mandatory", "uk-dpa", "UK", "explicit-granular"),
496
- constraint("uk-trust", "trust-level", "UK DPA: Minimum trust T3 (Monitored)", "required", "uk-dpa", "UK", 3),
497
- constraint("uk-residency", "data-residency", "UK DPA: UK data residency", "mandatory", "uk-dpa", "UK", "uk-south"),
417
+ constraint('uk-retention', 'retention', 'UK DPA: 5-year retention', 'mandatory', 'uk-dpa', 'UK', 1825),
418
+ constraint('uk-consent', 'consent', 'UK DPA: Explicit granular consent', 'mandatory', 'uk-dpa', 'UK', 'explicit-granular'),
419
+ constraint('uk-trust', 'trust-level', 'UK DPA: Minimum trust T3 (Monitored)', 'required', 'uk-dpa', 'UK', 3),
420
+ constraint('uk-residency', 'data-residency', 'UK DPA: UK data residency', 'mandatory', 'uk-dpa', 'UK', 'uk-south'),
498
421
  ],
499
422
  },
500
423
  // -- Canada --
501
424
  {
502
- id: "ca-pipeda",
503
- name: "Canada PIPEDA",
504
- jurisdictions: ["CA"],
425
+ id: 'ca-pipeda',
426
+ name: 'Canada PIPEDA',
427
+ jurisdictions: ['CA'],
505
428
  priority: 10,
506
429
  constraints: [
507
- constraint("ca-consent", "consent", "PIPEDA: Opt-in consent", "mandatory", "ca-pipeda", "CA", "opt-in"),
508
- constraint("ca-trust", "trust-level", "PIPEDA: Minimum trust T3", "required", "ca-pipeda", "CA", 3),
509
- constraint("ca-retention", "retention", "PIPEDA: 3-year retention", "required", "ca-pipeda", "CA", 1095),
430
+ constraint('ca-consent', 'consent', 'PIPEDA: Opt-in consent', 'mandatory', 'ca-pipeda', 'CA', 'opt-in'),
431
+ constraint('ca-trust', 'trust-level', 'PIPEDA: Minimum trust T3', 'required', 'ca-pipeda', 'CA', 3),
432
+ constraint('ca-retention', 'retention', 'PIPEDA: 3-year retention', 'required', 'ca-pipeda', 'CA', 1095),
510
433
  ],
511
434
  },
512
435
  ];
@@ -541,10 +464,10 @@ export class PolicyComposer {
541
464
  */
542
465
  registerBundle(bundle) {
543
466
  if (this.bundles.has(bundle.id)) {
544
- logger.warn({ bundleId: bundle.id }, "Overwriting existing policy bundle");
467
+ logger.warn({ bundleId: bundle.id }, 'Overwriting existing policy bundle');
545
468
  }
546
469
  this.bundles.set(bundle.id, bundle);
547
- logger.info({ bundleId: bundle.id, priority: bundle.priority }, "Policy bundle registered");
470
+ logger.info({ bundleId: bundle.id, priority: bundle.priority }, 'Policy bundle registered');
548
471
  }
549
472
  /**
550
473
  * Compose a policy set by selecting applicable bundles for the given
@@ -554,7 +477,7 @@ export class PolicyComposer {
554
477
  const applicable = this.selectApplicable(ctx, additionalBundleIds);
555
478
  // Always include global default as a fallback
556
479
  if (applicable.length === 0) {
557
- const global = this.bundles.get("global-default");
480
+ const global = this.bundles.get('global-default');
558
481
  if (global)
559
482
  applicable.push(global);
560
483
  }
@@ -582,10 +505,10 @@ export class PolicyComposer {
582
505
  resolvedConflicts.push(...result.resolvedConflicts);
583
506
  unresolvedConflicts.push(...result.unresolvedConflicts);
584
507
  }
585
- const isValid = unresolvedConflicts.every((c) => c.severity !== "critical");
508
+ const isValid = unresolvedConflicts.every(c => c.severity !== 'critical');
586
509
  return {
587
510
  constraints: resolved,
588
- sourceBundles: applicable.map((b) => b.id),
511
+ sourceBundles: applicable.map(b => b.id),
589
512
  resolvedConflicts,
590
513
  unresolvedConflicts,
591
514
  isValid,
@@ -601,7 +524,7 @@ export class PolicyComposer {
601
524
  const selected = [];
602
525
  const used = new Set();
603
526
  for (const [id, bundle] of this.bundles) {
604
- const applies = bundle.jurisdictions.some((j) => j === "GLOBAL" || ctx.primaryJurisdictions.includes(j));
527
+ const applies = bundle.jurisdictions.some(j => j === 'GLOBAL' || ctx.primaryJurisdictions.includes(j));
605
528
  if (applies && !used.has(id)) {
606
529
  selected.push(bundle);
607
530
  used.add(id);
@@ -627,34 +550,30 @@ export class PolicyComposer {
627
550
  resolveGroup(type, constraints, bundles) {
628
551
  // No conflict possible with a single constraint
629
552
  if (constraints.length <= 1) {
630
- return {
631
- resolved: constraints,
632
- resolvedConflicts: [],
633
- unresolvedConflicts: [],
634
- };
553
+ return { resolved: constraints, resolvedConflicts: [], unresolvedConflicts: [] };
635
554
  }
636
555
  switch (type) {
637
556
  // Numeric max-wins
638
- case "retention":
639
- case "trust-level":
557
+ case 'retention':
558
+ case 'trust-level':
640
559
  return this.resolveByMax(type, constraints);
641
560
  // Ordered-enum strictest-wins
642
- case "crypto":
561
+ case 'crypto':
643
562
  return this.resolveByStrictness(type, constraints, CRYPTO_SUITE_STRICTNESS);
644
- case "consent":
563
+ case 'consent':
645
564
  return this.resolveByStrictness(type, constraints, CONSENT_STRICTNESS);
646
- case "escalation":
565
+ case 'escalation':
647
566
  return this.resolveByStrictness(type, constraints, ESCALATION_STRICTNESS);
648
- case "proof-anchoring":
567
+ case 'proof-anchoring':
649
568
  return this.resolveByStrictness(type, constraints, PROOF_ANCHORING_STRICTNESS);
650
569
  // Special resolution
651
- case "data-residency":
570
+ case 'data-residency':
652
571
  return this.resolveDataResidency(constraints);
653
- case "external-services":
572
+ case 'external-services':
654
573
  return this.resolveExternalServices(constraints);
655
574
  // Additive (keep all unique values)
656
- case "audit-requirement":
657
- case "processing-restriction":
575
+ case 'audit-requirement':
576
+ case 'processing-restriction':
658
577
  return this.resolveAdditive(constraints);
659
578
  // Fallback: by bundle priority
660
579
  default:
@@ -663,46 +582,42 @@ export class PolicyComposer {
663
582
  }
664
583
  /** Resolve numeric constraints by taking the maximum value. */
665
584
  resolveByMax(type, constraints) {
666
- const valued = constraints.map((c) => ({
585
+ const valued = constraints.map(c => ({
667
586
  constraint: c,
668
- numericValue: typeof c.value === "number" ? c.value : 0,
587
+ numericValue: typeof c.value === 'number' ? c.value : 0,
669
588
  }));
670
589
  const winner = valued.reduce((max, v) => v.numericValue > max.numericValue ? v : max);
671
- const hasConflict = new Set(valued.map((v) => v.numericValue)).size > 1;
590
+ const hasConflict = new Set(valued.map(v => v.numericValue)).size > 1;
672
591
  return {
673
592
  resolved: [winner.constraint],
674
593
  resolvedConflicts: hasConflict
675
- ? [
676
- {
594
+ ? [{
677
595
  constraintType: type,
678
596
  constraints,
679
597
  description: `${type}: resolved to max value ${winner.numericValue}`,
680
- severity: "low",
681
- },
682
- ]
598
+ severity: 'low',
599
+ }]
683
600
  : [],
684
601
  unresolvedConflicts: [],
685
602
  };
686
603
  }
687
604
  /** Resolve ordered-enum constraints by taking the strictest value. */
688
605
  resolveByStrictness(type, constraints, strictnessMap) {
689
- const valued = constraints.map((c) => ({
606
+ const valued = constraints.map(c => ({
690
607
  constraint: c,
691
608
  strictness: strictnessMap[String(c.value)] ?? 0,
692
609
  }));
693
610
  const winner = valued.reduce((max, v) => v.strictness > max.strictness ? v : max);
694
- const hasConflict = new Set(valued.map((v) => v.strictness)).size > 1;
611
+ const hasConflict = new Set(valued.map(v => v.strictness)).size > 1;
695
612
  return {
696
613
  resolved: [winner.constraint],
697
614
  resolvedConflicts: hasConflict
698
- ? [
699
- {
615
+ ? [{
700
616
  constraintType: type,
701
617
  constraints,
702
618
  description: `${type}: resolved to strictest value "${winner.constraint.value}"`,
703
- severity: "low",
704
- },
705
- ]
619
+ severity: 'low',
620
+ }]
706
621
  : [],
707
622
  unresolvedConflicts: [],
708
623
  };
@@ -713,63 +628,50 @@ export class PolicyComposer {
713
628
  * both places. This is surfaced as an unresolved critical conflict.
714
629
  */
715
630
  resolveDataResidency(constraints) {
716
- const zones = new Set(constraints.map((c) => String(c.value)));
631
+ const zones = new Set(constraints.map(c => String(c.value)));
717
632
  if (zones.size <= 1) {
718
- return {
719
- resolved: [constraints[0]],
720
- resolvedConflicts: [],
721
- unresolvedConflicts: [],
722
- };
633
+ return { resolved: [constraints[0]], resolvedConflicts: [], unresolvedConflicts: [] };
723
634
  }
724
635
  // Sort by enforcement level (strictest first)
725
- const sorted = [...constraints].sort((a, b) => (ENFORCEMENT_ORDER[b.enforcement] ?? 0) -
726
- (ENFORCEMENT_ORDER[a.enforcement] ?? 0));
727
- const hasMandatory = sorted.some((c) => c.enforcement === "blocking" || c.enforcement === "mandatory");
636
+ const sorted = [...constraints].sort((a, b) => (ENFORCEMENT_ORDER[b.enforcement] ?? 0) - (ENFORCEMENT_ORDER[a.enforcement] ?? 0));
637
+ const hasMandatory = sorted.some(c => c.enforcement === 'blocking' || c.enforcement === 'mandatory');
728
638
  if (hasMandatory) {
729
639
  return {
730
640
  resolved: [sorted[0]],
731
641
  resolvedConflicts: [],
732
- unresolvedConflicts: [
733
- {
734
- constraintType: "data-residency",
642
+ unresolvedConflicts: [{
643
+ constraintType: 'data-residency',
735
644
  constraints,
736
- description: `Incompatible data residency requirements: ${[...zones].join(" vs ")}`,
737
- severity: "critical",
738
- },
739
- ],
645
+ description: `Incompatible data residency requirements: ${[...zones].join(' vs ')}`,
646
+ severity: 'critical',
647
+ }],
740
648
  };
741
649
  }
742
650
  return {
743
651
  resolved: [sorted[0]],
744
- resolvedConflicts: [
745
- {
746
- constraintType: "data-residency",
652
+ resolvedConflicts: [{
653
+ constraintType: 'data-residency',
747
654
  constraints,
748
655
  description: `Data residency resolved to ${sorted[0].value}`,
749
- severity: "medium",
750
- },
751
- ],
656
+ severity: 'medium',
657
+ }],
752
658
  unresolvedConflicts: [],
753
659
  };
754
660
  }
755
661
  /** External services: false (restrictive) wins over true (permissive). */
756
662
  resolveExternalServices(constraints) {
757
- const blocked = constraints.some((c) => c.value === false);
758
- const winner = blocked
759
- ? constraints.find((c) => c.value === false)
760
- : constraints[0];
761
- const hasConflict = new Set(constraints.map((c) => c.value)).size > 1;
663
+ const blocked = constraints.some(c => c.value === false);
664
+ const winner = blocked ? constraints.find(c => c.value === false) : constraints[0];
665
+ const hasConflict = new Set(constraints.map(c => c.value)).size > 1;
762
666
  return {
763
667
  resolved: [winner],
764
668
  resolvedConflicts: hasConflict
765
- ? [
766
- {
767
- constraintType: "external-services",
669
+ ? [{
670
+ constraintType: 'external-services',
768
671
  constraints,
769
672
  description: `External services: resolved to ${winner.value}`,
770
- severity: "low",
771
- },
772
- ]
673
+ severity: 'low',
674
+ }]
773
675
  : [],
774
676
  unresolvedConflicts: [],
775
677
  };
@@ -785,28 +687,21 @@ export class PolicyComposer {
785
687
  unique.push(c);
786
688
  }
787
689
  }
788
- return {
789
- resolved: unique,
790
- resolvedConflicts: [],
791
- unresolvedConflicts: [],
792
- };
690
+ return { resolved: unique, resolvedConflicts: [], unresolvedConflicts: [] };
793
691
  }
794
692
  /** Fallback: resolve by bundle priority (highest priority wins). */
795
693
  resolveByPriority(type, constraints, bundles) {
796
- const priorityMap = new Map(bundles.map((b) => [b.id, b.priority]));
797
- const sorted = [...constraints].sort((a, b) => (priorityMap.get(b.sourceBundleId) ?? 0) -
798
- (priorityMap.get(a.sourceBundleId) ?? 0));
694
+ const priorityMap = new Map(bundles.map(b => [b.id, b.priority]));
695
+ const sorted = [...constraints].sort((a, b) => (priorityMap.get(b.sourceBundleId) ?? 0) - (priorityMap.get(a.sourceBundleId) ?? 0));
799
696
  return {
800
697
  resolved: [sorted[0]],
801
698
  resolvedConflicts: constraints.length > 1
802
- ? [
803
- {
699
+ ? [{
804
700
  constraintType: type,
805
701
  constraints,
806
702
  description: `${type}: resolved by priority to bundle "${sorted[0].sourceBundleId}"`,
807
- severity: "low",
808
- },
809
- ]
703
+ severity: 'low',
704
+ }]
810
705
  : [],
811
706
  unresolvedConflicts: [],
812
707
  };
@@ -817,140 +712,86 @@ export class PolicyComposer {
817
712
  // ---------------------------------------------------------------------------
818
713
  /** Keywords that trigger "unacceptable" (prohibited) classification under Art. 5. */
819
714
  const PROHIBITED_KEYWORDS = [
820
- "social scoring",
821
- "social credit",
822
- "subliminal manipulation",
823
- "subliminal technique",
824
- "exploit vulnerability",
825
- "exploit vulnerabilities",
826
- "real-time biometric identification",
827
- "real-time facial recognition",
828
- "mass surveillance",
829
- "emotion recognition workplace",
830
- "emotion recognition education",
831
- "predictive policing individual",
832
- "cognitive behavioral manipulation",
833
- "biometric categorisation sensitive",
834
- "untargeted scraping facial",
715
+ 'social scoring', 'social credit', 'subliminal manipulation',
716
+ 'subliminal technique', 'exploit vulnerability', 'exploit vulnerabilities',
717
+ 'real-time biometric identification', 'real-time facial recognition',
718
+ 'mass surveillance', 'emotion recognition workplace',
719
+ 'emotion recognition education', 'predictive policing individual',
720
+ 'cognitive behavioral manipulation', 'biometric categorisation sensitive',
721
+ 'untargeted scraping facial',
835
722
  ];
836
723
  /** Keywords mapped to Annex III high-risk categories. */
837
724
  const HIGH_RISK_KEYWORDS = {
838
- "biometric-identification": [
839
- "biometric identification",
840
- "biometric verification",
841
- "facial recognition",
842
- "fingerprint matching",
843
- "voice identification",
844
- "iris recognition",
725
+ 'biometric-identification': [
726
+ 'biometric identification', 'biometric verification', 'facial recognition',
727
+ 'fingerprint matching', 'voice identification', 'iris recognition',
845
728
  ],
846
- "critical-infrastructure": [
847
- "critical infrastructure",
848
- "power grid",
849
- "water supply",
850
- "traffic management",
851
- "electricity distribution",
852
- "energy management",
729
+ 'critical-infrastructure': [
730
+ 'critical infrastructure', 'power grid', 'water supply',
731
+ 'traffic management', 'electricity distribution', 'energy management',
853
732
  ],
854
- "education-vocational": [
855
- "student assessment",
856
- "educational admission",
857
- "learning evaluation",
858
- "exam scoring",
859
- "academic grading",
860
- "educational placement",
733
+ 'education-vocational': [
734
+ 'student assessment', 'educational admission', 'learning evaluation',
735
+ 'exam scoring', 'academic grading', 'educational placement',
861
736
  ],
862
- "employment-worker-management": [
863
- "recruitment",
864
- "hiring decision",
865
- "cv screening",
866
- "resume screening",
867
- "employee evaluation",
868
- "performance monitoring",
869
- "promotion decision",
870
- "termination decision",
871
- "worker management",
737
+ 'employment-worker-management': [
738
+ 'recruitment', 'hiring decision', 'cv screening', 'resume screening',
739
+ 'employee evaluation', 'performance monitoring', 'promotion decision',
740
+ 'termination decision', 'worker management',
872
741
  ],
873
- "essential-services": [
874
- "credit scoring",
875
- "creditworthiness",
876
- "insurance pricing",
877
- "insurance risk",
878
- "social benefit",
879
- "public assistance",
880
- "emergency services dispatch",
881
- "loan application",
882
- "mortgage decision",
742
+ 'essential-services': [
743
+ 'credit scoring', 'creditworthiness', 'insurance pricing',
744
+ 'insurance risk', 'social benefit', 'public assistance',
745
+ 'emergency services dispatch', 'loan application', 'mortgage decision',
883
746
  ],
884
- "law-enforcement": [
885
- "law enforcement",
886
- "criminal risk assessment",
887
- "recidivism prediction",
888
- "crime prediction",
889
- "evidence analysis",
890
- "suspect profiling",
747
+ 'law-enforcement': [
748
+ 'law enforcement', 'criminal risk assessment', 'recidivism prediction',
749
+ 'crime prediction', 'evidence analysis', 'suspect profiling',
891
750
  ],
892
- "migration-asylum-border": [
893
- "border control",
894
- "immigration",
895
- "asylum application",
896
- "visa application",
897
- "migration management",
898
- "refugee assessment",
751
+ 'migration-asylum-border': [
752
+ 'border control', 'immigration', 'asylum application',
753
+ 'visa application', 'migration management', 'refugee assessment',
899
754
  ],
900
- "justice-democratic": [
901
- "judicial decision",
902
- "court ruling",
903
- "sentencing",
904
- "legal outcome prediction",
905
- "electoral",
906
- "voting",
907
- "election",
908
- "democratic process",
755
+ 'justice-democratic': [
756
+ 'judicial decision', 'court ruling', 'sentencing',
757
+ 'legal outcome prediction', 'electoral', 'voting',
758
+ 'election', 'democratic process',
909
759
  ],
910
760
  };
911
761
  /** Keywords that trigger "limited-risk" classification (transparency obligations). */
912
762
  const LIMITED_RISK_KEYWORDS = [
913
- "chatbot",
914
- "conversational ai",
915
- "virtual assistant",
916
- "deepfake",
917
- "synthetic media",
918
- "generated content",
919
- "ai-generated text",
920
- "ai-generated image",
921
- "ai-generated video",
922
- "emotion detection",
923
- "content generation",
924
- "text generation",
925
- "image generation",
763
+ 'chatbot', 'conversational ai', 'virtual assistant', 'deepfake',
764
+ 'synthetic media', 'generated content', 'ai-generated text',
765
+ 'ai-generated image', 'ai-generated video', 'emotion detection',
766
+ 'content generation', 'text generation', 'image generation',
926
767
  ];
927
768
  /** Regulatory obligations per classification tier. */
928
769
  const OBLIGATIONS_MAP = {
929
- unacceptable: [
930
- "PROHIBITED - System must not be deployed in EU/EEA",
931
- "Immediate cessation required for EU market",
932
- "Notify national supervisory authority",
770
+ 'unacceptable': [
771
+ 'PROHIBITED - System must not be deployed in EU/EEA',
772
+ 'Immediate cessation required for EU market',
773
+ 'Notify national supervisory authority',
933
774
  ],
934
- "high-risk": [
935
- "Risk management system (Art. 9)",
936
- "Data governance and management (Art. 10)",
937
- "Technical documentation (Art. 11)",
938
- "Record-keeping and logging (Art. 12)",
939
- "Transparency and user information (Art. 13)",
940
- "Human oversight measures (Art. 14)",
941
- "Accuracy, robustness, cybersecurity (Art. 15)",
942
- "Conformity assessment (Art. 43)",
943
- "Post-market monitoring (Art. 61)",
944
- "Serious incident reporting (Art. 62)",
775
+ 'high-risk': [
776
+ 'Risk management system (Art. 9)',
777
+ 'Data governance and management (Art. 10)',
778
+ 'Technical documentation (Art. 11)',
779
+ 'Record-keeping and logging (Art. 12)',
780
+ 'Transparency and user information (Art. 13)',
781
+ 'Human oversight measures (Art. 14)',
782
+ 'Accuracy, robustness, cybersecurity (Art. 15)',
783
+ 'Conformity assessment (Art. 43)',
784
+ 'Post-market monitoring (Art. 61)',
785
+ 'Serious incident reporting (Art. 62)',
945
786
  ],
946
- "limited-risk": [
947
- "Inform users of AI interaction (Art. 50)",
948
- "Label AI-generated content (Art. 50)",
949
- "Disclose deepfake/synthetic content (Art. 50)",
787
+ 'limited-risk': [
788
+ 'Inform users of AI interaction (Art. 50)',
789
+ 'Label AI-generated content (Art. 50)',
790
+ 'Disclose deepfake/synthetic content (Art. 50)',
950
791
  ],
951
- "minimal-risk": [
952
- "Voluntary codes of conduct (Art. 95)",
953
- "No mandatory obligations",
792
+ 'minimal-risk': [
793
+ 'Voluntary codes of conduct (Art. 95)',
794
+ 'No mandatory obligations',
954
795
  ],
955
796
  };
956
797
  /**
@@ -986,10 +827,10 @@ export class AiActClassifier {
986
827
  if (limited)
987
828
  return limited;
988
829
  return {
989
- classification: "minimal-risk",
830
+ classification: 'minimal-risk',
990
831
  confidence: 0.6,
991
- reasoning: "No risk indicators detected; classified as minimal-risk",
992
- obligations: OBLIGATIONS_MAP["minimal-risk"],
832
+ reasoning: 'No risk indicators detected; classified as minimal-risk',
833
+ obligations: OBLIGATIONS_MAP['minimal-risk'],
993
834
  };
994
835
  }
995
836
  buildSearchText(goal, context, intentType) {
@@ -998,29 +839,29 @@ export class AiActClassifier {
998
839
  parts.push(intentType.toLowerCase());
999
840
  if (context) {
1000
841
  for (const [key, value] of Object.entries(context)) {
1001
- if (typeof value === "string") {
842
+ if (typeof value === 'string') {
1002
843
  parts.push(`${key}: ${value}`.toLowerCase());
1003
844
  }
1004
845
  else if (Array.isArray(value)) {
1005
846
  for (const item of value) {
1006
- if (typeof item === "string")
847
+ if (typeof item === 'string')
1007
848
  parts.push(item.toLowerCase());
1008
849
  }
1009
850
  }
1010
851
  }
1011
852
  }
1012
- return parts.join(" ");
853
+ return parts.join(' ');
1013
854
  }
1014
855
  checkProhibited(text) {
1015
856
  for (const keyword of PROHIBITED_KEYWORDS) {
1016
857
  if (text.includes(keyword)) {
1017
- logger.warn({ keyword }, "EU AI Act: PROHIBITED system detected");
858
+ logger.warn({ keyword }, 'EU AI Act: PROHIBITED system detected');
1018
859
  return {
1019
- classification: "unacceptable",
860
+ classification: 'unacceptable',
1020
861
  confidence: 0.9,
1021
862
  reasoning: `Prohibited practice detected: "${keyword}" (Art. 5)`,
1022
- annexReference: "Article 5",
1023
- obligations: OBLIGATIONS_MAP["unacceptable"],
863
+ annexReference: 'Article 5',
864
+ obligations: OBLIGATIONS_MAP['unacceptable'],
1024
865
  };
1025
866
  }
1026
867
  }
@@ -1030,7 +871,7 @@ export class AiActClassifier {
1030
871
  let bestMatch = null;
1031
872
  for (const [category, keywords] of Object.entries(HIGH_RISK_KEYWORDS)) {
1032
873
  let count = 0;
1033
- let firstKeyword = "";
874
+ let firstKeyword = '';
1034
875
  for (const keyword of keywords) {
1035
876
  if (text.includes(keyword)) {
1036
877
  count++;
@@ -1044,14 +885,14 @@ export class AiActClassifier {
1044
885
  }
1045
886
  if (bestMatch) {
1046
887
  const confidence = Math.min(0.5 + bestMatch.count * 0.15, 0.95);
1047
- logger.info({ category: bestMatch.category, confidence }, "EU AI Act: High-risk classification");
888
+ logger.info({ category: bestMatch.category, confidence }, 'EU AI Act: High-risk classification');
1048
889
  return {
1049
- classification: "high-risk",
890
+ classification: 'high-risk',
1050
891
  highRiskCategory: bestMatch.category,
1051
892
  confidence,
1052
893
  reasoning: `High-risk system (Annex III: ${bestMatch.category}). Matched: "${bestMatch.keyword}"`,
1053
- annexReference: "Article 6, Annex III",
1054
- obligations: OBLIGATIONS_MAP["high-risk"],
894
+ annexReference: 'Article 6, Annex III',
895
+ obligations: OBLIGATIONS_MAP['high-risk'],
1055
896
  };
1056
897
  }
1057
898
  return null;
@@ -1060,11 +901,11 @@ export class AiActClassifier {
1060
901
  for (const keyword of LIMITED_RISK_KEYWORDS) {
1061
902
  if (text.includes(keyword)) {
1062
903
  return {
1063
- classification: "limited-risk",
904
+ classification: 'limited-risk',
1064
905
  confidence: 0.7,
1065
906
  reasoning: `Limited-risk transparency obligation: "${keyword}"`,
1066
- annexReference: "Article 50",
1067
- obligations: OBLIGATIONS_MAP["limited-risk"],
907
+ annexReference: 'Article 50',
908
+ obligations: OBLIGATIONS_MAP['limited-risk'],
1068
909
  };
1069
910
  }
1070
911
  }
@@ -1080,17 +921,15 @@ export class AiActClassifier {
1080
921
  */
1081
922
  function pickStrictest(defaults, policyValue, strictnessMap) {
1082
923
  const all = policyValue ? [...defaults, policyValue] : defaults;
1083
- return all.reduce((strictest, current) => (strictnessMap[current] ?? 0) > (strictnessMap[strictest] ?? 0)
1084
- ? current
1085
- : strictest);
924
+ return all.reduce((strictest, current) => (strictnessMap[current] ?? 0) > (strictnessMap[strictest] ?? 0) ? current : strictest);
1086
925
  }
1087
926
  /** Check if a jurisdiction context includes any of the given jurisdictions. */
1088
927
  function hasJurisdiction(ctx, ...jurisdictions) {
1089
- return jurisdictions.some((j) => ctx.primaryJurisdictions.includes(j));
928
+ return jurisdictions.some(j => ctx.primaryJurisdictions.includes(j));
1090
929
  }
1091
930
  /** Extract a typed constraint value from a composed policy set. */
1092
931
  function extractPolicyValue(policySet, type) {
1093
- return policySet.constraints.find((c) => c.type === type)?.value;
932
+ return policySet.constraints.find(c => c.type === type)?.value;
1094
933
  }
1095
934
  /**
1096
935
  * Assembles a complete GovernanceRegime from a jurisdiction context and
@@ -1125,13 +964,13 @@ export class RegimeSelector {
1125
964
  // Build human-readable name
1126
965
  const jurisdictionPart = ctx.primaryJurisdictions.length === 1
1127
966
  ? ctx.primaryJurisdictions[0]
1128
- : `Multi(${ctx.primaryJurisdictions.join("+")})`;
1129
- const name = ctx.industry !== "general"
967
+ : `Multi(${ctx.primaryJurisdictions.join('+')})`;
968
+ const name = ctx.industry !== 'general'
1130
969
  ? `${jurisdictionPart}-${ctx.industry}`
1131
970
  : jurisdictionPart;
1132
971
  const regime = {
1133
972
  regimeId,
1134
- name: name || "default",
973
+ name: name || 'default',
1135
974
  jurisdictions: ctx.primaryJurisdictions,
1136
975
  policyNamespaces: policySet.sourceBundles,
1137
976
  cryptoSuite,
@@ -1142,64 +981,64 @@ export class RegimeSelector {
1142
981
  dataResidency: ctx.dataResidency,
1143
982
  externalServicesAllowed,
1144
983
  minimumTrustLevel,
1145
- conformityAssessmentRequired: hasJurisdiction(ctx, "EU"),
1146
- transparencyRequired: hasJurisdiction(ctx, "EU", "CA", "UK"),
984
+ conformityAssessmentRequired: hasJurisdiction(ctx, 'EU'),
985
+ transparencyRequired: hasJurisdiction(ctx, 'EU', 'CA', 'UK'),
1147
986
  metadata: {},
1148
987
  };
1149
- logger.info({ regimeId, name, cryptoSuite, minimumTrustLevel }, "Governance regime assembled");
988
+ logger.info({ regimeId, name, cryptoSuite, minimumTrustLevel }, 'Governance regime assembled');
1150
989
  return regime;
1151
990
  }
1152
991
  resolveCryptoSuite(ctx, ps) {
1153
- const pv = extractPolicyValue(ps, "crypto");
1154
- const defaults = ["standard"];
1155
- if (hasJurisdiction(ctx, "US"))
1156
- defaults.push("fips-140-2");
992
+ const pv = extractPolicyValue(ps, 'crypto');
993
+ const defaults = ['standard'];
994
+ if (hasJurisdiction(ctx, 'US'))
995
+ defaults.push('fips-140-2');
1157
996
  return pickStrictest(defaults, pv, CRYPTO_SUITE_STRICTNESS);
1158
997
  }
1159
998
  resolveProofAnchoring(ctx, ps) {
1160
- const pv = extractPolicyValue(ps, "proof-anchoring");
1161
- const defaults = ["database"];
1162
- if (hasJurisdiction(ctx, "US"))
1163
- defaults.push("tsa-rfc3161");
1164
- else if (hasJurisdiction(ctx, "EU"))
1165
- defaults.push("merkle-tree");
999
+ const pv = extractPolicyValue(ps, 'proof-anchoring');
1000
+ const defaults = ['database'];
1001
+ if (hasJurisdiction(ctx, 'US'))
1002
+ defaults.push('tsa-rfc3161');
1003
+ else if (hasJurisdiction(ctx, 'EU'))
1004
+ defaults.push('merkle-tree');
1166
1005
  return pickStrictest(defaults, pv, PROOF_ANCHORING_STRICTNESS);
1167
1006
  }
1168
1007
  resolveConsentModel(ctx, ps) {
1169
- const pv = extractPolicyValue(ps, "consent");
1170
- const defaults = ["implicit"];
1171
- if (hasJurisdiction(ctx, "EU", "UK"))
1172
- defaults.push("explicit-granular");
1173
- else if (hasJurisdiction(ctx, "CA"))
1174
- defaults.push("opt-in");
1175
- else if (hasJurisdiction(ctx, "US"))
1176
- defaults.push("opt-out");
1008
+ const pv = extractPolicyValue(ps, 'consent');
1009
+ const defaults = ['implicit'];
1010
+ if (hasJurisdiction(ctx, 'EU', 'UK'))
1011
+ defaults.push('explicit-granular');
1012
+ else if (hasJurisdiction(ctx, 'CA'))
1013
+ defaults.push('opt-in');
1014
+ else if (hasJurisdiction(ctx, 'US'))
1015
+ defaults.push('opt-out');
1177
1016
  return pickStrictest(defaults, pv, CONSENT_STRICTNESS);
1178
1017
  }
1179
1018
  resolveEscalationMode(ctx, ps) {
1180
- const pv = extractPolicyValue(ps, "escalation");
1181
- const defaults = ["flag-review"];
1182
- if (hasJurisdiction(ctx, "US", "EU"))
1183
- defaults.push("block-escalate");
1019
+ const pv = extractPolicyValue(ps, 'escalation');
1020
+ const defaults = ['flag-review'];
1021
+ if (hasJurisdiction(ctx, 'US', 'EU'))
1022
+ defaults.push('block-escalate');
1184
1023
  return pickStrictest(defaults, pv, ESCALATION_STRICTNESS);
1185
1024
  }
1186
1025
  resolveAuditRetentionDays(ctx, ps) {
1187
- const pv = extractPolicyValue(ps, "retention");
1026
+ const pv = extractPolicyValue(ps, 'retention');
1188
1027
  const defaults = [365];
1189
- if (hasJurisdiction(ctx, "EU", "UK"))
1028
+ if (hasJurisdiction(ctx, 'EU', 'UK'))
1190
1029
  defaults.push(1825);
1191
- if (hasJurisdiction(ctx, "US"))
1030
+ if (hasJurisdiction(ctx, 'US'))
1192
1031
  defaults.push(2555);
1193
1032
  return Math.max(...(pv !== undefined ? [...defaults, pv] : defaults));
1194
1033
  }
1195
1034
  resolveExternalServicesAllowed(ctx, ps) {
1196
- const pv = extractPolicyValue(ps, "external-services");
1035
+ const pv = extractPolicyValue(ps, 'external-services');
1197
1036
  return pv !== undefined ? pv : true;
1198
1037
  }
1199
1038
  resolveMinimumTrustLevel(ctx, ps) {
1200
- const pv = extractPolicyValue(ps, "trust-level");
1039
+ const pv = extractPolicyValue(ps, 'trust-level');
1201
1040
  const defaults = [2];
1202
- if (hasJurisdiction(ctx, "EU", "US", "UK", "CA"))
1041
+ if (hasJurisdiction(ctx, 'EU', 'US', 'UK', 'CA'))
1203
1042
  defaults.push(3);
1204
1043
  return Math.max(...(pv !== undefined ? [...defaults, pv] : defaults));
1205
1044
  }
@@ -1224,10 +1063,10 @@ export class RegimeSelector {
1224
1063
  let hash = 0;
1225
1064
  for (let i = 0; i < str.length; i++) {
1226
1065
  const char = str.charCodeAt(i);
1227
- hash = (hash << 5) - hash + char;
1066
+ hash = ((hash << 5) - hash) + char;
1228
1067
  hash = hash & hash; // Convert to 32-bit integer
1229
1068
  }
1230
- return `regime-${Math.abs(hash).toString(16).padStart(8, "0")}`;
1069
+ return `regime-${Math.abs(hash).toString(16).padStart(8, '0')}`;
1231
1070
  }
1232
1071
  }
1233
1072
  // ---------------------------------------------------------------------------
@@ -1240,9 +1079,9 @@ export class RegimeSelector {
1240
1079
  export class GatewayConflictError extends Error {
1241
1080
  conflicts;
1242
1081
  constructor(conflicts) {
1243
- super("Intent blocked by unresolved policy conflicts: " +
1244
- conflicts.map((c) => c.description).join("; "));
1245
- this.name = "GatewayConflictError";
1082
+ super('Intent blocked by unresolved policy conflicts: ' +
1083
+ conflicts.map(c => c.description).join('; '));
1084
+ this.name = 'GatewayConflictError';
1246
1085
  this.conflicts = conflicts;
1247
1086
  }
1248
1087
  }
@@ -1250,7 +1089,7 @@ export class GatewayConflictError extends Error {
1250
1089
  // Intent Gateway (Orchestrator)
1251
1090
  // ---------------------------------------------------------------------------
1252
1091
  /** EU/EEA jurisdiction codes that trigger AI Act classification. */
1253
- const EU_JURISDICTION_CODES = new Set(["EU"]);
1092
+ const EU_JURISDICTION_CODES = new Set(['EU']);
1254
1093
  /**
1255
1094
  * The Intent Gateway is the policy-aware orchestrator for all agent intents.
1256
1095
  *
@@ -1299,10 +1138,7 @@ export class IntentGateway {
1299
1138
  this.policyComposer = new PolicyComposer();
1300
1139
  this.regimeSelector = new RegimeSelector();
1301
1140
  this.aiActClassifier = new AiActClassifier();
1302
- logger.info({
1303
- enabled: this.config.enabled,
1304
- defaultJurisdiction: this.config.defaultJurisdiction,
1305
- }, "IntentGateway initialized");
1141
+ logger.info({ enabled: this.config.enabled, defaultJurisdiction: this.config.defaultJurisdiction }, 'IntentGateway initialized');
1306
1142
  }
1307
1143
  /**
1308
1144
  * Dispatch an intent through the full governance pipeline.
@@ -1341,13 +1177,11 @@ export class IntentGateway {
1341
1177
  }
1342
1178
  // Step 3: EU AI Act classification (when EU jurisdiction applies)
1343
1179
  let aiActResult;
1344
- if (jurisdictionContext.primaryJurisdictions.some((j) => EU_JURISDICTION_CODES.has(j))) {
1345
- const goal = typeof submission.goal === "string" ? submission.goal : "";
1346
- const intentType = typeof submission.intentType === "string"
1347
- ? submission.intentType
1348
- : undefined;
1180
+ if (jurisdictionContext.primaryJurisdictions.some(j => EU_JURISDICTION_CODES.has(j))) {
1181
+ const goal = typeof submission.goal === 'string' ? submission.goal : '';
1182
+ const intentType = typeof submission.intentType === 'string' ? submission.intentType : undefined;
1349
1183
  aiActResult = this.aiActClassifier.classify(goal, intentMetadata, intentType);
1350
- if (aiActResult.classification === "unacceptable") {
1184
+ if (aiActResult.classification === 'unacceptable') {
1351
1185
  warnings.push(`EU AI Act: PROHIBITED - ${aiActResult.reasoning}`);
1352
1186
  }
1353
1187
  }
@@ -1375,8 +1209,7 @@ export class IntentGateway {
1375
1209
  },
1376
1210
  };
1377
1211
  // Enforce minimum trust level
1378
- if (!enrichedOptions.trustLevel ||
1379
- enrichedOptions.trustLevel < regime.minimumTrustLevel) {
1212
+ if (!enrichedOptions.trustLevel || enrichedOptions.trustLevel < regime.minimumTrustLevel) {
1380
1213
  enrichedOptions.trustLevel = regime.minimumTrustLevel;
1381
1214
  }
1382
1215
  // Log regime decision
@@ -1389,7 +1222,7 @@ export class IntentGateway {
1389
1222
  minimumTrustLevel: regime.minimumTrustLevel,
1390
1223
  aiActClassification: regime.aiActClassification,
1391
1224
  bundles: policySet.sourceBundles,
1392
- }, "Gateway regime decision");
1225
+ }, 'Gateway regime decision');
1393
1226
  }
1394
1227
  // Submit the intent
1395
1228
  const intent = await this.intentService.submit(submission, enrichedOptions);
@@ -1400,10 +1233,10 @@ export class IntentGateway {
1400
1233
  if (error instanceof GatewayConflictError)
1401
1234
  throw error;
1402
1235
  // Degrade gracefully: submit without governance enrichment
1403
- logger.error({ error: error instanceof Error ? error.message : "Unknown error" }, "Gateway error - falling through to passthrough");
1236
+ logger.error({ error: error instanceof Error ? error.message : 'Unknown error' }, 'Gateway error - falling through to passthrough');
1404
1237
  const intent = await this.intentService.submit(submission, options);
1405
1238
  const result = this.createPassthroughResult(intent);
1406
- result.warnings.push(`Gateway degraded: ${error instanceof Error ? error.message : "Unknown error"}`);
1239
+ result.warnings.push(`Gateway degraded: ${error instanceof Error ? error.message : 'Unknown error'}`);
1407
1240
  return result;
1408
1241
  }
1409
1242
  }
@@ -1444,16 +1277,16 @@ export class IntentGateway {
1444
1277
  return {
1445
1278
  intent,
1446
1279
  regime: {
1447
- regimeId: "regime-passthrough",
1448
- name: "passthrough",
1280
+ regimeId: 'regime-passthrough',
1281
+ name: 'passthrough',
1449
1282
  jurisdictions: [this.config.defaultJurisdiction],
1450
1283
  policyNamespaces: [],
1451
- cryptoSuite: "standard",
1452
- proofAnchoring: "database",
1284
+ cryptoSuite: 'standard',
1285
+ proofAnchoring: 'database',
1453
1286
  auditRetentionDays: 365,
1454
- consentModel: "implicit",
1455
- escalationMode: "flag-review",
1456
- dataResidency: "global",
1287
+ consentModel: 'implicit',
1288
+ escalationMode: 'flag-review',
1289
+ dataResidency: 'global',
1457
1290
  externalServicesAllowed: true,
1458
1291
  minimumTrustLevel: 2,
1459
1292
  conformityAssessmentRequired: false,
@@ -1463,9 +1296,9 @@ export class IntentGateway {
1463
1296
  jurisdictionContext: {
1464
1297
  primaryJurisdictions: [this.config.defaultJurisdiction],
1465
1298
  industry: this.config.defaultIndustry,
1466
- dataResidency: "global",
1299
+ dataResidency: 'global',
1467
1300
  crossBorderTransfer: false,
1468
- source: "default",
1301
+ source: 'default',
1469
1302
  },
1470
1303
  policySet: {
1471
1304
  constraints: [],