@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
@@ -0,0 +1,342 @@
1
+ /*
2
+ <MODULE_CONTRACT>
3
+ <purpose>
4
+ RFC-1333: rfc.verify.workspace — export a committed candidate as a plain tree
5
+ (no git metadata) for a clean-context acceptance verifier, stripped of the
6
+ implementer's in-range tests and of the RFC's plan, review, session, and queue
7
+ documents, with a VERIFY-BUNDLE.md carrying only the RFC's normative prose.
8
+ </purpose>
9
+ <non-goals>
10
+ <item>Do not run the verifier — the fo-review acceptance mode does.</item>
11
+ <item>Do not write inside the repository — the export lives under the OS temp dir.</item>
12
+ <item>Do not hide anything cryptographically — the verifier is pointed at the export; isolation is recorded, not enforced.</item>
13
+ </non-goals>
14
+ </MODULE_CONTRACT>
15
+ <KEY_DECISIONS>
16
+ <item>git archive piped into tar, never a worktree: a worktree shares the object database.</item>
17
+ <item>A test file touched in range by any commit without the verifier trailer pair is stripped.</item>
18
+ <item>node_modules (root included) are mirrored entry by entry with workspace links rewritten into the export.</item>
19
+ <item>The candidate resolves to a full commit sha once; a failed export removes its partial tree.</item>
20
+ <item>Directory links are junctions on Windows; path checks use forward slashes.</item>
21
+ </KEY_DECISIONS>
22
+ <CHANGE_SUMMARY>
23
+ <item>RFC-1333: initial implementation — git-free export, self-test and RFC-document stripping, VERIFY-BUNDLE.md.</item>
24
+ <item>RFC-1333: review hardening — piped export, root node_modules mirroring, failure cleanup, sha resolution, Windows links.</item>
25
+ </CHANGE_SUMMARY>
26
+ */
27
+
28
+ import { spawn } from "node:child_process";
29
+ import { existsSync } from "node:fs";
30
+ import {
31
+ lstat,
32
+ mkdir,
33
+ mkdtemp,
34
+ readdir,
35
+ readFile,
36
+ readlink,
37
+ rm,
38
+ symlink,
39
+ writeFile,
40
+ } from "node:fs/promises";
41
+ import { tmpdir } from "node:os";
42
+ import { dirname, join, relative, resolve, sep } from "node:path";
43
+
44
+ import { execFile } from "../../src/utils/sync-fs.ts";
45
+ import { listRfcFiles, readAndParseRfc, rfcFileMatchesId } from "./frontmatter-io.ts";
46
+ import { RFC_DIR } from "./types.ts";
47
+ import {
48
+ createOriginGit,
49
+ gitEnvForCwd,
50
+ hasVerifierTrailers,
51
+ resolveImplementationRange,
52
+ type OriginGit,
53
+ } from "./verification-origin.ts";
54
+ import type {
55
+ ForgeCommandInput,
56
+ ForgeCommandResult,
57
+ ForgeRuntimeContext,
58
+ } from "../../src/types.ts";
59
+
60
+ export interface RfcVerifyWorkspaceResult {
61
+ command: "rfc.verify.workspace";
62
+ status: "pass" | "fail";
63
+ rfcId: string;
64
+ candidateSha: string;
65
+ path: string | null;
66
+ removed: string[];
67
+ error?: string;
68
+ }
69
+
70
+ const TEST_FILE_RE = /\.(test|spec)\.(ts|tsx|mts|js|mjs)$/;
71
+ const DOC_DIRS = ["docs/plans/", "docs/reviews/", "docs/sessions/", "docs/queues/"];
72
+ const BUNDLE_SECTIONS = ["Context", "Problem", "Decision", "Design", "Acceptance criteria"];
73
+
74
+ const EXPORT_TIMEOUT_MS = 300_000;
75
+
76
+ const toPosix = (p: string): string => p.split(sep).join("/");
77
+
78
+ function run(
79
+ cwd: string,
80
+ cmd: string,
81
+ args: string[],
82
+ ): Promise<{ ok: boolean; stdout: string; stderr: string }> {
83
+ return new Promise((done) => {
84
+ execFile(
85
+ cmd,
86
+ args,
87
+ { cwd, timeout: 120000, maxBuffer: 64 * 1024 * 1024, env: gitEnvForCwd() },
88
+ (err, stdout, stderr) => done({ ok: !err, stdout: String(stdout), stderr: String(stderr) }),
89
+ );
90
+ });
91
+ }
92
+
93
+ /** Test files touched in base..head by at least one commit without the verifier trailer pair. */
94
+ export async function listSelfTestFiles(
95
+ git: OriginGit,
96
+ base: string,
97
+ head: string,
98
+ ): Promise<string[]> {
99
+ const out = await git.run([
100
+ "log",
101
+ "--first-parent",
102
+ "-m",
103
+ "--format=%x1e%H%x1f%B%x1f",
104
+ "--name-only",
105
+ `${base}..${head}`,
106
+ ]);
107
+ if (!out) return [];
108
+ const self = new Set<string>();
109
+ for (const chunk of out.split("\x1e")) {
110
+ const [, body = "", files = ""] = chunk.split("\x1f");
111
+ if (hasVerifierTrailers(body)) continue;
112
+ for (const f of files.split("\n").map((l) => l.trim())) if (TEST_FILE_RE.test(f)) self.add(f);
113
+ }
114
+ return [...self].sort();
115
+ }
116
+
117
+ /** Keep only the normative sections of the RFC body. */
118
+ export function extractBundleSections(body: string): string {
119
+ return body
120
+ .split(/^(?=## )/m)
121
+ .filter((p) => BUNDLE_SECTIONS.some((h) => new RegExp(`^## ${h}\\r?\\n`).test(p)))
122
+ .join("\n")
123
+ .trim();
124
+ }
125
+
126
+ /** Directory links use junctions on Windows (no Developer Mode needed). */
127
+ async function linkPath(target: string, dst: string): Promise<void> {
128
+ const isDir = (await lstat(target).catch(() => null))?.isDirectory() ?? true;
129
+ const type = isDir ? (process.platform === "win32" ? "junction" : "dir") : "file";
130
+ await symlink(target, dst, type);
131
+ }
132
+
133
+ /**
134
+ * Mirror `<pkg>/node_modules` (root included) entry by entry. A link that
135
+ * resolves inside the repository but outside any node_modules is a workspace
136
+ * link and is rewritten into the export, so siblings run at the candidate.
137
+ */
138
+ async function mirrorNodeModules(mainRoot: string, outRoot: string, pkgRel: string): Promise<void> {
139
+ const srcDir = join(mainRoot, pkgRel, "node_modules");
140
+ const dstDir = join(outRoot, pkgRel, "node_modules");
141
+ if (!existsSync(srcDir) || existsSync(dstDir)) return;
142
+ await mkdir(dstDir, { recursive: true });
143
+ const link = async (rel: string): Promise<void> => {
144
+ const src = join(srcDir, rel);
145
+ let target = src;
146
+ if ((await lstat(src)).isSymbolicLink()) {
147
+ const resolved = resolve(dirname(src), await readlink(src));
148
+ const inRepo = toPosix(relative(mainRoot, resolved));
149
+ const workspaceLink =
150
+ !inRepo.startsWith("..") &&
151
+ inRepo !== "node_modules" &&
152
+ !inRepo.startsWith("node_modules/") &&
153
+ !inRepo.includes("/node_modules/");
154
+ target = workspaceLink ? join(outRoot, inRepo) : resolved;
155
+ }
156
+ await mkdir(dirname(join(dstDir, rel)), { recursive: true });
157
+ await linkPath(target, join(dstDir, rel));
158
+ };
159
+ for (const name of await readdir(srcDir)) {
160
+ if (name.startsWith("@")) {
161
+ for (const sub of await readdir(join(srcDir, name))) await link(join(name, sub));
162
+ } else {
163
+ await link(name);
164
+ }
165
+ }
166
+ }
167
+
168
+ /** `git archive <sha> | tar -x` through pipes — no temp tarball, no drive-letter paths. */
169
+ function exportTree(workspaceRoot: string, sha: string, out: string): Promise<string | null> {
170
+ const exitOf = (child: ReturnType<typeof spawn>): Promise<number | null> =>
171
+ new Promise((r) => {
172
+ child.on("error", () => r(-1));
173
+ child.on("close", (code) => r(code));
174
+ });
175
+ const archive = spawn("git", ["archive", "--format=tar", sha], {
176
+ cwd: workspaceRoot,
177
+ env: gitEnvForCwd(),
178
+ });
179
+ const tar = spawn("tar", ["-x", "-f", "-"], { cwd: out });
180
+ let err = "";
181
+ archive.stderr?.on("data", (d) => (err += String(d)));
182
+ tar.stderr?.on("data", (d) => (err += String(d)));
183
+ // An early tar exit must surface as a failed export, not an uncaught EPIPE.
184
+ tar.stdin?.on("error", () => {});
185
+ archive.stdout?.on("error", () => {});
186
+ archive.stdout?.pipe(tar.stdin!);
187
+ tar.on("close", (code) => {
188
+ if (code !== 0) archive.kill();
189
+ });
190
+ const timer = setTimeout(() => {
191
+ err += `export timed out after ${EXPORT_TIMEOUT_MS} ms`;
192
+ archive.kill();
193
+ tar.kill();
194
+ }, EXPORT_TIMEOUT_MS);
195
+ // Both processes must exit before the verdict — tar can close first.
196
+ return Promise.all([exitOf(archive), exitOf(tar)]).then(([g, t]) => {
197
+ clearTimeout(timer);
198
+ return g === 0 && t === 0 ? null : err.trim() || `export failed (git ${g}, tar ${t})`;
199
+ });
200
+ }
201
+
202
+ export async function buildVerifyWorkspace(opts: {
203
+ workspaceRoot: string;
204
+ rfcId: string;
205
+ candidateSha: string;
206
+ outDir?: string;
207
+ }): Promise<RfcVerifyWorkspaceResult> {
208
+ const { workspaceRoot, rfcId } = opts;
209
+ // Resolve once to a full commit sha: a moving branch name must not shift the binding.
210
+ const resolved = (
211
+ await run(workspaceRoot, "git", ["rev-parse", "--verify", `${opts.candidateSha}^{commit}`])
212
+ ).stdout.trim();
213
+ const candidateSha = resolved || opts.candidateSha;
214
+ const fail = (error: string): RfcVerifyWorkspaceResult => ({
215
+ command: "rfc.verify.workspace",
216
+ status: "fail",
217
+ rfcId,
218
+ candidateSha,
219
+ path: null,
220
+ removed: [],
221
+ error,
222
+ });
223
+ if (!resolved) return fail(`candidate ${opts.candidateSha} is not a commit`);
224
+
225
+ const rfcDir = join(workspaceRoot, RFC_DIR);
226
+ const fileName = (await listRfcFiles(rfcDir)).find((f) => rfcFileMatchesId(f, rfcId));
227
+ if (!fileName) return fail(`${rfcId} not found`);
228
+ const parsed = await readAndParseRfc(rfcDir, fileName);
229
+ if (!parsed || "error" in parsed) return fail(`${rfcId} unparseable`);
230
+
231
+ const git = createOriginGit(workspaceRoot);
232
+ const rfcRel = toPosix(relative(workspaceRoot, join(rfcDir, fileName)));
233
+ const range = await resolveImplementationRange(git, rfcRel);
234
+ if (!range.base) return fail(`${rfcId} has no status: accepted transition in history`);
235
+ const selfTests = await listSelfTestFiles(git, range.base, candidateSha);
236
+
237
+ const selfCreated = opts.outDir === undefined;
238
+ const out = opts.outDir ?? (await mkdtemp(join(tmpdir(), `rfc-verify-${rfcId.toLowerCase()}-`)));
239
+ let result: RfcVerifyWorkspaceResult;
240
+ try {
241
+ await mkdir(out, { recursive: true });
242
+ const exportError = await exportTree(workspaceRoot, candidateSha, out);
243
+ if (exportError) {
244
+ result = fail(`export failed: ${exportError}`);
245
+ } else {
246
+ const removed: string[] = [];
247
+ const drop = async (rel: string): Promise<void> => {
248
+ if (existsSync(join(out, rel))) {
249
+ await rm(join(out, rel), { recursive: true, force: true });
250
+ removed.push(rel);
251
+ }
252
+ };
253
+ for (const f of selfTests) await drop(f);
254
+ const idRe = new RegExp(`\\b${rfcId}\\b`, "i");
255
+ const tracked = (
256
+ await run(workspaceRoot, "git", ["ls-tree", "-r", "--name-only", candidateSha])
257
+ ).stdout.split("\n");
258
+ for (const f of tracked) {
259
+ if (!DOC_DIRS.some((d) => f.startsWith(d))) continue;
260
+ const abs = join(out, f);
261
+ if (existsSync(abs) && (idRe.test(f) || idRe.test(await readFile(abs, "utf8")))) {
262
+ await drop(f);
263
+ }
264
+ }
265
+ const slug = rfcId.toLowerCase();
266
+ await drop(`${RFC_DIR}/verification/${slug}.generated.yaml`);
267
+ await drop(`docs/metrics/rfcs/${slug}.metrics.yaml`);
268
+
269
+ await mirrorNodeModules(workspaceRoot, out, ".");
270
+ for (const pj of tracked.filter(
271
+ (f) => f.endsWith("/package.json") && !f.includes("node_modules/"),
272
+ )) {
273
+ await mirrorNodeModules(workspaceRoot, out, dirname(pj));
274
+ }
275
+
276
+ await writeFile(
277
+ join(out, "VERIFY-BUNDLE.md"),
278
+ [
279
+ `# Acceptance verification bundle — ${rfcId}`,
280
+ "",
281
+ `Candidate: ${candidateSha}`,
282
+ "",
283
+ "Removed from this tree (exists in the candidate, intentionally hidden):",
284
+ ...removed.map((r) => `- ${r}`),
285
+ "",
286
+ extractBundleSections(parsed.parsed.body),
287
+ "",
288
+ ].join("\n"),
289
+ );
290
+ result = {
291
+ command: "rfc.verify.workspace",
292
+ status: "pass",
293
+ rfcId,
294
+ candidateSha,
295
+ path: out,
296
+ removed,
297
+ };
298
+ }
299
+ } catch (e) {
300
+ result = fail(e instanceof Error ? e.message : String(e));
301
+ }
302
+ // A failed export must not leave a partial tree behind.
303
+ if (result.status === "fail" && selfCreated) await rm(out, { recursive: true, force: true });
304
+ return result;
305
+ }
306
+
307
+ export async function runRfcVerifyWorkspace(
308
+ input: ForgeCommandInput,
309
+ context: ForgeRuntimeContext,
310
+ ): Promise<ForgeCommandResult<RfcVerifyWorkspaceResult>> {
311
+ const rfcId = String(input.flags["id"] ?? "").toUpperCase();
312
+ const candidateSha = String(input.flags["candidate"] ?? "");
313
+ if (!rfcId || !candidateSha) {
314
+ const data: RfcVerifyWorkspaceResult = {
315
+ command: "rfc.verify.workspace",
316
+ status: "fail",
317
+ rfcId,
318
+ candidateSha,
319
+ path: null,
320
+ removed: [],
321
+ error: "--id and --candidate are required",
322
+ };
323
+ return {
324
+ data,
325
+ exitCode: 1,
326
+ summary: "rfc.verify.workspace: --id and --candidate are required",
327
+ };
328
+ }
329
+ const data = await buildVerifyWorkspace({
330
+ workspaceRoot: context.workspaceRoot,
331
+ rfcId,
332
+ candidateSha,
333
+ });
334
+ return {
335
+ data,
336
+ exitCode: data.status === "pass" ? 0 : 1,
337
+ summary:
338
+ data.status === "pass"
339
+ ? `rfc.verify.workspace: ${rfcId} at ${candidateSha.slice(0, 9)} → ${data.path} (${data.removed.length} path(s) hidden)`
340
+ : `rfc.verify.workspace: ${data.error}`,
341
+ };
342
+ }
@@ -13,6 +13,7 @@ Writes to docs/metrics/rfcs/<rfc-id>.metrics.yaml via writeFileAtomic.
13
13
  </non-goals>
14
14
  </MODULE_CONTRACT>
15
15
  <CHANGE_SUMMARY>
16
+ <item>RFC-1321: getRfcCommits grep hardened — --fixed-strings + --regexp-ignore-case so a lowercase rfcId still finds canonical subjects.</item>
16
17
  <item>RFC-1053: initial generateRfcMetrics pure function.</item>
17
18
  </CHANGE_SUMMARY>
18
19
  */
@@ -80,6 +81,8 @@ async function getRfcCommits(workspaceRoot: string, rfcId: string): Promise<GitL
80
81
  const raw = await execGit(workspaceRoot, [
81
82
  "log",
82
83
  "--no-merges",
84
+ "--fixed-strings",
85
+ "--regexp-ignore-case",
83
86
  `--grep=${rfcId}`,
84
87
  `--format=${format}`,
85
88
  ]);
@@ -0,0 +1,130 @@
1
+ /*
2
+ <MODULE_CONTRACT>
3
+ <purpose>Prove spec.status resolves materializedAs against archived RFCs: an implemented RFC living only under docs/rfcs/archive/implemented/ still marks its node implemented and unblocks the front.</purpose>
4
+ <non-goals><item>Do not duplicate spec.validate rule coverage — that lives in spec-validate.test.ts.</item></non-goals>
5
+ </MODULE_CONTRACT>
6
+ <CHANGE_SUMMARY><item>FIX: initial coverage — archived-implemented dependency unblocks front; top-level draft stays a blocker.</item></CHANGE_SUMMARY>
7
+ */
8
+
9
+ import fs from "node:fs/promises";
10
+ import os from "node:os";
11
+ import path from "node:path";
12
+ import { afterEach, describe, expect, it } from "vitest";
13
+ import type { ForgeRuntimeContext } from "../../src/types.ts";
14
+ import { runSpecStatus } from "./spec-status.ts";
15
+
16
+ const roots: string[] = [];
17
+
18
+ afterEach(async () => {
19
+ await Promise.all(roots.splice(0).map((root) => fs.rm(root, { recursive: true, force: true })));
20
+ });
21
+
22
+ async function makeWorkspace(): Promise<string> {
23
+ const workspaceRoot = await fs.mkdtemp(path.join(os.tmpdir(), "spec-status-"));
24
+ roots.push(workspaceRoot);
25
+ await fs.mkdir(path.join(workspaceRoot, "docs/rfcs"), { recursive: true });
26
+ return workspaceRoot;
27
+ }
28
+
29
+ async function writeSpec(workspaceRoot: string, id: string, rfcs: string): Promise<void> {
30
+ const specDir = path.join(workspaceRoot, "docs/specs", id);
31
+ await fs.mkdir(specDir, { recursive: true });
32
+ await fs.writeFile(path.join(specDir, "forge-spec.yaml"), `schema: forge/spec@1
33
+ id: ${id}
34
+ title: ${id}
35
+ version: 1.0.0
36
+ status: accepted
37
+ reviewers: []
38
+ sourceNote: test fixture
39
+ vendoredAt: 2026-10-13
40
+ documents: {}
41
+ decisions: []
42
+ rfcs:
43
+ ${rfcs}waves:
44
+ - id: 1
45
+ name: Test
46
+ goal: Exercise archived-RFC resolution
47
+ `);
48
+ }
49
+
50
+ async function writeRfc(
51
+ workspaceRoot: string,
52
+ relPath: string,
53
+ id: string,
54
+ status: string,
55
+ ): Promise<void> {
56
+ const filePath = path.join(workspaceRoot, "docs/rfcs", relPath);
57
+ await fs.mkdir(path.dirname(filePath), { recursive: true });
58
+ await fs.writeFile(filePath, `---\nid: ${id}\nstatus: ${status}\n---\n\n# ${id}\n`);
59
+ }
60
+
61
+ function ctx(workspaceRoot: string): ForgeRuntimeContext {
62
+ return {
63
+ workspaceRoot,
64
+ dryRun: false,
65
+ outputFormat: "json",
66
+ logger: { section() {}, info() {}, warn() {}, error() {}, success() {} },
67
+ } as ForgeRuntimeContext;
68
+ }
69
+
70
+ const TWO_NODE_SPEC = ` - id: A
71
+ title: Shipped node
72
+ dependsOn: []
73
+ wave: 1
74
+ sources: []
75
+ materializedAs: RFC-0001
76
+ - id: B
77
+ title: Front node
78
+ dependsOn:
79
+ - A
80
+ wave: 2
81
+ sources: []
82
+ `;
83
+
84
+ describe("spec.status archived-RFC resolution", () => {
85
+ it("resolves an implemented RFC living only under archive/implemented and unblocks the front", async () => {
86
+ const workspaceRoot = await makeWorkspace();
87
+ await writeSpec(workspaceRoot, "journal", TWO_NODE_SPEC);
88
+ await writeRfc(
89
+ workspaceRoot,
90
+ "archive/implemented/rfc-0001-shipped.md",
91
+ "RFC-0001",
92
+ "implemented",
93
+ );
94
+
95
+ const result = await runSpecStatus({ argv: [], flags: { spec: "journal" } }, ctx(workspaceRoot));
96
+ expect(result.exitCode).toBe(0);
97
+ const data = result.data as {
98
+ specs: Array<{
99
+ nodes: Array<{ id: string; state: string }>;
100
+ front: string[];
101
+ progress: { implemented: number; total: number };
102
+ }>;
103
+ };
104
+ const spec = data.specs[0]!;
105
+ expect(spec.nodes.find((n) => n.id === "A")!.state).toBe("implemented");
106
+ expect(spec.nodes.find((n) => n.id === "B")!.state).toBe("unmaterialized");
107
+ expect(spec.front).toEqual(["B"]);
108
+ expect(spec.progress).toEqual({ implemented: 1, total: 2 });
109
+ });
110
+
111
+ it("keeps a top-level draft RFC as a blocker", async () => {
112
+ const workspaceRoot = await makeWorkspace();
113
+ await writeSpec(workspaceRoot, "journal", TWO_NODE_SPEC);
114
+ await writeRfc(workspaceRoot, "rfc-0001-wip.md", "RFC-0001", "draft");
115
+
116
+ const result = await runSpecStatus({ argv: [], flags: { spec: "journal" } }, ctx(workspaceRoot));
117
+ const data = result.data as {
118
+ specs: Array<{
119
+ nodes: Array<{ id: string; state: string; blockedBy: string[] }>;
120
+ front: string[];
121
+ }>;
122
+ };
123
+ const spec = data.specs[0]!;
124
+ expect(spec.nodes.find((n) => n.id === "A")!.state).toBe("draft");
125
+ const b = spec.nodes.find((n) => n.id === "B")!;
126
+ expect(b.state).toBe("unmaterialized");
127
+ expect(b.blockedBy).toEqual(["A"]);
128
+ expect(spec.front).toEqual([]);
129
+ });
130
+ });
@@ -8,6 +8,7 @@
8
8
  <CHANGE_SUMMARY>
9
9
  <item>RFC-0396: initial spec.status handler — per-node states, blockers, front, progress.</item>
10
10
  <item>RFC-1240: consumer-aware front — foreignOwned flag/list, foreign deps are not local blockers, --consumer flag resolution.</item>
11
+ <item>FIX: loadRfcStatuses delegated to loadRfcStatusMap (recursive) — archived implemented RFCs resolve their status, so terminal dependencies unblock the front instead of collapsing nodes to stale draft.</item>
11
12
  </CHANGE_SUMMARY>
12
13
  */
13
14
 
@@ -29,6 +30,7 @@ import {
29
30
  type ForgeSpec,
30
31
  type SpecAmendment,
31
32
  } from "./spec-schema.ts";
33
+ import { loadRfcStatusMap } from "../rfc/frontmatter-io.ts";
32
34
 
33
35
  // ---------------------------------------------------------------------------
34
36
  // Types
@@ -93,24 +95,9 @@ async function listSpecDirs(specsDir: string): Promise<string[]> {
93
95
  async function loadRfcStatuses(
94
96
  rfcDir: string,
95
97
  ): Promise<Map<string, string>> {
96
- const statuses = new Map<string, string>();
97
- if (!existsSync(rfcDir)) return statuses;
98
- const files = (await fs.readdir(rfcDir)).map((e) => e.name);
99
- for (const file of files) {
100
- if (!file.endsWith(".md") || file.startsWith("rfc-0000")) continue;
101
- try {
102
- const content = await fs.readFile(path.join(rfcDir, file));
103
- const fmMatch = content.match(/^---\n([\s\S]*?)\n---/);
104
- if (!fmMatch) continue;
105
- const fm = parseYaml(fmMatch[1]) as Record<string, unknown>;
106
- const id = String(fm["id"] ?? "");
107
- const status = String(fm["status"] ?? "");
108
- if (id && status) statuses.set(id, status);
109
- } catch {
110
- // skip
111
- }
112
- }
113
- return statuses;
98
+ // loadRfcStatusMap recurses — archived RFCs still resolve their status, so a
99
+ // terminal (implemented/archived) dependency unblocks the front correctly.
100
+ return loadRfcStatusMap(rfcDir);
114
101
  }
115
102
 
116
103
  async function loadAmendments(specDir: string): Promise<SpecAmendment[]> {
@@ -3,7 +3,11 @@
3
3
  <purpose>Prove vendored spec validation behaviors — consumer rules, SPEC-07 archive resolution, and sweep-mode package scoping.</purpose>
4
4
  <non-goals><item>Do not duplicate individual integrity, graph, or amendment rule tests.</item></non-goals>
5
5
  </MODULE_CONTRACT>
6
- <CHANGE_SUMMARY><item>Gap fix: cover SPEC-07 after terminal RFC archival.</item><item>Handoff xrepo-personal-agent-to-forge-spec-validate-sweep: cover sweep-mode manifest-dir scoping and skippedDirs.</item></CHANGE_SUMMARY>
6
+ <CHANGE_SUMMARY>
7
+ <item>Gap fix: cover SPEC-07 after terminal RFC archival.</item>
8
+ <item>Handoff xrepo-personal-agent-to-forge-spec-validate-sweep: cover sweep-mode manifest-dir scoping and skippedDirs.</item>
9
+ <item>RFC-1302: consumer-aware SPEC-07, narrowed SPEC-10, source-first bin entry (RFC-1302)</item>
10
+ </CHANGE_SUMMARY>
7
11
  */
8
12
 
9
13
  import fs from "node:fs/promises";
@@ -172,3 +176,74 @@ describe("spec.validate sweep scoping (xrepo-personal-agent-to-forge-spec-valida
172
176
  expect(result.data!.specs[0]!.violations[0]!.rule).toBe("SPEC-02");
173
177
  });
174
178
  });
179
+
180
+ describe("spec.validate RFC-1302 consumer-aware SPEC-07 and narrowed SPEC-10", () => {
181
+ async function workspace(nodeExtra: string, consumer?: string): Promise<string> {
182
+ const workspaceRoot = await fs.mkdtemp(path.join(os.tmpdir(), "spec-validate-1302-"));
183
+ roots.push(workspaceRoot);
184
+ if (consumer) {
185
+ await fs.writeFile(path.join(workspaceRoot, "forge.yaml"),
186
+ `schema: forge/config@1\nproject:\n name: test-ws\n consumer: ${consumer}\npaths: {}\n`);
187
+ }
188
+ await writeConsumerSpec(workspaceRoot, nodeExtra);
189
+ return workspaceRoot;
190
+ }
191
+
192
+ async function amendment(root: string, id: string, targetsYaml: string): Promise<void> {
193
+ const dir = path.join(root, "docs/specs/example/amendments");
194
+ await fs.mkdir(dir, { recursive: true });
195
+ await fs.writeFile(path.join(dir, `${id.toLowerCase()}.md`), `---
196
+ schema: forge/spec-amendment@1
197
+ id: ${id}
198
+ title: ${id}
199
+ status: accepted
200
+ createdAt: 2026-10-15
201
+ reviewers:
202
+ - human:test
203
+ targets:
204
+ ${targetsYaml}discoveredBy: test
205
+ ---
206
+ `);
207
+ }
208
+
209
+ it("skips SPEC-07 for a materialized node owned by another consumer", async () => {
210
+ const root = await workspace(" consumers:\n - werkstatt\n materializedAs: RFC-9001\n", "pipelines");
211
+ const result = await runSpecValidate({ argv: [], flags: { spec: "example" } }, ctx(root));
212
+ expect(result.exitCode).toBe(0);
213
+ expect(result.data!.specs[0]!.violations).toEqual([]);
214
+ });
215
+
216
+ it("keeps SPEC-07 for a locally owned materialized node whose RFC is missing", async () => {
217
+ const root = await workspace(" consumers:\n - werkstatt\n materializedAs: RFC-9001\n", "werkstatt");
218
+ const result = await runSpecValidate({ argv: [], flags: { spec: "example" } }, ctx(root));
219
+ expect(result.exitCode).toBe(1);
220
+ expect(result.data!.specs[0]!.violations.map((v) => v.rule)).toEqual(["SPEC-07"]);
221
+ });
222
+
223
+ it("downgrades SPEC-10 node-target overlap to a warning", async () => {
224
+ const root = await workspace("");
225
+ await amendment(root, "AMD-001", " - kind: node\n id: EX-001\n");
226
+ await amendment(root, "AMD-002", " - kind: node\n id: EX-001\n");
227
+ const result = await runSpecValidate({ argv: [], flags: { spec: "example" } }, ctx(root));
228
+ expect(result.exitCode).toBe(0);
229
+ const v = result.data!.specs[0]!.violations;
230
+ expect(v).toHaveLength(1);
231
+ expect(v[0]).toMatchObject({ rule: "SPEC-10", severity: "warning" });
232
+ expect(v[0]!.message).toContain("AMD-001, AMD-002");
233
+ });
234
+
235
+ it("keeps SPEC-10 as an error when two amendments rewrite the same section anchor", async () => {
236
+ const root = await workspace("");
237
+ await fs.writeFile(path.join(root, "docs/specs/example/forge-spec.yaml"),
238
+ (await fs.readFile(path.join(root, "docs/specs/example/forge-spec.yaml"), "utf8"))
239
+ .replace("documents: {}", "documents:\n doc: doc.md"));
240
+ const t = " - kind: section\n document: doc\n anchor: a\n";
241
+ await amendment(root, "AMD-001", t);
242
+ await amendment(root, "AMD-002", t);
243
+ const result = await runSpecValidate({ argv: [], flags: { spec: "example" } }, ctx(root));
244
+ expect(result.exitCode).toBe(1);
245
+ const spec10 = result.data!.specs[0]!.violations.filter((x) => x.rule === "SPEC-10");
246
+ expect(spec10).toHaveLength(1);
247
+ expect(spec10[0]!.severity).toBeUndefined();
248
+ });
249
+ });