@cohortapp/agent-sdk 2.16.0 → 2.18.4

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 (529) hide show
  1. package/.claude/settings.json +18 -0
  2. package/.env.example +23 -7
  3. package/README.md +1 -0
  4. package/bin/maestro.mjs +62 -0
  5. package/docs/guides/billing-console-keys.md +60 -0
  6. package/docs/guides/front-door-session.md +54 -9
  7. package/docs/guides/mac-mini.md +20 -25
  8. package/docs/guides/poller-daemon-setup.md +4 -1
  9. package/docs/guides/setup-wizard.md +1 -1
  10. package/docs/runbooks/fleet-rollout.md +156 -0
  11. package/docs/runbooks/mac-mini-bootstrap.md +12 -14
  12. package/lib/action-executor.js +19 -3
  13. package/lib/budget-guard.mjs +279 -3
  14. package/lib/channels/base-adapter.mjs +3 -1
  15. package/lib/channels/contract.mjs +2 -1
  16. package/lib/channels/inbox-item.mjs +8 -0
  17. package/lib/claude-bin.mjs +5 -6
  18. package/lib/cli/doctor-checks.mjs +141 -10
  19. package/lib/cli/global-setup-extras.mjs +5 -1
  20. package/lib/cli/inbox.mjs +100 -15
  21. package/lib/cli/seat-auth.mjs +463 -0
  22. package/lib/cli/session.mjs +80 -12
  23. package/lib/collective/capture.mjs +8 -6
  24. package/lib/collective/global-config.mjs +63 -1
  25. package/lib/collective/presence.mjs +142 -5
  26. package/lib/comms/send-gate.mjs +559 -1
  27. package/lib/context/budget.mjs +327 -0
  28. package/lib/context/history-scope.mjs +138 -0
  29. package/lib/diagnostics/alerts.mjs +49 -0
  30. package/lib/diagnostics/cadence-output-freshness.mjs +288 -0
  31. package/lib/engine/agents/definitions.mjs +343 -0
  32. package/lib/engine/agents/persist.mjs +275 -0
  33. package/lib/engine/agents/runtime.mjs +748 -0
  34. package/lib/engine/agents/usage.mjs +95 -0
  35. package/lib/engine/auth-status.mjs +139 -0
  36. package/lib/engine/budget.mjs +194 -0
  37. package/lib/engine/cli.mjs +1204 -0
  38. package/lib/engine/commands/index.mjs +269 -0
  39. package/lib/engine/context/budget.mjs +219 -0
  40. package/lib/engine/context/cache.mjs +125 -0
  41. package/lib/engine/context/child-env.mjs +215 -0
  42. package/lib/engine/context/compaction.mjs +342 -0
  43. package/lib/engine/context/images.mjs +90 -0
  44. package/lib/engine/context/instructions.mjs +327 -0
  45. package/lib/engine/context/lazy-instructions.mjs +169 -0
  46. package/lib/engine/context/manager.mjs +182 -0
  47. package/lib/engine/context/real-path.mjs +91 -0
  48. package/lib/engine/context/secret-values.mjs +163 -0
  49. package/lib/engine/context/settings.mjs +274 -0
  50. package/lib/engine/context/stream-input.mjs +159 -0
  51. package/lib/engine/guard.mjs +152 -0
  52. package/lib/engine/hooks.mjs +713 -0
  53. package/lib/engine/loop.mjs +560 -0
  54. package/lib/engine/mcp/client.mjs +254 -0
  55. package/lib/engine/mcp/config.mjs +301 -0
  56. package/lib/engine/mcp/http.mjs +201 -0
  57. package/lib/engine/mcp/index.mjs +146 -0
  58. package/lib/engine/mcp/jsonrpc.mjs +147 -0
  59. package/lib/engine/mcp/naming.mjs +66 -0
  60. package/lib/engine/mcp/resources.mjs +89 -0
  61. package/lib/engine/mcp/results.mjs +133 -0
  62. package/lib/engine/mcp/stdio.mjs +137 -0
  63. package/lib/engine/mcp/supervisor.mjs +116 -0
  64. package/lib/engine/messages.mjs +104 -0
  65. package/lib/engine/output/json.mjs +164 -0
  66. package/lib/engine/output/stream-json.mjs +266 -0
  67. package/lib/engine/permissions.mjs +845 -0
  68. package/lib/engine/process-identity.mjs +164 -0
  69. package/lib/engine/process-tree.mjs +551 -0
  70. package/lib/engine/prompt.mjs +60 -0
  71. package/lib/engine/session/store.mjs +299 -0
  72. package/lib/engine/session-runtime/args.mjs +97 -0
  73. package/lib/engine/session-runtime/host.mjs +143 -0
  74. package/lib/engine/session-runtime/inbox.mjs +122 -0
  75. package/lib/engine/session-runtime/notifications.mjs +129 -0
  76. package/lib/engine/session-runtime/registry.mjs +328 -0
  77. package/lib/engine/session-runtime/runner.mjs +344 -0
  78. package/lib/engine/session-runtime/socket.mjs +212 -0
  79. package/lib/engine/session-runtime/wakeup.mjs +115 -0
  80. package/lib/engine/skills/index.mjs +321 -0
  81. package/lib/engine/tools/bash-background.mjs +533 -0
  82. package/lib/engine/tools/bash.mjs +216 -0
  83. package/lib/engine/tools/edit.mjs +97 -0
  84. package/lib/engine/tools/glob.mjs +81 -0
  85. package/lib/engine/tools/grep.mjs +224 -0
  86. package/lib/engine/tools/index.mjs +84 -0
  87. package/lib/engine/tools/list-agents.mjs +32 -0
  88. package/lib/engine/tools/ls.mjs +127 -0
  89. package/lib/engine/tools/monitor.mjs +82 -0
  90. package/lib/engine/tools/notebook-edit.mjs +218 -0
  91. package/lib/engine/tools/read.mjs +103 -0
  92. package/lib/engine/tools/schedule-wakeup.mjs +45 -0
  93. package/lib/engine/tools/schema.mjs +144 -0
  94. package/lib/engine/tools/send-message.mjs +77 -0
  95. package/lib/engine/tools/session.mjs +70 -0
  96. package/lib/engine/tools/todo.mjs +144 -0
  97. package/lib/engine/tools/toolsearch.mjs +217 -0
  98. package/lib/engine/tools/walk.mjs +193 -0
  99. package/lib/engine/tools/web-switch.mjs +31 -0
  100. package/lib/engine/tools/webfetch-html.mjs +387 -0
  101. package/lib/engine/tools/webfetch-net.mjs +340 -0
  102. package/lib/engine/tools/webfetch.mjs +198 -0
  103. package/lib/engine/tools/websearch.mjs +91 -0
  104. package/lib/engine/tools/workflow.mjs +95 -0
  105. package/lib/engine/tools/write.mjs +76 -0
  106. package/lib/engine/tui/line-editor.mjs +137 -0
  107. package/lib/engine/tui/render.mjs +86 -0
  108. package/lib/engine/tui/tui.mjs +274 -0
  109. package/lib/engine/wire/anthropic-messages.mjs +263 -0
  110. package/lib/engine/wire/effort.mjs +36 -0
  111. package/lib/engine/wire/errors.mjs +496 -0
  112. package/lib/engine/wire/http.mjs +441 -0
  113. package/lib/engine/wire/index.mjs +76 -0
  114. package/lib/engine/wire/openai-chat.mjs +332 -0
  115. package/lib/engine/wire/prompt-cache.mjs +79 -0
  116. package/lib/engine/wire/search.mjs +140 -0
  117. package/lib/engine/wire/sse.mjs +114 -0
  118. package/lib/engine/wire/stall.mjs +349 -0
  119. package/lib/engine/wire/token-provider.mjs +175 -0
  120. package/lib/engine/wire/usage.mjs +192 -0
  121. package/lib/engine/workflow/host.mjs +524 -0
  122. package/lib/engine/workflow/journal.mjs +188 -0
  123. package/lib/engine/workflow/json-schema.mjs +171 -0
  124. package/lib/engine/workflow/meta.mjs +329 -0
  125. package/lib/engine/workflow/notifications.mjs +52 -0
  126. package/lib/engine/workflow/runtime.mjs +447 -0
  127. package/lib/engine/workflow/sandbox.mjs +534 -0
  128. package/lib/engine/workflow/worker.mjs +141 -0
  129. package/lib/engine/workflow/worktree.mjs +74 -0
  130. package/lib/execution/disposition.mjs +1 -1
  131. package/lib/execution/intake.mjs +10 -0
  132. package/lib/execution/surface-policy.mjs +15 -0
  133. package/lib/learning/curator.mjs +8 -6
  134. package/lib/learning/reflect.mjs +8 -6
  135. package/lib/model-router/catalog/cohort.yaml +137 -0
  136. package/lib/model-router/catalog.mjs +118 -1
  137. package/lib/model-router/economics.mjs +9 -0
  138. package/lib/model-router/failover.mjs +67 -16
  139. package/lib/model-router/llm-task.mjs +39 -3
  140. package/lib/model-router/resolve.mjs +95 -3
  141. package/lib/model-router/spawn.mjs +46 -47
  142. package/lib/model-router/taxonomy.mjs +126 -4
  143. package/lib/org/cost-sync.mjs +141 -11
  144. package/lib/org/inbound/broadcast.mjs +289 -0
  145. package/lib/org/inbound/collective.mjs +375 -0
  146. package/lib/org/inbound/directedness.mjs +96 -8
  147. package/lib/org/inbound/facts.mjs +82 -4
  148. package/lib/org/inbound/hydrate.mjs +555 -51
  149. package/lib/org/inbound/project.mjs +22 -0
  150. package/lib/org/inbound/surfaces.mjs +14 -0
  151. package/lib/org/llm-token.mjs +879 -0
  152. package/lib/org/mesh.mjs +61 -0
  153. package/lib/org/messaging.mjs +3 -1
  154. package/lib/org/protocol.checksum +1 -1
  155. package/lib/org/protocol.mjs +15 -0
  156. package/lib/org/quota.mjs +520 -0
  157. package/lib/org/tool-surface.mjs +104 -16
  158. package/lib/org/ui-parity.mjs +16 -1
  159. package/lib/org/work-ledger.mjs +37 -6
  160. package/lib/rate-guard.mjs +114 -1
  161. package/lib/resource-governor.mjs +41 -6
  162. package/lib/runtime/adapter.mjs +823 -0
  163. package/lib/runtime/child-env.mjs +191 -0
  164. package/lib/runtime/legacy-shell-guard.mjs +97 -0
  165. package/lib/runtime/seat-engine.mjs +162 -0
  166. package/lib/session/ask-ledger.mjs +271 -0
  167. package/lib/session/current-work.mjs +676 -0
  168. package/lib/session/feed-core.mjs +40 -3
  169. package/lib/session/launch-args.mjs +56 -4
  170. package/lib/session/status-summary.mjs +26 -9
  171. package/lib/session/upgrade-notice.mjs +42 -0
  172. package/lib/setup/claude-probe.mjs +117 -13
  173. package/lib/setup/enrich.mjs +13 -10
  174. package/lib/setup/sections/model.mjs +39 -13
  175. package/lib/telemetry/collect.mjs +208 -9
  176. package/lib/upgrade/ignored-drift.mjs +105 -0
  177. package/lib/voice/post-call-brief.mjs +30 -17
  178. package/package.json +15 -3
  179. package/plugins/maestro-skills/skills/board-work.md +5 -0
  180. package/plugins/maestro-skills/skills/inbound-triage.md +56 -15
  181. package/plugins/maestro-skills/skills/main-session.md +18 -7
  182. package/scripts/ci/check-tarball-fidelity.mjs +126 -2
  183. package/scripts/ci/run-tests.mjs +47 -19
  184. package/scripts/cohort-llm/api-key-helper.mjs +92 -0
  185. package/scripts/collective/hook-runner.mjs +29 -2
  186. package/scripts/continuous-monitor.sh +13 -0
  187. package/scripts/cost/track-claude-usage.mjs +15 -0
  188. package/scripts/daemon/agent-daemon.mjs +408 -20
  189. package/scripts/daemon/assurance.mjs +48 -12
  190. package/scripts/daemon/cadence-consumer.mjs +218 -68
  191. package/scripts/daemon/cadence-handlers.mjs +73 -4
  192. package/scripts/daemon/classifier.mjs +75 -26
  193. package/scripts/daemon/context-compiler.mjs +104 -59
  194. package/scripts/daemon/deliver.mjs +30 -1
  195. package/scripts/daemon/dispatcher.mjs +804 -157
  196. package/scripts/daemon/health.mjs +14 -1
  197. package/scripts/daemon/lib/session-router.mjs +310 -42
  198. package/scripts/daemon/maestro-daemon.mjs +11 -0
  199. package/scripts/daemon/prompt-builder.mjs +121 -12
  200. package/scripts/daemon/responder.mjs +315 -146
  201. package/scripts/daemon/sdk-version.mjs +98 -16
  202. package/scripts/eval/probe-gateway.mjs +635 -0
  203. package/scripts/eval/replay/extract.mjs +270 -0
  204. package/scripts/eval/replay/grade.mjs +260 -0
  205. package/scripts/eval/replay/lib/config.mjs +50 -0
  206. package/scripts/eval/replay/lib/effects.mjs +65 -0
  207. package/scripts/eval/replay/lib/fixture.mjs +188 -0
  208. package/scripts/eval/replay/lib/judge.mjs +72 -0
  209. package/scripts/eval/replay/lib/redact.mjs +136 -0
  210. package/scripts/eval/replay/lib/sandbox.mjs +170 -0
  211. package/scripts/eval/replay/lib/schema-check.mjs +63 -0
  212. package/scripts/eval/replay/lib/transcript.mjs +76 -0
  213. package/scripts/eval/replay/mcp-replay-stub.mjs +101 -0
  214. package/scripts/eval/replay/report.mjs +185 -0
  215. package/scripts/eval/replay/run.mjs +404 -0
  216. package/scripts/fleet/rollout.mjs +1094 -0
  217. package/scripts/hooks/pre-send-audit.sh +36 -245
  218. package/scripts/hooks/pre-write-yaml-validate.mjs +275 -0
  219. package/scripts/hooks/validate-state-yaml.sh +190 -0
  220. package/scripts/huddle/huddle-llm.mjs +361 -0
  221. package/scripts/huddle/huddle-server.mjs +46 -121
  222. package/scripts/local-triggers/autoupdate.sh +448 -78
  223. package/scripts/local-triggers/run-trigger.sh +13 -0
  224. package/scripts/maintenance/pin-integrity.mjs +364 -0
  225. package/scripts/poll-slack-events.sh +41 -9
  226. package/scripts/poller/slack-socket-mode.mjs +28 -3
  227. package/scripts/session/supervisor.mjs +80 -13
  228. package/scripts/spawn-session.sh +13 -0
  229. package/bin/maestro.test.mjs +0 -1574
  230. package/lib/action-executor.test.mjs +0 -871
  231. package/lib/archetype.test.mjs +0 -132
  232. package/lib/assurance/plan-note.test.mjs +0 -234
  233. package/lib/assurance/room-budget.test.mjs +0 -486
  234. package/lib/assurance/tier.test.mjs +0 -174
  235. package/lib/autonomy.test.mjs +0 -66
  236. package/lib/backlog.test.mjs +0 -302
  237. package/lib/backup/policy.test.mjs +0 -305
  238. package/lib/budget-escalate.test.mjs +0 -232
  239. package/lib/budget-guard.envelope.test.mjs +0 -476
  240. package/lib/budget-guard.test.mjs +0 -427
  241. package/lib/cadence-bus-requeue.test.mjs +0 -83
  242. package/lib/cadence-bus-schedule.test.mjs +0 -194
  243. package/lib/cadence-bus.test.mjs +0 -720
  244. package/lib/cadences.test.mjs +0 -230
  245. package/lib/capability/inventory.test.mjs +0 -232
  246. package/lib/capability.test.mjs +0 -78
  247. package/lib/channels/base-adapter.test.mjs +0 -590
  248. package/lib/channels/channels.test.mjs +0 -371
  249. package/lib/channels/contract.test.mjs +0 -162
  250. package/lib/channels/inbox-item.test.mjs +0 -368
  251. package/lib/channels/orgmail/adapter.test.mjs +0 -448
  252. package/lib/channels/pairing.test.mjs +0 -270
  253. package/lib/channels/repeat-suppressor.test.mjs +0 -134
  254. package/lib/channels/slack-adapter.test.mjs +0 -212
  255. package/lib/channels/telegram-adapter.test.mjs +0 -306
  256. package/lib/channels/voice/adapter.test.mjs +0 -278
  257. package/lib/channels/whatsapp/adapter-baileys.test.mjs +0 -359
  258. package/lib/channels/whatsapp/baileys-typing.test.mjs +0 -154
  259. package/lib/charter.test.mjs +0 -89
  260. package/lib/claude-bin.test.mjs +0 -131
  261. package/lib/cli/board.test.mjs +0 -227
  262. package/lib/cli/design.test.mjs +0 -270
  263. package/lib/cli/doctor-checks.test.mjs +0 -336
  264. package/lib/cli/global-setup-extras.test.mjs +0 -462
  265. package/lib/cli/inbox.test.mjs +0 -230
  266. package/lib/cli/session-ack.test.mjs +0 -63
  267. package/lib/cli/session.test.mjs +0 -613
  268. package/lib/collective/capture.test.mjs +0 -121
  269. package/lib/collective/cards.test.mjs +0 -114
  270. package/lib/collective/config.test.mjs +0 -123
  271. package/lib/collective/global-config.test.mjs +0 -220
  272. package/lib/collective/global-skills.test.mjs +0 -126
  273. package/lib/collective/presence.test.mjs +0 -95
  274. package/lib/collective/recall.test.mjs +0 -116
  275. package/lib/collective/vendor-skills.test.mjs +0 -306
  276. package/lib/comms/send-gate.test.mjs +0 -770
  277. package/lib/comms.test.mjs +0 -41
  278. package/lib/cost/ledger-row.test.mjs +0 -183
  279. package/lib/design/design-md.test.mjs +0 -318
  280. package/lib/design/fixtures/DESIGN.golden.md +0 -238
  281. package/lib/design/fixtures/PRODUCT.golden.md +0 -67
  282. package/lib/design/fixtures/foundation.json +0 -133
  283. package/lib/design/refresh-gate.test.mjs +0 -144
  284. package/lib/design/write.test.mjs +0 -241
  285. package/lib/diagnostics/alerts.test.mjs +0 -318
  286. package/lib/diagnostics/backup-freshness.test.mjs +0 -185
  287. package/lib/diagnostics/counters.test.mjs +0 -206
  288. package/lib/diagnostics/events.test.mjs +0 -290
  289. package/lib/diagnostics/otel.test.mjs +0 -196
  290. package/lib/diagnostics/trace.test.mjs +0 -251
  291. package/lib/env-compat.test.mjs +0 -104
  292. package/lib/execution/disposition.test.mjs +0 -553
  293. package/lib/execution/drive.test.mjs +0 -270
  294. package/lib/execution/effects.test.mjs +0 -344
  295. package/lib/execution/intake.test.mjs +0 -389
  296. package/lib/execution/journal.test.mjs +0 -261
  297. package/lib/execution/match.test.mjs +0 -235
  298. package/lib/execution/pipeline.test.mjs +0 -392
  299. package/lib/execution/route.test.mjs +0 -186
  300. package/lib/execution/surface-policy.test.mjs +0 -162
  301. package/lib/fs-atomic.test.mjs +0 -72
  302. package/lib/fs-ownership.test.mjs +0 -158
  303. package/lib/goals/admission.test.mjs +0 -164
  304. package/lib/goals/classify.test.mjs +0 -167
  305. package/lib/goals/collaborate.test.mjs +0 -336
  306. package/lib/goals/gaps.test.mjs +0 -284
  307. package/lib/goals/loop.test.mjs +0 -845
  308. package/lib/hooks/bus.test.mjs +0 -387
  309. package/lib/identity/persona.test.mjs +0 -142
  310. package/lib/kpi-sensors.test.mjs +0 -278
  311. package/lib/kpi.test.mjs +0 -244
  312. package/lib/learning/config.test.mjs +0 -75
  313. package/lib/learning/counters.test.mjs +0 -69
  314. package/lib/learning/curator-consolidate.test.mjs +0 -238
  315. package/lib/learning/curator.test.mjs +0 -106
  316. package/lib/learning/reflect.test.mjs +0 -0
  317. package/lib/learning/session-index.test.mjs +0 -125
  318. package/lib/learning/skill-writer.test.mjs +0 -210
  319. package/lib/mandate/audit.test.mjs +0 -195
  320. package/lib/mandate/contract.test.mjs +0 -185
  321. package/lib/mandate/derive.test.mjs +0 -274
  322. package/lib/mandate/model.test.mjs +0 -164
  323. package/lib/mandate/refresh.test.mjs +0 -389
  324. package/lib/mcp/server.test.mjs +0 -426
  325. package/lib/model-router/auth-profiles.test.mjs +0 -580
  326. package/lib/model-router/catalog.test.mjs +0 -385
  327. package/lib/model-router/economics.test.mjs +0 -438
  328. package/lib/model-router/failover.test.mjs +0 -439
  329. package/lib/model-router/health.test.mjs +0 -338
  330. package/lib/model-router/integration-coverage.test.mjs +0 -831
  331. package/lib/model-router/integration.test.mjs +0 -564
  332. package/lib/model-router/ledger.test.mjs +0 -415
  333. package/lib/model-router/llm-task.test.mjs +0 -392
  334. package/lib/model-router/org-credentials.test.mjs +0 -265
  335. package/lib/model-router/pricing-refresh.test.mjs +0 -286
  336. package/lib/model-router/reconcile.test.mjs +0 -316
  337. package/lib/model-router/repair.test.mjs +0 -180
  338. package/lib/model-router/spawn.test.mjs +0 -446
  339. package/lib/model-router/taxonomy.test.mjs +0 -410
  340. package/lib/model-router.test.mjs +0 -1207
  341. package/lib/org/activity.test.mjs +0 -134
  342. package/lib/org/approvals.test.mjs +0 -216
  343. package/lib/org/awareness.test.mjs +0 -159
  344. package/lib/org/board-mine-cache.test.mjs +0 -53
  345. package/lib/org/board.test.mjs +0 -187
  346. package/lib/org/bootstrap-context.test.mjs +0 -153
  347. package/lib/org/client.test.mjs +0 -1206
  348. package/lib/org/cohort-client.test.mjs +0 -126
  349. package/lib/org/cost-sync.test.mjs +0 -153
  350. package/lib/org/doctor.test.mjs +0 -346
  351. package/lib/org/engagement-ledger.test.mjs +0 -112
  352. package/lib/org/engagement.test.mjs +0 -739
  353. package/lib/org/handoff.test.mjs +0 -269
  354. package/lib/org/inbound/directedness.test.mjs +0 -668
  355. package/lib/org/inbound/facts.test.mjs +0 -471
  356. package/lib/org/inbound/hydrate.test.mjs +0 -453
  357. package/lib/org/inbound/index.test.mjs +0 -429
  358. package/lib/org/inbound/project.test.mjs +0 -287
  359. package/lib/org/integration-tools.test.mjs +0 -160
  360. package/lib/org/keys.test.mjs +0 -92
  361. package/lib/org/knowledge.test.mjs +0 -326
  362. package/lib/org/leases.test.mjs +0 -235
  363. package/lib/org/mesh-directives.test.mjs +0 -110
  364. package/lib/org/mesh-integration.test.mjs +0 -127
  365. package/lib/org/mesh.test.mjs +0 -400
  366. package/lib/org/messaging.test.mjs +0 -471
  367. package/lib/org/param-contract.test.mjs +0 -477
  368. package/lib/org/policy.test.mjs +0 -237
  369. package/lib/org/protocol.checksum.test.mjs +0 -90
  370. package/lib/org/protocol.test.mjs +0 -323
  371. package/lib/org/push.test.mjs +0 -792
  372. package/lib/org/registry.test.mjs +0 -100
  373. package/lib/org/resource-tools.test.mjs +0 -361
  374. package/lib/org/tool-access.test.mjs +0 -144
  375. package/lib/org/tool-surface-integration.test.mjs +0 -120
  376. package/lib/org/tool-surface.test.mjs +0 -1268
  377. package/lib/org/typing.test.mjs +0 -291
  378. package/lib/org/ui-parity.test.mjs +0 -560
  379. package/lib/org/verify.test.mjs +0 -194
  380. package/lib/org/work-ledger.test.mjs +0 -273
  381. package/lib/plan/adoption-e2e.test.mjs +0 -366
  382. package/lib/plan/budget-enforcement.test.mjs +0 -400
  383. package/lib/plan/compile.test.mjs +0 -382
  384. package/lib/plan/emit.test.mjs +0 -269
  385. package/lib/plan/explain.test.mjs +0 -188
  386. package/lib/prompts/parallelism.test.mjs +0 -177
  387. package/lib/rag/rag.test.mjs +0 -505
  388. package/lib/rate-guard.test.mjs +0 -272
  389. package/lib/reactive-gate.test.mjs +0 -57
  390. package/lib/render.test.mjs +0 -68
  391. package/lib/resource-governor.test.mjs +0 -488
  392. package/lib/scheduling/dynamic-jobs.test.mjs +0 -344
  393. package/lib/scheduling/jitter.test.mjs +0 -140
  394. package/lib/secrets/broker.test.mjs +0 -280
  395. package/lib/secrets/providers.test.mjs +0 -274
  396. package/lib/security/audit-engine.test.mjs +0 -424
  397. package/lib/security/coerce-args.test.mjs +0 -281
  398. package/lib/security/dangerous-tools.test.mjs +0 -68
  399. package/lib/security/external-content.test.mjs +0 -84
  400. package/lib/security/redact.test.mjs +0 -441
  401. package/lib/security/secret-equal.test.mjs +0 -55
  402. package/lib/session/config.test.mjs +0 -92
  403. package/lib/session/feed-core.test.mjs +0 -198
  404. package/lib/session/first-run.test.mjs +0 -121
  405. package/lib/session/frontdoor.test.mjs +0 -205
  406. package/lib/session/handoffs.test.mjs +0 -183
  407. package/lib/session/identity.test.mjs +0 -180
  408. package/lib/session/inbox-claims.test.mjs +0 -286
  409. package/lib/session/launch-args.test.mjs +0 -157
  410. package/lib/session/liveness.test.mjs +0 -100
  411. package/lib/session/status-summary.test.mjs +0 -118
  412. package/lib/session-permissions.test.mjs +0 -120
  413. package/lib/setup/claude-probe.test.mjs +0 -187
  414. package/lib/setup/completeness.test.mjs +0 -110
  415. package/lib/setup/context-pack.test.mjs +0 -89
  416. package/lib/setup/enrich.test.mjs +0 -115
  417. package/lib/setup/enroll-from-cohort.test.mjs +0 -300
  418. package/lib/setup/integration.test.mjs +0 -162
  419. package/lib/setup/io.test.mjs +0 -77
  420. package/lib/setup/runner.test.mjs +0 -132
  421. package/lib/setup/sections/identity.test.mjs +0 -234
  422. package/lib/setup/sections/inventory.test.mjs +0 -198
  423. package/lib/setup/sections/learning.test.mjs +0 -81
  424. package/lib/setup/sections/mandate.test.mjs +0 -388
  425. package/lib/setup/sections/messaging.test.mjs +0 -127
  426. package/lib/setup/sections/model.test.mjs +0 -240
  427. package/lib/setup/sections/org.test.mjs +0 -346
  428. package/lib/setup/sections/orgmail.test.mjs +0 -118
  429. package/lib/setup/sections/recovery.test.mjs +0 -98
  430. package/lib/setup/sections/subagents.test.mjs +0 -429
  431. package/lib/setup/sections/verify.test.mjs +0 -175
  432. package/lib/setup/sot.test.mjs +0 -81
  433. package/lib/setup/state.test.mjs +0 -115
  434. package/lib/singleton.test.mjs +0 -151
  435. package/lib/subagents/cli.test.mjs +0 -389
  436. package/lib/subagents/client.test.mjs +0 -309
  437. package/lib/subagents/gap.test.mjs +0 -234
  438. package/lib/subagents/lock.test.mjs +0 -248
  439. package/lib/subagents/manifest.test.mjs +0 -175
  440. package/lib/subagents/refs.test.mjs +0 -204
  441. package/lib/subagents/resolve.test.mjs +0 -422
  442. package/lib/subagents/schema.test.mjs +0 -328
  443. package/lib/telemetry/alerts.test.mjs +0 -109
  444. package/lib/telemetry/collect.test.mjs +0 -1274
  445. package/lib/tool-definitions-integration.test.mjs +0 -83
  446. package/lib/tool-definitions.test.mjs +0 -437
  447. package/lib/upgrade/global-refresh.test.mjs +0 -65
  448. package/lib/upgrade/launchd-reconcile.test.mjs +0 -272
  449. package/lib/upgrade/post-steps.test.mjs +0 -200
  450. package/lib/upgrade/verify.test.mjs +0 -164
  451. package/lib/util/fetch-timeout.test.mjs +0 -202
  452. package/lib/util/reconnect.test.mjs +0 -369
  453. package/lib/util/unhandled.test.mjs +0 -216
  454. package/lib/voice/outbound.test.mjs +0 -69
  455. package/lib/voice/session-rotation.test.mjs +0 -114
  456. package/lib/voice/stt.test.mjs +0 -226
  457. package/lib/voice/voice.test.mjs +0 -990
  458. package/scripts/cadence/enqueue-cadence-tick.test.mjs +0 -187
  459. package/scripts/ci/check-docs-accuracy.test.mjs +0 -409
  460. package/scripts/ci/check-durable-write-seam.test.mjs +0 -90
  461. package/scripts/ci/check-no-build-artifacts.test.mjs +0 -71
  462. package/scripts/ci/check-no-residual-identity.test.mjs +0 -202
  463. package/scripts/ci/check-skill-packs.test.mjs +0 -495
  464. package/scripts/ci/check-subagent-frontmatter.test.mjs +0 -124
  465. package/scripts/ci/check.test.mjs +0 -194
  466. package/scripts/ci/conformance-org-api.test.mjs +0 -425
  467. package/scripts/cloud-relay/voice/relay-identity.test.mjs +0 -96
  468. package/scripts/collective/hook-runner.test.mjs +0 -173
  469. package/scripts/cost/fleet-digest.test.mjs +0 -207
  470. package/scripts/cost/track-claude-usage-pricing.test.mjs +0 -183
  471. package/scripts/cost/track-claude-usage.test.mjs +0 -148
  472. package/scripts/daemon/agent-daemon-board-mine.test.mjs +0 -96
  473. package/scripts/daemon/agent-daemon-design.test.mjs +0 -238
  474. package/scripts/daemon/agent-daemon-frontdoor.test.mjs +0 -60
  475. package/scripts/daemon/agent-daemon.test.mjs +0 -995
  476. package/scripts/daemon/assurance-e2e.test.mjs +0 -613
  477. package/scripts/daemon/assurance.test.mjs +0 -1791
  478. package/scripts/daemon/board-mirror.test.mjs +0 -165
  479. package/scripts/daemon/cadence-consumer-frontdoor.test.mjs +0 -393
  480. package/scripts/daemon/cadence-consumer-governance.test.mjs +0 -276
  481. package/scripts/daemon/cadence-consumer.test.mjs +0 -776
  482. package/scripts/daemon/cadence-handlers.test.mjs +0 -837
  483. package/scripts/daemon/classifier-identity.test.mjs +0 -137
  484. package/scripts/daemon/classifier.test.mjs +0 -266
  485. package/scripts/daemon/classify-kind.test.mjs +0 -40
  486. package/scripts/daemon/context-compiler.test.mjs +0 -300
  487. package/scripts/daemon/deliver.test.mjs +0 -564
  488. package/scripts/daemon/dispatcher-cooldown.test.mjs +0 -122
  489. package/scripts/daemon/dispatcher-governance.test.mjs +0 -1013
  490. package/scripts/daemon/dispatcher-resume.test.mjs +0 -166
  491. package/scripts/daemon/execution-ladder.test.mjs +0 -470
  492. package/scripts/daemon/goal-steward-cadence.test.mjs +0 -312
  493. package/scripts/daemon/inbox-deferral-session.test.mjs +0 -49
  494. package/scripts/daemon/inbox-deferral.test.mjs +0 -336
  495. package/scripts/daemon/inbox-wake.test.mjs +0 -199
  496. package/scripts/daemon/integration.test.mjs +0 -149
  497. package/scripts/daemon/lib/self-echo.test.mjs +0 -153
  498. package/scripts/daemon/lib/session-router.test.mjs +0 -295
  499. package/scripts/daemon/prompt-builder-preamble.test.mjs +0 -210
  500. package/scripts/daemon/prompt-builder.test.mjs +0 -344
  501. package/scripts/daemon/responder-cost.test.mjs +0 -68
  502. package/scripts/daemon/responder-history.test.mjs +0 -185
  503. package/scripts/daemon/sdk-version.test.mjs +0 -31
  504. package/scripts/daemon/session-lock.test.mjs +0 -252
  505. package/scripts/daemon/session-outcomes.test.mjs +0 -533
  506. package/scripts/daemon/typing-registry.test.mjs +0 -102
  507. package/scripts/hooks/pre-send-audit.test.mjs +0 -354
  508. package/scripts/huddle/huddle-prompt.test.mjs +0 -176
  509. package/scripts/local-triggers/autoupdate.test.mjs +0 -518
  510. package/scripts/local-triggers/generate-plists.test.mjs +0 -456
  511. package/scripts/media-generation/brand-clause.test.mjs +0 -135
  512. package/scripts/org/send-orgmail.first-contact.test.mjs +0 -102
  513. package/scripts/poller/inbox-privilege-injection.test.mjs +0 -167
  514. package/scripts/poller/inbox-scan-poller.test.mjs +0 -295
  515. package/scripts/poller/lib/cloud-relay-dedup.test.mjs +0 -133
  516. package/scripts/poller/slack-socket-mode.test.mjs +0 -805
  517. package/scripts/poller-launchd/install.test.mjs +0 -243
  518. package/scripts/restore-from-backup.test.mjs +0 -181
  519. package/scripts/session/feed.test.mjs +0 -196
  520. package/scripts/session/supervisor-sh.test.mjs +0 -218
  521. package/scripts/session/supervisor.test.mjs +0 -482
  522. package/scripts/setup/configure-macos.test.mjs +0 -306
  523. package/scripts/setup/gen-subagent-manifest.test.mjs +0 -124
  524. package/scripts/setup/generate-agent-package-json.test.mjs +0 -143
  525. package/scripts/setup/generate-capability.test.mjs +0 -134
  526. package/scripts/setup/init-agent.test.mjs +0 -370
  527. package/scripts/setup/init-skill-marketplace.test.mjs +0 -193
  528. package/scripts/vendor/sync-skill-packs.test.mjs +0 -103
  529. package/scripts/watchdog/memory-watchdog.test.mjs +0 -64
@@ -1,237 +0,0 @@
1
- /**
2
- * policy.test.mjs — fetch + verify-signed policy bundle against the PINNED trust
3
- * root, cache it, isStale, and the policy_stale directive handler. A GOOD
4
- * signature applies + caches; a BAD/unsigned/wrong-signer bundle is QUARANTINED
5
- * (never cached). Real Ed25519 keypairs; injected fetchImpl; tmp cache dir.
6
- * Run: node --test lib/org/policy.test.mjs
7
- */
8
- "use strict";
9
-
10
- import { test } from "node:test";
11
- import assert from "node:assert/strict";
12
- import { mkdtempSync, writeFileSync, existsSync, mkdirSync } from "node:fs";
13
- import { tmpdir } from "node:os";
14
- import { join } from "node:path";
15
-
16
- import { createPublicKey } from "node:crypto";
17
-
18
- import { generateDeviceKey, signWith } from "./keys.mjs";
19
- import { canonicalize } from "./protocol.mjs";
20
- import {
21
- verifyBundle,
22
- readCachedBundle,
23
- cacheBundle,
24
- isStale,
25
- fetchAndApply,
26
- handlePolicyStale,
27
- parseAllowedSigners,
28
- DEFAULT_STALE_MS,
29
- } from "./policy.mjs";
30
-
31
- const BASE = "https://org.cohortapp.com";
32
-
33
- delete process.env.COHORT_API_TOKEN;
34
- delete process.env.COHORT_TOKEN;
35
-
36
- /** Build a bundle and sign its canonical body (envelope stripped) with privPem. */
37
- function signBundle(body, privPem) {
38
- // The verify layer strips content_sig/sig/signature/signer from the body, then
39
- // canonicalizes — so we sign the body WITHOUT those fields.
40
- const material = Buffer.from(canonicalize(body));
41
- return { ...body, content_sig: signWith(privPem, material) };
42
- }
43
-
44
- function cfgFor(signersPem) {
45
- return { org: { cohort: { enabled: true, base: BASE, token: "tok", trustedSignersPem: signersPem } } };
46
- }
47
-
48
- function fakeFetch(responder) {
49
- const calls = [];
50
- const impl = async (url, init) => {
51
- calls.push({ url, init });
52
- const r = responder ? responder(url, init, calls.length - 1) : null;
53
- const status = r && typeof r.status === "number" ? r.status : 200;
54
- const ok = r && typeof r.ok === "boolean" ? r.ok : status >= 200 && status < 300;
55
- const body = r ? r.body : null;
56
- return { ok, status, headers: { get: () => undefined }, json: async () => body };
57
- };
58
- impl.calls = calls;
59
- return impl;
60
- }
61
-
62
- const KEY = generateDeviceKey(); // the trusted signer
63
- const ATTACKER = generateDeviceKey(); // not pinned
64
-
65
- /** Encode an Ed25519 SPKI PEM as an OpenSSH `ssh-ed25519 <base64>` blob. */
66
- function spkiToSshEd25519(spkiPem) {
67
- const der = createPublicKey(spkiPem).export({ type: "spki", format: "der" });
68
- const raw = der.subarray(12);
69
- const sshStr = (buf) => { const l = Buffer.alloc(4); l.writeUInt32BE(buf.length); return Buffer.concat([l, buf]); };
70
- return Buffer.concat([sshStr(Buffer.from("ssh-ed25519")), sshStr(raw)]).toString("base64");
71
- }
72
-
73
- const BODY = { kind: "communication-style", version: 7, content: '{"rule":"no-emoji"}', source_commit: "abc123" };
74
-
75
- // --- verifyBundle ----------------------------------------------------------
76
-
77
- test("verifyBundle: accepts a signature from a pinned signer", () => {
78
- const bundle = signBundle(BODY, KEY.privateKeyPem);
79
- const v = verifyBundle(bundle, [KEY.publicKeyPem]);
80
- assert.equal(v.ok, true);
81
- assert.equal(v.signer, KEY.publicKeyPem);
82
- });
83
-
84
- test("verifyBundle: rejects unsigned, wrong-signer, tampered, and empty-trust", () => {
85
- // unsigned
86
- assert.equal(verifyBundle(BODY, [KEY.publicKeyPem]).ok, false);
87
- // wrong signer (attacker signed; only KEY is pinned)
88
- const attackerBundle = signBundle(BODY, ATTACKER.privateKeyPem);
89
- assert.equal(verifyBundle(attackerBundle, [KEY.publicKeyPem]).ok, false);
90
- // tampered body after signing
91
- const good = signBundle(BODY, KEY.privateKeyPem);
92
- const tampered = { ...good, content: '{"rule":"emoji-ok"}' };
93
- assert.equal(verifyBundle(tampered, [KEY.publicKeyPem]).ok, false);
94
- // empty pinned list → default-deny
95
- assert.equal(verifyBundle(good, []).ok, false);
96
- });
97
-
98
- // --- cache + staleness -----------------------------------------------------
99
-
100
- test("cacheBundle / readCachedBundle round-trip; isStale honours the window", () => {
101
- const dir = mkdtempSync(join(tmpdir(), "policy-cache-"));
102
- const t0 = Date.UTC(2026, 5, 11, 0, 0, 0);
103
- cacheBundle("communication-style", BODY, { cacheDir: dir, now: () => t0, signer: KEY.publicKeyPem });
104
- const rec = readCachedBundle("communication-style", { cacheDir: dir });
105
- assert.equal(rec.bundle.version, 7);
106
- assert.equal(rec.signer, KEY.publicKeyPem);
107
- // fresh just after caching
108
- assert.equal(isStale("communication-style", { cacheDir: dir, now: () => t0 + 1000 }), false);
109
- // stale past the window
110
- assert.equal(isStale("communication-style", { cacheDir: dir, now: () => t0 + DEFAULT_STALE_MS + 1 }), true);
111
- // absent kind → stale (nothing fresh)
112
- assert.equal(isStale("model-allowlist", { cacheDir: dir }), true);
113
- });
114
-
115
- // --- fetchAndApply: good applies + caches; bad quarantines -----------------
116
-
117
- test("fetchAndApply: verifies a good signature, caches the bundle", async () => {
118
- const dir = mkdtempSync(join(tmpdir(), "policy-apply-"));
119
- const bundle = signBundle(BODY, KEY.privateKeyPem);
120
- const f = fakeFetch((url) => (url.includes("/v1/policy") ? { body: bundle } : null));
121
- const r = await fetchAndApply({
122
- cfg: cfgFor([KEY.publicKeyPem]),
123
- kind: "communication-style",
124
- cacheDir: dir,
125
- fetchImpl: f,
126
- });
127
- assert.equal(r.ok, true);
128
- assert.equal(r.applied, true);
129
- assert.equal(r.signer, KEY.publicKeyPem);
130
- // it was cached
131
- assert.ok(readCachedBundle("communication-style", { cacheDir: dir }));
132
- });
133
-
134
- test("fetchAndApply: QUARANTINES a bad-signature bundle — never caches it", async () => {
135
- const dir = mkdtempSync(join(tmpdir(), "policy-quarantine-"));
136
- const forged = signBundle(BODY, ATTACKER.privateKeyPem); // signed by an unpinned key
137
- const f = fakeFetch((url) => (url.includes("/v1/policy") ? { body: forged } : null));
138
- const r = await fetchAndApply({
139
- cfg: cfgFor([KEY.publicKeyPem]), // only KEY is pinned
140
- kind: "communication-style",
141
- cacheDir: dir,
142
- fetchImpl: f,
143
- });
144
- assert.equal(r.ok, false);
145
- assert.equal(r.quarantined, true);
146
- assert.match(r.reason, /not from any pinned signer/);
147
- // NOT cached — the last-good state is untouched
148
- assert.equal(readCachedBundle("communication-style", { cacheDir: dir }), null);
149
- });
150
-
151
- test("fetchAndApply: fetch failure (disabled/unreachable) → no-bundle, no throw", async () => {
152
- const dir = mkdtempSync(join(tmpdir(), "policy-nofetch-"));
153
- const f = fakeFetch(() => ({ ok: false, status: 404, body: {} }));
154
- const r = await fetchAndApply({ cfg: cfgFor([KEY.publicKeyPem]), kind: "x", cacheDir: dir, fetchImpl: f });
155
- assert.equal(r.ok, false);
156
- assert.equal(r.reason, "no-bundle");
157
- });
158
-
159
- // --- handlePolicyStale: the directive handler ------------------------------
160
-
161
- test("handlePolicyStale: re-fetches + re-verifies + caches the named kind", async () => {
162
- const dir = mkdtempSync(join(tmpdir(), "policy-stale-"));
163
- const bundle = signBundle(BODY, KEY.privateKeyPem);
164
- const f = fakeFetch((url) => (url.includes("/v1/policy") ? { body: bundle } : null));
165
- const out = await handlePolicyStale({
166
- cfg: cfgFor([KEY.publicKeyPem]),
167
- kind: "communication-style",
168
- cacheDir: dir,
169
- fetchImpl: f,
170
- });
171
- assert.equal(out.refreshed, 1);
172
- assert.equal(out.results[0].applied, true);
173
- assert.ok(readCachedBundle("communication-style", { cacheDir: dir }));
174
- });
175
-
176
- test("handlePolicyStale: with no kind, refreshes every cached kind", async () => {
177
- const dir = mkdtempSync(join(tmpdir(), "policy-stale-all-"));
178
- // seed two cached kinds
179
- cacheBundle("communication-style", BODY, { cacheDir: dir });
180
- cacheBundle("model-allowlist", { ...BODY, kind: "model-allowlist" }, { cacheDir: dir });
181
- // server returns a freshly-signed bundle for whatever kind is asked
182
- const f = fakeFetch((url) => {
183
- const u = new URL(url);
184
- const kind = u.searchParams.get("kind") || "communication-style";
185
- return { body: signBundle({ ...BODY, kind, version: 8 }, KEY.privateKeyPem) };
186
- });
187
- const out = await handlePolicyStale({ cfg: cfgFor([KEY.publicKeyPem]), cacheDir: dir, fetchImpl: f });
188
- assert.equal(out.refreshed, 2);
189
- });
190
-
191
- // --- trust-root parsing ----------------------------------------------------
192
-
193
- test("parseAllowedSigners: extracts PEM public-key blocks; [] when missing", () => {
194
- const dir = mkdtempSync(join(tmpdir(), "policy-trust-"));
195
- if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
196
- const path = join(dir, "allowed-signers");
197
- writeFileSync(path, `# trust root\n${KEY.publicKeyPem}\n${ATTACKER.publicKeyPem}\n`);
198
- const pems = parseAllowedSigners(path);
199
- assert.equal(pems.length, 2);
200
- // a bundle signed by KEY verifies against the parsed pins
201
- const bundle = signBundle(BODY, KEY.privateKeyPem);
202
- assert.equal(verifyBundle(bundle, pems).ok, true);
203
- // missing file → []
204
- assert.deepEqual(parseAllowedSigners(join(dir, "nope")), []);
205
- });
206
-
207
- test("parseAllowedSigners: loads OpenSSH allowed-signers one-liners (SPEC trust-root format)", () => {
208
- const dir = mkdtempSync(join(tmpdir(), "policy-trust-ssh-"));
209
- if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
210
- const path = join(dir, "allowed-signers");
211
- const keyBlob = spkiToSshEd25519(KEY.publicKeyPem);
212
- const attackerBlob = spkiToSshEd25519(ATTACKER.publicKeyPem);
213
- // The OpenSSH allowed-signers format: principal [namespaces] keytype base64 [comment].
214
- writeFileSync(path,
215
- `# org trust root (allowed-signers format)\n` +
216
- `org@example.com namespaces="policy" ssh-ed25519 ${keyBlob} server-2026\n` +
217
- `bad@evil.example ssh-ed25519 ${attackerBlob}\n`,
218
- );
219
- const pems = parseAllowedSigners(path);
220
- assert.equal(pems.length, 2, "both SSH one-liners convert to SPKI PEMs");
221
- // a bundle signed by KEY verifies against the SSH-loaded pins
222
- const bundle = signBundle(BODY, KEY.privateKeyPem);
223
- assert.equal(verifyBundle(bundle, pems).ok, true);
224
- });
225
-
226
- test("parseAllowedSigners: mixes SPKI PEM blocks and SSH one-liners in one file", () => {
227
- const dir = mkdtempSync(join(tmpdir(), "policy-trust-mixed-"));
228
- if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
229
- const path = join(dir, "allowed-signers");
230
- writeFileSync(path,
231
- `${KEY.publicKeyPem}\n` + // raw SPKI PEM
232
- `peer@example.com ssh-ed25519 ${spkiToSshEd25519(ATTACKER.publicKeyPem)}\n`, // SSH one-liner
233
- );
234
- const pems = parseAllowedSigners(path);
235
- assert.equal(pems.length, 2, "PEM block + SSH line both load (no double-parse of the PEM body)");
236
- assert.equal(verifyBundle(signBundle(BODY, KEY.privateKeyPem), pems).ok, true);
237
- });
@@ -1,90 +0,0 @@
1
- /**
2
- * protocol.checksum.test.mjs — cross-repo wire-contract parity guard.
3
- *
4
- * `lib/org/protocol.mjs` is the SINGLE canonical source of truth for the Cohort
5
- * org-protocol wire contract (method names, scopes, mutating-method set, event
6
- * families, board status vocabulary, error codes, and — critically — the
7
- * `computeRowHash` function that defines the append-only `org_events` hash chain).
8
- * Both maestro (ESM .mjs / Node) and Cohort (TS / Next) must agree on it
9
- * BYTE-FOR-BYTE, or the hash chain and verification will silently diverge.
10
- *
11
- * This test pins the sha256 of `protocol.mjs` to a committed checksum reference
12
- * (`lib/org/protocol.checksum`). If anyone edits `protocol.mjs` without re-vendoring
13
- * the shared `@cohort/protocol` package and updating BOTH repos' checksums, this
14
- * test fails — which is exactly the drift we want to catch in CI.
15
- *
16
- * The ONLY supported way to evolve the protocol: edit `lib/org/protocol.mjs`, run
17
- * `node scripts/sync-protocol.mjs` (re-vendors @cohort/protocol + rewrites both
18
- * checksums), then commit both repos.
19
- *
20
- * Node builtins only. Run: node --test lib/org/protocol.checksum.test.mjs
21
- *
22
- * @module lib/org/protocol.checksum.test
23
- */
24
- "use strict";
25
-
26
- import { test } from "node:test";
27
- import assert from "node:assert/strict";
28
- import { createHash } from "node:crypto";
29
- import { readFileSync } from "node:fs";
30
- import { dirname, join } from "node:path";
31
- import { fileURLToPath } from "node:url";
32
-
33
- const HERE = dirname(fileURLToPath(import.meta.url));
34
- const PROTOCOL_PATH = join(HERE, "protocol.mjs");
35
- const CHECKSUM_PATH = join(HERE, "protocol.checksum");
36
-
37
- /**
38
- * The expected checksum is READ from the committed `protocol.checksum` reference,
39
- * never hardcoded as a literal. `scripts/sync-protocol.mjs` writes that file when
40
- * the protocol changes; reading it here means there is no in-test constant that a
41
- * re-vendor can leave stale (the exact bug class this guard exists to catch). The
42
- * test still triangulates three independent values so a partial sync can't pass:
43
- * sha256(protocol.mjs) === committed protocol.checksum === a fresh digest.
44
- */
45
- const EXPECTED = readFileSync(CHECKSUM_PATH, "utf8").trim();
46
-
47
- /**
48
- * sha256 of a file's exact bytes (no normalization — byte-for-byte is the point).
49
- * @param {string} path
50
- * @returns {string} lowercase hex digest
51
- */
52
- function sha256File(path) {
53
- return createHash("sha256").update(readFileSync(path)).digest("hex");
54
- }
55
-
56
- const DRIFT_MSG =
57
- "protocol drift: lib/org/protocol.mjs changed — run `node scripts/sync-protocol.mjs` " +
58
- "to re-vendor @cohort/protocol + update both checksums, then commit both repos.";
59
-
60
- test("EXPECTED is a well-formed sha256 read from protocol.checksum", () => {
61
- // Guard the source-of-truth file itself: an empty/corrupt checksum file must
62
- // fail loudly here rather than make the digest comparisons trivially pass.
63
- assert.match(
64
- EXPECTED,
65
- /^[0-9a-f]{64}$/,
66
- `lib/org/protocol.checksum is missing or malformed (got: ${JSON.stringify(EXPECTED)}). ${DRIFT_MSG}`,
67
- );
68
- });
69
-
70
- test("protocol.mjs sha256 matches the committed protocol.checksum", () => {
71
- const actual = sha256File(PROTOCOL_PATH);
72
- assert.equal(actual, EXPECTED, DRIFT_MSG);
73
- });
74
-
75
- test("committed protocol.checksum reference matches protocol.mjs", () => {
76
- const actual = sha256File(PROTOCOL_PATH);
77
- const committed = readFileSync(CHECKSUM_PATH, "utf8").trim();
78
- assert.equal(
79
- committed,
80
- actual,
81
- `${DRIFT_MSG} (lib/org/protocol.checksum is stale: ${committed} != ${actual})`,
82
- );
83
- });
84
-
85
- test("the file-read expectation and the committed checksum agree", () => {
86
- // Belt-and-suspenders: EXPECTED is read from protocol.checksum, so this also
87
- // asserts a stable, repeatable read of the same on-disk reference.
88
- const committed = readFileSync(CHECKSUM_PATH, "utf8").trim();
89
- assert.equal(committed, EXPECTED, DRIFT_MSG);
90
- });
@@ -1,323 +0,0 @@
1
- /**
2
- * Tests for lib/org/protocol.mjs — the shared Cohort protocol contract.
3
- * Locks the load-bearing invariants: scope resolution (default-deny + reserved
4
- * namespaces), the hash chain (determinism + tamper detection), and frame
5
- * validation. @module lib/org/protocol.test
6
- */
7
-
8
- import { test } from "node:test";
9
- import assert from "node:assert/strict";
10
- import {
11
- PROTOCOL_VERSION, METHODS, FAMILIES, BOARD_STATUS,
12
- scopeForMethod, actorCan, isReservedAdminNamespace,
13
- computeRowHash, verifyChain, canonicalize,
14
- validateReqFrame, buildReqFrame, okFrame, errFrame,
15
- } from "./protocol.mjs";
16
-
17
- test("protocol: every method's family is a known family", () => {
18
- for (const [name, def] of Object.entries(METHODS)) {
19
- assert.ok(FAMILIES.includes(def.family), `${name} family ${def.family} is known`);
20
- }
21
- });
22
-
23
- test("scopeForMethod: reserved namespaces always resolve to admin", () => {
24
- assert.equal(scopeForMethod("admin.deactivate"), "admin");
25
- assert.equal(scopeForMethod("pairing.request"), "admin");
26
- assert.equal(scopeForMethod("policy.anything"), "admin");
27
- assert.equal(scopeForMethod("governance.x"), "admin");
28
- // unknown method → admin (deny)
29
- assert.equal(scopeForMethod("totally.unknown"), "admin");
30
- // ordinary method → its declared scope
31
- assert.equal(scopeForMethod("board.claim"), "board.work");
32
- });
33
-
34
- test("actorCan: default-deny; admin satisfies everything", () => {
35
- assert.equal(actorCan(["board.work"], "board.claim"), true);
36
- assert.equal(actorCan(["board.read"], "board.claim"), false, "wrong scope denied");
37
- assert.equal(actorCan(["admin"], "board.claim"), true, "admin is a superset");
38
- assert.equal(actorCan(["board.work"], "admin.deactivate"), false, "non-admin cannot kill-switch");
39
- assert.equal(actorCan([], "board.claim"), false);
40
- assert.equal(actorCan(null, "board.claim"), false);
41
- });
42
-
43
- test("isReservedAdminNamespace", () => {
44
- assert.equal(isReservedAdminNamespace("admin.x"), true);
45
- assert.equal(isReservedAdminNamespace("board.claim"), false);
46
- });
47
-
48
- test("canonicalize: key order does not change the bytes", () => {
49
- assert.equal(canonicalize({ b: 1, a: 2 }), canonicalize({ a: 2, b: 1 }));
50
- assert.equal(canonicalize({ a: { y: 1, x: 2 } }), '{"a":{"x":2,"y":1}}');
51
- });
52
-
53
- test("computeRowHash: deterministic + sensitive to every field", () => {
54
- const row = { seq: 1, family: "board", kind: "create", entity_id: "i1", actor: "a", at: "2026-06-11T00:00:00Z", payload: { title: "x" } };
55
- const h1 = computeRowHash("", row);
56
- const h2 = computeRowHash("", { ...row });
57
- assert.equal(h1, h2, "same input → same hash");
58
- assert.notEqual(h1, computeRowHash("prev", row), "prev hash matters");
59
- assert.notEqual(h1, computeRowHash("", { ...row, payload: { title: "y" } }), "payload matters");
60
- assert.notEqual(h1, computeRowHash("", { ...row, seq: 2 }), "seq matters");
61
- assert.match(h1, /^[0-9a-f]{64}$/, "lowercase hex sha-256");
62
- });
63
-
64
- test("verifyChain: accepts a valid chain, pinpoints tampering", () => {
65
- const mk = (seq, prev, payload) => {
66
- const base = { seq, family: "board", kind: "create", entity_id: `i${seq}`, actor: "a", at: `2026-06-11T00:00:0${seq}Z`, payload };
67
- return { ...base, prev_hash: prev, row_hash: computeRowHash(prev, base) };
68
- };
69
- const e1 = mk(1, "", { n: 1 });
70
- const e2 = mk(2, e1.row_hash, { n: 2 });
71
- const e3 = mk(3, e2.row_hash, { n: 3 });
72
- assert.equal(verifyChain([e1, e2, e3]), null, "clean chain verifies");
73
-
74
- // Tamper with e2's payload but keep its stored row_hash → detected at index 1.
75
- const tampered = { ...e2, payload: { n: 999 } };
76
- const break1 = verifyChain([e1, tampered, e3]);
77
- assert.ok(break1 && break1.index === 1, "tamper detected at the rewritten row");
78
-
79
- // Splice/delete e2 → e3.prev_hash no longer matches → detected at index 1.
80
- const break2 = verifyChain([e1, e3]);
81
- assert.ok(break2 && break2.index === 1, "deletion detected");
82
- });
83
-
84
- test("validateReqFrame: registry-checked", () => {
85
- assert.equal(validateReqFrame(buildReqFrame("board.claim", { id: "x" })).ok, true);
86
- assert.equal(validateReqFrame({ method: "nope.method" }).ok, false);
87
- assert.equal(validateReqFrame({}).ok, false);
88
- assert.equal(validateReqFrame({ method: "board.claim", params: 7 }).ok, false);
89
- });
90
-
91
- test("ok/err frames + version", () => {
92
- assert.deepEqual(okFrame({ a: 1 }), { ok: true, result: { a: 1 } });
93
- const e = errFrame("FORBIDDEN_SCOPE", "no");
94
- assert.equal(e.ok, false);
95
- assert.equal(e.error.code, "FORBIDDEN_SCOPE");
96
- assert.equal(errFrame("MADE_UP", "x").error.code, "INTERNAL", "unknown code coerces to INTERNAL");
97
- assert.equal(PROTOCOL_VERSION, 1);
98
- assert.ok(BOARD_STATUS.includes("ready") && BOARD_STATUS.includes("done"));
99
- });
100
-
101
- test("protocol phase 2: governance gating + new families/scopes", async () => {
102
- const p = await import("./protocol.mjs");
103
- // handoffs + assignment/decomposition are governance-gated; ordinary board ops are not.
104
- for (const m of ["handoff.offer", "handoff.accept", "handoff.decline", "handoff.cancel", "board.assign", "board.decompose"]) {
105
- assert.equal(p.isGovernanceGated(m), true, `${m} is governance-gated`);
106
- }
107
- for (const m of ["board.create", "board.claim", "lease.claim", "registry.heartbeat"]) {
108
- assert.equal(p.isGovernanceGated(m), false, `${m} is NOT governance-gated`);
109
- }
110
- // new scopes resolve; lease/handoff are in the default agent set, governance is admin-only.
111
- assert.equal(p.scopeForMethod("lease.claim"), "lease.write");
112
- assert.equal(p.scopeForMethod("handoff.offer"), "handoff.send");
113
- assert.equal(p.scopeForMethod("governance.set_decision_rights"), "admin");
114
- assert.ok(p.DEFAULT_AGENT_SCOPES.includes("lease.write") && p.DEFAULT_AGENT_SCOPES.includes("handoff.send"));
115
- assert.equal(p.actorCan(p.DEFAULT_AGENT_SCOPES, "governance.set_decision_rights"), false, "agents cannot set decision rights");
116
- assert.ok(p.FAMILIES.includes("lease") && p.FAMILIES.includes("handoff") && p.FAMILIES.includes("governance"));
117
- });
118
-
119
- test("protocol: frozen family + method counts (additive evolution guard)", () => {
120
- // These counts move ONLY when the protocol intentionally grows; pinning them
121
- // catches an accidental method drop/addition that the checksum alone wouldn't
122
- // explain. Bump deliberately alongside the descriptors.
123
- // 47 = the 19 mesh-protocol families + 20 agent UI-parity families (charter,
124
- // member, team, channel, persona, profile, sop, escalation, annotation,
125
- // contact, file, memory, compact, notification, invitation, user, settings,
126
- // billing, org, integration) + 1 Brand Studio v2 family (branding) + 1
127
- // workspace-email family (email; 2026-07-21 agent-email-server spec §8.1)
128
- // + 1 generative-UI artifact family (artifact; GU program 2026-07)
129
- // + 5 agent-desk families (2026-07): books (Books desk), calendar
130
- // (workspace calendar), crm (CRM desk), files (workspace drive — distinct
131
- // from the UI-parity "file" pins/comments family), and directory (external
132
- // people + organisations; the Design half of that program rides the existing
133
- // `branding` family — the section is renamed, the wire name is not).
134
- // The 2026-08 protocol-convergence pass adds 4: subagent (the org-scoped
135
- // sub-agent registry), agent (the agent.wait control lane), mandate (the
136
- // MANDATE spine) and preference (member-scoped preferences) → 51.
137
- // The 2026-08 Genesis agent-surface pass adds 2: genesis (the founder's
138
- // pre-commit workspace draft — the ten-stage run and its editable sections)
139
- // and architecture (the four tier review decisions and the one whole-
140
- // architecture approval, which outlive the run as the Org › Architecture
141
- // view) → 53.
142
- // The 2026-08 venture-deliverable pass adds 1: resource (the OrgResource
143
- // catalogue — a venture's own deliverables). The table predates every agent
144
- // plane and was reachable from none of them, so a venture's colleagues could
145
- // not list, add, correct, reorder or remove one of their own artifacts → 54.
146
- assert.equal(FAMILIES.length, 54, "family count");
147
- // 357 = the mesh-protocol + agent UI-parity + calling + branding + email
148
- // methods, plus the Live Integrations surface: integration.toolsetVersion +
149
- // integration.listAgentTools (SP1) and integration.invokeTool (SP5, execute a
150
- // granted plugin tool as the seat), plus the six artifact methods
151
- // (create/act/patch/get/list/catalog — GU program 2026-07), plus the 141
152
- // agent-desk methods (2026-07, the integration manifest's definitive table):
153
- // books 43, calendar 8, crm 43 (38 + the guest-call trio addCallGuest/
154
- // mintGuestToken/linkEmail back-ported from Cohort 2026-07-25 + the
155
- // articulation program's proposeTerms/revokeDealShare), the email Inbox-app
156
- // surface 31, files 20, and meetings.recapFile. Then the 2026-07 Directory &
157
- // Design program adds 44: directory 34 (11 reads + 23 writes, of which the
158
- // merge/awareness/archive verbs are human-gated in the hq domain) and 10 new
159
- // branding methods (getFoundation, getVoice, listTemplates, renderTemplate,
160
- // rewriteInVoice, exportKit, generateImage, proposeChange, saveFoundation,
161
- // restoreFoundation) taking branding 14 → 24. The 2026-08 mobile-program
162
- // parity pass adds 16: email 5 (reportSpam/react/moveMailbox/summarise/ask),
163
- // files 9 (sheetTabOp/docTabOp/docSuggestResolve/docSuggestions/commentAdd/
164
- // commentResolve/comments/sheetFedRange/ask), calendar.ask and crm.ask.
165
- // The 2026-08 host-moderation pass adds 2: calling.removeParticipant +
166
- // calling.setLock (host-gated remove-from-room + room lock) → 424.
167
- // The 2026-08 call working-sessions pass adds 6: calling.appShareStart/
168
- // appShareAct/appShareEnd (agent app-share lifecycle) + getAppShare/
169
- // getVisualContext/getCallEvents (participation-gated reads) → 430.
170
- // Bumped deliberately alongside
171
- // The 2026-08 agent-parity pass adds 1: messaging.typing (the write-less
172
- // "is composing…" indicator an SDK-driven agent raises while it works —
173
- // sideEffecting:false, no chain event, expires client-side) → 431.
174
- // Bumped deliberately alongside
175
- // The 2026-08 protocol-convergence pass closes the 29-method gap against hq's
176
- // vendored table (the client rejected every one of them BEFORE the network,
177
- // so mandate.* et al were unreachable from a daemon): messaging.search,
178
- // escalation.ask/answer, memory.recall, preference.upsert/list (6 reverse-
179
- // parity methods), the 9 subagent.* registry methods, agent.wait, the 11
180
- // mandate.* spine methods, and board.requestReview/resolveReview → 460.
181
- // The 2026-08 work-visibility pass adds 1: board.track — ONE step of an
182
- // agent's work made visible (find-or-open the row for an ask, move its
183
- // column, comment progress, attach output, tag the requester). It is the
184
- // single door BOTH planes use: hq's in-process responder calls the same
185
- // `server/work/ledger.ts` directly, the daemon reaches it over this wire, so
186
- // the threshold and the idempotency cannot fork → 461.
187
- // the descriptors; the checksum (read at runtime) is the primary drift guard.
188
- // The 2026-08 Genesis agent-surface pass adds 13, the 1:1 programmatic
189
- // parity for the founder's own Generate surface: genesis 10 (outline/entity/
190
- // grid/plan reads + set/insert/remove/reorder/revert/applyPlan writes) and
191
- // architecture 3 (status read + accept/approve review gates). The handlers
192
- // had shipped WITHOUT descriptors, which made all 13 unreachable — dispatch
193
- // rejects unknown methods and scopeForMethod resolves them to `admin`, which
194
- // no principal holds → 474.
195
- // The 2026-08 voice-capability pass adds 1: messaging.synthesizeVoiceNote —
196
- // hq could always synthesise a colleague's voice note but only as a REFLEX
197
- // (answering a human's spoken note in kind), so an agent asked in text for a
198
- // voice note truthfully answered that it could not. This is the verb that
199
- // makes it askable on every plane; the POST stays plain messaging.send → 475.
200
- // The 2026-08 venture-deliverable pass adds 8: resource.list/get (reads) and
201
- // resource.create/update/delete/reorder/attachFile/detachFile (writes). Both
202
- // reads ride `org.read` and every write `org.write`, so the family is
203
- // reachable by the VIEWER and EDITOR tiers that already exist rather than by
204
- // a scope nobody has been minted. attachFile/detachFile are the ONLY bridge
205
- // to `files.*`: a card carries a fileId POINTER and the drive keeps its own
206
- // seat-scoped read surface → 483. Then +1: messaging.electResponder (the
207
- // fleet's server-side respond-election) → 484.
208
- // The 2026-08 architecture live-board pass adds 3, closing the half of the
209
- // `architecture` family that was never on the wire: the three methods above
210
- // review a Genesis DRAFT, while hq's /org/architecture is a CRUD surface over
211
- // the COMMITTED company and no agent could see it, let alone ask it to change.
212
- // architecture.board (the read that hands back LIVE ROW IDS beside the
213
- // positional `P1`/`S3` labels the board renders — an agent has no browser to
214
- // hold the derived-id -> row-id map, so without it every id it could propose
215
- // on would be a guess), architecture.propose (the agent's end of hq's
216
- // "agents propose, a human with the floor approves" rule) and
217
- // architecture.proposals (the queue that says what became of the ask). NOT
218
- // approve/reject: those are session acts in hq by design → 487.
219
- assert.equal(Object.keys(METHODS).length, 487, "method count");
220
- });
221
-
222
- test("protocol SP3: messaging + calling families/methods/scopes", async () => {
223
- const p = await import("./protocol.mjs");
224
- // new families exist.
225
- assert.ok(p.FAMILIES.includes("messaging") && p.FAMILIES.includes("calling"));
226
- // messaging methods + their declared scopes / side-effect posture.
227
- const messagingMethods = {
228
- "messaging.send": { scope: "messaging.write", sideEffecting: true, idempotent: true },
229
- "messaging.react": { scope: "messaging.write", sideEffecting: true },
230
- "messaging.edit": { scope: "messaging.write", sideEffecting: true },
231
- "messaging.history": { scope: "messaging.read", sideEffecting: false },
232
- "messaging.channels": { scope: "messaging.read", sideEffecting: false },
233
- };
234
- for (const [m, want] of Object.entries(messagingMethods)) {
235
- const def = p.METHODS[m];
236
- assert.ok(def, `${m} is registered`);
237
- assert.equal(def.family, "messaging", `${m} family`);
238
- assert.equal(def.scope, want.scope, `${m} scope`);
239
- assert.equal(p.scopeForMethod(m), want.scope, `${m} scopeForMethod`);
240
- assert.equal(def.sideEffecting, want.sideEffecting, `${m} sideEffecting`);
241
- if (want.idempotent) assert.equal(def.idempotent, true, `${m} idempotent`);
242
- }
243
- // send is idempotent via the client-supplied message id.
244
- assert.equal(p.METHODS["messaging.send"].idempotent, true);
245
- // calling methods: all calling.write + side-effecting. removeParticipant +
246
- // setLock are the 2026-08 host-moderation verbs (host-gated in the hq domain).
247
- for (const m of ["calling.start", "calling.join", "calling.end", "calling.invite", "calling.removeParticipant", "calling.setLock"]) {
248
- const def = p.METHODS[m];
249
- assert.ok(def, `${m} is registered`);
250
- assert.equal(def.family, "calling", `${m} family`);
251
- assert.equal(def.scope, "calling.write", `${m} scope`);
252
- assert.equal(p.scopeForMethod(m), "calling.write", `${m} scopeForMethod`);
253
- assert.equal(def.sideEffecting, true, `${m} sideEffecting`);
254
- }
255
- // messaging/calling are NOT reserved-admin namespaces (scope is NOT forced to admin).
256
- assert.equal(p.isReservedAdminNamespace("messaging.send"), false);
257
- assert.equal(p.isReservedAdminNamespace("calling.start"), false);
258
- // new scopes are first-class capabilities.
259
- for (const s of ["messaging.read", "messaging.write", "calling.write"]) {
260
- assert.ok(p.SCOPES.includes(s), `SCOPES includes ${s}`);
261
- }
262
- // agents participate in the human app: the new scopes are in the default set.
263
- for (const s of ["messaging.read", "messaging.write", "calling.write"]) {
264
- assert.ok(p.DEFAULT_AGENT_SCOPES.includes(s), `DEFAULT_AGENT_SCOPES includes ${s}`);
265
- }
266
- // a default-scoped agent can actually exercise the new surfaces.
267
- assert.equal(p.actorCan(p.DEFAULT_AGENT_SCOPES, "messaging.send"), true);
268
- assert.equal(p.actorCan(p.DEFAULT_AGENT_SCOPES, "messaging.history"), true);
269
- assert.equal(p.actorCan(p.DEFAULT_AGENT_SCOPES, "calling.start"), true);
270
- // default-deny still holds: a read-only token cannot send.
271
- assert.equal(p.actorCan(["messaging.read"], "messaging.send"), false);
272
- });
273
-
274
- test("protocol agent desks: per-family scope pairs, counts, and default grants", async () => {
275
- const p = await import("./protocol.mjs");
276
- // Each desk family rides its OWN read/write scope pair (the integration
277
- // manifest's declared contract) so a key can be minted for exactly one desk.
278
- // 2026-08 mobile-parity delta: crm +ask (44), calendar +ask (9), files +9
279
- // (tab/suggestion/comment/fed-range ops + ask → 29).
280
- const desks = { books: 43, crm: 44, files: 29, calendar: 9 };
281
- for (const [fam, want] of Object.entries(desks)) {
282
- const rows = Object.entries(p.METHODS).filter(([, d]) => d.family === fam);
283
- assert.equal(rows.length, want, `${fam} method count`);
284
- for (const [name, d] of rows) {
285
- assert.ok(
286
- d.scope === `${fam}.read` || d.scope === `${fam}.write`,
287
- `${name} rides the ${fam}.read/${fam}.write pair (got ${d.scope})`,
288
- );
289
- if (d.scope === `${fam}.read` && name !== "files.exportRequest") {
290
- assert.equal(d.sideEffecting, false, `${name} read is sideEffecting:false`);
291
- }
292
- }
293
- assert.ok(p.SCOPES.includes(`${fam}.read`) && p.SCOPES.includes(`${fam}.write`), `${fam} scope pair declared`);
294
- assert.ok(
295
- p.DEFAULT_AGENT_SCOPES.includes(`${fam}.read`) && p.DEFAULT_AGENT_SCOPES.includes(`${fam}.write`),
296
- `${fam} scopes in the default agent set`,
297
- );
298
- }
299
- // The email Inbox-app surface rides the existing email pair: 41 methods
300
- // total (36 + the 2026-08 spam/react/moveMailbox/summarise/ask delta).
301
- assert.equal(Object.entries(p.METHODS).filter(([, d]) => d.family === "email").length, 41, "email method count");
302
- assert.equal(p.scopeForMethod("email.draftSend"), "email.write");
303
- assert.equal(p.scopeForMethod("email.mailboxes"), "email.read");
304
- // files.exportRequest is the AUDITED export: read scope, side-effecting.
305
- assert.deepEqual(
306
- { scope: p.METHODS["files.exportRequest"].scope, se: p.METHODS["files.exportRequest"].sideEffecting },
307
- { scope: "files.read", se: true },
308
- );
309
- // meetings.recapFile is knowledge capture (meetings family, knowledge.write).
310
- assert.equal(p.METHODS["meetings.recapFile"].scope, "knowledge.write");
311
- assert.equal(p.METHODS["meetings.recapFile"].family, "meetings");
312
- // Spot-check idempotency posture from the manifest: draftSend/ruleSave are
313
- // NOT idempotent (each send/save is a new act); holdReplies/markAllRead are.
314
- assert.ok(!p.METHODS["email.draftSend"].idempotent);
315
- assert.ok(!p.METHODS["email.ruleSave"].idempotent);
316
- assert.equal(p.METHODS["email.holdReplies"].idempotent, true);
317
- assert.equal(p.METHODS["email.markAllRead"].idempotent, true);
318
- // A default-scoped agent can work the desks; a single-desk token stays fenced.
319
- assert.equal(p.actorCan(p.DEFAULT_AGENT_SCOPES, "books.invoiceDraft"), true);
320
- assert.equal(p.actorCan(p.DEFAULT_AGENT_SCOPES, "crm.listDeals"), true);
321
- assert.equal(p.actorCan(["books.read"], "books.invoiceDraft"), false, "read tier cannot write");
322
- assert.equal(p.actorCan(["books.read", "books.write"], "crm.createDeal"), false, "books key cannot touch crm");
323
- });