@holmes-lab/holmes-kit 0.39.0 → 0.40.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 (298) hide show
  1. package/CHANGELOG.md +344 -6
  2. package/README.md +54 -41
  3. package/dist/.build-id +1 -1
  4. package/dist/holmes/admission/core/admission-policy.d.ts +37 -0
  5. package/dist/holmes/admission/core/admission-policy.js +147 -0
  6. package/dist/holmes/admission/core/bounded-reader.d.ts +56 -0
  7. package/dist/holmes/admission/core/bounded-reader.js +135 -0
  8. package/dist/holmes/admission/core/change-classifier.d.ts +34 -0
  9. package/dist/holmes/admission/core/change-classifier.js +278 -0
  10. package/dist/holmes/admission/core/config-loader.d.ts +30 -0
  11. package/dist/holmes/admission/core/config-loader.js +145 -0
  12. package/dist/holmes/admission/core/event-judgement.d.ts +37 -0
  13. package/dist/holmes/admission/core/event-judgement.js +251 -0
  14. package/dist/holmes/admission/core/path-rules.d.ts +35 -0
  15. package/dist/holmes/admission/core/path-rules.js +88 -0
  16. package/dist/holmes/admission/core/pin.d.ts +7 -0
  17. package/dist/holmes/admission/core/pin.js +29 -0
  18. package/dist/holmes/admission/core/ports.d.ts +48 -0
  19. package/dist/holmes/admission/core/ports.js +11 -0
  20. package/dist/holmes/admission/core/range-resolver.d.ts +32 -0
  21. package/dist/holmes/admission/core/range-resolver.js +51 -0
  22. package/dist/holmes/admission/core/self-containment.d.ts +1 -0
  23. package/dist/holmes/admission/core/self-containment.js +125 -0
  24. package/dist/holmes/admission/core/signature-source.d.ts +9 -0
  25. package/dist/holmes/admission/core/signature-source.js +4 -0
  26. package/dist/holmes/admission/core/transition-planner.d.ts +15 -0
  27. package/dist/holmes/admission/core/transition-planner.js +14 -0
  28. package/dist/holmes/admission/core/verdict.d.ts +38 -0
  29. package/dist/holmes/admission/core/verdict.js +17 -0
  30. package/dist/holmes/admission/core/wiring.d.ts +44 -0
  31. package/dist/holmes/admission/core/wiring.js +618 -0
  32. package/dist/holmes/admission/forge/git-object-port.d.ts +4 -0
  33. package/dist/holmes/admission/forge/git-object-port.js +132 -0
  34. package/dist/holmes/assoc/assoc-arm.d.ts +1 -1
  35. package/dist/holmes/assoc/assoc-arm.js +1 -1
  36. package/dist/holmes/cli/agents.d.ts +8 -0
  37. package/dist/holmes/cli/agents.js +9 -5
  38. package/dist/holmes/cli/approve-cli.d.ts +2 -0
  39. package/dist/holmes/cli/approve-cli.js +392 -0
  40. package/dist/holmes/cli/approve-ref.d.ts +13 -7
  41. package/dist/holmes/cli/approve-ref.js +30 -10
  42. package/dist/holmes/cli/approve-status.d.ts +26 -2
  43. package/dist/holmes/cli/approve-status.js +98 -18
  44. package/dist/holmes/cli/approve-watch.d.ts +5 -0
  45. package/dist/holmes/cli/approve-watch.js +10 -5
  46. package/dist/holmes/cli/approve.d.ts +49 -13
  47. package/dist/holmes/cli/approve.js +249 -67
  48. package/dist/holmes/cli/attest.js +2 -1
  49. package/dist/holmes/cli/autonomy.d.ts +4 -1
  50. package/dist/holmes/cli/autonomy.js +17 -10
  51. package/dist/holmes/cli/codex-oracle.d.ts +11 -0
  52. package/dist/holmes/cli/codex-oracle.js +5 -1
  53. package/dist/holmes/cli/codex-toml.d.ts +10 -0
  54. package/dist/holmes/cli/codex-toml.js +36 -2
  55. package/dist/holmes/cli/doctor-boundary.d.ts +76 -0
  56. package/dist/holmes/cli/doctor-boundary.js +308 -0
  57. package/dist/holmes/cli/doctor-locks.d.ts +15 -0
  58. package/dist/holmes/cli/doctor-locks.js +119 -0
  59. package/dist/holmes/cli/doctor.d.ts +2 -0
  60. package/dist/holmes/cli/doctor.js +34 -5
  61. package/dist/holmes/cli/flags.d.ts +23 -0
  62. package/dist/holmes/cli/flags.js +89 -0
  63. package/dist/holmes/cli/index.d.ts +5 -1
  64. package/dist/holmes/cli/index.js +202 -424
  65. package/dist/holmes/cli/init.js +33 -0
  66. package/dist/holmes/cli/lock-recover.d.ts +5 -0
  67. package/dist/holmes/cli/lock-recover.js +126 -0
  68. package/dist/holmes/cli/mcp-processes.js +1 -1
  69. package/dist/holmes/cli/release-docs.js +1 -1
  70. package/dist/holmes/cli/run-exec.d.ts +141 -0
  71. package/dist/holmes/cli/run-exec.js +1435 -0
  72. package/dist/holmes/cli/run-provision.d.ts +3 -1
  73. package/dist/holmes/cli/run-provision.js +255 -44
  74. package/dist/holmes/cli/run-wiring.d.ts +69 -0
  75. package/dist/holmes/cli/run-wiring.js +270 -0
  76. package/dist/holmes/cli/run.d.ts +21 -0
  77. package/dist/holmes/cli/run.js +341 -92
  78. package/dist/holmes/cli/runtime-binding-approval.js +32 -19
  79. package/dist/holmes/cli/screen-safe.d.ts +3 -92
  80. package/dist/holmes/cli/screen-safe.js +18 -756
  81. package/dist/holmes/config/config.d.ts +2 -0
  82. package/dist/holmes/config/config.js +5 -2
  83. package/dist/holmes/cpg/foundation/language-matrix.js +2 -2
  84. package/dist/holmes/cpg/import-resolver.js +1 -1
  85. package/dist/holmes/governance/approval-decisions.d.ts +47 -0
  86. package/dist/holmes/governance/approval-decisions.js +29 -0
  87. package/dist/holmes/governance/approval-grants.d.ts +220 -1
  88. package/dist/holmes/governance/approval-grants.js +612 -33
  89. package/dist/holmes/governance/approval-queue.d.ts +26 -0
  90. package/dist/holmes/governance/approval-queue.js +109 -11
  91. package/dist/holmes/governance/approval-spend.d.ts +95 -0
  92. package/dist/holmes/governance/approval-spend.js +191 -0
  93. package/dist/holmes/governance/autonomous-shell.d.ts +61 -0
  94. package/dist/holmes/governance/autonomous-shell.js +332 -0
  95. package/dist/holmes/governance/autonomy.d.ts +5 -0
  96. package/dist/holmes/governance/autonomy.js +16 -11
  97. package/dist/holmes/governance/constitution.d.ts +5 -0
  98. package/dist/holmes/governance/constitution.js +32 -12
  99. package/dist/holmes/governance/full-autonomy.d.ts +10 -0
  100. package/dist/holmes/governance/full-autonomy.js +103 -7
  101. package/dist/holmes/governance/harness-catalog.d.ts +103 -0
  102. package/dist/holmes/governance/harness-catalog.js +348 -0
  103. package/dist/holmes/governance/human-channel.d.ts +38 -0
  104. package/dist/holmes/governance/human-channel.js +49 -0
  105. package/dist/holmes/governance/install-manifest.d.ts +22 -0
  106. package/dist/holmes/governance/install-manifest.js +160 -0
  107. package/dist/holmes/governance/ledger-rechain.js +2 -0
  108. package/dist/holmes/governance/ledger-store.conformance.d.ts +7 -1
  109. package/dist/holmes/governance/ledger-store.conformance.js +66 -0
  110. package/dist/holmes/governance/ledger-store.d.ts +88 -11
  111. package/dist/holmes/governance/ledger-store.js +186 -8
  112. package/dist/holmes/governance/provenance-chain.d.ts +16 -4
  113. package/dist/holmes/governance/provenance-chain.js +19 -4
  114. package/dist/holmes/governance/provenance-ledger.d.ts +6 -3
  115. package/dist/holmes/governance/provenance-ledger.js +53 -18
  116. package/dist/holmes/governance/push-gate-runner.js +11 -7
  117. package/dist/holmes/governance/recorded-pairs.d.ts +96 -0
  118. package/dist/holmes/governance/recorded-pairs.js +522 -0
  119. package/dist/holmes/governance/replica-id.d.ts +1 -1
  120. package/dist/holmes/governance/replica-id.js +1 -1
  121. package/dist/holmes/governance/spec-seam.d.ts +59 -0
  122. package/dist/holmes/governance/spec-seam.js +587 -0
  123. package/dist/holmes/governance/spend-kinds.d.ts +16 -0
  124. package/dist/holmes/governance/spend-kinds.js +18 -0
  125. package/dist/holmes/guardrail/decision-ledger.d.ts +2 -1
  126. package/dist/holmes/guardrail/decision-ledger.js +2 -1
  127. package/dist/holmes/guardrail/impact-gate.d.ts +1 -0
  128. package/dist/holmes/guardrail/impact-gate.js +1 -1
  129. package/dist/holmes/guardrail/line-continuation.d.ts +8 -0
  130. package/dist/holmes/guardrail/line-continuation.js +39 -0
  131. package/dist/holmes/guardrail/operator-person.d.ts +28 -4
  132. package/dist/holmes/guardrail/operator-person.js +57 -11
  133. package/dist/holmes/guardrail/refusal-codes.d.ts +8 -3
  134. package/dist/holmes/guardrail/refusal-codes.js +64 -10
  135. package/dist/holmes/guardrail/risk-classifier.d.ts +15 -9
  136. package/dist/holmes/guardrail/risk-classifier.js +228 -16
  137. package/dist/holmes/guardrail/risk-gate.d.ts +2 -8
  138. package/dist/holmes/guardrail/risk-gate.js +7 -34
  139. package/dist/holmes/guardrail/risk-types.d.ts +10 -0
  140. package/dist/holmes/guardrail/run-plan-scope.js +3 -1
  141. package/dist/holmes/guardrail/run-refusals.js +24 -8
  142. package/dist/holmes/guardrail/run-stages.d.ts +5 -0
  143. package/dist/holmes/guardrail/run-stages.js +25 -5
  144. package/dist/holmes/guardrail/scope-judgment.js +1 -1
  145. package/dist/holmes/guardrail/shell-words.js +24 -3
  146. package/dist/holmes/guardrail/unresolved-write.d.ts +40 -0
  147. package/dist/holmes/guardrail/unresolved-write.js +556 -0
  148. package/dist/holmes/guardrail/write-target.d.ts +3 -0
  149. package/dist/holmes/guardrail/write-target.js +26 -5
  150. package/dist/holmes/hooks/pre-tool-use.d.ts +105 -1
  151. package/dist/holmes/hooks/pre-tool-use.js +1134 -167
  152. package/dist/holmes/hooks/rtm-refresh-child.d.ts +1 -1
  153. package/dist/holmes/hooks/rtm-refresh-child.js +1 -1
  154. package/dist/holmes/hooks/stop.d.ts +23 -0
  155. package/dist/holmes/hooks/stop.js +86 -33
  156. package/dist/holmes/mcp/approval-adapters.js +3 -1
  157. package/dist/holmes/mcp/approval-commit.js +3 -2
  158. package/dist/holmes/mcp/approval-policy.d.ts +2 -1
  159. package/dist/holmes/mcp/approval-policy.js +3 -1
  160. package/dist/holmes/mcp/handlers/adoption.d.ts +1 -1
  161. package/dist/holmes/mcp/handlers/approval-ask.d.ts +3 -0
  162. package/dist/holmes/mcp/handlers/approval-ask.js +18 -7
  163. package/dist/holmes/mcp/handlers/entity-integration.d.ts +3 -3
  164. package/dist/holmes/mcp/handlers/entity-integration.js +29 -11
  165. package/dist/holmes/mcp/handlers/entity-renumber.d.ts +4 -4
  166. package/dist/holmes/mcp/handlers/entity-renumber.js +29 -11
  167. package/dist/holmes/mcp/handlers/entity-store.d.ts +2 -2
  168. package/dist/holmes/mcp/handlers/entity-store.js +133 -59
  169. package/dist/holmes/mcp/handlers/operator-inspection.d.ts +9 -5
  170. package/dist/holmes/mcp/handlers/operator-inspection.js +79 -16
  171. package/dist/holmes/mcp/handlers/phase-queries.d.ts +1 -1
  172. package/dist/holmes/mcp/handlers/requirement-triage.d.ts +4 -4
  173. package/dist/holmes/mcp/handlers/review-evidence.d.ts +2 -2
  174. package/dist/holmes/mcp/handlers/review-evidence.js +35 -11
  175. package/dist/holmes/mcp/handlers/review-queries.d.ts +5 -0
  176. package/dist/holmes/mcp/handlers/review-queries.js +8 -1
  177. package/dist/holmes/mcp/handlers/review-verdict.d.ts +3 -0
  178. package/dist/holmes/mcp/handlers/review-verdict.js +10 -3
  179. package/dist/holmes/mcp/handlers/risk-assessment.d.ts +7 -2
  180. package/dist/holmes/mcp/handlers/risk-assessment.js +34 -12
  181. package/dist/holmes/mcp/handlers/runtime-binding-tool.d.ts +2 -2
  182. package/dist/holmes/mcp/handlers/slice-orchestration.d.ts +6 -1
  183. package/dist/holmes/mcp/handlers/slice-orchestration.js +14 -1
  184. package/dist/holmes/mcp/handlers/spec-approval.d.ts +15 -3
  185. package/dist/holmes/mcp/handlers/spec-approval.js +32 -5
  186. package/dist/holmes/mcp/handlers/spec-authoring.d.ts +2 -2
  187. package/dist/holmes/mcp/handlers/spec-authoring.js +19 -2
  188. package/dist/holmes/mcp/handlers/spec-lifecycle.d.ts +11 -38
  189. package/dist/holmes/mcp/handlers/spec-lifecycle.js +441 -94
  190. package/dist/holmes/mcp/handlers/spec-queries.d.ts +2 -2
  191. package/dist/holmes/mcp/handlers/taint-screening.d.ts +1 -1
  192. package/dist/holmes/mcp/handlers/taint-screening.js +2 -2
  193. package/dist/holmes/mcp/handlers/test-execution.d.ts +1 -1
  194. package/dist/holmes/mcp/handlers/workspace-queries.d.ts +2 -2
  195. package/dist/holmes/mcp/handlers.d.ts +89 -79
  196. package/dist/holmes/mcp/handlers.js +69 -22
  197. package/dist/holmes/mcp/harness-attestation.d.ts +78 -5
  198. package/dist/holmes/mcp/harness-attestation.js +325 -53
  199. package/dist/holmes/mcp/maintenance-analyze.d.ts +1 -1
  200. package/dist/holmes/mcp/maintenance-analyze.js +9 -9
  201. package/dist/holmes/mcp/maintenance-evidence.js +31 -2
  202. package/dist/holmes/mcp/requirement-triage-evidence.js +22 -13
  203. package/dist/holmes/mcp/server-staleness.js +1 -1
  204. package/dist/holmes/mcp/server.js +9 -8
  205. package/dist/holmes/mcp/spec-id-guard.js +1 -1
  206. package/dist/holmes/mcp/tool-schemas.d.ts +13 -0
  207. package/dist/holmes/mcp/tool-schemas.js +29 -2
  208. package/dist/holmes/project/act-root.d.ts +19 -0
  209. package/dist/holmes/project/act-root.js +100 -0
  210. package/dist/holmes/project/baseline.js +4 -3
  211. package/dist/holmes/project/bounded-group.d.ts +47 -0
  212. package/dist/holmes/project/bounded-group.js +140 -0
  213. package/dist/holmes/project/bounded-io.d.ts +50 -2
  214. package/dist/holmes/project/bounded-io.js +138 -6
  215. package/dist/holmes/project/change-source.js +2 -2
  216. package/dist/holmes/project/instance-id.d.ts +10 -0
  217. package/dist/holmes/project/instance-id.js +233 -0
  218. package/dist/holmes/project/machine-identity.d.ts +25 -0
  219. package/dist/holmes/project/machine-identity.js +133 -0
  220. package/dist/holmes/project/owned-lock.d.ts +84 -0
  221. package/dist/holmes/project/owned-lock.js +263 -0
  222. package/dist/holmes/project/plain-lock-fs.d.ts +2 -0
  223. package/dist/holmes/project/plain-lock-fs.js +126 -0
  224. package/dist/holmes/project/request-lock.d.ts +85 -0
  225. package/dist/holmes/project/request-lock.js +459 -0
  226. package/dist/holmes/project/root.d.ts +12 -4
  227. package/dist/holmes/project/root.js +26 -7
  228. package/dist/holmes/project/run-records.d.ts +19 -0
  229. package/dist/holmes/project/run-records.js +94 -12
  230. package/dist/holmes/project/screen-text.d.ts +94 -0
  231. package/dist/holmes/project/screen-text.js +763 -0
  232. package/dist/holmes/project/spend-lock.d.ts +82 -0
  233. package/dist/holmes/project/spend-lock.js +413 -0
  234. package/dist/holmes/refresh/freshness-coordinator.d.ts +1 -1
  235. package/dist/holmes/refresh/freshness-coordinator.js +1 -1
  236. package/dist/holmes/review/condition-hunk-replay.js +4 -2
  237. package/dist/holmes/review/confidence-calibration.d.ts +1 -1
  238. package/dist/holmes/review/confidence-calibration.js +1 -1
  239. package/dist/holmes/review/content-verify.js +1 -1
  240. package/dist/holmes/review/hop-ablation.d.ts +4 -4
  241. package/dist/holmes/review/hop-ablation.js +5 -5
  242. package/dist/holmes/review/point-in-time-replay.js +12 -3
  243. package/dist/holmes/review/rank-diagnosis.d.ts +2 -2
  244. package/dist/holmes/review/rank-diagnosis.js +1 -1
  245. package/dist/holmes/review/replay-corpus.d.ts +10 -4
  246. package/dist/holmes/review/replay-corpus.js +25 -9
  247. package/dist/holmes/review/requirement-triage.js +2 -2
  248. package/dist/holmes/review/semantic-arm.d.ts +3 -3
  249. package/dist/holmes/review/semantic-arm.js +3 -3
  250. package/dist/holmes/review/test-outcomes.js +3 -1
  251. package/dist/holmes/review/test-runner.d.ts +11 -0
  252. package/dist/holmes/review/test-runner.js +31 -10
  253. package/dist/holmes/review/test-selection-breadth.js +2 -2
  254. package/dist/holmes/review/verdicts.d.ts +105 -8
  255. package/dist/holmes/review/verdicts.js +640 -36
  256. package/dist/holmes/rtm/anchor-census.d.ts +9 -0
  257. package/dist/holmes/rtm/anchor-census.js +151 -0
  258. package/dist/holmes/rtm/anchor-ids.d.ts +25 -1
  259. package/dist/holmes/rtm/anchor-ids.js +45 -2
  260. package/dist/holmes/rtm/comment-ranges.d.ts +2 -0
  261. package/dist/holmes/rtm/comment-ranges.js +104 -0
  262. package/dist/holmes/rtm/counted-tests.d.ts +1 -0
  263. package/dist/holmes/rtm/counted-tests.js +63 -0
  264. package/dist/holmes/rtm/impact-advisory.d.ts +1 -1
  265. package/dist/holmes/rtm/known-defects.js +1 -1
  266. package/dist/holmes/rtm/localize.js +1 -1
  267. package/dist/holmes/rtm/taint-benchmark.d.ts +1 -1
  268. package/dist/holmes/rtm/taint-vocabulary.d.ts +1 -1
  269. package/dist/holmes/rtm/test-scope.d.ts +31 -0
  270. package/dist/holmes/rtm/test-scope.js +166 -5
  271. package/dist/holmes/rtm/trace-gaps.js +1 -1
  272. package/dist/holmes/runtime/dispatch.d.ts +10 -0
  273. package/dist/holmes/runtime/dispatch.js +12 -1
  274. package/dist/holmes/semantic/cloud-usage.d.ts +1 -1
  275. package/dist/holmes/semantic/cloud-usage.js +1 -1
  276. package/dist/holmes/semantic/unreadable-paths.d.ts +1 -1
  277. package/dist/holmes/semantic/unreadable-paths.js +1 -1
  278. package/dist/holmes/spec/approval-blockers.js +1 -1
  279. package/dist/holmes/spec/entity-store.d.ts +6 -1
  280. package/dist/holmes/spec/entity-store.js +16 -2
  281. package/dist/holmes/spec/entity-transaction.d.ts +7 -2
  282. package/dist/holmes/spec/entity-transaction.js +87 -170
  283. package/dist/holmes/spec/spec-store.d.ts +12 -6
  284. package/dist/holmes/spec/spec-store.js +4 -2
  285. package/dist/holmes/spec/spec-types.js +1 -1
  286. package/dist/holmes/spec/succession-guard.d.ts +56 -0
  287. package/dist/holmes/spec/succession-guard.js +187 -0
  288. package/dist/holmes/spec/succession.d.ts +70 -0
  289. package/dist/holmes/spec/succession.js +171 -0
  290. package/dist/holmes/spec/transition-policy.d.ts +2 -2
  291. package/docs/install-guide.md +9 -3
  292. package/docs/language-support.md +78 -0
  293. package/package.json +4 -3
  294. package/playbooks/author-slice/PLAYBOOK.md +1 -1
  295. package/playbooks/promote-slice/PLAYBOOK.md +5 -1
  296. package/playbooks/publish/PLAYBOOK.md +45 -33
  297. package/dist/holmes/review/manual-baseline.d.ts +0 -209
  298. package/dist/holmes/review/manual-baseline.js +0 -2847
@@ -0,0 +1,9 @@
1
+ export interface AnchorCensus {
2
+ at: string[];
3
+ unreadable: string[];
4
+ skipped: string[];
5
+ truncated: boolean;
6
+ }
7
+ export declare function anchorCensus(root: string, id: string, opts?: {
8
+ fileMax?: number;
9
+ }): AnchorCensus;
@@ -0,0 +1,151 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.anchorCensus = anchorCensus;
37
+ // @implements A-SPEC-222.7, A-SPEC-222.8
38
+ /**
39
+ * Where an A-SPEC is still anchored, read over every file the code gate governs (AU1-a.1 H3: the census read only
40
+ * `src` and `scripts`, `.ts/.js/.sh`, so a Python workspace always looked unanchored). A file is in scope when
41
+ * `classifyAction` calls a write to it code or test; only `.git`, `.ax`, `node_modules`, third-party Python
42
+ * environments and nested work trees are skipped. What cannot be read is reported, never taken as unanchored.
43
+ */
44
+ const fs = __importStar(require("node:fs"));
45
+ const path = __importStar(require("node:path"));
46
+ const phase_1 = require("../guardrail/phase");
47
+ const cpg_scanner_1 = require("../cpg/cpg-scanner");
48
+ const anchor_ids_1 = require("./anchor-ids");
49
+ const SKIPPED = new Set(['.git', '.ax', 'node_modules', '__pycache__', '.tox', '.nox']);
50
+ const FILE_MAX = 8 * 1024 * 1024;
51
+ const FILES_MAX = 200_000;
52
+ /**
53
+ * @implements A-SPEC-222.11 — the binary formats the census may skip, each by its extension AND its signature: an
54
+ * archive is not an anchor carrier, but a text file merely named like one is read, and any other file the census
55
+ * cannot read still fails closed.
56
+ */
57
+ const DECLARED_BINARY = [
58
+ { ext: /\.zip$/i, magic: [[0x50, 0x4b, 0x03, 0x04], [0x50, 0x4b, 0x05, 0x06]] },
59
+ { ext: /\.(?:gz|tgz)$/i, magic: [[0x1f, 0x8b]] },
60
+ { ext: /\.png$/i, magic: [[0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]] },
61
+ { ext: /\.jpe?g$/i, magic: [[0xff, 0xd8, 0xff]] },
62
+ ];
63
+ function declaredBinary(abs) {
64
+ const formats = DECLARED_BINARY.filter((f) => f.ext.test(abs));
65
+ if (formats.length === 0)
66
+ return false;
67
+ const head = Buffer.alloc(8);
68
+ let n = 0;
69
+ try {
70
+ const fd = fs.openSync(abs, 'r');
71
+ try {
72
+ n = fs.readSync(fd, head, 0, 8, 0);
73
+ }
74
+ finally {
75
+ fs.closeSync(fd);
76
+ }
77
+ }
78
+ catch {
79
+ return false;
80
+ }
81
+ return formats.some((f) => f.magic.some((m) => n >= m.length && m.every((b, i) => head[i] === b)));
82
+ }
83
+ /** @implements A-SPEC-222.8 — L-b: a Python environment only when it is one, wherever its name appears. */
84
+ function pythonEnvironment(abs, name) {
85
+ if (name === 'venv' || name === '.venv')
86
+ return fs.existsSync(path.join(abs, 'pyvenv.cfg'));
87
+ if (name === 'site-packages')
88
+ return /[\\/]lib[\\/]python[^\\/]*$/.test(path.dirname(abs));
89
+ return false;
90
+ }
91
+ function anchorCensus(root, id, opts = {}) {
92
+ const out = { at: [], unreadable: [], skipped: [], truncated: false };
93
+ const fileMax = opts.fileMax ?? FILE_MAX;
94
+ // @implements A-SPEC-222.8 — L-b: a file the gate governs under either classification option (in a run or not)
95
+ const { classifyOptionsFor } = require('../guardrail/classification-mode');
96
+ const options = [classifyOptionsFor(root, false), classifyOptionsFor(root, true)];
97
+ let seen = 0;
98
+ const walk = (dir) => {
99
+ let entries;
100
+ try {
101
+ entries = fs.readdirSync(dir, { withFileTypes: true });
102
+ }
103
+ catch {
104
+ out.unreadable.push(path.relative(root, dir).split(path.sep).join('/') || '.');
105
+ return;
106
+ }
107
+ for (const e of entries) {
108
+ if (out.truncated)
109
+ return;
110
+ const abs = path.join(dir, e.name);
111
+ const rel = path.relative(root, abs).split(path.sep).join('/');
112
+ if (e.isDirectory()) {
113
+ if (!SKIPPED.has(e.name) && !pythonEnvironment(abs, e.name) && !(0, cpg_scanner_1.isNestedWorkTree)(abs, root))
114
+ walk(abs);
115
+ continue;
116
+ }
117
+ if (!options.some((o) => { const a = (0, phase_1.classifyAction)(rel, undefined, o); return a === 'WRITE_CODE' || a === 'WRITE_TEST'; }))
118
+ continue;
119
+ if (!(0, cpg_scanner_1.isRegularSource)(e, abs, root))
120
+ continue;
121
+ if (++seen > FILES_MAX) {
122
+ out.truncated = true;
123
+ return;
124
+ }
125
+ if (declaredBinary(abs)) {
126
+ out.skipped.push(rel);
127
+ continue;
128
+ }
129
+ let text;
130
+ try {
131
+ if (fs.statSync(abs).size > fileMax) {
132
+ out.unreadable.push(rel);
133
+ continue;
134
+ }
135
+ text = fs.readFileSync(abs, 'utf8');
136
+ }
137
+ catch {
138
+ out.unreadable.push(rel);
139
+ continue;
140
+ }
141
+ if (!text.includes(id))
142
+ continue;
143
+ // @implements A-SPEC-222.8 — N1: read as the gate reads this format (a non-code file raw)
144
+ for (const s of (0, anchor_ids_1.anchorSitesFor)(rel, text))
145
+ if (s.spec === id)
146
+ out.at.push(`${rel}:${s.line}`);
147
+ }
148
+ };
149
+ walk(root);
150
+ return out;
151
+ }
@@ -28,10 +28,34 @@ export declare function anchorSpecIds(text: string): string[];
28
28
  *
29
29
  * Lines are counted by `\n`, so a CRLF file numbers exactly as its LF twin does.
30
30
  */
31
- export declare function anchorSpecSites(text: string): Array<{
31
+ export declare function anchorSpecSites(text: string, opts?: {
32
+ raw?: boolean;
33
+ }): Array<{
32
34
  spec: string;
33
35
  line: number;
34
36
  }>;
37
+ /**
38
+ * @implements A-SPEC-222.6 — the same sites as `anchorSpecSites` (string literals excluded), as offsets: each A-SPEC id
39
+ * token of each anchor list, `[start, end)` in `text`. What an anchor move may change, and nothing else.
40
+ */
41
+ export declare function anchorIdSpans(text: string, opts?: {
42
+ raw?: boolean;
43
+ }): Array<{
44
+ spec: string;
45
+ start: number;
46
+ end: number;
47
+ }>;
48
+ export declare function anchorCodeFormat(relPath: string): boolean;
49
+ export declare function anchorSpecIdsFor(relPath: string, text: string): string[];
50
+ export declare function anchorSitesFor(relPath: string, text: string): Array<{
51
+ spec: string;
52
+ line: number;
53
+ }>;
54
+ export declare function anchorIdSpansFor(relPath: string, text: string): Array<{
55
+ spec: string;
56
+ start: number;
57
+ end: number;
58
+ }>;
35
59
  /** Flattened wrong-kind ids (a governed id anchored where only A-SPEC belongs) — anywhere in a list. */
36
60
  export declare function wrongKindAnchorIds(text: string): string[];
37
61
  /** A list the comma grammar does not read: the first non-comma joiner after a list, and every id the join drops. */
@@ -15,6 +15,11 @@ exports.stringLiteralRanges = stringLiteralRanges;
15
15
  exports.implementsIdLists = implementsIdLists;
16
16
  exports.anchorSpecIds = anchorSpecIds;
17
17
  exports.anchorSpecSites = anchorSpecSites;
18
+ exports.anchorIdSpans = anchorIdSpans;
19
+ exports.anchorCodeFormat = anchorCodeFormat;
20
+ exports.anchorSpecIdsFor = anchorSpecIdsFor;
21
+ exports.anchorSitesFor = anchorSitesFor;
22
+ exports.anchorIdSpansFor = anchorIdSpansFor;
18
23
  exports.wrongKindAnchorIds = wrongKindAnchorIds;
19
24
  exports.anchorListDiagnostics = anchorListDiagnostics;
20
25
  // @implements A-SPEC-504.1
@@ -100,8 +105,8 @@ function anchorSpecIds(text) {
100
105
  *
101
106
  * Lines are counted by `\n`, so a CRLF file numbers exactly as its LF twin does.
102
107
  */
103
- function anchorSpecSites(text) {
104
- const strings = stringLiteralRanges(text);
108
+ function anchorSpecSites(text, opts = {}) {
109
+ const strings = opts.raw ? [] : stringLiteralRanges(text);
105
110
  const sites = [];
106
111
  let s = 0; // first string range that could still contain the marker
107
112
  let line = 1; // line of `lineAt`
@@ -121,6 +126,44 @@ function anchorSpecSites(text) {
121
126
  }
122
127
  return sites;
123
128
  }
129
+ /**
130
+ * @implements A-SPEC-222.6 — the same sites as `anchorSpecSites` (string literals excluded), as offsets: each A-SPEC id
131
+ * token of each anchor list, `[start, end)` in `text`. What an anchor move may change, and nothing else.
132
+ */
133
+ function anchorIdSpans(text, opts = {}) {
134
+ const strings = opts.raw ? [] : stringLiteralRanges(text);
135
+ const spans = [];
136
+ let s = 0;
137
+ for (const m of text.matchAll(LIST_RE)) {
138
+ const at = m.index ?? 0;
139
+ while (s < strings.length && strings[s][1] < at)
140
+ s++;
141
+ if (s < strings.length && strings[s][0] < at)
142
+ continue; // the marker sits inside that literal
143
+ const listAt = at + m[0].length - m[1].length;
144
+ for (const id of m[1].matchAll(ID_RE)) {
145
+ if (id[0].startsWith('A-SPEC-'))
146
+ spans.push({ spec: id[0], start: listAt + (id.index ?? 0), end: listAt + (id.index ?? 0) + id[0].length });
147
+ }
148
+ }
149
+ return spans;
150
+ }
151
+ /**
152
+ * @implements A-SPEC-222.8 — the ONE per-format reading the gate, the census and the move judgment share (N1): a code
153
+ * format (line-comment anchors) drops string literals; every other file (JSON, YAML, shell, Dockerfile, Makefile, …) is
154
+ * read raw, because a string value is its only way to carry an anchor (A-SPEC-529.2).
155
+ */
156
+ const ANCHOR_CODE_EXT = /\.(?:ts|tsx|mts|cts|js|jsx|mjs|cjs|py|go|rs|java|kt|cs|cc|cxx|cpp|hh|hpp|rb|php|swift)$/i;
157
+ function anchorCodeFormat(relPath) { return ANCHOR_CODE_EXT.test(relPath); }
158
+ function anchorSpecIdsFor(relPath, text) {
159
+ return anchorSpecIds(anchorCodeFormat(relPath) ? stripStringLiterals(text) : text);
160
+ }
161
+ function anchorSitesFor(relPath, text) {
162
+ return anchorSpecSites(text, { raw: !anchorCodeFormat(relPath) });
163
+ }
164
+ function anchorIdSpansFor(relPath, text) {
165
+ return anchorIdSpans(text, { raw: !anchorCodeFormat(relPath) });
166
+ }
124
167
  /** Flattened wrong-kind ids (a governed id anchored where only A-SPEC belongs) — anywhere in a list. */
125
168
  function wrongKindAnchorIds(text) {
126
169
  return [...new Set(implementsIdLists(text).flat().filter((id) => !id.startsWith('A-SPEC-')))];
@@ -0,0 +1,2 @@
1
+ /** The comment ranges of a code file, or null for a language with no reader here. */
2
+ export declare function commentRanges(relPath: string, text: string): Array<[number, number]> | null;
@@ -0,0 +1,104 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.commentRanges = commentRanges;
37
+ // @implements A-SPEC-222.8
38
+ /**
39
+ * Where a code file's comments are, `[start, end)` — what an anchor move may change in a code format (AU1.2 N3: a
40
+ * literal scan that does not know the language let a string after a backtick in a comment, a regex literal and a
41
+ * Python docstring pass as anchors). TypeScript and JavaScript are read with the compiler's own parse; Python with a
42
+ * tokenizer that knows triple-quoted strings. Any other code language returns null: no reader, no autonomous move.
43
+ */
44
+ const ts = __importStar(require("typescript"));
45
+ const TS_EXT = /\.(?:ts|tsx|mts|cts|js|jsx|mjs|cjs)$/i;
46
+ function tsComments(relPath, text) {
47
+ const kind = /\.(?:tsx|jsx)$/i.test(relPath) ? ts.ScriptKind.TSX : /\.(?:js|mjs|cjs)$/i.test(relPath) ? ts.ScriptKind.JS : ts.ScriptKind.TS;
48
+ const sf = ts.createSourceFile(relPath, text, ts.ScriptTarget.Latest, false, kind);
49
+ const seen = new Set();
50
+ const out = [];
51
+ const add = (rs) => { for (const r of rs ?? [])
52
+ if (!seen.has(r.pos)) {
53
+ seen.add(r.pos);
54
+ out.push([r.pos, r.end]);
55
+ } };
56
+ const visit = (n) => {
57
+ add(ts.getLeadingCommentRanges(text, n.getFullStart()));
58
+ add(ts.getTrailingCommentRanges(text, n.getEnd()));
59
+ for (const c of n.getChildren(sf))
60
+ visit(c);
61
+ };
62
+ visit(sf);
63
+ return out.sort((a, b) => a[0] - b[0]);
64
+ }
65
+ function pyComments(text) {
66
+ const out = [];
67
+ for (let i = 0; i < text.length; i++) {
68
+ const c = text[i];
69
+ if (c === '#') {
70
+ let j = text.indexOf('\n', i);
71
+ if (j < 0)
72
+ j = text.length;
73
+ out.push([i, j]);
74
+ i = j;
75
+ continue;
76
+ }
77
+ if (c === '"' || c === "'") {
78
+ const triple = text.startsWith(c.repeat(3), i);
79
+ const close = triple ? c.repeat(3) : c;
80
+ let j = i + close.length;
81
+ while (j < text.length) {
82
+ if (text[j] === '\\') {
83
+ j += 2;
84
+ continue;
85
+ }
86
+ if (text.startsWith(close, j))
87
+ break;
88
+ if (!triple && text[j] === '\n')
89
+ break; // an unterminated single-line string ends at the line
90
+ j++;
91
+ }
92
+ i = j + close.length - 1;
93
+ }
94
+ }
95
+ return out;
96
+ }
97
+ /** The comment ranges of a code file, or null for a language with no reader here. */
98
+ function commentRanges(relPath, text) {
99
+ if (TS_EXT.test(relPath))
100
+ return tsComments(relPath, text);
101
+ if (/\.py$/i.test(relPath))
102
+ return pyComments(text);
103
+ return null;
104
+ }
@@ -0,0 +1 @@
1
+ export declare function countedTests(projectRoot: string): (aspec: string) => number;
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.countedTests = countedTests;
37
+ // @implements A-SPEC-222.9
38
+ /**
39
+ * The counted test cases an A-SPEC has (SD1 finding 5): one reading of the test anchors for `spec_retire`'s autonomous
40
+ * retirement and its after-the-fact T record, which kept two copies of it. An A-SPEC counts its own anchors and those
41
+ * of its sub-slices (`A-SPEC-300` counts `A-SPEC-300.1`). Read lazily, once per `countedTests` call.
42
+ */
43
+ const fs = __importStar(require("node:fs"));
44
+ const path = __importStar(require("node:path"));
45
+ const test_scope_1 = require("./test-scope");
46
+ function countedTests(projectRoot) {
47
+ let counts;
48
+ return (aspec) => {
49
+ if (!counts) {
50
+ counts = {};
51
+ for (const [file, anchored] of Object.entries((0, test_scope_1.scanTestAnchors)(projectRoot))) {
52
+ let n = 0;
53
+ try {
54
+ n = (0, test_scope_1.testCountDetail)(fs.readFileSync(path.resolve(projectRoot, file), 'utf8'), file).cases;
55
+ }
56
+ catch { /* unreadable: counts zero */ }
57
+ for (const id of anchored)
58
+ counts[id] = (counts[id] ?? 0) + n;
59
+ }
60
+ }
61
+ return Object.entries(counts).filter(([id]) => id === aspec || id.startsWith(`${aspec}.`)).reduce((s, [, n]) => s + n, 0);
62
+ };
63
+ }
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * The impact advisory: what the Files-to-Touch declaration MISSES, computed from the call graph at
3
- * the moment of sealing. jarvis proposal #1, admitted on our own measured record — of fourteen
3
+ * the moment of sealing. A consumer workspace's proposal #1, admitted on our own measured record — of fourteen
4
4
  * graph mechanisms, the only win was the IMPACT axis (PPR, three corpora), and REQ-565 established
5
5
  * the "declaration vs machine" gate pattern this extends.
6
6
  *
@@ -7,7 +7,7 @@ exports.judgeKnownDefects = judgeKnownDefects;
7
7
  * `@known-defect(<reason>, expires=YYYY-MM-DD)` — the machine-readable marker for an assertion that
8
8
  * pins a KNOWN DEFECT as the expected value.
9
9
  *
10
- * jarvis 2026-09-08: a query that could only ever return 0 was worked around instead of fixed, the
10
+ * A consumer workspace, 2026-09-08: a query that could only ever return 0 was worked around instead of fixed, the
11
11
  * workaround was pinned by a test (`assert raw == []`), and to every gate that test was
12
12
  * indistinguishable from a healthy one — green, anchored, covered. The docstring said "trap"; only
13
13
  * people read docstrings, and the next person repeated the misjudgement. Three precedents make the
@@ -210,7 +210,7 @@ function localizeIssue(issueText, scanned, specs, topN = 10) {
210
210
  // a whole group of unrelated files at once. Threshold 1 means "one term of average rarity, or
211
211
  // several common ones". Measured over both corpora at thresholds 0.5/1/2/3: 1 was the only
212
212
  // setting that improved BOTH (this repository Top-1 0.317 -> 0.333, Top-10 recall 0.754 ->
213
- // 0.770; jarvis 0.333 -> 0.367 and 0.662 -> 0.684).
213
+ // 0.770; consumer corpus 0.333 -> 0.367 and 0.662 -> 0.684).
214
214
  let mass = 0;
215
215
  for (const t of termSet)
216
216
  if (st.has(t))
@@ -77,7 +77,7 @@ export interface RealCorpusTaint {
77
77
  *
78
78
  * When this is 0 the corpus is UNMEASURED, not clean: the data-flow walk exists for a subset of
79
79
  * languages, so a Python/JS repository yields no facts and would otherwise report a confident
80
- * `findings: 0`. Measured on jarvis: 145 files scanned, 0 with facts.
80
+ * `findings: 0`. Measured on the consumer corpus: 145 files scanned, 0 with facts.
81
81
  */
82
82
  filesWithFacts: number;
83
83
  findings: number;
@@ -2,7 +2,7 @@
2
2
  * Taint vocabulary, per language — because "we found nothing" and "we do not speak this language"
3
3
  * are different sentences and the tool was saying the first while meaning the second.
4
4
  *
5
- * Measured on jarvis (27,232 Python files) 2026-09-02: the shipped list matched `subprocess.Popen`
5
+ * Measured on the consumer corpus (27,232 Python files) 2026-09-02: the shipped list matched `subprocess.Popen`
6
6
  * and `exec(`, and missed `subprocess.run` (7 files), `os.environ` (5) and `input(` (4) — the three
7
7
  * most common Python spellings. The engine already handled Python (its CFG/DDG landed in S-510.7);
8
8
  * it simply had no Python words to look for.
@@ -127,6 +127,37 @@ export declare function stripCode(src: string, js: boolean): string;
127
127
  /** Frameworks this counter understands, for diagnostics and tests. */
128
128
  export declare const SUPPORTED_TEST_FRAMEWORKS: string[];
129
129
  export declare function countTestCases(source: string, filePath?: string): number;
130
+ /**
131
+ * @implements A-SPEC-750.2 — the count with what explains a zero: the first line holding a suite-skip marker (each
132
+ * original line stripped alone), and the reason the whole file was forfeited when it was.
133
+ */
134
+ export declare function testCountDetail(source: string, filePath?: string): {
135
+ cases: number;
136
+ markerLine?: number;
137
+ placedSkip?: boolean;
138
+ forfeit?: {
139
+ line: number;
140
+ reason: string;
141
+ };
142
+ };
143
+ /** @implements A-SPEC-750.4 — why an anchored file counts zero, in the words ART-4, remediate and review_prepare use. */
144
+ export declare function zeroCountReason(d: {
145
+ markerLine?: number;
146
+ placedSkip?: boolean;
147
+ forfeit?: {
148
+ line: number;
149
+ reason: string;
150
+ };
151
+ }): string;
152
+ /**
153
+ * @implements A-SPEC-750.2 — every anchored test file that counts zero, with its A-SPECs and why: `suite-skip marker at
154
+ * line N`, or `no case heads`. What ART-4, spec_remediate and review_prepare say instead of "anchor the tests".
155
+ */
156
+ export declare function zeroCountDiagnostics(root: string): Array<{
157
+ file: string;
158
+ aspecs: string[];
159
+ reason: string;
160
+ }>;
130
161
  /** A-SPEC ids anchored by a file, counting only standalone comment-line markers outside literals. */
131
162
  export declare function extractAnchors(source: string): string[];
132
163
  /**