@feigi/fleet-ctl 3.47.2 → 3.47.3
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 +37 -21
- package/skills/run-team/SKILL.md +14 -11
package/package.json
CHANGED
|
@@ -65,11 +65,12 @@
|
|
|
65
65
|
// never a path.
|
|
66
66
|
// unknown — some read failed: git, a hash, HEAD, `origin/main`, or a baseline
|
|
67
67
|
// that EXISTS but cannot be read (unreadable file, unsearchable
|
|
68
|
-
// `.fleet/`, dangling symlink, not written by --record) — or is
|
|
69
|
-
//
|
|
70
|
-
//
|
|
71
|
-
//
|
|
72
|
-
//
|
|
68
|
+
// `.fleet/`, dangling symlink, not written by --record) — or is
|
|
69
|
+
// an older version's baseline, which this code cannot compare:
|
|
70
|
+
// re-record it — or is a newer version's, written by a newer
|
|
71
|
+
// plugin: run that plugin — or names a commit absent from the
|
|
72
|
+
// repository: examine HEAD, then re-record it. "A failure is an
|
|
73
|
+
// unknown answer, never a 'no'" — never `clean`.
|
|
73
74
|
// absent — no baseline at all: the run never recorded one. A refusal
|
|
74
75
|
// ("record at run start"), never `clean`.
|
|
75
76
|
//
|
|
@@ -78,10 +79,11 @@
|
|
|
78
79
|
// the maintainer's clear only AFTER the stray paths are resolved. Over `unknown`
|
|
79
80
|
// it would walk the run from "could not look" to "certified clean" in one step,
|
|
80
81
|
// so it refuses on every unknown cause it can see: a baseline that exists but
|
|
81
|
-
// cannot be read,
|
|
82
|
-
//
|
|
83
|
-
//
|
|
84
|
-
//
|
|
82
|
+
// cannot be read, one a newer plugin wrote (overwriting it would discard a
|
|
83
|
+
// baseline nobody read), and any failed git or hash read (no snapshot, nothing
|
|
84
|
+
// to write). A detached HEAD has no symbolic ref to record, so it refuses that
|
|
85
|
+
// too. An older version's baseline, and one whose commit is gone (it never
|
|
86
|
+
// reads the recorded commit), it overwrites without a word.
|
|
85
87
|
//
|
|
86
88
|
// A BASELINE COMMIT GONE FROM THE REPOSITORY is its own unknown. An amend or
|
|
87
89
|
// reset leaves the baseline's commit unreachable, and once reflog expiry and
|
|
@@ -121,8 +123,12 @@ import { gitEnv, workspaceDirFromGitCommonDir } from "./git-env.mjs";
|
|
|
121
123
|
export const BASELINE_FILE = "main-checkout.sha";
|
|
122
124
|
export const RECORD_COMMAND = "~/.fleet/bin/fleet-run main-checkout.mjs --record";
|
|
123
125
|
const RUN_BOOKKEEPING = new Set(["docs/metrics/tier-outcomes.tsv", "docs/metrics/member-outcomes.tsv", "docs/metrics/ticket-features.tsv"]);
|
|
124
|
-
|
|
125
|
-
|
|
126
|
+
// Any change to an entry's hash or to a line's format bumps VERSION: a
|
|
127
|
+
// baseline an older plugin wrote then reads `outdated` (re-record) and one a
|
|
128
|
+
// newer plugin wrote reads `newer`, never as a baseline this code wrote.
|
|
129
|
+
const VERSION = 2;
|
|
130
|
+
const HEADER = `fleet main-checkout baseline v${VERSION}`;
|
|
131
|
+
const HEADER_RE = /^fleet main-checkout baseline v(\d+)$/;
|
|
126
132
|
const GIT_TIMEOUT_MS = 30_000;
|
|
127
133
|
const MAX_BUFFER = 64 * 1024 * 1024;
|
|
128
134
|
const NAME = "main-checkout";
|
|
@@ -320,7 +326,8 @@ function headMove(root, env, was, now) {
|
|
|
320
326
|
|
|
321
327
|
/**
|
|
322
328
|
* The run's baseline: `{status: "ok", entries, head}`, `{status: "absent"}`,
|
|
323
|
-
* `{status: "outdated", why}` (
|
|
329
|
+
* `{status: "outdated", why}` (an older VERSION's file), `{status: "newer",
|
|
330
|
+
* why}` (a newer VERSION's) or `{status: "unreadable", why}`.
|
|
324
331
|
* ABSENT is only "nothing at that name": a
|
|
325
332
|
* dangling symlink is present-but-broken, and an unsearchable `.fleet/`
|
|
326
333
|
* answers EACCES rather than ENOENT, so neither can fall through to
|
|
@@ -343,7 +350,9 @@ export function readBaseline(path) {
|
|
|
343
350
|
return { status: "unreadable", why: `${path} exists but cannot be read: ${e?.code ?? e?.message}` };
|
|
344
351
|
}
|
|
345
352
|
const lines = text.split("\n");
|
|
346
|
-
|
|
353
|
+
const version = HEADER_RE.exec(lines[0]);
|
|
354
|
+
if (version && Number(version[1]) < VERSION) return { status: "outdated", why: `baseline v${version[1]} — re-record` };
|
|
355
|
+
if (version && Number(version[1]) > VERSION) return { status: "newer", why: `baseline v${version[1]} written by a newer plugin` };
|
|
347
356
|
const ref = lines[1]?.startsWith("ref ") ? lines[1].slice(4) : "";
|
|
348
357
|
const oid = lines[2]?.startsWith("oid ") ? lines[2].slice(4) : "";
|
|
349
358
|
if (lines[0] !== HEADER || lines.at(-1) !== "" || !ref || !/^[0-9a-f]{40,64}$/.test(oid)) {
|
|
@@ -370,10 +379,11 @@ export function changedPaths(baseline, current) {
|
|
|
370
379
|
|
|
371
380
|
/**
|
|
372
381
|
* The tick's question: `{state, root?, baseline?, changed?, headMove?, why?, cause?}`.
|
|
373
|
-
* `cause` tells the
|
|
374
|
-
* be read), `"outdated"` (
|
|
375
|
-
* answer nothing), `"
|
|
376
|
-
*
|
|
382
|
+
* `cause` tells the unknowns apart — `"baseline"` (it exists but cannot
|
|
383
|
+
* be read), `"outdated"` (an older version's baseline: this code cannot
|
|
384
|
+
* compare it, so it can answer nothing), `"newer"` (a newer plugin wrote it),
|
|
385
|
+
* `"missing"` (the baseline's commit is absent from the repository) and
|
|
386
|
+
* `"read"` (git or a hash failed) — since each has its own
|
|
377
387
|
* message. The baseline is read before the tree, because without one there
|
|
378
388
|
* is nothing to compare against and no reason to look.
|
|
379
389
|
* A HEAD move is the first entry of `changed`, also named in `headMove`.
|
|
@@ -388,6 +398,7 @@ export function checkMainCheckout({ cwd = process.cwd(), env = process.env } = {
|
|
|
388
398
|
const unknown = (why, cause = "read") => ({ state: "unknown", cause, root, baseline: path, why });
|
|
389
399
|
if (base.status === "unreadable") return unknown(base.why, "baseline");
|
|
390
400
|
if (base.status === "outdated") return unknown(base.why, "outdated");
|
|
401
|
+
if (base.status === "newer") return unknown(base.why, "newer");
|
|
391
402
|
const now = readState(root, env);
|
|
392
403
|
if (!now.ok) return unknown(now.why);
|
|
393
404
|
const move = headMove(root, env, base.head, now.head);
|
|
@@ -426,6 +437,7 @@ export function describe(check, live = null) {
|
|
|
426
437
|
return `MAIN-CHECKOUT-UNKNOWN ${check.why}${members}`
|
|
427
438
|
+ ` — dispatch held: resolve any stray paths FIRST, then re-record with ${RECORD_COMMAND} (it overwrites, it does not compare)`;
|
|
428
439
|
}
|
|
440
|
+
if (check.cause === "newer") return `MAIN-CHECKOUT-UNKNOWN ${check.why}${members} — dispatch held: run the plugin that wrote it`;
|
|
429
441
|
if (check.cause === "missing") {
|
|
430
442
|
return `MAIN-CHECKOUT-UNKNOWN ${check.why}${members}`
|
|
431
443
|
+ " — dispatch held: examine HEAD against origin/main FIRST, since a missing baseline commit means HEAD moved off it by an amend or reset nobody has looked at, and resolve any stray paths;"
|
|
@@ -441,10 +453,11 @@ export function describe(check, live = null) {
|
|
|
441
453
|
|
|
442
454
|
/**
|
|
443
455
|
* Write the baseline: `{ok, path, entries, head}` or `{ok: false, why}`.
|
|
444
|
-
* Refuses over a baseline that exists but cannot be read
|
|
445
|
-
*
|
|
446
|
-
*
|
|
447
|
-
*
|
|
456
|
+
* Refuses over a baseline that exists but cannot be read, and over one a
|
|
457
|
+
* newer plugin wrote — overwriting either blind discards evidence nobody
|
|
458
|
+
* read — and on any failed read of the tree, of HEAD or of `origin/main`, and
|
|
459
|
+
* on a detached HEAD, which has no symbolic ref to record. An older version's
|
|
460
|
+
* baseline is not unreadable: it is the one this overwrites.
|
|
448
461
|
* Written to a temporary name and renamed, so a reader never sees half of it.
|
|
449
462
|
*/
|
|
450
463
|
export function recordBaseline({ cwd = process.cwd(), env = process.env } = {}) {
|
|
@@ -455,6 +468,9 @@ export function recordBaseline({ cwd = process.cwd(), env = process.env } = {})
|
|
|
455
468
|
if (prior.status === "unreadable") {
|
|
456
469
|
return { ok: false, why: `${prior.why} — fix it first; do NOT --record over it, --record overwrites rather than compares` };
|
|
457
470
|
}
|
|
471
|
+
if (prior.status === "newer") {
|
|
472
|
+
return { ok: false, why: `${prior.why} — run the plugin that wrote it; do NOT --record over it, --record overwrites rather than compares` };
|
|
473
|
+
}
|
|
458
474
|
const now = readState(where.root, env);
|
|
459
475
|
if (!now.ok) return { ok: false, why: `${now.why} — could not look, so there is nothing to record` };
|
|
460
476
|
if (now.head.ref === null) {
|
package/skills/run-team/SKILL.md
CHANGED
|
@@ -307,10 +307,11 @@ phase, or in any later one, asks the maintainer which tickets to take.
|
|
|
307
307
|
them — and only then re-runs `--record`; re-recording over unresolved paths
|
|
308
308
|
certifies them. **Never re-record over `MAIN-CHECKOUT-UNKNOWN`**: that
|
|
309
309
|
walks the run from "could not look" to "certified clean" in one step, so
|
|
310
|
-
`--record` itself refuses over a baseline it cannot read
|
|
311
|
-
read that fails. The exceptions are
|
|
312
|
-
|
|
313
|
-
|
|
310
|
+
`--record` itself refuses over a baseline it cannot read, over one a newer
|
|
311
|
+
plugin wrote, and on any git read that fails. The exceptions are an
|
|
312
|
+
older-version baseline and a baseline whose commit is missing from the
|
|
313
|
+
repository; Phase 3's tick lines say how each is cleared.
|
|
314
|
+
`main-checkout.mjs --check` prints the same answer
|
|
314
315
|
without a tick.
|
|
315
316
|
|
|
316
317
|
**Run the pre-flight, once the pin and the baseline are recorded.**
|
|
@@ -1972,13 +1973,15 @@ depth** guard table applied in code. Act on each line as it reads:
|
|
|
1972
1973
|
could not look: a git or hash read failed (`could not look:`), or the
|
|
1973
1974
|
baseline exists but cannot be read (`baseline unreadable:`). Never clean,
|
|
1974
1975
|
and **never re-baseline over it** — `--record` overwrites, so that certifies
|
|
1975
|
-
a tree nobody read. Fix what the line names and tick again.
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1976
|
+
a tree nobody read. Fix what the line names and tick again. `baseline v<n>
|
|
1977
|
+
written by a newer plugin` is a baseline a newer plugin version wrote:
|
|
1978
|
+
`--record` refuses over it too — run the plugin that wrote it. The
|
|
1979
|
+
exceptions are the two whose remedy is `--record`: `baseline v<n> —
|
|
1980
|
+
re-record`, an older-format baseline this plugin cannot compare; and
|
|
1981
|
+
`baseline commit <oid> is missing from this repository`, which an amend or
|
|
1982
|
+
reset followed by gc leaves — examine HEAD against `origin/main` FIRST,
|
|
1983
|
+
since HEAD moved off that commit and nobody has looked at the move, and
|
|
1984
|
+
resolve any stray paths, which the line does not name; only then re-record.
|
|
1982
1985
|
- `MAIN-CHECKOUT-NO-BASELINE …` with `HOLD (main checkout no baseline)` — no
|
|
1983
1986
|
baseline was recorded. Yours to fix: run Phase 0's `--record`. A baseline
|
|
1984
1987
|
that vanished mid-run is not a fresh run — report it to the maintainer
|