@davidahmann/mill 0.1.4 → 0.2.1

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 (249) hide show
  1. package/README.md +141 -32
  2. package/dist/audit/repository.d.ts.map +1 -1
  3. package/dist/audit/repository.js +2 -0
  4. package/dist/audit/repository.js.map +1 -1
  5. package/dist/cli-program.d.ts.map +1 -1
  6. package/dist/cli-program.js +189 -0
  7. package/dist/cli-program.js.map +1 -1
  8. package/dist/contracts/schemas.d.ts +467 -2
  9. package/dist/contracts/schemas.d.ts.map +1 -1
  10. package/dist/contracts/schemas.js +211 -1
  11. package/dist/contracts/schemas.js.map +1 -1
  12. package/dist/index.d.ts +7 -1
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/index.js +7 -1
  15. package/dist/index.js.map +1 -1
  16. package/dist/planning/closure.d.ts +24 -0
  17. package/dist/planning/closure.d.ts.map +1 -0
  18. package/dist/planning/closure.js +68 -0
  19. package/dist/planning/closure.js.map +1 -0
  20. package/dist/planning/outcomes.d.ts +6 -0
  21. package/dist/planning/outcomes.d.ts.map +1 -0
  22. package/dist/planning/outcomes.js +36 -0
  23. package/dist/planning/outcomes.js.map +1 -0
  24. package/dist/planning/tasks.d.ts +32 -0
  25. package/dist/planning/tasks.d.ts.map +1 -0
  26. package/dist/planning/tasks.js +305 -0
  27. package/dist/planning/tasks.js.map +1 -0
  28. package/dist/repository/intelligence.d.ts +78 -0
  29. package/dist/repository/intelligence.d.ts.map +1 -0
  30. package/dist/repository/intelligence.js +537 -0
  31. package/dist/repository/intelligence.js.map +1 -0
  32. package/dist/repository/native-adoption.d.ts +36 -0
  33. package/dist/repository/native-adoption.d.ts.map +1 -0
  34. package/dist/repository/native-adoption.js +146 -0
  35. package/dist/repository/native-adoption.js.map +1 -0
  36. package/dist/repository/scan.d.ts.map +1 -1
  37. package/dist/repository/scan.js +4 -0
  38. package/dist/repository/scan.js.map +1 -1
  39. package/dist/runtime/authority-plans.d.ts +43 -0
  40. package/dist/runtime/authority-plans.d.ts.map +1 -0
  41. package/dist/runtime/authority-plans.js +173 -0
  42. package/dist/runtime/authority-plans.js.map +1 -0
  43. package/dist/runtime/codex.d.ts.map +1 -1
  44. package/dist/runtime/codex.js +24 -5
  45. package/dist/runtime/codex.js.map +1 -1
  46. package/dist/runtime/context.d.ts.map +1 -1
  47. package/dist/runtime/context.js +36 -0
  48. package/dist/runtime/context.js.map +1 -1
  49. package/dist/runtime/delivery.d.ts +8 -1
  50. package/dist/runtime/delivery.d.ts.map +1 -1
  51. package/dist/runtime/delivery.js +187 -74
  52. package/dist/runtime/delivery.js.map +1 -1
  53. package/dist/runtime/effect-boundary.d.ts +38 -0
  54. package/dist/runtime/effect-boundary.d.ts.map +1 -0
  55. package/dist/runtime/effect-boundary.js +59 -0
  56. package/dist/runtime/effect-boundary.js.map +1 -0
  57. package/dist/runtime/github.d.ts +24 -0
  58. package/dist/runtime/github.d.ts.map +1 -1
  59. package/dist/runtime/github.js +117 -2
  60. package/dist/runtime/github.js.map +1 -1
  61. package/dist/runtime/inputs.js.map +1 -1
  62. package/dist/runtime/lifecycle.d.ts +5 -0
  63. package/dist/runtime/lifecycle.d.ts.map +1 -1
  64. package/dist/runtime/lifecycle.js +60 -16
  65. package/dist/runtime/lifecycle.js.map +1 -1
  66. package/dist/runtime/merge.d.ts +73 -0
  67. package/dist/runtime/merge.d.ts.map +1 -0
  68. package/dist/runtime/merge.js +299 -0
  69. package/dist/runtime/merge.js.map +1 -0
  70. package/dist/runtime/public-metadata.d.ts +3 -0
  71. package/dist/runtime/public-metadata.d.ts.map +1 -0
  72. package/dist/runtime/public-metadata.js +15 -0
  73. package/dist/runtime/public-metadata.js.map +1 -0
  74. package/dist/runtime/repair.d.ts +12 -0
  75. package/dist/runtime/repair.d.ts.map +1 -0
  76. package/dist/runtime/repair.js +34 -0
  77. package/dist/runtime/repair.js.map +1 -0
  78. package/dist/runtime/repository.d.ts +18 -0
  79. package/dist/runtime/repository.d.ts.map +1 -1
  80. package/dist/runtime/repository.js +114 -2
  81. package/dist/runtime/repository.js.map +1 -1
  82. package/dist/runtime/state.d.ts +42 -1
  83. package/dist/runtime/state.d.ts.map +1 -1
  84. package/dist/runtime/state.js +324 -11
  85. package/dist/runtime/state.js.map +1 -1
  86. package/dist/runtime/usage.d.ts +12 -0
  87. package/dist/runtime/usage.d.ts.map +1 -0
  88. package/dist/runtime/usage.js +45 -0
  89. package/dist/runtime/usage.js.map +1 -0
  90. package/dist/runtime/verifier.d.ts.map +1 -1
  91. package/dist/runtime/verifier.js +12 -0
  92. package/dist/runtime/verifier.js.map +1 -1
  93. package/dist/runtime/worker.d.ts +1 -0
  94. package/dist/runtime/worker.d.ts.map +1 -1
  95. package/dist/runtime/worker.js.map +1 -1
  96. package/dist/version.d.ts +1 -1
  97. package/dist/version.js +1 -1
  98. package/dist/workflows/founder.d.ts.map +1 -1
  99. package/dist/workflows/founder.js +5 -0
  100. package/dist/workflows/founder.js.map +1 -1
  101. package/node_modules/typescript/LICENSE.txt +55 -0
  102. package/node_modules/typescript/README.md +50 -0
  103. package/node_modules/typescript/SECURITY.md +39 -0
  104. package/node_modules/typescript/ThirdPartyNoticeText.txt +193 -0
  105. package/node_modules/typescript/bin/tsc +2 -0
  106. package/node_modules/typescript/bin/tsserver +2 -0
  107. package/node_modules/typescript/lib/_tsc.js +134465 -0
  108. package/node_modules/typescript/lib/_tsserver.js +659 -0
  109. package/node_modules/typescript/lib/_typingsInstaller.js +222 -0
  110. package/node_modules/typescript/lib/cs/diagnosticMessages.generated.json +2129 -0
  111. package/node_modules/typescript/lib/de/diagnosticMessages.generated.json +2125 -0
  112. package/node_modules/typescript/lib/es/diagnosticMessages.generated.json +2129 -0
  113. package/node_modules/typescript/lib/fr/diagnosticMessages.generated.json +2129 -0
  114. package/node_modules/typescript/lib/it/diagnosticMessages.generated.json +2125 -0
  115. package/node_modules/typescript/lib/ja/diagnosticMessages.generated.json +2129 -0
  116. package/node_modules/typescript/lib/ko/diagnosticMessages.generated.json +2129 -0
  117. package/node_modules/typescript/lib/lib.d.ts +20 -0
  118. package/node_modules/typescript/lib/lib.decorators.d.ts +382 -0
  119. package/node_modules/typescript/lib/lib.decorators.legacy.d.ts +20 -0
  120. package/node_modules/typescript/lib/lib.dom.asynciterable.d.ts +18 -0
  121. package/node_modules/typescript/lib/lib.dom.d.ts +45125 -0
  122. package/node_modules/typescript/lib/lib.dom.iterable.d.ts +18 -0
  123. package/node_modules/typescript/lib/lib.es2015.collection.d.ts +150 -0
  124. package/node_modules/typescript/lib/lib.es2015.core.d.ts +595 -0
  125. package/node_modules/typescript/lib/lib.es2015.d.ts +26 -0
  126. package/node_modules/typescript/lib/lib.es2015.generator.d.ts +75 -0
  127. package/node_modules/typescript/lib/lib.es2015.iterable.d.ts +603 -0
  128. package/node_modules/typescript/lib/lib.es2015.promise.d.ts +79 -0
  129. package/node_modules/typescript/lib/lib.es2015.proxy.d.ts +126 -0
  130. package/node_modules/typescript/lib/lib.es2015.reflect.d.ts +142 -0
  131. package/node_modules/typescript/lib/lib.es2015.symbol.d.ts +44 -0
  132. package/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts +324 -0
  133. package/node_modules/typescript/lib/lib.es2016.array.include.d.ts +114 -0
  134. package/node_modules/typescript/lib/lib.es2016.d.ts +19 -0
  135. package/node_modules/typescript/lib/lib.es2016.full.d.ts +21 -0
  136. package/node_modules/typescript/lib/lib.es2016.intl.d.ts +29 -0
  137. package/node_modules/typescript/lib/lib.es2017.arraybuffer.d.ts +19 -0
  138. package/node_modules/typescript/lib/lib.es2017.d.ts +24 -0
  139. package/node_modules/typescript/lib/lib.es2017.date.d.ts +29 -0
  140. package/node_modules/typescript/lib/lib.es2017.full.d.ts +21 -0
  141. package/node_modules/typescript/lib/lib.es2017.intl.d.ts +42 -0
  142. package/node_modules/typescript/lib/lib.es2017.object.d.ts +47 -0
  143. package/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts +133 -0
  144. package/node_modules/typescript/lib/lib.es2017.string.d.ts +43 -0
  145. package/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts +51 -0
  146. package/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts +75 -0
  147. package/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts +51 -0
  148. package/node_modules/typescript/lib/lib.es2018.d.ts +22 -0
  149. package/node_modules/typescript/lib/lib.es2018.full.d.ts +22 -0
  150. package/node_modules/typescript/lib/lib.es2018.intl.d.ts +81 -0
  151. package/node_modules/typescript/lib/lib.es2018.promise.d.ts +28 -0
  152. package/node_modules/typescript/lib/lib.es2018.regexp.d.ts +35 -0
  153. package/node_modules/typescript/lib/lib.es2019.array.d.ts +77 -0
  154. package/node_modules/typescript/lib/lib.es2019.d.ts +22 -0
  155. package/node_modules/typescript/lib/lib.es2019.full.d.ts +22 -0
  156. package/node_modules/typescript/lib/lib.es2019.intl.d.ts +21 -0
  157. package/node_modules/typescript/lib/lib.es2019.object.d.ts +31 -0
  158. package/node_modules/typescript/lib/lib.es2019.string.d.ts +35 -0
  159. package/node_modules/typescript/lib/lib.es2019.symbol.d.ts +22 -0
  160. package/node_modules/typescript/lib/lib.es2020.bigint.d.ts +763 -0
  161. package/node_modules/typescript/lib/lib.es2020.d.ts +25 -0
  162. package/node_modules/typescript/lib/lib.es2020.date.d.ts +40 -0
  163. package/node_modules/typescript/lib/lib.es2020.full.d.ts +22 -0
  164. package/node_modules/typescript/lib/lib.es2020.intl.d.ts +472 -0
  165. package/node_modules/typescript/lib/lib.es2020.number.d.ts +26 -0
  166. package/node_modules/typescript/lib/lib.es2020.promise.d.ts +45 -0
  167. package/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts +97 -0
  168. package/node_modules/typescript/lib/lib.es2020.string.d.ts +42 -0
  169. package/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts +39 -0
  170. package/node_modules/typescript/lib/lib.es2021.d.ts +21 -0
  171. package/node_modules/typescript/lib/lib.es2021.full.d.ts +22 -0
  172. package/node_modules/typescript/lib/lib.es2021.intl.d.ts +164 -0
  173. package/node_modules/typescript/lib/lib.es2021.promise.d.ts +46 -0
  174. package/node_modules/typescript/lib/lib.es2021.string.d.ts +31 -0
  175. package/node_modules/typescript/lib/lib.es2021.weakref.d.ts +76 -0
  176. package/node_modules/typescript/lib/lib.es2022.array.d.ts +119 -0
  177. package/node_modules/typescript/lib/lib.es2022.d.ts +23 -0
  178. package/node_modules/typescript/lib/lib.es2022.error.d.ts +73 -0
  179. package/node_modules/typescript/lib/lib.es2022.full.d.ts +22 -0
  180. package/node_modules/typescript/lib/lib.es2022.intl.d.ts +143 -0
  181. package/node_modules/typescript/lib/lib.es2022.object.d.ts +24 -0
  182. package/node_modules/typescript/lib/lib.es2022.regexp.d.ts +37 -0
  183. package/node_modules/typescript/lib/lib.es2022.string.d.ts +23 -0
  184. package/node_modules/typescript/lib/lib.es2023.array.d.ts +922 -0
  185. package/node_modules/typescript/lib/lib.es2023.collection.d.ts +19 -0
  186. package/node_modules/typescript/lib/lib.es2023.d.ts +20 -0
  187. package/node_modules/typescript/lib/lib.es2023.full.d.ts +22 -0
  188. package/node_modules/typescript/lib/lib.es2023.intl.d.ts +62 -0
  189. package/node_modules/typescript/lib/lib.es2024.arraybuffer.d.ts +63 -0
  190. package/node_modules/typescript/lib/lib.es2024.collection.d.ts +27 -0
  191. package/node_modules/typescript/lib/lib.es2024.d.ts +24 -0
  192. package/node_modules/typescript/lib/lib.es2024.full.d.ts +22 -0
  193. package/node_modules/typescript/lib/lib.es2024.object.d.ts +27 -0
  194. package/node_modules/typescript/lib/lib.es2024.promise.d.ts +33 -0
  195. package/node_modules/typescript/lib/lib.es2024.regexp.d.ts +23 -0
  196. package/node_modules/typescript/lib/lib.es2024.sharedmemory.d.ts +66 -0
  197. package/node_modules/typescript/lib/lib.es2024.string.d.ts +27 -0
  198. package/node_modules/typescript/lib/lib.es2025.collection.d.ts +94 -0
  199. package/node_modules/typescript/lib/lib.es2025.d.ts +23 -0
  200. package/node_modules/typescript/lib/lib.es2025.float16.d.ts +443 -0
  201. package/node_modules/typescript/lib/lib.es2025.full.d.ts +22 -0
  202. package/node_modules/typescript/lib/lib.es2025.intl.d.ts +200 -0
  203. package/node_modules/typescript/lib/lib.es2025.iterator.d.ts +146 -0
  204. package/node_modules/typescript/lib/lib.es2025.promise.d.ts +32 -0
  205. package/node_modules/typescript/lib/lib.es2025.regexp.d.ts +30 -0
  206. package/node_modules/typescript/lib/lib.es5.d.ts +4599 -0
  207. package/node_modules/typescript/lib/lib.es6.d.ts +21 -0
  208. package/node_modules/typescript/lib/lib.esnext.array.d.ts +33 -0
  209. package/node_modules/typescript/lib/lib.esnext.collection.d.ts +47 -0
  210. package/node_modules/typescript/lib/lib.esnext.d.ts +27 -0
  211. package/node_modules/typescript/lib/lib.esnext.date.d.ts +21 -0
  212. package/node_modules/typescript/lib/lib.esnext.decorators.d.ts +26 -0
  213. package/node_modules/typescript/lib/lib.esnext.disposable.d.ts +191 -0
  214. package/node_modules/typescript/lib/lib.esnext.error.d.ts +22 -0
  215. package/node_modules/typescript/lib/lib.esnext.full.d.ts +22 -0
  216. package/node_modules/typescript/lib/lib.esnext.intl.d.ts +107 -0
  217. package/node_modules/typescript/lib/lib.esnext.sharedmemory.d.ts +23 -0
  218. package/node_modules/typescript/lib/lib.esnext.temporal.d.ts +485 -0
  219. package/node_modules/typescript/lib/lib.esnext.typedarrays.d.ts +90 -0
  220. package/node_modules/typescript/lib/lib.scripthost.d.ts +320 -0
  221. package/node_modules/typescript/lib/lib.webworker.asynciterable.d.ts +18 -0
  222. package/node_modules/typescript/lib/lib.webworker.d.ts +15606 -0
  223. package/node_modules/typescript/lib/lib.webworker.importscripts.d.ts +21 -0
  224. package/node_modules/typescript/lib/lib.webworker.iterable.d.ts +18 -0
  225. package/node_modules/typescript/lib/pl/diagnosticMessages.generated.json +2129 -0
  226. package/node_modules/typescript/lib/pt-br/diagnosticMessages.generated.json +2129 -0
  227. package/node_modules/typescript/lib/ru/diagnosticMessages.generated.json +2125 -0
  228. package/node_modules/typescript/lib/tr/diagnosticMessages.generated.json +2129 -0
  229. package/node_modules/typescript/lib/tsc.js +8 -0
  230. package/node_modules/typescript/lib/tsserver.js +8 -0
  231. package/node_modules/typescript/lib/tsserverlibrary.d.ts +17 -0
  232. package/node_modules/typescript/lib/tsserverlibrary.js +21 -0
  233. package/node_modules/typescript/lib/typesMap.json +497 -0
  234. package/node_modules/typescript/lib/typescript.d.ts +11448 -0
  235. package/node_modules/typescript/lib/typescript.js +201039 -0
  236. package/node_modules/typescript/lib/typingsInstaller.js +8 -0
  237. package/node_modules/typescript/lib/watchGuard.js +53 -0
  238. package/node_modules/typescript/lib/zh-cn/diagnosticMessages.generated.json +2129 -0
  239. package/node_modules/typescript/lib/zh-tw/diagnosticMessages.generated.json +2125 -0
  240. package/node_modules/typescript/package.json +118 -0
  241. package/package.json +7 -4
  242. package/schemas/audit-report.schema.json +1 -0
  243. package/schemas/change-request.schema.json +189 -0
  244. package/schemas/context-manifest.schema.json +50 -0
  245. package/schemas/delivery-record.schema.json +109 -0
  246. package/schemas/mill-config.schema.json +50 -2
  247. package/schemas/repository-intelligence.schema.json +200 -0
  248. package/schemas/review-result.schema.json +21 -0
  249. package/schemas/task-packet.schema.json +12 -0
@@ -0,0 +1,24 @@
1
+ /** Propose a repository-authority update from finalized evidence; never approve it. */
2
+ export declare function planOutcomeClosure(input: {
3
+ root: string;
4
+ taskPath: string;
5
+ runId: string;
6
+ nextOutcomeId?: string;
7
+ }): Promise<{
8
+ approvalDigest: string;
9
+ schemaVersion: string;
10
+ authority: string;
11
+ baseCommit: string;
12
+ baseTree: string;
13
+ previousPlanDigest: string;
14
+ runId: string;
15
+ taskDigest: string;
16
+ evidenceDigest: string;
17
+ mergeCommit: string;
18
+ files: {
19
+ path: string;
20
+ content: string;
21
+ }[];
22
+ nextAction: string;
23
+ }>;
24
+ //# sourceMappingURL=closure.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"closure.d.ts","sourceRoot":"","sources":["../../src/planning/closure.ts"],"names":[],"mappings":"AAiBA,uFAAuF;AACvF,wBAAsB,kBAAkB,CAAC,KAAK,EAAE;IAC9C,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;;;;;;;;;;;;;;;;GAsFA"}
@@ -0,0 +1,68 @@
1
+ import { parse as parseYaml, stringify as yaml } from "yaml";
2
+ import { canonicalDigest } from "../contracts/canonical.js";
3
+ import { deliveryRecordSchema, outcomePlanSchema, } from "../contracts/schemas.js";
4
+ import { MillError, ExitCode } from "../errors.js";
5
+ import { loadRuntimeInputs, textDigest } from "../runtime/inputs.js";
6
+ import { assertRepositoryWorktreeClean, commonGitDirectory, readCandidateIdentity, } from "../runtime/repository.js";
7
+ import { StateStore } from "../runtime/state.js";
8
+ import { safeReadText } from "../security/safe-path.js";
9
+ import { assertOutcomeDependencies } from "./outcomes.js";
10
+ /** Propose a repository-authority update from finalized evidence; never approve it. */
11
+ export async function planOutcomeClosure(input) {
12
+ await assertRepositoryWorktreeClean(input.root);
13
+ const base = await readCandidateIdentity(input.root);
14
+ const inputs = await loadRuntimeInputs(input.root, input.taskPath, "readback");
15
+ const original = await safeReadText(input.root, "product/plan.yaml");
16
+ const plan = outcomePlanSchema.parse(parseYaml(original));
17
+ const store = await StateStore.open(inputs.config.repositoryId, await commonGitDirectory(input.root));
18
+ try {
19
+ const run = store.getRun(input.runId);
20
+ const delivery = run.deliveryJson === undefined
21
+ ? undefined
22
+ : deliveryRecordSchema.parse(JSON.parse(run.deliveryJson));
23
+ const outcome = plan.outcomes.find((item) => item.id === inputs.continuity?.impact.outcomeId);
24
+ if (inputs.continuity === undefined ||
25
+ run.status !== "closed" ||
26
+ run.deliveryJson === undefined ||
27
+ run.taskDigest !== inputs.taskDigest ||
28
+ delivery?.state !== "closed" ||
29
+ delivery.merge === null ||
30
+ delivery.candidateCommit !== run.candidateCommit ||
31
+ delivery.merge.tree !== run.candidateTree ||
32
+ outcome?.taskRef !== input.taskPath ||
33
+ plan.productContractDigest !==
34
+ canonicalDigest(inputs.continuity.product))
35
+ throw new MillError("OUTCOME_CLOSURE_UNVERIFIED", "Closure requires the exact task, product plan and provider-finalized run; a ready flag or model claim is insufficient.", ExitCode.configuration);
36
+ outcome.status = "closed";
37
+ if (input.nextOutcomeId !== undefined) {
38
+ const next = plan.outcomes.find((item) => item.id === input.nextOutcomeId);
39
+ if (next?.status !== "approved")
40
+ throw new MillError("OUTCOME_NEXT_NOT_APPROVED", "The next outcome must already be approved.", ExitCode.configuration);
41
+ next.status = "ready";
42
+ }
43
+ assertOutcomeDependencies(plan);
44
+ if (plan.outcomes.filter((item) => item.status === "ready").length > 1)
45
+ throw new MillError("OUTCOME_MULTIPLE_READY", "Closure cannot create multiple ready outcomes.", ExitCode.configuration);
46
+ await assertRepositoryWorktreeClean(input.root);
47
+ if ((await readCandidateIdentity(input.root)).commit !== base.commit)
48
+ throw new MillError("CHANGE_BASE_STALE", "The source changed during closure planning.", ExitCode.configuration);
49
+ const result = {
50
+ schemaVersion: "1",
51
+ authority: "proposal_only",
52
+ baseCommit: base.commit,
53
+ baseTree: base.tree,
54
+ previousPlanDigest: textDigest(original),
55
+ runId: run.id,
56
+ taskDigest: run.taskDigest,
57
+ evidenceDigest: textDigest(run.deliveryJson),
58
+ mergeCommit: delivery.merge.commit,
59
+ files: [{ path: "product/plan.yaml", content: yaml(plan) }],
60
+ nextAction: "Review and commit this authority update through an ordinary approved repository change; closure planning writes nothing.",
61
+ };
62
+ return { ...result, approvalDigest: canonicalDigest(result) };
63
+ }
64
+ finally {
65
+ store.close();
66
+ }
67
+ }
68
+ //# sourceMappingURL=closure.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"closure.js","sourceRoot":"","sources":["../../src/planning/closure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,K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M,EAAE,cAAc,EAAE,eAAe,CAAC,MAAM,CAAC,EAAE,CAAC;IAChE,CAAC;YAAS,CAAC;QACT,KAAK,CAAC,KAAK,EAAE,CAAC;IAChB,CAAC;AACH,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type { z } from "zod";
2
+ import type { outcomePlanSchema } from "../contracts/schemas.js";
3
+ export type OutcomePlan = z.infer<typeof outcomePlanSchema>;
4
+ /** A ready flag cannot override missing predecessors or a cyclic plan. */
5
+ export declare function assertOutcomeDependencies(plan: OutcomePlan): void;
6
+ //# sourceMappingURL=outcomes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outcomes.d.ts","sourceRoot":"","sources":["../../src/planning/outcomes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAGjE,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE5D,0EAA0E;AAC1E,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,CAsCjE"}
@@ -0,0 +1,36 @@
1
+ import { ExitCode, MillError } from "../errors.js";
2
+ /** A ready flag cannot override missing predecessors or a cyclic plan. */
3
+ export function assertOutcomeDependencies(plan) {
4
+ const outcomes = new Map(plan.outcomes.map((outcome) => [outcome.id, outcome]));
5
+ const fail = (reason) => {
6
+ throw new MillError("OUTCOME_DEPENDENCY_INVALID", reason, ExitCode.configuration);
7
+ };
8
+ if (outcomes.size !== plan.outcomes.length)
9
+ fail("Outcome IDs must be unique.");
10
+ const visited = new Set();
11
+ const visiting = new Set();
12
+ const visit = (id) => {
13
+ if (visiting.has(id))
14
+ fail(`Outcome dependency cycle at ${id}.`);
15
+ if (visited.has(id))
16
+ return;
17
+ const outcome = outcomes.get(id);
18
+ if (outcome === undefined)
19
+ return fail(`Unknown outcome dependency: ${id}.`);
20
+ visiting.add(id);
21
+ const dependencies = outcome.dependsOn;
22
+ if (new Set(dependencies).size !== dependencies.length)
23
+ fail(`Duplicate dependencies for ${id}.`);
24
+ for (const dependency of dependencies)
25
+ visit(dependency);
26
+ visiting.delete(id);
27
+ visited.add(id);
28
+ if (outcome.status === "ready" &&
29
+ dependencies.some((dependency) => outcomes.get(dependency)?.status !== "closed")) {
30
+ fail(`Ready outcome ${id} has an unclosed dependency.`);
31
+ }
32
+ };
33
+ for (const id of outcomes.keys())
34
+ visit(id);
35
+ }
36
+ //# sourceMappingURL=outcomes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outcomes.js","sourceRoot":"","sources":["../../src/planning/outcomes.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAInD,0EAA0E;AAC1E,MAAM,UAAU,yBAAyB,CAAC,IAAiB;IACzD,MAAM,QAAQ,GAAG,IAAI,GAAG,CACtB,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC,CACtD,CAAC;IACF,MAAM,IAAI,GAAG,CAAC,MAAc,EAAS,EAAE;QACrC,MAAM,IAAI,SAAS,CACjB,4BAA4B,EAC5B,MAAM,EACN,QAAQ,CAAC,aAAa,CACvB,CAAC;IACJ,CAAC,CAAC;IACF,IAAI,QAAQ,CAAC,IAAI,KAAK,IAAI,CAAC,QAAQ,CAAC,MAAM;QACxC,IAAI,CAAC,6BAA6B,CAAC,CAAC;IACtC,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAC;IAClC,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAU,CAAC;IACnC,MAAM,KAAK,GAAG,CAAC,EAAU,EAAQ,EAAE;QACjC,IAAI,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YAAE,IAAI,CAAC,+BAA+B,EAAE,GAAG,CAAC,CAAC;QACjE,IAAI,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;YAAE,OAAO;QAC5B,MAAM,OAAO,GAAG,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACjC,IAAI,OAAO,KAAK,SAAS;YACvB,OAAO,IAAI,CAAC,+BAA+B,EAAE,GAAG,CAAC,CAAC;QACpD,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACjB,MAAM,YAAY,GAAG,OAAO,CAAC,SAAS,CAAC;QACvC,IAAI,IAAI,GAAG,CAAC,YAAY,CAAC,CAAC,IAAI,KAAK,YAAY,CAAC,MAAM;YACpD,IAAI,CAAC,8BAA8B,EAAE,GAAG,CAAC,CAAC;QAC5C,KAAK,MAAM,UAAU,IAAI,YAAY;YAAE,KAAK,CAAC,UAAU,CAAC,CAAC;QACzD,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACpB,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAChB,IACE,OAAO,CAAC,MAAM,KAAK,OAAO;YAC1B,YAAY,CAAC,IAAI,CACf,CAAC,UAAU,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,MAAM,KAAK,QAAQ,CAC9D,EACD,CAAC;YACD,IAAI,CAAC,iBAAiB,EAAE,8BAA8B,CAAC,CAAC;QAC1D,CAAC;IACH,CAAC,CAAC;IACF,KAAK,MAAM,EAAE,IAAI,QAAQ,CAAC,IAAI,EAAE;QAAE,KAAK,CAAC,EAAE,CAAC,CAAC;AAC9C,CAAC"}
@@ -0,0 +1,32 @@
1
+ /** Deterministic compilation; source prose and model proposals never confer authority. */
2
+ export declare function compileChangeTasks(input: {
3
+ root: string;
4
+ requestPath: string;
5
+ }): Promise<{
6
+ approvalDigest: string;
7
+ schemaVersion: string;
8
+ kind: "prd" | "plan" | "bug" | "review" | "maintenance";
9
+ requestId: string;
10
+ requestDigest: string;
11
+ baseCommit: string;
12
+ baseTree: string;
13
+ configDigest: string;
14
+ files: {
15
+ path: string;
16
+ content: string;
17
+ }[];
18
+ }>;
19
+ /** Apply only in a new disposable worktree; never overwrite an existing task. */
20
+ export declare function applyChangeTasks(input: {
21
+ root: string;
22
+ requestPath: string;
23
+ approvalDigest: string;
24
+ attended: boolean;
25
+ }): Promise<{
26
+ approvalDigest: string;
27
+ branch: string;
28
+ worktree: string;
29
+ files: string[];
30
+ nextAction: string;
31
+ }>;
32
+ //# sourceMappingURL=tasks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tasks.d.ts","sourceRoot":"","sources":["../../src/planning/tasks.ts"],"names":[],"mappings":"AA+BA,0FAA0F;AAC1F,wBAAsB,kBAAkB,CAAC,KAAK,EAAE;IAC9C,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACrB;;;;;;;;;;cAwBsB,MAAM;iBAAW,MAAM;;GA+Q7C;AAED,iFAAiF;AACjF,wBAAsB,gBAAgB,CAAC,KAAK,EAAE;IAC5C,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,OAAO,CAAC;CACnB;;;;;;GAuHA"}
@@ -0,0 +1,305 @@
1
+ import { lstat, mkdir, writeFile } from "node:fs/promises";
2
+ import path from "node:path";
3
+ import { parse as parseYaml, stringify as yaml } from "yaml";
4
+ import { canonicalDigest } from "../contracts/canonical.js";
5
+ import { changeRequestSchema, impactManifestSchema, outcomePlanSchema, productContractSchema, scenarioSetSchema, taskPacketV2Schema, } from "../contracts/schemas.js";
6
+ import { ExitCode, MillError } from "../errors.js";
7
+ import { loadMillConfig, textDigest } from "../runtime/inputs.js";
8
+ import { assertRepositoryWorktreeClean, commonGitDirectory, createCandidateWorktree, readCandidateIdentity, } from "../runtime/repository.js";
9
+ import { acquireWriterLease, StateStore, isTerminalRun, } from "../runtime/state.js";
10
+ import { safeReadText } from "../security/safe-path.js";
11
+ import { assessImpactManifest } from "./impact.js";
12
+ import { assertOutcomeDependencies } from "./outcomes.js";
13
+ const digest = (value) => canonicalDigest(value);
14
+ /** Deterministic compilation; source prose and model proposals never confer authority. */
15
+ export async function compileChangeTasks(input) {
16
+ await assertRepositoryWorktreeClean(input.root);
17
+ const base = await readCandidateIdentity(input.root);
18
+ const request = changeRequestSchema.parse(parseYaml(await safeReadText(input.root, input.requestPath, 2 * 1024 * 1024)));
19
+ const [source, productText, scenarioText, policyText, config] = await Promise.all([
20
+ safeReadText(input.root, request.source.path, 2 * 1024 * 1024),
21
+ safeReadText(input.root, request.productPath, 2 * 1024 * 1024),
22
+ safeReadText(input.root, request.scenariosPath, 2 * 1024 * 1024),
23
+ safeReadText(input.root, request.policyPath, 2 * 1024 * 1024),
24
+ loadMillConfig(input.root),
25
+ ]);
26
+ if (textDigest(source) !== request.source.digest)
27
+ throw new MillError("CHANGE_SOURCE_STALE", "The change request is bound to different source bytes.", ExitCode.configuration);
28
+ const product = productContractSchema.parse(parseYaml(productText));
29
+ const scenarios = scenarioSetSchema.parse(parseYaml(scenarioText));
30
+ const files = [];
31
+ const outcomes = [];
32
+ const taskIds = new Set();
33
+ const commandControls = Object.values(config.commands).flatMap((command) => command.controlPaths);
34
+ const authorityPaths = [
35
+ "AGENTS.md",
36
+ "WORKFLOW.md",
37
+ "mill.yaml",
38
+ "mill.lock",
39
+ request.productPath,
40
+ request.scenariosPath,
41
+ request.policyPath,
42
+ input.requestPath,
43
+ request.source.path,
44
+ "product/tasks/**",
45
+ "product/impacts/**",
46
+ "product/plan.yaml",
47
+ ...request.tasks.map((task) => task.impactPath),
48
+ ...commandControls,
49
+ ];
50
+ const overlaps = (left, right) => {
51
+ const a = left.replace(/\/\*\*$/u, "");
52
+ const b = right.replace(/\/\*\*$/u, "");
53
+ return (a === b ||
54
+ (left.endsWith("/**") && b.startsWith(`${a}/`)) ||
55
+ (right.endsWith("/**") && a.startsWith(`${b}/`)));
56
+ };
57
+ for (const draft of request.tasks) {
58
+ if (taskIds.has(draft.id))
59
+ throw new MillError("DUPLICATE_TASK_ID", "Compiled task IDs must be unique.", ExitCode.configuration);
60
+ taskIds.add(draft.id);
61
+ if (draft.allowedPaths.some((allowed) => [...authorityPaths, ...config.sensitivePaths].some((protectedPath) => overlaps(allowed, protectedPath))))
62
+ throw new MillError("TASK_AUTHORITY_OVERLAP", "Compiled outputs overlap authority, command controls or sensitive paths.", ExitCode.configuration);
63
+ const impactText = await safeReadText(input.root, draft.impactPath, 2 * 1024 * 1024);
64
+ const impact = impactManifestSchema.parse(parseYaml(impactText));
65
+ const assessed = assessImpactManifest({
66
+ manifest: impact,
67
+ product,
68
+ scenarios,
69
+ });
70
+ if (!assessed.approved ||
71
+ assessed.blockers.length > 0 ||
72
+ impact.outcomeId !== draft.outcomeId)
73
+ throw new MillError("CHANGE_IMPACT_BLOCKED", "Every compiled task requires its own approved, closed impact manifest.", ExitCode.configuration, { blockers: assessed.blockers });
74
+ const outcome = product.outcomes.find((value) => value.id === draft.outcomeId);
75
+ if (outcome === undefined ||
76
+ (outcome.acceptanceIds !== undefined &&
77
+ digest([...outcome.acceptanceIds].sort()) !==
78
+ digest([...impact.acceptanceIds].sort())))
79
+ throw new MillError("CHANGE_OUTCOME_MISMATCH", "Task acceptance must equal the approved outcome acceptance.", ExitCode.configuration);
80
+ for (const command of impact.commandIds)
81
+ if (config.commands[command] === undefined)
82
+ throw new MillError("CHANGE_COMMAND_MISSING", "An impact references an undeclared native command.", ExitCode.configuration);
83
+ const acceptance = impact.acceptanceIds.map((id) => {
84
+ const item = product.acceptance.find((value) => value.id === id);
85
+ if (item === undefined)
86
+ throw new MillError("CHANGE_ACCEPTANCE_MISSING", "An acceptance item does not resolve in the approved product.", ExitCode.configuration);
87
+ const selected = scenarios.scenarios.filter((scenario) => impact.scenarioIds.includes(scenario.id) &&
88
+ scenario.acceptanceRefs.includes(id));
89
+ const commandIds = [
90
+ ...new Set(selected.map((scenario) => scenario.executionRef)),
91
+ ];
92
+ if (selected.length === 0 ||
93
+ commandIds.length !== 1 ||
94
+ commandIds[0] === undefined ||
95
+ selected.some((scenario) => scenario.oracleOwner !== "repository"))
96
+ throw new MillError("CHANGE_ORACLE_UNSUPPORTED", "Compilation requires one explicit repository-native command per acceptance item; human or external oracles require an expert task packet.", ExitCode.configuration);
97
+ return {
98
+ id,
99
+ statement: item.statement,
100
+ invariantIds: [
101
+ ...new Set(selected.flatMap((scenario) => scenario.invariantRefs)),
102
+ ],
103
+ scenarioIds: selected.map((scenario) => scenario.id),
104
+ coverage: selected.every((scenario) => scenario.coverage === "new_behavior")
105
+ ? "new_behavior"
106
+ : selected.every((scenario) => scenario.coverage === "preservation")
107
+ ? "preservation"
108
+ : "both",
109
+ evidence: { mode: "command", commandId: commandIds[0] },
110
+ };
111
+ });
112
+ const task = taskPacketV2Schema.parse({
113
+ schemaVersion: "2",
114
+ ...(request.repositoryIntelligence === true
115
+ ? { repositoryIntelligence: true }
116
+ : {}),
117
+ id: draft.id,
118
+ title: draft.title,
119
+ objective: draft.objective,
120
+ riskClass: impact.riskClass,
121
+ baseRef: "HEAD",
122
+ authority: {
123
+ productContract: {
124
+ path: request.productPath,
125
+ digest: textDigest(productText),
126
+ },
127
+ scenarioSet: {
128
+ path: request.scenariosPath,
129
+ digest: textDigest(scenarioText),
130
+ },
131
+ policy: { path: request.policyPath, digest: textDigest(policyText) },
132
+ impactManifest: {
133
+ path: draft.impactPath,
134
+ digest: textDigest(impactText),
135
+ },
136
+ },
137
+ contextPaths: [
138
+ ...new Set([...draft.contextPaths, request.source.path]),
139
+ ].sort(),
140
+ allowedPaths: draft.allowedPaths,
141
+ commandIds: impact.commandIds,
142
+ attestations: draft.attestations,
143
+ acceptance,
144
+ commit: {
145
+ ...request.commit,
146
+ message: `feat: ${draft.title}\n\nSigned-off-by: ${request.commit.authorName} <${request.commit.authorEmail}>`,
147
+ },
148
+ budget: request.budget,
149
+ });
150
+ const taskPath = `product/tasks/${draft.id}.yaml`;
151
+ try {
152
+ await lstat(path.join(input.root, taskPath));
153
+ throw new MillError("CHANGE_OUTPUT_EXISTS", "Generated tasks require fresh IDs; existing task files are never replaced, including during supersession.", ExitCode.configuration);
154
+ }
155
+ catch (error) {
156
+ if (!(error instanceof Error &&
157
+ "code" in error &&
158
+ error.code === "ENOENT"))
159
+ throw error;
160
+ }
161
+ files.push({ path: taskPath, content: yaml(task) });
162
+ outcomes.push({
163
+ id: draft.outcomeId,
164
+ title: draft.title,
165
+ acceptance: acceptance.map((item) => item.statement),
166
+ acceptanceIds: impact.acceptanceIds,
167
+ dependsOn: draft.dependsOn,
168
+ status: draft.outcomeId === request.readyOutcomeId ? "ready" : "approved",
169
+ taskRef: taskPath,
170
+ });
171
+ }
172
+ let previousText;
173
+ try {
174
+ previousText = await safeReadText(input.root, "product/plan.yaml");
175
+ }
176
+ catch (error) {
177
+ if (!(error instanceof MillError && error.code === "FILE_NOT_FOUND"))
178
+ throw error;
179
+ }
180
+ if (previousText !== undefined) {
181
+ const previous = outcomePlanSchema.parse(parseYaml(previousText));
182
+ for (const outcome of previous.outcomes) {
183
+ if (!outcomes.some((next) => next.id === outcome.id))
184
+ outcomes.push(outcome);
185
+ else if (outcome.status === "closed")
186
+ throw new MillError("CHANGE_REOPENS_CLOSED_OUTCOME", "A follow-up must use a new approved outcome; closed history cannot be rewritten.", ExitCode.configuration);
187
+ else {
188
+ const draft = request.tasks.find((task) => task.outcomeId === outcome.id);
189
+ if (outcome.taskRef === undefined ||
190
+ draft?.supersedesTaskDigest === undefined ||
191
+ textDigest(await safeReadText(input.root, outcome.taskRef)) !==
192
+ draft.supersedesTaskDigest)
193
+ throw new MillError("CHANGE_SUPERSESSION_REQUIRED", "Replacing an existing outcome requires its exact prior task-file digest; preserve closed history.", ExitCode.configuration);
194
+ }
195
+ }
196
+ }
197
+ const plan = outcomePlanSchema.parse({
198
+ schemaVersion: "1",
199
+ productContractDigest: digest(product),
200
+ outcomes,
201
+ });
202
+ assertOutcomeDependencies(plan);
203
+ if (outcomes.filter((outcome) => outcome.status === "ready").length !== 1)
204
+ throw new MillError("CHANGE_READY_OUTCOME_INVALID", "The change plan must select exactly one dependency-ready outcome.", ExitCode.configuration);
205
+ files.push({ path: "product/plan.yaml", content: yaml(plan) });
206
+ await assertRepositoryWorktreeClean(input.root);
207
+ if ((await readCandidateIdentity(input.root)).commit !== base.commit)
208
+ throw new MillError("CHANGE_BASE_STALE", "Source changed during task compilation.", ExitCode.configuration);
209
+ const result = {
210
+ schemaVersion: "1",
211
+ kind: request.kind,
212
+ requestId: request.id,
213
+ requestDigest: digest(request),
214
+ baseCommit: base.commit,
215
+ baseTree: base.tree,
216
+ configDigest: digest(config),
217
+ files,
218
+ };
219
+ return { ...result, approvalDigest: digest(result) };
220
+ }
221
+ /** Apply only in a new disposable worktree; never overwrite an existing task. */
222
+ export async function applyChangeTasks(input) {
223
+ if (!input.attended)
224
+ throw new MillError("ATTENDANCE_REQUIRED", "Task-plan apply requires an attended operator.", ExitCode.configuration);
225
+ const plan = await compileChangeTasks(input);
226
+ if (plan.approvalDigest !== input.approvalDigest)
227
+ throw new MillError("CHANGE_APPROVAL_MISMATCH", "Approval does not match the exact source, base, policy and compiled files.", ExitCode.configuration);
228
+ const config = await loadMillConfig(input.root);
229
+ if (config.trustCeiling === "inspect")
230
+ throw new MillError("TRUST_CEILING_EXCEEDED", "Inspect-only policy permits task planning, not authority writes.", ExitCode.configuration);
231
+ const store = await StateStore.open(config.repositoryId, await commonGitDirectory(input.root));
232
+ let lease;
233
+ const id = plan.approvalDigest.slice(7);
234
+ const destination = path.join(store.worktreesDirectory, `plan-${id}`);
235
+ let branch;
236
+ try {
237
+ lease = await acquireWriterLease(store);
238
+ if (store.runs().some((run) => !isTerminalRun(run.status)))
239
+ throw new MillError("ACTIVE_RUN_CONFLICT", "Finish or reconcile the existing lifecycle before applying new task authority.", ExitCode.configuration);
240
+ if ((await compileChangeTasks(input)).approvalDigest !== plan.approvalDigest)
241
+ throw new MillError("CHANGE_BASE_STALE", "The approved plan changed before apply.", ExitCode.configuration);
242
+ store.beginAuthorityPlan({
243
+ kind: "tasks",
244
+ state: "intent",
245
+ approvalDigest: plan.approvalDigest,
246
+ baseCommit: plan.baseCommit,
247
+ worktreePath: destination,
248
+ branch: `mill/${`plan-${plan.requestId}`.slice(0, 32)}-${id.slice(0, 8)}`,
249
+ files: plan.files.map((file) => ({
250
+ path: file.path,
251
+ digest: textDigest(file.content),
252
+ })),
253
+ }, "CHANGE_APPLY_RECONCILIATION_REQUIRED");
254
+ branch = await createCandidateWorktree(input.root, destination, plan.baseCommit, `plan-${plan.requestId}`, id);
255
+ for (const file of plan.files) {
256
+ let ancestor = destination;
257
+ for (const segment of file.path.split("/")) {
258
+ ancestor = path.join(ancestor, segment);
259
+ try {
260
+ const info = await lstat(ancestor);
261
+ if (info.isSymbolicLink())
262
+ throw new MillError("CHANGE_UNSAFE_OUTPUT", "A generated-file ancestor is a symbolic link.", ExitCode.configuration);
263
+ }
264
+ catch (error) {
265
+ if (!(error instanceof Error &&
266
+ "code" in error &&
267
+ error.code === "ENOENT"))
268
+ throw error;
269
+ }
270
+ }
271
+ await mkdir(path.dirname(path.join(destination, file.path)), {
272
+ recursive: true,
273
+ });
274
+ if (file.path === "product/plan.yaml") {
275
+ // Replacement is visible in the exact approved plan and isolated from the operator checkout.
276
+ await writeFile(path.join(destination, file.path), file.content, {
277
+ flag: "w",
278
+ mode: 0o644,
279
+ });
280
+ }
281
+ else
282
+ await writeFile(path.join(destination, file.path), file.content, {
283
+ flag: "wx",
284
+ mode: 0o644,
285
+ });
286
+ }
287
+ store.settleAuthorityPlan(plan.approvalDigest, { branch });
288
+ return {
289
+ approvalDigest: plan.approvalDigest,
290
+ branch,
291
+ worktree: destination,
292
+ files: plan.files.map((file) => file.path),
293
+ nextAction: "Review and commit the authority files, then qualify the selected task against that new exact base.",
294
+ };
295
+ }
296
+ finally {
297
+ try {
298
+ await lease?.release();
299
+ }
300
+ finally {
301
+ store.close();
302
+ }
303
+ }
304
+ }
305
+ //# sourceMappingURL=tasks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tasks.js","sourceRoot":"","sources":["../../src/planning/tasks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,SAAS,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAkB,MAAM,2BAA2B,CAAC;AAC5E,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,iBAAiB,EACjB,qBAAqB,EACrB,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,EACL,6BAA6B,EAC7B,kBAAkB,EAClB,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,kBAAkB,EAClB,UAAU,EACV,aAAa,GACd,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAE1D,MAAM,MAAM,GAAG,CAAC,KAAc,EAAE,EAAE,CAAC,eAAe,CAAC,KAAkB,CAAC,CAAC;AAEvE,0FAA0F;AAC1F,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,KAGxC;IACC,MAAM,6BAA6B,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAChD,MAAM,IAAI,GAAG,MAAM,qBAAqB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H,CAAC;YACD,MAAM,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE;gBAC3D,SAAS,EAAE,IAAI;aAChB,CAAC,CAAC;YACH,IAAI,IAAI,CAAC,IAAI,KAAK,mBAAmB,EAAE,CAAC;gBACtC,6FAA6F;gBAC7F,MAAM,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,OAAO,EAAE;oBAC/D,IAAI,EAAE,GAAG;oBACT,IAAI,EAAE,KAAK;iBACZ,CAAC,CAAC;YACL,CAAC;;gBACC,MAAM,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,OAAO,EAAE;oBAC/D,IAAI,EAAE,IAAI;oBACV,IAAI,EAAE,KAAK;iBACZ,CAAC,CAAC;QACP,CAAC;QACD,KAAK,CAAC,mBAAmB,CAAC,IAAI,CAAC,cAAc,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;QAC3D,OAAO;YACL,cAAc,EAAE,IAAI,CAAC,cAAc;YACnC,MAAM;YACN,QAAQ,EAAE,WAAW;YACrB,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC;YAC1C,UAAU,EACR,oGAAoG;SACvG,CAAC;IACJ,CAAC;YAAS,CAAC;QACT,IAAI,CAAC;YACH,MAAM,KAAK,EAAE,OAAO,EAAE,CAAC;QACzB,CAAC;gBAAS,CAAC;YACT,KAAK,CAAC,KAAK,EAAE,CAAC;QAChB,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,78 @@
1
+ declare const extractorId = "mill.repository-intelligence";
2
+ declare const extractorVersion = "3";
3
+ export interface SourceLocation {
4
+ path: string;
5
+ line: number;
6
+ column: number;
7
+ }
8
+ export interface ImportObservation {
9
+ kind: "dynamic" | "require" | "static" | "type";
10
+ specifier: string;
11
+ location: SourceLocation;
12
+ resolution: "external" | "resolved_local" | "unresolved";
13
+ targetPath?: string;
14
+ }
15
+ export interface ModuleObservation {
16
+ path: string;
17
+ digest: string;
18
+ imports: readonly ImportObservation[];
19
+ parseDiagnostics: readonly SourceLocation[];
20
+ }
21
+ export interface TestInventoryEntry {
22
+ path: string;
23
+ source: "filename";
24
+ }
25
+ export interface TestSelection {
26
+ script: string;
27
+ command: string;
28
+ selector: string;
29
+ matchedInventory: readonly string[];
30
+ status: "observed" | "unknown";
31
+ }
32
+ export interface ChangeLead {
33
+ path: string;
34
+ relationship: "changed" | "direct_importer" | "transitive_importer";
35
+ via?: string;
36
+ }
37
+ export interface ChangeImpact {
38
+ changedPath: string;
39
+ leads: readonly ChangeLead[];
40
+ unknowns: readonly string[];
41
+ }
42
+ export interface RepositoryIntelligence {
43
+ schemaVersion: "1";
44
+ extractor: {
45
+ id: typeof extractorId;
46
+ version: typeof extractorVersion;
47
+ digest: string;
48
+ };
49
+ source: {
50
+ commit: string;
51
+ tree: string;
52
+ root: ".";
53
+ };
54
+ scanDigest: string;
55
+ sourceFiles: readonly string[];
56
+ modules: readonly ModuleObservation[];
57
+ tests: {
58
+ inventory: readonly TestInventoryEntry[];
59
+ declaredSelection: readonly TestSelection[];
60
+ executedCoverage: "unknown";
61
+ };
62
+ changeImpact: readonly ChangeImpact[];
63
+ unknowns: readonly string[];
64
+ digest: string;
65
+ authority: "derived_read_only";
66
+ }
67
+ export interface DiscoverRepositoryInput {
68
+ root: string;
69
+ changedPaths?: readonly string[];
70
+ }
71
+ export interface DiscoveryFreshness {
72
+ fresh: boolean;
73
+ reasons: readonly string[];
74
+ }
75
+ export declare function assessDiscoveryFreshness(report: RepositoryIntelligence, current: Pick<RepositoryIntelligence, "extractor" | "source">): DiscoveryFreshness;
76
+ export declare function discoverRepository(input: DiscoverRepositoryInput): Promise<RepositoryIntelligence>;
77
+ export {};
78
+ //# sourceMappingURL=intelligence.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"intelligence.d.ts","sourceRoot":"","sources":["../../src/repository/intelligence.ts"],"names":[],"mappings":"AAeA,QAAA,MAAM,WAAW,iCAAiC,CAAC;AACnD,QAAA,MAAM,gBAAgB,MAAM,CAAC;AAuB7B,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,MAAM,CAAC;IAChD,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,cAAc,CAAC;IACzB,UAAU,EAAE,UAAU,GAAG,gBAAgB,GAAG,YAAY,CAAC;IACzD,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,SAAS,iBAAiB,EAAE,CAAC;IACtC,gBAAgB,EAAE,SAAS,cAAc,EAAE,CAAC;CAC7C;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,UAAU,CAAC;CACpB;AAED,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,MAAM,EAAE,UAAU,GAAG,SAAS,CAAC;CAChC;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,SAAS,GAAG,iBAAiB,GAAG,qBAAqB,CAAC;IACpE,GAAG,CAAC,EAAE,MAAM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