@memnexus-ai/mx-agent-cli 0.1.296 → 0.1.298

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 (797) hide show
  1. package/dist/agent-config/hooks/gh-pr-edit-guard.sh +21 -9
  2. package/dist/agent-config/settings.json +7 -1
  3. package/dist/commands/check.d.ts +20 -0
  4. package/dist/commands/check.d.ts.map +1 -0
  5. package/dist/commands/check.js +30 -0
  6. package/dist/commands/check.js.map +1 -0
  7. package/dist/commands/create.d.ts +36 -0
  8. package/dist/commands/create.d.ts.map +1 -1
  9. package/dist/commands/create.js +85 -8
  10. package/dist/commands/create.js.map +1 -1
  11. package/dist/commands/gh.d.ts +38 -0
  12. package/dist/commands/gh.d.ts.map +1 -0
  13. package/dist/commands/gh.js +162 -0
  14. package/dist/commands/gh.js.map +1 -0
  15. package/dist/commands/git-credential.d.ts +22 -0
  16. package/dist/commands/git-credential.d.ts.map +1 -0
  17. package/dist/commands/git-credential.js +53 -0
  18. package/dist/commands/git-credential.js.map +1 -0
  19. package/dist/commands/new.d.ts +24 -0
  20. package/dist/commands/new.d.ts.map +1 -1
  21. package/dist/commands/new.js +56 -5
  22. package/dist/commands/new.js.map +1 -1
  23. package/dist/commands/pr-set-body.d.ts +120 -35
  24. package/dist/commands/pr-set-body.d.ts.map +1 -1
  25. package/dist/commands/pr-set-body.js +343 -108
  26. package/dist/commands/pr-set-body.js.map +1 -1
  27. package/dist/commands/pr-sync.d.ts +2 -1
  28. package/dist/commands/pr-sync.d.ts.map +1 -1
  29. package/dist/commands/pr-sync.js +129 -32
  30. package/dist/commands/pr-sync.js.map +1 -1
  31. package/dist/index.d.ts +3 -0
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.js +82 -2
  34. package/dist/index.js.map +1 -1
  35. package/dist/lib/check-run.d.ts +131 -0
  36. package/dist/lib/check-run.d.ts.map +1 -0
  37. package/dist/lib/check-run.js +291 -0
  38. package/dist/lib/check-run.js.map +1 -0
  39. package/dist/lib/coordination-token.d.ts +33 -1
  40. package/dist/lib/coordination-token.d.ts.map +1 -1
  41. package/dist/lib/coordination-token.js +138 -9
  42. package/dist/lib/coordination-token.js.map +1 -1
  43. package/dist/lib/gh-remote.d.ts +20 -0
  44. package/dist/lib/gh-remote.d.ts.map +1 -1
  45. package/dist/lib/gh-remote.js +26 -0
  46. package/dist/lib/gh-remote.js.map +1 -1
  47. package/dist/lib/gh-token-run.d.ts +551 -0
  48. package/dist/lib/gh-token-run.d.ts.map +1 -0
  49. package/dist/lib/gh-token-run.js +1246 -0
  50. package/dist/lib/gh-token-run.js.map +1 -0
  51. package/dist/lib/git-credential.d.ts +120 -0
  52. package/dist/lib/git-credential.d.ts.map +1 -0
  53. package/dist/lib/git-credential.js +204 -0
  54. package/dist/lib/git-credential.js.map +1 -0
  55. package/dist/lib/github-app-token.d.ts +288 -0
  56. package/dist/lib/github-app-token.d.ts.map +1 -0
  57. package/dist/lib/github-app-token.js +519 -0
  58. package/dist/lib/github-app-token.js.map +1 -0
  59. package/dist/lib/memory.d.ts.map +1 -1
  60. package/dist/lib/memory.js +35 -2
  61. package/dist/lib/memory.js.map +1 -1
  62. package/dist/lib/repo-guard-state-dirs.d.ts +39 -0
  63. package/dist/lib/repo-guard-state-dirs.d.ts.map +1 -0
  64. package/dist/lib/repo-guard-state-dirs.js +170 -0
  65. package/dist/lib/repo-guard-state-dirs.js.map +1 -0
  66. package/dist/standards/decision-request.md +6 -57
  67. package/dist/standards/po-communication-standard.md +0 -34
  68. package/dist/standards/report-format.md +0 -90
  69. package/dist/standards/writing-standard.md +0 -312
  70. package/package.json +3 -1
  71. package/dist/__tests__/agent-attribution.test.d.ts +0 -16
  72. package/dist/__tests__/agent-attribution.test.d.ts.map +0 -1
  73. package/dist/__tests__/agent-attribution.test.js +0 -250
  74. package/dist/__tests__/agent-attribution.test.js.map +0 -1
  75. package/dist/__tests__/agents-md-canonicalization.test.d.ts +0 -23
  76. package/dist/__tests__/agents-md-canonicalization.test.d.ts.map +0 -1
  77. package/dist/__tests__/agents-md-canonicalization.test.js +0 -319
  78. package/dist/__tests__/agents-md-canonicalization.test.js.map +0 -1
  79. package/dist/__tests__/behavioral-compliance.test.d.ts +0 -8
  80. package/dist/__tests__/behavioral-compliance.test.d.ts.map +0 -1
  81. package/dist/__tests__/behavioral-compliance.test.js +0 -226
  82. package/dist/__tests__/behavioral-compliance.test.js.map +0 -1
  83. package/dist/__tests__/behavioral-extraction.test.d.ts +0 -12
  84. package/dist/__tests__/behavioral-extraction.test.d.ts.map +0 -1
  85. package/dist/__tests__/behavioral-extraction.test.js +0 -330
  86. package/dist/__tests__/behavioral-extraction.test.js.map +0 -1
  87. package/dist/__tests__/behavioral-git-read.test.d.ts +0 -21
  88. package/dist/__tests__/behavioral-git-read.test.d.ts.map +0 -1
  89. package/dist/__tests__/behavioral-git-read.test.js +0 -955
  90. package/dist/__tests__/behavioral-git-read.test.js.map +0 -1
  91. package/dist/__tests__/behavioral-injection.test.d.ts +0 -13
  92. package/dist/__tests__/behavioral-injection.test.d.ts.map +0 -1
  93. package/dist/__tests__/behavioral-injection.test.js +0 -384
  94. package/dist/__tests__/behavioral-injection.test.js.map +0 -1
  95. package/dist/__tests__/binary-smoke.test.d.ts +0 -12
  96. package/dist/__tests__/binary-smoke.test.d.ts.map +0 -1
  97. package/dist/__tests__/binary-smoke.test.js +0 -88
  98. package/dist/__tests__/binary-smoke.test.js.map +0 -1
  99. package/dist/__tests__/bootstrap-behavioral-contract.test.d.ts +0 -18
  100. package/dist/__tests__/bootstrap-behavioral-contract.test.d.ts.map +0 -1
  101. package/dist/__tests__/bootstrap-behavioral-contract.test.js +0 -104
  102. package/dist/__tests__/bootstrap-behavioral-contract.test.js.map +0 -1
  103. package/dist/__tests__/bundle-config.test.d.ts +0 -18
  104. package/dist/__tests__/bundle-config.test.d.ts.map +0 -1
  105. package/dist/__tests__/bundle-config.test.js +0 -123
  106. package/dist/__tests__/bundle-config.test.js.map +0 -1
  107. package/dist/__tests__/catalog-interaction.test.d.ts +0 -25
  108. package/dist/__tests__/catalog-interaction.test.d.ts.map +0 -1
  109. package/dist/__tests__/catalog-interaction.test.js +0 -269
  110. package/dist/__tests__/catalog-interaction.test.js.map +0 -1
  111. package/dist/__tests__/catalog-named-memories.test.d.ts +0 -2
  112. package/dist/__tests__/catalog-named-memories.test.d.ts.map +0 -1
  113. package/dist/__tests__/catalog-named-memories.test.js +0 -204
  114. package/dist/__tests__/catalog-named-memories.test.js.map +0 -1
  115. package/dist/__tests__/catalog-origin-main.test.d.ts +0 -15
  116. package/dist/__tests__/catalog-origin-main.test.d.ts.map +0 -1
  117. package/dist/__tests__/catalog-origin-main.test.js +0 -305
  118. package/dist/__tests__/catalog-origin-main.test.js.map +0 -1
  119. package/dist/__tests__/catalog.test.d.ts +0 -2
  120. package/dist/__tests__/catalog.test.d.ts.map +0 -1
  121. package/dist/__tests__/catalog.test.js +0 -131
  122. package/dist/__tests__/catalog.test.js.map +0 -1
  123. package/dist/__tests__/claude-local-sanitizer.test.d.ts +0 -24
  124. package/dist/__tests__/claude-local-sanitizer.test.d.ts.map +0 -1
  125. package/dist/__tests__/claude-local-sanitizer.test.js +0 -906
  126. package/dist/__tests__/claude-local-sanitizer.test.js.map +0 -1
  127. package/dist/__tests__/claude-md-compose.test.d.ts +0 -17
  128. package/dist/__tests__/claude-md-compose.test.d.ts.map +0 -1
  129. package/dist/__tests__/claude-md-compose.test.js +0 -119
  130. package/dist/__tests__/claude-md-compose.test.js.map +0 -1
  131. package/dist/__tests__/claude-sync.test.d.ts +0 -2
  132. package/dist/__tests__/claude-sync.test.d.ts.map +0 -1
  133. package/dist/__tests__/claude-sync.test.js +0 -571
  134. package/dist/__tests__/claude-sync.test.js.map +0 -1
  135. package/dist/__tests__/cli-build-integration.test.d.ts +0 -2
  136. package/dist/__tests__/cli-build-integration.test.d.ts.map +0 -1
  137. package/dist/__tests__/cli-build-integration.test.js +0 -64
  138. package/dist/__tests__/cli-build-integration.test.js.map +0 -1
  139. package/dist/__tests__/cli-build.test.d.ts +0 -2
  140. package/dist/__tests__/cli-build.test.d.ts.map +0 -1
  141. package/dist/__tests__/cli-build.test.js +0 -640
  142. package/dist/__tests__/cli-build.test.js.map +0 -1
  143. package/dist/__tests__/codex-agent-gate.test.d.ts +0 -2
  144. package/dist/__tests__/codex-agent-gate.test.d.ts.map +0 -1
  145. package/dist/__tests__/codex-agent-gate.test.js +0 -480
  146. package/dist/__tests__/codex-agent-gate.test.js.map +0 -1
  147. package/dist/__tests__/codex-deploy-config.test.d.ts +0 -2
  148. package/dist/__tests__/codex-deploy-config.test.d.ts.map +0 -1
  149. package/dist/__tests__/codex-deploy-config.test.js +0 -1230
  150. package/dist/__tests__/codex-deploy-config.test.js.map +0 -1
  151. package/dist/__tests__/codex-trust-keys.test.d.ts +0 -2
  152. package/dist/__tests__/codex-trust-keys.test.d.ts.map +0 -1
  153. package/dist/__tests__/codex-trust-keys.test.js +0 -731
  154. package/dist/__tests__/codex-trust-keys.test.js.map +0 -1
  155. package/dist/__tests__/codex-write-race.test.d.ts +0 -2
  156. package/dist/__tests__/codex-write-race.test.d.ts.map +0 -1
  157. package/dist/__tests__/codex-write-race.test.js +0 -2253
  158. package/dist/__tests__/codex-write-race.test.js.map +0 -1
  159. package/dist/__tests__/completion-rows-discriminate.test.d.ts +0 -20
  160. package/dist/__tests__/completion-rows-discriminate.test.d.ts.map +0 -1
  161. package/dist/__tests__/completion-rows-discriminate.test.js +0 -481
  162. package/dist/__tests__/completion-rows-discriminate.test.js.map +0 -1
  163. package/dist/__tests__/config-command.test.d.ts +0 -9
  164. package/dist/__tests__/config-command.test.d.ts.map +0 -1
  165. package/dist/__tests__/config-command.test.js +0 -75
  166. package/dist/__tests__/config-command.test.js.map +0 -1
  167. package/dist/__tests__/config-fidelity-archived-symlinks.test.d.ts +0 -2
  168. package/dist/__tests__/config-fidelity-archived-symlinks.test.d.ts.map +0 -1
  169. package/dist/__tests__/config-fidelity-archived-symlinks.test.js +0 -127
  170. package/dist/__tests__/config-fidelity-archived-symlinks.test.js.map +0 -1
  171. package/dist/__tests__/config-fidelity-display.test.d.ts +0 -2
  172. package/dist/__tests__/config-fidelity-display.test.d.ts.map +0 -1
  173. package/dist/__tests__/config-fidelity-display.test.js +0 -77
  174. package/dist/__tests__/config-fidelity-display.test.js.map +0 -1
  175. package/dist/__tests__/config-fidelity-unreadable-fixture.d.ts +0 -32
  176. package/dist/__tests__/config-fidelity-unreadable-fixture.d.ts.map +0 -1
  177. package/dist/__tests__/config-fidelity-unreadable-fixture.js +0 -37
  178. package/dist/__tests__/config-fidelity-unreadable-fixture.js.map +0 -1
  179. package/dist/__tests__/config-fidelity.test.d.ts +0 -16
  180. package/dist/__tests__/config-fidelity.test.d.ts.map +0 -1
  181. package/dist/__tests__/config-fidelity.test.js +0 -2679
  182. package/dist/__tests__/config-fidelity.test.js.map +0 -1
  183. package/dist/__tests__/config-generation-gate.test.d.ts +0 -46
  184. package/dist/__tests__/config-generation-gate.test.d.ts.map +0 -1
  185. package/dist/__tests__/config-generation-gate.test.js +0 -435
  186. package/dist/__tests__/config-generation-gate.test.js.map +0 -1
  187. package/dist/__tests__/config-generation.test.d.ts +0 -7
  188. package/dist/__tests__/config-generation.test.d.ts.map +0 -1
  189. package/dist/__tests__/config-generation.test.js +0 -141
  190. package/dist/__tests__/config-generation.test.js.map +0 -1
  191. package/dist/__tests__/config-sync.test.d.ts +0 -10
  192. package/dist/__tests__/config-sync.test.d.ts.map +0 -1
  193. package/dist/__tests__/config-sync.test.js +0 -268
  194. package/dist/__tests__/config-sync.test.js.map +0 -1
  195. package/dist/__tests__/coordination-401-production-wiring.test.d.ts +0 -19
  196. package/dist/__tests__/coordination-401-production-wiring.test.d.ts.map +0 -1
  197. package/dist/__tests__/coordination-401-production-wiring.test.js +0 -286
  198. package/dist/__tests__/coordination-401-production-wiring.test.js.map +0 -1
  199. package/dist/__tests__/coordination-401-recovery.test.d.ts +0 -22
  200. package/dist/__tests__/coordination-401-recovery.test.d.ts.map +0 -1
  201. package/dist/__tests__/coordination-401-recovery.test.js +0 -601
  202. package/dist/__tests__/coordination-401-recovery.test.js.map +0 -1
  203. package/dist/__tests__/coordination-brief-pin.test.d.ts +0 -20
  204. package/dist/__tests__/coordination-brief-pin.test.d.ts.map +0 -1
  205. package/dist/__tests__/coordination-brief-pin.test.js +0 -66
  206. package/dist/__tests__/coordination-brief-pin.test.js.map +0 -1
  207. package/dist/__tests__/coordination-brief.test.d.ts +0 -9
  208. package/dist/__tests__/coordination-brief.test.d.ts.map +0 -1
  209. package/dist/__tests__/coordination-brief.test.js +0 -290
  210. package/dist/__tests__/coordination-brief.test.js.map +0 -1
  211. package/dist/__tests__/coordination-client.test.d.ts +0 -9
  212. package/dist/__tests__/coordination-client.test.d.ts.map +0 -1
  213. package/dist/__tests__/coordination-client.test.js +0 -517
  214. package/dist/__tests__/coordination-client.test.js.map +0 -1
  215. package/dist/__tests__/coordination-command.test.d.ts +0 -9
  216. package/dist/__tests__/coordination-command.test.d.ts.map +0 -1
  217. package/dist/__tests__/coordination-command.test.js +0 -1082
  218. package/dist/__tests__/coordination-command.test.js.map +0 -1
  219. package/dist/__tests__/coordination-credential-endpoint.test.d.ts +0 -24
  220. package/dist/__tests__/coordination-credential-endpoint.test.d.ts.map +0 -1
  221. package/dist/__tests__/coordination-credential-endpoint.test.js +0 -1292
  222. package/dist/__tests__/coordination-credential-endpoint.test.js.map +0 -1
  223. package/dist/__tests__/coordination-expected-team.test.d.ts +0 -19
  224. package/dist/__tests__/coordination-expected-team.test.d.ts.map +0 -1
  225. package/dist/__tests__/coordination-expected-team.test.js +0 -423
  226. package/dist/__tests__/coordination-expected-team.test.js.map +0 -1
  227. package/dist/__tests__/coordination-fallback.test.d.ts +0 -9
  228. package/dist/__tests__/coordination-fallback.test.d.ts.map +0 -1
  229. package/dist/__tests__/coordination-fallback.test.js +0 -192
  230. package/dist/__tests__/coordination-fallback.test.js.map +0 -1
  231. package/dist/__tests__/coordination-file-guards.test.d.ts +0 -29
  232. package/dist/__tests__/coordination-file-guards.test.d.ts.map +0 -1
  233. package/dist/__tests__/coordination-file-guards.test.js +0 -380
  234. package/dist/__tests__/coordination-file-guards.test.js.map +0 -1
  235. package/dist/__tests__/coordination-history.test.d.ts +0 -8
  236. package/dist/__tests__/coordination-history.test.d.ts.map +0 -1
  237. package/dist/__tests__/coordination-history.test.js +0 -447
  238. package/dist/__tests__/coordination-history.test.js.map +0 -1
  239. package/dist/__tests__/coordination-memory.test.d.ts +0 -14
  240. package/dist/__tests__/coordination-memory.test.d.ts.map +0 -1
  241. package/dist/__tests__/coordination-memory.test.js +0 -401
  242. package/dist/__tests__/coordination-memory.test.js.map +0 -1
  243. package/dist/__tests__/coordination-mode.test.d.ts +0 -13
  244. package/dist/__tests__/coordination-mode.test.d.ts.map +0 -1
  245. package/dist/__tests__/coordination-mode.test.js +0 -180
  246. package/dist/__tests__/coordination-mode.test.js.map +0 -1
  247. package/dist/__tests__/coordination-plain-shell-commands.test.d.ts +0 -22
  248. package/dist/__tests__/coordination-plain-shell-commands.test.d.ts.map +0 -1
  249. package/dist/__tests__/coordination-plain-shell-commands.test.js +0 -1875
  250. package/dist/__tests__/coordination-plain-shell-commands.test.js.map +0 -1
  251. package/dist/__tests__/coordination-provision.test.d.ts +0 -12
  252. package/dist/__tests__/coordination-provision.test.d.ts.map +0 -1
  253. package/dist/__tests__/coordination-provision.test.js +0 -103
  254. package/dist/__tests__/coordination-provision.test.js.map +0 -1
  255. package/dist/__tests__/coordination-render.test.d.ts +0 -9
  256. package/dist/__tests__/coordination-render.test.d.ts.map +0 -1
  257. package/dist/__tests__/coordination-render.test.js +0 -335
  258. package/dist/__tests__/coordination-render.test.js.map +0 -1
  259. package/dist/__tests__/coordination-setup.test.d.ts +0 -6
  260. package/dist/__tests__/coordination-setup.test.d.ts.map +0 -1
  261. package/dist/__tests__/coordination-setup.test.js +0 -448
  262. package/dist/__tests__/coordination-setup.test.js.map +0 -1
  263. package/dist/__tests__/coordination-status-plain-shell.test.d.ts +0 -19
  264. package/dist/__tests__/coordination-status-plain-shell.test.d.ts.map +0 -1
  265. package/dist/__tests__/coordination-status-plain-shell.test.js +0 -332
  266. package/dist/__tests__/coordination-status-plain-shell.test.js.map +0 -1
  267. package/dist/__tests__/coordination-status-registration.test.d.ts +0 -16
  268. package/dist/__tests__/coordination-status-registration.test.d.ts.map +0 -1
  269. package/dist/__tests__/coordination-status-registration.test.js +0 -480
  270. package/dist/__tests__/coordination-status-registration.test.js.map +0 -1
  271. package/dist/__tests__/coordination-token-multitenant.test.d.ts +0 -11
  272. package/dist/__tests__/coordination-token-multitenant.test.d.ts.map +0 -1
  273. package/dist/__tests__/coordination-token-multitenant.test.js +0 -106
  274. package/dist/__tests__/coordination-token-multitenant.test.js.map +0 -1
  275. package/dist/__tests__/coordination-token.test.d.ts +0 -11
  276. package/dist/__tests__/coordination-token.test.d.ts.map +0 -1
  277. package/dist/__tests__/coordination-token.test.js +0 -201
  278. package/dist/__tests__/coordination-token.test.js.map +0 -1
  279. package/dist/__tests__/coordination-wiring.test.d.ts +0 -11
  280. package/dist/__tests__/coordination-wiring.test.d.ts.map +0 -1
  281. package/dist/__tests__/coordination-wiring.test.js +0 -43
  282. package/dist/__tests__/coordination-wiring.test.js.map +0 -1
  283. package/dist/__tests__/creation-pr-class-check.test.d.ts +0 -17
  284. package/dist/__tests__/creation-pr-class-check.test.d.ts.map +0 -1
  285. package/dist/__tests__/creation-pr-class-check.test.js +0 -346
  286. package/dist/__tests__/creation-pr-class-check.test.js.map +0 -1
  287. package/dist/__tests__/creation-step6a-push-check.test.d.ts +0 -15
  288. package/dist/__tests__/creation-step6a-push-check.test.d.ts.map +0 -1
  289. package/dist/__tests__/creation-step6a-push-check.test.js +0 -150
  290. package/dist/__tests__/creation-step6a-push-check.test.js.map +0 -1
  291. package/dist/__tests__/decision-check.test.d.ts +0 -2
  292. package/dist/__tests__/decision-check.test.d.ts.map +0 -1
  293. package/dist/__tests__/decision-check.test.js +0 -105
  294. package/dist/__tests__/decision-check.test.js.map +0 -1
  295. package/dist/__tests__/digest-fail-closed.test.d.ts +0 -16
  296. package/dist/__tests__/digest-fail-closed.test.d.ts.map +0 -1
  297. package/dist/__tests__/digest-fail-closed.test.js +0 -248
  298. package/dist/__tests__/digest-fail-closed.test.js.map +0 -1
  299. package/dist/__tests__/digest-team-omission.test.d.ts +0 -15
  300. package/dist/__tests__/digest-team-omission.test.d.ts.map +0 -1
  301. package/dist/__tests__/digest-team-omission.test.js +0 -247
  302. package/dist/__tests__/digest-team-omission.test.js.map +0 -1
  303. package/dist/__tests__/doctor-config-fidelity.test.d.ts +0 -19
  304. package/dist/__tests__/doctor-config-fidelity.test.d.ts.map +0 -1
  305. package/dist/__tests__/doctor-config-fidelity.test.js +0 -324
  306. package/dist/__tests__/doctor-config-fidelity.test.js.map +0 -1
  307. package/dist/__tests__/doctor-framework-version.test.d.ts +0 -2
  308. package/dist/__tests__/doctor-framework-version.test.d.ts.map +0 -1
  309. package/dist/__tests__/doctor-framework-version.test.js +0 -146
  310. package/dist/__tests__/doctor-framework-version.test.js.map +0 -1
  311. package/dist/__tests__/doctor-worktree-path.test.d.ts +0 -17
  312. package/dist/__tests__/doctor-worktree-path.test.d.ts.map +0 -1
  313. package/dist/__tests__/doctor-worktree-path.test.js +0 -158
  314. package/dist/__tests__/doctor-worktree-path.test.js.map +0 -1
  315. package/dist/__tests__/doctor.test.d.ts +0 -20
  316. package/dist/__tests__/doctor.test.d.ts.map +0 -1
  317. package/dist/__tests__/doctor.test.js +0 -849
  318. package/dist/__tests__/doctor.test.js.map +0 -1
  319. package/dist/__tests__/event-shipper.test.d.ts +0 -16
  320. package/dist/__tests__/event-shipper.test.d.ts.map +0 -1
  321. package/dist/__tests__/event-shipper.test.js +0 -287
  322. package/dist/__tests__/event-shipper.test.js.map +0 -1
  323. package/dist/__tests__/fleet-data.test.d.ts +0 -2
  324. package/dist/__tests__/fleet-data.test.d.ts.map +0 -1
  325. package/dist/__tests__/fleet-data.test.js +0 -501
  326. package/dist/__tests__/fleet-data.test.js.map +0 -1
  327. package/dist/__tests__/fleet-devpod.test.d.ts +0 -12
  328. package/dist/__tests__/fleet-devpod.test.d.ts.map +0 -1
  329. package/dist/__tests__/fleet-devpod.test.js +0 -260
  330. package/dist/__tests__/fleet-devpod.test.js.map +0 -1
  331. package/dist/__tests__/fleet-tmux.test.d.ts +0 -2
  332. package/dist/__tests__/fleet-tmux.test.d.ts.map +0 -1
  333. package/dist/__tests__/fleet-tmux.test.js +0 -289
  334. package/dist/__tests__/fleet-tmux.test.js.map +0 -1
  335. package/dist/__tests__/fleet.test.d.ts +0 -16
  336. package/dist/__tests__/fleet.test.d.ts.map +0 -1
  337. package/dist/__tests__/fleet.test.js +0 -75
  338. package/dist/__tests__/fleet.test.js.map +0 -1
  339. package/dist/__tests__/generate-claude.test.d.ts +0 -18
  340. package/dist/__tests__/generate-claude.test.d.ts.map +0 -1
  341. package/dist/__tests__/generate-claude.test.js +0 -1015
  342. package/dist/__tests__/generate-claude.test.js.map +0 -1
  343. package/dist/__tests__/gh-remote.test.d.ts +0 -2
  344. package/dist/__tests__/gh-remote.test.d.ts.map +0 -1
  345. package/dist/__tests__/gh-remote.test.js +0 -136
  346. package/dist/__tests__/gh-remote.test.js.map +0 -1
  347. package/dist/__tests__/git-env.test.d.ts +0 -14
  348. package/dist/__tests__/git-env.test.d.ts.map +0 -1
  349. package/dist/__tests__/git-env.test.js +0 -131
  350. package/dist/__tests__/git-env.test.js.map +0 -1
  351. package/dist/__tests__/git-identity-isolation.test.d.ts +0 -33
  352. package/dist/__tests__/git-identity-isolation.test.d.ts.map +0 -1
  353. package/dist/__tests__/git-identity-isolation.test.js +0 -626
  354. package/dist/__tests__/git-identity-isolation.test.js.map +0 -1
  355. package/dist/__tests__/harness-extract.test.d.ts +0 -19
  356. package/dist/__tests__/harness-extract.test.d.ts.map +0 -1
  357. package/dist/__tests__/harness-extract.test.js +0 -566
  358. package/dist/__tests__/harness-extract.test.js.map +0 -1
  359. package/dist/__tests__/harness-wiring.test.d.ts +0 -16
  360. package/dist/__tests__/harness-wiring.test.d.ts.map +0 -1
  361. package/dist/__tests__/harness-wiring.test.js +0 -469
  362. package/dist/__tests__/harness-wiring.test.js.map +0 -1
  363. package/dist/__tests__/hook-completeness.test.d.ts +0 -13
  364. package/dist/__tests__/hook-completeness.test.d.ts.map +0 -1
  365. package/dist/__tests__/hook-completeness.test.js +0 -238
  366. package/dist/__tests__/hook-completeness.test.js.map +0 -1
  367. package/dist/__tests__/hook-heal.test.d.ts +0 -8
  368. package/dist/__tests__/hook-heal.test.d.ts.map +0 -1
  369. package/dist/__tests__/hook-heal.test.js +0 -156
  370. package/dist/__tests__/hook-heal.test.js.map +0 -1
  371. package/dist/__tests__/human-turn-classifier.test.d.ts +0 -17
  372. package/dist/__tests__/human-turn-classifier.test.d.ts.map +0 -1
  373. package/dist/__tests__/human-turn-classifier.test.js +0 -311
  374. package/dist/__tests__/human-turn-classifier.test.js.map +0 -1
  375. package/dist/__tests__/init-coordination-url.test.d.ts +0 -11
  376. package/dist/__tests__/init-coordination-url.test.d.ts.map +0 -1
  377. package/dist/__tests__/init-coordination-url.test.js +0 -217
  378. package/dist/__tests__/init-coordination-url.test.js.map +0 -1
  379. package/dist/__tests__/isolation-probe.test.d.ts +0 -15
  380. package/dist/__tests__/isolation-probe.test.d.ts.map +0 -1
  381. package/dist/__tests__/isolation-probe.test.js +0 -611
  382. package/dist/__tests__/isolation-probe.test.js.map +0 -1
  383. package/dist/__tests__/leader-lock.test.d.ts +0 -12
  384. package/dist/__tests__/leader-lock.test.d.ts.map +0 -1
  385. package/dist/__tests__/leader-lock.test.js +0 -293
  386. package/dist/__tests__/leader-lock.test.js.map +0 -1
  387. package/dist/__tests__/memory-archive-checks.test.d.ts +0 -22
  388. package/dist/__tests__/memory-archive-checks.test.d.ts.map +0 -1
  389. package/dist/__tests__/memory-archive-checks.test.js +0 -748
  390. package/dist/__tests__/memory-archive-checks.test.js.map +0 -1
  391. package/dist/__tests__/memory-archive-prep.test.d.ts +0 -8
  392. package/dist/__tests__/memory-archive-prep.test.d.ts.map +0 -1
  393. package/dist/__tests__/memory-archive-prep.test.js +0 -524
  394. package/dist/__tests__/memory-archive-prep.test.js.map +0 -1
  395. package/dist/__tests__/memory-autocreate.test.d.ts +0 -10
  396. package/dist/__tests__/memory-autocreate.test.d.ts.map +0 -1
  397. package/dist/__tests__/memory-autocreate.test.js +0 -709
  398. package/dist/__tests__/memory-autocreate.test.js.map +0 -1
  399. package/dist/__tests__/memory-log-result.test.d.ts +0 -13
  400. package/dist/__tests__/memory-log-result.test.d.ts.map +0 -1
  401. package/dist/__tests__/memory-log-result.test.js +0 -149
  402. package/dist/__tests__/memory-log-result.test.js.map +0 -1
  403. package/dist/__tests__/memory-named-exists.test.d.ts +0 -16
  404. package/dist/__tests__/memory-named-exists.test.d.ts.map +0 -1
  405. package/dist/__tests__/memory-named-exists.test.js +0 -288
  406. package/dist/__tests__/memory-named-exists.test.js.map +0 -1
  407. package/dist/__tests__/message-bus.test.d.ts +0 -10
  408. package/dist/__tests__/message-bus.test.d.ts.map +0 -1
  409. package/dist/__tests__/message-bus.test.js +0 -526
  410. package/dist/__tests__/message-bus.test.js.map +0 -1
  411. package/dist/__tests__/monitor.test.d.ts +0 -6
  412. package/dist/__tests__/monitor.test.d.ts.map +0 -1
  413. package/dist/__tests__/monitor.test.js +0 -458
  414. package/dist/__tests__/monitor.test.js.map +0 -1
  415. package/dist/__tests__/mx-agent-cli-pin-validation.test.d.ts +0 -2
  416. package/dist/__tests__/mx-agent-cli-pin-validation.test.d.ts.map +0 -1
  417. package/dist/__tests__/mx-agent-cli-pin-validation.test.js +0 -232
  418. package/dist/__tests__/mx-agent-cli-pin-validation.test.js.map +0 -1
  419. package/dist/__tests__/mx-agent-cli-version-pin.test.d.ts +0 -2
  420. package/dist/__tests__/mx-agent-cli-version-pin.test.d.ts.map +0 -1
  421. package/dist/__tests__/mx-agent-cli-version-pin.test.js +0 -236
  422. package/dist/__tests__/mx-agent-cli-version-pin.test.js.map +0 -1
  423. package/dist/__tests__/new-project-first-team.test.d.ts +0 -15
  424. package/dist/__tests__/new-project-first-team.test.d.ts.map +0 -1
  425. package/dist/__tests__/new-project-first-team.test.js +0 -444
  426. package/dist/__tests__/new-project-first-team.test.js.map +0 -1
  427. package/dist/__tests__/otel-env.test.d.ts +0 -2
  428. package/dist/__tests__/otel-env.test.d.ts.map +0 -1
  429. package/dist/__tests__/otel-env.test.js +0 -127
  430. package/dist/__tests__/otel-env.test.js.map +0 -1
  431. package/dist/__tests__/pager-fail-closed.test.d.ts +0 -19
  432. package/dist/__tests__/pager-fail-closed.test.d.ts.map +0 -1
  433. package/dist/__tests__/pager-fail-closed.test.js +0 -229
  434. package/dist/__tests__/pager-fail-closed.test.js.map +0 -1
  435. package/dist/__tests__/pr-set-body.test.d.ts +0 -29
  436. package/dist/__tests__/pr-set-body.test.d.ts.map +0 -1
  437. package/dist/__tests__/pr-set-body.test.js +0 -314
  438. package/dist/__tests__/pr-set-body.test.js.map +0 -1
  439. package/dist/__tests__/prior-sync-failure.test.d.ts +0 -2
  440. package/dist/__tests__/prior-sync-failure.test.d.ts.map +0 -1
  441. package/dist/__tests__/prior-sync-failure.test.js +0 -81
  442. package/dist/__tests__/prior-sync-failure.test.js.map +0 -1
  443. package/dist/__tests__/project-config.test.d.ts +0 -2
  444. package/dist/__tests__/project-config.test.d.ts.map +0 -1
  445. package/dist/__tests__/project-config.test.js +0 -458
  446. package/dist/__tests__/project-config.test.js.map +0 -1
  447. package/dist/__tests__/provision-behavioral-contract.test.d.ts +0 -13
  448. package/dist/__tests__/provision-behavioral-contract.test.d.ts.map +0 -1
  449. package/dist/__tests__/provision-behavioral-contract.test.js +0 -548
  450. package/dist/__tests__/provision-behavioral-contract.test.js.map +0 -1
  451. package/dist/__tests__/provision-catalog-precondition.test.d.ts +0 -26
  452. package/dist/__tests__/provision-catalog-precondition.test.d.ts.map +0 -1
  453. package/dist/__tests__/provision-catalog-precondition.test.js +0 -622
  454. package/dist/__tests__/provision-catalog-precondition.test.js.map +0 -1
  455. package/dist/__tests__/provision-completion-rows.test.d.ts +0 -17
  456. package/dist/__tests__/provision-completion-rows.test.d.ts.map +0 -1
  457. package/dist/__tests__/provision-completion-rows.test.js +0 -3473
  458. package/dist/__tests__/provision-completion-rows.test.js.map +0 -1
  459. package/dist/__tests__/provision-copy-containment.test.d.ts +0 -19
  460. package/dist/__tests__/provision-copy-containment.test.d.ts.map +0 -1
  461. package/dist/__tests__/provision-copy-containment.test.js +0 -187
  462. package/dist/__tests__/provision-copy-containment.test.js.map +0 -1
  463. package/dist/__tests__/provision-identity-gate.test.d.ts +0 -20
  464. package/dist/__tests__/provision-identity-gate.test.d.ts.map +0 -1
  465. package/dist/__tests__/provision-identity-gate.test.js +0 -602
  466. package/dist/__tests__/provision-identity-gate.test.js.map +0 -1
  467. package/dist/__tests__/provision-resume.test.d.ts +0 -26
  468. package/dist/__tests__/provision-resume.test.d.ts.map +0 -1
  469. package/dist/__tests__/provision-resume.test.js +0 -1344
  470. package/dist/__tests__/provision-resume.test.js.map +0 -1
  471. package/dist/__tests__/provision-roleguide-anchors.test.d.ts +0 -27
  472. package/dist/__tests__/provision-roleguide-anchors.test.d.ts.map +0 -1
  473. package/dist/__tests__/provision-roleguide-anchors.test.js +0 -747
  474. package/dist/__tests__/provision-roleguide-anchors.test.js.map +0 -1
  475. package/dist/__tests__/provision-row12-stub-server.test.d.ts +0 -21
  476. package/dist/__tests__/provision-row12-stub-server.test.d.ts.map +0 -1
  477. package/dist/__tests__/provision-row12-stub-server.test.js +0 -264
  478. package/dist/__tests__/provision-row12-stub-server.test.js.map +0 -1
  479. package/dist/__tests__/provision-skeleton-fill.test.d.ts +0 -16
  480. package/dist/__tests__/provision-skeleton-fill.test.d.ts.map +0 -1
  481. package/dist/__tests__/provision-skeleton-fill.test.js +0 -490
  482. package/dist/__tests__/provision-skeleton-fill.test.js.map +0 -1
  483. package/dist/__tests__/provision-step8-commit.test.d.ts +0 -40
  484. package/dist/__tests__/provision-step8-commit.test.d.ts.map +0 -1
  485. package/dist/__tests__/provision-step8-commit.test.js +0 -529
  486. package/dist/__tests__/provision-step8-commit.test.js.map +0 -1
  487. package/dist/__tests__/provision-teambuilder-flow.test.d.ts +0 -22
  488. package/dist/__tests__/provision-teambuilder-flow.test.d.ts.map +0 -1
  489. package/dist/__tests__/provision-teambuilder-flow.test.js +0 -253
  490. package/dist/__tests__/provision-teambuilder-flow.test.js.map +0 -1
  491. package/dist/__tests__/provision-write-integrity.test.d.ts +0 -18
  492. package/dist/__tests__/provision-write-integrity.test.d.ts.map +0 -1
  493. package/dist/__tests__/provision-write-integrity.test.js +0 -141
  494. package/dist/__tests__/provision-write-integrity.test.js.map +0 -1
  495. package/dist/__tests__/repo-guard-wiring.test.d.ts +0 -21
  496. package/dist/__tests__/repo-guard-wiring.test.d.ts.map +0 -1
  497. package/dist/__tests__/repo-guard-wiring.test.js +0 -638
  498. package/dist/__tests__/repo-guard-wiring.test.js.map +0 -1
  499. package/dist/__tests__/report-format.test.d.ts +0 -2
  500. package/dist/__tests__/report-format.test.d.ts.map +0 -1
  501. package/dist/__tests__/report-format.test.js +0 -219
  502. package/dist/__tests__/report-format.test.js.map +0 -1
  503. package/dist/__tests__/row15-detail-sanitizer.test.d.ts +0 -20
  504. package/dist/__tests__/row15-detail-sanitizer.test.d.ts.map +0 -1
  505. package/dist/__tests__/row15-detail-sanitizer.test.js +0 -61
  506. package/dist/__tests__/row15-detail-sanitizer.test.js.map +0 -1
  507. package/dist/__tests__/rows-9-10-zero-remotes.test.d.ts +0 -32
  508. package/dist/__tests__/rows-9-10-zero-remotes.test.d.ts.map +0 -1
  509. package/dist/__tests__/rows-9-10-zero-remotes.test.js +0 -203
  510. package/dist/__tests__/rows-9-10-zero-remotes.test.js.map +0 -1
  511. package/dist/__tests__/runtime-claude-adapter.test.d.ts +0 -2
  512. package/dist/__tests__/runtime-claude-adapter.test.d.ts.map +0 -1
  513. package/dist/__tests__/runtime-claude-adapter.test.js +0 -70
  514. package/dist/__tests__/runtime-claude-adapter.test.js.map +0 -1
  515. package/dist/__tests__/runtime-codex-adapter.test.d.ts +0 -2
  516. package/dist/__tests__/runtime-codex-adapter.test.d.ts.map +0 -1
  517. package/dist/__tests__/runtime-codex-adapter.test.js +0 -558
  518. package/dist/__tests__/runtime-codex-adapter.test.js.map +0 -1
  519. package/dist/__tests__/runtime-codex-config.test.d.ts +0 -2
  520. package/dist/__tests__/runtime-codex-config.test.d.ts.map +0 -1
  521. package/dist/__tests__/runtime-codex-config.test.js +0 -1421
  522. package/dist/__tests__/runtime-codex-config.test.js.map +0 -1
  523. package/dist/__tests__/runtime-codex-gateway-pilot.test.d.ts +0 -2
  524. package/dist/__tests__/runtime-codex-gateway-pilot.test.d.ts.map +0 -1
  525. package/dist/__tests__/runtime-codex-gateway-pilot.test.js +0 -309
  526. package/dist/__tests__/runtime-codex-gateway-pilot.test.js.map +0 -1
  527. package/dist/__tests__/runtime-codex-gateway-provider.test.d.ts +0 -2
  528. package/dist/__tests__/runtime-codex-gateway-provider.test.d.ts.map +0 -1
  529. package/dist/__tests__/runtime-codex-gateway-provider.test.js +0 -163
  530. package/dist/__tests__/runtime-codex-gateway-provider.test.js.map +0 -1
  531. package/dist/__tests__/runtime-codex-guard-proof.test.d.ts +0 -2
  532. package/dist/__tests__/runtime-codex-guard-proof.test.d.ts.map +0 -1
  533. package/dist/__tests__/runtime-codex-guard-proof.test.js +0 -822
  534. package/dist/__tests__/runtime-codex-guard-proof.test.js.map +0 -1
  535. package/dist/__tests__/runtime-codex-version-pin.test.d.ts +0 -2
  536. package/dist/__tests__/runtime-codex-version-pin.test.d.ts.map +0 -1
  537. package/dist/__tests__/runtime-codex-version-pin.test.js +0 -86
  538. package/dist/__tests__/runtime-codex-version-pin.test.js.map +0 -1
  539. package/dist/__tests__/runtime-identity.test.d.ts +0 -2
  540. package/dist/__tests__/runtime-identity.test.d.ts.map +0 -1
  541. package/dist/__tests__/runtime-identity.test.js +0 -117
  542. package/dist/__tests__/runtime-identity.test.js.map +0 -1
  543. package/dist/__tests__/runtime-resolve.test.d.ts +0 -2
  544. package/dist/__tests__/runtime-resolve.test.d.ts.map +0 -1
  545. package/dist/__tests__/runtime-resolve.test.js +0 -172
  546. package/dist/__tests__/runtime-resolve.test.js.map +0 -1
  547. package/dist/__tests__/security-posture.test.d.ts +0 -8
  548. package/dist/__tests__/security-posture.test.d.ts.map +0 -1
  549. package/dist/__tests__/security-posture.test.js +0 -82
  550. package/dist/__tests__/security-posture.test.js.map +0 -1
  551. package/dist/__tests__/session-model.test.d.ts +0 -2
  552. package/dist/__tests__/session-model.test.d.ts.map +0 -1
  553. package/dist/__tests__/session-model.test.js +0 -74
  554. package/dist/__tests__/session-model.test.js.map +0 -1
  555. package/dist/__tests__/session-pause-provisioning.test.d.ts +0 -19
  556. package/dist/__tests__/session-pause-provisioning.test.d.ts.map +0 -1
  557. package/dist/__tests__/session-pause-provisioning.test.js +0 -115
  558. package/dist/__tests__/session-pause-provisioning.test.js.map +0 -1
  559. package/dist/__tests__/session-reclamation.test.d.ts +0 -15
  560. package/dist/__tests__/session-reclamation.test.d.ts.map +0 -1
  561. package/dist/__tests__/session-reclamation.test.js +0 -73
  562. package/dist/__tests__/session-reclamation.test.js.map +0 -1
  563. package/dist/__tests__/session-record-disclosure.test.d.ts +0 -24
  564. package/dist/__tests__/session-record-disclosure.test.d.ts.map +0 -1
  565. package/dist/__tests__/session-record-disclosure.test.js +0 -494
  566. package/dist/__tests__/session-record-disclosure.test.js.map +0 -1
  567. package/dist/__tests__/session-status.test.d.ts +0 -11
  568. package/dist/__tests__/session-status.test.d.ts.map +0 -1
  569. package/dist/__tests__/session-status.test.js +0 -76
  570. package/dist/__tests__/session-status.test.js.map +0 -1
  571. package/dist/__tests__/session.test.d.ts +0 -15
  572. package/dist/__tests__/session.test.d.ts.map +0 -1
  573. package/dist/__tests__/session.test.js +0 -366
  574. package/dist/__tests__/session.test.js.map +0 -1
  575. package/dist/__tests__/shim-deploy-safety.test.d.ts +0 -24
  576. package/dist/__tests__/shim-deploy-safety.test.d.ts.map +0 -1
  577. package/dist/__tests__/shim-deploy-safety.test.js +0 -174
  578. package/dist/__tests__/shim-deploy-safety.test.js.map +0 -1
  579. package/dist/__tests__/slug-validation.test.d.ts +0 -13
  580. package/dist/__tests__/slug-validation.test.d.ts.map +0 -1
  581. package/dist/__tests__/slug-validation.test.js +0 -202
  582. package/dist/__tests__/slug-validation.test.js.map +0 -1
  583. package/dist/__tests__/standards-injection.test.d.ts +0 -2
  584. package/dist/__tests__/standards-injection.test.d.ts.map +0 -1
  585. package/dist/__tests__/standards-injection.test.js +0 -179
  586. package/dist/__tests__/standards-injection.test.js.map +0 -1
  587. package/dist/__tests__/start-config-conflict.test.d.ts +0 -17
  588. package/dist/__tests__/start-config-conflict.test.d.ts.map +0 -1
  589. package/dist/__tests__/start-config-conflict.test.js +0 -101
  590. package/dist/__tests__/start-config-conflict.test.js.map +0 -1
  591. package/dist/__tests__/start-interactive-role.test.d.ts +0 -22
  592. package/dist/__tests__/start-interactive-role.test.d.ts.map +0 -1
  593. package/dist/__tests__/start-interactive-role.test.js +0 -204
  594. package/dist/__tests__/start-interactive-role.test.js.map +0 -1
  595. package/dist/__tests__/start-rebase-never-ran.test.d.ts +0 -25
  596. package/dist/__tests__/start-rebase-never-ran.test.d.ts.map +0 -1
  597. package/dist/__tests__/start-rebase-never-ran.test.js +0 -227
  598. package/dist/__tests__/start-rebase-never-ran.test.js.map +0 -1
  599. package/dist/__tests__/start-report-generation-capture.test.d.ts +0 -17
  600. package/dist/__tests__/start-report-generation-capture.test.d.ts.map +0 -1
  601. package/dist/__tests__/start-report-generation-capture.test.js +0 -127
  602. package/dist/__tests__/start-report-generation-capture.test.js.map +0 -1
  603. package/dist/__tests__/start-report-integration.test.d.ts +0 -12
  604. package/dist/__tests__/start-report-integration.test.d.ts.map +0 -1
  605. package/dist/__tests__/start-report-integration.test.js +0 -138
  606. package/dist/__tests__/start-report-integration.test.js.map +0 -1
  607. package/dist/__tests__/start-runtime-wiring.test.d.ts +0 -31
  608. package/dist/__tests__/start-runtime-wiring.test.d.ts.map +0 -1
  609. package/dist/__tests__/start-runtime-wiring.test.js +0 -735
  610. package/dist/__tests__/start-runtime-wiring.test.js.map +0 -1
  611. package/dist/__tests__/start-stash.test.d.ts +0 -2
  612. package/dist/__tests__/start-stash.test.d.ts.map +0 -1
  613. package/dist/__tests__/start-stash.test.js +0 -131
  614. package/dist/__tests__/start-stash.test.js.map +0 -1
  615. package/dist/__tests__/start-sync-hardstop.test.d.ts +0 -15
  616. package/dist/__tests__/start-sync-hardstop.test.d.ts.map +0 -1
  617. package/dist/__tests__/start-sync-hardstop.test.js +0 -280
  618. package/dist/__tests__/start-sync-hardstop.test.js.map +0 -1
  619. package/dist/__tests__/start-team-identity.test.d.ts +0 -25
  620. package/dist/__tests__/start-team-identity.test.d.ts.map +0 -1
  621. package/dist/__tests__/start-team-identity.test.js +0 -307
  622. package/dist/__tests__/start-team-identity.test.js.map +0 -1
  623. package/dist/__tests__/startup-health-render.test.d.ts +0 -11
  624. package/dist/__tests__/startup-health-render.test.d.ts.map +0 -1
  625. package/dist/__tests__/startup-health-render.test.js +0 -60
  626. package/dist/__tests__/startup-health-render.test.js.map +0 -1
  627. package/dist/__tests__/startup-policy.test.d.ts +0 -2
  628. package/dist/__tests__/startup-policy.test.d.ts.map +0 -1
  629. package/dist/__tests__/startup-policy.test.js +0 -27
  630. package/dist/__tests__/startup-policy.test.js.map +0 -1
  631. package/dist/__tests__/startup-report.test.d.ts +0 -13
  632. package/dist/__tests__/startup-report.test.d.ts.map +0 -1
  633. package/dist/__tests__/startup-report.test.js +0 -278
  634. package/dist/__tests__/startup-report.test.js.map +0 -1
  635. package/dist/__tests__/startup-shipper.test.d.ts +0 -13
  636. package/dist/__tests__/startup-shipper.test.d.ts.map +0 -1
  637. package/dist/__tests__/startup-shipper.test.js +0 -149
  638. package/dist/__tests__/startup-shipper.test.js.map +0 -1
  639. package/dist/__tests__/stream-input-controller.test.d.ts +0 -10
  640. package/dist/__tests__/stream-input-controller.test.d.ts.map +0 -1
  641. package/dist/__tests__/stream-input-controller.test.js +0 -167
  642. package/dist/__tests__/stream-input-controller.test.js.map +0 -1
  643. package/dist/__tests__/team-memory-commands.test.d.ts +0 -11
  644. package/dist/__tests__/team-memory-commands.test.d.ts.map +0 -1
  645. package/dist/__tests__/team-memory-commands.test.js +0 -240
  646. package/dist/__tests__/team-memory-commands.test.js.map +0 -1
  647. package/dist/__tests__/team-name-propagation.test.d.ts +0 -13
  648. package/dist/__tests__/team-name-propagation.test.d.ts.map +0 -1
  649. package/dist/__tests__/team-name-propagation.test.js +0 -198
  650. package/dist/__tests__/team-name-propagation.test.js.map +0 -1
  651. package/dist/__tests__/team-token-probe.test.d.ts +0 -16
  652. package/dist/__tests__/team-token-probe.test.d.ts.map +0 -1
  653. package/dist/__tests__/team-token-probe.test.js +0 -295
  654. package/dist/__tests__/team-token-probe.test.js.map +0 -1
  655. package/dist/__tests__/template-budget.test.d.ts +0 -2
  656. package/dist/__tests__/template-budget.test.d.ts.map +0 -1
  657. package/dist/__tests__/template-budget.test.js +0 -119
  658. package/dist/__tests__/template-budget.test.js.map +0 -1
  659. package/dist/__tests__/template-sync.test.d.ts +0 -19
  660. package/dist/__tests__/template-sync.test.d.ts.map +0 -1
  661. package/dist/__tests__/template-sync.test.js +0 -480
  662. package/dist/__tests__/template-sync.test.js.map +0 -1
  663. package/dist/__tests__/test-project.test.d.ts +0 -18
  664. package/dist/__tests__/test-project.test.d.ts.map +0 -1
  665. package/dist/__tests__/test-project.test.js +0 -465
  666. package/dist/__tests__/test-project.test.js.map +0 -1
  667. package/dist/__tests__/tracked-instruction-files.test.d.ts +0 -21
  668. package/dist/__tests__/tracked-instruction-files.test.d.ts.map +0 -1
  669. package/dist/__tests__/tracked-instruction-files.test.js +0 -489
  670. package/dist/__tests__/tracked-instruction-files.test.js.map +0 -1
  671. package/dist/__tests__/unlock.test.d.ts +0 -11
  672. package/dist/__tests__/unlock.test.d.ts.map +0 -1
  673. package/dist/__tests__/unlock.test.js +0 -100
  674. package/dist/__tests__/unlock.test.js.map +0 -1
  675. package/dist/__tests__/usage-per-call-grouping.test.d.ts +0 -25
  676. package/dist/__tests__/usage-per-call-grouping.test.d.ts.map +0 -1
  677. package/dist/__tests__/usage-per-call-grouping.test.js +0 -952
  678. package/dist/__tests__/usage-per-call-grouping.test.js.map +0 -1
  679. package/dist/__tests__/usage-pricing.test.d.ts +0 -20
  680. package/dist/__tests__/usage-pricing.test.d.ts.map +0 -1
  681. package/dist/__tests__/usage-pricing.test.js +0 -176
  682. package/dist/__tests__/usage-pricing.test.js.map +0 -1
  683. package/dist/__tests__/usage-subagent-discovery.test.d.ts +0 -17
  684. package/dist/__tests__/usage-subagent-discovery.test.d.ts.map +0 -1
  685. package/dist/__tests__/usage-subagent-discovery.test.js +0 -213
  686. package/dist/__tests__/usage-subagent-discovery.test.js.map +0 -1
  687. package/dist/__tests__/verify-hooks-check-all.test.d.ts +0 -32
  688. package/dist/__tests__/verify-hooks-check-all.test.d.ts.map +0 -1
  689. package/dist/__tests__/verify-hooks-check-all.test.js +0 -563
  690. package/dist/__tests__/verify-hooks-check-all.test.js.map +0 -1
  691. package/dist/__tests__/verify-hooks-heal-log.test.d.ts +0 -11
  692. package/dist/__tests__/verify-hooks-heal-log.test.d.ts.map +0 -1
  693. package/dist/__tests__/verify-hooks-heal-log.test.js +0 -172
  694. package/dist/__tests__/verify-hooks-heal-log.test.js.map +0 -1
  695. package/dist/__tests__/worker-cap.test.d.ts +0 -14
  696. package/dist/__tests__/worker-cap.test.d.ts.map +0 -1
  697. package/dist/__tests__/worker-cap.test.js +0 -97
  698. package/dist/__tests__/worker-cap.test.js.map +0 -1
  699. package/dist/__tests__/worktree-link-repair.test.d.ts +0 -2
  700. package/dist/__tests__/worktree-link-repair.test.d.ts.map +0 -1
  701. package/dist/__tests__/worktree-link-repair.test.js +0 -471
  702. package/dist/__tests__/worktree-link-repair.test.js.map +0 -1
  703. package/dist/__tests__/worktree-sync-fixture.test.d.ts +0 -17
  704. package/dist/__tests__/worktree-sync-fixture.test.d.ts.map +0 -1
  705. package/dist/__tests__/worktree-sync-fixture.test.js +0 -519
  706. package/dist/__tests__/worktree-sync-fixture.test.js.map +0 -1
  707. package/dist/__tests__/worktree-sync-hardening.test.d.ts +0 -13
  708. package/dist/__tests__/worktree-sync-hardening.test.d.ts.map +0 -1
  709. package/dist/__tests__/worktree-sync-hardening.test.js +0 -919
  710. package/dist/__tests__/worktree-sync-hardening.test.js.map +0 -1
  711. package/dist/__tests__/worktree-sync-shell-free.test.d.ts +0 -25
  712. package/dist/__tests__/worktree-sync-shell-free.test.d.ts.map +0 -1
  713. package/dist/__tests__/worktree-sync-shell-free.test.js +0 -185
  714. package/dist/__tests__/worktree-sync-shell-free.test.js.map +0 -1
  715. package/dist/__tests__/worktree.test.d.ts +0 -2
  716. package/dist/__tests__/worktree.test.d.ts.map +0 -1
  717. package/dist/__tests__/worktree.test.js +0 -168
  718. package/dist/__tests__/worktree.test.js.map +0 -1
  719. package/dist/lib/code-context-file.test.d.ts +0 -19
  720. package/dist/lib/code-context-file.test.d.ts.map +0 -1
  721. package/dist/lib/code-context-file.test.js +0 -202
  722. package/dist/lib/code-context-file.test.js.map +0 -1
  723. package/dist/lib/harness/console/announce.test.d.ts +0 -2
  724. package/dist/lib/harness/console/announce.test.d.ts.map +0 -1
  725. package/dist/lib/harness/console/announce.test.js +0 -104
  726. package/dist/lib/harness/console/announce.test.js.map +0 -1
  727. package/dist/lib/harness/console/by-session.test.d.ts +0 -2
  728. package/dist/lib/harness/console/by-session.test.d.ts.map +0 -1
  729. package/dist/lib/harness/console/by-session.test.js +0 -86
  730. package/dist/lib/harness/console/by-session.test.js.map +0 -1
  731. package/dist/lib/harness/console/console.test.d.ts +0 -2
  732. package/dist/lib/harness/console/console.test.d.ts.map +0 -1
  733. package/dist/lib/harness/console/console.test.js +0 -269
  734. package/dist/lib/harness/console/console.test.js.map +0 -1
  735. package/dist/lib/harness/console/decision-request.test.d.ts +0 -2
  736. package/dist/lib/harness/console/decision-request.test.d.ts.map +0 -1
  737. package/dist/lib/harness/console/decision-request.test.js +0 -75
  738. package/dist/lib/harness/console/decision-request.test.js.map +0 -1
  739. package/dist/lib/harness/console/rank.test.d.ts +0 -2
  740. package/dist/lib/harness/console/rank.test.d.ts.map +0 -1
  741. package/dist/lib/harness/console/rank.test.js +0 -124
  742. package/dist/lib/harness/console/rank.test.js.map +0 -1
  743. package/dist/lib/harness/console/render.test.d.ts +0 -2
  744. package/dist/lib/harness/console/render.test.d.ts.map +0 -1
  745. package/dist/lib/harness/console/render.test.js +0 -96
  746. package/dist/lib/harness/console/render.test.js.map +0 -1
  747. package/dist/lib/harness/console/replay-cli.test.d.ts +0 -2
  748. package/dist/lib/harness/console/replay-cli.test.d.ts.map +0 -1
  749. package/dist/lib/harness/console/replay-cli.test.js +0 -96
  750. package/dist/lib/harness/console/replay-cli.test.js.map +0 -1
  751. package/dist/lib/harness/console/replay.test.d.ts +0 -2
  752. package/dist/lib/harness/console/replay.test.d.ts.map +0 -1
  753. package/dist/lib/harness/console/replay.test.js +0 -81
  754. package/dist/lib/harness/console/replay.test.js.map +0 -1
  755. package/dist/lib/harness/console/turn-reader.test.d.ts +0 -2
  756. package/dist/lib/harness/console/turn-reader.test.d.ts.map +0 -1
  757. package/dist/lib/harness/console/turn-reader.test.js +0 -108
  758. package/dist/lib/harness/console/turn-reader.test.js.map +0 -1
  759. package/dist/lib/harness/credential.test.d.ts +0 -2
  760. package/dist/lib/harness/credential.test.d.ts.map +0 -1
  761. package/dist/lib/harness/credential.test.js +0 -74
  762. package/dist/lib/harness/credential.test.js.map +0 -1
  763. package/dist/lib/harness/evaluate.test.d.ts +0 -2
  764. package/dist/lib/harness/evaluate.test.d.ts.map +0 -1
  765. package/dist/lib/harness/evaluate.test.js +0 -621
  766. package/dist/lib/harness/evaluate.test.js.map +0 -1
  767. package/dist/lib/harness/gate.test.d.ts +0 -2
  768. package/dist/lib/harness/gate.test.d.ts.map +0 -1
  769. package/dist/lib/harness/gate.test.js +0 -111
  770. package/dist/lib/harness/gate.test.js.map +0 -1
  771. package/dist/lib/harness/self-check.test.d.ts +0 -2
  772. package/dist/lib/harness/self-check.test.d.ts.map +0 -1
  773. package/dist/lib/harness/self-check.test.js +0 -43
  774. package/dist/lib/harness/self-check.test.js.map +0 -1
  775. package/dist/lib/harness/transcript.test.d.ts +0 -2
  776. package/dist/lib/harness/transcript.test.d.ts.map +0 -1
  777. package/dist/lib/harness/transcript.test.js +0 -118
  778. package/dist/lib/harness/transcript.test.js.map +0 -1
  779. package/dist/lib/projects-registry.test.d.ts +0 -2
  780. package/dist/lib/projects-registry.test.d.ts.map +0 -1
  781. package/dist/lib/projects-registry.test.js +0 -176
  782. package/dist/lib/projects-registry.test.js.map +0 -1
  783. package/dist/lib/roster.test.d.ts +0 -15
  784. package/dist/lib/roster.test.d.ts.map +0 -1
  785. package/dist/lib/roster.test.js +0 -299
  786. package/dist/lib/roster.test.js.map +0 -1
  787. package/dist/lib/vault.test.d.ts +0 -17
  788. package/dist/lib/vault.test.d.ts.map +0 -1
  789. package/dist/lib/vault.test.js +0 -169
  790. package/dist/lib/vault.test.js.map +0 -1
  791. package/dist/lib/window-view.test.d.ts +0 -2
  792. package/dist/lib/window-view.test.d.ts.map +0 -1
  793. package/dist/lib/window-view.test.js +0 -168
  794. package/dist/lib/window-view.test.js.map +0 -1
  795. package/dist/standards/fail-loud-standard.md +0 -495
  796. package/dist/standards/known-issues-standard.md +0 -380
  797. package/dist/standards/rulings.md +0 -104
@@ -1,1344 +0,0 @@
1
- /**
2
- * Resumable creation (#5, #76, #295; plan #316).
3
- *
4
- * A provision that failed after the worktree was created could not be retried:
5
- * the second run met `Worktree already exists at ...` and exited before it
6
- * checked anything (`create.ts:3620-3624` at `7d336e0`, reproduced live by the
7
- * v25 probe at `99d01b1`). The catalog entry and the three named memories were
8
- * never written, and the only way through was deleting the worktree by hand.
9
- *
10
- * These tests pin what replaces it:
11
- * 1. A second run RESUMES: it performs the missing steps and reaches a full
12
- * row table (acceptance rows 2 and 3).
13
- * 2. It resumes only a worktree it can show belongs to this team, and a
14
- * mismatch refuses naming both (change A, red-team Critical 3).
15
- * 3. Two runs for one team cannot overlap (change A, red-team Major 4).
16
- * 4. Two resumes fetch exactly one credential (change B, red-team Critical 1).
17
- * 5. A standing memory this team owns asserts its row, and one whose seed
18
- * differs reads `present, stale` (change B, finding 7).
19
- * 6. A catalog entry is byte-identical after a resume (change B, finding 8).
20
- * 7. `--recheck` writes nothing and states row 10's limitation (change D,
21
- * finding 6).
22
- * 8. Nothing between `createGitWorktree` and the pre-check calls
23
- * `process.exit` (change C, red-team Critical 2).
24
- */
25
- import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
26
- import { existsSync, lstatSync, mkdtempSync, mkdirSync, readFileSync, readdirSync, rmSync, statSync, symlinkSync, utimesSync, writeFileSync, } from 'fs';
27
- import { join, dirname, relative, sep, isAbsolute } from 'path';
28
- import { tmpdir } from 'os';
29
- // ── Test-controlled state, declared before the factories that close over it ──
30
- /** Which step, if any, the run under test is cut at. */
31
- let failAfter = null;
32
- /** Names that already resolve, with the content and codeContext they hold. */
33
- const standingMemories = new Map();
34
- /**
35
- * Names that are held but cannot be read back (#478): `readNamedMemoryJson`
36
- * answers `unknown`, and the create path's probe finds the name taken but
37
- * returns no content. Both classify `could-not-run`.
38
- */
39
- const unreadableMemories = new Set();
40
- /** How many times the stubbed credential service issued a token. */
41
- let credentialFetches = 0;
42
- /** When true, the stubbed credential service refuses the next request (403) instead of issuing. */
43
- let credentialRefuseNext = false;
44
- /** When true, a forced re-mint's cache write removes the old file and then fails, write and retry (N-1). */
45
- let failRemintWrite = false;
46
- /**
47
- * Row 12's probe (v41): what the injected GET /obligations answers, in call
48
- * order with the last entry repeating, and what each call was sent. The tokens
49
- * recorded are this fixture's own fakes (`stub-token-N`); recording them is how
50
- * a test shows the probe read the cache the re-mint wrote.
51
- */
52
- let obligationsAnswers = [200];
53
- let obligationsCalls = [];
54
- /** The `serviceUrl` each call handed the credential path, in call order. */
55
- let credentialServiceUrls = [];
56
- /**
57
- * What `resolveCoordinationUrl` answers, BY ROOT.
58
- *
59
- * Two answers, because the defect they pin is two resolvers disagreeing:
60
- * `runCreate` resolves with `{ projectRoot }` and `obtainCredential` resolves
61
- * with nothing, which derives a root from the current directory
62
- * (`lib/coordination-client.ts:346-352`).
63
- */
64
- let urlFromProjectRoot = 'http://127.0.0.1:9';
65
- const URL_FROM_CWD = 'https://coordination.example.invalid';
66
- let credentialProjects = new Set(['mx-agent']);
67
- let configuredProjectSlug = 'mx-agent';
68
- let hasOrigin = false;
69
- let mxAvailable = true;
70
- vi.mock('../lib/config.js', () => ({
71
- getConfigValue: () => undefined,
72
- setConfigValue: () => undefined,
73
- getConfigPath: () => '/nonexistent/config.json',
74
- }));
75
- /**
76
- * The worktree the real command makes, including the `.git` file that tells a
77
- * linked worktree from a directory. `findTeamWorktree` reads exactly that, so a
78
- * mock without it would never produce a resume and every test here would pass
79
- * against the old behaviour.
80
- */
81
- const createGitWorktree = vi.fn((worktreePath) => {
82
- mkdirSync(worktreePath, { recursive: true });
83
- writeFileSync(join(worktreePath, '.git'), 'gitdir: /nowhere\n');
84
- });
85
- vi.mock('../lib/worktree.js', async (importOriginal) => ({
86
- // `findTeamWorktree` decides whether a run is a resume (#316). The REAL one:
87
- // it reads `.git` off the candidate, and a stub that answered null would make
88
- // every test here take the fresh-creation path whatever is on disk.
89
- findTeamWorktree: (await importOriginal()).findTeamWorktree,
90
- findProjectRoot: vi.fn(() => '/unused'),
91
- assignSlot: vi.fn(() => 4),
92
- getCurrentBranch: vi.fn(() => 'worktree/newteam-20260101'),
93
- fetchOrigin: vi.fn(() => true),
94
- createGitWorktree: (worktreePath, ..._rest) => createGitWorktree(worktreePath),
95
- addToGitSafeDirectory: vi.fn(),
96
- createHuskySymlink: vi.fn(),
97
- generateBranchName: vi.fn((s) => `worktree/${s}-20260101`),
98
- generateWorktreeDirName: vi.fn((s) => `${s}-20260101`),
99
- listRemotes: vi.fn(() => (hasOrigin ? ['origin'] : [])),
100
- findWorktreePath: vi.fn(() => null),
101
- }));
102
- /** Step 5, which is where #5's incident died. The fault point is right after it. */
103
- const syncClaudeConfig = vi.fn();
104
- vi.mock('../lib/claude.js', async (importOriginal) => {
105
- const real = await importOriginal();
106
- return {
107
- ...real,
108
- syncClaudeConfig: (...a) => syncClaudeConfig(...a),
109
- deployClaudeMd: vi.fn(),
110
- // The pointer line comes from the REAL builder, and the identity check reads
111
- // it with the REAL reader (red-team round 2, finding 1). A hand-written copy
112
- // here would pass while the shipped pair drifted apart.
113
- writeClaudeLocal: vi.fn((opts) => {
114
- const pointer = opts.behavioralOverride?.roleguideRelPath;
115
- writeFileSync(join(opts.worktreePath, 'CLAUDE.local.md'), pointer
116
- ? `# Team — Behavioral Checks (every-turn reinforcement)\n\n${real.behavioralPointerLine(pointer)}\n`
117
- : '# no behavioral block\n');
118
- return { written: true, path: join(opts.worktreePath, 'CLAUDE.local.md') };
119
- }),
120
- logSuccess: vi.fn(),
121
- logWarning: vi.fn(),
122
- logDim: vi.fn(),
123
- };
124
- });
125
- vi.mock('../lib/catalog.js', async (importOriginal) => {
126
- const real = await importOriginal();
127
- return {
128
- ...real,
129
- catalogEntryOnOriginMain: vi.fn(() => 'present'),
130
- // The REAL row-7 reader, wrapped so its arguments are recorded (#407 review
131
- // round 1, red-team finding 2). Row 7's outcome is unchanged by the wrapper:
132
- // these fixtures have no reachable remote, so the real function answers
133
- // `unresolvable` here exactly as it did before. What the wrapper adds is the
134
- // only evidence available about the path the CALL SITES compute, which no
135
- // test asserted: the row tests supply that path by hand.
136
- roleguideOnOriginMain: vi.fn(real.roleguideOnOriginMain),
137
- listTeams: vi.fn(() => []),
138
- };
139
- });
140
- vi.mock('../lib/roster.js', async (importOriginal) => ({
141
- // #607: the real ref builder, so the ref rows 9 and 10 name is the one the read uses.
142
- rosterRefFor: (await importOriginal()).rosterRefFor,
143
- rosterEntryOnRef: vi.fn(() => 'present'),
144
- rosterSourceHasSlug: vi.fn(() => 'absent'),
145
- }));
146
- vi.mock('../lib/vault.js', () => ({
147
- vaultTokenPresent: vi.fn(() => 'present'),
148
- VAULT_NAME: 'mx-dev-eastus2-kv-001',
149
- }));
150
- /**
151
- * The REAL credential path with a stubbed service.
152
- *
153
- * Only the HTTP fetch is faked. The cache read, the born-0600 write and the
154
- * pre-mint check are the shipped code, which is what makes "two resumes, one
155
- * fetch" a statement about the product rather than about this file.
156
- */
157
- vi.mock('../lib/coordination-token.js', async (importOriginal) => {
158
- const real = await importOriginal();
159
- return {
160
- ...real,
161
- usesCredentialEndpoint: (project) => credentialProjects.has(project),
162
- provisionCredentialForWorktree: vi.fn((i) => {
163
- // WHAT THE COMMAND PASSED, recorded before the stub overrides it so the
164
- // fetcher below is reachable. The assertion is about the argument, not
165
- // about where this fixture then sends the request.
166
- credentialServiceUrls.push(i.serviceUrl);
167
- return real.provisionCredentialForWorktree({
168
- ...i,
169
- serviceUrl: 'http://127.0.0.1:9',
170
- readUserKey: () => 'fake-user-key-for-tests-only',
171
- ...(failRemintWrite && i.forceMint === true
172
- ? { writeCache: (path) => { rmSync(path, { force: true }); return false; } }
173
- : {}),
174
- fetchCredential: async () => {
175
- if (credentialRefuseNext) {
176
- credentialRefuseNext = false;
177
- return { status: 'not-authorized' };
178
- }
179
- credentialFetches += 1;
180
- return { status: 'issued', token: `stub-token-${credentialFetches}` };
181
- },
182
- });
183
- }),
184
- };
185
- });
186
- vi.mock('../lib/coordination-client.js', async (importOriginal) => ({
187
- ...(await importOriginal()),
188
- // ROOT-AWARE, the way the real resolver is. A caller that passes a root gets
189
- // that project's URL; a caller that passes none gets whatever the current
190
- // directory implies, which is a different repository's answer.
191
- resolveCoordinationUrl: vi.fn((opts) => (opts?.projectRoot
192
- ? { url: urlFromProjectRoot, source: 'project' }
193
- : { url: URL_FROM_CWD, source: 'project' })),
194
- projectUrlValidationError: vi.fn(() => undefined),
195
- }));
196
- /**
197
- * Row 12's probe (v41). The REAL `probeTeamToken`, including its real token
198
- * reader, which reads the 0600 cache the real credential path above wrote. Only
199
- * the request is injected: no socket is opened.
200
- */
201
- vi.mock('../lib/team-token-probe.js', async (importOriginal) => {
202
- const real = await importOriginal();
203
- const client = await vi.importActual('../lib/coordination-client.js');
204
- return {
205
- ...real,
206
- probeTeamToken: vi.fn((i) => real.probeTeamToken({
207
- ...i,
208
- getObligations: async ({ url, token }) => {
209
- obligationsCalls.push({ url, token });
210
- const a = obligationsAnswers[Math.min(obligationsCalls.length - 1, obligationsAnswers.length - 1)];
211
- if (a >= 200 && a < 300)
212
- return {};
213
- throw new client.ServiceHttpError(a, 'service-error-text-for-tests');
214
- },
215
- })),
216
- };
217
- });
218
- /** What `mx-agent-system/cli` looks like to the build stage: absent, so row 14 is not required. */
219
- vi.mock('../lib/cli-build.js', () => ({
220
- buildCliInWorktree: vi.fn(() => ({
221
- kind: 'not-applicable',
222
- detail: 'no mx-agent-system/cli/package.json in this worktree (this project installs the published CLI)',
223
- })),
224
- probeBuiltCli: vi.fn(() => ({
225
- kind: 'not-applicable',
226
- detail: 'no mx-agent-system/cli/package.json in this worktree (this project installs the published CLI)',
227
- })),
228
- REBUILD_REMEDY: 'npm ci && npm run build',
229
- }));
230
- /**
231
- * The memory boundary, modelling the two rules the real module states: a create
232
- * over a taken name is refused (`lib/memory.ts:948-996`), and the probe reports
233
- * whose the standing memory is from its own codeContext (`:960-967`).
234
- */
235
- vi.mock('../lib/memory.js', async (importOriginal) => {
236
- const real = await importOriginal();
237
- return {
238
- ...real,
239
- isMxAvailable: vi.fn(() => mxAvailable),
240
- namedMemoryResolvesById: vi.fn(() => ({ ok: true, detail: '' })),
241
- namedMemoryExists: vi.fn((name) => standingMemories.has(name) ? { ok: true, detail: '' } : { ok: false, detail: 'mx returned no such memory' }),
242
- readNamedMemoryJson: vi.fn((name) => {
243
- if (unreadableMemories.has(name)) {
244
- return { status: 'unknown', content: '', reason: 'mx timed out', exitCode: null };
245
- }
246
- const held = standingMemories.get(name);
247
- return held
248
- ? { status: 'present', content: held.content, body: { name, codeContext: held.codeContext }, exitCode: 0 }
249
- : { status: 'absent', content: '', exitCode: 1 };
250
- }),
251
- logMemoryResult: vi.fn(),
252
- logManualMemoryCommands: vi.fn(),
253
- bootstrapTeamMemories: vi.fn((slug, displayName, rg, projectSlug, opts) => {
254
- const specs = real.teamMemorySpecs(slug, displayName, rg, projectSlug, opts);
255
- const seed = (idx) => {
256
- const spec = specs[idx];
257
- const held = standingMemories.get(spec.name);
258
- if (held) {
259
- const ctx = held.codeContext;
260
- const ownership = !ctx || typeof ctx.team !== 'string'
261
- ? 'unconfirmed'
262
- : projectSlug !== '' && typeof ctx.product !== 'string'
263
- ? 'unconfirmed'
264
- : ctx.team === slug && (projectSlug === '' || ctx.product === projectSlug)
265
- ? 'this-team'
266
- : 'not-this-team';
267
- return {
268
- ok: false,
269
- output: 'name already taken',
270
- id: null,
271
- conversationId: null,
272
- preExisting: true,
273
- preExistingOwnership: ownership,
274
- probeConclusive: true,
275
- preExistingRead: unreadableMemories.has(spec.name)
276
- ? undefined
277
- : { content: held.content, codeContext: held.codeContext },
278
- };
279
- }
280
- standingMemories.set(spec.name, { content: spec.content, codeContext: spec.codeContext });
281
- return {
282
- ok: true,
283
- output: '',
284
- id: `id-of-${spec.name}`,
285
- conversationId: 'conv_testfixture',
286
- preExisting: false,
287
- probeConclusive: true,
288
- };
289
- };
290
- const leaderState = seed(0);
291
- const iterationLog = seed(1);
292
- const knownIssues = seed(2);
293
- return {
294
- leaderState,
295
- iterationLog,
296
- knownIssues,
297
- extras: [],
298
- conversationThreaded: true,
299
- conversationId: 'conv_testfixture',
300
- conversationOutcome: 'threaded-by-this-run',
301
- };
302
- }),
303
- };
304
- });
305
- vi.mock('../lib/project-config.js', async (importOriginal) => ({
306
- ...(await importOriginal()),
307
- loadProjectConfig: vi.fn((root) => ({ __root: root })),
308
- resolveProjectConfig: vi.fn(() => ({
309
- worktreeDir: '.worktrees',
310
- baseBranch: 'main',
311
- configSource: 'mx-agent-system/agent-config',
312
- teamsDir: 'mx-agent-system/teams',
313
- roleguidesDir: 'mx-agent-system/roleguides',
314
- projectSlug: configuredProjectSlug,
315
- coordinationServiceUrl: '',
316
- })),
317
- }));
318
- vi.mock('../lib/config-generation.js', () => ({ checkConfigGeneration: vi.fn() }));
319
- import { runCreate, CompletionCheckError, ResumeIdentityError, memoryStateHolds, __testing } from '../commands/create.js';
320
- import { roleguideOnOriginMain } from '../lib/catalog.js';
321
- import { rosterEntryOnRef } from '../lib/roster.js';
322
- import { BEHAVIORAL_START_MARKER, BEHAVIORAL_END_MARKER } from '../lib/behavioral-injection.js';
323
- const { checkResumeIdentity, memoryPresenceState, claimProvisionLock, provisionLockPath } = __testing;
324
- const RG = 'mx-agent-system/roleguides/newteam-leader.md';
325
- const WORKTREE_REL = '.worktrees/newteam-20260101';
326
- const MEMORY_NAMES = [
327
- 'mx-agent-newteam-leader-state',
328
- 'mx-agent-newteam-iteration-log',
329
- 'mx-agent-newteam-known-issues',
330
- ];
331
- function roleguideText(slug, projectSlug) {
332
- const prefix = projectSlug ? `${projectSlug}-${slug}` : slug;
333
- return [
334
- `# ${slug} Leader Roleguide`,
335
- '',
336
- BEHAVIORAL_START_MARKER,
337
- '## Decision Authority',
338
- '',
339
- '- Ship without asking when the data is clear.',
340
- BEHAVIORAL_END_MARKER,
341
- '',
342
- '## Named Memory Anchors',
343
- '',
344
- '| Name | Content | Updated when |',
345
- '|---|---|---|',
346
- `| \`${prefix}-leader-state\` | State | Every change |`,
347
- `| \`${prefix}-iteration-log\` | Log | At iteration close |`,
348
- `| \`${prefix}-known-issues\` | Issues | When found |`,
349
- ].join('\n');
350
- }
351
- let root;
352
- let stdout;
353
- let stderr;
354
- class ExitCalled extends Error {
355
- code;
356
- constructor(code) {
357
- super(`process.exit(${code})`);
358
- this.code = code;
359
- }
360
- }
361
- beforeEach(() => {
362
- root = mkdtempSync(join(tmpdir(), 'mx-provision-resume-'));
363
- failAfter = null;
364
- standingMemories.clear();
365
- unreadableMemories.clear();
366
- credentialFetches = 0;
367
- credentialRefuseNext = false;
368
- failRemintWrite = false;
369
- obligationsAnswers = [200];
370
- obligationsCalls = [];
371
- credentialServiceUrls = [];
372
- urlFromProjectRoot = 'http://127.0.0.1:9';
373
- credentialProjects = new Set(['mx-agent']);
374
- configuredProjectSlug = 'mx-agent';
375
- hasOrigin = false;
376
- mxAvailable = true;
377
- stdout = [];
378
- stderr = [];
379
- delete process.env.MX_PROVISION_FAIL_AFTER;
380
- delete process.env.MX_PROVISION_FAULT_INJECTION;
381
- vi.clearAllMocks();
382
- vi.spyOn(console, 'log').mockImplementation((...a) => { stdout.push(a.map(String).join(' ')); });
383
- vi.spyOn(console, 'error').mockImplementation((...a) => { stderr.push(a.map(String).join(' ')); });
384
- vi.spyOn(process, 'exit').mockImplementation(((code) => {
385
- throw new ExitCalled(code ?? 0);
386
- }));
387
- });
388
- afterEach(() => {
389
- rmSync(root, { recursive: true, force: true });
390
- delete process.env.MX_PROVISION_FAIL_AFTER;
391
- delete process.env.MX_PROVISION_FAULT_INJECTION;
392
- vi.restoreAllMocks();
393
- });
394
- /** Write the roleguide this project's team is provisioned from. */
395
- function writeRoleguide(name = RG, slug = 'newteam') {
396
- const abs = join(root, name);
397
- mkdirSync(dirname(abs), { recursive: true });
398
- writeFileSync(abs, roleguideText(slug, configuredProjectSlug));
399
- }
400
- /**
401
- * Run `mx-agent provision`, cut at `failAfter` when one is set.
402
- *
403
- * The fault is injected through the shipped mechanism — the environment
404
- * variable, honoured because vitest sets `VITEST` — rather than by patching the
405
- * module, so the recipe in the pull-request body is the one under test here.
406
- */
407
- async function provision(opts = {}) {
408
- if (failAfter) {
409
- process.env.MX_PROVISION_FAIL_AFTER = failAfter;
410
- // The second switch (red-team round 2, finding 5). A test build alone no
411
- // longer injects, so the fixture arms both exactly as the recipe does.
412
- process.env.MX_PROVISION_FAULT_INJECTION = '1';
413
- }
414
- else {
415
- delete process.env.MX_PROVISION_FAIL_AFTER;
416
- delete process.env.MX_PROVISION_FAULT_INJECTION;
417
- }
418
- try {
419
- await runCreate({
420
- roleguide: opts.roleguide ?? (opts.recheck ? undefined : RG),
421
- name: opts.name ?? 'newteam',
422
- projectRoot: root,
423
- recheck: opts.recheck,
424
- });
425
- return { failure: null };
426
- }
427
- catch (err) {
428
- if (err instanceof ExitCalled)
429
- throw new Error(`unexpected process.exit(${err.code})`);
430
- return { failure: err };
431
- }
432
- }
433
- /** Every printed `row N:` line, in order. */
434
- function rowLines() {
435
- return stdout.filter((l) => /^\s*row [\d]/.test(l));
436
- }
437
- /** Every file under `dir`, with its bytes, as one comparable snapshot. */
438
- function snapshot(dir) {
439
- const out = new Map();
440
- const walk = (d) => {
441
- for (const entry of readdirSync(d, { withFileTypes: true })) {
442
- const p = join(d, entry.name);
443
- if (entry.isDirectory())
444
- walk(p);
445
- else
446
- out.set(relative(dir, p), readFileSync(p, 'utf-8'));
447
- }
448
- };
449
- walk(dir);
450
- return out;
451
- }
452
- // ── The reproduction, and what a second run now does ─────────────────────────
453
- describe('a run interrupted after the worktree resumes to a full row table (#5)', () => {
454
- it('run 1 leaves a worktree and no memories; run 2 finishes it', async () => {
455
- writeRoleguide();
456
- failAfter = 'worktree';
457
- const first = await provision();
458
- // The #5 state: a worktree, and nothing after it.
459
- expect(first.failure).toBeInstanceOf(CompletionCheckError);
460
- expect(existsSync(join(root, WORKTREE_REL))).toBe(true);
461
- expect(standingMemories.size).toBe(0);
462
- expect(existsSync(join(root, 'mx-agent-system/teams/newteam.md'))).toBe(false);
463
- // What the old code did NOT print: the row table.
464
- expect(rowLines()).toHaveLength(16);
465
- expect(first.failure.message).toContain('worktree');
466
- expect(first.failure.message).toContain('--recheck');
467
- stdout = [];
468
- failAfter = null;
469
- const second = await provision();
470
- expect(second.failure).toBeNull();
471
- expect(rowLines()).toHaveLength(16);
472
- for (const n of [0, 1, 2, 3, 4, 5]) {
473
- expect(rowLines()[n]).toMatch(/row \d+: asserted/);
474
- }
475
- expect(standingMemories.size).toBe(3);
476
- expect(existsSync(join(root, 'mx-agent-system/teams/newteam.md'))).toBe(true);
477
- expect(stdout.join('\n')).toContain('Team Created!');
478
- });
479
- it('says it is resuming, and does not create a second worktree', async () => {
480
- writeRoleguide();
481
- failAfter = 'claude-config';
482
- await provision();
483
- const before = readdirSync(join(root, '.worktrees')).filter((e) => !e.endsWith('.lock'));
484
- stdout = [];
485
- failAfter = null;
486
- const second = await provision();
487
- expect(second.failure).toBeNull();
488
- expect(stdout.join('\n')).toContain('Resuming the provisioning of newteam');
489
- expect(readdirSync(join(root, '.worktrees')).filter((e) => !e.endsWith('.lock'))).toEqual(before);
490
- expect(createGitWorktree).toHaveBeenCalledTimes(1);
491
- });
492
- it('leaves no provision lock behind on a failed run', async () => {
493
- writeRoleguide();
494
- failAfter = 'memories';
495
- await provision();
496
- expect(existsSync(provisionLockPath(join(root, WORKTREE_REL)))).toBe(false);
497
- });
498
- });
499
- // ── Change A: the identity check ─────────────────────────────────────────────
500
- describe('the resume identity check refuses a worktree this run does not own', () => {
501
- it('refuses when the worktree names another team, and prints both names', async () => {
502
- writeRoleguide();
503
- failAfter = 'claude-config';
504
- await provision();
505
- // Another team's scope file at the same path: the state a slug collision or a
506
- // recycled directory produces.
507
- writeFileSync(join(root, WORKTREE_REL, '.mx-code-context.json'), JSON.stringify({ product: 'mx-agent', service: 'team-provisioning', team: 'otherteam', role: 'team-lead' }));
508
- stdout = [];
509
- failAfter = null;
510
- const second = await provision();
511
- expect(second.failure).toBeInstanceOf(ResumeIdentityError);
512
- expect(second.failure.message).toContain('otherteam');
513
- expect(second.failure.message).toContain('newteam');
514
- // NO WRITE on a mismatch.
515
- expect(standingMemories.size).toBe(0);
516
- expect(existsSync(join(root, 'mx-agent-system/teams/newteam.md'))).toBe(false);
517
- expect(existsSync(provisionLockPath(join(root, WORKTREE_REL)))).toBe(false);
518
- });
519
- it('refuses the same --name provisioned from a different roleguide, naming both', async () => {
520
- writeRoleguide();
521
- // Cut AFTER step 6: `CLAUDE.local.md` is what records which roleguide the
522
- // worktree was provisioned from, and a run cut before it leaves a worktree
523
- // that names nothing, which is `unestablished` rather than a mismatch.
524
- failAfter = 'memories';
525
- await provision();
526
- const other = 'mx-agent-system/roleguides/newteam-rewrite.md';
527
- mkdirSync(dirname(join(root, other)), { recursive: true });
528
- writeFileSync(join(root, other), roleguideText('newteam', configuredProjectSlug));
529
- stdout = [];
530
- failAfter = null;
531
- const seededByRunOne = new Map(standingMemories);
532
- const second = await provision({ roleguide: other });
533
- expect(second.failure).toBeInstanceOf(ResumeIdentityError);
534
- expect(second.failure.message).toContain('newteam-leader.md');
535
- expect(second.failure.message).toContain('newteam-rewrite.md');
536
- // NO WRITE on a mismatch: what run 1 left is exactly what is there.
537
- expect(standingMemories).toEqual(seededByRunOne);
538
- expect(existsSync(join(root, 'mx-agent-system/teams/newteam.md'))).toBe(false);
539
- });
540
- it('resumes a worktree whose scope file names this team', async () => {
541
- writeRoleguide();
542
- failAfter = 'memories';
543
- await provision();
544
- expect(JSON.parse(readFileSync(join(root, WORKTREE_REL, '.mx-code-context.json'), 'utf-8')).team).toBe('newteam');
545
- stdout = [];
546
- failAfter = null;
547
- const second = await provision();
548
- expect(second.failure).toBeNull();
549
- expect(stdout.join('\n')).toContain('names team "newteam"');
550
- });
551
- // The verdict function itself, so each branch is pinned without a fixture.
552
- it('reads three verdicts, not two', () => {
553
- expect(checkResumeIdentity({
554
- worktree: { team: null, product: null, roleguide: null },
555
- runTeam: 'a', runProduct: 'p', runRoleguide: 'x.md',
556
- }).kind).toBe('unestablished');
557
- expect(checkResumeIdentity({
558
- worktree: { team: 'a', product: 'p', roleguide: 'dir/x.md' },
559
- runTeam: 'a', runProduct: 'p', runRoleguide: './dir/x.md',
560
- }).kind).toBe('match');
561
- expect(checkResumeIdentity({
562
- worktree: { team: 'a', product: 'other', roleguide: null },
563
- runTeam: 'a', runProduct: 'p', runRoleguide: null,
564
- }).kind).toBe('mismatch');
565
- // A project that configures no slug has no identity to compare against.
566
- expect(checkResumeIdentity({
567
- worktree: { team: 'a', product: 'anything', roleguide: null },
568
- runTeam: 'a', runProduct: '', runRoleguide: null,
569
- }).kind).toBe('match');
570
- });
571
- });
572
- // ── Change A: the provision lock ─────────────────────────────────────────────
573
- describe('the provision lock refuses a concurrent run', () => {
574
- it('refuses while another live run holds it, and writes nothing', async () => {
575
- writeRoleguide();
576
- mkdirSync(join(root, WORKTREE_REL), { recursive: true });
577
- writeFileSync(join(root, WORKTREE_REL, '.git'), 'gitdir: /nowhere\n');
578
- // A lock recorded by a process that IS live: this one. It names this run's
579
- // team AND worktree, which is what makes it a run to wait for.
580
- writeFileSync(provisionLockPath(join(root, WORKTREE_REL)), JSON.stringify({
581
- team: 'newteam',
582
- worktreePath: join(root, WORKTREE_REL),
583
- pid: process.pid,
584
- startedAt: new Date().toISOString(),
585
- }));
586
- const { failure } = await provision();
587
- expect(failure).toBeTruthy();
588
- expect(failure.message).toContain('another provisioning run holds');
589
- expect(failure.message).toContain(String(process.pid));
590
- expect(standingMemories.size).toBe(0);
591
- });
592
- it('clears a lock whose owner is gone, rather than refusing for ever', () => {
593
- const worktree = join(root, WORKTREE_REL);
594
- mkdirSync(worktree, { recursive: true });
595
- // 2^22 is above every Linux pid_max default, so no process holds it.
596
- writeFileSync(provisionLockPath(worktree), JSON.stringify({
597
- team: 'newteam',
598
- worktreePath: worktree,
599
- pid: 4194304,
600
- startedAt: new Date().toISOString(),
601
- }));
602
- const claim = claimProvisionLock(worktree, 'newteam');
603
- expect(claim.ok).toBe(true);
604
- if (claim.ok)
605
- claim.release();
606
- expect(existsSync(provisionLockPath(worktree))).toBe(false);
607
- });
608
- it('is exclusive: the second claim of one path fails while the first is held', () => {
609
- const worktree = join(root, WORKTREE_REL);
610
- mkdirSync(worktree, { recursive: true });
611
- const first = claimProvisionLock(worktree, 'newteam');
612
- const second = claimProvisionLock(worktree, 'newteam');
613
- expect(first.ok).toBe(true);
614
- expect(second.ok).toBe(false);
615
- if (first.ok)
616
- first.release();
617
- });
618
- it('ages out a live pid rather than honouring it for ever', () => {
619
- // Security review round 2, Should Fix 4. pid 1 always exists and answers
620
- // EPERM, so it reads as live; the previous order returned on that before any
621
- // age was computed, and aging ran only when the pid was UNREADABLE. A record
622
- // naming pid 1 therefore refused every later run for this team for ever.
623
- const worktree = join(root, WORKTREE_REL);
624
- mkdirSync(worktree, { recursive: true });
625
- const lock = provisionLockPath(worktree);
626
- writeFileSync(lock, JSON.stringify({
627
- team: 'newteam',
628
- worktreePath: worktree,
629
- pid: 1,
630
- startedAt: new Date(Date.now() - 7 * 60 * 60 * 1000).toISOString(),
631
- }));
632
- // Older than the six-hour limit, set on the file itself: the age is read
633
- // from the filesystem, never from the record's own claim about its start.
634
- const old = new Date(Date.now() - 7 * 60 * 60 * 1000);
635
- utimesSync(lock, old, old);
636
- const claim = claimProvisionLock(worktree, 'newteam');
637
- expect(claim.ok).toBe(true);
638
- if (claim.ok)
639
- claim.release();
640
- });
641
- it('honours a fresh lock naming pid 1, so aging is the only thing that clears it', () => {
642
- const worktree = join(root, WORKTREE_REL);
643
- mkdirSync(worktree, { recursive: true });
644
- writeFileSync(provisionLockPath(worktree), JSON.stringify({
645
- team: 'newteam',
646
- worktreePath: worktree,
647
- pid: 1,
648
- startedAt: new Date().toISOString(),
649
- }));
650
- const claim = claimProvisionLock(worktree, 'newteam');
651
- expect(claim.ok).toBe(false);
652
- if (!claim.ok)
653
- expect(claim.detail).toContain('pid 1');
654
- });
655
- it('clears a lock that records another team, rather than waiting for it', () => {
656
- const worktree = join(root, WORKTREE_REL);
657
- mkdirSync(worktree, { recursive: true });
658
- writeFileSync(provisionLockPath(worktree), JSON.stringify({
659
- team: 'someone-else',
660
- worktreePath: '/somewhere/else',
661
- pid: process.pid,
662
- startedAt: new Date().toISOString(),
663
- }));
664
- const claim = claimProvisionLock(worktree, 'newteam');
665
- expect(claim.ok).toBe(true);
666
- if (claim.ok)
667
- claim.release();
668
- });
669
- it('does not read a symlink planted at the lock path', () => {
670
- // Red-team round 2, finding 2. The create and the release were already safe;
671
- // the READ was not, so a link would have supplied the record and the mtime
672
- // this decision rests on.
673
- const worktree = join(root, WORKTREE_REL);
674
- mkdirSync(worktree, { recursive: true });
675
- const target = join(root, 'planted-lock-target');
676
- writeFileSync(target, JSON.stringify({
677
- team: 'newteam',
678
- worktreePath: worktree,
679
- pid: process.pid,
680
- startedAt: new Date().toISOString(),
681
- }));
682
- symlinkSync(target, provisionLockPath(worktree));
683
- const claim = claimProvisionLock(worktree, 'newteam');
684
- // Taken, not refused: a link records no run to wait for.
685
- expect(claim.ok).toBe(true);
686
- expect(lstatSync(provisionLockPath(worktree)).isSymbolicLink()).toBe(false);
687
- // The file the link pointed at is untouched.
688
- expect(JSON.parse(readFileSync(target, 'utf-8')).team).toBe('newteam');
689
- if (claim.ok)
690
- claim.release();
691
- });
692
- it('releases the lock on a clean run', async () => {
693
- writeRoleguide();
694
- const { failure } = await provision();
695
- expect(failure).toBeNull();
696
- expect(existsSync(provisionLockPath(join(root, WORKTREE_REL)))).toBe(false);
697
- });
698
- });
699
- // ── Change B: one credential across two resumes ──────────────────────────────
700
- describe('row 10 mints once, however many times the run resumes', () => {
701
- it('two resumes against a stubbed service fetch exactly one credential', async () => {
702
- writeRoleguide();
703
- failAfter = 'memories';
704
- await provision();
705
- expect(credentialFetches).toBe(0); // the run never reached row 10
706
- failAfter = null;
707
- await provision();
708
- expect(credentialFetches).toBe(1);
709
- stdout = [];
710
- await provision();
711
- expect(credentialFetches).toBe(1);
712
- expect(rowLines()[10]).toMatch(/row 10: asserted/);
713
- // WHAT WAS READ, not who wrote it (security review round 2, Should Fix 1).
714
- expect(rowLines()[10]).toContain('a file is present at');
715
- expect(rowLines()[10]).toContain('mode 0600');
716
- expect(rowLines()[10]).toContain('did not check who wrote it');
717
- // One cache file, holding what the first fetch wrote.
718
- const cache = join(root, WORKTREE_REL, '.mx-coordination-token--mx-agent--newteam');
719
- expect(readFileSync(cache, 'utf-8')).toBe('stub-token-1');
720
- expect(statSync(cache).mode & 0o777).toBe(0o600);
721
- });
722
- });
723
- // ── Row 12 on a resume: probe with the cache, re-mint only on 401 (v41) ──────
724
- //
725
- // Amendment 1 to the v41 plan on #15 (comment 6135584856), Must Fix 2 and Should
726
- // Fix 2: a re-provision re-uses a usable 0600 cache, probes with it, and mints
727
- // only when the probe answers 401. The re-mint writes the cache only after the
728
- // service issued a token (bar-raiser Step 4 condition R1).
729
- describe('row 12 on a resume (v41)', () => {
730
- const cache = () => join(root, WORKTREE_REL, '.mx-coordination-token--mx-agent--newteam');
731
- it('probes with the cached token and does not mint when the probe answers 200', async () => {
732
- writeRoleguide();
733
- await provision();
734
- expect(credentialFetches).toBe(1);
735
- stdout = [];
736
- obligationsCalls = [];
737
- const { failure } = await provision();
738
- expect(failure).toBeNull();
739
- expect(credentialFetches).toBe(1);
740
- expect(obligationsCalls.map((c) => c.token)).toEqual(['stub-token-1']);
741
- expect(rowLines()[12]).toMatch(/row 12: asserted/);
742
- });
743
- it('a cached token answered 401 is re-minted once, the new cache is probed, and the run finishes', async () => {
744
- writeRoleguide();
745
- await provision();
746
- stdout = [];
747
- obligationsCalls = [];
748
- obligationsAnswers = [401, 200];
749
- const { failure } = await provision();
750
- expect(failure).toBeNull();
751
- expect(credentialFetches).toBe(2);
752
- expect(obligationsCalls.map((c) => c.token)).toEqual(['stub-token-1', 'stub-token-2']);
753
- // The probe and the re-mint asked the same service the first mint used.
754
- expect(obligationsCalls.map((c) => c.url)).toEqual(['http://127.0.0.1:9', 'http://127.0.0.1:9']);
755
- expect(credentialServiceUrls).toEqual(['http://127.0.0.1:9', 'http://127.0.0.1:9', 'http://127.0.0.1:9']);
756
- expect(readFileSync(cache(), 'utf-8')).toBe('stub-token-2');
757
- expect(statSync(cache()).mode & 0o777).toBe(0o600);
758
- expect(rowLines()[12]).toMatch(/row 12: asserted/);
759
- expect(stdout.join('\n')).toContain('Team Created!');
760
- });
761
- it('a re-mint the service refuses leaves the old cache byte for byte, and the run fails on row 12 (R1)', async () => {
762
- writeRoleguide();
763
- await provision();
764
- const before = readFileSync(cache());
765
- const modeBefore = statSync(cache()).mode & 0o777;
766
- stdout = [];
767
- obligationsCalls = [];
768
- obligationsAnswers = [401];
769
- credentialRefuseNext = true;
770
- const { failure } = await provision();
771
- expect(failure).toBeInstanceOf(CompletionCheckError);
772
- expect(failure.message).toContain('row 12:');
773
- expect(stdout.join('\n')).not.toContain('Team Created!');
774
- expect(readFileSync(cache()).equals(before)).toBe(true);
775
- expect(statSync(cache()).mode & 0o777).toBe(modeBefore);
776
- expect(obligationsCalls).toHaveLength(1);
777
- });
778
- });
779
- describe('row 12 on a resume: an issued re-mint whose cache write fails (N-1)', () => {
780
- it('row 10 reports the write failure instead of the removed cache, and the run fails', async () => {
781
- writeRoleguide();
782
- await provision();
783
- const cache = join(root, WORKTREE_REL, '.mx-coordination-token--mx-agent--newteam');
784
- stdout = [];
785
- obligationsCalls = [];
786
- obligationsAnswers = [401];
787
- failRemintWrite = true;
788
- const { failure } = await provision();
789
- expect(credentialFetches).toBe(2);
790
- expect(existsSync(cache)).toBe(false);
791
- expect(failure).toBeInstanceOf(CompletionCheckError);
792
- expect(stdout.join('\n')).not.toContain('Team Created!');
793
- expect(rowLines()[10]).toMatch(/row 10: could not run/);
794
- expect(rowLines()[10]).toContain('could not be written');
795
- expect(rowLines()[10]).not.toContain('a file is present at');
796
- expect(rowLines()[12]).toMatch(/row 12: not asserted/);
797
- expect(obligationsCalls).toHaveLength(1);
798
- });
799
- });
800
- // ── Row 12's mode at the two callers that do not probe (condition R2) ────────
801
- describe('row 12 is not probed by --recheck or after a failed step (R2)', () => {
802
- it('--recheck on a credential-endpoint team exits 0 with row 12 not run, and makes no request', async () => {
803
- writeRoleguide();
804
- await provision();
805
- stdout = [];
806
- obligationsCalls = [];
807
- const { failure } = await provision({ recheck: true });
808
- expect(failure).toBeNull();
809
- expect(obligationsCalls).toHaveLength(0);
810
- expect(rowLines()[12]).toMatch(/row 12: not asserted/);
811
- expect(rowLines()[12]).toContain('not run: --recheck does not contact the coordination service');
812
- });
813
- it('a step that fails after the worktree exists prints row 12 as stopped before the probe', async () => {
814
- writeRoleguide();
815
- failAfter = 'catalog';
816
- const { failure } = await provision();
817
- expect(failure).toBeInstanceOf(CompletionCheckError);
818
- expect(obligationsCalls).toHaveLength(0);
819
- expect(rowLines()[12]).toContain('not run: provision stopped before the probe');
820
- // Not listed among the failed rows: the step that stopped provision is the failure.
821
- expect(failure.message).not.toMatch(/row 12: the new team/);
822
- });
823
- });
824
- // ── #607 (b): --recheck reads rows 9 and 10 through the same helper ──────────
825
- describe('--recheck reads the roster through the helper provisioning uses (#607)', () => {
826
- it('with zero remotes it reads refs/heads/<base>, as the provisioning run did', async () => {
827
- writeRoleguide();
828
- await provision();
829
- vi.mocked(rosterEntryOnRef).mockClear();
830
- stdout = [];
831
- await provision({ recheck: true });
832
- expect(vi.mocked(rosterEntryOnRef)).toHaveBeenCalled();
833
- for (const call of vi.mocked(rosterEntryOnRef).mock.calls) {
834
- expect(call[2]).toMatchObject({ localBase: true, baseBranch: 'main' });
835
- }
836
- expect(rowLines()[9]).toContain('refs/heads/main');
837
- expect(rowLines()[9]).not.toContain('origin/main');
838
- });
839
- it('with an origin it keeps the origin/<base> read', async () => {
840
- writeRoleguide();
841
- await provision();
842
- // The remote appears after the team was provisioned, as `new project
843
- // --with-remote` adds it. The re-check reads `git remote` itself.
844
- hasOrigin = true;
845
- vi.mocked(rosterEntryOnRef).mockClear();
846
- stdout = [];
847
- await provision({ recheck: true });
848
- expect(vi.mocked(rosterEntryOnRef)).toHaveBeenCalled();
849
- expect(rowLines()[9]).toContain('origin/main');
850
- for (const call of vi.mocked(rosterEntryOnRef).mock.calls) {
851
- expect(call[2]).toMatchObject({ localBase: false });
852
- }
853
- });
854
- });
855
- // ── Change B: standing memories, and finding 7's `present, stale` ────────────
856
- describe('a standing memory this team owns asserts its row', () => {
857
- it('asserts rows 3 to 5 on a resume that finds the three already seeded', async () => {
858
- writeRoleguide();
859
- failAfter = 'catalog';
860
- await provision();
861
- expect(standingMemories.size).toBe(3);
862
- stdout = [];
863
- failAfter = null;
864
- const second = await provision();
865
- expect(second.failure).toBeNull();
866
- for (const n of [3, 4, 5])
867
- expect(rowLines()[n]).toMatch(/row \d: asserted/);
868
- expect(rowLines()[3]).toContain('seeded by an earlier run of this team');
869
- });
870
- it('prints no memory warning and no manual commands on that same resume (#471)', async () => {
871
- // THE DEFECT, in one run: rows 3 to 5 asserted, and the same run told the
872
- // operator the three memories had failed to initialise and handed over three
873
- // `mx memories create --name` commands. Those commands UPSERT
874
- // (memnexus#5485), so an operator who followed the instruction the command
875
- // had just given them replaced the three memories the rows had just verified.
876
- writeRoleguide();
877
- failAfter = 'catalog';
878
- await provision();
879
- expect(standingMemories.size).toBe(3);
880
- const { logWarning } = await import('../lib/claude.js');
881
- const { logManualMemoryCommands } = await import('../lib/memory.js');
882
- // Run 1's calls are not run 2's evidence.
883
- vi.mocked(logWarning).mockClear();
884
- vi.mocked(logManualMemoryCommands).mockClear();
885
- stdout = [];
886
- failAfter = null;
887
- const second = await provision();
888
- expect(second.failure).toBeNull();
889
- for (const n of [3, 4, 5])
890
- expect(rowLines()[n]).toMatch(/row \d: asserted/);
891
- const warnings = vi.mocked(logWarning).mock.calls.map((c) => String(c[0]));
892
- expect(warnings.filter((w) => /memor/i.test(w))).toEqual([]);
893
- expect(vi.mocked(logManualMemoryCommands)).not.toHaveBeenCalled();
894
- // The DoD checklist line reads the same flag, so it agrees with the rows too.
895
- expect(stdout.join('\n')).toContain('[✓] Named memories');
896
- expect(stdout.join('\n')).not.toContain('create manually');
897
- });
898
- it('still warns, but prints NO create command, when a standing memory is another team\'s (#471, #493)', async () => {
899
- // The other half of the #471 fix. A name held by a memory this team does not
900
- // own is not "present and usable": row 4 stays red, and the warning has to
901
- // stay with it. A fix that suppressed the warning whenever a name was taken
902
- // would silence exactly this run.
903
- //
904
- // This test used to require the manual create commands here too. #493 (plan
905
- // #494 amendment 1) removes them: `mx memories create --name` is an upsert,
906
- // so the command overwrote the other team's memory. The warning stays; the
907
- // command does not.
908
- writeRoleguide();
909
- failAfter = 'catalog';
910
- await provision();
911
- const held = standingMemories.get(MEMORY_NAMES[1]);
912
- standingMemories.set(MEMORY_NAMES[1], {
913
- ...held,
914
- codeContext: { product: 'mx-agent', service: 'team-provisioning', team: 'someone-else', role: 'team-lead' },
915
- });
916
- const { logWarning } = await import('../lib/claude.js');
917
- const { logManualMemoryCommands } = await import('../lib/memory.js');
918
- vi.mocked(logWarning).mockClear();
919
- vi.mocked(logManualMemoryCommands).mockClear();
920
- stdout = [];
921
- failAfter = null;
922
- const second = await provision();
923
- expect(second.failure).toBeInstanceOf(CompletionCheckError);
924
- expect(rowLines()[4]).toMatch(/row 4: not asserted/);
925
- const warnings = vi.mocked(logWarning).mock.calls.map((c) => String(c[0]));
926
- expect(warnings.some((w) => w.includes('Some team memories are not there'))).toBe(true);
927
- expect(warnings.some((w) => w.includes('Create them manually'))).toBe(false);
928
- expect(vi.mocked(logManualMemoryCommands)).not.toHaveBeenCalled();
929
- });
930
- it('reads `present, stale` when the seed differs from what this run would write', async () => {
931
- writeRoleguide();
932
- failAfter = 'catalog';
933
- await provision();
934
- // The Linkage line names another catalog entry: the shape a team whose
935
- // catalog path changed between the two runs leaves behind.
936
- const held = standingMemories.get(MEMORY_NAMES[0]);
937
- standingMemories.set(MEMORY_NAMES[0], {
938
- ...held,
939
- content: held.content.replace(/- Linkage: .*/, '- Linkage: mx-agent-system/teams/old.md, old.md'),
940
- });
941
- stdout = [];
942
- failAfter = null;
943
- const second = await provision();
944
- expect(second.failure).toBeNull();
945
- expect(rowLines()[3]).toContain('present, stale');
946
- expect(rowLines()[3]).toContain('Linkage');
947
- // ASSERTED, and told apart from a row this run wrote (#316 review round 2,
948
- // red-team finding 3). The verdict word is its own, and a line above the
949
- // table names the row, because a yellow verdict fifteen rows down on a run
950
- // that exits 0 is easy to read past.
951
- expect(rowLines()[3]).toMatch(/row 3: asserted, stale/);
952
- expect(rowLines()[3]).not.toContain('asserted (shape)');
953
- expect(stdout.join('\n')).toContain('1 row present but stale: row 3');
954
- expect(stdout.join('\n')).toContain('nothing was overwritten');
955
- });
956
- it('names every stale row in the summary line, memories and catalog together', async () => {
957
- writeRoleguide();
958
- failAfter = 'catalog';
959
- await provision();
960
- const held = standingMemories.get(MEMORY_NAMES[0]);
961
- standingMemories.set(MEMORY_NAMES[0], {
962
- ...held,
963
- content: held.content.replace(/- Linkage: .*/, '- Linkage: teams/old.md, old.md'),
964
- });
965
- // The catalog entry gets the same comparison as the memories, instead of an
966
- // existence check that reads identical for an entry nobody wrote this run.
967
- const entry = join(root, 'mx-agent-system/teams/newteam.md');
968
- writeFileSync(entry, `${readFileSync(entry, 'utf-8')}\n## Goal\n\nEdited by a person.\n`);
969
- stdout = [];
970
- failAfter = null;
971
- const second = await provision();
972
- expect(second.failure).toBeNull();
973
- expect(rowLines()[2]).toMatch(/row 2: asserted, stale/);
974
- expect(rowLines()[2]).toContain('differs from what this run would write');
975
- expect(stdout.join('\n')).toContain('2 rows present but stale: row 2, row 3');
976
- });
977
- it('leaves row 2 green when the entry is what this run would write', async () => {
978
- writeRoleguide();
979
- failAfter = 'catalog';
980
- await provision();
981
- stdout = [];
982
- failAfter = null;
983
- const second = await provision();
984
- expect(second.failure).toBeNull();
985
- expect(rowLines()[2]).toMatch(/row 2: asserted /);
986
- expect(rowLines()[2]).not.toContain('stale');
987
- });
988
- it('keeps a memory that belongs to another team red, on a resume as on a first run', async () => {
989
- writeRoleguide();
990
- failAfter = 'catalog';
991
- await provision();
992
- const held = standingMemories.get(MEMORY_NAMES[1]);
993
- standingMemories.set(MEMORY_NAMES[1], {
994
- ...held,
995
- codeContext: { product: 'mx-agent', service: 'team-provisioning', team: 'someone-else', role: 'team-lead' },
996
- });
997
- stdout = [];
998
- failAfter = null;
999
- const second = await provision();
1000
- expect(second.failure).toBeInstanceOf(CompletionCheckError);
1001
- expect(rowLines()[4]).toMatch(/row 4: not asserted/);
1002
- expect(rowLines()[4]).toContain('another team');
1003
- });
1004
- it('holds for the two present states and for no other one (#471)', () => {
1005
- // WHAT THE PREDICATE EXCLUDES, pinned. `memoryStateHolds` gates rows 3 to 5
1006
- // and, since #471, the `memoriesOk` flag behind the warning and the DoD
1007
- // checklist line. Nothing failed when the predicate was widened to accept
1008
- // `malformed` and `could-not-run`: a security review mutated it to
1009
- // `presence !== 'not-this-team'` and the whole suite still passed, which this
1010
- // lead reproduced before adding this test.
1011
- //
1012
- // What that widening would print is the defect #471 fixes, pointing the other
1013
- // way. `create.ts:3619` reads `!row.asserted && row.couldNotRun === true`, so
1014
- // an asserted row never reaches the could-not-run branch, and a memory nobody
1015
- // could read would print a green row and a green `[✓] Named memories` line.
1016
- //
1017
- // ASSERTED ON THE PREDICATE, not on a rendered row, so it stays true if the
1018
- // printer changes. `Record<MemoryPresence, boolean>` is exhaustive at compile
1019
- // time: a sixth state added to the union fails `tsc` here until someone says
1020
- // which way it goes.
1021
- const expected = {
1022
- present: true,
1023
- 'present-stale': true,
1024
- 'not-this-team': false,
1025
- malformed: false,
1026
- 'could-not-run': false,
1027
- };
1028
- for (const [presence, holds] of Object.entries(expected)) {
1029
- expect([presence, memoryStateHolds(presence)]).toEqual([presence, holds]);
1030
- }
1031
- });
1032
- // ── The row builder's CALL to the predicate, pinned through rendered rows (#478) ──
1033
- //
1034
- // The test above pins `memoryStateHolds`. It does not pin that the row builder
1035
- // still asks it: a security review replaced the call at `create.ts:2867` with
1036
- // `standing.presence !== 'not-this-team'`, left the predicate correct, and the
1037
- // whole suite passed (#478). Under that edit a `malformed` or `could-not-run`
1038
- // memory prints an asserted row, because the printer reads
1039
- // `!row.asserted && row.couldNotRun === true` and an asserted row never reaches
1040
- // the could-not-run branch.
1041
- //
1042
- // These drive the `standing` branch through `runCreate` and assert the PRINTED
1043
- // row, so the edit above fails here. The two states render differently, and
1044
- // each is pinned to its own word: `could-not-run` prints `could not run`, and
1045
- // `malformed` prints `not asserted`, which is what the fresh-creation path
1046
- // prints for a malformed leftover too. Neither prints `asserted`.
1047
- it('prints a malformed standing memory not asserted on a resume, never asserted (#478)', async () => {
1048
- writeRoleguide();
1049
- failAfter = 'catalog';
1050
- await provision();
1051
- // This team's memory, with its seed reduced to one flat sentence: the #6
1052
- // shape `mx-agent window` reads as `unknown`. Ownership still reads
1053
- // `this-team`, so the classification is `malformed`, not `not-this-team`.
1054
- const held = standingMemories.get(MEMORY_NAMES[0]);
1055
- standingMemories.set(MEMORY_NAMES[0], { ...held, content: 'Leader state for newteam.' });
1056
- stdout = [];
1057
- failAfter = null;
1058
- const second = await provision();
1059
- // The row first: under the #478 edit this is the line that reads `asserted`.
1060
- expect(rowLines()[3]).toMatch(/row 3: not asserted/);
1061
- expect(rowLines()[3]).toContain('pre-existing and malformed');
1062
- expect(rowLines()[3]).not.toMatch(/row 3: asserted/);
1063
- expect(second.failure).toBeInstanceOf(CompletionCheckError);
1064
- // The two untouched memories still assert, so the fixture reached the branch.
1065
- for (const n of [4, 5])
1066
- expect(rowLines()[n]).toMatch(/row \d: asserted/);
1067
- expect(stdout.join('\n')).not.toContain('[✓] Named memories');
1068
- });
1069
- it('prints a standing memory nobody could read as could not run on a resume, never asserted (#478)', async () => {
1070
- writeRoleguide();
1071
- failAfter = 'catalog';
1072
- await provision();
1073
- expect(standingMemories.size).toBe(3);
1074
- // The probe found the name taken but brought back no content, which
1075
- // `memoryPresenceState` classifies `could-not-run` (`read: null`).
1076
- unreadableMemories.add(MEMORY_NAMES[2]);
1077
- stdout = [];
1078
- failAfter = null;
1079
- const second = await provision();
1080
- expect(rowLines()[5]).toMatch(/row 5: could not run/);
1081
- expect(rowLines()[5]).toContain('could not read the standing memory');
1082
- expect(rowLines()[5]).not.toMatch(/row 5: asserted/);
1083
- expect(second.failure).toBeInstanceOf(CompletionCheckError);
1084
- for (const n of [3, 4])
1085
- expect(rowLines()[n]).toMatch(/row \d: asserted/);
1086
- expect(stdout.join('\n')).not.toContain('[✓] Named memories');
1087
- });
1088
- it('prints a memory --recheck could not read as could not run, never asserted (#478)', async () => {
1089
- writeRoleguide();
1090
- await provision();
1091
- // `--recheck` reads each name itself. An `unknown` read, the status for a
1092
- // backend that could not be asked, classifies `could-not-run`.
1093
- unreadableMemories.add(MEMORY_NAMES[1]);
1094
- stdout = [];
1095
- const { failure } = await provision({ recheck: true });
1096
- expect(rowLines()[4]).toMatch(/row 4: could not run/);
1097
- expect(rowLines()[4]).toContain('could not read');
1098
- expect(rowLines()[4]).not.toMatch(/row 4: asserted/);
1099
- expect(failure).toBeInstanceOf(CompletionCheckError);
1100
- for (const n of [3, 5])
1101
- expect(rowLines()[n]).toMatch(/row \d: asserted/);
1102
- });
1103
- it('classifies the five states without a fixture', () => {
1104
- const expected = {
1105
- codeContext: { product: 'p', service: 'team-provisioning', team: 't', role: 'team-lead' },
1106
- content: '- Linkage: teams/t.md, roleguides/t.md\n',
1107
- };
1108
- const base = { name: 'p-t-leader-state', leaderState: true, requireProduct: true, expected };
1109
- expect(memoryPresenceState({ ...base, read: null, ownership: 'this-team' }).presence).toBe('could-not-run');
1110
- expect(memoryPresenceState({
1111
- ...base,
1112
- read: { content: expected.content, codeContext: expected.codeContext },
1113
- ownership: 'not-this-team',
1114
- }).presence).toBe('not-this-team');
1115
- expect(memoryPresenceState({
1116
- ...base,
1117
- read: { content: expected.content, codeContext: expected.codeContext },
1118
- ownership: 'unconfirmed',
1119
- }).presence).toBe('not-this-team');
1120
- });
1121
- });
1122
- // ── Change B: finding 8, the catalog entry is terminal ───────────────────────
1123
- describe('a resume leaves the catalog entry byte for byte', () => {
1124
- it('does not rewrite an entry edited between the two runs', async () => {
1125
- writeRoleguide();
1126
- failAfter = 'catalog';
1127
- await provision();
1128
- const entry = join(root, 'mx-agent-system/teams/newteam.md');
1129
- expect(existsSync(entry)).toBe(true);
1130
- const edited = `${readFileSync(entry, 'utf-8')}\n## Goal\n\nWritten by a person between the two runs.\n`;
1131
- writeFileSync(entry, edited);
1132
- failAfter = null;
1133
- const second = await provision();
1134
- expect(second.failure).toBeNull();
1135
- expect(readFileSync(entry, 'utf-8')).toBe(edited);
1136
- });
1137
- });
1138
- // ── Change D: `--recheck` ────────────────────────────────────────────────────
1139
- describe('--recheck reads the rows and writes nothing', () => {
1140
- it('changes no byte under the project root', async () => {
1141
- writeRoleguide();
1142
- await provision();
1143
- const before = snapshot(root);
1144
- stdout = [];
1145
- const { failure } = await provision({ recheck: true });
1146
- expect(failure).toBeNull();
1147
- const after = snapshot(root);
1148
- expect([...after.keys()].sort()).toEqual([...before.keys()].sort());
1149
- for (const [path, bytes] of before)
1150
- expect(after.get(path)).toBe(bytes);
1151
- });
1152
- it('prints the sixteen rows and asserts the ones a finished team holds', async () => {
1153
- writeRoleguide();
1154
- await provision();
1155
- stdout = [];
1156
- const { failure } = await provision({ recheck: true });
1157
- expect(failure).toBeNull();
1158
- expect(rowLines()).toHaveLength(16);
1159
- for (const n of [0, 1, 2, 3, 4, 5, 9, 10]) {
1160
- expect(rowLines()[n]).toMatch(/row \d+: asserted/);
1161
- }
1162
- expect(stdout.join('\n')).toContain('Nothing was written.');
1163
- });
1164
- it('states that row 10 was checked by cache presence only, and names what mints', async () => {
1165
- writeRoleguide();
1166
- await provision();
1167
- stdout = [];
1168
- await provision({ recheck: true });
1169
- expect(rowLines()[10]).toContain('checked by cache presence only');
1170
- expect(rowLines()[10]).toContain('mx-agent provision');
1171
- expect(rowLines()[10]).toContain('mints');
1172
- });
1173
- it('says so, and asks for no credential, when the cache is not there', async () => {
1174
- writeRoleguide();
1175
- await provision();
1176
- rmSync(join(root, WORKTREE_REL, '.mx-coordination-token--mx-agent--newteam'));
1177
- const fetchesBefore = credentialFetches;
1178
- stdout = [];
1179
- const { failure } = await provision({ recheck: true });
1180
- expect(failure).toBeInstanceOf(CompletionCheckError);
1181
- expect(credentialFetches).toBe(fetchesBefore);
1182
- expect(rowLines()[10]).toContain('no credential cache');
1183
- expect(rowLines()[10]).toContain('checked by cache presence only');
1184
- });
1185
- it('refuses when there is no worktree to check', async () => {
1186
- const { failure } = await provision({ recheck: true });
1187
- expect(failure).toBeInstanceOf(CompletionCheckError);
1188
- expect(failure.message).toContain('no worktree');
1189
- });
1190
- });
1191
- // ── Row 7's path, at the two sites that compute it (#406 part 1) ─────────────
1192
- //
1193
- // The row tests in `provision-completion-rows.test.ts` hand `checkCompletionRows`
1194
- // a `roleguideOnBasePath` and assert the row it produces. That proves the row
1195
- // discriminates. It proves NOTHING about the two call sites that compute the
1196
- // path, and a wrong basename, a wrong `roleguidesDir` join or a stale
1197
- // `roleguideRel` at either site would pass every one of those tests while row 7
1198
- // reported confidently about a different file on a live creation (red-team
1199
- // finding 2, #407 review round 1).
1200
- //
1201
- // These two run the real computation through `runCreate` and assert the exact
1202
- // string it produced. Nothing about row 7 is stubbed: the reader is the real
1203
- // one, wrapped only to record its arguments.
1204
- describe('row 7 is given the path the run computed, at both call sites', () => {
1205
- /**
1206
- * The path row 7 must be read at, in this platform's separator, and the
1207
- * `/`-separated git object path it becomes.
1208
- *
1209
- * Two forms because `join` is platform-dependent and a git object path is
1210
- * `/`-separated everywhere. Both are asserted: the first is the literal string
1211
- * the call site produced, the second is what the reader interpolates.
1212
- */
1213
- const EXPECTED = join('mx-agent-system', 'roleguides', 'newteam-leader.md');
1214
- const EXPECTED_GIT_PATH = 'mx-agent-system/roleguides/newteam-leader.md';
1215
- /** The path argument of every recorded call, in call order. */
1216
- function pathArgs() {
1217
- return vi.mocked(roleguideOnOriginMain).mock.calls.map((c) => c[1]);
1218
- }
1219
- it('provisioning passes the re-anchored copy destination, not the operator string', async () => {
1220
- writeRoleguide();
1221
- const { failure } = await provision();
1222
- expect(failure).toBeNull();
1223
- expect(pathArgs()).toEqual([EXPECTED]);
1224
- expect(pathArgs()[0].split(sep).join('/')).toBe(EXPECTED_GIT_PATH);
1225
- // The three ways the computation is wrong and the row still renders: a bare
1226
- // basename, an absolute path, and a path anchored inside the new worktree.
1227
- expect(pathArgs()[0]).not.toBe('newteam-leader.md');
1228
- expect(isAbsolute(pathArgs()[0])).toBe(false);
1229
- expect(pathArgs()[0]).not.toContain(WORKTREE_REL);
1230
- // The root and the ref options are the run's own, not defaults.
1231
- expect(vi.mocked(roleguideOnOriginMain).mock.calls[0][0]).toBe(root);
1232
- expect(vi.mocked(roleguideOnOriginMain).mock.calls[0][2])
1233
- .toEqual({ baseBranch: 'main', fetchOk: true });
1234
- });
1235
- it('a re-check reconstructs the same path row 1 reads, from the recorded roleguide', async () => {
1236
- writeRoleguide();
1237
- await provision();
1238
- vi.mocked(roleguideOnOriginMain).mockClear();
1239
- // No `--roleguide`: the path comes from the catalog entry or the worktree
1240
- // pointer, through `join(cfg.roleguidesDir, basename(roleguideRel))`. That
1241
- // is the expression this test exists to pin.
1242
- const { failure } = await provision({ recheck: true });
1243
- expect(failure).toBeNull();
1244
- expect(pathArgs()).toEqual([EXPECTED]);
1245
- expect(pathArgs()[0].split(sep).join('/')).toBe(EXPECTED_GIT_PATH);
1246
- expect(vi.mocked(roleguideOnOriginMain).mock.calls[0][0]).toBe(root);
1247
- expect(vi.mocked(roleguideOnOriginMain).mock.calls[0][2])
1248
- .toEqual({ baseBranch: 'main', fetchOk: true });
1249
- });
1250
- it('the two sites agree, so row 7 reports about one file across a provision and a re-check', async () => {
1251
- writeRoleguide();
1252
- await provision();
1253
- const fromProvision = pathArgs();
1254
- vi.mocked(roleguideOnOriginMain).mockClear();
1255
- await provision({ recheck: true });
1256
- expect(pathArgs()).toEqual(fromProvision);
1257
- });
1258
- });
1259
- // ── Change C: no process.exit in the window ──────────────────────────────────
1260
- describe('the window between the worktree and the pre-check has no process.exit', () => {
1261
- it('greps the span in the shipped source', () => {
1262
- const source = readFileSync(join(__dirname, '..', 'commands', 'create.ts'), 'utf-8');
1263
- const start = source.indexOf('createGitWorktree(worktreePath, branch, cfg.baseBranch, projectRoot)');
1264
- const end = source.indexOf('willRefuseAtRow13 = !row13AtGate.asserted;');
1265
- expect(start).toBeGreaterThan(0);
1266
- expect(end).toBeGreaterThan(start);
1267
- const span = source.slice(start, end);
1268
- // The CALL, not the words: the comments in this file name `process.exit` to
1269
- // say what the code no longer does.
1270
- expect(span).not.toContain('process.exit(');
1271
- });
1272
- it('has none anywhere in the durable half of the command', () => {
1273
- const source = readFileSync(join(__dirname, '..', 'commands', 'create.ts'), 'utf-8');
1274
- const start = source.indexOf('async function runProvisionSteps(');
1275
- const end = source.indexOf(' * Test-only surface for the two filesystem-containment helpers.');
1276
- expect(start).toBeGreaterThan(0);
1277
- expect(end).toBeGreaterThan(start);
1278
- expect(source.slice(start, end)).not.toContain('process.exit(');
1279
- });
1280
- });
1281
- // ── The fault-injection mechanism itself ─────────────────────────────────────
1282
- describe('fault injection is refused outside a test build', () => {
1283
- it('names the step and cuts the run in a test build', async () => {
1284
- writeRoleguide();
1285
- failAfter = 'catalog';
1286
- const { failure } = await provision();
1287
- expect(failure).toBeInstanceOf(CompletionCheckError);
1288
- expect(failure.message).toContain('catalog');
1289
- });
1290
- it('provisions normally when the variable names no known point', async () => {
1291
- writeRoleguide();
1292
- process.env.MX_PROVISION_FAIL_AFTER = 'not-a-step';
1293
- process.env.MX_PROVISION_FAULT_INJECTION = '1';
1294
- const { failure } = await provision();
1295
- expect(failure).toBeNull();
1296
- });
1297
- it('needs BOTH the test build and the arming variable', () => {
1298
- const { faultInjectionStep } = __testing;
1299
- const armed = { MX_PROVISION_FAIL_AFTER: 'worktree', MX_PROVISION_FAULT_INJECTION: '1' };
1300
- // Neither alone.
1301
- expect(faultInjectionStep({ ...armed, NODE_ENV: 'production' })).toBeNull();
1302
- expect(faultInjectionStep({ MX_PROVISION_FAIL_AFTER: 'worktree', NODE_ENV: 'test' })).toBeNull();
1303
- // Both.
1304
- expect(faultInjectionStep({ ...armed, NODE_ENV: 'test' })).toBe('worktree');
1305
- expect(faultInjectionStep({})).toBeNull();
1306
- });
1307
- it('refuses a credential fault point against a service that is not on this host', async () => {
1308
- // Security review round 2, Should Fix 2. The point reaches a real mint, so a
1309
- // non-loopback service would spend a token per run and leave it unrevoked.
1310
- const { isLoopbackServiceUrl } = __testing;
1311
- expect(isLoopbackServiceUrl('http://127.0.0.1:9')).toBe(true);
1312
- expect(isLoopbackServiceUrl('http://localhost:8080/x')).toBe(true);
1313
- expect(isLoopbackServiceUrl('https://coordination.example.invalid')).toBe(false);
1314
- expect(isLoopbackServiceUrl(undefined)).toBe(false);
1315
- expect(isLoopbackServiceUrl('not a url')).toBe(false);
1316
- });
1317
- it('hands the mint the URL the gate checked, not one the callee re-resolves', async () => {
1318
- // Security re-check round 3. The gate reads the URL resolved from
1319
- // `projectRoot`; `obtainCredential` resolves its own with no root, which
1320
- // derives one from the current directory. Two answers, and this fixture's
1321
- // resolver gives a different one to each caller, so a run that let the callee
1322
- // re-resolve would send the request to URL_FROM_CWD while the gate cleared a
1323
- // loopback stub.
1324
- writeRoleguide();
1325
- const { failure } = await provision();
1326
- expect(failure).toBeNull();
1327
- expect(credentialServiceUrls).toEqual(['http://127.0.0.1:9']);
1328
- expect(credentialServiceUrls[0]).not.toBe(URL_FROM_CWD);
1329
- });
1330
- it('refuses the injected mint when the project resolves a service off this host', async () => {
1331
- writeRoleguide();
1332
- // The project's own URL is remote. The gate must fire on THAT, which is the
1333
- // URL the request now carries.
1334
- urlFromProjectRoot = 'https://coordination.example.invalid';
1335
- failAfter = 'credential-cache-write-once';
1336
- const { failure } = await provision();
1337
- expect(failure).toBeInstanceOf(CompletionCheckError);
1338
- expect(failure.message).toContain('loopback');
1339
- // Nothing was asked of any service.
1340
- expect(credentialServiceUrls).toEqual([]);
1341
- expect(credentialFetches).toBe(0);
1342
- });
1343
- });
1344
- //# sourceMappingURL=provision-resume.test.js.map