@warpgogol/forge 9.5.0 → 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 (338) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +30 -0
  3. package/README.uk.md +30 -0
  4. package/bin/cli.ts +19 -50
  5. package/dist/bin/cli.js +18 -43
  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/flow.module.d.ts.map +1 -1
  156. package/dist/os/flow/flow.module.js +17 -3
  157. package/dist/os/flow/flow.module.js.map +1 -1
  158. package/dist/os/flow/handlers/flow-digest.d.ts.map +1 -1
  159. package/dist/os/flow/handlers/flow-digest.js +11 -1
  160. package/dist/os/flow/handlers/flow-digest.js.map +1 -1
  161. package/dist/os/flow/handlers/flow-integrate.d.ts +11 -0
  162. package/dist/os/flow/handlers/flow-integrate.d.ts.map +1 -1
  163. package/dist/os/flow/handlers/flow-integrate.js +90 -5
  164. package/dist/os/flow/handlers/flow-integrate.js.map +1 -1
  165. package/dist/os/flow/post-rebase-regen.d.ts +33 -0
  166. package/dist/os/flow/post-rebase-regen.d.ts.map +1 -0
  167. package/dist/os/flow/post-rebase-regen.js +120 -0
  168. package/dist/os/flow/post-rebase-regen.js.map +1 -0
  169. package/dist/os/flow/preflight.d.ts.map +1 -1
  170. package/dist/os/flow/preflight.js +11 -15
  171. package/dist/os/flow/preflight.js.map +1 -1
  172. package/dist/os/flow/publish.d.ts.map +1 -1
  173. package/dist/os/flow/publish.js +23 -4
  174. package/dist/os/flow/publish.js.map +1 -1
  175. package/dist/os/flow/registry.d.ts +4 -4
  176. package/dist/os/flow/tests/helpers.d.ts +9 -1
  177. package/dist/os/flow/tests/helpers.d.ts.map +1 -1
  178. package/dist/os/flow/tests/helpers.js +36 -2
  179. package/dist/os/flow/tests/helpers.js.map +1 -1
  180. package/dist/os/friction/types.d.ts +2 -2
  181. package/dist/os/gate-run/status.d.ts +12 -0
  182. package/dist/os/gate-run/status.d.ts.map +1 -1
  183. package/dist/os/gate-run/status.js +24 -3
  184. package/dist/os/gate-run/status.js.map +1 -1
  185. package/dist/os/program/schemas.d.ts +3 -3
  186. package/dist/os/queue/types.d.ts +2 -2
  187. package/dist/os/rfc/handlers/implement-stamp-promotes.d.ts +8 -0
  188. package/dist/os/rfc/handlers/implement-stamp-promotes.d.ts.map +1 -0
  189. package/dist/os/rfc/handlers/implement-stamp-promotes.js +65 -0
  190. package/dist/os/rfc/handlers/implement-stamp-promotes.js.map +1 -0
  191. package/dist/os/rfc/handlers/implement-stamp.d.ts.map +1 -1
  192. package/dist/os/rfc/handlers/implement-stamp.js +15 -2
  193. package/dist/os/rfc/handlers/implement-stamp.js.map +1 -1
  194. package/dist/os/rfc/handlers/validate-rules.d.ts.map +1 -1
  195. package/dist/os/rfc/handlers/validate-rules.js +26 -5
  196. package/dist/os/rfc/handlers/validate-rules.js.map +1 -1
  197. package/dist/os/rfc/rfc.module.d.ts.map +1 -1
  198. package/dist/os/rfc/rfc.module.js +18 -6
  199. package/dist/os/rfc/rfc.module.js.map +1 -1
  200. package/dist/os/rfc/types.d.ts +12 -3
  201. package/dist/os/rfc/types.d.ts.map +1 -1
  202. package/dist/os/rfc/types.js +5 -2
  203. package/dist/os/rfc/types.js.map +1 -1
  204. package/dist/os/rfc/verify-workspace.d.ts +12 -0
  205. package/dist/os/rfc/verify-workspace.d.ts.map +1 -1
  206. package/dist/os/rfc/verify-workspace.js +155 -0
  207. package/dist/os/rfc/verify-workspace.js.map +1 -1
  208. package/dist/os/system/task-schemas.d.ts +1 -1
  209. package/dist/os/system/tests/helpers.d.ts.map +1 -1
  210. package/dist/os/system/tests/helpers.js +6 -1
  211. package/dist/os/system/tests/helpers.js.map +1 -1
  212. package/dist/os/werkstatt/handlers/schema.d.ts +1 -1
  213. package/dist/src/command-modules.d.ts +4 -0
  214. package/dist/src/command-modules.d.ts.map +1 -0
  215. package/dist/src/command-modules.js +42 -0
  216. package/dist/src/command-modules.js.map +1 -0
  217. package/dist/src/config/forge-config.d.ts +16 -1
  218. package/dist/src/config/forge-config.d.ts.map +1 -1
  219. package/dist/src/config/forge-config.js +27 -11
  220. package/dist/src/config/forge-config.js.map +1 -1
  221. package/dist/src/correctness/index.d.ts +32 -0
  222. package/dist/src/correctness/index.d.ts.map +1 -0
  223. package/dist/src/correctness/index.js +157 -0
  224. package/dist/src/correctness/index.js.map +1 -0
  225. package/dist/src/correctness/schema-hash.d.ts +15 -0
  226. package/dist/src/correctness/schema-hash.d.ts.map +1 -0
  227. package/dist/src/correctness/schema-hash.js +44 -0
  228. package/dist/src/correctness/schema-hash.js.map +1 -0
  229. package/dist/src/knowledge/schema.d.ts +1 -1
  230. package/dist/src/onboarding/agents-generate.d.ts.map +1 -1
  231. package/dist/src/onboarding/agents-generate.js +20 -3
  232. package/dist/src/onboarding/agents-generate.js.map +1 -1
  233. package/dist/src/onboarding/create.d.ts +7 -0
  234. package/dist/src/onboarding/create.d.ts.map +1 -1
  235. package/dist/src/onboarding/create.js +62 -9
  236. package/dist/src/onboarding/create.js.map +1 -1
  237. package/docs/reference/correctness-audit.md +91 -0
  238. package/docs/reference/correctness-gate.md +102 -0
  239. package/docs/reference/correctness-manifest.md +142 -0
  240. package/docs/reference/forge-yaml.md +15 -0
  241. package/os/codebase/codebase.module.ts +57 -0
  242. package/os/codebase/handlers/codebase-measure-symbols.ts +131 -0
  243. package/os/codebase/handlers/codebase-measure.ts +503 -0
  244. package/os/codebase/index.ts +21 -0
  245. package/os/codebase/types.ts +55 -0
  246. package/os/core/handlers/package-health.test.ts +24 -2
  247. package/os/core/handlers/package-health.ts +16 -19
  248. package/os/correctness/anchors.ts +182 -0
  249. package/os/correctness/audit/bindings-verify-substance.test.ts +79 -0
  250. package/os/correctness/audit/bindings-verify-substance.ts +155 -0
  251. package/os/correctness/audit/differential.test.ts +113 -0
  252. package/os/correctness/audit/differential.ts +131 -0
  253. package/os/correctness/audit/ledger-orphans.test.ts +96 -0
  254. package/os/correctness/audit/ledger-orphans.ts +84 -0
  255. package/os/correctness/audit/ledger.test.ts +65 -0
  256. package/os/correctness/audit/ledger.ts +103 -0
  257. package/os/correctness/audit/run.ts +220 -0
  258. package/os/correctness/audit/schema-db.ts +208 -0
  259. package/os/correctness/audit/snapshot.ts +211 -0
  260. package/os/correctness/audit/sql-scanner.test.ts +84 -0
  261. package/os/correctness/audit/sql-scanner.ts +289 -0
  262. package/os/correctness/audit/sql-schema-conform.test.ts +170 -0
  263. package/os/correctness/audit/sql-schema-conform.ts +178 -0
  264. package/os/correctness/audit/state-transitions-coverage.test.ts +141 -0
  265. package/os/correctness/audit/state-transitions-coverage.ts +271 -0
  266. package/os/correctness/audit/tests/git-fixture.ts +98 -0
  267. package/os/correctness/audit/types.ts +91 -0
  268. package/os/correctness/correctness-capture.test.ts +107 -0
  269. package/os/correctness/correctness-chain.test.ts +232 -0
  270. package/os/correctness/correctness-coverage.test.ts +86 -0
  271. package/os/correctness/correctness-mode.test.ts +108 -0
  272. package/os/correctness/correctness-substrate.test.ts +64 -0
  273. package/os/correctness/correctness.module.ts +182 -0
  274. package/os/correctness/gate/anchor-events.test.ts +77 -0
  275. package/os/correctness/gate/freeze-coverage.test.ts +218 -0
  276. package/os/correctness/gate/freeze-diff.test.ts +110 -0
  277. package/os/correctness/gate/frozen.ts +399 -0
  278. package/os/correctness/gate/gate-mode.test.ts +76 -0
  279. package/os/correctness/gate/hardening.test.ts +175 -0
  280. package/os/correctness/gate/oracle-edit.test.ts +83 -0
  281. package/os/correctness/gate/oracle-origin.test.ts +142 -0
  282. package/os/correctness/gate/origin.ts +175 -0
  283. package/os/correctness/gate/repo.ts +102 -0
  284. package/os/correctness/gate/run.ts +547 -0
  285. package/os/correctness/gate/runner.ts +136 -0
  286. package/os/correctness/gate/substrate-attestation.test.ts +71 -0
  287. package/os/correctness/gate/tests/gate-fixture.ts +205 -0
  288. package/os/correctness/gate/tier-high.test.ts +92 -0
  289. package/os/correctness/gate/types.ts +144 -0
  290. package/os/correctness/handlers/audit.ts +107 -0
  291. package/os/correctness/handlers/gate.ts +75 -0
  292. package/os/correctness/handlers/validate.ts +514 -0
  293. package/os/correctness/index.ts +24 -0
  294. package/os/correctness/manifest-schema.ts +174 -0
  295. package/os/correctness/references.ts +143 -0
  296. package/os/correctness/tests/fixture-workspace.ts +119 -0
  297. package/os/correctness/workspace.ts +167 -0
  298. package/os/flow/correctness-step.ts +166 -0
  299. package/os/flow/digest.ts +40 -1
  300. package/os/flow/flow.module.ts +18 -3
  301. package/os/flow/handlers/flow-digest.ts +11 -1
  302. package/os/flow/handlers/flow-integrate.ts +117 -5
  303. package/os/flow/post-rebase-regen.ts +170 -0
  304. package/os/flow/preflight.ts +11 -19
  305. package/os/flow/publish.ts +23 -4
  306. package/os/flow/tests/flow-detachable.test.ts +31 -0
  307. package/os/flow/tests/flow-digest-correctness-trail.test.ts +55 -0
  308. package/os/flow/tests/flow-integrate-correctness-gate.test.ts +275 -0
  309. package/os/flow/tests/flow-integrate.post-rebase-regen.test.ts +234 -0
  310. package/os/flow/tests/flow-integrate.test.ts +10 -9
  311. package/os/flow/tests/helpers.ts +45 -24
  312. package/os/gate-run/status.ts +36 -3
  313. package/os/gate-run/tests/gate-run-status.test.ts +114 -0
  314. package/os/rfc/handlers/implement-stamp-promotes.test.ts +214 -0
  315. package/os/rfc/handlers/implement-stamp-promotes.ts +79 -0
  316. package/os/rfc/handlers/implement-stamp.ts +16 -2
  317. package/os/rfc/handlers/validate-rules.ts +43 -5
  318. package/os/rfc/rfc.module.ts +19 -6
  319. package/os/rfc/types.ts +16 -2
  320. package/os/rfc/verify-workspace-manifest.test.ts +55 -0
  321. package/os/rfc/verify-workspace.ts +167 -0
  322. package/os/system/tests/helpers.ts +6 -1
  323. package/package.json +41 -1
  324. package/profiles/typescript.yaml +16 -0
  325. package/skills/_shared/agent-operating-model.md +4 -0
  326. package/skills/fo/fo-idea-audit/SKILL.md +4 -0
  327. package/skills/fo/fo-idea-create-rfc/SKILL.md +6 -2
  328. package/skills/fo/fo-idea-implement/SKILL.md +8 -2
  329. package/skills/fo/fo-review/SKILL.md +16 -2
  330. package/src/command-modules.ts +62 -0
  331. package/src/config/forge-config.ts +37 -11
  332. package/src/correctness/index.ts +192 -0
  333. package/src/correctness/schema-hash.ts +59 -0
  334. package/src/onboarding/agents-generate.ts +20 -3
  335. package/src/onboarding/create.ts +59 -9
  336. package/src/tests/agents-generate-detach.test.ts +126 -0
  337. package/src/tests/codebase-measure-rfc-1581.test.ts +260 -0
  338. package/src/tests/command-modules.test.ts +34 -0
@@ -0,0 +1,55 @@
1
+ /*
2
+ <MODULE_CONTRACT>
3
+ <purpose>
4
+ RFC-1581: contracts for codebase.measure — project-scale measurement over
5
+ git-tracked files. Categories, per-language measures, top-directory ranking.
6
+ </purpose>
7
+ <non-goals>
8
+ <item>Does not define symbol contracts — symbol counts nest under LanguageMeasure.symbols.</item>
9
+ </non-goals>
10
+ </MODULE_CONTRACT>
11
+ <CHANGE_SUMMARY>
12
+ <item>RFC-1581: initial codebase.measure contracts.</item>
13
+ <item>RFC-1581: apply REVIEW-CODE-2026-11-13-01 — contract alignment, repo-root anchor, publishConfig exports</item>
14
+ </CHANGE_SUMMARY>
15
+ */
16
+
17
+ export type CodebaseCategory = "code" | "tests" | "docs" | "generated";
18
+
19
+ export interface CodebaseCategoryTotals {
20
+ files: number;
21
+ code: number;
22
+ }
23
+
24
+ export interface SymbolMeasure {
25
+ classes: number;
26
+ functions: number;
27
+ methods: number;
28
+ }
29
+
30
+ export interface LanguageMeasure {
31
+ language: string;
32
+ files: number;
33
+ code: number;
34
+ comments: number;
35
+ blanks: number;
36
+ symbols?: SymbolMeasure;
37
+ }
38
+
39
+ export interface TopDirMeasure {
40
+ path: string;
41
+ code: number;
42
+ }
43
+
44
+ export interface CodebaseMeasure {
45
+ command: "codebase.measure";
46
+ status: "ok";
47
+ repo: string;
48
+ totals: Record<CodebaseCategory, CodebaseCategoryTotals>;
49
+ languages: LanguageMeasure[];
50
+ topDirs: TopDirMeasure[];
51
+ symbolsSkipped: string[];
52
+ binaryFiles: number;
53
+ exclusions: string[];
54
+ measuredAt: string;
55
+ }
@@ -6,7 +6,6 @@
6
6
  </non-goals>
7
7
  </MODULE_CONTRACT>
8
8
  <CHANGE_SUMMARY>
9
- <item>RFC-1517: add preflight-extract-gates — FLOW-PUB-01 changelog check at ref plus shared PKG-HEALTH-10 fixture-path scan for RFC-1517</item>
10
9
  <item>RFC-1517: make pkg-health-10 shipped-set faithful and scan the publish ref</item>
11
10
  <item>RFC-1518: docs-drift gate PKG-HEALTH-11/12 in forge.package.health
12
11
 
@@ -24,7 +23,10 @@ journaled suppressions for code paths, family prefixes, and the planned
24
23
  werkstatt-knowledge CLI surface.</item>
25
24
  <item>RFC-1518: attribution merge, private-package docs gate, suppression journal</item>
26
25
  <item>RFC-1518: provider-aware module attribution, per-rule markers, tld-tail scoping</item>
27
- <history>RFC-1311</history>
26
+ <item>ADR-0131: pkg-health-10 suppression on the line above the literal
27
+
28
+ 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>
29
+ <history>RFC-1311, RFC-1517</history>
28
30
  </CHANGE_SUMMARY>
29
31
  */
30
32
 
@@ -620,6 +622,26 @@ test("scanFixturePathEscapes honors suppression, raw-mode, and per-extension mod
620
622
  expect(escapes[0]?.literal).toContain("../");
621
623
  });
622
624
 
625
+ // Test-Reason: invariant ADR-0131 suppression placement
626
+ test("ADR-0131: a pkg-health-10 line comment directly above the literal suppresses it; two lines up or a non-comment line does not", () => {
627
+ const pkgDir = join(tmpDir, "packages", "above");
628
+ mkdirSync(pkgDir, { recursive: true });
629
+ writeFileSync(
630
+ join(pkgDir, "above.ts"),
631
+ '// pkg-health-10: probe both layouts\nconst a = "../../outside.md";\n', // pkg-health-10: fixture text
632
+ );
633
+ writeFileSync(
634
+ join(pkgDir, "two-up.ts"),
635
+ '// pkg-health-10: too far\n\nconst b = "../../outside.md";\n', // pkg-health-10: fixture text
636
+ );
637
+ writeFileSync(
638
+ join(pkgDir, "not-comment.ts"),
639
+ 'const note = "pkg-health-10: not a comment";\nconst c = "../../outside.md";\n', // pkg-health-10: fixture text
640
+ );
641
+ const escapes = scanFixturePathEscapes(pkgDir, ["above.ts", "two-up.ts", "not-comment.ts"]);
642
+ expect(escapes.map((e) => e.file).sort()).toEqual(["not-comment.ts", "two-up.ts"]);
643
+ });
644
+
623
645
  test("deriveShippedFiles applies ignoreDirs, excludePathSegments, and excludeExtensions", () => {
624
646
  const pkgDir = join(tmpDir, "packages", "derive");
625
647
  mkdirSync(join(pkgDir, "src", "tests"), { recursive: true });
@@ -15,25 +15,14 @@
15
15
  <item>Module attribution is provider-aware: deriveModulePackageMap returns separate workshop/site maps because module names collide across buckets (deploy is engine() AND sitePlugin()), and each command resolves through the map matching its manifest siteScope — a flat last-write-wins map silently misattributed the engine deploy.* family to the private site package (RFC-1518 r2, deviation D-004).</item>
16
16
  </KEY_DECISIONS>
17
17
  <CHANGE_SUMMARY>
18
- <item>RFC-1518: docs-drift gate PKG-HEALTH-11/12 in forge.package.health
19
-
20
- Live-inventory docs gate: PKG-HEALTH-11 flags registered commands absent
21
- from the package DOCS_SURFACE, PKG-HEALTH-12 flags dead x.y doc tokens.
22
- loadCommandInventory unions the runtime registry with the generated
23
- command manifest (getLiveCommands precedent); namespace + TLD-tail
24
- resolution keep property paths and domains silent. Same-line
25
- pkg-health-11/12 markers journal intentional exceptions.
26
-
27
- Audit diff to land green: canonical forge.* names in forge docs,
28
- leitstand.access.* expansions, registered-surface listings for
29
- projektarchiv-operations/werkstatt-journal/werkstatt-engine, and 100+
30
- journaled suppressions for code paths, family prefixes, and the planned
31
- werkstatt-knowledge CLI surface.</item>
32
18
  <item>RFC-1518: attribution merge, private-package docs gate, suppression journal</item>
33
19
  <item>RFC-1518: key decision for private-package docs-gate scope</item>
34
20
  <item>RFC-1518: provider-aware module attribution, per-rule markers, tld-tail scoping</item>
35
21
  <item>RFC-1518: key decision for provider-aware attribution</item>
36
- <history>PKG-HEALTH-05, RFC-1097, RFC-1254, RFC-1255, RFC-1517</history>
22
+ <item>ADR-0131: pkg-health-10 suppression on the line above the literal
23
+
24
+ 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>
25
+ <history>PKG-HEALTH-05, RFC-1097, RFC-1254, RFC-1255, RFC-1517, RFC-1518</history>
37
26
  </CHANGE_SUMMARY>
38
27
  */
39
28
 
@@ -158,6 +147,8 @@ const BINARY_FILE_RE =
158
147
  const QUOTED_PARENT_RE = /["'`]([^"'`\n]*(?:\.\.\/)+[^"'`\n]*)["'`]/g;
159
148
  const RAW_PARENT_RE = /(?:\.\.\/)+[^\s"'`)\],;:}]*/g;
160
149
  const SUPPRESS_RE = /pkg-health-10:/;
150
+ /** ADR-0131: a line comment directly above the literal carrying the token. */
151
+ const PREV_LINE_SUPPRESS_RE = new RegExp("^\\s*//.*pkg-health-10:");
161
152
 
162
153
  /** File extensions the fixture scan judges (docs and binaries are excluded). */
163
154
  export function fixtureScanSkipped(file: string): boolean {
@@ -167,9 +158,11 @@ export function fixtureScanSkipped(file: string): boolean {
167
158
  /**
168
159
  * The single `../` literal matcher shared by the working-tree scan and the
169
160
  * publish at-ref scan — apply the per-extension mode to one source line and
170
- * report every literal resolving outside `rootAbs`. Same-line
171
- * `pkg-health-10:` suppression only (JSON and fixture templates cannot carry
172
- * comments — those go through the config suppressions list instead).
161
+ * report every literal resolving outside `rootAbs`. A `pkg-health-10:`
162
+ * suppression on the literal's own line, or (ADR-0131) in a `//` line comment
163
+ * directly above it — the placement prettier keeps stable — silences the
164
+ * line; reach is exactly one line. JSON and fixture templates cannot carry
165
+ * comments — those go through the config suppressions list instead.
173
166
  */
174
167
  export function literalEscapesInLine(
175
168
  file: string,
@@ -177,8 +170,10 @@ export function literalEscapesInLine(
177
170
  lineNo: number,
178
171
  fileDirAbs: string,
179
172
  rootAbs: string,
173
+ prevLine?: string,
180
174
  ): FixtureEscape[] {
181
175
  if (SUPPRESS_RE.test(text)) return [];
176
+ if (prevLine !== undefined && PREV_LINE_SUPPRESS_RE.test(prevLine)) return [];
182
177
  const re = TS_FAMILY_RE.test(file) ? QUOTED_PARENT_RE : RAW_PARENT_RE;
183
178
  const out: FixtureEscape[] = [];
184
179
  for (const m of text.matchAll(re)) {
@@ -219,7 +214,9 @@ export function scanFixturePathEscapes(
219
214
  }
220
215
  const lines = source.split("\n");
221
216
  for (let i = 0; i < lines.length; i++) {
222
- escapes.push(...literalEscapesInLine(file, lines[i]!, i + 1, path.dirname(abs), root));
217
+ escapes.push(
218
+ ...literalEscapesInLine(file, lines[i]!, i + 1, path.dirname(abs), root, lines[i - 1]),
219
+ );
223
220
  }
224
221
  }
225
222
  return escapes.sort((a, b) => a.file.localeCompare(b.file) || a.line - b.line);
@@ -0,0 +1,182 @@
1
+ /*
2
+ <MODULE_CONTRACT>
3
+ <purpose>RFC-1578: the anchor index — every tagged `@ai-invariant[INV-…]`
4
+ in the workspace with its normalized statement and `checked-by` binding refs.
5
+ Uses `docs/invariants.generated.yaml` (RFC-1390) as a hint: every anchor the
6
+ manifest names is re-verified by parsing its recorded file; any miss (absent
7
+ id, moved or deleted file, changed binding) falls back to a full scan of code
8
+ files with the forge RFC-1390 parser.</purpose>
9
+ <non-goals>
10
+ <item>Do not parse `@ai-invariant` markers here — `src/compass/invariant-parser.ts` is the only parser.</item>
11
+ <item>Do not resolve whether a binding target exists — compass.validate owns binding resolution.</item>
12
+ </non-goals>
13
+ </MODULE_CONTRACT>
14
+ <CHANGE_SUMMARY>
15
+ <item>RFC-1578: initial anchor index for CORR-04/CORR-05.</item>
16
+ <item>RFC-1578: correctness manifest, validator, promotes gate
17
+
18
+ Add os/correctness (forge/correctness-manifest@1, correctness.manifest.validate CORR-01..09), bindings.paths.correctnessManifest, bindings.commands.checkRun and the correctness section, promotes with V-55 and RFC-IMP-16, the typescript profile skeleton, reference pages, and the promotes marking in fo-idea-create-rfc/fo-idea-audit. Repoint the RFC-1391 AC-8 registry test at src/command-modules.ts (stale since RFC-1573) and close the types.ts header comment without a glob-shaped terminator (EC-33).</item>
19
+ <item>RFC-1578: close review REVIEW-CODE-2026-11-12-08 findings
20
+
21
+ F1 code-only anchor scan (markdown fences never declare anchors); F2 generated index as a re-verified hint, scan on any miss; F3 RFC-IMP-16 asserted through rfc.implement.stamp; F4 forge create patches only absent/null keys; F5 type: refs normalized; F6/F10/F11 capture existence via existsSync, future recordedAt and workspace-escaping paths are CORR-07; F7 V-55 reuses criteriaEval; F8 validator inventory regenerated; F9 binding-driven reads; F12 git listing, index hint, create patch tests; DEV-1 single sidecar spelling; DEV-2 output field dropped.</item>
22
+ <item>RFC-1578: close review REVIEW-CODE-2026-11-12-09 findings
23
+
24
+ N1 index-hint rows count only for files in the workspace listing; N2 forge create leaves exempt repositories unbound; N3 listing test stages a file. Record DEV-3/DEV-4 amendments (CORR-07 future/escaping captures, index as re-verified hint) in the RFC Deviations section.</item>
25
+ </CHANGE_SUMMARY>
26
+ */
27
+
28
+ import { readFileSync } from "node:fs";
29
+ import path from "node:path";
30
+ import { parse as parseYaml } from "yaml";
31
+
32
+ import { extractInvariants } from "../../src/compass/invariant-parser.ts";
33
+ import { normalizeCheckRef } from "./workspace.ts";
34
+
35
+ export interface AnchorRecord {
36
+ id: string;
37
+ file: string;
38
+ line: number;
39
+ statement: string;
40
+ /** Normalized `kind:target` refs from the `checked-by` binding. */
41
+ checkedBy: string[];
42
+ }
43
+
44
+ export const INVARIANT_INDEX_REL = "docs/invariants.generated.yaml";
45
+
46
+ /**
47
+ * Code files only. Markdown/HTML are excluded on purpose: a `// @ai-invariant`
48
+ * line inside a documentation code fence is an example, not a code anchor, and
49
+ * would otherwise satisfy CORR-04/CORR-05 without any code site.
50
+ */
51
+ const SOURCE_EXT_RE = /\.(?:[cm]?[jt]sx?|astro|svelte|vue|gd|py|rs|go|sh|css|scss)$/;
52
+
53
+ export function isAnchorSourceCandidate(rel: string): boolean {
54
+ if (rel === INVARIANT_INDEX_REL) return false;
55
+ if (rel.endsWith(".generated.yaml") || rel.endsWith(".generated.md")) return false;
56
+ return SOURCE_EXT_RE.test(rel);
57
+ }
58
+
59
+ function fromIndex(workspaceRoot: string): AnchorRecord[] | null {
60
+ let raw: unknown;
61
+ try {
62
+ raw = parseYaml(readFileSync(path.join(workspaceRoot, INVARIANT_INDEX_REL), "utf8"));
63
+ } catch {
64
+ return null;
65
+ }
66
+ const list = (raw as { invariants?: unknown })?.invariants;
67
+ if (!Array.isArray(list)) return null;
68
+ const out: AnchorRecord[] = [];
69
+ for (const item of list) {
70
+ const inv = item as {
71
+ id?: unknown;
72
+ file?: unknown;
73
+ line?: unknown;
74
+ statement?: unknown;
75
+ bindings?: { kind?: unknown; target?: unknown }[];
76
+ };
77
+ if (typeof inv.id !== "string") continue;
78
+ out.push({
79
+ id: inv.id,
80
+ file: String(inv.file ?? ""),
81
+ line: Number(inv.line ?? 0),
82
+ statement: String(inv.statement ?? ""),
83
+ checkedBy: (inv.bindings ?? []).map((b) =>
84
+ normalizeCheckRef(`${String(b.kind ?? "")}:${String(b.target ?? "")}`),
85
+ ),
86
+ });
87
+ }
88
+ return out;
89
+ }
90
+
91
+ /** Parse one source text into anchor records (tagged invariants only). */
92
+ export function anchorsFromSource(file: string, source: string): AnchorRecord[] {
93
+ return extractInvariants(source)
94
+ .filter((inv) => inv.id !== null)
95
+ .map((inv) => ({
96
+ id: inv.id!,
97
+ file,
98
+ line: inv.line,
99
+ statement: inv.statement,
100
+ checkedBy: inv.rawBindings.map((b) => normalizeCheckRef(`${b.kind}:${b.target}`)),
101
+ }));
102
+ }
103
+
104
+ export interface AnchorIndex {
105
+ source: "index" | "scan";
106
+ anchors: Map<string, AnchorRecord[]>;
107
+ }
108
+
109
+ function parseFile(workspaceRoot: string, rel: string): AnchorRecord[] | null {
110
+ let text: string;
111
+ try {
112
+ text = readFileSync(path.join(workspaceRoot, rel), "utf8");
113
+ } catch {
114
+ return null;
115
+ }
116
+ if (!text.includes("@ai-invariant[")) return [];
117
+ return anchorsFromSource(rel, text);
118
+ }
119
+
120
+ function group(records: AnchorRecord[]): Map<string, AnchorRecord[]> {
121
+ const anchors = new Map<string, AnchorRecord[]>();
122
+ for (const r of records) {
123
+ const list = anchors.get(r.id) ?? [];
124
+ list.push(r);
125
+ anchors.set(r.id, list);
126
+ }
127
+ return anchors;
128
+ }
129
+
130
+ /**
131
+ * Resolve the anchors a manifest names. The generated index is a hint only:
132
+ * each named id is re-parsed from the file the index records, and the result
133
+ * is used only when every named id is found there as a code anchor. Any miss
134
+ * falls back to scanning every code file in `files`.
135
+ */
136
+ export function buildAnchorIndex(
137
+ workspaceRoot: string,
138
+ files: string[],
139
+ named: string[],
140
+ ): AnchorIndex {
141
+ const wanted = [...new Set(named)];
142
+ const hint = fromIndex(workspaceRoot);
143
+ if (hint !== null && wanted.length > 0) {
144
+ // Only files the scan would read count — an index row naming an ignored
145
+ // or untracked-ignored file must not satisfy CORR-04 in index mode.
146
+ const listed = new Set(files);
147
+ const fileOf = new Map<string, Set<string>>();
148
+ for (const r of hint) {
149
+ if (!wanted.includes(r.id) || !isAnchorSourceCandidate(r.file) || !listed.has(r.file))
150
+ continue;
151
+ const set = fileOf.get(r.id) ?? new Set<string>();
152
+ set.add(r.file);
153
+ fileOf.set(r.id, set);
154
+ }
155
+ if (wanted.every((id) => fileOf.has(id))) {
156
+ const parsed = new Map<string, AnchorRecord[]>();
157
+ const records: AnchorRecord[] = [];
158
+ let complete = true;
159
+ for (const id of wanted) {
160
+ let found = false;
161
+ for (const rel of fileOf.get(id)!) {
162
+ if (!parsed.has(rel)) parsed.set(rel, parseFile(workspaceRoot, rel) ?? []);
163
+ const hits = parsed.get(rel)!.filter((r) => r.id === id);
164
+ if (hits.length > 0) {
165
+ found = true;
166
+ records.push(...hits);
167
+ }
168
+ }
169
+ if (!found) {
170
+ complete = false;
171
+ break;
172
+ }
173
+ }
174
+ if (complete) return { source: "index", anchors: group(records) };
175
+ }
176
+ }
177
+ const records: AnchorRecord[] = [];
178
+ for (const rel of files.filter(isAnchorSourceCandidate)) {
179
+ records.push(...(parseFile(workspaceRoot, rel) ?? []));
180
+ }
181
+ return { source: "scan", anchors: group(records) };
182
+ }
@@ -0,0 +1,79 @@
1
+ /*
2
+ <MODULE_CONTRACT>
3
+ <purpose>RFC-1579 AC-6: `bindings.verify.substance` — a null verify binding is
4
+ an introduced error even when the base already had it null (configuration
5
+ auditor, never differential); test/typecheck duplicates and trivial
6
+ invocations are errors; exempt repositories skip.</purpose>
7
+ <non-goals>
8
+ <item>Not a contract source of truth — the auditor owns behaviour.</item>
9
+ </non-goals>
10
+ </MODULE_CONTRACT>
11
+ <CHANGE_SUMMARY>
12
+ <item>RFC-1579: initial suite.</item>
13
+ <item>RFC-1579: correctness.audit auditors and differential attribution
14
+
15
+ Add os/correctness/audit: tree snapshots (working tree, index, base via one cat-file batch with git-grep prefilter), literal scanner + SQL classifier, wrangler D1 schema builder on node:sqlite, the four auditors (sql.schema.conform, ledger.orphans, state.transitions.coverage, bindings.verify.substance), subject-keyed differential attribution with allow-list, survival ledger, the correctness.audit handler and registration, and bindings.paths.correctnessLedger.</item>
16
+ <item>RFC-1579: close review REVIEW-CODE-2026-11-13-01 findings
17
+
18
+ F1 INSERT 'has no column named' is a finding; F2 severity/kind escalation since base is introduced; F3 unparseable machine tables are errors; F4 comma joins, string literals and comments in table extraction; F5 only migration INSERT/REPLACE seed writes; F6 SET-clause-only coverage; F7 method-call writers; F8 regex literals in the scanner; F9 alias resolution; F10 EC-34 judges the payload only; F11 EC-34 before the scoped gates with a dry-run line; F12/F13 config and YAML errors named; F14 config-only check skips snapshots; F15 git grep failures fail closed; F16 portable prefilter; F17 shell no-ops; F18 shared D1 schemas; in-code DDL scoped per package; ledger tests. DEV-1..DEV-4 recorded in the RFC Deviations section.</item>
19
+ </CHANGE_SUMMARY>
20
+ */
21
+
22
+ import { afterEach, describe, expect, it } from "vitest";
23
+
24
+ import { auditVerifySubstance, isTrivialVerify } from "./bindings-verify-substance.ts";
25
+ import { runCorrectnessAudit } from "./run.ts";
26
+ import { FORGE_YAML, makeGitFixture, type GitFixture } from "./tests/git-fixture.ts";
27
+
28
+ const fixtures: GitFixture[] = [];
29
+ afterEach(() => fixtures.splice(0).forEach((f) => f.cleanup()));
30
+
31
+ const NULL_VERIFY = FORGE_YAML.replace(
32
+ "verify: pnpm exec tsx scripts/verify-dispatch.ts",
33
+ "verify: null",
34
+ );
35
+
36
+ describe("bindings.verify.substance", () => {
37
+ it("AC-6: verify null at base and now is an introduced error", async () => {
38
+ const f = makeGitFixture({ "forge.yaml": NULL_VERIFY });
39
+ fixtures.push(f);
40
+ const out = await runCorrectnessAudit(f.root, { base: f.base });
41
+ if (!out.ok) throw new Error(out.usageError);
42
+ const finding = out.result.findings.find((x) => x.check === "bindings.verify.substance");
43
+ expect(finding, "the configuration auditor blocks from day one").toBeDefined();
44
+ expect(finding!.attribution).toBe("introduced");
45
+ expect(finding!.severity).toBe("error");
46
+ expect(finding!.rule).toBe("CORR-AUDIT-04");
47
+ expect(out.result.status).toBe("fail");
48
+ });
49
+
50
+ it("flags a verify equal to test or typecheck and trivial invocations", () => {
51
+ const yaml = (verify: string) =>
52
+ FORGE_YAML.replace("verify: pnpm exec tsx scripts/verify-dispatch.ts", `verify: "${verify}"`);
53
+ expect(auditVerifySubstance(yaml("pnpm test"), false).findings[0]?.message).toMatch(
54
+ /equals bindings.commands.test/,
55
+ );
56
+ expect(auditVerifySubstance(yaml("turbo run build:check"), false).findings).toHaveLength(1);
57
+ expect(
58
+ auditVerifySubstance(yaml("pnpm --filter api run test && pnpm exec tsc --noEmit"), false)
59
+ .findings,
60
+ ).toHaveLength(1);
61
+ expect(isTrivialVerify("pnpm exec vitest run apps/api")).toBe(true);
62
+ expect(isTrivialVerify("pnpm exec vitest run && pnpm run verify:dispatch")).toBe(false);
63
+ });
64
+
65
+ it("a substantive verify passes and an exempt repository is skipped", () => {
66
+ expect(auditVerifySubstance(FORGE_YAML, false).findings).toEqual([]);
67
+ const exempt = auditVerifySubstance(NULL_VERIFY, true);
68
+ expect(exempt.findings).toEqual([]);
69
+ expect(exempt.skipped).toEqual(["bindings.verify.substance: exempt"]);
70
+ });
71
+
72
+ it("shell no-ops add no substance and invalid YAML is reported as such", () => {
73
+ expect(isTrivialVerify("pnpm test && echo ok")).toBe(true);
74
+ expect(isTrivialVerify("cd . && pnpm test")).toBe(true);
75
+ expect(auditVerifySubstance("bindings: [unclosed", false).findings[0]?.message).toMatch(
76
+ /not valid YAML/,
77
+ );
78
+ });
79
+ });
@@ -0,0 +1,155 @@
1
+ /*
2
+ <MODULE_CONTRACT>
3
+ <purpose>RFC-1579 CORR-AUDIT-04 `bindings.verify.substance` — the verify
4
+ slot must prove more than tests or types. Error when
5
+ `bindings.commands.verify` is null, equals the `test` or `typecheck`
6
+ binding, or consists only of `test`, `typecheck`, `build:check`, `tsc`, or
7
+ `vitest` invocations. A configuration auditor: never differential, blocking
8
+ whenever present. `correctness.mode: exempt` skips it.</purpose>
9
+ <non-goals>
10
+ <item>Do not run the verify command — the audit is static.</item>
11
+ </non-goals>
12
+ </MODULE_CONTRACT>
13
+ <CHANGE_SUMMARY>
14
+ <item>RFC-1579: initial auditor.</item>
15
+ <item>RFC-1579: correctness.audit auditors and differential attribution
16
+
17
+ Add os/correctness/audit: tree snapshots (working tree, index, base via one cat-file batch with git-grep prefilter), literal scanner + SQL classifier, wrangler D1 schema builder on node:sqlite, the four auditors (sql.schema.conform, ledger.orphans, state.transitions.coverage, bindings.verify.substance), subject-keyed differential attribution with allow-list, survival ledger, the correctness.audit handler and registration, and bindings.paths.correctnessLedger.</item>
18
+ <item>RFC-1579: close review REVIEW-CODE-2026-11-13-01 findings
19
+
20
+ F1 INSERT 'has no column named' is a finding; F2 severity/kind escalation since base is introduced; F3 unparseable machine tables are errors; F4 comma joins, string literals and comments in table extraction; F5 only migration INSERT/REPLACE seed writes; F6 SET-clause-only coverage; F7 method-call writers; F8 regex literals in the scanner; F9 alias resolution; F10 EC-34 judges the payload only; F11 EC-34 before the scoped gates with a dry-run line; F12/F13 config and YAML errors named; F14 config-only check skips snapshots; F15 git grep failures fail closed; F16 portable prefilter; F17 shell no-ops; F18 shared D1 schemas; in-code DDL scoped per package; ledger tests. DEV-1..DEV-4 recorded in the RFC Deviations section.</item>
21
+ </CHANGE_SUMMARY>
22
+ */
23
+
24
+ import { parse as parseYaml } from "yaml";
25
+
26
+ import type { AuditorOutput } from "./types.ts";
27
+
28
+ const TRIVIAL = new Set(["test", "typecheck", "build:check", "tsc", "vitest"]);
29
+ const NO_OPS = new Set([
30
+ "echo",
31
+ "true",
32
+ "cd",
33
+ ":",
34
+ "tee",
35
+ "printf",
36
+ "exit",
37
+ "set",
38
+ "export",
39
+ "sleep",
40
+ ]);
41
+ const RUNNERS = new Set([
42
+ "pnpm",
43
+ "npm",
44
+ "yarn",
45
+ "bun",
46
+ "npx",
47
+ "bunx",
48
+ "turbo",
49
+ "exec",
50
+ "run",
51
+ "dlx",
52
+ ]);
53
+ /** Runner flags that take a value (`--filter <pkg>`, `-F <pkg>`, `-C <dir>`). */
54
+ const VALUE_FLAGS = new Set(["--filter", "-F", "-C", "--dir", "--workspace", "--cwd"]);
55
+
56
+ function normalize(cmd: string): string {
57
+ return cmd.replace(/\s+/g, " ").trim();
58
+ }
59
+
60
+ /** The script or binary a single shell segment invokes, after runner words and flags. */
61
+ export function invokedTarget(segment: string): string | null {
62
+ const tokens = segment
63
+ .trim()
64
+ .split(/\s+/)
65
+ .filter((t) => t.length > 0);
66
+ let i = 0;
67
+ while (i < tokens.length) {
68
+ const t = tokens[i]!;
69
+ if (/^[A-Z_][A-Z0-9_]*=/.test(t)) {
70
+ i += 1; // env assignment
71
+ continue;
72
+ }
73
+ if (RUNNERS.has(t)) {
74
+ i += 1;
75
+ continue;
76
+ }
77
+ if (t.startsWith("-")) {
78
+ i += VALUE_FLAGS.has(t) && !t.includes("=") ? 2 : 1;
79
+ continue;
80
+ }
81
+ return t;
82
+ }
83
+ return null;
84
+ }
85
+
86
+ /** True when every segment of the command only runs tests or type checks. */
87
+ export function isTrivialVerify(cmd: string): boolean {
88
+ const segments = cmd
89
+ .split(/&&|\|\||;|\|/)
90
+ .map((s) => s.trim())
91
+ .filter((s) => s.length > 0);
92
+ if (segments.length === 0) return true;
93
+ // Shell no-ops and builtins add no substance (`pnpm test && echo ok`).
94
+ return segments.every((seg) => {
95
+ const target = invokedTarget(seg);
96
+ return target === null || TRIVIAL.has(target) || NO_OPS.has(target);
97
+ });
98
+ }
99
+
100
+ export function auditVerifySubstance(
101
+ forgeYaml: string | undefined,
102
+ exempt: boolean,
103
+ ): AuditorOutput {
104
+ if (exempt)
105
+ return { findings: [], unverifiable: 0, skipped: ["bindings.verify.substance: exempt"] };
106
+ let commands: Record<string, unknown> = {};
107
+ try {
108
+ const doc = (forgeYaml ? parseYaml(forgeYaml) : {}) as {
109
+ bindings?: { commands?: Record<string, unknown> };
110
+ };
111
+ commands = doc?.bindings?.commands ?? {};
112
+ } catch (err) {
113
+ return {
114
+ findings: [
115
+ {
116
+ check: "bindings.verify.substance",
117
+ subject: "bindings.commands.verify",
118
+ severity: "error",
119
+ message: `forge.yaml is not valid YAML (${(err as Error).message.split("\n")[0]}) — the verify binding cannot be judged`,
120
+ location: { file: "forge.yaml", line: 1 },
121
+ },
122
+ ],
123
+ unverifiable: 0,
124
+ skipped: [],
125
+ };
126
+ }
127
+ const verify =
128
+ typeof commands["verify"] === "string" ? normalize(commands["verify"] as string) : null;
129
+ const test = typeof commands["test"] === "string" ? normalize(commands["test"] as string) : null;
130
+ const typecheck =
131
+ typeof commands["typecheck"] === "string" ? normalize(commands["typecheck"] as string) : null;
132
+ let reason: string | null = null;
133
+ if (!verify) reason = "bindings.commands.verify is null — the verify slot proves nothing";
134
+ else if (verify === test)
135
+ reason = `bindings.commands.verify equals bindings.commands.test ("${verify}")`;
136
+ else if (verify === typecheck)
137
+ reason = `bindings.commands.verify equals bindings.commands.typecheck ("${verify}")`;
138
+ else if (isTrivialVerify(verify)) {
139
+ reason = `bindings.commands.verify ("${verify}") only runs test/typecheck/build:check/tsc/vitest`;
140
+ }
141
+ if (!reason) return { findings: [], unverifiable: 0, skipped: [] };
142
+ return {
143
+ findings: [
144
+ {
145
+ check: "bindings.verify.substance",
146
+ subject: "bindings.commands.verify",
147
+ severity: "error",
148
+ message: `${reason} — bind a command that checks domain behaviour on a real substrate`,
149
+ location: { file: "forge.yaml", line: 1 },
150
+ },
151
+ ],
152
+ unverifiable: 0,
153
+ skipped: [],
154
+ };
155
+ }