greprag 5.43.0 → 5.43.2
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/dist/commands/inbox-watch-supervisor.d.ts +0 -9
- package/dist/commands/inbox-watch-supervisor.js +23 -105
- package/dist/commands/inbox-watch-supervisor.js.map +1 -1
- package/dist/commands/watcher-registry.d.ts +93 -93
- package/dist/commands/watcher-registry.js +259 -296
- package/dist/commands/watcher-registry.js.map +1 -1
- package/dist/guard.js +16 -3
- package/dist/guard.js.map +1 -1
- package/dist/hook.js +18 -11
- package/dist/hook.js.map +1 -1
- package/dist/session-id.d.ts +18 -10
- package/dist/session-id.js +24 -22
- package/dist/session-id.js.map +1 -1
- package/package.json +1 -1
|
@@ -35,15 +35,6 @@ export declare const FATAL_EXIT_CODE = 64;
|
|
|
35
35
|
* so it respawns; SIGINT/SIGTERM skip these and return via the
|
|
36
36
|
* normal abort path. */
|
|
37
37
|
export declare function installLastResortHandlers(): void;
|
|
38
|
-
/** Resolve once `file`'s mtime has been UNCHANGED for `quietMs` (the build is
|
|
39
|
-
* done writing), or after `maxWaitMs` regardless (never wedge the supervisor
|
|
40
|
-
* on a watch loop). A stat failure (file mid-rename) counts as "still
|
|
41
|
-
* changing". Exported for tests. */
|
|
42
|
-
export declare function waitForStableMtime(file: string, opts?: {
|
|
43
|
-
pollMs?: number;
|
|
44
|
-
quietMs?: number;
|
|
45
|
-
maxWaitMs?: number;
|
|
46
|
-
}): Promise<void>;
|
|
47
38
|
/** Parent supervisor. Spawns the watch loop as a Node child, forwards
|
|
48
39
|
* stdio so Monitor sees each printed line as a notification verbatim,
|
|
49
40
|
* and respawns on any non-clean exit. */
|
|
@@ -26,46 +26,11 @@
|
|
|
26
26
|
* module-eval time), so it is safe.
|
|
27
27
|
*
|
|
28
28
|
* adr: adr/monitor-resilience.md */
|
|
29
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
30
|
-
if (k2 === undefined) k2 = k;
|
|
31
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
32
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
33
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
34
|
-
}
|
|
35
|
-
Object.defineProperty(o, k2, desc);
|
|
36
|
-
}) : (function(o, m, k, k2) {
|
|
37
|
-
if (k2 === undefined) k2 = k;
|
|
38
|
-
o[k2] = m[k];
|
|
39
|
-
}));
|
|
40
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
41
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
42
|
-
}) : function(o, v) {
|
|
43
|
-
o["default"] = v;
|
|
44
|
-
});
|
|
45
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
46
|
-
var ownKeys = function(o) {
|
|
47
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
48
|
-
var ar = [];
|
|
49
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
50
|
-
return ar;
|
|
51
|
-
};
|
|
52
|
-
return ownKeys(o);
|
|
53
|
-
};
|
|
54
|
-
return function (mod) {
|
|
55
|
-
if (mod && mod.__esModule) return mod;
|
|
56
|
-
var result = {};
|
|
57
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
58
|
-
__setModuleDefault(result, mod);
|
|
59
|
-
return result;
|
|
60
|
-
};
|
|
61
|
-
})();
|
|
62
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
63
30
|
exports.FATAL_EXIT_CODE = exports.SUPERVISE_ENV = void 0;
|
|
64
31
|
exports.installLastResortHandlers = installLastResortHandlers;
|
|
65
|
-
exports.waitForStableMtime = waitForStableMtime;
|
|
66
32
|
exports.runSupervisor = runSupervisor;
|
|
67
|
-
const
|
|
68
|
-
const proc_1 = require("../proc");
|
|
33
|
+
const child_process_1 = require("child_process");
|
|
69
34
|
const inbox_watch_1 = require("./inbox-watch");
|
|
70
35
|
const watcher_registry_1 = require("./watcher-registry");
|
|
71
36
|
const LOG_PREFIX = '[greprag inbox watch]';
|
|
@@ -102,21 +67,6 @@ const SUPERVISOR_BACKOFF_FACTOR = 2;
|
|
|
102
67
|
// 60s of uninterrupted child life resets the backoff so a long-lived
|
|
103
68
|
// child that finally dies retries fast, not slowly.
|
|
104
69
|
const SUPERVISOR_HEALTHY_RESET_MS = 60_000;
|
|
105
|
-
// The --monitor-pid monitor-task liveness probe (ff681bb, 2026-06-10) was
|
|
106
|
-
// reverted 2026-06-11: /proc/$$/winpid stamped the transient arm-line bash, not
|
|
107
|
-
// the persistent Monitor task, so the probe false-killed live watchers
|
|
108
|
-
// (terminal stop, no respawn) → "constantly dying". The pipe binding
|
|
109
|
-
// (bindToConsumer) + --owner-pid reaper remain the supervision layers.
|
|
110
|
-
// adr: adr/monitor-resilience.md
|
|
111
|
-
// Rebuild settle (2026-06-10): `npm run build` swaps dist/ under every running
|
|
112
|
-
// watcher; the child crashes (a lazy `require` loads a half-written module) and
|
|
113
|
-
// an immediate respawn loads a partially-emitted entry file → a crash-loop wave
|
|
114
|
-
// per rebuild, fleet-wide. When the entry script's mtime has changed since the
|
|
115
|
-
// child was spawned, wait for the build to go quiet before respawning, and
|
|
116
|
-
// reset the backoff — a rebuild is a restart condition, not a crash storm.
|
|
117
|
-
const REBUILD_SETTLE_POLL_MS = 500;
|
|
118
|
-
const REBUILD_SETTLE_QUIET_MS = 1_500;
|
|
119
|
-
const REBUILD_SETTLE_MAX_WAIT_MS = 30_000;
|
|
120
70
|
// Exit code the child uses for "fatal, do not respawn" conditions —
|
|
121
71
|
// 4xx HTTP responses, missing API key, missing anchor. Anything else
|
|
122
72
|
// (signal, code 1, code 2, exception) is a crash and gets respawned.
|
|
@@ -166,39 +116,6 @@ function ownerPidFromArgv(argv) {
|
|
|
166
116
|
}
|
|
167
117
|
return undefined;
|
|
168
118
|
}
|
|
169
|
-
/** Entry-script mtime, or null when unstatable (deleted mid-rebuild, exotic
|
|
170
|
-
* launcher). Null disables the rebuild-settle branch — fail-open. */
|
|
171
|
-
function entryMtimeMs(entry) {
|
|
172
|
-
try {
|
|
173
|
-
return fs.statSync(entry).mtimeMs;
|
|
174
|
-
}
|
|
175
|
-
catch {
|
|
176
|
-
return null;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
/** Resolve once `file`'s mtime has been UNCHANGED for `quietMs` (the build is
|
|
180
|
-
* done writing), or after `maxWaitMs` regardless (never wedge the supervisor
|
|
181
|
-
* on a watch loop). A stat failure (file mid-rename) counts as "still
|
|
182
|
-
* changing". Exported for tests. */
|
|
183
|
-
async function waitForStableMtime(file, opts) {
|
|
184
|
-
const pollMs = opts?.pollMs ?? REBUILD_SETTLE_POLL_MS;
|
|
185
|
-
const quietMs = opts?.quietMs ?? REBUILD_SETTLE_QUIET_MS;
|
|
186
|
-
const maxWaitMs = opts?.maxWaitMs ?? REBUILD_SETTLE_MAX_WAIT_MS;
|
|
187
|
-
const deadline = Date.now() + maxWaitMs;
|
|
188
|
-
let last = null;
|
|
189
|
-
let stableSince = Date.now();
|
|
190
|
-
while (Date.now() < deadline) {
|
|
191
|
-
const m = entryMtimeMs(file);
|
|
192
|
-
if (m === null || m !== last) {
|
|
193
|
-
last = m;
|
|
194
|
-
stableSince = Date.now();
|
|
195
|
-
}
|
|
196
|
-
else if (Date.now() - stableSince >= quietMs) {
|
|
197
|
-
return;
|
|
198
|
-
}
|
|
199
|
-
await new Promise((r) => setTimeout(r, pollMs));
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
119
|
/** Fire one short, best-effort liveness request. Never throws; never blocks
|
|
203
120
|
* longer than `timeoutMs` (so a dead network can't hang the heartbeat or stall
|
|
204
121
|
* exit). adr: docs/registry-freshness-design.md */
|
|
@@ -249,6 +166,21 @@ async function runSupervisor() {
|
|
|
249
166
|
const onSigterm = () => forward('SIGTERM');
|
|
250
167
|
process.on('SIGINT', onSigint);
|
|
251
168
|
process.on('SIGTERM', onSigterm);
|
|
169
|
+
// Supervisor self-protection (2026-06-13). A stray throw in the supervisor's OWN
|
|
170
|
+
// code (the heartbeat, the spawn path, the exit promise) used to crash it
|
|
171
|
+
// uncaught — and Monitor `persistent:true` does NOT restart a dead command
|
|
172
|
+
// (verified live), so the watcher simply vanished until the next turn re-armed
|
|
173
|
+
// it. Exit NON-ZERO on any uncaught error so the bash relauncher
|
|
174
|
+
// (`armMonitorCommand`) relaunches a fresh supervisor — turn-free recovery, the
|
|
175
|
+
// missing rung for supervisor death. adr: adr/monitor-resilience.md
|
|
176
|
+
const onFatalError = (label) => (err) => {
|
|
177
|
+
console.error(`${LOG_PREFIX} supervisor ${label}: ${(err && err.message) || String(err)}`);
|
|
178
|
+
process.exit(1); // non-zero (not 0/64) → the relauncher relaunches us
|
|
179
|
+
};
|
|
180
|
+
const onUncaught = onFatalError('uncaughtException');
|
|
181
|
+
const onRejection = onFatalError('unhandledRejection');
|
|
182
|
+
process.on('uncaughtException', onUncaught);
|
|
183
|
+
process.on('unhandledRejection', onRejection);
|
|
252
184
|
// Re-invoke the same JS entrypoint via the Node binary we're running
|
|
253
185
|
// under. Skips the bash/sh npm shim on respawn — the shim's fork
|
|
254
186
|
// pressure is paid once at initial invocation, not once per restart.
|
|
@@ -294,16 +226,11 @@ async function runSupervisor() {
|
|
|
294
226
|
if (typeof heartbeat.unref === 'function')
|
|
295
227
|
heartbeat.unref();
|
|
296
228
|
}
|
|
297
|
-
// Entry-script mtime at the moment each child is (re)spawned — the rebuild
|
|
298
|
-
// detector's baseline. Null when unstatable (branch disabled, fail-open).
|
|
299
|
-
const entryScript = process.argv[1];
|
|
300
|
-
let spawnedMtime = null;
|
|
301
229
|
while (!shutdownRequested) {
|
|
302
230
|
const startedAt = Date.now();
|
|
303
|
-
spawnedMtime = entryMtimeMs(entryScript);
|
|
304
231
|
let spawnErr = null;
|
|
305
232
|
try {
|
|
306
|
-
currentChild = (0,
|
|
233
|
+
currentChild = (0, child_process_1.spawn)(process.execPath, childArgs, {
|
|
307
234
|
env: childEnv,
|
|
308
235
|
stdio: 'inherit',
|
|
309
236
|
// detached:false keeps the child in our process group so
|
|
@@ -355,7 +282,9 @@ async function runSupervisor() {
|
|
|
355
282
|
// missing anchor. Respawning would loop forever.
|
|
356
283
|
if (exit.err === null && exit.code === exports.FATAL_EXIT_CODE) {
|
|
357
284
|
terminalReason = 'fatal(no-respawn: bad key/4xx/anchor)';
|
|
358
|
-
|
|
285
|
+
// Exit 64 (FATAL_EXIT_CODE), not 1, so the bash relauncher BREAKS on a
|
|
286
|
+
// known-bad config instead of relaunching it forever. adr: adr/monitor-resilience.md
|
|
287
|
+
process.exitCode = exports.FATAL_EXIT_CODE;
|
|
359
288
|
break;
|
|
360
289
|
}
|
|
361
290
|
// Child signaled "my consumer is gone" — the Monitor task's stdout/stderr
|
|
@@ -368,19 +297,6 @@ async function runSupervisor() {
|
|
|
368
297
|
terminalReason = 'consumer-gone(pipe-broke)';
|
|
369
298
|
break;
|
|
370
299
|
}
|
|
371
|
-
// Rebuild settle: if dist/ was swapped under this child (its entry mtime
|
|
372
|
-
// changed since spawn), this death is a rebuild casualty, not a crash. Wait
|
|
373
|
-
// for the build to go quiet, reset the backoff, and respawn fresh — without
|
|
374
|
-
// this, the respawn loads a half-written entry file and the backoff
|
|
375
|
-
// escalates through a wave of bogus "crashes" on every `npm run build`.
|
|
376
|
-
const mtimeNow = entryMtimeMs(entryScript);
|
|
377
|
-
if (mtimeNow !== null && spawnedMtime !== null && mtimeNow !== spawnedMtime) {
|
|
378
|
-
console.error(`${LOG_PREFIX} supervisor: dist updated underneath (rebuild) — waiting for the build to settle, then restarting fresh`);
|
|
379
|
-
(0, watcher_registry_1.watcherAuditLog)(`rebuild-settle session=${session ?? 'tenant'} (entry mtime changed under live child — respawning after quiet period)`);
|
|
380
|
-
await waitForStableMtime(entryScript);
|
|
381
|
-
backoff = SUPERVISOR_BACKOFF_INITIAL_MS;
|
|
382
|
-
continue;
|
|
383
|
-
}
|
|
384
300
|
if (liveMs >= SUPERVISOR_HEALTHY_RESET_MS)
|
|
385
301
|
backoff = SUPERVISOR_BACKOFF_INITIAL_MS;
|
|
386
302
|
const reason = exit.err
|
|
@@ -400,12 +316,14 @@ async function runSupervisor() {
|
|
|
400
316
|
if (heartbeat)
|
|
401
317
|
clearInterval(heartbeat);
|
|
402
318
|
if (session)
|
|
403
|
-
(0, watcher_registry_1.
|
|
319
|
+
(0, watcher_registry_1.removeWatcherEntry)(session, process.pid);
|
|
404
320
|
if (leaseEnabled) {
|
|
405
321
|
await bestEffortFetch(deregisterUrl(cfg.apiUrl, session), cfg.apiKey, 'DELETE', GOODBYE_TIMEOUT_MS);
|
|
406
322
|
}
|
|
407
323
|
process.off('SIGINT', onSigint);
|
|
408
324
|
process.off('SIGTERM', onSigterm);
|
|
325
|
+
process.off('uncaughtException', onUncaught);
|
|
326
|
+
process.off('unhandledRejection', onRejection);
|
|
409
327
|
}
|
|
410
328
|
/** Sleep that polls a shutdown predicate every 100ms so the supervisor
|
|
411
329
|
* wakes promptly on signal-driven shutdown without needing a shared
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inbox-watch-supervisor.js","sourceRoot":"","sources":["../../src/commands/inbox-watch-supervisor.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;qCA0BqC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6ErC,8DAWC;AAqCD,gDAoBC;AAiCD,sCAoLC;AAnWD,uCAAyB;AACzB,kCAAoC;AACpC,+CAAgF;AAChF,yDAAgH;AAEhH,MAAM,UAAU,GAAG,uBAAuB,CAAC;AAE3C,6EAA6E;AAC7E,yCAAyC;AACzC,EAAE;AACF,gFAAgF;AAChF,+EAA+E;AAC/E,WAAW;AACX,4EAA4E;AAC5E,8EAA8E;AAC9E,iFAAiF;AACjF,o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
/** Local watcher process registry + COUNT-CAP (the post-saga model).
|
|
2
2
|
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* (consumer dead, process still respawning) as "armed". Two local signals fix
|
|
10
|
-
* that:
|
|
3
|
+
* THE LESSON (adr/monitor-resilience.md, "⭐ The watcher in one pass"): a
|
|
4
|
+
* functional watcher and an orphaned-but-alive one are EXTERNALLY
|
|
5
|
+
* INDISTINGUISHABLE — same command line, same live PID. Only the watcher itself
|
|
6
|
+
* can tell, via its own stdout pipe (EPIPE). So every external reaper that
|
|
7
|
+
* *judged* orphan-ness (ancestry, owner-pid, monitor-pid) was guessing, and the
|
|
8
|
+
* guesses false-killed live watchers — the 548-kill saga in one line.
|
|
11
9
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* to gate re-arming with zero cloud dependency and zero ghost-lease lag.
|
|
15
|
-
* Paired with EPIPE-terminal in the watcher (a watcher whose consumer pipe
|
|
16
|
-
* breaks exits and removes its own pidfile), a live pidfile means a live,
|
|
17
|
-
* *consumed* watcher.
|
|
10
|
+
* This module no longer judges. Two reliable facts replace the one unknowable
|
|
11
|
+
* one:
|
|
18
12
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* the kill set is intersected with "cmdline contains `inbox watch`", so it
|
|
26
|
-
* can only ever terminate greprag watchers — never claude.exe, an editor, or
|
|
27
|
-
* an unrelated node server.
|
|
13
|
+
* 1. **pidfile registry** — `~/.greprag/watchers/<short>.json` is a LIST of every
|
|
14
|
+
* supervisor armed for that session (`{short,pid,startedAt,ownerPid}`). A
|
|
15
|
+
* supervisor appends on arm and removes its own entry on terminal exit; a
|
|
16
|
+
* hard kill leaves a dead entry that the alive-filter sweeps. `isLocallyArmed`
|
|
17
|
+
* = "any entry alive". (Multiple live supervisors per session is normal under
|
|
18
|
+
* the June-8 spray; the count-cap bounds them.)
|
|
28
19
|
*
|
|
29
|
-
*
|
|
20
|
+
* 2. **count-cap** — `reapOrphanWatchers` keeps the K freshest LIVE watchers per
|
|
21
|
+
* session and kills only the surplus, NEVER below K. No death-detection → no
|
|
22
|
+
* false-kill; a floor of K → it can never reap to zero, so the bug that broke
|
|
23
|
+
* liveness every time is structurally impossible. "Freshest" is a *bias*
|
|
24
|
+
* toward the just-armed functional one, not a guarantee — and that's fine:
|
|
25
|
+
* EPIPE kills a wrongly-kept orphan in ~30s and the supervisor respawns. It is
|
|
26
|
+
* **snapshot-free** (per-session file reads + `pidAlive()` syscalls), so the
|
|
27
|
+
* 06-05b conhost-OOM engine — a `powershell Get-CimInstance` per SessionStart —
|
|
28
|
+
* is gone from the cleanup path entirely.
|
|
29
|
+
*
|
|
30
|
+
* EPIPE-terminal (in the watcher) + the supervisor's programmatic respawn do the
|
|
31
|
+
* real liveness work; the count-cap only bounds the pile. adr: adr/monitor-resilience.md */
|
|
32
|
+
/** Default per-session watcher floor: keep this many freshest live watchers, reap
|
|
33
|
+
* only the surplus above it, never below it. K=2 = the live one + one margin. */
|
|
34
|
+
export declare const DEFAULT_WATCHER_CAP = 2;
|
|
30
35
|
export interface WatcherPidRecord {
|
|
31
36
|
short: string;
|
|
32
37
|
pid: number;
|
|
33
38
|
startedAt: number;
|
|
34
39
|
ownerPid?: number;
|
|
35
40
|
}
|
|
36
|
-
/**
|
|
37
|
-
*
|
|
38
|
-
* without enumerating the process table. Best-effort: a failed write only means
|
|
39
|
-
* `isLocallyArmed` falls back to re-arming, never a crash. */
|
|
41
|
+
/** APPEND this supervisor's entry to the session's list (pruning dead entries as
|
|
42
|
+
* it goes). Best-effort. adr: adr/monitor-resilience.md */
|
|
40
43
|
export declare function writeWatcherPidfile(short: string, pid: number, ownerPid?: number): void;
|
|
44
|
+
/** Remove THIS supervisor's entry (called on a supervisor's terminal exit). */
|
|
45
|
+
export declare function removeWatcherEntry(short: string, pid: number): void;
|
|
46
|
+
/** Remove a session's whole pidfile (legacy / full sweep). */
|
|
41
47
|
export declare function removeWatcherPidfile(short: string): void;
|
|
42
|
-
/**
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
|
|
48
|
+
/** The session→owner record at `~/.greprag/watchers/<short>.owner`: the CURRENT
|
|
49
|
+
* claude.exe PID for a session, refreshed on every SessionStart (so a restart
|
|
50
|
+
* re-resolves it within seconds), plus a `deadSince` stamp the GC uses to reap an
|
|
51
|
+
* owner only after it has stayed dead past the grace window — NOT a frozen
|
|
52
|
+
* arm-time PID, which was the owner-pid reaper's fatal flaw. adr: adr/monitor-resilience.md */
|
|
53
|
+
export interface SessionOwner {
|
|
54
|
+
pid: number;
|
|
55
|
+
ts: number;
|
|
56
|
+
deadSince?: number;
|
|
57
|
+
}
|
|
58
|
+
/** Append-only diagnostic audit log at ~/.greprag/watchers/audit.log. ALWAYS ON so
|
|
59
|
+
* every arm / terminal exit / cap-kill leaves a trail. Behaviour-neutral: pure
|
|
60
|
+
* observation, never gates a kill or an arm. adr: adr/monitor-resilience.md */
|
|
48
61
|
export declare function watcherAuditLog(event: string): void;
|
|
49
|
-
/** Local-first arm check:
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
* dead, socket still open) as armed and so both (a) suppresses re-arm when the
|
|
54
|
-
* real watcher is gone and (b) lets re-arm stack new watchers on undead
|
|
55
|
-
* orphans. A dead-PID pidfile is swept here so the next turn re-arms. */
|
|
62
|
+
/** Local-first arm check: does this session have ANY live watcher process on THIS
|
|
63
|
+
* machine? Ground truth for "armed" — the consumer (the Monitor task) is local,
|
|
64
|
+
* so a live local entry means a live, consumed watcher. Sweeps dead entries as it
|
|
65
|
+
* reads, so a hard-killed watcher doesn't read as armed. */
|
|
56
66
|
export declare function isLocallyArmed(short: string): boolean;
|
|
57
|
-
/**
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
* is computed on demand from ground truth, never a cached/replicated list, so it
|
|
62
|
-
* cannot go stale the way the cloud `/attached` registry does. adr:
|
|
63
|
-
* adr/monitor-resilience.md */
|
|
67
|
+
/** Every session whose watcher process is alive on THIS machine right now —
|
|
68
|
+
* computed on demand from the pidfile registry + OS liveness, sweeping dead
|
|
69
|
+
* entries. Most-recently-armed first. This is what the desk-line returns when the
|
|
70
|
+
* cloud asks "what's truly active?". adr: adr/monitor-resilience.md */
|
|
64
71
|
export declare function listLocalLiveWatchers(): WatcherPidRecord[];
|
|
65
72
|
export interface ProcRow {
|
|
66
73
|
pid: number;
|
|
@@ -68,54 +75,47 @@ export interface ProcRow {
|
|
|
68
75
|
name: string;
|
|
69
76
|
cmd: string;
|
|
70
77
|
}
|
|
71
|
-
/** Resolve the owning claude.exe PID for the CURRENT process by walking its
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
* 2026-06-05: a supervisor's ancestry to claude.exe is already severed at arm
|
|
76
|
-
* time). The hook stamps the result into the watch command (`--owner-pid`) so
|
|
77
|
-
* the reaper can later ask "is that exact claude.exe still alive?" instead of
|
|
78
|
-
* re-walking a chain that no longer exists. Returns null if no claude.exe
|
|
79
|
-
* ancestor is found (caller omits the flag → the watcher is flagless → the reaper
|
|
80
|
-
* KEEPS it, since the ancestry fallback that used to reap it was a false-kill).
|
|
81
|
-
* adr: adr/monitor-resilience.md */
|
|
78
|
+
/** Resolve the owning claude.exe PID for the CURRENT process by walking its parent
|
|
79
|
+
* chain. MUST be called from a hook (a live descendant of claude.exe). Stamped
|
|
80
|
+
* into the arm command (`--owner-pid`) for audit continuity. Cache hit skips the
|
|
81
|
+
* snapshot. Returns null if no claude.exe ancestor. adr: adr/monitor-resilience.md */
|
|
82
82
|
export declare function resolveClaudeOwnerPid(cacheShort?: string): number | null;
|
|
83
|
-
/**
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
* (adr 2026-06-05a) — a Monitor-armed watcher's launcher shell exits by design,
|
|
91
|
-
* so within seconds of a healthy arm its chain to claude.exe is already severed,
|
|
92
|
-
* indistinguishable from a real orphan. It was the dominant false-kill on
|
|
93
|
-
* flagless watchers, and flagless is not rare: the bare arm form is taught by the
|
|
94
|
-
* skill docs AND emitted by the hook itself whenever resolveClaudeOwnerPid
|
|
95
|
-
* returns null on a snapshot miss (so `--owner-pid` cannot be guaranteed at the
|
|
96
|
-
* arm site). The only safe verdict for a flagless watcher is therefore KEEP.
|
|
97
|
-
* Genuine death of a flagless watcher is still caught at the right layer: its
|
|
98
|
-
* consumer pipe breaks on session reload/end → EPIPE-terminal (consumer-gone)
|
|
99
|
-
* tears it down, and `sweepDeadPidfiles` collects a dead-PID pidfile. The
|
|
100
|
-
* residual — a flagless watcher orphaned by a TaskStop while claude.exe stays
|
|
101
|
-
* alive (no pipe break, no owner to die) — is one idle process, the exact blind
|
|
102
|
-
* spot the 2026-06-11 revert already knowingly left open. This also retires the
|
|
103
|
-
* GREPRAG_REAP_BY_OWNER escape hatch, whose only effect was to re-enable the
|
|
104
|
-
* proven-bad pure-ancestry walk. adr: adr/monitor-resilience.md */
|
|
105
|
-
export declare function severedVerdict(w: ProcRow, byPid: Map<number, ProcRow>): {
|
|
106
|
-
severed: boolean;
|
|
107
|
-
reason: string;
|
|
83
|
+
/** Pure verdict (testable): given a session's LIVE entries, keep the K freshest
|
|
84
|
+
* (by startedAt), return the older surplus to kill. Never kills when count ≤ K;
|
|
85
|
+
* never kills more than count − K; never the K freshest. This is the entire
|
|
86
|
+
* liveness-safety guarantee — no death judgment, just a count + a floor. */
|
|
87
|
+
export declare function capSurplusVerdict(entries: WatcherPidRecord[], K: number): {
|
|
88
|
+
keep: WatcherPidRecord[];
|
|
89
|
+
kill: WatcherPidRecord[];
|
|
108
90
|
};
|
|
109
91
|
export interface ReapResult {
|
|
110
92
|
scanned: number;
|
|
111
93
|
orphans: number;
|
|
112
94
|
killed: number[];
|
|
113
95
|
}
|
|
114
|
-
/**
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
|
|
121
|
-
|
|
96
|
+
/** Count-cap every session: keep the K freshest LIVE watchers, kill only the
|
|
97
|
+
* surplus. NO death-detection, NO process snapshot — per-session file reads +
|
|
98
|
+
* `pidAlive()`, and a `taskkill` only when there is genuine surplus. Run at
|
|
99
|
+
* SessionStart (via the recap hook) and exposed as `greprag inbox reap`. The name
|
|
100
|
+
* is retained for its callers; the behaviour is "cap", not "judge orphans".
|
|
101
|
+
* adr: adr/monitor-resilience.md */
|
|
102
|
+
export declare function reapOrphanWatchers(K?: number): ReapResult;
|
|
103
|
+
/** Minutes a session's owner must stay CONTINUOUSLY dead before its watchers are
|
|
104
|
+
* GC'd. Must exceed the worst-case claude.exe restart→SessionStart window (which
|
|
105
|
+
* is seconds), so a restart can never be mistaken for a death. */
|
|
106
|
+
export declare const GC_GRACE_MS: number;
|
|
107
|
+
/** Pure GC decision (testable): given a session's owner record and whether its PID
|
|
108
|
+
* is alive right now, decide keep / start-the-grace-clock / reap. */
|
|
109
|
+
export declare function gcVerdict(owner: {
|
|
110
|
+
ts: number;
|
|
111
|
+
deadSince?: number;
|
|
112
|
+
} | null, ownerAlive: boolean, now: number, graceMs: number): 'keep' | 'mark-dead' | 'reap';
|
|
113
|
+
export interface GcResult {
|
|
114
|
+
reaped: string[];
|
|
115
|
+
killed: number[];
|
|
116
|
+
}
|
|
117
|
+
/** Reap every watcher of a session whose owning claude.exe has stayed dead past the
|
|
118
|
+
* grace window. Run at SessionStart, AFTER refreshing THIS session's own owner
|
|
119
|
+
* (so it is never its own victim). No process snapshot — owner-file reads +
|
|
120
|
+
* pidAlive() syscalls. adr: adr/monitor-resilience.md */
|
|
121
|
+
export declare function gcDeadSessions(graceMs?: number): GcResult;
|