@feigi/fleet-ctl 3.71.11 → 3.71.12
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
CHANGED
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
// `docs/metrics/ticket-features.tsv`, deduped on `session` + `agent`, and
|
|
15
15
|
// deletes the pending file. A crash between the write and the delete leaves
|
|
16
16
|
// rows the next drain finds already there, so a second run changes nothing.
|
|
17
|
+
// A pending file that is empty, or blank lines only, is removed with its own
|
|
18
|
+
// line: an append created it and never wrote.
|
|
17
19
|
//
|
|
18
20
|
// COST GUARD. `pr-cost.mjs --guard` rewrites `.fleet/cost-guard.json`, which
|
|
19
21
|
// the router reads and fails closed without. It needs all three metrics TSVs;
|
|
@@ -56,7 +58,16 @@ function drain(repo) {
|
|
|
56
58
|
const pending = join(repo, PENDING);
|
|
57
59
|
if (!existsSync(pending)) return say(`drain: nothing pending in ${PENDING}`);
|
|
58
60
|
const pendingText = readFileSync(pending, "utf8");
|
|
59
|
-
|
|
61
|
+
if (pendingText.trim() === "") {
|
|
62
|
+
unlinkSync(pending);
|
|
63
|
+
return say(`drain: ${PENDING} was empty — removed (an append created it and never wrote: crash or full disk)`);
|
|
64
|
+
}
|
|
65
|
+
let incoming;
|
|
66
|
+
try {
|
|
67
|
+
incoming = parseFeatures(pendingText);
|
|
68
|
+
} catch (e) {
|
|
69
|
+
throw new Error(`${PENDING}: ${e.message}`);
|
|
70
|
+
}
|
|
60
71
|
const target = join(repo, FEATURES);
|
|
61
72
|
let text = existsSync(target) ? readFileSync(target, "utf8") : `${FEATURE_COLUMNS.join("\t")}\n`;
|
|
62
73
|
const seen = new Set(parseFeatures(text).map(pullKey));
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
// the guard are files the caller wrote, and a fitted commit is fetched by the
|
|
37
37
|
// caller.
|
|
38
38
|
|
|
39
|
-
import { readFileSync, writeFileSync, renameSync,
|
|
39
|
+
import { readFileSync, writeFileSync, renameSync, appendFileSync, mkdirSync, statSync } from "node:fs";
|
|
40
40
|
import { spawnSync } from "node:child_process";
|
|
41
41
|
import { basename, dirname, join, resolve } from "node:path";
|
|
42
42
|
import { fileURLToPath } from "node:url";
|
|
@@ -580,7 +580,7 @@ function main() {
|
|
|
580
580
|
const pending = F.arg("pending") ?? join(dirname(guardPath), "ticket-features.pending.tsv");
|
|
581
581
|
try {
|
|
582
582
|
mkdirSync(dirname(pending), { recursive: true });
|
|
583
|
-
const header =
|
|
583
|
+
const header = statSync(pending, { throwIfNoEntry: false })?.size > 0 ? "" : `${COLUMNS.join("\t")}\n`;
|
|
584
584
|
appendFileSync(pending, `${header}${formatFeatureRow(row)}\n`);
|
|
585
585
|
} catch (e) {
|
|
586
586
|
process.stderr.write(`${NAME}: WARNING could not append to ${pending}: ${e.message} — this Pull's ticket-features row is not recorded\n`);
|