@warpgogol/forge 9.4.1 → 9.6.0

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 (411) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/README.md +30 -0
  3. package/README.uk.md +30 -0
  4. package/bin/cli.ts +163 -53
  5. package/dist/bin/cli.js +137 -42
  6. package/dist/bin/cli.js.map +1 -1
  7. package/dist/os/codebase/codebase.module.d.ts +3 -0
  8. package/dist/os/codebase/codebase.module.d.ts.map +1 -0
  9. package/dist/os/codebase/codebase.module.js +53 -0
  10. package/dist/os/codebase/codebase.module.js.map +1 -0
  11. package/dist/os/codebase/handlers/codebase-measure-symbols.d.ts +15 -0
  12. package/dist/os/codebase/handlers/codebase-measure-symbols.d.ts.map +1 -0
  13. package/dist/os/codebase/handlers/codebase-measure-symbols.js +97 -0
  14. package/dist/os/codebase/handlers/codebase-measure-symbols.js.map +1 -0
  15. package/dist/os/codebase/handlers/codebase-measure.d.ts +22 -0
  16. package/dist/os/codebase/handlers/codebase-measure.d.ts.map +1 -0
  17. package/dist/os/codebase/handlers/codebase-measure.js +435 -0
  18. package/dist/os/codebase/handlers/codebase-measure.js.map +1 -0
  19. package/dist/os/codebase/index.d.ts +4 -0
  20. package/dist/os/codebase/index.d.ts.map +1 -0
  21. package/dist/os/codebase/index.js +13 -0
  22. package/dist/os/codebase/index.js.map +1 -0
  23. package/dist/os/codebase/types.d.ts +35 -0
  24. package/dist/os/codebase/types.d.ts.map +1 -0
  25. package/dist/os/codebase/types.js +17 -0
  26. package/dist/os/codebase/types.js.map +1 -0
  27. package/dist/os/core/handlers/package-health.d.ts +6 -4
  28. package/dist/os/core/handlers/package-health.d.ts.map +1 -1
  29. package/dist/os/core/handlers/package-health.js +15 -20
  30. package/dist/os/core/handlers/package-health.js.map +1 -1
  31. package/dist/os/correctness/anchors.d.ts +24 -0
  32. package/dist/os/correctness/anchors.d.ts.map +1 -0
  33. package/dist/os/correctness/anchors.js +156 -0
  34. package/dist/os/correctness/anchors.js.map +1 -0
  35. package/dist/os/correctness/audit/bindings-verify-substance.d.ts +7 -0
  36. package/dist/os/correctness/audit/bindings-verify-substance.d.ts.map +1 -0
  37. package/dist/os/correctness/audit/bindings-verify-substance.js +145 -0
  38. package/dist/os/correctness/audit/bindings-verify-substance.js.map +1 -0
  39. package/dist/os/correctness/audit/differential.d.ts +7 -0
  40. package/dist/os/correctness/audit/differential.d.ts.map +1 -0
  41. package/dist/os/correctness/audit/differential.js +105 -0
  42. package/dist/os/correctness/audit/differential.js.map +1 -0
  43. package/dist/os/correctness/audit/ledger-orphans.d.ts +6 -0
  44. package/dist/os/correctness/audit/ledger-orphans.d.ts.map +1 -0
  45. package/dist/os/correctness/audit/ledger-orphans.js +71 -0
  46. package/dist/os/correctness/audit/ledger-orphans.js.map +1 -0
  47. package/dist/os/correctness/audit/ledger.d.ts +29 -0
  48. package/dist/os/correctness/audit/ledger.d.ts.map +1 -0
  49. package/dist/os/correctness/audit/ledger.js +72 -0
  50. package/dist/os/correctness/audit/ledger.js.map +1 -0
  51. package/dist/os/correctness/audit/run.d.ts +27 -0
  52. package/dist/os/correctness/audit/run.d.ts.map +1 -0
  53. package/dist/os/correctness/audit/run.js +184 -0
  54. package/dist/os/correctness/audit/run.js.map +1 -0
  55. package/dist/os/correctness/audit/schema-db.d.ts +32 -0
  56. package/dist/os/correctness/audit/schema-db.d.ts.map +1 -0
  57. package/dist/os/correctness/audit/schema-db.js +166 -0
  58. package/dist/os/correctness/audit/schema-db.js.map +1 -0
  59. package/dist/os/correctness/audit/snapshot.d.ts +34 -0
  60. package/dist/os/correctness/audit/snapshot.d.ts.map +1 -0
  61. package/dist/os/correctness/audit/snapshot.js +190 -0
  62. package/dist/os/correctness/audit/snapshot.js.map +1 -0
  63. package/dist/os/correctness/audit/sql-scanner.d.ts +28 -0
  64. package/dist/os/correctness/audit/sql-scanner.d.ts.map +1 -0
  65. package/dist/os/correctness/audit/sql-scanner.js +279 -0
  66. package/dist/os/correctness/audit/sql-scanner.js.map +1 -0
  67. package/dist/os/correctness/audit/sql-schema-conform.d.ts +17 -0
  68. package/dist/os/correctness/audit/sql-schema-conform.d.ts.map +1 -0
  69. package/dist/os/correctness/audit/sql-schema-conform.js +163 -0
  70. package/dist/os/correctness/audit/sql-schema-conform.js.map +1 -0
  71. package/dist/os/correctness/audit/state-transitions-coverage.d.ts +19 -0
  72. package/dist/os/correctness/audit/state-transitions-coverage.d.ts.map +1 -0
  73. package/dist/os/correctness/audit/state-transitions-coverage.js +263 -0
  74. package/dist/os/correctness/audit/state-transitions-coverage.js.map +1 -0
  75. package/dist/os/correctness/audit/tests/git-fixture.d.ts +15 -0
  76. package/dist/os/correctness/audit/tests/git-fixture.d.ts.map +1 -0
  77. package/dist/os/correctness/audit/tests/git-fixture.js +85 -0
  78. package/dist/os/correctness/audit/tests/git-fixture.js.map +1 -0
  79. package/dist/os/correctness/audit/types.d.ts +58 -0
  80. package/dist/os/correctness/audit/types.d.ts.map +1 -0
  81. package/dist/os/correctness/audit/types.js +34 -0
  82. package/dist/os/correctness/audit/types.js.map +1 -0
  83. package/dist/os/correctness/correctness.module.d.ts +3 -0
  84. package/dist/os/correctness/correctness.module.d.ts.map +1 -0
  85. package/dist/os/correctness/correctness.module.js +173 -0
  86. package/dist/os/correctness/correctness.module.js.map +1 -0
  87. package/dist/os/correctness/gate/frozen.d.ts +52 -0
  88. package/dist/os/correctness/gate/frozen.d.ts.map +1 -0
  89. package/dist/os/correctness/gate/frozen.js +322 -0
  90. package/dist/os/correctness/gate/frozen.js.map +1 -0
  91. package/dist/os/correctness/gate/origin.d.ts +28 -0
  92. package/dist/os/correctness/gate/origin.d.ts.map +1 -0
  93. package/dist/os/correctness/gate/origin.js +139 -0
  94. package/dist/os/correctness/gate/origin.js.map +1 -0
  95. package/dist/os/correctness/gate/repo.d.ts +25 -0
  96. package/dist/os/correctness/gate/repo.d.ts.map +1 -0
  97. package/dist/os/correctness/gate/repo.js +88 -0
  98. package/dist/os/correctness/gate/repo.js.map +1 -0
  99. package/dist/os/correctness/gate/run.d.ts +22 -0
  100. package/dist/os/correctness/gate/run.d.ts.map +1 -0
  101. package/dist/os/correctness/gate/run.js +430 -0
  102. package/dist/os/correctness/gate/run.js.map +1 -0
  103. package/dist/os/correctness/gate/runner.d.ts +18 -0
  104. package/dist/os/correctness/gate/runner.d.ts.map +1 -0
  105. package/dist/os/correctness/gate/runner.js +123 -0
  106. package/dist/os/correctness/gate/runner.js.map +1 -0
  107. package/dist/os/correctness/gate/tests/gate-fixture.d.ts +36 -0
  108. package/dist/os/correctness/gate/tests/gate-fixture.d.ts.map +1 -0
  109. package/dist/os/correctness/gate/tests/gate-fixture.js +153 -0
  110. package/dist/os/correctness/gate/tests/gate-fixture.js.map +1 -0
  111. package/dist/os/correctness/gate/types.d.ts +102 -0
  112. package/dist/os/correctness/gate/types.d.ts.map +1 -0
  113. package/dist/os/correctness/gate/types.js +64 -0
  114. package/dist/os/correctness/gate/types.js.map +1 -0
  115. package/dist/os/correctness/handlers/audit.d.ts +4 -0
  116. package/dist/os/correctness/handlers/audit.d.ts.map +1 -0
  117. package/dist/os/correctness/handlers/audit.js +95 -0
  118. package/dist/os/correctness/handlers/audit.js.map +1 -0
  119. package/dist/os/correctness/handlers/gate.d.ts +4 -0
  120. package/dist/os/correctness/handlers/gate.d.ts.map +1 -0
  121. package/dist/os/correctness/handlers/gate.js +62 -0
  122. package/dist/os/correctness/handlers/gate.js.map +1 -0
  123. package/dist/os/correctness/handlers/validate.d.ts +19 -0
  124. package/dist/os/correctness/handlers/validate.d.ts.map +1 -0
  125. package/dist/os/correctness/handlers/validate.js +367 -0
  126. package/dist/os/correctness/handlers/validate.js.map +1 -0
  127. package/dist/os/correctness/index.d.ts +8 -0
  128. package/dist/os/correctness/index.d.ts.map +1 -0
  129. package/dist/os/correctness/index.js +23 -0
  130. package/dist/os/correctness/index.js.map +1 -0
  131. package/dist/os/correctness/manifest-schema.d.ts +155 -0
  132. package/dist/os/correctness/manifest-schema.d.ts.map +1 -0
  133. package/dist/os/correctness/manifest-schema.js +110 -0
  134. package/dist/os/correctness/manifest-schema.js.map +1 -0
  135. package/dist/os/correctness/references.d.ts +22 -0
  136. package/dist/os/correctness/references.d.ts.map +1 -0
  137. package/dist/os/correctness/references.js +129 -0
  138. package/dist/os/correctness/references.js.map +1 -0
  139. package/dist/os/correctness/tests/fixture-workspace.d.ts +23 -0
  140. package/dist/os/correctness/tests/fixture-workspace.d.ts.map +1 -0
  141. package/dist/os/correctness/tests/fixture-workspace.js +104 -0
  142. package/dist/os/correctness/tests/fixture-workspace.js.map +1 -0
  143. package/dist/os/correctness/workspace.d.ts +32 -0
  144. package/dist/os/correctness/workspace.d.ts.map +1 -0
  145. package/dist/os/correctness/workspace.js +147 -0
  146. package/dist/os/correctness/workspace.js.map +1 -0
  147. package/dist/os/flow/correctness-step.d.ts +19 -0
  148. package/dist/os/flow/correctness-step.d.ts.map +1 -0
  149. package/dist/os/flow/correctness-step.js +133 -0
  150. package/dist/os/flow/correctness-step.js.map +1 -0
  151. package/dist/os/flow/digest.d.ts +18 -0
  152. package/dist/os/flow/digest.d.ts.map +1 -1
  153. package/dist/os/flow/digest.js +28 -1
  154. package/dist/os/flow/digest.js.map +1 -1
  155. package/dist/os/flow/dirty-classify.d.ts +7 -0
  156. package/dist/os/flow/dirty-classify.d.ts.map +1 -1
  157. package/dist/os/flow/dirty-classify.js +11 -0
  158. package/dist/os/flow/dirty-classify.js.map +1 -1
  159. package/dist/os/flow/flow.module.d.ts.map +1 -1
  160. package/dist/os/flow/flow.module.js +19 -4
  161. package/dist/os/flow/flow.module.js.map +1 -1
  162. package/dist/os/flow/handlers/flow-check.d.ts.map +1 -1
  163. package/dist/os/flow/handlers/flow-check.js +9 -9
  164. package/dist/os/flow/handlers/flow-check.js.map +1 -1
  165. package/dist/os/flow/handlers/flow-digest.d.ts.map +1 -1
  166. package/dist/os/flow/handlers/flow-digest.js +11 -1
  167. package/dist/os/flow/handlers/flow-digest.js.map +1 -1
  168. package/dist/os/flow/handlers/flow-integrate.d.ts +11 -0
  169. package/dist/os/flow/handlers/flow-integrate.d.ts.map +1 -1
  170. package/dist/os/flow/handlers/flow-integrate.js +148 -30
  171. package/dist/os/flow/handlers/flow-integrate.js.map +1 -1
  172. package/dist/os/flow/handlers/flow-open.d.ts.map +1 -1
  173. package/dist/os/flow/handlers/flow-open.js +14 -19
  174. package/dist/os/flow/handlers/flow-open.js.map +1 -1
  175. package/dist/os/flow/index.d.ts +1 -0
  176. package/dist/os/flow/index.d.ts.map +1 -1
  177. package/dist/os/flow/index.js +5 -3
  178. package/dist/os/flow/index.js.map +1 -1
  179. package/dist/os/flow/post-rebase-regen.d.ts +33 -0
  180. package/dist/os/flow/post-rebase-regen.d.ts.map +1 -0
  181. package/dist/os/flow/post-rebase-regen.js +120 -0
  182. package/dist/os/flow/post-rebase-regen.js.map +1 -0
  183. package/dist/os/flow/preflight.d.ts +24 -0
  184. package/dist/os/flow/preflight.d.ts.map +1 -1
  185. package/dist/os/flow/preflight.js +364 -24
  186. package/dist/os/flow/preflight.js.map +1 -1
  187. package/dist/os/flow/publish.d.ts.map +1 -1
  188. package/dist/os/flow/publish.js +23 -4
  189. package/dist/os/flow/publish.js.map +1 -1
  190. package/dist/os/flow/registry.d.ts +6 -6
  191. package/dist/os/flow/tests/helpers.d.ts +9 -1
  192. package/dist/os/flow/tests/helpers.d.ts.map +1 -1
  193. package/dist/os/flow/tests/helpers.js +36 -2
  194. package/dist/os/flow/tests/helpers.js.map +1 -1
  195. package/dist/os/friction/types.d.ts +2 -2
  196. package/dist/os/gate-run/detach.d.ts +27 -0
  197. package/dist/os/gate-run/detach.d.ts.map +1 -0
  198. package/dist/os/gate-run/detach.js +85 -0
  199. package/dist/os/gate-run/detach.js.map +1 -0
  200. package/dist/os/gate-run/gate-run.module.d.ts +3 -0
  201. package/dist/os/gate-run/gate-run.module.d.ts.map +1 -0
  202. package/dist/os/gate-run/gate-run.module.js +23 -0
  203. package/dist/os/gate-run/gate-run.module.js.map +1 -0
  204. package/dist/os/gate-run/index.d.ts +7 -0
  205. package/dist/os/gate-run/index.d.ts.map +1 -0
  206. package/dist/os/gate-run/index.js +5 -0
  207. package/dist/os/gate-run/index.js.map +1 -0
  208. package/dist/os/gate-run/record.d.ts +47 -0
  209. package/dist/os/gate-run/record.d.ts.map +1 -0
  210. package/dist/os/gate-run/record.js +157 -0
  211. package/dist/os/gate-run/record.js.map +1 -0
  212. package/dist/os/gate-run/status.d.ts +53 -0
  213. package/dist/os/gate-run/status.d.ts.map +1 -0
  214. package/dist/os/gate-run/status.js +163 -0
  215. package/dist/os/gate-run/status.js.map +1 -0
  216. package/dist/os/gate-run/types.d.ts +47 -0
  217. package/dist/os/gate-run/types.d.ts.map +1 -0
  218. package/dist/os/gate-run/types.js +24 -0
  219. package/dist/os/gate-run/types.js.map +1 -0
  220. package/dist/os/program/schemas.d.ts +3 -3
  221. package/dist/os/queue/types.d.ts +2 -2
  222. package/dist/os/rfc/evidence-annotation.d.ts +26 -0
  223. package/dist/os/rfc/evidence-annotation.d.ts.map +1 -0
  224. package/dist/os/rfc/evidence-annotation.js +52 -0
  225. package/dist/os/rfc/evidence-annotation.js.map +1 -0
  226. package/dist/os/rfc/handlers/fixed-inputs.d.ts.map +1 -1
  227. package/dist/os/rfc/handlers/fixed-inputs.js +7 -1
  228. package/dist/os/rfc/handlers/fixed-inputs.js.map +1 -1
  229. package/dist/os/rfc/handlers/implement-stamp-promotes.d.ts +8 -0
  230. package/dist/os/rfc/handlers/implement-stamp-promotes.d.ts.map +1 -0
  231. package/dist/os/rfc/handlers/implement-stamp-promotes.js +65 -0
  232. package/dist/os/rfc/handlers/implement-stamp-promotes.js.map +1 -0
  233. package/dist/os/rfc/handlers/implement-stamp.d.ts.map +1 -1
  234. package/dist/os/rfc/handlers/implement-stamp.js +35 -29
  235. package/dist/os/rfc/handlers/implement-stamp.js.map +1 -1
  236. package/dist/os/rfc/handlers/validate-rules.d.ts.map +1 -1
  237. package/dist/os/rfc/handlers/validate-rules.js +152 -11
  238. package/dist/os/rfc/handlers/validate-rules.js.map +1 -1
  239. package/dist/os/rfc/rfc.module.d.ts.map +1 -1
  240. package/dist/os/rfc/rfc.module.js +20 -7
  241. package/dist/os/rfc/rfc.module.js.map +1 -1
  242. package/dist/os/rfc/types.d.ts +12 -3
  243. package/dist/os/rfc/types.d.ts.map +1 -1
  244. package/dist/os/rfc/types.js +5 -2
  245. package/dist/os/rfc/types.js.map +1 -1
  246. package/dist/os/rfc/verify-workspace.d.ts +12 -0
  247. package/dist/os/rfc/verify-workspace.d.ts.map +1 -1
  248. package/dist/os/rfc/verify-workspace.js +155 -0
  249. package/dist/os/rfc/verify-workspace.js.map +1 -1
  250. package/dist/os/system/task-schemas.d.ts +1 -1
  251. package/dist/os/system/tests/helpers.d.ts.map +1 -1
  252. package/dist/os/system/tests/helpers.js +6 -1
  253. package/dist/os/system/tests/helpers.js.map +1 -1
  254. package/dist/os/werkstatt/handlers/schema.d.ts +1 -1
  255. package/dist/src/cli-flags.d.ts.map +1 -1
  256. package/dist/src/cli-flags.js +6 -0
  257. package/dist/src/cli-flags.js.map +1 -1
  258. package/dist/src/command-modules.d.ts +4 -0
  259. package/dist/src/command-modules.d.ts.map +1 -0
  260. package/dist/src/command-modules.js +42 -0
  261. package/dist/src/command-modules.js.map +1 -0
  262. package/dist/src/config/forge-config.d.ts +16 -1
  263. package/dist/src/config/forge-config.d.ts.map +1 -1
  264. package/dist/src/config/forge-config.js +27 -11
  265. package/dist/src/config/forge-config.js.map +1 -1
  266. package/dist/src/correctness/index.d.ts +32 -0
  267. package/dist/src/correctness/index.d.ts.map +1 -0
  268. package/dist/src/correctness/index.js +157 -0
  269. package/dist/src/correctness/index.js.map +1 -0
  270. package/dist/src/correctness/schema-hash.d.ts +15 -0
  271. package/dist/src/correctness/schema-hash.d.ts.map +1 -0
  272. package/dist/src/correctness/schema-hash.js +44 -0
  273. package/dist/src/correctness/schema-hash.js.map +1 -0
  274. package/dist/src/knowledge/schema.d.ts +1 -1
  275. package/dist/src/onboarding/agents-generate.d.ts.map +1 -1
  276. package/dist/src/onboarding/agents-generate.js +20 -3
  277. package/dist/src/onboarding/agents-generate.js.map +1 -1
  278. package/dist/src/onboarding/create.d.ts +7 -0
  279. package/dist/src/onboarding/create.d.ts.map +1 -1
  280. package/dist/src/onboarding/create.js +62 -9
  281. package/dist/src/onboarding/create.js.map +1 -1
  282. package/dist/src/types.d.ts +7 -0
  283. package/dist/src/types.d.ts.map +1 -1
  284. package/dist/src/types.js +2 -8
  285. package/dist/src/types.js.map +1 -1
  286. package/docs/reference/correctness-audit.md +91 -0
  287. package/docs/reference/correctness-gate.md +102 -0
  288. package/docs/reference/correctness-manifest.md +142 -0
  289. package/docs/reference/forge-yaml.md +15 -0
  290. package/os/codebase/codebase.module.ts +57 -0
  291. package/os/codebase/handlers/codebase-measure-symbols.ts +131 -0
  292. package/os/codebase/handlers/codebase-measure.ts +503 -0
  293. package/os/codebase/index.ts +21 -0
  294. package/os/codebase/types.ts +55 -0
  295. package/os/core/handlers/package-health.test.ts +24 -2
  296. package/os/core/handlers/package-health.ts +16 -19
  297. package/os/correctness/anchors.ts +182 -0
  298. package/os/correctness/audit/bindings-verify-substance.test.ts +79 -0
  299. package/os/correctness/audit/bindings-verify-substance.ts +155 -0
  300. package/os/correctness/audit/differential.test.ts +113 -0
  301. package/os/correctness/audit/differential.ts +131 -0
  302. package/os/correctness/audit/ledger-orphans.test.ts +96 -0
  303. package/os/correctness/audit/ledger-orphans.ts +84 -0
  304. package/os/correctness/audit/ledger.test.ts +65 -0
  305. package/os/correctness/audit/ledger.ts +103 -0
  306. package/os/correctness/audit/run.ts +220 -0
  307. package/os/correctness/audit/schema-db.ts +208 -0
  308. package/os/correctness/audit/snapshot.ts +211 -0
  309. package/os/correctness/audit/sql-scanner.test.ts +84 -0
  310. package/os/correctness/audit/sql-scanner.ts +289 -0
  311. package/os/correctness/audit/sql-schema-conform.test.ts +170 -0
  312. package/os/correctness/audit/sql-schema-conform.ts +178 -0
  313. package/os/correctness/audit/state-transitions-coverage.test.ts +141 -0
  314. package/os/correctness/audit/state-transitions-coverage.ts +271 -0
  315. package/os/correctness/audit/tests/git-fixture.ts +98 -0
  316. package/os/correctness/audit/types.ts +91 -0
  317. package/os/correctness/correctness-capture.test.ts +107 -0
  318. package/os/correctness/correctness-chain.test.ts +232 -0
  319. package/os/correctness/correctness-coverage.test.ts +86 -0
  320. package/os/correctness/correctness-mode.test.ts +108 -0
  321. package/os/correctness/correctness-substrate.test.ts +64 -0
  322. package/os/correctness/correctness.module.ts +182 -0
  323. package/os/correctness/gate/anchor-events.test.ts +77 -0
  324. package/os/correctness/gate/freeze-coverage.test.ts +218 -0
  325. package/os/correctness/gate/freeze-diff.test.ts +110 -0
  326. package/os/correctness/gate/frozen.ts +399 -0
  327. package/os/correctness/gate/gate-mode.test.ts +76 -0
  328. package/os/correctness/gate/hardening.test.ts +175 -0
  329. package/os/correctness/gate/oracle-edit.test.ts +83 -0
  330. package/os/correctness/gate/oracle-origin.test.ts +142 -0
  331. package/os/correctness/gate/origin.ts +175 -0
  332. package/os/correctness/gate/repo.ts +102 -0
  333. package/os/correctness/gate/run.ts +547 -0
  334. package/os/correctness/gate/runner.ts +136 -0
  335. package/os/correctness/gate/substrate-attestation.test.ts +71 -0
  336. package/os/correctness/gate/tests/gate-fixture.ts +205 -0
  337. package/os/correctness/gate/tier-high.test.ts +92 -0
  338. package/os/correctness/gate/types.ts +144 -0
  339. package/os/correctness/handlers/audit.ts +107 -0
  340. package/os/correctness/handlers/gate.ts +75 -0
  341. package/os/correctness/handlers/validate.ts +514 -0
  342. package/os/correctness/index.ts +24 -0
  343. package/os/correctness/manifest-schema.ts +174 -0
  344. package/os/correctness/references.ts +143 -0
  345. package/os/correctness/tests/fixture-workspace.ts +119 -0
  346. package/os/correctness/workspace.ts +167 -0
  347. package/os/flow/correctness-step.ts +166 -0
  348. package/os/flow/digest.ts +40 -1
  349. package/os/flow/dirty-classify.ts +13 -0
  350. package/os/flow/flow.module.ts +20 -4
  351. package/os/flow/handlers/flow-check.ts +17 -18
  352. package/os/flow/handlers/flow-digest.ts +11 -1
  353. package/os/flow/handlers/flow-integrate.ts +191 -39
  354. package/os/flow/handlers/flow-open.ts +24 -31
  355. package/os/flow/index.ts +5 -7
  356. package/os/flow/post-rebase-regen.ts +170 -0
  357. package/os/flow/preflight.ts +361 -27
  358. package/os/flow/publish.ts +23 -4
  359. package/os/flow/tests/flow-detachable.test.ts +31 -0
  360. package/os/flow/tests/flow-digest-correctness-trail.test.ts +55 -0
  361. package/os/flow/tests/flow-integrate-correctness-gate.test.ts +275 -0
  362. package/os/flow/tests/flow-integrate.post-rebase-regen.test.ts +234 -0
  363. package/os/flow/tests/flow-integrate.preflight.test.ts +26 -5
  364. package/os/flow/tests/flow-integrate.test.ts +77 -10
  365. package/os/flow/tests/helpers.ts +45 -24
  366. package/os/flow/tests/lockfile-induced.test.ts +328 -0
  367. package/os/gate-run/detach.ts +106 -0
  368. package/os/gate-run/gate-run.module.ts +25 -0
  369. package/os/gate-run/index.ts +16 -0
  370. package/os/gate-run/record.ts +194 -0
  371. package/os/gate-run/status.ts +201 -0
  372. package/os/gate-run/tests/gate-run-detach.test.ts +144 -0
  373. package/os/gate-run/tests/gate-run-record.test.ts +200 -0
  374. package/os/gate-run/tests/gate-run-status.test.ts +114 -0
  375. package/os/gate-run/types.ts +73 -0
  376. package/os/rfc/evidence-annotation.ts +61 -0
  377. package/os/rfc/handlers/fixed-inputs.test.ts +70 -0
  378. package/os/rfc/handlers/fixed-inputs.ts +11 -1
  379. package/os/rfc/handlers/implement-stamp-promotes.test.ts +214 -0
  380. package/os/rfc/handlers/implement-stamp-promotes.ts +79 -0
  381. package/os/rfc/handlers/implement-stamp.ts +40 -29
  382. package/os/rfc/handlers/list-create.test.ts +14 -5
  383. package/os/rfc/handlers/validate-evidence-shape.test.ts +218 -0
  384. package/os/rfc/handlers/validate-probe-meta.test.ts +71 -0
  385. package/os/rfc/handlers/validate-rules.ts +211 -21
  386. package/os/rfc/handlers/validate-transient-probes.test.ts +222 -0
  387. package/os/rfc/rfc-0000-template.md +10 -10
  388. package/os/rfc/rfc.module.ts +21 -7
  389. package/os/rfc/types.ts +16 -2
  390. package/os/rfc/verify-workspace-manifest.test.ts +55 -0
  391. package/os/rfc/verify-workspace.ts +167 -0
  392. package/os/system/tests/helpers.ts +6 -1
  393. package/package.json +57 -1
  394. package/profiles/typescript.yaml +16 -0
  395. package/skills/_shared/agent-operating-model.md +4 -0
  396. package/skills/fo/fo-idea-audit/SKILL.md +4 -0
  397. package/skills/fo/fo-idea-create-rfc/SKILL.md +6 -2
  398. package/skills/fo/fo-idea-implement/SKILL.md +8 -2
  399. package/skills/fo/fo-review/SKILL.md +16 -2
  400. package/skills/fo/fo-session-retro/SKILL.md +4 -2
  401. package/src/cli-flags.ts +7 -0
  402. package/src/command-modules.ts +62 -0
  403. package/src/config/forge-config.ts +37 -11
  404. package/src/correctness/index.ts +192 -0
  405. package/src/correctness/schema-hash.ts +59 -0
  406. package/src/onboarding/agents-generate.ts +20 -3
  407. package/src/onboarding/create.ts +59 -9
  408. package/src/tests/agents-generate-detach.test.ts +126 -0
  409. package/src/tests/codebase-measure-rfc-1581.test.ts +260 -0
  410. package/src/tests/command-modules.test.ts +34 -0
  411. package/src/types.ts +9 -8
package/CHANGELOG.md CHANGED
@@ -6,6 +6,39 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
 
7
7
  For the full commit history, see the [GitHub releases page](https://github.com/syrokomskyi/forge/releases).
8
8
 
9
+ ## [9.6.0] — 2026-11-13
10
+
11
+ _A product-level correctness contour lands — manifest, audit, and an integration gate — alongside a repository-scale measurement command._
12
+
13
+ ### Added
14
+
15
+ - **`correctness.manifest.validate`** (RFC-1578): validates the product correctness manifest at `bindings.paths.correctnessManifest` (CORR-01..09), plus the `bindings.commands.checkRun` binding and the correctness section in `forge.yaml`.
16
+ - **`correctness.audit`** (RFC-1579): runs four cross-artifact auditors with subject-keyed differential attribution — only introduced errors block; wired as a consumer gate line and an early `ecosystem.commit` run.
17
+ - **`correctness.gate`** (RFC-1580): enforces the correctness manifest at `flow.integrate` with frozen oracles — spawned from the primary install after `hooks/integration-gate.sh` (CORR-GATE-01..08), plus digest trail and manifest review export.
18
+ - **`codebase.measure`** (RFC-1581): project-scale measurement over git-tracked files — category totals (`code`/`tests`/`docs`/`generated`), per-language line metrics, real AST symbol counts for TypeScript/JavaScript via lazy `import("typescript")`, top directories, binary-file accounting, and honest `symbolsSkipped` degradation; `--json` output and `--out` snapshot modes.
19
+ - **Single forge command-module list** (RFC-1573): `loadForgeCommandModules` is the one registry consumed by both the standalone CLI and `forge.agents.generate`; `flow.cut`, `flow.backmerge`, and `mission.close` declared detachable.
20
+ - **Gate reports** carry the first failure cause and timeout class (RFC-1576); `gate.run.status --wait` ends with a verdict and marks itself uncacheable (RFC-1575).
21
+
22
+ ### Changed
23
+
24
+ - **`flow.integrate`** regenerates derived manifests after the rebase and commits them, so post-rebase drift never reaches the heavyweight gate (RFC-1574).
25
+ - **READMEs** document the measured production fleet — 8 repositories, ~5.9M code lines, measured by `codebase.measure` itself.
26
+
27
+ ## [9.5.0] — 2026-11-12
28
+
29
+ _Long gates run detached with durable records, the kernel command-result cache is shared across session worktrees, and flow refusals name their paths and remedies._
30
+
31
+ ### Added
32
+
33
+ - **`gate.run.status`**: long gates (`flow.integrate`, `ecosystem.commit`, `mission.validate`) accept `--detach` — the parent prints a run id and log path, exits immediately, and every attempt writes an immutable durable gate-run record; `gate.run.status` reports runs, blocks on `--wait`, and classifies unfinished runs as `lost` via the same dead-holder liveness rule as flow locks (RFC-1568).
34
+ - **Shared kernel command-result cache**: command results are cached across session worktrees so reruns of identical commands reuse the verdict instead of re-executing; `kernel.cache.prune` manages the cache (RFC-1563).
35
+ - **RFC evidence lint**: `rfc.validate` and `rfc.create` lint evidence annotations (`test:`/`file:` prefixes) and transient probe targets while RFCs are authored (RFC-1569).
36
+
37
+ ### Changed
38
+
39
+ - **`flow.integrate`** names the rebase stderr tail and porcelain status when no untracked file explains a conflict (ADR-0128), names unattributed paths with a three-way remedy hint (ADR-0129), classifies induced-change lockfile diffs through BFS reachability and restores foreign open-mission importer diffs verbatim (ADR-0130), and skips the rfc-0000 template in preflight id extraction.
40
+ - **Session-end teardown** stops worktree-held dev servers before flow cleanup (RFC-1460).
41
+
9
42
  ## [9.4.1] — 2026-11-10
10
43
 
11
44
  _Flow surfaces self-repair: cross-checkout dirt is attributed to its live operation, generated rebase conflicts regenerate, and recoverable state is derived instead of refused._
package/README.md CHANGED
@@ -6,6 +6,8 @@
6
6
 
7
7
  A repository-native control layer for AI-assisted development. Decisions, rules, skills and verification stay with the project — independent of the agent that works on it.
8
8
 
9
+ **Battle-tested at scale — not a demo.** Forge already governs a ~5.9M-line engineering fleet: 8 repositories, 40,000+ tracked files, from the monorepo that builds Forge itself to production data platforms. [The measured fleet ↓](#forged-in-production)
10
+
9
11
  > Engineered at [Warpgogol](https://warpgogol.com) · Released as open source. <!-- pkg-health-12: domain name, not a command -->
10
12
 
11
13
  [![npm version](https://img.shields.io/npm/v/@warpgogol/forge.svg)](https://www.npmjs.com/package/@warpgogol/forge) [![npm downloads](https://img.shields.io/npm/dm/@warpgogol/forge.svg)](https://www.npmjs.com/package/@warpgogol/forge) [![CI](https://github.com/syrokomskyi/forge/actions/workflows/ci.yml/badge.svg)](https://github.com/syrokomskyi/forge/actions) [![Node](https://img.shields.io/badge/Node-24%2B-green.svg)](https://nodejs.org) [![License: Apache-2.0](https://img.shields.io/badge/License-Apache--2.0-blue.svg)](LICENSE) <!-- pkg-health-12: domain name, not a command -->
@@ -290,6 +292,34 @@ pnpm exec forge doctor
290
292
 
291
293
  ---
292
294
 
295
+ ## Forged in production
296
+
297
+ Forge does not govern toy projects. It is the control layer of a working engineering fleet — measured 2026-11-13 by Forge's own `codebase.measure` over git-tracked files only (generated, vendored, and mirrored content is classified separately; export mirrors and deployment caches are excluded to avoid double counting).
298
+
299
+ | Repository | Role | Files | Code lines | code | tests | docs | generated | Top language |
300
+ | --- | --- | --- | --- | --- | --- | --- | --- | --- |
301
+ | pipelines | Production document pipeline suite | 22,609 | 3,122,894 | 1,215,172 | 127,237 | 1,747,517 | 32,968 | Markdown |
302
+ | werkstatt | The platform monorepo that builds Forge itself | 14,084 | 1,737,825 | 808,969 | 351,999 | 233,302 | 343,555 | TypeScript |
303
+ | dater | Production product monorepo | 1,419 | 479,041 | 380,487 | 51,992 | 31,716 | 14,846 | JSON |
304
+ | hdri | Client repository | 1,510 | 463,226 | 402,796 | 38,774 | 13,763 | 7,893 | TypeScript |
305
+ | lagebild | Client-facing data platform | 486 | 50,096 | 16,660 | 13,319 | 10,774 | 9,343 | TypeScript |
306
+ | metads | Product monorepo | 283 | 48,011 | 34,096 | 3,310 | 1,456 | 9,149 | TypeScript |
307
+ | dialogue-steward | Product monorepo | 288 | 34,698 | 13,935 | 5,666 | 4,665 | 10,432 | TypeScript |
308
+ | warpgogol-verbund | System hub — product registry and task queue | 132 | 9,671 | 7,160 | 0 | 1,467 | 1,044 | Other |
309
+ | **Fleet total** | | 40,811 | 5,945,462 | 2,879,275 | 592,297 | 2,044,660 | 429,230 | |
310
+
311
+ Language rollup across the fleet: Markdown 34.1%, TypeScript 25.3%, JSON 19.1%, YAML 15.3%, XML 3.2% — a fleet where a third of the mass is written knowledge, which is exactly what a governance layer exists to keep coherent.
312
+
313
+ Symbol counts come from a real TypeScript AST pass — 98,494 symbols measured (1,721 classes, 90,761 functions, 6,012 methods), not regex estimates. Where a workspace resolves a compiler the walker cannot use, the command reports `symbolsSkipped` instead of fabricating numbers.
314
+
315
+ Measure your own repository:
316
+
317
+ ```sh
318
+ pnpm exec forge codebase.measure --json
319
+ ```
320
+
321
+ ---
322
+
293
323
  ## License
294
324
 
295
325
  Apache-2.0
package/README.uk.md CHANGED
@@ -6,6 +6,8 @@
6
6
 
7
7
  Репозиторіо-нативний шар управління для розробки за допомогою ШІ. Рішення, правила, навички та перевірки залишаються з проєктом — незалежно від агента, який з ним працює.
8
8
 
9
+ **Випробувано на масштабі — не демо.** Forge уже управляє інженерним флотом на ~5,9 млн рядків: 8 репозиторіїв, 40 000+ відстежуваних файлів — від монорепозиторію, що будує сам Forge, до продакшн-платформ даних. [Виміряний флот ↓](#виковано-в-продакшні)
10
+
9
11
  > Розроблено в [Warpgogol](https://warpgogol.com) · Опубліковано як open source.
10
12
 
11
13
  [![npm version](https://img.shields.io/npm/v/@warpgogol/forge.svg)](https://www.npmjs.com/package/@warpgogol/forge) [![npm downloads](https://img.shields.io/npm/dm/@warpgogol/forge.svg)](https://www.npmjs.com/package/@warpgogol/forge) [![CI](https://github.com/syrokomskyi/forge/actions/workflows/ci.yml/badge.svg)](https://github.com/syrokomskyi/forge/actions) [![Node](https://img.shields.io/badge/Node-24%2B-green.svg)](https://nodejs.org) [![License: Apache-2.0](https://img.shields.io/badge/License-Apache--2.0-blue.svg)](LICENSE)
@@ -289,6 +291,34 @@ pnpm exec forge doctor
289
291
 
290
292
  ---
291
293
 
294
+ ## Виковано в продакшні
295
+
296
+ Forge управляє не іграшковими проєктами. Це контрольний шар робочого інженерного флоту — виміряно 2026-11-13 власною командою `codebase.measure` лише за git-tracked файлами (згенерований, вендорений і дзеркальний вміст класифікується окремо; експортні дзеркала та деплой-кеші виключено, щоб уникнути подвійного підрахунку).
297
+
298
+ | Репозиторій | Роль | Файли | Рядки коду | code | tests | docs | generated | Топ-мова |
299
+ | --- | --- | --- | --- | --- | --- | --- | --- | --- |
300
+ | pipelines | Продакшн-сьют документних пайплайнів | 22 609 | 3 122 894 | 1 215 172 | 127 237 | 1 747 517 | 32 968 | Markdown |
301
+ | werkstatt | Платформний монорепозиторій, що будує сам Forge | 14 084 | 1 737 825 | 808 969 | 351 999 | 233 302 | 343 555 | TypeScript |
302
+ | dater | Продакшн-продуктовий монорепозиторій | 1 419 | 479 041 | 380 487 | 51 992 | 31 716 | 14 846 | JSON |
303
+ | hdri | Клієнтський репозиторій | 1 510 | 463 226 | 402 796 | 38 774 | 13 763 | 7 893 | TypeScript |
304
+ | lagebild | Клієнтська платформа даних | 486 | 50 096 | 16 660 | 13 319 | 10 774 | 9 343 | TypeScript |
305
+ | metads | Продуктовий монорепозиторій | 283 | 48 011 | 34 096 | 3 310 | 1 456 | 9 149 | TypeScript |
306
+ | dialogue-steward | Продуктовий монорепозиторій | 288 | 34 698 | 13 935 | 5 666 | 4 665 | 10 432 | TypeScript |
307
+ | warpgogol-verbund | Системний хаб — реєстр продуктів і черга задач | 132 | 9 671 | 7 160 | 0 | 1 467 | 1 044 | Other |
308
+ | **Флот разом** | | 40 811 | 5 945 462 | 2 879 275 | 592 297 | 2 044 660 | 429 230 | |
309
+
310
+ Зведення мов по флоту: Markdown 34.1%, TypeScript 25.3%, JSON 19.1%, YAML 15.3%, XML 3.2% — флот, де третина маси це письмове знання, і саме для цього існує шар управління, що тримає її когерентною.
311
+
312
+ Кількість символів походить зі справжнього TypeScript AST-проходу — виміряно 98 494 символи (1 721 клас, 90 761 функція, 6 012 методів), а не оцінки регулярними виразами. Там, де workspace резолвить компілятор, який аналізатор не може використати, команда звітує `symbolsSkipped` замість вигаданих чисел.
313
+
314
+ Виміряйте власний репозиторій:
315
+
316
+ ```sh
317
+ pnpm exec forge codebase.measure --json
318
+ ```
319
+
320
+ ---
321
+
292
322
  ## Ліцензія
293
323
 
294
324
  Apache-2.0
package/bin/cli.ts CHANGED
@@ -10,12 +10,18 @@ registers forge modules and dispatches commands. Works autonomously without
10
10
  </non-goals>
11
11
  </MODULE_CONTRACT>
12
12
  <CHANGE_SUMMARY>
13
- <item>RFC-1472: trajectory.index + trajectory.recall + trajectory.outcome.record — procedural-memory retrieval with green-verdict admission</item>
14
- <item>RFC-1478: yaml.scalars.validate + EC-25 colon-space staged lint (F-0006)</item>
15
- <item>RFC-1486: step 5 — forge-flow module registration + dual CLI/kernel wiring</item>
16
- <item>RFC-1508: implement RFC-1508 — system profile, system map schemas and system.map.validate</item>
17
- <item>RFC-1517: make pkg-health-10 shipped-set faithful and scan the publish ref</item>
18
- <history>RFC-0542, RFC-0543, RFC-1140, RFC-1231, RFC-1336, RFC-1365, RFC-1391, RFC-1433, RFC-1464, RFC-1465, RFC-1466, RFC-1468, RFC-1469, RFC-1470, RFC-1473</history>
13
+ <item>ADR-0129: F-0186/F-0187 — FLOW-INT-03 names paths + three-way remedy, FLOW-OPEN-01 same hint, forge CLI kernel-command hint</item>
14
+ <item>RFC-1568: durable gate-run records, --detach mechanics, and forge CLI wiring</item>
15
+ <item>RFC-1573: step 3 — single forge command-module list
16
+
17
+ buildRegistry() consumes loadForgeCommandModules() from src/command-modules.ts so the AGENTS generator reads the same list.</item>
18
+ <item>RFC-1573: close review REVIEW-CODE-2026-11-12-01 findings
19
+
20
+ Restore same-line pkg-health-10 suppressions in forge bin/cli.ts (prettier-ignore) and revert unrelated registry.ts reflows; DETACH-01 also matches call sites (slice cap cut mission.close off before runMissionValidate); exempt marker anchored to a non-global line-comment regex; live-source test pins entrypoint resolution and the flow.cut/mission.close negative control; command-modules test; AC-8 literal comment; RFC Deviations DEV-1..3.</item>
21
+ <item>ADR-0131: pkg-health-10 suppression on the line above the literal
22
+
23
+ literalEscapesInLine accepts a // pkg-health-10: comment directly above the literal (one-line reach); the publish at-ref scan fetches that line via git show only for candidate lines; bin/cli.ts drops its prettier-ignore lines.</item>
24
+ <history>RFC-0542, RFC-0543, RFC-1140, RFC-1231, RFC-1336, RFC-1365, RFC-1391, RFC-1433, RFC-1464, RFC-1465, RFC-1466, RFC-1468, RFC-1469, RFC-1470, RFC-1472, RFC-1473, RFC-1478, RFC-1486, RFC-1508, RFC-1517</history>
19
25
  </CHANGE_SUMMARY>
20
26
  */
21
27
 
@@ -63,10 +69,22 @@ import type {
63
69
  ForgeRuntimeContext,
64
70
  CommandRegistry,
65
71
  ForgeRegisteredCommandInfo,
72
+ WorkspaceIO,
66
73
  } from "../src/types.ts";
67
74
  import { renderNextSteps, renderIdeRecommendation, generateHelp } from "../src/cli-output.ts";
68
75
  import { resolveCliFlags } from "../src/cli-flags.ts";
69
- import type { ForgeModule, ForgeModuleRegistry, ForgePipelineStep } from "../src/forge-module.ts";
76
+ import type { ForgeModuleRegistry, ForgePipelineStep } from "../src/forge-module.ts";
77
+ import { loadForgeCommandModules } from "../src/command-modules.ts";
78
+ import { resolveIo } from "../src/utils/io.ts";
79
+ import { commonGitDir } from "../os/flow/registry.ts";
80
+ import { GATE_RUN_ID_ENV, detachPointerLines, detachSelf } from "../os/gate-run/detach.ts";
81
+ import {
82
+ finishGateRun,
83
+ repoRelativeCwd,
84
+ saveGateRun,
85
+ startGateRun,
86
+ } from "../os/gate-run/record.ts";
87
+ import type { GateRunRecord } from "../os/gate-run/types.ts";
70
88
 
71
89
  class ForgeCliRegistry implements ForgeModuleRegistry, CommandRegistry {
72
90
  private commands = new Map<string, ForgeCommandDefinition>();
@@ -119,50 +137,7 @@ class ForgeCliRegistry implements ForgeModuleRegistry, CommandRegistry {
119
137
  async function buildRegistry(): Promise<ForgeCliRegistry> {
120
138
  const registry = new ForgeCliRegistry();
121
139
 
122
- const modules: ForgeModule[] = [
123
- await import("../os/core/core.module.ts").then((m) => m.createForgeCoreModule()),
124
- await import("../os/rfc/rfc.module.ts").then((m) => m.createForgeRfcModule()),
125
- await import("../os/adr/adr.module.ts").then((m) => m.createForgeAdrModule()),
126
- await import("../os/plan/plan.module.ts").then((m) => m.createForgePlanModule()),
127
- await import("../os/audit/audit.module.ts").then((m) => m.createForgeAuditModule()),
128
- await import("../os/mission/mission.module.ts").then((m) => m.createForgeMissionModule()),
129
- await import("../os/spec/spec.module.ts").then((m) => m.createForgeSpecModule()),
130
- await import("../os/program/program.module.ts").then((m) => m.createForgeProgramModule()),
131
- await import("../os/plugin/plugin.module.ts").then((m) => m.forgePluginModule),
132
- await import("../os/workflow/workflow.module.ts").then((m) => m.createForgeWorkflowModule()),
133
- await import("../os/naming/naming.module.ts").then((m) => m.createForgeNamingModule()),
134
- await import("../os/compass/compass.module.ts").then((m) => m.forgeCompassModule),
135
- await import("../os/werkstatt/werkstatt.module.ts").then((m) => m.forgeWerkstattModule),
136
- await import("../os/session/session.module.ts").then((m) => m.createForgeSessionModule()),
137
- await import("../os/exploration/exploration.module.ts").then((m) =>
138
- m.createForgeExplorationModule(),
139
- ),
140
- await import("../os/notes/notes.module.ts").then((m) => m.createForgeNotesModule()),
141
- await import("../os/queue/queue.module.ts").then((m) => m.createForgeQueueModule()),
142
- await import("../os/authority/authority.module.ts").then((m) => m.createForgeAuthorityModule()),
143
- await import("../os/conformance/conformance.module.ts").then((m) =>
144
- m.createForgeConformanceModule(),
145
- ),
146
- await import("../os/flow/flow.module.ts").then((m) => m.createForgeFlowModule()),
147
- await import("../os/system/system.module.ts").then((m) => m.createForgeSystemModule()),
148
- await import("../os/formal/formal.module.ts").then((m) => m.createForgeFormalModule()),
149
- await import("../os/friction/friction.module.ts").then((m) =>
150
- m.createForgeFrictionModule(),
151
- ),
152
- await import("../os/yaml/yaml.module.ts").then((m) => m.createForgeYamlModule()),
153
- await import("../os/resolver/resolver.module.ts").then((m) => m.forgeResolverModule),
154
- await import("../os/instructions/instructions.module.ts").then(
155
- (m) => m.forgeInstructionsModule,
156
- ),
157
- await import("../os/agent/agent.module.ts").then((m) => m.forgeAgentModule),
158
- await import("../os/knowledge/knowledge.module.ts").then(
159
- (m) => m.forgeKnowledgeModule,
160
- ),
161
- await import("../os/gate/gate.module.ts").then((m) => m.forgeGateModule),
162
- await import("../os/checks/checks.module.ts").then((m) => m.forgeChecksModule),
163
- await import("../os/context/context.module.ts").then((m) => m.forgeContextModule),
164
- await import("../os/trajectory/trajectory.module.ts").then((m) => m.forgeTrajectoryModule),
165
- ].filter((m): m is ForgeModule => m !== null);
140
+ const modules = await loadForgeCommandModules();
166
141
 
167
142
  for (const mod of modules) {
168
143
  for (const cmd of mod.commands) {
@@ -187,7 +162,9 @@ async function buildRegistry(): Promise<ForgeCliRegistry> {
187
162
  function readVersion(): string {
188
163
  // Source: packages/forge/bin/cli.ts → packages/forge/package.json (one up)
189
164
  // Compiled: dist/bin/cli.js → package.json (two up)
190
- for (const up of ["..", "../.."]) { // pkg-health-10: candidates probe bin/ and dist/bin/ layouts — in extract ../.. lands on the package root
165
+ // Candidates probe bin/ and dist/bin/ layouts; in extract ../.. lands on the package root.
166
+ // pkg-health-10: bin/ and dist/bin/ probe layouts (ADR-0131 line-above placement)
167
+ for (const up of ["..", "../.."]) {
191
168
  const pkgPath = join(__dirname, up, "package.json");
192
169
  try {
193
170
  const pkg = JSON.parse(readFileSync(pkgPath, "utf8")) as { version?: string };
@@ -204,7 +181,9 @@ const VERSION = readVersion();
204
181
  function resolveForgeRootFromCli(): string | undefined {
205
182
  // Source: packages/forge/bin/cli.ts → packages/forge/ (one up)
206
183
  // Compiled: dist/bin/cli.js → packages/forge/ (two up)
207
- for (const up of ["..", "../.."]) { // pkg-health-10: candidates probe bin/ and dist/bin/ layouts — in extract ../.. lands on the package root
184
+ // Candidates probe bin/ and dist/bin/ layouts; in extract ../.. lands on the package root.
185
+ // pkg-health-10: bin/ and dist/bin/ probe layouts (ADR-0131 line-above placement)
186
+ for (const up of ["..", "../.."]) {
208
187
  const pkgPath = join(__dirname, up, "package.json");
209
188
  try {
210
189
  const pkg = JSON.parse(readFileSync(pkgPath, "utf8")) as { name?: string };
@@ -216,11 +195,41 @@ function resolveForgeRootFromCli(): string | undefined {
216
195
  return undefined;
217
196
  }
218
197
 
198
+ /**
199
+ * ADR-0129 (F-0187): `forge run <cmd>` and bare kernel-command names get a
200
+ * pointer to the workshop host instead of a bare "Unknown command". Fires
201
+ * only when `docs/command-manifest.generated.yaml` exists and lists the
202
+ * name — forge-only consumer repos (no manifest) keep the old output.
203
+ */
204
+ function kernelCommandHint(commandName: string, workspaceRoot: string): string | undefined {
205
+ const hint = "Kernel commands run through the workshop host: pnpm exec werkstatt run <cmd>";
206
+ if (commandName === "run") return hint;
207
+ try {
208
+ const manifest = readFileSync(
209
+ join(workspaceRoot, "docs/command-manifest.generated.yaml"),
210
+ "utf8",
211
+ );
212
+ if (
213
+ new RegExp(
214
+ `^\\s*- name: ${commandName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}\\s*$`,
215
+ "m",
216
+ ).test(manifest)
217
+ ) {
218
+ return hint;
219
+ }
220
+ } catch {
221
+ // no manifest — unchanged output
222
+ }
223
+ return undefined;
224
+ }
225
+
219
226
  function printCommandHelp(registry: ForgeCliRegistry, commandName: string): void {
220
227
  const resolved = resolveCommandName(commandName, registry);
221
228
  const cmd = resolved ? registry.getCommand(resolved) : undefined;
222
229
  if (!resolved || !cmd) {
223
230
  logger.error(`Unknown command: ${commandName}`);
231
+ const hint = kernelCommandHint(commandName, process.cwd());
232
+ if (hint) logger.info(hint);
224
233
  logger.info(`Run 'forge --help' for available commands.`);
225
234
  process.exit(1);
226
235
  }
@@ -289,6 +298,8 @@ async function main(): Promise<void> {
289
298
 
290
299
  if (!command) {
291
300
  logger.error(`Unknown command: ${commandName}`);
301
+ const hint = kernelCommandHint(commandName, process.cwd());
302
+ if (hint) logger.info(hint);
292
303
  logger.info(`Run 'forge --help' for available commands.`);
293
304
  process.exit(1);
294
305
  }
@@ -332,6 +343,86 @@ async function main(): Promise<void> {
332
343
  commandRegistry: registry,
333
344
  };
334
345
 
346
+ // RFC-1568: --detach on a non-detachable command refuses GATE-RUN-01 before
347
+ // any work; under --dry-run GATE-RUN-02. On a detachable command the parent
348
+ // re-spawns itself detached, prints the pointer block, and exits 0 — the
349
+ // outcome lives in the durable gate-run record.
350
+ if (flags["detach"] === true && command.flags?.["detach"] === undefined) {
351
+ const io = resolveIo(undefined);
352
+ if (command.detachable !== true) {
353
+ logger.error(
354
+ `[${commandName}] GATE-RUN-01 --detach requires the command to declare \`detachable: true\` — ${commandName} does not`,
355
+ );
356
+ process.exit(1);
357
+ }
358
+ if (dryRun) {
359
+ logger.error(
360
+ `[${commandName}] GATE-RUN-02 --detach with --dry-run detaches nothing — run the dry-run attached`,
361
+ );
362
+ process.exit(1);
363
+ }
364
+ const common = await commonGitDir(io, workspaceRoot);
365
+ const record = await startGateRun({
366
+ commonGitDir: common,
367
+ command: commandName,
368
+ argv: rest.filter((t) => t !== "--detach" && !t.startsWith("--detach=")),
369
+ cwd: repoRelativeCwd(common, workspaceRoot),
370
+ detached: true,
371
+ io,
372
+ });
373
+ const detached = await detachSelf({
374
+ entry: process.argv[1] ?? "",
375
+ argv: [commandName, ...rest.filter((t) => t !== "--detach" && !t.startsWith("--detach="))],
376
+ record,
377
+ commonGitDir: common,
378
+ });
379
+ record.pid = detached.pid;
380
+ await saveGateRun(common, record, io);
381
+ if (outputFormat === "json") {
382
+ console.log(
383
+ JSON.stringify(
384
+ {
385
+ data: { runId: detached.runId, pid: detached.pid, logPath: detached.logPath },
386
+ nextSteps: [],
387
+ },
388
+ null,
389
+ 2,
390
+ ),
391
+ );
392
+ } else {
393
+ for (const line of detachPointerLines(detached, common, "pnpm exec forge gate.run.status")) {
394
+ console.log(line);
395
+ }
396
+ }
397
+ process.exit(0);
398
+ }
399
+
400
+ // RFC-1568: durable gate-run record for attached executions of detachable
401
+ // commands; the detached child adopts the parent's record via env handoff.
402
+ const ioForRecord = command.detachable === true ? resolveIo(undefined) : null;
403
+ let gateRun: { common: string; record: GateRunRecord; io: WorkspaceIO } | null = null;
404
+ if (ioForRecord !== null && command.detachable === true) {
405
+ try {
406
+ const common = await commonGitDir(ioForRecord, workspaceRoot);
407
+ const adoptedId = process.env[GATE_RUN_ID_ENV];
408
+ gateRun = {
409
+ common,
410
+ io: ioForRecord,
411
+ record: await startGateRun({
412
+ commonGitDir: common,
413
+ command: commandName,
414
+ argv: rest,
415
+ cwd: repoRelativeCwd(common, workspaceRoot),
416
+ detached: adoptedId !== undefined,
417
+ io: ioForRecord,
418
+ ...(adoptedId !== undefined ? { runId: adoptedId } : {}),
419
+ }),
420
+ };
421
+ } catch (error) {
422
+ logger.warn(`[gate-run] record start failed (gate still runs): ${(error as Error).message}`);
423
+ }
424
+ }
425
+
335
426
  try {
336
427
  const result = (await command.execute(input, context)) as ForgeCommandResult | void;
337
428
  if (result && outputFormat === "json") {
@@ -350,8 +441,27 @@ async function main(): Promise<void> {
350
441
  }
351
442
  }
352
443
  const exitCode = result?.exitCode ?? 0;
444
+ if (gateRun !== null) {
445
+ try {
446
+ await finishGateRun(
447
+ gateRun.common,
448
+ gateRun.record,
449
+ { exitCode, ...(result?.summary ? { summary: result.summary } : {}) },
450
+ gateRun.io,
451
+ );
452
+ } catch (recordError) {
453
+ logger.warn(`[gate-run] record finish failed: ${(recordError as Error).message}`);
454
+ }
455
+ }
353
456
  process.exit(exitCode);
354
457
  } catch (error) {
458
+ if (gateRun !== null) {
459
+ try {
460
+ await finishGateRun(gateRun.common, gateRun.record, { exitCode: 1 }, gateRun.io);
461
+ } catch {
462
+ // warn-only — never mask the real error below
463
+ }
464
+ }
355
465
  logger.error(
356
466
  error instanceof Error ? error.message : String(error),
357
467
  error instanceof Error && error.stack ? error.stack : undefined,