@warpgogol/forge 9.2.3 → 9.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (247) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/bin/cli.ts +3 -2
  3. package/dist/bin/cli.js +3 -2
  4. package/dist/bin/cli.js.map +1 -1
  5. package/dist/os/adr/handlers/implement-stamp.d.ts +6 -0
  6. package/dist/os/adr/handlers/implement-stamp.d.ts.map +1 -1
  7. package/dist/os/adr/handlers/implement-stamp.js +23 -15
  8. package/dist/os/adr/handlers/implement-stamp.js.map +1 -1
  9. package/dist/os/checks/handlers/counters-journal.d.ts.map +1 -1
  10. package/dist/os/checks/handlers/counters-journal.js +9 -1
  11. package/dist/os/checks/handlers/counters-journal.js.map +1 -1
  12. package/dist/os/core/core.module.d.ts.map +1 -1
  13. package/dist/os/core/core.module.js +27 -36
  14. package/dist/os/core/core.module.js.map +1 -1
  15. package/dist/os/core/lock-holder.d.ts +32 -0
  16. package/dist/os/core/lock-holder.d.ts.map +1 -0
  17. package/dist/os/core/lock-holder.js +81 -0
  18. package/dist/os/core/lock-holder.js.map +1 -0
  19. package/dist/os/core/stamp-lock.d.ts +30 -0
  20. package/dist/os/core/stamp-lock.d.ts.map +1 -0
  21. package/dist/os/core/stamp-lock.js +112 -0
  22. package/dist/os/core/stamp-lock.js.map +1 -0
  23. package/dist/os/flow/digest.d.ts +19 -0
  24. package/dist/os/flow/digest.d.ts.map +1 -1
  25. package/dist/os/flow/digest.js +33 -4
  26. package/dist/os/flow/digest.js.map +1 -1
  27. package/dist/os/flow/flow.module.d.ts.map +1 -1
  28. package/dist/os/flow/flow.module.js +61 -6
  29. package/dist/os/flow/flow.module.js.map +1 -1
  30. package/dist/os/flow/handlers/flow-cut.d.ts +8 -0
  31. package/dist/os/flow/handlers/flow-cut.d.ts.map +1 -1
  32. package/dist/os/flow/handlers/flow-cut.js +91 -5
  33. package/dist/os/flow/handlers/flow-cut.js.map +1 -1
  34. package/dist/os/flow/handlers/flow-digest.d.ts.map +1 -1
  35. package/dist/os/flow/handlers/flow-digest.js +6 -0
  36. package/dist/os/flow/handlers/flow-digest.js.map +1 -1
  37. package/dist/os/flow/handlers/flow-discard.d.ts.map +1 -1
  38. package/dist/os/flow/handlers/flow-discard.js +17 -13
  39. package/dist/os/flow/handlers/flow-discard.js.map +1 -1
  40. package/dist/os/flow/handlers/flow-fix.d.ts.map +1 -1
  41. package/dist/os/flow/handlers/flow-fix.js +99 -10
  42. package/dist/os/flow/handlers/flow-fix.js.map +1 -1
  43. package/dist/os/flow/handlers/flow-integrate.d.ts.map +1 -1
  44. package/dist/os/flow/handlers/flow-integrate.js +32 -15
  45. package/dist/os/flow/handlers/flow-integrate.js.map +1 -1
  46. package/dist/os/flow/handlers/flow-publication-retire.d.ts +17 -0
  47. package/dist/os/flow/handlers/flow-publication-retire.d.ts.map +1 -0
  48. package/dist/os/flow/handlers/flow-publication-retire.js +132 -0
  49. package/dist/os/flow/handlers/flow-publication-retire.js.map +1 -0
  50. package/dist/os/flow/handlers/flow-push.d.ts +7 -0
  51. package/dist/os/flow/handlers/flow-push.d.ts.map +1 -1
  52. package/dist/os/flow/handlers/flow-push.js +106 -15
  53. package/dist/os/flow/handlers/flow-push.js.map +1 -1
  54. package/dist/os/flow/locks.d.ts +6 -1
  55. package/dist/os/flow/locks.d.ts.map +1 -1
  56. package/dist/os/flow/locks.js +53 -23
  57. package/dist/os/flow/locks.js.map +1 -1
  58. package/dist/os/flow/publication-order.d.ts +25 -0
  59. package/dist/os/flow/publication-order.d.ts.map +1 -0
  60. package/dist/os/flow/publication-order.js +75 -0
  61. package/dist/os/flow/publication-order.js.map +1 -0
  62. package/dist/os/flow/publish.d.ts +18 -0
  63. package/dist/os/flow/publish.d.ts.map +1 -1
  64. package/dist/os/flow/publish.js +58 -2
  65. package/dist/os/flow/publish.js.map +1 -1
  66. package/dist/os/flow/registry.d.ts +1 -1
  67. package/dist/os/flow/registry.d.ts.map +1 -1
  68. package/dist/os/flow/registry.js +2 -1
  69. package/dist/os/flow/registry.js.map +1 -1
  70. package/dist/os/flow/release-tags.d.ts +1 -0
  71. package/dist/os/flow/release-tags.d.ts.map +1 -1
  72. package/dist/os/flow/release-tags.js +5 -4
  73. package/dist/os/flow/release-tags.js.map +1 -1
  74. package/dist/os/flow/scripts.d.ts +1 -1
  75. package/dist/os/flow/scripts.d.ts.map +1 -1
  76. package/dist/os/flow/scripts.js +1 -0
  77. package/dist/os/flow/scripts.js.map +1 -1
  78. package/dist/os/flow/task-files.d.ts +11 -0
  79. package/dist/os/flow/task-files.d.ts.map +1 -0
  80. package/dist/os/flow/task-files.js +51 -0
  81. package/dist/os/flow/task-files.js.map +1 -0
  82. package/dist/os/flow/tests/helpers.d.ts +4 -1
  83. package/dist/os/flow/tests/helpers.d.ts.map +1 -1
  84. package/dist/os/flow/tests/helpers.js +9 -5
  85. package/dist/os/flow/tests/helpers.js.map +1 -1
  86. package/dist/os/mission/handlers/archive.d.ts.map +1 -1
  87. package/dist/os/mission/handlers/archive.js +30 -74
  88. package/dist/os/mission/handlers/archive.js.map +1 -1
  89. package/dist/os/mission/lockfile.d.ts +21 -0
  90. package/dist/os/mission/lockfile.d.ts.map +1 -0
  91. package/dist/os/mission/lockfile.js +76 -0
  92. package/dist/os/mission/lockfile.js.map +1 -0
  93. package/dist/os/mission/mission.module.d.ts.map +1 -1
  94. package/dist/os/mission/mission.module.js +2 -1
  95. package/dist/os/mission/mission.module.js.map +1 -1
  96. package/dist/os/rfc/handlers/implement-stamp.d.ts +6 -0
  97. package/dist/os/rfc/handlers/implement-stamp.d.ts.map +1 -1
  98. package/dist/os/rfc/handlers/implement-stamp.js +24 -19
  99. package/dist/os/rfc/handlers/implement-stamp.js.map +1 -1
  100. package/dist/os/system/handlers/outbox-validate.d.ts +8 -0
  101. package/dist/os/system/handlers/outbox-validate.d.ts.map +1 -0
  102. package/dist/os/system/handlers/outbox-validate.js +102 -0
  103. package/dist/os/system/handlers/outbox-validate.js.map +1 -0
  104. package/dist/os/system/handlers/system-map-validate.d.ts +13 -0
  105. package/dist/os/system/handlers/system-map-validate.d.ts.map +1 -0
  106. package/dist/os/system/handlers/system-map-validate.js +78 -0
  107. package/dist/os/system/handlers/system-map-validate.js.map +1 -0
  108. package/dist/os/system/handlers/system-outbox-scan.d.ts +10 -0
  109. package/dist/os/system/handlers/system-outbox-scan.d.ts.map +1 -0
  110. package/dist/os/system/handlers/system-outbox-scan.js +195 -0
  111. package/dist/os/system/handlers/system-outbox-scan.js.map +1 -0
  112. package/dist/os/system/handlers/system-task-collect.d.ts +13 -0
  113. package/dist/os/system/handlers/system-task-collect.d.ts.map +1 -0
  114. package/dist/os/system/handlers/system-task-collect.js +238 -0
  115. package/dist/os/system/handlers/system-task-collect.js.map +1 -0
  116. package/dist/os/system/handlers/system-task-create.d.ts +32 -0
  117. package/dist/os/system/handlers/system-task-create.d.ts.map +1 -0
  118. package/dist/os/system/handlers/system-task-create.js +216 -0
  119. package/dist/os/system/handlers/system-task-create.js.map +1 -0
  120. package/dist/os/system/handlers/system-task-dispatch.d.ts +14 -0
  121. package/dist/os/system/handlers/system-task-dispatch.d.ts.map +1 -0
  122. package/dist/os/system/handlers/system-task-dispatch.js +290 -0
  123. package/dist/os/system/handlers/system-task-dispatch.js.map +1 -0
  124. package/dist/os/system/handlers/system-task-move.d.ts +12 -0
  125. package/dist/os/system/handlers/system-task-move.d.ts.map +1 -0
  126. package/dist/os/system/handlers/system-task-move.js +217 -0
  127. package/dist/os/system/handlers/system-task-move.js.map +1 -0
  128. package/dist/os/system/handlers/system-task-status.d.ts +20 -0
  129. package/dist/os/system/handlers/system-task-status.d.ts.map +1 -0
  130. package/dist/os/system/handlers/system-task-status.js +139 -0
  131. package/dist/os/system/handlers/system-task-status.js.map +1 -0
  132. package/dist/os/system/handlers/system-versionset-record.d.ts +12 -0
  133. package/dist/os/system/handlers/system-versionset-record.d.ts.map +1 -0
  134. package/dist/os/system/handlers/system-versionset-record.js +332 -0
  135. package/dist/os/system/handlers/system-versionset-record.js.map +1 -0
  136. package/dist/os/system/index.d.ts +6 -0
  137. package/dist/os/system/index.d.ts.map +1 -0
  138. package/dist/os/system/index.js +18 -0
  139. package/dist/os/system/index.js.map +1 -0
  140. package/dist/os/system/outbox-schema.d.ts +30 -0
  141. package/dist/os/system/outbox-schema.d.ts.map +1 -0
  142. package/dist/os/system/outbox-schema.js +29 -0
  143. package/dist/os/system/outbox-schema.js.map +1 -0
  144. package/dist/os/system/repo.d.ts +64 -0
  145. package/dist/os/system/repo.d.ts.map +1 -0
  146. package/dist/os/system/repo.js +364 -0
  147. package/dist/os/system/repo.js.map +1 -0
  148. package/dist/os/system/scenario-schemas.d.ts +26 -0
  149. package/dist/os/system/scenario-schemas.d.ts.map +1 -0
  150. package/dist/os/system/scenario-schemas.js +53 -0
  151. package/dist/os/system/scenario-schemas.js.map +1 -0
  152. package/dist/os/system/schemas.d.ts +63 -0
  153. package/dist/os/system/schemas.d.ts.map +1 -0
  154. package/dist/os/system/schemas.js +83 -0
  155. package/dist/os/system/schemas.js.map +1 -0
  156. package/dist/os/system/system.module.d.ts +3 -0
  157. package/dist/os/system/system.module.d.ts.map +1 -0
  158. package/dist/os/system/system.module.js +429 -0
  159. package/dist/os/system/system.module.js.map +1 -0
  160. package/dist/os/system/task-schemas.d.ts +108 -0
  161. package/dist/os/system/task-schemas.d.ts.map +1 -0
  162. package/dist/os/system/task-schemas.js +152 -0
  163. package/dist/os/system/task-schemas.js.map +1 -0
  164. package/dist/os/system/task-store.d.ts +41 -0
  165. package/dist/os/system/task-store.d.ts.map +1 -0
  166. package/dist/os/system/task-store.js +142 -0
  167. package/dist/os/system/task-store.js.map +1 -0
  168. package/dist/os/system/tests/helpers.d.ts +30 -0
  169. package/dist/os/system/tests/helpers.d.ts.map +1 -0
  170. package/dist/os/system/tests/helpers.js +178 -0
  171. package/dist/os/system/tests/helpers.js.map +1 -0
  172. package/dist/src/index.d.ts +3 -0
  173. package/dist/src/index.d.ts.map +1 -1
  174. package/dist/src/index.js +5 -4
  175. package/dist/src/index.js.map +1 -1
  176. package/os/adr/handlers/implement-stamp-lock.test.ts +90 -0
  177. package/os/adr/handlers/implement-stamp.ts +29 -20
  178. package/os/checks/handlers/counters-journal.test.ts +10 -0
  179. package/os/checks/handlers/counters-journal.ts +8 -1
  180. package/os/core/core.module.ts +32 -36
  181. package/os/core/lock-holder.ts +88 -0
  182. package/os/core/stamp-lock.ts +142 -0
  183. package/os/flow/digest.ts +46 -4
  184. package/os/flow/flow.module.ts +62 -6
  185. package/os/flow/handlers/flow-cut.ts +118 -5
  186. package/os/flow/handlers/flow-digest.ts +6 -0
  187. package/os/flow/handlers/flow-discard.ts +22 -13
  188. package/os/flow/handlers/flow-fix.ts +116 -10
  189. package/os/flow/handlers/flow-integrate.ts +31 -15
  190. package/os/flow/handlers/flow-publication-retire.ts +156 -0
  191. package/os/flow/handlers/flow-push.ts +128 -13
  192. package/os/flow/locks.ts +75 -25
  193. package/os/flow/publication-order.ts +99 -0
  194. package/os/flow/publish.ts +73 -2
  195. package/os/flow/registry.ts +5 -2
  196. package/os/flow/release-tags.ts +5 -4
  197. package/os/flow/scripts.ts +2 -0
  198. package/os/flow/task-files.ts +59 -0
  199. package/os/flow/tests/flow-cut-prepare.test.ts +298 -0
  200. package/os/flow/tests/flow-cut.test.ts +5 -1
  201. package/os/flow/tests/flow-publication-retire.test.ts +191 -0
  202. package/os/flow/tests/flow-push-supersede.test.ts +221 -0
  203. package/os/flow/tests/flow-task-files.test.ts +59 -0
  204. package/os/flow/tests/helpers.ts +9 -5
  205. package/os/flow/tests/locks.test.ts +219 -0
  206. package/os/flow/tests/publication-order.test.ts +102 -0
  207. package/os/mission/handlers/archive.test.ts +97 -52
  208. package/os/mission/handlers/archive.ts +31 -76
  209. package/os/mission/lockfile.ts +84 -0
  210. package/os/mission/mission.module.ts +2 -1
  211. package/os/rfc/handlers/implement-stamp-lock.test.ts +133 -0
  212. package/os/rfc/handlers/implement-stamp.ts +30 -24
  213. package/os/system/handlers/outbox-validate.ts +120 -0
  214. package/os/system/handlers/system-map-validate.ts +107 -0
  215. package/os/system/handlers/system-outbox-scan.ts +320 -0
  216. package/os/system/handlers/system-task-collect.ts +305 -0
  217. package/os/system/handlers/system-task-create.ts +271 -0
  218. package/os/system/handlers/system-task-dispatch.ts +387 -0
  219. package/os/system/handlers/system-task-move.ts +353 -0
  220. package/os/system/handlers/system-task-status.ts +176 -0
  221. package/os/system/handlers/system-versionset-record.ts +476 -0
  222. package/os/system/index.ts +47 -0
  223. package/os/system/outbox-schema.ts +47 -0
  224. package/os/system/repo.ts +451 -0
  225. package/os/system/scenario-schemas.ts +62 -0
  226. package/os/system/schemas.ts +102 -0
  227. package/os/system/system.module.ts +449 -0
  228. package/os/system/task-schemas.ts +190 -0
  229. package/os/system/task-store.ts +184 -0
  230. package/os/system/tests/helpers.ts +189 -0
  231. package/os/system/tests/outbox-validate.test.ts +92 -0
  232. package/os/system/tests/system-map-validate.test.ts +321 -0
  233. package/os/system/tests/system-outbox-scan.test.ts +273 -0
  234. package/os/system/tests/system-profile.test.ts +90 -0
  235. package/os/system/tests/system-task-collect.test.ts +293 -0
  236. package/os/system/tests/system-task-dispatch.test.ts +279 -0
  237. package/os/system/tests/system-task-status.test.ts +153 -0
  238. package/os/system/tests/system-task.test.ts +330 -0
  239. package/os/system/tests/system-versionset.test.ts +314 -0
  240. package/package.json +33 -1
  241. package/profiles/system.yaml +650 -0
  242. package/skills/fo/fo-outbox/SKILL.md +71 -0
  243. package/skills/fo/fo-system-dispatch/SKILL.md +65 -0
  244. package/skills/fo/fo-task-run/SKILL.md +75 -0
  245. package/src/index.ts +11 -4
  246. package/src/tests/fixtures/agents-generate-business-before.txt +6 -0
  247. package/src/tests/profile-schema.test.ts +2 -1
@@ -0,0 +1,221 @@
1
+ /*
2
+ <MODULE_CONTRACT>
3
+ <purpose>flow.push supersession tests (RFC-1503, AC-1..AC-5): with two pending
4
+ tags of one line only the highest is attempted; publishing it journals
5
+ publish-superseded for the lower one; a pending tag at or below the newest
6
+ published is never extracted and is superseded on sight; the exit code
7
+ counts only this run's refs and attempted publications; the digest reports
8
+ pendingPublications as the highest pending tag per line.</purpose>
9
+ <non-goals>
10
+ <item>No real repo-extract — the fixture installs node_modules/.bin/repo-extract.</item>
11
+ <item>Never touches the enclosing repository — all fixtures are mkdtemp repos.</item>
12
+ </non-goals>
13
+ </MODULE_CONTRACT>
14
+ <CHANGE_SUMMARY>
15
+ <item>RFC-1503: step 1 — supersede/ordering publication tests</item>
16
+ <item>RFC-1503: steps 1-5 — highest-per-line pending selection, publish-superseded/publish-retired journal events, flow.publication.retire</item>
17
+ </CHANGE_SUMMARY>
18
+ */
19
+
20
+ import { mkdir, readFile, rm, writeFile } from "node:fs/promises";
21
+ import { join } from "node:path";
22
+
23
+ import { afterEach, describe, expect, it } from "vitest";
24
+
25
+ import { ambientIo } from "../../../src/utils/io.ts";
26
+ import { collectDigest } from "../digest.ts";
27
+ import { pushFlow } from "../handlers/flow-push.ts";
28
+ import { markerContent } from "../markers.ts";
29
+ import { releaseTagAnnotation, writeReleaseTag } from "../release-tags.ts";
30
+ import { commonGitDir, readJournal } from "../registry.ts";
31
+ import { gitExec, initRepoWithOrigin } from "./helpers.ts";
32
+
33
+ const dirs: string[] = [];
34
+ afterEach(async () => {
35
+ for (const dir of dirs.splice(0)) {
36
+ await rm(dir, { recursive: true, force: true });
37
+ }
38
+ delete process.env["FAKE_EXTRACT_FAIL"];
39
+ }, 20_000);
40
+
41
+ async function addPackageLine(repo: string): Promise<void> {
42
+ await mkdir(join(repo, "packages", "lib"), { recursive: true });
43
+ await writeFile(
44
+ join(repo, "packages", "lib", "extract.config.yaml"),
45
+ "standalone: true\ndestName: lib-export\n",
46
+ );
47
+ await writeFile(
48
+ join(repo, "packages", "lib", "package.json"),
49
+ '{\n "name": "lib",\n "version": "2.1.0"\n}\n',
50
+ );
51
+ await writeFile(join(repo, "packages", "lib", "forge.generated.yaml"), markerContent("test"));
52
+ await gitExec(repo, ["add", "-A"]);
53
+ await gitExec(repo, ["commit", "-m", "package line lib"]);
54
+ const push = await gitExec(repo, ["push", "origin", "develop"]);
55
+ if (push.exitCode !== 0) throw new Error(`push failed: ${push.stderr}`);
56
+ }
57
+
58
+ async function tag(repo: string, name: string, line: string, version: string): Promise<void> {
59
+ const tip = (await gitExec(repo, ["rev-parse", "develop"])).stdout.trim();
60
+ const res = await writeReleaseTag(repo, ambientIo, {
61
+ name,
62
+ target: tip,
63
+ annotation: releaseTagAnnotation({
64
+ tag: name,
65
+ line,
66
+ version,
67
+ level: "minor",
68
+ previous: null,
69
+ rfcs: [],
70
+ fingerprints: {},
71
+ }),
72
+ });
73
+ if (res.exitCode !== 0) throw new Error(`tag ${name} failed: ${res.stderr}`);
74
+ }
75
+
76
+ async function extractLogText(path: string): Promise<string> {
77
+ try {
78
+ return await readFile(path, "utf8");
79
+ } catch {
80
+ return "";
81
+ }
82
+ }
83
+
84
+ /** Push every digest tag with the extract forced to fail — all become pending. */
85
+ async function failAllPublications(repo: string): Promise<void> {
86
+ process.env["FAKE_EXTRACT_FAIL"] = "1";
87
+ const digest = await collectDigest(repo, ambientIo, { fetch: false });
88
+ await pushFlow(repo, ambientIo, { digest: digest.digestId, dryRun: false });
89
+ delete process.env["FAKE_EXTRACT_FAIL"];
90
+ }
91
+
92
+ describe("flow.push supersession (RFC-1503)", () => {
93
+ it("attempts only the highest pending tag of a line and supersedes the lower one (AC-1, AC-2, AC-4)", async () => {
94
+ const { repo, extractLog: log } = await initRepoWithOrigin(dirs, {
95
+ prefix: "flow-sup-",
96
+ fakeExtract: true,
97
+ });
98
+ await addPackageLine(repo);
99
+ await tag(repo, "lib@1.0.0", "lib", "1.0.0");
100
+ await tag(repo, "lib@1.1.0", "lib", "1.1.0");
101
+ await failAllPublications(repo);
102
+
103
+ const digest = await collectDigest(repo, ambientIo, { fetch: false });
104
+ expect(digest.pendingPublications).toEqual([{ tag: "lib@1.1.0", line: "lib" }]);
105
+ expect(digest.supersededPublications).toEqual([
106
+ { tag: "lib@1.0.0", line: "lib", by: null },
107
+ ]);
108
+
109
+ const data = await pushFlow(repo, ambientIo, { digest: digest.digestId, dryRun: false });
110
+ // AC-4: refs and this run's attempted publications succeeded → exit-0 data.
111
+ expect(data.diagnostics).toEqual([]);
112
+
113
+ // AC-1: only lib@1.1.0 was attempted in this run.
114
+ const attempted = data.publications.filter((p) => p.status !== "skipped-baseline");
115
+ expect(attempted.map((p) => p.tag)).toEqual(["lib@1.1.0"]);
116
+ expect(attempted[0]?.status).toBe("published");
117
+ expect(data.superseded).toEqual([{ tag: "lib@1.0.0", by: "lib@1.1.0" }]);
118
+
119
+ // AC-2: the journal records publish-superseded for lib@1.0.0.
120
+ const common = await commonGitDir(ambientIo, repo);
121
+ const journal = await readJournal(ambientIo, common);
122
+ const superseded = journal.filter((e) => e.event === "publish-superseded");
123
+ expect(superseded.map((e) => [e.branch, e.detail])).toEqual([["lib@1.0.0", "lib@1.1.0"]]);
124
+
125
+ // AC-3 strengthened: lib@1.0.0 was never extracted at all — supersession
126
+ // already applied in the first run where it stayed shadowed pending.
127
+ const logged = await extractLogText(log);
128
+ expect(logged).not.toContain("--ref lib@1.0.0");
129
+
130
+ const after = await collectDigest(repo, ambientIo, { fetch: false });
131
+ expect(after.pendingPublications).toEqual([]);
132
+ expect(after.supersededPublications).toEqual([]);
133
+ }, 120_000);
134
+
135
+ it("a pending tag at or below the newest published is never extracted — superseded on sight (AC-3)", async () => {
136
+ const { repo, extractLog: log } = await initRepoWithOrigin(dirs, {
137
+ prefix: "flow-sup-",
138
+ fakeExtract: true,
139
+ });
140
+ await addPackageLine(repo);
141
+ await tag(repo, "lib@1.1.0", "lib", "1.1.0");
142
+ const first = await collectDigest(repo, ambientIo, { fetch: false });
143
+ const published = await pushFlow(repo, ambientIo, {
144
+ digest: first.digestId,
145
+ dryRun: false,
146
+ });
147
+ expect(published.diagnostics).toEqual([]);
148
+
149
+ // A lower tag created later — below the line's newest published version.
150
+ await tag(repo, "lib@1.0.0", "lib", "1.0.0");
151
+ const pendingDigest = await collectDigest(repo, ambientIo, { fetch: false });
152
+ // Journal-scoped views stay empty — the tag was never pushed, so it is
153
+ // a fresh digest tag that the push itself supersedes on sight.
154
+ expect(pendingDigest.pendingPublications).toEqual([]);
155
+ expect(pendingDigest.supersededPublications).toEqual([]);
156
+
157
+ const data = await pushFlow(repo, ambientIo, {
158
+ digest: pendingDigest.digestId,
159
+ dryRun: false,
160
+ });
161
+ expect(data.diagnostics).toEqual([]);
162
+ expect(data.publications.filter((p) => p.status !== "skipped-baseline")).toEqual([]);
163
+ expect(data.superseded).toEqual([{ tag: "lib@1.0.0", by: "lib@1.1.0" }]);
164
+
165
+ // The tag was pushed to origin but never extracted.
166
+ const logged = await extractLogText(log);
167
+ expect(logged).not.toContain("--ref lib@1.0.0");
168
+ const common = await commonGitDir(ambientIo, repo);
169
+ const journal = await readJournal(ambientIo, common);
170
+ expect(
171
+ journal.filter((e) => e.event === "publish-superseded").map((e) => e.branch),
172
+ ).toEqual(["lib@1.0.0"]);
173
+ }, 120_000);
174
+
175
+ it("semver order, not string order: 9.10.0 outranks 9.9.0 (AC-5)", async () => {
176
+ const { repo } = await initRepoWithOrigin(dirs, {
177
+ prefix: "flow-sup-",
178
+ fakeExtract: true,
179
+ });
180
+ await addPackageLine(repo);
181
+ await tag(repo, "lib@9.9.0", "lib", "9.9.0");
182
+ await tag(repo, "lib@9.10.0", "lib", "9.10.0");
183
+ await failAllPublications(repo);
184
+
185
+ const digest = await collectDigest(repo, ambientIo, { fetch: false });
186
+ expect(digest.pendingPublications).toEqual([{ tag: "lib@9.10.0", line: "lib" }]);
187
+ expect(digest.supersededPublications).toEqual([
188
+ { tag: "lib@9.9.0", line: "lib", by: null },
189
+ ]);
190
+ }, 120_000);
191
+
192
+ it("a lower pending tag stays pending when the highest fails", async () => {
193
+ const { repo } = await initRepoWithOrigin(dirs, {
194
+ prefix: "flow-sup-",
195
+ fakeExtract: true,
196
+ });
197
+ await addPackageLine(repo);
198
+ await tag(repo, "lib@1.0.0", "lib", "1.0.0");
199
+ await tag(repo, "lib@1.1.0", "lib", "1.1.0");
200
+ await failAllPublications(repo);
201
+
202
+ process.env["FAKE_EXTRACT_FAIL"] = "1";
203
+ const digest = await collectDigest(repo, ambientIo, { fetch: false });
204
+ const failed = await pushFlow(repo, ambientIo, {
205
+ digest: digest.digestId,
206
+ dryRun: false,
207
+ });
208
+ delete process.env["FAKE_EXTRACT_FAIL"];
209
+ expect(failed.diagnostics[0]?.ruleId).toBe("FLOW-PUSH-05");
210
+
211
+ // Both stay pending — 1.0.0 is not superseded because 1.1.0 never published.
212
+ const after = await collectDigest(repo, ambientIo, { fetch: false });
213
+ expect(after.pendingPublications).toEqual([{ tag: "lib@1.1.0", line: "lib" }]);
214
+ expect(after.supersededPublications).toEqual([
215
+ { tag: "lib@1.0.0", line: "lib", by: null },
216
+ ]);
217
+ const common = await commonGitDir(ambientIo, repo);
218
+ const journal = await readJournal(ambientIo, common);
219
+ expect(journal.filter((e) => e.event === "publish-superseded")).toEqual([]);
220
+ }, 120_000);
221
+ });
@@ -0,0 +1,59 @@
1
+ /*
2
+ <MODULE_CONTRACT>
3
+ <purpose>RFC-1509 unit tests for preserveTaskFiles — the copy of
4
+ .forge/task/ into &lt;common&gt;/forge/tasks/&lt;owner id&gt;/ before a task
5
+ worktree is removed.</purpose>
6
+ </MODULE_CONTRACT>
7
+ <CHANGE_SUMMARY>
8
+ <item>RFC-1509: step 4 — preserveTaskFiles unit tests</item>
9
+ <item>RFC-1509: implement RFC-1509 — system task queue, dispatch briefs and task reports</item>
10
+ <item>RFC-1509: close RFC-1509 review r1 findings — mark-failed escape, open-error refusal, dry-run coverage</item>
11
+ </CHANGE_SUMMARY>
12
+ */
13
+
14
+ // @vitest-environment node
15
+
16
+ import { mkdir, mkdtemp, readFile, writeFile } from "node:fs/promises";
17
+ import os from "node:os";
18
+ import path from "node:path";
19
+ import { describe, expect, it } from "vitest";
20
+
21
+ import { preserveTaskFiles } from "../task-files.ts";
22
+ import { resolveIo } from "../../../src/utils/io.ts";
23
+
24
+ describe("preserveTaskFiles", () => {
25
+ it("copies every file under .forge/task/ into the common git dir", async () => {
26
+ const root = await mkdtemp(path.join(os.tmpdir(), "preserve-"));
27
+ const worktree = path.join(root, "wt");
28
+ const common = path.join(root, "common");
29
+ await mkdir(path.join(worktree, ".forge", "task"), { recursive: true });
30
+ await writeFile(path.join(worktree, ".forge", "task", "brief.md"), "the brief");
31
+ await writeFile(path.join(worktree, ".forge", "task", "report.yaml"), "the report");
32
+ const io = resolveIo(undefined);
33
+
34
+ const copied = await preserveTaskFiles(common, worktree, "T-0042", io);
35
+ expect(copied.map((p) => path.basename(p)).sort()).toEqual(["brief.md", "report.yaml"]);
36
+ expect(await readFile(path.join(common, "forge", "tasks", "T-0042", "brief.md"), "utf8")).toBe("the brief");
37
+ expect(await readFile(path.join(common, "forge", "tasks", "T-0042", "report.yaml"), "utf8")).toBe("the report");
38
+ });
39
+
40
+ it("is a no-op when .forge/task/ is absent", async () => {
41
+ const root = await mkdtemp(path.join(os.tmpdir(), "preserve-"));
42
+ const io = resolveIo(undefined);
43
+ const copied = await preserveTaskFiles(path.join(root, "common"), path.join(root, "wt"), "T-0001", io);
44
+ expect(copied).toEqual([]);
45
+ });
46
+
47
+ it("re-copying over an existing preserved dir succeeds (idempotent)", async () => {
48
+ const root = await mkdtemp(path.join(os.tmpdir(), "preserve-"));
49
+ const worktree = path.join(root, "wt");
50
+ const common = path.join(root, "common");
51
+ await mkdir(path.join(worktree, ".forge", "task"), { recursive: true });
52
+ await writeFile(path.join(worktree, ".forge", "task", "report.yaml"), "v1");
53
+ const io = resolveIo(undefined);
54
+ await preserveTaskFiles(common, worktree, "T-0001", io);
55
+ await writeFile(path.join(worktree, ".forge", "task", "report.yaml"), "v2");
56
+ await preserveTaskFiles(common, worktree, "T-0001", io);
57
+ expect(await readFile(path.join(common, "forge", "tasks", "T-0001", "report.yaml"), "utf8")).toBe("v2");
58
+ });
59
+ });
@@ -13,11 +13,11 @@ flow.install does it (committed hooks dir + core.hooksPath).</purpose>
13
13
  <item>FORGE_FLOW_OP is always set explicitly ("" for the unset cases) so a leaked outer value cannot make tests non-deterministic.</item>
14
14
  </KEY_DECISIONS>
15
15
  <CHANGE_SUMMARY>
16
- <item>RFC-1486: step 3 — flow.check with FLOW-01..05 + managed-block helpers</item>
17
16
  <item>RFC-1486: review r1 — committed-state adoption gate, uncommitted-hook committedness, step-failure trail, idempotency declaration, lazy asset resolution</item>
18
17
  <item>RFC-1490: pre-merge-commit guard mode + per-mode op vocabulary; amends the wave-1 guard RFC's backmerge escape (AC-11)</item>
19
18
  <item>RFC-1491: step 2 — pre-push guard mode, install steps pre-push + markers, FLOW-10</item>
20
19
  <item>RFC-1491: step 5 — flow.push atomic outbound path + extract publication</item>
20
+ <item>RFC-1502: steps 1-5 — release-prepare hook, pre-tag extract verification, ordered steps</item>
21
21
  <history>RFC-1486</history>
22
22
  </CHANGE_SUMMARY>
23
23
  */
@@ -171,7 +171,10 @@ export async function initRepoWithOrigin(
171
171
  * materializes the destination exactly like resolveExtractDest does — a
172
172
  * git repo at <parent>/<destBase|packages>/<destName> with one export
173
173
  * commit and a bare `origin` at <parent>/extract-origins/<destName>.git.
174
- * Set FAKE_EXTRACT_FAIL=1 in its env to make it exit 3 (FLOW-PUSH-05 test).
174
+ * A `--dest <dir>` argument overrides the computed destination (RFC-1502's
175
+ * pre-tag verify extracts into a scratch). Set FAKE_EXTRACT_FAIL=1 in its
176
+ * env — or drop a `.fail-extract` marker in the caller's cwd — to make it
177
+ * exit 3 (FLOW-PUSH-05 / FLOW-CUT-13 tests).
175
178
  */
176
179
  export async function installFakeRepoExtract(
177
180
  repo: string,
@@ -185,15 +188,16 @@ export async function installFakeRepoExtract(
185
188
  `#!/bin/sh
186
189
  set -eu
187
190
  echo "$@" >> ${JSON.stringify(log)}
188
- if [ "\${FAKE_EXTRACT_FAIL:-0}" = "1" ]; then
191
+ if [ "\${FAKE_EXTRACT_FAIL:-0}" = "1" ] || [ -f "$PWD/.fail-extract" ]; then
189
192
  echo "fake extract failure" >&2
190
193
  exit 3
191
194
  fi
192
- cfg=""; ref=""
195
+ cfg=""; ref=""; destOverride=""
193
196
  while [ $# -gt 0 ]; do
194
197
  case "$1" in
195
198
  --config) cfg="$2"; shift 2 ;;
196
199
  --ref) ref="$2"; shift 2 ;;
200
+ --dest) destOverride="$2"; shift 2 ;;
197
201
  *) shift ;;
198
202
  esac
199
203
  done
@@ -201,7 +205,7 @@ lineDir=$(dirname "$cfg")
201
205
  destName=$(grep '^destName:' "$lineDir/extract.config.yaml" | sed 's/^destName: *//' | tr -d ' ')
202
206
  destBase=$(grep '^destBase:' "$lineDir/extract.config.yaml" | sed 's/^destBase: *//' | tr -d ' ')
203
207
  destBase=\${destBase:-packages}
204
- dest="$(dirname "$PWD")/$destBase/$destName"
208
+ dest="\${destOverride:-$(dirname "$PWD")/$destBase/$destName}"
205
209
  mkdir -p "$dest"
206
210
  if [ ! -d "$dest/.git" ]; then git -C "$dest" init -b main >/dev/null; fi
207
211
  # A CI runner has no global git identity; publish's reconcile merge commits
@@ -0,0 +1,219 @@
1
+ /*
2
+ <MODULE_CONTRACT>
3
+ <purpose>withFlowLock + holderIsDead tests (RFC-1504, AC-1..AC-4): a lock whose
4
+ pid does not exist on this host is broken without waiting; a live pid waits
5
+ to the age limit; a foreign host applies the age rule only; a foreign boot
6
+ id on this host is treated as dead. Uses injected now/sleep — no real waits.</purpose>
7
+ <non-goals>
8
+ <item>No real repository — lock files live under os.tmpdir().</item>
9
+ </non-goals>
10
+ </MODULE_CONTRACT>
11
+ <CHANGE_SUMMARY>
12
+ <item>RFC-1504: step 1 — dead-holder lock tests</item>
13
+ <item>RFC-1504: review fixes — legacy acquiredAt fallback, atomic break claim, verified stamp release, onStale warnings</item>
14
+ </CHANGE_SUMMARY>
15
+ */
16
+
17
+ import { mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
18
+ import { tmpdir, hostname } from "node:os";
19
+ import { join } from "node:path";
20
+ import { spawnSync } from "node:child_process";
21
+
22
+ import { afterEach, describe, expect, it } from "vitest";
23
+
24
+ import { currentBootId, holderIsDead } from "../../core/lock-holder.ts";
25
+ import { withFlowLock, LockTimeoutError } from "../locks.ts";
26
+
27
+ const dirs: string[] = [];
28
+ afterEach(async () => {
29
+ for (const dir of dirs.splice(0)) await rm(dir, { recursive: true, force: true });
30
+ }, 20_000);
31
+
32
+ const deadPid = (): number => {
33
+ const pid = spawnSync(process.execPath, ["-e", ""]).pid;
34
+ if (pid === undefined) throw new Error("spawn failed — cannot produce a dead pid");
35
+ return pid;
36
+ };
37
+ const livePid = (): number => process.pid;
38
+ const HOST = hostname();
39
+
40
+ function fakeClock(start = 0) {
41
+ let t = start;
42
+ const sleep = async (ms: number): Promise<void> => {
43
+ t += ms;
44
+ };
45
+ return { now: () => t, sleep, advance: (ms: number) => (t += ms) };
46
+ }
47
+
48
+ const io = { readFile: (p: string) => readFile(p, "utf8") };
49
+
50
+ async function lockDir(): Promise<string> {
51
+ const dir = await mkdtemp(join(tmpdir(), "flow-lock-"));
52
+ dirs.push(dir);
53
+ return dir;
54
+ }
55
+
56
+ interface StaleCall {
57
+ path: string;
58
+ at: string;
59
+ ageMs: number;
60
+ reason?: string;
61
+ pid?: number;
62
+ host?: string;
63
+ }
64
+
65
+ describe("holderIsDead (RFC-1504)", () => {
66
+ it("dead pid on this host → dead (AC-1 basis)", () => {
67
+ expect(holderIsDead({ pid: deadPid(), host: HOST })).toBe(true);
68
+ });
69
+
70
+ it("live pid on this host → alive", () => {
71
+ expect(holderIsDead({ pid: livePid(), host: HOST })).toBe(false);
72
+ });
73
+
74
+ it("foreign host → never dead by pid (AC-3 basis)", () => {
75
+ expect(holderIsDead({ pid: deadPid(), host: "other-host" })).toBe(false);
76
+ });
77
+
78
+ it("absent host → never dead by pid", () => {
79
+ expect(holderIsDead({ pid: deadPid() })).toBe(false);
80
+ });
81
+
82
+ it("a pid we cannot signal (EPERM) counts as alive — fail closed", () => {
83
+ // pid 1 belongs to init: signal-0 either succeeds or EPERMs, never ESRCH.
84
+ expect(holderIsDead({ pid: 1, host: HOST })).toBe(false);
85
+ });
86
+
87
+ it("different boot id on this host → dead even with a live pid (AC-4 basis)", () => {
88
+ const boot = currentBootId();
89
+ if (boot === undefined) return; // non-Linux — the boot rule cannot fire
90
+ expect(holderIsDead({ pid: livePid(), host: HOST, bootId: "different-boot" })).toBe(true);
91
+ });
92
+ });
93
+
94
+ describe("withFlowLock dead-holder recovery (RFC-1504)", () => {
95
+ it("acquires a dead-holder lock without waiting (AC-1)", async () => {
96
+ const dir = await lockDir();
97
+ const lockPath = join(dir, "test.lock");
98
+ const at = new Date().toISOString();
99
+ await writeFile(lockPath, JSON.stringify({ pid: deadPid(), host: HOST, at }));
100
+
101
+ const stale: StaleCall[] = [];
102
+ const clock = fakeClock();
103
+ const result = await withFlowLock(
104
+ lockPath,
105
+ {
106
+ waitMs: 60_000,
107
+ staleMs: 3_600_000,
108
+ onStale: (l) => stale.push(l as StaleCall),
109
+ now: clock.now,
110
+ sleep: clock.sleep,
111
+ },
112
+ async () => "held",
113
+ io,
114
+ );
115
+ expect(result).toBe("held");
116
+ expect(stale).toHaveLength(1);
117
+ expect(stale[0]?.reason).toBe("dead-holder");
118
+ expect(stale[0]?.pid).toBeGreaterThan(0);
119
+ // Lock released after fn — file is gone.
120
+ await expect(readFile(lockPath, "utf8")).rejects.toThrow();
121
+ });
122
+
123
+ it("waits to the age limit behind a live pid (AC-2)", async () => {
124
+ const dir = await lockDir();
125
+ const lockPath = join(dir, "test.lock");
126
+ const at = new Date().toISOString();
127
+ await writeFile(lockPath, JSON.stringify({ pid: livePid(), host: HOST, at }));
128
+
129
+ const clock = fakeClock();
130
+ const stale: StaleCall[] = [];
131
+ await expect(
132
+ withFlowLock(
133
+ lockPath,
134
+ {
135
+ waitMs: 500,
136
+ staleMs: 3_600_000,
137
+ onStale: (l) => stale.push(l as StaleCall),
138
+ now: clock.now,
139
+ sleep: clock.sleep,
140
+ },
141
+ async () => "held",
142
+ io,
143
+ ),
144
+ ).rejects.toBeInstanceOf(LockTimeoutError);
145
+ expect(stale).toHaveLength(0);
146
+ // The live lock file survives the refused wait.
147
+ const held = JSON.parse(await readFile(lockPath, "utf8")) as { pid: number };
148
+ expect(held.pid).toBe(livePid());
149
+ });
150
+
151
+ it("a foreign host applies only the age rule (AC-3)", async () => {
152
+ const dir = await lockDir();
153
+ const lockPath = join(dir, "test.lock");
154
+ const at = new Date().toISOString();
155
+ await writeFile(lockPath, JSON.stringify({ pid: deadPid(), host: "other-host", at }));
156
+
157
+ const clock = fakeClock();
158
+ const stale: StaleCall[] = [];
159
+ await expect(
160
+ withFlowLock(
161
+ lockPath,
162
+ {
163
+ waitMs: 500,
164
+ staleMs: 3_600_000,
165
+ onStale: (l) => stale.push(l as StaleCall),
166
+ now: clock.now,
167
+ sleep: clock.sleep,
168
+ },
169
+ async () => "held",
170
+ io,
171
+ ),
172
+ ).rejects.toBeInstanceOf(LockTimeoutError);
173
+ expect(stale).toHaveLength(0); // dead pid on a foreign host is not broken
174
+ });
175
+
176
+ it("a different boot id on this host is broken without waiting (AC-4)", async () => {
177
+ const boot = currentBootId();
178
+ if (boot === undefined) return; // non-Linux platform — rule not applicable
179
+ const dir = await lockDir();
180
+ const lockPath = join(dir, "test.lock");
181
+ const at = new Date().toISOString();
182
+ await writeFile(
183
+ lockPath,
184
+ JSON.stringify({ pid: livePid(), host: HOST, at, bootId: "different-boot" }),
185
+ );
186
+
187
+ const stale: StaleCall[] = [];
188
+ const result = await withFlowLock(
189
+ lockPath,
190
+ {
191
+ waitMs: 500,
192
+ staleMs: 3_600_000,
193
+ onStale: (l) => stale.push(l as StaleCall),
194
+ },
195
+ async () => "held",
196
+ io,
197
+ );
198
+ expect(result).toBe("held");
199
+ expect(stale[0]?.reason).toBe("dead-holder");
200
+ });
201
+
202
+ it("writes bootId into fresh lock content when available", async () => {
203
+ const boot = currentBootId();
204
+ const dir = await lockDir();
205
+ const lockPath = join(dir, "test.lock");
206
+ let captured: { bootId?: string } | null = null;
207
+ await withFlowLock(
208
+ lockPath,
209
+ { waitMs: 500, staleMs: 3_600_000 },
210
+ async () => {
211
+ captured = JSON.parse(await readFile(lockPath, "utf8")) as { bootId?: string };
212
+ },
213
+ io,
214
+ );
215
+ const content = captured as { bootId?: string } | null;
216
+ if (boot === undefined) expect(content?.bootId).toBeUndefined();
217
+ else expect(content?.bootId).toBe(boot);
218
+ });
219
+ });
@@ -0,0 +1,102 @@
1
+ /*
2
+ <MODULE_CONTRACT>
3
+ <purpose>Unit tests for planPublications (RFC-1503) — the pure pending-
4
+ publication selection behind flow.digest and flow.push. Covers per-line
5
+ highest selection, semver (not string) order, superseded-on-sight at or
6
+ below the newest published, retired/published filtering, cross-line prefix
7
+ isolation, equal versions and non-semver drops.</purpose>
8
+ <non-goals>
9
+ <item>No git fixtures — pure function, table-driven.</item>
10
+ </non-goals>
11
+ </MODULE_CONTRACT>
12
+ <CHANGE_SUMMARY>
13
+ <item>RFC-1503: review r1 F-7 — direct planPublications unit tests</item>
14
+ <item>RFC-1503: review r1 — FLOW-07 on retire journal failure, journal re-read before publish, publication-order unit tests, stale catalog/inventory regen</item>
15
+ </CHANGE_SUMMARY>
16
+ */
17
+
18
+ import { describe, expect, it } from "vitest";
19
+
20
+ import { planPublications } from "../publication-order.ts";
21
+ import { parseVersion, type SemVer } from "../semver.ts";
22
+
23
+ interface Line {
24
+ id: string;
25
+ tagPrefix: string;
26
+ }
27
+
28
+ const LINES: Line[] = [
29
+ { id: "lib", tagPrefix: "lib@" },
30
+ { id: "lib-sub", tagPrefix: "lib-sub@" },
31
+ { id: "repo", tagPrefix: "v" },
32
+ ];
33
+
34
+ function versionOf(tag: string, lineId: string): SemVer | null {
35
+ const line = LINES.find((l) => l.id === lineId);
36
+ if (line === undefined || !tag.startsWith(line.tagPrefix)) return null;
37
+ return parseVersion(tag.slice(line.tagPrefix.length));
38
+ }
39
+
40
+ const e = (tag: string, line = "lib") => ({ tag, line });
41
+ const plan = (
42
+ candidates: Array<{ tag: string; line: string }>,
43
+ published: string[] = [],
44
+ retired: string[] = [],
45
+ ) => planPublications(candidates, new Set(published), new Set(retired), versionOf);
46
+
47
+ describe("planPublications (RFC-1503)", () => {
48
+ it("attempts the highest version per line — semver, not string order", () => {
49
+ const p = plan([e("lib@9.9.0"), e("lib@9.10.0")]);
50
+ expect(p.attempt).toEqual([{ tag: "lib@9.10.0", line: "lib" }]);
51
+ expect(p.superseded).toEqual([{ tag: "lib@9.9.0", line: "lib", by: null }]);
52
+ });
53
+
54
+ it("supersedes on sight at or below the newest published version", () => {
55
+ const p = plan([e("lib@1.0.0"), e("lib@0.9.0")], ["lib@1.1.0"]);
56
+ expect(p.attempt).toEqual([]);
57
+ expect(p.superseded).toEqual([
58
+ { tag: "lib@0.9.0", line: "lib", by: "lib@1.1.0" },
59
+ { tag: "lib@1.0.0", line: "lib", by: "lib@1.1.0" },
60
+ ]);
61
+ });
62
+
63
+ it("a candidate above the newest published still attempts", () => {
64
+ const p = plan([e("lib@1.2.0"), e("lib@1.0.0")], ["lib@1.1.0"]);
65
+ expect(p.attempt).toEqual([{ tag: "lib@1.2.0", line: "lib" }]);
66
+ expect(p.superseded).toEqual([{ tag: "lib@1.0.0", line: "lib", by: "lib@1.1.0" }]);
67
+ });
68
+
69
+ it("drops published and retired candidates entirely", () => {
70
+ const p = plan([e("lib@1.0.0"), e("lib@1.1.0"), e("lib@1.2.0")], ["lib@1.1.0"], ["lib@1.0.0"]);
71
+ expect(p.attempt).toEqual([{ tag: "lib@1.2.0", line: "lib" }]);
72
+ expect(p.superseded).toEqual([]);
73
+ });
74
+
75
+ it("keeps lines independent — lib does not supersede lib-sub", () => {
76
+ const p = plan([e("lib@1.0.0"), e("lib-sub@0.5.0", "lib-sub")]);
77
+ expect(p.attempt).toEqual([
78
+ { tag: "lib@1.0.0", line: "lib" },
79
+ { tag: "lib-sub@0.5.0", line: "lib-sub" },
80
+ ]);
81
+ expect(p.superseded).toEqual([]);
82
+ });
83
+
84
+ it("published tags of other lines never form a bar", () => {
85
+ const p = plan([e("lib@1.0.0")], ["lib-sub@9.9.9"]);
86
+ expect(p.attempt).toEqual([{ tag: "lib@1.0.0", line: "lib" }]);
87
+ expect(p.superseded).toEqual([]);
88
+ });
89
+
90
+ it("equal candidate versions: exactly one attempts, deterministically", () => {
91
+ const p = plan([e("lib@1.0.0"), e("lib@1.0.0")]);
92
+ expect(p.attempt).toEqual([{ tag: "lib@1.0.0", line: "lib" }]);
93
+ // The duplicate is shadowed, not attempted twice.
94
+ expect(p.superseded).toEqual([{ tag: "lib@1.0.0", line: "lib", by: null }]);
95
+ });
96
+
97
+ it("drops candidates whose suffix is not strict semver", () => {
98
+ const p = plan([e("lib@next"), e("lib@1.0.0")]);
99
+ expect(p.attempt).toEqual([{ tag: "lib@1.0.0", line: "lib" }]);
100
+ expect(p.superseded).toEqual([]);
101
+ });
102
+ });