@hearsay-tools/squawk 0.18.0-dev.6799 → 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 +27 -2
- package/dist/contract/run-predicates.d.ts +28 -1
- package/dist/contract/runs.d.ts +4 -0
- 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/conversations.d.ts +2 -0
- package/dist/delegation/execution-identity.d.ts +13 -5
- package/dist/delegation/execution-identity.js +21 -8
- package/dist/delegation/execution-identity.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 +25 -21
- 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 +82 -78
- 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/run-exits.d.ts +4 -0
- package/dist/runs/store.d.ts +23 -8
- 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/activity-routes.d.ts +23 -23
- package/dist/server/open-in-targets.js +5 -4
- package/dist/server/open-in-targets.js.map +1 -1
- package/dist/server/provider-auth-runtime.js +2 -1
- package/dist/server/provider-auth-runtime.js.map +1 -1
- package/dist/server/server.d.ts +1659 -1633
- package/dist/server/server.js +4 -7
- package/dist/server/server.js.map +1 -1
- 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/continuation-admission.d.ts +8 -1
- package/dist/workflows/continuation-admission.js +12 -7
- package/dist/workflows/continuation-admission.js.map +1 -1
- package/dist/workflows/execution-account.js +4 -3
- package/dist/workflows/execution-account.js.map +1 -1
- 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 +4 -2
- package/dist/workflows/run/compose.js.map +1 -1
- package/dist/workflows/run/continuation-acceptance.js +2 -1
- package/dist/workflows/run/continuation-acceptance.js.map +1 -1
- package/dist/workflows/run/continuation-session.js +5 -3
- package/dist/workflows/run/continuation-session.js.map +1 -1
- package/dist/workflows/run/human-waits.js +2 -0
- package/dist/workflows/run/human-waits.js.map +1 -1
- package/dist/workflows/run/input-delivery.d.ts +16 -0
- package/dist/workflows/run/input-delivery.js +51 -4
- package/dist/workflows/run/input-delivery.js.map +1 -1
- package/dist/workflows/run/input-receipts.d.ts +1 -0
- package/dist/workflows/run/input-receipts.js +1 -0
- package/dist/workflows/run/input-receipts.js.map +1 -1
- package/dist/workflows/run/launch-read-resolver.d.ts +3 -1
- package/dist/workflows/run/launch-read-resolver.js +11 -4
- package/dist/workflows/run/launch-read-resolver.js.map +1 -1
- package/dist/workflows/run/queued-revival.js +2 -1
- package/dist/workflows/run/queued-revival.js.map +1 -1
- package/dist/workflows/run/run-settlement.d.ts +1 -1
- package/dist/workflows/run/run-settlement.js +3 -3
- package/dist/workflows/run/run-settlement.js.map +1 -1
- package/dist/workflows/run/session-events.js +6 -3
- package/dist/workflows/run/session-events.js.map +1 -1
- package/dist/workflows/run/step-loop.d.ts +2 -2
- package/dist/workflows/run/step-loop.js +6 -4
- 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/turn-boundary.d.ts +16 -4
- package/dist/workflows/run/turn-boundary.js +6 -12
- package/dist/workflows/run/turn-boundary.js.map +1 -1
- package/dist/workflows/run/turn-nudges.d.ts +6 -0
- package/dist/workflows/run/turn-nudges.js +21 -2
- package/dist/workflows/run/turn-nudges.js.map +1 -1
- package/dist/workflows/run/turn-settler.js +6 -5
- package/dist/workflows/run/turn-settler.js.map +1 -1
- package/dist/workflows/run/wait-engine.d.ts +1 -0
- package/dist/workflows/run/wake-admission.d.ts +12 -0
- package/dist/workflows/run/wake-admission.js +27 -1
- package/dist/workflows/run/wake-admission.js.map +1 -1
- package/dist/workflows/run/wake-ledger.d.ts +8 -1
- package/dist/workflows/run/wake-ledger.js +12 -2
- package/dist/workflows/run/wake-ledger.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-gOopdagH.js → activity-motion-AuQA350-.js} +1 -1
- package/web/dist/assets/{activity-route-D7bDtXpW.js → activity-route-BNZ9bOOZ.js} +1 -1
- package/web/dist/assets/{agent-accounts-otlDWnij.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-iQf0Rlcx.js → commit-diff-panel-DBW7us79.js} +1 -1
- package/web/dist/assets/{diff-DQfcliZC.js → diff-C3Cms5Ep.js} +2 -2
- package/web/dist/assets/{diff-view-BbM-71Cs.js → diff-view-D5zTYOKV.js} +1 -1
- package/web/dist/assets/{file-preview-DgU8vo8k.js → file-preview-FhzIdXZ3.js} +1 -1
- package/web/dist/assets/git-toolbar-MFjkjDDG.js +1 -0
- package/web/dist/assets/{github-hXmxAXmA.js → github-CYmdc5Dh.js} +1 -1
- package/web/dist/assets/{global-activity-route-D_r1ImUh.js → global-activity-route-C41ofuHV.js} +1 -1
- package/web/dist/assets/index-e1OpsDKN.js +17 -0
- package/web/dist/assets/{live-protocol-aMLJJ0MQ.js → live-protocol-B8boP96Z.js} +1 -1
- package/web/dist/assets/{preview-pane-connected-D__9JwyU.js → preview-pane-connected-Ds209_UZ.js} +1 -1
- package/web/dist/assets/{project-router-WQWd3UUn.js → project-router-F1inY-EB.js} +1 -1
- package/web/dist/assets/{project-scope-context-bgdvGX9z.js → project-scope-context-0Z0nsheq.js} +2 -2
- package/web/dist/assets/{prompt-template-menu-BJfUg1uF.js → prompt-template-menu-uUjg9v98.js} +1 -1
- package/web/dist/assets/{queries-BJM44umy.js → queries-7W9tOZsg.js} +1 -1
- package/web/dist/assets/{reference-chip-vraIzoEF.js → reference-chip-BqRpnpaI.js} +1 -1
- package/web/dist/assets/{repo-git-B4qZq37d.js → repo-git-BZcRanYE.js} +1 -1
- package/web/dist/assets/{report-reader-Djix-ICM.js → report-reader-BLlV3dPF.js} +1 -1
- package/web/dist/assets/{reports-Do-dkavq.js → reports-C--EXqf1.js} +1 -1
- package/web/dist/assets/{run-header-Di9LaKQs.js → run-header-CJg8dyfz.js} +1 -1
- package/web/dist/assets/{skills-CPnIvFnR.js → skills-CHWVejdV.js} +1 -1
- package/web/dist/assets/{tab-link-DiNYVlpl.js → tab-link-XI9xWLwR.js} +1 -1
- package/web/dist/assets/{task-changes-CW7NzgL5.js → task-changes-DFm_EHnj.js} +1 -1
- package/web/dist/assets/{task-commits-Bkwi7o1B.js → task-commits-BX-GVdXG.js} +1 -1
- package/web/dist/assets/{task-files-geRzIszC.js → task-files-Dsn11PYu.js} +1 -1
- package/web/dist/assets/task-github-item-3N6jEijR.js +1 -0
- package/web/dist/assets/task-thread-VNPhkI8i.js +9 -0
- package/web/dist/assets/{thread-state-CajkV5Ft.js → thread-state-D1XLo7ab.js} +1 -1
- package/web/dist/assets/use-desktop-DdcA0Atl.js +1 -0
- package/web/dist/assets/use-hand-to-agent-state-2tzEmCDo.js +1 -0
- package/web/dist/assets/{useInfiniteQuery-s3lTx_YX.js → useInfiniteQuery-BmmIZbVY.js} +1 -1
- package/web/dist/assets/useQuery-CBKC2lBX.js +1 -0
- package/web/dist/assets/{workflows-Csr2hbks.js → workflows-CqqdPBFr.js} +1 -1
- package/web/dist/assets/{ws-WW6DrfbT.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-CVI366xV.js +0 -1
- package/web/dist/assets/git-toolbar-C8agvpYS.js +0 -1
- package/web/dist/assets/index-tN02NX7A.js +0 -17
- package/web/dist/assets/task-github-item-UbCCP2Ud.js +0 -1
- package/web/dist/assets/task-thread-CkiEiypn.js +0 -9
- package/web/dist/assets/use-desktop-Ct4lvA3b.js +0 -1
- package/web/dist/assets/use-hand-to-agent-state-Cnxq_2F6.js +0 -1
- package/web/dist/assets/useQuery-C0ee1rw5.js +0 -1
package/dist/runs/store.js
CHANGED
|
@@ -6,7 +6,7 @@ import { productEnv } from '../core/product-env.js';
|
|
|
6
6
|
import { registeredWaitRecord, registeredReceiptRecord } from './wait-registration-write.js';
|
|
7
7
|
import { stageCommit, stageLoaded, stageDurableUpdate, stageDebouncedUpdate, stageConversation, stageArchiveFields, stagePullRequests, stageStepUpdate, redactPatch, redactText, clearPin } from './record-write-rules.js';
|
|
8
8
|
import { workerDeletionProof } from './worker-deletion-proof.js';
|
|
9
|
-
import {
|
|
9
|
+
import { recordedHolders, workerResourceAuthorized } from './worker-resource-holders.js';
|
|
10
10
|
import { listPeerTaskSummaries, parseStoredSummary } from './run-summary-page.js';
|
|
11
11
|
export { parseStoredSummary } from './run-summary-page.js';
|
|
12
12
|
import { defined } from '../core/defined.js';
|
|
@@ -18,9 +18,12 @@ import { jobRunsIn } from '../jobs/job.js';
|
|
|
18
18
|
import { removeArtifacts } from '../artifacts/lifecycle.js';
|
|
19
19
|
import { randomUUID, createHash } from 'node:crypto';
|
|
20
20
|
import { isDeepStrictEqual } from 'node:util';
|
|
21
|
-
import { appendFileSync, closeSync, constants, fstatSync, fsyncSync, lstatSync, openSync, readSync, realpathSync, existsSync, mkdirSync, readFileSync,
|
|
21
|
+
import { appendFileSync, closeSync, constants, fstatSync, fsyncSync, lstatSync, openSync, readSync, realpathSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
22
22
|
import { join, resolve } from 'node:path';
|
|
23
23
|
import { z } from 'zod';
|
|
24
|
+
import { scopeRecordSchema } from '../worker-scope/scope.js';
|
|
25
|
+
import { WorkerScopes } from '../worker-scope/worker-scopes.js';
|
|
26
|
+
import { readPrivateRecord, writePrivateRecord } from './private-record-file.js';
|
|
24
27
|
import { agentInputSchema, inboxClaimSchema, delegationStateSchema, workerResultFileSchema, workerDestroyRetrySchema, } from '../contract/index.js';
|
|
25
28
|
import { automationIdOf, stepStateSchema as contractStepStateSchema, queuedMessageSchema, toRunSummary, runRecordSchema as contractRunRecordSchema, runPullRequestSchema, mergedPullRequestSchema, } from '../contract/index.js';
|
|
26
29
|
import { previewServerSchema } from '../contract/index.js';
|
|
@@ -33,7 +36,7 @@ import { LiveItemSnapshots } from './live-item-snapshots.js';
|
|
|
33
36
|
import { emptyFacts, stampOf, TranscriptFactsIndex } from './transcript-facts.js';
|
|
34
37
|
import { hasPlainHistory, historyPaths, readHistoryText, readHistoryTextAsync, removeHistory, restoreHistory } from './history-file.js';
|
|
35
38
|
import { workerExecutionIdentitySchema } from '../delegation/execution-identity.js';
|
|
36
|
-
import {
|
|
39
|
+
import { processStartToken } from '../delegation/process-liveness.js';
|
|
37
40
|
import { collectSecretValues, redactDeep } from '../core/secret-redaction.js';
|
|
38
41
|
// Pure, dependency-free reference helpers — the same sanity bound the marker parser applies.
|
|
39
42
|
import { archivePullRequests, pullRequestKey } from './pull-requests.js';
|
|
@@ -447,6 +450,8 @@ export class RunStore extends EventEmitter {
|
|
|
447
450
|
dirty = new Set();
|
|
448
451
|
/** The lifecycle events run exits write (B12). */
|
|
449
452
|
exitEvents = new ExitEvents((id, event) => this.appendEvent(id, event));
|
|
453
|
+
/** Every worker's process scope (ADR 0032): spawn sites, Continue and destroy reach it here. */
|
|
454
|
+
scopes = new WorkerScopes(this);
|
|
450
455
|
/** Runs gone from memory whose rows the next save or commit deletes. */
|
|
451
456
|
deleted = new Set();
|
|
452
457
|
/** Deleted runs whose history files (events, handoff, images, artifacts) go once the delete of
|
|
@@ -2728,55 +2733,21 @@ export class RunStore extends EventEmitter {
|
|
|
2728
2733
|
}
|
|
2729
2734
|
readWorkerExecution(id) {
|
|
2730
2735
|
try {
|
|
2731
|
-
const
|
|
2732
|
-
|
|
2733
|
-
try {
|
|
2734
|
-
const info = fstatSync(fd);
|
|
2735
|
-
if (!info.isFile() || info.size > 16384 || (info.mode & 0o077))
|
|
2736
|
-
return undefined;
|
|
2737
|
-
const buffer = Buffer.alloc(16385);
|
|
2738
|
-
const count = readSync(fd, buffer, 0, buffer.length, 0);
|
|
2739
|
-
return workerExecutionSchema.parse(JSON.parse(buffer.subarray(0, count).toString('utf8')));
|
|
2740
|
-
}
|
|
2741
|
-
finally {
|
|
2742
|
-
closeSync(fd);
|
|
2743
|
-
}
|
|
2736
|
+
const proof = readPrivateRecord(this.executionPath(id), 16384, value => workerExecutionSchema.parse(value));
|
|
2737
|
+
return typeof proof === 'string' ? undefined : proof;
|
|
2744
2738
|
}
|
|
2745
2739
|
catch {
|
|
2746
2740
|
return undefined;
|
|
2747
2741
|
}
|
|
2748
2742
|
}
|
|
2749
2743
|
writeWorkerExecution(id, proof, fresh = false) {
|
|
2750
|
-
|
|
2751
|
-
try {
|
|
2752
|
-
const existing = lstatSync(path);
|
|
2753
|
-
if (fresh || !existing.isFile() || existing.isSymbolicLink())
|
|
2754
|
-
throw new Error('Unsafe execution checkpoint');
|
|
2755
|
-
}
|
|
2756
|
-
catch (error) {
|
|
2757
|
-
if (error.code !== 'ENOENT')
|
|
2758
|
-
throw error;
|
|
2759
|
-
}
|
|
2760
|
-
const temporary = `${path}.${randomUUID()}.tmp`;
|
|
2761
|
-
const fd = openSync(temporary, constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | constants.O_NOFOLLOW, 0o600);
|
|
2762
|
-
try {
|
|
2763
|
-
writeFileSync(fd, JSON.stringify(proof));
|
|
2764
|
-
fsyncSync(fd);
|
|
2765
|
-
}
|
|
2766
|
-
finally {
|
|
2767
|
-
closeSync(fd);
|
|
2768
|
-
}
|
|
2769
|
-
try {
|
|
2770
|
-
renameSync(temporary, path);
|
|
2771
|
-
}
|
|
2772
|
-
finally {
|
|
2773
|
-
rmSync(temporary, { force: true });
|
|
2774
|
-
}
|
|
2744
|
+
writePrivateRecord(this.executionPath(id, true), proof, { fresh });
|
|
2775
2745
|
}
|
|
2776
2746
|
/** Complete execution is not permission to reuse/delete persistent resources (#738).
|
|
2777
2747
|
* Synchronous, fresh and generation/resource fenced; callers hold admission off across awaits. */
|
|
2778
2748
|
workerResourcesSafe(id, generation, resourceId) {
|
|
2779
|
-
|
|
2749
|
+
// Reclaim and history deletion also need an empty scope; admission does not (ADR 0032).
|
|
2750
|
+
return this.workerResourceHolders(id, generation, resourceId) === 'safe' && this.scopes.empty(id);
|
|
2780
2751
|
}
|
|
2781
2752
|
/** `workerResourcesSafe` with the refusal's live PIDs (empty when no PID explains it). */
|
|
2782
2753
|
workerResourceHolders(id, generation, resourceId, opts = {}) {
|
|
@@ -2789,13 +2760,8 @@ export class RunStore extends EventEmitter {
|
|
|
2789
2760
|
const record = this.readWorkerProcesses(id, generation);
|
|
2790
2761
|
if (record === 'unknown' || !agentTmpDirOwnershipProven(this.dataDir, id))
|
|
2791
2762
|
return [];
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
// retire completed cleanup despite ambient denial, while recorded survivors/unknown evidence
|
|
2795
|
-
// still block. Only ENOENT proves absence; existsSync would also hide access errors.
|
|
2796
|
-
if (workerResourcePathsGone(paths))
|
|
2797
|
-
return workerResourceAbsentHolders(record);
|
|
2798
|
-
return workerResourceLiveHolders(inspectGeneration({ ...(record === 'absent' ? {} : { record }), paths, cwds: opts.cwds }));
|
|
2763
|
+
// Only the generation's recorded processes count; an outside process blocks nothing (ADR 0032).
|
|
2764
|
+
return recordedHolders(record);
|
|
2799
2765
|
}
|
|
2800
2766
|
/** Upgrade a legacy completed checkpoint while terminal task ownership is still known.
|
|
2801
2767
|
* No holder scan here: settlement and scheduling must never wait on cleanup proof. */
|
|
@@ -2808,18 +2774,18 @@ export class RunStore extends EventEmitter {
|
|
|
2808
2774
|
return;
|
|
2809
2775
|
this.writeWorkerExecution(id, { ...proof, scratchCleanup: { resourceId, path } });
|
|
2810
2776
|
}
|
|
2811
|
-
/** Cleanup can outlive its index row, but never its generation or terminal task intent.
|
|
2812
|
-
|
|
2813
|
-
workerScratchResourcesSafe(id, generation, resourceId, cwds) {
|
|
2777
|
+
/** Cleanup can outlive its index row, but never its generation or terminal task intent. */
|
|
2778
|
+
workerScratchResourcesSafe(id, generation, resourceId) {
|
|
2814
2779
|
if (autosaveCleanupBlocker(this.dataDir, id))
|
|
2815
2780
|
return false;
|
|
2816
2781
|
const run = this.peek(id), proof = this.readWorkerExecution(id);
|
|
2817
2782
|
if (proof?.phase !== 'complete' || proof.generation !== generation || proof.scratchCleanup?.resourceId !== resourceId ||
|
|
2818
2783
|
(run && ['queued', 'running', 'waiting'].includes(run.status)))
|
|
2819
2784
|
return false;
|
|
2785
|
+
// A process still in the worker's scope may use its scratch; one outside it is not the worker's.
|
|
2820
2786
|
if (run?.delegation?.role === 'worker')
|
|
2821
2787
|
return run.delegation.workspace.path === proof.scratchCleanup.path &&
|
|
2822
|
-
this.workerResourceHolders(id, generation, resourceId
|
|
2788
|
+
this.workerResourceHolders(id, generation, resourceId) === 'safe' && this.scopes.empty(id);
|
|
2823
2789
|
// A valid different role contradicts the retained intent. Quarantined/missing metadata
|
|
2824
2790
|
// supplies no new authority; only the private terminal checkpoint authorizes scratch.
|
|
2825
2791
|
if (run && run.delegation?.role !== 'invalid')
|
|
@@ -2827,8 +2793,7 @@ export class RunStore extends EventEmitter {
|
|
|
2827
2793
|
const record = this.readWorkerProcesses(id, generation);
|
|
2828
2794
|
if (record === 'unknown' || !agentTmpDirOwnershipProven(this.dataDir, id))
|
|
2829
2795
|
return false;
|
|
2830
|
-
return
|
|
2831
|
-
paths: [proof.scratchCleanup.path, ...agentTmpDirLocations(this.dataDir, id)], cwds }).liveness === 'gone';
|
|
2796
|
+
return recordedHolders(record) === 'safe' && this.scopes.empty(id);
|
|
2832
2797
|
}
|
|
2833
2798
|
commitWorkerExecutionStart(id) {
|
|
2834
2799
|
const run = this.peek(id);
|
|
@@ -2851,51 +2816,28 @@ export class RunStore extends EventEmitter {
|
|
|
2851
2816
|
/** Tri-state: only ENOENT is `absent` (legacy, scan-only). A present record that is unreadable,
|
|
2852
2817
|
* wrongly permissioned, malformed or of another generation is `unknown`: never finalized or reaped. */
|
|
2853
2818
|
readWorkerProcesses(id, generation) {
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
try {
|
|
2857
|
-
const info = fstatSync(fd);
|
|
2858
|
-
if (!info.isFile() || info.size > 8192 || (info.mode & 0o077))
|
|
2859
|
-
return 'unknown';
|
|
2860
|
-
const buffer = Buffer.alloc(8193);
|
|
2861
|
-
const count = readSync(fd, buffer, 0, buffer.length, 0);
|
|
2862
|
-
const record = workerProcessRecordSchema.parse(JSON.parse(buffer.subarray(0, count).toString('utf8')));
|
|
2863
|
-
return record.generation === generation ? record : 'unknown';
|
|
2864
|
-
}
|
|
2865
|
-
finally {
|
|
2866
|
-
closeSync(fd);
|
|
2867
|
-
}
|
|
2868
|
-
}
|
|
2869
|
-
catch (error) {
|
|
2870
|
-
return error.code === 'ENOENT' ? 'absent' : 'unknown';
|
|
2871
|
-
}
|
|
2819
|
+
const record = readPrivateRecord(() => this.processesPath(id), 8192, value => workerProcessRecordSchema.parse(value));
|
|
2820
|
+
return typeof record === 'string' || record.generation === generation ? record : 'unknown';
|
|
2872
2821
|
}
|
|
2873
2822
|
writeWorkerProcesses(id, record) {
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
}
|
|
2893
|
-
try {
|
|
2894
|
-
renameSync(temporary, path);
|
|
2895
|
-
}
|
|
2896
|
-
finally {
|
|
2897
|
-
rmSync(temporary, { force: true });
|
|
2898
|
-
}
|
|
2823
|
+
writePrivateRecord(this.processesPath(id, true), workerProcessRecordSchema.parse(record));
|
|
2824
|
+
}
|
|
2825
|
+
/** Private scope record: the cgroups and process groups the worker owns (ADR 0032). */
|
|
2826
|
+
scopePath(id, write = false) {
|
|
2827
|
+
return this.executionPath(id, write).replace(/\.execution\.json$/, '.scope.json');
|
|
2828
|
+
}
|
|
2829
|
+
/** Tri-state like the process record: only ENOENT is `absent`. */
|
|
2830
|
+
readWorkerScope(id) {
|
|
2831
|
+
const record = readPrivateRecord(() => this.scopePath(id), 65_536, value => scopeRecordSchema.parse(value));
|
|
2832
|
+
return typeof record === 'string' || record.workerId === id ? record : 'unknown';
|
|
2833
|
+
}
|
|
2834
|
+
/** Durable before the caller acts on it. */
|
|
2835
|
+
writeWorkerScope(id, record) {
|
|
2836
|
+
writePrivateRecord(this.scopePath(id, true), scopeRecordSchema.parse(record));
|
|
2837
|
+
}
|
|
2838
|
+
/** The scope a run's processes start in: a worker's own, none for any other run (ADR 0032). */
|
|
2839
|
+
spawnScope(id) {
|
|
2840
|
+
return this.peek(id)?.delegation?.role === 'worker' ? this.scopes.spawnScope(id) : undefined;
|
|
2899
2841
|
}
|
|
2900
2842
|
/** Bound to the current generation. Past the cap the record never drops an entry: the
|
|
2901
2843
|
* working-directory scan is the remaining evidence. */
|
|
@@ -2911,7 +2853,7 @@ export class RunStore extends EventEmitter {
|
|
|
2911
2853
|
this.writeWorkerProcesses(id, { ...record, processes: [...record.processes, entry] });
|
|
2912
2854
|
return true;
|
|
2913
2855
|
}
|
|
2914
|
-
commitWorkerExecutionComplete(id, generation) {
|
|
2856
|
+
commitWorkerExecutionComplete(id, generation, opts = {}) {
|
|
2915
2857
|
const proof = this.readWorkerExecution(id);
|
|
2916
2858
|
if (!proof || proof.generation !== generation)
|
|
2917
2859
|
return false;
|
|
@@ -2927,6 +2869,7 @@ export class RunStore extends EventEmitter {
|
|
|
2927
2869
|
this.writeWorkerExecution(id, { generation, phase: 'complete',
|
|
2928
2870
|
// Nothing abandons an execution any more (hearsay-tools/cezarion#889); keep a checkpoint that already was.
|
|
2929
2871
|
...(proof.abandoned ? { abandoned: true } : {}),
|
|
2872
|
+
...(proof.interrupted || (opts.interrupted && proof.phase === 'starting') ? { interrupted: true } : {}),
|
|
2930
2873
|
...(proof.phase === 'queued' || proof.neverMaterialized ? { neverMaterialized: true } : {}),
|
|
2931
2874
|
...(!['queued', 'running', 'waiting'].includes(run.status) ? { scratchCleanup: {
|
|
2932
2875
|
resourceId: run.delegation.workspace.resourceId, path: run.delegation.workspace.path
|
|
@@ -3042,6 +2985,7 @@ export class RunStore extends EventEmitter {
|
|
|
3042
2985
|
// Private process/account evidence is now replaced by the exact parent receipt.
|
|
3043
2986
|
rmSync(this.identityPath(id), { force: true });
|
|
3044
2987
|
rmSync(this.processesPath(id), { force: true });
|
|
2988
|
+
rmSync(this.scopePath(id), { force: true });
|
|
3045
2989
|
rmSync(this.executionPath(id), { force: true });
|
|
3046
2990
|
const retained = this.readWorkerResult(parent.id, id);
|
|
3047
2991
|
this.commitWorkerResult(parent.id, { ...retained, observedAt: new Date().toISOString(),
|