@hearsay-tools/squawk 0.18.0-dev.7779 → 0.18.0-dev.7788
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/artifacts/removal-slot.d.ts +3 -0
- package/dist/artifacts/removal-slot.js +7 -0
- package/dist/artifacts/removal-slot.js.map +1 -0
- package/dist/autosave-removal-slots.d.ts +6 -0
- package/dist/autosave-removal-slots.js +13 -0
- package/dist/autosave-removal-slots.js.map +1 -0
- package/dist/built-in-run-slots.d.ts +9 -0
- package/dist/built-in-run-slots.js +21 -0
- package/dist/built-in-run-slots.js.map +1 -0
- package/dist/ci-wait/controller.d.ts +42 -42
- package/dist/delegation/family-end.js +5 -1
- package/dist/delegation/family-end.js.map +1 -1
- package/dist/delegation/removal-slot.d.ts +4 -0
- package/dist/delegation/removal-slot.js +20 -0
- package/dist/delegation/removal-slot.js.map +1 -0
- package/dist/delegation/routes.d.ts +79 -79
- package/dist/delegation/transport.d.ts +76 -76
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/jobs/removal-slot.d.ts +4 -0
- package/dist/jobs/removal-slot.js +10 -0
- package/dist/jobs/removal-slot.js.map +1 -0
- package/dist/runs/removal-slots.d.ts +56 -0
- package/dist/runs/removal-slots.js +66 -0
- package/dist/runs/removal-slots.js.map +1 -0
- package/dist/runs/retention.d.ts +10 -7
- package/dist/runs/retention.js +8 -19
- package/dist/runs/retention.js.map +1 -1
- package/dist/runs/store.d.ts +4 -2
- package/dist/runs/store.js +18 -20
- package/dist/runs/store.js.map +1 -1
- package/dist/server/live-routes.d.ts +6 -6
- package/dist/server/models-routes.d.ts +13 -13
- package/dist/server/provider-sign-in-routes.d.ts +2 -2
- package/dist/server/reports-api.d.ts +2 -2
- package/dist/server/runner-install-routes.d.ts +10 -10
- package/dist/server/server.d.ts +1595 -1595
- package/dist/server/workspace-live-routes.d.ts +6 -6
- package/package.json +4 -4
- package/scripts/benchmark-family-reconcile.ts +2 -0
- package/scripts/benchmark-run-store.ts +2 -0
- package/scripts/benchmark-stuck-destroys.ts +2 -0
- package/scripts/benchmark-worker-lifecycle.ts +2 -0
- package/scripts/benchmark-workspace-events.ts +2 -0
- package/scripts/benchmark-worktree-retention.ts +2 -0
- package/scripts/measure-transcript-facts-health.mjs +4 -1
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
const gates = [];
|
|
2
|
+
const preparations = [];
|
|
3
|
+
const cleanups = [];
|
|
4
|
+
let sealed = false;
|
|
5
|
+
function add(list, slots) {
|
|
6
|
+
for (const slot of slots ?? []) {
|
|
7
|
+
if (list.includes(slot))
|
|
8
|
+
continue;
|
|
9
|
+
if (sealed)
|
|
10
|
+
throw new Error('The removal slots are sealed: register every slot before sealRunSlots().');
|
|
11
|
+
list.push(slot);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
/** Add slots, in call order. Registering the same slot object again does nothing. */
|
|
15
|
+
export function registerRunSlots(slots) {
|
|
16
|
+
add(gates, slots.gates);
|
|
17
|
+
add(preparations, slots.preparations);
|
|
18
|
+
add(cleanups, slots.cleanups);
|
|
19
|
+
}
|
|
20
|
+
/** Close the registry: removals may run, and no new slot may register. */
|
|
21
|
+
export function sealRunSlots() {
|
|
22
|
+
sealed = true;
|
|
23
|
+
}
|
|
24
|
+
/** Whether this process sealed its removal slots. Never throws. */
|
|
25
|
+
export function runSlotsSealed() {
|
|
26
|
+
return sealed;
|
|
27
|
+
}
|
|
28
|
+
/** Throws unless the registry is sealed. A removal path calls it before its first side effect. */
|
|
29
|
+
export function assertRunSlotsSealed() {
|
|
30
|
+
if (!sealed) {
|
|
31
|
+
throw new Error('No removal slot is registered: call registerBuiltInRunSlots() from built-in-run-slots.ts at the process entry, '
|
|
32
|
+
+ 'or seal the slots this test uses with sealTestRunSlots() from runs/removal-slots.testkit.ts.');
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/** The first gate's reason to refuse this deletion, in registration order. */
|
|
36
|
+
export function deletionRefusal(runId, kind, dataDir) {
|
|
37
|
+
assertRunSlotsSealed();
|
|
38
|
+
for (const gate of gates) {
|
|
39
|
+
const reason = gate.refuse(runId, kind, dataDir);
|
|
40
|
+
if (reason)
|
|
41
|
+
return reason;
|
|
42
|
+
}
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
/** Run every preparation in registration order; the first rejection stops the rest. */
|
|
46
|
+
export async function prepareReclaim(run, context) {
|
|
47
|
+
assertRunSlotsSealed();
|
|
48
|
+
for (const preparation of preparations)
|
|
49
|
+
await preparation.prepare(run, context);
|
|
50
|
+
}
|
|
51
|
+
/** Run every cleanup in registration order, then throw the first failure. */
|
|
52
|
+
export function runRemovalCleanups(runId, dataDir) {
|
|
53
|
+
assertRunSlotsSealed();
|
|
54
|
+
const failures = [];
|
|
55
|
+
for (const cleanup of cleanups) {
|
|
56
|
+
try {
|
|
57
|
+
cleanup.removed(runId, dataDir);
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
failures.push(error);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (failures.length)
|
|
64
|
+
throw failures[0];
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=removal-slots.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"removal-slots.js","sourceRoot":"","sources":["../../src/runs/removal-slots.ts"],"names":[],"mappings":"AAkDA,MAAM,KAAK,GAAmB,EAAE,CAAC;AACjC,MAAM,YAAY,GAAyB,EAAE,CAAC;AAC9C,MAAM,QAAQ,GAAqB,EAAE,CAAC;AACtC,IAAI,MAAM,GAAG,KAAK,CAAC;AAEnB,SAAS,GAAG,CAAI,IAAS,EAAE,KAA+B;IACxD,KAAK,MAAM,IAAI,IAAI,KAAK,IAAI,EAAE,EAAE,CAAC;QAC/B,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;YAAE,SAAS;QAClC,IAAI,MAAM;YAAE,MAAM,IAAI,KAAK,CA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MAAM,UAAU,kBAAkB,CAAC,KAAa,EAAE,OAAe;IAC/D,oBAAoB,EAAE,CAAC;IACvB,MAAM,QAAQ,GAAc,EAAE,CAAC;IAC/B,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,IAAI,CAAC;YAAC,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAAC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAAC,CAAC;IAClF,CAAC;IACD,IAAI,QAAQ,CAAC,MAAM;QAAE,MAAM,QAAQ,CAAC,CAAC,CAAC,CAAC;AACzC,CAAC"}
|
package/dist/runs/retention.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { PreviewHostLike } from '../preview/registration.ts';
|
|
2
1
|
import type { RunPins, RunAccess, RunFamilyReads, WorkerExecutions, WorkerResults } from './ports.ts';
|
|
3
2
|
import type { RunRecord } from './store.ts';
|
|
4
3
|
/** Whether an owned worker's family has ended: its parent was archived, by the user or by history
|
|
@@ -27,9 +26,9 @@ export declare function isReclaimable(run: RunRecord, lookup?: (id: string) => R
|
|
|
27
26
|
export declare function selectReclaimableWorktrees(runs: readonly RunRecord[], keep: number, lookup?: (id: string) => RunRecord | undefined, workersOf?: (parentId: string) => readonly RunRecord[]): string[];
|
|
28
27
|
/** The store members a real store has and a structural test store may lack: each use checks for it. */
|
|
29
28
|
type RealStoreMembers = Partial<RunAccess & RunFamilyReads & RunPins & WorkerExecutions & WorkerResults>;
|
|
30
|
-
/** The slice of the runs store the enforcer needs
|
|
31
|
-
* enforcer stays easy to test and never imports the concrete store. */
|
|
32
|
-
export interface RetentionStore {
|
|
29
|
+
/** The slice of the runs store the enforcer needs, and the worker results a reclaim preparation
|
|
30
|
+
* saves. Kept structural so the enforcer stays easy to test and never imports the concrete store. */
|
|
31
|
+
export interface RetentionStore extends WorkerResults {
|
|
33
32
|
/** The candidates: runs with a materialized worktree (an indexed query, #779). */
|
|
34
33
|
listRunsWithWorktree(): RunRecord[];
|
|
35
34
|
getRun(id: string): RunRecord | undefined;
|
|
@@ -81,13 +80,17 @@ export interface ReclaimOptions {
|
|
|
81
80
|
* the forced removal is about to delete. The run manager's `claimWorktreeReclaim` is the one
|
|
82
81
|
* that also blocks admission; startup sweeps run before any run can start and omit it. */
|
|
83
82
|
claim?: (run: RunRecord) => (() => void) | null;
|
|
84
|
-
/** The workspace preview host (#781): the default reclaimer releases the run's preview
|
|
85
|
-
|
|
83
|
+
/** The workspace preview host (#781): the default reclaimer releases the run's preview once the
|
|
84
|
+
* removal goes ahead. */
|
|
85
|
+
previewHost?: {
|
|
86
|
+
release(runId: string): Promise<void>;
|
|
87
|
+
} | undefined;
|
|
86
88
|
}
|
|
87
89
|
/**
|
|
88
90
|
* The proof a destructive step on `run`'s resources re-checks right before each step, as a
|
|
89
91
|
* function that throws when it fails. Startup has no manager claim, and a terminal execution can
|
|
90
|
-
* still have a retained autosave writer, so the
|
|
92
|
+
* still have a retained autosave writer, so the deletion gates (`runs/removal-slots.ts`) are asked
|
|
93
|
+
* each time. An
|
|
91
94
|
* owned worker's generation and fresh resource holders must also be safe, including after async
|
|
92
95
|
* evidence or preview work. Structural test stores have no execution machinery and skip that part.
|
|
93
96
|
*/
|
package/dist/runs/retention.js
CHANGED
|
@@ -6,9 +6,8 @@ import { isFallbackProjectPath, projectPaths } from '../project-paths.js';
|
|
|
6
6
|
// recoverable) and the thin I/O enforcer that performs the reclaim. The selector
|
|
7
7
|
// is pure and unit-testable; the enforcer never throws (helper discipline).
|
|
8
8
|
import { existsSync } from 'node:fs';
|
|
9
|
-
import {
|
|
9
|
+
import { assertRunSlotsSealed, deletionRefusal, prepareReclaim } from './removal-slots.js';
|
|
10
10
|
import { hostsLiveSharedWorker } from './shared-hosts.js';
|
|
11
|
-
import { collectWorkerEvidence } from '../delegation/results.js';
|
|
12
11
|
import { createWorktree } from '../git-worktree.js';
|
|
13
12
|
import { releaseThenRemoveWorktree } from '../git-worktree-release.js';
|
|
14
13
|
import { isEndedRoot, isLiveRecord } from './run-row.js';
|
|
@@ -116,31 +115,20 @@ export async function rematerializeReclaimedWorktree(repoRoot, store, runId) {
|
|
|
116
115
|
return false;
|
|
117
116
|
}
|
|
118
117
|
}
|
|
119
|
-
/** Snapshot parent-owned worker evidence before the checkout goes.
|
|
120
|
-
* Test fakes without `commitWorkerResult` skip this. A collect/commit failure
|
|
121
|
-
* returns false so the directory is left for the next pass. */
|
|
122
|
-
async function preserveWorkerResult(repoRoot, store, run) {
|
|
123
|
-
if (run.delegation?.role !== 'worker')
|
|
124
|
-
return true;
|
|
125
|
-
const commit = store.commitWorkerResult;
|
|
126
|
-
if (typeof commit !== 'function')
|
|
127
|
-
return true;
|
|
128
|
-
const evidence = await collectWorkerEvidence(repoRoot, store, run);
|
|
129
|
-
commit.call(store, run.delegation.parentRunId, evidence.result, evidence.diffSnapshot);
|
|
130
|
-
return evidence.diffSnapshot !== undefined || evidence.result.diff.state === 'available';
|
|
131
|
-
}
|
|
132
118
|
/**
|
|
133
119
|
* The proof a destructive step on `run`'s resources re-checks right before each step, as a
|
|
134
120
|
* function that throws when it fails. Startup has no manager claim, and a terminal execution can
|
|
135
|
-
* still have a retained autosave writer, so the
|
|
121
|
+
* still have a retained autosave writer, so the deletion gates (`runs/removal-slots.ts`) are asked
|
|
122
|
+
* each time. An
|
|
136
123
|
* owned worker's generation and fresh resource holders must also be safe, including after async
|
|
137
124
|
* evidence or preview work. Structural test stores have no execution machinery and skip that part.
|
|
138
125
|
*/
|
|
139
126
|
export function cleanupSafety(repoRoot, store, run) {
|
|
140
127
|
const execution = store.readWorkerExecution?.(run.id);
|
|
141
128
|
return () => {
|
|
142
|
-
|
|
143
|
-
|
|
129
|
+
const refusal = deletionRefusal(run.id, 'worktree', store.sourceDataDir?.(run.id) ?? projectPaths(repoRoot).write);
|
|
130
|
+
if (refusal)
|
|
131
|
+
throw Error(refusal);
|
|
144
132
|
if (run.delegation?.role !== 'worker')
|
|
145
133
|
return;
|
|
146
134
|
if (typeof store.workerResourcesSafe === 'function' && (!execution ||
|
|
@@ -180,6 +168,7 @@ export async function reclaimWorktrees(repoRoot, store, keep, opts = {}) {
|
|
|
180
168
|
* preserved). Never throws.
|
|
181
169
|
*/
|
|
182
170
|
export async function reclaimWorktree(repoRoot, store, run, opts = {}) {
|
|
171
|
+
assertRunSlotsSealed();
|
|
183
172
|
if (readOnlyWorktree(repoRoot, store, run))
|
|
184
173
|
return null;
|
|
185
174
|
const now = opts.now ?? (() => new Date().toISOString());
|
|
@@ -208,7 +197,7 @@ export async function reclaimWorktree(repoRoot, store, run, opts = {}) {
|
|
|
208
197
|
}
|
|
209
198
|
try {
|
|
210
199
|
assertSafe();
|
|
211
|
-
if (!(await
|
|
200
|
+
if (!(await prepareReclaim(run, { repoRoot, store }).then(() => true, () => false)))
|
|
212
201
|
return null;
|
|
213
202
|
if (opts.remove)
|
|
214
203
|
assertSafe(); // injected reclaimer has no final callback
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retention.js","sourceRoot":"","sources":["../../src/runs/retention.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC1E,6EAA6E;AAC7E,iFAAiF;AACjF,+EAA+E;AAC/E,iFAAiF;AACjF,iFAAiF;AACjF,4EAA4E;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"retention.js","sourceRoot":"","sources":["../../src/runs/retention.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC1E,6EAA6E;AAC7E,iFAAiF;AACjF,+EAA+E;AAC/E,iFAAiF;AACjF,iFAAiF;AACjF,4EAA4E;AAC5E,OAAO,EAAE,UAAU,EAAE,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AAuB,CAAC,CAAC;IAC5G,IAAI,CAAC,MAAM,EAAE,CAAC;QAAC,OAAO,EAAE,CAAC;QAAC,OAAO,IAAI,CAAC;IAAC,CAAC;IACxC,IAAI,CAAC;QACH,UAAU,EAAE,CAAC;QACb,IAAI,CAAC,CAAC,MAAM,cAAc,CAAC,GAAG,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC;YAAE,OAAO,IAAI,CAAC;QACjG,IAAI,IAAI,CAAC,MAAM;YAAE,UAAU,EAAE,CAAC,CAAC,2CAA2C;QAC1E,MAAM,MAAM,CAAC,QAAQ,EAAE,GAAG,CAAC,YAAY,CAAC,CAAC;QACzC,IAAI,UAAU,CAAC,GAAG,CAAC,YAAY,CAAC;YAAE,OAAO,IAAI,CAAC,CAAC,kCAAkC;QACjF,MAAM,KAAK,GAAG,GAAG,EAAE,CAAC;QACpB,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,mBAAmB,EAAE,KAAK,EAAE,CAAC,CAAC;QACxD,OAAO,KAAK,CAAC;IACf,CAAC;IAAC,MAAM,CAAC;QACP,2EAA2E;QAC3E,OAAO,IAAI,CAAC;IACd,CAAC;YAAS,CAAC;QACT,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,EAAE,SAAS,CAAC,CAAC;QAC3C,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC"}
|
package/dist/runs/store.d.ts
CHANGED
|
@@ -4004,6 +4004,8 @@ export declare class RunStore {
|
|
|
4004
4004
|
/** Delegated history deletion is synchronous and checkpointed; any failed byte/index removal remains retryable. */
|
|
4005
4005
|
private deleteDelegatedRun;
|
|
4006
4006
|
private removeRunHistoryBytes;
|
|
4007
|
+
/** The run's history, handoff and images, then the removal cleanups (`runs/removal-slots.ts`). */
|
|
4008
|
+
private removeHistoryFiles;
|
|
4007
4009
|
deleteRun(id: string): boolean;
|
|
4008
4010
|
/** Write the pending rows out now (used on shutdown). */
|
|
4009
4011
|
flush(): void;
|
|
@@ -4028,8 +4030,8 @@ export declare class RunStore {
|
|
|
4028
4030
|
/** The held record is gone; the next save or commit deletes its row, fenced by `family`'s claim
|
|
4029
4031
|
* and by the revision this store last saw (kept in `base` until the delete is written). */
|
|
4030
4032
|
private markDeleted;
|
|
4031
|
-
/** A deleted run's history files, once the delete of its row has committed.
|
|
4032
|
-
*
|
|
4033
|
+
/** A deleted run's history files and removal cleanups, once the delete of its row has committed.
|
|
4034
|
+
* Best effort: a failure is logged, and the row stays deleted. */
|
|
4033
4035
|
private removeOwedHistory;
|
|
4034
4036
|
/**
|
|
4035
4037
|
* Count-based history retention: of the runs past the newest `MAX_RUNS_KEPT` unarchived ones,
|
package/dist/runs/store.js
CHANGED
|
@@ -10,11 +10,9 @@ import { recordedHolders, workerResourceAuthorized } from './worker-resource-hol
|
|
|
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';
|
|
13
|
-
import {
|
|
13
|
+
import { assertRunSlotsSealed, deletionRefusal, runRemovalCleanups } from './removal-slots.js';
|
|
14
14
|
import { admissibleExecution, holderRefusal, SPAWN_NEXT, WorkerAdmissionRefusal, workerEvidenceRunIds, workerExecutionSchema } from './worker-execution.js';
|
|
15
|
-
import {
|
|
16
|
-
import { jobRunsIn } from '../jobs/job.js';
|
|
17
|
-
import { removeArtifacts } from '../artifacts/lifecycle.js';
|
|
15
|
+
import { agentTmpDirMayExist, agentTmpDirOwnershipProven, removeAgentTmpDir } from './agent-tmpdir.js';
|
|
18
16
|
import { randomUUID, createHash } from 'node:crypto';
|
|
19
17
|
import { isDeepStrictEqual } from 'node:util';
|
|
20
18
|
import { appendFileSync, closeSync, constants, fstatSync, fsyncSync, lstatSync, openSync, readSync, realpathSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
@@ -2735,7 +2733,7 @@ export class RunStore {
|
|
|
2735
2733
|
}
|
|
2736
2734
|
/** `workerResourcesSafe` with the refusal's live PIDs (empty when no PID explains it). */
|
|
2737
2735
|
workerResourceHolders(id, generation, resourceId, opts = {}) {
|
|
2738
|
-
if (
|
|
2736
|
+
if (deletionRefusal(id, 'worktree', this.dataDir))
|
|
2739
2737
|
return [];
|
|
2740
2738
|
const run = this.peek(id);
|
|
2741
2739
|
const proof = this.readWorkerExecution(id);
|
|
@@ -2760,7 +2758,7 @@ export class RunStore {
|
|
|
2760
2758
|
}
|
|
2761
2759
|
/** Cleanup can outlive its index row, but never its generation or terminal task intent. */
|
|
2762
2760
|
workerScratchResourcesSafe(id, generation, resourceId) {
|
|
2763
|
-
if (
|
|
2761
|
+
if (deletionRefusal(id, 'worktree', this.dataDir))
|
|
2764
2762
|
return false;
|
|
2765
2763
|
const run = this.peek(id), proof = this.readWorkerExecution(id);
|
|
2766
2764
|
if (proof?.phase !== 'complete' || proof.generation !== generation || proof.scratchCleanup?.resourceId !== resourceId ||
|
|
@@ -2912,7 +2910,7 @@ export class RunStore {
|
|
|
2912
2910
|
canDeleteRun(id, kind = 'record') {
|
|
2913
2911
|
if (this.fallbackDeleteError(id, kind))
|
|
2914
2912
|
return false;
|
|
2915
|
-
if (
|
|
2913
|
+
if (deletionRefusal(id, kind === 'record' ? 'history' : 'worktree', this.dataDir))
|
|
2916
2914
|
return false;
|
|
2917
2915
|
const run = this.peek(id);
|
|
2918
2916
|
if (run?.delegation?.role === 'invalid')
|
|
@@ -3005,12 +3003,15 @@ export class RunStore {
|
|
|
3005
3003
|
const dir = join(runDataDir(this.dataDir, id), 'runs');
|
|
3006
3004
|
if (realpathSync(dir) !== resolve(dir))
|
|
3007
3005
|
throw new Error('History storage redirected');
|
|
3006
|
+
this.removeHistoryFiles(id);
|
|
3007
|
+
}
|
|
3008
|
+
/** The run's history, handoff and images, then the removal cleanups (`runs/removal-slots.ts`). */
|
|
3009
|
+
removeHistoryFiles(id) {
|
|
3008
3010
|
this.facts.forget(id);
|
|
3009
3011
|
removeHistory(this.dataDir, id);
|
|
3010
3012
|
rmSync(this.handoffPath(id), { force: true });
|
|
3011
3013
|
rmSync(this.imagesDir(id), { recursive: true, force: true });
|
|
3012
|
-
|
|
3013
|
-
clearAutosaveCleanup(this.dataDir, id);
|
|
3014
|
+
runRemovalCleanups(id, this.dataDir);
|
|
3014
3015
|
}
|
|
3015
3016
|
deleteRun(id) {
|
|
3016
3017
|
const refusal = this.fallbackDeleteError(id);
|
|
@@ -3023,8 +3024,6 @@ export class RunStore {
|
|
|
3023
3024
|
return false;
|
|
3024
3025
|
if (run?.delegation?.role === 'worker' || run?.delegation?.role === 'root')
|
|
3025
3026
|
return this.deleteDelegatedRun(id);
|
|
3026
|
-
if (run)
|
|
3027
|
-
clearAutosaveCleanup(this.dataDir, id);
|
|
3028
3027
|
const existed = run !== undefined;
|
|
3029
3028
|
this.held.delete(id);
|
|
3030
3029
|
if (existed) {
|
|
@@ -3097,19 +3096,17 @@ export class RunStore {
|
|
|
3097
3096
|
this.deletedFamilies.set(id, family);
|
|
3098
3097
|
this.historyOwed.add(id);
|
|
3099
3098
|
}
|
|
3100
|
-
/** A deleted run's history files, once the delete of its row has committed.
|
|
3101
|
-
*
|
|
3099
|
+
/** A deleted run's history files and removal cleanups, once the delete of its row has committed.
|
|
3100
|
+
* Best effort: a failure is logged, and the row stays deleted. */
|
|
3102
3101
|
removeOwedHistory(id) {
|
|
3103
3102
|
if (!this.historyOwed.delete(id))
|
|
3104
3103
|
return;
|
|
3105
3104
|
try {
|
|
3106
|
-
this.
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
removeArtifacts(this.dataDir, id);
|
|
3105
|
+
this.removeHistoryFiles(id);
|
|
3106
|
+
}
|
|
3107
|
+
catch (error) {
|
|
3108
|
+
console.warn(`[hsq] History cleanup of run ${id} is incomplete: ${error instanceof Error ? error.message : String(error)}`);
|
|
3111
3109
|
}
|
|
3112
|
-
catch { /* best effort */ }
|
|
3113
3110
|
}
|
|
3114
3111
|
/**
|
|
3115
3112
|
* Count-based history retention: of the runs past the newest `MAX_RUNS_KEPT` unarchived ones,
|
|
@@ -3159,12 +3156,13 @@ export class RunStore {
|
|
|
3159
3156
|
/** Archive a root with its workers unless a member is live, mid-destroy or pinned, or a history
|
|
3160
3157
|
* deletion is under way. Each member is marked dirty: the next save writes the family at once. */
|
|
3161
3158
|
archiveSettledFamily(root) {
|
|
3159
|
+
assertRunSlotsSealed();
|
|
3162
3160
|
const workers = this.listWorkersOf(root.id), family = [root, ...workers];
|
|
3163
3161
|
if (family.some((run) => isLiveRecord(run) || run.pinned) || (root.delegation?.role === 'root' && root.delegation.historyDeletion))
|
|
3164
3162
|
return;
|
|
3165
3163
|
for (const member of [root, ...workers.flatMap((worker) => this.record(worker.id) ?? [])].filter((run) => !run.archived)) {
|
|
3166
3164
|
this.applyArchived(member, true);
|
|
3167
|
-
if (!
|
|
3165
|
+
if (!deletionRefusal(member.id, 'archive-tmp', this.dataDir))
|
|
3168
3166
|
removeAgentTmpDir(this.dataDir, member.id);
|
|
3169
3167
|
}
|
|
3170
3168
|
}
|