clinkx 1.2.0 → 1.3.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 (270) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/README.md +4 -2
  3. package/clinkx-workflows/dist/architecture-arena/admission.d.ts +16 -0
  4. package/clinkx-workflows/dist/architecture-arena/admission.js +107 -0
  5. package/clinkx-workflows/dist/architecture-arena/admission.js.map +1 -0
  6. package/clinkx-workflows/dist/architecture-arena/contract.d.ts +1368 -0
  7. package/clinkx-workflows/dist/architecture-arena/contract.js +254 -0
  8. package/clinkx-workflows/dist/architecture-arena/contract.js.map +1 -0
  9. package/clinkx-workflows/dist/architecture-arena/runtime.d.ts +53 -0
  10. package/clinkx-workflows/dist/architecture-arena/runtime.js +511 -0
  11. package/clinkx-workflows/dist/architecture-arena/runtime.js.map +1 -0
  12. package/clinkx-workflows/dist/architecture-comparison/admission.d.ts +17 -1
  13. package/clinkx-workflows/dist/architecture-comparison/admission.js +27 -4
  14. package/clinkx-workflows/dist/architecture-comparison/admission.js.map +1 -1
  15. package/clinkx-workflows/dist/architecture-comparison/contract.d.ts +59 -62
  16. package/clinkx-workflows/dist/architecture-comparison/contract.js +4 -21
  17. package/clinkx-workflows/dist/architecture-comparison/contract.js.map +1 -1
  18. package/clinkx-workflows/dist/architecture-comparison/runtime.d.ts +4 -3
  19. package/clinkx-workflows/dist/architecture-comparison/runtime.js +22 -67
  20. package/clinkx-workflows/dist/architecture-comparison/runtime.js.map +1 -1
  21. package/clinkx-workflows/dist/artifacts.d.ts +19 -4
  22. package/clinkx-workflows/dist/artifacts.js +16 -7
  23. package/clinkx-workflows/dist/artifacts.js.map +1 -1
  24. package/clinkx-workflows/dist/backend.d.ts +30 -0
  25. package/clinkx-workflows/dist/clink-client.d.ts +8 -2
  26. package/clinkx-workflows/dist/clink-client.js +4 -2
  27. package/clinkx-workflows/dist/clink-client.js.map +1 -1
  28. package/clinkx-workflows/dist/context-preflight.d.ts +6 -0
  29. package/clinkx-workflows/dist/context-preflight.js.map +1 -1
  30. package/clinkx-workflows/dist/council-execution-policy.d.ts +3 -1
  31. package/clinkx-workflows/dist/council-execution-policy.js +4 -0
  32. package/clinkx-workflows/dist/council-execution-policy.js.map +1 -1
  33. package/clinkx-workflows/dist/dashboard/contracts.d.ts +586 -586
  34. package/clinkx-workflows/dist/dashboard/progress-report-contract.d.ts +28 -28
  35. package/clinkx-workflows/dist/dashboard/session-log-contract.d.ts +32 -32
  36. package/clinkx-workflows/dist/dashboard-ui/assets/index-DRId2DVA.js +119 -0
  37. package/clinkx-workflows/dist/dashboard-ui/assets/style-CHAw57y5.css +1 -0
  38. package/clinkx-workflows/dist/dashboard-ui/index.html +2 -2
  39. package/clinkx-workflows/dist/delegate-signature.d.ts +4 -3
  40. package/clinkx-workflows/dist/delegate-signature.js +4 -3
  41. package/clinkx-workflows/dist/delegate-signature.js.map +1 -1
  42. package/clinkx-workflows/dist/durable-file.d.ts +69 -0
  43. package/clinkx-workflows/dist/durable-file.js +145 -0
  44. package/clinkx-workflows/dist/durable-file.js.map +1 -0
  45. package/clinkx-workflows/dist/engine.d.ts +42 -7
  46. package/clinkx-workflows/dist/engine.js +196 -24
  47. package/clinkx-workflows/dist/engine.js.map +1 -1
  48. package/clinkx-workflows/dist/ping-pong/admission.d.ts +127 -0
  49. package/clinkx-workflows/dist/ping-pong/admission.js +522 -0
  50. package/clinkx-workflows/dist/ping-pong/admission.js.map +1 -0
  51. package/clinkx-workflows/dist/ping-pong/contract.d.ts +2539 -0
  52. package/clinkx-workflows/dist/ping-pong/contract.js +819 -0
  53. package/clinkx-workflows/dist/ping-pong/contract.js.map +1 -0
  54. package/clinkx-workflows/dist/ping-pong/control.d.ts +67 -0
  55. package/clinkx-workflows/dist/ping-pong/control.js +12 -0
  56. package/clinkx-workflows/dist/ping-pong/control.js.map +1 -0
  57. package/clinkx-workflows/dist/ping-pong/runtime-handle.d.ts +24 -0
  58. package/clinkx-workflows/dist/ping-pong/runtime-handle.js +55 -0
  59. package/clinkx-workflows/dist/ping-pong/runtime-handle.js.map +1 -0
  60. package/clinkx-workflows/dist/ping-pong/runtime.d.ts +235 -0
  61. package/clinkx-workflows/dist/ping-pong/runtime.js +1183 -0
  62. package/clinkx-workflows/dist/ping-pong/runtime.js.map +1 -0
  63. package/clinkx-workflows/dist/ping-pong/settle.d.ts +57 -0
  64. package/clinkx-workflows/dist/ping-pong/settle.js +58 -0
  65. package/clinkx-workflows/dist/ping-pong/settle.js.map +1 -0
  66. package/clinkx-workflows/dist/ping-pong/sidecar.d.ts +65 -0
  67. package/clinkx-workflows/dist/ping-pong/sidecar.js +138 -0
  68. package/clinkx-workflows/dist/ping-pong/sidecar.js.map +1 -0
  69. package/clinkx-workflows/dist/plan-review/publication.d.ts +2 -1
  70. package/clinkx-workflows/dist/plan-review/publication.js +5 -6
  71. package/clinkx-workflows/dist/plan-review/publication.js.map +1 -1
  72. package/clinkx-workflows/dist/plan-review/snapshot.d.ts +3 -2
  73. package/clinkx-workflows/dist/plan-review/snapshot.js +8 -8
  74. package/clinkx-workflows/dist/plan-review/snapshot.js.map +1 -1
  75. package/clinkx-workflows/dist/recipe-host.d.ts +315 -0
  76. package/clinkx-workflows/dist/recipe-host.js +183 -0
  77. package/clinkx-workflows/dist/recipe-host.js.map +1 -0
  78. package/clinkx-workflows/dist/recipe-seats.d.ts +96 -0
  79. package/clinkx-workflows/dist/recipe-seats.js +163 -0
  80. package/clinkx-workflows/dist/recipe-seats.js.map +1 -0
  81. package/clinkx-workflows/dist/recipe-shared/evidence.d.ts +67 -0
  82. package/clinkx-workflows/dist/recipe-shared/evidence.js +111 -0
  83. package/clinkx-workflows/dist/recipe-shared/evidence.js.map +1 -0
  84. package/clinkx-workflows/dist/reducers/index.d.ts +9 -1
  85. package/clinkx-workflows/dist/reducers/index.js +30 -0
  86. package/clinkx-workflows/dist/reducers/index.js.map +1 -1
  87. package/clinkx-workflows/dist/run-lock-reclaim.d.ts +44 -0
  88. package/clinkx-workflows/dist/run-lock-reclaim.js +86 -0
  89. package/clinkx-workflows/dist/run-lock-reclaim.js.map +1 -0
  90. package/clinkx-workflows/dist/state-schema.d.ts +11 -0
  91. package/clinkx-workflows/dist/state-schema.js +4 -1
  92. package/clinkx-workflows/dist/state-schema.js.map +1 -1
  93. package/clinkx-workflows/dist/state.d.ts +178 -3
  94. package/clinkx-workflows/dist/state.js +618 -83
  95. package/clinkx-workflows/dist/state.js.map +1 -1
  96. package/clinkx-workflows/dist/transport.d.ts +2 -1
  97. package/clinkx-workflows/dist/transport.js +5 -0
  98. package/clinkx-workflows/dist/transport.js.map +1 -1
  99. package/clinkx-workflows/dist/validators/architecture-arena.d.ts +6 -0
  100. package/clinkx-workflows/dist/validators/architecture-arena.js +16 -0
  101. package/clinkx-workflows/dist/validators/architecture-arena.js.map +1 -0
  102. package/clinkx-workflows/dist/validators/index.js +4 -0
  103. package/clinkx-workflows/dist/validators/index.js.map +1 -1
  104. package/clinkx-workflows/dist/validators/ping-pong.d.ts +6 -0
  105. package/clinkx-workflows/dist/validators/ping-pong.js +10 -0
  106. package/clinkx-workflows/dist/validators/ping-pong.js.map +1 -0
  107. package/clinkx-workflows/dist/workflow-tools.d.ts +51 -5
  108. package/clinkx-workflows/dist/workflow-tools.js +785 -34
  109. package/clinkx-workflows/dist/workflow-tools.js.map +1 -1
  110. package/clinkx-workflows/dist/workflow-verification-contract.d.ts +4 -4
  111. package/clinkx-workflows/templates/architecture-arena/candidate.txt +39 -0
  112. package/clinkx-workflows/templates/architecture-arena/judge.txt +34 -0
  113. package/clinkx-workflows/templates/ping-pong/implement.txt +14 -0
  114. package/clinkx-workflows/templates/ping-pong/remediate.txt +14 -0
  115. package/clinkx-workflows/templates/ping-pong/review.txt +27 -0
  116. package/clinkx-workflows/workflows/architecture-arena.yaml +127 -0
  117. package/clinkx-workflows/workflows/ping-pong.yaml +158 -0
  118. package/dist/context-builder/bundle.js +4 -3
  119. package/dist/context-builder/bundle.js.map +1 -1
  120. package/dist/context-builder/delegate-packet.d.ts +1 -0
  121. package/dist/context-builder/delegate-packet.js +66 -7
  122. package/dist/context-builder/delegate-packet.js.map +1 -1
  123. package/dist/context-builder/delegate-validation.d.ts +12 -3
  124. package/dist/context-builder/delegate-validation.js +23 -13
  125. package/dist/context-builder/delegate-validation.js.map +1 -1
  126. package/dist/context-builder/external-gaps.d.ts +14 -3
  127. package/dist/context-builder/external-gaps.js +124 -18
  128. package/dist/context-builder/external-gaps.js.map +1 -1
  129. package/dist/context-builder/handler.js +108 -191
  130. package/dist/context-builder/handler.js.map +1 -1
  131. package/dist/context-builder/review-coverage.js +27 -1
  132. package/dist/context-builder/review-coverage.js.map +1 -1
  133. package/dist/context-builder/secrets.js +1 -1
  134. package/dist/context-builder/secrets.js.map +1 -1
  135. package/dist/context-builder/versions.d.ts +10 -4
  136. package/dist/context-builder/versions.js +10 -4
  137. package/dist/context-builder/versions.js.map +1 -1
  138. package/dist/context-builder/workflow-runner.js +33 -24
  139. package/dist/context-builder/workflow-runner.js.map +1 -1
  140. package/dist/dashboard-cli.d.ts +2 -0
  141. package/dist/dashboard-cli.js +147 -57
  142. package/dist/dashboard-cli.js.map +1 -1
  143. package/dist/dashboard-companion/client.d.ts +10 -0
  144. package/dist/dashboard-companion/client.js +43 -1
  145. package/dist/dashboard-companion/client.js.map +1 -1
  146. package/dist/dashboard-companion/config.d.ts +19 -1
  147. package/dist/dashboard-companion/config.js +104 -3
  148. package/dist/dashboard-companion/config.js.map +1 -1
  149. package/dist/dashboard-companion/protocol.d.ts +16 -0
  150. package/dist/dashboard-companion/protocol.js +38 -1
  151. package/dist/dashboard-companion/protocol.js.map +1 -1
  152. package/dist/dashboard-companion/workstation-binding.d.ts +69 -0
  153. package/dist/dashboard-companion/workstation-binding.js +192 -0
  154. package/dist/dashboard-companion/workstation-binding.js.map +1 -0
  155. package/dist/dashboard-gateway/admin-cli.d.ts +10 -0
  156. package/dist/dashboard-gateway/admin-cli.js +266 -0
  157. package/dist/dashboard-gateway/admin-cli.js.map +1 -0
  158. package/dist/dashboard-gateway/config.d.ts +50 -0
  159. package/dist/dashboard-gateway/config.js +235 -1
  160. package/dist/dashboard-gateway/config.js.map +1 -1
  161. package/dist/dashboard-gateway/connection-registry.d.ts +100 -0
  162. package/dist/dashboard-gateway/connection-registry.js +228 -0
  163. package/dist/dashboard-gateway/connection-registry.js.map +1 -0
  164. package/dist/dashboard-gateway/control-plane/account-auth.d.ts +78 -0
  165. package/dist/dashboard-gateway/control-plane/account-auth.js +198 -0
  166. package/dist/dashboard-gateway/control-plane/account-auth.js.map +1 -0
  167. package/dist/dashboard-gateway/control-plane/billing.d.ts +264 -0
  168. package/dist/dashboard-gateway/control-plane/billing.js +787 -0
  169. package/dist/dashboard-gateway/control-plane/billing.js.map +1 -0
  170. package/dist/dashboard-gateway/control-plane/contracts.d.ts +1293 -0
  171. package/dist/dashboard-gateway/control-plane/contracts.js +280 -0
  172. package/dist/dashboard-gateway/control-plane/contracts.js.map +1 -0
  173. package/dist/dashboard-gateway/control-plane/cookies.d.ts +13 -0
  174. package/dist/dashboard-gateway/control-plane/cookies.js +46 -0
  175. package/dist/dashboard-gateway/control-plane/cookies.js.map +1 -0
  176. package/dist/dashboard-gateway/control-plane/credentials.d.ts +63 -0
  177. package/dist/dashboard-gateway/control-plane/credentials.js +66 -0
  178. package/dist/dashboard-gateway/control-plane/credentials.js.map +1 -0
  179. package/dist/dashboard-gateway/control-plane/entitlements.d.ts +118 -0
  180. package/dist/dashboard-gateway/control-plane/entitlements.js +329 -0
  181. package/dist/dashboard-gateway/control-plane/entitlements.js.map +1 -0
  182. package/dist/dashboard-gateway/control-plane/errors.d.ts +17 -0
  183. package/dist/dashboard-gateway/control-plane/errors.js +23 -0
  184. package/dist/dashboard-gateway/control-plane/errors.js.map +1 -0
  185. package/dist/dashboard-gateway/control-plane/hosts.d.ts +6 -0
  186. package/dist/dashboard-gateway/control-plane/hosts.js +16 -0
  187. package/dist/dashboard-gateway/control-plane/hosts.js.map +1 -0
  188. package/dist/dashboard-gateway/control-plane/http.d.ts +34 -0
  189. package/dist/dashboard-gateway/control-plane/http.js +331 -0
  190. package/dist/dashboard-gateway/control-plane/http.js.map +1 -0
  191. package/dist/dashboard-gateway/control-plane/schema.d.ts +9 -0
  192. package/dist/dashboard-gateway/control-plane/schema.js +247 -0
  193. package/dist/dashboard-gateway/control-plane/schema.js.map +1 -0
  194. package/dist/dashboard-gateway/control-plane/secrets.d.ts +20 -0
  195. package/dist/dashboard-gateway/control-plane/secrets.js +39 -0
  196. package/dist/dashboard-gateway/control-plane/secrets.js.map +1 -0
  197. package/dist/dashboard-gateway/control-plane/store.d.ts +579 -0
  198. package/dist/dashboard-gateway/control-plane/store.js +1115 -0
  199. package/dist/dashboard-gateway/control-plane/store.js.map +1 -0
  200. package/dist/dashboard-gateway/cookie-boundary.d.ts +60 -0
  201. package/dist/dashboard-gateway/cookie-boundary.js +205 -0
  202. package/dist/dashboard-gateway/cookie-boundary.js.map +1 -0
  203. package/dist/dashboard-gateway/index.js +271 -494
  204. package/dist/dashboard-gateway/index.js.map +1 -1
  205. package/dist/dashboard-gateway/main.js +7 -2
  206. package/dist/dashboard-gateway/main.js.map +1 -1
  207. package/dist/dashboard-gateway/routing.d.ts +43 -0
  208. package/dist/dashboard-gateway/routing.js +65 -0
  209. package/dist/dashboard-gateway/routing.js.map +1 -0
  210. package/dist/dashboard-gateway/tenant-gateway.d.ts +56 -0
  211. package/dist/dashboard-gateway/tenant-gateway.js +989 -0
  212. package/dist/dashboard-gateway/tenant-gateway.js.map +1 -0
  213. package/dist/dashboard-gateway/tenant-main.d.ts +41 -0
  214. package/dist/dashboard-gateway/tenant-main.js +303 -0
  215. package/dist/dashboard-gateway/tenant-main.js.map +1 -0
  216. package/dist/dashboard-gateway/tunnel-errors.d.ts +16 -0
  217. package/dist/dashboard-gateway/tunnel-errors.js +22 -0
  218. package/dist/dashboard-gateway/tunnel-errors.js.map +1 -0
  219. package/dist/dashboard-gateway/tunnel-http.d.ts +21 -0
  220. package/dist/dashboard-gateway/tunnel-http.js +175 -0
  221. package/dist/dashboard-gateway/tunnel-http.js.map +1 -0
  222. package/dist/handler.d.ts +6 -0
  223. package/dist/handler.js +17 -1
  224. package/dist/handler.js.map +1 -1
  225. package/dist/local-clink-backend.d.ts +2 -1
  226. package/dist/local-clink-backend.js +28 -4
  227. package/dist/local-clink-backend.js.map +1 -1
  228. package/dist/parsers/extract.d.ts +19 -1
  229. package/dist/parsers/extract.js +68 -3
  230. package/dist/parsers/extract.js.map +1 -1
  231. package/dist/pipeline.d.ts +17 -1
  232. package/dist/pipeline.js +34 -6
  233. package/dist/pipeline.js.map +1 -1
  234. package/dist/process-group.d.ts +65 -0
  235. package/dist/process-group.js +153 -0
  236. package/dist/process-group.js.map +1 -0
  237. package/dist/progress-report/schema.d.ts +23 -23
  238. package/dist/project-verification/files.js +1 -1
  239. package/dist/project-verification/files.js.map +1 -1
  240. package/dist/project-verification/process.js +23 -44
  241. package/dist/project-verification/process.js.map +1 -1
  242. package/dist/project-verification/service.js +9 -1
  243. package/dist/project-verification/service.js.map +1 -1
  244. package/dist/prompt.d.ts +7 -0
  245. package/dist/prompt.js +18 -1
  246. package/dist/prompt.js.map +1 -1
  247. package/dist/recipe-host/git-trust.d.ts +43 -0
  248. package/dist/recipe-host/git-trust.js +360 -0
  249. package/dist/recipe-host/git-trust.js.map +1 -0
  250. package/dist/recipe-host/git.d.ts +42 -0
  251. package/dist/recipe-host/git.js +207 -0
  252. package/dist/recipe-host/git.js.map +1 -0
  253. package/dist/recipe-host/native-recipe-host.d.ts +127 -0
  254. package/dist/recipe-host/native-recipe-host.js +880 -0
  255. package/dist/recipe-host/native-recipe-host.js.map +1 -0
  256. package/dist/recipe-host/seat-cwd.d.ts +16 -0
  257. package/dist/recipe-host/seat-cwd.js +170 -0
  258. package/dist/recipe-host/seat-cwd.js.map +1 -0
  259. package/dist/runner.d.ts +43 -1
  260. package/dist/runner.js +234 -35
  261. package/dist/runner.js.map +1 -1
  262. package/dist/server.js +9 -1
  263. package/dist/server.js.map +1 -1
  264. package/docs/configuration.md +24 -3
  265. package/docs/engineering-recipes.md +291 -0
  266. package/docs/security.md +84 -0
  267. package/docs/verification/project-checks.md +24 -2
  268. package/package.json +5 -1
  269. package/clinkx-workflows/dist/dashboard-ui/assets/index-BdpmbPps.js +0 -115
  270. package/clinkx-workflows/dist/dashboard-ui/assets/style-Im5i1iAs.css +0 -1
@@ -0,0 +1,360 @@
1
+ import { createHash } from "node:crypto";
2
+ import { constants } from "node:fs";
3
+ import { lstat, open, readlink, stat } from "node:fs/promises";
4
+ import { dirname, join } from "node:path";
5
+ import { RecipeGitMetadataDriftError, RecipeHostError, redactUrlCredentials, } from "../../clinkx-workflows/dist/recipe-host.js";
6
+ const WITNESS_HEADER = "clinkx-candidate-witness-v1\n";
7
+ const READ_CHUNK_BYTES = 1024 * 1024;
8
+ /** Bound on the `git ls-files -s -z` listing the witness is computed over. */
9
+ export const WITNESS_LISTING_MAX_BYTES = 64 * 1024 * 1024;
10
+ function witnessError(message) {
11
+ return new RecipeHostError(`candidate witness: ${message}`, "identity");
12
+ }
13
+ function frame(hash, mode, path, length) {
14
+ hash.update(`${mode} ${length}\0`);
15
+ hash.update(path);
16
+ hash.update("\0");
17
+ }
18
+ /** Content digest and mode of a regular file the caller lstat-ed as `expected`. */
19
+ async function hashRegularFile(file, expected, display) {
20
+ // O_NOFOLLOW: a leaf swapped for a symlink after the lstat fails instead of being followed.
21
+ const handle = await open(file, constants.O_RDONLY | constants.O_NOFOLLOW);
22
+ try {
23
+ const stats = await handle.stat();
24
+ if (!stats.isFile() || stats.dev !== expected.dev || stats.ino !== expected.ino) {
25
+ throw witnessError(`${display} changed while it was read`);
26
+ }
27
+ const content = createHash("sha256");
28
+ const buffer = Buffer.allocUnsafe(Math.min(READ_CHUNK_BYTES, Math.max(1, stats.size)));
29
+ let total = 0;
30
+ for (;;) {
31
+ const { bytesRead } = await handle.read(buffer, 0, buffer.length, total);
32
+ if (bytesRead === 0)
33
+ break;
34
+ total += bytesRead;
35
+ if (total > stats.size)
36
+ throw witnessError(`${display} grew while it was read`);
37
+ content.update(buffer.subarray(0, bytesRead));
38
+ }
39
+ if (total !== stats.size)
40
+ throw witnessError(`${display} shrank while it was read`);
41
+ return { mode: (stats.mode & 0o100) !== 0 ? "100755" : "100644", size: total, digest: content.digest() };
42
+ }
43
+ finally {
44
+ await handle.close();
45
+ }
46
+ }
47
+ /**
48
+ * D4(a) candidate byte witness: sha256 over framed (mode, path, raw content)
49
+ * records, one per entry of the throwaway index (`git ls-files -s -z` output),
50
+ * in index order. Content is the file's bytes as they are on disk (no clean
51
+ * filter, no eol conversion), a symlink's target, or a gitlink's commit id
52
+ * (nested repositories stay recorded by HEAD only, as in the tree id).
53
+ *
54
+ * Cost: every listed file is read once more, the same O(bytes) as the `git
55
+ * add -A` that built the index; there is no separate size bound.
56
+ */
57
+ export async function computeCandidateWitness(root, listing) {
58
+ const hash = createHash("sha256");
59
+ hash.update(WITNESS_HEADER);
60
+ const rootPrefix = Buffer.from(root.endsWith("/") ? root : `${root}/`);
61
+ let start = 0;
62
+ while (start < listing.length) {
63
+ let end = listing.indexOf(0, start);
64
+ if (end < 0)
65
+ end = listing.length;
66
+ const record = listing.subarray(start, end);
67
+ start = end + 1;
68
+ if (record.length === 0)
69
+ continue;
70
+ const tab = record.indexOf(0x09);
71
+ const header = tab < 0 ? null : /^(\d{6}) ([0-9a-f]{40,64}) 0$/.exec(record.subarray(0, tab).toString("latin1"));
72
+ if (tab < 0 || header === null)
73
+ throw witnessError("unexpected git ls-files record");
74
+ const path = record.subarray(tab + 1);
75
+ const display = JSON.stringify(path.toString("utf8"));
76
+ const indexMode = header[1];
77
+ const objectId = header[2];
78
+ if (indexMode === "160000") {
79
+ frame(hash, indexMode, path, objectId.length);
80
+ hash.update(objectId);
81
+ continue;
82
+ }
83
+ const file = Buffer.concat([rootPrefix, path]);
84
+ const stats = await lstat(file);
85
+ if (stats.isSymbolicLink()) {
86
+ const target = await readlink(file, { encoding: "buffer" });
87
+ frame(hash, "120000", path, target.length);
88
+ hash.update(target);
89
+ }
90
+ else if (stats.isFile()) {
91
+ // Content enters as its own digest so the record can stay mode-first.
92
+ const { mode, size, digest } = await hashRegularFile(file, stats, display);
93
+ frame(hash, mode, path, size);
94
+ hash.update(digest);
95
+ }
96
+ else {
97
+ throw witnessError(`${display} is neither a regular file nor a symlink`);
98
+ }
99
+ }
100
+ return hash.digest("hex");
101
+ }
102
+ // ---------------------------------------------------------------------------
103
+ // D4(c) shared git-metadata snapshot and drift check
104
+ // ---------------------------------------------------------------------------
105
+ const MAX_METADATA_FILE_BYTES = 8 * 1024 * 1024;
106
+ /** Must match PP_MAX_GIT_METADATA_KEYS in the sidecar schema. */
107
+ const MAX_RECORDED_KEYS = 256;
108
+ const MAX_NAMED_KEYS = 8;
109
+ /**
110
+ * Files git reads for a linked worktree that a writer can change through the
111
+ * shared repository: the common config, both `config.worktree` files, and the
112
+ * `info/attributes` / `info/exclude` files (also the per-worktree copies,
113
+ * which git ignores, so a planted one is still reported).
114
+ */
115
+ function metadataFiles(commonDir, gitDir) {
116
+ return [
117
+ { name: "common/config", path: join(commonDir, "config"), kind: "config" },
118
+ { name: "common/config.worktree", path: join(commonDir, "config.worktree"), kind: "config" },
119
+ { name: "common/info/attributes", path: join(commonDir, "info", "attributes"), kind: "raw" },
120
+ { name: "common/info/exclude", path: join(commonDir, "info", "exclude"), kind: "raw" },
121
+ { name: "worktree/config.worktree", path: join(gitDir, "config.worktree"), kind: "config" },
122
+ { name: "worktree/info/attributes", path: join(gitDir, "info", "attributes"), kind: "raw" },
123
+ { name: "worktree/info/exclude", path: join(gitDir, "info", "exclude"), kind: "raw" },
124
+ ];
125
+ }
126
+ /**
127
+ * The only keys a writer may change without stopping the run: identity and
128
+ * branch/remote tracking bookkeeping that host git never acts on.
129
+ */
130
+ export function isAllowlistedGitConfigKey(key) {
131
+ return key === "user.name" || key === "user.email" ||
132
+ /^branch\..+\.(?:remote|merge|rebase|description)$/s.test(key) ||
133
+ /^remote\..+\.fetch$/s.test(key);
134
+ }
135
+ function sha256Hex(...parts) {
136
+ const hash = createHash("sha256");
137
+ for (const part of parts)
138
+ hash.update(part);
139
+ return hash.digest("hex");
140
+ }
141
+ /** Sorted-key JSON: zod rebuilds parsed objects in schema order, so key order must not matter. */
142
+ function canonical(value) {
143
+ if (Array.isArray(value))
144
+ return `[${value.map(canonical).join(",")}]`;
145
+ if (value !== null && typeof value === "object") {
146
+ const entries = Object.entries(value)
147
+ .filter(([, entry]) => entry !== undefined)
148
+ .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0));
149
+ return `{${entries.map(([key, entry]) => `${JSON.stringify(key)}:${canonical(entry)}`).join(",")}}`;
150
+ }
151
+ return JSON.stringify(value);
152
+ }
153
+ function filesDigest(files) {
154
+ return sha256Hex(canonical(files));
155
+ }
156
+ async function readBoundedRegular(path, nofollow) {
157
+ const handle = await open(path, constants.O_RDONLY | (nofollow ? constants.O_NOFOLLOW : 0) | constants.O_NONBLOCK);
158
+ try {
159
+ const stats = await handle.stat();
160
+ if (!stats.isFile())
161
+ throw new Error("not a regular file");
162
+ if (stats.size > MAX_METADATA_FILE_BYTES)
163
+ throw new Error(`larger than ${MAX_METADATA_FILE_BYTES} bytes`);
164
+ return await handle.readFile();
165
+ }
166
+ finally {
167
+ await handle.close();
168
+ }
169
+ }
170
+ async function observe(path) {
171
+ let stats;
172
+ try {
173
+ stats = await lstat(path);
174
+ }
175
+ catch (error) {
176
+ const code = error.code;
177
+ if (code === "ENOENT" || code === "ENOTDIR")
178
+ return { state: "absent" };
179
+ throw error;
180
+ }
181
+ if (stats.isSymbolicLink()) {
182
+ // git follows the link: bind both the target name and the content behind it.
183
+ const target = await readlink(path, { encoding: "buffer" });
184
+ let content = "unreadable";
185
+ try {
186
+ if ((await stat(path)).isFile())
187
+ content = await readBoundedRegular(path, false);
188
+ }
189
+ catch {
190
+ // A dangling or unreadable target is recorded as such; a later change still differs.
191
+ }
192
+ return { state: "symlink", sha256: sha256Hex("symlink\0", target, "\0", content) };
193
+ }
194
+ if (stats.isFile())
195
+ return { state: "file", sha256: sha256Hex(await readBoundedRegular(path, true)) };
196
+ return { state: "other", sha256: sha256Hex("other") };
197
+ }
198
+ /** Non-allowlisted entries of a `--list -z` listing: ordered digest plus per-key value digests. */
199
+ function parseConfigListing(listing) {
200
+ const entries = createHash("sha256");
201
+ const perKey = new Map();
202
+ let start = 0;
203
+ while (start < listing.length) {
204
+ let end = listing.indexOf(0, start);
205
+ if (end < 0)
206
+ end = listing.length;
207
+ const entry = listing.subarray(start, end);
208
+ start = end + 1;
209
+ if (entry.length === 0)
210
+ continue;
211
+ const newline = entry.indexOf(0x0a);
212
+ const keyBytes = newline < 0 ? entry : entry.subarray(0, newline);
213
+ const key = keyBytes.toString("utf8");
214
+ if (isAllowlistedGitConfigKey(key))
215
+ continue;
216
+ // A key with no `=value` (boolean true) is distinct from an empty value.
217
+ const value = newline < 0 ? Buffer.from([0x00]) : Buffer.concat([Buffer.from([0x01]), entry.subarray(newline + 1)]);
218
+ const valueFrame = Buffer.concat([Buffer.from(`${value.length}\0`), value]);
219
+ entries.update(`${keyBytes.length}\0`);
220
+ entries.update(keyBytes);
221
+ entries.update(valueFrame);
222
+ let keyHash = perKey.get(key);
223
+ if (keyHash === undefined) {
224
+ keyHash = createHash("sha256");
225
+ perKey.set(key, keyHash);
226
+ }
227
+ keyHash.update(valueFrame);
228
+ }
229
+ return {
230
+ entriesSha256: entries.digest("hex"),
231
+ keys: new Map([...perKey].map(([key, hash]) => [key, hash.digest("hex")])),
232
+ };
233
+ }
234
+ /** Snapshot taken once, right after the worktree is created and verified. */
235
+ export async function snapshotGitMetadata(commonDir, gitDir, listConfig, signal) {
236
+ const files = [];
237
+ for (const spec of metadataFiles(commonDir, gitDir)) {
238
+ const observed = await observe(spec.path);
239
+ const record = {
240
+ name: spec.name, path: spec.path, kind: spec.kind, state: observed.state,
241
+ };
242
+ if (observed.sha256 !== undefined)
243
+ record.sha256 = observed.sha256;
244
+ if (spec.kind === "config" && observed.state === "file") {
245
+ const parsed = parseConfigListing(await listConfig(spec.path, signal));
246
+ record.entries_sha256 = parsed.entriesSha256;
247
+ if (parsed.keys.size <= MAX_RECORDED_KEYS)
248
+ record.keys = Object.fromEntries(parsed.keys);
249
+ }
250
+ files.push(record);
251
+ }
252
+ return { version: 1, digest: filesDigest(files), files };
253
+ }
254
+ function drift(file, safeDetail, changes = []) {
255
+ // The message is logged, so `safeDetail` is built from fixed text and redacted
256
+ // tokens (re-redacting it would collapse a long key list into a placeholder).
257
+ // `path` and `changes` stay raw for the stop-detail formatter, which redacts again.
258
+ return new RecipeGitMetadataDriftError(`git metadata drift in ${file.name} (${redactUrlCredentials(file.path, "path")}): ${safeDetail}; refusing to run host git on this recipe worktree`, file.name, changes.map(({ key }) => key), { path: file.path, fileKind: file.kind, detail: safeDetail, changes });
259
+ }
260
+ /**
261
+ * Writer-controlled text, redacted before clipping: a clipped URL could lose
262
+ * the `@` or `?` that marks its credential.
263
+ */
264
+ function redactedClip(raw, label, max) {
265
+ const text = redactUrlCredentials(raw, label);
266
+ return text.length > max ? `${text.slice(0, max - 3)}...` : text;
267
+ }
268
+ function describeKeyDrift(recorded, current) {
269
+ if (recorded === undefined)
270
+ return { detail: "non-allowlisted entries changed (keys not recorded)", changes: [] };
271
+ const changes = [];
272
+ for (const [key, digest] of current) {
273
+ const before = recorded[key];
274
+ if (before === undefined)
275
+ changes.push({ key, change: "added" });
276
+ else if (before !== digest)
277
+ changes.push({ key, change: "changed" });
278
+ }
279
+ for (const key of Object.keys(recorded)) {
280
+ if (!current.has(key))
281
+ changes.push({ key, change: "removed" });
282
+ }
283
+ if (changes.length === 0)
284
+ return { detail: "non-allowlisted entries were reordered", changes: [] };
285
+ const shown = changes.slice(0, MAX_NAMED_KEYS).map(({ key, change }) => `${redactedClip(key, "key", 200)} ${change}`);
286
+ const more = changes.length > MAX_NAMED_KEYS ? ` (+${changes.length - MAX_NAMED_KEYS} more)` : "";
287
+ return { detail: `key ${shown.join(", ")}${more}`, changes };
288
+ }
289
+ function assertSnapshotIntact(snapshot) {
290
+ if (snapshot.version !== 1 || filesDigest(snapshot.files) !== snapshot.digest) {
291
+ throw drift({ name: "snapshot", path: "recipe sidecar" }, "the recorded snapshot does not match its digest");
292
+ }
293
+ }
294
+ /**
295
+ * The recorded files only mean something for the admin dirs they were taken
296
+ * from. A seat's `.git` link is writer-controlled, so a seat re-pointed at
297
+ * another (self-consistent) admin dir would leave every recorded file intact
298
+ * while host git loads the other repository's config. Called with the dirs
299
+ * git resolves for the seat, before any identity or delta git spawns.
300
+ */
301
+ export function assertGitMetadataDirs(snapshot, resolved) {
302
+ assertSnapshotIntact(snapshot);
303
+ const recordedDir = (name) => {
304
+ const file = snapshot.files.find((entry) => entry.name === name);
305
+ if (file === undefined)
306
+ throw drift({ name: "snapshot", path: "recipe sidecar" }, `the recorded snapshot has no ${name}`);
307
+ return dirname(file.path);
308
+ };
309
+ const checks = [
310
+ { name: "common dir", recorded: recordedDir("common/config"), current: resolved.commonDir },
311
+ { name: "git dir", recorded: recordedDir("worktree/config.worktree"), current: resolved.gitDir },
312
+ ];
313
+ for (const { name, recorded, current } of checks) {
314
+ if (current !== recorded)
315
+ throw drift({ name, path: recorded }, `the seat now resolves ${JSON.stringify(redactedClip(current, "path", 200))}`);
316
+ }
317
+ }
318
+ /**
319
+ * Recheck before a host git spawn. A file whose raw bytes match is unchanged;
320
+ * a changed config file is re-listed and passes only when its non-allowlisted
321
+ * entries are identical (`accepted` caches such bytes per snapshot).
322
+ * Residuals: a file included through `include.path` is not itself recorded
323
+ * (a new or changed include directive is), and a change landing between this
324
+ * check and git's own read is not seen.
325
+ */
326
+ export async function assertGitMetadataUnchanged(snapshot, listConfig, accepted, signal) {
327
+ assertSnapshotIntact(snapshot);
328
+ for (const file of snapshot.files) {
329
+ let observed;
330
+ try {
331
+ observed = await observe(file.path);
332
+ }
333
+ catch (error) {
334
+ throw drift(file, `could not be read (${error.code ?? "error"})`);
335
+ }
336
+ if (observed.state !== file.state)
337
+ throw drift(file, `${file.state} at creation, now ${observed.state}`);
338
+ if (observed.sha256 === file.sha256)
339
+ continue;
340
+ if (file.kind !== "config" || observed.state !== "file")
341
+ throw drift(file, "content changed");
342
+ const cacheKey = `${snapshot.digest}\0${file.path}`;
343
+ if (accepted.get(cacheKey) === observed.sha256)
344
+ continue;
345
+ let parsed;
346
+ try {
347
+ parsed = parseConfigListing(await listConfig(file.path, signal));
348
+ }
349
+ catch {
350
+ throw drift(file, "could not be parsed");
351
+ }
352
+ if (parsed.entriesSha256 === file.entries_sha256) {
353
+ accepted.set(cacheKey, observed.sha256);
354
+ continue;
355
+ }
356
+ const { detail, changes } = describeKeyDrift(file.keys, parsed.keys);
357
+ throw drift(file, detail, changes);
358
+ }
359
+ }
360
+ //# sourceMappingURL=git-trust.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"git-trust.js","sourceRoot":"","sources":["../../src/recipe-host/git-trust.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EACL,2BAA2B,EAC3B,eAAe,EAIf,oBAAoB,GACrB,MAAM,4CAA4C,CAAC;AAEpD,MAAM,cAAc,GAAG,+BAA+B,CAAC;AACvD,MAAM,gBAAgB,GAAG,IAAI,GAAG,IAAI,CAAC;AACrC,8EAA8E;AAC9E,MAAM,CAAC,MAAM,yBAAyB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AAE1D,SAAS,YAAY,CAAC,OAAe;IACnC,OAAO,IAAI,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S;QACX,CAAC;QACD,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,gBAAgB,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;QACrE,MAAM,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,CAAC;AACH,CAAC"}
@@ -0,0 +1,42 @@
1
+ import { RecipeHostError } from "../../clinkx-workflows/dist/recipe-host.js";
2
+ export declare const DEFAULT_GIT_TIMEOUT_MS = 120000;
3
+ /**
4
+ * Bounded wait, after the group is proven gone, for the stdout/stderr pipes to
5
+ * close. A pipe still open past it is held by a process that left the group,
6
+ * so the call is rejected as unconfirmed instead of waiting on that process.
7
+ */
8
+ export declare const GIT_STREAM_CLOSE_WAIT_MS = 2000;
9
+ /**
10
+ * git ran and exited with a non-accepted status. Only this failure says
11
+ * something about the caller's input; spawn errors, timeouts, aborts and
12
+ * output overflow stay plain `RecipeHostError`s.
13
+ */
14
+ export declare class GitExitError extends RecipeHostError {
15
+ readonly exitCode: number;
16
+ constructor(message: string, operation: string, exitCode: number);
17
+ }
18
+ export interface RunGitOptions {
19
+ readonly cwd?: string | undefined;
20
+ /** Extra child-only env (e.g. GIT_INDEX_FILE). Never written to process.env. */
21
+ readonly env?: Readonly<Record<string, string>> | undefined;
22
+ readonly timeoutMs?: number | undefined;
23
+ readonly maxStdoutBytes?: number | undefined;
24
+ /** Exit codes treated as success besides 0 (e.g. `symbolic-ref -q` exits 1 on a detached HEAD). */
25
+ readonly allowExitCodes?: readonly number[] | undefined;
26
+ readonly signal?: AbortSignal | undefined;
27
+ /** git executable to spawn (default `git`, resolved via PATH). Test seam. */
28
+ readonly gitBinary?: string | undefined;
29
+ /** Error label; defaults to the first argv entry. */
30
+ readonly operation?: string | undefined;
31
+ }
32
+ export interface RunGitResult {
33
+ readonly stdout: Buffer;
34
+ readonly exitCode: number;
35
+ }
36
+ /**
37
+ * Spawns `git` with an argv array (`shell:false`), a minimal env, bounded
38
+ * output, and a timeout. git runs in its own process group, registered for
39
+ * shutdown; the call settles only after that group is proven gone (ESRCH) and
40
+ * the pipes closed, and otherwise rejects as "process-group exit unconfirmed".
41
+ */
42
+ export declare function runGit(args: readonly string[], options?: RunGitOptions): Promise<RunGitResult>;
@@ -0,0 +1,207 @@
1
+ import { spawn } from "node:child_process";
2
+ import { RecipeHostError } from "../../clinkx-workflows/dist/recipe-host.js";
3
+ import { activeProcesses, trackProcessGroup } from "../process-group.js";
4
+ import { isSubprocessAdmissionClosed } from "../runner.js";
5
+ const ENV_BASELINE = ["PATH", "HOME", "USER", "LANG", "TMPDIR"];
6
+ const STDERR_LIMIT = 16 * 1024;
7
+ const DEFAULT_STDOUT_LIMIT = 1024 * 1024;
8
+ export const DEFAULT_GIT_TIMEOUT_MS = 120_000;
9
+ /**
10
+ * Bounded wait, after the group is proven gone, for the stdout/stderr pipes to
11
+ * close. A pipe still open past it is held by a process that left the group,
12
+ * so the call is rejected as unconfirmed instead of waiting on that process.
13
+ */
14
+ export const GIT_STREAM_CLOSE_WAIT_MS = 2_000;
15
+ /**
16
+ * Applied to every invocation: host-owned git operations never run repository
17
+ * hooks or an fsmonitor command that a writer could have configured, and
18
+ * never read an attributes file named by config (which a repository config
19
+ * could point anywhere).
20
+ */
21
+ const HARDENING = [
22
+ "-c", "core.hooksPath=/dev/null",
23
+ "-c", "core.fsmonitor=false",
24
+ "-c", "core.attributesFile=/dev/null",
25
+ ];
26
+ /**
27
+ * Host git reads only the repository's own config: no system or global
28
+ * config (`HOME` still passes through for other tools), and no system
29
+ * attributes. Applied after the caller env so no caller can undo it.
30
+ */
31
+ const ISOLATION_ENV = {
32
+ GIT_CONFIG_NOSYSTEM: "1",
33
+ GIT_CONFIG_GLOBAL: "/dev/null",
34
+ GIT_ATTR_NOSYSTEM: "1",
35
+ };
36
+ /** Env that injects config entries directly; never passed to host git. */
37
+ const CONFIG_INJECTION_ENV = ["GIT_CONFIG_PARAMETERS", "GIT_CONFIG_COUNT", "GIT_CONFIG_SYSTEM"];
38
+ /**
39
+ * git ran and exited with a non-accepted status. Only this failure says
40
+ * something about the caller's input; spawn errors, timeouts, aborts and
41
+ * output overflow stay plain `RecipeHostError`s.
42
+ */
43
+ export class GitExitError extends RecipeHostError {
44
+ exitCode;
45
+ constructor(message, operation, exitCode) {
46
+ super(message, operation);
47
+ this.exitCode = exitCode;
48
+ this.name = "GitExitError";
49
+ }
50
+ }
51
+ /**
52
+ * Spawns `git` with an argv array (`shell:false`), a minimal env, bounded
53
+ * output, and a timeout. git runs in its own process group, registered for
54
+ * shutdown; the call settles only after that group is proven gone (ESRCH) and
55
+ * the pipes closed, and otherwise rejects as "process-group exit unconfirmed".
56
+ */
57
+ export function runGit(args, options = {}) {
58
+ const operation = options.operation ?? `git ${args[0] ?? ""}`.trim();
59
+ const maxStdout = options.maxStdoutBytes ?? DEFAULT_STDOUT_LIMIT;
60
+ const timeoutMs = options.timeoutMs ?? DEFAULT_GIT_TIMEOUT_MS;
61
+ options.signal?.throwIfAborted();
62
+ // Same admission rule as runSubprocess: once shutdown latched, killAllActive
63
+ // has taken its snapshot, so a child spawned now could outlive the drain.
64
+ if (isSubprocessAdmissionClosed()) {
65
+ return Promise.reject(new RecipeHostError(`${operation} refused: server is shutting down; subprocess admission is closed`, operation));
66
+ }
67
+ const env = { GIT_TERMINAL_PROMPT: "0" };
68
+ for (const key of ENV_BASELINE) {
69
+ const value = process.env[key];
70
+ if (value !== undefined)
71
+ env[key] = value;
72
+ }
73
+ Object.assign(env, options.env);
74
+ for (const key of CONFIG_INJECTION_ENV)
75
+ delete env[key];
76
+ Object.assign(env, ISOLATION_ENV);
77
+ return new Promise((resolvePromise, reject) => {
78
+ // Own process group (`detached`), so a filter, credential helper or pager
79
+ // git starts can be swept with it instead of holding our pipes open.
80
+ const child = spawn(options.gitBinary ?? "git", [...HARDENING, ...args], {
81
+ cwd: options.cwd,
82
+ env,
83
+ shell: false,
84
+ stdio: ["ignore", "pipe", "pipe"],
85
+ detached: true,
86
+ });
87
+ const group = trackProcessGroup(child, { probeFirst: true });
88
+ activeProcesses.add(child);
89
+ const stdout = [];
90
+ let stdoutBytes = 0;
91
+ let stderr = "";
92
+ let failure;
93
+ let settled = false;
94
+ let sweepStarted = false;
95
+ let confirmed = false;
96
+ let closed = false;
97
+ let closeCode = null;
98
+ let closeSignal = null;
99
+ let streamTimer;
100
+ const settle = (outcome) => {
101
+ if (settled)
102
+ return;
103
+ settled = true;
104
+ clearTimeout(timer);
105
+ clearTimeout(streamTimer);
106
+ options.signal?.removeEventListener("abort", onAbort);
107
+ outcome();
108
+ };
109
+ const rejectUnconfirmed = () => {
110
+ child.stdout.destroy();
111
+ child.stderr.destroy();
112
+ const after = failure === undefined ? "" : ` (after: ${failure.message})`;
113
+ settle(() => reject(new RecipeHostError(`${operation} process-group exit unconfirmed${after}`, operation)));
114
+ };
115
+ // Only once the group is proven gone and the pipes have closed.
116
+ const decide = () => {
117
+ if (!closed || !confirmed)
118
+ return;
119
+ settle(() => {
120
+ if (failure !== undefined) {
121
+ reject(failure);
122
+ return;
123
+ }
124
+ if (closeCode === null) {
125
+ // Killed by a signal: says nothing about the caller's input.
126
+ reject(new RecipeHostError(`${operation} was terminated by signal ${closeSignal ?? "unknown"}`, operation));
127
+ return;
128
+ }
129
+ if (closeCode === 0 || (options.allowExitCodes?.includes(closeCode) ?? false)) {
130
+ resolvePromise({ stdout: Buffer.concat(stdout), exitCode: closeCode });
131
+ return;
132
+ }
133
+ const detail = stderr.trim().slice(0, 2000) || "no stderr";
134
+ reject(new GitExitError(`${operation} failed (exit ${closeCode}): ${detail}`, operation, closeCode));
135
+ });
136
+ };
137
+ // Kills a running group, or after a normal exit removes members left
138
+ // behind, then waits a bounded time for the pipes to close.
139
+ const sweepGroup = () => {
140
+ if (sweepStarted)
141
+ return;
142
+ sweepStarted = true;
143
+ void group.sweep().then((result) => {
144
+ if (settled)
145
+ return;
146
+ if (!result.exited) {
147
+ rejectUnconfirmed();
148
+ return;
149
+ }
150
+ confirmed = true;
151
+ decide();
152
+ if (!settled)
153
+ streamTimer = setTimeout(rejectUnconfirmed, GIT_STREAM_CLOSE_WAIT_MS);
154
+ });
155
+ };
156
+ const fail = (error) => {
157
+ if (failure !== undefined || settled)
158
+ return;
159
+ failure = error;
160
+ sweepGroup();
161
+ };
162
+ const timer = setTimeout(() => fail(new RecipeHostError(`${operation} timed out after ${timeoutMs} ms`, operation)), timeoutMs);
163
+ const onAbort = () => {
164
+ const reason = options.signal?.reason;
165
+ fail(reason instanceof Error ? reason : new RecipeHostError(`${operation} was aborted`, operation));
166
+ };
167
+ options.signal?.addEventListener("abort", onAbort, { once: true });
168
+ child.stdout.on("data", (chunk) => {
169
+ stdoutBytes += chunk.length;
170
+ if (stdoutBytes > maxStdout) {
171
+ fail(new RecipeHostError(`${operation} output exceeded ${maxStdout} bytes`, operation));
172
+ return;
173
+ }
174
+ stdout.push(chunk);
175
+ });
176
+ child.stderr.on("data", (chunk) => {
177
+ if (stderr.length < STDERR_LIMIT)
178
+ stderr += chunk.toString("utf8").slice(0, STDERR_LIMIT - stderr.length);
179
+ });
180
+ child.on("error", (error) => {
181
+ const startError = new RecipeHostError(`${operation} could not start git: ${error.message}`, operation);
182
+ if (child.pid === undefined) {
183
+ // Never spawned: there is no group to sweep and no `close` to wait for.
184
+ activeProcesses.delete(child);
185
+ failure ??= startError;
186
+ const spawnFailure = failure;
187
+ settle(() => reject(spawnFailure));
188
+ return;
189
+ }
190
+ fail(startError);
191
+ });
192
+ child.once("exit", () => sweepGroup());
193
+ child.on("close", (code, signal) => {
194
+ closed = true;
195
+ closeCode = code;
196
+ closeSignal = signal;
197
+ // Joins the in-flight sweep, or sends nothing once the group is retired.
198
+ // An unconfirmed group stays registered for the shutdown sweep.
199
+ void group.sweep().then((swept) => {
200
+ if (swept.exited)
201
+ activeProcesses.delete(child);
202
+ });
203
+ decide();
204
+ });
205
+ });
206
+ }
207
+ //# sourceMappingURL=git.js.map
@@ -0,0 +1 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