@intentius/chant 0.124.56 → 0.124.58

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 (199) hide show
  1. package/dist/ci-audit/index.d.ts.map +1 -1
  2. package/dist/ci-audit/index.js +1 -2
  3. package/dist/ci-product-words.d.ts +47 -2
  4. package/dist/ci-product-words.d.ts.map +1 -1
  5. package/dist/ci-product-words.js +59 -1
  6. package/dist/ci-product.d.ts +26 -2
  7. package/dist/ci-product.d.ts.map +1 -1
  8. package/dist/ci-product.js +30 -7
  9. package/dist/cli/commands/init.d.ts +2 -0
  10. package/dist/cli/commands/init.d.ts.map +1 -1
  11. package/dist/cli/commands/init.js +1 -1
  12. package/dist/cli/handlers/build.d.ts.map +1 -1
  13. package/dist/cli/handlers/build.js +5 -1
  14. package/dist/cli/handlers/init.d.ts.map +1 -1
  15. package/dist/cli/handlers/init.js +16 -0
  16. package/dist/cli/handlers/lifecycle.d.ts.map +1 -1
  17. package/dist/cli/handlers/lifecycle.js +14 -0
  18. package/dist/cli/handlers/pr.d.ts.map +1 -1
  19. package/dist/cli/handlers/pr.js +90 -35
  20. package/dist/cli/handlers/serve.d.ts.map +1 -1
  21. package/dist/cli/handlers/serve.js +9 -0
  22. package/dist/cli/main.d.ts.map +1 -1
  23. package/dist/cli/main.js +6 -2
  24. package/dist/cli/mcp/product-tools.d.ts +40 -7
  25. package/dist/cli/mcp/product-tools.d.ts.map +1 -1
  26. package/dist/cli/mcp/product-tools.js +59 -15
  27. package/dist/cli/mcp/read-only.d.ts +2 -1
  28. package/dist/cli/mcp/read-only.d.ts.map +1 -1
  29. package/dist/cli/mcp/read-only.js +2 -1
  30. package/dist/cli/mcp/server.d.ts +11 -0
  31. package/dist/cli/mcp/server.d.ts.map +1 -1
  32. package/dist/cli/mcp/server.js +15 -3
  33. package/dist/cli/mcp-config.d.ts +4 -1
  34. package/dist/cli/mcp-config.d.ts.map +1 -1
  35. package/dist/cli/mcp-config.js +6 -2
  36. package/dist/cli/parse-args.d.ts.map +1 -1
  37. package/dist/cli/parse-args.js +9 -0
  38. package/dist/cli/registry.d.ts +8 -0
  39. package/dist/cli/registry.d.ts.map +1 -1
  40. package/dist/components/auto-release.d.ts +5 -2
  41. package/dist/components/auto-release.d.ts.map +1 -1
  42. package/dist/components/auto-release.js +9 -4
  43. package/dist/components/capability.d.ts +10 -0
  44. package/dist/components/capability.d.ts.map +1 -1
  45. package/dist/components/deploy-units.d.ts +12 -0
  46. package/dist/components/deploy-units.d.ts.map +1 -1
  47. package/dist/components/deploy-units.js +20 -1
  48. package/dist/components/pr-pipeline.d.ts +64 -2
  49. package/dist/components/pr-pipeline.d.ts.map +1 -1
  50. package/dist/components/pr-pipeline.js +66 -5
  51. package/dist/components/product-pipeline.d.ts +18 -1
  52. package/dist/components/product-pipeline.d.ts.map +1 -1
  53. package/dist/components/product-pipeline.js +8 -2
  54. package/dist/components/row-lease.d.ts +22 -1
  55. package/dist/components/row-lease.d.ts.map +1 -1
  56. package/dist/components/row-lease.js +32 -6
  57. package/dist/e2e-harness/driver.d.ts.map +1 -1
  58. package/dist/e2e-harness/driver.js +97 -0
  59. package/dist/e2e-harness/forgejo.d.ts +5 -1
  60. package/dist/e2e-harness/forgejo.d.ts.map +1 -1
  61. package/dist/e2e-harness/forgejo.js +35 -0
  62. package/dist/e2e-harness/index.d.ts +7 -0
  63. package/dist/e2e-harness/index.d.ts.map +1 -1
  64. package/dist/e2e-harness/index.js +11 -2
  65. package/dist/e2e-harness/ports.d.ts +31 -0
  66. package/dist/e2e-harness/ports.d.ts.map +1 -1
  67. package/dist/e2e-harness/scenario.d.ts.map +1 -1
  68. package/dist/e2e-harness/scenario.js +9 -5
  69. package/dist/e2e-harness/schemas/e2e-scenario.schema.json +43 -3
  70. package/dist/e2e-harness/schemas/index.d.ts +22 -1
  71. package/dist/e2e-harness/schemas/index.d.ts.map +1 -1
  72. package/dist/e2e-harness/schemas/index.js +1 -1
  73. package/dist/e2e-harness/steps.d.ts.map +1 -1
  74. package/dist/e2e-harness/steps.js +4 -0
  75. package/dist/lexicon.d.ts +9 -0
  76. package/dist/lexicon.d.ts.map +1 -1
  77. package/dist/lifecycle/git.d.ts +39 -3
  78. package/dist/lifecycle/git.d.ts.map +1 -1
  79. package/dist/lifecycle/git.js +223 -15
  80. package/dist/lifecycle/lock-rows.d.ts +23 -0
  81. package/dist/lifecycle/lock-rows.d.ts.map +1 -1
  82. package/dist/lifecycle/lock-rows.js +47 -8
  83. package/dist/lifecycle/resource-lock.d.ts +70 -0
  84. package/dist/lifecycle/resource-lock.d.ts.map +1 -1
  85. package/dist/lifecycle/resource-lock.js +241 -5
  86. package/dist/mcp/types.d.ts +9 -0
  87. package/dist/mcp/types.d.ts.map +1 -1
  88. package/dist/op/gate.js +21 -4
  89. package/dist/op/op-waves-release-port.js +1 -1
  90. package/dist/op/op-waves-release.d.ts +2 -1
  91. package/dist/op/op-waves-release.d.ts.map +1 -1
  92. package/dist/op/op-waves-run.d.ts +8 -0
  93. package/dist/op/op-waves-run.d.ts.map +1 -1
  94. package/dist/op/op-waves-run.js +101 -29
  95. package/dist/op/op-waves.d.ts +18 -0
  96. package/dist/op/op-waves.d.ts.map +1 -1
  97. package/dist/op/op-waves.js +16 -0
  98. package/dist/pr-loop.d.ts.map +1 -1
  99. package/dist/pr-loop.js +1 -2
  100. package/dist/release-floors.d.ts +1 -1
  101. package/dist/release-floors.js +1 -1
  102. package/dist/template-request/index.d.ts +9 -0
  103. package/dist/template-request/index.d.ts.map +1 -0
  104. package/dist/template-request/index.js +8 -0
  105. package/dist/template-request/request-body.d.ts +21 -0
  106. package/dist/template-request/request-body.d.ts.map +1 -0
  107. package/dist/template-request/request-body.js +86 -0
  108. package/dist/template-request/template-request.d.ts +100 -0
  109. package/dist/template-request/template-request.d.ts.map +1 -0
  110. package/dist/template-request/template-request.js +150 -0
  111. package/dist/template-request/template-request.schema.json +100 -0
  112. package/dist/template-request/template-spec.d.ts +83 -0
  113. package/dist/template-request/template-spec.d.ts.map +1 -0
  114. package/dist/template-request/template-spec.js +146 -0
  115. package/dist/template-request/template.schema.json +114 -0
  116. package/dist/template-request/validate.d.ts +4 -0
  117. package/dist/template-request/validate.d.ts.map +1 -0
  118. package/dist/template-request/validate.js +21 -0
  119. package/dist/wave-runtime.mjs +310 -300
  120. package/package.json +8 -1
  121. package/src/ci-audit/index.ts +1 -2
  122. package/src/ci-product-words.test.ts +23 -0
  123. package/src/ci-product-words.ts +68 -3
  124. package/src/ci-product.ts +36 -6
  125. package/src/cli/commands/init.ts +3 -1
  126. package/src/cli/handlers/build.ts +5 -1
  127. package/src/cli/handlers/init.ts +18 -0
  128. package/src/cli/handlers/lifecycle.ts +13 -0
  129. package/src/cli/handlers/pr-before-merge.test.ts +1 -1
  130. package/src/cli/handlers/pr-deploy-inputs.test.ts +1 -1
  131. package/src/cli/handlers/pr-endpoint.test.ts +1 -1
  132. package/src/cli/handlers/pr-green.test.ts +1 -1
  133. package/src/cli/handlers/pr-plan-comment-targets.test.ts +1 -1
  134. package/src/cli/handlers/pr-plan-flags.test.ts +1 -1
  135. package/src/cli/handlers/pr-plan-targets.test.ts +1 -1
  136. package/src/cli/handlers/pr-record.test.ts +34 -2
  137. package/src/cli/handlers/pr-waves-blocked.test.ts +1 -1
  138. package/src/cli/handlers/pr-waves.test.ts +1 -1
  139. package/src/cli/handlers/pr.test.ts +1 -1
  140. package/src/cli/handlers/pr.ts +86 -31
  141. package/src/cli/handlers/serve.ts +9 -0
  142. package/src/cli/main.ts +6 -2
  143. package/src/cli/mcp/product-tools.test.ts +57 -1
  144. package/src/cli/mcp/product-tools.ts +67 -15
  145. package/src/cli/mcp/read-only.ts +2 -1
  146. package/src/cli/mcp/server.ts +20 -5
  147. package/src/cli/mcp-config.test.ts +52 -2
  148. package/src/cli/mcp-config.ts +6 -3
  149. package/src/cli/parse-args.ts +7 -0
  150. package/src/cli/registry.ts +8 -0
  151. package/src/components/auto-release.test.ts +4 -2
  152. package/src/components/auto-release.ts +9 -5
  153. package/src/components/capability.ts +10 -0
  154. package/src/components/deploy-units.test.ts +18 -1
  155. package/src/components/deploy-units.ts +26 -1
  156. package/src/components/pr-pipeline.ts +99 -5
  157. package/src/components/product-actions.test.ts +76 -0
  158. package/src/components/product-pipeline.ts +21 -2
  159. package/src/components/row-lease.test.ts +61 -1
  160. package/src/components/row-lease.ts +48 -7
  161. package/src/e2e-harness/driver.test.ts +163 -0
  162. package/src/e2e-harness/driver.ts +86 -1
  163. package/src/e2e-harness/forgejo.ts +42 -1
  164. package/src/e2e-harness/index.ts +12 -2
  165. package/src/e2e-harness/ports.ts +33 -0
  166. package/src/e2e-harness/scenario.ts +8 -6
  167. package/src/e2e-harness/schemas/README.md +11 -2
  168. package/src/e2e-harness/schemas/e2e-scenario.schema.json +43 -3
  169. package/src/e2e-harness/schemas/index.ts +5 -1
  170. package/src/e2e-harness/schemas.test.ts +44 -1
  171. package/src/e2e-harness/steps.ts +4 -0
  172. package/src/lexicon.ts +9 -0
  173. package/src/lifecycle/git.test.ts +155 -0
  174. package/src/lifecycle/git.ts +213 -17
  175. package/src/lifecycle/lock-rows.test.ts +6 -1
  176. package/src/lifecycle/lock-rows.ts +58 -7
  177. package/src/lifecycle/resource-lock-wait.test.ts +292 -0
  178. package/src/lifecycle/resource-lock.ts +261 -7
  179. package/src/mcp/types.ts +9 -0
  180. package/src/op/gate.test.ts +7 -5
  181. package/src/op/gate.ts +20 -4
  182. package/src/op/op-waves-after-plan.test.ts +1 -2
  183. package/src/op/op-waves-ledger-lock.test.ts +208 -0
  184. package/src/op/op-waves-release-port.ts +1 -1
  185. package/src/op/op-waves-release.ts +1 -1
  186. package/src/op/op-waves-run.ts +104 -29
  187. package/src/op/op-waves.ts +18 -0
  188. package/src/pr-loop-bundle.test.ts +0 -2
  189. package/src/pr-loop.ts +1 -2
  190. package/src/release-floors.ts +1 -1
  191. package/src/template-request/__fixtures__/request-body.md +41 -0
  192. package/src/template-request/index.ts +8 -0
  193. package/src/template-request/request-body.ts +91 -0
  194. package/src/template-request/template-request.schema.json +100 -0
  195. package/src/template-request/template-request.test.ts +316 -0
  196. package/src/template-request/template-request.ts +235 -0
  197. package/src/template-request/template-spec.ts +176 -0
  198. package/src/template-request/template.schema.json +114 -0
  199. package/src/template-request/validate.ts +28 -0
@@ -4,6 +4,8 @@
4
4
  * All operations use git plumbing commands — no checkout, no branch switching,
5
5
  * no working tree changes.
6
6
  */
7
+ import { unlinkSync } from "node:fs";
8
+ import { isAbsolute, join } from "node:path";
7
9
  import { getRuntime } from "../runtime-adapter.js";
8
10
  import { memberLedgerPrefix, resolveMemberLedger } from "./member-ledger.js";
9
11
  import { LIFECYCLE_LOCAL_NOTE } from "./local-note.js";
@@ -723,24 +725,221 @@ export function describeLifecyclePush(result) {
723
725
  */
724
726
  export async function pushLifecycleReport(opts) {
725
727
  try {
726
- const result = await pushLifecycleStatus(opts);
727
- switch (result.status) {
728
- case "pushed":
729
- return { pushed: true };
730
- case "no-remote":
731
- return { pushed: false, pushWarning: LIFECYCLE_LOCAL_NOTE };
732
- case "not-recorded":
733
- return { pushed: false, pushWarning: NO_RECORD_PUSH_NOTE };
734
- case "stale":
735
- return { pushed: false, pushWarning: new StaleLifecycleBranchError(result.expected, result.stderr).message };
736
- case "failed":
737
- return { pushed: false, pushWarning: describeLifecyclePush(result) ?? "the push did not land" };
738
- }
728
+ return pushReportOf(await pushLifecycleStatus(opts));
739
729
  }
740
730
  catch (err) {
741
731
  return { pushed: false, pushWarning: err instanceof Error ? err.message : String(err) };
742
732
  }
743
733
  }
734
+ function pushReportOf(result) {
735
+ switch (result.status) {
736
+ case "pushed":
737
+ return { pushed: true };
738
+ case "no-remote":
739
+ return { pushed: false, pushWarning: LIFECYCLE_LOCAL_NOTE };
740
+ case "not-recorded":
741
+ return { pushed: false, pushWarning: NO_RECORD_PUSH_NOTE };
742
+ case "stale":
743
+ return { pushed: false, pushWarning: new StaleLifecycleBranchError(result.expected, result.stderr).message };
744
+ case "failed":
745
+ return { pushed: false, pushWarning: describeLifecyclePush(result) ?? "the push did not land" };
746
+ }
747
+ }
748
+ /** How many pushes {@link pushLifecycleRebasing} makes, as the snapshot store's `publishRef` does. */
749
+ export const LIFECYCLE_PUSH_TRIES = 3;
750
+ /**
751
+ * Thrown by {@link pushLifecycleRebasing} when the ledger branch did not reach
752
+ * the remote: another writer pushed before each of its tries, or this
753
+ * checkout's commits do not replay on the remote's tip. What this run wrote
754
+ * stays in this checkout's `chant/lifecycle` only.
755
+ */
756
+ export class LifecyclePushLostError extends Error {
757
+ constructor(remote, tries, detail) {
758
+ super(`${STATE_BRANCH} was not pushed to "${remote}" after ${tries} ${tries === 1 ? "try" : "tries"}: ${detail}. ` +
759
+ `The records this run wrote are only in this checkout; run the command again.`);
760
+ this.name = "LifecyclePushLostError";
761
+ this.remote = remote;
762
+ this.tries = tries;
763
+ }
764
+ }
765
+ /** Scratch ref for the remote tip while {@link rebaseLifecycleOnRemote} replays onto it. */
766
+ const REBASE_REF = "refs/chant/lifecycle-rebase";
767
+ /**
768
+ * Put this checkout's `chant/lifecycle` commits that the remote lacks on top
769
+ * of the remote's tip (fetched again), and point the push's lease at that
770
+ * tip. Each commit is replayed with `git merge-tree --write-tree` against its
771
+ * own parent and keeps its author and message; nothing touches a work tree.
772
+ * Returns why it could not, such as a commit whose files the other writer
773
+ * changed too.
774
+ */
775
+ async function rebaseLifecycleOnRemote(remote, cwd) {
776
+ const rt = getRuntime();
777
+ const run = (args, env = {}) => rt.spawn(["git", ...args], { cwd, env: { ...C_LOCALE_ENV, ...env } });
778
+ const firstLine = (s) => (s ?? "").trim().split("\n")[0] ?? "";
779
+ try {
780
+ const fetched = await run(["fetch", "--no-tags", "--force", remote, `refs/heads/${STATE_BRANCH}:${REBASE_REF}`]);
781
+ if (fetched.exitCode !== 0)
782
+ return { error: `the fetch of the remote's tip failed (git said: ${firstLine(fetched.stderr)})` };
783
+ const remoteTip = (await run(["rev-parse", "--verify", REBASE_REF])).stdout.trim();
784
+ const local = await getStateBranchTip(cwd);
785
+ if (!remoteTip || !local)
786
+ return { error: "the remote's tip or the local branch could not be read" };
787
+ if ((await run(["merge-base", "--is-ancestor", remoteTip, local])).exitCode === 0) {
788
+ // Already on the remote's history: only the lease was behind.
789
+ await trackRemoteLifecycle(remote, remoteTip, cwd);
790
+ return { rebased: 0 };
791
+ }
792
+ const ours = (await run(["rev-list", "--reverse", "--first-parent", local, `^${remoteTip}`])).stdout.trim().split("\n").filter(Boolean);
793
+ const identityArgs = await ledgerCommitIdentityArgs(cwd);
794
+ let onto = remoteTip;
795
+ for (const commit of ours) {
796
+ const parent = await run(["rev-parse", "--verify", "--quiet", `${commit}^1`]);
797
+ if (parent.exitCode !== 0)
798
+ return { error: `${commit.slice(0, 12)} shares no history with the remote's ${STATE_BRANCH}` };
799
+ const merged = await run(["merge-tree", "--write-tree", `--merge-base=${parent.stdout.trim()}`, onto, commit]);
800
+ const subject = firstLine((await run(["log", "-1", "--format=%s", commit])).stdout);
801
+ let tree;
802
+ if (merged.exitCode === 1) {
803
+ // plywood#22 finding 9: two writers that each appended lines to one ledger file (a run record, a release record, a gate line) meet here.
804
+ const appended = await replayAppends(parent.stdout.trim(), commit, onto, cwd);
805
+ if ("error" in appended)
806
+ return { error: `"${subject}" (${commit.slice(0, 12)}) changes files the other writer changed too: ${appended.error}` };
807
+ tree = appended.tree;
808
+ }
809
+ else if (merged.exitCode !== 0) {
810
+ return { error: `git merge-tree failed on ${commit.slice(0, 12)} (git said: ${firstLine(merged.stderr)})` };
811
+ }
812
+ else {
813
+ tree = firstLine(merged.stdout);
814
+ }
815
+ const [name, email, date] = (await run(["log", "-1", "--format=%an%x00%ae%x00%aI", commit])).stdout.replace(/\n$/, "").split("\0");
816
+ const message = (await run(["log", "-1", "--format=%B", commit])).stdout;
817
+ const made = await rt.spawn(["git", ...identityArgs, "commit-tree", tree, "-p", onto, "-F", "-"], {
818
+ cwd,
819
+ stdin: message,
820
+ env: { ...C_LOCALE_ENV, GIT_AUTHOR_NAME: name ?? "", GIT_AUTHOR_EMAIL: email ?? "", GIT_AUTHOR_DATE: date ?? "" },
821
+ });
822
+ if (made.exitCode !== 0)
823
+ return { error: `git commit-tree failed on ${commit.slice(0, 12)} (git said: ${firstLine(made.stderr)})` };
824
+ onto = made.stdout.trim();
825
+ }
826
+ try {
827
+ await updateRefCAS(`refs/heads/${STATE_BRANCH}`, onto, local, { cwd });
828
+ }
829
+ catch (err) {
830
+ if (err instanceof RefCASConflictError)
831
+ return { error: `${STATE_BRANCH} moved in this checkout while it was replayed` };
832
+ throw err;
833
+ }
834
+ await trackRemoteLifecycle(remote, remoteTip, cwd);
835
+ return { rebased: ours.length };
836
+ }
837
+ finally {
838
+ await run(["update-ref", "-d", REBASE_REF]);
839
+ }
840
+ }
841
+ /**
842
+ * Replay a commit whose only changes are lines appended to `.jsonl` ledger
843
+ * files, or new `.jsonl` files, onto `onto` (plywood#22 finding 9): each
844
+ * file becomes `onto`'s copy with the commit's new lines after it, less any
845
+ * line `onto` already holds. A run record, a release record and a gate line
846
+ * are such appends, so two writers to one environment's file no longer lose
847
+ * one of them on a replay. Any other change, or a file the commit rewrote
848
+ * rather than appended to, returns why, and the replay stops as before.
849
+ */
850
+ async function replayAppends(parent, commit, onto, cwd) {
851
+ const rt = getRuntime();
852
+ const run = (args, opts = {}) => rt.spawn(["git", ...args], { cwd, env: { ...C_LOCALE_ENV, ...(opts.env ?? {}) }, ...(opts.stdin !== undefined ? { stdin: opts.stdin } : {}) });
853
+ const diff = await run(["diff-tree", "-r", "--no-renames", "--name-status", "-z", parent, commit]);
854
+ if (diff.exitCode !== 0)
855
+ return { error: "git diff-tree failed" };
856
+ const fields = diff.stdout.split("\0").filter((f) => f !== "");
857
+ const changes = [];
858
+ for (let i = 0; i + 1 < fields.length; i += 2)
859
+ changes.push({ status: fields[i], path: fields[i + 1] });
860
+ if (changes.length === 0)
861
+ return { error: "nothing to replay" };
862
+ const blob = async (rev, path) => {
863
+ const out = await run(["cat-file", "blob", `${rev}:${path}`]);
864
+ return out.exitCode === 0 ? out.stdout : null;
865
+ };
866
+ const files = [];
867
+ for (const { status, path } of changes) {
868
+ if (!path.endsWith(".jsonl") || (status !== "M" && status !== "A"))
869
+ return { error: `${path} is not a ledger line file this replay appends to` };
870
+ const ours = (await blob(commit, path)) ?? "";
871
+ const base = status === "M" ? ((await blob(parent, path)) ?? "") : "";
872
+ if (!ours.startsWith(base))
873
+ return { error: `${path} was rewritten, not appended to` };
874
+ const theirs = (await blob(onto, path)) ?? "";
875
+ const have = new Set(theirs.split("\n").filter((l) => l !== ""));
876
+ const added = ours.slice(base.length).split("\n").filter((l) => l !== "" && !have.has(l));
877
+ const head = theirs === "" || theirs.endsWith("\n") ? theirs : `${theirs}\n`;
878
+ files.push({ path, content: added.length > 0 ? `${head}${added.join("\n")}\n` : theirs });
879
+ }
880
+ const indexPath = (await run(["rev-parse", "--git-path", `chant-lifecycle-replay-${process.pid}.index`])).stdout.trim();
881
+ if (!indexPath)
882
+ return { error: "no scratch index path" };
883
+ const index = isAbsolute(indexPath) || !cwd ? indexPath : join(cwd, indexPath);
884
+ const env = { GIT_INDEX_FILE: index };
885
+ try {
886
+ if ((await run(["read-tree", onto], { env })).exitCode !== 0)
887
+ return { error: "git read-tree failed" };
888
+ for (const f of files) {
889
+ const hashed = await run(["hash-object", "-w", "--stdin"], { stdin: f.content });
890
+ if (hashed.exitCode !== 0)
891
+ return { error: `git hash-object failed on ${f.path}` };
892
+ const added = await run(["update-index", "--add", "--cacheinfo", `100644,${hashed.stdout.trim()},${f.path}`], { env });
893
+ if (added.exitCode !== 0)
894
+ return { error: `git update-index failed on ${f.path}` };
895
+ }
896
+ const written = await run(["write-tree"], { env });
897
+ if (written.exitCode !== 0)
898
+ return { error: "git write-tree failed" };
899
+ return { tree: written.stdout.trim() };
900
+ }
901
+ finally {
902
+ try {
903
+ unlinkSync(index);
904
+ }
905
+ catch {
906
+ // No index was written.
907
+ }
908
+ }
909
+ }
910
+ /**
911
+ * {@link pushLifecycleReport} for a writer whose records must reach the
912
+ * remote, such as the merge record `pr-record` writes. A push refused because
913
+ * another writer pushed first fetches the remote's tip, replays this
914
+ * checkout's commits on it ({@link rebaseLifecycleOnRemote}) and pushes again,
915
+ * up to {@link LIFECYCLE_PUSH_TRIES} pushes in all. After the last refusal, or
916
+ * a replay that cannot be made, it throws {@link LifecyclePushLostError}. No
917
+ * remote, recording off and a push git refused for another reason (no
918
+ * network, no credentials) are returned as {@link pushLifecycleReport}
919
+ * returns them.
920
+ */
921
+ export async function pushLifecycleRebasing(opts) {
922
+ const tries = Math.max(1, opts?.tries ?? LIFECYCLE_PUSH_TRIES);
923
+ const cwd = opts?.cwd;
924
+ for (let attempt = 1;; attempt++) {
925
+ let result;
926
+ try {
927
+ result = await pushLifecycleStatus({ cwd });
928
+ }
929
+ catch (err) {
930
+ return { pushed: false, pushWarning: err instanceof Error ? err.message : String(err) };
931
+ }
932
+ if (result.status !== "stale")
933
+ return pushReportOf(result);
934
+ if (attempt >= tries) {
935
+ const said = result.stderr.trim().split("\n")[0];
936
+ throw new LifecyclePushLostError(result.remote, attempt, `another writer pushed before each try${said ? ` (git said: ${said})` : ""}`);
937
+ }
938
+ const rebased = await rebaseLifecycleOnRemote(result.remote, cwd);
939
+ if ("error" in rebased)
940
+ throw new LifecyclePushLostError(result.remote, attempt, rebased.error);
941
+ }
942
+ }
744
943
  /**
745
944
  * Fetch the state branch from remote.
746
945
  */
@@ -842,7 +1041,13 @@ export async function fetchLifecycleStatus(opts) {
842
1041
  await trackRemoteLifecycle(remote, remoteTip, cwd);
843
1042
  return { status: "ahead", remote };
844
1043
  }
845
- return { status: "diverged", remote, stderr };
1044
+ // plywood#22 finding 9: the commits this checkout wrote and never pushed go on top of the remote's tip, as a push that
1045
+ // lost its race replays them, and the read goes on from there. A local branch that shares no history with the remote's,
1046
+ // or whose commits change what the other writer changed, still reads as diverged.
1047
+ const replayed = await rebaseLifecycleOnRemote(remote, cwd);
1048
+ if (!("error" in replayed))
1049
+ return { status: "ahead", remote };
1050
+ return { status: "diverged", remote, stderr: `${stderr}${stderr ? "\n" : ""}the unpushed commits could not be replayed on the remote's tip: ${replayed.error}` };
846
1051
  }
847
1052
  /**
848
1053
  * Thrown when the ledger branch cannot be read, rather than being reported as
@@ -893,7 +1098,10 @@ export class LifecycleLedgerUnreadableError extends Error {
893
1098
  * So there is one rule now, for readers and writers alike:
894
1099
  *
895
1100
  * - `diverged` always refuses. A fork is not the ledger, and nothing good
896
- * comes of reading one as if it were.
1101
+ * comes of reading one as if it were. Before a fetch calls it diverged,
1102
+ * it replays this checkout's unpushed commits on the remote's tip
1103
+ * (plywood#22 finding 9), as a push that lost its race does; only a
1104
+ * branch whose commits cannot be replayed there stays diverged.
897
1105
  * - `unreachable` refuses only when the checkout has no local history at all,
898
1106
  * which is the case that would otherwise read as an empty ledger. With
899
1107
  * local history and no answer from the remote, the read proceeds and the
@@ -16,6 +16,13 @@ export interface PlannedLock {
16
16
  source: "step" | "declared" | "lexicon" | "default";
17
17
  /** The rows, sorted by key. Empty on any grain but `resource`. */
18
18
  rows: LockRow[];
19
+ /**
20
+ * The rows the apply waits for on the `target` and `repo` grains (ruling
21
+ * for ci-products 2026-10-28): the target's own row, from the lexicon's
22
+ * `targetLockRow`, or the `repo` row. Absent when the grain is `resource`
23
+ * or the lexicon names no target row.
24
+ */
25
+ queue?: LockRow[];
19
26
  }
20
27
  /** A lexicon refused the grain asked of a member, by name (#4552: `resource` on Terraform, tofu, Terragrunt and stock Pulumi). */
21
28
  export declare class LockGrainRefusedError extends Error {
@@ -25,6 +32,12 @@ export declare class LockGrainRefusedError extends Error {
25
32
  }
26
33
  /** The key of the row that stands for a whole Pulumi stack (ruling C). */
27
34
  export declare function stackRowKey(project: string, stack: string): string;
35
+ /** The key of the row that stands for a whole Terraform, tofu or Terragrunt root. A choudoufu root keys its resources `root <root> <address>` on the resource grain and never takes this row. */
36
+ export declare function rootRowKey(root: string): string;
37
+ /** The key of the row a `repo`-grain apply waits for: it meets every other row. */
38
+ export declare const REPO_ROW_KEY = "repo";
39
+ /** The row a `repo`-grain apply waits for. */
40
+ export declare function repoLockRow(target: string): LockRow;
28
41
  /** The key of a URN's row. */
29
42
  export declare function urnRowKey(urn: string): string;
30
43
  /** The key of a live object's row: two members that act on one object meet here. */
@@ -41,6 +54,7 @@ export interface LockGrainHooks {
41
54
  defaultLockGrain?(input: never, plan?: never): LockGrain | Promise<LockGrain>;
42
55
  lockGrainRefusal?(input: never, grain: LockGrain, plan?: never): string | undefined | Promise<string | undefined>;
43
56
  lockRows?(input: never, plan: never): LockRow[] | Promise<LockRow[]>;
57
+ targetLockRow?(input: never, plan?: never): LockRow | undefined | Promise<LockRow | undefined>;
44
58
  }
45
59
  /**
46
60
  * A member's grain and rows (#4552): the step input's own `lockGrain` when it
@@ -52,6 +66,15 @@ export interface LockGrainHooks {
52
66
  export declare function resolvePlannedLock(capability: LockGrainHooks, input: unknown, plan: {
53
67
  member: string;
54
68
  }, declared: LockGrain | null | undefined): Promise<PlannedLock>;
69
+ /**
70
+ * The rows an apply on the `target` or `repo` grain waits for (ruling for
71
+ * ci-products 2026-10-28): the `repo` row, or the target's row from the
72
+ * lexicon's `targetLockRow`. Empty for `resource`, and for a lexicon that
73
+ * names no target row.
74
+ */
75
+ export declare function queueRowsOf(capability: LockGrainHooks, input: unknown, member: string, grain: LockGrain, plan?: unknown): Promise<LockRow[]>;
76
+ /** Every row the waiting members of `locks` wait for, deduplicated and sorted. */
77
+ export declare function queueRowsOfLocks(locks: Readonly<Record<string, PlannedLock>> | undefined): LockRow[];
55
78
  /**
56
79
  * A member's grain before anything planned (#4594), by the order
57
80
  * {@link resolvePlannedLock} uses: the step input's own `lockGrain`, else the
@@ -1 +1 @@
1
- {"version":3,"file":"lock-rows.d.ts","sourceRoot":"","sources":["../../src/lifecycle/lock-rows.ts"],"names":[],"mappings":"AA2BA,oCAAoC;AACpC,eAAO,MAAM,WAAW,YAAI,QAAQ,EAAE,UAAU,E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E,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,GAAG,SAAS,GAAG,OAAO,EAAE,CAE/F"}
@@ -6,14 +6,20 @@
6
6
  * `ci.lockGrain` (ruling A) says what one apply holds while it applies, and,
7
7
  * under `ci.locks`, what a pull request's target locks name (ruling D):
8
8
  *
9
- * - `target`: the component, member, root or stack. The apply takes no row
10
- * lease; the engine's own lock keeps one target's applies apart.
9
+ * - `target`: the component, member, root or stack. A lexicon that names
10
+ * the target's row (`targetLockRow`: `stack <project>/<stack>` for stock
11
+ * Pulumi, `root <root>` for Terraform, tofu and Terragrunt) has the apply
12
+ * wait for that row on the ledger, oldest commit first, up to the job's
13
+ * timeout (ruling for ci-products 2026-10-28, "Ledger lock"). Any other
14
+ * lexicon takes no row lease, and the engine's own lock keeps one
15
+ * target's applies apart.
11
16
  * - `resource`: one row per resource the plan changes, from the lexicon's
12
17
  * `lockRows` hook. The apply leases those rows before it applies and lets
13
18
  * go after, and a pull request under `ci.locks` locks the same keys in
14
19
  * place of its component names.
15
- * - `repo`: one apply at a time in the repository, which the pipeline keeps
16
- * (a concurrency group, a resource group, the lock tag on Forgejo).
20
+ * - `repo`: one apply at a time in the repository: the apply waits for the
21
+ * `repo` row, which meets every other row, in the same queue. The waves
22
+ * pipelines carry no concurrency group of their own.
17
23
  *
18
24
  * Absent, each member takes its lexicon's `defaultLockGrain`, else `target`.
19
25
  *
@@ -21,7 +27,10 @@
21
27
  * of cover (ruling C): a `stack <project>/<stack>` row conflicts with every
22
28
  * `urn urn:pulumi:<stack>::<project>::...` row of that stack, which is how a
23
29
  * plunge apply whose components may register children only at apply locks
24
- * the whole stack and still meets a run holding one of its resources.
30
+ * the whole stack and still meets a run holding one of its resources. A
31
+ * waiting grain's rows ({@link PlannedLock.queue}) use the same keys: a stock
32
+ * stack waits on `stack <project>/<stack>`, so a plunge run on that stack's
33
+ * URNs meets it too, and the `repo` row meets every row.
25
34
  */
26
35
  import { parsePulumiUrn } from "../pulumi-urn.js";
27
36
  /** The values of `ci.lockGrain`. */
@@ -43,6 +52,16 @@ export class LockGrainRefusedError extends Error {
43
52
  export function stackRowKey(project, stack) {
44
53
  return `stack ${project}/${stack}`;
45
54
  }
55
+ /** The key of the row that stands for a whole Terraform, tofu or Terragrunt root. A choudoufu root keys its resources `root <root> <address>` on the resource grain and never takes this row. */
56
+ export function rootRowKey(root) {
57
+ return `root ${root}`;
58
+ }
59
+ /** The key of the row a `repo`-grain apply waits for: it meets every other row. */
60
+ export const REPO_ROW_KEY = "repo";
61
+ /** The row a `repo`-grain apply waits for. */
62
+ export function repoLockRow(target) {
63
+ return { key: REPO_ROW_KEY, target, address: "the repository" };
64
+ }
46
65
  /** The key of a URN's row. */
47
66
  export function urnRowKey(urn) {
48
67
  return `urn ${urn}`;
@@ -60,7 +79,7 @@ export function lockRowCover(key) {
60
79
  }
61
80
  /** Whether a holder of row `a` keeps row `b` from being taken: the same key, or one covers the other. */
62
81
  export function lockRowsConflict(a, b) {
63
- return a === b || lockRowCover(a) === b || lockRowCover(b) === a;
82
+ return a === b || a === REPO_ROW_KEY || b === REPO_ROW_KEY || lockRowCover(a) === b || lockRowCover(b) === a;
64
83
  }
65
84
  /** Rows deduplicated by key and sorted, so two takes of the same rows write the same file. */
66
85
  export function sortedLockRows(rows) {
@@ -85,12 +104,32 @@ export async function resolvePlannedLock(capability, input, plan, declared) {
85
104
  const refused = capability.lockGrainRefusal ? await capability.lockGrainRefusal(input, grain, plan) : undefined;
86
105
  if (refused)
87
106
  throw new LockGrainRefusedError(plan.member, grain, refused);
88
- if (grain !== "resource")
89
- return { grain, source, rows: [] };
107
+ if (grain !== "resource") {
108
+ const queue = await queueRowsOf(capability, input, plan.member, grain, plan);
109
+ return { grain, source, rows: [], ...(queue.length > 0 ? { queue } : {}) };
110
+ }
90
111
  if (!capability.lockRows)
91
112
  throw new LockGrainRefusedError(plan.member, grain, `${capability.kind} names no rows for its resources; set ci.lockGrain to target`);
92
113
  return { grain, source, rows: sortedLockRows(await capability.lockRows(input, plan)) };
93
114
  }
115
+ /**
116
+ * The rows an apply on the `target` or `repo` grain waits for (ruling for
117
+ * ci-products 2026-10-28): the `repo` row, or the target's row from the
118
+ * lexicon's `targetLockRow`. Empty for `resource`, and for a lexicon that
119
+ * names no target row.
120
+ */
121
+ export async function queueRowsOf(capability, input, member, grain, plan) {
122
+ if (grain === "repo")
123
+ return [repoLockRow(member)];
124
+ if (grain !== "target" || !capability.targetLockRow)
125
+ return [];
126
+ const row = await capability.targetLockRow(input, plan);
127
+ return row ? [row] : [];
128
+ }
129
+ /** Every row the waiting members of `locks` wait for, deduplicated and sorted. */
130
+ export function queueRowsOfLocks(locks) {
131
+ return sortedLockRows(Object.values(locks ?? {}).flatMap((l) => l.queue ?? []));
132
+ }
94
133
  /**
95
134
  * A member's grain before anything planned (#4594), by the order
96
135
  * {@link resolvePlannedLock} uses: the step input's own `lockGrain`, else the
@@ -11,12 +11,20 @@ export interface LockRowHolder {
11
11
  url?: string;
12
12
  sha?: string;
13
13
  }
14
+ /** A run waiting for rows: who it is, the rows it waits for, and the commit time that orders it. */
15
+ export interface LockRowWaiter extends LockRowHolder {
16
+ keys: string[];
17
+ /** The commit time (ISO 8601) of the commit the run applies. Absent sorts after every waiter that has one. */
18
+ commitAt?: string;
19
+ }
14
20
  /** `_locks/rows/<gate>.json`. */
15
21
  export interface LockRowsFile {
16
22
  version: 1;
17
23
  holders: Record<string, LockRowHolder>;
18
24
  /** Row key to the run that holds it. */
19
25
  rows: Record<string, string>;
26
+ /** The runs waiting for rows (ruling for ci-products 2026-10-28), by run. Left out of the file when empty. */
27
+ waiting?: Record<string, LockRowWaiter>;
20
28
  }
21
29
  /** A row another run holds, conflicting with `wanted`. */
22
30
  export interface HeldLockRow {
@@ -61,6 +69,16 @@ export declare function heldLockRowsIn(file: LockRowsFile, keys: readonly string
61
69
  * `gone`. Pure, so the decision can be checked without git.
62
70
  */
63
71
  export declare function withRowsTaken(file: LockRowsFile, keys: readonly string[], me: LockRowHolder, gone: readonly string[]): LockRowsFile;
72
+ /** The rows file with `me` in the queue for `keys`, less the waiters in `gone`. Pure. */
73
+ export declare function withWaiter(file: LockRowsFile, me: LockRowWaiter, gone?: readonly string[]): LockRowsFile;
74
+ /** The rows file with `me` out of the queue. Pure. */
75
+ export declare function withoutWaiter(file: LockRowsFile, me: string): LockRowsFile;
76
+ /**
77
+ * Whether waiter `a` goes before waiter `b`: the older commit first, then the
78
+ * lower run id (as numbers when both are, else as text), then the commit
79
+ * sha. A waiter with no commit time goes after every one that has one.
80
+ */
81
+ export declare function waiterBefore(a: Pick<LockRowWaiter, "run" | "commitAt" | "sha">, b: Pick<LockRowWaiter, "run" | "commitAt" | "sha">): boolean;
64
82
  /** The rows file after `me` lets go of `keys`; its holder entry goes once it holds no row. */
65
83
  export declare function withRowsReleased(file: LockRowsFile, keys: readonly string[], me: string): LockRowsFile;
66
84
  export interface LockRowsOptions {
@@ -86,6 +104,54 @@ export type TakeLockRowsResult = {
86
104
  * run that is gone are dropped in the same commit.
87
105
  */
88
106
  export declare function takeLockRows(gate: string, rows: readonly LockRow[], me: LockRowHolder, opts?: LockRowsOptions): Promise<TakeLockRowsResult>;
107
+ /** A wait for rows reached its deadline (ruling for ci-products 2026-10-28): nothing applied. Exit 5, as a held row is. */
108
+ export declare class LockWaitTimeoutError extends Error {
109
+ readonly held: HeldLockRow[];
110
+ readonly ahead: LockRowWaiter[];
111
+ readonly waitedSeconds: number;
112
+ readonly lockRowsHeld = true;
113
+ constructor(message: string, held: HeldLockRow[], ahead: LockRowWaiter[], waitedSeconds: number);
114
+ }
115
+ /** How a take waits for its rows. */
116
+ export interface LockRowsWait {
117
+ /** When the wait gives up, in ms since the epoch. */
118
+ deadline: number;
119
+ /** The commit time (ISO 8601) of the commit the run applies, which orders the queue. */
120
+ commitAt?: string;
121
+ /** How long between reads of the rows file, in ms. Default `CHANT_LOCK_POLL` seconds, else 10 s. */
122
+ pollMs?: number;
123
+ /** Where the wait's lines go. Default: none. */
124
+ log?: (line: string) => void;
125
+ /** The clock and the pause, for tests. */
126
+ now?: () => number;
127
+ sleep?: (ms: number) => Promise<void>;
128
+ }
129
+ /** The default wait when a job names no timeout: just under three hours, a Forgejo runner's default job timeout. */
130
+ export declare const DEFAULT_LOCK_WAIT_SECONDS: number;
131
+ /** How long a take waits, in seconds: `CHANT_LOCK_WAIT`, else {@link DEFAULT_LOCK_WAIT_SECONDS}. */
132
+ export declare function lockWaitSeconds(env: Record<string, string | undefined>): number;
133
+ /** The poll interval in ms: `CHANT_LOCK_POLL` seconds, else 10 s. */
134
+ export declare function lockPollMs(env: Record<string, string | undefined>): number;
135
+ /** The commit time of `rev` in `cwd` (ISO 8601), or undefined when git cannot say. */
136
+ export declare function commitTimeOf(rev: string, cwd?: string): Promise<string | undefined>;
137
+ /** The live waiters for a row that meets one of `keys` who go before `me`, and the waiters that are gone. */
138
+ export declare function waitersAhead(file: LockRowsFile, keys: readonly string[], me: LockRowWaiter, alive: LockLiveness): Promise<{
139
+ ahead: LockRowWaiter[];
140
+ gone: string[];
141
+ }>;
142
+ /**
143
+ * Take `rows` for `me`, waiting in the queue until no live run holds any of
144
+ * them and no live waiter that goes first ({@link waiterBefore}) waits for a
145
+ * row that meets one of them. Throws {@link LockWaitTimeoutError} at the
146
+ * deadline, after leaving the queue.
147
+ */
148
+ export declare function waitLockRows(gate: string, rows: readonly LockRow[], me: LockRowHolder, wait: LockRowsWait, opts?: LockRowsOptions): Promise<{
149
+ ok: true;
150
+ tookOver: LockRowHolder[];
151
+ pushed: boolean;
152
+ waitedSeconds: number;
153
+ waited: boolean;
154
+ }>;
89
155
  /** Let go of `keys` where run `me` still holds them. Never throws: a row left held is taken over once the run is gone. */
90
156
  export declare function releaseLockRows(gate: string, keys: readonly string[], me: string, opts?: {
91
157
  cwd?: string;
@@ -107,14 +173,18 @@ export interface LockRowsLease {
107
173
  */
108
174
  export declare function leaseLockRows(gate: string, rows: readonly LockRow[], opts?: LockRowsOptions & {
109
175
  holder?: LockRowHolder;
176
+ wait?: LockRowsWait;
110
177
  }): Promise<{
111
178
  ok: true;
112
179
  lease: LockRowsLease;
113
180
  tookOver: LockRowHolder[];
181
+ waitedSeconds?: number;
182
+ waited?: boolean;
114
183
  } | {
115
184
  ok: false;
116
185
  held: HeldLockRow[];
117
186
  message: string;
187
+ timedOut?: true;
118
188
  }>;
119
189
  export {};
120
190
  //# sourceMappingURL=resource-lock.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"resource-lock.d.ts","sourceRoot":"","sources":["../../src/lifecycle/resource-lock.ts"],"names":[],"mappings":"AAsCA,OAAO,EAAoC,KAAK,OAAO,EAAE,MAAM,aAAa,CAAC;AAG7E,mFAAmF;AACnF,eAAO,MAAM,aAAa,gBAAsB,CAAC;AAEjD,+EAA+E;AAC/E,eAAO,MAAM,0BAA0B,OAAO,CAAC;AAK/C,qFAAqF;AACrF,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,EAAE,EAAE,MAAM,CAAC;IACX,mDAAmD;IACnD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,iCAAiC;AACjC,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,CAAC,CAAC;IACX,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IACvC,wCAAwC;IACxC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC9B;AAED,0DAA0D;AAC1D,MAAM,WAAW,WAAW;IAC1B,oCAAoC;IACpC,GAAG,EAAE,MAAM,CAAC;IACZ,sFAAsF;IACtF,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,aAAa,CAAC;CACvB;AAED,yGAAyG;AACzG,MAAM,MAAM,YAAY,GAAG,CAAC,MAAM,EAAE,aAAa,KAAK,OAAO,CAAC,OAAO,GAAG,MAAM,CAAC,CAAC;AAEhF,+EA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