@hearsay-tools/squawk 0.19.0-dev.9220 → 0.19.0-dev.9235
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/activity/read-model.js +5 -2
- package/dist/activity/read-model.js.map +1 -1
- package/dist/contract/hosts.d.ts +3 -0
- package/dist/contract/index.d.ts +1 -0
- package/dist/contract/index.js +2257 -1939
- package/dist/contract/projects.d.ts +6 -0
- package/dist/contract/runs.d.ts +117 -0
- package/dist/contract/task-result.d.ts +1075 -0
- package/dist/core/forge-registry.d.ts +8 -0
- package/dist/core/forge-registry.js +36 -13
- package/dist/core/forge-registry.js.map +1 -1
- package/dist/delegation/readiness.d.ts +8 -5
- package/dist/delegation/readiness.js +23 -9
- package/dist/delegation/readiness.js.map +1 -1
- package/dist/delegation/routes.d.ts +4 -4
- package/dist/delegation/service.js +4 -2
- package/dist/delegation/service.js.map +1 -1
- package/dist/delegation/worker-cleanup.js +1 -1
- package/dist/delegation/worker-cleanup.js.map +1 -1
- package/dist/features/hosts/routes.d.ts +2 -0
- package/dist/features/webhooks/routes.d.ts +3 -0
- package/dist/project-migration/journal.d.ts +2 -0
- package/dist/project-migration/journal.js +1 -1
- package/dist/project-migration/journal.js.map +1 -1
- package/dist/project-migration/plan.js +2 -0
- package/dist/project-migration/plan.js.map +1 -1
- package/dist/runs/legacy-run-rows.d.ts +1 -1
- package/dist/runs/legacy-run-rows.js +7 -3
- package/dist/runs/legacy-run-rows.js.map +1 -1
- package/dist/runs/ports.d.ts +16 -1
- package/dist/runs/project-run-connection.d.ts +3 -0
- package/dist/runs/project-run-connection.js +57 -10
- package/dist/runs/project-run-connection.js.map +1 -1
- package/dist/runs/project-run-sources.d.ts +6 -0
- package/dist/runs/project-run-sources.js +20 -0
- package/dist/runs/project-run-sources.js.map +1 -1
- package/dist/runs/run-archive.d.ts +19 -0
- package/dist/runs/run-decode.d.ts +58 -0
- package/dist/runs/run-decode.js +10 -0
- package/dist/runs/run-decode.js.map +1 -1
- package/dist/runs/run-exits.d.ts +114 -0
- package/dist/runs/run-retention.d.ts +2 -0
- package/dist/runs/run-retention.js +11 -2
- package/dist/runs/run-retention.js.map +1 -1
- package/dist/runs/store.d.ts +3 -0
- package/dist/runs/store.js +11 -5
- package/dist/runs/store.js.map +1 -1
- package/dist/runs/task-result-commit.d.ts +24 -0
- package/dist/runs/task-result-commit.js +114 -0
- package/dist/runs/task-result-commit.js.map +1 -0
- package/dist/runs/task-results.d.ts +61 -0
- package/dist/runs/task-results.js +220 -0
- package/dist/runs/task-results.js.map +1 -0
- package/dist/runs/worker-result-commit.d.ts +12 -12
- package/dist/runs/worker-result-commit.js +77 -55
- package/dist/runs/worker-result-commit.js.map +1 -1
- package/dist/runs/worker-results.d.ts +10 -26
- package/dist/runs/worker-results.js +11 -73
- package/dist/runs/worker-results.js.map +1 -1
- package/dist/server/projects-routes.d.ts +6 -0
- package/dist/server/runs-routes.d.ts +189 -18
- package/dist/server/server.d.ts +1666 -1318
- package/dist/workflows/continuation-admission.d.ts +91 -72
- package/dist/workflows/input-acknowledgement.d.ts +24 -24
- package/dist/workflows/run/completion-gate.js +10 -4
- package/dist/workflows/run/completion-gate.js.map +1 -1
- package/dist/workflows/run/wait-engine.d.ts +91 -72
- package/dist/workspace/projects.d.ts +5 -0
- package/dist/workspace/projects.js +8 -2
- package/dist/workspace/projects.js.map +1 -1
- package/package.json +4 -4
- package/web/dist/assets/accounts-section-BOZ9JyE6.js +1 -0
- package/web/dist/assets/{activity-motion-CXlbNrMI.js → activity-motion-D48R7Vry.js} +1 -1
- package/web/dist/assets/{activity-route-BL-QWLNp.js → activity-route-jcGRtnMT.js} +1 -1
- package/web/dist/assets/{agent-accounts-Du8CHfFX.js → agent-accounts-CUthX0Yh.js} +1 -1
- package/web/dist/assets/{agent-config-section-BzMSlPK0.js → agent-config-section-BvwoyNZb.js} +1 -1
- package/web/dist/assets/{agent-defaults-section-CqEVmRK0.js → agent-defaults-section-Hb-jy4TN.js} +1 -1
- package/web/dist/assets/{appearance-vI6ae_So.js → appearance-EXKzoghV.js} +1 -1
- package/web/dist/assets/{archive-on-merge-field-C4hrO55O.js → archive-on-merge-field-Ni7bKGkG.js} +1 -1
- package/web/dist/assets/{ask-card-hEb8IHjL.js → ask-card-CkE44gm3.js} +3 -3
- package/web/dist/assets/automations-route-3bhtdTy3.js +2 -0
- package/web/dist/assets/{commit-list-Jr1_04RS.js → commit-list-DSw7qvVY.js} +1 -1
- package/web/dist/assets/{diff-BOF9OXhn.js → diff-BidPzsVK.js} +2 -2
- package/web/dist/assets/{diff-controls-CkxtRrbB.js → diff-controls-DeMSGYln.js} +1 -1
- package/web/dist/assets/{diff-view-Chu6rn_i.js → diff-view-BqU4sJld.js} +1 -1
- package/web/dist/assets/{discard-changes-dialog-BB47RqdX.js → discard-changes-dialog-B1AO0GSt.js} +1 -1
- package/web/dist/assets/{file-preview-DNM-krBZ.js → file-preview-BIZXTzkp.js} +1 -1
- package/web/dist/assets/{folder-browser-TNWat5kt.js → folder-browser-C9Phl0rS.js} +1 -1
- package/web/dist/assets/{git-toolbar-CoKBTzNV.js → git-toolbar-BBon1yHh.js} +1 -1
- package/web/dist/assets/{github-t611QkCi.js → github-QOB5Qi4v.js} +1 -1
- package/web/dist/assets/{global-activity-route-B9DMoviv.js → global-activity-route-lSnYAZE9.js} +1 -1
- package/web/dist/assets/{host-context-iTMFRMT5.js → host-context-KsSKxKbI.js} +1 -1
- package/web/dist/assets/host-storage-BHtMSWBL.js +1 -0
- package/web/dist/assets/{hosts-rdWe_OBc.js → hosts-DDwDUxT9.js} +1 -1
- package/web/dist/assets/{image-preview-C_xACQXI.js → image-preview-CvcSCCBU.js} +1 -1
- package/web/dist/assets/index-BuR9xHfb.js +21 -0
- package/web/dist/assets/index-DZXi-K2N.css +1 -0
- package/web/dist/assets/{label-B_s8eiYA.js → label-D6vgq5lF.js} +1 -1
- package/web/dist/assets/{markdown-Bmdr6MIa.js → markdown-A6dvDky9.js} +1 -1
- package/web/dist/assets/{open-in-menu-DkFneOWr.js → open-in-menu-Bb_jc7pm.js} +1 -1
- package/web/dist/assets/{option-select-BxTmKg8G.js → option-select-CCpypHbW.js} +1 -1
- package/web/dist/assets/{preferences-section-B_yl_o-g.js → preferences-section-B75Zx0mY.js} +1 -1
- package/web/dist/assets/{preview-D3zYSmIA.js → preview-DiBpgf-5.js} +1 -1
- package/web/dist/assets/{preview-pane-connected-s9LvCVbp.js → preview-pane-connected-BVu2oO0V.js} +2 -2
- package/web/dist/assets/{project-location-BczZtNyO.js → project-location-D1etWKHg.js} +1 -1
- package/web/dist/assets/{project-router-CfEuKuz1.js → project-router-yoWCTDaT.js} +1 -1
- package/web/dist/assets/project-scope-context-hfRzPMZ4.js +4 -0
- package/web/dist/assets/{projects-section-C6DnyUa2.js → projects-section-BRnIJ47e.js} +1 -1
- package/web/dist/assets/{prompt-templates-section-BQvKWcaX.js → prompt-templates-section-D7JLM5BM.js} +2 -2
- package/web/dist/assets/queries-ChH9ctc-.js +1 -0
- package/web/dist/assets/{reference-chip-e-fG4-yW.js → reference-chip-BPRZm7Kb.js} +1 -1
- package/web/dist/assets/{remote-settings-notice-CUqI2DdF.js → remote-settings-notice-Ip6H5hLU.js} +1 -1
- package/web/dist/assets/{repo-git-NG_TxE7N.js → repo-git-Wf30akEt.js} +1 -1
- package/web/dist/assets/{report-reader-LYNHrAe-.js → report-reader-DhcZcNql.js} +1 -1
- package/web/dist/assets/{report-selection-nUbQVjJu.js → report-selection-CwPw7vbG.js} +1 -1
- package/web/dist/assets/{reports-DuT4m7i5.js → reports-DPKDwzxY.js} +1 -1
- package/web/dist/assets/{resources-section-CT48TCXY.js → resources-section-DaWcyqur.js} +1 -1
- package/web/dist/assets/{review-notes-drafts-C7HCRebB.js → review-notes-drafts-D7QuBuTL.js} +1 -1
- package/web/dist/assets/{review-panel-BffLSkRo.js → review-panel-Bpxl4TvO.js} +1 -1
- package/web/dist/assets/{review-strip-COa0ir6V.js → review-strip-Da5n1k8s.js} +1 -1
- package/web/dist/assets/{run-detail-refresh-Db5HOGMX.js → run-detail-refresh-CVSK_VKG.js} +1 -1
- package/web/dist/assets/{run-diff-DldSY8BJ.js → run-diff-CPuNFD3X.js} +1 -1
- package/web/dist/assets/run-header-B8EAOHFc.js +2 -0
- package/web/dist/assets/{select-Cd8wvwvm.js → select-xjUzLrk9.js} +1 -1
- package/web/dist/assets/{session-context-section-CW8DS0dW.js → session-context-section-C7OTexKU.js} +1 -1
- package/web/dist/assets/{settings-agent-picker-an3ysM1B.js → settings-agent-picker-mESK-hj4.js} +1 -1
- package/web/dist/assets/{settings-save-bar-BiHFQ4c0.js → settings-save-bar-BUaa1kHw.js} +1 -1
- package/web/dist/assets/{settings-shell-KZ801oLH.js → settings-shell-BKSsBxqQ.js} +1 -1
- package/web/dist/assets/{sidebar-section-BRMO7aY4.js → sidebar-section-BFBZlQ-x.js} +1 -1
- package/web/dist/assets/{skills-DHkLoxXb.js → skills-BSqszv5g.js} +1 -1
- package/web/dist/assets/{status-dot-Da1M54kK.js → status-dot-Fp5SnPHI.js} +1 -1
- package/web/dist/assets/{tab-link-DL1UtKVR.js → tab-link-j06AaWSU.js} +1 -1
- package/web/dist/assets/{task-changes-CQhwyj0L.js → task-changes-B4KFHxVa.js} +2 -2
- package/web/dist/assets/{task-commits-CTP8izpc.js → task-commits-D-UAUoZ5.js} +1 -1
- package/web/dist/assets/{task-file-scope-CDIfOvl-.js → task-file-scope-BhWG35a8.js} +1 -1
- package/web/dist/assets/{task-files-CGlRH86B.js → task-files-BOCx_Lp0.js} +1 -1
- package/web/dist/assets/{task-github-item-ChgjULzj.js → task-github-item-CZqaaxNv.js} +1 -1
- package/web/dist/assets/task-thread-D3d419VX.js +2 -0
- package/web/dist/assets/{thread-state-D2KJrZ1o.js → thread-state-B0pz2Y8K.js} +1 -1
- package/web/dist/assets/{use-finish-run-DifixlCM.js → use-finish-run-TX3pIPCS.js} +1 -1
- package/web/dist/assets/{use-hand-to-agent-state-Bjh1EnB3.js → use-hand-to-agent-state-D2oChRzw.js} +1 -1
- package/web/dist/assets/use-path-bases-DFxEHoyU.js +1 -0
- package/web/dist/assets/use-workspace-config-save-DR8brU5p.js +1 -0
- package/web/dist/assets/{workflows-BDc-MpiC.js → workflows-BwzNhxT0.js} +1 -1
- package/web/dist/assets/{workspace-tools-D7kUSb-0.js → workspace-tools-Be_j9oke.js} +1 -1
- package/web/dist/assets/{worktrees-section-Cv65NBgq.js → worktrees-section-cnibWU5-.js} +4 -4
- package/web/dist/assets/{zoomable-image-DJ1lJEMc.js → zoomable-image-Dv85Vr4A.js} +1 -1
- package/web/dist/index.html +17 -17
- package/web/dist/live-worker.js +1 -1
- package/web/dist/assets/accounts-section-s6sAdUT8.js +0 -1
- package/web/dist/assets/automations-route-Bd6crv15.js +0 -2
- package/web/dist/assets/host-storage-Cr_NKfWy.js +0 -1
- package/web/dist/assets/index-C3kap2_j.js +0 -21
- package/web/dist/assets/index-CWmMYQdT.css +0 -1
- package/web/dist/assets/project-scope-context-DNrHbqd2.js +0 -4
- package/web/dist/assets/queries-DD_9iITj.js +0 -1
- package/web/dist/assets/run-header-DxpN6yVQ.js +0 -2
- package/web/dist/assets/task-thread-Cj9B2ISO.js +0 -2
- package/web/dist/assets/use-path-bases-AV9YYh2B.js +0 -1
- package/web/dist/assets/use-workspace-config-save-02qlUK8v.js +0 -1
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import { workerResultFileSchema } from '../contract/index.js';
|
|
2
|
+
import { taskResultFileSchema, taskResultIdSchema, workerResultToStoredTaskResult } from '../contract/index.js';
|
|
3
|
+
import { closeSync, constants, fstatSync, openSync, readSync } from 'node:fs';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import { runDataDir } from '../project-paths.js';
|
|
7
|
+
import { upgradeRemovedRunnerResult } from './legacy-run-rows.js';
|
|
8
|
+
import { bindTaskResultPath, bindWorkerResultPath, taskResultsDirectory, workerResultsDirectory } from './project-run-sources.js';
|
|
9
|
+
import { commitStoreTaskResult } from './task-result-commit.js';
|
|
10
|
+
import { commitStoreWorkerResult } from './worker-result-commit.js';
|
|
11
|
+
const MAX_RESULT_FILE_BYTES = 3_145_728;
|
|
12
|
+
/** Read a regular non-symlink file capped at 3 MiB without blocking on FIFOs. */
|
|
13
|
+
function readBoundedRegularFile(path) {
|
|
14
|
+
const fd = openSync(path, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
|
|
15
|
+
try {
|
|
16
|
+
const info = fstatSync(fd);
|
|
17
|
+
if (!info.isFile() || info.size > MAX_RESULT_FILE_BYTES)
|
|
18
|
+
return undefined;
|
|
19
|
+
const buffer = Buffer.allocUnsafe(Math.min(info.size + 1, MAX_RESULT_FILE_BYTES + 1));
|
|
20
|
+
let offset = 0;
|
|
21
|
+
while (offset < buffer.length) {
|
|
22
|
+
const read = readSync(fd, buffer, offset, buffer.length - offset, null);
|
|
23
|
+
if (read === 0)
|
|
24
|
+
break;
|
|
25
|
+
offset += read;
|
|
26
|
+
}
|
|
27
|
+
if (offset > MAX_RESULT_FILE_BYTES)
|
|
28
|
+
return undefined;
|
|
29
|
+
return buffer.subarray(0, offset).toString('utf8');
|
|
30
|
+
}
|
|
31
|
+
finally {
|
|
32
|
+
closeSync(fd);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function matchesTaskPointer(file, runId, reference) {
|
|
36
|
+
const { result, diffSnapshot } = file;
|
|
37
|
+
const idMatches = 'taskId' in result
|
|
38
|
+
? result.taskId === runId
|
|
39
|
+
: result.workerId === runId && result.workspace.ownerRunId === runId;
|
|
40
|
+
if (!idMatches || result.revision !== reference.revision || result.observedAt !== reference.observedAt)
|
|
41
|
+
return false;
|
|
42
|
+
if (result.diff.state === 'available' && (result.diff.snapshotId !== reference.snapshotId || diffSnapshot === undefined))
|
|
43
|
+
return false;
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
function isWorkerResultFile(file, parentId, workerId) {
|
|
47
|
+
return 'workerId' in file.result && file.result.workerId === workerId && file.result.parentRunId === parentId;
|
|
48
|
+
}
|
|
49
|
+
export class TaskResultsTopic {
|
|
50
|
+
dataDir;
|
|
51
|
+
state;
|
|
52
|
+
constructor(dataDir, state) {
|
|
53
|
+
this.dataDir = dataDir;
|
|
54
|
+
this.state = state;
|
|
55
|
+
}
|
|
56
|
+
taskResultsDir(runId, write = false, familyId) {
|
|
57
|
+
let baseDir;
|
|
58
|
+
if (write) {
|
|
59
|
+
// Assert the owning family is writable before touching disk, then use the task's own dir.
|
|
60
|
+
this.state.writeDir(familyId && !this.state.hasRun(runId) ? familyId : runId);
|
|
61
|
+
baseDir = runDataDir(this.dataDir, runId);
|
|
62
|
+
}
|
|
63
|
+
else if (!this.state.hasRun(runId) && familyId) {
|
|
64
|
+
baseDir = this.state.isFallbackRun(familyId) ? this.state.sourceDataDir(familyId) : runDataDir(this.dataDir, runId);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
baseDir = this.state.sourceDataDir(runId);
|
|
68
|
+
}
|
|
69
|
+
return taskResultsDirectory(baseDir, runId, write);
|
|
70
|
+
}
|
|
71
|
+
legacyWorkerResultsDir(parentId) {
|
|
72
|
+
return workerResultsDirectory(this.state.sourceDataDir(parentId), parentId, false);
|
|
73
|
+
}
|
|
74
|
+
taskResultSnapshotPath(runId, snapshotId) {
|
|
75
|
+
return join(runDataDir(this.dataDir, runId), 'runs', `${taskResultIdSchema.parse(runId)}-results`, `${z.uuid().parse(snapshotId)}.json`);
|
|
76
|
+
}
|
|
77
|
+
workerResultSnapshotPath(parentId, workerId, snapshotId) {
|
|
78
|
+
z.uuid().parse(parentId);
|
|
79
|
+
return this.taskResultSnapshotPath(z.uuid().parse(workerId), snapshotId);
|
|
80
|
+
}
|
|
81
|
+
readTaskOwnedFile(runId, reference, familyId) {
|
|
82
|
+
try {
|
|
83
|
+
const path = join(this.taskResultsDir(runId, false, familyId), `${z.uuid().parse(reference.snapshotId)}.json`);
|
|
84
|
+
const raw = readBoundedRegularFile(path);
|
|
85
|
+
if (raw === undefined)
|
|
86
|
+
return undefined;
|
|
87
|
+
const file = taskResultFileSchema.parse(upgradeRemovedRunnerResult(JSON.parse(raw)));
|
|
88
|
+
const fallbackCheckId = familyId && !this.state.hasRun(runId) ? familyId : runId;
|
|
89
|
+
if (!bindTaskResultPath(file.result.diff, this.dataDir, this.state.hasFallbackRun(fallbackCheckId), runId, path))
|
|
90
|
+
return undefined;
|
|
91
|
+
if (!matchesTaskPointer(file, runId, reference))
|
|
92
|
+
return undefined;
|
|
93
|
+
return file;
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
return undefined;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
/** Read a legacy pre-E2 worker snapshot from `runs/<parentId>-worker-results/`. */
|
|
100
|
+
readLegacyWorkerResultFile(parentId, workerId) {
|
|
101
|
+
const parent = this.state.peek(parentId);
|
|
102
|
+
if (parent?.delegation?.role !== 'root' || !parent.delegation.receipts.some(receipt => receipt.workerId === workerId))
|
|
103
|
+
return undefined;
|
|
104
|
+
const reference = parent.delegation.results?.find(result => result.workerId === workerId);
|
|
105
|
+
if (!reference)
|
|
106
|
+
return undefined;
|
|
107
|
+
try {
|
|
108
|
+
const path = join(this.legacyWorkerResultsDir(parentId), `${z.uuid().parse(workerId)}.${z.uuid().parse(reference.snapshotId)}.json`);
|
|
109
|
+
const raw = readBoundedRegularFile(path);
|
|
110
|
+
if (raw === undefined)
|
|
111
|
+
return undefined;
|
|
112
|
+
const file = workerResultFileSchema.parse(upgradeRemovedRunnerResult(JSON.parse(raw)));
|
|
113
|
+
if (!bindWorkerResultPath(file.result.diff, this.dataDir, this.state.hasFallbackRun(parentId), parentId, path))
|
|
114
|
+
return undefined;
|
|
115
|
+
if (file.result.parentRunId !== parentId || file.result.workerId !== workerId || file.result.workspace.ownerRunId !== workerId ||
|
|
116
|
+
file.result.revision !== reference.revision || file.result.observedAt !== reference.observedAt ||
|
|
117
|
+
(file.result.diff.state === 'available' && (file.result.diff.snapshotId !== reference.snapshotId || file.diffSnapshot === undefined))) {
|
|
118
|
+
return undefined;
|
|
119
|
+
}
|
|
120
|
+
return file;
|
|
121
|
+
}
|
|
122
|
+
catch {
|
|
123
|
+
return undefined;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
readLegacyWorkerResult(parentId, workerId) {
|
|
127
|
+
return this.readLegacyWorkerResultFile(parentId, workerId)?.result;
|
|
128
|
+
}
|
|
129
|
+
readTaskResult(runId) {
|
|
130
|
+
const run = this.state.peek(runId);
|
|
131
|
+
if (!run)
|
|
132
|
+
return undefined;
|
|
133
|
+
if (run.result) {
|
|
134
|
+
const file = this.readTaskOwnedFile(runId, run.result);
|
|
135
|
+
if (!file)
|
|
136
|
+
return undefined;
|
|
137
|
+
const result = 'taskId' in file.result ? file.result : workerResultToStoredTaskResult(file.result, file.diffSnapshot);
|
|
138
|
+
return { result, ...(file.diffSnapshot === undefined ? {} : { diffSnapshot: file.diffSnapshot }) };
|
|
139
|
+
}
|
|
140
|
+
if (run.delegation?.role === 'worker') {
|
|
141
|
+
const legacy = this.readLegacyWorkerResultFile(run.delegation.parentRunId, runId);
|
|
142
|
+
if (!legacy)
|
|
143
|
+
return undefined;
|
|
144
|
+
return {
|
|
145
|
+
result: workerResultToStoredTaskResult(legacy.result, legacy.diffSnapshot),
|
|
146
|
+
...(legacy.diffSnapshot === undefined ? {} : { diffSnapshot: legacy.diffSnapshot }),
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
return undefined;
|
|
150
|
+
}
|
|
151
|
+
readTaskResultDiff(runId) {
|
|
152
|
+
return this.readTaskResult(runId)?.diffSnapshot;
|
|
153
|
+
}
|
|
154
|
+
commitTaskResult(runId, value, diffSnapshot, opts = {}) {
|
|
155
|
+
return commitStoreTaskResult({
|
|
156
|
+
redactTaskResult: (result) => this.state.redactTaskResult(result),
|
|
157
|
+
peek: (id) => this.state.peek(id),
|
|
158
|
+
readTaskOwnedFile: (id, reference) => this.readTaskOwnedFile(id, reference),
|
|
159
|
+
redactText: (text) => this.state.redactText(text),
|
|
160
|
+
taskResultSnapshotPath: (id, snapshotId) => this.taskResultSnapshotPath(id, snapshotId),
|
|
161
|
+
taskResultsDir: (id) => this.taskResultsDir(id, true),
|
|
162
|
+
commitIndex: (input, source) => this.state.commitIndex(input, source),
|
|
163
|
+
}, runId, value, diffSnapshot, opts);
|
|
164
|
+
}
|
|
165
|
+
/** Read a worker's stored snapshot: task-owned `<workerId>-results/` first, then legacy `<parentId>-worker-results/`. */
|
|
166
|
+
readWorkerResultFile(parentId, workerId) {
|
|
167
|
+
const parent = this.state.peek(parentId);
|
|
168
|
+
if (parent?.delegation?.role !== 'root' || !parent.delegation.receipts.some(receipt => receipt.workerId === workerId))
|
|
169
|
+
return undefined;
|
|
170
|
+
const worker = this.state.peek(workerId);
|
|
171
|
+
if (worker) {
|
|
172
|
+
if (worker.result) {
|
|
173
|
+
const file = this.readTaskOwnedFile(workerId, worker.result, parentId);
|
|
174
|
+
return file && isWorkerResultFile(file, parentId, workerId) ? file : undefined;
|
|
175
|
+
}
|
|
176
|
+
return this.readLegacyWorkerResultFile(parentId, workerId);
|
|
177
|
+
}
|
|
178
|
+
const reference = parent.delegation.results?.find(entry => entry.workerId === workerId);
|
|
179
|
+
if (!reference)
|
|
180
|
+
return undefined;
|
|
181
|
+
const owned = this.readTaskOwnedFile(workerId, reference, parentId);
|
|
182
|
+
if (owned && isWorkerResultFile(owned, parentId, workerId))
|
|
183
|
+
return owned;
|
|
184
|
+
return this.readLegacyWorkerResultFile(parentId, workerId);
|
|
185
|
+
}
|
|
186
|
+
readWorkerResult(parentId, workerId) {
|
|
187
|
+
return this.readWorkerResultFile(parentId, workerId)?.result;
|
|
188
|
+
}
|
|
189
|
+
readWorkerResultDiff(parentId, workerId) {
|
|
190
|
+
return this.readWorkerResultFile(parentId, workerId)?.diffSnapshot;
|
|
191
|
+
}
|
|
192
|
+
commitWorkerResult(parentId, value, diffSnapshot, opts = {}) {
|
|
193
|
+
return commitStoreWorkerResult({
|
|
194
|
+
redactResult: (result) => this.state.redactWorkerResult(result),
|
|
195
|
+
peek: (id) => this.state.peek(id),
|
|
196
|
+
readWorkerResultFile: (id, workerId) => this.readWorkerResultFile(id, workerId),
|
|
197
|
+
readWorkerResult: (id, workerId) => this.readWorkerResult(id, workerId),
|
|
198
|
+
redactText: (text) => this.state.redactText(text),
|
|
199
|
+
workerResultSnapshotPath: (id, workerId, snapshotId) => this.workerResultSnapshotPath(id, workerId, snapshotId),
|
|
200
|
+
workerResultsDir: (workerId) => this.taskResultsDir(workerId, true, parentId),
|
|
201
|
+
commitIndex: (input, source) => this.state.commitIndex(input, source),
|
|
202
|
+
}, parentId, value, diffSnapshot, opts);
|
|
203
|
+
}
|
|
204
|
+
/** Complete replacement evidence can stand in for absent child history, never for a present execution. */
|
|
205
|
+
readDeletedWorkerResult(parentId, workerId) {
|
|
206
|
+
if (this.state.hasRun(workerId))
|
|
207
|
+
return undefined;
|
|
208
|
+
const parent = this.state.peek(parentId);
|
|
209
|
+
if (parent?.delegation?.role !== 'root' || parent.delegation.historyDeletion)
|
|
210
|
+
return undefined;
|
|
211
|
+
const deletion = parent.delegation.receipts.find(receipt => receipt.workerId === workerId)?.deletion;
|
|
212
|
+
if (deletion?.phase !== 'complete')
|
|
213
|
+
return undefined;
|
|
214
|
+
const result = this.readWorkerResult(parentId, workerId);
|
|
215
|
+
return result?.settled && ['review', 'done', 'failed', 'cancelled'].includes(result.status) &&
|
|
216
|
+
result.cleanup === 'complete' && result.revision === deletion.revision &&
|
|
217
|
+
result.workspace.resourceId === deletion.resourceId ? result : undefined;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
//# sourceMappingURL=task-results.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task-results.js","sourceRoot":"","sources":["../../src/runs/task-results.ts"],"names":[],"mappings":"AAUA,OAAO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AClD,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACzC,IAAI,MAAM,EAAE,UAAU,EAAE,IAAI,KAAK,MAAM,IAAI,MAAM,CAAC,UAAU,CAAC,eAAe;YAAE,OAAO,SAAS,CAAC;QAC/F,MAAM,QAAQ,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,QAAQ,KAAK,QAAQ,CAAC,EAAE,QAAQ,CAAC;QACrG,IAAI,QAAQ,EAAE,KAAK,KAAK,UAAU;YAAE,OAAO,SAAS,CAAC;QACrD,MAAM,MAAM,GAAG,IAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QACzD,OAAO,MAAM,EAAE,OAAO,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;YACzF,MAAM,CAAC,OAAO,KAAK,UAAU,IAAI,MAAM,CAAC,QAAQ,KAAK,QAAQ,CAAC,QAAQ;YACtE,MAAM,CAAC,SAAS,CAAC,UAAU,KAAK,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;IAC7E,CAAC;CACF"}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RunRecord, WorkerCollectedResult } from '../contract/index.js';
|
|
2
2
|
import { workerResultFileSchema } from '../contract/index.js';
|
|
3
|
+
import type { CommitSource } from './run-persistence.ts';
|
|
3
4
|
type WorkerResultFile = ReturnType<typeof workerResultFileSchema.parse>;
|
|
5
|
+
export interface WorkerResultCommitOptions {
|
|
6
|
+
ignoreCleanup?: boolean;
|
|
7
|
+
acknowledge?: boolean;
|
|
8
|
+
retainOnParent?: boolean;
|
|
9
|
+
}
|
|
4
10
|
/** The store methods a worker-result commit needs; no import of `store.ts`. */
|
|
5
11
|
export interface WorkerResultCommitState {
|
|
6
12
|
redactResult(value: WorkerCollectedResult): WorkerCollectedResult;
|
|
@@ -9,18 +15,12 @@ export interface WorkerResultCommitState {
|
|
|
9
15
|
readWorkerResult(parentId: string, workerId: string): WorkerCollectedResult | undefined;
|
|
10
16
|
redactText(text: string): string;
|
|
11
17
|
workerResultSnapshotPath(parentId: string, workerId: string, snapshotId: string): string;
|
|
12
|
-
workerResultsDir(
|
|
13
|
-
|
|
14
|
-
id: string;
|
|
15
|
-
delegation: DelegationState;
|
|
16
|
-
}>): void;
|
|
18
|
+
workerResultsDir(workerId: string): string;
|
|
19
|
+
commitIndex(input: ReadonlyMap<string, RunRecord | null>, source?: CommitSource): void;
|
|
17
20
|
}
|
|
18
21
|
/**
|
|
19
|
-
* Publish a
|
|
20
|
-
*
|
|
21
|
-
* caller that only needs the payload durable, whatever cleanup phase the stored copy names.
|
|
22
|
+
* Publish a worker snapshot to `runs/<workerId>-results/<snapshotId>.json` and commit `worker.result`
|
|
23
|
+
* (plus supervisor acknowledgement or deleted-worker parent pointer) in one fenced transaction.
|
|
22
24
|
*/
|
|
23
|
-
export declare function commitStoreWorkerResult(state: WorkerResultCommitState, parentId: string, value: WorkerCollectedResult, diffSnapshot?: string, opts?:
|
|
24
|
-
ignoreCleanup?: boolean;
|
|
25
|
-
}): WorkerCollectedResult;
|
|
25
|
+
export declare function commitStoreWorkerResult(state: WorkerResultCommitState, parentId: string, value: WorkerCollectedResult, diffSnapshot?: string, opts?: WorkerResultCommitOptions): WorkerCollectedResult;
|
|
26
26
|
export {};
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Publish a worker-result snapshot
|
|
3
|
-
*
|
|
2
|
+
* Publish a worker-result snapshot to `runs/<workerId>-results/<snapshotId>.json` and commit
|
|
3
|
+
* `worker.result` (plus `parent.workerAcknowledgements` on supervisor acknowledgement, or
|
|
4
|
+
* `parent.delegation.results` when retaining a deleted worker's pointer) in one fenced write.
|
|
4
5
|
*/
|
|
5
6
|
import { randomUUID } from 'node:crypto';
|
|
6
|
-
import {
|
|
7
|
+
import { existsSync } from 'node:fs';
|
|
7
8
|
import { join } from 'node:path';
|
|
8
9
|
import { isDeepStrictEqual } from 'node:util';
|
|
9
|
-
import { workerCollectedResultSchema, workerResultFileSchema } from '../contract/index.js';
|
|
10
|
+
import { delegationStateSchema, workerCollectedResultSchema, workerResultFileSchema } from '../contract/index.js';
|
|
11
|
+
import { workerAcknowledgementSchema } from '../contract/index.js';
|
|
12
|
+
import { buildTaskResultReference, removeStaleTaskResultSnapshots, writeAtomicResultSnapshot } from './task-result-commit.js';
|
|
10
13
|
/**
|
|
11
14
|
* Two collected worker results carry the same evidence: equal but for when they were observed and
|
|
12
15
|
* which snapshot file holds them, and, with `ignoreCleanup`, the cleanup phase. A retried destroy
|
|
@@ -17,33 +20,92 @@ function sameWorkerResult(a, b, opts) {
|
|
|
17
20
|
diff: value.diff.state === 'available' ? { ...value.diff, snapshotId: undefined, path: undefined } : value.diff });
|
|
18
21
|
return isDeepStrictEqual(comparable(a), comparable(b));
|
|
19
22
|
}
|
|
23
|
+
function hasMatchingAcknowledgement(parent, result) {
|
|
24
|
+
return Boolean(parent.workerAcknowledgements?.some((entry) => entry.workerId === result.workerId && entry.revision === result.revision && entry.status === result.status));
|
|
25
|
+
}
|
|
26
|
+
function withWorkerAcknowledgement(parent, result) {
|
|
27
|
+
if (!result.settled || hasMatchingAcknowledgement(parent, result))
|
|
28
|
+
return parent;
|
|
29
|
+
const entry = workerAcknowledgementSchema.parse({
|
|
30
|
+
workerId: result.workerId,
|
|
31
|
+
revision: result.revision,
|
|
32
|
+
status: result.status,
|
|
33
|
+
observedAt: result.observedAt,
|
|
34
|
+
});
|
|
35
|
+
return {
|
|
36
|
+
...parent,
|
|
37
|
+
workerAcknowledgements: [
|
|
38
|
+
...(parent.workerAcknowledgements ?? []).filter((existing) => existing.workerId !== result.workerId),
|
|
39
|
+
entry,
|
|
40
|
+
],
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function withParentResultReference(parent, reference) {
|
|
44
|
+
const delegation = delegationStateSchema.parse({
|
|
45
|
+
...parent.delegation,
|
|
46
|
+
results: [...(parent.delegation.results ?? []).filter((entry) => entry.workerId !== reference.workerId), reference],
|
|
47
|
+
});
|
|
48
|
+
if (delegation.role !== 'root')
|
|
49
|
+
throw new Error('missing result ownership');
|
|
50
|
+
return { ...parent, delegation };
|
|
51
|
+
}
|
|
52
|
+
function commitMatchedMetadata(state, parentId, parent, worker, matched, oldParentRef, opts) {
|
|
53
|
+
let nextParent = parent;
|
|
54
|
+
if (opts.retainOnParent && worker?.result &&
|
|
55
|
+
(oldParentRef?.snapshotId !== worker.result.snapshotId || oldParentRef.observedAt !== worker.result.observedAt)) {
|
|
56
|
+
nextParent = withParentResultReference(nextParent, { workerId: matched.workerId, ...worker.result });
|
|
57
|
+
}
|
|
58
|
+
if (opts.acknowledge) {
|
|
59
|
+
nextParent = withWorkerAcknowledgement(nextParent, matched);
|
|
60
|
+
}
|
|
61
|
+
if (nextParent !== parent) {
|
|
62
|
+
state.commitIndex(new Map([[parentId, nextParent]]), 'delegation-checkpoint');
|
|
63
|
+
}
|
|
64
|
+
}
|
|
20
65
|
/**
|
|
21
|
-
* Publish a
|
|
22
|
-
*
|
|
23
|
-
* caller that only needs the payload durable, whatever cleanup phase the stored copy names.
|
|
66
|
+
* Publish a worker snapshot to `runs/<workerId>-results/<snapshotId>.json` and commit `worker.result`
|
|
67
|
+
* (plus supervisor acknowledgement or deleted-worker parent pointer) in one fenced transaction.
|
|
24
68
|
*/
|
|
25
69
|
export function commitStoreWorkerResult(state, parentId, value, diffSnapshot, opts = {}) {
|
|
26
70
|
const result = workerCollectedResultSchema.parse(state.redactResult(value));
|
|
27
71
|
const parent = state.peek(parentId);
|
|
28
72
|
const worker = state.peek(result.workerId);
|
|
29
73
|
assertWorkerResultOwnership(parentId, parent, worker, result);
|
|
30
|
-
const
|
|
31
|
-
const
|
|
74
|
+
const oldParentRef = parent.delegation.results?.find((entry) => entry.workerId === result.workerId);
|
|
75
|
+
const oldPointer = worker ? (worker.result ?? oldParentRef) : oldParentRef;
|
|
76
|
+
const stored = oldPointer && state.readWorkerResultFile(parentId, result.workerId);
|
|
32
77
|
const matched = matchingStoredWorkerResult(stored, result, diffSnapshot, opts, (text) => state.redactText(text));
|
|
33
|
-
if (matched)
|
|
78
|
+
if (matched) {
|
|
79
|
+
commitMatchedMetadata(state, parentId, parent, worker, matched, oldParentRef, opts);
|
|
34
80
|
return matched;
|
|
35
|
-
|
|
81
|
+
}
|
|
82
|
+
if (workerResultIsObsolete(worker, oldPointer, result, () => state.readWorkerResult(parentId, result.workerId))) {
|
|
36
83
|
throw new Error('worker result is obsolete');
|
|
37
84
|
}
|
|
38
85
|
const snapshotId = assignWorkerResultSnapshotPath(result, parentId, (id, workerId, snap) => state.workerResultSnapshotPath(id, workerId, snap), diffSnapshot);
|
|
39
86
|
const file = workerResultFileSchema.parse({ result, ...(diffSnapshot === undefined ? {} : { diffSnapshot: state.redactText(diffSnapshot) }) });
|
|
40
|
-
const dir = state.workerResultsDir(
|
|
41
|
-
const path = join(dir, `${
|
|
87
|
+
const dir = state.workerResultsDir(result.workerId);
|
|
88
|
+
const path = join(dir, `${snapshotId}.json`);
|
|
42
89
|
if (existsSync(path))
|
|
43
90
|
throw new Error('worker result snapshot identity already exists');
|
|
44
|
-
|
|
91
|
+
const taskReference = buildTaskResultReference(result, snapshotId, oldPointer);
|
|
92
|
+
writeAtomicResultSnapshot(path, file, oldPointer?.snapshotId === snapshotId, () => {
|
|
93
|
+
const staged = new Map();
|
|
94
|
+
if (worker)
|
|
95
|
+
staged.set(worker.id, { ...worker, result: taskReference });
|
|
96
|
+
let nextParent = parent;
|
|
97
|
+
if (!worker || opts.retainOnParent) {
|
|
98
|
+
nextParent = withParentResultReference(nextParent, { workerId: result.workerId, ...taskReference });
|
|
99
|
+
}
|
|
100
|
+
if (opts.acknowledge) {
|
|
101
|
+
nextParent = withWorkerAcknowledgement(nextParent, result);
|
|
102
|
+
}
|
|
103
|
+
if (nextParent !== parent)
|
|
104
|
+
staged.set(parentId, nextParent);
|
|
105
|
+
state.commitIndex(staged, 'delegation-checkpoint');
|
|
106
|
+
});
|
|
45
107
|
// Keep the latest payload only; bounded previous outcome metadata lives in the pointer.
|
|
46
|
-
|
|
108
|
+
removeStaleTaskResultSnapshots(dir, snapshotId);
|
|
47
109
|
return result;
|
|
48
110
|
}
|
|
49
111
|
function assertWorkerResultOwnership(parentId, parent, worker, result) {
|
|
@@ -78,44 +140,4 @@ function assignWorkerResultSnapshotPath(result, parentId, snapshotPath, diffSnap
|
|
|
78
140
|
throw new Error('missing diff snapshot');
|
|
79
141
|
return snapshotId;
|
|
80
142
|
}
|
|
81
|
-
function workerResultReference(result, snapshotId, old) {
|
|
82
|
-
return {
|
|
83
|
-
workerId: result.workerId, revision: result.revision, observedAt: result.observedAt, snapshotId,
|
|
84
|
-
lastExecutionOutcome: result.lastExecutionOutcome,
|
|
85
|
-
...(old ? { previous: old.revision === result.revision ? old.previous : { revision: old.revision, observedAt: old.observedAt, lastExecutionOutcome: old.lastExecutionOutcome } } : {}),
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
function writeWorkerResultSnapshot(path, file, parentId, parent, result, snapshotId, old, commitDelegation) {
|
|
89
|
-
const temp = `${path}.${randomUUID()}.tmp`;
|
|
90
|
-
try {
|
|
91
|
-
const fd = openSync(temp, constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | constants.O_NOFOLLOW, 0o600);
|
|
92
|
-
try {
|
|
93
|
-
writeFileSync(fd, JSON.stringify(file));
|
|
94
|
-
fsyncSync(fd);
|
|
95
|
-
}
|
|
96
|
-
finally {
|
|
97
|
-
closeSync(fd);
|
|
98
|
-
}
|
|
99
|
-
renameSync(temp, path);
|
|
100
|
-
const reference = workerResultReference(result, snapshotId, old);
|
|
101
|
-
commitDelegation([{ id: parentId, delegation: { ...parent.delegation,
|
|
102
|
-
results: [...(parent.delegation.results ?? []).filter((entry) => entry.workerId !== result.workerId), reference],
|
|
103
|
-
} }]);
|
|
104
|
-
}
|
|
105
|
-
catch (error) {
|
|
106
|
-
rmSync(temp, { force: true });
|
|
107
|
-
if (old?.snapshotId !== snapshotId)
|
|
108
|
-
rmSync(path, { force: true });
|
|
109
|
-
throw error;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
function removeStaleWorkerResultSnapshots(dir, workerId, snapshotId) {
|
|
113
|
-
for (const name of readdirSync(dir))
|
|
114
|
-
if (name.startsWith(`${workerId}.`) && name !== `${workerId}.${snapshotId}.json`) {
|
|
115
|
-
try {
|
|
116
|
-
rmSync(join(dir, name), { force: true });
|
|
117
|
-
}
|
|
118
|
-
catch { /* retry on next collection */ }
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
143
|
//# sourceMappingURL=worker-result-commit.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker-result-commit.js","sourceRoot":"","sources":["../../src/runs/worker-result-commit.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"worker-result-commit.js","sourceRoot":"","sources":["../../src/runs/worker-result-commit.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE9C,OAAO,EAAE,qBAAqB,EAAE,2BAA2B,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AACrI,OAAO,EAAE,2BAA2B,EAAE,MAAM,0CAA0C,CAAC;AAEvF,OAAO,EAAE,wBAAwB,EAAE,8BAA8B,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;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CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,IAAI,CAAC,GAAG,CAAC,QAAQ,KAAK,MAAM,CAAC,QAAQ,IAAI,GAAG,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;AACpH,CAAC;AAED,SAAS,8BAA8B,CACrC,MAA6B,EAC7B,QAAgB,EAChB,YAAgF,EAChF,YAAgC;IAEhC,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,KAAK,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC;IAC7F,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,KAAK,WAAW;QAAE,MAAM,CAAC,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;IAC9G,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,KAAK,WAAW,IAAI,YAAY,KAAK,SAAS;QAAE,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;IAC9G,OAAO,UAAU,CAAC;AACpB,CAAC"}
|
|
@@ -1,38 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The worker-results
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* The worker-results view over `TaskResultsTopic` (hearsay-tools/squawk#4038, E2
|
|
3
|
+
* hearsay-tools/squawk#4628). Preserves the `WorkerResults` port and `store.workerResults`
|
|
4
|
+
* surface while delegating storage, legacy fallback, and atomic commits to `runs/task-results.ts`.
|
|
5
5
|
*/
|
|
6
|
-
import type {
|
|
6
|
+
import type { WorkerCollectedResult } from '../contract/index.js';
|
|
7
7
|
import type { WorkerResults } from './ports.ts';
|
|
8
|
-
|
|
9
|
-
export interface WorkerResultsState {
|
|
10
|
-
peek(id: string): RunRecord | undefined;
|
|
11
|
-
hasRun(id: string): boolean;
|
|
12
|
-
hasFallbackRun(id: string): boolean;
|
|
13
|
-
writeDir(id: string): string;
|
|
14
|
-
sourceDataDir(id: string): string;
|
|
15
|
-
/** The result as the store's redaction leaves it. */
|
|
16
|
-
redactResult(value: WorkerCollectedResult): WorkerCollectedResult;
|
|
17
|
-
redactText(text: string): string;
|
|
18
|
-
commitDelegation(patches: ReadonlyArray<{
|
|
19
|
-
id: string;
|
|
20
|
-
delegation: DelegationState;
|
|
21
|
-
}>): void;
|
|
22
|
-
}
|
|
8
|
+
import type { TaskResultsTopic } from './task-results.ts';
|
|
23
9
|
export declare class WorkerResultsTopic implements WorkerResults {
|
|
24
|
-
private readonly
|
|
25
|
-
|
|
26
|
-
constructor(dataDir: string, state: WorkerResultsState);
|
|
27
|
-
private workerResultsDir;
|
|
10
|
+
private readonly taskResults;
|
|
11
|
+
constructor(taskResults: TaskResultsTopic);
|
|
28
12
|
workerResultSnapshotPath(parentId: string, workerId: string, snapshotId: string): string;
|
|
29
|
-
private readWorkerResultFile;
|
|
30
13
|
readWorkerResult(parentId: string, workerId: string): WorkerCollectedResult | undefined;
|
|
14
|
+
readLegacyWorkerResult(parentId: string, workerId: string): WorkerCollectedResult | undefined;
|
|
31
15
|
readWorkerResultDiff(parentId: string, workerId: string): string | undefined;
|
|
32
|
-
/** Publish a pointer only after its redacted immutable snapshot reaches disk. */
|
|
33
16
|
commitWorkerResult(parentId: string, value: WorkerCollectedResult, diffSnapshot?: string, opts?: {
|
|
34
17
|
ignoreCleanup?: boolean;
|
|
18
|
+
acknowledge?: boolean;
|
|
19
|
+
retainOnParent?: boolean;
|
|
35
20
|
}): WorkerCollectedResult;
|
|
36
|
-
/** Complete replacement evidence can stand in for absent child history, never for a present execution. */
|
|
37
21
|
readDeletedWorkerResult(parentId: string, workerId: string): WorkerCollectedResult | undefined;
|
|
38
22
|
}
|