@warpgogol/forge 7.0.0 → 8.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (455) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/bin/cli.js +6 -12
  3. package/bin/cli.ts +3 -2
  4. package/bin/resolve-entry.js +24 -0
  5. package/dist/bin/cli.js +3 -2
  6. package/dist/bin/cli.js.map +1 -1
  7. package/dist/os/authority/authority.module.d.ts +3 -0
  8. package/dist/os/authority/authority.module.d.ts.map +1 -0
  9. package/dist/os/authority/authority.module.js +169 -0
  10. package/dist/os/authority/authority.module.js.map +1 -0
  11. package/dist/os/authority/handlers/delegate-revoke.d.ts +15 -0
  12. package/dist/os/authority/handlers/delegate-revoke.d.ts.map +1 -0
  13. package/dist/os/authority/handlers/delegate-revoke.js +91 -0
  14. package/dist/os/authority/handlers/delegate-revoke.js.map +1 -0
  15. package/dist/os/authority/handlers/delegate.d.ts +14 -0
  16. package/dist/os/authority/handlers/delegate.d.ts.map +1 -0
  17. package/dist/os/authority/handlers/delegate.js +134 -0
  18. package/dist/os/authority/handlers/delegate.js.map +1 -0
  19. package/dist/os/authority/handlers/delegation-list.d.ts +12 -0
  20. package/dist/os/authority/handlers/delegation-list.d.ts.map +1 -0
  21. package/dist/os/authority/handlers/delegation-list.js +54 -0
  22. package/dist/os/authority/handlers/delegation-list.js.map +1 -0
  23. package/dist/os/authority/handlers/delegation-validate.d.ts +11 -0
  24. package/dist/os/authority/handlers/delegation-validate.d.ts.map +1 -0
  25. package/dist/os/authority/handlers/delegation-validate.js +132 -0
  26. package/dist/os/authority/handlers/delegation-validate.js.map +1 -0
  27. package/dist/os/authority/helpers.d.ts +36 -0
  28. package/dist/os/authority/helpers.d.ts.map +1 -0
  29. package/dist/os/authority/helpers.js +83 -0
  30. package/dist/os/authority/helpers.js.map +1 -0
  31. package/dist/os/authority/index.d.ts +2 -0
  32. package/dist/os/authority/index.d.ts.map +1 -0
  33. package/dist/os/authority/index.js +14 -0
  34. package/dist/os/authority/index.js.map +1 -0
  35. package/dist/os/compass/comment-safety.d.ts +83 -0
  36. package/dist/os/compass/comment-safety.d.ts.map +1 -0
  37. package/dist/os/compass/comment-safety.js +305 -0
  38. package/dist/os/compass/comment-safety.js.map +1 -0
  39. package/dist/os/compass/compass.module.d.ts.map +1 -1
  40. package/dist/os/compass/compass.module.js +47 -4
  41. package/dist/os/compass/compass.module.js.map +1 -1
  42. package/dist/os/compass/handlers/compass-change-summary-handler.d.ts +2 -1
  43. package/dist/os/compass/handlers/compass-change-summary-handler.d.ts.map +1 -1
  44. package/dist/os/compass/handlers/compass-change-summary-handler.js +34 -10
  45. package/dist/os/compass/handlers/compass-change-summary-handler.js.map +1 -1
  46. package/dist/os/compass/handlers/compass-docs-scaffold.d.ts.map +1 -1
  47. package/dist/os/compass/handlers/compass-docs-scaffold.js +54 -17
  48. package/dist/os/compass/handlers/compass-docs-scaffold.js.map +1 -1
  49. package/dist/os/compass/handlers/compass-header-scaffold-handler.d.ts +14 -0
  50. package/dist/os/compass/handlers/compass-header-scaffold-handler.d.ts.map +1 -0
  51. package/dist/os/compass/handlers/compass-header-scaffold-handler.js +261 -0
  52. package/dist/os/compass/handlers/compass-header-scaffold-handler.js.map +1 -0
  53. package/dist/os/compass/handlers/compass-header-scaffold.d.ts +31 -0
  54. package/dist/os/compass/handlers/compass-header-scaffold.d.ts.map +1 -0
  55. package/dist/os/compass/handlers/compass-header-scaffold.js +739 -0
  56. package/dist/os/compass/handlers/compass-header-scaffold.js.map +1 -0
  57. package/dist/os/compass/handlers/compass-inventory-handler.d.ts.map +1 -1
  58. package/dist/os/compass/handlers/compass-inventory-handler.js +8 -4
  59. package/dist/os/compass/handlers/compass-inventory-handler.js.map +1 -1
  60. package/dist/os/compass/handlers/compass-inventory.d.ts +6 -0
  61. package/dist/os/compass/handlers/compass-inventory.d.ts.map +1 -1
  62. package/dist/os/compass/handlers/compass-inventory.js +28 -13
  63. package/dist/os/compass/handlers/compass-inventory.js.map +1 -1
  64. package/dist/os/compass/handlers/compass-migrate-handler.d.ts.map +1 -1
  65. package/dist/os/compass/handlers/compass-migrate-handler.js +12 -26
  66. package/dist/os/compass/handlers/compass-migrate-handler.js.map +1 -1
  67. package/dist/os/compass/handlers/compass-migrate.d.ts +15 -2
  68. package/dist/os/compass/handlers/compass-migrate.d.ts.map +1 -1
  69. package/dist/os/compass/handlers/compass-migrate.js +58 -20
  70. package/dist/os/compass/handlers/compass-migrate.js.map +1 -1
  71. package/dist/os/compass/handlers/git-revision.d.ts +10 -0
  72. package/dist/os/compass/handlers/git-revision.d.ts.map +1 -1
  73. package/dist/os/compass/handlers/git-revision.js +58 -4
  74. package/dist/os/compass/handlers/git-revision.js.map +1 -1
  75. package/dist/os/compass/handlers/summary-record.d.ts +20 -5
  76. package/dist/os/compass/handlers/summary-record.d.ts.map +1 -1
  77. package/dist/os/compass/handlers/summary-record.js +175 -44
  78. package/dist/os/compass/handlers/summary-record.js.map +1 -1
  79. package/dist/os/compass/index.d.ts +1 -0
  80. package/dist/os/compass/index.d.ts.map +1 -1
  81. package/dist/os/compass/index.js +2 -0
  82. package/dist/os/compass/index.js.map +1 -1
  83. package/dist/os/compass/policy.d.ts +9 -0
  84. package/dist/os/compass/policy.d.ts.map +1 -1
  85. package/dist/os/compass/policy.js +11 -2
  86. package/dist/os/compass/policy.js.map +1 -1
  87. package/dist/os/core/core.module.js +1 -1
  88. package/dist/os/core/handlers/package-health.d.ts.map +1 -1
  89. package/dist/os/core/handlers/package-health.js +1 -6
  90. package/dist/os/core/handlers/package-health.js.map +1 -1
  91. package/dist/os/queue/types.d.ts +2 -0
  92. package/dist/os/queue/types.d.ts.map +1 -1
  93. package/dist/os/queue/types.js +3 -1
  94. package/dist/os/queue/types.js.map +1 -1
  95. package/dist/os/rfc/acceptance.d.ts.map +1 -1
  96. package/dist/os/rfc/acceptance.js +51 -1
  97. package/dist/os/rfc/acceptance.js.map +1 -1
  98. package/dist/os/rfc/decision-log.d.ts.map +1 -1
  99. package/dist/os/rfc/decision-log.js +21 -3
  100. package/dist/os/rfc/decision-log.js.map +1 -1
  101. package/dist/os/rfc/dna-trace.d.ts +2 -0
  102. package/dist/os/rfc/dna-trace.d.ts.map +1 -1
  103. package/dist/os/rfc/dna-trace.js +13 -4
  104. package/dist/os/rfc/dna-trace.js.map +1 -1
  105. package/dist/os/rfc/handlers/implement-stamp-origin.d.ts +37 -0
  106. package/dist/os/rfc/handlers/implement-stamp-origin.d.ts.map +1 -0
  107. package/dist/os/rfc/handlers/implement-stamp-origin.js +118 -0
  108. package/dist/os/rfc/handlers/implement-stamp-origin.js.map +1 -0
  109. package/dist/os/rfc/handlers/implement-stamp.d.ts +41 -1
  110. package/dist/os/rfc/handlers/implement-stamp.d.ts.map +1 -1
  111. package/dist/os/rfc/handlers/implement-stamp.js +594 -81
  112. package/dist/os/rfc/handlers/implement-stamp.js.map +1 -1
  113. package/dist/os/rfc/handlers/rfc-evidence-sync.d.ts +42 -0
  114. package/dist/os/rfc/handlers/rfc-evidence-sync.d.ts.map +1 -0
  115. package/dist/os/rfc/handlers/rfc-evidence-sync.js +147 -0
  116. package/dist/os/rfc/handlers/rfc-evidence-sync.js.map +1 -0
  117. package/dist/os/rfc/handlers/validate-rules.d.ts +9 -1
  118. package/dist/os/rfc/handlers/validate-rules.d.ts.map +1 -1
  119. package/dist/os/rfc/handlers/validate-rules.js +90 -9
  120. package/dist/os/rfc/handlers/validate-rules.js.map +1 -1
  121. package/dist/os/rfc/reachable-symbol.d.ts +17 -0
  122. package/dist/os/rfc/reachable-symbol.d.ts.map +1 -0
  123. package/dist/os/rfc/reachable-symbol.js +376 -0
  124. package/dist/os/rfc/reachable-symbol.js.map +1 -0
  125. package/dist/os/rfc/rfc.module.d.ts.map +1 -1
  126. package/dist/os/rfc/rfc.module.js +89 -5
  127. package/dist/os/rfc/rfc.module.js.map +1 -1
  128. package/dist/os/rfc/types.d.ts +89 -12
  129. package/dist/os/rfc/types.d.ts.map +1 -1
  130. package/dist/os/rfc/types.js +17 -10
  131. package/dist/os/rfc/types.js.map +1 -1
  132. package/dist/os/rfc/verification-evidence.d.ts +10 -1
  133. package/dist/os/rfc/verification-evidence.d.ts.map +1 -1
  134. package/dist/os/rfc/verification-evidence.js +175 -10
  135. package/dist/os/rfc/verification-evidence.js.map +1 -1
  136. package/dist/os/rfc/verification-origin.d.ts +58 -0
  137. package/dist/os/rfc/verification-origin.d.ts.map +1 -0
  138. package/dist/os/rfc/verification-origin.js +346 -0
  139. package/dist/os/rfc/verification-origin.js.map +1 -0
  140. package/dist/os/rfc/verification-refresh.d.ts.map +1 -1
  141. package/dist/os/rfc/verification-refresh.js +11 -1
  142. package/dist/os/rfc/verification-refresh.js.map +1 -1
  143. package/dist/os/rfc/verify-workspace.d.ts +23 -0
  144. package/dist/os/rfc/verify-workspace.d.ts.map +1 -0
  145. package/dist/os/rfc/verify-workspace.js +278 -0
  146. package/dist/os/rfc/verify-workspace.js.map +1 -0
  147. package/dist/os/session/handlers/metrics-rfc.d.ts.map +1 -1
  148. package/dist/os/session/handlers/metrics-rfc.js +3 -0
  149. package/dist/os/session/handlers/metrics-rfc.js.map +1 -1
  150. package/dist/os/session/handlers/save.d.ts.map +1 -1
  151. package/dist/os/session/handlers/save.js +41 -10
  152. package/dist/os/session/handlers/save.js.map +1 -1
  153. package/dist/os/spec/spec-status.d.ts.map +1 -1
  154. package/dist/os/spec/spec-status.js +5 -23
  155. package/dist/os/spec/spec-status.js.map +1 -1
  156. package/dist/os/spec/spec-validate.d.ts.map +1 -1
  157. package/dist/os/spec/spec-validate.js +30 -9
  158. package/dist/os/spec/spec-validate.js.map +1 -1
  159. package/dist/os/workflow/handlers.d.ts +0 -4
  160. package/dist/os/workflow/handlers.d.ts.map +1 -1
  161. package/dist/os/workflow/handlers.js +9 -36
  162. package/dist/os/workflow/handlers.js.map +1 -1
  163. package/dist/os/workflow/index.d.ts +2 -2
  164. package/dist/os/workflow/index.d.ts.map +1 -1
  165. package/dist/os/workflow/index.js +1 -1
  166. package/dist/os/workflow/index.js.map +1 -1
  167. package/dist/os/workflow/types.d.ts +0 -19
  168. package/dist/os/workflow/types.d.ts.map +1 -1
  169. package/dist/os/workflow/types.js +0 -2
  170. package/dist/os/workflow/types.js.map +1 -1
  171. package/dist/os/workflow/workflow.module.d.ts.map +1 -1
  172. package/dist/os/workflow/workflow.module.js +6 -15
  173. package/dist/os/workflow/workflow.module.js.map +1 -1
  174. package/dist/src/authority/delegations.d.ts +108 -0
  175. package/dist/src/authority/delegations.d.ts.map +1 -0
  176. package/dist/src/authority/delegations.js +217 -0
  177. package/dist/src/authority/delegations.js.map +1 -0
  178. package/dist/src/authority/index.d.ts +3 -0
  179. package/dist/src/authority/index.d.ts.map +1 -0
  180. package/dist/src/authority/index.js +17 -0
  181. package/dist/src/authority/index.js.map +1 -0
  182. package/dist/src/authority/signing.d.ts +8 -0
  183. package/dist/src/authority/signing.d.ts.map +1 -0
  184. package/dist/src/authority/signing.js +72 -0
  185. package/dist/src/authority/signing.js.map +1 -0
  186. package/dist/src/config/forge-config.d.ts +5 -0
  187. package/dist/src/config/forge-config.d.ts.map +1 -1
  188. package/dist/src/config/forge-config.js +5 -2
  189. package/dist/src/config/forge-config.js.map +1 -1
  190. package/dist/src/onboarding/agents-generate.js +1 -1
  191. package/dist/src/onboarding/doctor.js +3 -3
  192. package/dist/src/onboarding/doctor.js.map +1 -1
  193. package/dist/src/onboarding/init.js +2 -2
  194. package/dist/src/onboarding/nested-agents-templates.js +1 -1
  195. package/dist/src/onboarding/prettierignore.js +1 -1
  196. package/dist/src/onboarding/upgrade.js +2 -2
  197. package/dist/src/onboarding/workspace-discovery.js +1 -1
  198. package/dist/src/profiles/profile-schema.d.ts +2 -0
  199. package/dist/src/profiles/profile-schema.d.ts.map +1 -1
  200. package/dist/src/profiles/profile-schema.js +1 -0
  201. package/dist/src/profiles/profile-schema.js.map +1 -1
  202. package/dist/src/profiles/stack-profile.d.ts +1 -0
  203. package/dist/src/profiles/stack-profile.d.ts.map +1 -1
  204. package/dist/src/types.d.ts +23 -0
  205. package/dist/src/types.d.ts.map +1 -1
  206. package/dist/src/types.js +2 -1
  207. package/dist/src/types.js.map +1 -1
  208. package/docs/reference/cli.md +0 -1
  209. package/docs/reference/programmatic-api.md +1 -1
  210. package/os/adr/handlers/validate.test.ts +14 -0
  211. package/os/authority/authority.module.ts +183 -0
  212. package/os/authority/authority.test.ts +328 -0
  213. package/os/authority/handlers/delegate-revoke.ts +123 -0
  214. package/os/authority/handlers/delegate.ts +190 -0
  215. package/os/authority/handlers/delegation-list.ts +80 -0
  216. package/os/authority/handlers/delegation-validate.ts +231 -0
  217. package/os/authority/helpers.ts +111 -0
  218. package/os/authority/index.ts +14 -0
  219. package/os/compass/comment-safety.ts +331 -0
  220. package/os/compass/compass.module.ts +50 -4
  221. package/os/compass/handlers/compass-change-summary-handler.ts +41 -11
  222. package/os/compass/handlers/compass-docs-scaffold.ts +59 -17
  223. package/os/compass/handlers/compass-game-extensions.test.ts +3 -7
  224. package/os/compass/handlers/compass-header-scaffold-handler.ts +352 -0
  225. package/os/compass/handlers/compass-header-scaffold.ts +847 -0
  226. package/os/compass/handlers/compass-inventory-handler.ts +9 -4
  227. package/os/compass/handlers/compass-inventory.ts +29 -13
  228. package/os/compass/handlers/compass-migrate-handler.ts +13 -27
  229. package/os/compass/handlers/compass-migrate.ts +77 -21
  230. package/os/compass/handlers/git-revision.ts +59 -4
  231. package/os/compass/handlers/resolve-scan-root-package.test.ts +14 -0
  232. package/os/compass/handlers/resolve-scan-root-workpiece.test.ts +14 -0
  233. package/os/compass/handlers/summary-record.ts +194 -41
  234. package/os/compass/handlers/tests/compass-audit-plan.test.ts +6 -0
  235. package/os/compass/handlers/tests/compass-audit-record.test.ts +6 -0
  236. package/os/compass/handlers/tests/compass-audit-validate.test.ts +6 -0
  237. package/os/compass/handlers/tests/compass-change-summary-handler.test.ts +131 -0
  238. package/os/compass/handlers/tests/compass-docs-validate.test.ts +6 -0
  239. package/os/compass/handlers/tests/compass-header-scaffold.test.ts +896 -0
  240. package/os/compass/handlers/tests/compass-ledger-scope.test.ts +6 -0
  241. package/os/compass/handlers/tests/compass-migrate.test.ts +87 -9
  242. package/os/compass/handlers/tests/compass-policy.test.ts +1 -1
  243. package/os/compass/handlers/tests/compass-text-safety.test.ts +271 -0
  244. package/os/compass/handlers/tests/compass-v2-contract.test.ts +52 -3
  245. package/os/compass/handlers/tests/summary-record.test.ts +324 -3
  246. package/os/compass/index.ts +15 -0
  247. package/os/compass/policy.ts +27 -2
  248. package/os/core/core.module.ts +1 -1
  249. package/os/core/handlers/invariant-engine.test.ts +3 -1
  250. package/os/core/handlers/note-frontmatter-validate.test.ts +6 -1
  251. package/os/core/handlers/note-link-validate.test.ts +6 -1
  252. package/os/core/handlers/note-orphan-detect.test.ts +6 -1
  253. package/os/core/handlers/package-health.test.ts +6 -0
  254. package/os/core/handlers/package-health.ts +1 -6
  255. package/os/mission/handlers/archive.test.ts +14 -0
  256. package/os/naming/naming-convention.test.ts +14 -0
  257. package/os/queue/decision-ledger.test.ts +27 -4
  258. package/os/queue/queue-validate.test.ts +14 -0
  259. package/os/queue/types.ts +3 -1
  260. package/os/rfc/acceptance-reachable.test.ts +146 -0
  261. package/os/rfc/acceptance.test.ts +25 -0
  262. package/os/rfc/acceptance.ts +51 -1
  263. package/os/rfc/decision-log.ts +22 -4
  264. package/os/rfc/dna-trace.ts +17 -5
  265. package/os/rfc/frontmatter-io.test.ts +14 -0
  266. package/os/rfc/handlers/implement-stamp-acceptance-verification.test.ts +81 -0
  267. package/os/rfc/handlers/implement-stamp-binding.test.ts +79 -0
  268. package/os/rfc/handlers/implement-stamp-origin.test.ts +132 -0
  269. package/os/rfc/handlers/implement-stamp-origin.ts +154 -0
  270. package/os/rfc/handlers/implement-stamp-stale.test.ts +20 -2
  271. package/os/rfc/handlers/implement-stamp.ts +714 -87
  272. package/os/rfc/handlers/lifecycle.test.ts +14 -0
  273. package/os/rfc/handlers/rfc-evidence-sync.ts +221 -0
  274. package/os/rfc/handlers/validate-rules-rfc0997.test.ts +14 -0
  275. package/os/rfc/handlers/validate-rules-rfc1006.test.ts +14 -0
  276. package/os/rfc/handlers/validate-rules-rfc1330.test.ts +120 -0
  277. package/os/rfc/handlers/validate-rules-rfc1334.test.ts +65 -0
  278. package/os/rfc/handlers/validate-rules.test.ts +14 -0
  279. package/os/rfc/handlers/validate-rules.ts +122 -13
  280. package/os/rfc/handlers/validate.test.ts +4 -3
  281. package/os/rfc/reachable-symbol.ts +441 -0
  282. package/os/rfc/rfc-0000-template.md +3 -0
  283. package/os/rfc/rfc-create-concurrent.test.ts +6 -0
  284. package/os/rfc/rfc-create-hint.test.ts +6 -0
  285. package/os/rfc/rfc-read-only-no-side-effects.test.ts +6 -0
  286. package/os/rfc/rfc.module.ts +95 -5
  287. package/os/rfc/types.ts +116 -12
  288. package/os/rfc/verification-emit-check.test.ts +14 -0
  289. package/os/rfc/verification-emit-freshness.test.ts +415 -0
  290. package/os/rfc/verification-emit.test.ts +14 -0
  291. package/os/rfc/verification-evidence.ts +230 -10
  292. package/os/rfc/verification-normalize.test.ts +14 -0
  293. package/os/rfc/verification-origin.test.ts +236 -0
  294. package/os/rfc/verification-origin.ts +417 -0
  295. package/os/rfc/verification-refresh.test.ts +14 -0
  296. package/os/rfc/verification-refresh.ts +12 -1
  297. package/os/rfc/verifier/rfc-1333/imp12-binding.acceptance.test.ts +78 -0
  298. package/os/rfc/verifier/rfc-1333/imp12-gate.acceptance.test.ts +81 -0
  299. package/os/rfc/verifier/rfc-1333/skills-and-types.acceptance.test.ts +50 -0
  300. package/os/rfc/verifier/rfc-1333/verify-workspace.acceptance.test.ts +103 -0
  301. package/os/rfc/verify-workspace.test.ts +122 -0
  302. package/os/rfc/verify-workspace.ts +342 -0
  303. package/os/session/handlers/metrics-rfc.ts +3 -0
  304. package/os/session/handlers/save.ts +43 -9
  305. package/os/spec/spec-status.test.ts +130 -0
  306. package/os/spec/spec-status.ts +5 -18
  307. package/os/spec/spec-validate.test.ts +76 -1
  308. package/os/spec/spec-validate.ts +26 -7
  309. package/os/workflow/handlers.ts +8 -42
  310. package/os/workflow/index.ts +1 -4
  311. package/os/workflow/types.ts +0 -22
  312. package/os/workflow/workflow.module.ts +6 -16
  313. package/package.json +13 -1
  314. package/skills/_shared/agent-operating-model.md +1 -1
  315. package/skills/_shared/fo-pipeline-conventions.md +1 -0
  316. package/skills/fo/fo-add-tests/SKILL.md +14 -0
  317. package/skills/fo/fo-fix/SKILL.md +2 -1
  318. package/skills/fo/fo-handoff/SKILL.md +1 -1
  319. package/skills/fo/fo-idea-create-rfc/acceptance-criteria-standard.md +8 -0
  320. package/skills/fo/fo-idea-i-just-want-to-see-the-result/SKILL.md +4 -2
  321. package/skills/fo/fo-idea-implement/SKILL.md +68 -53
  322. package/skills/fo/fo-idea-plan/SKILL.md +3 -1
  323. package/skills/fo/fo-review/SKILL.md +12 -0
  324. package/skills/fo/fo-session-save/learned-principles.md +13 -0
  325. package/skills/fo/fo-step-commit/SKILL.md +1 -1
  326. package/src/authority/delegations.ts +267 -0
  327. package/src/authority/index.ts +38 -0
  328. package/src/authority/signing.ts +73 -0
  329. package/src/bin-entry.test.ts +37 -0
  330. package/src/compass/contract-registry.test.ts +14 -0
  331. package/src/compass/types.test.ts +14 -0
  332. package/src/config/__tests__/resolve-terminology.test.ts +14 -0
  333. package/src/config/forge-config.test.ts +14 -0
  334. package/src/config/forge-config.ts +7 -2
  335. package/src/forge-module.test.ts +14 -0
  336. package/src/knowledge/__tests__/promote.test.ts +14 -0
  337. package/src/knowledge/__tests__/serialize.test.ts +14 -0
  338. package/src/knowledge/__tests__/sync.test.ts +4 -1
  339. package/src/knowledge/budgets.test.ts +14 -0
  340. package/src/knowledge/compact.test.ts +14 -0
  341. package/src/knowledge/parse.test.ts +14 -0
  342. package/src/knowledge/schema.test.ts +14 -0
  343. package/src/migration-adapters/__tests__/ignored-files.test.ts +14 -0
  344. package/src/migration-adapters/__tests__/registry.test.ts +14 -0
  345. package/src/migration-adapters/__tests__/types.test.ts +14 -0
  346. package/src/onboarding/__tests__/workspace-discovery.test.ts +14 -0
  347. package/src/onboarding/agents-generate.ts +1 -1
  348. package/src/onboarding/compass-docs/semantic-layer-block.test.ts +6 -0
  349. package/src/onboarding/create.test.ts +14 -0
  350. package/src/onboarding/doctor-token-check.test.ts +3 -0
  351. package/src/onboarding/doctor.test.ts +14 -0
  352. package/src/onboarding/doctor.ts +3 -3
  353. package/src/onboarding/init.test.ts +14 -0
  354. package/src/onboarding/init.ts +2 -2
  355. package/src/onboarding/nested-agents-templates.ts +1 -1
  356. package/src/onboarding/prettierignore.ts +1 -1
  357. package/src/onboarding/scaffold.test.ts +14 -0
  358. package/src/onboarding/site-workshop-profile.test.ts +3 -0
  359. package/src/onboarding/upgrade.test.ts +14 -0
  360. package/src/onboarding/upgrade.ts +2 -2
  361. package/src/onboarding/workspace-discovery.ts +1 -1
  362. package/src/pipeline-status.test.ts +14 -0
  363. package/src/plugin/forge-plugin-manifest.test.ts +14 -0
  364. package/src/profiles/__tests__/profile-schema.test.ts +14 -0
  365. package/src/profiles/__tests__/stack-profile.test.ts +14 -0
  366. package/src/profiles/__tests__/terminology-utils.test.ts +14 -0
  367. package/src/profiles/profile-schema.ts +1 -0
  368. package/src/tests/acceptance-criteria.test.ts +14 -0
  369. package/src/tests/acceptance-probe-kinds.test.ts +14 -0
  370. package/src/tests/adr-implement-stamp.test.ts +14 -0
  371. package/src/tests/agents-generate-domain.test.ts +3 -0
  372. package/src/tests/agents-generate.test.ts +3 -0
  373. package/src/tests/bindings-schema.test.ts +2 -0
  374. package/src/tests/budgets.test.ts +14 -0
  375. package/src/tests/compact.test.ts +14 -0
  376. package/src/tests/compass-docs-flag.test.ts +6 -0
  377. package/src/tests/compass-docs-scaffold.test.ts +6 -0
  378. package/src/tests/compass-docs-validate-scope.test.ts +6 -0
  379. package/src/tests/contract-registry.test.ts +14 -0
  380. package/src/tests/create.test.ts +3 -0
  381. package/src/tests/discover-pack-skills.test.ts +14 -0
  382. package/src/tests/doctor-autonomy.test.ts +3 -0
  383. package/src/tests/doctor-bindings.test.ts +6 -1
  384. package/src/tests/doctor-dist-freshness.test.ts +26 -2
  385. package/src/tests/doctor-domain.test.ts +6 -1
  386. package/src/tests/doctor-fix.test.ts +3 -0
  387. package/src/tests/doctor-nested-agents.test.ts +3 -0
  388. package/src/tests/doctor-profile-id-known.test.ts +3 -0
  389. package/src/tests/doctor-skills-unmanaged.test.ts +3 -0
  390. package/src/tests/doctor-version-sync.test.ts +4 -1
  391. package/src/tests/editable-generated-region.test.ts +6 -3
  392. package/src/tests/exploration-handlers.test.ts +14 -0
  393. package/src/tests/file-size-lint.test.ts +6 -1
  394. package/src/tests/forge-autonomy-validate.test.ts +3 -1
  395. package/src/tests/forge-config.test.ts +6 -1
  396. package/src/tests/forge-validate-compass-docs.test.ts +6 -0
  397. package/src/tests/fs-atomic.test.ts +14 -0
  398. package/src/tests/fs.test.ts +14 -0
  399. package/src/tests/generated-marker.test.ts +14 -0
  400. package/src/tests/hash.test.ts +14 -0
  401. package/src/tests/implement-stamp.test.ts +476 -10
  402. package/src/tests/init-bindings.test.ts +6 -1
  403. package/src/tests/knowledge-parse.test.ts +14 -0
  404. package/src/tests/knowledge-pbt.test.ts +14 -0
  405. package/src/tests/markdown-table.test.ts +6 -3
  406. package/src/tests/memory-compact.test.ts +3 -0
  407. package/src/tests/memory-scaffold.test.ts +6 -1
  408. package/src/tests/metrics-rfc-1053.test.ts +14 -0
  409. package/src/tests/migration-adapters.test.ts +3 -0
  410. package/src/tests/package-files.test.ts +4 -1
  411. package/src/tests/package-health-lint-surface.test.ts +3 -0
  412. package/src/tests/pinned-check.test.ts +14 -0
  413. package/src/tests/pinned-init.test.ts +14 -0
  414. package/src/tests/pinned-validate.test.ts +14 -0
  415. package/src/tests/plugin-manifest.test.ts +14 -0
  416. package/src/tests/prettierignore-manage.test.ts +3 -0
  417. package/src/tests/profile-schema.test.ts +6 -1
  418. package/src/tests/profile-validate.test.ts +6 -1
  419. package/src/tests/program-lease.test.ts +3 -0
  420. package/src/tests/program-paths-extended.test.ts +3 -0
  421. package/src/tests/program-paths.test.ts +3 -0
  422. package/src/tests/program-property.test.ts +3 -0
  423. package/src/tests/program-schemas.test.ts +3 -0
  424. package/src/tests/program-spec-node.test.ts +3 -0
  425. package/src/tests/promote.test.ts +14 -0
  426. package/src/tests/public-surface.test.ts +6 -1
  427. package/src/tests/registry.test.ts +14 -0
  428. package/src/tests/rfc-evidence-sync.test.ts +347 -0
  429. package/src/tests/rfc-implement-stamp-governance.test.ts +403 -0
  430. package/src/tests/rfc-validate-delegation.test.ts +178 -0
  431. package/src/tests/scaffold-project.test.ts +3 -0
  432. package/src/tests/session-handlers.test.ts +79 -0
  433. package/src/tests/session-pbt.test.ts +14 -0
  434. package/src/tests/skill-agents-sync.test.ts +3 -4
  435. package/src/tests/skill-schema.test.ts +14 -0
  436. package/src/tests/skill-sync-marker.test.ts +3 -0
  437. package/src/tests/skill-validate-knowledge.test.ts +14 -0
  438. package/src/tests/skill-validate.test.ts +14 -0
  439. package/src/tests/stack-profile.test.ts +6 -1
  440. package/src/tests/string-utils.test.ts +14 -0
  441. package/src/tests/upgrade.test.ts +6 -1
  442. package/src/tests/werkstatt-lock.test.ts +14 -0
  443. package/src/tests/workspace-discovery-domain.test.ts +6 -1
  444. package/src/tests/workspace-discovery.test.ts +6 -1
  445. package/src/types.test.ts +14 -0
  446. package/src/types.ts +30 -1
  447. package/src/utils/__tests__/fs-idempotent.test.ts +17 -0
  448. package/src/utils/__tests__/fs-trash.test.ts +17 -0
  449. package/src/utils/fs-atomic.test.ts +17 -0
  450. package/src/utils/fs-trash-sync.test.ts +17 -0
  451. package/src/utils/fs.test.ts +17 -0
  452. package/src/utils/generated-marker.test.ts +17 -0
  453. package/src/utils/hash.test.ts +17 -0
  454. package/src/utils/string-utils.test.ts +17 -0
  455. package/src/validators/__tests__/note-orphan-detect.test.ts +14 -0
@@ -1,3 +1,17 @@
1
+ /*
2
+ <MODULE_CONTRACT>
3
+ <purpose>
4
+ Unit tests for metrics rfc 1053 covering RFC-1053: generateRfcMetrics; RFC-1053: generateSessionMetrics; RFC-1053: metrics.aggregate.
5
+ </purpose>
6
+ <non-goals>
7
+ <item>Not a contract source of truth — the module under test owns the authoritative behavior; fixtures are minimal scaffolding only.</item>
8
+ </non-goals>
9
+ </MODULE_CONTRACT>
10
+ <CHANGE_SUMMARY>
11
+ <item>RFC-1311: Compass header sweep — declares the metrics suite's contract for test-file scaffold coverage.</item>
12
+ </CHANGE_SUMMARY>
13
+ */
14
+
1
15
  import { describe, it, expect, beforeEach, afterEach } from "vitest";
2
16
  import { mkdtemp, rm, mkdir, writeFile, readFile } from "node:fs/promises";
3
17
  import { join } from "node:path";
@@ -1,6 +1,9 @@
1
1
  /*
2
2
  <MODULE_CONTRACT>
3
3
  <purpose>Unit tests for migration-adapter module — adapter detect/analyze/migrate, registry discovery, forge-protected file enforcement (RFC-0546).</purpose>
4
+ <non-goals>
5
+ <item>Not a contract source of truth — the module under test owns the authoritative behavior; fixtures are minimal scaffolding only.</item>
6
+ </non-goals>
4
7
  </MODULE_CONTRACT>
5
8
  <CHANGE_SUMMARY>
6
9
  <item>RFC-0546: initial migration-adapter tests.</item>
@@ -3,9 +3,12 @@
3
3
  <purpose>Verify that template files referenced by source code are included in the npm package
4
4
  (files array in package.json). Prevents shipping bugs where template files exist on disk
5
5
  but are missing from the published package.</purpose>
6
+ <non-goals>
7
+ <item>Not a contract source of truth — the module under test owns the authoritative behavior; fixtures are minimal scaffolding only.</item>
8
+ </non-goals>
6
9
  </MODULE_CONTRACT>
7
10
  <CHANGE_SUMMARY>
8
- <item>Initial test: verify onboarding templates are in package.json files array.</item>
11
+ <item>RFC-1311: carried legacy entry — Initial test: verify onboarding templates are in package.json files array.</item>
9
12
  </CHANGE_SUMMARY>
10
13
  */
11
14
 
@@ -7,6 +7,9 @@ per-package lint-surface: fail and flip passed/exitCode.</purpose>
7
7
  <item>Does not exercise the real pnpm execFileSync runner — the lint subprocess is stubbed via the injected lintRunner seam.</item>
8
8
  </non-goals>
9
9
  </MODULE_CONTRACT>
10
+ <CHANGE_SUMMARY>
11
+ <item>RFC-1311: Compass header sweep — declares the package suite's contract for test-file scaffold coverage.</item>
12
+ </CHANGE_SUMMARY>
10
13
  */
11
14
 
12
15
  import { test, expect, beforeEach, afterEach } from "vitest";
@@ -1,3 +1,17 @@
1
+ /*
2
+ <MODULE_CONTRACT>
3
+ <purpose>
4
+ Unit tests for pinned check covering loadPinnedManifest; isPinned; checkFilesForPinned. It also guards the documented public contract and regression-sensitive edge cases.
5
+ </purpose>
6
+ <non-goals>
7
+ <item>Not a contract source of truth — the module under test owns the authoritative behavior; fixtures are minimal scaffolding only.</item>
8
+ </non-goals>
9
+ </MODULE_CONTRACT>
10
+ <CHANGE_SUMMARY>
11
+ <item>RFC-1311: Compass header sweep — declares the pinned suite's contract for test-file scaffold coverage.</item>
12
+ </CHANGE_SUMMARY>
13
+ */
14
+
1
15
  import { test, expect, describe } from "vitest";
2
16
  import { mkdtemp, rm, mkdir, writeFile } from "node:fs/promises";
3
17
  import { join } from "node:path";
@@ -1,3 +1,17 @@
1
+ /*
2
+ <MODULE_CONTRACT>
3
+ <purpose>
4
+ Unit tests for pinned init covering runPinnedInit. It also guards the documented public contract and regression-sensitive edge cases.
5
+ </purpose>
6
+ <non-goals>
7
+ <item>Not a contract source of truth — the module under test owns the authoritative behavior; fixtures are minimal scaffolding only.</item>
8
+ </non-goals>
9
+ </MODULE_CONTRACT>
10
+ <CHANGE_SUMMARY>
11
+ <item>RFC-1311: Compass header sweep — declares the pinned suite's contract for test-file scaffold coverage.</item>
12
+ </CHANGE_SUMMARY>
13
+ */
14
+
1
15
  import { test, expect, describe } from "vitest";
2
16
  import { mkdtemp, rm, mkdir, writeFile, readFile } from "node:fs/promises";
3
17
  import { existsSync } from "node:fs";
@@ -1,3 +1,17 @@
1
+ /*
2
+ <MODULE_CONTRACT>
3
+ <purpose>
4
+ Unit tests for pinned validate covering runPinnedValidate. It also guards the documented public contract and regression-sensitive edge cases.
5
+ </purpose>
6
+ <non-goals>
7
+ <item>Not a contract source of truth — the module under test owns the authoritative behavior; fixtures are minimal scaffolding only.</item>
8
+ </non-goals>
9
+ </MODULE_CONTRACT>
10
+ <CHANGE_SUMMARY>
11
+ <item>RFC-1311: Compass header sweep — declares the pinned suite's contract for test-file scaffold coverage.</item>
12
+ </CHANGE_SUMMARY>
13
+ */
14
+
1
15
  import { test, expect, describe } from "vitest";
2
16
  import { mkdtemp, rm, mkdir, writeFile } from "node:fs/promises";
3
17
  import { execFile } from "node:child_process";
@@ -1,3 +1,17 @@
1
+ /*
2
+ <MODULE_CONTRACT>
3
+ <purpose>
4
+ Unit tests for plugin manifest covering forgePluginManifestSchema (RFC-0941, RFC-0943). It also guards the documented public contract and regression-sensitive edge cases.
5
+ </purpose>
6
+ <non-goals>
7
+ <item>Not a contract source of truth — the module under test owns the authoritative behavior; fixtures are minimal scaffolding only.</item>
8
+ </non-goals>
9
+ </MODULE_CONTRACT>
10
+ <CHANGE_SUMMARY>
11
+ <item>RFC-1311: Compass header sweep — declares the plugin suite's contract for test-file scaffold coverage.</item>
12
+ </CHANGE_SUMMARY>
13
+ */
14
+
1
15
  import { test, expect, describe } from "vitest";
2
16
  import { forgePluginManifestSchema } from "../plugin/forge-plugin-manifest.ts";
3
17
 
@@ -4,6 +4,9 @@
4
4
  root-only prettier detection, delimited-block reconcile preserving operator
5
5
  content, marker-driven skill entries, and the skipped contract for
6
6
  prettier-free consumers.</purpose>
7
+ <non-goals>
8
+ <item>Not a contract source of truth — the module under test owns the authoritative behavior; fixtures are minimal scaffolding only.</item>
9
+ </non-goals>
7
10
  </MODULE_CONTRACT>
8
11
  <CHANGE_SUMMARY>
9
12
  <item>RFC-1154: initial prettierignore plan/apply tests.</item>
@@ -1,6 +1,11 @@
1
1
  /*
2
2
  <MODULE_CONTRACT>
3
- <purpose>Unit tests for RFC-0638 domain-neutral profile schema extensions.</purpose>
3
+ <purpose>
4
+ Unit tests for profile schema covering its documented public contract and regression-sensitive edge cases.
5
+ </purpose>
6
+ <non-goals>
7
+ <item>Not a contract source of truth — the module under test owns the authoritative behavior; fixtures are minimal scaffolding only.</item>
8
+ </non-goals>
4
9
  </MODULE_CONTRACT>
5
10
  <CHANGE_SUMMARY>
6
11
  <item>RFC-0638: initial domain field tests — parsing, defaults, validation, backward compat.</item>
@@ -1,6 +1,11 @@
1
1
  /*
2
2
  <MODULE_CONTRACT>
3
- <purpose>Unit tests for forge.profile.validate command handler (RFC-0640).</purpose>
3
+ <purpose>
4
+ Unit tests for profile validate covering its documented public contract and regression-sensitive edge cases.
5
+ </purpose>
6
+ <non-goals>
7
+ <item>Not a contract source of truth — the module under test owns the authoritative behavior; fixtures are minimal scaffolding only.</item>
8
+ </non-goals>
4
9
  </MODULE_CONTRACT>
5
10
  <CHANGE_SUMMARY>
6
11
  <item>RFC-0640: initial profile-validate tests.</item>
@@ -3,6 +3,9 @@
3
3
  <purpose>Exclusive lease tests — concurrent starts, heartbeat, token mismatch,
4
4
  timeout, explicit recovery, interrupted seal/complete, and release after
5
5
  committed completion (RFC-0856 AC-6).</purpose>
6
+ <non-goals>
7
+ <item>Not a contract source of truth — the module under test owns the authoritative behavior; fixtures are minimal scaffolding only.</item>
8
+ </non-goals>
6
9
  </MODULE_CONTRACT>
7
10
  <CHANGE_SUMMARY>
8
11
  <item>RFC-0856: initial exclusive lease tests.</item>
@@ -3,6 +3,9 @@
3
3
  <purpose>Extended path tests — symlinks, traversal, case-only paths, Windows
4
4
  separators, deleted files, renames, generated files, and ecosystem.commit
5
5
  split ranges (RFC-0856 AC-7).</purpose>
6
+ <non-goals>
7
+ <item>Not a contract source of truth — the module under test owns the authoritative behavior; fixtures are minimal scaffolding only.</item>
8
+ </non-goals>
6
9
  </MODULE_CONTRACT>
7
10
  <CHANGE_SUMMARY>
8
11
  <item>RFC-0856: initial extended path tests.</item>
@@ -3,6 +3,9 @@
3
3
  <purpose>Unit tests for program packet path matching utilities — verify
4
4
  cross-platform glob matching, symlink safety, and forbidden path detection
5
5
  (RFC-0856).</purpose>
6
+ <non-goals>
7
+ <item>Not a contract source of truth — the module under test owns the authoritative behavior; fixtures are minimal scaffolding only.</item>
8
+ </non-goals>
6
9
  </MODULE_CONTRACT>
7
10
  <CHANGE_SUMMARY>
8
11
  <item>RFC-0856: initial path matching tests.</item>
@@ -3,6 +3,9 @@
3
3
  <purpose>Property-based tests — idempotent seal/complete retries, stable
4
4
  digests for identical bytes, and rejection when reordered YAML/JSON changes
5
5
  the sealed exact-byte source identity (RFC-0856 AC-8).</purpose>
6
+ <non-goals>
7
+ <item>Not a contract source of truth — the module under test owns the authoritative behavior; fixtures are minimal scaffolding only.</item>
8
+ </non-goals>
6
9
  </MODULE_CONTRACT>
7
10
  <CHANGE_SUMMARY>
8
11
  <item>RFC-0856: initial property tests.</item>
@@ -2,6 +2,9 @@
2
2
  <MODULE_CONTRACT>
3
3
  <purpose>Unit tests for program packet schemas — verify strict rejection of
4
4
  unknown fields, required fields, and type constraints (RFC-0856).</purpose>
5
+ <non-goals>
6
+ <item>Not a contract source of truth — the module under test owns the authoritative behavior; fixtures are minimal scaffolding only.</item>
7
+ </non-goals>
5
8
  </MODULE_CONTRACT>
6
9
  <CHANGE_SUMMARY>
7
10
  <item>RFC-0856: initial schema tests.</item>
@@ -4,6 +4,9 @@
4
4
  spec-node packets with null resolvedRfc are rejected at seal boundary
5
5
  (PROGRAM-PACKET-12) and that phase-aware lease schema accepts preparation
6
6
  and execution phases.</purpose>
7
+ <non-goals>
8
+ <item>Not a contract source of truth — the module under test owns the authoritative behavior; fixtures are minimal scaffolding only.</item>
9
+ </non-goals>
7
10
  </MODULE_CONTRACT>
8
11
  <CHANGE_SUMMARY>
9
12
  <item>RFC-0857: spec-node seal validation and phase-aware lease tests.</item>
@@ -1,3 +1,17 @@
1
+ /*
2
+ <MODULE_CONTRACT>
3
+ <purpose>
4
+ Unit tests for promote covering normalizeTitle; detectDuplicatePrinciples; planPromotion. It also guards the documented public contract and regression-sensitive edge cases.
5
+ </purpose>
6
+ <non-goals>
7
+ <item>Not a contract source of truth — the module under test owns the authoritative behavior; fixtures are minimal scaffolding only.</item>
8
+ </non-goals>
9
+ </MODULE_CONTRACT>
10
+ <CHANGE_SUMMARY>
11
+ <item>RFC-1311: Compass header sweep — declares the promote suite's contract for test-file scaffold coverage.</item>
12
+ </CHANGE_SUMMARY>
13
+ */
14
+
1
15
  import { test, expect, describe } from "vitest";
2
16
  import { normalizeTitle, detectDuplicatePrinciples, planPromotion } from "../knowledge/promote.ts";
3
17
  import type {
@@ -1,6 +1,11 @@
1
1
  /*
2
2
  <MODULE_CONTRACT>
3
- <purpose>Unit tests for forge.public-surface.validate — SURFACE-01..05 rules from RFC-1080.</purpose>
3
+ <purpose>
4
+ Unit tests for public surface covering its documented public contract and regression-sensitive edge cases.
5
+ </purpose>
6
+ <non-goals>
7
+ <item>Not a contract source of truth — the module under test owns the authoritative behavior; fixtures are minimal scaffolding only.</item>
8
+ </non-goals>
4
9
  </MODULE_CONTRACT>
5
10
  <CHANGE_SUMMARY>
6
11
  <item>RFC-1080: initial public-surface validator tests covering all 5 rules, exit codes, and monorepo resolution.</item>
@@ -1,3 +1,17 @@
1
+ /*
2
+ <MODULE_CONTRACT>
3
+ <purpose>
4
+ Unit tests for registry covering FORGE_SKILLS registry. It also guards the documented public contract and regression-sensitive edge cases.
5
+ </purpose>
6
+ <non-goals>
7
+ <item>Not a contract source of truth — the module under test owns the authoritative behavior; fixtures are minimal scaffolding only.</item>
8
+ </non-goals>
9
+ </MODULE_CONTRACT>
10
+ <CHANGE_SUMMARY>
11
+ <item>RFC-1311: Compass header sweep — declares the registry suite's contract for test-file scaffold coverage.</item>
12
+ </CHANGE_SUMMARY>
13
+ */
14
+
1
15
  import { test, expect, describe } from "vitest";
2
16
  import { FORGE_SKILLS } from "../registry.ts";
3
17
 
@@ -0,0 +1,347 @@
1
+ /*
2
+ <MODULE_CONTRACT>
3
+ <purpose>
4
+ Unit tests for rfc evidence sync covering rfc.evidence.sync (RFC-1306); rfc.implement.stamp --sync (RFC-1306).
5
+ </purpose>
6
+ <non-goals>
7
+ <item>Not a contract source of truth — the module under test owns the authoritative behavior; fixtures are minimal scaffolding only.</item>
8
+ </non-goals>
9
+ </MODULE_CONTRACT>
10
+ <CHANGE_SUMMARY>
11
+ <item>RFC-1311: Compass header sweep — declares the rfc suite's contract for test-file scaffold coverage.</item>
12
+ <item>RFC-1310: governance-id parity guards on ecosystem.commit and rfc.implement.stamp</item>
13
+ <item>RFC-1320</item>
14
+ </CHANGE_SUMMARY>
15
+ */
16
+
17
+ // @vitest-environment node
18
+ import { existsSync, readFileSync } from "node:fs";
19
+ import { fileURLToPath } from "node:url";
20
+ import { describe, expect, test, vi } from "vitest";
21
+
22
+ import {
23
+ EVIDENCE_SYNC_STEPS,
24
+ EVIDENCE_SYNC_EMIT_STEP,
25
+ runRfcEvidenceSync,
26
+ } from "../../os/rfc/handlers/rfc-evidence-sync.ts";
27
+ import type { ForgeCommandInput, ForgeInvokeResult, ForgeRuntimeContext } from "../types.ts";
28
+
29
+ function makeContext(
30
+ invoke?: ForgeRuntimeContext["invoke"],
31
+ workspaceRoot = "/tmp/rfc-evidence-sync-test",
32
+ ): ForgeRuntimeContext {
33
+ return {
34
+ workspaceRoot,
35
+ logger: {
36
+ section: () => {},
37
+ info: () => {},
38
+ warn: () => {},
39
+ error: () => {},
40
+ success: () => {},
41
+ },
42
+ dryRun: false,
43
+ outputFormat: "json",
44
+ invoke,
45
+ } as unknown as ForgeRuntimeContext;
46
+ }
47
+
48
+ const okReport: ForgeInvokeResult = { exitCode: 0, ok: true, filesModified: [] };
49
+
50
+ const run = (input: Partial<ForgeCommandInput>, ctx: ForgeRuntimeContext) =>
51
+ runRfcEvidenceSync({ argv: [], flags: {}, ...input } as ForgeCommandInput, ctx);
52
+
53
+ describe("rfc.evidence.sync (RFC-1306)", () => {
54
+ test("step list is pinned — the canonical regen order is contract", () => {
55
+ expect(EVIDENCE_SYNC_STEPS).toEqual([
56
+ "checks.commands.generate",
57
+ "command.manifest.generate",
58
+ "validator.inventory.generate",
59
+ "docs.commands.generate",
60
+ "ecosystem.manifest.generate",
61
+ ]);
62
+ expect(EVIDENCE_SYNC_EMIT_STEP).toBe("rfc.verification.emit");
63
+ });
64
+
65
+ // The committed command manifest exists only in the monorepo workshop; the
66
+ // standalone forge extraction has no docs/ tree, so the ratchet is skipped there.
67
+ const ratchetManifestPath = fileURLToPath(
68
+ new URL("../../../../docs/command-manifest.generated.yaml", import.meta.url),
69
+ );
70
+ test.skipIf(!existsSync(ratchetManifestPath))(
71
+ "coverage ratchet: every chain step's declared writes stay inside the sync declaration",
72
+ () => {
73
+ // RFC-1306 Risks: the chain is the canonical regen order — a step gaining
74
+ // a generated artifact without the sync declaration covering it must fail
75
+ // here. Source of truth is the committed command manifest (the command's
76
+ // writes are embedded verbatim); the workspace-wide *.generated.*
77
+ // producer set (60+ commands) is deliberately out of scope — the chain is
78
+ // the RFC-evidence subset, not every generator.
79
+ const manifest = readFileSync(ratchetManifestPath, "utf8");
80
+ const entries = manifest.split(/\n(?= - name: )/);
81
+ const writesOf = (name: string): string[] => {
82
+ const entry = entries.find((e) => e.startsWith(` - name: ${name}\n`));
83
+ if (!entry)
84
+ throw new Error(`command "${name}" missing from command manifest — stale fixture?`);
85
+ const block = entry.match(/ writes:\n((?: - .*\n)+)/);
86
+ return block ? [...block[1]!.matchAll(/ - (.*)/g)].map((m) => m[1]!) : [];
87
+ };
88
+ const syncWrites = new Set(writesOf("rfc.evidence.sync"));
89
+ expect(syncWrites.size).toBeGreaterThan(0);
90
+ for (const step of [...EVIDENCE_SYNC_STEPS, EVIDENCE_SYNC_EMIT_STEP]) {
91
+ for (const artifact of writesOf(step)) {
92
+ expect(
93
+ syncWrites.has(artifact),
94
+ `${step} writes ${artifact} — rfc.evidence.sync's writes[] must declare every step output`,
95
+ ).toBe(true);
96
+ }
97
+ }
98
+ },
99
+ );
100
+
101
+ test("EVIDENCE-SYNC-01: absent invoke port fails closed (standalone forge CLI)", async () => {
102
+ const result = await run({ flags: { id: "RFC-9999" } }, makeContext(undefined));
103
+ expect(result.exitCode).toBe(1);
104
+ const violations = (result.data as { violations: Array<{ rule: string }> }).violations;
105
+ expect(violations.map((v) => v.rule)).toEqual(["EVIDENCE-SYNC-01"]);
106
+ expect(violations[0]!.rule).toBe("EVIDENCE-SYNC-01");
107
+ });
108
+
109
+ test("dry-run lists all steps and invokes nothing (AC: honors context.dryRun)", async () => {
110
+ const invoke = vi.fn(async () => okReport);
111
+ const ctx = makeContext(invoke);
112
+ ctx.dryRun = true;
113
+ const result = await run({ flags: { id: "RFC-9999" } }, ctx);
114
+ expect(result.exitCode).toBe(0);
115
+ expect(invoke).not.toHaveBeenCalled();
116
+ expect(result.summary).toContain(EVIDENCE_SYNC_EMIT_STEP);
117
+ });
118
+
119
+ test("AC-2: mid-chain step failure exits non-zero with that step's diagnostics verbatim", async () => {
120
+ const failingDiagnostics = [
121
+ { ruleId: "CMDGEN-04", severity: "error", message: "suspect file x.ts" },
122
+ { ruleId: "CMDGEN-05", severity: "error", message: "control codepoint" },
123
+ ];
124
+ const invoke = vi.fn(async (name: string) =>
125
+ name === "validator.inventory.generate"
126
+ ? ({
127
+ exitCode: 1,
128
+ ok: false,
129
+ data: { diagnostics: failingDiagnostics },
130
+ summary: "inventory failed",
131
+ } satisfies ForgeInvokeResult)
132
+ : okReport,
133
+ );
134
+ const result = await run({}, makeContext(invoke));
135
+ expect(result.exitCode).toBe(1);
136
+
137
+ const data = result.data as {
138
+ violations: Array<{ rule: string; step?: string; stepDiagnostics?: unknown }>;
139
+ data: { failedStep: string; steps: Array<{ step: string; status: string }> };
140
+ };
141
+ expect(data.violations).toHaveLength(1);
142
+ expect(data.violations[0]!.rule).toBe("EVIDENCE-SYNC-02");
143
+ expect(data.violations[0]!.step).toBe("validator.inventory.generate");
144
+ expect(data.violations[0]!.stepDiagnostics).toEqual(failingDiagnostics);
145
+ expect(data.data.failedStep).toBe("validator.inventory.generate");
146
+ // Steps after the failure never ran — the chain stops loud.
147
+ expect(data.data.steps).toHaveLength(3);
148
+ expect(invoke).toHaveBeenCalledTimes(3);
149
+ });
150
+
151
+ test("AC-3: fully-synced tree reports all steps clean with zero changed files", async () => {
152
+ const invoke = vi.fn(async () => okReport);
153
+ const result = await run({ flags: { id: "RFC-9999" } }, makeContext(invoke));
154
+ expect(result.exitCode).toBe(0);
155
+ const data = result.data as {
156
+ data: { steps: Array<{ step: string; status: string; filesModified: string[] }> };
157
+ };
158
+ expect(data.data.steps).toHaveLength(6);
159
+ expect(data.data.steps.every((s) => s.status === "pass")).toBe(true);
160
+ expect(data.data.steps.flatMap((s) => s.filesModified)).toEqual([]);
161
+ expect(result.summary).toContain("0 files changed");
162
+ });
163
+
164
+ test("AC-4: --id appends rfc.verification.emit as the final step with the id", async () => {
165
+ const invoke = vi.fn(async (_name: string): Promise<ForgeInvokeResult> => okReport);
166
+ await run({ flags: { id: "RFC-1306" } }, makeContext(invoke));
167
+
168
+ const calls = invoke.mock.calls.map(([name]) => name);
169
+ expect(calls).toEqual([...EVIDENCE_SYNC_STEPS, EVIDENCE_SYNC_EMIT_STEP]);
170
+ expect(invoke).toHaveBeenLastCalledWith(EVIDENCE_SYNC_EMIT_STEP, { id: "RFC-1306" });
171
+ });
172
+
173
+ test("no --id: only the five manifest steps run (emit skipped)", async () => {
174
+ const invoke = vi.fn(async (_name: string): Promise<ForgeInvokeResult> => okReport);
175
+ const result = await run({}, makeContext(invoke));
176
+ expect(result.exitCode).toBe(0);
177
+ const calls = invoke.mock.calls.map(([name]) => name);
178
+ expect(calls).toEqual([...EVIDENCE_SYNC_STEPS]);
179
+ });
180
+
181
+ test("filesModified per step surfaces in the step report and summary", async () => {
182
+ const invoke = vi.fn(async (name: string) =>
183
+ name === "checks.commands.generate"
184
+ ? {
185
+ ...okReport,
186
+ filesModified: ["packages/werkstatt-site/src/checks/command-tables/index.generated.ts"],
187
+ }
188
+ : okReport,
189
+ );
190
+ const result = await run({}, makeContext(invoke));
191
+ expect(result.exitCode).toBe(0);
192
+ const data = result.data as { data: { steps: Array<{ filesModified: string[] }> } };
193
+ expect(data.data.steps[0]!.filesModified).toEqual([
194
+ "packages/werkstatt-site/src/checks/command-tables/index.generated.ts",
195
+ ]);
196
+ expect(result.summary).toContain("1 file changed");
197
+ });
198
+ });
199
+
200
+ // ── rfc.implement.stamp --sync (RFC-1306) ────────────────────────────────────
201
+
202
+ import { mkdtemp, mkdir, rm, writeFile } from "node:fs/promises";
203
+ import { tmpdir } from "node:os";
204
+ import { join } from "node:path";
205
+ import { execFileSync } from "node:child_process";
206
+
207
+ import { runRfcImplementStamp } from "../../os/rfc/handlers/implement-stamp.ts";
208
+
209
+ const { mockRunProbe } = vi.hoisted(() => ({ mockRunProbe: vi.fn() }));
210
+ // Spread the original module — validate-rules.ts also consumes
211
+ // validateAcceptanceShape from acceptance.ts; a bare factory drops it and
212
+ // the frontmatter parse fails closed as IMP-01.
213
+ vi.mock("../../os/rfc/acceptance.ts", async (importOriginal) => ({
214
+ ...(await importOriginal<typeof import("../../os/rfc/acceptance.ts")>()),
215
+ runProbe: mockRunProbe,
216
+ }));
217
+
218
+ const git = (dir: string, args: string[]) =>
219
+ execFileSync("git", args, { cwd: dir, encoding: "utf-8" }).trim();
220
+
221
+ async function stampWorkspace() {
222
+ const dir = await mkdtemp(join(tmpdir(), "stamp-sync-"));
223
+ git(dir, ["init", "-q"]);
224
+ git(dir, ["config", "user.email", "t@t.t"]);
225
+ git(dir, ["config", "user.name", "t"]);
226
+ await mkdir(join(dir, "docs", "rfcs"), { recursive: true });
227
+ return dir;
228
+ }
229
+
230
+ const RFC_MD = `---
231
+ id: RFC-0100
232
+ title: "Stamp sync fixture"
233
+ status: accepted
234
+ kind: command
235
+ scope: workspace
236
+ owners:
237
+ - architecture
238
+ createdAt: 2026-10-01
239
+ updatedAt: 2026-10-01
240
+ acceptance:
241
+ - probe: file-exists
242
+ path: src/index.ts
243
+ criterion: AC-1
244
+ ---
245
+
246
+ # RFC-0100
247
+
248
+ ## Context
249
+ Fixture.
250
+ ## Acceptance criteria
251
+
252
+ - [x] AC-1: THE thing SHALL work (evidence: test: packages/forge/x.test.ts)
253
+ `;
254
+
255
+ describe("rfc.implement.stamp --sync (RFC-1306)", () => {
256
+ test("--sync invokes rfc.evidence.sync through the host port before stamping", async () => {
257
+ const dir = await stampWorkspace();
258
+ try {
259
+ await writeFile(join(dir, "docs", "rfcs", "rfc-0100-stamp-sync.md"), RFC_MD);
260
+ mockRunProbe.mockResolvedValue({
261
+ probe: { probe: "file-exists", path: "src/index.ts", criterion: "AC-1" },
262
+ ok: true,
263
+ detail: "exists",
264
+ });
265
+ // Emit the evidence envelope, then commit so the stamp gates see a
266
+ // clean RFC file and a passing envelope.
267
+ const emit = await import("../../os/rfc/verification-evidence.ts");
268
+ const emitResult = await emit.runRfcVerificationEmit(
269
+ { argv: [], flags: { id: "RFC-0100" } } as unknown as ForgeCommandInput,
270
+ makeContext(undefined, dir),
271
+ );
272
+ expect(emitResult.exitCode).toBe(0);
273
+ git(dir, ["add", "-A"]);
274
+ git(dir, ["commit", "-qm", "feat: implement RFC-0100\n\nX-RFC: RFC-0100"]);
275
+
276
+ const invoke = vi.fn(async (_name: string): Promise<ForgeInvokeResult> => okReport);
277
+ const result = await runRfcImplementStamp(
278
+ {
279
+ argv: [],
280
+ flags: { id: "RFC-0100", sync: true },
281
+ } as unknown as ForgeCommandInput,
282
+ makeContext(invoke, dir),
283
+ );
284
+ expect(result.exitCode).toBe(0);
285
+ // RFC-1320: the post-stamp re-emit (RFC-1271) runs the freshness gate
286
+ // through the same invoke port — generated.drift.validate precedes the
287
+ // probe run for the file-exists probe's referenced path.
288
+ expect(invoke).toHaveBeenCalledTimes(2);
289
+ expect(invoke).toHaveBeenNthCalledWith(1, "rfc.evidence.sync", { id: "RFC-0100" });
290
+ expect(invoke).toHaveBeenNthCalledWith(2, "generated.drift.validate", {
291
+ target: "workspace",
292
+ paths: ["src/index.ts"],
293
+ });
294
+ } finally {
295
+ await rm(dir, { recursive: true, force: true });
296
+ }
297
+ });
298
+
299
+ test("--sync fails closed without a kernel host (EVIDENCE-SYNC-01)", async () => {
300
+ const dir = await stampWorkspace();
301
+ try {
302
+ await writeFile(join(dir, "docs", "rfcs", "rfc-0100-stamp-sync.md"), RFC_MD);
303
+ git(dir, ["add", "-A"]);
304
+ git(dir, ["commit", "-qm", "feat: implement RFC-0100"]);
305
+
306
+ const result = await runRfcImplementStamp(
307
+ {
308
+ argv: [],
309
+ flags: { id: "RFC-0100", sync: true },
310
+ } as unknown as ForgeCommandInput,
311
+ makeContext(undefined, dir),
312
+ );
313
+ expect(result.exitCode).toBe(1);
314
+ const violations = (result.data as { violations: Array<{ rule: string }> }).violations;
315
+ expect(violations.map((v) => v.rule)).toContain("EVIDENCE-SYNC-01");
316
+ } finally {
317
+ await rm(dir, { recursive: true, force: true });
318
+ }
319
+ });
320
+
321
+ test("--sync propagates a chain failure as EVIDENCE-SYNC-02 and does not stamp", async () => {
322
+ const dir = await stampWorkspace();
323
+ try {
324
+ await writeFile(join(dir, "docs", "rfcs", "rfc-0100-stamp-sync.md"), RFC_MD);
325
+ git(dir, ["add", "-A"]);
326
+ git(dir, ["commit", "-qm", "feat: implement RFC-0100"]);
327
+
328
+ const invoke = vi.fn(async (): Promise<ForgeInvokeResult> => ({
329
+ exitCode: 1,
330
+ ok: false,
331
+ summary: 'failed at step "command.manifest.generate"',
332
+ }));
333
+ const result = await runRfcImplementStamp(
334
+ {
335
+ argv: [],
336
+ flags: { id: "RFC-0100", sync: true },
337
+ } as unknown as ForgeCommandInput,
338
+ makeContext(invoke, dir),
339
+ );
340
+ expect(result.exitCode).toBe(1);
341
+ const violations = (result.data as { violations: Array<{ rule: string }> }).violations;
342
+ expect(violations.map((v) => v.rule)).toContain("EVIDENCE-SYNC-02");
343
+ } finally {
344
+ await rm(dir, { recursive: true, force: true });
345
+ }
346
+ });
347
+ });