@sentropic/h2a-runtime 0.90.1 → 0.90.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/index.d.ts +16 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +131 -20
- package/dist/index.js.map +1 -1
- package/dist/proc-cpu.d.ts +44 -0
- package/dist/proc-cpu.d.ts.map +1 -1
- package/dist/proc-cpu.js +84 -2
- package/dist/proc-cpu.js.map +1 -1
- package/dist/relaunch.d.ts +32 -1
- package/dist/relaunch.d.ts.map +1 -1
- package/dist/relaunch.js +93 -0
- package/dist/relaunch.js.map +1 -1
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +0 -3
- package/dist/run.js.map +1 -1
- package/dist/session-lease.d.ts +83 -4
- package/dist/session-lease.d.ts.map +1 -1
- package/dist/session-lease.js +197 -6
- package/dist/session-lease.js.map +1 -1
- package/dist/tmux.d.ts +45 -0
- package/dist/tmux.d.ts.map +1 -1
- package/dist/tmux.js +111 -1
- package/dist/tmux.js.map +1 -1
- package/package.json +2 -3
package/dist/proc-cpu.d.ts
CHANGED
|
@@ -16,6 +16,27 @@ export type ProcEntry = {
|
|
|
16
16
|
readonly pid: number;
|
|
17
17
|
readonly ppid: number;
|
|
18
18
|
readonly cpuMs: number;
|
|
19
|
+
/** /proc stat field 22: ticks since boot, preserved as a string. */
|
|
20
|
+
readonly startTime: string;
|
|
21
|
+
};
|
|
22
|
+
export type WorkerAttribution = {
|
|
23
|
+
readonly pid: number;
|
|
24
|
+
readonly startTime: string;
|
|
25
|
+
readonly bootId: string;
|
|
26
|
+
};
|
|
27
|
+
export type ProcIdentity = {
|
|
28
|
+
readonly pid: number;
|
|
29
|
+
readonly startTime: string;
|
|
30
|
+
};
|
|
31
|
+
/** One fleet-wide /proc view, suitable for pure lease projections. */
|
|
32
|
+
export type ProcView = {
|
|
33
|
+
readonly currentBootId: string;
|
|
34
|
+
readonly processes: ReadonlyMap<number, {
|
|
35
|
+
readonly startTime: string;
|
|
36
|
+
}> | ReadonlyArray<ProcIdentity>;
|
|
37
|
+
/** The parsed snapshot is retained so a pane worker can be resolved without
|
|
38
|
+
* another /proc walk during a supervising pass. */
|
|
39
|
+
readonly entries?: ReadonlyArray<ProcEntry>;
|
|
19
40
|
};
|
|
20
41
|
/**
|
|
21
42
|
* Parse one /proc/<pid>/stat line. `comm` may contain spaces and parentheses,
|
|
@@ -25,6 +46,7 @@ export type ProcEntry = {
|
|
|
25
46
|
export declare function parseProcStat(content: string, clockTicksPerSecond?: number): {
|
|
26
47
|
readonly ppid: number;
|
|
27
48
|
readonly cpuMs: number;
|
|
49
|
+
readonly startTime: string;
|
|
28
50
|
} | undefined;
|
|
29
51
|
/**
|
|
30
52
|
* Total CPU of `rootPid` plus every live descendant. Returns undefined when the
|
|
@@ -44,10 +66,32 @@ export declare function busiestDescendant(rootPid: number, entries: Iterable<Pro
|
|
|
44
66
|
export type ProcReaderDeps = {
|
|
45
67
|
readonly listPids: () => ReadonlyArray<number>;
|
|
46
68
|
readonly readStat: (pid: number) => string | undefined;
|
|
69
|
+
/** Optional injection point for tests; the default reads kernel boot_id. */
|
|
70
|
+
readonly readBootId?: () => string | undefined;
|
|
47
71
|
readonly clockTicksPerSecond?: number;
|
|
48
72
|
};
|
|
49
73
|
/** Snapshot /proc once, parsed into entries. */
|
|
50
74
|
export declare function snapshotProc(deps: ProcReaderDeps): ProcEntry[];
|
|
75
|
+
/** Snapshot /proc once and retain both CPU/process-tree and identity facts. */
|
|
76
|
+
export declare function snapshotProcView(deps: ProcReaderDeps): {
|
|
77
|
+
readonly entries: ProcEntry[];
|
|
78
|
+
readonly view: ProcView;
|
|
79
|
+
};
|
|
80
|
+
/** Snapshot /proc once for the liveness predicate. */
|
|
81
|
+
export declare function readProcView(deps: ProcReaderDeps): ProcView;
|
|
82
|
+
/** Resolve a worker from an already captured snapshot; performs no syscalls. */
|
|
83
|
+
export declare function resolveWorkerAttributionFromView(rootPid: number, view: ProcView): WorkerAttribution | undefined;
|
|
84
|
+
/** Resolve the worker once from a pane pid, including its composite identity. */
|
|
85
|
+
export declare function readWorkerAttribution(rootPid: number, deps: ProcReaderDeps): WorkerAttribution | undefined;
|
|
86
|
+
/** Descriptive alias for callers that prefer resolver terminology. */
|
|
87
|
+
export declare const resolveWorkerAttribution: typeof readWorkerAttribution;
|
|
88
|
+
export type ProcessObservation = {
|
|
89
|
+
readonly cpuMs: number | undefined;
|
|
90
|
+
readonly worker: WorkerAttribution | undefined;
|
|
91
|
+
readonly procView: ProcView;
|
|
92
|
+
};
|
|
93
|
+
/** CPU + worker observation sharing exactly one /proc snapshot. */
|
|
94
|
+
export declare function readProcessObservation(rootPid: number, deps: ProcReaderDeps): ProcessObservation;
|
|
51
95
|
/** Snapshot /proc and total the tree rooted at `rootPid`. */
|
|
52
96
|
export declare function readProcessTreeCpuMs(rootPid: number, deps: ProcReaderDeps): number | undefined;
|
|
53
97
|
/** Snapshot /proc and name the process actually doing the work. */
|
package/dist/proc-cpu.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proc-cpu.d.ts","sourceRoot":"","sources":["../src/proc-cpu.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;
|
|
1
|
+
{"version":3,"file":"proc-cpu.d.ts","sourceRoot":"","sources":["../src/proc-cpu.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,eAAO,MAAM,8BAA8B,MAAM,CAAC;AAElD,MAAM,MAAM,SAAS,GAAG;IACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,oEAAoE;IACpE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,CAAC,GAAG,EAAE,MAAM,CA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S,CAEpB;AAED,mEAAmE;AACnE,wBAAgB,aAAa,CAC3B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,cAAc,GACnB,MAAM,GAAG,SAAS,CAEpB"}
|
package/dist/proc-cpu.js
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
* finished child's time is not reclaimed here). Callers compare deltas well
|
|
12
12
|
* above that noise, so the approximation never decides anything on its own.
|
|
13
13
|
*/
|
|
14
|
+
import { readFileSync } from "node:fs";
|
|
14
15
|
export const DEFAULT_CLOCK_TICKS_PER_SECOND = 100;
|
|
15
16
|
/**
|
|
16
17
|
* Parse one /proc/<pid>/stat line. `comm` may contain spaces and parentheses,
|
|
@@ -26,12 +27,18 @@ export function parseProcStat(content, clockTicksPerSecond = DEFAULT_CLOCK_TICKS
|
|
|
26
27
|
const ppid = Number.parseInt(fields[1] ?? "", 10);
|
|
27
28
|
const utime = Number.parseInt(fields[11] ?? "", 10);
|
|
28
29
|
const stime = Number.parseInt(fields[12] ?? "", 10);
|
|
29
|
-
|
|
30
|
+
const startTime = fields[19];
|
|
31
|
+
if (!Number.isInteger(ppid) ||
|
|
32
|
+
!Number.isInteger(utime) ||
|
|
33
|
+
!Number.isInteger(stime) ||
|
|
34
|
+
startTime === undefined ||
|
|
35
|
+
!/^\d+$/.test(startTime)) {
|
|
30
36
|
return undefined;
|
|
31
37
|
}
|
|
32
38
|
return {
|
|
33
39
|
ppid,
|
|
34
40
|
cpuMs: ((utime + stime) / clockTicksPerSecond) * 1000,
|
|
41
|
+
startTime,
|
|
35
42
|
};
|
|
36
43
|
}
|
|
37
44
|
/**
|
|
@@ -118,10 +125,85 @@ export function snapshotProc(deps) {
|
|
|
118
125
|
const parsed = parseProcStat(raw, deps.clockTicksPerSecond);
|
|
119
126
|
if (!parsed)
|
|
120
127
|
continue;
|
|
121
|
-
entries.push({
|
|
128
|
+
entries.push({
|
|
129
|
+
pid,
|
|
130
|
+
ppid: parsed.ppid,
|
|
131
|
+
cpuMs: parsed.cpuMs,
|
|
132
|
+
startTime: parsed.startTime,
|
|
133
|
+
});
|
|
122
134
|
}
|
|
123
135
|
return entries;
|
|
124
136
|
}
|
|
137
|
+
const DEFAULT_BOOT_ID_READER = () => {
|
|
138
|
+
try {
|
|
139
|
+
return readFileSync("/proc/sys/kernel/random/boot_id", "utf8").trim() || undefined;
|
|
140
|
+
}
|
|
141
|
+
catch {
|
|
142
|
+
return undefined;
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
// A reader function is stable for the lifetime of a process. WeakMap keeps
|
|
146
|
+
// injected readers isolated in tests while preserving the production contract:
|
|
147
|
+
// boot_id is read once per process, regardless of how many lease passes run.
|
|
148
|
+
const bootIdCache = new WeakMap();
|
|
149
|
+
function cachedBootId(reader) {
|
|
150
|
+
if (bootIdCache.has(reader))
|
|
151
|
+
return bootIdCache.get(reader);
|
|
152
|
+
const value = reader();
|
|
153
|
+
bootIdCache.set(reader, value);
|
|
154
|
+
return value;
|
|
155
|
+
}
|
|
156
|
+
function bootIdReader(deps) {
|
|
157
|
+
return deps.readBootId ?? DEFAULT_BOOT_ID_READER;
|
|
158
|
+
}
|
|
159
|
+
/** Snapshot /proc once and retain both CPU/process-tree and identity facts. */
|
|
160
|
+
export function snapshotProcView(deps) {
|
|
161
|
+
const entries = snapshotProc(deps);
|
|
162
|
+
const processes = new Map();
|
|
163
|
+
for (const entry of entries)
|
|
164
|
+
processes.set(entry.pid, { startTime: entry.startTime });
|
|
165
|
+
const currentBootId = cachedBootId(bootIdReader(deps));
|
|
166
|
+
return {
|
|
167
|
+
entries,
|
|
168
|
+
view: {
|
|
169
|
+
currentBootId: currentBootId ?? "",
|
|
170
|
+
processes,
|
|
171
|
+
entries,
|
|
172
|
+
},
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
/** Snapshot /proc once for the liveness predicate. */
|
|
176
|
+
export function readProcView(deps) {
|
|
177
|
+
return snapshotProcView(deps).view;
|
|
178
|
+
}
|
|
179
|
+
/** Resolve a worker from an already captured snapshot; performs no syscalls. */
|
|
180
|
+
export function resolveWorkerAttributionFromView(rootPid, view) {
|
|
181
|
+
if (!view.entries)
|
|
182
|
+
return undefined;
|
|
183
|
+
const workerPid = busiestDescendant(rootPid, view.entries);
|
|
184
|
+
if (workerPid === undefined)
|
|
185
|
+
return undefined;
|
|
186
|
+
const worker = view.entries.find((entry) => entry.pid === workerPid);
|
|
187
|
+
if (!worker || !view.currentBootId)
|
|
188
|
+
return undefined;
|
|
189
|
+
return { pid: worker.pid, startTime: worker.startTime, bootId: view.currentBootId };
|
|
190
|
+
}
|
|
191
|
+
/** Resolve the worker once from a pane pid, including its composite identity. */
|
|
192
|
+
export function readWorkerAttribution(rootPid, deps) {
|
|
193
|
+
const { view } = snapshotProcView(deps);
|
|
194
|
+
return resolveWorkerAttributionFromView(rootPid, view);
|
|
195
|
+
}
|
|
196
|
+
/** Descriptive alias for callers that prefer resolver terminology. */
|
|
197
|
+
export const resolveWorkerAttribution = readWorkerAttribution;
|
|
198
|
+
/** CPU + worker observation sharing exactly one /proc snapshot. */
|
|
199
|
+
export function readProcessObservation(rootPid, deps) {
|
|
200
|
+
const { entries, view } = snapshotProcView(deps);
|
|
201
|
+
return {
|
|
202
|
+
cpuMs: sumTreeCpuMs(rootPid, entries),
|
|
203
|
+
worker: resolveWorkerAttributionFromView(rootPid, view),
|
|
204
|
+
procView: view,
|
|
205
|
+
};
|
|
206
|
+
}
|
|
125
207
|
/** Snapshot /proc and total the tree rooted at `rootPid`. */
|
|
126
208
|
export function readProcessTreeCpuMs(rootPid, deps) {
|
|
127
209
|
return sumTreeCpuMs(rootPid, snapshotProc(deps));
|
package/dist/proc-cpu.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proc-cpu.js","sourceRoot":"","sources":["../src/proc-cpu.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,MAAM,CAAC,MAAM,8BAA8B,GAAG,GAAG,CAAC;
|
|
1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,CAAC;AACnD,CAAC;AAED,mEAAmE;AACnE,MAAM,UAAU,aAAa,CAC3B,OAAe,EACf,IAAoB;IAEpB,OAAO,iBAAiB,CAAC,OAAO,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC;AACxD,CAAC"}
|
package/dist/relaunch.d.ts
CHANGED
|
@@ -15,6 +15,33 @@ export type ResumeLaunch = {
|
|
|
15
15
|
args: string[];
|
|
16
16
|
display: string;
|
|
17
17
|
};
|
|
18
|
+
export type RelaunchSafety = {
|
|
19
|
+
/** True only when the pane is a shell with no live worker descendant. */
|
|
20
|
+
idle: boolean;
|
|
21
|
+
/** The hard floor: true also covers indeterminate liveness. */
|
|
22
|
+
activelyWorking: boolean;
|
|
23
|
+
reason: string;
|
|
24
|
+
rateMsPerSecond?: number;
|
|
25
|
+
};
|
|
26
|
+
export type RelaunchSafetySample = {
|
|
27
|
+
paneCommand?: string | undefined;
|
|
28
|
+
panePid?: number | undefined;
|
|
29
|
+
firstWorkerPid?: number | undefined;
|
|
30
|
+
secondWorkerPid?: number | undefined;
|
|
31
|
+
firstCpuMs?: number | undefined;
|
|
32
|
+
secondCpuMs?: number | undefined;
|
|
33
|
+
elapsedMs?: number | undefined;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Pure relaunch liveness projection.
|
|
37
|
+
*
|
|
38
|
+
* The relaunch path must never turn missing evidence into permission to kill.
|
|
39
|
+
* A complete pair of observations is required: the pane must be a wrapper
|
|
40
|
+
* shell, both observations must resolve the same worker/root, and CPU must
|
|
41
|
+
* produce a non-negative rate. Anything else is indeterminate and therefore
|
|
42
|
+
* receives the hard working floor.
|
|
43
|
+
*/
|
|
44
|
+
export declare function decideRelaunchSafety(sample: RelaunchSafetySample): RelaunchSafety;
|
|
18
45
|
/** Structured argv for resuming a conversation, safe to hand to a new tmux session. */
|
|
19
46
|
export declare function resumeLaunchFor(profile: string, convId: string): ResumeLaunch | undefined;
|
|
20
47
|
/** The shell command that resumes `convId` for `profile`, or undefined if the */
|
|
@@ -26,8 +53,12 @@ export type RelaunchCandidate = {
|
|
|
26
53
|
/** full tmux session name, e.g. `h2a-sentropic#2` */
|
|
27
54
|
name: string;
|
|
28
55
|
profile: string;
|
|
29
|
-
/** true when the
|
|
56
|
+
/** true when the shell has no working worker (dead or parked) */
|
|
30
57
|
idle: boolean;
|
|
58
|
+
/** Hard safety floor. Indeterminate probes must set this true. */
|
|
59
|
+
activelyWorking: boolean;
|
|
60
|
+
/** Diagnostic reason for the hard floor or liveness projection. */
|
|
61
|
+
livenessReason?: string;
|
|
31
62
|
/** this session's own conversation id, from the registry */
|
|
32
63
|
convId?: string;
|
|
33
64
|
/** why its registry row cannot safely produce a resume conversation */
|
package/dist/relaunch.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"relaunch.d.ts","sourceRoot":"","sources":["../src/relaunch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;
|
|
1
|
+
{"version":3,"file":"relaunch.d.ts","sourceRoot":"","sources":["../src/relaunch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAQH,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,yEAAyE;IACzE,IAAI,EAAE,OAAO,CAAC;IACd,+DAA+D;IAC/D,eAAe,EAAE,OAAO,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,eAAe,CAAC,E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GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAE5D,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,EAAE,cAAc,EAAE,CAAC;IAC1B,OAAO,EAAE,YAAY,EAAE,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,gEAAgE;IAChE,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,gFAAgF;IAChF,wBAAwB,CAAC,EAAE,OAAO,CAAC;CACpC,CAAC;AAEF,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAIlE;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAC1B,UAAU,EAAE,aAAa,CAAC,iBAAiB,CAAC,EAC5C,OAAO,GAAE,mBAAwB,GAChC,YAAY,CA8Ed"}
|
package/dist/relaunch.js
CHANGED
|
@@ -11,6 +11,91 @@
|
|
|
11
11
|
* a cwd never collide on one .jsonl.
|
|
12
12
|
*/
|
|
13
13
|
import { isCliProfile, resolveProfile, resumeArgsFor } from "./profiles.js";
|
|
14
|
+
import { cpuRateMsPerSecond, DEFAULT_WORKING_CPU_MS_PER_SECOND, } from "./session-lease.js";
|
|
15
|
+
const SHELL_COMMANDS = new Set(["bash", "sh"]);
|
|
16
|
+
/**
|
|
17
|
+
* Pure relaunch liveness projection.
|
|
18
|
+
*
|
|
19
|
+
* The relaunch path must never turn missing evidence into permission to kill.
|
|
20
|
+
* A complete pair of observations is required: the pane must be a wrapper
|
|
21
|
+
* shell, both observations must resolve the same worker/root, and CPU must
|
|
22
|
+
* produce a non-negative rate. Anything else is indeterminate and therefore
|
|
23
|
+
* receives the hard working floor.
|
|
24
|
+
*/
|
|
25
|
+
export function decideRelaunchSafety(sample) {
|
|
26
|
+
if (!SHELL_COMMANDS.has(sample.paneCommand ?? "")) {
|
|
27
|
+
return {
|
|
28
|
+
idle: false,
|
|
29
|
+
activelyWorking: true,
|
|
30
|
+
reason: "liveness indeterminate: pane command is not a readable shell",
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
if (typeof sample.panePid !== "number" ||
|
|
34
|
+
!Number.isInteger(sample.panePid) ||
|
|
35
|
+
sample.panePid <= 0 ||
|
|
36
|
+
typeof sample.firstWorkerPid !== "number" ||
|
|
37
|
+
!Number.isInteger(sample.firstWorkerPid) ||
|
|
38
|
+
typeof sample.secondWorkerPid !== "number" ||
|
|
39
|
+
!Number.isInteger(sample.secondWorkerPid) ||
|
|
40
|
+
typeof sample.firstCpuMs !== "number" ||
|
|
41
|
+
!Number.isFinite(sample.firstCpuMs) ||
|
|
42
|
+
typeof sample.secondCpuMs !== "number" ||
|
|
43
|
+
!Number.isFinite(sample.secondCpuMs) ||
|
|
44
|
+
typeof sample.elapsedMs !== "number" ||
|
|
45
|
+
!Number.isFinite(sample.elapsedMs) ||
|
|
46
|
+
sample.elapsedMs <= 0) {
|
|
47
|
+
return {
|
|
48
|
+
idle: false,
|
|
49
|
+
activelyWorking: true,
|
|
50
|
+
reason: "liveness indeterminate: pane, worker, or CPU sample unreadable",
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
// A worker disappearing, appearing, or changing identity during the sample
|
|
54
|
+
// is not evidence of idleness. The safe outcome is to leave the session.
|
|
55
|
+
if (sample.firstWorkerPid !== sample.secondWorkerPid) {
|
|
56
|
+
return {
|
|
57
|
+
idle: false,
|
|
58
|
+
activelyWorking: true,
|
|
59
|
+
reason: "liveness indeterminate: worker identity changed during sample",
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
// busiestDescendant returns the pane root when the wrapper has no live
|
|
63
|
+
// descendant. This is the only shape that proves a dead/parked shell.
|
|
64
|
+
if (sample.firstWorkerPid === sample.panePid) {
|
|
65
|
+
return {
|
|
66
|
+
idle: true,
|
|
67
|
+
activelyWorking: false,
|
|
68
|
+
reason: "no live CLI worker descendant",
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
const rateMsPerSecond = cpuRateMsPerSecond({
|
|
72
|
+
sample: {
|
|
73
|
+
cpuMs: sample.firstCpuMs,
|
|
74
|
+
sampledAt: new Date(0).toISOString(),
|
|
75
|
+
},
|
|
76
|
+
}, sample.secondCpuMs, new Date(sample.elapsedMs).toISOString());
|
|
77
|
+
if (rateMsPerSecond === undefined) {
|
|
78
|
+
return {
|
|
79
|
+
idle: false,
|
|
80
|
+
activelyWorking: true,
|
|
81
|
+
reason: "liveness indeterminate: CPU rate could not be computed",
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
if (rateMsPerSecond >= DEFAULT_WORKING_CPU_MS_PER_SECOND) {
|
|
85
|
+
return {
|
|
86
|
+
idle: false,
|
|
87
|
+
activelyWorking: true,
|
|
88
|
+
rateMsPerSecond,
|
|
89
|
+
reason: "live working CLI — never killed (even with --force)",
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
return {
|
|
93
|
+
idle: true,
|
|
94
|
+
activelyWorking: false,
|
|
95
|
+
rateMsPerSecond,
|
|
96
|
+
reason: "live CLI worker is parked below the working CPU threshold",
|
|
97
|
+
};
|
|
98
|
+
}
|
|
14
99
|
/** Structured argv for resuming a conversation, safe to hand to a new tmux session. */
|
|
15
100
|
export function resumeLaunchFor(profile, convId) {
|
|
16
101
|
if (!isCliProfile(profile))
|
|
@@ -68,6 +153,14 @@ export function planRelaunch(candidates, options = {}) {
|
|
|
68
153
|
});
|
|
69
154
|
continue;
|
|
70
155
|
}
|
|
156
|
+
if (c.activelyWorking !== false) {
|
|
157
|
+
skipped.push({
|
|
158
|
+
slug: c.slug,
|
|
159
|
+
reason: c.livenessReason ??
|
|
160
|
+
"liveness indeterminate — left alone (never kill on unknown)",
|
|
161
|
+
});
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
71
164
|
if (!options.force && !c.idle) {
|
|
72
165
|
skipped.push({ slug: c.slug, reason: "CLI is running — left alone" });
|
|
73
166
|
continue;
|
package/dist/relaunch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"relaunch.js","sourceRoot":"","sources":["../src/relaunch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"relaunch.js","sourceRoot":"","sources":["../src/relaunch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC5E,OAAO,EACL,kBAAkB,EAClB,iCAAiC,GAClC,MAAM,oBAAoB,CAAC;AA2B5B,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;AAE/C;;;;;;;;GAQG;AACH,MAAM,UAAU,oBAAoB,CAClC,MAA4B;IAE5B,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,WAAW,IAAI,EAAE,CAAC,EAAE,CAAC;QAClD,OAAO;YACL,IAAI,EAAE,KAAK;YACX,eAAe,EAAE,IAAI;YACrB,MAAM,EAAE,8DAA8D;SACvE,CAAC;IACJ,CAAC;IACD,IACE,OAAO,MAAM,CAAC,OAAO,KAAK,QAAQ;QAClC,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC;QACjC,MAAM,CAAC,OAAO,IAAI,CAAC;QACnB,OAAO,MAAM,CAAC,cAAc,KAAK,QAAQ;QACzC,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,cAAc,CAAC;QACxC,OAAO,MAAM,CAAC,eAAe,KAAK,QAAQ;QAC1C,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,eAAe,CAAC;QACzC,OAAO,MAAM,CAAC,UAAU,KAAK,QAAQ;QACrC,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAU,CA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EAAE,CAAC,CAAC,MAAM;YAChB,GAAG,EAAE,MAAM,CAAC,OAAO;YACnB,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,IAAI,EAAE,MAAM,CAAC,IAAI;SAClB,CAAC,CAAC;IACL,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;AAC9B,CAAC"}
|
package/dist/run.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":"AAUA,OAAO,EAAkC,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3E,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAC5C,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAChD,QAAQ,CAAC,WAAW,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAC7C,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACnC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,WAAW,CAAC;IACrC,QAAQ,CAAC,OAAO,CAAC,EAAE,UAAU,CAAC;IAC9B,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC;IAC/C,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B,QAAQ,CAAC,WAAW,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;CACvD,CAAC;AAmDF,MAAM,MAAM,SAAS,GAAG;IACtB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC9D,QAAQ,CAAC,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACpC,CAAC;AAEF,wBAAsB,GAAG,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,SAAS,CAAC,CAyMjE"}
|
package/dist/run.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { serve } from "@hono/node-server";
|
|
2
|
-
import { createNodeWebSocket } from "@hono/node-ws";
|
|
3
2
|
import { REMOTE_PROTOCOL_VERSION, REMOTE_SCHEMA_VERSION, } from "./protocol-local.js";
|
|
4
3
|
import { Hono } from "hono";
|
|
5
4
|
import { streamSSE } from "hono/streaming";
|
|
@@ -94,7 +93,6 @@ export async function run(options) {
|
|
|
94
93
|
stdout.on?.("resize", onResize);
|
|
95
94
|
// Open control-plane in-process for remote attach.
|
|
96
95
|
const app = new Hono();
|
|
97
|
-
const nodeWs = createNodeWebSocket({ app });
|
|
98
96
|
app.get("/healthz", (c) => c.json({ ok: true, sessionId, profile: profile.profile }));
|
|
99
97
|
app.get(`/sessions/${sessionId}`, (c) => c.json({
|
|
100
98
|
session: {
|
|
@@ -152,7 +150,6 @@ export async function run(options) {
|
|
|
152
150
|
});
|
|
153
151
|
const port = options.port ?? 0;
|
|
154
152
|
const server = serve({ fetch: app.fetch, port, hostname: "127.0.0.1" });
|
|
155
|
-
nodeWs.injectWebSocket(server);
|
|
156
153
|
let actualPort = port;
|
|
157
154
|
const address = server.address();
|
|
158
155
|
if (address && typeof address === "object") {
|
package/dist/run.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.js","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,
|
|
1
|
+
{"version":3,"file":"run.js","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EACL,uBAAuB,EACvB,qBAAqB,GAEtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EAAE,cAAc,EAAE,UAAU,EAAsB,MAAM,eAAe,CAAC;AAC/E,OAAO,EAAE,cAAc,EAAmC,MAAM,UAAU,CAAC;AAiB3E,SAAS,eAAe,CAAC,MAAc;IACrC,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC;SAC5C,QAAQ,CAAC,EAAE,CAAC;SACZ,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IACpB,OAAO,GAAG,MAAM,IAAI,MAAM,EAAE,CAAC;AAC/B,CAAC;AAED,MAAM,mBAAmB,GAAG;IAC1B,EAAE,EAAE,YAAY;IAChB,IAAI,EAAE,eAAwB;IAC9B,WAAW,EAAE,YAAY;CAC1B,CAAC;AAEF,MAAM,WAAW,GAAG;IAClB,EAAE,EAAE,kBAAkB;IACtB,IAAI,EAAE,eAAwB;IAC9B,WAAW,EAAE,kBAAkB;CAChC,CAAC;AAUF,SAAS,aAAa,CACpB,OAAuB,EACvB,IAAiC,EACjC,OAAgC,EAChC,QAAoC,EACpC,KAAiB,EACjB,KAAK,GAAG,WAAW;IAEnB,OAA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ACjB,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,CAAC,OAAO,EAAE,EACtC,QAAQ,EACR,KAAK,CACN,CACF,CAAC;IAEF,aAAa;IACb,IAAI,WAAqE,CAAC;IAC1E,MAAM,IAAI,GAAG,IAAI,OAAO,CAAwC,CAAC,OAAO,EAAE,EAAE;QAC1E,WAAW,GAAG,OAAO,CAAC;IACxB,CAAC,CAAC,CAAC;IACH,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;QACtB,IAAI,OAAO,CAAC,MAAM;YAAE,OAAO;QAC3B,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;QACtB,SAAS,CACP,aAAa,CACX,OAAO,EACP,iBAAiB,EACjB;YACE,UAAU;YACV,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,GAAG,CAAC,KAAK,CAAC,MAAM,KAAK,SAAS;gBAC5B,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE;gBAClC,CAAC,CAAC,EAAE,CAAC;SACR,EACD,QAAQ,EACR,KAAK,CACN,CACF,CAAC;QACF,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;YAChB,KAAK,CAAC,UAAU,EAAE,CAAC,KAAK,CAAC,CAAC;QAC5B,CAAC;QACD,MAAM,CAAC,KAAK,EAAE,CAAC;QACf,WAAW,CAAC,KAAK,CAAC,CAAC;IACrB,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,SAAS;QACT,IAAI,EAAE,UAAU;QAChB,IAAI;QACJ,KAAK,CAAC,IAAI;YACR,MAAM,CAAC,IAAI,EAAE,CAAC;YACd,MAAM,IAAI,CAAC;QACb,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/session-lease.d.ts
CHANGED
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
* REPLACED its own. That property is enforced by the code and tested; secrecy
|
|
42
42
|
* against a local reader is not claimed.
|
|
43
43
|
*/
|
|
44
|
+
import type { ProcView } from "./proc-cpu.js";
|
|
44
45
|
/**
|
|
45
46
|
* Default lease TTL. 30 minutes, the same figure track settled on: long enough
|
|
46
47
|
* that a session pausing between two tool calls is never mistaken for finished,
|
|
@@ -69,6 +70,14 @@ export declare const DEFAULT_SESSION_LEASE_TTL_MS: number;
|
|
|
69
70
|
* PROPOSED for reclamation to a human or conductor, who can still see it.
|
|
70
71
|
*/
|
|
71
72
|
export declare const DEFAULT_WORKING_CPU_MS_PER_SECOND = 75;
|
|
73
|
+
/** Maximum time a token-holder may keep a lease in the relaunch gap. */
|
|
74
|
+
export declare const DEFAULT_RESOLVING_BOUND_MS = 60000;
|
|
75
|
+
export type SessionLeaseWorker = {
|
|
76
|
+
pid: number;
|
|
77
|
+
startTime: string;
|
|
78
|
+
bootId: string;
|
|
79
|
+
};
|
|
80
|
+
export type SessionLeaseWorkerState = SessionLeaseWorker | "resolving";
|
|
72
81
|
/** A CPU observation of the session's pane process tree, at a point in time. */
|
|
73
82
|
export interface SessionCpuSample {
|
|
74
83
|
/** Cumulative CPU (ms) of the pane's whole process tree — `paneTreeCpuMs`. */
|
|
@@ -98,6 +107,11 @@ export interface SessionLease {
|
|
|
98
107
|
token: string;
|
|
99
108
|
/** Last CPU observation — the evidence the beat decision is derived from. */
|
|
100
109
|
sample?: SessionCpuSample;
|
|
110
|
+
/** Composite identity of the process actually doing the work. */
|
|
111
|
+
worker?: SessionLeaseWorkerState;
|
|
112
|
+
/** Bounded token-protected relaunch window (used while worker is resolving). */
|
|
113
|
+
relaunchStartedAt?: string;
|
|
114
|
+
resolvingBoundMs?: number;
|
|
101
115
|
}
|
|
102
116
|
/** Rejected lease operation (wrong token, absent lease, subject already held). */
|
|
103
117
|
export declare class SessionLeaseError extends Error {
|
|
@@ -109,6 +123,14 @@ export declare class SessionLeaseError extends Error {
|
|
|
109
123
|
* acquire guard, by the reclaim report, and by callers deciding what to show.
|
|
110
124
|
*/
|
|
111
125
|
export declare function isSessionLeaseAbandoned(lease: SessionLease, now: string): boolean;
|
|
126
|
+
/** True when a present worker is contradicted by the current boot/proc view. */
|
|
127
|
+
export declare function workerDisproven(lease: SessionLease, procView: ProcView | undefined, now?: string): boolean;
|
|
128
|
+
/** The one liveness projection used by slot and reclaim readers. */
|
|
129
|
+
export declare function isSessionLeaseAlive(lease: SessionLease, procView: ProcView | undefined, now: string): boolean;
|
|
130
|
+
export declare function isSessionLeaseDeadBoot(lease: SessionLease, procView: ProcView | undefined): boolean;
|
|
131
|
+
export declare function isSessionLeaseContested(lease: SessionLease, procView: ProcView | undefined, now: string): boolean;
|
|
132
|
+
/** Pure slot counter; every count goes through the same liveness predicate. */
|
|
133
|
+
export declare function countLiveSessionLeases(leases: ReadonlyArray<SessionLease>, procView: ProcView | undefined, now: string): number;
|
|
112
134
|
/**
|
|
113
135
|
* CPU rate (ms of CPU per second of wall clock) between the lease's last
|
|
114
136
|
* observation and `cpuMsNow` taken at `now`. Undefined when there is no prior
|
|
@@ -116,7 +138,7 @@ export declare function isSessionLeaseAbandoned(lease: SessionLease, now: string
|
|
|
116
138
|
* BACKWARDS (the pane's tree was replaced — a relaunch, or PID reuse): a
|
|
117
139
|
* negative delta is not a rate, and must never be read as "idle". PURE.
|
|
118
140
|
*/
|
|
119
|
-
export declare function cpuRateMsPerSecond(lease: SessionLease, cpuMsNow: number, now: string): number | undefined;
|
|
141
|
+
export declare function cpuRateMsPerSecond(lease: Pick<SessionLease, "sample">, cpuMsNow: number, now: string): number | undefined;
|
|
120
142
|
/**
|
|
121
143
|
* What a supervising pass should do with one lease, given a fresh CPU reading.
|
|
122
144
|
* PURE — the probe is the caller's effect, the decision is testable here.
|
|
@@ -154,6 +176,8 @@ export interface SessionReclaimProposal {
|
|
|
154
176
|
heartbeatAt: string;
|
|
155
177
|
/** CPU rate over the whole unbeaten window, when a sample exists (ms/s). */
|
|
156
178
|
lastRateMsPerSecond?: number;
|
|
179
|
+
/** Contested is same-boot worker disproof; abandoned is the legacy TTL case. */
|
|
180
|
+
reason?: "abandoned" | "contested";
|
|
157
181
|
}
|
|
158
182
|
/**
|
|
159
183
|
* The abandoned leases at `now`, as PROPOSALS. This function proposes; it never
|
|
@@ -161,7 +185,7 @@ export interface SessionReclaimProposal {
|
|
|
161
185
|
* that still beats — is structurally excluded: the only filter is
|
|
162
186
|
* `isSessionLeaseAbandoned`, so a beating session can never appear here. PURE.
|
|
163
187
|
*/
|
|
164
|
-
export declare function reclaimProposals(leases: ReadonlyArray<SessionLease>, now: string): SessionReclaimProposal[];
|
|
188
|
+
export declare function reclaimProposals(leases: ReadonlyArray<SessionLease>, now: string, procView?: ProcView): SessionReclaimProposal[];
|
|
165
189
|
/**
|
|
166
190
|
* What a supervising pass must do with each recorded lease, BEFORE any probe.
|
|
167
191
|
* The registry state decides; the CPU probe only happens for `probe` steps.
|
|
@@ -194,6 +218,25 @@ export interface LeasedSessionState {
|
|
|
194
218
|
tmuxSession?: string;
|
|
195
219
|
}
|
|
196
220
|
export declare function planLeaseSupervision(leases: ReadonlyArray<SessionLease>, sessions: ReadonlyArray<LeasedSessionState>): LeaseSupervisionStep[];
|
|
221
|
+
export type SessionLeaseManagedSession = {
|
|
222
|
+
readonly sessionId: string;
|
|
223
|
+
readonly tmuxSession?: string;
|
|
224
|
+
readonly jobState?: string;
|
|
225
|
+
};
|
|
226
|
+
export type SessionLeaseStatusSurface = {
|
|
227
|
+
readonly sessionName: string;
|
|
228
|
+
readonly marker?: string;
|
|
229
|
+
};
|
|
230
|
+
export type SessionLeaseFleetAudit = {
|
|
231
|
+
/** Live managed sessions for which the installed marker is absent/drifted. */
|
|
232
|
+
missingStatusSurface: string[];
|
|
233
|
+
/** Same-boot worker disproofs; these are reclaim proposals, not reaps. */
|
|
234
|
+
contested: SessionReclaimProposal[];
|
|
235
|
+
/** Prior-boot worker leases; these are silently reaped. */
|
|
236
|
+
deadBoot: string[];
|
|
237
|
+
};
|
|
238
|
+
/** Pure read-back auditor projection over one tmux and one /proc snapshot. */
|
|
239
|
+
export declare function auditSessionLeaseFleet(sessions: ReadonlyArray<SessionLeaseManagedSession>, leases: ReadonlyArray<SessionLease>, statusSurfaces: ReadonlyArray<SessionLeaseStatusSurface>, procView: ProcView, now: string): SessionLeaseFleetAudit;
|
|
197
240
|
/** Machine-scoped path of the session-lease side-store (beside `registry.json`). */
|
|
198
241
|
export declare function resolveSessionLeasePath(): string;
|
|
199
242
|
/**
|
|
@@ -216,8 +259,8 @@ export declare class SessionLeaseStore {
|
|
|
216
259
|
readAll(): SessionLease[];
|
|
217
260
|
/** The lease recorded for a session, live or abandoned, if any. */
|
|
218
261
|
forSession(sessionId: string): SessionLease | undefined;
|
|
219
|
-
/** The leases
|
|
220
|
-
abandoned(now: string): SessionLease[];
|
|
262
|
+
/** The leases not alive at `now`, using the shared reader predicate. */
|
|
263
|
+
abandoned(now: string, procView?: ProcView): SessionLease[];
|
|
221
264
|
/**
|
|
222
265
|
* Take the slot for `sessionId`. Rejects when a LIVE lease already covers it
|
|
223
266
|
* (one active lease per session). An ABANDONED prior lease does not block: the
|
|
@@ -231,6 +274,7 @@ export declare class SessionLeaseStore {
|
|
|
231
274
|
workspace?: string;
|
|
232
275
|
ttlMs?: number;
|
|
233
276
|
cpuMs?: number;
|
|
277
|
+
worker?: SessionLeaseWorker;
|
|
234
278
|
}): SessionLease;
|
|
235
279
|
/**
|
|
236
280
|
* Renew a lease — the holder's assertion that the session is WORKING. Only the
|
|
@@ -255,6 +299,39 @@ export declare class SessionLeaseStore {
|
|
|
255
299
|
token: string;
|
|
256
300
|
cpuMs: number;
|
|
257
301
|
}): SessionLease;
|
|
302
|
+
/** Lazily migrate a legacy lease once a supervising pass can resolve its worker. */
|
|
303
|
+
populateWorker(input: {
|
|
304
|
+
sessionId: string;
|
|
305
|
+
token: string;
|
|
306
|
+
worker: SessionLeaseWorker;
|
|
307
|
+
}): SessionLease;
|
|
308
|
+
/** Begin the bounded token-guarded relaunch window. */
|
|
309
|
+
beginRelaunch(input: {
|
|
310
|
+
sessionId: string;
|
|
311
|
+
token: string;
|
|
312
|
+
resolvingBoundMs?: number;
|
|
313
|
+
}): SessionLease;
|
|
314
|
+
/** Complete the same-act relaunch with the newly resolved worker identity. */
|
|
315
|
+
finishRelaunch(input: {
|
|
316
|
+
sessionId: string;
|
|
317
|
+
token: string;
|
|
318
|
+
worker: SessionLeaseWorker;
|
|
319
|
+
}): SessionLease;
|
|
320
|
+
/**
|
|
321
|
+
* Run a relaunch and re-resolve the worker under the holder's token. If the
|
|
322
|
+
* process is not visible immediately, the bounded `resolving` state remains
|
|
323
|
+
* on disk and becomes reclaimable after its bound.
|
|
324
|
+
*/
|
|
325
|
+
relaunch(input: {
|
|
326
|
+
sessionId: string;
|
|
327
|
+
token: string;
|
|
328
|
+
resolvingBoundMs?: number;
|
|
329
|
+
act: () => boolean;
|
|
330
|
+
resolveWorker: () => SessionLeaseWorker | undefined;
|
|
331
|
+
}): {
|
|
332
|
+
succeeded: boolean;
|
|
333
|
+
lease: SessionLease;
|
|
334
|
+
};
|
|
258
335
|
/** Give the slot back. Only the matching token is accepted. */
|
|
259
336
|
release(input: {
|
|
260
337
|
sessionId: string;
|
|
@@ -262,5 +339,7 @@ export declare class SessionLeaseStore {
|
|
|
262
339
|
}): void;
|
|
263
340
|
/** Shared token-guarded read-modify-write for `heartbeat` and `observe`. */
|
|
264
341
|
private mutate;
|
|
342
|
+
/** Remove only leases proven to belong to a prior kernel boot. */
|
|
343
|
+
reapDeadBootLeases(procView: ProcView): string[];
|
|
265
344
|
}
|
|
266
345
|
//# sourceMappingURL=session-lease.d.ts.map
|