@hearsay-tools/squawk 0.18.0-pr3927.7421 → 0.18.0-pr3928.7425
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 +1 -1
- package/dist/ci-wait/errors.js +0 -2
- package/dist/ci-wait/errors.js.map +1 -1
- package/dist/ci-wait/tools.d.ts +5 -5
- package/dist/contract/delegation.d.ts +27 -14
- package/dist/contract/index.js +23 -31
- package/dist/contract/runs.d.ts +3 -10
- package/dist/contract/waits.d.ts +0 -2
- package/dist/contract/workspace-events.d.ts +0 -2
- package/dist/delegation/capacity.d.ts +3 -12
- package/dist/delegation/capacity.js +8 -23
- package/dist/delegation/capacity.js.map +1 -1
- package/dist/delegation/cli.js +15 -10
- package/dist/delegation/cli.js.map +1 -1
- package/dist/delegation/conversations.d.ts +0 -3
- package/dist/delegation/conversations.js +1 -4
- package/dist/delegation/conversations.js.map +1 -1
- package/dist/delegation/owned-workspace-release.d.ts +2 -3
- package/dist/delegation/owned-workspace-release.js +2 -2
- package/dist/delegation/owned-workspace-release.js.map +1 -1
- package/dist/delegation/policy.d.ts +3 -13
- package/dist/delegation/policy.js +14 -30
- package/dist/delegation/policy.js.map +1 -1
- package/dist/delegation/provision.js +4 -5
- package/dist/delegation/provision.js.map +1 -1
- package/dist/delegation/readiness.d.ts +2 -4
- package/dist/delegation/readiness.js +8 -9
- package/dist/delegation/readiness.js.map +1 -1
- package/dist/delegation/routes.d.ts +19 -5
- package/dist/delegation/routes.js +3 -3
- package/dist/delegation/routes.js.map +1 -1
- package/dist/delegation/service.d.ts +16 -4
- package/dist/delegation/service.js +39 -60
- package/dist/delegation/service.js.map +1 -1
- package/dist/delegation/transport.d.ts +19 -5
- package/dist/delegation/worker-cleanup.d.ts +6 -14
- package/dist/delegation/worker-cleanup.js +27 -61
- package/dist/delegation/worker-cleanup.js.map +1 -1
- package/dist/delegation/workspace-kinds.d.ts +11 -2
- package/dist/delegation/workspace-kinds.js +13 -6
- package/dist/delegation/workspace-kinds.js.map +1 -1
- package/dist/delegation/workspace-record.js +3 -2
- package/dist/delegation/workspace-record.js.map +1 -1
- package/dist/delegation/workspace-removal.d.ts +9 -4
- package/dist/delegation/workspace-removal.js +36 -37
- package/dist/delegation/workspace-removal.js.map +1 -1
- package/dist/delegation/workspace-work.d.ts +35 -0
- package/dist/delegation/workspace-work.js +75 -0
- package/dist/delegation/workspace-work.js.map +1 -0
- package/dist/runs/delegation-state.d.ts +1 -2
- package/dist/runs/owned-run-create.js +9 -33
- package/dist/runs/owned-run-create.js.map +1 -1
- package/dist/runs/run-exits.d.ts +6 -12
- package/dist/runs/shared-hosts.d.ts +0 -4
- package/dist/runs/shared-hosts.js +0 -6
- package/dist/runs/shared-hosts.js.map +1 -1
- package/dist/runs/store.d.ts +5 -6
- package/dist/runs/store.js +6 -5
- package/dist/runs/store.js.map +1 -1
- package/dist/runs/task-rights.d.ts +3 -22
- package/dist/runs/task-rights.js +13 -58
- package/dist/runs/task-rights.js.map +1 -1
- package/dist/server/run-checkout.js +0 -4
- package/dist/server/run-checkout.js.map +1 -1
- package/dist/server/server.d.ts +430 -424
- package/dist/server/server.js +35 -5
- package/dist/server/server.js.map +1 -1
- package/dist/workflows/completion-policy.d.ts +1 -7
- package/dist/workflows/completion-policy.js +3 -13
- package/dist/workflows/completion-policy.js.map +1 -1
- package/dist/workflows/continuation-admission.d.ts +1 -2
- package/dist/workflows/continuation-admission.js +0 -6
- package/dist/workflows/continuation-admission.js.map +1 -1
- package/dist/workflows/question-routing.d.ts +0 -2
- package/dist/workflows/question-routing.js +0 -7
- package/dist/workflows/question-routing.js.map +1 -1
- package/dist/workflows/run/completion-gate.d.ts +0 -3
- package/dist/workflows/run/completion-gate.js +7 -12
- package/dist/workflows/run/completion-gate.js.map +1 -1
- package/dist/workflows/run/family-reconciler.d.ts +8 -13
- package/dist/workflows/run/family-reconciler.js +17 -26
- package/dist/workflows/run/family-reconciler.js.map +1 -1
- package/dist/workflows/run/run-cancel.d.ts +1 -2
- package/dist/workflows/run/run-cancel.js +3 -5
- package/dist/workflows/run/run-cancel.js.map +1 -1
- package/dist/workflows/run/run-finish.js +6 -4
- package/dist/workflows/run/run-finish.js.map +1 -1
- package/dist/workflows/run/run-recovery.js +0 -10
- package/dist/workflows/run/run-recovery.js.map +1 -1
- package/dist/workflows/run/run-workspace.js +2 -3
- package/dist/workflows/run/run-workspace.js.map +1 -1
- package/dist/workflows/run/wait-engine.d.ts +1 -2
- package/dist/workflows/run/wait-engine.js +1 -2
- package/dist/workflows/run/wait-engine.js.map +1 -1
- package/dist/workflows/run/wait-registry.d.ts +1 -4
- package/dist/workflows/run/wait-registry.js +3 -12
- package/dist/workflows/run/wait-registry.js.map +1 -1
- package/dist/workflows/run/worker-questions.d.ts +3 -11
- package/dist/workflows/run/worker-questions.js +18 -38
- package/dist/workflows/run/worker-questions.js.map +1 -1
- package/dist/workflows/wait-scope.d.ts +2 -2
- package/dist/workflows/wait-scope.js +4 -4
- package/dist/workflows/wait-scope.js.map +1 -1
- package/package.json +4 -4
- package/web/dist/assets/{activity-motion-BjRSOxuh.js → activity-motion-CP1uMAhc.js} +1 -1
- package/web/dist/assets/{activity-route-CG_suLmL.js → activity-route-DeU2Kbwd.js} +1 -1
- package/web/dist/assets/{agent-accounts-DaF-ybaB.js → agent-accounts-B5mlyHu6.js} +1 -1
- package/web/dist/assets/attention-KWONtkLe.js +1 -0
- package/web/dist/assets/{commit-diff-panel-DvSOi3Dk.js → commit-diff-panel-BZUB5Z1f.js} +1 -1
- package/web/dist/assets/{diff-DhcQus9M.js → diff-BrHuVh8o.js} +2 -2
- package/web/dist/assets/{diff-view-DiuMMFWa.js → diff-view-CedKSSPs.js} +1 -1
- package/web/dist/assets/{file-preview-CZoDjpW4.js → file-preview-Be5LTCAp.js} +1 -1
- package/web/dist/assets/{git-toolbar-CA-ZwUuj.js → git-toolbar-DVuQmXZy.js} +1 -1
- package/web/dist/assets/{github-Dita6Kp5.js → github-DN_dnIH-.js} +1 -1
- package/web/dist/assets/{global-activity-route-DksHUiPz.js → global-activity-route-LJCoq_eu.js} +1 -1
- package/web/dist/assets/{index-D59vfFuq.js → index-BSkJHRdF.js} +9 -9
- package/web/dist/assets/{markdown-B66DXw4l.js → markdown-D2-rnRmg.js} +1 -1
- package/web/dist/assets/{picker-pill-bwLTIbHM.js → picker-pill-DeXs_3wA.js} +1 -1
- package/web/dist/assets/{preview-pane-connected-B7-FZ5DE.js → preview-pane-connected-DnLLyOv7.js} +1 -1
- package/web/dist/assets/{project-router-ewovT3Kf.js → project-router-Ca-Yys9p.js} +1 -1
- package/web/dist/assets/project-scope-context-Bq74vnQ8.js +4 -0
- package/web/dist/assets/{prompt-template-menu-BJEe-Kv2.js → prompt-template-menu-Ba29Yvb4.js} +1 -1
- package/web/dist/assets/queries-CteMqpzA.js +1 -0
- package/web/dist/assets/{reference-chip-Tj9CYsE2.js → reference-chip-CLBt6hDk.js} +1 -1
- package/web/dist/assets/{repo-git-C0MVr1i5.js → repo-git-CctMXHJm.js} +1 -1
- package/web/dist/assets/{report-reader-BW21aq_k.js → report-reader-D4rRCdx8.js} +1 -1
- package/web/dist/assets/{reports-DWXaed-t.js → reports-CYFYZ4j8.js} +1 -1
- package/web/dist/assets/run-header-y5q0tNyC.js +2 -0
- package/web/dist/assets/{skills-CZq8WNx7.js → skills-C_fXdjTf.js} +1 -1
- package/web/dist/assets/{tab-link-D4l87fgz.js → tab-link-CEKTsBqM.js} +1 -1
- package/web/dist/assets/{task-changes-FumjZsw6.js → task-changes-_iq_dPMh.js} +1 -1
- package/web/dist/assets/{task-commits-75nPVeL3.js → task-commits-ttgZYzlA.js} +1 -1
- package/web/dist/assets/{task-files-CdhoQGlN.js → task-files-BB2K7_8M.js} +1 -1
- package/web/dist/assets/{task-github-item-1IbcFtr-.js → task-github-item-BAR2_YLS.js} +1 -1
- package/web/dist/assets/task-thread-CWv3VJj0.js +9 -0
- package/web/dist/assets/{thread-state-Bfb8orUP.js → thread-state-DMd4D69h.js} +1 -1
- package/web/dist/assets/{use-desktop-DJrxV0gM.js → use-desktop-BjYpWIqI.js} +1 -1
- package/web/dist/assets/{use-hand-to-agent-state-bZUXClR3.js → use-hand-to-agent-state-CALyzrgv.js} +1 -1
- package/web/dist/assets/{useInfiniteQuery-Bbi75-bb.js → useInfiniteQuery-GJoCV7zM.js} +1 -1
- package/web/dist/assets/useQuery-B9tMLxA1.js +1 -0
- package/web/dist/assets/{workflows-gbQKlO53.js → workflows-DnIdj5zW.js} +2 -2
- package/web/dist/assets/{ws-BRHd49V3.js → ws-D7DpYPkk.js} +1 -1
- package/web/dist/index.html +13 -13
- package/dist/runs/supervised.d.ts +0 -21
- package/dist/runs/supervised.js +0 -28
- package/dist/runs/supervised.js.map +0 -1
- package/dist/server/run-relationships.d.ts +0 -14
- package/dist/server/run-relationships.js +0 -47
- package/dist/server/run-relationships.js.map +0 -1
- package/web/dist/assets/attention-DtccMSEl.js +0 -1
- package/web/dist/assets/project-scope-context-CdJF4Chv.js +0 -4
- package/web/dist/assets/queries-DEhoSzZx.js +0 -1
- package/web/dist/assets/run-header-LMdC07au.js +0 -2
- package/web/dist/assets/task-thread-9Q-PLOFf.js +0 -9
- package/web/dist/assets/useQuery-is45BI1J.js +0 -1
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { entryExists } from './entry-exists.js';
|
|
2
|
+
import { branchLog, workspaceGit } from './workspace-git.js';
|
|
3
|
+
/** For the branch tip and each reflog entry that is not the baseline, a branch or remote-tracking
|
|
4
|
+
* ref that contains it, other than this branch and never an alias; undefined when one has none,
|
|
5
|
+
* or when one ref is seen at two tips. A tip's ref also keeps every commit under it. */
|
|
6
|
+
export async function keepingRefs(git, workspace, branch) {
|
|
7
|
+
const tip = branch.sha;
|
|
8
|
+
const refs = new Map();
|
|
9
|
+
for (const sha of new Set([tip, ...reflogTips(branch)])) {
|
|
10
|
+
if (sha === workspace.baselineSha)
|
|
11
|
+
continue;
|
|
12
|
+
if (sha !== tip && refs.size > 0 && (await git(['merge-base', '--is-ancestor', sha, tip])).ok)
|
|
13
|
+
continue;
|
|
14
|
+
const listed = await git(['for-each-ref', '--contains', sha, '--format=%(refname)%00%(objectname)%00%(symref)', 'refs/heads', 'refs/remotes']);
|
|
15
|
+
const witness = listed.ok ? listed.stdout.split('\n').map(line => line.split('\0'))
|
|
16
|
+
.find(([ref, at, symref]) => ref && at && !symref && ref !== `refs/heads/${workspace.branch}`) : undefined;
|
|
17
|
+
if (!witness || (refs.has(witness[0]) && refs.get(witness[0]) !== witness[1]))
|
|
18
|
+
return undefined;
|
|
19
|
+
refs.set(witness[0], witness[1]);
|
|
20
|
+
}
|
|
21
|
+
return [...refs].map(([ref, sha]) => ({ ref, sha }));
|
|
22
|
+
}
|
|
23
|
+
function reflogTips(branch) {
|
|
24
|
+
return branch.log.content.toString('utf8').split('\n').filter(Boolean).map(entry => entry.split(' ')[1] ?? '').filter(Boolean);
|
|
25
|
+
}
|
|
26
|
+
/** Commits the branch tip or its reflog holds that no other branch or remote-tracking ref
|
|
27
|
+
* reaches: 0 when `keepingRefs` finds a keeper for each, otherwise at least 1. */
|
|
28
|
+
export async function unlandedCommits(git, workspace, branch) {
|
|
29
|
+
if (await keepingRefs(git, workspace, branch))
|
|
30
|
+
return 0;
|
|
31
|
+
const tips = [...new Set([branch.sha, ...reflogTips(branch)])].filter(sha => sha !== workspace.baselineSha);
|
|
32
|
+
const counted = await git(['rev-list', '--count', ...tips, `^${workspace.baselineSha}`, '--not', `--exclude=${workspace.branch}`, '--branches', '--remotes']);
|
|
33
|
+
const commits = counted.ok ? Number(counted.stdout.trim()) : NaN;
|
|
34
|
+
// Unreachable reflog entries or an alias can leave nothing countable; the work is still unproven.
|
|
35
|
+
return Number.isInteger(commits) && commits > 0 ? commits : 1;
|
|
36
|
+
}
|
|
37
|
+
/** Files with uncommitted changes in a worker directory: staged, modified, deleted or untracked;
|
|
38
|
+
* ignored files do not count. Throws when Git cannot read the directory. */
|
|
39
|
+
export async function uncommittedFiles(path) {
|
|
40
|
+
const status = await workspaceGit(path, ['--no-optional-locks', 'status', '--porcelain=v1', '-z', '--untracked-files=all']);
|
|
41
|
+
if (!status.ok)
|
|
42
|
+
throw new Error('Owned workspace Git status failed');
|
|
43
|
+
const fields = status.stdout.split('\0');
|
|
44
|
+
let files = 0;
|
|
45
|
+
for (let index = 0; index < fields.length; index++) {
|
|
46
|
+
const entry = fields[index];
|
|
47
|
+
if (entry.length < 4)
|
|
48
|
+
continue;
|
|
49
|
+
files++;
|
|
50
|
+
// A rename or copy carries its source path as the next field.
|
|
51
|
+
if (/[RC]/.test(entry.slice(0, 2)))
|
|
52
|
+
index++;
|
|
53
|
+
}
|
|
54
|
+
return files;
|
|
55
|
+
}
|
|
56
|
+
/** The work a destroy would delete now, or undefined when there is none. Reads only; the checked
|
|
57
|
+
* removal repeats it under the worktree mutation lock. Throws when Git cannot answer. */
|
|
58
|
+
export async function workspaceWork(repoRoot, workspace) {
|
|
59
|
+
const files = await entryExists(workspace.path) ? await uncommittedFiles(workspace.path) : 0;
|
|
60
|
+
const tip = await workspaceGit(repoRoot, ['rev-parse', '--verify', '--quiet', `refs/heads/${workspace.branch}^{commit}`]);
|
|
61
|
+
const sha = tip.ok ? tip.stdout.trim() : '';
|
|
62
|
+
const commits = sha ? await unlandedCommits(args => workspaceGit(repoRoot, args), workspace, { sha, log: await branchLog(repoRoot, workspace) }) : 0;
|
|
63
|
+
return files || commits ? { uncommittedFiles: files, commits } : undefined;
|
|
64
|
+
}
|
|
65
|
+
const count = (n, one, many) => `${n} ${n === 1 ? one : many}`;
|
|
66
|
+
/** The refusal that names the work and both ways forward. */
|
|
67
|
+
export function describeWork(workerId, work) {
|
|
68
|
+
const parts = [
|
|
69
|
+
...(work.uncommittedFiles ? [count(work.uncommittedFiles, 'uncommitted file', 'uncommitted files')] : []),
|
|
70
|
+
...(work.commits ? [`${count(work.commits, 'commit', 'commits')} no other branch reaches`] : []),
|
|
71
|
+
];
|
|
72
|
+
return `Worker ${workerId.slice(0, 8)} holds work destroy would delete: ${parts.join(' and ')}. ` +
|
|
73
|
+
'Land or commit what you need and rerun destroy, or rerun destroy with --discard-work to delete it';
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=workspace-work.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace-work.js","sourceRoot":"","sources":["../../src/delegation/workspace-work.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAQ7D;;wFAEwF;AACxF,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,GAAY,EAAE,SAA+B,EAAE,MAAmB;IAClG,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC;IACvB,MAAM,IAAI,GAAG,IAAI,GAAG,EAAkB,CAAC;IACvC,KAAK,MAAM,GAAG,IAAI,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;QACxD,IAAI,GAAG,KAAK,SAAS,CAAC,WAAW;YAAE,SAAS;QAC5C,IAAI,GAAG,KAAK,GAAG,IAAI,IAAI,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,YAAY,EAAE,eAAe,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE;YAAE,SAAS;QACxG,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,CAAC,cAAc,EAAE,YAAY,EAAE,GAAG,EAAE,iDAAiD,EAAE,YAAY,EAAE,cAAc,CAAC,CAAC,CAAC;QAC/I,MAAM,OAAO,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CA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AC;AAED,MAAM,KAAK,GAAG,CAAC,CAAS,EAAE,GAAW,EAAE,IAAY,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;AAEvF,6DAA6D;AAC7D,MAAM,UAAU,YAAY,CAAC,QAAgB,EAAE,IAAuB;IACpE,MAAM,KAAK,GAAG;QACZ,GAAG,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,gBAAgB,EAAE,kBAAkB,EAAE,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACzG,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC,0BAA0B,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;KACjG,CAAC;IACF,OAAO,UAAU,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,qCAAqC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI;QAC/F,mGAAmG,CAAC;AACxG,CAAC"}
|
|
@@ -91,7 +91,6 @@ export declare const storedDelegationStateSchema: import("zod").ZodCatch<import(
|
|
|
91
91
|
requestId: import("zod").ZodUUID;
|
|
92
92
|
workerId: import("zod").ZodUUID;
|
|
93
93
|
requestHash: import("zod").ZodString;
|
|
94
|
-
supervisorRunId: import("zod").ZodOptional<import("zod").ZodUUID>;
|
|
95
94
|
deletion: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
96
95
|
phase: import("zod").ZodEnum<{
|
|
97
96
|
complete: "complete";
|
|
@@ -379,7 +378,6 @@ export declare const storedDelegationStateSchema: import("zod").ZodCatch<import(
|
|
|
379
378
|
children: import("zod").ZodOptional<import("zod").ZodObject<any, import("zod/v4/core").$strict>>;
|
|
380
379
|
}, import("zod/v4/core").$strict>>;
|
|
381
380
|
parentRunId: import("zod").ZodUUID;
|
|
382
|
-
supervisorRunId: import("zod").ZodOptional<import("zod").ZodUUID>;
|
|
383
381
|
workspace: import("zod").ZodDiscriminatedUnion<[import("zod").ZodObject<{
|
|
384
382
|
ownerRunId: import("zod").ZodUUID;
|
|
385
383
|
resourceId: import("zod").ZodUUID;
|
|
@@ -410,6 +408,7 @@ export declare const storedDelegationStateSchema: import("zod").ZodCatch<import(
|
|
|
410
408
|
worktree: "worktree";
|
|
411
409
|
}>>;
|
|
412
410
|
error: import("zod").ZodOptional<import("zod").ZodString>;
|
|
411
|
+
discardWork: import("zod").ZodOptional<import("zod").ZodLiteral<true>>;
|
|
413
412
|
}, import("zod/v4/core").$strict>>;
|
|
414
413
|
context: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
415
414
|
text: import("zod").ZodOptional<import("zod").ZodString>;
|
|
@@ -5,8 +5,7 @@
|
|
|
5
5
|
import { randomUUID } from 'node:crypto';
|
|
6
6
|
import { delegationStateSchema, ownsDirectory, workerCreationReceiptSchema } from '../contract/index.js';
|
|
7
7
|
import { workerExecutionIdentitySchema } from '../delegation/execution-identity.js';
|
|
8
|
-
import {
|
|
9
|
-
import { receiptSupervisorId, supervisedReceipts, supervisorIdOf } from './task-rights.js';
|
|
8
|
+
import { capacityError, workerCapacity } from '../delegation/capacity.js';
|
|
10
9
|
/**
|
|
11
10
|
* requestHash is supplied only by the trusted service: hash the ORIGINAL normalized request,
|
|
12
11
|
* before resolving refs. A retry keeps the original worker and pinned SHA even if HEAD moved.
|
|
@@ -17,37 +16,18 @@ export function createStoreOwnedRun(state, input, parentId, requestId, worker, r
|
|
|
17
16
|
// Validate retry identity independently of the newly proposed resource.
|
|
18
17
|
const identity = workerCreationReceiptSchema.pick({ requestId: true, requestHash: true })
|
|
19
18
|
.parse({ requestId, requestHash });
|
|
20
|
-
const
|
|
21
|
-
// A request ID is one supervisor's: another supervisor's same ID names its own worker.
|
|
22
|
-
const receipt = supervisedReceipts(parent, supervisorId).find((entry) => entry.requestId === identity.requestId);
|
|
19
|
+
const receipt = authority.receipts.find((entry) => entry.requestId === identity.requestId);
|
|
23
20
|
if (receipt)
|
|
24
21
|
return existingOwnedRunReceipt(state, parentId, receipt, identity);
|
|
25
|
-
|
|
26
|
-
//
|
|
27
|
-
|
|
28
|
-
// checks the grant's kinds in the same synchronous step, before this call.
|
|
29
|
-
const supervisor = liveSupervisor(state, parent, supervisorId);
|
|
30
|
-
const refusal = spawnCapacityRefusal(parent, supervisor, (id) => state.peek(id));
|
|
22
|
+
// #816: the same check the spawn policy makes, inside the receipt transaction, so no path
|
|
23
|
+
// writes a receipt past either limit.
|
|
24
|
+
const refusal = capacityError(workerCapacity(parent, (id) => state.peek(id)));
|
|
31
25
|
if (refusal)
|
|
32
26
|
throw new Error(refusal);
|
|
27
|
+
const metadata = parseOwnedWorkerMetadata(worker, parentId, input.worktree);
|
|
33
28
|
assertWorkerResourceFree(state, metadata.workspace);
|
|
34
29
|
return publishOwnedRun(state, parentId, parent, authority, identity, metadata, input, executionIdentity);
|
|
35
30
|
}
|
|
36
|
-
/** The task that starts the worker: the family's root, or a worker of this family that still runs,
|
|
37
|
-
* is not being destroyed and holds a live receipt. */
|
|
38
|
-
function liveSupervisor(state, parent, supervisorId) {
|
|
39
|
-
if (supervisorId === parent.id)
|
|
40
|
-
return parent;
|
|
41
|
-
const supervisor = state.peek(supervisorId);
|
|
42
|
-
const metadata = delegationStateSchema.safeParse(supervisor?.delegation);
|
|
43
|
-
if (!supervisor || !metadata.success || metadata.data.role !== 'worker' || metadata.data.parentRunId !== parent.id ||
|
|
44
|
-
metadata.data.workspace.ownerRunId !== supervisor.id || metadata.data.destroy || supervisor.stopping ||
|
|
45
|
-
!['running', 'waiting'].includes(supervisor.status) ||
|
|
46
|
-
!supervisedReceipts(parent, supervisorIdOf(supervisor)).some((entry) => entry.workerId === supervisor.id && !entry.deletion)) {
|
|
47
|
-
throw new Error('invalid delegation supervisor');
|
|
48
|
-
}
|
|
49
|
-
return supervisor;
|
|
50
|
-
}
|
|
51
31
|
function resolveOwnedRunParent(state, parentId) {
|
|
52
32
|
const parent = state.peek(parentId);
|
|
53
33
|
const authority = delegationStateSchema.safeParse(parent?.delegation);
|
|
@@ -61,10 +41,8 @@ function existingOwnedRunReceipt(state, parentId, receipt, identity) {
|
|
|
61
41
|
throw new Error('request ID payload conflict');
|
|
62
42
|
const existing = state.peek(receipt.workerId);
|
|
63
43
|
const metadata = delegationStateSchema.safeParse(existing?.delegation);
|
|
64
|
-
|
|
65
|
-
if (!existing || !parent || !metadata.success || metadata.data.role !== 'worker' ||
|
|
44
|
+
if (!existing || !metadata.success || metadata.data.role !== 'worker' ||
|
|
66
45
|
metadata.data.parentRunId !== parentId || metadata.data.workspace.ownerRunId !== existing.id ||
|
|
67
|
-
supervisorIdOf(existing) !== receiptSupervisorId(parent, receipt) ||
|
|
68
46
|
existing.id === parentId)
|
|
69
47
|
throw new Error('invalid request receipt ownership');
|
|
70
48
|
return existing;
|
|
@@ -72,8 +50,7 @@ function existingOwnedRunReceipt(state, parentId, receipt, identity) {
|
|
|
72
50
|
function parseOwnedWorkerMetadata(worker, parentId, worktree) {
|
|
73
51
|
const metadata = delegationStateSchema.parse(worker);
|
|
74
52
|
if (metadata.role !== 'worker' || metadata.parentRunId !== parentId ||
|
|
75
|
-
metadata.workspace.ownerRunId === parentId ||
|
|
76
|
-
metadata.supervisorRunId === parentId || worktree === false) {
|
|
53
|
+
metadata.workspace.ownerRunId === parentId || worktree === false) {
|
|
77
54
|
throw new Error('invalid worker ownership');
|
|
78
55
|
}
|
|
79
56
|
return metadata;
|
|
@@ -115,8 +92,7 @@ function publishOwnedRun(state, parentId, parent, authority, identity, metadata,
|
|
|
115
92
|
const workspace = metadata.workspace;
|
|
116
93
|
const delegation = delegationStateSchema.parse({
|
|
117
94
|
...authority,
|
|
118
|
-
receipts: [...authority.receipts, { ...identity, workerId: workspace.ownerRunId,
|
|
119
|
-
...(metadata.supervisorRunId === undefined ? {} : { supervisorRunId: metadata.supervisorRunId }) }],
|
|
95
|
+
receipts: [...authority.receipts, { ...identity, workerId: workspace.ownerRunId }],
|
|
120
96
|
});
|
|
121
97
|
const run = { ...state.buildRun(input, workspace.ownerRunId), delegation: metadata };
|
|
122
98
|
// This transaction precedes materialization. Every launch must rotate this
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"owned-run-create.js","sourceRoot":"","sources":["../../src/runs/owned-run-create.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,2BAA2B,EAAE,MAAM,yCAAyC,CAAC;AAC5H,OAAO,EAAE,6BAA6B,EAAgC,MAAM,qCAAqC,CAAC;AAClH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"owned-run-create.js","sourceRoot":"","sources":["../../src/runs/owned-run-create.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,2BAA2B,EAAE,MAAM,yCAAyC,CAAC;AAC5H,OAAO,EAAE,6BAA6B,EAAgC,MAAM,qCAAqC,CAAC;AAClH,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAyB1E;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CACjC,KAAkC,EAClC,KAAa,EACb,QAAgB,EAChB,SAAiB,EACjB,MAAuB,EACvB,WAAmB,EACnB,iBAA0C;IAE1C,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,qBAAqB,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IACrE,wEAAwE;IACxE,MAAM,QAAQ,GAAG,2BAA2B,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI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,UAAU,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,IAAI,CAAC,CAAC;IACxF,wFAAwF;IACxF,KAAK,CAAC,WAAW,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,EAAE,GAAG,MAAM,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACnF,OAAO,GAAG,CAAC;AACb,CAAC"}
|
package/dist/runs/run-exits.d.ts
CHANGED
|
@@ -225,7 +225,6 @@ export declare const RUN_EXITS: {
|
|
|
225
225
|
requestId: string;
|
|
226
226
|
workerId: string;
|
|
227
227
|
requestHash: string;
|
|
228
|
-
supervisorRunId?: string | undefined;
|
|
229
228
|
deletion?: {
|
|
230
229
|
phase: "complete" | "pending";
|
|
231
230
|
revision: number;
|
|
@@ -368,7 +367,6 @@ export declare const RUN_EXITS: {
|
|
|
368
367
|
children?: any | undefined;
|
|
369
368
|
} | undefined;
|
|
370
369
|
parentRunId: string;
|
|
371
|
-
supervisorRunId?: string | undefined;
|
|
372
370
|
workspace: {
|
|
373
371
|
ownerRunId: string;
|
|
374
372
|
resourceId: string;
|
|
@@ -389,6 +387,7 @@ export declare const RUN_EXITS: {
|
|
|
389
387
|
phase: "cleaning" | "complete" | "incomplete" | "requested" | "terminating";
|
|
390
388
|
remaining: ("branch" | "process" | "worktree")[];
|
|
391
389
|
error?: string | undefined;
|
|
390
|
+
discardWork?: true | undefined;
|
|
392
391
|
} | undefined;
|
|
393
392
|
context?: {
|
|
394
393
|
text?: string | undefined;
|
|
@@ -964,7 +963,6 @@ export declare const RUN_EXITS: {
|
|
|
964
963
|
requestId: string;
|
|
965
964
|
workerId: string;
|
|
966
965
|
requestHash: string;
|
|
967
|
-
supervisorRunId?: string | undefined;
|
|
968
966
|
deletion?: {
|
|
969
967
|
phase: "complete" | "pending";
|
|
970
968
|
revision: number;
|
|
@@ -1107,7 +1105,6 @@ export declare const RUN_EXITS: {
|
|
|
1107
1105
|
children?: any | undefined;
|
|
1108
1106
|
} | undefined;
|
|
1109
1107
|
parentRunId: string;
|
|
1110
|
-
supervisorRunId?: string | undefined;
|
|
1111
1108
|
workspace: {
|
|
1112
1109
|
ownerRunId: string;
|
|
1113
1110
|
resourceId: string;
|
|
@@ -1128,6 +1125,7 @@ export declare const RUN_EXITS: {
|
|
|
1128
1125
|
phase: "cleaning" | "complete" | "incomplete" | "requested" | "terminating";
|
|
1129
1126
|
remaining: ("branch" | "process" | "worktree")[];
|
|
1130
1127
|
error?: string | undefined;
|
|
1128
|
+
discardWork?: true | undefined;
|
|
1131
1129
|
} | undefined;
|
|
1132
1130
|
context?: {
|
|
1133
1131
|
text?: string | undefined;
|
|
@@ -1744,7 +1742,6 @@ export declare const RUN_EXITS: {
|
|
|
1744
1742
|
requestId: string;
|
|
1745
1743
|
workerId: string;
|
|
1746
1744
|
requestHash: string;
|
|
1747
|
-
supervisorRunId?: string | undefined;
|
|
1748
1745
|
deletion?: {
|
|
1749
1746
|
phase: "complete" | "pending";
|
|
1750
1747
|
revision: number;
|
|
@@ -1887,7 +1884,6 @@ export declare const RUN_EXITS: {
|
|
|
1887
1884
|
children?: any | undefined;
|
|
1888
1885
|
} | undefined;
|
|
1889
1886
|
parentRunId: string;
|
|
1890
|
-
supervisorRunId?: string | undefined;
|
|
1891
1887
|
workspace: {
|
|
1892
1888
|
ownerRunId: string;
|
|
1893
1889
|
resourceId: string;
|
|
@@ -1908,6 +1904,7 @@ export declare const RUN_EXITS: {
|
|
|
1908
1904
|
phase: "cleaning" | "complete" | "incomplete" | "requested" | "terminating";
|
|
1909
1905
|
remaining: ("branch" | "process" | "worktree")[];
|
|
1910
1906
|
error?: string | undefined;
|
|
1907
|
+
discardWork?: true | undefined;
|
|
1911
1908
|
} | undefined;
|
|
1912
1909
|
context?: {
|
|
1913
1910
|
text?: string | undefined;
|
|
@@ -2833,7 +2830,6 @@ export declare const RUN_EXITS: {
|
|
|
2833
2830
|
requestId: string;
|
|
2834
2831
|
workerId: string;
|
|
2835
2832
|
requestHash: string;
|
|
2836
|
-
supervisorRunId?: string | undefined;
|
|
2837
2833
|
deletion?: {
|
|
2838
2834
|
phase: "complete" | "pending";
|
|
2839
2835
|
revision: number;
|
|
@@ -2976,7 +2972,6 @@ export declare const RUN_EXITS: {
|
|
|
2976
2972
|
children?: any | undefined;
|
|
2977
2973
|
} | undefined;
|
|
2978
2974
|
parentRunId: string;
|
|
2979
|
-
supervisorRunId?: string | undefined;
|
|
2980
2975
|
workspace: {
|
|
2981
2976
|
ownerRunId: string;
|
|
2982
2977
|
resourceId: string;
|
|
@@ -2997,6 +2992,7 @@ export declare const RUN_EXITS: {
|
|
|
2997
2992
|
phase: "cleaning" | "complete" | "incomplete" | "requested" | "terminating";
|
|
2998
2993
|
remaining: ("branch" | "process" | "worktree")[];
|
|
2999
2994
|
error?: string | undefined;
|
|
2995
|
+
discardWork?: true | undefined;
|
|
3000
2996
|
} | undefined;
|
|
3001
2997
|
context?: {
|
|
3002
2998
|
text?: string | undefined;
|
|
@@ -3936,7 +3932,6 @@ export declare const RUN_EXITS: {
|
|
|
3936
3932
|
requestId: string;
|
|
3937
3933
|
workerId: string;
|
|
3938
3934
|
requestHash: string;
|
|
3939
|
-
supervisorRunId?: string | undefined;
|
|
3940
3935
|
deletion?: {
|
|
3941
3936
|
phase: "complete" | "pending";
|
|
3942
3937
|
revision: number;
|
|
@@ -4079,7 +4074,6 @@ export declare const RUN_EXITS: {
|
|
|
4079
4074
|
children?: any | undefined;
|
|
4080
4075
|
} | undefined;
|
|
4081
4076
|
parentRunId: string;
|
|
4082
|
-
supervisorRunId?: string | undefined;
|
|
4083
4077
|
workspace: {
|
|
4084
4078
|
ownerRunId: string;
|
|
4085
4079
|
resourceId: string;
|
|
@@ -4100,6 +4094,7 @@ export declare const RUN_EXITS: {
|
|
|
4100
4094
|
phase: "cleaning" | "complete" | "incomplete" | "requested" | "terminating";
|
|
4101
4095
|
remaining: ("branch" | "process" | "worktree")[];
|
|
4102
4096
|
error?: string | undefined;
|
|
4097
|
+
discardWork?: true | undefined;
|
|
4103
4098
|
} | undefined;
|
|
4104
4099
|
context?: {
|
|
4105
4100
|
text?: string | undefined;
|
|
@@ -5033,7 +5028,6 @@ export declare const RUN_EXITS: {
|
|
|
5033
5028
|
requestId: string;
|
|
5034
5029
|
workerId: string;
|
|
5035
5030
|
requestHash: string;
|
|
5036
|
-
supervisorRunId?: string | undefined;
|
|
5037
5031
|
deletion?: {
|
|
5038
5032
|
phase: "complete" | "pending";
|
|
5039
5033
|
revision: number;
|
|
@@ -5176,7 +5170,6 @@ export declare const RUN_EXITS: {
|
|
|
5176
5170
|
children?: any | undefined;
|
|
5177
5171
|
} | undefined;
|
|
5178
5172
|
parentRunId: string;
|
|
5179
|
-
supervisorRunId?: string | undefined;
|
|
5180
5173
|
workspace: {
|
|
5181
5174
|
ownerRunId: string;
|
|
5182
5175
|
resourceId: string;
|
|
@@ -5197,6 +5190,7 @@ export declare const RUN_EXITS: {
|
|
|
5197
5190
|
phase: "cleaning" | "complete" | "incomplete" | "requested" | "terminating";
|
|
5198
5191
|
remaining: ("branch" | "process" | "worktree")[];
|
|
5199
5192
|
error?: string | undefined;
|
|
5193
|
+
discardWork?: true | undefined;
|
|
5200
5194
|
} | undefined;
|
|
5201
5195
|
context?: {
|
|
5202
5196
|
text?: string | undefined;
|
|
@@ -4,10 +4,6 @@ export declare const SHARED_HOST_REFUSAL = "a worker runs in this task's worktre
|
|
|
4
4
|
/** The run whose directory `run` works in: itself, or the host its workspace record names. A claim
|
|
5
5
|
* on that run's directory holds `run` off, and `run` being live holds that claim off. */
|
|
6
6
|
export declare function directoryRunId(run: RunRecord): string;
|
|
7
|
-
/** The directory a run works in, from its record: the host path a shared worker's workspace
|
|
8
|
-
* records, else the worktree the engine recorded for the run (`worktreePath`), else the repository
|
|
9
|
-
* root. Never the working directory of a live session. */
|
|
10
|
-
export declare function recordedDirectory(run: RunRecord | undefined, repoRoot: string): string;
|
|
11
7
|
/**
|
|
12
8
|
* Whether a live worker works in `run`'s directory: one whose workspace record names `run` as its
|
|
13
9
|
* host (`hostRunId`) and that is queued, running, waiting or mid-destroy. Every path that removes
|
|
@@ -7,12 +7,6 @@ export const SHARED_HOST_REFUSAL = 'a worker runs in this task\'s worktree — s
|
|
|
7
7
|
export function directoryRunId(run) {
|
|
8
8
|
return run.delegation?.role === 'worker' && !ownsDirectory(run.delegation.workspace) ? run.delegation.workspace.hostRunId : run.id;
|
|
9
9
|
}
|
|
10
|
-
/** The directory a run works in, from its record: the host path a shared worker's workspace
|
|
11
|
-
* records, else the worktree the engine recorded for the run (`worktreePath`), else the repository
|
|
12
|
-
* root. Never the working directory of a live session. */
|
|
13
|
-
export function recordedDirectory(run, repoRoot) {
|
|
14
|
-
return run?.delegation?.role === 'worker' && !ownsDirectory(run.delegation.workspace) ? run.delegation.workspace.path : run?.worktreePath ?? repoRoot;
|
|
15
|
-
}
|
|
16
10
|
/**
|
|
17
11
|
* Whether a live worker works in `run`'s directory: one whose workspace record names `run` as its
|
|
18
12
|
* host (`hostRunId`) and that is queued, running, waiting or mid-destroy. Every path that removes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared-hosts.js","sourceRoot":"","sources":["../../src/runs/shared-hosts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAG5C,gEAAgE;AAChE,MAAM,CAAC,MAAM,mBAAmB,GAAG,uEAAuE,CAAC;AAE3G;0FAC0F;AAC1F,MAAM,UAAU,cAAc,CAAC,GAAc;IAC3C,OAAO,GAAG,CAAC,UAAU,EAAE,IAAI,KAAK,QAAQ,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC,SAA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AAC,CAAC;AAC/D,CAAC"}
|
package/dist/runs/store.d.ts
CHANGED
|
@@ -1528,7 +1528,6 @@ export declare const runRecordSchema: z.ZodObject<{
|
|
|
1528
1528
|
requestId: z.ZodUUID;
|
|
1529
1529
|
workerId: z.ZodUUID;
|
|
1530
1530
|
requestHash: z.ZodString;
|
|
1531
|
-
supervisorRunId: z.ZodOptional<z.ZodUUID>;
|
|
1532
1531
|
deletion: z.ZodOptional<z.ZodObject<{
|
|
1533
1532
|
phase: z.ZodEnum<{
|
|
1534
1533
|
complete: "complete";
|
|
@@ -1816,7 +1815,6 @@ export declare const runRecordSchema: z.ZodObject<{
|
|
|
1816
1815
|
children: z.ZodOptional<z.ZodObject<any, z.core.$strict>>;
|
|
1817
1816
|
}, z.core.$strict>>;
|
|
1818
1817
|
parentRunId: z.ZodUUID;
|
|
1819
|
-
supervisorRunId: z.ZodOptional<z.ZodUUID>;
|
|
1820
1818
|
workspace: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
1821
1819
|
ownerRunId: z.ZodUUID;
|
|
1822
1820
|
resourceId: z.ZodUUID;
|
|
@@ -1847,6 +1845,7 @@ export declare const runRecordSchema: z.ZodObject<{
|
|
|
1847
1845
|
worktree: "worktree";
|
|
1848
1846
|
}>>;
|
|
1849
1847
|
error: z.ZodOptional<z.ZodString>;
|
|
1848
|
+
discardWork: z.ZodOptional<z.ZodLiteral<true>>;
|
|
1850
1849
|
}, z.core.$strict>>;
|
|
1851
1850
|
context: z.ZodOptional<z.ZodObject<{
|
|
1852
1851
|
text: z.ZodOptional<z.ZodString>;
|
|
@@ -2831,7 +2830,6 @@ export declare function parseRunRecords(raw: unknown): z.ZodSafeParseResult<{
|
|
|
2831
2830
|
requestId: string;
|
|
2832
2831
|
workerId: string;
|
|
2833
2832
|
requestHash: string;
|
|
2834
|
-
supervisorRunId?: string | undefined;
|
|
2835
2833
|
deletion?: {
|
|
2836
2834
|
phase: "complete" | "pending";
|
|
2837
2835
|
revision: number;
|
|
@@ -2974,7 +2972,6 @@ export declare function parseRunRecords(raw: unknown): z.ZodSafeParseResult<{
|
|
|
2974
2972
|
children?: any | undefined;
|
|
2975
2973
|
} | undefined;
|
|
2976
2974
|
parentRunId: string;
|
|
2977
|
-
supervisorRunId?: string | undefined;
|
|
2978
2975
|
workspace: {
|
|
2979
2976
|
ownerRunId: string;
|
|
2980
2977
|
resourceId: string;
|
|
@@ -2995,6 +2992,7 @@ export declare function parseRunRecords(raw: unknown): z.ZodSafeParseResult<{
|
|
|
2995
2992
|
phase: "cleaning" | "complete" | "incomplete" | "requested" | "terminating";
|
|
2996
2993
|
remaining: ("branch" | "process" | "worktree")[];
|
|
2997
2994
|
error?: string | undefined;
|
|
2995
|
+
discardWork?: true | undefined;
|
|
2998
2996
|
} | undefined;
|
|
2999
2997
|
context?: {
|
|
3000
2998
|
text?: string | undefined;
|
|
@@ -3389,8 +3387,9 @@ export declare class RunStore extends EventEmitter {
|
|
|
3389
3387
|
* not parse (hearsay-tools/squawk#3530). The caller has claimed the row's family. */
|
|
3390
3388
|
private adoptLoadedRun;
|
|
3391
3389
|
/**
|
|
3392
|
-
* Hold one delegation family: its root and
|
|
3393
|
-
* `parent_run_id` index. No recursion: a worker's own id never
|
|
3390
|
+
* Hold one delegation family: its root and the root's direct workers, read through the
|
|
3391
|
+
* `parent_run_id` index. No recursion: workers cannot delegate, so a worker's own id never
|
|
3392
|
+
* names a family. The caller has claimed it. `settle` settles its live rows instead of keeping
|
|
3394
3393
|
* them for recovery (`settleOrphanedRun`); `stopId` is the run a Stop settles as cancelled.
|
|
3395
3394
|
*/
|
|
3396
3395
|
private holdFamily;
|
package/dist/runs/store.js
CHANGED
|
@@ -68,7 +68,6 @@ import { archiveStoreFamily } from './archive-family.js';
|
|
|
68
68
|
import { claimStoreFamilies } from './claim-families.js';
|
|
69
69
|
import { createStoreOwnedRun } from './owned-run-create.js';
|
|
70
70
|
import { commitStoreWorkerResult } from './worker-result-commit.js';
|
|
71
|
-
import { supervisedWorkers } from './supervised.js';
|
|
72
71
|
import { claimOwnerLive, closeClaimSession, familyKey, foreignClaimedRunIds, liveForeignClaimedRunIds, openClaimSession, rowFamily } from './run-claims.js';
|
|
73
72
|
import { assertProjectWritable, projectWriteRefused } from '../server/cockpit-ownership.js';
|
|
74
73
|
/**
|
|
@@ -403,7 +402,8 @@ function decodeArchivedCursor(cursor) {
|
|
|
403
402
|
function sortNewestFirst(entries) {
|
|
404
403
|
return [...entries].sort(([, a], [, b]) => newestFirst(a, b)).map(([item]) => item);
|
|
405
404
|
}
|
|
406
|
-
/** The family a run belongs to, by its root's id
|
|
405
|
+
/** The delegation family a run belongs to, by its root's id: a root is its own, a worker its
|
|
406
|
+
* parent's. Workers cannot delegate, so a family is one root and its direct workers, never more. */
|
|
407
407
|
function familyRootOf(run) {
|
|
408
408
|
if (run.delegation?.role === 'root')
|
|
409
409
|
return run.id;
|
|
@@ -694,8 +694,9 @@ export class RunStore extends EventEmitter {
|
|
|
694
694
|
this.exitEvents.loadCancelled(run.id);
|
|
695
695
|
}
|
|
696
696
|
/**
|
|
697
|
-
* Hold one delegation family: its root and
|
|
698
|
-
* `parent_run_id` index. No recursion: a worker's own id never
|
|
697
|
+
* Hold one delegation family: its root and the root's direct workers, read through the
|
|
698
|
+
* `parent_run_id` index. No recursion: workers cannot delegate, so a worker's own id never
|
|
699
|
+
* names a family. The caller has claimed it. `settle` settles its live rows instead of keeping
|
|
699
700
|
* them for recovery (`settleOrphanedRun`); `stopId` is the run a Stop settles as cancelled.
|
|
700
701
|
*/
|
|
701
702
|
holdFamily(rootId, decode = (row) => decodeRunRow(row.data), settle = false, stopId) {
|
|
@@ -2934,7 +2935,7 @@ export class RunStore extends EventEmitter {
|
|
|
2934
2935
|
if (run?.delegation?.role === 'invalid')
|
|
2935
2936
|
return false;
|
|
2936
2937
|
if (run?.delegation?.role === 'worker')
|
|
2937
|
-
return
|
|
2938
|
+
return this.workerDeletionEvidence(id);
|
|
2938
2939
|
const privateWorkers = workerEvidenceRunIds(this.dataDir);
|
|
2939
2940
|
if (!privateWorkers || privateWorkers.includes(id))
|
|
2940
2941
|
return false;
|