@warpgogol/forge 9.7.1 → 10.1.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 (262) hide show
  1. package/AGENTS.md +50 -27
  2. package/CHANGELOG.md +39 -0
  3. package/bin/cli.js +0 -0
  4. package/dist/os/codebase/handlers/codebase-measure-symbols.d.ts.map +1 -1
  5. package/dist/os/codebase/handlers/codebase-measure-symbols.js +35 -4
  6. package/dist/os/codebase/handlers/codebase-measure-symbols.js.map +1 -1
  7. package/dist/os/core/core.module.d.ts.map +1 -1
  8. package/dist/os/core/core.module.js +1 -69
  9. package/dist/os/core/core.module.js.map +1 -1
  10. package/dist/os/core/handlers/assets-helpers.d.ts.map +1 -1
  11. package/dist/os/core/handlers/assets-helpers.js +2 -3
  12. package/dist/os/core/handlers/assets-helpers.js.map +1 -1
  13. package/dist/os/core/handlers/determinism-check.d.ts.map +1 -1
  14. package/dist/os/core/handlers/determinism-check.js +2 -3
  15. package/dist/os/core/handlers/determinism-check.js.map +1 -1
  16. package/dist/os/core/handlers/release-prepare.d.ts.map +1 -1
  17. package/dist/os/core/handlers/release-prepare.js +2 -4
  18. package/dist/os/core/handlers/release-prepare.js.map +1 -1
  19. package/dist/os/flow/handlers/flow-peers.js +1 -1
  20. package/dist/os/flow/handlers/flow-peers.js.map +1 -1
  21. package/dist/os/{mission → flow}/open-missions.d.ts +1 -2
  22. package/dist/os/flow/open-missions.d.ts.map +1 -0
  23. package/dist/os/flow/open-missions.js +37 -0
  24. package/dist/os/flow/open-missions.js.map +1 -0
  25. package/dist/os/flow/preflight.js +1 -1
  26. package/dist/os/flow/preflight.js.map +1 -1
  27. package/dist/os/rfc/probe-batch.d.ts.map +1 -1
  28. package/dist/os/rfc/probe-batch.js +13 -6
  29. package/dist/os/rfc/probe-batch.js.map +1 -1
  30. package/dist/src/command-modules.d.ts.map +1 -1
  31. package/dist/src/command-modules.js +0 -2
  32. package/dist/src/command-modules.js.map +1 -1
  33. package/dist/src/contract/core-nodes.d.ts +8 -0
  34. package/dist/src/contract/core-nodes.d.ts.map +1 -0
  35. package/dist/src/contract/core-nodes.js +101 -0
  36. package/dist/src/contract/core-nodes.js.map +1 -0
  37. package/dist/src/contract/evaluator.d.ts +48 -0
  38. package/dist/src/contract/evaluator.d.ts.map +1 -0
  39. package/dist/src/contract/evaluator.js +158 -0
  40. package/dist/src/contract/evaluator.js.map +1 -0
  41. package/dist/src/contract/evidence-store.d.ts +17 -0
  42. package/dist/src/contract/evidence-store.d.ts.map +1 -0
  43. package/dist/src/contract/evidence-store.js +113 -0
  44. package/dist/src/contract/evidence-store.js.map +1 -0
  45. package/dist/src/contract/executors/zero-deps.d.ts +3 -0
  46. package/dist/src/contract/executors/zero-deps.d.ts.map +1 -0
  47. package/dist/src/contract/executors/zero-deps.js +88 -0
  48. package/dist/src/contract/executors/zero-deps.js.map +1 -0
  49. package/dist/src/contract/fingerprint.d.ts +34 -0
  50. package/dist/src/contract/fingerprint.d.ts.map +1 -0
  51. package/dist/src/contract/fingerprint.js +153 -0
  52. package/dist/src/contract/fingerprint.js.map +1 -0
  53. package/dist/src/contract/graph.d.ts +23 -0
  54. package/dist/src/contract/graph.d.ts.map +1 -0
  55. package/dist/src/contract/graph.js +158 -0
  56. package/dist/src/contract/graph.js.map +1 -0
  57. package/dist/src/contract/migration-map.d.ts +51 -0
  58. package/dist/src/contract/migration-map.d.ts.map +1 -0
  59. package/dist/src/contract/migration-map.js +130 -0
  60. package/dist/src/contract/migration-map.js.map +1 -0
  61. package/dist/src/contract/types.d.ts +108 -0
  62. package/dist/src/contract/types.d.ts.map +1 -0
  63. package/dist/src/contract/types.js +23 -0
  64. package/dist/src/contract/types.js.map +1 -0
  65. package/dist/src/index.d.ts +0 -2
  66. package/dist/src/index.d.ts.map +1 -1
  67. package/dist/src/index.js +0 -2
  68. package/dist/src/index.js.map +1 -1
  69. package/dist/src/integration/drain.d.ts +31 -0
  70. package/dist/src/integration/drain.d.ts.map +1 -0
  71. package/dist/src/integration/drain.js +195 -0
  72. package/dist/src/integration/drain.js.map +1 -0
  73. package/dist/src/integration/enqueue.d.ts +30 -0
  74. package/dist/src/integration/enqueue.d.ts.map +1 -0
  75. package/dist/src/integration/enqueue.js +64 -0
  76. package/dist/src/integration/enqueue.js.map +1 -0
  77. package/dist/src/integration/gitops.d.ts +33 -0
  78. package/dist/src/integration/gitops.d.ts.map +1 -0
  79. package/dist/src/integration/gitops.js +128 -0
  80. package/dist/src/integration/gitops.js.map +1 -0
  81. package/dist/src/integration/lease.d.ts +16 -0
  82. package/dist/src/integration/lease.d.ts.map +1 -0
  83. package/dist/src/integration/lease.js +140 -0
  84. package/dist/src/integration/lease.js.map +1 -0
  85. package/dist/src/integration/materialize.d.ts +7 -0
  86. package/dist/src/integration/materialize.d.ts.map +1 -0
  87. package/dist/src/integration/materialize.js +34 -0
  88. package/dist/src/integration/materialize.js.map +1 -0
  89. package/dist/src/integration/store.d.ts +21 -0
  90. package/dist/src/integration/store.d.ts.map +1 -0
  91. package/dist/src/integration/store.js +131 -0
  92. package/dist/src/integration/store.js.map +1 -0
  93. package/dist/src/integration/types.d.ts +71 -0
  94. package/dist/src/integration/types.d.ts.map +1 -0
  95. package/dist/src/integration/types.js +18 -0
  96. package/dist/src/integration/types.js.map +1 -0
  97. package/dist/src/onboarding/doctor.d.ts +0 -5
  98. package/dist/src/onboarding/doctor.d.ts.map +1 -1
  99. package/dist/src/onboarding/doctor.js +6 -79
  100. package/dist/src/onboarding/doctor.js.map +1 -1
  101. package/dist/src/onboarding/npm-token-check.d.ts +1 -1
  102. package/dist/src/onboarding/npm-token-check.d.ts.map +1 -1
  103. package/dist/src/onboarding/npm-token-check.js +2 -2
  104. package/dist/src/onboarding/npm-token-check.js.map +1 -1
  105. package/dist/src/sdk/context.d.ts +13 -0
  106. package/dist/src/sdk/context.d.ts.map +1 -0
  107. package/dist/src/sdk/context.js +128 -0
  108. package/dist/src/sdk/context.js.map +1 -0
  109. package/dist/src/sdk/loader.d.ts +25 -0
  110. package/dist/src/sdk/loader.d.ts.map +1 -0
  111. package/dist/src/sdk/loader.js +155 -0
  112. package/dist/src/sdk/loader.js.map +1 -0
  113. package/dist/src/sdk/scan.d.ts +16 -0
  114. package/dist/src/sdk/scan.d.ts.map +1 -0
  115. package/dist/src/sdk/scan.js +126 -0
  116. package/dist/src/sdk/scan.js.map +1 -0
  117. package/dist/src/sdk/skills-gen.d.ts +27 -0
  118. package/dist/src/sdk/skills-gen.d.ts.map +1 -0
  119. package/dist/src/sdk/skills-gen.js +87 -0
  120. package/dist/src/sdk/skills-gen.js.map +1 -0
  121. package/dist/src/sdk/types.d.ts +124 -0
  122. package/dist/src/sdk/types.d.ts.map +1 -0
  123. package/dist/src/sdk/types.js +34 -0
  124. package/dist/src/sdk/types.js.map +1 -0
  125. package/dist/src/utils/hash.d.ts +1 -0
  126. package/dist/src/utils/hash.d.ts.map +1 -1
  127. package/dist/src/utils/hash.js +4 -0
  128. package/dist/src/utils/hash.js.map +1 -1
  129. package/dist/{os/mission → src/utils}/lockfile.d.ts +1 -18
  130. package/dist/src/utils/lockfile.d.ts.map +1 -0
  131. package/dist/src/utils/lockfile.js +70 -0
  132. package/dist/src/utils/lockfile.js.map +1 -0
  133. package/os/codebase/handlers/codebase-measure-symbols.ts +32 -4
  134. package/os/core/core.module.ts +3 -76
  135. package/os/core/handlers/assets-helpers.ts +2 -4
  136. package/os/core/handlers/determinism-check.ts +2 -3
  137. package/os/core/handlers/lifecycle-handlers.test.ts +529 -0
  138. package/os/core/handlers/release-prepare.ts +2 -4
  139. package/os/correctness/gate/trust-boundary-cx18.test.ts +1 -1
  140. package/os/flow/handlers/flow-peers.ts +1 -1
  141. package/os/flow/open-missions.ts +45 -0
  142. package/os/flow/preflight.ts +1 -1
  143. package/os/flow/tests/release-lines.test.ts +136 -0
  144. package/os/flow/tests/state-roots.test.ts +1 -48
  145. package/os/rfc/handlers/validate-corpus.test.ts +149 -0
  146. package/os/rfc/probe-batch.test.ts +253 -0
  147. package/os/rfc/probe-batch.ts +13 -6
  148. package/os/rfc/verifier/rfc-1391/ac10-operating-model-policy.acceptance.test.ts +63 -0
  149. package/package.json +177 -506
  150. package/src/command-modules.ts +0 -2
  151. package/src/contract/core-nodes.ts +111 -0
  152. package/src/contract/evaluator.ts +207 -0
  153. package/src/contract/evidence-store.ts +119 -0
  154. package/src/contract/executors/zero-deps.ts +92 -0
  155. package/src/contract/fingerprint.ts +176 -0
  156. package/src/contract/graph.ts +181 -0
  157. package/src/contract/migration-map.ts +174 -0
  158. package/src/contract/types.ts +125 -0
  159. package/src/index.ts +0 -2
  160. package/src/integration/drain.ts +271 -0
  161. package/src/integration/enqueue.ts +92 -0
  162. package/src/integration/gitops.ts +174 -0
  163. package/src/integration/lease.ts +144 -0
  164. package/src/integration/materialize.ts +40 -0
  165. package/src/integration/store.ts +153 -0
  166. package/src/integration/types.ts +79 -0
  167. package/src/onboarding/doctor.ts +9 -96
  168. package/src/onboarding/npm-token-check.ts +3 -3
  169. package/src/sdk/context.ts +135 -0
  170. package/src/sdk/loader.ts +170 -0
  171. package/src/sdk/scan.ts +132 -0
  172. package/src/sdk/skills-gen.ts +104 -0
  173. package/src/sdk/types.ts +135 -0
  174. package/src/tests/pkg-health-self-scan.test.ts +29 -0
  175. package/src/tests/rfc-evidence-sync.test.ts +369 -0
  176. package/src/tests/skill-agents-sync.test.ts +192 -0
  177. package/src/utils/hash.ts +5 -0
  178. package/src/utils/lockfile.ts +78 -0
  179. package/dist/os/core/handlers/forge-autonomy-validate.d.ts +0 -25
  180. package/dist/os/core/handlers/forge-autonomy-validate.d.ts.map +0 -1
  181. package/dist/os/core/handlers/forge-autonomy-validate.js +0 -208
  182. package/dist/os/core/handlers/forge-autonomy-validate.js.map +0 -1
  183. package/dist/os/mission/handlers/archive.d.ts +0 -4
  184. package/dist/os/mission/handlers/archive.d.ts.map +0 -1
  185. package/dist/os/mission/handlers/archive.js +0 -583
  186. package/dist/os/mission/handlers/archive.js.map +0 -1
  187. package/dist/os/mission/importer-block.d.ts +0 -19
  188. package/dist/os/mission/importer-block.d.ts.map +0 -1
  189. package/dist/os/mission/importer-block.js +0 -124
  190. package/dist/os/mission/importer-block.js.map +0 -1
  191. package/dist/os/mission/index.d.ts +0 -2
  192. package/dist/os/mission/index.d.ts.map +0 -1
  193. package/dist/os/mission/index.js +0 -15
  194. package/dist/os/mission/index.js.map +0 -1
  195. package/dist/os/mission/lockfile.d.ts.map +0 -1
  196. package/dist/os/mission/lockfile.js +0 -138
  197. package/dist/os/mission/lockfile.js.map +0 -1
  198. package/dist/os/mission/mission.module.d.ts +0 -3
  199. package/dist/os/mission/mission.module.d.ts.map +0 -1
  200. package/dist/os/mission/mission.module.js +0 -63
  201. package/dist/os/mission/mission.module.js.map +0 -1
  202. package/dist/os/mission/open-missions.d.ts.map +0 -1
  203. package/dist/os/mission/open-missions.js +0 -42
  204. package/dist/os/mission/open-missions.js.map +0 -1
  205. package/dist/os/mission/types.d.ts +0 -23
  206. package/dist/os/mission/types.d.ts.map +0 -1
  207. package/dist/os/mission/types.js +0 -19
  208. package/dist/os/mission/types.js.map +0 -1
  209. package/dist/os/werkstatt/handlers/lock.d.ts +0 -10
  210. package/dist/os/werkstatt/handlers/lock.d.ts.map +0 -1
  211. package/dist/os/werkstatt/handlers/lock.js +0 -153
  212. package/dist/os/werkstatt/handlers/lock.js.map +0 -1
  213. package/dist/os/werkstatt/handlers/schema.d.ts +0 -33
  214. package/dist/os/werkstatt/handlers/schema.d.ts.map +0 -1
  215. package/dist/os/werkstatt/handlers/schema.js +0 -42
  216. package/dist/os/werkstatt/handlers/schema.js.map +0 -1
  217. package/dist/os/werkstatt/handlers/werkstatt-lock-recover.d.ts +0 -15
  218. package/dist/os/werkstatt/handlers/werkstatt-lock-recover.d.ts.map +0 -1
  219. package/dist/os/werkstatt/handlers/werkstatt-lock-recover.js +0 -171
  220. package/dist/os/werkstatt/handlers/werkstatt-lock-recover.js.map +0 -1
  221. package/dist/os/werkstatt/handlers/werkstatt-lock-status.d.ts +0 -18
  222. package/dist/os/werkstatt/handlers/werkstatt-lock-status.d.ts.map +0 -1
  223. package/dist/os/werkstatt/handlers/werkstatt-lock-status.js +0 -51
  224. package/dist/os/werkstatt/handlers/werkstatt-lock-status.js.map +0 -1
  225. package/dist/os/werkstatt/handlers/werkstatt-operation-validate.d.ts +0 -11
  226. package/dist/os/werkstatt/handlers/werkstatt-operation-validate.d.ts.map +0 -1
  227. package/dist/os/werkstatt/handlers/werkstatt-operation-validate.js +0 -86
  228. package/dist/os/werkstatt/handlers/werkstatt-operation-validate.js.map +0 -1
  229. package/dist/os/werkstatt/handlers/workspace-deps.d.ts +0 -12
  230. package/dist/os/werkstatt/handlers/workspace-deps.d.ts.map +0 -1
  231. package/dist/os/werkstatt/handlers/workspace-deps.js +0 -42
  232. package/dist/os/werkstatt/handlers/workspace-deps.js.map +0 -1
  233. package/dist/os/werkstatt/index.d.ts +0 -7
  234. package/dist/os/werkstatt/index.d.ts.map +0 -1
  235. package/dist/os/werkstatt/index.js +0 -18
  236. package/dist/os/werkstatt/index.js.map +0 -1
  237. package/dist/os/werkstatt/werkstatt.module.d.ts +0 -3
  238. package/dist/os/werkstatt/werkstatt.module.d.ts.map +0 -1
  239. package/dist/os/werkstatt/werkstatt.module.js +0 -91
  240. package/dist/os/werkstatt/werkstatt.module.js.map +0 -1
  241. package/os/core/handlers/forge-autonomy-validate.ts +0 -276
  242. package/os/correctness/gate/trust-boundary-cx19.test.ts +0 -514
  243. package/os/mission/handlers/archive.test.ts +0 -764
  244. package/os/mission/handlers/archive.ts +0 -711
  245. package/os/mission/handlers/ship-inflight-degraded.test.ts +0 -105
  246. package/os/mission/importer-block.ts +0 -119
  247. package/os/mission/index.ts +0 -15
  248. package/os/mission/lockfile.ts +0 -152
  249. package/os/mission/mission.module.ts +0 -68
  250. package/os/mission/open-missions.ts +0 -50
  251. package/os/mission/types.ts +0 -42
  252. package/os/werkstatt/handlers/lock.ts +0 -168
  253. package/os/werkstatt/handlers/schema.ts +0 -47
  254. package/os/werkstatt/handlers/werkstatt-lock-recover.ts +0 -206
  255. package/os/werkstatt/handlers/werkstatt-lock-status.ts +0 -82
  256. package/os/werkstatt/handlers/werkstatt-operation-validate.ts +0 -112
  257. package/os/werkstatt/handlers/workspace-deps.ts +0 -56
  258. package/os/werkstatt/index.ts +0 -39
  259. package/os/werkstatt/werkstatt.module.ts +0 -95
  260. package/src/tests/doctor-autonomy.test.ts +0 -246
  261. package/src/tests/forge-autonomy-validate.test.ts +0 -159
  262. package/src/tests/werkstatt-lock.test.ts +0 -357
@@ -1,514 +0,0 @@
1
- /*
2
- RFC-1616 round-19 independent adversarial probes — candidate commit
3
- 338aa25c, exported tree.
4
-
5
- Every counterexample probe asserts the CONTRACT outcome (truthful
6
- result or explicit refusal) — it FAILS while its hole is live.
7
- Numbering continues from CX-165 (round 18).
8
-
9
- Round-19 findings:
10
-
11
- CX-166 — ignoreRuleSourcesProven (os/compass/handlers/
12
- compass-audit-handler.ts) proves only the STRUCTURAL exclude
13
- candidates: a linked-worktree metadir `commondir` file redirect —
14
- and a `.git/info/exclude` reachable only through it — is never
15
- checked, so `check-ignore` honors a session exclude the verifier
16
- never saw; and for a subdir cwd the real `.git` and every parent
17
- `.gitignore` escape the walk. filterLedgerEligiblePaths then marks
18
- a never-audited authored file ineligible → compass.audit.validate
19
- --strict passes.
20
-
21
- CX-167 — sessionIgnoreRulePaths walks only the passed cwd:
22
- gitIsClean/statusDirty/listDirtyPaths report clean on a dirty
23
- repo when the session-authored `.gitignore` sits in a parent dir
24
- of the workspaceRoot the helper was handed.
25
-
26
- CX-168 — getFileRevisionFromHistory (os/compass/handlers/
27
- git-revision.ts) collapses a refused judged read to revision 1:
28
- under a channel-wide refusal (planted include.path) every audited
29
- ledger entry reads `current=1` → not due → --strict validate goes
30
- green.
31
-
32
- CX-169 — pinnedGitAdd (os/mission/lockfile.ts) runs `git add` on
33
- cwd discovery with no GIT_DIR anchor and no `.git` indirection
34
- judgment: a `.git` swap between the judged `show` and the `add`
35
- repoints the mutation into a foreign repo's index while
36
- `staged:true` is reported; `info/attributes` filter.*.clean also
37
- execs inside the pinned spawn.
38
-
39
- CX-170 — ambient io.exec("git", …) evidence reads remain in
40
- system.outbox.scan, codebase.measure, archive-regen and
41
- core.module: GIT_DIR/GIT_INDEX_FILE env redirects or narrows the
42
- read and non-zero exits map to benign verdicts.
43
-
44
- CX-171 — isBare (os/flow/git.ts) maps a channel refusal to `false`
45
- and topologicalBare misclassifies path shapes: a bare repo whose
46
- gitdir sits under a `worktrees/`-named parent (or is literally
47
- named `.git`) refuses every judged read or pins core.bare=false →
48
- isBare reports non-bare → detectRepoKind's fs branch fabricates
49
- "exempt"/"ungoverned" from planted files (CX-162 via path shape).
50
- */
51
-
52
- import { execFileSync } from "node:child_process";
53
- import { cpSync, mkdirSync, mkdtempSync, renameSync, rmSync, writeFileSync } from "node:fs";
54
- import os from "node:os";
55
- import path from "node:path";
56
- import { afterEach, describe, expect, it } from "vitest";
57
-
58
- import { ambientIo } from "../../../src/utils/io.ts";
59
- import { verifierGit } from "../../../src/utils/verifier-git.ts";
60
- import { gitEvidence, isBare, statusDirty } from "../../flow/git.ts";
61
- import { detectRepoKind } from "../../flow/repo-kind.ts";
62
- import { runCompassAuditValidate } from "../../compass/handlers/compass-audit-handler.ts";
63
- import { gitAncestorOf, gitChangedFilesBetween, gitIsClean } from "../../program/discovery.ts";
64
- import { pruneMissionImportersFromLockfile } from "../../mission/lockfile.ts";
65
- import { getRevisionByPath, listDirtyPaths } from "../../compass/handlers/git-revision.ts";
66
- import { runSystemOutboxScan } from "../../system/handlers/system-outbox-scan.ts";
67
- import { runCodebaseMeasure } from "../../codebase/handlers/codebase-measure.ts";
68
- import { planInstall } from "../../flow/handlers/flow-install.ts";
69
- import {
70
- VALID_EDGES_YAML,
71
- VALID_PRODUCTS_YAML,
72
- VALID_SYSTEM_YAML,
73
- localMapFor,
74
- makeContext,
75
- makeProduct,
76
- makeSystemRepo,
77
- } from "../../system/tests/helpers.ts";
78
-
79
- const tmpdirs: string[] = [];
80
- afterEach(() => {
81
- while (tmpdirs.length > 0) rmSync(tmpdirs.pop()!, { recursive: true, force: true });
82
- });
83
-
84
- const git = (root: string, args: string[]) =>
85
- execFileSync("git", ["-C", root, ...args], { encoding: "utf8" }).trim();
86
-
87
- const mkRepo = () => {
88
- const root = mkdtempSync(path.join(os.tmpdir(), "cx19-"));
89
- tmpdirs.push(root);
90
- execFileSync("git", ["init", "-q", "-b", "main", root]);
91
- git(root, ["config", "user.email", "t@t"]);
92
- git(root, ["config", "user.name", "t"]);
93
- writeFileSync(path.join(root, "f.txt"), "v1\n");
94
- git(root, ["add", "f.txt"]);
95
- git(root, ["commit", "-qm", "c1"]);
96
- return root;
97
- };
98
-
99
- const mkBareRepo = (dest: string, seedFiles: Record<string, string>) => {
100
- const work = mkdtempSync(path.join(os.tmpdir(), "cx19-seed-"));
101
- tmpdirs.push(work);
102
- execFileSync("git", ["init", "-q", "-b", "develop", work]);
103
- git(work, ["config", "user.email", "t@t"]);
104
- git(work, ["config", "user.name", "t"]);
105
- for (const [rel, body] of Object.entries(seedFiles)) {
106
- const abs = path.join(work, rel);
107
- mkdirSync(path.dirname(abs), { recursive: true });
108
- writeFileSync(abs, body);
109
- git(work, ["add", rel]);
110
- }
111
- git(work, ["commit", "-qm", "seed"]);
112
- mkdirSync(path.dirname(dest), { recursive: true });
113
- execFileSync("git", ["init", "-q", "--bare", dest]);
114
- tmpdirs.push(dest);
115
- git(work, ["push", "-q", dest, "HEAD:refs/heads/develop"]);
116
- git(dest, ["symbolic-ref", "HEAD", "refs/heads/develop"]);
117
- return dest;
118
- };
119
-
120
- const GOVERNED = {
121
- "forge.yaml": "schema: forge/config@1\nproject:\n name: governed-fixture\n",
122
- };
123
-
124
- const mkCtx = (root: string) =>
125
- ({
126
- workspaceRoot: root,
127
- logger: {
128
- info: () => {},
129
- warn: () => {},
130
- error: () => {},
131
- success: () => {},
132
- section: () => {},
133
- },
134
- dryRun: false,
135
- outputFormat: "json",
136
- }) as never;
137
-
138
- /** include.path → refusedKeys → every judged read -1. */
139
- const plantConfigInclude = (gitDir: string, includeFile: string) => {
140
- writeFileSync(includeFile, "# session include\n");
141
- execFileSync("git", [
142
- "-C",
143
- gitDir,
144
- "config",
145
- "--file",
146
- path.join(gitDir, "config"),
147
- "--add",
148
- "include.path",
149
- includeFile,
150
- ]);
151
- };
152
-
153
- const AUTHORED = "src/audit-me.ts";
154
- const writeAuthoredFile = (root: string) => {
155
- mkdirSync(path.join(root, "src"), { recursive: true });
156
- writeFileSync(
157
- path.join(root, AUTHORED),
158
- "// <MODULE_CONTRACT>\n// purpose: authored fixture file\n// </MODULE_CONTRACT>\nexport const v = 1;\n",
159
- );
160
- };
161
-
162
- describe("CX-166 — ignoreRuleSourcesProven misses commondir redirect + subdir cwd", () => {
163
- it("control: an authored untracked file is audit-due under --strict", async () => {
164
- const root = mkRepo();
165
- writeAuthoredFile(root);
166
- const result = await runCompassAuditValidate(
167
- { argv: [], flags: { strict: true } },
168
- mkCtx(root),
169
- );
170
- expect(result.data?.dueCount).toBeGreaterThan(0);
171
- expect(result.exitCode).toBe(1);
172
- });
173
-
174
- it("a forged metadir commondir points info/exclude outside every scanned candidate", async () => {
175
- // Primary repo + real linked worktree.
176
- const main = mkRepo();
177
- const wt = path.join(main, "wt1");
178
- git(main, ["worktree", "add", wt, "-b", "auto/x"]);
179
- writeAuthoredFile(wt);
180
- // Evil common dir: a full gitdir whose info/exclude hides the file.
181
- const evil = mkdtempSync(path.join(os.tmpdir(), "cx19-evil-"));
182
- tmpdirs.push(evil);
183
- cpSync(path.join(main, ".git"), evil, { recursive: true });
184
- mkdirSync(path.join(evil, "info"), { recursive: true });
185
- writeFileSync(path.join(evil, "info", "exclude"), "src/**\n");
186
- // The metadir (<main>/.git/worktrees/wt1) is session-writable .git
187
- // state — rewrite its commondir to the forged common dir.
188
- const meta = path.join(main, ".git", "worktrees", path.basename(wt));
189
- writeFileSync(path.join(meta, "commondir"), `${evil}\n`);
190
- // Sanity: ambient check-ignore in wt honors the forged common exclude.
191
- const ci = execFileSync("git", ["-C", wt, "check-ignore", "-v", AUTHORED], {
192
- encoding: "utf8",
193
- stdio: ["ignore", "pipe", "ignore"],
194
- });
195
- expect(ci).toContain("info/exclude");
196
- // The judged channel correctly refuses the forged indirection — but
197
- // ignoreRuleSourcesProven never consults it when no .gitignore exists.
198
- const judged = await verifierGit(wt, ["status", "--porcelain"]);
199
- expect(judged.exitCode).toBe(-1);
200
- const result = await runCompassAuditValidate({ argv: [], flags: { strict: true } }, mkCtx(wt));
201
- const suppressed =
202
- result.exitCode === 0 &&
203
- !(result.data?.diagnostics ?? []).some(
204
- (d: { ruleId: string }) => d.ruleId === "COMPASS-AUDIT-01",
205
- );
206
- // Contract: an unproven ignore source must not narrow the ledger
207
- // set — expected COMPASS-AUDIT-01 (or an unverifiable verdict),
208
- // never a silent skip + pass.
209
- expect(suppressed).toBe(false);
210
- });
211
-
212
- it("a .git/info/exclude reachable from a subdir cwd is never proven — payload hidden, gate passes", async () => {
213
- const root = mkRepo();
214
- const sub = path.join(root, "pkg");
215
- mkdirSync(sub, { recursive: true });
216
- writeAuthoredFile(sub); // pkg/src/audit-me.ts
217
- mkdirSync(path.join(root, ".git", "info"), { recursive: true });
218
- writeFileSync(path.join(root, ".git", "info", "exclude"), "pkg/**\n");
219
- const result = await runCompassAuditValidate({ argv: [], flags: { strict: true } }, mkCtx(sub));
220
- const suppressed =
221
- result.exitCode === 0 &&
222
- !(result.data?.diagnostics ?? []).some(
223
- (d: { ruleId: string }) => d.ruleId === "COMPASS-AUDIT-01",
224
- );
225
- expect(suppressed).toBe(false);
226
- });
227
- });
228
-
229
- describe("CX-167 — sessionIgnoreRulePaths misses parent-scope .gitignore rules", () => {
230
- it("gitIsClean reports clean from a subdir while a parent rule hides payloads", async () => {
231
- const root = mkRepo();
232
- const sub = path.join(root, "work");
233
- mkdirSync(sub, { recursive: true });
234
- // Untracked session rule at repo root: self-hides AND hides payload.
235
- writeFileSync(path.join(root, ".gitignore"), "*\n");
236
- writeFileSync(path.join(sub, "payload.ts"), "export const p = 1;\n");
237
- // Sanity: judged status from the subdir surfaces the ignored rule
238
- // file — porcelain paths are repository-root-relative (CX-167).
239
- const st = await verifierGit(sub, ["status", "--porcelain"]);
240
- expect(st.exitCode).toBe(0);
241
- expect(st.stdout).toContain("!! .gitignore");
242
- // Contract: dirty evidence must be truthful or refused — never
243
- // "clean".
244
- expect(await gitIsClean(sub)).toBe(false);
245
- const dirty = await statusDirty(sub, ambientIo);
246
- expect(dirty.entries.length).toBeGreaterThan(0);
247
- const listed = await listDirtyPaths(sub);
248
- expect(listed.paths === null || listed.paths.length > 0).toBe(true);
249
- });
250
- });
251
-
252
- describe("CX-168 — refused history read collapses to revision 1 inside the audit gate", () => {
253
- it("a dead channel suppresses every audited entry under --strict", async () => {
254
- const root = mkRepo();
255
- writeAuthoredFile(root);
256
- git(root, ["add", AUTHORED]);
257
- git(root, ["commit", "-qm", "authored"]);
258
- // Ledger: audited at revision 5, threshold 2.
259
- mkdirSync(path.join(root, "docs"), { recursive: true });
260
- writeFileSync(
261
- path.join(root, "docs", "compass-audit-ledger.generated.yaml"),
262
- [
263
- "revisionThreshold: 2",
264
- "entries:",
265
- ` - path: ${AUTHORED}`,
266
- " entityId: e1",
267
- " auditedRevision: 5",
268
- " auditedHash: sha256-x",
269
- " auditedAt: '2026-01-01T00:00:00Z'",
270
- " verdict: pass",
271
- " agent: human:t",
272
- "",
273
- ].join("\n"),
274
- );
275
- // Refuse every judged read: include.path is a refusedKeys entry.
276
- plantConfigInclude(path.join(root, ".git"), path.join(root, "session-include.cfg"));
277
- const probe = await verifierGit(root, ["status", "--porcelain"]);
278
- expect(probe.exitCode).toBe(-1);
279
- const result = await runCompassAuditValidate(
280
- { argv: [], flags: { strict: true } },
281
- mkCtx(root),
282
- );
283
- // Contract: unverifiable revision evidence must fail closed —
284
- // never a clean pass built on fabricated revision:1 answers.
285
- expect(result.exitCode).not.toBe(0);
286
- });
287
-
288
- it("getRevisionByPath itself reports a fabricated revision on refusal", async () => {
289
- const root = mkRepo();
290
- writeAuthoredFile(root);
291
- git(root, ["add", AUTHORED]);
292
- git(root, ["commit", "-qm", "authored"]);
293
- plantConfigInclude(path.join(root, ".git"), path.join(root, "session-include.cfg"));
294
- const rev = await getRevisionByPath(root, AUTHORED);
295
- // Contract: revision evidence is truthful or unverifiable — never
296
- // 1 on refusal.
297
- expect(rev.revision).not.toBe(1);
298
- });
299
- });
300
-
301
- describe("CX-169 — pinnedGitAdd repoints the staged mutation after a .git swap", () => {
302
- const LOCKFILE = [
303
- "lockfileVersion: '9.0'",
304
- "",
305
- "importers:",
306
- "",
307
- " .:",
308
- " devDependencies: {}",
309
- "",
310
- " missions/m1/workpiece:",
311
- " devDependencies: {}",
312
- "",
313
- ].join("\n");
314
-
315
- it("a .git flip between judged show and add stages into a foreign repo; staged:true lies", async () => {
316
- const real = mkRepo();
317
- const evil = mkRepo();
318
- writeFileSync(path.join(real, "pnpm-lock.yaml"), LOCKFILE);
319
- git(real, ["add", "pnpm-lock.yaml"]);
320
- git(real, ["commit", "-qm", "lockfile"]);
321
- const evilIndexBefore = git(evil, ["ls-files", "-s"]);
322
- // Move the real .git aside mid-call via the io.writeFile seam — the
323
- // session's deterministic interleaving point between judged read
324
- // and add.
325
- const io = {
326
- exec: ambientIo.exec,
327
- writeFile: async (target: string, content: string) => {
328
- renameSync(path.join(real, ".git"), path.join(real, ".git-real"));
329
- writeFileSync(path.join(real, ".git"), `gitdir: ${path.join(evil, ".git")}\n`);
330
- writeFileSync(target, content);
331
- },
332
- };
333
- const outcome = await pruneMissionImportersFromLockfile(real, ["m1"], io as never);
334
- // Restore the real .git for assertions.
335
- rmSync(path.join(real, ".git"));
336
- renameSync(path.join(real, ".git-real"), path.join(real, ".git"));
337
- // Contract: staged:true must mean the JUDGED repo's index carries
338
- // the pruned bytes — a foreign-index landing is fabricated staging.
339
- if (outcome.staged) {
340
- const realIndex = git(real, ["ls-files", "-s", "pnpm-lock.yaml"]);
341
- const realHeadBlob = git(real, ["rev-parse", "HEAD:pnpm-lock.yaml"]);
342
- expect(realIndex).not.toContain(realHeadBlob);
343
- const evilIndexAfter = git(evil, ["ls-files", "-s"]);
344
- expect(evilIndexAfter).toBe(evilIndexBefore);
345
- }
346
- });
347
-
348
- it("info/attributes filter.*.clean must never rewrite staged bytes inside the pinned add", async () => {
349
- const real = mkRepo();
350
- const prog = path.join(real, "evil-clean.sh");
351
- writeFileSync(prog, "#!/bin/sh\necho FORGED-BYTES\n");
352
- execFileSync("chmod", ["+x", prog]);
353
- mkdirSync(path.join(real, ".git", "info"), { recursive: true });
354
- writeFileSync(path.join(real, ".git", "info", "attributes"), "pnpm-lock.yaml filter=evil\n");
355
- git(real, ["config", "filter.evil.clean", prog]);
356
- writeFileSync(path.join(real, "pnpm-lock.yaml"), LOCKFILE);
357
- git(real, ["add", "pnpm-lock.yaml"]);
358
- git(real, ["commit", "-qm", "lockfile"]);
359
- const outcome = await pruneMissionImportersFromLockfile(real, ["m1"], {
360
- exec: ambientIo.exec,
361
- writeFile: ambientIo.writeFile,
362
- } as never);
363
- if (outcome.staged) {
364
- const stagedBlob = git(real, ["show", ":pnpm-lock.yaml"]);
365
- // Contract: the staged bytes must be the file the helper wrote —
366
- // a filter-program rewrite inside the pinned mutation is
367
- // fabrication.
368
- expect(stagedBlob).not.toContain("FORGED-BYTES");
369
- }
370
- });
371
- });
372
-
373
- describe("CX-170 — ambient io.exec git reads inherit the session environment", () => {
374
- const OUTBOX_ENTRY = `schema: forge/outbox@1
375
- id: OB-9001
376
- contract: alpha-contract
377
- need: "a stable surface"
378
- why: "forged entry"
379
- state: open
380
- `;
381
-
382
- it("system.outbox.scan: GIT_DIR forges a product's committed outbox entries", async () => {
383
- const alpha = await makeProduct();
384
- const beta = await makeProduct();
385
- const systemRoot = await makeSystemRepo({
386
- "system/system.yaml": VALID_SYSTEM_YAML,
387
- "system/products.yaml": VALID_PRODUCTS_YAML,
388
- "system/edges.yaml": VALID_EDGES_YAML,
389
- "system/products.local.yaml": localMapFor({ alpha, beta }),
390
- });
391
- // Clean scan: no product carries committed outbox entries — nothing
392
- // may be created.
393
- const clean = await runSystemOutboxScan(
394
- { argv: [], flags: { create: true } },
395
- makeContext(systemRoot),
396
- );
397
- expect(clean.data?.created ?? []).toEqual([]);
398
- // Evil repo: a forged outbox entry at develop:docs/outbox/.
399
- const evil = mkRepo();
400
- mkdirSync(path.join(evil, "docs", "outbox"), { recursive: true });
401
- writeFileSync(path.join(evil, "docs", "outbox", "OB-9001.yaml"), OUTBOX_ENTRY);
402
- writeFileSync(path.join(evil, "forge.yaml"), 'schema: "forge/workspace@1"\n');
403
- git(evil, ["add", "."]);
404
- git(evil, ["commit", "-qm", "evil"]);
405
- git(evil, ["branch", "develop"]);
406
- const prev = process.env.GIT_DIR;
407
- process.env.GIT_DIR = path.join(evil, ".git");
408
- try {
409
- const forged = await runSystemOutboxScan(
410
- { argv: [], flags: { create: true } },
411
- makeContext(systemRoot),
412
- );
413
- // Contract: tasks derive only from the PRODUCT's own develop —
414
- // a session GIT_DIR redirect must never author them.
415
- expect(forged.data?.created ?? []).toEqual([]);
416
- } finally {
417
- if (prev === undefined) delete process.env.GIT_DIR;
418
- else process.env.GIT_DIR = prev;
419
- }
420
- });
421
-
422
- it("codebase.measure: GIT_INDEX_FILE narrows the measured file set", async () => {
423
- const root = mkRepo();
424
- writeFileSync(path.join(root, "src.ts"), "export const a = 1;\n");
425
- git(root, ["add", "src.ts"]);
426
- git(root, ["commit", "-qm", "src"]);
427
- const realTotal = 2; // f.txt + src.ts
428
- // Curated foreign index: a repo missing src.ts.
429
- const evil = mkRepo();
430
- const prev = process.env.GIT_INDEX_FILE;
431
- process.env.GIT_INDEX_FILE = path.join(evil, ".git", "index");
432
- try {
433
- const result = await runCodebaseMeasure({ argv: [], flags: {} }, mkCtx(root));
434
- const measured = Object.values(
435
- (result.data as { totals?: Record<string, { files: number }> } | undefined)?.totals ?? {},
436
- ).reduce((sum, t) => sum + t.files, 0);
437
- // Contract: the measured set is the repo's real tracked set or
438
- // an explicit failure — never a session-narrowed index.
439
- expect(measured).toBeGreaterThanOrEqual(realTotal);
440
- } finally {
441
- if (prev === undefined) delete process.env.GIT_INDEX_FILE;
442
- else process.env.GIT_INDEX_FILE = prev;
443
- }
444
- });
445
- });
446
-
447
- describe("CX-171 — isBare refusal→false + topological path misclassification", () => {
448
- it("a bare repo under a worktrees/-named parent reports non-bare then exempt", async () => {
449
- const base = mkdtempSync(path.join(os.tmpdir(), "cx19-wtp-"));
450
- tmpdirs.push(base);
451
- const bare = mkBareRepo(path.join(base, "worktrees", "x"), GOVERNED);
452
- const ambient = git(bare, ["rev-parse", "--is-bare-repository"]);
453
- expect(ambient).toBe("true");
454
- const judged = await gitEvidence(bare, ["rev-parse", "--is-bare-repository"]);
455
- // Contract: truthful output or explicit refusal — never a
456
- // fabricated "false" that detectRepoKind maps into the filesystem
457
- // branch.
458
- expect(judged.exitCode === 0 ? judged.stdout.trim() : "-1").not.toBe("false");
459
- expect(await isBare(bare, ambientIo)).toBe(true);
460
- });
461
-
462
- it("a bare repo literally named .git answers non-bare through the channel", async () => {
463
- const base = mkdtempSync(path.join(os.tmpdir(), "cx19-dotgit-"));
464
- tmpdirs.push(base);
465
- const bare = mkBareRepo(path.join(base, ".git"), GOVERNED);
466
- const ambient = git(bare, ["rev-parse", "--is-bare-repository"]);
467
- expect(ambient).toBe("true");
468
- const judged = await gitEvidence(bare, ["rev-parse", "--is-bare-repository"]);
469
- expect(judged.exitCode === 0 ? judged.stdout.trim() : "-1").not.toBe("false");
470
- expect(await isBare(bare, ambientIo)).toBe(true);
471
- });
472
-
473
- it("detectRepoKind on a misclassified bare repo fabricates exempt from a planted marker", async () => {
474
- const base = mkdtempSync(path.join(os.tmpdir(), "cx19-wtp2-"));
475
- tmpdirs.push(base);
476
- const bare = mkBareRepo(path.join(base, "worktrees", "x"), GOVERNED);
477
- writeFileSync(
478
- path.join(bare, "forge.generated.yaml"),
479
- "schema: forge/generated@1\ngenerator: session\nsource: session\n",
480
- );
481
- const detection = await detectRepoKind(bare, ambientIo);
482
- // Contract: repo identity must come from committed evidence or be
483
- // unverifiable — a planted file inside a bare dir is not an
484
- // exemption.
485
- expect(detection.ok && detection.repoKind.kind === "exempt").toBe(false);
486
- });
487
-
488
- it("hold: a governed bare repo on a normal path is refused at install plan, before any write", async () => {
489
- const bare = mkBareRepo(
490
- path.join(mkdtempSync(path.join(os.tmpdir(), "cx19-b-")), "repo.git"),
491
- GOVERNED,
492
- );
493
- const plan = await planInstall(bare, ambientIo);
494
- expect(plan.refusal?.ruleId).toBe("FLOW-ADOPT-05");
495
- expect(plan.steps.some((s) => s.status === "done" && s.step === "detect")).toBe(true);
496
- });
497
- });
498
-
499
- describe("holds — r18 closures re-probed", () => {
500
- it("HOLD: refused diff is unverifiable, never an empty change set", async () => {
501
- const root = mkRepo();
502
- const sha = git(root, ["rev-parse", "HEAD"]);
503
- plantConfigInclude(path.join(root, ".git"), path.join(root, "session-include.cfg"));
504
- const changed = await gitChangedFilesBetween(root, sha, sha);
505
- expect(changed).toBe(null);
506
- });
507
-
508
- it("HOLD: gitAncestorOf refusal maps to false (fail-closed at callers)", async () => {
509
- const root = mkRepo();
510
- const sha = git(root, ["rev-parse", "HEAD"]);
511
- plantConfigInclude(path.join(root, ".git"), path.join(root, "session-include.cfg"));
512
- expect(await gitAncestorOf(root, sha, sha)).toBe(false);
513
- });
514
- });