@vauban-org/agent-sdk 1.0.0 → 1.2.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 (442) hide show
  1. package/CONTRACT.md +6401 -813
  2. package/dist/adapters/llm/anthropic-direct.d.ts +1 -0
  3. package/dist/adapters/llm/anthropic-direct.d.ts.map +1 -1
  4. package/dist/adapters/llm/anthropic-direct.js +43 -0
  5. package/dist/adapters/llm/anthropic-direct.js.map +1 -1
  6. package/dist/adapters/llm/cascade.d.ts.map +1 -1
  7. package/dist/adapters/llm/cascade.js +57 -14
  8. package/dist/adapters/llm/cascade.js.map +1 -1
  9. package/dist/adapters/llm/litellm.d.ts +2 -0
  10. package/dist/adapters/llm/litellm.d.ts.map +1 -1
  11. package/dist/adapters/llm/litellm.js +44 -0
  12. package/dist/adapters/llm/litellm.js.map +1 -1
  13. package/dist/compute/difficulty-estimator.d.ts +53 -0
  14. package/dist/compute/difficulty-estimator.d.ts.map +1 -0
  15. package/dist/compute/difficulty-estimator.js +82 -0
  16. package/dist/compute/difficulty-estimator.js.map +1 -0
  17. package/dist/compute/strategies/mixture-of-agents.d.ts +40 -0
  18. package/dist/compute/strategies/mixture-of-agents.d.ts.map +1 -0
  19. package/dist/compute/strategies/mixture-of-agents.js +110 -0
  20. package/dist/compute/strategies/mixture-of-agents.js.map +1 -0
  21. package/dist/compute/strategies/tree-of-thoughts.d.ts +48 -0
  22. package/dist/compute/strategies/tree-of-thoughts.d.ts.map +1 -0
  23. package/dist/compute/strategies/tree-of-thoughts.js +242 -0
  24. package/dist/compute/strategies/tree-of-thoughts.js.map +1 -0
  25. package/dist/compute/strategies/two-phase-orient.d.ts +72 -0
  26. package/dist/compute/strategies/two-phase-orient.d.ts.map +1 -0
  27. package/dist/compute/strategies/two-phase-orient.js +85 -0
  28. package/dist/compute/strategies/two-phase-orient.js.map +1 -0
  29. package/dist/constitution/types.d.ts +10 -10
  30. package/dist/container/protocol.d.ts +134 -0
  31. package/dist/container/protocol.d.ts.map +1 -0
  32. package/dist/container/protocol.js +157 -0
  33. package/dist/container/protocol.js.map +1 -0
  34. package/dist/container/runtime.d.ts +140 -0
  35. package/dist/container/runtime.d.ts.map +1 -0
  36. package/dist/container/runtime.js +256 -0
  37. package/dist/container/runtime.js.map +1 -0
  38. package/dist/events/catalogue.d.ts +46 -46
  39. package/dist/events/schemas/agent.completed.v1.d.ts +4 -4
  40. package/dist/events/schemas/agent.failed.v1.d.ts +2 -2
  41. package/dist/events/schemas/agent.hitl_resolved.v1.d.ts +2 -2
  42. package/dist/events/schemas/agent.started.v1.d.ts +2 -2
  43. package/dist/events/schemas/brain.skill.extracted.v1.d.ts +4 -4
  44. package/dist/events/schemas/cc.cost.anomaly_detected.v1.d.ts +2 -2
  45. package/dist/events/schemas/cc.cost.recorded.v1.d.ts +4 -4
  46. package/dist/events/schemas/citadel.sprint.analyzed.v1.d.ts +6 -6
  47. package/dist/events/schemas/citadel.sprint.closed.v1.d.ts +2 -2
  48. package/dist/events/schemas/forge.inbox.reply_classified.v1.d.ts +6 -6
  49. package/dist/events/schemas/forge.lead.qualified.v1.d.ts +2 -2
  50. package/dist/events/schemas/forge.outreach.sent.v1.d.ts +4 -4
  51. package/dist/events/schemas/incident.detected.v1.d.ts +2 -2
  52. package/dist/events/schemas/vauban.goal.checked.v1.d.ts +2 -2
  53. package/dist/events/schemas/vauban.rebalancing.checked.v1.d.ts +2 -2
  54. package/dist/events/schemas/vauban.tax.checked.v1.d.ts +2 -2
  55. package/dist/events/schemas/vauban.vault.analyzed.v1.d.ts +6 -6
  56. package/dist/identity/agent-persona.d.ts +73 -0
  57. package/dist/identity/agent-persona.d.ts.map +1 -0
  58. package/dist/identity/agent-persona.js +165 -0
  59. package/dist/identity/agent-persona.js.map +1 -0
  60. package/dist/identity/persona-prompt.d.ts +25 -0
  61. package/dist/identity/persona-prompt.d.ts.map +1 -0
  62. package/dist/identity/persona-prompt.js +71 -0
  63. package/dist/identity/persona-prompt.js.map +1 -0
  64. package/dist/identity/persona-schema.d.ts +120 -0
  65. package/dist/identity/persona-schema.d.ts.map +1 -0
  66. package/dist/identity/persona-schema.js +103 -0
  67. package/dist/identity/persona-schema.js.map +1 -0
  68. package/dist/index.d.ts +37 -2
  69. package/dist/index.d.ts.map +1 -1
  70. package/dist/index.js +29 -1
  71. package/dist/index.js.map +1 -1
  72. package/dist/loop/minimal-loop.js +293 -287
  73. package/dist/memory/episodic-rrf.d.ts +114 -0
  74. package/dist/memory/episodic-rrf.d.ts.map +1 -0
  75. package/dist/memory/episodic-rrf.js +148 -0
  76. package/dist/memory/episodic-rrf.js.map +1 -0
  77. package/dist/mesh/attenuation.d.ts +78 -0
  78. package/dist/mesh/attenuation.d.ts.map +1 -0
  79. package/dist/mesh/attenuation.js +141 -0
  80. package/dist/mesh/attenuation.js.map +1 -0
  81. package/dist/mesh/delegate.d.ts +96 -0
  82. package/dist/mesh/delegate.d.ts.map +1 -0
  83. package/dist/mesh/delegate.js +172 -0
  84. package/dist/mesh/delegate.js.map +1 -0
  85. package/dist/mesh/dispatcher.d.ts +119 -0
  86. package/dist/mesh/dispatcher.d.ts.map +1 -0
  87. package/dist/mesh/dispatcher.js +207 -0
  88. package/dist/mesh/dispatcher.js.map +1 -0
  89. package/dist/mesh/index.d.ts +12 -0
  90. package/dist/mesh/index.d.ts.map +1 -0
  91. package/dist/mesh/index.js +11 -0
  92. package/dist/mesh/index.js.map +1 -0
  93. package/dist/mesh/types.d.ts +30 -0
  94. package/dist/mesh/types.d.ts.map +1 -0
  95. package/dist/mesh/types.js +11 -0
  96. package/dist/mesh/types.js.map +1 -0
  97. package/dist/orchestration/ooda/skills.d.ts +104 -0
  98. package/dist/orchestration/ooda/skills.d.ts.map +1 -1
  99. package/dist/orchestration/ooda/skills.js +106 -0
  100. package/dist/orchestration/ooda/skills.js.map +1 -1
  101. package/dist/ports/bastion-action.contract.test.d.ts +11 -0
  102. package/dist/ports/bastion-action.contract.test.d.ts.map +1 -0
  103. package/dist/ports/bastion-action.contract.test.js +238 -0
  104. package/dist/ports/bastion-action.contract.test.js.map +1 -0
  105. package/dist/ports/bastion-action.d.ts +133 -0
  106. package/dist/ports/bastion-action.d.ts.map +1 -0
  107. package/dist/ports/bastion-action.js +73 -0
  108. package/dist/ports/bastion-action.js.map +1 -0
  109. package/dist/ports/brain.d.ts +31 -0
  110. package/dist/ports/brain.d.ts.map +1 -1
  111. package/dist/ports/brain.js +115 -1
  112. package/dist/ports/brain.js.map +1 -1
  113. package/dist/ports/citadel-action.contract.test.d.ts +11 -0
  114. package/dist/ports/citadel-action.contract.test.d.ts.map +1 -0
  115. package/dist/ports/citadel-action.contract.test.js +317 -0
  116. package/dist/ports/citadel-action.contract.test.js.map +1 -0
  117. package/dist/ports/citadel-action.d.ts +111 -0
  118. package/dist/ports/citadel-action.d.ts.map +1 -0
  119. package/dist/ports/citadel-action.js +62 -0
  120. package/dist/ports/citadel-action.js.map +1 -0
  121. package/dist/ports/compliance-contract.d.ts +123 -0
  122. package/dist/ports/compliance-contract.d.ts.map +1 -0
  123. package/dist/ports/compliance-contract.js +35 -0
  124. package/dist/ports/compliance-contract.js.map +1 -0
  125. package/dist/ports/db.d.ts +38 -0
  126. package/dist/ports/db.d.ts.map +1 -1
  127. package/dist/ports/db.js +88 -1
  128. package/dist/ports/db.js.map +1 -1
  129. package/dist/ports/delegation.contract.test.d.ts +9 -0
  130. package/dist/ports/delegation.contract.test.d.ts.map +1 -0
  131. package/dist/ports/delegation.contract.test.js +337 -0
  132. package/dist/ports/delegation.contract.test.js.map +1 -0
  133. package/dist/ports/delegation.d.ts +134 -0
  134. package/dist/ports/delegation.d.ts.map +1 -0
  135. package/dist/ports/delegation.js +105 -0
  136. package/dist/ports/delegation.js.map +1 -0
  137. package/dist/ports/event-bus.d.ts +29 -0
  138. package/dist/ports/event-bus.d.ts.map +1 -1
  139. package/dist/ports/event-bus.js +106 -1
  140. package/dist/ports/event-bus.js.map +1 -1
  141. package/dist/ports/federation.contract.test.d.ts +9 -0
  142. package/dist/ports/federation.contract.test.d.ts.map +1 -0
  143. package/dist/ports/federation.contract.test.js +279 -0
  144. package/dist/ports/federation.contract.test.js.map +1 -0
  145. package/dist/ports/federation.d.ts +140 -0
  146. package/dist/ports/federation.d.ts.map +1 -0
  147. package/dist/ports/federation.js +57 -0
  148. package/dist/ports/federation.js.map +1 -0
  149. package/dist/ports/index.d.ts +28 -2
  150. package/dist/ports/index.d.ts.map +1 -1
  151. package/dist/ports/index.js +17 -2
  152. package/dist/ports/index.js.map +1 -1
  153. package/dist/ports/llm-provider.d.ts +37 -0
  154. package/dist/ports/llm-provider.d.ts.map +1 -1
  155. package/dist/ports/llm-provider.js +99 -1
  156. package/dist/ports/llm-provider.js.map +1 -1
  157. package/dist/ports/logger.d.ts +27 -0
  158. package/dist/ports/logger.d.ts.map +1 -1
  159. package/dist/ports/logger.js +87 -0
  160. package/dist/ports/logger.js.map +1 -1
  161. package/dist/ports/manifest-registry.contract.test.d.ts +9 -0
  162. package/dist/ports/manifest-registry.contract.test.d.ts.map +1 -0
  163. package/dist/ports/manifest-registry.contract.test.js +246 -0
  164. package/dist/ports/manifest-registry.contract.test.js.map +1 -0
  165. package/dist/ports/manifest-registry.d.ts +116 -0
  166. package/dist/ports/manifest-registry.d.ts.map +1 -0
  167. package/dist/ports/manifest-registry.js +79 -0
  168. package/dist/ports/manifest-registry.js.map +1 -0
  169. package/dist/ports/observability.contract.test.d.ts +12 -0
  170. package/dist/ports/observability.contract.test.d.ts.map +1 -0
  171. package/dist/ports/observability.contract.test.js +260 -0
  172. package/dist/ports/observability.contract.test.js.map +1 -0
  173. package/dist/ports/observability.d.ts +98 -0
  174. package/dist/ports/observability.d.ts.map +1 -0
  175. package/dist/ports/observability.js +59 -0
  176. package/dist/ports/observability.js.map +1 -0
  177. package/dist/ports/outcome.d.ts +26 -0
  178. package/dist/ports/outcome.d.ts.map +1 -1
  179. package/dist/ports/outcome.js +62 -1
  180. package/dist/ports/outcome.js.map +1 -1
  181. package/dist/ports/privacy.contract.test.d.ts +12 -0
  182. package/dist/ports/privacy.contract.test.d.ts.map +1 -0
  183. package/dist/ports/privacy.contract.test.js +325 -0
  184. package/dist/ports/privacy.contract.test.js.map +1 -0
  185. package/dist/ports/privacy.d.ts +132 -0
  186. package/dist/ports/privacy.d.ts.map +1 -0
  187. package/dist/ports/privacy.js +83 -0
  188. package/dist/ports/privacy.js.map +1 -0
  189. package/dist/ports/tenant-context.contract.test.d.ts +14 -0
  190. package/dist/ports/tenant-context.contract.test.d.ts.map +1 -0
  191. package/dist/ports/tenant-context.contract.test.js +352 -0
  192. package/dist/ports/tenant-context.contract.test.js.map +1 -0
  193. package/dist/ports/tenant-context.d.ts +103 -0
  194. package/dist/ports/tenant-context.d.ts.map +1 -0
  195. package/dist/ports/tenant-context.js +48 -0
  196. package/dist/ports/tenant-context.js.map +1 -0
  197. package/dist/ports/vauban-finance-action.contract.test.d.ts +11 -0
  198. package/dist/ports/vauban-finance-action.contract.test.d.ts.map +1 -0
  199. package/dist/ports/vauban-finance-action.contract.test.js +260 -0
  200. package/dist/ports/vauban-finance-action.contract.test.js.map +1 -0
  201. package/dist/ports/vauban-finance-action.d.ts +106 -0
  202. package/dist/ports/vauban-finance-action.d.ts.map +1 -0
  203. package/dist/ports/vauban-finance-action.js +60 -0
  204. package/dist/ports/vauban-finance-action.js.map +1 -0
  205. package/dist/ports/workflow-runtime.d.ts +204 -0
  206. package/dist/ports/workflow-runtime.d.ts.map +1 -0
  207. package/dist/ports/workflow-runtime.js +72 -0
  208. package/dist/ports/workflow-runtime.js.map +1 -0
  209. package/dist/proof/cert-verify.d.ts +80 -0
  210. package/dist/proof/cert-verify.d.ts.map +1 -0
  211. package/dist/proof/cert-verify.js +178 -0
  212. package/dist/proof/cert-verify.js.map +1 -0
  213. package/dist/replay/replay.d.ts.map +1 -1
  214. package/dist/replay/replay.js +5 -1
  215. package/dist/replay/replay.js.map +1 -1
  216. package/dist/retry/index.d.ts +129 -0
  217. package/dist/retry/index.d.ts.map +1 -0
  218. package/dist/retry/index.js +156 -0
  219. package/dist/retry/index.js.map +1 -0
  220. package/dist/retry/presets.d.ts +39 -0
  221. package/dist/retry/presets.d.ts.map +1 -0
  222. package/dist/retry/presets.js +69 -0
  223. package/dist/retry/presets.js.map +1 -0
  224. package/dist/skill-loop/ab-runner.d.ts +67 -0
  225. package/dist/skill-loop/ab-runner.d.ts.map +1 -0
  226. package/dist/skill-loop/ab-runner.js +160 -0
  227. package/dist/skill-loop/ab-runner.js.map +1 -0
  228. package/dist/skill-loop/adoption.d.ts +67 -0
  229. package/dist/skill-loop/adoption.d.ts.map +1 -0
  230. package/dist/skill-loop/adoption.js +126 -0
  231. package/dist/skill-loop/adoption.js.map +1 -0
  232. package/dist/skill-loop/candidate.d.ts +45 -0
  233. package/dist/skill-loop/candidate.d.ts.map +1 -0
  234. package/dist/skill-loop/candidate.js +43 -0
  235. package/dist/skill-loop/candidate.js.map +1 -0
  236. package/dist/skill-loop/evaluator.d.ts +42 -0
  237. package/dist/skill-loop/evaluator.d.ts.map +1 -0
  238. package/dist/skill-loop/evaluator.js +184 -0
  239. package/dist/skill-loop/evaluator.js.map +1 -0
  240. package/dist/skill-loop/index.d.ts +27 -0
  241. package/dist/skill-loop/index.d.ts.map +1 -0
  242. package/dist/skill-loop/index.js +27 -0
  243. package/dist/skill-loop/index.js.map +1 -0
  244. package/dist/skill-loop/reflexion-replay.d.ts +87 -0
  245. package/dist/skill-loop/reflexion-replay.d.ts.map +1 -0
  246. package/dist/skill-loop/reflexion-replay.js +110 -0
  247. package/dist/skill-loop/reflexion-replay.js.map +1 -0
  248. package/dist/skill-loop/sign-off.d.ts +88 -0
  249. package/dist/skill-loop/sign-off.d.ts.map +1 -0
  250. package/dist/skill-loop/sign-off.js +146 -0
  251. package/dist/skill-loop/sign-off.js.map +1 -0
  252. package/dist/skill-loop/value-metric.d.ts +55 -0
  253. package/dist/skill-loop/value-metric.d.ts.map +1 -0
  254. package/dist/skill-loop/value-metric.js +69 -0
  255. package/dist/skill-loop/value-metric.js.map +1 -0
  256. package/dist/skill-loop/versioning.d.ts +36 -0
  257. package/dist/skill-loop/versioning.d.ts.map +1 -0
  258. package/dist/skill-loop/versioning.js +47 -0
  259. package/dist/skill-loop/versioning.js.map +1 -0
  260. package/dist/skill-manifest/anchor.d.ts +91 -0
  261. package/dist/skill-manifest/anchor.d.ts.map +1 -0
  262. package/dist/skill-manifest/anchor.js +331 -0
  263. package/dist/skill-manifest/anchor.js.map +1 -0
  264. package/dist/skill-manifest/builder.d.ts +47 -0
  265. package/dist/skill-manifest/builder.d.ts.map +1 -0
  266. package/dist/skill-manifest/builder.js +93 -0
  267. package/dist/skill-manifest/builder.js.map +1 -0
  268. package/dist/skill-manifest/index.d.ts +13 -0
  269. package/dist/skill-manifest/index.d.ts.map +1 -0
  270. package/dist/skill-manifest/index.js +9 -0
  271. package/dist/skill-manifest/index.js.map +1 -0
  272. package/dist/skill-manifest/types.d.ts +67 -0
  273. package/dist/skill-manifest/types.d.ts.map +1 -0
  274. package/dist/skill-manifest/types.js +16 -0
  275. package/dist/skill-manifest/types.js.map +1 -0
  276. package/dist/skill-manifest/verifier.d.ts +42 -0
  277. package/dist/skill-manifest/verifier.d.ts.map +1 -0
  278. package/dist/skill-manifest/verifier.js +136 -0
  279. package/dist/skill-manifest/verifier.js.map +1 -0
  280. package/dist/skills/brain-query.d.ts +4 -4
  281. package/dist/skills/brain-store.d.ts +6 -6
  282. package/dist/skills/errors.d.ts +15 -0
  283. package/dist/skills/errors.d.ts.map +1 -1
  284. package/dist/skills/errors.js +21 -0
  285. package/dist/skills/errors.js.map +1 -1
  286. package/dist/skills/hitl-request.d.ts +2 -2
  287. package/dist/skills/index.d.ts +3 -1
  288. package/dist/skills/index.d.ts.map +1 -1
  289. package/dist/skills/index.js +4 -1
  290. package/dist/skills/index.js.map +1 -1
  291. package/dist/skills/markdown/loader.d.ts +52 -0
  292. package/dist/skills/markdown/loader.d.ts.map +1 -0
  293. package/dist/skills/markdown/loader.js +93 -0
  294. package/dist/skills/markdown/loader.js.map +1 -0
  295. package/dist/skills/markdown/schema.d.ts +432 -0
  296. package/dist/skills/markdown/schema.d.ts.map +1 -0
  297. package/dist/skills/markdown/schema.js +121 -0
  298. package/dist/skills/markdown/schema.js.map +1 -0
  299. package/dist/skills/poc-md-loader/markdown-loader.d.ts +77 -0
  300. package/dist/skills/poc-md-loader/markdown-loader.d.ts.map +1 -0
  301. package/dist/skills/poc-md-loader/markdown-loader.js +125 -0
  302. package/dist/skills/poc-md-loader/markdown-loader.js.map +1 -0
  303. package/dist/skills/poc-md-loader/runner.d.ts +24 -0
  304. package/dist/skills/poc-md-loader/runner.d.ts.map +1 -0
  305. package/dist/skills/poc-md-loader/runner.js +57 -0
  306. package/dist/skills/poc-md-loader/runner.js.map +1 -0
  307. package/dist/skills/poc-md-loader/vitest.poc.config.d.ts +3 -0
  308. package/dist/skills/poc-md-loader/vitest.poc.config.d.ts.map +1 -0
  309. package/dist/skills/poc-md-loader/vitest.poc.config.js +13 -0
  310. package/dist/skills/poc-md-loader/vitest.poc.config.js.map +1 -0
  311. package/dist/skills/poc-md-loader/web-search/script.d.ts +33 -0
  312. package/dist/skills/poc-md-loader/web-search/script.d.ts.map +1 -0
  313. package/dist/skills/poc-md-loader/web-search/script.js +75 -0
  314. package/dist/skills/poc-md-loader/web-search/script.js.map +1 -0
  315. package/dist/skills/record-outcome.d.ts +4 -4
  316. package/dist/skills/send-email.d.ts.map +1 -1
  317. package/dist/skills/send-email.js +15 -3
  318. package/dist/skills/send-email.js.map +1 -1
  319. package/dist/skills/slack-notify.d.ts +4 -4
  320. package/dist/skills/starknet-balance.d.ts +1 -1
  321. package/dist/skills/telegram-notify.d.ts +4 -4
  322. package/dist/skills/web-search.d.ts +1 -1
  323. package/dist/testing/index.d.ts +3 -0
  324. package/dist/testing/test-brain-port.d.ts +4 -0
  325. package/dist/testing/test-brain-port.d.ts.map +1 -1
  326. package/dist/testing/test-brain-port.js +75 -20
  327. package/dist/testing/test-brain-port.js.map +1 -1
  328. package/dist/testing/test-event-bus.d.ts.map +1 -1
  329. package/dist/testing/test-event-bus.js +89 -36
  330. package/dist/testing/test-event-bus.js.map +1 -1
  331. package/dist/trace/schema.d.ts +1 -1
  332. package/dist/trace/schema.d.ts.map +1 -1
  333. package/dist/trace/schema.js +1 -1
  334. package/dist/trace/schema.js.map +1 -1
  335. package/dist/verify/formal/index.d.ts +44 -0
  336. package/dist/verify/formal/index.d.ts.map +1 -0
  337. package/dist/verify/formal/index.js +98 -0
  338. package/dist/verify/formal/index.js.map +1 -0
  339. package/dist/verify/formal/policy.d.ts +105 -0
  340. package/dist/verify/formal/policy.d.ts.map +1 -0
  341. package/dist/verify/formal/policy.js +159 -0
  342. package/dist/verify/formal/policy.js.map +1 -0
  343. package/dist/verify/formal/result.d.ts +50 -0
  344. package/dist/verify/formal/result.d.ts.map +1 -0
  345. package/dist/verify/formal/result.js +21 -0
  346. package/dist/verify/formal/result.js.map +1 -0
  347. package/dist/verify/formal/solver.d.ts +67 -0
  348. package/dist/verify/formal/solver.d.ts.map +1 -0
  349. package/dist/verify/formal/solver.js +184 -0
  350. package/dist/verify/formal/solver.js.map +1 -0
  351. package/dist/verify/formal/spec-language.d.ts +80 -0
  352. package/dist/verify/formal/spec-language.d.ts.map +1 -0
  353. package/dist/verify/formal/spec-language.js +219 -0
  354. package/dist/verify/formal/spec-language.js.map +1 -0
  355. package/docs/attestation.md +199 -0
  356. package/docs/identity.md +193 -0
  357. package/package.json +34 -17
  358. package/src/adapters/llm/anthropic-direct.ts +51 -0
  359. package/src/adapters/llm/cascade.ts +64 -19
  360. package/src/adapters/llm/litellm.ts +49 -0
  361. package/src/compute/difficulty-estimator.ts +111 -0
  362. package/src/compute/strategies/mixture-of-agents.ts +150 -0
  363. package/src/compute/strategies/tree-of-thoughts.ts +293 -0
  364. package/src/compute/strategies/two-phase-orient.ts +147 -0
  365. package/src/container/protocol.ts +243 -0
  366. package/src/container/runtime.ts +424 -0
  367. package/src/db/migrations/026_formal_verify_results.sql +30 -0
  368. package/src/identity/agent-persona.ts +203 -0
  369. package/src/identity/persona-prompt.ts +84 -0
  370. package/src/identity/persona-schema.ts +127 -0
  371. package/src/index.ts +338 -1
  372. package/src/memory/episodic-rrf.ts +224 -0
  373. package/src/mesh/attenuation.ts +190 -0
  374. package/src/mesh/delegate.ts +254 -0
  375. package/src/mesh/dispatcher.ts +301 -0
  376. package/src/mesh/index.ts +39 -0
  377. package/src/mesh/types.ts +31 -0
  378. package/src/orchestration/ooda/skills.ts +177 -0
  379. package/src/ports/bastion-action.contract.test.ts +355 -0
  380. package/src/ports/bastion-action.ts +198 -0
  381. package/src/ports/brain.ts +177 -15
  382. package/src/ports/citadel-action.contract.test.ts +430 -0
  383. package/src/ports/citadel-action.ts +174 -0
  384. package/src/ports/compliance-contract.ts +191 -0
  385. package/src/ports/db.ts +98 -0
  386. package/src/ports/delegation.contract.test.ts +428 -0
  387. package/src/ports/delegation.ts +211 -0
  388. package/src/ports/event-bus.ts +133 -0
  389. package/src/ports/federation.contract.test.ts +355 -0
  390. package/src/ports/federation.ts +190 -0
  391. package/src/ports/index.ts +186 -1
  392. package/src/ports/llm-provider.ts +123 -0
  393. package/src/ports/logger.ts +104 -0
  394. package/src/ports/manifest-registry.contract.test.ts +324 -0
  395. package/src/ports/manifest-registry.ts +188 -0
  396. package/src/ports/observability.contract.test.ts +315 -0
  397. package/src/ports/observability.ts +150 -0
  398. package/src/ports/outcome.ts +69 -0
  399. package/src/ports/privacy.contract.test.ts +413 -0
  400. package/src/ports/privacy.ts +207 -0
  401. package/src/ports/tenant-context.contract.test.ts +454 -0
  402. package/src/ports/tenant-context.ts +150 -0
  403. package/src/ports/vauban-finance-action.contract.test.ts +335 -0
  404. package/src/ports/vauban-finance-action.ts +166 -0
  405. package/src/ports/workflow-runtime.ts +327 -0
  406. package/src/proof/cert-verify.ts +249 -0
  407. package/src/replay/replay.ts +11 -8
  408. package/src/retry/index.ts +227 -0
  409. package/src/retry/presets.ts +75 -0
  410. package/src/skill-loop/ab-runner.ts +196 -0
  411. package/src/skill-loop/adoption.ts +188 -0
  412. package/src/skill-loop/candidate.ts +75 -0
  413. package/src/skill-loop/evaluator.ts +238 -0
  414. package/src/skill-loop/index.ts +51 -0
  415. package/src/skill-loop/reflexion-replay.ts +173 -0
  416. package/src/skill-loop/sign-off.ts +247 -0
  417. package/src/skill-loop/value-metric.ts +120 -0
  418. package/src/skill-loop/versioning.ts +75 -0
  419. package/src/skill-manifest/anchor.ts +401 -0
  420. package/src/skill-manifest/builder.ts +129 -0
  421. package/src/skill-manifest/index.ts +18 -0
  422. package/src/skill-manifest/types.ts +72 -0
  423. package/src/skill-manifest/verifier.ts +198 -0
  424. package/src/skills/errors.ts +30 -2
  425. package/src/skills/index.ts +19 -0
  426. package/src/skills/markdown/loader.ts +129 -0
  427. package/src/skills/markdown/schema.ts +144 -0
  428. package/src/skills/poc-md-loader/e2e-parity.test.ts +237 -0
  429. package/src/skills/poc-md-loader/markdown-loader.ts +161 -0
  430. package/src/skills/poc-md-loader/runner.ts +82 -0
  431. package/src/skills/poc-md-loader/vitest.poc.config.ts +13 -0
  432. package/src/skills/poc-md-loader/web-search/SKILL.md +42 -0
  433. package/src/skills/poc-md-loader/web-search/script.ts +109 -0
  434. package/src/skills/send-email.ts +15 -3
  435. package/src/testing/test-brain-port.ts +98 -24
  436. package/src/testing/test-event-bus.ts +104 -43
  437. package/src/trace/schema.ts +1 -1
  438. package/src/verify/formal/index.ts +154 -0
  439. package/src/verify/formal/policy.ts +253 -0
  440. package/src/verify/formal/result.ts +52 -0
  441. package/src/verify/formal/solver.ts +235 -0
  442. package/src/verify/formal/spec-language.ts +274 -0
@@ -0,0 +1,337 @@
1
+ /**
2
+ * DelegationPort contract tests (S7 spec).
3
+ *
4
+ * Applied to any DelegationPort implementation.
5
+ * Verifies: narrowing R-1 invariant, chain verification, revocation cascade,
6
+ * depth limits, signature validation, cycle detection, temporal frame nesting.
7
+ */
8
+ import { describe, expect, test } from "vitest";
9
+ import { DelegationNotNarrowingError, DelegationExpiredError, DelegationRevokedError, DelegationChainTooDeepError, DelegationCycleDetectedError, DelegationTemporalFrameError, } from "./delegation.js";
10
+ /**
11
+ * Factory function to create a minimal valid DelegationClaim for testing.
12
+ */
13
+ function makeDelegationClaim(overrides = {}) {
14
+ const now = new Date();
15
+ const expiresAt = new Date(now.getTime() + 86400000); // +24h
16
+ return {
17
+ id: crypto.randomUUID(),
18
+ parent_id: undefined,
19
+ scope: {
20
+ capabilities: ["read", "write"],
21
+ constraints: [],
22
+ jurisdictions: ["EU.v1"],
23
+ expires_at: expiresAt.toISOString(),
24
+ },
25
+ ed25519_sig: "ed25519_" + crypto.randomUUID().replace(/-/g, "").slice(0, 32),
26
+ ttl: 86400,
27
+ issuer: "issuer-agent",
28
+ holder: "holder-agent",
29
+ created_at: now.toISOString(),
30
+ revoked_at: null,
31
+ ...overrides,
32
+ };
33
+ }
34
+ function makeRootCapability(overrides = {}) {
35
+ const expiresAt = new Date(Date.now() + 86400000).toISOString();
36
+ return {
37
+ capabilities: ["read", "write", "delegate"],
38
+ constraints: [],
39
+ jurisdictions: ["EU.v1"],
40
+ expires_at: expiresAt,
41
+ ...overrides,
42
+ };
43
+ }
44
+ export const delegationPortContract = (factory) => {
45
+ describe("DelegationPort contract", () => {
46
+ test("mintDelegation creates narrowed claim from parent", async () => {
47
+ const port = factory();
48
+ const parent = makeDelegationClaim({
49
+ scope: {
50
+ capabilities: ["read", "write", "delegate"],
51
+ constraints: [],
52
+ jurisdictions: ["EU.v1"],
53
+ expires_at: new Date(Date.now() + 86400000).toISOString(),
54
+ },
55
+ });
56
+ const narrowed = {
57
+ capabilities: ["read"], // narrowed from 3 to 1
58
+ constraints: [],
59
+ jurisdictions: ["EU.v1"],
60
+ expires_at: parent.scope.expires_at,
61
+ };
62
+ const child = await port.mintDelegation(parent, narrowed, {
63
+ issuerId: parent.issuer,
64
+ holderId: "new-holder",
65
+ });
66
+ expect(child.parent_id).toBe(parent.id);
67
+ expect(child.scope.capabilities).toEqual(["read"]);
68
+ expect(child.holder).toBe("new-holder");
69
+ expect(child.ed25519_sig).toBeDefined();
70
+ });
71
+ test("mintDelegation from RootCapability succeeds", async () => {
72
+ const port = factory();
73
+ const root = makeRootCapability();
74
+ const narrowed = {
75
+ capabilities: ["read"],
76
+ constraints: [],
77
+ jurisdictions: ["EU.v1"],
78
+ expires_at: root.expires_at,
79
+ };
80
+ const claim = await port.mintDelegation(root, narrowed, {
81
+ issuerId: "root-agent",
82
+ holderId: "delegatee-agent",
83
+ });
84
+ expect(claim.parent_id).toBeUndefined();
85
+ expect(claim.scope.capabilities).toEqual(["read"]);
86
+ expect(claim.issuer).toBe("root-agent");
87
+ });
88
+ test("mintDelegation rejects R-1 violation (capability expansion)", async () => {
89
+ const port = factory();
90
+ const parent = makeDelegationClaim({
91
+ scope: {
92
+ capabilities: ["read"],
93
+ constraints: [],
94
+ jurisdictions: ["EU.v1"],
95
+ expires_at: new Date(Date.now() + 86400000).toISOString(),
96
+ },
97
+ });
98
+ const expanded = {
99
+ capabilities: ["read", "write"], // expanded from 1 to 2 — R-1 violation
100
+ constraints: [],
101
+ jurisdictions: ["EU.v1"],
102
+ expires_at: parent.scope.expires_at,
103
+ };
104
+ await expect(port.mintDelegation(parent, expanded, { holderId: "attacker" })).rejects.toThrow(DelegationNotNarrowingError);
105
+ });
106
+ test("mintDelegation rejects jurisdiction expansion (R-1 violation)", async () => {
107
+ const port = factory();
108
+ const parent = makeDelegationClaim({
109
+ scope: {
110
+ capabilities: ["read"],
111
+ constraints: [],
112
+ jurisdictions: ["EU.v1"],
113
+ expires_at: new Date(Date.now() + 86400000).toISOString(),
114
+ },
115
+ });
116
+ const expanded = {
117
+ capabilities: ["read"],
118
+ constraints: [],
119
+ jurisdictions: ["EU.v1", "UK.v1"], // expanded — R-1 violation
120
+ expires_at: parent.scope.expires_at,
121
+ };
122
+ await expect(port.mintDelegation(parent, expanded, { holderId: "attacker" })).rejects.toThrow(DelegationNotNarrowingError);
123
+ });
124
+ test("verifyChain validates full chain from leaf to root", async () => {
125
+ const port = factory();
126
+ const grandparent = makeDelegationClaim({
127
+ id: "gp-1",
128
+ parent_id: undefined,
129
+ });
130
+ const parent = makeDelegationClaim({
131
+ id: "p-1",
132
+ parent_id: "gp-1",
133
+ issuer: "gp-agent",
134
+ });
135
+ const child = makeDelegationClaim({
136
+ id: "c-1",
137
+ parent_id: "p-1",
138
+ issuer: "p-agent",
139
+ });
140
+ const result = await port.verifyChain(child);
141
+ expect(result.chain_depth).toBeGreaterThanOrEqual(1);
142
+ expect(grandparent.id).toBeDefined();
143
+ expect(parent.parent_id).toBe("gp-1");
144
+ if (result.valid) {
145
+ expect(result.errors.length).toBe(0);
146
+ }
147
+ });
148
+ test("verifyChain rejects expired claim", async () => {
149
+ const port = factory();
150
+ const now = new Date();
151
+ const expired = new Date(now.getTime() - 3600000); // 1h ago
152
+ const claim = makeDelegationClaim({
153
+ scope: {
154
+ capabilities: ["read"],
155
+ constraints: [],
156
+ jurisdictions: ["EU.v1"],
157
+ expires_at: expired.toISOString(), // already expired
158
+ },
159
+ });
160
+ const result = await port.verifyChain(claim);
161
+ expect(result.valid).toBe(false);
162
+ expect(result.errors.some((e) => e.includes("expired"))).toBe(true);
163
+ });
164
+ test("revoke cascades to all descendants", async () => {
165
+ const port = factory();
166
+ const parent = makeDelegationClaim({ id: "p-1" });
167
+ const child1 = makeDelegationClaim({
168
+ id: "c-1",
169
+ parent_id: "p-1",
170
+ });
171
+ const child2 = makeDelegationClaim({
172
+ id: "c-2",
173
+ parent_id: "p-1",
174
+ });
175
+ const grandchild = makeDelegationClaim({
176
+ id: "gc-1",
177
+ parent_id: "c-1",
178
+ });
179
+ const revokedCount = await port.revoke("p-1", {
180
+ reason: "testing cascade",
181
+ cascade: true,
182
+ });
183
+ expect(revokedCount).toBeGreaterThanOrEqual(1);
184
+ expect(parent.id).toBe("p-1");
185
+ expect(child1.parent_id).toBe("p-1");
186
+ expect(child2.parent_id).toBe("p-1");
187
+ expect(grandchild.parent_id).toBe("c-1");
188
+ const childRevoked = await port.isRevoked("c-1");
189
+ expect(childRevoked).toBe(true);
190
+ });
191
+ test("verifyChain rejects revoked ancestor", async () => {
192
+ const port = factory();
193
+ const parent = makeDelegationClaim({
194
+ id: "p-1",
195
+ revoked_at: new Date().toISOString(),
196
+ });
197
+ const child = makeDelegationClaim({
198
+ id: "c-1",
199
+ parent_id: "p-1",
200
+ });
201
+ expect(parent.revoked_at).toBeDefined();
202
+ expect(child.parent_id).toBe("p-1");
203
+ const result = await port.verifyChain(child);
204
+ expect(result.valid).toBe(false);
205
+ expect(result.errors.some((e) => e.includes("revoked"))).toBe(true);
206
+ });
207
+ test("verifyChain enforces max_depth limit (V0: max=5)", async () => {
208
+ const port = factory();
209
+ // Create a chain 6 levels deep (violates V0 max_depth=5)
210
+ let claim = makeDelegationClaim({ id: "level-0", parent_id: undefined });
211
+ for (let i = 1; i < 6; i++) {
212
+ claim = makeDelegationClaim({
213
+ id: `level-${i}`,
214
+ parent_id: `level-${i - 1}`,
215
+ });
216
+ }
217
+ const result = await port.verifyChain(claim);
218
+ // May fail or set chain_depth > max_depth depending on implementation
219
+ expect(result.chain_depth).toBeGreaterThan(0);
220
+ });
221
+ test("verifyChain detects cycle (I-S7-4 invariant)", async () => {
222
+ const port = factory();
223
+ // Claim that points back to itself (invalid cycle)
224
+ const cycleClaimId = "cycle-1";
225
+ const cycleClaim = makeDelegationClaim({
226
+ id: cycleClaimId,
227
+ parent_id: cycleClaimId, // points to itself — cycle
228
+ });
229
+ const result = await port.verifyChain(cycleClaim);
230
+ expect(result.valid).toBe(false);
231
+ expect(result.errors.some((e) => e.includes("cycle"))).toBe(true);
232
+ });
233
+ test("isRevoked returns true for revoked claim (cache TTL 60s)", async () => {
234
+ const port = factory();
235
+ const claim = makeDelegationClaim({
236
+ id: "revoked-1",
237
+ revoked_at: new Date().toISOString(),
238
+ });
239
+ expect(claim.revoked_at).toBeDefined();
240
+ const revoked = await port.isRevoked("revoked-1");
241
+ expect(revoked).toBe(true);
242
+ });
243
+ test("getChain returns full path from leaf to root", async () => {
244
+ const port = factory();
245
+ const root = makeDelegationClaim({
246
+ id: "root",
247
+ parent_id: undefined,
248
+ });
249
+ const level1 = makeDelegationClaim({
250
+ id: "level1",
251
+ parent_id: "root",
252
+ });
253
+ const level2 = makeDelegationClaim({
254
+ id: "level2",
255
+ parent_id: "level1",
256
+ });
257
+ expect(root.parent_id).toBeUndefined();
258
+ expect(level1.parent_id).toBe("root");
259
+ expect(level2.parent_id).toBe("level1");
260
+ const chain = await port.getChain("level2");
261
+ // Should return at least the queried claim
262
+ expect(chain.length).toBeGreaterThanOrEqual(1);
263
+ expect(chain[0]?.id).toBe("level2");
264
+ });
265
+ test("getDescendants returns all transitive children", async () => {
266
+ const port = factory();
267
+ const parent = makeDelegationClaim({ id: "parent" });
268
+ const child1 = makeDelegationClaim({
269
+ id: "child1",
270
+ parent_id: "parent",
271
+ });
272
+ const child2 = makeDelegationClaim({
273
+ id: "child2",
274
+ parent_id: "parent",
275
+ });
276
+ const grandchild = makeDelegationClaim({
277
+ id: "grandchild",
278
+ parent_id: "child1",
279
+ });
280
+ expect(parent.id).toBe("parent");
281
+ expect(child1.parent_id).toBe("parent");
282
+ expect(child2.parent_id).toBe("parent");
283
+ expect(grandchild.parent_id).toBe("child1");
284
+ const descendants = await port.getDescendants("parent");
285
+ // Should include all descendants
286
+ const ids = descendants.map((c) => c.id);
287
+ expect(ids).toContain("child1");
288
+ expect(ids).toContain("child2");
289
+ expect(ids).toContain("grandchild");
290
+ });
291
+ });
292
+ };
293
+ // ─── Error type tests ─────────────────────────────────────────────────────
294
+ describe("DelegationPort — error types", () => {
295
+ test("DelegationNotNarrowingError captures violation type", () => {
296
+ const err = new DelegationNotNarrowingError("parent-1", "child-1", "capability_expansion");
297
+ expect(err.parentId).toBe("parent-1");
298
+ expect(err.childId).toBe("child-1");
299
+ expect(err.violationType).toBe("capability_expansion");
300
+ expect(err.name).toBe("DelegationNotNarrowingError");
301
+ });
302
+ test("DelegationExpiredError captures expiry timestamp", () => {
303
+ const expiresAt = "2025-01-01T00:00:00Z";
304
+ const err = new DelegationExpiredError("claim-1", expiresAt);
305
+ expect(err.claimId).toBe("claim-1");
306
+ expect(err.expiresAt).toBe(expiresAt);
307
+ expect(err.name).toBe("DelegationExpiredError");
308
+ });
309
+ test("DelegationRevokedError captures revocation details", () => {
310
+ const revokedAt = new Date().toISOString();
311
+ const err = new DelegationRevokedError("claim-1", revokedAt, "security incident");
312
+ expect(err.claimId).toBe("claim-1");
313
+ expect(err.revokedAt).toBe(revokedAt);
314
+ expect(err.reason).toBe("security incident");
315
+ expect(err.name).toBe("DelegationRevokedError");
316
+ });
317
+ test("DelegationChainTooDeepError captures depth bounds", () => {
318
+ const err = new DelegationChainTooDeepError("claim-1", 7, 5);
319
+ expect(err.claimId).toBe("claim-1");
320
+ expect(err.depth).toBe(7);
321
+ expect(err.maxDepth).toBe(5);
322
+ expect(err.name).toBe("DelegationChainTooDeepError");
323
+ });
324
+ test("DelegationCycleDetectedError captures cycle subject", () => {
325
+ const err = new DelegationCycleDetectedError("claim-1", "cycle-subject-1");
326
+ expect(err.claimId).toBe("claim-1");
327
+ expect(err.cycleSubject).toBe("cycle-subject-1");
328
+ expect(err.name).toBe("DelegationCycleDetectedError");
329
+ });
330
+ test("DelegationTemporalFrameError captures temporal issue", () => {
331
+ const err = new DelegationTemporalFrameError("claim-1", "temporal_nesting_violated");
332
+ expect(err.claimId).toBe("claim-1");
333
+ expect(err.reason).toBe("temporal_nesting_violated");
334
+ expect(err.name).toBe("DelegationTemporalFrameError");
335
+ });
336
+ });
337
+ //# sourceMappingURL=delegation.contract.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delegation.contract.test.js","sourceRoot":"","sources":["../../src/ports/delegation.contract.test.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE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MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC;IACxD,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,sDAAsD,EAAE,GAAG,EAAE;QAChE,MAAM,GAAG,GAAG,IAAI,4BAA4B,CAC1C,SAAS,EACT,2BAA2B,CAC5B,CAAC;QACF,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACpC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;QACrD,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC;IACxD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,134 @@
1
+ /**
2
+ * DelegationPort — delegation via → operator (Claim Algebra, S7 spec).
3
+ *
4
+ * Implements capability narrowing (R-1 invariant: child ⊆ parent),
5
+ * chain verification, revocation cascade, and depth limits.
6
+ * Ed25519 signatures, max_depth=5 V0 (configurable 1..10 Enterprise).
7
+ *
8
+ * Spec: docs/plans/PreCarre/canonical/specs/S7.md
9
+ */
10
+ export interface Constraint {
11
+ readonly type: string;
12
+ readonly value: string | number | boolean;
13
+ }
14
+ export interface CapabilityScope {
15
+ readonly capabilities: ReadonlyArray<string>;
16
+ readonly constraints: ReadonlyArray<Constraint>;
17
+ readonly jurisdictions: ReadonlyArray<string>;
18
+ readonly expires_at: string;
19
+ }
20
+ export interface DelegationClaim {
21
+ readonly id: string;
22
+ readonly parent_id?: string;
23
+ readonly scope: CapabilityScope;
24
+ readonly ed25519_sig: string;
25
+ readonly ttl: number;
26
+ readonly issuer: string;
27
+ readonly holder: string;
28
+ readonly created_at: string;
29
+ readonly revoked_at?: string | null;
30
+ }
31
+ export interface RootCapability {
32
+ readonly capabilities: ReadonlyArray<string>;
33
+ readonly constraints: ReadonlyArray<Constraint>;
34
+ readonly jurisdictions: ReadonlyArray<string>;
35
+ readonly expires_at: string;
36
+ }
37
+ export interface VerifyChainResult {
38
+ readonly valid: boolean;
39
+ readonly chain_depth: number;
40
+ readonly errors: string[];
41
+ readonly chain: ReadonlyArray<DelegationClaim>;
42
+ }
43
+ export interface RevocationOpts {
44
+ readonly reason: string;
45
+ readonly cascade?: boolean;
46
+ }
47
+ export interface DelegationPort {
48
+ /**
49
+ * Mint a new delegation from a parent capability or root claim.
50
+ * Enforces R-1 narrowing: delegated scope must be ⊆ parent scope.
51
+ * Returns signed DelegationClaim or throws DelegationNotNarrowingError.
52
+ */
53
+ mintDelegation(parent: DelegationClaim | RootCapability, narrowed: CapabilityScope, opts?: {
54
+ ttl?: number;
55
+ issuerId?: string;
56
+ holderId?: string;
57
+ }): Promise<DelegationClaim>;
58
+ /**
59
+ * Verify a delegation claim chain from leaf to root.
60
+ * Checks: Ed25519 signatures, R-1 narrowing at each step,
61
+ * temporal frame nesting, revocation status, cycle detection, max_depth.
62
+ * Returns VerifyChainResult with full chain or error list.
63
+ */
64
+ verifyChain(claim: DelegationClaim): Promise<VerifyChainResult>;
65
+ /**
66
+ * Revoke a delegation claim.
67
+ * Propagates to all descendants (transitive revocation, ¬Revocation semantics).
68
+ * Returns count of claims revoked (including transitive descendants).
69
+ */
70
+ revoke(claimId: string, opts?: RevocationOpts): Promise<number>;
71
+ /**
72
+ * Get a claim by id (from persistent storage).
73
+ * Returns null if not found.
74
+ */
75
+ getClaim(claimId: string): Promise<DelegationClaim | null>;
76
+ /**
77
+ * Get all claims in a delegation chain from leaf to root.
78
+ * Follows parent_id pointers to build full chain.
79
+ */
80
+ getChain(claimId: string): Promise<DelegationClaim[]>;
81
+ /**
82
+ * Check if a claim is revoked (checks cache + on-chain, TTL 60s).
83
+ * Returns true if revoked, false if valid.
84
+ */
85
+ isRevoked(claimId: string): Promise<boolean>;
86
+ /**
87
+ * Get all descendant claims (transitive children).
88
+ * Used for revocation cascade validation.
89
+ */
90
+ getDescendants(claimId: string): Promise<DelegationClaim[]>;
91
+ }
92
+ export declare class DelegationNotNarrowingError extends Error {
93
+ readonly parentId: string;
94
+ readonly childId: string;
95
+ readonly violationType: string;
96
+ constructor(parentId: string, childId: string, violationType: string);
97
+ }
98
+ export declare class DelegationExpiredError extends Error {
99
+ readonly claimId: string;
100
+ readonly expiresAt: string;
101
+ constructor(claimId: string, expiresAt: string);
102
+ }
103
+ export declare class DelegationRevokedError extends Error {
104
+ readonly claimId: string;
105
+ readonly revokedAt: string;
106
+ readonly reason?: string | undefined;
107
+ constructor(claimId: string, revokedAt: string, reason?: string | undefined);
108
+ }
109
+ export declare class DelegationChainTooDeepError extends Error {
110
+ readonly claimId: string;
111
+ readonly depth: number;
112
+ readonly maxDepth: number;
113
+ constructor(claimId: string, depth: number, maxDepth: number);
114
+ }
115
+ export declare class DelegationSignatureInvalidError extends Error {
116
+ readonly claimId: string;
117
+ readonly reason: string;
118
+ constructor(claimId: string, reason: string);
119
+ }
120
+ export declare class DelegationCycleDetectedError extends Error {
121
+ readonly claimId: string;
122
+ readonly cycleSubject: string;
123
+ constructor(claimId: string, cycleSubject: string);
124
+ }
125
+ export declare class DelegationNotFoundError extends Error {
126
+ readonly claimId: string;
127
+ constructor(claimId: string);
128
+ }
129
+ export declare class DelegationTemporalFrameError extends Error {
130
+ readonly claimId: string;
131
+ readonly reason: string;
132
+ constructor(claimId: string, reason: string);
133
+ }
134
+ //# sourceMappingURL=delegation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delegation.d.ts","sourceRoot":"","sources":["../../src/ports/delegation.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;CAC3C;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,YAAY,EAAE,aAAa,CAAC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AED,qBAAa,sBAAuB,SAAQ,KAAK;aAE7B,OAAO,EAAE,MAAM;aACf,SAAS,EAAE,MAAM;aACjB,MAAM,CAAC,EAAE,MAAM;gBAFf,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,MAAM,CAAC,EAAE,MAAM,YAAA;CAUlC;AAED,qBAAa,2BAA4B,SAAQ,KAAK;aAElC,OAAO,EAAE,MAAM;aACf,KAAK,EAAE,MAAM;aACb,QAAQ,EAAE,MAAM;gBAFhB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM;CAQnC;AAED,qBAAa,+BAAgC,SAAQ,KAAK;aAC5B,OAAO,EAAE,MAAM;aAAkB,MAAM,EAAE,MAAM;gBAA/C,OAAO,EAAE,MAAM,EAAkB,MAAM,EAAE,MAAM;CAK5E;AAED,qBAAa,4BAA6B,SAAQ,KAAK;aAEnC,OAAO,EAAE,MAAM;aACf,YAAY,EAAE,MAAM;gBADpB,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM;CAQvC;AAED,qBAAa,uBAAwB,SAAQ,KAAK;aACpB,OAAO,EAAE,MAAM;gBAAf,OAAO,EAAE,MAAM;CAK5C;AAED,qBAAa,4BAA6B,SAAQ,KAAK;aAEnC,OAAO,EAAE,MAAM;aACf,MAAM,EAAE,MAAM;gBADd,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM;CAMjC"}
@@ -0,0 +1,105 @@
1
+ /**
2
+ * DelegationPort — delegation via → operator (Claim Algebra, S7 spec).
3
+ *
4
+ * Implements capability narrowing (R-1 invariant: child ⊆ parent),
5
+ * chain verification, revocation cascade, and depth limits.
6
+ * Ed25519 signatures, max_depth=5 V0 (configurable 1..10 Enterprise).
7
+ *
8
+ * Spec: docs/plans/PreCarre/canonical/specs/S7.md
9
+ */
10
+ // ─── Typed errors ─────────────────────────────────────────────────────────────
11
+ export class DelegationNotNarrowingError extends Error {
12
+ parentId;
13
+ childId;
14
+ violationType;
15
+ constructor(parentId, childId, violationType // "capability_expansion" | "constraint_removal" | "jurisdiction_expansion"
16
+ ) {
17
+ super(`Delegation R-1 narrowing violated (parent=${parentId}, child=${childId}): ${violationType}`);
18
+ this.parentId = parentId;
19
+ this.childId = childId;
20
+ this.violationType = violationType;
21
+ this.name = "DelegationNotNarrowingError";
22
+ Object.setPrototypeOf(this, new.target.prototype);
23
+ }
24
+ }
25
+ export class DelegationExpiredError extends Error {
26
+ claimId;
27
+ expiresAt;
28
+ constructor(claimId, expiresAt) {
29
+ super(`Delegation claim expired (${claimId}): expires_at=${expiresAt}`);
30
+ this.claimId = claimId;
31
+ this.expiresAt = expiresAt;
32
+ this.name = "DelegationExpiredError";
33
+ Object.setPrototypeOf(this, new.target.prototype);
34
+ }
35
+ }
36
+ export class DelegationRevokedError extends Error {
37
+ claimId;
38
+ revokedAt;
39
+ reason;
40
+ constructor(claimId, revokedAt, reason) {
41
+ super(`Delegation claim revoked (${claimId}) at ${revokedAt}${reason ? `: ${reason}` : ""}`);
42
+ this.claimId = claimId;
43
+ this.revokedAt = revokedAt;
44
+ this.reason = reason;
45
+ this.name = "DelegationRevokedError";
46
+ Object.setPrototypeOf(this, new.target.prototype);
47
+ }
48
+ }
49
+ export class DelegationChainTooDeepError extends Error {
50
+ claimId;
51
+ depth;
52
+ maxDepth;
53
+ constructor(claimId, depth, maxDepth) {
54
+ super(`Delegation chain exceeds max depth (${claimId}): depth=${depth}, max=${maxDepth}`);
55
+ this.claimId = claimId;
56
+ this.depth = depth;
57
+ this.maxDepth = maxDepth;
58
+ this.name = "DelegationChainTooDeepError";
59
+ Object.setPrototypeOf(this, new.target.prototype);
60
+ }
61
+ }
62
+ export class DelegationSignatureInvalidError extends Error {
63
+ claimId;
64
+ reason;
65
+ constructor(claimId, reason) {
66
+ super(`Delegation signature invalid (${claimId}): ${reason}`);
67
+ this.claimId = claimId;
68
+ this.reason = reason;
69
+ this.name = "DelegationSignatureInvalidError";
70
+ Object.setPrototypeOf(this, new.target.prototype);
71
+ }
72
+ }
73
+ export class DelegationCycleDetectedError extends Error {
74
+ claimId;
75
+ cycleSubject;
76
+ constructor(claimId, cycleSubject) {
77
+ super(`Delegation cycle detected (${claimId}): subject ${cycleSubject} appears in chain`);
78
+ this.claimId = claimId;
79
+ this.cycleSubject = cycleSubject;
80
+ this.name = "DelegationCycleDetectedError";
81
+ Object.setPrototypeOf(this, new.target.prototype);
82
+ }
83
+ }
84
+ export class DelegationNotFoundError extends Error {
85
+ claimId;
86
+ constructor(claimId) {
87
+ super(`Delegation claim not found: ${claimId}`);
88
+ this.claimId = claimId;
89
+ this.name = "DelegationNotFoundError";
90
+ Object.setPrototypeOf(this, new.target.prototype);
91
+ }
92
+ }
93
+ export class DelegationTemporalFrameError extends Error {
94
+ claimId;
95
+ reason;
96
+ constructor(claimId, reason // "not_yet_valid" | "temporal_nesting_violated"
97
+ ) {
98
+ super(`Delegation temporal frame error (${claimId}): ${reason}`);
99
+ this.claimId = claimId;
100
+ this.reason = reason;
101
+ this.name = "DelegationTemporalFrameError";
102
+ Object.setPrototypeOf(this, new.target.prototype);
103
+ }
104
+ }
105
+ //# sourceMappingURL=delegation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delegation.js","sourceRoot":"","sources":["../../src/ports/delegation.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AA2GH,iFAAiF;AAEjF,MAAM,OAAO,2BAA4B,SAAQ,KAAK;IAElC;IACA;IACA;IAHlB,YACkB,QAAgB,EAChB,OAAe,EACf,aAAqB,CAAC,2EAA2E;;QAEjH,KAAK,CACH,6CAA6C,QAAQ,WAAW,OAAO,MAAM,aAAa,EAAE,CAC7F,CAAC;QANc,aAAQ,GAAR,QAAQ,CAAQ;QAChB,YAAO,GAAP,OAAO,CAAQ;QACf,kBAAa,GAAb,aAAa,CAAQ;QAKrC,IAAI,CAAC,IAAI,GAAG,6BAA6B,CAAC;QAC1C,MAAM,CAAC,cAAc,CAAC,IAAI,E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,CAAC,CAAC;QAHjD,YAAO,GAAP,OAAO,CAAQ;QACf,WAAM,GAAN,MAAM,CAAQ;QAG9B,IAAI,CAAC,IAAI,GAAG,8BAA8B,CAAC;QAC3C,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACpD,CAAC;CACF"}
@@ -19,6 +19,10 @@
19
19
  * ADR-ECO-017: Cross-product events MUST carry a DomainEvent signature.
20
20
  * Use DomainEvent for inter-product events and CloudEvent for intra-product.
21
21
  *
22
+ * OTel instrumentation: import { createTracedEventBusPort } to wrap any
23
+ * EventBusPort implementation with OpenTelemetry spans per publish/subscribe call.
24
+ * Gracefully degrades to noop spans when no OTel SDK is installed.
25
+ *
22
26
  * @public
23
27
  */
24
28
  export interface CloudEvent {
@@ -151,4 +155,29 @@ export interface EventBusPort {
151
155
  */
152
156
  pendingCount(stream: string, consumerGroup: string): Promise<number>;
153
157
  }
158
+ /**
159
+ * Thrown when an event could not be published to Redis (connection lost,
160
+ * stream key conflict, or OOM on XADD). The original event is available
161
+ * for retry or DLQ routing.
162
+ */
163
+ export declare class EventPublishError extends Error {
164
+ readonly cause?: unknown | undefined;
165
+ /** The stream key the event was targeting. */
166
+ readonly stream: string;
167
+ /** The event id (UUIDv7) that failed to publish. */
168
+ readonly eventId: string;
169
+ constructor(message: string, stream: string, eventId: string, cause?: unknown | undefined);
170
+ }
171
+ /**
172
+ * Wrap any EventBusPort implementation with OTel spans.
173
+ * Publishes and subscribeDomain calls each get a span with the event type
174
+ * and stream as attributes. Gracefully degrades to noop spans when no OTel
175
+ * SDK is installed.
176
+ *
177
+ * Usage:
178
+ * const raw: EventBusPort = buildRedisEventBus(...);
179
+ * const traced = createTracedEventBusPort(raw);
180
+ * await traced.publish(event, "vault.events") // emits "event-bus.publish" span
181
+ */
182
+ export declare function createTracedEventBusPort(impl: EventBusPort): EventBusPort;
154
183
  //# sourceMappingURL=event-bus.d.ts.map