@feigi/fleet-ctl 3.23.36 → 3.23.37
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.
- package/package.json +1 -1
- package/scripts/main-checkout.mjs +1 -1
- package/scripts/member-write-guard.mjs +1 -1
- package/scripts/repo-root.mjs +1 -1
- package/skills/run-team/references/reaping.md +1 -1
- package/scripts/agent-test-dir-prose.test.mjs +0 -59
- package/scripts/agent-test.test.mjs +0 -1640
- package/scripts/ambient-git-vars-mjs-prose.test.mjs +0 -397
- package/scripts/ambient-git-vars-prose.test.mjs +0 -192
- package/scripts/ancestry-check-position-prose.test.mjs +0 -175
- package/scripts/apply-ruleset.test.mjs +0 -421
- package/scripts/arg-header-probes-prose.test.mjs +0 -394
- package/scripts/arg.test.mjs +0 -1354
- package/scripts/board-cli.test.mjs +0 -710
- package/scripts/board-identity.test.mjs +0 -429
- package/scripts/board-liveness-banner.test.mjs +0 -119
- package/scripts/board-prev-shape.test.mjs +0 -228
- package/scripts/board-tryparse-null.test.mjs +0 -119
- package/scripts/board.test.mjs +0 -3121
- package/scripts/brief-after-cut-prose.test.mjs +0 -53
- package/scripts/candidates-exit3-prose.test.mjs +0 -302
- package/scripts/candidates.test.mjs +0 -2312
- package/scripts/caveat-unification-prose.test.mjs +0 -98
- package/scripts/cell-readout.test.mjs +0 -615
- package/scripts/ci-comment-rot-prose.test.mjs +0 -2025
- package/scripts/ci-completes-premise-prose.test.mjs +0 -257
- package/scripts/ci-state-prose.test.mjs +0 -113
- package/scripts/ci-state.test.mjs +0 -1933
- package/scripts/ci-vacuous-green.test.mjs +0 -368
- package/scripts/citation-sweep-prose.test.mjs +0 -1712
- package/scripts/claim-lifecycle.test.mjs +0 -187
- package/scripts/claim-ticket.test.mjs +0 -1122
- package/scripts/closing-keyword-prose.test.mjs +0 -193
- package/scripts/cockpit-launch-idempotent-prose.test.mjs +0 -165
- package/scripts/cockpit-tick-nonblocking.test.mjs +0 -210
- package/scripts/compute-board.test.mjs +0 -1214
- package/scripts/compute-spend.test.mjs +0 -517
- package/scripts/consumer-technology-prose.test.mjs +0 -126
- package/scripts/cross-repo-citation-prose.test.mjs +0 -155
- package/scripts/cwd-isolation-pins.mjs +0 -83
- package/scripts/dedupe-guard-prose.test.mjs +0 -243
- package/scripts/delete-merged-branch.test.mjs +0 -576
- package/scripts/derive-testcmd.test.mjs +0 -595
- package/scripts/diff-stats.test.mjs +0 -404
- package/scripts/dispatch-block-golden-prose.test.mjs +0 -1130
- package/scripts/dispatch-block-pins-prose.test.mjs +0 -615
- package/scripts/dispositions-check.test.mjs +0 -936
- package/scripts/dispositions-gate-prose.test.mjs +0 -129
- package/scripts/drop-merged-label.test.mjs +0 -479
- package/scripts/exec-stub.mjs +0 -93
- package/scripts/exec-stub.test.mjs +0 -69
- package/scripts/expected-jobs-prose.test.mjs +0 -80
- package/scripts/fan-out-authorization-prose.test.mjs +0 -80
- package/scripts/filing-bar-seat-prose.test.mjs +0 -242
- package/scripts/filing-claim-bar-prose.test.mjs +0 -166
- package/scripts/finisher-died-prose.test.mjs +0 -31
- package/scripts/finisher-dispatch-premise-prose.test.mjs +0 -312
- package/scripts/finisher-halt-prose.test.mjs +0 -106
- package/scripts/finisher-name-prose.test.mjs +0 -134
- package/scripts/finisher-own-tree-prose.test.mjs +0 -299
- package/scripts/finisher-pin-race-prose.test.mjs +0 -339
- package/scripts/finisher-test-verdict-prose.test.mjs +0 -102
- package/scripts/fix-applier-correction-rules-prose.test.mjs +0 -202
- package/scripts/fix-applier-result-file-prose.test.mjs +0 -149
- package/scripts/fleet-bootstrap.test.mjs +0 -75
- package/scripts/fleet-heartbeat.test.mjs +0 -450
- package/scripts/fleet-provenance.test.mjs +0 -138
- package/scripts/fleet-run.test.mjs +0 -90
- package/scripts/fleet-state.test.mjs +0 -460
- package/scripts/fleet-tick-prose.test.mjs +0 -300
- package/scripts/fleet-tick.test.mjs +0 -2444
- package/scripts/force-with-lease-reason-prose.test.mjs +0 -184
- package/scripts/frontmatter-check.test.mjs +0 -436
- package/scripts/git-env.test.mjs +0 -149
- package/scripts/git-status-untracked-mode-sweep.test.mjs +0 -216
- package/scripts/gone-walk.test.mjs +0 -213
- package/scripts/gp-sep-invariant-prose.test.mjs +0 -188
- package/scripts/head-moved-after-label-prose.test.mjs +0 -233
- package/scripts/immutable-body-claim-prose.test.mjs +0 -204
- package/scripts/implementer-model-tier.test.mjs +0 -235
- package/scripts/inflight-citation-prose.test.mjs +0 -144
- package/scripts/inflight-exit2-prose.test.mjs +0 -81
- package/scripts/inflight-probe-guard-prose.test.mjs +0 -109
- package/scripts/inflight-scan-scope-prose.test.mjs +0 -57
- package/scripts/inflight.test.mjs +0 -2882
- package/scripts/injection-control-prose.test.mjs +0 -404
- package/scripts/install-root-audit.test.mjs +0 -464
- package/scripts/instrument-check-prose.test.mjs +0 -235
- package/scripts/instruments.test.mjs +0 -787
- package/scripts/is-cli.test.mjs +0 -99
- package/scripts/issue-tracker-prose.test.mjs +0 -71
- package/scripts/json.test.mjs +0 -364
- package/scripts/ledger-dispatch.test.mjs +0 -927
- package/scripts/ledger-grammar.test.mjs +0 -227
- package/scripts/ledger-read-require-file.test.mjs +0 -197
- package/scripts/ledger-rotate.test.mjs +0 -142
- package/scripts/ledger.test.mjs +0 -3436
- package/scripts/line-distance-prose.test.mjs +0 -245
- package/scripts/liveness-rationale-prose.test.mjs +0 -83
- package/scripts/locale-pin-prose.test.mjs +0 -189
- package/scripts/main-checkout.test.mjs +0 -332
- package/scripts/member-outcome-prose.test.mjs +0 -167
- package/scripts/member-outcomes-header.test.mjs +0 -129
- package/scripts/member-outcomes-prose.test.mjs +0 -63
- package/scripts/member-outcomes.test.mjs +0 -638
- package/scripts/member-prompt-prose.test.mjs +0 -165
- package/scripts/member-record.test.mjs +0 -541
- package/scripts/member-write-guard.test.mjs +0 -214
- package/scripts/merge-commit-probe-prose.test.mjs +0 -122
- package/scripts/merge-gate.test.mjs +0 -613
- package/scripts/muted-git-guard-sweep.test.mjs +0 -493
- package/scripts/net-ssh-precedence-prose.test.mjs +0 -91
- package/scripts/net-watchdog-prose.test.mjs +0 -79
- package/scripts/net.test.mjs +0 -211
- package/scripts/no-ci-gate-prose.test.mjs +0 -108
- package/scripts/no-undo-audit.test.mjs +0 -3961
- package/scripts/no-wave.test.mjs +0 -138
- package/scripts/node-floor-sweep.test.mjs +0 -611
- package/scripts/pointer-target-prose.test.mjs +0 -186
- package/scripts/pr-cost.test.mjs +0 -521
- package/scripts/pr-overlap.test.mjs +0 -692
- package/scripts/printf-die-sweep.test.mjs +0 -384
- package/scripts/prompt-renderer.mjs +0 -40
- package/scripts/prompt-renderer.test.mjs +0 -68
- package/scripts/prose-pin.mjs +0 -807
- package/scripts/prose-pin.test.mjs +0 -1034
- package/scripts/prove-merge.test.mjs +0 -995
- package/scripts/pull-table-relabel-prose.test.mjs +0 -60
- package/scripts/quiet-payload-prose.test.mjs +0 -222
- package/scripts/reap-cherry-check-prose.test.mjs +0 -80
- package/scripts/reap.test.mjs +0 -4432
- package/scripts/reaping-prose.test.mjs +0 -239
- package/scripts/reaping-reap-authorizers-prose.test.mjs +0 -112
- package/scripts/reaping-release-authorizers-prose.test.mjs +0 -85
- package/scripts/recipe-derivation-prose.test.mjs +0 -112
- package/scripts/recipe-prove.test.mjs +0 -1042
- package/scripts/refuter-scratch-prose.test.mjs +0 -135
- package/scripts/release-label-required-prose.test.mjs +0 -71
- package/scripts/release-label-split-prose.test.mjs +0 -184
- package/scripts/release-ticket-reap-pairing-prose.test.mjs +0 -63
- package/scripts/release-ticket.test.mjs +0 -5099
- package/scripts/renovate-release-contract.test.mjs +0 -379
- package/scripts/repo-root.test.mjs +0 -873
- package/scripts/reporter-output-rule-prose.test.mjs +0 -208
- package/scripts/review-agent-report-only.test.mjs +0 -49
- package/scripts/review-core-booking.test.mjs +0 -35
- package/scripts/review-core-cwd-isolation.test.mjs +0 -374
- package/scripts/review-core-reads.test.mjs +0 -478
- package/scripts/review-core-refuter-scratch.test.mjs +0 -148
- package/scripts/review-core-scratch-refusal.test.mjs +0 -64
- package/scripts/review-core-shared-test-run.test.mjs +0 -275
- package/scripts/review-core-snapshot-path.test.mjs +0 -830
- package/scripts/review-core-specialist-scratch.test.mjs +0 -191
- package/scripts/review-core-testcmd.test.mjs +0 -335
- package/scripts/review-core-unrun.test.mjs +0 -566
- package/scripts/review-core-unverified-discriminant.test.mjs +0 -208
- package/scripts/review-eval-resolver-path.test.mjs +0 -55
- package/scripts/review-host-fixture.mjs +0 -89
- package/scripts/review-in-run-retry.test.mjs +0 -211
- package/scripts/review-no-vendor-dispatch.test.mjs +0 -45
- package/scripts/review-path-default.test.mjs +0 -796
- package/scripts/review-runner-spawns.test.mjs +0 -95
- package/scripts/review-runner.test.mjs +0 -166
- package/scripts/review-tier-audit.test.mjs +0 -140
- package/scripts/run-artifact-pr-prose.test.mjs +0 -341
- package/scripts/run-merge-bot-prose.test.mjs +0 -1413
- package/scripts/run-team-local-hook.test.mjs +0 -442
- package/scripts/scratch-partition-invariant-prose.test.mjs +0 -74
- package/scripts/scripts-path-citation-sweep.test.mjs +0 -73
- package/scripts/section-between-guard-prose.test.mjs +0 -379
- package/scripts/select-dimensions.test.mjs +0 -674
- package/scripts/shared-refusal.test.mjs +0 -388
- package/scripts/shell-traps-prose.test.mjs +0 -504
- package/scripts/shortlist.test.mjs +0 -380
- package/scripts/slow-transport.mjs +0 -72
- package/scripts/snapshot-repo.test.mjs +0 -1006
- package/scripts/snapshot-runner-audience-prose.test.mjs +0 -130
- package/scripts/spend-view.test.mjs +0 -312
- package/scripts/staleness-qualifier-prose.test.mjs +0 -251
- package/scripts/staleness-verdict-prose.test.mjs +0 -142
- package/scripts/staleness.test.mjs +0 -893
- package/scripts/stalled-member-liveness-prose.test.mjs +0 -219
- package/scripts/stash-prohibition-prose.test.mjs +0 -313
- package/scripts/strip-comments.mjs +0 -44
- package/scripts/temp-dir.mjs +0 -47
- package/scripts/ticket-router.test.mjs +0 -981
- package/scripts/tier-check.test.mjs +0 -828
- package/scripts/tier-outcomes-header.test.mjs +0 -518
- package/scripts/tier-outcomes.test.mjs +0 -572
- package/scripts/tier-roles.test.mjs +0 -535
- package/scripts/tracker-block-copy-prose.test.mjs +0 -288
- package/scripts/triage-labels-gloss-prose.test.mjs +0 -97
- package/scripts/unattended-git-sweep.test.mjs +0 -142
- package/scripts/verify-sha-exit2-prose.test.mjs +0 -269
- package/scripts/verify-sha.test.mjs +0 -692
- package/scripts/watcher-degraded-block.test.mjs +0 -369
- package/scripts/watcher-key-prose.test.mjs +0 -106
- package/scripts/within-run-pair-prose.test.mjs +0 -212
- package/scripts/worktree-audit.test.mjs +0 -1408
- package/scripts/worktree-head-prose.test.mjs +0 -276
- package/scripts/worktree-listing-sweep.test.mjs +0 -217
- package/scripts/worktree-model-prose.test.mjs +0 -216
- package/scripts/worktree-porcelain.mjs +0 -35
- package/scripts/worktree-porcelain.test.mjs +0 -102
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
// The Resolver's single-resolution-point contract (ADR 0014, ADR 0021):
|
|
2
|
-
// fleet-run resolves the Install root as the realpath of
|
|
3
|
-
// `~/.omp/plugins/node_modules/@feigi/fleet-ctl` — the one path every omp install
|
|
4
|
-
// kind (marketplace/link/npm) places — and nothing else. Driven through the
|
|
5
|
-
// real CLI — fleet-run reads `os.homedir()` directly and `process.exit()`s,
|
|
6
|
-
// so it cannot be exercised in-process the way a module-exporting script can.
|
|
7
|
-
//
|
|
8
|
-
// Every fixture's env is built from scratch (never `...process.env`), so
|
|
9
|
-
// these tests are deterministic regardless of the box they run on.
|
|
10
|
-
import { test } from "node:test";
|
|
11
|
-
import assert from "node:assert/strict";
|
|
12
|
-
import { spawnSync } from "node:child_process";
|
|
13
|
-
import { mkdirSync, writeFileSync, symlinkSync, realpathSync } from "node:fs";
|
|
14
|
-
import { tempDir } from "./temp-dir.mjs";
|
|
15
|
-
import { join } from "node:path";
|
|
16
|
-
import { fileURLToPath } from "node:url";
|
|
17
|
-
|
|
18
|
-
const FLEET_RUN = fileURLToPath(new URL("./fleet-run", import.meta.url));
|
|
19
|
-
|
|
20
|
-
function runFleetRun(home, args, extraEnv = {}) {
|
|
21
|
-
return spawnSync(process.execPath, [FLEET_RUN, ...args], {
|
|
22
|
-
encoding: "utf8",
|
|
23
|
-
env: { HOME: home, PATH: process.env.PATH, ...extraEnv },
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// A marketplace/link-shaped install: a real payload dir with a scripts/
|
|
28
|
-
// subtree, symlinked into node_modules/@feigi/fleet-ctl — the shape omp's own
|
|
29
|
-
// installers place. The Install root the resolver reports is the payload's
|
|
30
|
-
// realpath (macOS resolves tmpdir through /private, and the resolver applies
|
|
31
|
-
// realpathSync, so expectations must too).
|
|
32
|
-
function fakeInstall() {
|
|
33
|
-
const home = tempDir("fleet-run-home-");
|
|
34
|
-
const payload = join(home, ".omp", "plugins", "cache", "a");
|
|
35
|
-
mkdirSync(join(payload, "scripts"), { recursive: true });
|
|
36
|
-
writeFileSync(join(payload, "scripts", "probe.mjs"), "content\n");
|
|
37
|
-
const nm = join(home, ".omp", "plugins", "node_modules");
|
|
38
|
-
mkdirSync(join(nm, "@feigi"), { recursive: true });
|
|
39
|
-
symlinkSync(payload, join(nm, "@feigi", "fleet-ctl"));
|
|
40
|
-
return { home, payload };
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
test("node_modules/@feigi/fleet-ctl present: --root prints its realpath, no notice", () => {
|
|
44
|
-
const { home, payload } = fakeInstall();
|
|
45
|
-
const r = runFleetRun(home, ["--root"]);
|
|
46
|
-
assert.equal(r.status, 0, `expected success, got status ${r.status}: ${r.stderr}`);
|
|
47
|
-
assert.equal(r.stdout.trim(), realpathSync(payload));
|
|
48
|
-
assert.equal(r.stderr, "", "a single present package dir needs no notice at all");
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
test("node_modules/@feigi/fleet-ctl absent: exit 2, stderr names ~/.omp/plugins/node_modules/@feigi/fleet-ctl", () => {
|
|
52
|
-
const home = tempDir("fleet-run-home-");
|
|
53
|
-
const r = runFleetRun(home, ["--root"]);
|
|
54
|
-
assert.equal(r.status, 2, `expected a resolver refusal, got status ${r.status}: ${r.stdout}`);
|
|
55
|
-
assert.match(r.stderr, /no omp plugin "@feigi\/fleet-ctl"/);
|
|
56
|
-
assert.match(r.stderr, /\.omp[/\\]plugins[/\\]node_modules[/\\]@feigi[/\\]fleet-ctl/);
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
test("a dangling link is named as dangling, not as a missing entry", () => {
|
|
60
|
-
const home = tempDir("fleet-run-home-");
|
|
61
|
-
const nm = join(home, ".omp", "plugins", "node_modules");
|
|
62
|
-
mkdirSync(join(nm, "@feigi"), { recursive: true });
|
|
63
|
-
symlinkSync(join(home, "does", "not", "exist"), join(nm, "@feigi", "fleet-ctl"));
|
|
64
|
-
const r = runFleetRun(home, ["--root"]);
|
|
65
|
-
assert.equal(r.status, 2);
|
|
66
|
-
assert.match(r.stderr, /dangling/);
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
test("--path prints the resolved script path without executing it", () => {
|
|
70
|
-
const { home, payload } = fakeInstall();
|
|
71
|
-
const r = runFleetRun(home, ["--path", "probe.mjs"]);
|
|
72
|
-
assert.equal(r.status, 0, r.stderr);
|
|
73
|
-
assert.equal(r.stdout.trim(), join(realpathSync(payload), "scripts", "probe.mjs"));
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
test("a bare script name execs the resolved file, arguments and exit code passed through", () => {
|
|
77
|
-
const { home, payload } = fakeInstall();
|
|
78
|
-
writeFileSync(join(payload, "scripts", "echo-args.mjs"), "console.log(JSON.stringify(process.argv.slice(2)));\n");
|
|
79
|
-
const r = runFleetRun(home, ["echo-args.mjs", "a", "b"]);
|
|
80
|
-
assert.equal(r.status, 0, r.stderr);
|
|
81
|
-
assert.deepEqual(JSON.parse(r.stdout.trim()), ["a", "b"]);
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
test("a script that does not exist under the resolved install refuses by name", () => {
|
|
85
|
-
const { home } = fakeInstall();
|
|
86
|
-
const r = runFleetRun(home, ["does-not-exist.mjs"]);
|
|
87
|
-
assert.equal(r.status, 2);
|
|
88
|
-
assert.match(r.stderr, /script not found/);
|
|
89
|
-
assert.match(r.stderr, /does-not-exist\.mjs/);
|
|
90
|
-
});
|
|
@@ -1,460 +0,0 @@
|
|
|
1
|
-
// The shared state module — #357. Both of its callers have a CLI test file of
|
|
2
|
-
// their own, and almost everything this module does shows through one of them:
|
|
3
|
-
// the corrupt-file announcements, the per-field validation, the patch write, the
|
|
4
|
-
// failed-write return value.
|
|
5
|
-
//
|
|
6
|
-
// One thing does not, and it is a contract rather than an output: `rest` is the
|
|
7
|
-
// fields OUTSIDE the schema, never a second unvalidated copy of the fields
|
|
8
|
-
// inside it. Two copies of one key — one sanitized, one raw — is a trap for the
|
|
9
|
-
// next caller (#1597's `beat` would have arrived in `rest` had it not been
|
|
10
|
-
// destructured out), and it leaves
|
|
11
|
-
// writeState's key ORDER as the only thing standing between a junk value and
|
|
12
|
-
// the disk. No CLI output differs on that, so it is pinned here.
|
|
13
|
-
|
|
14
|
-
import test from "node:test";
|
|
15
|
-
import assert from "node:assert/strict";
|
|
16
|
-
import { spawn, spawnSync } from "node:child_process";
|
|
17
|
-
import { mkdtempSync, mkdirSync, writeFileSync, readFileSync, readdirSync, rmSync, symlinkSync, linkSync } from "node:fs";
|
|
18
|
-
import { tmpdir } from "node:os";
|
|
19
|
-
import { join } from "node:path";
|
|
20
|
-
import { fileURLToPath } from "node:url";
|
|
21
|
-
|
|
22
|
-
import { readState, writeState, assessBeat, isStalled, stallReport, stallsAt, BEAT_GRACE, DEFAULT_CEILING_S } from "./fleet-state.mjs";
|
|
23
|
-
|
|
24
|
-
const SCRIPT = fileURLToPath(new URL("./fleet-state.mjs", import.meta.url));
|
|
25
|
-
|
|
26
|
-
test("readState: `rest` is what lies outside the schema, never a second copy of it", () => {
|
|
27
|
-
const dir = mkdtempSync(join(tmpdir(), "fleet-state-"));
|
|
28
|
-
const path = join(dir, "heartbeat.json");
|
|
29
|
-
writeFileSync(path, JSON.stringify({ quiet: "bogus", elapsed: 5, digest: "abc", note: "not ours" }));
|
|
30
|
-
const state = readState(path, "fleet-state-test");
|
|
31
|
-
rmSync(dir, { recursive: true, force: true });
|
|
32
|
-
|
|
33
|
-
// The validated view, per field: a junk `quiet` sanitizes to 0 without taking
|
|
34
|
-
// the good `elapsed` down with it.
|
|
35
|
-
assert.equal(state.quiet, 0);
|
|
36
|
-
assert.equal(state.elapsed, 5);
|
|
37
|
-
assert.equal(state.digest, "abc");
|
|
38
|
-
// And `rest` carries the foreign key alone. A raw `quiet: "bogus"` sitting in
|
|
39
|
-
// here is the value writeState would spread back onto the disk — the script
|
|
40
|
-
// that owns neither key re-persisting a fault the read had already repaired.
|
|
41
|
-
assert.deepEqual(state.rest, { note: "not ours" });
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
test("statePath: an ambient GIT_COMMON_DIR is not canonicalised — this caller does not opt in (#1658)", () => {
|
|
45
|
-
// git-env.mjs's own docstring: `canonicalise` is board.mjs's opt-in alone
|
|
46
|
-
// (#1582, a symlinked cockpit route deriving a second port); ledger.mjs and
|
|
47
|
-
// fleet-state.mjs stay on the default because both PRINT the path they
|
|
48
|
-
// resolve, and realpath would change that output without changing which
|
|
49
|
-
// file either reaches. board.test.mjs pins board.mjs's OPPOSITE choice;
|
|
50
|
-
// git-env.test.mjs pins the HELPER's own default, which cannot see whether
|
|
51
|
-
// THIS caller opted in — nothing before this test pinned that fact, so an
|
|
52
|
-
// accidental `{ canonicalise: true }` added here would break no test.
|
|
53
|
-
//
|
|
54
|
-
// statePath() shells out to real `git`, which resolves a symlinked cwd
|
|
55
|
-
// itself (the OS's own getcwd() never carries a symlink component), so the
|
|
56
|
-
// vector has to be an ambient answer git echoes back verbatim instead:
|
|
57
|
-
// GIT_COMMON_DIR, which statePath()'s scrub does not touch (only GIT_DIR
|
|
58
|
-
// and GIT_WORK_TREE are). Measured directly: `GIT_COMMON_DIR=<symlinked
|
|
59
|
-
// path>/.git git rev-parse --git-common-dir` from inside a repository
|
|
60
|
-
// answers with that exact string, unresolved.
|
|
61
|
-
const root = mkdtempSync(join(tmpdir(), "fleet-state-link-"));
|
|
62
|
-
try {
|
|
63
|
-
const real = join(root, "repo");
|
|
64
|
-
assert.equal(spawnSync("git", ["init", "-q", real], { stdio: "ignore" }).status, 0);
|
|
65
|
-
const link = join(root, "link");
|
|
66
|
-
symlinkSync(real, link);
|
|
67
|
-
// A plain repository to run FROM, not this suite's own (linked) worktree:
|
|
68
|
-
// a GIT_COMMON_DIR override from inside a linked worktree collides with
|
|
69
|
-
// that worktree's own admin files (measured: git then reports "not a git
|
|
70
|
-
// repository", expecting GIT_DIR to name the worktree too).
|
|
71
|
-
const cwdRepo = join(root, "cwd-repo");
|
|
72
|
-
mkdirSync(cwdRepo, { recursive: true });
|
|
73
|
-
assert.equal(spawnSync("git", ["init", "-q"], { cwd: cwdRepo, stdio: "ignore" }).status, 0);
|
|
74
|
-
const r = spawnSync(process.execPath,
|
|
75
|
-
["-e", 'import(process.argv[1]).then((m) => { process.stdout.write(m.statePath("fleet-state-test")); });', SCRIPT],
|
|
76
|
-
{ cwd: cwdRepo, encoding: "utf8", env: { ...process.env, GIT_COMMON_DIR: join(link, ".git") } });
|
|
77
|
-
assert.equal(r.status, 0, r.stderr);
|
|
78
|
-
assert.equal(r.stdout, join(link, ".fleet", "heartbeat.json"),
|
|
79
|
-
"statePath() must keep the symlinked spelling — canonicalising here is board.mjs's opt-in alone");
|
|
80
|
-
} finally { rmSync(root, { recursive: true, force: true }); }
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
// --------------------------------------------------------------------------
|
|
84
|
-
// The liveness mark — #1597. `beat` is fleet-heartbeat's key and fleet-tick
|
|
85
|
-
// and board.mjs are its readers, so the contract that matters is what a
|
|
86
|
-
// READER is handed for a file it did not write, and what a NON-OWNER's write
|
|
87
|
-
// leaves behind. Both are invisible to either CLI's own output.
|
|
88
|
-
|
|
89
|
-
test("readState: a half-written mark is no mark, never a stale one", () => {
|
|
90
|
-
// The failure DIRECTION is the whole point. A mark is a time judged against
|
|
91
|
-
// the interval it was promised at, so a record carrying one without the
|
|
92
|
-
// other cannot be judged at all — and the two ways of pretending otherwise
|
|
93
|
-
// are both worse than saying nothing. Defaulting the missing interval to 0
|
|
94
|
-
// makes every mark instantly overdue, which reports a live fleet as dead;
|
|
95
|
-
// defaulting the missing time to now makes a dead one look fresh forever.
|
|
96
|
-
const dir = mkdtempSync(join(tmpdir(), "fleet-state-beat-"));
|
|
97
|
-
const path = join(dir, "heartbeat.json");
|
|
98
|
-
const read = (beat) => {
|
|
99
|
-
writeFileSync(path, JSON.stringify({ quiet: 0, elapsed: 0, digest: "", beat }));
|
|
100
|
-
return readState(path, "fleet-state-test").beat;
|
|
101
|
-
};
|
|
102
|
-
assert.equal(read({ at: 1_700_000_000_000 }), null, "a time with no interval cannot be judged");
|
|
103
|
-
assert.equal(read({ interval: 300 }), null, "an interval with no time is not a sighting");
|
|
104
|
-
assert.equal(read({ at: 0, interval: 300 }), null, "the epoch is not a beat");
|
|
105
|
-
assert.equal(read("1700000000000"), null, "a scalar is not a mark");
|
|
106
|
-
assert.equal(read([1, 2]), null, "an array is not a mark");
|
|
107
|
-
// But a junk REASON does not take the mark down with it: the reason is the
|
|
108
|
-
// one field whose absence already has a meaning the readers state out loud
|
|
109
|
-
// ("stopped without a recorded reason"), so degrading to it loses nothing.
|
|
110
|
-
assert.deepEqual(read({ at: 1_700_000_000_000, interval: 300, stopped: 7 }),
|
|
111
|
-
{ at: 1_700_000_000_000, interval: 300, stopped: "" });
|
|
112
|
-
rmSync(dir, { recursive: true, force: true });
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
test("readState: a junk mark does not ride back to disk through `rest`", () => {
|
|
116
|
-
// The same trap the file's header names for quiet/elapsed/digest, one key
|
|
117
|
-
// later. If `beat` were left in `rest`, fleet-tick's streak write would
|
|
118
|
-
// spread the RAW record straight back over the sanitized one, and a mark
|
|
119
|
-
// this read repaired would survive every write that repaired it.
|
|
120
|
-
const dir = mkdtempSync(join(tmpdir(), "fleet-state-beat-rest-"));
|
|
121
|
-
const path = join(dir, "heartbeat.json");
|
|
122
|
-
writeFileSync(path, JSON.stringify({ quiet: 1, elapsed: 0, digest: "d", beat: { at: "soon" }, note: "not ours" }));
|
|
123
|
-
const state = readState(path, "fleet-state-test");
|
|
124
|
-
assert.equal(state.beat, null);
|
|
125
|
-
assert.deepEqual(state.rest, { note: "not ours" }, "`beat` must be destructured out, not left in `rest`");
|
|
126
|
-
rmSync(dir, { recursive: true, force: true });
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
test("writeState: a non-owner's patch carries the mark instead of erasing it", () => {
|
|
130
|
-
// One writer per key is only true if the OTHER writers preserve it.
|
|
131
|
-
// fleet-tick patches quiet/digest on every tick — every five minutes on a
|
|
132
|
-
// busy run — so a write that dropped `beat` would delete the heartbeat's
|
|
133
|
-
// mark almost immediately, and the absence is indistinguishable from a run
|
|
134
|
-
// that never beat: readers would go silent on exactly the run that died.
|
|
135
|
-
const dir = mkdtempSync(join(tmpdir(), "fleet-state-beat-carry-"));
|
|
136
|
-
const path = join(dir, "heartbeat.json");
|
|
137
|
-
const beat = { at: 1_700_000_000_000, interval: 600, stopped: "" };
|
|
138
|
-
writeFileSync(path, JSON.stringify({ quiet: 2, elapsed: 5, digest: "old", beat }));
|
|
139
|
-
const prev = readState(path, "fleet-state-test");
|
|
140
|
-
assert.equal(writeState(path, "fleet-state-test", prev, { quiet: 0, digest: "new" }), true);
|
|
141
|
-
const after = readState(path, "fleet-state-test");
|
|
142
|
-
assert.deepEqual(after.beat, beat, "fleet-tick's streak write erased the heartbeat's mark");
|
|
143
|
-
assert.equal(after.quiet, 0);
|
|
144
|
-
assert.equal(after.digest, "new");
|
|
145
|
-
|
|
146
|
-
// And the absent mark is OMITTED rather than written as an explicit null,
|
|
147
|
-
// so a file that has never been beaten into stays the shape it was.
|
|
148
|
-
writeFileSync(path, JSON.stringify({ quiet: 0, elapsed: 0, digest: "" }));
|
|
149
|
-
const fresh = readState(path, "fleet-state-test");
|
|
150
|
-
assert.equal(writeState(path, "fleet-state-test", fresh, { quiet: 1 }), true);
|
|
151
|
-
assert.equal("beat" in JSON.parse(readFileSync(path, "utf8")), false);
|
|
152
|
-
rmSync(dir, { recursive: true, force: true });
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
test("writeState: `ticked` survives a heartbeat write the same way `beat` survives a tick write", () => {
|
|
156
|
-
// The mirror of the test above, other direction: fleet-heartbeat patches
|
|
157
|
-
// elapsed/beat on every hold, so a write that dropped `ticked` would erase
|
|
158
|
-
// fleet-tick's own liveness key the first time a heartbeat lands after a
|
|
159
|
-
// busy stretch — silently reopening the #1597 follow-up this key exists to
|
|
160
|
-
// close.
|
|
161
|
-
const dir = mkdtempSync(join(tmpdir(), "fleet-state-ticked-carry-"));
|
|
162
|
-
const path = join(dir, "heartbeat.json");
|
|
163
|
-
const ticked = { at: 1_700_000_500_000 };
|
|
164
|
-
writeFileSync(path, JSON.stringify({ quiet: 0, elapsed: 0, digest: "", ticked }));
|
|
165
|
-
const prev = readState(path, "fleet-state-test");
|
|
166
|
-
assert.deepEqual(prev.ticked, ticked, "readState did not parse a well-formed ticked mark");
|
|
167
|
-
const beat = { at: 1_700_000_000_000, interval: 300, stopped: "" };
|
|
168
|
-
assert.equal(writeState(path, "fleet-state-test", prev, { elapsed: 5, beat }), true);
|
|
169
|
-
const after = readState(path, "fleet-state-test");
|
|
170
|
-
assert.deepEqual(after.ticked, ticked, "fleet-heartbeat's mark write erased fleet-tick's ticked key");
|
|
171
|
-
assert.deepEqual(after.beat, beat);
|
|
172
|
-
|
|
173
|
-
// A junk `ticked` degrades to absent, never to a false zero: `at: 0` is a
|
|
174
|
-
// decades-old occurrence, not "no occurrence", and would falsely rescue a
|
|
175
|
-
// stale beat forever.
|
|
176
|
-
writeFileSync(path, JSON.stringify({ quiet: 0, elapsed: 0, digest: "", ticked: { at: "soon" } }));
|
|
177
|
-
assert.equal(readState(path, "fleet-state-test").ticked, null);
|
|
178
|
-
rmSync(dir, { recursive: true, force: true });
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
test("writeState: the file a reader already opened is replaced whole, never rewritten in place", () => {
|
|
182
|
-
// #2349. readState maps an empty or half-written file to the no-mark state
|
|
183
|
-
// on purpose, so a write that truncated heartbeat.json and then filled it
|
|
184
|
-
// let a reader landing in between see "no mark" on a live run — and
|
|
185
|
-
// ledger.mjs rotate, which refuses only while a mark is beating, moved the
|
|
186
|
-
// live controller's ledger. A hard link stands in for that reader: it holds
|
|
187
|
-
// the inode the reader opened. An in-place write changes what it sees; a
|
|
188
|
-
// rename leaves it the complete old version while the path gets the new.
|
|
189
|
-
const dir = mkdtempSync(join(tmpdir(), "fleet-state-atomic-"));
|
|
190
|
-
const path = join(dir, "heartbeat.json");
|
|
191
|
-
const held = join(dir, "held-by-reader");
|
|
192
|
-
const old = { at: 1_700_000_000_000, interval: 300, stopped: "" };
|
|
193
|
-
writeFileSync(path, JSON.stringify({ quiet: 0, elapsed: 0, digest: "", beat: old }));
|
|
194
|
-
linkSync(path, held);
|
|
195
|
-
const beat = { at: 1_700_000_300_000, interval: 300, stopped: "" };
|
|
196
|
-
assert.equal(writeState(path, "fleet-state-test", readState(path, "fleet-state-test"), { beat }), true);
|
|
197
|
-
assert.deepEqual(readState(held, "fleet-state-test").beat, old, "the write rewrote the file a reader holds in place");
|
|
198
|
-
assert.deepEqual(readState(path, "fleet-state-test").beat, beat);
|
|
199
|
-
rmSync(dir, { recursive: true, force: true });
|
|
200
|
-
});
|
|
201
|
-
|
|
202
|
-
test("writeState: a write that cannot land leaves no temp file behind", () => {
|
|
203
|
-
// The temp is written first and renamed second, so a rename that fails —
|
|
204
|
-
// here the target is a directory — would otherwise strand one
|
|
205
|
-
// `heartbeat.json.<pid>.tmp` per failed invocation beside the file, each
|
|
206
|
-
// heartbeat run a new pid.
|
|
207
|
-
const dir = mkdtempSync(join(tmpdir(), "fleet-state-unlandable-"));
|
|
208
|
-
const path = join(dir, "heartbeat.json");
|
|
209
|
-
mkdirSync(path);
|
|
210
|
-
writeFileSync(join(path, "occupant"), "x");
|
|
211
|
-
assert.equal(writeState(path, "fleet-state-test", readState(path, "fleet-state-test"), { quiet: 1 }), false);
|
|
212
|
-
assert.deepEqual(readdirSync(dir), ["heartbeat.json"]);
|
|
213
|
-
rmSync(dir, { recursive: true, force: true });
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
test("writeState: two scripts writing the file at once both land — neither takes the other's temp", async () => {
|
|
217
|
-
// fleet-tick and fleet-heartbeat both write heartbeat.json, each its own
|
|
218
|
-
// process. A temp name the two share lets one rename the other's temp out
|
|
219
|
-
// from under it, and the loser's rename fails on ENOENT — a reported write
|
|
220
|
-
// failure that fleet-heartbeat treats as a fire (#531's race, ledger.mjs's
|
|
221
|
-
// own temp). Timing decides only whether the two loops overlap, never
|
|
222
|
-
// whether correct code passes: two pid-named temps cannot collide. Measured
|
|
223
|
-
// with the shared name `${path}.tmp` instead, it failed on each of six runs.
|
|
224
|
-
const dir = mkdtempSync(join(tmpdir(), "fleet-state-concurrent-"));
|
|
225
|
-
const path = join(dir, "heartbeat.json");
|
|
226
|
-
const writer = `
|
|
227
|
-
const { readState, writeState } = await import(${JSON.stringify(new URL("./fleet-state.mjs", import.meta.url).href)});
|
|
228
|
-
let fails = 0;
|
|
229
|
-
for (let i = 0; i < 300; i++) {
|
|
230
|
-
if (!writeState(${JSON.stringify(path)}, "writer", readState(${JSON.stringify(path)}, "writer"), { digest: String(i).repeat(500) })) fails++;
|
|
231
|
-
}
|
|
232
|
-
console.log(fails);
|
|
233
|
-
`;
|
|
234
|
-
const run = () => new Promise((resolve) => {
|
|
235
|
-
const child = spawn(process.execPath, ["--input-type=module", "-e", writer]);
|
|
236
|
-
let out = "", err = "";
|
|
237
|
-
child.stdout.on("data", (d) => { out += d; });
|
|
238
|
-
child.stderr.on("data", (d) => { err += d; });
|
|
239
|
-
child.on("close", (status) => resolve({ status, out: out.trim(), err }));
|
|
240
|
-
});
|
|
241
|
-
const results = await Promise.all([run(), run()]);
|
|
242
|
-
rmSync(dir, { recursive: true, force: true });
|
|
243
|
-
for (const r of results) {
|
|
244
|
-
assert.equal(r.status, 0, r.err);
|
|
245
|
-
assert.equal(r.out, "0", `writes failed under a concurrent writer:\n${r.err}`);
|
|
246
|
-
}
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
test("assessBeat: staleness is judged against the RECORDED interval, not a constant", () => {
|
|
250
|
-
// The whole reason the mark carries an interval. A quiet night backs off to
|
|
251
|
-
// the ceiling, so the same twenty-minute silence is a healthy beat at
|
|
252
|
-
// --ceiling 1200 and a dead run at --base 300. A fixed threshold has to
|
|
253
|
-
// pick one and be wrong about the other, every night.
|
|
254
|
-
const now = 2_000_000_000_000;
|
|
255
|
-
const at = now - 20 * 60 * 1000;
|
|
256
|
-
assert.equal(assessBeat({ beat: { at, interval: 1200, stopped: "" }, now }).kind, "beating",
|
|
257
|
-
"a quiet run at the back-off ceiling must not be reported as dead");
|
|
258
|
-
assert.equal(assessBeat({ beat: { at, interval: 300, stopped: "" }, now }).kind, "stale",
|
|
259
|
-
"the same silence at the base interval IS overdue");
|
|
260
|
-
|
|
261
|
-
// The grace is a multiplier on the promise, so the boundary moves with it.
|
|
262
|
-
// Pinned on both sides of the edge rather than at one point: a check that
|
|
263
|
-
// only ever asserts "far past" passes for any threshold at all.
|
|
264
|
-
const edge = 300 * 1000 * BEAT_GRACE;
|
|
265
|
-
assert.equal(assessBeat({ beat: { at: now - edge, interval: 300, stopped: "" }, now }).kind, "beating");
|
|
266
|
-
assert.equal(assessBeat({ beat: { at: now - edge - 1, interval: 300, stopped: "" }, now }).kind, "stale");
|
|
267
|
-
|
|
268
|
-
// No mark is not a stall: a fresh run legitimately has none, and a banner
|
|
269
|
-
// that fires on every first tick is a banner nobody reads by the second.
|
|
270
|
-
assert.equal(assessBeat({ beat: null, now }).kind, "none");
|
|
271
|
-
assert.equal(isStalled(assessBeat({ beat: null, now })), false);
|
|
272
|
-
// A mark from the future is a clock that moved, not a negative overdue.
|
|
273
|
-
const ahead = assessBeat({ beat: { at: now + 60_000, interval: 300, stopped: "" }, now });
|
|
274
|
-
assert.equal(ahead.ageMs, 0);
|
|
275
|
-
assert.equal(ahead.overdueMs, 0);
|
|
276
|
-
});
|
|
277
|
-
|
|
278
|
-
test("assessBeat: a busy run's own `ticked` covers for a `beat` the busy stretch never let refresh", () => {
|
|
279
|
-
// #1597 follow-up. `beat` only refreshes when the queue drains ("beat when
|
|
280
|
-
// there is nothing to do") — a fully-staffed fleet that has been busy for
|
|
281
|
-
// eleven straight minutes never touches it, so the recorded interval stays
|
|
282
|
-
// whatever it was when the stretch started (base, if it started right after a
|
|
283
|
-
// dispatch) and the OLD mark ages straight past its own grace window. A
|
|
284
|
-
// reconcile tick fires on every completion during that same stretch, though,
|
|
285
|
-
// and now leaves its own mark behind — that is the evidence this asserts.
|
|
286
|
-
const now = 2_000_000_000_000;
|
|
287
|
-
const beat = { at: now - 11 * 60 * 1000, interval: 300, stopped: "" };
|
|
288
|
-
assert.equal(assessBeat({ beat, now }).kind, "stale",
|
|
289
|
-
"no ticked evidence at all is exactly the #1597 bug — still correctly overdue");
|
|
290
|
-
assert.equal(assessBeat({ beat, ticked: { at: now - 2 * 60 * 1000 }, now }).kind, "beating",
|
|
291
|
-
"a tick two minutes ago is a busy run working, not a dead one");
|
|
292
|
-
|
|
293
|
-
// The reverse never happens: a stale `ticked` cannot rescue a genuinely
|
|
294
|
-
// dead run, and a healthy `beat` needs no help from `ticked` at all.
|
|
295
|
-
assert.equal(assessBeat({ beat, ticked: { at: now - 3 * DEFAULT_CEILING_S * 1000 }, now }).kind, "stale");
|
|
296
|
-
const healthyBeat = { at: now - 60 * 1000, interval: 300, stopped: "" };
|
|
297
|
-
assert.equal(assessBeat({ beat: healthyBeat, now }).kind, "beating");
|
|
298
|
-
|
|
299
|
-
// `stopped` still outranks everything, ticked included: a run that named
|
|
300
|
-
// its own death is not un-dead because fleet-tick happened to fire once on
|
|
301
|
-
// the way out.
|
|
302
|
-
const stopped = { at: now - 11 * 60 * 1000, interval: 300, stopped: "budget" };
|
|
303
|
-
assert.equal(assessBeat({ beat: stopped, ticked: { at: now - 1000 }, now }).kind, "stopped");
|
|
304
|
-
});
|
|
305
|
-
|
|
306
|
-
test("stallsAt: a tick's window ends at the ceiling times grace, and only ever postpones `beat`'s own end", () => {
|
|
307
|
-
const now = 2_000_000_000_000;
|
|
308
|
-
// A beat already past its own window, so the tick alone decides — pinned on
|
|
309
|
-
// both sides of the edge, the same pair the beat boundary above uses.
|
|
310
|
-
const beat = { at: now - 11 * 60 * 1000, interval: 300, stopped: "" };
|
|
311
|
-
const tickEdge = DEFAULT_CEILING_S * 1000 * BEAT_GRACE;
|
|
312
|
-
assert.equal(stallsAt({ beat, ticked: { at: now - tickEdge } }), now);
|
|
313
|
-
assert.equal(assessBeat({ beat, ticked: { at: now - tickEdge }, now }).kind, "beating");
|
|
314
|
-
assert.equal(assessBeat({ beat, ticked: { at: now - tickEdge - 1 }, now }).kind, "stale");
|
|
315
|
-
|
|
316
|
-
// The later of the two windows wins: a long recorded interval outlives an
|
|
317
|
-
// old tick, so the tick must not cut that beat short.
|
|
318
|
-
const long = { at: now - 30 * 60 * 1000, interval: 1200, stopped: "" };
|
|
319
|
-
const oldTick = { at: now - 2 * tickEdge };
|
|
320
|
-
assert.equal(stallsAt({ beat: long, ticked: oldTick }), long.at + 1200 * 1000 * BEAT_GRACE);
|
|
321
|
-
assert.equal(assessBeat({ beat: long, ticked: oldTick, now }).kind, "beating");
|
|
322
|
-
assert.equal(stallsAt({ beat: long }), long.at + 1200 * 1000 * BEAT_GRACE, "no tick is `beat` alone");
|
|
323
|
-
});
|
|
324
|
-
|
|
325
|
-
test("assessBeat: a recorded stop is reported whatever its age, and outranks staleness", () => {
|
|
326
|
-
// A stop that had to wait two intervals to be believed is a stop reported
|
|
327
|
-
// after the only window in which anyone could act on it — and it is the one
|
|
328
|
-
// verdict that knows its own cause, so it is the last one to sit on.
|
|
329
|
-
const now = 2_000_000_000_000;
|
|
330
|
-
const fresh = assessBeat({ beat: { at: now - 1000, interval: 300, stopped: "budget" }, now });
|
|
331
|
-
assert.equal(fresh.kind, "stopped");
|
|
332
|
-
assert.equal(isStalled(fresh), true);
|
|
333
|
-
assert.equal(fresh.reason, "budget");
|
|
334
|
-
// And an OLD stop stays `stopped`, never degrading into the reasonless
|
|
335
|
-
// wording — the cause does not expire just because the silence grew.
|
|
336
|
-
assert.equal(assessBeat({ beat: { at: now - 86_400_000, interval: 300, stopped: "budget" }, now }).kind, "stopped");
|
|
337
|
-
});
|
|
338
|
-
|
|
339
|
-
test("stallReport: names the four facts, and says `unknown` rather than guessing a zero", () => {
|
|
340
|
-
const now = 2_000_000_000_000;
|
|
341
|
-
const at = now - 90 * 60 * 1000;
|
|
342
|
-
const stale = assessBeat({ beat: { at, interval: 1200, stopped: "" }, now });
|
|
343
|
-
const line = stallReport(stale, { claimed: 7, supply: 3 });
|
|
344
|
-
// When it was last seen, how overdue against the interval it PROMISED, what
|
|
345
|
-
// is claimed, and whether there is still supply. A bare "stale" tells the
|
|
346
|
-
// maintainer nothing they can act on, which is why each is asserted rather
|
|
347
|
-
// than the line merely being non-empty.
|
|
348
|
-
assert.match(line, /last beat 2033-05-18T02:03:20\.000Z/);
|
|
349
|
-
assert.match(line, /90m ago/);
|
|
350
|
-
assert.match(line, /70m past the 20m interval it promised/);
|
|
351
|
-
assert.match(line, /7 ticket\(s\) claimed and in flight/);
|
|
352
|
-
assert.match(line, /pool supply 3/);
|
|
353
|
-
// No reason recorded: say exactly that, never a cause it cannot know.
|
|
354
|
-
assert.match(line, /stopped without a recorded reason/);
|
|
355
|
-
|
|
356
|
-
const stopped = assessBeat({ beat: { at, interval: 1200, stopped: "context ceiling reached" }, now });
|
|
357
|
-
assert.match(stallReport(stopped, { claimed: 0, supply: 0 }),
|
|
358
|
-
/stopped deliberately — recorded reason: context ceiling reached/);
|
|
359
|
-
|
|
360
|
-
// Unknown is not zero. A failed claim query reporting "0 claimed" says the
|
|
361
|
-
// dead run stranded nothing, which is the one answer that makes the whole
|
|
362
|
-
// report safe to ignore — the same refusal fleet-tick's own NOT_ZERO wording
|
|
363
|
-
// makes about a pool it could not read.
|
|
364
|
-
const unknown = stallReport(stale, { claimed: null, supply: null });
|
|
365
|
-
assert.match(unknown, /unknown ticket\(s\) claimed and in flight/);
|
|
366
|
-
assert.match(unknown, /pool supply unknown/);
|
|
367
|
-
assert.doesNotMatch(unknown, /\b0 ticket/);
|
|
368
|
-
|
|
369
|
-
// And a healthy verdict has no report at all, so a caller that skipped
|
|
370
|
-
// isStalled() cannot print a death for a beating run by accident.
|
|
371
|
-
assert.equal(stallReport(assessBeat({ beat: { at: now, interval: 300, stopped: "" }, now }), { claimed: 1, supply: 1 }), null);
|
|
372
|
-
assert.equal(stallReport(assessBeat({ beat: null, now }), { claimed: 1, supply: 1 }), null);
|
|
373
|
-
});
|
|
374
|
-
|
|
375
|
-
test("stallReport: a sub-60s interval renders as seconds, not a floored 0m", () => {
|
|
376
|
-
// #1735: mins() floors to whole minutes, and the CLI guard for --base/
|
|
377
|
-
// --ceiling only requires >= 1 (fleet-heartbeat.test.mjs relies on that —
|
|
378
|
-
// its CLI cases use 2s/3s/8s intervals throughout to keep real
|
|
379
|
-
// Atomics.wait holds fast), so a sub-minute mark is a real, reachable
|
|
380
|
-
// shape here, not an input this module gets to refuse. Flooring it to
|
|
381
|
-
// "0m" read as a division-by-zero defect rather than the true value.
|
|
382
|
-
const now = 2_000_000_000_000;
|
|
383
|
-
const at = now - 45_000;
|
|
384
|
-
const verdict = assessBeat({ beat: { at, interval: 30, stopped: "smoke test" }, now });
|
|
385
|
-
const line = stallReport(verdict, { claimed: 0, supply: 0 });
|
|
386
|
-
assert.match(line, /45s ago/);
|
|
387
|
-
assert.match(line, /15s past the 30s interval it promised/);
|
|
388
|
-
assert.doesNotMatch(line, /\b0m\b/);
|
|
389
|
-
|
|
390
|
-
// The boundary itself: exactly 60s reports as "1m", never "60s" — mins()
|
|
391
|
-
// has exactly one branch point and this pins which side 60000ms falls on.
|
|
392
|
-
const boundary = assessBeat({ beat: { at: now - 60_000, interval: 30, stopped: "smoke test" }, now });
|
|
393
|
-
assert.match(stallReport(boundary, { claimed: 0, supply: 0 }), /1m ago/);
|
|
394
|
-
});
|
|
395
|
-
|
|
396
|
-
test("stallReport: a 60-119s band value does not silently break the trio's arithmetic (#1797)", () => {
|
|
397
|
-
// #1735 only moved the floor for values UNDER 60s. mins() still floored
|
|
398
|
-
// every value >= 60s to whole minutes independently of the other two, so
|
|
399
|
-
// an interval landing in 60-119s (a real, CLI-reachable shape — see the
|
|
400
|
-
// comment above mins()) floored to "1m" or "2m" while its own overdue
|
|
401
|
-
// remainder kept printing in seconds, and the three displayed numbers
|
|
402
|
-
// stopped agreeing with each other. These are the exact reviewer repros.
|
|
403
|
-
const now = 2_000_000_000_000;
|
|
404
|
-
const line = (ageS, intervalS) =>
|
|
405
|
-
stallReport(
|
|
406
|
-
assessBeat({ beat: { at: now - ageS * 1000, interval: intervalS, stopped: "smoke test" }, now }),
|
|
407
|
-
{ claimed: 0, supply: 0 },
|
|
408
|
-
);
|
|
409
|
-
|
|
410
|
-
// interval=90s, age=100s: overdue=10s. Old output read "1m ago ... 10s
|
|
411
|
-
// past the 1m interval" — 1m minus 1m is 0, not 10s.
|
|
412
|
-
assert.match(line(100, 90), /\(1m40s ago, 10s past the 1m30s interval it promised\)/);
|
|
413
|
-
|
|
414
|
-
// interval=90s, age=200s: overdue=110s. Old output read "3m ago ... 1m
|
|
415
|
-
// past the 1m interval" — 3m minus 1m is 2m, not 1m.
|
|
416
|
-
assert.match(line(200, 90), /\(3m20s ago, 1m50s past the 1m30s interval it promised\)/);
|
|
417
|
-
|
|
418
|
-
// interval=120s, age=150s: overdue=30s. Old output happened to print "2m
|
|
419
|
-
// ago ... 30s past the 2m interval" only because 120s floors to an exact
|
|
420
|
-
// "2m" with nothing dropped — fragile, not a fix, and now stated to full
|
|
421
|
-
// precision like every other case in this band.
|
|
422
|
-
assert.match(line(150, 120), /\(2m30s ago, 30s past the 2m interval it promised\)/);
|
|
423
|
-
});
|
|
424
|
-
|
|
425
|
-
test("stallReport: age always reconciles to overdue+interval, across every unit boundary the CLI can produce", () => {
|
|
426
|
-
// Property check standing in for the two hand-picked repros above: for a
|
|
427
|
-
// spread of intervals that straddle every unit boundary mins() has (under
|
|
428
|
-
// 60s, the 60-119s band, and clean multi-minute values), and a spread of
|
|
429
|
-
// deltas layered on top so age also straddles those same boundaries, the
|
|
430
|
-
// three numbers stallReport prints must parse back to millisecond figures
|
|
431
|
-
// that satisfy overdue + interval === age — never merely "doesn't crash".
|
|
432
|
-
const now = 2_000_000_000_000;
|
|
433
|
-
const parseDur = (s) => {
|
|
434
|
-
const m = /^(?:(\d+)m)?(?:(\d+)s)?$/.exec(s);
|
|
435
|
-
assert.ok(m, `unparseable duration: ${s}`);
|
|
436
|
-
return ((m[1] ? Number(m[1]) : 0) * 60 + (m[2] ? Number(m[2]) : 0)) * 1000;
|
|
437
|
-
};
|
|
438
|
-
const lineShape = /\((\S+) ago, (\S+) past the (\S+) interval it promised\)/;
|
|
439
|
-
|
|
440
|
-
const intervals = [30, 60, 90, 100, 119, 120, 150, 300];
|
|
441
|
-
const deltas = [1, 15, 29, 30, 31, 59, 60, 61, 89, 90, 91, 119, 120, 121, 200, 599, 3600];
|
|
442
|
-
for (const intervalS of intervals) {
|
|
443
|
-
for (const delta of deltas) {
|
|
444
|
-
const ageS = intervalS + delta;
|
|
445
|
-
const verdict = assessBeat({ beat: { at: now - ageS * 1000, interval: intervalS, stopped: "smoke test" }, now });
|
|
446
|
-
const line = stallReport(verdict, { claimed: 0, supply: 0 });
|
|
447
|
-
const m = lineShape.exec(line);
|
|
448
|
-
assert.ok(m, `line did not match expected shape: ${line}`);
|
|
449
|
-
const [, ageStr, overdueStr, intervalStr] = m;
|
|
450
|
-
const ageMs = parseDur(ageStr);
|
|
451
|
-
const overdueMs = parseDur(overdueStr);
|
|
452
|
-
const intervalMs = parseDur(intervalStr);
|
|
453
|
-
assert.equal(
|
|
454
|
-
overdueMs + intervalMs,
|
|
455
|
-
ageMs,
|
|
456
|
-
`interval=${intervalS}s age=${ageS}s: "${overdueStr}" + "${intervalStr}" != "${ageStr}" (line: ${line})`,
|
|
457
|
-
);
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
});
|