@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,919 +0,0 @@
1
- /**
2
- * Hardening and review-fix coverage for #172, at review round 2.
3
- *
4
- * Security review Must Fix 1 (audit write target), Must Fix 2 (staged content
5
- * dropped by the checkpoint), red-team Findings 1 (crash durability), 2
6
- * (restore), 3 (squash-point ancestry), 4 (the uncovered step-7 window) and 6
7
- * (conflict told apart from failure).
8
- *
9
- * Every scenario uses a scratch fixture under `os.tmpdir()`. Nothing here runs
10
- * against this repository or any worktree of it.
11
- */
12
- import { execFileSync, spawnSync } from 'node:child_process';
13
- import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, symlinkSync, writeFileSync, appendFileSync } from 'node:fs';
14
- import { tmpdir } from 'node:os';
15
- import path from 'node:path';
16
- import { afterAll, describe, it, expect } from 'vitest';
17
- import { appendAuditLine, auditLogPath, createCheckpoint, defaultExecFile, findSquashPoint, restoreCheckpoint, runWorktreeSyncCore, OID_RE, } from '../lib/worktree-sync.js';
18
- const ROOTS = [];
19
- afterAll(() => {
20
- for (const r of ROOTS) {
21
- try {
22
- rmSync(r, { recursive: true, force: true });
23
- }
24
- catch {
25
- /* leftover tmp dir */
26
- }
27
- }
28
- });
29
- function git(cwd, args, env) {
30
- return execFileSync('git', args, {
31
- cwd,
32
- encoding: 'utf-8',
33
- env: { ...process.env, ...env },
34
- stdio: ['ignore', 'pipe', 'pipe'],
35
- }).toString();
36
- }
37
- function makeFixture(label) {
38
- const root = mkdtempSync(path.join(tmpdir(), `mx-hard-${label}-`));
39
- ROOTS.push(root);
40
- const origin = path.join(root, 'origin');
41
- const wt = path.join(root, 'wt');
42
- const home = path.join(root, 'home');
43
- mkdirSync(home, { recursive: true });
44
- git(root, ['init', '-q', '--initial-branch=main', origin]);
45
- git(origin, ['config', 'user.email', 'fixture@example.invalid']);
46
- git(origin, ['config', 'user.name', 'Fixture']);
47
- writeFileSync(path.join(origin, 'base.txt'), 'v0-committed\n');
48
- writeFileSync(path.join(origin, 'other.txt'), 'other\n');
49
- git(origin, ['add', '-A']);
50
- git(origin, ['commit', '-qm', 'base']);
51
- git(root, ['clone', '-q', origin, wt]);
52
- git(wt, ['config', 'user.email', 'fixture@example.invalid']);
53
- git(wt, ['config', 'user.name', 'Fixture']);
54
- git(wt, ['checkout', '-qb', 'worktree/test']);
55
- return {
56
- root,
57
- wt,
58
- home,
59
- name: `fixture-${label}`,
60
- deps: { homeDir: () => home, leaderGate: () => ({ held: true }) },
61
- };
62
- }
63
- function pushToMain(fx, files, message) {
64
- const origin = path.join(fx.root, 'origin');
65
- for (const [rel, content] of Object.entries(files))
66
- writeFileSync(path.join(origin, rel), content);
67
- git(origin, ['add', '-A']);
68
- git(origin, ['commit', '-qm', message]);
69
- }
70
- function sync(fx, extra = {}) {
71
- return runWorktreeSyncCore({
72
- worktreePath: fx.wt,
73
- assertNoTeammatesActive: true,
74
- caller: 'fixture/pid-0',
75
- baseBranch: 'main',
76
- worktreeName: fx.name,
77
- deps: fx.deps,
78
- ...extra,
79
- });
80
- }
81
- function auditRecords(fx) {
82
- const p = auditLogPath(fx.deps);
83
- if (!existsSync(p))
84
- return [];
85
- return readFileSync(p, 'utf-8').split('\n').filter(Boolean).map((l) => JSON.parse(l));
86
- }
87
- const SAMPLE = {
88
- runId: '1-aaaaaa',
89
- timestamp: '2026-08-25T00:00:00.000Z',
90
- worktree: 'wt',
91
- caller: 'test/pid-1',
92
- quiescenceAsserted: true,
93
- baseRef: 'origin/main',
94
- headBefore: 'a'.repeat(40),
95
- headAfter: 'b'.repeat(40),
96
- checkpointRef: null,
97
- syncBranch: 'reset',
98
- refsPruned: [],
99
- outcome: 'ok',
100
- };
101
- // ── security Must Fix 1 ───────────────────────────────────────────────────
102
- describe('#172 security Must Fix 1 — the audit log write target is hardened', () => {
103
- it('writes normally when the path is a plain regular file', () => {
104
- const home = mkdtempSync(path.join(tmpdir(), 'mx-audit-ok-'));
105
- ROOTS.push(home);
106
- const deps = { homeDir: () => home };
107
- expect(appendAuditLine(SAMPLE, deps)).toBe(true);
108
- const written = readFileSync(auditLogPath(deps), 'utf-8').trim();
109
- expect(JSON.parse(written).runId).toBe('1-aaaaaa');
110
- // Field order is the declared order, so the file is diffable by eye.
111
- expect(Object.keys(JSON.parse(written))[0]).toBe('runId');
112
- });
113
- it('refuses a SYMLINKED leaf instead of following it, and reports failure', () => {
114
- const home = mkdtempSync(path.join(tmpdir(), 'mx-audit-symlink-'));
115
- ROOTS.push(home);
116
- const deps = { homeDir: () => home };
117
- const logPath = auditLogPath(deps);
118
- mkdirSync(path.join(logPath, '..'), { recursive: true });
119
- const victim = path.join(home, 'victim.txt');
120
- writeFileSync(victim, '');
121
- symlinkSync(victim, logPath);
122
- // Must return false. Returning true is the defect: the caller then prints
123
- // no warning and the run is reported as recorded when it is not.
124
- expect(appendAuditLine(SAMPLE, deps)).toBe(false);
125
- expect(readFileSync(victim, 'utf-8')).toBe('');
126
- });
127
- it('refuses a SYMLINKED log directory, which a leaf-only check would miss', () => {
128
- const home = mkdtempSync(path.join(tmpdir(), 'mx-audit-symdir-'));
129
- ROOTS.push(home);
130
- const deps = { homeDir: () => home };
131
- const elsewhere = path.join(home, 'elsewhere');
132
- mkdirSync(elsewhere, { recursive: true });
133
- mkdirSync(path.join(home, '.mx-agent'), { recursive: true });
134
- symlinkSync(elsewhere, path.join(home, '.mx-agent', 'logs'));
135
- expect(appendAuditLine(SAMPLE, deps)).toBe(false);
136
- expect(existsSync(path.join(elsewhere, 'worktree-sync.jsonl'))).toBe(false);
137
- });
138
- it('refuses a FIFO leaf without blocking', () => {
139
- const mkfifo = spawnSync('mkfifo', ['--version'], { stdio: 'ignore' });
140
- if (mkfifo.status !== 0) {
141
- // Reported as could-not-run rather than silently passing.
142
- console.warn('SKIP: mkfifo unavailable, FIFO case not exercised');
143
- return;
144
- }
145
- const home = mkdtempSync(path.join(tmpdir(), 'mx-audit-fifo-'));
146
- ROOTS.push(home);
147
- const deps = { homeDir: () => home };
148
- const logPath = auditLogPath(deps);
149
- mkdirSync(path.join(logPath, '..'), { recursive: true });
150
- execFileSync('mkfifo', [logPath]);
151
- // The defect is a hang, so the assertion is on elapsed time as well as the
152
- // return value. Without O_NONBLOCK this open never returns.
153
- const started = Date.now();
154
- const ok = appendAuditLine(SAMPLE, deps);
155
- const elapsed = Date.now() - started;
156
- expect(ok).toBe(false);
157
- expect(elapsed).toBeLessThan(2_000);
158
- });
159
- });
160
- // ── security Must Fix 2 ───────────────────────────────────────────────────
161
- describe('#172 security Must Fix 2 — staged content survives the checkpoint and the sync', () => {
162
- /** Put `base.txt` into MM state: staged as v1, working tree at v2. */
163
- function makeMM(fx) {
164
- writeFileSync(path.join(fx.wt, 'base.txt'), 'v1-staged\n');
165
- git(fx.wt, ['add', 'base.txt']);
166
- writeFileSync(path.join(fx.wt, 'base.txt'), 'v2-working\n');
167
- expect(git(fx.wt, ['status', '--porcelain']).trim()).toBe('MM base.txt');
168
- }
169
- it('the checkpoint keeps the staged bytes and the working bytes separately, and they differ', () => {
170
- const fx = makeFixture('s2-capture');
171
- makeMM(fx);
172
- const cp = createCheckpoint(fx.wt, fx.name, fx.deps);
173
- expect(cp.ok).toBe(true);
174
- expect(cp.indexCommit).toBeTruthy();
175
- // Same idiom as `git stash`: the commit is the working tree, its second
176
- // parent is the index.
177
- const working = git(fx.wt, ['show', `${cp.ref}:base.txt`]);
178
- const staged = git(fx.wt, ['show', `${cp.ref}^2:base.txt`]);
179
- expect(working).toBe('v2-working\n');
180
- expect(staged).toBe('v1-staged\n');
181
- expect(staged).not.toBe(working);
182
- });
183
- it('a full sync restores BOTH the staged bytes and the working bytes', () => {
184
- const fx = makeFixture('s2-restore');
185
- pushToMain(fx, { 'main-only.txt': 'main only\n' }, 'main moves on');
186
- makeMM(fx);
187
- const r = sync(fx);
188
- expect(r.exitCode).toBe(0);
189
- expect(r.audit.outcome).toBe('ok');
190
- // MM is reproduced: index at v1, working tree at v2.
191
- expect(git(fx.wt, ['status', '--porcelain']).trim()).toBe('MM base.txt');
192
- expect(readFileSync(path.join(fx.wt, 'base.txt'), 'utf-8')).toBe('v2-working\n');
193
- expect(git(fx.wt, ['show', ':base.txt'])).toBe('v1-staged\n');
194
- // And both are still recoverable from the published ref.
195
- expect(git(fx.wt, ['show', `${r.checkpointRef}:base.txt`])).toBe('v2-working\n');
196
- expect(git(fx.wt, ['show', `${r.checkpointRef}^2:base.txt`])).toBe('v1-staged\n');
197
- // The sync actually happened.
198
- expect(readFileSync(path.join(fx.wt, 'main-only.txt'), 'utf-8')).toBe('main only\n');
199
- });
200
- });
201
- // ── red team Finding 2, the restore ───────────────────────────────────────
202
- describe('#172 Finding 2 — restore by default', () => {
203
- it('reapplies the checkpointed working tree and leaves untracked files alone', () => {
204
- const fx = makeFixture('restore');
205
- pushToMain(fx, { 'main-only.txt': 'main only\n' }, 'main moves on');
206
- writeFileSync(path.join(fx.wt, 'base.txt'), 'my uncommitted edit\n');
207
- writeFileSync(path.join(fx.wt, 'scratch.txt'), 'untracked scratch\n');
208
- const r = sync(fx);
209
- expect(r.exitCode).toBe(0);
210
- expect(readFileSync(path.join(fx.wt, 'base.txt'), 'utf-8')).toBe('my uncommitted edit\n');
211
- expect(readFileSync(path.join(fx.wt, 'scratch.txt'), 'utf-8')).toBe('untracked scratch\n');
212
- expect(readFileSync(path.join(fx.wt, 'main-only.txt'), 'utf-8')).toBe('main only\n');
213
- });
214
- it('--no-restore parks the work in the ref and leaves the tree committed-clean', () => {
215
- const fx = makeFixture('norestore');
216
- pushToMain(fx, { 'main-only.txt': 'main only\n' }, 'main moves on');
217
- writeFileSync(path.join(fx.wt, 'base.txt'), 'my uncommitted edit\n');
218
- const r = sync(fx, { restore: false });
219
- expect(r.exitCode).toBe(0);
220
- expect(readFileSync(path.join(fx.wt, 'base.txt'), 'utf-8')).toBe('v0-committed\n');
221
- expect(git(fx.wt, ['show', `${r.checkpointRef}:base.txt`])).toBe('my uncommitted edit\n');
222
- });
223
- it('a restore conflict returns the tree to the committed state and exits non-zero', () => {
224
- const fx = makeFixture('restore-conflict');
225
- // main edits the same line the uncommitted work edits.
226
- pushToMain(fx, { 'base.txt': 'main version of this line\n' }, 'main edits base');
227
- writeFileSync(path.join(fx.wt, 'base.txt'), 'my version of this line\n');
228
- const r = sync(fx);
229
- expect(r.exitCode).not.toBe(0);
230
- expect(r.audit.outcome).toBe('restore-conflict');
231
- // No conflict markers, no half-merged index: `git cherry-pick --abort` does
232
- // not work under -n, so the cleanup is a reset and this asserts it ran.
233
- expect(git(fx.wt, ['status', '--porcelain']).trim()).toBe('');
234
- expect(readFileSync(path.join(fx.wt, 'base.txt'), 'utf-8')).toBe('main version of this line\n');
235
- // Nothing is lost.
236
- expect(git(fx.wt, ['show', `${r.checkpointRef}:base.txt`])).toBe('my version of this line\n');
237
- expect(r.lines.join('\n')).toContain(r.checkpointRef);
238
- });
239
- });
240
- /**
241
- * Run the real sync core in a CHILD process, stalled inside step 7, then send
242
- * it `signal`. Returns null when `dist/` is not built, which the caller reports
243
- * as could-not-run rather than passing quietly.
244
- */
245
- function runStalledChildAndSignal(fx, signal) {
246
- const libUrl = path.resolve(import.meta.dirname, '..', '..', 'dist', 'lib', 'worktree-sync.js');
247
- if (!existsSync(libUrl)) {
248
- console.warn(`SKIP: dist not built, SIG${signal} case not exercised (run npm run build first)`);
249
- return null;
250
- }
251
- const runner = path.join(fx.root, `runner-${signal}.mjs`);
252
- writeFileSync(runner, `import { runWorktreeSyncCore, defaultExecFile } from ${JSON.stringify(libUrl)};
253
- let stalled = false;
254
- const r = runWorktreeSyncCore({
255
- worktreePath: ${JSON.stringify(fx.wt)},
256
- assertNoTeammatesActive: true,
257
- caller: 'child/pid-0',
258
- baseBranch: 'main',
259
- worktreeName: ${JSON.stringify(fx.name)},
260
- deps: {
261
- homeDir: () => ${JSON.stringify(fx.home)},
262
- leaderGate: () => ({ held: true }),
263
- exec: (file, args, opts) => {
264
- if (file === 'git' && args[0] === 'reset' && args[1] === '--hard' && !stalled) {
265
- stalled = true;
266
- console.log('STALLING');
267
- const sab = new Int32Array(new SharedArrayBuffer(4));
268
- Atomics.wait(sab, 0, 0, 30000);
269
- }
270
- return defaultExecFile(file, args, opts);
271
- },
272
- },
273
- });
274
- console.log('COMPLETED', r.audit.outcome);
275
- `);
276
- const logPath = path.join(fx.root, `child-${signal}.log`);
277
- const shell = execFileSync('bash', [
278
- '-c',
279
- `node ${JSON.stringify(runner)} > ${JSON.stringify(logPath)} 2>&1 & CHILD=$!; ` +
280
- `sleep 4; kill -${signal} $CHILD 2>/dev/null; wait $CHILD; echo "EXIT=$?"`,
281
- ], { encoding: 'utf-8', timeout: 60_000 });
282
- const m = /EXIT=(\d+)/.exec(shell);
283
- return { exitCode: m ? Number(m[1]) : -1, childLog: readFileSync(logPath, 'utf-8') };
284
- }
285
- // ── red team Finding 1, crash durability ──────────────────────────────────
286
- describe('#172 Finding 1 — a run killed during step 7 is findable', () => {
287
- it('SIGKILL during the destructive step leaves an in-progress record and no terminal record', (ctx) => {
288
- const fx = makeFixture('sigkill');
289
- pushToMain(fx, { 'main-only.txt': 'main only\n' }, 'main moves on');
290
- // Dirty, so a checkpoint is written and `reset --hard HEAD` runs as the
291
- // first mutating call after the in-progress record.
292
- writeFileSync(path.join(fx.wt, 'base.txt'), 'uncommitted work\n');
293
- const out = runStalledChildAndSignal(fx, 'KILL');
294
- // could-not-run is its own outcome. A bare `return` here reports PASSED,
295
- // which would let a CI run with no build pass this vacuously. The `return`
296
- // after `skip()` is unreachable (skip throws) and is there so TypeScript
297
- // narrows `out` to non-null below.
298
- if (out === null) {
299
- ctx.skip();
300
- return;
301
- }
302
- expect(out.childLog).toContain('STALLING');
303
- expect(out.childLog).not.toContain('COMPLETED');
304
- const records = auditRecords(fx);
305
- const started = records.filter((r) => r.outcome === 'in-progress');
306
- const terminal = records.filter((r) => r.outcome !== 'in-progress');
307
- // This is the whole point of the fix: the killed run left a record.
308
- expect(started.length).toBe(1);
309
- expect(terminal.length).toBe(0);
310
- expect(started[0].baseRef).toBe('origin/main');
311
- expect(started[0].headBefore).toBeTruthy();
312
- expect(started[0].runId).toMatch(/^\d+-[0-9a-f]{6}$/);
313
- }, 120_000);
314
- it('SIGTERM during the destructive step TERMINATES the process, and the run is still findable', (ctx) => {
315
- // This asserts the post-fix behaviour. An earlier revision registered
316
- // SIGTERM/SIGINT handlers here. Because the destructive sequence is
317
- // entirely synchronous `execFileSync`, and Node dispatches signal handlers
318
- // on the event loop, those handlers could never run; registering them only
319
- // REPLACED Node's default termination, so the signal was discarded and an
320
- // operator's Ctrl-C mid-reset did nothing. Measured three ways on Node
321
- // v22.16.0. The handlers are gone, so SIGTERM terminates as it should.
322
- const fx = makeFixture('sigterm');
323
- pushToMain(fx, { 'main-only.txt': 'main only\n' }, 'main moves on');
324
- writeFileSync(path.join(fx.wt, 'base.txt'), 'uncommitted work\n');
325
- const out = runStalledChildAndSignal(fx, 'TERM');
326
- if (out === null) {
327
- ctx.skip();
328
- return;
329
- }
330
- // 143 = 128 + SIGTERM. Exit 0 would mean the signal was swallowed and the
331
- // sync ran to completion anyway, which is the defect this replaces.
332
- expect(out.exitCode).toBe(143);
333
- expect(out.childLog).toContain('STALLING');
334
- expect(out.childLog).not.toContain('COMPLETED');
335
- const records = auditRecords(fx);
336
- expect(records.filter((r) => r.outcome === 'in-progress').length).toBe(1);
337
- expect(records.filter((r) => r.outcome !== 'in-progress').length).toBe(0);
338
- }, 120_000);
339
- });
340
- // ── red team Finding 3, squash-point ancestry ─────────────────────────────
341
- describe('#172 Finding 3 — the squash point must be an ancestor of HEAD', () => {
342
- function ghStub(prs, commitsByPr) {
343
- return (file, args, options) => {
344
- if (file !== 'gh')
345
- return defaultExecFile(file, args, options);
346
- if (args[1] === 'list')
347
- return { status: 0, stdout: JSON.stringify(prs), stderr: '' };
348
- if (args[1] === 'view') {
349
- const n = Number(args[2]);
350
- return { status: 0, stdout: JSON.stringify({ commits: [{ oid: commitsByPr[n] }] }), stderr: '' };
351
- }
352
- return { status: 1, stdout: '', stderr: 'unexpected gh call' };
353
- };
354
- }
355
- it('picks the most recently MERGED pull request, not the most recently created', () => {
356
- const fx = makeFixture('f3-order');
357
- writeFileSync(path.join(fx.wt, 'a.txt'), 'a\n');
358
- git(fx.wt, ['add', '-A']);
359
- git(fx.wt, ['commit', '-qm', 'commit a']);
360
- const oidA = git(fx.wt, ['rev-parse', 'HEAD']).trim();
361
- writeFileSync(path.join(fx.wt, 'b.txt'), 'b\n');
362
- git(fx.wt, ['add', '-A']);
363
- git(fx.wt, ['commit', '-qm', 'commit b']);
364
- const oidB = git(fx.wt, ['rev-parse', 'HEAD']).trim();
365
- // #900 was created last but merged FIRST. `--limit 1` would return it.
366
- const deps = {
367
- ...fx.deps,
368
- exec: ghStub([
369
- { number: 900, mergedAt: '2026-08-01T00:00:00Z' },
370
- { number: 800, mergedAt: '2026-08-20T00:00:00Z' },
371
- ], { 900: oidA, 800: oidB }),
372
- };
373
- const found = findSquashPoint(fx.wt, 'worktree/test', deps);
374
- expect(found?.prNumber).toBe(800);
375
- expect(found?.oid).toBe(oidB);
376
- });
377
- it('refuses when the squash point is not an ancestor of HEAD, naming the pull request and the oid', () => {
378
- const fx = makeFixture('f3-ancestor');
379
- writeFileSync(path.join(fx.wt, 'a.txt'), 'a\n');
380
- git(fx.wt, ['add', '-A']);
381
- git(fx.wt, ['commit', '-qm', 'commit a']);
382
- // A commit on a DIFFERENT branch: a real oid, merged under the same branch
383
- // name by another team, that this branch does not contain.
384
- git(fx.wt, ['checkout', '-qb', 'foreign']);
385
- writeFileSync(path.join(fx.wt, 'foreign.txt'), 'foreign\n');
386
- git(fx.wt, ['add', '-A']);
387
- git(fx.wt, ['commit', '-qm', 'foreign commit']);
388
- const foreignOid = git(fx.wt, ['rev-parse', 'HEAD']).trim();
389
- git(fx.wt, ['checkout', '-q', 'worktree/test']);
390
- expect(OID_RE.test(foreignOid)).toBe(true);
391
- pushToMain(fx, { 'main-only.txt': 'main only\n' }, 'main moves on');
392
- const headBefore = git(fx.wt, ['rev-parse', 'HEAD']).trim();
393
- const r = sync(fx, {
394
- deps: { ...fx.deps, exec: ghStub([{ number: 777, mergedAt: '2026-08-20T00:00:00Z' }], { 777: foreignOid }) },
395
- });
396
- expect(r.exitCode).not.toBe(0);
397
- expect(r.audit.outcome).toBe('refused-squash-point-not-ancestor');
398
- const out = r.lines.join('\n');
399
- expect(out).toContain('#777');
400
- expect(out).toContain(foreignOid);
401
- // Nothing was mutated, and no in-progress record was written for a run
402
- // that never reached the destructive step.
403
- expect(git(fx.wt, ['rev-parse', 'HEAD']).trim()).toBe(headBefore);
404
- expect(auditRecords(fx).filter((x) => x.outcome === 'in-progress').length).toBe(0);
405
- });
406
- it('rejects an oid from gh that is not a 40-character hex object name', () => {
407
- const fx = makeFixture('f3-oid');
408
- const deps = {
409
- ...fx.deps,
410
- exec: ghStub([{ number: 1, mergedAt: '2026-08-20T00:00:00Z' }], { 1: '--upstream=/etc/passwd' }),
411
- };
412
- expect(findSquashPoint(fx.wt, 'worktree/test', deps)).toBeNull();
413
- });
414
- });
415
- // ── red team Finding 4, the uncovered step-7 window ───────────────────────
416
- describe('#172 Finding 4 — a write landing inside step 7, after the quiescence re-sample', () => {
417
- // KNOWN RESIDUAL, reported in its own bucket rather than folded into the pass
418
- // count. A green suite must not read as "step 7 is covered". The test below
419
- // MEASURES the gap and fails if it ever changes; this line is what appears in
420
- // the run summary, so the gap is visible without reading the file.
421
- it.todo('KNOWN RESIDUAL (#172 Concurrency): step 7 has no quiescence coverage, so a write landing ' +
422
- 'there is lost and undetected at any write rate. Closing it needs a scheduling rule that no ' +
423
- 'sync runs while teammates are live, which is outside this command.');
424
- it('MEASURES the known residual: a write inside step 7 is neither detected nor recoverable', () => {
425
- const fx = makeFixture('f4');
426
- pushToMain(fx, { 'main-only.txt': 'main only\n' }, 'main moves on');
427
- const target = path.join(fx.wt, 'base.txt');
428
- writeFileSync(target, 'teammate work in progress\n');
429
- // Exactly one write, landing after step 6 has passed and before step 7
430
- // finishes. The `diff --quiet` call is the first thing step 7 runs after
431
- // the re-sample, so this is inside the window with no quiescence coverage.
432
- let fired = false;
433
- const deps = {
434
- ...fx.deps,
435
- exec: (file, args, options) => {
436
- if (file === 'git' && args[0] === 'diff' && args[1] === '--quiet' && !fired) {
437
- fired = true;
438
- appendFileSync(target, 'LANDED INSIDE STEP 7\n');
439
- }
440
- return defaultExecFile(file, args, options);
441
- },
442
- };
443
- const r = runWorktreeSyncCore({
444
- worktreePath: fx.wt,
445
- assertNoTeammatesActive: true,
446
- caller: 'fixture/pid-0',
447
- baseBranch: 'main',
448
- worktreeName: fx.name,
449
- deps,
450
- });
451
- expect(fired).toBe(true);
452
- const onDisk = existsSync(target) ? readFileSync(target, 'utf-8') : '';
453
- const inCheckpoint = r.checkpointRef
454
- ? (() => {
455
- try {
456
- return git(fx.wt, ['show', `${r.checkpointRef}:base.txt`]);
457
- }
458
- catch {
459
- return '';
460
- }
461
- })()
462
- : '';
463
- const detected = r.exitCode !== 0;
464
- const recoverable = onDisk.includes('LANDED INSIDE STEP 7') || inCheckpoint.includes('LANDED INSIDE STEP 7');
465
- // THIS IS THE PLAN'S STATED RESIDUAL RISK, ASSERTED RATHER THAN DESCRIBED.
466
- // The plan's Concurrency section says: "a teammate writing files during the
467
- // destructive step can still lose work, and no mechanism here detects it."
468
- // This test pins that to a number instead of leaving it as prose. The
469
- // checkpoint at step 5 predates the write, and the step-6 re-sample has
470
- // already passed, so the write is neither captured nor detected.
471
- //
472
- // The assertion is deliberately on the MEASURED behaviour, so that if
473
- // anyone later closes this window the test fails and forces the claim in
474
- // the module header and the plan to be updated with it.
475
- expect(detected).toBe(false);
476
- expect(recoverable).toBe(false);
477
- });
478
- });
479
- // ── red team Finding 6 ────────────────────────────────────────────────────
480
- describe('#172 Finding 6 — a rebase failure that is not a conflict is logged as such', () => {
481
- it('records rebase-failed, not conflict, when the rebase never started', () => {
482
- const fx = makeFixture('f6');
483
- writeFileSync(path.join(fx.wt, 'a.txt'), 'a\n');
484
- git(fx.wt, ['add', '-A']);
485
- git(fx.wt, ['commit', '-qm', 'commit a']);
486
- pushToMain(fx, { 'main-only.txt': 'main only\n' }, 'main moves on');
487
- // A rebase that fails without ever starting: no rebase state is left, so
488
- // there are no conflict markers to send an operator looking for.
489
- const deps = {
490
- ...fx.deps,
491
- exec: (file, args, options) => {
492
- if (file === 'git' && args[0] === 'rebase') {
493
- return { status: 128, stdout: '', stderr: 'fatal: could not write to index (disk full)' };
494
- }
495
- return defaultExecFile(file, args, options);
496
- },
497
- };
498
- const r = sync(fx, { deps });
499
- expect(r.exitCode).not.toBe(0);
500
- expect(r.audit.outcome).toBe('rebase-failed');
501
- expect(r.audit.outcome).not.toBe('conflict');
502
- expect(r.lines.join('\n')).toContain('This is not a merge conflict');
503
- });
504
- });
505
- // ── Should Fix: a rebase already in progress ──────────────────────────────
506
- describe('#172 — a rebase already in progress is refused, never aborted', () => {
507
- it('refuses at step 0 rather than aborting a rebase it did not start', () => {
508
- const fx = makeFixture('inprogress');
509
- writeFileSync(path.join(fx.wt, 'base.txt'), 'branch version\n');
510
- git(fx.wt, ['add', '-A']);
511
- git(fx.wt, ['commit', '-qm', 'branch edits base']);
512
- git(fx.wt, ['checkout', '-qb', 'other', 'HEAD~1']);
513
- writeFileSync(path.join(fx.wt, 'base.txt'), 'other version\n');
514
- git(fx.wt, ['add', '-A']);
515
- git(fx.wt, ['commit', '-qm', 'other edits base']);
516
- // Start a conflicting rebase and leave it in progress, as a human would.
517
- const started = spawnSync('git', ['rebase', 'worktree/test'], { cwd: fx.wt, stdio: 'pipe' });
518
- expect(started.status).not.toBe(0);
519
- const gitDir = git(fx.wt, ['rev-parse', '--absolute-git-dir']).trim();
520
- expect(existsSync(path.join(gitDir, 'rebase-merge')) || existsSync(path.join(gitDir, 'rebase-apply'))).toBe(true);
521
- const r = sync(fx);
522
- expect(r.exitCode).not.toBe(0);
523
- expect(r.audit.outcome).toBe('refused-rebase-in-progress');
524
- // The other rebase is untouched.
525
- expect(existsSync(path.join(gitDir, 'rebase-merge')) || existsSync(path.join(gitDir, 'rebase-apply'))).toBe(true);
526
- git(fx.wt, ['rebase', '--abort']);
527
- });
528
- });
529
- // ── Should Fix: git status exit code ──────────────────────────────────────
530
- describe('#172 — an unreadable git status refuses instead of reading as clean', () => {
531
- it('refuses when git status fails, and does not proceed to the reset', () => {
532
- const fx = makeFixture('status');
533
- pushToMain(fx, { 'main-only.txt': 'main only\n' }, 'main moves on');
534
- const headBefore = git(fx.wt, ['rev-parse', 'HEAD']).trim();
535
- const deps = {
536
- ...fx.deps,
537
- exec: (file, args, options) => {
538
- if (file === 'git' && args[0] === 'status') {
539
- return { status: 128, stdout: '', stderr: 'fatal: unable to read index' };
540
- }
541
- return defaultExecFile(file, args, options);
542
- },
543
- };
544
- const r = sync(fx, { deps });
545
- expect(r.exitCode).not.toBe(0);
546
- expect(r.audit.outcome).toBe('refused-status-unreadable');
547
- expect(git(fx.wt, ['rev-parse', 'HEAD']).trim()).toBe(headBefore);
548
- });
549
- });
550
- // ── restoreCheckpoint unit behaviour ──────────────────────────────────────
551
- describe('#172 — restoreCheckpoint with nothing to do', () => {
552
- it('reports nothing-to-restore rather than running a cherry-pick', () => {
553
- const fx = makeFixture('restore-noop');
554
- const calls = [];
555
- const deps = {
556
- ...fx.deps,
557
- exec: (file, args, options) => {
558
- calls.push([file, ...args]);
559
- return defaultExecFile(file, args, options);
560
- },
561
- };
562
- expect(restoreCheckpoint(fx.wt, null, deps, null, null).outcome).toBe('nothing-to-restore');
563
- expect(calls.length).toBe(0);
564
- });
565
- });
566
- // ── Should Fix: quoted paths in the index restore ─────────────────────────
567
- describe('#172 — the index restore survives a path git would quote', () => {
568
- it('restores both halves for a non-ASCII filename', () => {
569
- const fx = makeFixture('quotepath');
570
- // core.quotePath is unset here, so it takes its default of true: `diff
571
- // --name-only` without -z returns this path C-quoted, and feeding that
572
- // literal back as a pathspec fails. `git config --get` exits 1 when unset.
573
- expect(spawnSync('git', ['config', '--get', 'core.quotePath'], { cwd: fx.wt }).status).toBe(1);
574
- const weird = 'café journée.txt';
575
- writeFileSync(path.join(fx.wt, weird), 'v0\n');
576
- git(fx.wt, ['add', '-A']);
577
- git(fx.wt, ['commit', '-qm', 'add a non-ascii path']);
578
- // MM state on the non-ASCII path.
579
- writeFileSync(path.join(fx.wt, weird), 'v1-staged\n');
580
- git(fx.wt, ['add', weird]);
581
- writeFileSync(path.join(fx.wt, weird), 'v2-working\n');
582
- pushToMain(fx, { 'main-only.txt': 'main only\n' }, 'main moves on');
583
- const r = sync(fx);
584
- expect(r.exitCode).toBe(0);
585
- expect(r.audit.outcome).toBe('ok');
586
- // Both halves restored: working tree at v2, index at v1. Before the -z fix
587
- // the working half succeeded and the staged half was silently skipped.
588
- expect(readFileSync(path.join(fx.wt, weird), 'utf-8')).toBe('v2-working\n');
589
- expect(git(fx.wt, ['show', ':' + weird])).toBe('v1-staged\n');
590
- expect(git(fx.wt, ['status', '--porcelain']).trim().slice(0, 2)).toBe('MM');
591
- });
592
- });
593
- // ── Should Fix: MERGE_HEAD and CHERRY_PICK_HEAD ──────────────────────────
594
- describe('#172 — a half-finished merge or cherry-pick is refused, never cleared', () => {
595
- it('refuses when MERGE_HEAD is present, so reset --hard cannot discard the merge', () => {
596
- const fx = makeFixture('mergehead');
597
- writeFileSync(path.join(fx.wt, 'base.txt'), 'ours\n');
598
- git(fx.wt, ['add', '-A']);
599
- git(fx.wt, ['commit', '-qm', 'ours']);
600
- git(fx.wt, ['checkout', '-qb', 'theirs', 'HEAD~1']);
601
- writeFileSync(path.join(fx.wt, 'base.txt'), 'theirs\n');
602
- git(fx.wt, ['add', '-A']);
603
- git(fx.wt, ['commit', '-qm', 'theirs']);
604
- git(fx.wt, ['checkout', '-q', 'worktree/test']);
605
- // Conflicting merge, left in progress exactly as an operator would have it.
606
- const merged = spawnSync('git', ['merge', 'theirs'], { cwd: fx.wt, stdio: 'pipe' });
607
- expect(merged.status).not.toBe(0);
608
- const gitDir = git(fx.wt, ['rev-parse', '--absolute-git-dir']).trim();
609
- expect(existsSync(path.join(gitDir, 'MERGE_HEAD'))).toBe(true);
610
- const r = sync(fx);
611
- expect(r.exitCode).not.toBe(0);
612
- expect(r.audit.outcome).toBe('refused-rebase-in-progress');
613
- expect(r.lines.join('\n')).toContain('MERGE_HEAD');
614
- // The merge is untouched: this is the whole point.
615
- expect(existsSync(path.join(gitDir, 'MERGE_HEAD'))).toBe(true);
616
- expect(git(fx.wt, ['status', '--porcelain']).trim()).toContain('base.txt');
617
- git(fx.wt, ['merge', '--abort']);
618
- });
619
- it('refuses when CHERRY_PICK_HEAD is present', () => {
620
- const fx = makeFixture('cherrypickhead');
621
- writeFileSync(path.join(fx.wt, 'base.txt'), 'ours\n');
622
- git(fx.wt, ['add', '-A']);
623
- git(fx.wt, ['commit', '-qm', 'ours']);
624
- git(fx.wt, ['checkout', '-qb', 'other', 'HEAD~1']);
625
- writeFileSync(path.join(fx.wt, 'base.txt'), 'theirs\n');
626
- git(fx.wt, ['add', '-A']);
627
- git(fx.wt, ['commit', '-qm', 'theirs']);
628
- const otherTip = git(fx.wt, ['rev-parse', 'HEAD']).trim();
629
- git(fx.wt, ['checkout', '-q', 'worktree/test']);
630
- const picked = spawnSync('git', ['cherry-pick', otherTip], { cwd: fx.wt, stdio: 'pipe' });
631
- expect(picked.status).not.toBe(0);
632
- const gitDir = git(fx.wt, ['rev-parse', '--absolute-git-dir']).trim();
633
- expect(existsSync(path.join(gitDir, 'CHERRY_PICK_HEAD'))).toBe(true);
634
- const r = sync(fx);
635
- expect(r.exitCode).not.toBe(0);
636
- expect(r.audit.outcome).toBe('refused-rebase-in-progress');
637
- expect(r.lines.join('\n')).toContain('CHERRY_PICK_HEAD');
638
- expect(existsSync(path.join(gitDir, 'CHERRY_PICK_HEAD'))).toBe(true);
639
- git(fx.wt, ['cherry-pick', '--abort']);
640
- });
641
- });
642
- // ── Critical: a never-committed file that was staged ──────────────────────
643
- describe('#172 Critical — a staged, never-committed file survives the sync', () => {
644
- /** Stage a file that has never been committed, and move the base on. */
645
- function stagedNewFixture(label) {
646
- const fx = makeFixture(label);
647
- pushToMain(fx, { 'main-only.txt': 'main only\n' }, 'main moves on');
648
- return fx;
649
- }
650
- it('keeps the bytes ON DISK and staged, and never produces AD', () => {
651
- const fx = stagedNewFixture('stagednew');
652
- writeFileSync(path.join(fx.wt, 'newfile.txt'), 'IMPORTANT NEW BYTES\n');
653
- git(fx.wt, ['add', 'newfile.txt']);
654
- expect(git(fx.wt, ['status', '--porcelain']).trim()).toBe('A newfile.txt');
655
- const r = sync(fx);
656
- expect(r.exitCode).toBe(0);
657
- expect(r.audit.outcome).toBe('ok');
658
- const status = git(fx.wt, ['status', '--porcelain']).trim();
659
- // `AD` is the regression: staged as added, deleted from disk, bytes gone,
660
- // and the command reporting success. Assert against it by name so a
661
- // reintroduction is loud rather than subtle.
662
- expect(status).not.toContain('AD');
663
- expect(status).toBe('A newfile.txt');
664
- expect(existsSync(path.join(fx.wt, 'newfile.txt'))).toBe(true);
665
- expect(readFileSync(path.join(fx.wt, 'newfile.txt'), 'utf-8')).toBe('IMPORTANT NEW BYTES\n');
666
- expect(git(fx.wt, ['show', ':newfile.txt'])).toBe('IMPORTANT NEW BYTES\n');
667
- // And the sync really happened.
668
- expect(readFileSync(path.join(fx.wt, 'main-only.txt'), 'utf-8')).toBe('main only\n');
669
- });
670
- it('keeps the staged bytes and the later working-tree edit apart (AM)', () => {
671
- const fx = stagedNewFixture('stagednew-am');
672
- writeFileSync(path.join(fx.wt, 'newfile.txt'), 'STAGED BYTES\n');
673
- git(fx.wt, ['add', 'newfile.txt']);
674
- writeFileSync(path.join(fx.wt, 'newfile.txt'), 'EDITED AFTER STAGING\n');
675
- expect(git(fx.wt, ['status', '--porcelain']).trim()).toBe('AM newfile.txt');
676
- const r = sync(fx);
677
- expect(r.exitCode).toBe(0);
678
- expect(git(fx.wt, ['status', '--porcelain']).trim()).toBe('AM newfile.txt');
679
- expect(readFileSync(path.join(fx.wt, 'newfile.txt'), 'utf-8')).toBe('EDITED AFTER STAGING\n');
680
- expect(git(fx.wt, ['show', ':newfile.txt'])).toBe('STAGED BYTES\n');
681
- expect(git(fx.wt, ['show', `${r.checkpointRef}^2:newfile.txt`])).toBe('STAGED BYTES\n');
682
- });
683
- it('a staged new file and a plain untracked file coexist without tripping the restore', () => {
684
- // The staged-new path is added to the restore tree; the plain untracked one
685
- // must NOT be, or the cherry-pick fails with "untracked working tree files
686
- // would be overwritten by merge".
687
- const fx = stagedNewFixture('stagednew-mixed');
688
- writeFileSync(path.join(fx.wt, 'newfile.txt'), 'STAGED\n');
689
- git(fx.wt, ['add', 'newfile.txt']);
690
- writeFileSync(path.join(fx.wt, 'plain-untracked.txt'), 'untouched\n');
691
- const r = sync(fx);
692
- expect(r.exitCode).toBe(0);
693
- expect(r.audit.outcome).toBe('ok');
694
- expect(readFileSync(path.join(fx.wt, 'newfile.txt'), 'utf-8')).toBe('STAGED\n');
695
- expect(readFileSync(path.join(fx.wt, 'plain-untracked.txt'), 'utf-8')).toBe('untouched\n');
696
- expect(git(fx.wt, ['status', '--porcelain']).trim().split('\n').sort()).toEqual([
697
- '?? plain-untracked.txt',
698
- 'A newfile.txt',
699
- ]);
700
- });
701
- it('a file staged then deleted from disk stays recoverable from the ref', () => {
702
- const fx = stagedNewFixture('stagednew-deleted');
703
- writeFileSync(path.join(fx.wt, 'newfile.txt'), 'STAGED THEN DELETED\n');
704
- git(fx.wt, ['add', 'newfile.txt']);
705
- rmSync(path.join(fx.wt, 'newfile.txt'));
706
- const r = sync(fx);
707
- expect(r.exitCode).toBe(0);
708
- // Nothing can put bytes on disk for a path the operator deleted, and the
709
- // command does not pretend otherwise. The ref holds them.
710
- expect(git(fx.wt, ['show', `${r.checkpointRef}^2:newfile.txt`])).toBe('STAGED THEN DELETED\n');
711
- });
712
- });
713
- // ── Must Fix 4: renames ───────────────────────────────────────────────────
714
- describe('#172 Must Fix 4 — a renamed file survives the sync', () => {
715
- function renameFixture(label) {
716
- const fx = makeFixture(label);
717
- pushToMain(fx, { 'main-only.txt': 'main only\n' }, 'main moves on');
718
- return fx;
719
- }
720
- it('git mv: the destination is on disk afterwards and status never reads RD', () => {
721
- const fx = renameFixture('rename');
722
- git(fx.wt, ['mv', 'base.txt', 'renamed.txt']);
723
- expect(git(fx.wt, ['status', '--porcelain']).trim()).toBe('R base.txt -> renamed.txt');
724
- const r = sync(fx);
725
- expect(r.exitCode).toBe(0);
726
- expect(r.audit.outcome).toBe('ok');
727
- const status = git(fx.wt, ['status', '--porcelain']).trim();
728
- // `RD` is the regression: git reports a rename as `R`, which
729
- // `--diff-filter=A` does not match, so the destination was absent from the
730
- // restore tree and `reset --hard` deleted it while the run reported success.
731
- expect(status).not.toContain('RD');
732
- expect(status).toBe('R base.txt -> renamed.txt');
733
- expect(existsSync(path.join(fx.wt, 'renamed.txt'))).toBe(true);
734
- expect(readFileSync(path.join(fx.wt, 'renamed.txt'), 'utf-8')).toBe('v0-committed\n');
735
- expect(existsSync(path.join(fx.wt, 'base.txt'))).toBe(false);
736
- expect(readFileSync(path.join(fx.wt, 'main-only.txt'), 'utf-8')).toBe('main only\n');
737
- });
738
- it('git mv followed by an edit: the edited bytes are on disk and status reads RM', () => {
739
- const fx = renameFixture('rename-edit');
740
- git(fx.wt, ['mv', 'base.txt', 'renamed.txt']);
741
- writeFileSync(path.join(fx.wt, 'renamed.txt'), 'renamed and edited\n');
742
- expect(git(fx.wt, ['status', '--porcelain']).trim()).toBe('RM base.txt -> renamed.txt');
743
- const r = sync(fx);
744
- expect(r.exitCode).toBe(0);
745
- const status = git(fx.wt, ['status', '--porcelain']).trim();
746
- expect(status).not.toContain('RD');
747
- expect(status).toBe('RM base.txt -> renamed.txt');
748
- expect(readFileSync(path.join(fx.wt, 'renamed.txt'), 'utf-8')).toBe('renamed and edited\n');
749
- // The staged half of the rename is the pre-edit content, kept separately.
750
- expect(git(fx.wt, ['show', ':renamed.txt'])).toBe('v0-committed\n');
751
- });
752
- });
753
- // ── Must Fix 5: one unaddable path must not cancel the restore ────────────
754
- describe('#172 Must Fix 5 — a force-added ignored file does not cancel the whole restore', () => {
755
- it('brings back BOTH the ignored staged file and the tracked edit', () => {
756
- const fx = makeFixture('forceadd');
757
- writeFileSync(path.join(fx.wt, '.gitignore'), 'secretish.txt\n');
758
- git(fx.wt, ['add', '-A']);
759
- git(fx.wt, ['commit', '-qm', 'add gitignore']);
760
- pushToMain(fx, { 'main-only.txt': 'main only\n' }, 'main moves on');
761
- writeFileSync(path.join(fx.wt, 'base.txt'), 'MY TRACKED EDIT\n');
762
- writeFileSync(path.join(fx.wt, 'secretish.txt'), 'FORCE ADDED BYTES\n');
763
- git(fx.wt, ['add', '-f', 'secretish.txt']);
764
- const r = sync(fx);
765
- expect(r.exitCode).toBe(0);
766
- expect(r.audit.outcome).toBe('ok');
767
- // Before the fix this produced `AD secretish.txt` with base.txt REVERTED to
768
- // its committed bytes, and the run still printed "Restored the checkpointed
769
- // working tree" and exited 0. Both files must come back.
770
- expect(readFileSync(path.join(fx.wt, 'base.txt'), 'utf-8')).toBe('MY TRACKED EDIT\n');
771
- expect(existsSync(path.join(fx.wt, 'secretish.txt'))).toBe(true);
772
- expect(readFileSync(path.join(fx.wt, 'secretish.txt'), 'utf-8')).toBe('FORCE ADDED BYTES\n');
773
- expect(git(fx.wt, ['status', '--porcelain'])).not.toContain('AD');
774
- });
775
- });
776
- // ── Must Fix 5b: a failed restore never reports success ───────────────────
777
- describe('#172 Must Fix 5b — a restore tree that cannot be built is reported, never skipped', () => {
778
- it('returns restore-failed, mutates nothing, and never says restored', () => {
779
- const fx = makeFixture('restorefail');
780
- pushToMain(fx, { 'main-only.txt': 'main only\n' }, 'main moves on');
781
- writeFileSync(path.join(fx.wt, 'base.txt'), 'MY TRACKED EDIT\n');
782
- writeFileSync(path.join(fx.wt, 'newfile.txt'), 'STAGED NEW\n');
783
- git(fx.wt, ['add', 'newfile.txt']);
784
- const headBefore = git(fx.wt, ['rev-parse', 'HEAD']).trim();
785
- const statusBefore = git(fx.wt, ['status', '--porcelain']);
786
- // Make the restore-tree staging fail. Any cause will do; what matters is
787
- // that the failure is REPORTED rather than turned into a skipped
788
- // cherry-pick that still returns `restored`.
789
- const deps = {
790
- ...fx.deps,
791
- exec: (file, args, options) => {
792
- if (file === 'git' && args[0] === 'add' && args.includes('-f')) {
793
- return { status: 128, stdout: '', stderr: 'fatal: simulated staging failure' };
794
- }
795
- return defaultExecFile(file, args, options);
796
- },
797
- };
798
- const r = sync(fx, { deps });
799
- expect(r.audit.outcome).toBe('restore-failed');
800
- expect(r.audit.outcome).not.toBe('ok');
801
- expect(r.exitCode).not.toBe(0);
802
- const out = r.lines.join('\n');
803
- expect(out).not.toContain('Restored the checkpointed working tree');
804
- expect(out).toContain('simulated staging failure');
805
- expect(out).toContain(r.checkpointRef);
806
- // Nothing was mutated: the operator is exactly where they started.
807
- expect(git(fx.wt, ['rev-parse', 'HEAD']).trim()).toBe(headBefore);
808
- expect(git(fx.wt, ['status', '--porcelain'])).toBe(statusBefore);
809
- expect(readFileSync(path.join(fx.wt, 'base.txt'), 'utf-8')).toBe('MY TRACKED EDIT\n');
810
- // And the checkpoint still holds everything.
811
- expect(git(fx.wt, ['show', `${r.checkpointRef}:base.txt`])).toBe('MY TRACKED EDIT\n');
812
- });
813
- it('--no-restore still syncs when the restore tree could not be built', () => {
814
- const fx = makeFixture('restorefail-norestore');
815
- pushToMain(fx, { 'main-only.txt': 'main only\n' }, 'main moves on');
816
- writeFileSync(path.join(fx.wt, 'newfile.txt'), 'STAGED NEW\n');
817
- git(fx.wt, ['add', 'newfile.txt']);
818
- const deps = {
819
- ...fx.deps,
820
- exec: (file, args, options) => {
821
- if (file === 'git' && args[0] === 'add' && args.includes('-f')) {
822
- return { status: 128, stdout: '', stderr: 'fatal: simulated staging failure' };
823
- }
824
- return defaultExecFile(file, args, options);
825
- },
826
- };
827
- const r = sync(fx, { deps, restore: false });
828
- expect(r.exitCode).toBe(0);
829
- expect(r.audit.outcome).toBe('ok');
830
- // The caller asked for the parked state, so the ref is the recovery route.
831
- expect(git(fx.wt, ['show', `${r.checkpointRef}^2:newfile.txt`])).toBe('STAGED NEW\n');
832
- });
833
- });
834
- // ── Critical: unread exit status turning a failure into a plausible answer ──
835
- describe('#172 Critical — a git call whose stdout feeds a decision must have its status read', () => {
836
- /** A dirty tree with BOTH a tracked edit and a genuinely staged new file. */
837
- function mixedFixture(label) {
838
- const fx = makeFixture(label);
839
- pushToMain(fx, { 'main-only.txt': 'main only\n' }, 'main moves on');
840
- writeFileSync(path.join(fx.wt, 'base.txt'), 'TRACKED EDIT\n');
841
- writeFileSync(path.join(fx.wt, 'newfile.txt'), 'IMPORTANT NEW BYTES\n');
842
- git(fx.wt, ['add', 'newfile.txt']);
843
- return fx;
844
- }
845
- function failing(fx, match) {
846
- return {
847
- ...fx.deps,
848
- exec: (file, args, options) => {
849
- if (file === 'git' && match(args)) {
850
- return { status: 128, stdout: '', stderr: 'fatal: simulated git failure' };
851
- }
852
- return defaultExecFile(file, args, options);
853
- },
854
- };
855
- }
856
- it('the staged-new diff: a failure refuses instead of silently restoring nothing', () => {
857
- const fx = mixedFixture('status-stagednew');
858
- const headBefore = git(fx.wt, ['rev-parse', 'HEAD']).trim();
859
- const statusBefore = git(fx.wt, ['status', '--porcelain']);
860
- // Fail ONLY `git diff --cached ... --diff-filter=A`. Before the fix its
861
- // empty stdout read as "no staged-new files", `stageTree` got no extraAdd
862
- // and succeeded, and the run reported `ok` while deleting the file:
863
- // `AD newfile.txt`, absent from disk, exit 0.
864
- const r = sync(fx, { deps: failing(fx, (a) => a[0] === 'diff' && a.includes('--diff-filter=A')) });
865
- expect(r.audit.outcome).toBe('restore-failed');
866
- expect(r.audit.outcome).not.toBe('ok');
867
- expect(r.exitCode).not.toBe(0);
868
- expect(r.checkpointRef).toBeTruthy();
869
- expect(r.lines.join('\n')).toContain(r.checkpointRef);
870
- expect(r.lines.join('\n')).not.toContain('Restored the checkpointed working tree');
871
- // Refused BEFORE mutating: nothing moved at all.
872
- expect(git(fx.wt, ['rev-parse', 'HEAD']).trim()).toBe(headBefore);
873
- expect(git(fx.wt, ['status', '--porcelain'])).toBe(statusBefore);
874
- expect(git(fx.wt, ['status', '--porcelain'])).not.toContain('AD');
875
- expect(existsSync(path.join(fx.wt, 'newfile.txt'))).toBe(true);
876
- expect(readFileSync(path.join(fx.wt, 'newfile.txt'), 'utf-8')).toBe('IMPORTANT NEW BYTES\n');
877
- expect(readFileSync(path.join(fx.wt, 'base.txt'), 'utf-8')).toBe('TRACKED EDIT\n');
878
- });
879
- it('the HEAD tree lookup: a failure fails the checkpoint rather than comparing against an empty tree', () => {
880
- const fx = mixedFixture('status-headtree');
881
- const headBefore = git(fx.wt, ['rev-parse', 'HEAD']).trim();
882
- // `rev-parse <head>^{tree}` feeds two `!==` comparisons. An unread failure
883
- // returns '', which is unequal to every real tree, so both would answer
884
- // "changed" for a tree that did not change.
885
- const r = sync(fx, {
886
- deps: failing(fx, (a) => a[0] === 'rev-parse' && typeof a[1] === 'string' && a[1].endsWith('^{commit}') === false && a[1].endsWith('^{tree}')),
887
- });
888
- expect(r.audit.outcome).not.toBe('ok');
889
- expect(r.exitCode).not.toBe(0);
890
- expect(git(fx.wt, ['rev-parse', 'HEAD']).trim()).toBe(headBefore);
891
- expect(readFileSync(path.join(fx.wt, 'newfile.txt'), 'utf-8')).toBe('IMPORTANT NEW BYTES\n');
892
- });
893
- it('the staged-path list in the restore: a failure is reported, not treated as an empty list', () => {
894
- const fx = mixedFixture('status-changed');
895
- // `diff --name-only -z <head> <indexCommit>` decides which paths get their
896
- // index entries put back. An unread failure yields [], so the index restore
897
- // is skipped and the run still claims `restored`.
898
- const r = sync(fx, {
899
- deps: failing(fx, (a) => a[0] === 'diff' && a.includes('--name-only') && a.includes('-z') && !a.includes('--cached')),
900
- });
901
- expect(r.audit.outcome).not.toBe('ok');
902
- expect(r.exitCode).not.toBe(0);
903
- expect(r.lines.join('\n')).not.toContain('Restored the checkpointed working tree');
904
- // Whatever happened, the work is still in the ref.
905
- expect(git(fx.wt, ['show', `${r.checkpointRef}^2:newfile.txt`])).toBe('IMPORTANT NEW BYTES\n');
906
- expect(git(fx.wt, ['show', `${r.checkpointRef}:base.txt`])).toBe('TRACKED EDIT\n');
907
- });
908
- it('--no-restore is unaffected by a staged-new diff failure, because it does not restore', () => {
909
- const fx = mixedFixture('status-norestore');
910
- const r = sync(fx, {
911
- restore: false,
912
- deps: failing(fx, (a) => a[0] === 'diff' && a.includes('--diff-filter=A')),
913
- });
914
- expect(r.exitCode).toBe(0);
915
- expect(r.audit.outcome).toBe('ok');
916
- expect(git(fx.wt, ['show', `${r.checkpointRef}^2:newfile.txt`])).toBe('IMPORTANT NEW BYTES\n');
917
- });
918
- });
919
- //# sourceMappingURL=worktree-sync-hardening.test.js.map