@hearsay-tools/squawk 0.18.0-dev.6807 → 0.18.0-dev.6821

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.
Files changed (155) hide show
  1. package/dist/ci-wait/controller.d.ts +4 -4
  2. package/dist/contract/delegation.d.ts +20 -0
  3. package/dist/contract/index.js +4 -1
  4. package/dist/core/agent-runner.d.ts +16 -0
  5. package/dist/core/agent-runner.js +7 -0
  6. package/dist/core/agent-runner.js.map +1 -1
  7. package/dist/core/claude-cli-runner.js +3 -2
  8. package/dist/core/claude-cli-runner.js.map +1 -1
  9. package/dist/core/codex-app-server-runner.js +3 -3
  10. package/dist/core/codex-app-server-runner.js.map +1 -1
  11. package/dist/core/codex-app-server-transport.d.ts +2 -0
  12. package/dist/core/codex-app-server-transport.js +1 -1
  13. package/dist/core/codex-app-server-transport.js.map +1 -1
  14. package/dist/core/cursor-print-process.d.ts +3 -0
  15. package/dist/core/cursor-print-process.js +1 -1
  16. package/dist/core/cursor-print-process.js.map +1 -1
  17. package/dist/core/cursor-print-runner.js +3 -2
  18. package/dist/core/cursor-print-runner.js.map +1 -1
  19. package/dist/core/omp-runner.js +3 -1
  20. package/dist/core/omp-runner.js.map +1 -1
  21. package/dist/core/opencode-server-runner.js +3 -3
  22. package/dist/core/opencode-server-runner.js.map +1 -1
  23. package/dist/core/pi-runner.js +3 -2
  24. package/dist/core/pi-runner.js.map +1 -1
  25. package/dist/core/session-process.d.ts +6 -0
  26. package/dist/core/session-process.js +53 -2
  27. package/dist/core/session-process.js.map +1 -1
  28. package/dist/delegation/family-end.js +2 -4
  29. package/dist/delegation/family-end.js.map +1 -1
  30. package/dist/delegation/owned-workspace-release.d.ts +1 -2
  31. package/dist/delegation/owned-workspace-release.js +2 -2
  32. package/dist/delegation/owned-workspace-release.js.map +1 -1
  33. package/dist/delegation/process-liveness.d.ts +8 -58
  34. package/dist/delegation/process-liveness.js +9 -86
  35. package/dist/delegation/process-liveness.js.map +1 -1
  36. package/dist/delegation/routes.d.ts +25 -21
  37. package/dist/delegation/scratch-cleanup.d.ts +1 -1
  38. package/dist/delegation/scratch-cleanup.js +7 -10
  39. package/dist/delegation/scratch-cleanup.js.map +1 -1
  40. package/dist/delegation/service.js +2 -1
  41. package/dist/delegation/service.js.map +1 -1
  42. package/dist/delegation/transport.d.ts +20 -16
  43. package/dist/delegation/worker-cleanup.d.ts +2 -9
  44. package/dist/delegation/worker-cleanup.js +44 -86
  45. package/dist/delegation/worker-cleanup.js.map +1 -1
  46. package/dist/delegation/workspace-removal.d.ts +4 -12
  47. package/dist/delegation/workspace-removal.js +18 -51
  48. package/dist/delegation/workspace-removal.js.map +1 -1
  49. package/dist/git-worktree.js +2 -6
  50. package/dist/git-worktree.js.map +1 -1
  51. package/dist/preview/dev-server.d.ts +3 -0
  52. package/dist/preview/dev-server.js +40 -1
  53. package/dist/preview/dev-server.js.map +1 -1
  54. package/dist/preview/host.d.ts +3 -1
  55. package/dist/preview/host.js +2 -1
  56. package/dist/preview/host.js.map +1 -1
  57. package/dist/runs/private-record-file.d.ts +7 -0
  58. package/dist/runs/private-record-file.js +55 -0
  59. package/dist/runs/private-record-file.js.map +1 -0
  60. package/dist/runs/store.d.ts +18 -6
  61. package/dist/runs/store.js +43 -99
  62. package/dist/runs/store.js.map +1 -1
  63. package/dist/runs/worker-execution.d.ts +1 -0
  64. package/dist/runs/worker-execution.js +4 -1
  65. package/dist/runs/worker-execution.js.map +1 -1
  66. package/dist/runs/worker-resource-holders.d.ts +10 -7
  67. package/dist/runs/worker-resource-holders.js +9 -25
  68. package/dist/runs/worker-resource-holders.js.map +1 -1
  69. package/dist/server/server.d.ts +66 -58
  70. package/dist/server/workspace-live-routes.d.ts +6 -6
  71. package/dist/worker-scope/cgroup.d.ts +41 -0
  72. package/dist/worker-scope/cgroup.js +173 -0
  73. package/dist/worker-scope/cgroup.js.map +1 -0
  74. package/dist/worker-scope/groups.d.ts +24 -0
  75. package/dist/worker-scope/groups.js +60 -0
  76. package/dist/worker-scope/groups.js.map +1 -0
  77. package/dist/worker-scope/scope.d.ts +32 -0
  78. package/dist/worker-scope/scope.js +18 -0
  79. package/dist/worker-scope/scope.js.map +1 -0
  80. package/dist/worker-scope/worker-scopes.d.ts +63 -0
  81. package/dist/worker-scope/worker-scopes.js +181 -0
  82. package/dist/worker-scope/worker-scopes.js.map +1 -0
  83. package/dist/workflows/grouped-command.d.ts +3 -0
  84. package/dist/workflows/grouped-command.js +28 -2
  85. package/dist/workflows/grouped-command.js.map +1 -1
  86. package/dist/workflows/run/compose.d.ts +0 -2
  87. package/dist/workflows/run/compose.js.map +1 -1
  88. package/dist/workflows/run/continuation-session.js +1 -0
  89. package/dist/workflows/run/continuation-session.js.map +1 -1
  90. package/dist/workflows/run/input-delivery.d.ts +13 -3
  91. package/dist/workflows/run/input-delivery.js +26 -6
  92. package/dist/workflows/run/input-delivery.js.map +1 -1
  93. package/dist/workflows/run/step-loop.d.ts +1 -1
  94. package/dist/workflows/run/step-loop.js +4 -2
  95. package/dist/workflows/run/step-loop.js.map +1 -1
  96. package/dist/workflows/run/step-session.js +1 -0
  97. package/dist/workflows/run/step-session.js.map +1 -1
  98. package/dist/workflows/run/worker-executions.d.ts +2 -1
  99. package/dist/workflows/run/worker-executions.js +8 -4
  100. package/dist/workflows/run/worker-executions.js.map +1 -1
  101. package/dist/workflows/run/worker-orphans.d.ts +16 -31
  102. package/dist/workflows/run/worker-orphans.js +71 -123
  103. package/dist/workflows/run/worker-orphans.js.map +1 -1
  104. package/dist/workflows/run.d.ts +0 -2
  105. package/dist/workflows/run.js +1 -4
  106. package/dist/workflows/run.js.map +1 -1
  107. package/dist/worktree-setup.d.ts +3 -0
  108. package/dist/worktree-setup.js +2 -1
  109. package/dist/worktree-setup.js.map +1 -1
  110. package/package.json +4 -4
  111. package/web/dist/assets/{activity-motion-ankV4z_y.js → activity-motion-AuQA350-.js} +1 -1
  112. package/web/dist/assets/{activity-route-C7Lo4d_1.js → activity-route-BNZ9bOOZ.js} +1 -1
  113. package/web/dist/assets/{agent-accounts-BAUPVmTO.js → agent-accounts-D2uZHuiM.js} +1 -1
  114. package/web/dist/assets/attention-B7icDSLh.js +1 -0
  115. package/web/dist/assets/{cez-idle-TVRD1sce.js → cez-idle-MToU9Wv_.js} +1 -1
  116. package/web/dist/assets/{commit-diff-panel-Cmqi-EvU.js → commit-diff-panel-DBW7us79.js} +1 -1
  117. package/web/dist/assets/{diff-BawymO3F.js → diff-C3Cms5Ep.js} +2 -2
  118. package/web/dist/assets/{diff-view-DHx_pu8b.js → diff-view-D5zTYOKV.js} +1 -1
  119. package/web/dist/assets/{file-preview-DV7f2pOk.js → file-preview-FhzIdXZ3.js} +1 -1
  120. package/web/dist/assets/{git-toolbar-BrVfyYBr.js → git-toolbar-MFjkjDDG.js} +1 -1
  121. package/web/dist/assets/{github-DVXWmfeu.js → github-CYmdc5Dh.js} +1 -1
  122. package/web/dist/assets/{global-activity-route-ybR1xgLf.js → global-activity-route-C41ofuHV.js} +1 -1
  123. package/web/dist/assets/{index-Dc_KmL4Z.js → index-e1OpsDKN.js} +4 -4
  124. package/web/dist/assets/{live-protocol-aMLJJ0MQ.js → live-protocol-B8boP96Z.js} +1 -1
  125. package/web/dist/assets/{preview-pane-connected-CT7tXifI.js → preview-pane-connected-Ds209_UZ.js} +1 -1
  126. package/web/dist/assets/{project-router-CbWELZZ9.js → project-router-F1inY-EB.js} +1 -1
  127. package/web/dist/assets/{project-scope-context-p1OpXpSJ.js → project-scope-context-0Z0nsheq.js} +1 -1
  128. package/web/dist/assets/{prompt-template-menu-Ct3m86h1.js → prompt-template-menu-uUjg9v98.js} +1 -1
  129. package/web/dist/assets/{queries-BAUtqJph.js → queries-7W9tOZsg.js} +1 -1
  130. package/web/dist/assets/{reference-chip-B2B-Ky7w.js → reference-chip-BqRpnpaI.js} +1 -1
  131. package/web/dist/assets/{repo-git-DRONt4_i.js → repo-git-BZcRanYE.js} +1 -1
  132. package/web/dist/assets/{report-reader-BF8rmJRD.js → report-reader-BLlV3dPF.js} +1 -1
  133. package/web/dist/assets/{reports-Bv91XlcP.js → reports-C--EXqf1.js} +1 -1
  134. package/web/dist/assets/{run-header-CvJ84kr2.js → run-header-CJg8dyfz.js} +1 -1
  135. package/web/dist/assets/{skills-Ceg2Y9LM.js → skills-CHWVejdV.js} +1 -1
  136. package/web/dist/assets/{tab-link-CT5gqdai.js → tab-link-XI9xWLwR.js} +1 -1
  137. package/web/dist/assets/{task-changes-BplRsiSs.js → task-changes-DFm_EHnj.js} +1 -1
  138. package/web/dist/assets/{task-commits-CYLy-lg-.js → task-commits-BX-GVdXG.js} +1 -1
  139. package/web/dist/assets/{task-files-COYxL8mg.js → task-files-Dsn11PYu.js} +1 -1
  140. package/web/dist/assets/{task-github-item-DAD__wEa.js → task-github-item-3N6jEijR.js} +1 -1
  141. package/web/dist/assets/{task-thread-CTEobEyX.js → task-thread-VNPhkI8i.js} +1 -1
  142. package/web/dist/assets/{thread-state-CpdUCQVd.js → thread-state-D1XLo7ab.js} +1 -1
  143. package/web/dist/assets/{use-desktop-Bok38AjX.js → use-desktop-DdcA0Atl.js} +1 -1
  144. package/web/dist/assets/{use-hand-to-agent-state-DiBEjj2Y.js → use-hand-to-agent-state-2tzEmCDo.js} +1 -1
  145. package/web/dist/assets/{useInfiniteQuery-DD7iZHIJ.js → useInfiniteQuery-BmmIZbVY.js} +1 -1
  146. package/web/dist/assets/useQuery-CBKC2lBX.js +1 -0
  147. package/web/dist/assets/{workflows-Cq6Fg1ZT.js → workflows-CqqdPBFr.js} +1 -1
  148. package/web/dist/assets/{ws-CqtLOaJ8.js → ws-BvDSfSVH.js} +1 -1
  149. package/web/dist/index.html +14 -14
  150. package/web/dist/live-worker.js +1 -1
  151. package/dist/delegation/destroy-observation.d.ts +0 -44
  152. package/dist/delegation/destroy-observation.js +0 -116
  153. package/dist/delegation/destroy-observation.js.map +0 -1
  154. package/web/dist/assets/attention-C6XIgMqB.js +0 -1
  155. package/web/dist/assets/useQuery-DVAeyc_X.js +0 -1
@@ -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,UA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O,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;QAC5B,IAAI,KAAK,CAAC,UAAU,KAAK,SAAS,IAAI,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,iBAAiB,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,KAAK,CAAC,UAAU;YAAE,OAAO,IAAI,CAAC;QAC7H,OAAO,KAAK,CAAC,IAAI,KAAK,SAAS,IAAI,UAAU,CAAC,KAAK,CAAC,IAAI,mBAAmB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC1F,CAAC,CAAC,CAAC;AACL,CAAC;AAED;sDACsD;AACtD,MAAM,UAAU,UAAU,CAAC,OAAmC;IAC5D,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,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
+ //# sour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 @@
1
+ import type { RunRecord } from '../contract/index.js';
2
+ import type { WorkerProcessRecord } from '../delegation/process-liveness.ts';
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
+ }
@@ -0,0 +1,181 @@
1
+ /** The one place lifecycle code reaches a worker's scope: spawn sites wrap their command through
2
+ * `spawnScope`, Continue after a crash calls `kill`, destroy calls `stop`. The host's backend is
3
+ * picked once per controller and never changes inside it; a backend error fails the operation
4
+ * that met it, never falls back to another mechanism (ADR 0032). */
5
+ import { logPrefix } from '../home/display.js';
6
+ import { cgroupCommand, cgroupPopulated, ensureCgroup, killCgroup, probeCgroups, removeCgroup, workerCgroupPath } from './cgroup.js';
7
+ import { groupEntry, groupsStillStopping, killGroups, liveGroups } from './groups.js';
8
+ import { GUARANTEE, SCOPE_CGROUP_CAP, SCOPE_GROUP_CAP } from './scope.js';
9
+ let host;
10
+ /** This controller's backend: `cgroup` where a real probe proves delegation, else `groups`. */
11
+ export function hostScope() {
12
+ if (host)
13
+ return host;
14
+ const probe = process.platform === 'linux' ? probeCgroups() : { reason: `${process.platform} has no cgroups` };
15
+ host = 'base' in probe ? { backend: 'cgroup', base: probe.base } : { backend: 'groups', reason: probe.reason };
16
+ console.info(`${logPrefix()} worker scope: ${host.backend === 'cgroup' ? `cgroup (contained) under ${host.base}`
17
+ : `process groups (scoped: a detached descendant can outlive destroy) — ${host.reason}`}`);
18
+ return host;
19
+ }
20
+ /** Tests pin the backend; `undefined` re-probes on next use. */
21
+ export function setHostScope(value) { host = value; }
22
+ export class WorkerScopeUnreadable extends Error {
23
+ constructor() { super("the worker's scope record is unreadable; its processes cannot be found"); }
24
+ }
25
+ const key = (entry) => `${entry.pid}:${entry.startToken}`;
26
+ const capacityError = (workerId) => new Error(`worker ${workerId} already owns ${SCOPE_GROUP_CAP} live process groups`);
27
+ const STOP_POLL_MS = 10;
28
+ export class WorkerScopes {
29
+ store;
30
+ hostOf;
31
+ constructor(store, hostOf = hostScope) {
32
+ this.store = store;
33
+ this.hostOf = hostOf;
34
+ }
35
+ describe() {
36
+ const { backend } = this.hostOf();
37
+ return { backend, guarantee: GUARANTEE[backend] };
38
+ }
39
+ /** The scope every process of `workerId` starts in. The record names a cgroup before the cgroup
40
+ * exists and before anything enters it, so a crash at any point leaves nothing unrecorded. */
41
+ spawnScope(workerId) {
42
+ return {
43
+ command: (file, args) => {
44
+ const run = this.store.getRun(workerId);
45
+ if (run?.delegation?.role === 'worker' && run.delegation.destroy)
46
+ throw new Error('Worker destruction has begun; nothing new starts in its scope');
47
+ const host = this.hostOf();
48
+ // Refused before anything runs: a full group record never has to end a started process.
49
+ if (host.backend === 'groups' && liveGroups(this.read(workerId).groups).length >= SCOPE_GROUP_CAP)
50
+ throw capacityError(workerId);
51
+ if (host.backend !== 'cgroup')
52
+ return [file, [...args]];
53
+ const path = workerCgroupPath(host.base, workerId);
54
+ this.update(workerId, record => {
55
+ if (record.cgroups.includes(path))
56
+ return record;
57
+ if (record.cgroups.length >= SCOPE_CGROUP_CAP)
58
+ throw new Error(`worker ${workerId} already spans ${SCOPE_CGROUP_CAP} cgroups`);
59
+ return { ...record, cgroups: [...record.cgroups, path] };
60
+ });
61
+ return cgroupCommand(ensureCgroup(host.base, workerId), file, args);
62
+ },
63
+ started: pid => {
64
+ if (this.hostOf().backend !== 'groups' || process.platform === 'win32')
65
+ return;
66
+ this.update(workerId, record => {
67
+ const live = liveGroups(record.groups);
68
+ // Never forget a live group to make room: refuse the start instead (the caller ends it).
69
+ if (live.length >= SCOPE_GROUP_CAP)
70
+ throw capacityError(workerId);
71
+ const entry = groupEntry(pid);
72
+ // Without a start token the group can never be proven ours, so it could never be stopped:
73
+ // refuse it, and the spawn site ends the group now.
74
+ if (entry.startToken === undefined)
75
+ throw new Error(`process ${pid} exited before its identity could be recorded`);
76
+ return { ...record, groups: [...live, entry] };
77
+ });
78
+ },
79
+ };
80
+ }
81
+ /** Whether no process the worker owns still runs: its cgroups are unpopulated and none of its
82
+ * recorded groups has a member. An unreadable record is not empty. */
83
+ empty(workerId) {
84
+ let record;
85
+ try {
86
+ record = this.read(workerId);
87
+ }
88
+ catch {
89
+ return false;
90
+ }
91
+ return !record.cgroups.some(path => cgroupPopulated(path)) && !liveGroups(this.groups(workerId, record)).length;
92
+ }
93
+ /** After `kill`: whether nothing the worker owned still runs. A cgroup drops a task when it exits,
94
+ * zombie or not; a group counts while its recorded leader runs (see `groupsStillStopping`). */
95
+ stopped(workerId) {
96
+ let record;
97
+ try {
98
+ record = this.read(workerId);
99
+ }
100
+ catch {
101
+ return false;
102
+ }
103
+ return !record.cgroups.some(path => cgroupPopulated(path)) && !groupsStillStopping(this.groups(workerId, record)).length;
104
+ }
105
+ /** SIGKILL everything the worker owns, now, without waiting. */
106
+ kill(workerId) {
107
+ const record = this.read(workerId);
108
+ for (const path of record.cgroups)
109
+ killCgroup(path);
110
+ killGroups(this.groups(workerId, record));
111
+ }
112
+ /** End everything the worker owns and remove its cgroups, within `timeoutMs`. What could not be
113
+ * stopped stays recorded, so a retry starts from it. */
114
+ async stop(workerId, timeoutMs) {
115
+ const deadline = Date.now() + timeoutMs;
116
+ for (;;) {
117
+ const round = await this.stopRound(workerId, deadline, timeoutMs);
118
+ // A start admitted before destroy began can register while a round waits: stop it too.
119
+ if (round !== 'late')
120
+ return round;
121
+ if (Date.now() >= deadline)
122
+ return { stopped: false, error: `worker processes started while stopping did not stop within ${Math.round(timeoutMs / 1000)}s` };
123
+ }
124
+ }
125
+ /** One kill-and-wait over the record as read now; `late` when the record gained entries meanwhile. */
126
+ async stopRound(workerId, deadline, timeoutMs) {
127
+ let record;
128
+ try {
129
+ record = this.read(workerId);
130
+ }
131
+ catch (error) {
132
+ return { stopped: false, error: error.message };
133
+ }
134
+ killGroups(this.groups(workerId, record));
135
+ const cgroups = [];
136
+ for (const path of record.cgroups)
137
+ if (!await removeCgroup(path, deadline))
138
+ cgroups.push(path);
139
+ let groups = groupsStillStopping(this.groups(workerId, record));
140
+ while (groups.length && Date.now() < deadline) {
141
+ await new Promise(resolve => setTimeout(resolve, STOP_POLL_MS));
142
+ groups = groupsStillStopping(groups);
143
+ }
144
+ // Merged into the record as it is now: an entry written while this stop waited is kept, and only
145
+ // what this stop ended leaves it. Groups only the execution record names stay there.
146
+ const removed = new Set(record.cgroups.filter(path => !cgroups.includes(path)));
147
+ const ended = new Set(record.groups.filter(group => !groups.some(left => key(left) === key(group))).map(key));
148
+ let late = false;
149
+ this.update(workerId, current => {
150
+ late = current.cgroups.some(path => !record.cgroups.includes(path)) || current.groups.some(group => !record.groups.some(known => key(known) === key(group)));
151
+ return { ...current, cgroups: current.cgroups.filter(path => !removed.has(path)), groups: current.groups.filter(group => !ended.has(key(group))) };
152
+ });
153
+ if (late)
154
+ return 'late';
155
+ if (!cgroups.length && !groups.length)
156
+ return { stopped: true };
157
+ return { stopped: false, error: `worker processes did not stop within ${Math.round(timeoutMs / 1000)}s: ${[...cgroups.map(path => `cgroup ${path}`), ...groups.map(group => `process group ${group.pgid}`)].join(', ')}` };
158
+ }
159
+ read(workerId) {
160
+ const record = this.store.readWorkerScope(workerId);
161
+ if (record === 'unknown')
162
+ throw new WorkerScopeUnreadable();
163
+ return record === 'absent' ? { workerId, cgroups: [], groups: [] } : record;
164
+ }
165
+ /** The record's groups and the current execution's recorded processes, without duplicates. A
166
+ * worker created before scopes has its session groups only in its execution record. */
167
+ groups(workerId, record) {
168
+ const generation = this.store.readWorkerExecution(workerId)?.generation;
169
+ const execution = generation ? this.store.readWorkerProcesses(workerId, generation) : 'absent';
170
+ const seen = new Set(record.groups.map(key));
171
+ const recorded = typeof execution === 'string' ? [] : execution.processes;
172
+ return [...record.groups, ...recorded.filter(entry => !seen.has(key(entry)))];
173
+ }
174
+ update(workerId, change) {
175
+ const record = this.read(workerId);
176
+ const next = change(record);
177
+ if (next !== record)
178
+ this.store.writeWorkerScope(workerId, next);
179
+ }
180
+ }
181
+ //# sourceMappingURL=worker-scopes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker-scopes.js","sourceRoot":"","sources":["../../src/worker-scope/worker-scopes.ts"],"names":[],"mappings":"AAAA;;;oEAGoE;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAI/C,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACrI,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACtF,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,eAAe,EAA6E,MAAM,YAAY,CAAC;AAIrJ,IAAI,IAA2B,CAAC;AAEhC,+FAA+F;AAC/F,MAAM,UAAU,SAAS;IACvB,IAAI,IAAI;QAAE,OAAO,IAAI,CAAC;IACtB,MAAM,KAAK,GAAG,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,QAAQ,iBAAiB,EAAE,CAAC;IAC/G,IAAI,GAAG,MAAM,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC;IAC/G,OAAO,CAAC,IAAI,CAAC,GAAG,SAAS,EAAE,kBAAkB,IAAI,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,4BAA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gB,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IACnE,CAAC;CACF"}
@@ -1,3 +1,4 @@
1
+ import type { SpawnScope } from '../worker-scope/scope.ts';
1
2
  /** Stop on a workflow check: SIGTERM first, SIGKILL to its process group after this grace. */
2
3
  export declare const CHECK_KILL_GRACE_MS = 3000;
3
4
  /** After SIGKILL, how long to wait for the group to disappear before resolving unconfirmed. */
@@ -14,6 +15,8 @@ export interface GroupedCommandOptions {
14
15
  * setup, #917 — an install reports its error at the end). */
15
16
  keep: 'head' | 'tail';
16
17
  cap: number;
18
+ /** A worker's scope: the command starts inside it (ADR 0032). */
19
+ scope?: SpawnScope | undefined;
17
20
  }
18
21
  export interface GroupedCommandResult {
19
22
  /** `null` when a signal ended the command or it never started. */
@@ -11,14 +11,40 @@ export const CHECK_TERMINATION_CONFIRM_MS = 5_000;
11
11
  * confirmed gone or the confirmation bound passes, which the output then says.
12
12
  */
13
13
  export function runGroupedCommand(opts) {
14
- const { command, cwd, env, setInterrupt, timeoutMs, keep, cap } = opts;
14
+ const { command, cwd, env, setInterrupt, timeoutMs, keep, cap, scope } = opts;
15
15
  const refusal = fallbackProjectWriteError(cwd);
16
16
  if (refusal)
17
17
  return Promise.resolve({ exitCode: null, output: '', timedOut: false, spawnError: refusal });
18
+ let argv;
19
+ try {
20
+ argv = scope ? scope.command('bash', ['-lc', command]) : ['bash', ['-lc', command]];
21
+ }
22
+ catch (error) {
23
+ const message = error.message;
24
+ return Promise.resolve({ exitCode: null, output: `failed to start: ${message}`, timedOut: false, spawnError: message });
25
+ }
18
26
  return new Promise((resolve) => {
19
27
  const grouped = process.platform !== 'win32';
20
- const child = spawn('bash', ['-lc', command], { cwd, env, detached: grouped });
28
+ const child = spawn(argv[0], argv[1], { cwd, env, detached: grouped });
21
29
  const pid = child.pid;
30
+ if (pid !== undefined) {
31
+ try {
32
+ scope?.started(pid);
33
+ }
34
+ catch (error) {
35
+ child.on('error', () => undefined);
36
+ try {
37
+ if (grouped)
38
+ process.kill(-pid, 'SIGKILL');
39
+ else
40
+ child.kill('SIGKILL');
41
+ }
42
+ catch { /* already gone */ }
43
+ const message = error.message;
44
+ resolve({ exitCode: null, output: `failed to start: ${message}`, timedOut: false, spawnError: message });
45
+ return;
46
+ }
47
+ }
22
48
  let output = '';
23
49
  let truncated = false;
24
50
  let finished = false;
@@ -1 +1 @@
1
- {"version":3,"file":"grouped-command.js","sourceRoot":"","sources":["../../src/workflows/grouped-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C,8FAA8F;AAC9F,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,CAAC;AACzC,+FAA+F;AAC/F,MAAM,CAAC,MAAM,4BAA4B,GAAG,KAAK,CAAC;AAwBlD;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAA2B;IAC3D,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,YAAY,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IACvE,MAAM,OAAO,GAAG,yBAAyB,CAAC,GAAG,CAAC,CAAC;IAC/C,IAAI,OAAO;QAAE,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC,CAAC;IAC1G,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,MAAM,OAAO,GAAG,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC;QAC7C,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;QAC/E,MAA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EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;QACnH,CAAC,CAAC,CAAC;QACH,uEAAuE;QACvE,yEAAyE;QACzE,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE;YACxB,IAAI,QAAQ;gBAAE,KAAK,kBAAkB,CAAC,IAAI,CAAC,CAAC;QAC9C,CAAC,CAAC,CAAC;QACH,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE;YACzB,IAAI,QAAQ;gBAAE,KAAK,kBAAkB,CAAC,IAAI,CAAC,CAAC;;gBACvC,MAAM,CAAC,IAAI,CAAC,CAAC;QACpB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -52,7 +52,6 @@ import type { SquawkToolHandlers } from '../../ci-wait/controller.ts';
52
52
  import { type WorkerAccountBinding } from '../../delegation/execution-identity.ts';
53
53
  import type { DelegationProvisioner } from '../../delegation/provision.ts';
54
54
  import { WorkerScratchCleanup } from '../../delegation/scratch-cleanup.ts';
55
- import { type CwdSource } from '../../delegation/process-liveness.ts';
56
55
  import type { RunnerId } from '../../core/agent-runner.ts';
57
56
  import { type PastedContent, type PersistedAttachment } from '../pasted-content.ts';
58
57
  import type { ContentBlock } from '../../core/agent-runner.ts';
@@ -156,7 +155,6 @@ export interface FacadeHost {
156
155
  settleOrphanedWorkerExecution(runId: string, opts?: {
157
156
  admitting?: boolean;
158
157
  fresh?: boolean;
159
- cwds?: CwdSource;
160
158
  }): boolean;
161
159
  sendMessage(runId: string, content: PastedContent[], messageId?: string): boolean;
162
160
  canClaimInboxInput(runId: string, id: string): boolean;