@christang/keel 5.121.0 → 5.122.0
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/README.md +5 -2
- package/assets/bootstrap/AGENTS.md +1 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/plugins/keel/.claude-plugin/plugin.json +1 -1
- package/plugins/keel/.codex-plugin/plugin.json +1 -1
- package/scripts/validate_plugin.py +68 -13
- package/src/core/patrol.js +64 -14
package/README.md
CHANGED
|
@@ -796,8 +796,11 @@ hour for a note deliberately left parked (#295). `keel patrol --since-last` keep
|
|
|
796
796
|
idleness and open todos, and the coordinator's addressed records unread beyond `--idle` — and prints
|
|
797
797
|
only `changed:` lines for what differs from the previous run; the first run records a baseline. It
|
|
798
798
|
writes that snapshot on every run, and exits 2 only when something changed. Add `--notify` and the
|
|
799
|
-
|
|
800
|
-
the
|
|
799
|
+
coordinator gets one direct message from `keel-patrol`, which wakes its session, carrying only risks
|
|
800
|
+
(#307): the shared checkout gaining uncommitted paths after a clean run, free disk the host reports with
|
|
801
|
+
`--disk-free-gb` dropping below `--disk-min-gb` (default 20), and a role that left two nudges in a row
|
|
802
|
+
unanswered. Shift-status changes and new commits are printed, not sent. Every run appends one line to
|
|
803
|
+
`patrol/log/<role>.log` in the chat store, so a silent run can still be audited.
|
|
801
804
|
|
|
802
805
|
`keel patrol --nudge` goes further and nudges each idle role itself, with one direct message from
|
|
803
806
|
`keel-patrol` that wakes its session (#307): when records addressed to it have waited longer than
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@christang/keel",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.122.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@christang/keel",
|
|
9
|
-
"version": "5.
|
|
9
|
+
"version": "5.122.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@fission-ai/openspec": "^1.4.1"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "keel",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.122.0",
|
|
4
4
|
"description": "Keel OpenSpec execution discipline: stateless continuity, task capsules, deterministic gates, and expectation alignment for Codex and Claude Code.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "TanglmChris",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "keel",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.122.0",
|
|
4
4
|
"description": "Keel OpenSpec execution discipline: stateless continuity, task capsules, deterministic gates, and expectation alignment for Codex and Claude Code.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "TanglmChris",
|
|
@@ -47,8 +47,8 @@ REQUIRED_SCRIPTS = [
|
|
|
47
47
|
"scripts/validate_plugin.py",
|
|
48
48
|
]
|
|
49
49
|
|
|
50
|
-
PACKAGE_VERSION = "5.
|
|
51
|
-
PROTOCOL_VERSION = "5.
|
|
50
|
+
PACKAGE_VERSION = "5.122.0"
|
|
51
|
+
PROTOCOL_VERSION = "5.122.0"
|
|
52
52
|
LEGACY_MANAGED_START = "<!-- keel:start version=2.1 -->"
|
|
53
53
|
OPENSPEC_SCHEMA_NAME = "keel-spec-driven"
|
|
54
54
|
# Mirrors KEEL_PACKAGE_NAME in scripts/install_to_repo.py, one of the two
|
|
@@ -2809,15 +2809,9 @@ def validate_patrol_since_last_scenario() -> int:
|
|
|
2809
2809
|
if not any("remote" in line for line in changed):
|
|
2810
2810
|
report(f"{label} the remote tip change is not reported: {second.stdout!r}")
|
|
2811
2811
|
return 1
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
if "from: keel-patrol" not in notices()[0]:
|
|
2816
|
-
report(f"{label} the notice is not from keel-patrol: {notices()[0]!r}")
|
|
2817
|
-
return 1
|
|
2818
|
-
woken = run_keel(rtl, "chat", "notice", "--check", env=env)
|
|
2819
|
-
if woken.returncode != 0:
|
|
2820
|
-
report(f"{label} the notice does not wake rtl (notice --check exit {woken.returncode}).")
|
|
2812
|
+
# Shift-status and remote changes are not risks (#307 part 3): printed, not sent.
|
|
2813
|
+
if notices():
|
|
2814
|
+
report(f"{label} a run with no risk sent the coordinator a notice: {notices()!r}")
|
|
2821
2815
|
return 1
|
|
2822
2816
|
third = patrol("--since-last", "--notify")
|
|
2823
2817
|
if third.returncode != 0:
|
|
@@ -2826,8 +2820,8 @@ def validate_patrol_since_last_scenario() -> int:
|
|
|
2826
2820
|
if "changed:" in third.stdout:
|
|
2827
2821
|
report(f"{label} an unchanged run reported a change: {third.stdout!r}")
|
|
2828
2822
|
return 1
|
|
2829
|
-
if
|
|
2830
|
-
report(f"{label} an unchanged run sent
|
|
2823
|
+
if notices():
|
|
2824
|
+
report(f"{label} an unchanged run sent a notice.")
|
|
2831
2825
|
return 1
|
|
2832
2826
|
report("patrol-since-last scenario passed.")
|
|
2833
2827
|
return 0
|
|
@@ -2919,6 +2913,66 @@ def validate_patrol_nudge_scenario() -> int:
|
|
|
2919
2913
|
return 0
|
|
2920
2914
|
|
|
2921
2915
|
|
|
2916
|
+
def validate_patrol_escalate_scenario() -> int:
|
|
2917
|
+
"""Issue #307 part 3: only risks reach the coordinator; every run is logged."""
|
|
2918
|
+
label = "patrol-escalate:"
|
|
2919
|
+
with tempfile.TemporaryDirectory(prefix="keel-patrol-escalate-") as raw:
|
|
2920
|
+
base = Path(raw)
|
|
2921
|
+
rtl, verify, env, _ = shift_scratch(base)
|
|
2922
|
+
env = {**env, "KEEL_PATROL_UNREAD_EVERY_MS": "1"}
|
|
2923
|
+
runs = 0
|
|
2924
|
+
|
|
2925
|
+
def patrol(*args: str) -> subprocess.CompletedProcess[str]:
|
|
2926
|
+
nonlocal runs
|
|
2927
|
+
runs += 1
|
|
2928
|
+
return run_keel(rtl, "patrol", "--since-last", "--notify", "--idle", "1s", *args, env=env)
|
|
2929
|
+
|
|
2930
|
+
def sent(needle: str) -> int:
|
|
2931
|
+
return len(chat_records_with(rtl, "dm-keel-patrol--rtl", needle))
|
|
2932
|
+
|
|
2933
|
+
patrol()
|
|
2934
|
+
write_text(rtl / "dirty.txt", "left behind\n")
|
|
2935
|
+
dirty = patrol()
|
|
2936
|
+
if sent("uncommitted") != 1:
|
|
2937
|
+
report(f"{label} the dirty checkout was not sent once: {dirty.stdout!r} {dirty.stderr!r}")
|
|
2938
|
+
return 1
|
|
2939
|
+
if not any(line.startswith("risk:") for line in dirty.stdout.splitlines()):
|
|
2940
|
+
report(f"{label} the risk is not printed: {dirty.stdout!r}")
|
|
2941
|
+
return 1
|
|
2942
|
+
patrol("--disk-free-gb", "12")
|
|
2943
|
+
if sent("free disk is 12 GB") != 1:
|
|
2944
|
+
report(f"{label} low disk was not sent once.")
|
|
2945
|
+
return 1
|
|
2946
|
+
patrol("--disk-free-gb", "12")
|
|
2947
|
+
if sent("free disk") != 1:
|
|
2948
|
+
report(f"{label} low disk was sent again without changing.")
|
|
2949
|
+
return 1
|
|
2950
|
+
if sent("uncommitted") != 1:
|
|
2951
|
+
report(f"{label} the still-dirty checkout was sent again.")
|
|
2952
|
+
return 1
|
|
2953
|
+
run_keel(rtl, "chat", "post", "soc", "@verify rerun R007 please", env=env)
|
|
2954
|
+
time.sleep(1.2)
|
|
2955
|
+
patrol("--nudge")
|
|
2956
|
+
time.sleep(0.2)
|
|
2957
|
+
second = patrol("--nudge")
|
|
2958
|
+
if sent("2 nudges") != 1:
|
|
2959
|
+
report(f"{label} two unanswered nudges were not escalated once: {second.stdout!r}")
|
|
2960
|
+
return 1
|
|
2961
|
+
if "verify" not in "\n".join(chat_records_with(rtl, "dm-keel-patrol--rtl", "2 nudges")):
|
|
2962
|
+
report(f"{label} the escalation does not name verify.")
|
|
2963
|
+
return 1
|
|
2964
|
+
log = mailbox_common_dir(rtl) / "keel-chat" / "patrol" / "log" / "rtl.log"
|
|
2965
|
+
lines = log.read_text(encoding="utf-8").splitlines() if log.exists() else []
|
|
2966
|
+
if len(lines) != runs:
|
|
2967
|
+
report(f"{label} the run log holds {len(lines)} lines for {runs} runs.")
|
|
2968
|
+
return 1
|
|
2969
|
+
if not all("exit=" in line and "risks=" in line for line in lines):
|
|
2970
|
+
report(f"{label} a run log line lacks exit= or risks=: {lines!r}")
|
|
2971
|
+
return 1
|
|
2972
|
+
report("patrol-escalate scenario passed.")
|
|
2973
|
+
return 0
|
|
2974
|
+
|
|
2975
|
+
|
|
2922
2976
|
def validate_coordinator_patrol_scenario() -> int:
|
|
2923
2977
|
"""Issue #260: declared waits, and a patrol that notifies once.
|
|
2924
2978
|
|
|
@@ -39994,6 +40048,7 @@ SCENARIOS: tuple = (
|
|
|
39994
40048
|
("coordinator-patrol", validate_coordinator_patrol_scenario),
|
|
39995
40049
|
("patrol-since-last", validate_patrol_since_last_scenario),
|
|
39996
40050
|
("patrol-nudge", validate_patrol_nudge_scenario),
|
|
40051
|
+
("patrol-escalate", validate_patrol_escalate_scenario),
|
|
39997
40052
|
("patrol-host-task", validate_patrol_host_task_scenario),
|
|
39998
40053
|
("patrol-rearm", validate_patrol_rearm_scenario),
|
|
39999
40054
|
("patrol-issue-routing", validate_patrol_issue_routing_scenario),
|
package/src/core/patrol.js
CHANGED
|
@@ -152,6 +152,8 @@ function currentSnapshot(where, role, result, options) {
|
|
|
152
152
|
if (status !== null) entries[`checkout ${primary}`] = `${status ? status.split("\n").length : 0} uncommitted paths`;
|
|
153
153
|
}
|
|
154
154
|
for (const line of result.drift) entries[line.key] = line.text;
|
|
155
|
+
// Free disk as the host measured it (#307 part 3 D1).
|
|
156
|
+
if (options.diskFreeGb !== null) entries.disk = options.diskFreeGb < options.diskMinGb ? "low" : "ok";
|
|
155
157
|
for (const row of result.roles) {
|
|
156
158
|
entries[`role ${row.role}`] = `${row.idle ? "idle" : "active"}, ${row.openTodos} open todo${row.openTodos === 1 ? "" : "s"}`;
|
|
157
159
|
}
|
|
@@ -167,7 +169,7 @@ function sinceLast(where, role, result, options) {
|
|
|
167
169
|
const previous = fs.existsSync(file) ? store.readJsonFile(file) : null;
|
|
168
170
|
const now = currentSnapshot(where, role, result, options);
|
|
169
171
|
store.writeJsonAtomic(where, file, now);
|
|
170
|
-
if (!previous || !previous.entries) return { baseline: true, changes: [] };
|
|
172
|
+
if (!previous || !previous.entries) return { baseline: true, changes: [], risks: [] };
|
|
171
173
|
const changes = [];
|
|
172
174
|
const keys = [...new Set([...Object.keys(previous.entries), ...Object.keys(now.entries)])].sort();
|
|
173
175
|
for (const key of keys) {
|
|
@@ -179,7 +181,19 @@ function sinceLast(where, role, result, options) {
|
|
|
179
181
|
for (const record of now.unread) {
|
|
180
182
|
if (!seen.has(record.id)) changes.push(`unread: ${record.id} from ${record.from}, unanswered since ${record.created}`);
|
|
181
183
|
}
|
|
182
|
-
|
|
184
|
+
// What the coordinator must hear (#307 part 3 D1): a clean checkout turned
|
|
185
|
+
// dirty, and free disk turned low; the rest of the changes are only printed.
|
|
186
|
+
const risks = [];
|
|
187
|
+
for (const key of Object.keys(now.entries).filter((entry) => entry.startsWith("checkout "))) {
|
|
188
|
+
const count = Number.parseInt(now.entries[key], 10);
|
|
189
|
+
if (previous.entries[key] === "0 uncommitted paths" && count > 0) {
|
|
190
|
+
risks.push(`the shared checkout ${key.slice("checkout ".length)} has ${count} uncommitted paths`);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
if (now.entries.disk === "low" && previous.entries.disk !== "low") {
|
|
194
|
+
risks.push(`free disk is ${options.diskFreeGb} GB, below ${options.diskMinGb} GB`);
|
|
195
|
+
}
|
|
196
|
+
return { baseline: false, changes, risks };
|
|
183
197
|
}
|
|
184
198
|
|
|
185
199
|
// --- nudges (#307 part 1) -----------------------------------------------------------
|
|
@@ -189,7 +203,7 @@ function sinceLast(where, role, result, options) {
|
|
|
189
203
|
// as waiting, so a nudge cannot cause the next one.
|
|
190
204
|
|
|
191
205
|
const KEEL_SENDERS = new Set([NOTIFY_SENDER, "keel-shift", "keel"]);
|
|
192
|
-
const UNREAD_EVERY_MS = 2 * 60 * 60 * 1000;
|
|
206
|
+
const UNREAD_EVERY_MS = Number(process.env.KEEL_PATROL_UNREAD_EVERY_MS) > 0 ? Number(process.env.KEEL_PATROL_UNREAD_EVERY_MS) : 2 * 60 * 60 * 1000;
|
|
193
207
|
const SHIFT_EVERY_MS = 6 * 60 * 60 * 1000;
|
|
194
208
|
const SELF_INITIATED = "Self-initiated: this shift armed `keel shift ready --wake`.";
|
|
195
209
|
|
|
@@ -218,6 +232,7 @@ function nudgeRoles(where, patroller, options) {
|
|
|
218
232
|
const now = Date.now();
|
|
219
233
|
const idleBefore = parseSince(options.idle);
|
|
220
234
|
const sent = [];
|
|
235
|
+
const escalations = [];
|
|
221
236
|
const roles = [...new Set(Object.values(store.readJsonFile(path.join(where.root, "roles.json"))).filter(Boolean))]
|
|
222
237
|
.filter((role) => role !== patroller).sort();
|
|
223
238
|
for (const role of roles) {
|
|
@@ -235,9 +250,17 @@ function nudgeRoles(where, patroller, options) {
|
|
|
235
250
|
if (!Number.isNaN(oldest) && oldest < idleBefore && (Number.isNaN(recent) || now - recent >= UNREAD_EVERY_MS)) {
|
|
236
251
|
sent.push(sendNudge(where, role, "unread",
|
|
237
252
|
`${role}: ${waiting.length} record(s) addressed to you have waited since ${waiting[0].created}; read them with \`keel chat unread\`.`));
|
|
238
|
-
|
|
253
|
+
// A nudge over work older than the last one is a nudge left unanswered (D2).
|
|
254
|
+
mine.unanswered = !Number.isNaN(recent) && oldest < recent ? (mine.unanswered || 0) + 1 : 1;
|
|
255
|
+
if (mine.unanswered === 2) {
|
|
256
|
+
escalations.push(`${role} has not answered 2 nudges; ${waiting.length} record(s) addressed to it have waited since ${waiting[0].created}`);
|
|
257
|
+
}
|
|
258
|
+
mine.unread = new Date(now).toISOString();
|
|
239
259
|
}
|
|
240
|
-
} else
|
|
260
|
+
} else {
|
|
261
|
+
mine.unanswered = 0;
|
|
262
|
+
}
|
|
263
|
+
if (!waiting.length && !noteText && options.contexts.has(role) && options.contexts.get(role) >= options.shiftAt) {
|
|
241
264
|
const recent = Date.parse(mine.shift || "");
|
|
242
265
|
if (Number.isNaN(recent) || now - recent >= SHIFT_EVERY_MS) {
|
|
243
266
|
sent.push(sendNudge(where, role, "shift",
|
|
@@ -260,16 +283,16 @@ function nudgeRoles(where, patroller, options) {
|
|
|
260
283
|
}
|
|
261
284
|
state[role] = mine;
|
|
262
285
|
}
|
|
263
|
-
|
|
264
|
-
return sent;
|
|
286
|
+
store.writeJsonAtomic(where, stateFile, state);
|
|
287
|
+
return { sent, escalations };
|
|
265
288
|
}
|
|
266
289
|
|
|
267
|
-
function
|
|
290
|
+
function notifyRisks(where, role, risks) {
|
|
268
291
|
const group = store.directName(NOTIFY_SENDER, role);
|
|
269
292
|
if (!store.groupState(store.readLog(where, group)).exists) {
|
|
270
293
|
store.createGroup(where, NOTIFY_SENDER, group, [role], { direct: true });
|
|
271
294
|
}
|
|
272
|
-
const text = [`Patrol ${store.isoLocal(new Date())}:
|
|
295
|
+
const text = [`Patrol ${store.isoLocal(new Date())}: risks for the coordinator:`, ...risks.map((line) => `- risk: ${line}`)].join("\n");
|
|
273
296
|
return store.writeRecord(where, { group, kind: "message", from: NOTIFY_SENDER, refs: [NOTIFY_SENDER], text });
|
|
274
297
|
}
|
|
275
298
|
|
|
@@ -280,6 +303,7 @@ function render(result) {
|
|
|
280
303
|
else if (!result.notices.length && !result.held.length && !changes.length) lines.push("keel patrol: nothing new.");
|
|
281
304
|
for (const change of changes) lines.push(`changed: ${change}`);
|
|
282
305
|
for (const sent of result.nudges || []) lines.push(`nudged ${sent.role}: ${sent.kind}`);
|
|
306
|
+
for (const risk of result.risks || []) lines.push(`risk: ${risk}`);
|
|
283
307
|
for (const held of result.held) lines.push(`met: ${held.from} waited for ${held.condition} (${held.id})`);
|
|
284
308
|
for (const sent of result.notices) lines.push(`notified ${sent.to}: ${sent.text}`);
|
|
285
309
|
for (const wait of result.unchecked) lines.push(`unchecked: ${wait.from} waits for ${wait.condition}; pass --issues to check it`);
|
|
@@ -381,7 +405,7 @@ function runPatrol(argv) {
|
|
|
381
405
|
throw error;
|
|
382
406
|
}
|
|
383
407
|
}
|
|
384
|
-
const options = { repo: process.cwd(), issues: null, idle: "30m", json: false, sinceLast: false, notify: false, nudge: false, context: [], shiftAt: 50 };
|
|
408
|
+
const options = { repo: process.cwd(), issues: null, idle: "30m", json: false, sinceLast: false, notify: false, nudge: false, context: [], shiftAt: 50, diskFreeGb: null, diskMinGb: 20 };
|
|
385
409
|
try {
|
|
386
410
|
for (let index = 0; index < argv.length; index += 1) {
|
|
387
411
|
const arg = argv[index];
|
|
@@ -391,6 +415,8 @@ function runPatrol(argv) {
|
|
|
391
415
|
else if (arg === "--nudge") options.nudge = true;
|
|
392
416
|
else if (arg === "--context") options.context.push(argv[++index] || "");
|
|
393
417
|
else if (arg === "--shift-at") options.shiftAt = Number(argv[++index]);
|
|
418
|
+
else if (arg === "--disk-free-gb") options.diskFreeGb = Number(argv[++index]);
|
|
419
|
+
else if (arg === "--disk-min-gb") options.diskMinGb = Number(argv[++index]);
|
|
394
420
|
else if (arg === "--help" || arg === "-h") {
|
|
395
421
|
process.stdout.write(`${USAGE}\nExit 0: wrote nothing. 2: sent a notice or marked a wait met. 1: error.\n`);
|
|
396
422
|
return EXIT_QUIET;
|
|
@@ -400,22 +426,33 @@ function runPatrol(argv) {
|
|
|
400
426
|
options[arg.slice(2)] = value;
|
|
401
427
|
} else throw new PatrolError(`Unknown argument ${arg}. ${USAGE}`);
|
|
402
428
|
}
|
|
403
|
-
if (options.notify && !options.sinceLast) throw new PatrolError("--notify sends
|
|
429
|
+
if (options.notify && !options.sinceLast) throw new PatrolError("--notify sends the risks found since the last run, so it needs --since-last.");
|
|
404
430
|
if (!(options.shiftAt > 0 && options.shiftAt <= 100)) throw new PatrolError("--shift-at needs a percentage from 1 to 100.");
|
|
405
431
|
options.contexts = parseContexts(options.context);
|
|
432
|
+
if (options.diskFreeGb !== null && !(options.diskFreeGb >= 0)) throw new PatrolError("--disk-free-gb needs a number of gigabytes.");
|
|
433
|
+
if (!(options.diskMinGb > 0)) throw new PatrolError("--disk-min-gb needs a positive number of gigabytes.");
|
|
406
434
|
if (parseSince(options.idle) === null) throw new PatrolError(`--idle ${JSON.stringify(options.idle)} is not a duration; use 90s, 15m, 2h, or 3d.`);
|
|
407
435
|
options.issues = readIssues(options.issues);
|
|
408
436
|
const where = store.requireLocation(path.resolve(options.repo));
|
|
409
437
|
const role = store.requireRole(where);
|
|
410
438
|
const result = patrol(where, role, options);
|
|
411
|
-
|
|
439
|
+
result.risks = [];
|
|
440
|
+
if (options.nudge) {
|
|
441
|
+
const nudged = nudgeRoles(where, role, options);
|
|
442
|
+
result.nudges = nudged.sent;
|
|
443
|
+
result.risks.push(...nudged.escalations);
|
|
444
|
+
}
|
|
412
445
|
if (options.sinceLast) {
|
|
413
446
|
result.sinceLast = sinceLast(where, role, result, options);
|
|
414
|
-
|
|
447
|
+
result.risks.unshift(...result.sinceLast.risks);
|
|
448
|
+
// Only risks reach the coordinator (#307 part 3 D3).
|
|
449
|
+
if (options.notify && result.risks.length) result.notified = notifyRisks(where, role, result.risks).id;
|
|
415
450
|
}
|
|
416
451
|
process.stdout.write(`${options.json ? JSON.stringify(result, null, 2) : render(result)}\n`);
|
|
417
452
|
const changed = result.sinceLast && result.sinceLast.changes.length;
|
|
418
|
-
|
|
453
|
+
const code = result.notices.length || result.held.length || changed || (result.nudges || []).length || result.risks.length ? EXIT_WROTE : EXIT_QUIET;
|
|
454
|
+
appendRunLog(where, role, code, result);
|
|
455
|
+
return code;
|
|
419
456
|
} catch (error) {
|
|
420
457
|
if (error instanceof PatrolError || error instanceof store.ChatError) {
|
|
421
458
|
process.stderr.write(`keel patrol: ${error.message}\n`);
|
|
@@ -425,4 +462,17 @@ function runPatrol(argv) {
|
|
|
425
462
|
}
|
|
426
463
|
}
|
|
427
464
|
|
|
465
|
+
// One line per run, so a silent run can be audited (#307 part 3 D4).
|
|
466
|
+
function appendRunLog(where, role, code, result) {
|
|
467
|
+
try {
|
|
468
|
+
const file = path.join(where.root, "patrol", "log", `${role}.log`);
|
|
469
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
470
|
+
const changes = result.sinceLast ? result.sinceLast.changes.length : 0;
|
|
471
|
+
fs.appendFileSync(file, `${store.isoLocal(new Date())} exit=${code} changes=${changes} nudges=${(result.nudges || []).length} `
|
|
472
|
+
+ `risks=${result.risks.length} notified=${result.notified ? "yes" : "no"}\n`);
|
|
473
|
+
} catch {
|
|
474
|
+
// The log is for audit; failing to write it never fails the patrol.
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
|
|
428
478
|
module.exports = { PatrolError, runPatrol, patrol };
|