@warpgogol/forge 6.3.6 → 8.0.2

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 (405) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/README.md +2 -1
  3. package/bin/cli.js +6 -12
  4. package/bin/resolve-entry.js +24 -0
  5. package/dist/os/compass/comment-safety.d.ts +83 -0
  6. package/dist/os/compass/comment-safety.d.ts.map +1 -0
  7. package/dist/os/compass/comment-safety.js +305 -0
  8. package/dist/os/compass/comment-safety.js.map +1 -0
  9. package/dist/os/compass/compass.module.d.ts.map +1 -1
  10. package/dist/os/compass/compass.module.js +47 -4
  11. package/dist/os/compass/compass.module.js.map +1 -1
  12. package/dist/os/compass/handlers/compass-change-summary-handler.d.ts +2 -1
  13. package/dist/os/compass/handlers/compass-change-summary-handler.d.ts.map +1 -1
  14. package/dist/os/compass/handlers/compass-change-summary-handler.js +34 -10
  15. package/dist/os/compass/handlers/compass-change-summary-handler.js.map +1 -1
  16. package/dist/os/compass/handlers/compass-docs-scaffold.d.ts.map +1 -1
  17. package/dist/os/compass/handlers/compass-docs-scaffold.js +54 -17
  18. package/dist/os/compass/handlers/compass-docs-scaffold.js.map +1 -1
  19. package/dist/os/compass/handlers/compass-header-scaffold-handler.d.ts +14 -0
  20. package/dist/os/compass/handlers/compass-header-scaffold-handler.d.ts.map +1 -0
  21. package/dist/os/compass/handlers/compass-header-scaffold-handler.js +261 -0
  22. package/dist/os/compass/handlers/compass-header-scaffold-handler.js.map +1 -0
  23. package/dist/os/compass/handlers/compass-header-scaffold.d.ts +31 -0
  24. package/dist/os/compass/handlers/compass-header-scaffold.d.ts.map +1 -0
  25. package/dist/os/compass/handlers/compass-header-scaffold.js +739 -0
  26. package/dist/os/compass/handlers/compass-header-scaffold.js.map +1 -0
  27. package/dist/os/compass/handlers/compass-inventory-handler.d.ts.map +1 -1
  28. package/dist/os/compass/handlers/compass-inventory-handler.js +8 -4
  29. package/dist/os/compass/handlers/compass-inventory-handler.js.map +1 -1
  30. package/dist/os/compass/handlers/compass-inventory.d.ts +6 -0
  31. package/dist/os/compass/handlers/compass-inventory.d.ts.map +1 -1
  32. package/dist/os/compass/handlers/compass-inventory.js +28 -13
  33. package/dist/os/compass/handlers/compass-inventory.js.map +1 -1
  34. package/dist/os/compass/handlers/compass-migrate-handler.d.ts.map +1 -1
  35. package/dist/os/compass/handlers/compass-migrate-handler.js +12 -26
  36. package/dist/os/compass/handlers/compass-migrate-handler.js.map +1 -1
  37. package/dist/os/compass/handlers/compass-migrate.d.ts +15 -2
  38. package/dist/os/compass/handlers/compass-migrate.d.ts.map +1 -1
  39. package/dist/os/compass/handlers/compass-migrate.js +58 -20
  40. package/dist/os/compass/handlers/compass-migrate.js.map +1 -1
  41. package/dist/os/compass/handlers/git-revision.d.ts +10 -0
  42. package/dist/os/compass/handlers/git-revision.d.ts.map +1 -1
  43. package/dist/os/compass/handlers/git-revision.js +58 -4
  44. package/dist/os/compass/handlers/git-revision.js.map +1 -1
  45. package/dist/os/compass/handlers/summary-record.d.ts +20 -5
  46. package/dist/os/compass/handlers/summary-record.d.ts.map +1 -1
  47. package/dist/os/compass/handlers/summary-record.js +175 -44
  48. package/dist/os/compass/handlers/summary-record.js.map +1 -1
  49. package/dist/os/compass/index.d.ts +1 -0
  50. package/dist/os/compass/index.d.ts.map +1 -1
  51. package/dist/os/compass/index.js +2 -0
  52. package/dist/os/compass/index.js.map +1 -1
  53. package/dist/os/compass/policy.d.ts +9 -0
  54. package/dist/os/compass/policy.d.ts.map +1 -1
  55. package/dist/os/compass/policy.js +11 -2
  56. package/dist/os/compass/policy.js.map +1 -1
  57. package/dist/os/core/core.module.js +1 -1
  58. package/dist/os/core/handlers/package-health.d.ts.map +1 -1
  59. package/dist/os/core/handlers/package-health.js +1 -6
  60. package/dist/os/core/handlers/package-health.js.map +1 -1
  61. package/dist/os/queue/types.d.ts +2 -0
  62. package/dist/os/queue/types.d.ts.map +1 -1
  63. package/dist/os/queue/types.js +3 -1
  64. package/dist/os/queue/types.js.map +1 -1
  65. package/dist/os/rfc/acceptance.d.ts.map +1 -1
  66. package/dist/os/rfc/acceptance.js +66 -2
  67. package/dist/os/rfc/acceptance.js.map +1 -1
  68. package/dist/os/rfc/decision-log.d.ts.map +1 -1
  69. package/dist/os/rfc/decision-log.js +21 -3
  70. package/dist/os/rfc/decision-log.js.map +1 -1
  71. package/dist/os/rfc/dna-trace.d.ts +2 -0
  72. package/dist/os/rfc/dna-trace.d.ts.map +1 -1
  73. package/dist/os/rfc/dna-trace.js +13 -4
  74. package/dist/os/rfc/dna-trace.js.map +1 -1
  75. package/dist/os/rfc/handlers/implement-stamp-origin.d.ts +37 -0
  76. package/dist/os/rfc/handlers/implement-stamp-origin.d.ts.map +1 -0
  77. package/dist/os/rfc/handlers/implement-stamp-origin.js +118 -0
  78. package/dist/os/rfc/handlers/implement-stamp-origin.js.map +1 -0
  79. package/dist/os/rfc/handlers/implement-stamp.d.ts +41 -1
  80. package/dist/os/rfc/handlers/implement-stamp.d.ts.map +1 -1
  81. package/dist/os/rfc/handlers/implement-stamp.js +645 -47
  82. package/dist/os/rfc/handlers/implement-stamp.js.map +1 -1
  83. package/dist/os/rfc/handlers/rfc-evidence-sync.d.ts +42 -0
  84. package/dist/os/rfc/handlers/rfc-evidence-sync.d.ts.map +1 -0
  85. package/dist/os/rfc/handlers/rfc-evidence-sync.js +147 -0
  86. package/dist/os/rfc/handlers/rfc-evidence-sync.js.map +1 -0
  87. package/dist/os/rfc/handlers/validate-rules.d.ts +9 -1
  88. package/dist/os/rfc/handlers/validate-rules.d.ts.map +1 -1
  89. package/dist/os/rfc/handlers/validate-rules.js +71 -10
  90. package/dist/os/rfc/handlers/validate-rules.js.map +1 -1
  91. package/dist/os/rfc/reachable-symbol.d.ts +17 -0
  92. package/dist/os/rfc/reachable-symbol.d.ts.map +1 -0
  93. package/dist/os/rfc/reachable-symbol.js +376 -0
  94. package/dist/os/rfc/reachable-symbol.js.map +1 -0
  95. package/dist/os/rfc/rfc.module.d.ts.map +1 -1
  96. package/dist/os/rfc/rfc.module.js +99 -10
  97. package/dist/os/rfc/rfc.module.js.map +1 -1
  98. package/dist/os/rfc/types.d.ts +112 -14
  99. package/dist/os/rfc/types.d.ts.map +1 -1
  100. package/dist/os/rfc/types.js +27 -10
  101. package/dist/os/rfc/types.js.map +1 -1
  102. package/dist/os/rfc/verification-evidence.d.ts +25 -0
  103. package/dist/os/rfc/verification-evidence.d.ts.map +1 -1
  104. package/dist/os/rfc/verification-evidence.js +244 -13
  105. package/dist/os/rfc/verification-evidence.js.map +1 -1
  106. package/dist/os/rfc/verification-origin.d.ts +58 -0
  107. package/dist/os/rfc/verification-origin.d.ts.map +1 -0
  108. package/dist/os/rfc/verification-origin.js +346 -0
  109. package/dist/os/rfc/verification-origin.js.map +1 -0
  110. package/dist/os/rfc/verification-refresh.d.ts.map +1 -1
  111. package/dist/os/rfc/verification-refresh.js +11 -1
  112. package/dist/os/rfc/verification-refresh.js.map +1 -1
  113. package/dist/os/rfc/verify-workspace.d.ts +23 -0
  114. package/dist/os/rfc/verify-workspace.d.ts.map +1 -0
  115. package/dist/os/rfc/verify-workspace.js +278 -0
  116. package/dist/os/rfc/verify-workspace.js.map +1 -0
  117. package/dist/os/session/handlers/metrics-rfc.d.ts.map +1 -1
  118. package/dist/os/session/handlers/metrics-rfc.js +3 -0
  119. package/dist/os/session/handlers/metrics-rfc.js.map +1 -1
  120. package/dist/os/spec/spec-status.d.ts.map +1 -1
  121. package/dist/os/spec/spec-status.js +5 -23
  122. package/dist/os/spec/spec-status.js.map +1 -1
  123. package/dist/os/spec/spec-validate.d.ts.map +1 -1
  124. package/dist/os/spec/spec-validate.js +30 -9
  125. package/dist/os/spec/spec-validate.js.map +1 -1
  126. package/dist/os/workflow/handlers.d.ts +0 -4
  127. package/dist/os/workflow/handlers.d.ts.map +1 -1
  128. package/dist/os/workflow/handlers.js +9 -36
  129. package/dist/os/workflow/handlers.js.map +1 -1
  130. package/dist/os/workflow/index.d.ts +2 -2
  131. package/dist/os/workflow/index.d.ts.map +1 -1
  132. package/dist/os/workflow/index.js +1 -1
  133. package/dist/os/workflow/index.js.map +1 -1
  134. package/dist/os/workflow/types.d.ts +0 -19
  135. package/dist/os/workflow/types.d.ts.map +1 -1
  136. package/dist/os/workflow/types.js +0 -2
  137. package/dist/os/workflow/types.js.map +1 -1
  138. package/dist/os/workflow/workflow.module.d.ts.map +1 -1
  139. package/dist/os/workflow/workflow.module.js +6 -15
  140. package/dist/os/workflow/workflow.module.js.map +1 -1
  141. package/dist/src/config/forge-config.d.ts +5 -0
  142. package/dist/src/config/forge-config.d.ts.map +1 -1
  143. package/dist/src/config/forge-config.js +5 -2
  144. package/dist/src/config/forge-config.js.map +1 -1
  145. package/dist/src/onboarding/agents-generate.js +1 -1
  146. package/dist/src/onboarding/doctor.js +3 -3
  147. package/dist/src/onboarding/doctor.js.map +1 -1
  148. package/dist/src/onboarding/init.js +2 -2
  149. package/dist/src/onboarding/nested-agents-templates.js +1 -1
  150. package/dist/src/onboarding/prettierignore.js +1 -1
  151. package/dist/src/onboarding/upgrade.js +2 -2
  152. package/dist/src/onboarding/workspace-discovery.js +1 -1
  153. package/dist/src/profiles/profile-schema.d.ts +2 -0
  154. package/dist/src/profiles/profile-schema.d.ts.map +1 -1
  155. package/dist/src/profiles/profile-schema.js +1 -0
  156. package/dist/src/profiles/profile-schema.js.map +1 -1
  157. package/dist/src/profiles/stack-profile.d.ts +1 -0
  158. package/dist/src/profiles/stack-profile.d.ts.map +1 -1
  159. package/dist/src/skill-schema.d.ts +2 -0
  160. package/dist/src/skill-schema.d.ts.map +1 -1
  161. package/dist/src/skill-schema.js +9 -1
  162. package/dist/src/skill-schema.js.map +1 -1
  163. package/dist/src/types.d.ts +23 -0
  164. package/dist/src/types.d.ts.map +1 -1
  165. package/dist/src/types.js +2 -1
  166. package/dist/src/types.js.map +1 -1
  167. package/docs/reference/cli.md +0 -1
  168. package/docs/reference/programmatic-api.md +1 -1
  169. package/os/adr/handlers/validate.test.ts +14 -0
  170. package/os/compass/comment-safety.ts +331 -0
  171. package/os/compass/compass.module.ts +50 -4
  172. package/os/compass/handlers/compass-change-summary-handler.ts +41 -11
  173. package/os/compass/handlers/compass-docs-scaffold.ts +59 -17
  174. package/os/compass/handlers/compass-game-extensions.test.ts +3 -7
  175. package/os/compass/handlers/compass-header-scaffold-handler.ts +352 -0
  176. package/os/compass/handlers/compass-header-scaffold.ts +847 -0
  177. package/os/compass/handlers/compass-inventory-handler.ts +9 -4
  178. package/os/compass/handlers/compass-inventory.ts +29 -13
  179. package/os/compass/handlers/compass-migrate-handler.ts +13 -27
  180. package/os/compass/handlers/compass-migrate.ts +77 -21
  181. package/os/compass/handlers/git-revision.ts +59 -4
  182. package/os/compass/handlers/resolve-scan-root-package.test.ts +14 -0
  183. package/os/compass/handlers/resolve-scan-root-workpiece.test.ts +14 -0
  184. package/os/compass/handlers/summary-record.ts +194 -41
  185. package/os/compass/handlers/tests/compass-audit-plan.test.ts +6 -0
  186. package/os/compass/handlers/tests/compass-audit-record.test.ts +6 -0
  187. package/os/compass/handlers/tests/compass-audit-validate.test.ts +6 -0
  188. package/os/compass/handlers/tests/compass-change-summary-handler.test.ts +131 -0
  189. package/os/compass/handlers/tests/compass-docs-validate.test.ts +6 -0
  190. package/os/compass/handlers/tests/compass-header-scaffold.test.ts +896 -0
  191. package/os/compass/handlers/tests/compass-ledger-scope.test.ts +6 -0
  192. package/os/compass/handlers/tests/compass-migrate.test.ts +87 -9
  193. package/os/compass/handlers/tests/compass-policy.test.ts +1 -1
  194. package/os/compass/handlers/tests/compass-text-safety.test.ts +271 -0
  195. package/os/compass/handlers/tests/compass-v2-contract.test.ts +52 -3
  196. package/os/compass/handlers/tests/summary-record.test.ts +324 -3
  197. package/os/compass/index.ts +15 -0
  198. package/os/compass/policy.ts +27 -2
  199. package/os/core/core.module.ts +1 -1
  200. package/os/core/handlers/invariant-engine.test.ts +3 -1
  201. package/os/core/handlers/note-frontmatter-validate.test.ts +6 -1
  202. package/os/core/handlers/note-link-validate.test.ts +6 -1
  203. package/os/core/handlers/note-orphan-detect.test.ts +6 -1
  204. package/os/core/handlers/package-health.test.ts +6 -0
  205. package/os/core/handlers/package-health.ts +1 -6
  206. package/os/mission/handlers/archive.test.ts +14 -0
  207. package/os/naming/naming-convention.test.ts +14 -0
  208. package/os/queue/decision-ledger.test.ts +27 -4
  209. package/os/queue/queue-validate.test.ts +14 -0
  210. package/os/queue/types.ts +3 -1
  211. package/os/rfc/acceptance-reachable.test.ts +146 -0
  212. package/os/rfc/acceptance.test.ts +136 -0
  213. package/os/rfc/acceptance.ts +71 -2
  214. package/os/rfc/decision-log.ts +22 -4
  215. package/os/rfc/dna-trace.ts +17 -5
  216. package/os/rfc/frontmatter-io.test.ts +14 -0
  217. package/os/rfc/handlers/implement-stamp-acceptance-verification.test.ts +81 -0
  218. package/os/rfc/handlers/implement-stamp-binding.test.ts +79 -0
  219. package/os/rfc/handlers/implement-stamp-origin.test.ts +132 -0
  220. package/os/rfc/handlers/implement-stamp-origin.ts +154 -0
  221. package/os/rfc/handlers/implement-stamp-stale.test.ts +285 -0
  222. package/os/rfc/handlers/implement-stamp.ts +783 -55
  223. package/os/rfc/handlers/lifecycle.test.ts +14 -0
  224. package/os/rfc/handlers/rfc-evidence-sync.ts +221 -0
  225. package/os/rfc/handlers/validate-rules-rfc0997.test.ts +14 -0
  226. package/os/rfc/handlers/validate-rules-rfc1006.test.ts +14 -0
  227. package/os/rfc/handlers/validate-rules-rfc1330.test.ts +120 -0
  228. package/os/rfc/handlers/validate-rules-rfc1334.test.ts +65 -0
  229. package/os/rfc/handlers/validate-rules.test.ts +56 -0
  230. package/os/rfc/handlers/validate-rules.ts +101 -10
  231. package/os/rfc/handlers/validate.test.ts +4 -3
  232. package/os/rfc/reachable-symbol.ts +441 -0
  233. package/os/rfc/rfc-0000-template.md +21 -1
  234. package/os/rfc/rfc-create-concurrent.test.ts +6 -0
  235. package/os/rfc/rfc-create-hint.test.ts +6 -0
  236. package/os/rfc/rfc-read-only-no-side-effects.test.ts +6 -0
  237. package/os/rfc/rfc.module.ts +106 -10
  238. package/os/rfc/types.ts +151 -14
  239. package/os/rfc/verification-emit-check.test.ts +215 -0
  240. package/os/rfc/verification-emit-freshness.test.ts +415 -0
  241. package/os/rfc/verification-emit.test.ts +14 -0
  242. package/os/rfc/verification-evidence.ts +301 -13
  243. package/os/rfc/verification-normalize.test.ts +75 -0
  244. package/os/rfc/verification-origin.test.ts +236 -0
  245. package/os/rfc/verification-origin.ts +417 -0
  246. package/os/rfc/verification-refresh.test.ts +14 -0
  247. package/os/rfc/verification-refresh.ts +12 -1
  248. package/os/rfc/verifier/rfc-1333/imp12-binding.acceptance.test.ts +78 -0
  249. package/os/rfc/verifier/rfc-1333/imp12-gate.acceptance.test.ts +81 -0
  250. package/os/rfc/verifier/rfc-1333/skills-and-types.acceptance.test.ts +50 -0
  251. package/os/rfc/verifier/rfc-1333/verify-workspace.acceptance.test.ts +103 -0
  252. package/os/rfc/verify-workspace.test.ts +122 -0
  253. package/os/rfc/verify-workspace.ts +342 -0
  254. package/os/session/handlers/metrics-rfc.ts +3 -0
  255. package/os/spec/spec-status.test.ts +130 -0
  256. package/os/spec/spec-status.ts +5 -18
  257. package/os/spec/spec-validate.test.ts +76 -1
  258. package/os/spec/spec-validate.ts +26 -7
  259. package/os/workflow/handlers.ts +8 -42
  260. package/os/workflow/index.ts +1 -4
  261. package/os/workflow/types.ts +0 -22
  262. package/os/workflow/workflow.module.ts +6 -16
  263. package/package.json +1 -1
  264. package/skills/_shared/agent-operating-model.md +83 -0
  265. package/skills/_shared/fo-pipeline-conventions.md +1 -0
  266. package/skills/fo/fo-add-tests/SKILL.md +14 -0
  267. package/skills/fo/fo-fix/SKILL.md +2 -1
  268. package/skills/fo/fo-handoff/SKILL.md +1 -1
  269. package/skills/fo/fo-idea/SKILL.md +6 -3
  270. package/skills/fo/fo-idea-create-rfc/acceptance-criteria-standard.md +8 -0
  271. package/skills/fo/fo-idea-i-just-want-to-see-the-result/SKILL.md +4 -2
  272. package/skills/fo/fo-idea-implement/SKILL.md +68 -53
  273. package/skills/fo/fo-idea-plan/SKILL.md +3 -1
  274. package/skills/fo/fo-review/SKILL.md +12 -0
  275. package/skills/fo/fo-session-save/learned-principles.md +13 -0
  276. package/skills/fo/fo-step-commit/SKILL.md +1 -1
  277. package/src/bin-entry.test.ts +37 -0
  278. package/src/compass/contract-registry.test.ts +14 -0
  279. package/src/compass/types.test.ts +14 -0
  280. package/src/config/__tests__/resolve-terminology.test.ts +14 -0
  281. package/src/config/forge-config.test.ts +14 -0
  282. package/src/config/forge-config.ts +7 -2
  283. package/src/forge-module.test.ts +14 -0
  284. package/src/knowledge/__tests__/promote.test.ts +14 -0
  285. package/src/knowledge/__tests__/serialize.test.ts +14 -0
  286. package/src/knowledge/__tests__/sync.test.ts +4 -1
  287. package/src/knowledge/budgets.test.ts +14 -0
  288. package/src/knowledge/compact.test.ts +14 -0
  289. package/src/knowledge/parse.test.ts +14 -0
  290. package/src/knowledge/schema.test.ts +14 -0
  291. package/src/migration-adapters/__tests__/ignored-files.test.ts +14 -0
  292. package/src/migration-adapters/__tests__/registry.test.ts +14 -0
  293. package/src/migration-adapters/__tests__/types.test.ts +14 -0
  294. package/src/onboarding/__tests__/workspace-discovery.test.ts +14 -0
  295. package/src/onboarding/agents-generate.ts +1 -1
  296. package/src/onboarding/compass-docs/semantic-layer-block.test.ts +6 -0
  297. package/src/onboarding/create.test.ts +14 -0
  298. package/src/onboarding/doctor-token-check.test.ts +3 -0
  299. package/src/onboarding/doctor.test.ts +14 -0
  300. package/src/onboarding/doctor.ts +3 -3
  301. package/src/onboarding/init.test.ts +14 -0
  302. package/src/onboarding/init.ts +2 -2
  303. package/src/onboarding/nested-agents-templates.ts +1 -1
  304. package/src/onboarding/prettierignore.ts +1 -1
  305. package/src/onboarding/scaffold.test.ts +14 -0
  306. package/src/onboarding/site-workshop-profile.test.ts +3 -0
  307. package/src/onboarding/templates/behavioral-layer-core.md +8 -0
  308. package/src/onboarding/upgrade.test.ts +14 -0
  309. package/src/onboarding/upgrade.ts +2 -2
  310. package/src/onboarding/workspace-discovery.ts +1 -1
  311. package/src/pipeline-status.test.ts +14 -0
  312. package/src/plugin/forge-plugin-manifest.test.ts +14 -0
  313. package/src/profiles/__tests__/profile-schema.test.ts +14 -0
  314. package/src/profiles/__tests__/stack-profile.test.ts +14 -0
  315. package/src/profiles/__tests__/terminology-utils.test.ts +14 -0
  316. package/src/profiles/profile-schema.ts +1 -0
  317. package/src/skill-schema.ts +9 -1
  318. package/src/tests/acceptance-criteria.test.ts +14 -0
  319. package/src/tests/acceptance-probe-kinds.test.ts +14 -0
  320. package/src/tests/adr-implement-stamp.test.ts +14 -0
  321. package/src/tests/agents-generate-domain.test.ts +3 -0
  322. package/src/tests/agents-generate.test.ts +3 -0
  323. package/src/tests/bindings-schema.test.ts +2 -0
  324. package/src/tests/budgets.test.ts +14 -0
  325. package/src/tests/compact.test.ts +14 -0
  326. package/src/tests/compass-docs-flag.test.ts +6 -0
  327. package/src/tests/compass-docs-scaffold.test.ts +6 -0
  328. package/src/tests/compass-docs-validate-scope.test.ts +6 -0
  329. package/src/tests/contract-registry.test.ts +14 -0
  330. package/src/tests/create.test.ts +3 -0
  331. package/src/tests/discover-pack-skills.test.ts +14 -0
  332. package/src/tests/doctor-autonomy.test.ts +3 -0
  333. package/src/tests/doctor-bindings.test.ts +6 -1
  334. package/src/tests/doctor-dist-freshness.test.ts +26 -2
  335. package/src/tests/doctor-domain.test.ts +6 -1
  336. package/src/tests/doctor-fix.test.ts +3 -0
  337. package/src/tests/doctor-nested-agents.test.ts +3 -0
  338. package/src/tests/doctor-profile-id-known.test.ts +3 -0
  339. package/src/tests/doctor-skills-unmanaged.test.ts +3 -0
  340. package/src/tests/doctor-version-sync.test.ts +4 -1
  341. package/src/tests/editable-generated-region.test.ts +6 -3
  342. package/src/tests/exploration-handlers.test.ts +14 -0
  343. package/src/tests/file-size-lint.test.ts +6 -1
  344. package/src/tests/fixtures/agents-generate-business-before.txt +8 -0
  345. package/src/tests/forge-autonomy-validate.test.ts +3 -1
  346. package/src/tests/forge-config.test.ts +6 -1
  347. package/src/tests/forge-validate-compass-docs.test.ts +6 -0
  348. package/src/tests/fs-atomic.test.ts +14 -0
  349. package/src/tests/fs.test.ts +14 -0
  350. package/src/tests/generated-marker.test.ts +14 -0
  351. package/src/tests/hash.test.ts +14 -0
  352. package/src/tests/implement-stamp.test.ts +476 -10
  353. package/src/tests/init-bindings.test.ts +6 -1
  354. package/src/tests/knowledge-parse.test.ts +14 -0
  355. package/src/tests/knowledge-pbt.test.ts +14 -0
  356. package/src/tests/markdown-table.test.ts +6 -3
  357. package/src/tests/memory-compact.test.ts +3 -0
  358. package/src/tests/memory-scaffold.test.ts +6 -1
  359. package/src/tests/metrics-rfc-1053.test.ts +14 -0
  360. package/src/tests/migration-adapters.test.ts +3 -0
  361. package/src/tests/package-files.test.ts +4 -1
  362. package/src/tests/package-health-lint-surface.test.ts +3 -0
  363. package/src/tests/pinned-check.test.ts +14 -0
  364. package/src/tests/pinned-init.test.ts +14 -0
  365. package/src/tests/pinned-validate.test.ts +14 -0
  366. package/src/tests/plugin-manifest.test.ts +14 -0
  367. package/src/tests/prettierignore-manage.test.ts +3 -0
  368. package/src/tests/profile-schema.test.ts +6 -1
  369. package/src/tests/profile-validate.test.ts +6 -1
  370. package/src/tests/program-lease.test.ts +3 -0
  371. package/src/tests/program-paths-extended.test.ts +3 -0
  372. package/src/tests/program-paths.test.ts +3 -0
  373. package/src/tests/program-property.test.ts +3 -0
  374. package/src/tests/program-schemas.test.ts +3 -0
  375. package/src/tests/program-spec-node.test.ts +3 -0
  376. package/src/tests/promote.test.ts +14 -0
  377. package/src/tests/public-surface.test.ts +6 -1
  378. package/src/tests/registry.test.ts +14 -0
  379. package/src/tests/rfc-evidence-sync.test.ts +347 -0
  380. package/src/tests/rfc-implement-stamp-governance.test.ts +403 -0
  381. package/src/tests/scaffold-project.test.ts +3 -0
  382. package/src/tests/session-handlers.test.ts +14 -0
  383. package/src/tests/session-pbt.test.ts +14 -0
  384. package/src/tests/skill-agents-sync.test.ts +3 -4
  385. package/src/tests/skill-schema.test.ts +53 -0
  386. package/src/tests/skill-sync-marker.test.ts +3 -0
  387. package/src/tests/skill-validate-knowledge.test.ts +14 -0
  388. package/src/tests/skill-validate.test.ts +14 -0
  389. package/src/tests/stack-profile.test.ts +6 -1
  390. package/src/tests/string-utils.test.ts +14 -0
  391. package/src/tests/upgrade.test.ts +6 -1
  392. package/src/tests/werkstatt-lock.test.ts +14 -0
  393. package/src/tests/workspace-discovery-domain.test.ts +6 -1
  394. package/src/tests/workspace-discovery.test.ts +6 -1
  395. package/src/types.test.ts +14 -0
  396. package/src/types.ts +30 -1
  397. package/src/utils/__tests__/fs-idempotent.test.ts +17 -0
  398. package/src/utils/__tests__/fs-trash.test.ts +17 -0
  399. package/src/utils/fs-atomic.test.ts +17 -0
  400. package/src/utils/fs-trash-sync.test.ts +17 -0
  401. package/src/utils/fs.test.ts +17 -0
  402. package/src/utils/generated-marker.test.ts +17 -0
  403. package/src/utils/hash.test.ts +17 -0
  404. package/src/utils/string-utils.test.ts +17 -0
  405. package/src/validators/__tests__/note-orphan-detect.test.ts +14 -0
@@ -19,15 +19,17 @@ io.writeFile port routing, emit-canonical generated header — refresh owns
19
19
  content freshness, never envelope identity (ownerCommand stays
20
20
  rfc.verification.emit).</item>
21
21
  <item>RFC-1249: wire werkstatt.commands.validate into packages.check + retire CMD-OUTPUT debt</item>
22
+ <item>RFC-1330: refresh attaches git-derived origin like emit.</item>
22
23
  </CHANGE_SUMMARY>
23
24
  */
24
25
 
25
- import { join } from "node:path";
26
+ import { join, relative } from "node:path";
26
27
  import { resolveIo } from "../../src/utils/io.ts";
27
28
  import { performance } from "node:perf_hooks";
28
29
  import { parse as yamlParse } from "yaml";
29
30
 
30
31
  import { runProbe } from "./acceptance.ts";
32
+ import { attachProbeOrigins } from "./verification-origin.ts";
31
33
  import { listRfcFiles, readAndParseRfc } from "./frontmatter-io.ts";
32
34
  import {
33
35
  captureGitContext,
@@ -149,6 +151,15 @@ export async function runRfcVerificationRefresh(
149
151
  });
150
152
  }
151
153
 
154
+ // RFC-1330: git-derived origin per probe (post-cutoff RFCs only).
155
+ await attachProbeOrigins({
156
+ workspaceRoot,
157
+ rfcRelPath: relative(workspaceRoot, rfcFilePath),
158
+ frontmatter: fm,
159
+ probes,
160
+ records: probeRecords,
161
+ });
162
+
152
163
  const envelope = buildEvidenceEnvelope(
153
164
  rfcId,
154
165
  String(fm["title"] ?? ""),
@@ -0,0 +1,78 @@
1
+ // RFC-1333 Design "Stamp gate RFC-IMP-12" — candidate binding: descendants of
2
+ // candidateSha up to the implementation commit may touch only verifier-trailer
3
+ // commits and docs/**.
4
+ // @vitest-environment node
5
+ import { execFileSync } from "node:child_process";
6
+ import fs from "node:fs/promises";
7
+ import os from "node:os";
8
+ import path from "node:path";
9
+ import { describe, expect, test, vi } from "vitest";
10
+
11
+ import { runRfcImplementStamp } from "../../handlers/implement-stamp.ts";
12
+ import type { ForgeCommandInput, ForgeRuntimeContext } from "../../../../src/types.ts";
13
+
14
+ vi.mock("../../acceptance.ts", () => ({
15
+ runProbe: vi.fn(async (probe: unknown) => ({ probe, ok: true, detail: "ok" })),
16
+ }));
17
+
18
+ const git = (dir: string, args: string[]) =>
19
+ execFileSync("git", args, { cwd: dir, encoding: "utf-8" }).trim();
20
+ const put = async (dir: string, rel: string, body: string) => {
21
+ await fs.mkdir(path.dirname(path.join(dir, rel)), { recursive: true });
22
+ await fs.writeFile(path.join(dir, rel), body);
23
+ };
24
+ const commit = (dir: string, msg: string) => {
25
+ git(dir, ["add", "-A"]);
26
+ git(dir, ["commit", "-qm", msg]);
27
+ return git(dir, ["rev-parse", "HEAD"]);
28
+ };
29
+ const RFC = `---\nid: RFC-0100\ntitle: "T"\nstatus: accepted\nkind: command\nscope: workspace\nowners:\n - architecture\ncreatedAt: 2026-10-18\nupdatedAt: 2026-10-18\nverificationTier: high\nacceptance:\n - probe: file-exists\n path: src/index.ts\n criterion: AC-1\n---\n\n# RFC-0100\n## Context\nx\n## Acceptance criteria\n\n- [x] AC-1: THE thing SHALL exist (evidence: probe:AC-1)\n`;
30
+
31
+ async function scenario(laterPath: string): Promise<string[]> {
32
+ const dir = await fs.mkdtemp(path.join(os.tmpdir(), "imp12-"));
33
+ try {
34
+ git(dir, ["init", "-q"]);
35
+ git(dir, ["config", "user.email", "t@t.t"]);
36
+ git(dir, ["config", "user.name", "t"]);
37
+ await put(dir, "docs/rfcs/rfc-0100-t.md", RFC);
38
+ commit(dir, "docs: RFC-0100 accepted");
39
+ await put(dir, "src/index.ts", "export {};\n");
40
+ const cand = commit(dir, "feat: RFC-0100 implement");
41
+ await put(
42
+ dir,
43
+ "docs/reviews/acceptance/rfc-0100/acceptance-2026-10-18-r0.md",
44
+ `---\nrfcId: RFC-0100\ncandidateSha: ${cand}\nround: 0\nisolation: subagent\nverifierModel: null\nverdict: pass\ncounterexamples: []\n---\n\nok\n`,
45
+ );
46
+ commit(dir, "docs: RFC-0100 acceptance report");
47
+ await put(dir, laterPath, "changed after verification\n");
48
+ const head = commit(dir, "feat: RFC-0100 post-verification change");
49
+ const ctx = {
50
+ workspaceRoot: dir,
51
+ logger: { info: () => {}, warn: () => {} },
52
+ outputFormat: "json",
53
+ commandRegistry: undefined,
54
+ dryRun: false,
55
+ } as unknown as ForgeRuntimeContext;
56
+ const r = await runRfcImplementStamp(
57
+ {
58
+ flags: { id: "RFC-0100", "implementation-commit": head, "dry-run": true },
59
+ } as unknown as ForgeCommandInput,
60
+ ctx,
61
+ );
62
+ return (r.data?.violations ?? []).map((v) => v.rule);
63
+ } finally {
64
+ await fs.rm(dir, { recursive: true, force: true });
65
+ }
66
+ }
67
+
68
+ describe("RFC-IMP-12 candidate binding", () => {
69
+ test("control: post-candidate code change unbinds the report", async () => {
70
+ expect(await scenario("src/other.ts")).toContain("RFC-IMP-12");
71
+ });
72
+ test("post-candidate change to a non-docs/** markdown file (e.g. a skill) unbinds the report", async () => {
73
+ expect(await scenario("packages/forge/skills/fo/x/SKILL.md")).toContain("RFC-IMP-12");
74
+ });
75
+ test("post-candidate docs/** change keeps the report bound", async () => {
76
+ expect(await scenario("docs/notes.md")).not.toContain("RFC-IMP-12");
77
+ });
78
+ });
@@ -0,0 +1,81 @@
1
+ // RFC-1333 AC-5, AC-6 — RFC-IMP-12 gate (pure evaluator).
2
+ import { describe, expect, it } from "vitest";
3
+ import { evaluateAcceptanceVerificationGate } from "../../handlers/implement-stamp-origin.ts";
4
+
5
+ const fm = { createdAt: "2026-10-18", verificationTier: "high" };
6
+ const rep = (f: Record<string, unknown>) => ({
7
+ path: "docs/reviews/acceptance/rfc-9/a-r0.md",
8
+ frontmatter: f,
9
+ });
10
+ const bound = async () => true;
11
+
12
+ describe("RFC-IMP-12", () => {
13
+ it("AC-5: no report blocks", async () => {
14
+ const r = await evaluateAcceptanceVerificationGate({
15
+ targetId: "RFC-9",
16
+ frontmatter: fm,
17
+ reports: [],
18
+ isCandidateBound: bound,
19
+ });
20
+ expect(r.errors.map((e) => e.rule)).toContain("RFC-IMP-12");
21
+ });
22
+ it("AC-5: non-pass verdict blocks", async () => {
23
+ const r = await evaluateAcceptanceVerificationGate({
24
+ targetId: "RFC-9",
25
+ frontmatter: fm,
26
+ reports: [rep({ verdict: "counterexamples", isolation: "subagent", candidateSha: "abc" })],
27
+ isCandidateBound: bound,
28
+ });
29
+ expect(r.errors.map((e) => e.rule)).toContain("RFC-IMP-12");
30
+ });
31
+ it("AC-5: unbound candidate blocks", async () => {
32
+ const r = await evaluateAcceptanceVerificationGate({
33
+ targetId: "RFC-9",
34
+ frontmatter: fm,
35
+ reports: [rep({ verdict: "pass", isolation: "subagent", candidateSha: "abc" })],
36
+ isCandidateBound: async () => false,
37
+ });
38
+ expect(r.errors.map((e) => e.rule)).toContain("RFC-IMP-12");
39
+ });
40
+ it("AC-5: bound pass subagent report passes", async () => {
41
+ const r = await evaluateAcceptanceVerificationGate({
42
+ targetId: "RFC-9",
43
+ frontmatter: fm,
44
+ reports: [rep({ verdict: "pass", isolation: "subagent", candidateSha: "abc" })],
45
+ isCandidateBound: bound,
46
+ });
47
+ expect(r.errors).toEqual([]);
48
+ });
49
+ it("AC-6: non-subagent isolation without waiver blocks; with waiver warns", async () => {
50
+ const reports = [rep({ verdict: "pass", isolation: "inline", candidateSha: "abc" })];
51
+ const a = await evaluateAcceptanceVerificationGate({
52
+ targetId: "RFC-9",
53
+ frontmatter: fm,
54
+ reports,
55
+ isCandidateBound: bound,
56
+ });
57
+ expect(a.errors.map((e) => e.rule)).toContain("RFC-IMP-12");
58
+ const b = await evaluateAcceptanceVerificationGate({
59
+ targetId: "RFC-9",
60
+ frontmatter: fm,
61
+ reports,
62
+ isCandidateBound: bound,
63
+ waiverReason: "no subagents",
64
+ });
65
+ expect(b.errors).toEqual([]);
66
+ expect(b.warnings.map((e) => e.rule)).toContain("RFC-IMP-12");
67
+ });
68
+ });
69
+
70
+ describe("RFC-IMP-12 failure mode: no report", () => {
71
+ it("design: worktree cannot be created → no report; operator may waive", async () => {
72
+ const r = await evaluateAcceptanceVerificationGate({
73
+ targetId: "RFC-9",
74
+ frontmatter: fm,
75
+ reports: [],
76
+ isCandidateBound: bound,
77
+ waiverReason: "export failed",
78
+ });
79
+ expect(r.errors).toEqual([]);
80
+ });
81
+ });
@@ -0,0 +1,50 @@
1
+ // RFC-1333 AC-3, AC-4, AC-7, AC-8, AC-9.
2
+ import { readFileSync } from "node:fs";
3
+ import { describe, expect, expectTypeOf, it } from "vitest";
4
+ import { RFC_IMP_11_BLOCKING } from "../../handlers/implement-stamp-origin.ts";
5
+ import type { AcceptanceVerificationReport } from "../../types.ts";
6
+
7
+ const review = readFileSync(
8
+ new URL("../../../../skills/fo/fo-review/SKILL.md", import.meta.url),
9
+ "utf8",
10
+ );
11
+ const impl = readFileSync(
12
+ new URL("../../../../skills/fo/fo-idea-implement/SKILL.md", import.meta.url),
13
+ "utf8",
14
+ );
15
+ const section = review.split(/^## Acceptance verification mode\s*$/m)[1]?.split(/^## /m)[0] ?? "";
16
+
17
+ describe("RFC-1333 skills/types", () => {
18
+ it("AC-3: fo-review acceptance section covers inputs, minimization, isolation", () => {
19
+ expect(section).not.toBe("");
20
+ expect(section).toMatch(/Inputs/);
21
+ expect(section).toMatch(/[Mm]inimi/);
22
+ expect(section).toMatch(/isolation/);
23
+ });
24
+ it("AC-9: at most two fix rounds, then park", () => {
25
+ expect(section).toMatch(/at most two fix rounds/);
26
+ expect(section).toMatch(/park/);
27
+ });
28
+ it("AC-4: step 4.4b gated on verificationTier: high", () => {
29
+ const step =
30
+ impl.split(/^#### 4\.4b\. Independent acceptance verification/m)[1]?.split(/^#{2,4} /m)[0] ??
31
+ "";
32
+ expect(step).not.toBe("");
33
+ expect(step).toMatch(/verificationTier: high/);
34
+ });
35
+ it("AC-7: RFC-IMP-11 blocking", () => {
36
+ expect(RFC_IMP_11_BLOCKING).toBe(true);
37
+ });
38
+ it("AC-8: report type fields", () => {
39
+ expectTypeOf<AcceptanceVerificationReport>()
40
+ .toHaveProperty("candidateSha")
41
+ .toEqualTypeOf<string>();
42
+ expectTypeOf<AcceptanceVerificationReport>().toHaveProperty("round").toEqualTypeOf<0 | 1 | 2>();
43
+ expectTypeOf<AcceptanceVerificationReport>().toHaveProperty("isolation");
44
+ expectTypeOf<AcceptanceVerificationReport>()
45
+ .toHaveProperty("verifierModel")
46
+ .toEqualTypeOf<string | null>();
47
+ expectTypeOf<AcceptanceVerificationReport>().toHaveProperty("verdict");
48
+ expectTypeOf<AcceptanceVerificationReport>().toHaveProperty("counterexamples");
49
+ });
50
+ });
@@ -0,0 +1,103 @@
1
+ // RFC-1333 AC-1, AC-2, AC-10, Design step 2/3 — rfc.verify.workspace export.
2
+ import { execFileSync } from "node:child_process";
3
+ import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
4
+ import { tmpdir } from "node:os";
5
+ import { dirname, join } from "node:path";
6
+ import { afterAll, beforeAll, describe, expect, it } from "vitest";
7
+
8
+ import { buildVerifyWorkspace } from "../../verify-workspace.ts";
9
+
10
+ let repo = "";
11
+ let out = "";
12
+ let removed: string[] = [];
13
+ const git = (...a: string[]) =>
14
+ execFileSync("git", a, {
15
+ cwd: repo,
16
+ encoding: "utf8",
17
+ env: {
18
+ ...process.env,
19
+ GIT_AUTHOR_NAME: "t",
20
+ GIT_AUTHOR_EMAIL: "t@t",
21
+ GIT_COMMITTER_NAME: "t",
22
+ GIT_COMMITTER_EMAIL: "t@t",
23
+ },
24
+ });
25
+ const put = (rel: string, body: string) => {
26
+ mkdirSync(dirname(join(repo, rel)), { recursive: true });
27
+ writeFileSync(join(repo, rel), body);
28
+ };
29
+ const rfc = (status: string) =>
30
+ `---\nid: RFC-0001\ntitle: "x"\nstatus: ${status}\ncreatedAt: 2026-10-18\n---\n\n## Context\n\nctx\n\n## Problem\n\np\n\n## Decision\n\nd\n\n## Design\n\ndes\n\n## Acceptance criteria\n\n- [ ] AC-1: x\n\n## Implementation notes\n\nSECRET-NARRATIVE\n`;
31
+
32
+ beforeAll(async () => {
33
+ repo = mkdtempSync(join(tmpdir(), "vw-fixture-"));
34
+ git("init", "-q", "-b", "main");
35
+ put("docs/rfcs/rfc-0001-x.md", rfc("draft"));
36
+ put("src/old.test.ts", "// pre-existing\n");
37
+ put("docs/plans/other.md", "unrelated plan\n");
38
+ git("add", "-A");
39
+ git("commit", "-qm", "chore: init");
40
+ put("docs/rfcs/rfc-0001-x.md", rfc("accepted"));
41
+ git("commit", "-qam", "docs: accept");
42
+ put("src/a.ts", "export const a = 1;\n");
43
+ put("src/a.test.ts", "// self test\n");
44
+ put("src/old.test.ts", "// edited by implementer\n");
45
+ put("docs/plans/plan-x.md", "Plan for rfc-0001\n");
46
+ put("docs/reviews/code/r.md", "Review of RFC-0001\n");
47
+ put("docs/sessions/s.md", "session about RFC-0001\n");
48
+ put("docs/rfcs/verification/rfc-0001.generated.yaml", "x: 1\n");
49
+ put("docs/metrics/rfcs/rfc-0001.metrics.yaml", "x: 1\n");
50
+ git("add", "-A");
51
+ git("commit", "-qm", "feat: RFC-0001 impl");
52
+ put("src/v.test.ts", "// verifier\n");
53
+ git("add", "-A");
54
+ git(
55
+ "commit",
56
+ "-qm",
57
+ "test: verifier\n\nX-Expectation-Origin: independent-verifier\nX-Verifier-Report: docs/reviews/acceptance/rfc-0001/a-r0.md",
58
+ );
59
+ const head = git("rev-parse", "HEAD").trim();
60
+ const res = await buildVerifyWorkspace({
61
+ workspaceRoot: repo,
62
+ rfcId: "RFC-0001",
63
+ candidateSha: head,
64
+ });
65
+ expect(res.status).toBe("pass");
66
+ out = res.path!;
67
+ removed = res.removed;
68
+ });
69
+ afterAll(() => {
70
+ rmSync(repo, { recursive: true, force: true });
71
+ if (out) rmSync(out, { recursive: true, force: true });
72
+ });
73
+
74
+ describe("RFC-1333 rfc.verify.workspace", () => {
75
+ it("AC-1: self-origin test files are absent", () => {
76
+ expect(existsSync(join(out, "src/a.test.ts"))).toBe(false);
77
+ expect(existsSync(join(out, "src/old.test.ts"))).toBe(false);
78
+ expect(existsSync(join(out, "src/a.ts"))).toBe(true);
79
+ });
80
+ it("AC-1 (design): verifier-trailer test files are kept", () => {
81
+ expect(existsSync(join(out, "src/v.test.ts"))).toBe(true);
82
+ });
83
+ it("AC-2: plan/review/session docs referencing the RFC are absent; unrelated kept", () => {
84
+ expect(existsSync(join(out, "docs/plans/plan-x.md"))).toBe(false);
85
+ expect(existsSync(join(out, "docs/reviews/code/r.md"))).toBe(false);
86
+ expect(existsSync(join(out, "docs/sessions/s.md"))).toBe(false);
87
+ expect(existsSync(join(out, "docs/plans/other.md"))).toBe(true);
88
+ });
89
+ it("design: verification envelope and metrics removed", () => {
90
+ expect(existsSync(join(out, "docs/rfcs/verification/rfc-0001.generated.yaml"))).toBe(false);
91
+ expect(existsSync(join(out, "docs/metrics/rfcs/rfc-0001.metrics.yaml"))).toBe(false);
92
+ });
93
+ it("AC-10: no .git entry", () => {
94
+ expect(existsSync(join(out, ".git"))).toBe(false);
95
+ });
96
+ it("design step 3: bundle carries only normative sections and removed list", () => {
97
+ const b = readFileSync(join(out, "VERIFY-BUNDLE.md"), "utf8");
98
+ for (const h of ["Context", "Problem", "Decision", "Design", "Acceptance criteria"])
99
+ expect(b).toContain(`## ${h}`);
100
+ expect(b).not.toContain("SECRET-NARRATIVE");
101
+ for (const r of removed) expect(b).toContain(`- ${r}`);
102
+ });
103
+ });
@@ -0,0 +1,122 @@
1
+ /*
2
+ <MODULE_CONTRACT>
3
+ <purpose>RFC-1333: rfc.verify.workspace tests — stripped, git-free export of a committed candidate over a temporary git repository.</purpose>
4
+ <non-goals>
5
+ <item>Do not run a verifier — only the export contract is under test.</item>
6
+ </non-goals>
7
+ </MODULE_CONTRACT>
8
+ <CHANGE_SUMMARY>
9
+ <item>RFC-1333: tests for AC-1, AC-2, AC-10.</item>
10
+ <item>RFC-1333: steps 1-3 — report contract, rfc.verify.workspace export, RFC-IMP-12 gate, RFC-IMP-11 blocking</item>
11
+ </CHANGE_SUMMARY>
12
+ */
13
+
14
+ import { execFileSync } from "node:child_process";
15
+ import { existsSync } from "node:fs";
16
+ import * as fs from "node:fs/promises";
17
+ import * as os from "node:os";
18
+ import * as path from "node:path";
19
+ import { afterEach, beforeEach, describe, expect, it } from "vitest";
20
+ import { buildVerifyWorkspace } from "./verify-workspace.ts";
21
+
22
+ let root: string;
23
+ let out: string;
24
+
25
+ function git(...args: string[]): string {
26
+ return execFileSync(
27
+ "git",
28
+ ["-c", "core.hooksPath=/dev/null", "-c", "user.email=t@t", "-c", "user.name=T", ...args],
29
+ { cwd: root, encoding: "utf8" },
30
+ );
31
+ }
32
+
33
+ async function commit(message: string, files: Record<string, string>): Promise<string> {
34
+ for (const [rel, content] of Object.entries(files)) {
35
+ await fs.mkdir(path.dirname(path.join(root, rel)), { recursive: true });
36
+ await fs.writeFile(path.join(root, rel), content);
37
+ }
38
+ git("add", "-A");
39
+ git("commit", "-qm", message);
40
+ return git("rev-parse", "HEAD").trim();
41
+ }
42
+
43
+ const rfc = (status: string) =>
44
+ `---\nid: RFC-9002\ntitle: "Fixture"\nstatus: ${status}\ncreatedAt: 2026-10-18\n---\n\n# RFC-9002: Fixture\n\n## Context\n\nCtx.\n\n## Decision\n\nDecide.\n\n## Risks\n\nInternal only.\n\n## Acceptance criteria\n\n- [ ] AC-1: WHEN x, THE y SHALL z.\n`;
45
+
46
+ let candidate: string;
47
+
48
+ beforeEach(async () => {
49
+ root = await fs.mkdtemp(path.join(os.tmpdir(), "verify-ws-"));
50
+ out = path.join(await fs.mkdtemp(path.join(os.tmpdir(), "verify-out-")), "tree");
51
+ git("init", "-q");
52
+ await commit("draft", {
53
+ "docs/rfcs/rfc-9002-fixture.md": rfc("draft"),
54
+ "src/old.test.ts": "it('pre-existing', () => {});\n",
55
+ });
56
+ await commit("accept", { "docs/rfcs/rfc-9002-fixture.md": rfc("accepted") });
57
+ candidate = await commit("RFC-9002: implement", {
58
+ "src/feature.ts": "export const f = 1;\n",
59
+ "src/feature.test.ts": "it('self', () => {});\n",
60
+ "docs/plans/plan-rfc-9002-fixture.md": "# plan for RFC-9002\n",
61
+ "docs/reviews/code/x/review-1.md": "reviews RFC-9002\n",
62
+ "docs/sessions/s.md": "unrelated session\n",
63
+ });
64
+ });
65
+
66
+ afterEach(async () => {
67
+ await fs.rm(root, { recursive: true, force: true });
68
+ await fs.rm(path.dirname(out), { recursive: true, force: true });
69
+ });
70
+
71
+ describe("rfc.verify.workspace (RFC-1333)", () => {
72
+ it("omits test files whose derived origin is self from the verifier worktree", async () => {
73
+ const r = await buildVerifyWorkspace({
74
+ workspaceRoot: root,
75
+ rfcId: "RFC-9002",
76
+ candidateSha: candidate,
77
+ outDir: out,
78
+ });
79
+ expect(r.status, r.error).toBe("pass");
80
+ expect(existsSync(path.join(out, "src/feature.test.ts"))).toBe(false);
81
+ expect(existsSync(path.join(out, "src/old.test.ts")), "pre-acceptance tests stay visible").toBe(
82
+ true,
83
+ );
84
+ expect(existsSync(path.join(out, "src/feature.ts"))).toBe(true);
85
+ });
86
+
87
+ it("omits plan, review, and session documents for the RFC from the verifier worktree", async () => {
88
+ const r = await buildVerifyWorkspace({
89
+ workspaceRoot: root,
90
+ rfcId: "RFC-9002",
91
+ candidateSha: candidate,
92
+ outDir: out,
93
+ });
94
+ expect(existsSync(path.join(out, "docs/plans/plan-rfc-9002-fixture.md"))).toBe(false);
95
+ expect(existsSync(path.join(out, "docs/reviews/code/x/review-1.md"))).toBe(false);
96
+ expect(existsSync(path.join(out, "docs/sessions/s.md")), "unrelated docs stay").toBe(true);
97
+ const bundle = await fs.readFile(path.join(out, "VERIFY-BUNDLE.md"), "utf8");
98
+ expect(bundle).toContain("## Decision");
99
+ expect(bundle).not.toContain("## Risks");
100
+ expect(r.removed).toContain("src/feature.test.ts");
101
+ });
102
+
103
+ it("fails without leaving a partial tree for an unknown candidate", async () => {
104
+ const r = await buildVerifyWorkspace({
105
+ workspaceRoot: root,
106
+ rfcId: "RFC-9002",
107
+ candidateSha: "not-a-ref",
108
+ });
109
+ expect(r.status).toBe("fail");
110
+ expect(r.path).toBeNull();
111
+ });
112
+
113
+ it("exports the candidate without git metadata", async () => {
114
+ await buildVerifyWorkspace({
115
+ workspaceRoot: root,
116
+ rfcId: "RFC-9002",
117
+ candidateSha: candidate,
118
+ outDir: out,
119
+ });
120
+ expect(existsSync(path.join(out, ".git"))).toBe(false);
121
+ });
122
+ });