@hearsay-tools/squawk 0.18.0-dev.6807 → 0.18.0-dev.6810
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/ci-wait/controller.d.ts +4 -4
- package/dist/contract/delegation.d.ts +20 -0
- package/dist/contract/index.js +4 -1
- package/dist/core/agent-runner.d.ts +16 -0
- package/dist/core/agent-runner.js +7 -0
- package/dist/core/agent-runner.js.map +1 -1
- package/dist/core/claude-cli-runner.js +3 -2
- package/dist/core/claude-cli-runner.js.map +1 -1
- package/dist/core/codex-app-server-runner.js +3 -3
- package/dist/core/codex-app-server-runner.js.map +1 -1
- package/dist/core/codex-app-server-transport.d.ts +2 -0
- package/dist/core/codex-app-server-transport.js +1 -1
- package/dist/core/codex-app-server-transport.js.map +1 -1
- package/dist/core/cursor-print-process.d.ts +3 -0
- package/dist/core/cursor-print-process.js +1 -1
- package/dist/core/cursor-print-process.js.map +1 -1
- package/dist/core/cursor-print-runner.js +3 -2
- package/dist/core/cursor-print-runner.js.map +1 -1
- package/dist/core/omp-runner.js +3 -1
- package/dist/core/omp-runner.js.map +1 -1
- package/dist/core/opencode-server-runner.js +3 -3
- package/dist/core/opencode-server-runner.js.map +1 -1
- package/dist/core/pi-runner.js +3 -2
- package/dist/core/pi-runner.js.map +1 -1
- package/dist/core/session-process.d.ts +6 -0
- package/dist/core/session-process.js +53 -2
- package/dist/core/session-process.js.map +1 -1
- package/dist/delegation/family-end.js +2 -4
- package/dist/delegation/family-end.js.map +1 -1
- package/dist/delegation/owned-workspace-release.d.ts +1 -2
- package/dist/delegation/owned-workspace-release.js +2 -2
- package/dist/delegation/owned-workspace-release.js.map +1 -1
- package/dist/delegation/process-liveness.d.ts +8 -58
- package/dist/delegation/process-liveness.js +9 -86
- package/dist/delegation/process-liveness.js.map +1 -1
- package/dist/delegation/routes.d.ts +87 -83
- package/dist/delegation/scratch-cleanup.d.ts +1 -1
- package/dist/delegation/scratch-cleanup.js +7 -10
- package/dist/delegation/scratch-cleanup.js.map +1 -1
- package/dist/delegation/service.js +2 -1
- package/dist/delegation/service.js.map +1 -1
- package/dist/delegation/transport.d.ts +20 -16
- package/dist/delegation/worker-cleanup.d.ts +2 -9
- package/dist/delegation/worker-cleanup.js +44 -86
- package/dist/delegation/worker-cleanup.js.map +1 -1
- package/dist/delegation/workspace-removal.d.ts +4 -12
- package/dist/delegation/workspace-removal.js +18 -51
- package/dist/delegation/workspace-removal.js.map +1 -1
- package/dist/git-worktree.js +2 -6
- package/dist/git-worktree.js.map +1 -1
- package/dist/preview/dev-server.d.ts +3 -0
- package/dist/preview/dev-server.js +40 -1
- package/dist/preview/dev-server.js.map +1 -1
- package/dist/preview/host.d.ts +3 -1
- package/dist/preview/host.js +2 -1
- package/dist/preview/host.js.map +1 -1
- package/dist/runs/private-record-file.d.ts +7 -0
- package/dist/runs/private-record-file.js +55 -0
- package/dist/runs/private-record-file.js.map +1 -0
- package/dist/runs/store.d.ts +18 -6
- package/dist/runs/store.js +43 -99
- package/dist/runs/store.js.map +1 -1
- package/dist/runs/worker-execution.d.ts +1 -0
- package/dist/runs/worker-execution.js +4 -1
- package/dist/runs/worker-execution.js.map +1 -1
- package/dist/runs/worker-resource-holders.d.ts +10 -7
- package/dist/runs/worker-resource-holders.js +9 -25
- package/dist/runs/worker-resource-holders.js.map +1 -1
- package/dist/server/server.d.ts +8 -0
- package/dist/server/workspace-live-routes.d.ts +6 -6
- package/dist/worker-scope/cgroup.d.ts +41 -0
- package/dist/worker-scope/cgroup.js +173 -0
- package/dist/worker-scope/cgroup.js.map +1 -0
- package/dist/worker-scope/groups.d.ts +24 -0
- package/dist/worker-scope/groups.js +60 -0
- package/dist/worker-scope/groups.js.map +1 -0
- package/dist/worker-scope/scope.d.ts +32 -0
- package/dist/worker-scope/scope.js +18 -0
- package/dist/worker-scope/scope.js.map +1 -0
- package/dist/worker-scope/worker-scopes.d.ts +63 -0
- package/dist/worker-scope/worker-scopes.js +181 -0
- package/dist/worker-scope/worker-scopes.js.map +1 -0
- package/dist/workflows/grouped-command.d.ts +3 -0
- package/dist/workflows/grouped-command.js +28 -2
- package/dist/workflows/grouped-command.js.map +1 -1
- package/dist/workflows/run/compose.d.ts +0 -2
- package/dist/workflows/run/compose.js.map +1 -1
- package/dist/workflows/run/continuation-session.js +1 -0
- package/dist/workflows/run/continuation-session.js.map +1 -1
- package/dist/workflows/run/step-loop.d.ts +1 -1
- package/dist/workflows/run/step-loop.js +4 -2
- package/dist/workflows/run/step-loop.js.map +1 -1
- package/dist/workflows/run/step-session.js +1 -0
- package/dist/workflows/run/step-session.js.map +1 -1
- package/dist/workflows/run/worker-executions.d.ts +2 -1
- package/dist/workflows/run/worker-executions.js +8 -4
- package/dist/workflows/run/worker-executions.js.map +1 -1
- package/dist/workflows/run/worker-orphans.d.ts +16 -31
- package/dist/workflows/run/worker-orphans.js +71 -123
- package/dist/workflows/run/worker-orphans.js.map +1 -1
- package/dist/workflows/run.d.ts +0 -2
- package/dist/workflows/run.js +1 -4
- package/dist/workflows/run.js.map +1 -1
- package/dist/worktree-setup.d.ts +3 -0
- package/dist/worktree-setup.js +2 -1
- package/dist/worktree-setup.js.map +1 -1
- package/package.json +4 -4
- package/web/dist/assets/{activity-motion-ankV4z_y.js → activity-motion-AuQA350-.js} +1 -1
- package/web/dist/assets/{activity-route-C7Lo4d_1.js → activity-route-BNZ9bOOZ.js} +1 -1
- package/web/dist/assets/{agent-accounts-BAUPVmTO.js → agent-accounts-D2uZHuiM.js} +1 -1
- package/web/dist/assets/attention-B7icDSLh.js +1 -0
- package/web/dist/assets/{cez-idle-TVRD1sce.js → cez-idle-MToU9Wv_.js} +1 -1
- package/web/dist/assets/{commit-diff-panel-Cmqi-EvU.js → commit-diff-panel-DBW7us79.js} +1 -1
- package/web/dist/assets/{diff-BawymO3F.js → diff-C3Cms5Ep.js} +2 -2
- package/web/dist/assets/{diff-view-DHx_pu8b.js → diff-view-D5zTYOKV.js} +1 -1
- package/web/dist/assets/{file-preview-DV7f2pOk.js → file-preview-FhzIdXZ3.js} +1 -1
- package/web/dist/assets/{git-toolbar-BrVfyYBr.js → git-toolbar-MFjkjDDG.js} +1 -1
- package/web/dist/assets/{github-DVXWmfeu.js → github-CYmdc5Dh.js} +1 -1
- package/web/dist/assets/{global-activity-route-ybR1xgLf.js → global-activity-route-C41ofuHV.js} +1 -1
- package/web/dist/assets/{index-Dc_KmL4Z.js → index-e1OpsDKN.js} +4 -4
- package/web/dist/assets/{live-protocol-aMLJJ0MQ.js → live-protocol-B8boP96Z.js} +1 -1
- package/web/dist/assets/{preview-pane-connected-CT7tXifI.js → preview-pane-connected-Ds209_UZ.js} +1 -1
- package/web/dist/assets/{project-router-CbWELZZ9.js → project-router-F1inY-EB.js} +1 -1
- package/web/dist/assets/{project-scope-context-p1OpXpSJ.js → project-scope-context-0Z0nsheq.js} +1 -1
- package/web/dist/assets/{prompt-template-menu-Ct3m86h1.js → prompt-template-menu-uUjg9v98.js} +1 -1
- package/web/dist/assets/{queries-BAUtqJph.js → queries-7W9tOZsg.js} +1 -1
- package/web/dist/assets/{reference-chip-B2B-Ky7w.js → reference-chip-BqRpnpaI.js} +1 -1
- package/web/dist/assets/{repo-git-DRONt4_i.js → repo-git-BZcRanYE.js} +1 -1
- package/web/dist/assets/{report-reader-BF8rmJRD.js → report-reader-BLlV3dPF.js} +1 -1
- package/web/dist/assets/{reports-Bv91XlcP.js → reports-C--EXqf1.js} +1 -1
- package/web/dist/assets/{run-header-CvJ84kr2.js → run-header-CJg8dyfz.js} +1 -1
- package/web/dist/assets/{skills-Ceg2Y9LM.js → skills-CHWVejdV.js} +1 -1
- package/web/dist/assets/{tab-link-CT5gqdai.js → tab-link-XI9xWLwR.js} +1 -1
- package/web/dist/assets/{task-changes-BplRsiSs.js → task-changes-DFm_EHnj.js} +1 -1
- package/web/dist/assets/{task-commits-CYLy-lg-.js → task-commits-BX-GVdXG.js} +1 -1
- package/web/dist/assets/{task-files-COYxL8mg.js → task-files-Dsn11PYu.js} +1 -1
- package/web/dist/assets/{task-github-item-DAD__wEa.js → task-github-item-3N6jEijR.js} +1 -1
- package/web/dist/assets/{task-thread-CTEobEyX.js → task-thread-VNPhkI8i.js} +1 -1
- package/web/dist/assets/{thread-state-CpdUCQVd.js → thread-state-D1XLo7ab.js} +1 -1
- package/web/dist/assets/{use-desktop-Bok38AjX.js → use-desktop-DdcA0Atl.js} +1 -1
- package/web/dist/assets/{use-hand-to-agent-state-DiBEjj2Y.js → use-hand-to-agent-state-2tzEmCDo.js} +1 -1
- package/web/dist/assets/{useInfiniteQuery-DD7iZHIJ.js → useInfiniteQuery-BmmIZbVY.js} +1 -1
- package/web/dist/assets/useQuery-CBKC2lBX.js +1 -0
- package/web/dist/assets/{workflows-Cq6Fg1ZT.js → workflows-CqqdPBFr.js} +1 -1
- package/web/dist/assets/{ws-CqtLOaJ8.js → ws-BvDSfSVH.js} +1 -1
- package/web/dist/index.html +14 -14
- package/web/dist/live-worker.js +1 -1
- package/dist/delegation/destroy-observation.d.ts +0 -44
- package/dist/delegation/destroy-observation.js +0 -116
- package/dist/delegation/destroy-observation.js.map +0 -1
- package/web/dist/assets/attention-C6XIgMqB.js +0 -1
- package/web/dist/assets/useQuery-DVAeyc_X.js +0 -1
|
@@ -10,6 +10,7 @@ export declare const workerExecutionSchema: z.ZodObject<{
|
|
|
10
10
|
}>;
|
|
11
11
|
neverMaterialized: z.ZodOptional<z.ZodLiteral<true>>;
|
|
12
12
|
abandoned: z.ZodOptional<z.ZodLiteral<true>>;
|
|
13
|
+
interrupted: z.ZodOptional<z.ZodLiteral<true>>;
|
|
13
14
|
scratchCleanup: z.ZodOptional<z.ZodObject<{
|
|
14
15
|
resourceId: z.ZodString;
|
|
15
16
|
path: z.ZodString;
|
|
@@ -9,8 +9,11 @@ export const workerExecutionSchema = z.object({
|
|
|
9
9
|
generation: z.string().uuid(), phase: z.enum(['queued', 'starting', 'complete']), neverMaterialized: z.literal(true).optional(),
|
|
10
10
|
// Settlement after a same-boot crash with unverified holders is not exit proof (hearsay-tools/cezarion#839).
|
|
11
11
|
abandoned: z.literal(true).optional(),
|
|
12
|
+
// A crashed controller's generation, settled once its recorded sessions were gone: what it left
|
|
13
|
+
// in the worker's scope is stopped by the next Continue (ADR 0032).
|
|
14
|
+
interrupted: z.literal(true).optional(),
|
|
12
15
|
scratchCleanup: z.object({ resourceId: z.string().uuid(), path: z.string().refine(isAbsolute) }).strict().optional(),
|
|
13
|
-
}).strict().refine(proof => ((!proof.neverMaterialized && !proof.scratchCleanup && !proof.abandoned) || proof.phase === 'complete') &&
|
|
16
|
+
}).strict().refine(proof => ((!proof.neverMaterialized && !proof.scratchCleanup && !proof.abandoned && !proof.interrupted) || proof.phase === 'complete') &&
|
|
14
17
|
!(proof.abandoned && proof.neverMaterialized));
|
|
15
18
|
/** Presence, not parseability, reserves scratch. Unknown evidence must never turn into an
|
|
16
19
|
* orphan merely because runs.json was missing, partly salvaged, or unreadable. Undefined
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker-execution.js","sourceRoot":"","sources":["../../src/runs/worker-execution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAEtE;2FAC2F;AAC3F,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5C,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,UAAU,EAAE,UA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C,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;AAClG,CAAC"}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Holder proof for worker persistent paths (worktree and scratch). `RunStore.workerResourceHolders`
|
|
3
|
+
* reads the row and checkpoints, then these helpers decide whether the generation is gone. Only the
|
|
4
|
+
* generation's recorded processes count: ownership is set when Squawk starts a process, never read
|
|
5
|
+
* from which files a process uses (ADR 0032).
|
|
6
|
+
*/
|
|
1
7
|
import type { RunRecord } from '../contract/index.js';
|
|
2
|
-
import { type
|
|
8
|
+
import { type WorkerProcessRecord } from '../delegation/process-liveness.ts';
|
|
3
9
|
import type { WorkerExecution } from './worker-execution.ts';
|
|
4
10
|
type WorkerOwnedRun = RunRecord & {
|
|
5
11
|
delegation: Extract<RunRecord['delegation'], {
|
|
@@ -8,10 +14,7 @@ type WorkerOwnedRun = RunRecord & {
|
|
|
8
14
|
};
|
|
9
15
|
/** The row owns this generation's workspace and the checkpoint is complete, or queued when admitting. */
|
|
10
16
|
export declare function workerResourceAuthorized(run: RunRecord | undefined, proof: WorkerExecution | undefined, id: string, generation: string, resourceId: string, admittingQueued?: boolean): run is WorkerOwnedRun;
|
|
11
|
-
/**
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
export declare function workerResourceAbsentHolders(record: WorkerProcessRecord | 'absent'): 'safe' | number[];
|
|
15
|
-
/** Live PIDs that refuse reuse, or `safe` when the generation is gone. */
|
|
16
|
-
export declare function workerResourceLiveHolders(probe: GenerationProbe): 'safe' | number[];
|
|
17
|
+
/** The live recorded processes of a generation: another live controller, else live session
|
|
18
|
+
* processes. `safe` when none is live, or the generation predates process records. */
|
|
19
|
+
export declare function recordedHolders(record: WorkerProcessRecord | 'absent'): 'safe' | number[];
|
|
17
20
|
export {};
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Holder proof for worker persistent paths (worktree and scratch). `RunStore.workerResourceHolders`
|
|
3
|
-
* reads the row and checkpoints, then these helpers decide whether the generation is gone.
|
|
4
|
-
*/
|
|
5
|
-
import { lstatSync } from 'node:fs';
|
|
6
1
|
import { isCurrentProcess, recordedProcessLive } from '../delegation/process-liveness.js';
|
|
7
2
|
/** The row owns this generation's workspace and the checkpoint is complete, or queued when admitting. */
|
|
8
3
|
export function workerResourceAuthorized(run, proof, id, generation, resourceId, admittingQueued) {
|
|
@@ -10,25 +5,14 @@ export function workerResourceAuthorized(run, proof, id, generation, resourceId,
|
|
|
10
5
|
run.delegation.workspace.resourceId !== resourceId || proof?.generation !== generation ||
|
|
11
6
|
(proof.phase !== 'complete' && !(admittingQueued && proof.phase === 'queued')));
|
|
12
7
|
}
|
|
13
|
-
/**
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
/** Recorded survivors still block reuse when every persistent path is already gone. */
|
|
26
|
-
export function workerResourceAbsentHolders(record) {
|
|
27
|
-
return record === 'absent' ||
|
|
28
|
-
((!recordedProcessLive(record.controller) || isCurrentProcess(record.controller)) && !record.processes.some(recordedProcessLive)) ? 'safe' : [];
|
|
29
|
-
}
|
|
30
|
-
/** Live PIDs that refuse reuse, or `safe` when the generation is gone. */
|
|
31
|
-
export function workerResourceLiveHolders(probe) {
|
|
32
|
-
return probe.liveness === 'gone' ? 'safe' : probe.controller !== undefined ? [probe.controller] : probe.pids;
|
|
8
|
+
/** The live recorded processes of a generation: another live controller, else live session
|
|
9
|
+
* processes. `safe` when none is live, or the generation predates process records. */
|
|
10
|
+
export function recordedHolders(record) {
|
|
11
|
+
if (record === 'absent')
|
|
12
|
+
return 'safe';
|
|
13
|
+
if (!isCurrentProcess(record.controller) && recordedProcessLive(record.controller))
|
|
14
|
+
return [record.controller.pid];
|
|
15
|
+
const pids = record.processes.filter(recordedProcessLive).map(entry => entry.pid);
|
|
16
|
+
return pids.length ? pids : 'safe';
|
|
33
17
|
}
|
|
34
18
|
//# sourceMappingURL=worker-resource-holders.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker-resource-holders.js","sourceRoot":"","sources":["../../src/runs/worker-resource-holders.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"worker-resource-holders.js","sourceRoot":"","sources":["../../src/runs/worker-resource-holders.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAA4B,MAAM,mCAAmC,CAAC;AAKpH,yGAAyG;AACzG,MAAM,UAAU,wBAAwB,CACtC,GAA0B,EAC1B,KAAkC,EAClC,EAAU,EACV,UAAkB,EAClB,UAAkB,EAClB,eAAyB;IAEzB,OAAO,CAAC,CAAC,GAAG,EAAE,UAAU,EAAE,IAAI,KAAK,QAAQ,IAAI,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC,UAAU,KAAK,EAAE;QACvF,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC,UAAU,KAAK,UAAU,IAAI,KAAK,EAAE,UAAU,KAAK,UAAU;QACtF,CAAC,KAAK,CAAC,KAAK,KAAK,UAAU,IAAI,CAAC,CAAC,eAAe,IAAI,KAAK,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC;AACpF,CAAC;AAED;sFACsF;AACtF,MAAM,UAAU,eAAe,CAAC,MAAsC;IACpE,IAAI,MAAM,KAAK,QAAQ;QAAE,OAAO,MAAM,CAAC;IACvC,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,mBAAmB,CAAC,MAAM,CAAC,UAAU,CAAC;QAAE,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;IACnH,MAAM,IAAI,GAAG,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAClF,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC;AACrC,CAAC"}
|
package/dist/server/server.d.ts
CHANGED
|
@@ -8546,6 +8546,10 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
|
|
|
8546
8546
|
summary?: string | undefined;
|
|
8547
8547
|
revision?: number | undefined;
|
|
8548
8548
|
} | undefined;
|
|
8549
|
+
scope?: {
|
|
8550
|
+
backend: "cgroup" | "groups";
|
|
8551
|
+
guarantee: "contained" | "scoped";
|
|
8552
|
+
} | undefined;
|
|
8549
8553
|
}[];
|
|
8550
8554
|
titles?: {
|
|
8551
8555
|
id: string;
|
|
@@ -24351,6 +24355,10 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
|
|
|
24351
24355
|
summary?: string | undefined;
|
|
24352
24356
|
revision?: number | undefined;
|
|
24353
24357
|
} | undefined;
|
|
24358
|
+
scope?: {
|
|
24359
|
+
backend: "cgroup" | "groups";
|
|
24360
|
+
guarantee: "contained" | "scoped";
|
|
24361
|
+
} | undefined;
|
|
24354
24362
|
}[];
|
|
24355
24363
|
titles?: {
|
|
24356
24364
|
id: string;
|
|
@@ -7,6 +7,12 @@ export declare function createWorkspaceLiveRoutes(live: Parameters<typeof create
|
|
|
7
7
|
output: {
|
|
8
8
|
generation: string;
|
|
9
9
|
results: ({
|
|
10
|
+
projectId: string;
|
|
11
|
+
runId: string;
|
|
12
|
+
type: "error" | "reset";
|
|
13
|
+
status: 400 | 404 | 409 | 413 | 503;
|
|
14
|
+
error: string;
|
|
15
|
+
} | {
|
|
10
16
|
projectId: string;
|
|
11
17
|
runId: string;
|
|
12
18
|
type: "batch";
|
|
@@ -20,12 +26,6 @@ export declare function createWorkspaceLiveRoutes(live: Parameters<typeof create
|
|
|
20
26
|
cursor: string;
|
|
21
27
|
afterSeq: number;
|
|
22
28
|
hasMore: boolean;
|
|
23
|
-
} | {
|
|
24
|
-
projectId: string;
|
|
25
|
-
runId: string;
|
|
26
|
-
type: "error" | "reset";
|
|
27
|
-
status: 400 | 404 | 409 | 413 | 503;
|
|
28
|
-
error: string;
|
|
29
29
|
})[];
|
|
30
30
|
};
|
|
31
31
|
outputFormat: "json";
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/** What cgroup operations read and write; tests replace it. */
|
|
2
|
+
export type CgroupFs = {
|
|
3
|
+
readFile: (path: string) => string;
|
|
4
|
+
writeFile: (path: string, data: string) => void;
|
|
5
|
+
mkdir: (path: string) => void;
|
|
6
|
+
rmdir: (path: string) => void;
|
|
7
|
+
/** False only when nothing is there; any other lookup failure throws: it proves no absence. */
|
|
8
|
+
isDir: (path: string) => boolean;
|
|
9
|
+
/** The child cgroups directly under `path`. */
|
|
10
|
+
children: (path: string) => string[];
|
|
11
|
+
};
|
|
12
|
+
export declare const realCgroupFs: CgroupFs;
|
|
13
|
+
/** The cgroup v2 directory this process is in, from `/proc/self/cgroup`. Undefined on cgroup v1,
|
|
14
|
+
* a hybrid host without a unified entry, or a path that leaves the hierarchy. */
|
|
15
|
+
export declare function ownCgroup(fs?: CgroupFs): string | undefined;
|
|
16
|
+
/** The argv that runs `file args` inside the cgroup at `path`. */
|
|
17
|
+
export declare function cgroupCommand(path: string, file: string, args: readonly string[]): [string, string[]];
|
|
18
|
+
/** Whether this host lets the controller create, enter, kill and remove a child cgroup. A writable
|
|
19
|
+
* mount alone is no proof, so the probe does each step for real; any failure answers why. */
|
|
20
|
+
export declare function probeCgroups(fs?: CgroupFs, place?: (procs: string) => boolean): {
|
|
21
|
+
base: string;
|
|
22
|
+
} | {
|
|
23
|
+
reason: string;
|
|
24
|
+
};
|
|
25
|
+
/** Where the worker's cgroup lives under `base`. */
|
|
26
|
+
export declare function workerCgroupPath(base: string, workerId: string): string;
|
|
27
|
+
/** The worker's cgroup under `base`, created when absent. A path that exists as anything but a
|
|
28
|
+
* real directory throws: it is not ours. */
|
|
29
|
+
export declare function ensureCgroup(base: string, workerId: string, fs?: CgroupFs): string;
|
|
30
|
+
/** Whether `path` still holds a process; an absent group holds none. */
|
|
31
|
+
export declare function cgroupPopulated(path: string, fs?: CgroupFs): boolean;
|
|
32
|
+
/** SIGKILL every process in `path` and its descendants now. An absent group is already empty. */
|
|
33
|
+
export declare function killCgroup(path: string, fs?: CgroupFs): void;
|
|
34
|
+
/** Kill, wait until empty, remove; repeated until the group is gone or `deadline` passes. One
|
|
35
|
+
* `cgroup.kill` on the worker's cgroup ends every process in it and in its descendants, and its
|
|
36
|
+
* `populated 0` covers them all; a child cgroup the worker made (threaded ones refuse their own
|
|
37
|
+
* `cgroup.kill`) is then removed depth-first, since the kernel removes only a cgroup without
|
|
38
|
+
* children. A process that placed itself after the kill makes a removal fail with EBUSY, so the
|
|
39
|
+
* round repeats; once the group is removed no process can enter it. True when the group is gone;
|
|
40
|
+
* a lookup that fails for any reason but absence answers false, never success. */
|
|
41
|
+
export declare function removeCgroup(path: string, deadline: number, fs?: CgroupFs): Promise<boolean>;
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/** The Linux `cgroup` backend: one private cgroup v2 child per worker, under the controller's own
|
|
2
|
+
* cgroup. A process places itself before its command runs, so every descendant inherits the
|
|
3
|
+
* group, detached ones too, and `cgroup.kill` ends them all (ADR 0032). */
|
|
4
|
+
import { spawnSync } from 'node:child_process';
|
|
5
|
+
import { randomUUID } from 'node:crypto';
|
|
6
|
+
import { lstatSync, mkdirSync, readdirSync, readFileSync, rmdirSync, writeFileSync } from 'node:fs';
|
|
7
|
+
import { join } from 'node:path';
|
|
8
|
+
const CGROUP_ROOT = '/sys/fs/cgroup';
|
|
9
|
+
const SHELL = '/bin/sh';
|
|
10
|
+
/** `$0` is the target `cgroup.procs`; `0` names the writer, the shell itself, which then becomes
|
|
11
|
+
* the command through `exec` (same pid). A failed move ends the shell before the command runs. */
|
|
12
|
+
const PLACE = 'echo 0 > "$0" && exec "$@"';
|
|
13
|
+
const POLL_MS = 10;
|
|
14
|
+
export const realCgroupFs = {
|
|
15
|
+
readFile: path => readFileSync(path, 'utf8'),
|
|
16
|
+
writeFile: (path, data) => writeFileSync(path, data),
|
|
17
|
+
mkdir: path => mkdirSync(path, { mode: 0o700 }),
|
|
18
|
+
rmdir: path => rmdirSync(path),
|
|
19
|
+
isDir: path => {
|
|
20
|
+
try {
|
|
21
|
+
const s = lstatSync(path);
|
|
22
|
+
return s.isDirectory() && !s.isSymbolicLink();
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
if (code(error) === 'ENOENT')
|
|
26
|
+
return false;
|
|
27
|
+
throw error;
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
children: path => readdirSync(path, { withFileTypes: true }).filter(entry => entry.isDirectory()).map(entry => join(path, entry.name)),
|
|
31
|
+
};
|
|
32
|
+
/** The cgroup v2 directory this process is in, from `/proc/self/cgroup`. Undefined on cgroup v1,
|
|
33
|
+
* a hybrid host without a unified entry, or a path that leaves the hierarchy. */
|
|
34
|
+
export function ownCgroup(fs = realCgroupFs) {
|
|
35
|
+
let text;
|
|
36
|
+
try {
|
|
37
|
+
text = fs.readFile('/proc/self/cgroup');
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
const line = text.split('\n').find(entry => entry.startsWith('0::/'));
|
|
43
|
+
if (!line)
|
|
44
|
+
return undefined;
|
|
45
|
+
const path = line.slice(3).trim();
|
|
46
|
+
if (path.split('/').includes('..'))
|
|
47
|
+
return undefined;
|
|
48
|
+
return path === '/' ? CGROUP_ROOT : join(CGROUP_ROOT, path);
|
|
49
|
+
}
|
|
50
|
+
/** The argv that runs `file args` inside the cgroup at `path`. */
|
|
51
|
+
export function cgroupCommand(path, file, args) {
|
|
52
|
+
return [SHELL, ['-c', PLACE, join(path, 'cgroup.procs'), file, ...args]];
|
|
53
|
+
}
|
|
54
|
+
/** Whether this host lets the controller create, enter, kill and remove a child cgroup. A writable
|
|
55
|
+
* mount alone is no proof, so the probe does each step for real; any failure answers why. */
|
|
56
|
+
export function probeCgroups(fs = realCgroupFs, place = placeProbe) {
|
|
57
|
+
const base = ownCgroup(fs);
|
|
58
|
+
if (!base)
|
|
59
|
+
return { reason: 'no cgroup v2 entry in /proc/self/cgroup' };
|
|
60
|
+
const probe = join(base, `squawk-probe-${randomUUID()}`);
|
|
61
|
+
try {
|
|
62
|
+
fs.mkdir(probe);
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
return { reason: `cannot create a child cgroup (${code(error)})` };
|
|
66
|
+
}
|
|
67
|
+
let failure;
|
|
68
|
+
try {
|
|
69
|
+
if (!place(join(probe, 'cgroup.procs')))
|
|
70
|
+
failure = 'cannot move a process into a child cgroup';
|
|
71
|
+
else
|
|
72
|
+
fs.writeFile(join(probe, 'cgroup.kill'), '1');
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
failure = `cannot kill a child cgroup (${code(error)})`;
|
|
76
|
+
}
|
|
77
|
+
// Removal is part of the proof: a host that cannot remove a worker's cgroup cannot destroy it.
|
|
78
|
+
try {
|
|
79
|
+
fs.rmdir(probe);
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
failure ??= `cannot remove a child cgroup (${code(error)})`;
|
|
83
|
+
}
|
|
84
|
+
return failure ? { reason: failure } : { base };
|
|
85
|
+
}
|
|
86
|
+
/** A shell moves itself into the probe group and exits; exit 0 means the move worked. */
|
|
87
|
+
function placeProbe(procs) {
|
|
88
|
+
const result = spawnSync(SHELL, ['-c', 'echo 0 > "$0"', procs], { stdio: 'ignore', timeout: 5_000 });
|
|
89
|
+
return result.status === 0;
|
|
90
|
+
}
|
|
91
|
+
const code = (error) => error.code ?? String(error);
|
|
92
|
+
/** Where the worker's cgroup lives under `base`. */
|
|
93
|
+
export function workerCgroupPath(base, workerId) {
|
|
94
|
+
return join(base, `squawk-worker-${workerId}`);
|
|
95
|
+
}
|
|
96
|
+
/** The worker's cgroup under `base`, created when absent. A path that exists as anything but a
|
|
97
|
+
* real directory throws: it is not ours. */
|
|
98
|
+
export function ensureCgroup(base, workerId, fs = realCgroupFs) {
|
|
99
|
+
const path = workerCgroupPath(base, workerId);
|
|
100
|
+
if (fs.isDir(path))
|
|
101
|
+
return path;
|
|
102
|
+
fs.mkdir(path);
|
|
103
|
+
return path;
|
|
104
|
+
}
|
|
105
|
+
/** Whether `path` still holds a process; an absent group holds none. */
|
|
106
|
+
export function cgroupPopulated(path, fs = realCgroupFs) {
|
|
107
|
+
let events;
|
|
108
|
+
try {
|
|
109
|
+
events = fs.readFile(join(path, 'cgroup.events'));
|
|
110
|
+
}
|
|
111
|
+
catch (error) {
|
|
112
|
+
if (code(error) === 'ENOENT')
|
|
113
|
+
return false;
|
|
114
|
+
throw error;
|
|
115
|
+
}
|
|
116
|
+
return /(?:^|\n)populated 1(?:\n|$)/.test(events);
|
|
117
|
+
}
|
|
118
|
+
/** SIGKILL every process in `path` and its descendants now. An absent group is already empty. */
|
|
119
|
+
export function killCgroup(path, fs = realCgroupFs) {
|
|
120
|
+
try {
|
|
121
|
+
fs.writeFile(join(path, 'cgroup.kill'), '1');
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
if (code(error) !== 'ENOENT')
|
|
125
|
+
throw error;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
/** Kill, wait until empty, remove; repeated until the group is gone or `deadline` passes. One
|
|
129
|
+
* `cgroup.kill` on the worker's cgroup ends every process in it and in its descendants, and its
|
|
130
|
+
* `populated 0` covers them all; a child cgroup the worker made (threaded ones refuse their own
|
|
131
|
+
* `cgroup.kill`) is then removed depth-first, since the kernel removes only a cgroup without
|
|
132
|
+
* children. A process that placed itself after the kill makes a removal fail with EBUSY, so the
|
|
133
|
+
* round repeats; once the group is removed no process can enter it. True when the group is gone;
|
|
134
|
+
* a lookup that fails for any reason but absence answers false, never success. */
|
|
135
|
+
export async function removeCgroup(path, deadline, fs = realCgroupFs) {
|
|
136
|
+
try {
|
|
137
|
+
for (;;) {
|
|
138
|
+
if (!fs.isDir(path))
|
|
139
|
+
return true;
|
|
140
|
+
killCgroup(path, fs);
|
|
141
|
+
while (cgroupPopulated(path, fs) && Date.now() < deadline)
|
|
142
|
+
await sleep(POLL_MS);
|
|
143
|
+
const removed = removeTree(path, fs);
|
|
144
|
+
if (removed === true)
|
|
145
|
+
return true;
|
|
146
|
+
if (removed === 'fatal' || Date.now() >= deadline)
|
|
147
|
+
return false;
|
|
148
|
+
await sleep(POLL_MS);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
catch {
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
/** Removes `path` and its child cgroups, deepest first. `busy` when a cgroup still holds a process. */
|
|
156
|
+
function removeTree(path, fs) {
|
|
157
|
+
for (const child of fs.children(path)) {
|
|
158
|
+
const removed = removeTree(child, fs);
|
|
159
|
+
if (removed !== true)
|
|
160
|
+
return removed;
|
|
161
|
+
}
|
|
162
|
+
try {
|
|
163
|
+
fs.rmdir(path);
|
|
164
|
+
return true;
|
|
165
|
+
}
|
|
166
|
+
catch (error) {
|
|
167
|
+
if (code(error) === 'ENOENT')
|
|
168
|
+
return true;
|
|
169
|
+
return code(error) === 'EBUSY' ? 'busy' : 'fatal';
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
|
|
173
|
+
//# sourceMappingURL=cgroup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cgroup.js","sourceRoot":"","sources":["../../src/worker-scope/cgroup.ts"],"names":[],"mappings":"AAAA;;2EAE2E;AAC3E,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,SAAS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AI,CAAC;IAAC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAClD,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,QAAQ;YAAE,OAAO,IAAI,CAAC;QAC1C,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC;IACpD,CAAC;AACH,CAAC;AAED,MAAM,KAAK,GAAG,CAAC,EAAU,EAAE,EAAE,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type RecordedProcess } from '../core/process-stat.ts';
|
|
2
|
+
/** A group leader at spawn: its pid is its group id. */
|
|
3
|
+
export declare function groupEntry(pid: number): RecordedProcess;
|
|
4
|
+
/** Whether the recorded group is the one Squawk started. A live leader must be the recorded
|
|
5
|
+
* incarnation. A group whose leader is gone keeps its number while it has members, and the kernel
|
|
6
|
+
* does not reuse a pid while a group of that number exists; a reused number needs the group to
|
|
7
|
+
* empty first. So a leaderless group counts only where the record proves this boot: on Linux the
|
|
8
|
+
* start token carries the boot id, and a token from another boot (or none) is refused. The
|
|
9
|
+
* remaining case, the pid space wrapping within one boot while the worker lives, is ADR 0032's
|
|
10
|
+
* stated residual. Elsewhere (macOS: no boot id, a small pid space) a leaderless group is never
|
|
11
|
+
* signalled. */
|
|
12
|
+
export declare function groupOwned(entry: RecordedProcess): boolean;
|
|
13
|
+
/** SIGKILL every recorded group that is still ours, and every recorded process outside a group
|
|
14
|
+
* that is still the recorded incarnation. */
|
|
15
|
+
export declare function killGroups(entries: readonly RecordedProcess[]): void;
|
|
16
|
+
/** After a SIGKILL to the whole group, the recorded entries that still have a running process: a
|
|
17
|
+
* leader that is still the recorded incarnation, or, for a group of ours whose leader is gone, a
|
|
18
|
+
* running member (a zombie whose other threads run counts: they still hold its sockets). A SIGKILL takes effect asynchronously, so a member can still hold a
|
|
19
|
+
* port for a moment; a group of zombies still answers `kill(-pgid, 0)` until its reaper reaps it,
|
|
20
|
+
* which an init that does not reap never does, so zombies are never waited for. */
|
|
21
|
+
export declare function groupsStillStopping(entries: readonly RecordedProcess[]): RecordedProcess[];
|
|
22
|
+
/** The recorded groups that are still ours and have a member, and the recorded processes outside
|
|
23
|
+
* a group that are still the recorded incarnation. */
|
|
24
|
+
export declare function liveGroups(entries: readonly RecordedProcess[]): RecordedProcess[];
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/** The `groups` backend: the worker's recorded POSIX process groups. A process that leaves its group
|
|
2
|
+
* (`setsid`, Node `detached`) is outside it; ADR 0032 states that limit. */
|
|
3
|
+
import { processGroupAlive, processGroupRunning, signalProcessGroup } from '../core/session-process.js';
|
|
4
|
+
import { linuxBootId, pidExists, processStartToken } from '../core/process-stat.js';
|
|
5
|
+
/** A group leader at spawn: its pid is its group id. */
|
|
6
|
+
export function groupEntry(pid) {
|
|
7
|
+
const startToken = processStartToken(pid);
|
|
8
|
+
return { pid, pgid: pid, ...(startToken === undefined ? {} : { startToken }) };
|
|
9
|
+
}
|
|
10
|
+
/** Whether the recorded group is the one Squawk started. A live leader must be the recorded
|
|
11
|
+
* incarnation. A group whose leader is gone keeps its number while it has members, and the kernel
|
|
12
|
+
* does not reuse a pid while a group of that number exists; a reused number needs the group to
|
|
13
|
+
* empty first. So a leaderless group counts only where the record proves this boot: on Linux the
|
|
14
|
+
* start token carries the boot id, and a token from another boot (or none) is refused. The
|
|
15
|
+
* remaining case, the pid space wrapping within one boot while the worker lives, is ADR 0032's
|
|
16
|
+
* stated residual. Elsewhere (macOS: no boot id, a small pid space) a leaderless group is never
|
|
17
|
+
* signalled. */
|
|
18
|
+
export function groupOwned(entry) {
|
|
19
|
+
if (entry.pgid === undefined || entry.pgid !== entry.pid || entry.startToken === undefined || !processGroupAlive(entry.pgid))
|
|
20
|
+
return false;
|
|
21
|
+
if (pidExists(entry.pid))
|
|
22
|
+
return processStartToken(entry.pid) === entry.startToken;
|
|
23
|
+
const boot = process.platform === 'linux' ? linuxBootId() : undefined;
|
|
24
|
+
return boot !== undefined && entry.startToken.startsWith(`${boot}:`);
|
|
25
|
+
}
|
|
26
|
+
/** SIGKILL every recorded group that is still ours, and every recorded process outside a group
|
|
27
|
+
* that is still the recorded incarnation. */
|
|
28
|
+
export function killGroups(entries) {
|
|
29
|
+
for (const entry of entries) {
|
|
30
|
+
if (entry.pgid !== undefined) {
|
|
31
|
+
if (groupOwned(entry))
|
|
32
|
+
signalProcessGroup(entry.pgid, 'SIGKILL');
|
|
33
|
+
}
|
|
34
|
+
else if (entry.startToken !== undefined && processStartToken(entry.pid) === entry.startToken) {
|
|
35
|
+
try {
|
|
36
|
+
process.kill(entry.pid, 'SIGKILL');
|
|
37
|
+
}
|
|
38
|
+
catch { /* already gone */ }
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/** After a SIGKILL to the whole group, the recorded entries that still have a running process: a
|
|
43
|
+
* leader that is still the recorded incarnation, or, for a group of ours whose leader is gone, a
|
|
44
|
+
* running member (a zombie whose other threads run counts: they still hold its sockets). A SIGKILL takes effect asynchronously, so a member can still hold a
|
|
45
|
+
* port for a moment; a group of zombies still answers `kill(-pgid, 0)` until its reaper reaps it,
|
|
46
|
+
* which an init that does not reap never does, so zombies are never waited for. */
|
|
47
|
+
export function groupsStillStopping(entries) {
|
|
48
|
+
return entries.filter(entry => {
|
|
49
|
+
if (entry.startToken !== undefined && pidExists(entry.pid) && processStartToken(entry.pid) === entry.startToken)
|
|
50
|
+
return true;
|
|
51
|
+
return entry.pgid !== undefined && groupOwned(entry) && processGroupRunning(entry.pgid);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
/** The recorded groups that are still ours and have a member, and the recorded processes outside
|
|
55
|
+
* a group that are still the recorded incarnation. */
|
|
56
|
+
export function liveGroups(entries) {
|
|
57
|
+
return entries.filter(entry => entry.pgid !== undefined ? groupOwned(entry)
|
|
58
|
+
: entry.startToken !== undefined && pidExists(entry.pid) && processStartToken(entry.pid) === entry.startToken);
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=groups.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"groups.js","sourceRoot":"","sources":["../../src/worker-scope/groups.ts"],"names":[],"mappings":"AAAA;4EAC4E;AAC5E,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AACxG,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,iBAAiB,EAAwB,MAAM,yBAAyB,CAAC;AAE1G,wDAAwD;AACxD,MAAM,UAAU,UAAU,CAAC,GAAW;IACpC,MAAM,UAAU,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC;IAC1C,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC;AACjF,CAAC;AAED;;;;;;;gBAOgB;AAChB,MAAM,UAAU,UAAU,CAAC,KAAsB;IAC/C,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,IAAI,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,GAAG,IAAI,KAAK,CAAC,UAAU,KAAK,SAAS,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,IAAI,CAAC;QAAE,OAAO,KAAK,CAAC;IAC3I,IAAI,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC;QAAE,OAAO,iBAAiB,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,KAAK,CAAC,UAAU,CAAC;IACnF,MAAM,IAAI,GAAG,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;IACtE,OAAO,IAAI,KAA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,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC;QACzE,CAAC,CAAC,KAAK,CAAC,UAAU,KAAK,SAAS,IAAI,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,iBAAiB,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,KAAK,CAAC,UAAU,CAAC,CAAC;AACnH,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** What a worker scope is: the set of OS containers that hold every process Squawk starts for one
|
|
2
|
+
* worker, and the record that names them. ADR 0032. */
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
/** How a host contains a worker. `cgroup`: a private Linux cgroup, which every descendant inherits.
|
|
5
|
+
* `groups`: the worker's own POSIX process groups, which a detached descendant can leave. */
|
|
6
|
+
export type ScopeBackend = 'cgroup' | 'groups';
|
|
7
|
+
/** `contained`: stopping the scope ends every descendant. `scoped`: it ends the recorded groups
|
|
8
|
+
* only; a descendant that left them survives. */
|
|
9
|
+
export type ScopeGuarantee = 'contained' | 'scoped';
|
|
10
|
+
export declare const GUARANTEE: Readonly<Record<ScopeBackend, ScopeGuarantee>>;
|
|
11
|
+
/** Recorded groups kept per worker. A dead group is dropped before a new one is added. */
|
|
12
|
+
export declare const SCOPE_GROUP_CAP = 64;
|
|
13
|
+
/** Recorded cgroups kept per worker: one per controller cgroup it was spawned from. */
|
|
14
|
+
export declare const SCOPE_CGROUP_CAP = 8;
|
|
15
|
+
/** Everything one worker owns. It holds both kinds, so a worker started under one backend and
|
|
16
|
+
* continued under another (a controller restarted elsewhere) is stopped whole. */
|
|
17
|
+
export declare const scopeRecordSchema: z.ZodObject<{
|
|
18
|
+
workerId: z.ZodString;
|
|
19
|
+
cgroups: z.ZodArray<z.ZodString>;
|
|
20
|
+
groups: z.ZodArray<z.ZodObject<{
|
|
21
|
+
pid: z.ZodNumber;
|
|
22
|
+
startToken: z.ZodOptional<z.ZodString>;
|
|
23
|
+
pgid: z.ZodOptional<z.ZodNumber>;
|
|
24
|
+
}, z.core.$strict>>;
|
|
25
|
+
}, z.core.$strict>;
|
|
26
|
+
export type ScopeRecord = z.infer<typeof scopeRecordSchema>;
|
|
27
|
+
/** What a spawn site needs: the argv that runs a command inside the scope, and a report of the
|
|
28
|
+
* process it started. `command` may throw; the caller then starts nothing. */
|
|
29
|
+
export interface SpawnScope {
|
|
30
|
+
command(file: string, args: readonly string[]): [string, string[]];
|
|
31
|
+
started(pid: number): void;
|
|
32
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** What a worker scope is: the set of OS containers that hold every process Squawk starts for one
|
|
2
|
+
* worker, and the record that names them. ADR 0032. */
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
export const GUARANTEE = { cgroup: 'contained', groups: 'scoped' };
|
|
5
|
+
/** Recorded groups kept per worker. A dead group is dropped before a new one is added. */
|
|
6
|
+
export const SCOPE_GROUP_CAP = 64;
|
|
7
|
+
/** Recorded cgroups kept per worker: one per controller cgroup it was spawned from. */
|
|
8
|
+
export const SCOPE_CGROUP_CAP = 8;
|
|
9
|
+
const recordedGroupSchema = z.object({ pid: z.number().int().positive(), startToken: z.string().min(1).max(128).optional(),
|
|
10
|
+
pgid: z.number().int().positive().optional() }).strict();
|
|
11
|
+
/** Everything one worker owns. It holds both kinds, so a worker started under one backend and
|
|
12
|
+
* continued under another (a controller restarted elsewhere) is stopped whole. */
|
|
13
|
+
export const scopeRecordSchema = z.object({
|
|
14
|
+
workerId: z.string().uuid(),
|
|
15
|
+
cgroups: z.array(z.string().startsWith('/sys/fs/cgroup/').max(4096)).max(SCOPE_CGROUP_CAP),
|
|
16
|
+
groups: z.array(recordedGroupSchema).max(SCOPE_GROUP_CAP),
|
|
17
|
+
}).strict();
|
|
18
|
+
//# sourceMappingURL=scope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scope.js","sourceRoot":"","sources":["../../src/worker-scope/scope.ts"],"names":[],"mapp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3
|
+
import { type ScopeBackend, type ScopeGuarantee, type ScopeRecord, type SpawnScope } from './scope.ts';
|
|
4
|
+
export type HostScope = {
|
|
5
|
+
backend: 'cgroup';
|
|
6
|
+
base: string;
|
|
7
|
+
} | {
|
|
8
|
+
backend: 'groups';
|
|
9
|
+
reason: string;
|
|
10
|
+
};
|
|
11
|
+
/** This controller's backend: `cgroup` where a real probe proves delegation, else `groups`. */
|
|
12
|
+
export declare function hostScope(): HostScope;
|
|
13
|
+
/** Tests pin the backend; `undefined` re-probes on next use. */
|
|
14
|
+
export declare function setHostScope(value: HostScope | undefined): void;
|
|
15
|
+
/** The store operations a scope needs. */
|
|
16
|
+
export interface ScopeStore {
|
|
17
|
+
readWorkerScope(id: string): ScopeRecord | 'absent' | 'unknown';
|
|
18
|
+
writeWorkerScope(id: string, record: ScopeRecord): void;
|
|
19
|
+
getRun(id: string): RunRecord | undefined;
|
|
20
|
+
readWorkerExecution(id: string): {
|
|
21
|
+
generation: string;
|
|
22
|
+
} | undefined;
|
|
23
|
+
readWorkerProcesses(id: string, generation: string): WorkerProcessRecord | 'absent' | 'unknown';
|
|
24
|
+
}
|
|
25
|
+
export declare class WorkerScopeUnreadable extends Error {
|
|
26
|
+
constructor();
|
|
27
|
+
}
|
|
28
|
+
export type ScopeStop = {
|
|
29
|
+
stopped: true;
|
|
30
|
+
} | {
|
|
31
|
+
stopped: false;
|
|
32
|
+
error: string;
|
|
33
|
+
};
|
|
34
|
+
export declare class WorkerScopes {
|
|
35
|
+
private readonly store;
|
|
36
|
+
private readonly hostOf;
|
|
37
|
+
constructor(store: ScopeStore, hostOf?: () => HostScope);
|
|
38
|
+
describe(): {
|
|
39
|
+
backend: ScopeBackend;
|
|
40
|
+
guarantee: ScopeGuarantee;
|
|
41
|
+
};
|
|
42
|
+
/** The scope every process of `workerId` starts in. The record names a cgroup before the cgroup
|
|
43
|
+
* exists and before anything enters it, so a crash at any point leaves nothing unrecorded. */
|
|
44
|
+
spawnScope(workerId: string): SpawnScope;
|
|
45
|
+
/** Whether no process the worker owns still runs: its cgroups are unpopulated and none of its
|
|
46
|
+
* recorded groups has a member. An unreadable record is not empty. */
|
|
47
|
+
empty(workerId: string): boolean;
|
|
48
|
+
/** After `kill`: whether nothing the worker owned still runs. A cgroup drops a task when it exits,
|
|
49
|
+
* zombie or not; a group counts while its recorded leader runs (see `groupsStillStopping`). */
|
|
50
|
+
stopped(workerId: string): boolean;
|
|
51
|
+
/** SIGKILL everything the worker owns, now, without waiting. */
|
|
52
|
+
kill(workerId: string): void;
|
|
53
|
+
/** End everything the worker owns and remove its cgroups, within `timeoutMs`. What could not be
|
|
54
|
+
* stopped stays recorded, so a retry starts from it. */
|
|
55
|
+
stop(workerId: string, timeoutMs: number): Promise<ScopeStop>;
|
|
56
|
+
/** One kill-and-wait over the record as read now; `late` when the record gained entries meanwhile. */
|
|
57
|
+
private stopRound;
|
|
58
|
+
private read;
|
|
59
|
+
/** The record's groups and the current execution's recorded processes, without duplicates. A
|
|
60
|
+
* worker created before scopes has its session groups only in its execution record. */
|
|
61
|
+
private groups;
|
|
62
|
+
private update;
|
|
63
|
+
}
|