@intentius/chant 0.49.0 → 0.50.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 (247) hide show
  1. package/dist/audit/catalog.d.ts +13 -3
  2. package/dist/audit/catalog.d.ts.map +1 -1
  3. package/dist/audit/core.d.ts +9 -0
  4. package/dist/audit/core.d.ts.map +1 -1
  5. package/dist/audit/discover.d.ts +6 -0
  6. package/dist/audit/discover.d.ts.map +1 -1
  7. package/dist/audit/fetch.d.ts.map +1 -1
  8. package/dist/audit/report-html.d.ts.map +1 -1
  9. package/dist/audit/report-model.d.ts +6 -0
  10. package/dist/audit/report-model.d.ts.map +1 -1
  11. package/dist/audit/report.d.ts.map +1 -1
  12. package/dist/audit/rules-doc.d.ts.map +1 -1
  13. package/dist/audit/secrets.d.ts +95 -0
  14. package/dist/audit/secrets.d.ts.map +1 -0
  15. package/dist/audit/wrangler.d.ts +33 -0
  16. package/dist/audit/wrangler.d.ts.map +1 -0
  17. package/dist/build.d.ts.map +1 -1
  18. package/dist/cli/commands/audit.d.ts +7 -0
  19. package/dist/cli/commands/audit.d.ts.map +1 -1
  20. package/dist/cli/commands/build.d.ts +23 -0
  21. package/dist/cli/commands/build.d.ts.map +1 -1
  22. package/dist/cli/handlers/build.d.ts.map +1 -1
  23. package/dist/cli/handlers/components.d.ts +31 -0
  24. package/dist/cli/handlers/components.d.ts.map +1 -1
  25. package/dist/cli/handlers/lifecycle.d.ts +11 -0
  26. package/dist/cli/handlers/lifecycle.d.ts.map +1 -1
  27. package/dist/cli/handlers/operator.d.ts +32 -0
  28. package/dist/cli/handlers/operator.d.ts.map +1 -0
  29. package/dist/cli/handlers/scenario.d.ts +39 -0
  30. package/dist/cli/handlers/scenario.d.ts.map +1 -0
  31. package/dist/cli/main.d.ts.map +1 -1
  32. package/dist/cli/mcp/server.d.ts +35 -2
  33. package/dist/cli/mcp/server.d.ts.map +1 -1
  34. package/dist/cli/mcp/types.d.ts +29 -1
  35. package/dist/cli/mcp/types.d.ts.map +1 -1
  36. package/dist/cli/registry.d.ts +14 -2
  37. package/dist/cli/registry.d.ts.map +1 -1
  38. package/dist/codegen/docs-rule-scanning.d.ts.map +1 -1
  39. package/dist/components/capability.d.ts +17 -2
  40. package/dist/components/capability.d.ts.map +1 -1
  41. package/dist/components/cli-support.d.ts +7 -0
  42. package/dist/components/cli-support.d.ts.map +1 -1
  43. package/dist/components/component.d.ts +15 -0
  44. package/dist/components/component.d.ts.map +1 -1
  45. package/dist/components/driver.d.ts.map +1 -1
  46. package/dist/components/verbs/index.d.ts +6 -1
  47. package/dist/components/verbs/index.d.ts.map +1 -1
  48. package/dist/components/verbs/run-agent.d.ts +499 -0
  49. package/dist/components/verbs/run-agent.d.ts.map +1 -0
  50. package/dist/components/verbs/sign.d.ts +30 -0
  51. package/dist/components/verbs/sign.d.ts.map +1 -1
  52. package/dist/composite.d.ts +6 -1
  53. package/dist/composite.d.ts.map +1 -1
  54. package/dist/discovery/collect.d.ts.map +1 -1
  55. package/dist/discovery/fold-import.d.ts +15 -1
  56. package/dist/discovery/fold-import.d.ts.map +1 -1
  57. package/dist/discovery/fold-rank.d.ts +66 -0
  58. package/dist/discovery/fold-rank.d.ts.map +1 -0
  59. package/dist/discovery/index.d.ts +15 -0
  60. package/dist/discovery/index.d.ts.map +1 -1
  61. package/dist/discovery/param-deps.d.ts +17 -0
  62. package/dist/discovery/param-deps.d.ts.map +1 -0
  63. package/dist/fold/fold.d.ts +55 -2
  64. package/dist/fold/fold.d.ts.map +1 -1
  65. package/dist/fold/subset.d.ts +21 -14
  66. package/dist/fold/subset.d.ts.map +1 -1
  67. package/dist/lexicon-schema.d.ts +2 -0
  68. package/dist/lexicon-schema.d.ts.map +1 -1
  69. package/dist/lexicon.d.ts +93 -0
  70. package/dist/lexicon.d.ts.map +1 -1
  71. package/dist/lifecycle/converge-ledger.d.ts +90 -0
  72. package/dist/lifecycle/converge-ledger.d.ts.map +1 -0
  73. package/dist/lifecycle/deep-diff.d.ts +18 -0
  74. package/dist/lifecycle/deep-diff.d.ts.map +1 -1
  75. package/dist/lifecycle/deep-observe.d.ts +9 -1
  76. package/dist/lifecycle/deep-observe.d.ts.map +1 -1
  77. package/dist/lifecycle/gate-ledger.d.ts +33 -0
  78. package/dist/lifecycle/gate-ledger.d.ts.map +1 -0
  79. package/dist/lifecycle/git.d.ts +145 -21
  80. package/dist/lifecycle/git.d.ts.map +1 -1
  81. package/dist/lifecycle/index.d.ts +4 -0
  82. package/dist/lifecycle/index.d.ts.map +1 -1
  83. package/dist/lifecycle/lease.d.ts +113 -0
  84. package/dist/lifecycle/lease.d.ts.map +1 -0
  85. package/dist/lifecycle/scenario-eval.d.ts +42 -0
  86. package/dist/lifecycle/scenario-eval.d.ts.map +1 -0
  87. package/dist/lifecycle/scenario.d.ts +163 -0
  88. package/dist/lifecycle/scenario.d.ts.map +1 -0
  89. package/dist/lifecycle/symptoms.d.ts +63 -0
  90. package/dist/lifecycle/symptoms.d.ts.map +1 -0
  91. package/dist/lint/output-docs.d.ts +94 -0
  92. package/dist/lint/output-docs.d.ts.map +1 -0
  93. package/dist/lint/post-synth.d.ts +29 -0
  94. package/dist/lint/post-synth.d.ts.map +1 -1
  95. package/dist/lint/rules/__fixtures__/comp/comp003/pass/agent-turn.component.d.ts +11 -0
  96. package/dist/lint/rules/__fixtures__/comp/comp003/pass/agent-turn.component.d.ts.map +1 -0
  97. package/dist/lsp/lexicon-providers.d.ts +7 -0
  98. package/dist/lsp/lexicon-providers.d.ts.map +1 -1
  99. package/dist/op/activity-contract.d.ts +139 -0
  100. package/dist/op/activity-contract.d.ts.map +1 -0
  101. package/dist/op/builders.d.ts +42 -2
  102. package/dist/op/builders.d.ts.map +1 -1
  103. package/dist/op/converge-rule.d.ts +161 -0
  104. package/dist/op/converge-rule.d.ts.map +1 -0
  105. package/dist/op/generate-pipeline.d.ts +39 -0
  106. package/dist/op/generate-pipeline.d.ts.map +1 -0
  107. package/dist/op/index.d.ts +14 -0
  108. package/dist/op/index.d.ts.map +1 -1
  109. package/dist/op/local-executor.d.ts.map +1 -1
  110. package/dist/op/op-verb-class.d.ts +42 -0
  111. package/dist/op/op-verb-class.d.ts.map +1 -0
  112. package/dist/op/operator.d.ts +128 -0
  113. package/dist/op/operator.d.ts.map +1 -0
  114. package/dist/op/step-output-ref.d.ts +187 -0
  115. package/dist/op/step-output-ref.d.ts.map +1 -0
  116. package/dist/op/types.d.ts +18 -1
  117. package/dist/op/types.d.ts.map +1 -1
  118. package/dist/provenance.d.ts +73 -3
  119. package/dist/provenance.d.ts.map +1 -1
  120. package/dist/runtime-adapter.d.ts +7 -1
  121. package/dist/runtime-adapter.d.ts.map +1 -1
  122. package/dist/serializer.d.ts +18 -0
  123. package/dist/serializer.d.ts.map +1 -1
  124. package/dist/toml.d.ts +40 -5
  125. package/dist/toml.d.ts.map +1 -1
  126. package/package.json +1 -1
  127. package/src/audit/catalog.test.ts +1 -1
  128. package/src/audit/catalog.ts +75 -3
  129. package/src/audit/core.ts +9 -0
  130. package/src/audit/discover.ts +29 -2
  131. package/src/audit/fetch.test.ts +216 -3
  132. package/src/audit/fetch.ts +270 -59
  133. package/src/audit/report-html.ts +5 -2
  134. package/src/audit/report-model.ts +9 -0
  135. package/src/audit/report.test.ts +22 -0
  136. package/src/audit/report.ts +3 -2
  137. package/src/audit/rules-doc.ts +2 -0
  138. package/src/audit/secrets.test.ts +303 -0
  139. package/src/audit/secrets.ts +406 -0
  140. package/src/audit/wrangler.test.ts +230 -0
  141. package/src/audit/wrangler.ts +290 -0
  142. package/src/build.ts +8 -3
  143. package/src/cli/command-group.ts +1 -1
  144. package/src/cli/commands/__fixtures__/schemas/sarif-2.1.0.schema.json +2882 -0
  145. package/src/cli/commands/audit.test.ts +215 -1
  146. package/src/cli/commands/audit.ts +86 -17
  147. package/src/cli/commands/build.test.ts +167 -2
  148. package/src/cli/commands/build.ts +114 -23
  149. package/src/cli/handlers/build.ts +2 -0
  150. package/src/cli/handlers/components.test.ts +199 -1
  151. package/src/cli/handlers/components.ts +160 -3
  152. package/src/cli/handlers/graph.test.ts +20 -0
  153. package/src/cli/handlers/graph.ts +10 -1
  154. package/src/cli/handlers/lifecycle.ts +12 -4
  155. package/src/cli/handlers/operator.test.ts +255 -0
  156. package/src/cli/handlers/operator.ts +240 -0
  157. package/src/cli/handlers/scenario.test.ts +456 -0
  158. package/src/cli/handlers/scenario.ts +330 -0
  159. package/src/cli/main.test.ts +23 -0
  160. package/src/cli/main.ts +72 -1
  161. package/src/cli/mcp/server.test.ts +265 -2
  162. package/src/cli/mcp/server.ts +84 -7
  163. package/src/cli/mcp/types.ts +27 -1
  164. package/src/cli/registry.ts +14 -2
  165. package/src/codegen/docs-rule-scanning.test.ts +42 -0
  166. package/src/codegen/docs-rule-scanning.ts +25 -2
  167. package/src/components/README.md +7 -0
  168. package/src/components/capability.ts +17 -2
  169. package/src/components/cli-support.test.ts +17 -0
  170. package/src/components/cli-support.ts +13 -1
  171. package/src/components/component-schema.test.ts +32 -0
  172. package/src/components/component.schema.json +6 -0
  173. package/src/components/component.test.ts +21 -0
  174. package/src/components/component.ts +15 -0
  175. package/src/components/driver.ts +12 -4
  176. package/src/components/verbs/index.ts +6 -1
  177. package/src/components/verbs/run-agent.test.ts +683 -0
  178. package/src/components/verbs/run-agent.ts +786 -0
  179. package/src/components/verbs/sign.test.ts +19 -0
  180. package/src/components/verbs/sign.ts +34 -2
  181. package/src/composite.ts +31 -2
  182. package/src/discovery/collect.ts +11 -2
  183. package/src/discovery/fold-import.test.ts +54 -0
  184. package/src/discovery/fold-import.ts +178 -38
  185. package/src/discovery/fold-rank.test.ts +197 -0
  186. package/src/discovery/fold-rank.ts +346 -0
  187. package/src/discovery/index.ts +16 -1
  188. package/src/discovery/param-deps.test.ts +118 -0
  189. package/src/discovery/param-deps.ts +170 -0
  190. package/src/fold/fold.test.ts +6 -2
  191. package/src/fold/fold.ts +184 -3
  192. package/src/fold/subset.test.ts +82 -19
  193. package/src/fold/subset.ts +79 -41
  194. package/src/lexicon-schema.ts +3 -0
  195. package/src/lexicon.ts +103 -2
  196. package/src/lifecycle/converge-ledger.test.ts +199 -0
  197. package/src/lifecycle/converge-ledger.ts +179 -0
  198. package/src/lifecycle/deep-diff.test.ts +79 -1
  199. package/src/lifecycle/deep-diff.ts +23 -0
  200. package/src/lifecycle/deep-observe.ts +13 -2
  201. package/src/lifecycle/gate-ledger.test.ts +103 -0
  202. package/src/lifecycle/gate-ledger.ts +140 -0
  203. package/src/lifecycle/git.test.ts +430 -0
  204. package/src/lifecycle/git.ts +446 -84
  205. package/src/lifecycle/index.ts +4 -0
  206. package/src/lifecycle/lease.test.ts +343 -0
  207. package/src/lifecycle/lease.ts +270 -0
  208. package/src/lifecycle/scenario-eval.test.ts +199 -0
  209. package/src/lifecycle/scenario-eval.ts +158 -0
  210. package/src/lifecycle/scenario.test.ts +195 -0
  211. package/src/lifecycle/scenario.ts +321 -0
  212. package/src/lifecycle/symptoms.test.ts +116 -0
  213. package/src/lifecycle/symptoms.ts +126 -0
  214. package/src/lint/output-docs.test.ts +220 -0
  215. package/src/lint/output-docs.ts +204 -0
  216. package/src/lint/post-synth.test.ts +97 -0
  217. package/src/lint/post-synth.ts +45 -0
  218. package/src/lint/rules/__fixtures__/comp/comp003/pass/agent-turn.component.ts +26 -0
  219. package/src/lint/rules/comp/comp.test.ts +49 -1
  220. package/src/lint/rules/evl001-non-literal-expression.test.ts +8 -3
  221. package/src/lint/rules/evl001-non-literal-expression.ts +6 -6
  222. package/src/lsp/lexicon-providers.test.ts +44 -0
  223. package/src/lsp/lexicon-providers.ts +11 -1
  224. package/src/op/activity-contract.test.ts +180 -0
  225. package/src/op/activity-contract.ts +278 -0
  226. package/src/op/builders-exports.test.ts +17 -1
  227. package/src/op/builders.ts +59 -5
  228. package/src/op/converge-rule.test.ts +179 -0
  229. package/src/op/converge-rule.ts +311 -0
  230. package/src/op/generate-pipeline.test.ts +53 -0
  231. package/src/op/generate-pipeline.ts +99 -0
  232. package/src/op/index.ts +30 -0
  233. package/src/op/local-executor.test.ts +92 -0
  234. package/src/op/local-executor.ts +45 -9
  235. package/src/op/op-verb-class.test.ts +126 -0
  236. package/src/op/op-verb-class.ts +115 -0
  237. package/src/op/operator.test.ts +346 -0
  238. package/src/op/operator.ts +213 -0
  239. package/src/op/step-output-ref.test.ts +334 -0
  240. package/src/op/step-output-ref.ts +453 -0
  241. package/src/op/types.ts +18 -1
  242. package/src/provenance.test.ts +151 -4
  243. package/src/provenance.ts +118 -4
  244. package/src/runtime-adapter.ts +31 -10
  245. package/src/serializer.ts +18 -0
  246. package/src/toml.test.ts +157 -384
  247. package/src/toml.ts +371 -5
@@ -0,0 +1 @@
1
+ {"version":3,"file":"converge-ledger.d.ts","sourceRoot":"","sources":["../../src/lifecycle/converge-ledger.ts"],"names":[],"mappings":"AAmCA,wCAAwC;AACxC,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,CAAC;IACf;;;;;;;;OAQG;IACH,MAAM,EAAE,KAAK,GAAG,UAAU,GAAG,gBAAgB,GAAG,cAAc,GAAG,OAAO,CAAC;IACzE,gEAAgE;IAChE,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,qDAAqD;IACrD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,6JAA6J;IAC7J,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,0CAA0C;AAC1C,MAAM,WAAW,kBAAkB;IACjC,wFAAwF;IACxF,OAAO,EAAE,CAAC,CAAC;IACX,+CAA+C;IAC/C,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,6IAA6I;IAC7I,SAAS,EAAE,MAAM,CAAC;IAClB,oHAAoH;IACpH,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,8CAA8C;IAC9C,QAAQ,EAAE,mBAAmB,EAAE,CAAC;IAChC,wDAAwD;IACxD,OAAO,EAAE;QACP,OAAO,EAAE,MAAM,CAAC;QAChB,UAAU,EAAE,MAAM,CAAC;QACnB,QAAQ,EAAE,MAAM,CAAC;QACjB,aAAa,EAAE,MAAM,CAAC;QACtB,WAAW,EAAE,MAAM,CAAC;QACpB,UAAU,EAAE,MAAM,CAAC;QACnB,OAAO,EAAE,MAAM,CAAC;QAChB,uNAAuN;QACvN,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,iHAAiH;IACjH,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,MAAM,uBAAuB,GAAG,IAAI,CAAC,kBAAkB,EAAE,SAAS,CAAC,CAAC;AAE1E;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,oBAAoB,CACxC,KAAK,EAAE,uBAAuB,EAC9B,IAAI,CAAC,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GACtB,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,kBAAkB,CAAA;CAAE,CAAC,CAqBzD;AAED,6MAA6M;AAC7M,wBAAsB,kBAAkB,CACtC,WAAW,EAAE,MAAM,EACnB,IAAI,CAAC,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GACtB,OAAO,CAAC;IAAE,OAAO,EAAE,kBAAkB,EAAE,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,CA0B/D;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,kBAAkB,EAAE,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAO1F"}
@@ -22,6 +22,7 @@
22
22
  * interpolated property forever.
23
23
  */
24
24
  import { type DeepNormalizationHooks, type NormalizedDeepObservation } from "../deep-observation.js";
25
+ import { type PathOrigin } from "../provenance.js";
25
26
  import type { UnobservedResource } from "./live-diff.js";
26
27
  import { type BaselineLexicon } from "./observation-baseline.js";
27
28
  /**
@@ -61,6 +62,18 @@ export interface PropertyDrift {
61
62
  * with no per-field ownership, which is every substrate but k8s.
62
63
  */
63
64
  owner?: string;
65
+ /**
66
+ * What produced this path on the DECLARED side (#1443) — the counterpart of
67
+ * {@link owner}, and the reason the two are reported together: "owned live by
68
+ * `hpa-controller`, governed in source by the `tier` parameter" says where
69
+ * each half of a disagreement has to be fixed, which neither half says alone.
70
+ *
71
+ * Resolved by longest prefix from the entity's recorded path origins, so a
72
+ * field inside a keyed list element inherits the origin recorded for the
73
+ * list. Absent when the build recorded none — the run path, and a sandboxed
74
+ * child, have no expression to attribute (see `EntityProvenance.paths`).
75
+ */
76
+ origin?: PathOrigin;
64
77
  }
65
78
  /** Property-level drift for one declared entity. */
66
79
  export interface DeepEntityDrift {
@@ -88,6 +101,11 @@ export interface DeepDiffResult {
88
101
  export interface DeclaredDeepEntity {
89
102
  type: string;
90
103
  properties: Record<string, unknown>;
104
+ /**
105
+ * The entity's recorded path origins (#1443), as `EntityProvenance.paths`.
106
+ * Omit for a build that recorded none.
107
+ */
108
+ pathOrigins?: Record<string, PathOrigin>;
91
109
  }
92
110
  export interface DiffDeepInput {
93
111
  /** Normalized declared property trees, keyed by chant entity name. */
@@ -1 +1 @@
1
- {"version":3,"file":"deep-diff.d.ts","sourceRoot":"","sources":["../../src/lifecycle/deep-diff.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAIL,KAAK,sBAAsB,EAC3B,KAAK,yBAAyB,EAC/B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAqB,KAAK,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEjF;;;;;;;;;GASG;AACH,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,YAAY,GAAG,QAAQ,CAAC;AAEpE,qCAAqC;AACrC,MAAM,WAAW,aAAa;IAC5B,kEAAkE;IAClE,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,iBAAiB,CAAC;IACxB,gDAAg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AM,EAAE,CAAC;CAC9B;AAED,sFAAsF;AACtF,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACpC;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;CAC1C;AAED,MAAM,WAAW,aAAa;IAC5B,sEAAsE;IACtE,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;IAC7C,4EAA4E;IAC5E,IAAI,EAAE,yBAAyB,CAAC;IAChC,yEAAyE;IACzE,QAAQ,CAAC,EAAE,eAAe,CAAC;IAC3B;;;;;OAKG;IACH,KAAK,CAAC,EAAE,sBAAsB,CAAC;CAChC;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,aAAa,GAAG,cAAc,CAwG7D;AAED,+DAA+D;AAC/D,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,CAEjE"}
@@ -18,12 +18,20 @@
18
18
  */
19
19
  import type { ObservationLexicon } from "../lexicon.js";
20
20
  import { type DeepNormalizationHooks, type NormalizedDeepObservation } from "../deep-observation.js";
21
+ import type { PathOrigin } from "../provenance.js";
21
22
  import { type DeepDiffResult } from "./deep-diff.js";
22
23
  import type { BaselineLexicon } from "./observation-baseline.js";
23
- /** Declared entities for one lexicon, in the shape the observe paths pass around. */
24
+ /**
25
+ * Declared entities for one lexicon, in the shape the observe paths pass around.
26
+ *
27
+ * `pathOrigins` (#1443) rides alongside `props` rather than being read off the
28
+ * entity, because callers rebuild this map as plain objects and the symbol-keyed
29
+ * provenance channel does not survive that copy.
30
+ */
24
31
  export type DeclaredEntities = Map<string, {
25
32
  entityType: string;
26
33
  props: Record<string, unknown>;
34
+ pathOrigins?: Record<string, PathOrigin>;
27
35
  }>;
28
36
  export interface DeepObserveOptions {
29
37
  environment: string;
@@ -1 +1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;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,QAAQ,CAAC,yBAAyB,CAAC,GACzC,yBAAyB,CAS3B;AAED;;;;;GAKG;AACH,wBAAsB,WAAW,CAC/B,MAAM,EAAE,kBAAkB,EAC1B,IAAI,EAAE,kBAAkB,GACvB,OAAO,CAAC,yBAAyB,CAAC,CA+BpC;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,gBAAgB,EAC1B,IAAI,EAAE,yBAAyB,EAC/B,KAAK,CAAC,EAAE,sBAAsB,EAC9B,QAAQ,CAAC,EAAE,eAAe,GACzB,cAAc,CAoDhB;AAED,oFAAoF;AACpF,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,kBAAkB,EAC1B,IAAI,EAAE,kBAAkB,GAAG;IAAE,QAAQ,CAAC,EAAE,eAAe,CAAA;CAAE,GACxD,OAAO,CAAC,cAAc,CAAC,CAGzB"}
@@ -0,0 +1,33 @@
1
+ /** One immutable gate-resolution record. */
2
+ export interface GateResolutionRecord {
3
+ /** Schema version, so an incompatible future shape is detected before being misread. */
4
+ version: 1;
5
+ /** The dispatched op the gate belongs to. */
6
+ op: string;
7
+ /** The gate's signal name (matches `ConvergeRuleOutcome.gateName`). */
8
+ gate: string;
9
+ /** Who resolved it — an actor name, the same convention `components release --actor` and `run signal --approver` use. */
10
+ resolvedBy: string;
11
+ /** ISO-8601 timestamp, caller-supplied (library code never calls `Date.now()` internally). */
12
+ timestamp: string;
13
+ /** Optional free-text context (e.g. a PR URL — "or a merged PR" is the issue's other resolution path; recording its link here keeps both paths visible from one ledger). */
14
+ note?: string;
15
+ }
16
+ export type GateResolutionInput = Omit<GateResolutionRecord, "version">;
17
+ /** Append one immutable gate-resolution record. Does not push to the remote — call `pushLifecycle` (./git.ts) afterward, same two-step shape every other ledger write here uses. Retries on `RefCASConflictError` the same way `appendConvergeRecord` does (./converge-ledger.ts) — a concurrent writer to a different op's/env's file on the same orphan branch is the ordinary case, not an edge case. The baseline read must be `readPathSha` + `readBlobBySha` rather than `readBlobFromPath`, so the exact sha `existing` came from can be passed as `expectPriorPathSha` — see `writeBlobToPath` (./git.ts) for the race that closes. */
18
+ export declare function appendGateResolution(input: GateResolutionInput, opts?: {
19
+ cwd?: string;
20
+ }): Promise<{
21
+ commit: string;
22
+ record: GateResolutionRecord;
23
+ }>;
24
+ /** Read every gate-resolution record for `op`, oldest first. Malformed lines are skipped, not thrown on, the same graceful-degradation stance `readConvergeLedger` takes. Returns `[]` (never throws) when `op` has no resolutions recorded yet. */
25
+ export declare function readGateResolutions(op: string, opts?: {
26
+ cwd?: string;
27
+ }): Promise<{
28
+ records: GateResolutionRecord[];
29
+ malformed: number;
30
+ }>;
31
+ /** The most recent resolution for `gate` recorded after `sinceIso` (a gated tick's own timestamp) — what `chant operator status` uses to tell a resolved gate from a still-pending one. `undefined` when no such resolution exists. */
32
+ export declare function latestResolutionSince(records: GateResolutionRecord[], gate: string, sinceIso: string): GateResolutionRecord | undefined;
33
+ //# sourceMappingURL=gate-ledger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gate-ledger.d.ts","sourceRoot":"","sources":["../../src/lifecycle/gate-ledger.ts"],"names":[],"mappings":"AA4CA,4CAA4C;AAC5C,MAAM,WAAW,oBAAoB;IACnC,wFAAwF;IACxF,OAAO,EAAE,CAAC,CAAC;IACX,6CAA6C;IAC7C,EAAE,EAAE,MAAM,CAAC;IACX,uEAAuE;IACvE,IAAI,EAAE,MAAM,CAAC;IACb,yHAAyH;IACzH,UAAU,EAAE,MAAM,CAAC;IACnB,8FAA8F;IAC9F,SAAS,EAAE,MAAM,CAAC;IAClB,4KAA4K;IAC5K,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,MAAM,mBAAmB,GAAG,IAAI,CAAC,oBAAoB,EAAE,SAAS,CAAC,CAAC;AAMxE,+mBAA+mB;AAC/mB,wBAAsB,oBAAoB,CACxC,KAAK,EAAE,mBAAmB,EAC1B,IAAI,CAAC,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GACtB,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,oBAAoB,CAAA;CAAE,CAAC,CAqB3D;AAED,oPAAoP;AACpP,wBAAsB,mBAAmB,CACvC,EAAE,EAAE,MAAM,EACV,IAAI,CAAC,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GACtB,OAAO,CAAC;IAAE,OAAO,EAAE,oBAAoB,EAAE,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,CA0BjE;AAED,uOAAuO;AACvO,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,oBAAoB,EAAE,EAC/B,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,GACf,oBAAoB,GAAG,SAAS,CASlC"}
@@ -1,26 +1,6 @@
1
- /**
2
- * Write a blob to an arbitrary `<environment>/<filename>` path on the orphan
3
- * branch, preserving every other env/file entry already on the branch.
4
- *
5
- * Pipeline: hash-object → mktree → commit-tree → update-ref. Factored out of
6
- * `writeSnapshot` so the release ledger (#568, epic #551 "Build & deploy
7
- * observability") can reuse the identical git-plumbing path for a different
8
- * filename (`releases.jsonl`) under the same env directory, rather than a
9
- * parallel storage mechanism.
10
- *
11
- * Exported (not just used internally) so ./build-ledger-store.ts (#609) can
12
- * reuse this exact plumbing for a top-level directory that isn't really an
13
- * "environment" (`_builds`, keyed by manifest digest rather than env name) —
14
- * a build archive is promoted by digest across environments, never owned by
15
- * one, so it belongs in its own digest-keyed namespace on the same orphan
16
- * branch rather than duplicated per env. The parameter is still named
17
- * `environment` because it is literally the first path segment / root-tree
18
- * entry name this function's tree-building logic groups by; callers outside
19
- * this module that pass a non-env value (like `_builds`) are relying on that
20
- * generic behavior, not on any env-specific semantics.
21
- */
22
1
  export declare function writeBlobToPath(environment: string, filename: string, content: string, commitMessage: string, opts?: {
23
2
  cwd?: string;
3
+ expectPriorPathSha?: string | null;
24
4
  }): Promise<string>;
25
5
  /**
26
6
  * Read a blob from an arbitrary `<environment>/<filename>` path on the orphan
@@ -32,6 +12,16 @@ export declare function writeBlobToPath(environment: string, filename: string, c
32
12
  export declare function readBlobFromPath(environment: string, filename: string, opts?: {
33
13
  cwd?: string;
34
14
  }): Promise<string | null>;
15
+ /**
16
+ * Read the blob SHA stored at `<environment>/<filename>` on the orphan branch,
17
+ * or `null` if absent. Sibling of `readBlobFromPath` returning the
18
+ * content-address rather than the content. A read-modify-write ledger append
19
+ * pairs this with {@link readBlobBySha} to pin its baseline read to an exact
20
+ * sha, then passes that sha as `writeBlobToPath`'s `expectPriorPathSha`.
21
+ */
22
+ export declare function readPathSha(environment: string, filename: string, opts?: {
23
+ cwd?: string;
24
+ }): Promise<string | null>;
35
25
  /**
36
26
  * Storage key for a snapshot on the orphan branch. Single-stack projects key by
37
27
  * lexicon (`<env>/<lexicon>.json`, unchanged). A multi-stack project (see
@@ -81,6 +71,20 @@ export declare function readSnapshotAt(environment: string, lexicon: string, ref
81
71
  * Returns the new orphan-branch commit SHA — the caller still owns pushing
82
72
  * via `pushLifecycle` under the same concurrent-write lease `writeSnapshot`
83
73
  * uses.
74
+ *
75
+ * Retries the whole read-modify-append cycle on `RefCASConflictError`
76
+ * (#1959 finding 1), the same shape `appendConvergeRecord`
77
+ * (./converge-ledger.ts) and `appendGateResolution` (./gate-ledger.ts) use
78
+ * for their own append-only ledgers: `writeBlobToPath`'s own retry only
79
+ * absorbs a conflict caused by some *other* env/file changing — a conflict
80
+ * on this exact `releases.jsonl` (e.g. two deploys to the same env racing)
81
+ * needs `existing` re-read fresh so the appended line list is rebuilt onto
82
+ * whatever the other writer just committed, not silently dropped by
83
+ * retrying with a blob computed from a stale read.
84
+ *
85
+ * The baseline read must be `readPathSha` + `readBlobBySha` rather than
86
+ * `readBlobFromPath`, so the exact sha `existing` came from can be passed as
87
+ * `expectPriorPathSha`. See `writeBlobToPath` for the race that closes.
84
88
  */
85
89
  export declare function appendReleaseRecordLine(environment: string, recordJson: string, opts?: {
86
90
  cwd?: string;
@@ -166,6 +170,126 @@ export declare function pushLifecycle(opts?: {
166
170
  export declare function fetchLifecycle(opts?: {
167
171
  cwd?: string;
168
172
  }): Promise<boolean>;
173
+ /**
174
+ * Thrown by {@link updateRefCAS}/{@link deleteRefCAS} when `ref` no longer
175
+ * points at the `oldValue` the caller last observed — another writer moved
176
+ * it concurrently. Deliberately a distinct type from a generic git failure so
177
+ * callers (a lease acquire, a retried ledger append) can tell "I lost a race"
178
+ * from "git itself failed" and react differently to each.
179
+ */
180
+ export declare class RefCASConflictError extends Error {
181
+ readonly ref: string;
182
+ readonly expected: string | null;
183
+ constructor(ref: string, expected: string | null, stderr: string);
184
+ }
185
+ /**
186
+ * Thrown by {@link updateRefCAS}/{@link deleteRefCAS} when the ref update
187
+ * failed because git found a stale `.lock` file already sitting next to the
188
+ * ref (#1959 finding 2) — what a `chant operator`/`chant approve`/etc.
189
+ * process leaves behind when it is killed (SIGKILL, OOM, `kill -9`) mid-write,
190
+ * *before* `git update-ref`'s own lockfile-then-rename completes. This is
191
+ * exactly the crash this feature must recover from, and it is NOT a CAS
192
+ * conflict: nobody else actually holds the ref (no other writer is racing,
193
+ * the previous one is simply dead), so it must never be misread as "someone
194
+ * else updated it first" — see `./lease.ts`'s `acquireLease`, which used to
195
+ * (before this fix) read this as "lease held by someone else" and quietly
196
+ * back off forever, since the dead process's lock file never goes away on
197
+ * its own.
198
+ */
199
+ export declare class StaleLockError extends Error {
200
+ readonly ref: string;
201
+ readonly lockPath: string;
202
+ constructor(ref: string, lockPath: string, stderr: string);
203
+ }
204
+ /** Read the SHA `ref` currently points to, or `null` if it doesn't exist. Works for any ref, not just the lifecycle branch. */
205
+ export declare function readRefSha(ref: string, opts?: {
206
+ cwd?: string;
207
+ }): Promise<string | null>;
208
+ /**
209
+ * Compare-and-swap update of an arbitrary ref. `oldValue` is the SHA the
210
+ * caller last observed the ref at, or `null` to assert the ref does not yet
211
+ * exist (git's own convention: an empty `<oldvalue>` argument to
212
+ * `update-ref` means "must not exist"). Throws {@link RefCASConflictError}
213
+ * when the ref genuinely moved since `oldValue` was read, {@link
214
+ * StaleLockError} when a leftover lock file from a killed process is
215
+ * blocking the write, or a plain `Error` for anything else — never silently
216
+ * overwrites, and never misclassifies one failure as another (#1959 finding
217
+ * 2; see {@link classifyRefFailure}).
218
+ */
219
+ export declare function updateRefCAS(ref: string, newValue: string, oldValue: string | null, opts?: {
220
+ cwd?: string;
221
+ }): Promise<void>;
222
+ /**
223
+ * Compare-and-swap delete of an arbitrary ref — `oldValue` is required (no
224
+ * "delete unconditionally" escape hatch here) so releasing a lease you no
225
+ * longer hold can never delete someone else's newer one. Same failure
226
+ * classification as {@link updateRefCAS} (#1959 finding 2).
227
+ */
228
+ export declare function deleteRefCAS(ref: string, oldValue: string, opts?: {
229
+ cwd?: string;
230
+ }): Promise<void>;
231
+ /**
232
+ * Write arbitrary content as a git blob object — no tree, no commit, no ref
233
+ * update. The building block a CAS ref's value can point at directly: a
234
+ * lease record (`./lease.ts`) has no meaningful "tree of files", so its ref
235
+ * targets a blob SHA rather than a commit the way `writeBlobToPath`'s tree-
236
+ * building pipeline does.
237
+ */
238
+ export declare function writeBlob(content: string, opts?: {
239
+ cwd?: string;
240
+ }): Promise<string>;
241
+ /** Read a blob's raw content by its SHA (whatever object a ref points at directly). Returns `null` when the object doesn't exist locally. */
242
+ export declare function readBlobBySha(sha: string, opts?: {
243
+ cwd?: string;
244
+ }): Promise<string | null>;
245
+ /**
246
+ * Push one arbitrary ref (e.g. a lease ref) to the remote, guarded the same
247
+ * way {@link pushLifecycle} guards the ledger branch: `--force-with-lease`
248
+ * keyed to the remote SHA last observed locally, so a concurrent push from a
249
+ * second machine is rejected rather than silently clobbered. Plain `--force`
250
+ * underneath that lease — a lease ref's value is a bare blob SHA, not a
251
+ * commit descending from the previous one, so there is no "fast-forward" to
252
+ * preserve, only the CAS the lease guard already provides.
253
+ *
254
+ * Returns `false` (never throws) when no remote is configured — a
255
+ * remote-less project's lease is local-only by construction (see
256
+ * `./lease.ts`'s module doc), or when the push itself is rejected (the
257
+ * caller re-reads and retries; see `acquireLease`).
258
+ */
259
+ export declare function pushRef(ref: string, opts?: {
260
+ cwd?: string;
261
+ }): Promise<boolean>;
262
+ /**
263
+ * Fetch one arbitrary remote ref into a local ref of a possibly *different*
264
+ * name (#1959 finding 3). `+` forces the update even when it isn't a
265
+ * fast-forward (a lease ref's new value is rarely a descendant of its old
266
+ * one). Returns `false` (never throws) when no remote is configured.
267
+ *
268
+ * The `localRef !== remoteRef` shape exists so a read path can observe what
269
+ * the remote currently holds without ever touching a local ref another code
270
+ * path treats as CAS-authoritative — see {@link fetchRef}'s doc and
271
+ * `./lease.ts`'s `readLease`, which fetches into a side tracking ref
272
+ * (`refs/chant/lease-remote/<op>`) for exactly this reason.
273
+ */
274
+ export declare function fetchRefInto(remoteRef: string, localRef: string, opts?: {
275
+ cwd?: string;
276
+ }): Promise<boolean>;
277
+ /**
278
+ * Fetch one arbitrary ref from remote into the same local ref name.
279
+ *
280
+ * **Caution for a read path (#1959 finding 3):** this force-overwrites
281
+ * `ref` locally (`+ref:ref`) — safe for a ref only a CAS write path ever
282
+ * mutates locally between fetches, but NOT safe to call from a plain read
283
+ * before every read if some other local writer (in the same clone) might be
284
+ * mid-write: fetching here would force the local ref back to whatever the
285
+ * remote last had, clobbering a just-written, not-yet-pushed local value out
286
+ * from under it. `./lease.ts`'s `readLease` used to do exactly that; it now
287
+ * uses {@link fetchRefInto} against a side tracking ref instead. Prefer
288
+ * `fetchRefInto` for any new read-before-decide path.
289
+ */
290
+ export declare function fetchRef(ref: string, opts?: {
291
+ cwd?: string;
292
+ }): Promise<boolean>;
169
293
  /**
170
294
  * Get the current HEAD commit SHA of the main working branch.
171
295
  */
@@ -1 +1 @@
1
- {"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../../src/lifecycle/git.ts"],"names":[],"mappings":"A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AC,IAAI,CAAC,CAMxG;AAED;;;;;;GAMG;AACH,wBAAsB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAKzF;AAED,6IAA6I;AAC7I,wBAAsB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAKhG;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAgBpF;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,YAAY,CAChC,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,IAAI,CAAC,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GACtB,OAAO,CAAC,OAAO,CAAC,CAOlB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAErF;AAED;;GAEG;AACH,wBAAsB,aAAa,CAAC,IAAI,CAAC,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAO5E"}
@@ -16,4 +16,8 @@ export * from "./build-ledger-store.js";
16
16
  export * from "./oras-referrer-lookup.js";
17
17
  export * from "./status.js";
18
18
  export * from "./teardown.js";
19
+ export * from "./symptoms.js";
20
+ export * from "./converge-ledger.js";
21
+ export * from "./scenario.js";
22
+ export * from "./scenario-eval.js";
19
23
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lifecycle/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC;AACvC,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lifecycle/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC;AACvC,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,113 @@
1
+ export declare const LEASE_REF_PREFIX = "refs/chant/lease/";
2
+ /**
3
+ * Side namespace `readLease` fetches remote lease state into (#1959 finding
4
+ * 3), rather than into `refs/chant/lease/<op>` itself. That ref is the CAS
5
+ * write path's alone (`acquireLease`/`releaseLease`, both via
6
+ * `updateRefCAS`/`deleteRefCAS`); a read path force-fetching directly into
7
+ * it would risk clobbering a just-acquired, not-yet-pushed local lease with
8
+ * the still-stale remote value — the exact race a concurrent `chant operator
9
+ * status` in the same clone could hit during the acquire→push window. See
10
+ * `readLease`'s doc for how the two are reconciled without that risk.
11
+ */
12
+ export declare const LEASE_REMOTE_TRACKING_PREFIX = "refs/chant/lease-remote/";
13
+ /**
14
+ * Default lease TTL — long enough that a normal tick (observe, classify,
15
+ * a budget-bounded number of dispatches) finishes well inside it; short
16
+ * enough that a crashed operator's environment resumes converging soon
17
+ * after, without a human intervening. The operator loop renews well before
18
+ * this elapses (every round it still owns the lease for), so under normal
19
+ * operation the TTL is never actually reached.
20
+ */
21
+ export declare const DEFAULT_LEASE_TTL_MS: number;
22
+ export declare function leaseRef(opName: string): string;
23
+ /** One lease's live state — the entire durable record; there is no history, only the current holder (see this module's doc on why no separate ledger). */
24
+ export interface LeaseRecord {
25
+ op: string;
26
+ /** `<hostname>:<pid>:<random>` — a diagnostic identity, not itself the fencing mechanism (`token` is). */
27
+ holder: string;
28
+ /** Fencing token — new only when the lease actually changes hands; see module doc. */
29
+ token: string;
30
+ acquiredAt: string;
31
+ expiresAt: string;
32
+ }
33
+ /** A stable-enough identity for "who holds this lease", for logs and `chant operator status` — hostname:pid, plus a short random suffix so two processes started in the same pid-reuse window never read as the same holder. */
34
+ export declare function currentHolderId(): string;
35
+ export interface ReadLeaseResult {
36
+ /** The ref's current SHA (the CAS anchor for the next write), or `null` if no lease has ever been written. */
37
+ sha: string | null;
38
+ record?: LeaseRecord;
39
+ }
40
+ /**
41
+ * Read the live lease for `opName`, fetching the remote ref first (best-
42
+ * effort) so a lease held by another machine is visible before deciding
43
+ * whether to acquire.
44
+ *
45
+ * The fetch lands in a side tracking ref (`refs/chant/lease-remote/<op>`),
46
+ * never directly into `refs/chant/lease/<op>` itself (#1959 finding 3) — the
47
+ * canonical local ref is written *only* by the CAS path
48
+ * (`acquireLease`/`releaseLease`), so a read (this function is called
49
+ * before every `acquireLease`, and directly by `chant operator status`) can
50
+ * never force it back to a stale remote value out from under a concurrent
51
+ * local acquirer. The returned `record` is whichever of the local/remote
52
+ * views is more current by `leaseFreshnessKey` (ties keep local): this
53
+ * still gives full cross-machine visibility — a genuinely newer remote
54
+ * holder wins — while a just-acquired, not-yet-pushed local lease (freshest
55
+ * by construction) always survives a same-clone concurrent read. `sha`
56
+ * — the CAS anchor a subsequent `acquireLease`/`releaseLease` writes
57
+ * against — is always the local ref's own actual value; only the local
58
+ * canonical ref is ever a valid basis for a `updateRefCAS`/`deleteRefCAS`
59
+ * call against it, regardless of what the comparison decided about `record`.
60
+ */
61
+ export declare function readLease(opName: string, opts?: {
62
+ cwd?: string;
63
+ }): Promise<ReadLeaseResult>;
64
+ export interface AcquireLeaseResult {
65
+ acquired: boolean;
66
+ lease?: LeaseRecord;
67
+ /** Present when not acquired: the lease record currently held by someone else. */
68
+ heldBy?: LeaseRecord;
69
+ }
70
+ /**
71
+ * Acquire or renew the lease for `opName` as `holder`. Succeeds when the ref
72
+ * doesn't exist yet, is expired, or is already held by `holder` (a renewal:
73
+ * same token, pushed-out expiry). Fails — returns `acquired: false`, without
74
+ * throwing — when it's live-held by someone else, or when a concurrent CAS
75
+ * write is lost to a race that happened between this call's read and its
76
+ * write ({@link RefCASConflictError}); both read identically to a caller
77
+ * deciding whether to tick this round ("someone else has it right now,
78
+ * skip").
79
+ *
80
+ * Deliberately does NOT swallow a `StaleLockError` (./git.ts) into that same
81
+ * "someone else has it" outcome (#1959 finding 2): a leftover `.lock` file
82
+ * from a killed process is not contention, it's wreckage, and treating it as
83
+ * "held by someone else" would make `chant operator` back off forever
84
+ * against a lease nobody can ever actually acquire again without manual
85
+ * intervention. It propagates instead, so the caller (`../op/operator.ts`'s
86
+ * `runOperatorRound`) can surface it as its own distinct, diagnosable event
87
+ * rather than a silent, permanent skip.
88
+ */
89
+ export declare function acquireLease(opName: string, holder: string, opts?: {
90
+ cwd?: string;
91
+ ttlMs?: number;
92
+ now?: () => Date;
93
+ }): Promise<AcquireLeaseResult>;
94
+ /**
95
+ * Release the lease, but only when `holder`/`token` still match the live
96
+ * value — releasing a lease this caller no longer actually holds would
97
+ * silently drop someone else's. Best-effort courtesy: a lease nobody
98
+ * releases is reclaimed anyway once its TTL passes, so a failed release
99
+ * (returns `false`, never throws) is not itself a correctness problem.
100
+ */
101
+ export declare function releaseLease(opName: string, holder: string, token: string, opts?: {
102
+ cwd?: string;
103
+ }): Promise<boolean>;
104
+ /**
105
+ * Does `holder`/`token` still match the live lease? The fencing check a
106
+ * tick uses right before trusting its own work as authoritative (see
107
+ * `../op/operator.ts`). Fetches first, so a lease stolen by another machine
108
+ * is detected, not just a stale local read.
109
+ */
110
+ export declare function stillHoldsLease(opName: string, holder: string, token: string, opts?: {
111
+ cwd?: string;
112
+ }): Promise<boolean>;
113
+ //# sourceMappingURL=lease.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lease.d.ts","sourceRoot":"","sources":["../../src/lifecycle/lease.ts"],"names":[],"mappings":"AAqCA,eAAO,MAAM,gBAAgB,sBAAsB,CAAC;AAEpD;;;;;;;;;GASG;AACH,eAAO,MAAM,4BAA4B,6BAA6B,CAAC;AAEvE;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,QAAa,CAAC;AAE/C,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAE/C;AAoBD,0JAA0J;AAC1J,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,0GAA0G;IAC1G,MAAM,EAAE,MAAM,CAAC;IACf,sFAAsF;IACtF,KAAK,EAAE,MAAM,CAAC;IACd,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B,OAAO,CAAC,OAAO,CAAC,CAGlB"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Pure evaluation of a plan scenario's `expect` clause against a `ChangeSet`
3
+ * (#1292).
4
+ *
5
+ * `evaluateScenario` reads only what the caller hands it — a `ChangeSet` and
6
+ * a `ScenarioExpect` — and does no I/O. Building the change set (reading a
7
+ * fixture, replaying it in place of a live observation) is the CLI handler's
8
+ * job (../cli/handlers/scenario.ts); this module is the part that stays
9
+ * testable without a filesystem, a build, or a fixture.
10
+ *
11
+ * Built on the same primitives `chant lifecycle plan` already computes from:
12
+ * `summarize` for counts, a filter over `cs.entries` for named deletes and
13
+ * ownership, and `evaluateUnobservedGate` (./unobserved-gate.ts, #1568) for
14
+ * the unobserved clause.
15
+ */
16
+ import { type ChangeSet } from "./change-set.js";
17
+ import type { ScenarioExpect } from "./scenario.js";
18
+ /**
19
+ * One clause's verdict — always present in {@link ScenarioVerdict.checks}, in
20
+ * declaration order, whether it passed or not. A scenario with no failing
21
+ * clauses is legible too: every check that ran, and that it held.
22
+ */
23
+ export interface ScenarioCheckResult {
24
+ /** Which `expect` clause this is (`"noop"`, `"create"`, `"deletes"`, …). */
25
+ clause: string;
26
+ pass: boolean;
27
+ /** Present when `pass` is false — what was expected vs what the plan proposes, naming resources for delete/ownership failures. */
28
+ detail?: string;
29
+ }
30
+ /** The result of evaluating one scenario's `expect` against a change set. */
31
+ export interface ScenarioVerdict {
32
+ pass: boolean;
33
+ /** Every clause `expect` declared, evaluated — see {@link ScenarioCheckResult}. */
34
+ checks: ScenarioCheckResult[];
35
+ }
36
+ /**
37
+ * Evaluate `expect` against `cs`. Pure: reads `cs` and `expect`, computes
38
+ * nothing else. Every clause present on `expect` is checked independently and
39
+ * every one contributes to `checks`; `pass` is true only when all of them are.
40
+ */
41
+ export declare function evaluateScenario(cs: ChangeSet, expect: ScenarioExpect): ScenarioVerdict;
42
+ //# sourceMappingURL=scenario-eval.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scenario-eval.d.ts","sourceRoot":"","sources":["../../src/lifecycle/scenario-eval.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAa,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAGzD,OAAO,KAAK,EAA6B,cAAc,EAA4B,MAAM,YAAY,CAAC;AAEtG;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,4EAA4E;IAC5E,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,OAAO,CAAC;IACd,kIAAkI;IAClI,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,6EAA6E;AAC7E,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,OAAO,CAAC;IACd,mFAAmF;IACnF,MAAM,EAAE,mBAAmB,EAAE,CAAC;CAC/B;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,cAAc,GAAG,eAAe,CAgDvF"}