rollbridge 0.1.70 → 0.1.71

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 (63) hide show
  1. package/README.md +10 -63
  2. package/TODO.md +0 -13
  3. package/docs/cli.md +3 -128
  4. package/docs/config.md +6 -177
  5. package/docs/troubleshooting.md +6 -97
  6. package/docs/velocious.md +1 -1
  7. package/docs/workers.md +0 -11
  8. package/examples/tensorbuzz.com.js +2 -3
  9. package/package.json +1 -1
  10. package/src/cli.js +2 -68
  11. package/src/config.js +8 -347
  12. package/src/daemon.js +65 -387
  13. package/src/doctor.js +0 -74
  14. package/src/guardian-client.js +8 -67
  15. package/src/health.js +8 -99
  16. package/src/managed-process.js +16 -197
  17. package/src/process-guardian.js +22 -212
  18. package/src/process-memory.js +2 -62
  19. package/src/release-group.js +37 -435
  20. package/tensorbuzz.yml +1 -20
  21. package/test/completion.test.js +2 -5
  22. package/test/config-validation.test.js +5 -135
  23. package/test/guardian-client.test.js +5 -119
  24. package/test/health.test.js +1 -74
  25. package/test/managed-process.test.js +1 -260
  26. package/test/owner-recovery.test.js +21 -125
  27. package/test/owner-replacement.test.js +14 -175
  28. package/test/process-memory.test.js +1 -47
  29. package/test/release-group.test.js +2 -408
  30. package/test/rollbridge.test.js +72 -737
  31. package/test/shutdown-completion.test.js +0 -52
  32. package/test/support/process.js +1 -3
  33. package/changelog.d/20261025-guardian-re-register-dead-generation.md +0 -13
  34. package/changelog.d/20261026-stale-committed-generation-transition-recovery.md +0 -1
  35. package/changelog.d/20261104-compose-service-units.md +0 -21
  36. package/changelog.d/20261105-owner-mutation-lease-diagnostics.md +0 -20
  37. package/changelog.d/20261106-release-dependency-boot-budgets.md +0 -32
  38. package/changelog.d/20261109-path-filtered-builds.md +0 -11
  39. package/changelog.d/20261110-default-boot-budget-above-measured-startup.md +0 -26
  40. package/changelog.d/20261111-contention-sensitive-daemon-specs.md +0 -27
  41. package/changelog.d/20261113-bounded-nonblocking-retirement.md +0 -5
  42. package/changelog.d/20261115-bound-draining-release-groups.md +0 -62
  43. package/changelog.d/20261115-restore-deploy-refuses-held-generation.md +0 -27
  44. package/changelog.d/20261115-wedged-generation-escalation.md +0 -44
  45. package/changelog.d/20261116-bounded-explicit-stop-retirement.md +0 -30
  46. package/changelog.d/20261116-config-json-canonical-shape.md +0 -11
  47. package/changelog.d/20261116-drain-specs-gate-the-retirement-record.md +0 -29
  48. package/changelog.d/20261116-guardian-version-handoff.md +0 -37
  49. package/changelog.d/20261116-reclaim-dead-owner-mutation.md +0 -7
  50. package/changelog.d/20261117-activate-before-incumbent-retirement.md +0 -1
  51. package/changelog.d/20261117-activation-path-drain-deadline.md +0 -35
  52. package/changelog.d/20261117-stop-companion-after-retired-dependency.md +0 -7
  53. package/docs/compose-services.md +0 -222
  54. package/src/compose-unit.js +0 -725
  55. package/src/drain-policy.js +0 -252
  56. package/src/process-order.js +0 -26
  57. package/test/compose-config.test.js +0 -160
  58. package/test/compose-docker.test.js +0 -297
  59. package/test/compose-unit.test.js +0 -415
  60. package/test/drain-policy.test.js +0 -328
  61. package/test/fixtures/deferred-boot-app.js +0 -106
  62. package/test/fixtures/gated-app.js +0 -50
  63. package/test/tensorbuzz-config.test.js +0 -228
@@ -13,7 +13,7 @@ import {openControlSession, sendControlCommand} from "../src/control-client.js"
13
13
  import RollbridgeDaemon, {isLegacyGuardianPrepareDiagnostic, ownerConfigDigest, ownerReplacementTransitionAuthorityMatches} from "../src/daemon.js"
14
14
  import GuardianClient from "../src/guardian-client.js"
15
15
  import {findAvailablePort} from "../src/port-allocator.js"
16
- import {isProcessRunning, waitForProcessExit} from "./support/process.js"
16
+ import {waitForProcessExit} from "./support/process.js"
17
17
 
18
18
  describe("owner-replacement", () => {
19
19
 
@@ -22,93 +22,6 @@ const binPath = path.join(repoRoot, "bin", "rollbridge")
22
22
  const dummyAppPath = path.join(repoRoot, "test", "fixtures", "dummy-app.js")
23
23
  const legacyDaemonPath = path.join(repoRoot, "test", "fixtures", "pre-split3-daemon-runner.js")
24
24
  const partialGuardianPath = path.join(repoRoot, "test", "fixtures", "partial-owner-replacement-process-guardian.js")
25
- // Budget for the retired-drain fixture below. It spawns six child processes (a daemon, a worker and
26
- // a proxied web process for each of two releases, plus a partial owner-replacement guardian) and then
27
- // waits for the incumbent's retired drain to resume, so its cost tracks host contention, not the
28
- // behaviour under test. Measured on the same machine in the same invocation: 1.457s at load average
29
- // 8.3 and 7.105s at load average 24.5, both with the drain completing. The previous 5000ms cap sat
30
- // between those two numbers, which is why the spec reddened on a busy runner while nothing in the
31
- // drain actually stalled. 20000ms is 2.8x the measured worst case; the wait stays event-gated, so a
32
- // release that never resumes its drain still fails, and now fails naming the release record.
33
- const PARTIAL_DRAIN_FIXTURE_TIMEOUT_MS = 20000
34
-
35
- test("version-drifted retained guardian is handed to a current-version coordinator automatically", async () => {
36
- const root = await fs.mkdtemp(path.join(os.tmpdir(), "rollbridge-guardian-version-"))
37
- const socketPath = path.join(root, "rollbridge.sock")
38
- const statePath = path.join(root, "state.json")
39
- const configPath = path.join(root, "rollbridge.cjs")
40
- const daemonPidPath = path.join(root, "daemon.pid")
41
- const releasePath = path.join(root, "v1")
42
- const packagePath = path.join(root, "candidate-package")
43
- const runtimePath = path.join(root, "runtime")
44
- const candidateVersion = "9.9.9"
45
- let owner
46
- let retainedGuardian = /** @type {GuardianClient | undefined} */ (undefined)
47
- let retainedGuardianPid
48
-
49
- try {
50
- await fs.mkdir(releasePath)
51
- await makeFifo(path.join(releasePath, "worker.fifo"))
52
- await writeConfig(configPath, config({controlPath: socketPath, extraCompanion: false, statePath}))
53
- owner = spawn(process.execPath, [binPath, "daemon", "--config", configPath], {stdio: ["ignore", "pipe", "pipe"]})
54
- await waitForLog(owner, "control socket listening")
55
- if (!owner.pid) throw new Error("Missing required fixture: owner.pid")
56
- await fs.writeFile(daemonPidPath, `${owner.pid}\n`)
57
- await sendControlCommand({command: {command: "deploy", releaseId: "v1", releasePath, revision: "v1"}, path: socketPath})
58
- const before = await sendControlCommand({command: {command: "status"}, path: socketPath})
59
- const workerPid = releaseProcessPid(before, "v1", "worker")
60
- const webPid = releaseProcessPid(before, "v1", "web")
61
- const retainedIdentity = JSON.parse(await fs.readFile(statePath, "utf8")).recovery.guardian
62
-
63
- retainedGuardianPid = retainedIdentity.pid
64
- await prepareCandidatePackage(packagePath, {packageVersion: candidateVersion})
65
-
66
- const ownerExit = once(owner, "exit")
67
- const ensured = await runEnsureDaemon({configPath, daemonPidPath, logPath: path.join(root, "candidate.log"), packagePath, runtimePath})
68
-
69
- expect({value: ensured.code, context: `${ensured.stderr}\n${await fs.readFile(path.join(root, "candidate.log"), "utf8")}`}).toMatchObject({value: 0})
70
- // The handoff retires the incumbent daemon only; it never waits for the guardian's supervised generation.
71
- expect(await ownerExit).toEqual([null, "SIGKILL"])
72
-
73
- const status = await sendControlCommand({command: {command: "status"}, path: socketPath})
74
-
75
- expect(status.activeReleaseId).toBe("v1")
76
- expect(releaseProcessPid(status, "v1", "worker")).toBe(workerPid)
77
- expect(releaseProcessPid(status, "v1", "web")).toBe(webPid)
78
- expect(status.ownerTransition).toMatchObject({
79
- disruptive: true,
80
- mode: "guardian-version-handoff",
81
- reason: `retained guardian ${JSON.parse(await fs.readFile(path.join(repoRoot, "package.json"), "utf8")).version} predates this daemon runtime ${candidateVersion}`
82
- })
83
-
84
- const handedOff = JSON.parse(await fs.readFile(statePath, "utf8"))
85
-
86
- expect(handedOff.recovery.guardian.socketPath).toBe(`${statePath}.guardian-${candidateVersion}.sock`)
87
- expect(handedOff.recovery.guardian.pid).not.toBe(retainedIdentity.pid)
88
- // The retained guardian stays alive and keeps supervising the generation it already owns.
89
- expect(isProcessRunning(retainedGuardianPid)).toBe(true)
90
- retainedGuardian = new GuardianClient(retainedIdentity)
91
- await retainedGuardian.connect()
92
- const retainedInventory = await retainedGuardian.inventory()
93
-
94
- expect(retainedInventory.find(({key}) => key === "release:v1:worker")?.status.pid).toBe(workerPid)
95
- expect(retainedInventory.find(({key}) => key === "release:v1:web")?.status.pid).toBe(webPid)
96
- retainedGuardian.disconnect()
97
-
98
- const shutdown = sendControlCommand({command: {command: "shutdown"}, path: socketPath})
99
-
100
- await fs.writeFile(path.join(releasePath, "worker.fifo"), "drained\n")
101
- await shutdown
102
- await waitForProcessExit(workerPid, 5000)
103
- // An explicit stop of the new owner releases the retained supervisor once its children are gone.
104
- await waitForProcessExit(retainedGuardianPid, 5000)
105
- } finally {
106
- retainedGuardian?.disconnect()
107
- if (owner && owner.exitCode === null && owner.signalCode === null) owner.kill("SIGKILL")
108
- await stopGuardian(statePath)
109
- await fs.rm(root, {force: true, recursive: true})
110
- }
111
- })
112
25
 
113
26
  test("partial owner-replacement guardian crosses the authenticated legacy bridge before retired-owner commit", async () => {
114
27
  const root = await fs.mkdtemp(path.join(os.tmpdir(), "rollbridge-owner-replacement-partial-"))
@@ -411,7 +324,7 @@ test("partial guardian replacement persists the coordinator only after ownership
411
324
  }
412
325
  })
413
326
 
414
- test("failed partial upgrade resumes an incumbent retired release drain", {timeoutMs: PARTIAL_DRAIN_FIXTURE_TIMEOUT_MS}, async () => {
327
+ test("failed partial upgrade resumes an incumbent retired release drain", {timeoutMs: 5000}, async () => {
415
328
  const root = await fs.mkdtemp(path.join(os.tmpdir(), "rollbridge-owner-replacement-partial-drain-"))
416
329
  const socketPath = path.join(root, "rollbridge.sock")
417
330
  const statePath = path.join(root, "state.json")
@@ -469,18 +382,7 @@ test("failed partial upgrade resumes an incumbent retired release drain", {timeo
469
382
  retainedConnection.destroy()
470
383
  await fs.writeFile(path.join(v1Path, "worker.fifo"), "drained\n")
471
384
  await releaseDrained
472
- const drainedStatus = await sendControlCommand({command: {command: "status"}, path: socketPath})
473
-
474
- expect(releaseState(drainedStatus, "v1")).toBe("stopped")
475
- // The resumed drain must also be visible in the retired release's own record, not only as the
476
- // stdout line the wait is keyed on: a release cleared without draining its processes leaves no
477
- // drainStartedAt/stoppedAt pair behind.
478
- const drainedRelease = /** @type {{drainStartedAt?: string, releaseId: string, stoppedAt?: string}[]} */ (drainedStatus.releases)
479
- .find(({releaseId}) => releaseId === "v1")
480
-
481
- expect(typeof drainedRelease?.drainStartedAt).toBe("string")
482
- expect(typeof drainedRelease?.stoppedAt).toBe("string")
483
- expect(Date.parse(/** @type {string} */ (drainedRelease?.stoppedAt))).toBeGreaterThanOrEqual(Date.parse(/** @type {string} */ (drainedRelease?.drainStartedAt)))
385
+ expect(releaseState(await sendControlCommand({command: {command: "status"}, path: socketPath}), "v1")).toBe("stopped")
484
386
  const shutdown = sendControlCommand({command: {command: "shutdown"}, path: socketPath})
485
387
 
486
388
  await fs.writeFile(path.join(v2Path, "worker.fifo"), "drained\n")
@@ -1784,7 +1686,7 @@ test("same-authority owner replacement preserves completed activation compensati
1784
1686
  await waitForLog(owner, "control socket listening")
1785
1687
  await sendControlCommand({command: {command: "deploy", releaseId: "v1", releasePath: v1Path, revision: "v1"}, path: oldSocketPath})
1786
1688
  await expect(sendControlCommand({command: {command: "deploy", releaseId: "v2", releasePath: v2Path, revision: "v2"}, path: oldSocketPath})).rejects.toThrow(/activate command exited non-zero/)
1787
- expect(await fs.readFile(lifecycleLogPath, "utf8")).toBe("activate:v1\nretire:v2\nactivate:v1\n")
1689
+ expect(await fs.readFile(lifecycleLogPath, "utf8")).toBe("activate:v1\nretire:v1\nretire:v2\nactivate:v1\n")
1788
1690
 
1789
1691
  await writeConfig(configPath, failedConfig(oldSocketPath, false))
1790
1692
  candidate = spawn(process.execPath, [binPath, "daemon", "--config", configPath, "--replace-owner"], {stdio: ["ignore", "pipe", "pipe"]})
@@ -1793,7 +1695,7 @@ test("same-authority owner replacement preserves completed activation compensati
1793
1695
  expect(status.activeReleaseId).toBe("v1")
1794
1696
  expect(status.generationTransition).toBe(undefined)
1795
1697
  // Replacement must not replay completed compensation hooks.
1796
- expect(await fs.readFile(lifecycleLogPath, "utf8")).toBe("activate:v1\nretire:v2\nactivate:v1\n")
1698
+ expect(await fs.readFile(lifecycleLogPath, "utf8")).toBe("activate:v1\nretire:v1\nretire:v2\nactivate:v1\n")
1797
1699
 
1798
1700
  const shutdown = sendControlCommand({command: {command: "shutdown"}, path: oldSocketPath})
1799
1701
  await Promise.all([v1Path, v2Path].map((releasePath) => fs.writeFile(path.join(releasePath, "worker.fifo"), "drained\n")))
@@ -1805,62 +1707,6 @@ test("same-authority owner replacement preserves completed activation compensati
1805
1707
  }
1806
1708
  })
1807
1709
 
1808
- test("deploy after activation compensation in a replacement daemon accepts the unchanged config file", async () => {
1809
- const root = await fs.mkdtemp(path.join(os.tmpdir(), "rollbridge-owner-replacement-post-compensation-deploy-"))
1810
- const oldSocketPath = path.join(root, "old.sock")
1811
- const statePath = path.join(root, "state.json")
1812
- const configPath = path.join(root, "rollbridge.cjs")
1813
- const lifecycleLogPath = path.join(root, "generation.lifecycle")
1814
- const v1Path = path.join(root, "v1")
1815
- const v2Path = path.join(root, "v2")
1816
- const v3Path = path.join(root, "v3")
1817
- let owner
1818
- let candidate
1819
- const failedConfig = (/** @type {string} */ controlPath) => {
1820
- const raw = config({activationLogPath: lifecycleLogPath, controlPath, extraCompanion: false, statePath})
1821
- const processes = /** @type {Record<string, import("../src/json.js").JsonValue>[]} */ (raw.processes)
1822
- const generationMain = processes.find((processConfig) => processConfig.id === "generation-main")
1823
- const lifecycle = /** @type {Record<string, import("../src/json.js").JsonValue>} */ (generationMain?.lifecycle)
1824
-
1825
- lifecycle.activateCommand = `[ "$ROLLBRIDGE_RELEASE_ID" != v2 ] || exit 24; printf 'activate:%s\\n' "$ROLLBRIDGE_RELEASE_ID" >> ${JSON.stringify(lifecycleLogPath)}`
1826
- return raw
1827
- }
1828
-
1829
- try {
1830
- await Promise.all([fs.mkdir(v1Path), fs.mkdir(v2Path), fs.mkdir(v3Path)])
1831
- await Promise.all([v1Path, v2Path, v3Path].map((releasePath) => makeFifo(path.join(releasePath, "worker.fifo"))))
1832
- await writeConfig(configPath, failedConfig(oldSocketPath))
1833
- owner = spawn(process.execPath, [binPath, "daemon", "--config", configPath], {stdio: ["ignore", "pipe", "pipe"]})
1834
- await waitForLog(owner, "control socket listening")
1835
- await sendControlCommand({command: {command: "deploy", releaseId: "v1", releasePath: v1Path, revision: "v1"}, path: oldSocketPath})
1836
-
1837
- candidate = spawn(process.execPath, [binPath, "daemon", "--config", configPath, "--replace-owner"], {stdio: ["ignore", "pipe", "pipe"]})
1838
- await waitForLog(candidate, "owner replacement committed")
1839
-
1840
- // The measured production sequence (2026-11-16, tensorbuzz/production): the replacement
1841
- // daemon runs a deploy whose activation fails, compensates, and is then asked to deploy a
1842
- // new release with the same config file. Compensation leaves the daemon's config authority
1843
- // as the release definition it inherited through the guardian transfer, so the next deploy
1844
- // must still accept that unchanged file instead of demanding a daemon restart.
1845
- await expect(sendControlCommand({command: {command: "deploy", releaseId: "v2", releasePath: v2Path, revision: "v2"}, path: oldSocketPath})).rejects.toThrow(/activate command exited non-zero/)
1846
- const compensated = await sendControlCommand({command: {command: "status"}, path: oldSocketPath})
1847
-
1848
- expect(compensated.activeReleaseId).toBe("v1")
1849
- await sendControlCommand({command: {command: "deploy", releaseId: "v3", releasePath: v3Path, revision: "v3"}, path: oldSocketPath})
1850
- const deployed = await sendControlCommand({command: {command: "status"}, path: oldSocketPath})
1851
-
1852
- expect(deployed.activeReleaseId).toBe("v3")
1853
- const shutdown = sendControlCommand({command: {command: "shutdown"}, path: oldSocketPath})
1854
-
1855
- await Promise.all([v1Path, v2Path, v3Path].map((releasePath) => fs.writeFile(path.join(releasePath, "worker.fifo"), "drained\n")))
1856
- await shutdown
1857
- } finally {
1858
- for (const child of [owner, candidate]) if (child && child.exitCode === null && child.signalCode === null) child.kill("SIGKILL")
1859
- await stopGuardian(statePath)
1860
- await fs.rm(root, {force: true, recursive: true})
1861
- }
1862
- })
1863
-
1864
1710
  test("config-changing owner replacement proceeds after activation compensation clears the transition", async () => {
1865
1711
  const root = await fs.mkdtemp(path.join(os.tmpdir(), "rollbridge-owner-replacement-unresolved-config-"))
1866
1712
  const oldSocketPath = path.join(root, "old.sock")
@@ -1900,7 +1746,7 @@ test("config-changing owner replacement proceeds after activation compensation c
1900
1746
 
1901
1747
  expect(status.activeReleaseId).toBe("v1")
1902
1748
  expect(status.generationTransition).toBe(undefined)
1903
- expect(await fs.readFile(lifecycleLogPath, "utf8")).toBe("activate:v1\nretire:v2\nactivate:v1\n")
1749
+ expect(await fs.readFile(lifecycleLogPath, "utf8")).toBe("activate:v1\nretire:v1\nretire:v2\nactivate:v1\n")
1904
1750
  const shutdown = sendControlCommand({command: {command: "shutdown"}, path: newSocketPath})
1905
1751
 
1906
1752
  await Promise.all([v1Path, v2Path].map((releasePath) => fs.writeFile(path.join(releasePath, "worker.fifo"), "drained\n")))
@@ -1944,7 +1790,7 @@ test("owner replacement admits only the unresolved transition's exact retained c
1944
1790
  expect(admitted(exactConfig, "/srv/releases/wrong")).toBe(false)
1945
1791
  })
1946
1792
 
1947
- test.skip("owner replacement preserves accepted degraded incumbent traffic fence", async () => {
1793
+ test("owner replacement preserves accepted degraded incumbent web authority", async () => {
1948
1794
  const root = await fs.mkdtemp(path.join(os.tmpdir(), "rollbridge-owner-replacement-degraded-active-"))
1949
1795
  const socketPath = path.join(root, "rollbridge.sock")
1950
1796
  const statePath = path.join(root, "state.json")
@@ -1979,7 +1825,7 @@ test.skip("owner replacement preserves accepted degraded incumbent traffic fence
1979
1825
  await sendControlCommand({command: {command: "deploy", releaseId: "v1", releasePath: v1Path, revision: "v1"}, path: socketPath})
1980
1826
  await expect(sendControlCommand({command: {command: "deploy", releaseId: "v2", releasePath: v2Path, revision: "v2"}, path: socketPath})).rejects.toThrow(/pre-commit compensation failed.*status 26/i)
1981
1827
  const before = await sendControlCommand({command: {command: "status"}, path: socketPath})
1982
- const webStateBeforeReplacement = /** @type {{releaseId: string, processes: {id: string, state?: string}[]}[]} */ (before.releases).find(({releaseId}) => releaseId === "v1")?.processes.find(({id}) => id === "web")?.state
1828
+ const webPid = releaseProcessPid(before, "v1", "web")
1983
1829
 
1984
1830
  expect(/** @type {{releaseId: string, state: string}[]} */ (before.releases).find(({releaseId}) => releaseId === "v2")?.state).toBe("draining")
1985
1831
  const recovery = await sendControlCommand({command: {
@@ -2003,9 +1849,9 @@ test.skip("owner replacement preserves accepted degraded incumbent traffic fence
2003
1849
 
2004
1850
  expect(recovered.activeReleaseId).toBe("v1")
2005
1851
  expect(/** @type {{phase?: string}} */ (recovered.generationTransition).phase).toBe("degraded_active")
2006
- expect(webStateBeforeReplacement).toBe("stopped")
2007
- expect(/** @type {{releaseId: string, processes: {id: string, state?: string}[]}[]} */ (recovered.releases).find(({releaseId}) => releaseId === "v1")?.processes.find(({id}) => id === "web")?.state).toBe("stopped")
2008
- expect(response.status).toBe(502)
1852
+ expect(releaseProcessPid(recovered, "v1", "web")).toBe(webPid)
1853
+ expect(response.status).toBe(200)
1854
+ expect((await response.text()).trim()).toBe("v1")
2009
1855
  expect(await fs.readFile(lifecycleLogPath, "utf8")).toBe("activate:v1\nretire:v1\nretire:v2\n")
2010
1856
  } finally {
2011
1857
  for (const child of [owner, replacement]) if (child && child.exitCode === null && child.signalCode === null) child.kill("SIGKILL")
@@ -2147,11 +1993,11 @@ function config({activationLogPath, controlPath, extraCompanion, proxyPort = 0,
2147
1993
 
2148
1994
  /**
2149
1995
  * @param {string} destination - Candidate package path.
2150
- * @param {{dropCommitResponse?: boolean, packageVersion?: string}} [options] - Fault injection and candidate package identity.
1996
+ * @param {{dropCommitResponse?: boolean}} [options] - Fault injection.
2151
1997
  * @returns {Promise<void>} Package preparation completion.
2152
1998
  */
2153
1999
  async function prepareCandidatePackage(destination, options = {}) {
2154
- const {dropCommitResponse = false, packageVersion} = options
2000
+ const {dropCommitResponse = false} = options
2155
2001
 
2156
2002
  await fs.mkdir(destination, {recursive: true})
2157
2003
  await Promise.all([
@@ -2160,13 +2006,6 @@ async function prepareCandidatePackage(destination, options = {}) {
2160
2006
  fs.cp(path.join(repoRoot, "node_modules"), path.join(destination, "node_modules"), {dereference: true, recursive: true}),
2161
2007
  fs.copyFile(path.join(repoRoot, "package.json"), path.join(destination, "package.json"))
2162
2008
  ])
2163
- if (packageVersion) {
2164
- const metadataPath = path.join(destination, "package.json")
2165
- const metadata = JSON.parse(await fs.readFile(metadataPath, "utf8"))
2166
-
2167
- metadata.version = packageVersion
2168
- await fs.writeFile(metadataPath, `${JSON.stringify(metadata)}\n`)
2169
- }
2170
2009
  await fs.appendFile(path.join(destination, "src", "cli.js"), "\n// distinct owner-replacement candidate closure\n")
2171
2010
  if (dropCommitResponse) {
2172
2011
  const clientPath = path.join(destination, "src", "control-client.js")
@@ -2192,7 +2031,7 @@ async function removeDaemonRecoveryCapability(packagePath, {abortedPath, prepare
2192
2031
  const guardianPath = path.join(packagePath, "src", "process-guardian.js")
2193
2032
  const daemonPath = path.join(packagePath, "src", "daemon.js")
2194
2033
  const source = await fs.readFile(guardianPath, "utf8")
2195
- const capability = " if (request.command === \"capabilities\") return {daemonRecovery: 1, generationReactivation: 1, guardianVersion: GUARDIAN_VERSION}\n\n"
2034
+ const capability = " if (request.command === \"capabilities\") return {daemonRecovery: 1, generationReactivation: 1}\n\n"
2196
2035
  const incumbentAbortNotification = " if (ownerClient && !ownerClient.destroyed) ownerClient.write(`${JSON.stringify({event: \"replacement-aborted\", reason})}\\n`)\n"
2197
2036
  const legacyCapability = ` if (request.command === "capabilities") {
2198
2037
  while (!fsSync.existsSync(${JSON.stringify(preparedPath)})) await new Promise((resolve) => setTimeout(resolve, 5))
@@ -4,7 +4,7 @@ import fs from "node:fs"
4
4
  import {describe, expect, test} from "@velocious/testing"
5
5
  import os from "node:os"
6
6
  import path from "node:path"
7
- import {measureProcessGroupRssBytes, processGroupHasLiveMembers, processGroupMembers, sampleProcessGroup} from "../src/process-memory.js"
7
+ import {measureProcessGroupRssBytes, processGroupHasLiveMembers, processGroupMembers} from "../src/process-memory.js"
8
8
 
9
9
  describe("process-memory", () => {
10
10
 
@@ -59,50 +59,4 @@ test("treats a process group containing only defunct members as stopped", () =>
59
59
  fs.rmSync(procPath, {force: true, recursive: true})
60
60
  }
61
61
  })
62
-
63
- test("samples a process group's cumulative CPU and its live member count", () => {
64
- const procPath = fs.mkdtempSync(path.join(os.tmpdir(), "rollbridge-proc-cpu-"))
65
-
66
- try {
67
- // utime and stime are stat fields 14 and 15: index 11 and 12 after the parenthesised comm,
68
- // so exactly eight placeholder fields sit between pgrp and utime.
69
- fs.mkdirSync(path.join(procPath, "101"))
70
- fs.writeFileSync(path.join(procPath, "101", "stat"), "101 (worker) S 1 77 0 0 0 0 0 0 0 0 300 200")
71
- fs.mkdirSync(path.join(procPath, "102"))
72
- fs.writeFileSync(path.join(procPath, "102", "stat"), "102 (runner) Z 1 77 0 0 0 0 0 0 0 0 10 5")
73
- fs.mkdirSync(path.join(procPath, "103"))
74
- fs.writeFileSync(path.join(procPath, "103", "stat"), "103 (other) S 1 99 0 0 0 0 0 0 0 0 9000 9000")
75
-
76
- const sampled = sampleProcessGroup(77, procPath)
77
-
78
- // Defunct members keep their consumed CPU, so the total covers both group members and
79
- // excludes the foreign group 99 entirely: (300 + 200 + 10 + 5) ticks * 10ms per tick.
80
- expect(sampled).toEqual({cpuMs: 5150, liveMemberCount: 1, memberCount: 2})
81
- } finally {
82
- fs.rmSync(procPath, {force: true, recursive: true})
83
- }
84
- })
85
-
86
- test("reports group counts when a member's CPU fields are unreadable", () => {
87
- const procPath = fs.mkdtempSync(path.join(os.tmpdir(), "rollbridge-proc-cpu-partial-"))
88
-
89
- try {
90
- fs.mkdirSync(path.join(procPath, "101"))
91
- fs.writeFileSync(path.join(procPath, "101", "stat"), "101 (worker) S 1 77 0 0")
92
-
93
- expect(sampleProcessGroup(77, procPath)).toEqual({cpuMs: undefined, liveMemberCount: 1, memberCount: 1})
94
- } finally {
95
- fs.rmSync(procPath, {force: true, recursive: true})
96
- }
97
- })
98
-
99
- test("reports a zero sample for a process group with no members", () => {
100
- expect(sampleProcessGroup(2147483646)).toEqual({cpuMs: 0, liveMemberCount: 0, memberCount: 0})
101
- })
102
-
103
- linuxTest("samples the current process group's CPU as a positive measurable total", () => {
104
- const sampled = sampleProcessGroup(currentProcessGroupId())
105
-
106
- expect({value: Boolean(sampled && typeof sampled.cpuMs === "number" && sampled.cpuMs >= 0 && sampled.liveMemberCount >= 1), context: `expected a sampled group, got ${JSON.stringify(sampled)}`}).toMatchObject({value: true})
107
- })
108
62
  })