@hearsay-tools/squawk 0.18.0-dev.7779 → 0.18.0-dev.7792
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-cleanup.js +2 -1
- package/dist/autosave-cleanup.js.map +1 -1
- package/dist/autosave-git.js +1 -1
- package/dist/autosave-git.js.map +1 -1
- package/dist/autosave-holders.d.ts +1 -1
- package/dist/autosave-holders.js +2 -1
- package/dist/autosave-holders.js.map +1 -1
- 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 +46 -46
- package/dist/core/process-stat.d.ts +15 -0
- package/dist/core/process-stat.js +41 -1
- package/dist/core/process-stat.js.map +1 -1
- package/dist/delegation/family-end.js +5 -1
- package/dist/delegation/family-end.js.map +1 -1
- package/dist/delegation/process-liveness.d.ts +0 -15
- package/dist/delegation/process-liveness.js +5 -43
- package/dist/delegation/process-liveness.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/service.js +2 -1
- package/dist/delegation/service.js.map +1 -1
- package/dist/delegation/transport.d.ts +76 -76
- package/dist/delegation/worker-cleanup.js +1 -1
- package/dist/delegation/worker-cleanup.js.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/jobs/job.js +2 -1
- package/dist/jobs/job.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/preview/chromium.js +1 -1
- package/dist/preview/chromium.js.map +1 -1
- package/dist/preview/dev-server.js +1 -1
- package/dist/preview/dev-server.js.map +1 -1
- package/dist/process-wait/supervisor.js +1 -1
- package/dist/process-wait/supervisor.js.map +1 -1
- package/dist/project-commands.js +2 -1
- package/dist/project-commands.js.map +1 -1
- package/dist/runs/arm-repo-handle.d.ts +17 -2
- package/dist/runs/arm-repo-handle.js +2 -3
- package/dist/runs/arm-repo-handle.js.map +1 -1
- package/dist/runs/auto-name.d.ts +6 -1
- package/dist/runs/auto-name.js +1 -2
- package/dist/runs/auto-name.js.map +1 -1
- package/dist/runs/owned-run-create.d.ts +4 -1
- package/dist/runs/owned-run-create.js +1 -2
- package/dist/runs/owned-run-create.js.map +1 -1
- 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/run-claims.js +1 -1
- package/dist/runs/run-claims.js.map +1 -1
- package/dist/runs/store.d.ts +7 -4
- package/dist/runs/store.js +21 -24
- package/dist/runs/store.js.map +1 -1
- package/dist/runs/worker-execution.d.ts +1 -1
- package/dist/runs/worker-execution.js +1 -1
- package/dist/runs/worker-execution.js.map +1 -1
- package/dist/runs/worker-resource-holders.d.ts +1 -1
- package/dist/runs/worker-resource-holders.js +1 -1
- package/dist/runs/worker-resource-holders.js.map +1 -1
- package/dist/server/live-routes.d.ts +6 -6
- package/dist/server/project-context.d.ts +1 -1
- package/dist/server/project-context.js +2 -1
- package/dist/server/project-context.js.map +1 -1
- package/dist/server/provider-sign-in-routes.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/dist/worker-scope/worker-scopes.d.ts +1 -1
- package/dist/workflows/run/launch-read-resolver.d.ts +3 -0
- package/dist/workflows/run/launch-read-resolver.js +2 -0
- package/dist/workflows/run/launch-read-resolver.js.map +1 -1
- package/dist/workflows/run/turn-bookkeeping.js +2 -2
- package/dist/workflows/run/turn-bookkeeping.js.map +1 -1
- package/dist/workflows/run/wait-registry.js +1 -1
- package/dist/workflows/run/wait-registry.js.map +1 -1
- package/dist/workflows/run/worker-orphans.d.ts +1 -1
- package/dist/workflows/run/worker-orphans.js +1 -1
- package/dist/workflows/run/worker-orphans.js.map +1 -1
- package/package.json +4 -4
- package/scripts/benchmark-family-reconcile.ts +4 -1
- package/scripts/benchmark-run-store.ts +2 -0
- package/scripts/benchmark-stuck-destroys.ts +4 -1
- package/scripts/benchmark-worker-lifecycle.ts +4 -1
- 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
- package/scripts/seed-archive-profile.ts +2 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { WorkerResults } from './ports.ts';
|
|
2
|
+
import type { RunRecord } from './store.ts';
|
|
3
|
+
/**
|
|
4
|
+
* The removal slots (spec 2026-11-21-run-lifecycle-and-store-ports, "Removal slots"; owner decision
|
|
5
|
+
* 2): the features that a run deletion, a worktree reclaim or a family archive must ask, as three
|
|
6
|
+
* named slots in one process-wide registry. The core asks the registry and imports no feature. An
|
|
7
|
+
* entry fills the registry with `registerBuiltInRunSlots()` (`built-in-run-slots.ts`) before the CLI
|
|
8
|
+
* dispatch; a test seals it with only the slots it needs (`removal-slots.testkit.ts`).
|
|
9
|
+
*
|
|
10
|
+
* Fail closed: until the registry is sealed, every read throws an error that names the missing
|
|
11
|
+
* registration, and each removal path reads it before its first side effect.
|
|
12
|
+
*/
|
|
13
|
+
/** What a deletion removes: a run's history, its worktree or worker resources, or the agent tmp
|
|
14
|
+
* directory of an archived family member. */
|
|
15
|
+
export type DeletionKind = 'history' | 'worktree' | 'archive-tmp';
|
|
16
|
+
/** Refuses a deletion while the feature still needs what it removes. */
|
|
17
|
+
export interface DeletionGate {
|
|
18
|
+
readonly name: string;
|
|
19
|
+
/** A reason refuses the deletion; undefined lets it go ahead. `dataDir` is the run's data dir. */
|
|
20
|
+
refuse(runId: string, kind: DeletionKind, dataDir: string): string | undefined;
|
|
21
|
+
}
|
|
22
|
+
/** What a reclaim preparation gets from the reclaim: the repository and the store it reclaims in. */
|
|
23
|
+
export interface ReclaimContext {
|
|
24
|
+
readonly repoRoot: string;
|
|
25
|
+
/** The store the reclaim runs in. */
|
|
26
|
+
readonly store: WorkerResults;
|
|
27
|
+
}
|
|
28
|
+
/** Work that must finish before a reclaimed worktree goes. A rejection stops the reclaim. */
|
|
29
|
+
export interface ReclaimPreparation {
|
|
30
|
+
readonly name: string;
|
|
31
|
+
prepare(run: RunRecord, context: ReclaimContext): Promise<void>;
|
|
32
|
+
}
|
|
33
|
+
/** Removes what a feature keeps for a run when the run's history goes. */
|
|
34
|
+
export interface RemovalCleanup {
|
|
35
|
+
readonly name: string;
|
|
36
|
+
removed(runId: string, dataDir: string): void;
|
|
37
|
+
}
|
|
38
|
+
export interface RunSlots {
|
|
39
|
+
readonly gates?: readonly DeletionGate[] | undefined;
|
|
40
|
+
readonly preparations?: readonly ReclaimPreparation[] | undefined;
|
|
41
|
+
readonly cleanups?: readonly RemovalCleanup[] | undefined;
|
|
42
|
+
}
|
|
43
|
+
/** Add slots, in call order. Registering the same slot object again does nothing. */
|
|
44
|
+
export declare function registerRunSlots(slots: RunSlots): void;
|
|
45
|
+
/** Close the registry: removals may run, and no new slot may register. */
|
|
46
|
+
export declare function sealRunSlots(): void;
|
|
47
|
+
/** Whether this process sealed its removal slots. Never throws. */
|
|
48
|
+
export declare function runSlotsSealed(): boolean;
|
|
49
|
+
/** Throws unless the registry is sealed. A removal path calls it before its first side effect. */
|
|
50
|
+
export declare function assertRunSlotsSealed(): void;
|
|
51
|
+
/** The first gate's reason to refuse this deletion, in registration order. */
|
|
52
|
+
export declare function deletionRefusal(runId: string, kind: DeletionKind, dataDir: string): string | undefined;
|
|
53
|
+
/** Run every preparation in registration order; the first rejection stops the rest. */
|
|
54
|
+
export declare function prepareReclaim(run: RunRecord, context: ReclaimContext): Promise<void>;
|
|
55
|
+
/** Run every cleanup in registration order, then throw the first failure. */
|
|
56
|
+
export declare function runRemovalCleanups(runId: string, dataDir: string): void;
|
|
@@ -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,CA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AG,EAAE,OAAO,CAAC,CAAC;AAClF,CAAC;AAED,6EAA6E;AAC7E,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;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AC,KAAK,SAAS,CAAC;IAAC,CAAC;IAAC,MAAM,CAAC,CAAC,uBAAuB,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/run-claims.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { randomUUID } from 'node:crypto';
|
|
2
|
-
import { isCurrentProcess, processStartToken, recordedProcessLive } from '../
|
|
2
|
+
import { isCurrentProcess, processStartToken, recordedProcessLive } from '../core/process-stat.js';
|
|
3
3
|
/** The sessions open in this process: the only way to tell two stores in one process apart. */
|
|
4
4
|
const openSessions = new Set();
|
|
5
5
|
let ownStartToken;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-claims.js","sourceRoot":"","sources":["../../src/runs/run-claims.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"run-claims.js","sourceRoot":"","sources":["../../src/runs/run-claims.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAgBnG,+FAA+F;AAC/F,MAAM,YAAY,GAAG,IAAI,GAAG,EAAU,CAAC;AACvC,IAAI,aAAwC,CAAC;AAE7C,4EAA4E;AAC5E,MAAM,UAAU,gBAAgB;IAC9B,aAAa,KAAK,iBAAiB,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC;IACzD,MAAM,KAAK,GAAG,EAAE,OAAO,EAAE,UAAU,EAAE,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,UAAU,EAAE,aAAa,EAAE,CAAC;IACrF,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAChC,OAAO,KAAK,CAAC;AACf,CAAC;AAED,yFAAyF;AACzF,MAAM,UAAU,iBAAiB,CAAC,OAAe;IAC/C,YAAY,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AAC/B,CAAC;AAED,4FAA4F;AAC5F,MAAM,UAAU,cAAc,CAAC,KAAiB;IAC9C,MAAM,KAAK,GAAG,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,GAAG,CAAC,KAAK,CAAC,UAAU,KAAK,IAAI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EAAE,IAAI,CAAC,KAAK;QAAE,OAAO,EAAE,CAAC;IAC7B,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,KAAK,KAAK,CAAC,OAAO,IAAI,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;IACnJ,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AAChF,CAAC;AAED,wGAAwG;AACxG,MAAM,UAAU,SAAS,CAAC,GAAyC;IACjE,OAAO,GAAG,CAAC,UAAU,EAAE,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC;AACjF,CAAC;AAED,mDAAmD;AACnD,MAAM,UAAU,SAAS,CAAC,GAAuC;IAC/D,OAAO,GAAG,CAAC,WAAW,IAAI,GAAG,CAAC,EAAE,CAAC;AACnC,CAAC"}
|
package/dist/runs/store.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ import type { ArchiveFinishedScope, ArchivedRunsResponse, ArchivePullRequestIden
|
|
|
11
11
|
import { type AutomationNames } from '../contract/index.js';
|
|
12
12
|
import { type TranscriptFacts } from './transcript-facts.ts';
|
|
13
13
|
import { type WorkerExecutionIdentity } from '../delegation/execution-identity.ts';
|
|
14
|
-
import { type WorkerProcessRecord } from '../
|
|
14
|
+
import { type WorkerProcessRecord } from '../core/process-stat.ts';
|
|
15
15
|
import { workflowDefSchema } from '../workflows/types.ts';
|
|
16
16
|
import { type OutcomeDependencies, type OutcomeReceipt, type RunOutcome } from './outcome-commit.ts';
|
|
17
17
|
import { type ExitCall, type RunExitId, type RunPatch } from './run-exits.ts';
|
|
@@ -22,6 +22,7 @@ import { type BranchOwner } from './branch-owners.ts';
|
|
|
22
22
|
export { ciWaitEntry, holdsWorkerWait, upgradeLegacyWaits, workerWaitEntry } from './legacy-waits.ts';
|
|
23
23
|
import { type RawExtras } from './raw-record.ts';
|
|
24
24
|
import { RunStoreOpenError } from './store-open-error.ts';
|
|
25
|
+
import { type SpawnCapacityRefusal } from './owned-run-create.ts';
|
|
25
26
|
/** Per-store persistence adapter; the second argument is the normal fenced transaction. */
|
|
26
27
|
export type RunStorePersistence = (changes: RunDatabaseChanges, transaction: RunDatabase['transaction']) => RunDatabaseCommit;
|
|
27
28
|
export type RunStatus = 'queued' | 'running' | 'waiting' | 'review' | 'done' | 'failed' | 'cancelled';
|
|
@@ -3756,7 +3757,7 @@ export declare class RunStore {
|
|
|
3756
3757
|
ignoreCleanup?: boolean;
|
|
3757
3758
|
}): WorkerCollectedResult;
|
|
3758
3759
|
/** Create an owned worker run and its parent receipt; `createStoreOwnedRun` holds the checks. */
|
|
3759
|
-
createOwnedRun(input: Parameters<RunStore['createRun']>[0], parentId: string, requestId: string, worker: DelegationState, requestHash: string, executionIdentity?: WorkerExecutionIdentity): RunRecord;
|
|
3760
|
+
createOwnedRun(input: Parameters<RunStore['createRun']>[0], parentId: string, requestId: string, worker: DelegationState, requestHash: string, spawnCapacityRefusal: SpawnCapacityRefusal, executionIdentity?: WorkerExecutionIdentity): RunRecord;
|
|
3760
3761
|
/**
|
|
3761
3762
|
* Durably replace or delete staged rows together with pending dirty rows. Persist before
|
|
3762
3763
|
* changing held objects or notifying subscribers. On failure retain all pending state; flush()
|
|
@@ -4004,6 +4005,8 @@ export declare class RunStore {
|
|
|
4004
4005
|
/** Delegated history deletion is synchronous and checkpointed; any failed byte/index removal remains retryable. */
|
|
4005
4006
|
private deleteDelegatedRun;
|
|
4006
4007
|
private removeRunHistoryBytes;
|
|
4008
|
+
/** The run's history, handoff and images, then the removal cleanups (`runs/removal-slots.ts`). */
|
|
4009
|
+
private removeHistoryFiles;
|
|
4007
4010
|
deleteRun(id: string): boolean;
|
|
4008
4011
|
/** Write the pending rows out now (used on shutdown). */
|
|
4009
4012
|
flush(): void;
|
|
@@ -4028,8 +4031,8 @@ export declare class RunStore {
|
|
|
4028
4031
|
/** The held record is gone; the next save or commit deletes its row, fenced by `family`'s claim
|
|
4029
4032
|
* and by the revision this store last saw (kept in `base` until the delete is written). */
|
|
4030
4033
|
private markDeleted;
|
|
4031
|
-
/** A deleted run's history files, once the delete of its row has committed.
|
|
4032
|
-
*
|
|
4034
|
+
/** A deleted run's history files and removal cleanups, once the delete of its row has committed.
|
|
4035
|
+
* Best effort: a failure is logged, and the row stays deleted. */
|
|
4033
4036
|
private removeOwedHistory;
|
|
4034
4037
|
/**
|
|
4035
4038
|
* 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';
|
|
@@ -38,7 +36,7 @@ import { LiveItemSnapshots } from './live-item-snapshots.js';
|
|
|
38
36
|
import { emptyFacts, stampOf, TranscriptFactsIndex } from './transcript-facts.js';
|
|
39
37
|
import { hasPlainHistory, historyPaths, readHistoryText, readHistoryTextAsync, removeHistory, restoreHistory } from './history-file.js';
|
|
40
38
|
import { workerExecutionIdentitySchema } from '../delegation/execution-identity.js';
|
|
41
|
-
import {
|
|
39
|
+
import { startToken } from '../core/process-stat.js';
|
|
42
40
|
import { collectSecretValues, redactDeep } from '../core/secret-redaction.js';
|
|
43
41
|
// Pure, dependency-free reference helpers — the same sanity bound the marker parser applies.
|
|
44
42
|
import { archivePullRequests, pullRequestKey } from './pull-requests.js';
|
|
@@ -424,7 +422,6 @@ const recordedProcessSchema = z.object({ pid: z.number().int().positive(), start
|
|
|
424
422
|
pgid: z.number().int().positive().optional() }).strict();
|
|
425
423
|
const workerProcessRecordSchema = z.object({ generation: z.string().uuid(), controller: recordedProcessSchema,
|
|
426
424
|
processes: z.array(recordedProcessSchema).max(WORKER_PROCESS_CAP) }).strict();
|
|
427
|
-
const startToken = (pid) => { const token = processStartToken(pid); return token === undefined ? {} : { startToken: token }; };
|
|
428
425
|
/**
|
|
429
426
|
* Run rows in runs.db plus append-only NDJSON events and an in-process event bus. Hold live,
|
|
430
427
|
* pinned, related and unsettled records only. Optimistic writes debounce; durable commits
|
|
@@ -1857,7 +1854,7 @@ export class RunStore {
|
|
|
1857
1854
|
}, parentId, value, diffSnapshot, opts);
|
|
1858
1855
|
}
|
|
1859
1856
|
/** Create an owned worker run and its parent receipt; `createStoreOwnedRun` holds the checks. */
|
|
1860
|
-
createOwnedRun(input, parentId, requestId, worker, requestHash, executionIdentity = { kind: 'internal' }) {
|
|
1857
|
+
createOwnedRun(input, parentId, requestId, worker, requestHash, spawnCapacityRefusal, executionIdentity = { kind: 'internal' }) {
|
|
1861
1858
|
return createStoreOwnedRun({
|
|
1862
1859
|
peek: (id) => this.peek(id),
|
|
1863
1860
|
hasRun: (id) => this.hasRun(id),
|
|
@@ -1866,7 +1863,7 @@ export class RunStore {
|
|
|
1866
1863
|
writeWorkerIdentity: (id, identity) => this.writeWorkerIdentity(id, identity),
|
|
1867
1864
|
writeWorkerExecution: (id, proof, fresh) => this.writeWorkerExecution(id, proof, fresh),
|
|
1868
1865
|
commitIndex: (owned) => this.commitIndex(owned),
|
|
1869
|
-
}, input, parentId, requestId, worker, requestHash, executionIdentity);
|
|
1866
|
+
}, input, parentId, requestId, worker, requestHash, spawnCapacityRefusal, executionIdentity);
|
|
1870
1867
|
}
|
|
1871
1868
|
/**
|
|
1872
1869
|
* Durably replace or delete staged rows together with pending dirty rows. Persist before
|
|
@@ -2735,7 +2732,7 @@ export class RunStore {
|
|
|
2735
2732
|
}
|
|
2736
2733
|
/** `workerResourcesSafe` with the refusal's live PIDs (empty when no PID explains it). */
|
|
2737
2734
|
workerResourceHolders(id, generation, resourceId, opts = {}) {
|
|
2738
|
-
if (
|
|
2735
|
+
if (deletionRefusal(id, 'worktree', this.dataDir))
|
|
2739
2736
|
return [];
|
|
2740
2737
|
const run = this.peek(id);
|
|
2741
2738
|
const proof = this.readWorkerExecution(id);
|
|
@@ -2760,7 +2757,7 @@ export class RunStore {
|
|
|
2760
2757
|
}
|
|
2761
2758
|
/** Cleanup can outlive its index row, but never its generation or terminal task intent. */
|
|
2762
2759
|
workerScratchResourcesSafe(id, generation, resourceId) {
|
|
2763
|
-
if (
|
|
2760
|
+
if (deletionRefusal(id, 'worktree', this.dataDir))
|
|
2764
2761
|
return false;
|
|
2765
2762
|
const run = this.peek(id), proof = this.readWorkerExecution(id);
|
|
2766
2763
|
if (proof?.phase !== 'complete' || proof.generation !== generation || proof.scratchCleanup?.resourceId !== resourceId ||
|
|
@@ -2912,7 +2909,7 @@ export class RunStore {
|
|
|
2912
2909
|
canDeleteRun(id, kind = 'record') {
|
|
2913
2910
|
if (this.fallbackDeleteError(id, kind))
|
|
2914
2911
|
return false;
|
|
2915
|
-
if (
|
|
2912
|
+
if (deletionRefusal(id, kind === 'record' ? 'history' : 'worktree', this.dataDir))
|
|
2916
2913
|
return false;
|
|
2917
2914
|
const run = this.peek(id);
|
|
2918
2915
|
if (run?.delegation?.role === 'invalid')
|
|
@@ -3005,12 +3002,15 @@ export class RunStore {
|
|
|
3005
3002
|
const dir = join(runDataDir(this.dataDir, id), 'runs');
|
|
3006
3003
|
if (realpathSync(dir) !== resolve(dir))
|
|
3007
3004
|
throw new Error('History storage redirected');
|
|
3005
|
+
this.removeHistoryFiles(id);
|
|
3006
|
+
}
|
|
3007
|
+
/** The run's history, handoff and images, then the removal cleanups (`runs/removal-slots.ts`). */
|
|
3008
|
+
removeHistoryFiles(id) {
|
|
3008
3009
|
this.facts.forget(id);
|
|
3009
3010
|
removeHistory(this.dataDir, id);
|
|
3010
3011
|
rmSync(this.handoffPath(id), { force: true });
|
|
3011
3012
|
rmSync(this.imagesDir(id), { recursive: true, force: true });
|
|
3012
|
-
|
|
3013
|
-
clearAutosaveCleanup(this.dataDir, id);
|
|
3013
|
+
runRemovalCleanups(id, this.dataDir);
|
|
3014
3014
|
}
|
|
3015
3015
|
deleteRun(id) {
|
|
3016
3016
|
const refusal = this.fallbackDeleteError(id);
|
|
@@ -3023,8 +3023,6 @@ export class RunStore {
|
|
|
3023
3023
|
return false;
|
|
3024
3024
|
if (run?.delegation?.role === 'worker' || run?.delegation?.role === 'root')
|
|
3025
3025
|
return this.deleteDelegatedRun(id);
|
|
3026
|
-
if (run)
|
|
3027
|
-
clearAutosaveCleanup(this.dataDir, id);
|
|
3028
3026
|
const existed = run !== undefined;
|
|
3029
3027
|
this.held.delete(id);
|
|
3030
3028
|
if (existed) {
|
|
@@ -3097,19 +3095,17 @@ export class RunStore {
|
|
|
3097
3095
|
this.deletedFamilies.set(id, family);
|
|
3098
3096
|
this.historyOwed.add(id);
|
|
3099
3097
|
}
|
|
3100
|
-
/** A deleted run's history files, once the delete of its row has committed.
|
|
3101
|
-
*
|
|
3098
|
+
/** A deleted run's history files and removal cleanups, once the delete of its row has committed.
|
|
3099
|
+
* Best effort: a failure is logged, and the row stays deleted. */
|
|
3102
3100
|
removeOwedHistory(id) {
|
|
3103
3101
|
if (!this.historyOwed.delete(id))
|
|
3104
3102
|
return;
|
|
3105
3103
|
try {
|
|
3106
|
-
this.
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
removeArtifacts(this.dataDir, id);
|
|
3104
|
+
this.removeHistoryFiles(id);
|
|
3105
|
+
}
|
|
3106
|
+
catch (error) {
|
|
3107
|
+
console.warn(`[hsq] History cleanup of run ${id} is incomplete: ${error instanceof Error ? error.message : String(error)}`);
|
|
3111
3108
|
}
|
|
3112
|
-
catch { /* best effort */ }
|
|
3113
3109
|
}
|
|
3114
3110
|
/**
|
|
3115
3111
|
* Count-based history retention: of the runs past the newest `MAX_RUNS_KEPT` unarchived ones,
|
|
@@ -3159,12 +3155,13 @@ export class RunStore {
|
|
|
3159
3155
|
/** Archive a root with its workers unless a member is live, mid-destroy or pinned, or a history
|
|
3160
3156
|
* deletion is under way. Each member is marked dirty: the next save writes the family at once. */
|
|
3161
3157
|
archiveSettledFamily(root) {
|
|
3158
|
+
assertRunSlotsSealed();
|
|
3162
3159
|
const workers = this.listWorkersOf(root.id), family = [root, ...workers];
|
|
3163
3160
|
if (family.some((run) => isLiveRecord(run) || run.pinned) || (root.delegation?.role === 'root' && root.delegation.historyDeletion))
|
|
3164
3161
|
return;
|
|
3165
3162
|
for (const member of [root, ...workers.flatMap((worker) => this.record(worker.id) ?? [])].filter((run) => !run.archived)) {
|
|
3166
3163
|
this.applyArchived(member, true);
|
|
3167
|
-
if (!
|
|
3164
|
+
if (!deletionRefusal(member.id, 'archive-tmp', this.dataDir))
|
|
3168
3165
|
removeAgentTmpDir(this.dataDir, member.id);
|
|
3169
3166
|
}
|
|
3170
3167
|
}
|