rollbridge 0.1.69 → 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 (62) hide show
  1. package/README.md +1 -53
  2. package/TODO.md +0 -12
  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 +69 -370
  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 +21 -211
  18. package/src/process-memory.js +2 -62
  19. package/src/release-group.js +37 -427
  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 +4 -118
  24. package/test/health.test.js +1 -74
  25. package/test/managed-process.test.js +1 -260
  26. package/test/owner-recovery.test.js +28 -132
  27. package/test/owner-replacement.test.js +11 -172
  28. package/test/process-memory.test.js +1 -47
  29. package/test/release-group.test.js +2 -408
  30. package/test/rollbridge.test.js +82 -766
  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-activation-path-drain-deadline.md +0 -35
  51. package/changelog.d/20261117-stop-companion-after-retired-dependency.md +0 -7
  52. package/docs/compose-services.md +0 -222
  53. package/src/compose-unit.js +0 -725
  54. package/src/drain-policy.js +0 -252
  55. package/src/process-order.js +0 -26
  56. package/test/compose-config.test.js +0 -160
  57. package/test/compose-docker.test.js +0 -297
  58. package/test/compose-unit.test.js +0 -415
  59. package/test/drain-policy.test.js +0 -328
  60. package/test/fixtures/deferred-boot-app.js +0 -106
  61. package/test/fixtures/gated-app.js +0 -50
  62. package/test/tensorbuzz-config.test.js +0 -228
@@ -1,228 +0,0 @@
1
- // @ts-check
2
-
3
- import {execFile} from "node:child_process"
4
- import fs from "node:fs/promises"
5
- import path from "node:path"
6
- import {describe, expect, test} from "@velocious/testing"
7
- import {fileURLToPath} from "node:url"
8
- import {promisify} from "node:util"
9
-
10
- describe("tensorbuzz-config", () => {
11
-
12
- const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..")
13
- const execFileAsync = promisify(execFile)
14
-
15
- /**
16
- * @typedef {object} PathRule
17
- * @property {boolean} negated True when the rule carves the paths it matches out of the lane.
18
- * @property {string} pattern Rule body without its YAML quotes and without the `!` prefix.
19
- * @property {RegExp} regexp Matcher compiled from the rule body.
20
- * @property {string} raw Rule exactly as declared in tensorbuzz.yml, quotes included.
21
- */
22
-
23
- /**
24
- * @typedef {object} PathDecision
25
- * @property {string} filePath Repo-relative path the decision was taken on.
26
- * @property {string} matchedPattern Last rule that matched, empty when no rule matched.
27
- * @property {boolean} skipped True when the last matching rule negates the path.
28
- */
29
-
30
- /**
31
- * @typedef {object} GateInput
32
- * @property {string[]} readPaths Paths `npm run all-checks` opens: the suite and the linters read
33
- * these, so carving any of them out of the lane would skip a check that the change can break.
34
- * @property {string[]} skippedPaths Paths the lane must not need: Markdown the gate never opens.
35
- */
36
-
37
- const GATE_INPUTS = [
38
- "src/daemon.js",
39
- "src/process-guardian.js",
40
- "test/rollbridge.test.js",
41
- "test/fixtures/dummy-app.js",
42
- "bin/rollbridge",
43
- "examples/tensorbuzz.com.js",
44
- "package.json",
45
- "package-lock.json",
46
- "tsconfig.json",
47
- "eslint.config.js",
48
- ".npmignore",
49
- "LICENSE",
50
- "compose.yml",
51
- "tensorbuzz.yml"
52
- ]
53
-
54
- const MARKDOWN_PATHS = [
55
- "README.md",
56
- "AGENTS.md",
57
- "docs/tensorbuzz-runbook.md",
58
- "docs/releasing.md",
59
- "changelog.d/20261109-path-filtered-builds.md"
60
- ]
61
-
62
- /**
63
- * Reads the root `paths` rules out of tensorbuzz.yml.
64
- * @param {string} configText Full tensorbuzz.yml contents.
65
- * @returns {PathRule[]} Rules in declaration order.
66
- */
67
- function readPathRules(configText) {
68
- const lines = configText.split("\n")
69
- const start = lines.findIndex((line) => line.trim() === "paths:")
70
-
71
- if (start < 0) return []
72
-
73
- /** @type {PathRule[]} */
74
- const rules = []
75
-
76
- for (const line of lines.slice(start + 1)) {
77
- const entry = line.trim()
78
-
79
- if (!entry.startsWith("- ")) break
80
- if (!entry) continue
81
-
82
- const raw = entry.slice(2).trim()
83
- const quoted = raw.startsWith("\"") && raw.endsWith("\"") && raw.length > 1
84
- const body = quoted ? raw.slice(1, -1) : raw
85
- const negated = body.startsWith("!")
86
-
87
- rules.push({
88
- negated,
89
- pattern: negated ? body.slice(1) : body,
90
- raw,
91
- regexp: compileRuleRegExp(negated ? body.slice(1) : body)
92
- })
93
- }
94
-
95
- return rules
96
- }
97
-
98
- /**
99
- * Compiles a `paths` glob the way TensorBuzz does, for the syntax this config declares: `**`
100
- * crosses segments, `*` stays inside one segment, a rule containing `/` is anchored at the repo
101
- * root while a bare name matches at any depth, and a matched directory covers everything below
102
- * it. The `supported glob syntax` test keeps the config inside that subset.
103
- * @param {string} pattern Rule body without the `!` prefix.
104
- * @returns {RegExp} Anchored matcher for one repo-relative path.
105
- */
106
- function compileRuleRegExp(pattern) {
107
- const body = pattern.replace(/^\/+/, "").replace(/\/+$/, "")
108
- const segments = body.split("/")
109
- let source = body.includes("/") ? "" : "(?:[^/]+/)*"
110
-
111
- for (let index = 0; index < segments.length; index += 1) {
112
- const segment = segments[index]
113
- const isLast = index === segments.length - 1
114
-
115
- if (segment === "**") {
116
- source += isLast ? ".*" : "(?:.*/)?"
117
-
118
- continue
119
- }
120
-
121
- source += segment.split("*").map(escapeForRegExp).join("[^/]*")
122
-
123
- if (!isLast) source += "/"
124
- }
125
-
126
- if (!body.endsWith("**")) source += "(?:/.*)?"
127
-
128
- return new RegExp(`^${source}$`)
129
- }
130
-
131
- /**
132
- * @param {string} text Literal text to make regexp-safe.
133
- * @returns {string} Escaped text.
134
- */
135
- function escapeForRegExp(text) {
136
- return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")
137
- }
138
-
139
- /**
140
- * Applies ordered rules to one path; the last match wins, exactly like TensorBuzz.
141
- * @param {{filePath: string, rules: PathRule[]}} args Path and the declared rules.
142
- * @returns {PathDecision} Whether the lane runs for that path.
143
- */
144
- function decidePath({filePath, rules}) {
145
- /** @type {PathRule | null} */
146
- let lastMatch = null
147
-
148
- for (const rule of rules) {
149
- if (rule.regexp.test(filePath)) lastMatch = rule
150
- }
151
-
152
- return {
153
- filePath,
154
- matchedPattern: lastMatch ? lastMatch.pattern : "",
155
- skipped: lastMatch !== null && lastMatch.negated
156
- }
157
- }
158
-
159
- /**
160
- * @returns {Promise<PathRule[]>} Rules parsed from the repository's tensorbuzz.yml.
161
- */
162
- async function declaredPathRules() {
163
- return readPathRules(await fs.readFile(path.join(repoRoot, "tensorbuzz.yml"), "utf8"))
164
- }
165
-
166
- test("tensorbuzz.yml declares a paths block that defaults to running the lane", async () => {
167
- const rules = await declaredPathRules()
168
-
169
- expect(rules.length >= 2).toBeTruthy()
170
- expect(rules[0].pattern).toBe("**")
171
- expect(rules[0].negated).toBe(false)
172
-
173
- const firstNegation = rules.findIndex((rule) => rule.negated)
174
-
175
- expect(firstNegation > 0).toBeTruthy()
176
-
177
- // A positive rule after a negation would re-admit every path the negation carved out, because
178
- // the last match wins.
179
- expect(rules.slice(firstNegation).filter((rule) => !rule.negated).map((rule) => rule.raw)).toEqual([])
180
- })
181
-
182
- test("every paths rule is a quoted glob the config validator accepts", async () => {
183
- const rules = await declaredPathRules()
184
-
185
- // An unquoted `!x` is a YAML tag, not a string, and the validator rejects the whole config.
186
- expect(rules.map((rule) => rule.raw).filter((raw) => !raw.startsWith("\""))).toEqual([])
187
- expect(rules.map((rule) => rule.pattern).filter((pattern) => !/^[A-Za-z0-9_./*-]+$/.test(pattern))).toEqual([])
188
- expect(rules.map((rule) => rule.pattern).filter((pattern) => pattern.length < 1)).toEqual([])
189
- })
190
-
191
- test("a delivery that changes only Markdown is filtered out of the lane", async () => {
192
- const rules = await declaredPathRules()
193
-
194
- for (const filePath of MARKDOWN_PATHS) {
195
- const decision = decidePath({filePath, rules})
196
-
197
- expect({context: filePath, skipped: decision.skipped}).toEqual({context: filePath, skipped: true})
198
- }
199
- })
200
-
201
- test("every path the gate reads stays inside the lane", async () => {
202
- const rules = await declaredPathRules()
203
-
204
- for (const filePath of GATE_INPUTS) {
205
- const decision = decidePath({filePath, rules})
206
-
207
- expect({context: filePath, matchedPattern: decision.matchedPattern, skipped: decision.skipped})
208
- .toEqual({context: filePath, matchedPattern: "**", skipped: false})
209
- }
210
- })
211
-
212
- test("the declared rules partition every tracked path between the lane and the skip set", async () => {
213
- const rules = await declaredPathRules()
214
- const {stdout} = await execFileAsync("git", ["ls-files"], {cwd: repoRoot})
215
- const trackedPaths = stdout.split("\n").filter((line) => line.length > 0)
216
-
217
- const skipped = trackedPaths.filter((filePath) => decidePath({filePath, rules}).skipped)
218
- const runs = trackedPaths.filter((filePath) => !decidePath({filePath, rules}).skipped)
219
-
220
- expect(skipped.length > 0).toBeTruthy()
221
- expect(runs.length > 0).toBeTruthy()
222
-
223
- // Only Markdown may be carved out: any other tracked path is a gate input the lane must run for.
224
- expect(skipped.filter((filePath) => !filePath.endsWith(".md"))).toEqual([])
225
- expect(runs.filter((filePath) => filePath.endsWith(".md"))).toEqual([])
226
- })
227
-
228
- })