@usine/executor 0.2.1 → 0.4.0
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/LICENSE +661 -21
- package/README.md +212 -37
- package/dist/child-command.d.ts +5 -8
- package/dist/child-command.d.ts.map +1 -1
- package/dist/child-command.js +10 -14
- package/dist/child-command.js.map +1 -1
- package/dist/child-environment.d.ts +19 -0
- package/dist/child-environment.d.ts.map +1 -0
- package/dist/child-environment.js +18 -0
- package/dist/child-environment.js.map +1 -0
- package/dist/claude-login-lock.d.ts +9 -0
- package/dist/claude-login-lock.d.ts.map +1 -0
- package/dist/claude-login-lock.js +15 -0
- package/dist/claude-login-lock.js.map +1 -0
- package/dist/cloudflare/client.d.ts +50 -0
- package/dist/cloudflare/client.d.ts.map +1 -0
- package/dist/cloudflare/client.js +108 -0
- package/dist/cloudflare/client.js.map +1 -0
- package/dist/cloudflare/cloudflare.d.ts +17 -0
- package/dist/cloudflare/cloudflare.d.ts.map +1 -0
- package/dist/cloudflare/cloudflare.js +704 -0
- package/dist/cloudflare/cloudflare.js.map +1 -0
- package/dist/cloudflare/model.d.ts +42 -0
- package/dist/cloudflare/model.d.ts.map +1 -0
- package/dist/cloudflare/model.js +2 -0
- package/dist/cloudflare/model.js.map +1 -0
- package/dist/cloudflare/shell/environment.d.ts +12 -0
- package/dist/cloudflare/shell/environment.d.ts.map +1 -0
- package/dist/cloudflare/shell/environment.js +12 -0
- package/dist/cloudflare/shell/environment.js.map +1 -0
- package/dist/cloudflare/shell/shell.d.ts +2 -0
- package/dist/cloudflare/shell/shell.d.ts.map +1 -0
- package/dist/cloudflare/shell/shell.js +155 -0
- package/dist/cloudflare/shell/shell.js.map +1 -0
- package/dist/credential-environment.d.ts +20 -0
- package/dist/credential-environment.d.ts.map +1 -0
- package/dist/credential-environment.js +20 -0
- package/dist/credential-environment.js.map +1 -0
- package/dist/durable-session.d.ts +81 -0
- package/dist/durable-session.d.ts.map +1 -0
- package/dist/durable-session.js +550 -0
- package/dist/durable-session.js.map +1 -0
- package/dist/exe-dev/commands.d.ts +23 -13
- package/dist/exe-dev/commands.d.ts.map +1 -1
- package/dist/exe-dev/commands.js +11 -57
- package/dist/exe-dev/commands.js.map +1 -1
- package/dist/exe-dev/exe-dev.d.ts +9 -3
- package/dist/exe-dev/exe-dev.d.ts.map +1 -1
- package/dist/exe-dev/exe-dev.js +61 -128
- package/dist/exe-dev/exe-dev.js.map +1 -1
- package/dist/exe-dev/grants.d.ts.map +1 -1
- package/dist/exe-dev/grants.js +35 -15
- package/dist/exe-dev/grants.js.map +1 -1
- package/dist/exe-dev/model.d.ts +15 -19
- package/dist/exe-dev/model.d.ts.map +1 -1
- package/dist/exe-dev/model.js +9 -12
- package/dist/exe-dev/model.js.map +1 -1
- package/dist/exe-dev/preflight.d.ts +8 -4
- package/dist/exe-dev/preflight.d.ts.map +1 -1
- package/dist/exe-dev/preflight.js +26 -35
- package/dist/exe-dev/preflight.js.map +1 -1
- package/dist/executor.d.ts +292 -44
- package/dist/executor.d.ts.map +1 -1
- package/dist/executor.js +187 -19
- package/dist/executor.js.map +1 -1
- package/dist/guard.d.ts +57 -7
- package/dist/guard.d.ts.map +1 -1
- package/dist/guard.js +274 -59
- package/dist/guard.js.map +1 -1
- package/dist/harness-preflight.d.ts +27 -5
- package/dist/harness-preflight.d.ts.map +1 -1
- package/dist/harness-preflight.js +32 -31
- package/dist/harness-preflight.js.map +1 -1
- package/dist/keyed-lock.d.ts +2 -3
- package/dist/keyed-lock.d.ts.map +1 -1
- package/dist/keyed-lock.js +2 -3
- package/dist/keyed-lock.js.map +1 -1
- package/dist/leftovers.d.ts +9 -0
- package/dist/leftovers.d.ts.map +1 -0
- package/dist/leftovers.js +14 -0
- package/dist/leftovers.js.map +1 -0
- package/dist/local/credentials.d.ts +21 -0
- package/dist/local/credentials.d.ts.map +1 -0
- package/dist/local/credentials.js +39 -0
- package/dist/local/credentials.js.map +1 -0
- package/dist/local/leftovers.d.ts +8 -0
- package/dist/local/leftovers.d.ts.map +1 -0
- package/dist/local/leftovers.js +23 -0
- package/dist/local/leftovers.js.map +1 -0
- package/dist/local/local.d.ts +17 -11
- package/dist/local/local.d.ts.map +1 -1
- package/dist/local/local.js +205 -132
- package/dist/local/local.js.map +1 -1
- package/dist/memory-preflight.d.ts +27 -0
- package/dist/memory-preflight.d.ts.map +1 -0
- package/dist/memory-preflight.js +83 -0
- package/dist/memory-preflight.js.map +1 -0
- package/dist/pre-push-hook.d.ts +20 -0
- package/dist/pre-push-hook.d.ts.map +1 -0
- package/dist/pre-push-hook.js +33 -0
- package/dist/pre-push-hook.js.map +1 -0
- package/dist/prepared-attempt.d.ts +41 -3
- package/dist/prepared-attempt.d.ts.map +1 -1
- package/dist/prepared-attempt.js +109 -31
- package/dist/prepared-attempt.js.map +1 -1
- package/dist/provision.d.ts +129 -15
- package/dist/provision.d.ts.map +1 -1
- package/dist/provision.js +428 -69
- package/dist/provision.js.map +1 -1
- package/dist/remote/commands.d.ts +51 -0
- package/dist/remote/commands.d.ts.map +1 -0
- package/dist/remote/commands.js +94 -0
- package/dist/remote/commands.js.map +1 -0
- package/dist/remote/container.d.ts +90 -0
- package/dist/remote/container.d.ts.map +1 -0
- package/dist/remote/container.js +480 -0
- package/dist/remote/container.js.map +1 -0
- package/dist/remote/leftovers.d.ts +14 -0
- package/dist/remote/leftovers.d.ts.map +1 -0
- package/dist/remote/leftovers.js +22 -0
- package/dist/remote/leftovers.js.map +1 -0
- package/dist/remote/liveness.d.ts +33 -0
- package/dist/remote/liveness.d.ts.map +1 -0
- package/dist/remote/liveness.js +196 -0
- package/dist/remote/liveness.js.map +1 -0
- package/dist/remote/machine.d.ts +110 -0
- package/dist/remote/machine.d.ts.map +1 -0
- package/dist/remote/machine.js +2 -0
- package/dist/remote/machine.js.map +1 -0
- package/dist/remote/remote.d.ts +28 -0
- package/dist/remote/remote.d.ts.map +1 -0
- package/dist/remote/remote.js +556 -0
- package/dist/remote/remote.js.map +1 -0
- package/dist/remote/sweep.d.ts +17 -0
- package/dist/remote/sweep.d.ts.map +1 -0
- package/dist/remote/sweep.js +117 -0
- package/dist/remote/sweep.js.map +1 -0
- package/dist/renewable-credential.d.ts +17 -0
- package/dist/renewable-credential.d.ts.map +1 -0
- package/dist/renewable-credential.js +58 -0
- package/dist/renewable-credential.js.map +1 -0
- package/dist/salvage.d.ts +38 -0
- package/dist/salvage.d.ts.map +1 -0
- package/dist/salvage.js +198 -0
- package/dist/salvage.js.map +1 -0
- package/dist/ssh/api-keys.d.ts +36 -0
- package/dist/ssh/api-keys.d.ts.map +1 -0
- package/dist/ssh/api-keys.js +72 -0
- package/dist/ssh/api-keys.js.map +1 -0
- package/dist/ssh/codex-homes.d.ts +21 -0
- package/dist/ssh/codex-homes.d.ts.map +1 -0
- package/dist/ssh/codex-homes.js +78 -0
- package/dist/ssh/codex-homes.js.map +1 -0
- package/dist/ssh/container.d.ts +32 -0
- package/dist/ssh/container.d.ts.map +1 -0
- package/dist/ssh/container.js +282 -0
- package/dist/ssh/container.js.map +1 -0
- package/dist/ssh/credentials.d.ts +43 -0
- package/dist/ssh/credentials.d.ts.map +1 -0
- package/dist/ssh/credentials.js +86 -0
- package/dist/ssh/credentials.js.map +1 -0
- package/dist/ssh/gateway/admin.d.ts +45 -0
- package/dist/ssh/gateway/admin.d.ts.map +1 -0
- package/dist/ssh/gateway/admin.js +129 -0
- package/dist/ssh/gateway/admin.js.map +1 -0
- package/dist/ssh/gateway/attachments.d.ts +31 -0
- package/dist/ssh/gateway/attachments.d.ts.map +1 -0
- package/dist/ssh/gateway/attachments.js +168 -0
- package/dist/ssh/gateway/attachments.js.map +1 -0
- package/dist/ssh/gateway/environment.d.ts +71 -0
- package/dist/ssh/gateway/environment.d.ts.map +1 -0
- package/dist/ssh/gateway/environment.js +148 -0
- package/dist/ssh/gateway/environment.js.map +1 -0
- package/dist/ssh/gateway/forward.d.ts +74 -0
- package/dist/ssh/gateway/forward.d.ts.map +1 -0
- package/dist/ssh/gateway/forward.js +247 -0
- package/dist/ssh/gateway/forward.js.map +1 -0
- package/dist/ssh/gateway/preflight.d.ts +67 -0
- package/dist/ssh/gateway/preflight.d.ts.map +1 -0
- package/dist/ssh/gateway/preflight.js +320 -0
- package/dist/ssh/gateway/preflight.js.map +1 -0
- package/dist/ssh/limits.d.ts +60 -0
- package/dist/ssh/limits.d.ts.map +1 -0
- package/dist/ssh/limits.js +84 -0
- package/dist/ssh/limits.js.map +1 -0
- package/dist/ssh/model.d.ts +153 -0
- package/dist/ssh/model.d.ts.map +1 -0
- package/dist/ssh/model.js +2 -0
- package/dist/ssh/model.js.map +1 -0
- package/dist/ssh/preflight.d.ts +35 -0
- package/dist/ssh/preflight.d.ts.map +1 -0
- package/dist/ssh/preflight.js +87 -0
- package/dist/ssh/preflight.js.map +1 -0
- package/dist/ssh/provisioner/boat.d.ts +33 -0
- package/dist/ssh/provisioner/boat.d.ts.map +1 -0
- package/dist/ssh/provisioner/boat.js +247 -0
- package/dist/ssh/provisioner/boat.js.map +1 -0
- package/dist/ssh/provisioner/hetzner.d.ts +32 -0
- package/dist/ssh/provisioner/hetzner.d.ts.map +1 -0
- package/dist/ssh/provisioner/hetzner.js +337 -0
- package/dist/ssh/provisioner/hetzner.js.map +1 -0
- package/dist/ssh/provisioner/host-key.d.ts +11 -0
- package/dist/ssh/provisioner/host-key.d.ts.map +1 -0
- package/dist/ssh/provisioner/host-key.js +57 -0
- package/dist/ssh/provisioner/host-key.js.map +1 -0
- package/dist/ssh/provisioner/http.d.ts +45 -0
- package/dist/ssh/provisioner/http.d.ts.map +1 -0
- package/dist/ssh/provisioner/http.js +72 -0
- package/dist/ssh/provisioner/http.js.map +1 -0
- package/dist/ssh/provisioner/machines.d.ts +48 -0
- package/dist/ssh/provisioner/machines.d.ts.map +1 -0
- package/dist/ssh/provisioner/machines.js +686 -0
- package/dist/ssh/provisioner/machines.js.map +1 -0
- package/dist/ssh/provisioner/model.d.ts +92 -0
- package/dist/ssh/provisioner/model.d.ts.map +1 -0
- package/dist/ssh/provisioner/model.js +37 -0
- package/dist/ssh/provisioner/model.js.map +1 -0
- package/dist/ssh/ssh.d.ts +23 -0
- package/dist/ssh/ssh.d.ts.map +1 -0
- package/dist/ssh/ssh.js +145 -0
- package/dist/ssh/ssh.js.map +1 -0
- package/dist/ssh/worker-records.d.ts +18 -0
- package/dist/ssh/worker-records.d.ts.map +1 -0
- package/dist/ssh/worker-records.js +100 -0
- package/dist/ssh/worker-records.js.map +1 -0
- package/dist/ssh/workers.d.ts +80 -0
- package/dist/ssh/workers.d.ts.map +1 -0
- package/dist/ssh/workers.js +247 -0
- package/dist/ssh/workers.js.map +1 -0
- package/package.json +25 -9
- package/dist/exe-dev/channel.d.ts +0 -12
- package/dist/exe-dev/channel.d.ts.map +0 -1
- package/dist/exe-dev/channel.js +0 -42
- package/dist/exe-dev/channel.js.map +0 -1
- package/dist/exe-dev/shell.d.ts +0 -12
- package/dist/exe-dev/shell.d.ts.map +0 -1
- package/dist/exe-dev/shell.js +0 -31
- package/dist/exe-dev/shell.js.map +0 -1
- package/dist/exe-dev/sweep.d.ts +0 -10
- package/dist/exe-dev/sweep.d.ts.map +0 -1
- package/dist/exe-dev/sweep.js +0 -117
- package/dist/exe-dev/sweep.js.map +0 -1
- package/dist/invalid-frame.d.ts +0 -17
- package/dist/invalid-frame.d.ts.map +0 -1
- package/dist/invalid-frame.js +0 -111
- package/dist/invalid-frame.js.map +0 -1
- package/dist/run-host-session.d.ts +0 -27
- package/dist/run-host-session.d.ts.map +0 -1
- package/dist/run-host-session.js +0 -303
- package/dist/run-host-session.js.map +0 -1
|
@@ -0,0 +1,556 @@
|
|
|
1
|
+
import { CHILD_KILL_SCRIPT } from "@usine/agents/child-host";
|
|
2
|
+
import { ClaudeLoginLock } from "@usine/agents/runtime";
|
|
3
|
+
import { InfraFailure } from "@usine/core/attempt/failure";
|
|
4
|
+
import { RepositoryName, safeSegment } from "@usine/core/repository";
|
|
5
|
+
import { harvestFacts, harvestPostedComments, } from "@usine/core/step/harvest";
|
|
6
|
+
import { AttemptRuntime } from "@usine/durable/attempt-runtime";
|
|
7
|
+
import { Deferred, Effect, Exit, Option, Schema, Scope, SynchronizedRef } from "effect";
|
|
8
|
+
import { durableSessionFor } from "../durable-session.js";
|
|
9
|
+
import { CheckoutRequest, Executor, ExecutorError, ExecutorOperationError, WorkerCapabilityError, } from "../executor.js";
|
|
10
|
+
import { verifyHarnessReadiness } from "../harness-preflight.js";
|
|
11
|
+
import { childEnvironment, commitIdentity } from "../child-environment.js";
|
|
12
|
+
import { keyedLockFor } from "../keyed-lock.js";
|
|
13
|
+
import { cacheDirectoryName, keptCheckoutRecovery, linkedWorktree, provisionWorktree, reattachWorktree, recoverWorktree, recoveryFields, } from "../provision.js";
|
|
14
|
+
import { attemptContainerName, containerCheckoutMarker, containersFor, } from "./container.js";
|
|
15
|
+
import { workerLeftoversFor } from "./leftovers.js";
|
|
16
|
+
import { workerWatchesFor } from "./liveness.js";
|
|
17
|
+
import { abandonedWorktreeSweepFor } from "./sweep.js";
|
|
18
|
+
const isExecutorError = Schema.is(ExecutorError);
|
|
19
|
+
const executorError = (message, cause) => new ExecutorOperationError({ operation: "prepare", message, cause });
|
|
20
|
+
/** A script that writes `$2` to the file `$1`, creating its directory, and makes it executable. */
|
|
21
|
+
const WRITE_EXECUTABLE_SCRIPT = String.raw `
|
|
22
|
+
set -e
|
|
23
|
+
mkdir -p "$(dirname "$1")"
|
|
24
|
+
printf '%s' "$2" > "$1"
|
|
25
|
+
chmod 755 "$1"
|
|
26
|
+
`.trim();
|
|
27
|
+
/**
|
|
28
|
+
* A script that creates the checkout `$1` as its own repository at commit `$4`: objects come from
|
|
29
|
+
* the cached clone `$2` through an alternate, and missing blobs from the partial-clone remote
|
|
30
|
+
* `$3`. The checkout writes only its own directory, so the cached clone can be read-only.
|
|
31
|
+
*/
|
|
32
|
+
const STANDALONE_CHECKOUT_SCRIPT = String.raw `
|
|
33
|
+
set -e
|
|
34
|
+
git init -q "$1"
|
|
35
|
+
printf '%s\n' "$2/objects" > "$1/.git/objects/info/alternates"
|
|
36
|
+
git -C "$1" config core.repositoryformatversion 1
|
|
37
|
+
git -C "$1" config extensions.partialClone origin
|
|
38
|
+
git -C "$1" remote add origin "$3"
|
|
39
|
+
git -C "$1" config remote.origin.promisor true
|
|
40
|
+
git -C "$1" config remote.origin.partialclonefilter blob:none
|
|
41
|
+
git -C "$1" checkout -q --detach "$4"
|
|
42
|
+
`.trim();
|
|
43
|
+
/** A script that removes the checkout `$1`, then its container marker `$2`. */
|
|
44
|
+
const REMOVE_CHECKOUT_SCRIPT = 'rm -rf "$1" && rm -f "$2"';
|
|
45
|
+
/** A script that removes everything inside the directory `$1` and keeps the directory. */
|
|
46
|
+
const EMPTY_DIRECTORY_SCRIPT = 'find "$1" -mindepth 1 -maxdepth 1 -exec rm -rf {} +';
|
|
47
|
+
/**
|
|
48
|
+
* Returns the executor for Workers accessed over SSH. Each Attempt's Pi parent is a durable task
|
|
49
|
+
* in this process, and each child runs on the machine as one SSH command with a pid file next
|
|
50
|
+
* to the worktree, or inside the Attempt's container. `worker` provides the machine, preflight,
|
|
51
|
+
* isolation, and repository access.
|
|
52
|
+
*/
|
|
53
|
+
export const remoteExecutorFor = (worker) => Effect.gen(function* () {
|
|
54
|
+
const { commands, label } = worker;
|
|
55
|
+
const span = (name) => `${worker.spanPrefix}.${name}`;
|
|
56
|
+
const fetches = yield* keyedLockFor();
|
|
57
|
+
const logins = yield* ClaudeLoginLock;
|
|
58
|
+
const sweepAbandonedWorktrees = yield* abandonedWorktreeSweepFor(commands);
|
|
59
|
+
const workerLeftovers = yield* workerLeftoversFor(commands, worker.machineFor, worker.reclaim);
|
|
60
|
+
const session = yield* durableSessionFor({ interruptGrace: worker.interruptGrace });
|
|
61
|
+
const runtime = yield* AttemptRuntime;
|
|
62
|
+
const workerWatches = yield* workerWatchesFor(commands);
|
|
63
|
+
const containers = containersFor(commands);
|
|
64
|
+
const attemptMachine = worker.attemptMachine ??
|
|
65
|
+
((name, _attemptId) => worker.machineFor(name));
|
|
66
|
+
const leftoversOf = (attempt) => worker.leftovers === undefined
|
|
67
|
+
? workerLeftovers(attempt.worker).pipe(Effect.map((found) => Option.some(found)))
|
|
68
|
+
: worker.leftovers(attempt, workerLeftovers(attempt.worker));
|
|
69
|
+
const recovered = worker.recovered ?? (() => Effect.void);
|
|
70
|
+
const checkoutHeld = worker.checkoutHeld ?? (() => Effect.void);
|
|
71
|
+
/** Returns `removal` that records the checkout of `attemptId` as gone once it succeeds. */
|
|
72
|
+
const removing = (attemptId, removal) => Effect.tap(removal, () => checkoutHeld(attemptId, false));
|
|
73
|
+
const cachePath = (machine, repository) => `${machine.workerDirectory}/repos/${cacheDirectoryName(repository)}`;
|
|
74
|
+
const stopChildren = Effect.fn(span("stopChildren"))(function* (operation, machine, worktree, attemptId, isolation) {
|
|
75
|
+
const host = machine.shell.destination;
|
|
76
|
+
yield* Effect.annotateCurrentSpan({ host, worktree, isolation: isolation._tag });
|
|
77
|
+
if (isolation._tag === "Container")
|
|
78
|
+
return yield* containers.stopChildren(operation, machine.shell, attemptContainerName(attemptId), worktree);
|
|
79
|
+
const outcome = yield* commands.run(operation, machine.shell, "sh", [
|
|
80
|
+
"-c",
|
|
81
|
+
CHILD_KILL_SCRIPT,
|
|
82
|
+
"sh",
|
|
83
|
+
worktree,
|
|
84
|
+
]);
|
|
85
|
+
yield* Effect.logInfo("Confirmed no child of the Attempt runs on the Worker's machine", {
|
|
86
|
+
host,
|
|
87
|
+
worktree,
|
|
88
|
+
children: outcome.trim().split("\n"),
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
/**
|
|
92
|
+
* Returns how commands run in `attemptId`'s existing checkout at `worktree`: in its container
|
|
93
|
+
* if the container marker, which no container can reach, records one, or as the SSH user if
|
|
94
|
+
* it records none. Nothing in the checkout decides, since an Attempt can change it. Fails if
|
|
95
|
+
* the Worker's `isolation` can't run the checkout that way: a container's checkout on a
|
|
96
|
+
* machine without Docker, or a checkout from before Docker, as the SSH user who can now use
|
|
97
|
+
* Docker.
|
|
98
|
+
*/
|
|
99
|
+
const isolationOfCheckout = Effect.fn(span("isolationOfCheckout"))(function* (operation, machine, attemptId, worktree, isolation) {
|
|
100
|
+
if (!worker.runsContainers)
|
|
101
|
+
return isolation;
|
|
102
|
+
const host = machine.shell.destination;
|
|
103
|
+
yield* Effect.annotateCurrentSpan({ host, worktree, isolation: isolation._tag });
|
|
104
|
+
const contained = yield* containers.marked(operation, machine.shell, containerCheckoutMarker(machine.workerDirectory, attemptId));
|
|
105
|
+
if (contained === (isolation._tag === "Container"))
|
|
106
|
+
return isolation;
|
|
107
|
+
const message = contained
|
|
108
|
+
? `The checkout ${worktree} was mounted in an attempt container, and the machine no longer has Docker, so usine runs no command in it as the SSH user. Install Docker, or salvage and remove the checkout by hand.`
|
|
109
|
+
: `The checkout ${worktree} is from before the machine had Docker, and the SSH user can use Docker, so usine runs no command in it as that user. Salvage and remove the checkout by hand.`;
|
|
110
|
+
yield* Effect.logError("Refused to run commands in the checkout", {
|
|
111
|
+
attemptId,
|
|
112
|
+
host,
|
|
113
|
+
worktree,
|
|
114
|
+
contained,
|
|
115
|
+
message,
|
|
116
|
+
});
|
|
117
|
+
return yield* new ExecutorOperationError({
|
|
118
|
+
operation,
|
|
119
|
+
message,
|
|
120
|
+
cause: new Error(contained ? "container marker without Docker" : "no container marker"),
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
/** Returns the container of an Attempt, which mounts its checkout and the paths of `access`. */
|
|
124
|
+
const containerSpec = (machine, settings, attempt, worktree, access, harnesses) => ({
|
|
125
|
+
name: attemptContainerName(attempt.attemptId),
|
|
126
|
+
settings,
|
|
127
|
+
worker: attempt.worker,
|
|
128
|
+
attemptId: Option.some(attempt.attemptId),
|
|
129
|
+
checkout: Option.some({ path: worktree, parent: `${machine.workerDirectory}/attempts` }),
|
|
130
|
+
readOnly: [cachePath(machine, attempt.repository), ...access.readOnlyPaths],
|
|
131
|
+
writable: access.writablePaths,
|
|
132
|
+
harnesses,
|
|
133
|
+
environment: access.environment,
|
|
134
|
+
secrets: access.secrets,
|
|
135
|
+
});
|
|
136
|
+
/**
|
|
137
|
+
* Returns where the Attempt's commands in its checkout run. In a container, the container
|
|
138
|
+
* starts on first use in `scope` and is removed when `scope` closes.
|
|
139
|
+
*/
|
|
140
|
+
const checkoutHostFor = Effect.fn(span("checkoutHost"))(function* (operation, scope, machine, attempt, worktree, access, isolation, harnesses) {
|
|
141
|
+
if (isolation._tag === "SharedUser") {
|
|
142
|
+
const shell = Effect.succeed(access.shell);
|
|
143
|
+
const shared = {
|
|
144
|
+
isolation,
|
|
145
|
+
shell,
|
|
146
|
+
salvageShell: shell,
|
|
147
|
+
recordOutOfMemory: () => Effect.void,
|
|
148
|
+
};
|
|
149
|
+
return shared;
|
|
150
|
+
}
|
|
151
|
+
const started = yield* SynchronizedRef.make(Option.none());
|
|
152
|
+
const spec = containerSpec(machine, isolation.settings, attempt, worktree, access, harnesses);
|
|
153
|
+
const marker = containerCheckoutMarker(machine.workerDirectory, attempt.attemptId);
|
|
154
|
+
const memory = yield* containers.trackMemory(machine.shell, spec);
|
|
155
|
+
const shell = SynchronizedRef.modifyEffect(started, (current) => Option.match(current, {
|
|
156
|
+
onSome: (shell) => Effect.succeed([shell, current]),
|
|
157
|
+
onNone: () => containers.mark(operation, machine.shell, marker).pipe(Effect.andThen(containers.start(operation, machine.shell, spec)),
|
|
158
|
+
// Added after the start's removal, so it runs before it.
|
|
159
|
+
Effect.tap(() => Effect.addFinalizer(() => memory.recordKills())), Scope.provide(scope), Effect.map((shell) => [shell, Option.some(shell)])),
|
|
160
|
+
}));
|
|
161
|
+
const contained = {
|
|
162
|
+
isolation,
|
|
163
|
+
shell,
|
|
164
|
+
salvageShell: yield* Effect.cached(Effect.tap(shell, () => memory.ensureRunning)),
|
|
165
|
+
recordOutOfMemory: memory.recordTo,
|
|
166
|
+
};
|
|
167
|
+
return contained;
|
|
168
|
+
});
|
|
169
|
+
/**
|
|
170
|
+
* Runs git on the machine with the Attempt's repository access and `author` as the author and
|
|
171
|
+
* committer, refreshing the credential first if it's about to expire.
|
|
172
|
+
*/
|
|
173
|
+
const accessGit = (operation, access, author, shell = Effect.succeed(access.shell)) => (args) => {
|
|
174
|
+
const environment = { ...access.gitEnvironment, ...commitIdentity(author) };
|
|
175
|
+
return access.refresh.pipe(Effect.andThen(shell), Effect.flatMap((on) => commands.run(operation, on, "git", args, { environment, scrub: access.scrub })));
|
|
176
|
+
};
|
|
177
|
+
const harvestCommand = (operation, worktree, access, shell) => (command, args) => access.refresh
|
|
178
|
+
.pipe(Effect.andThen(commands.run(operation, shell, command, args, {
|
|
179
|
+
cwd: worktree,
|
|
180
|
+
environment: access.environment,
|
|
181
|
+
scrub: access.scrub,
|
|
182
|
+
})))
|
|
183
|
+
.pipe(Effect.map((stdout) => (stdout === "" ? [] : stdout.replace(/\n$/u, "").split("\n"))));
|
|
184
|
+
/** Returns whether the checkout at `worktree` exists on `machine`. */
|
|
185
|
+
const checkoutExists = (machine, worktree) => Effect.gen(function* () {
|
|
186
|
+
const inspected = yield* commands.inspect("cleanup", machine.shell, "test", [
|
|
187
|
+
"-d",
|
|
188
|
+
worktree,
|
|
189
|
+
]);
|
|
190
|
+
if (inspected.exitCode === 1)
|
|
191
|
+
return false;
|
|
192
|
+
if (inspected.exitCode !== 0)
|
|
193
|
+
return yield* executorError("Can't inspect the recovery checkout", new Error(inspected.stderr));
|
|
194
|
+
return true;
|
|
195
|
+
});
|
|
196
|
+
/**
|
|
197
|
+
* Removes a container's checkout at `worktree` from the machine, then its container marker.
|
|
198
|
+
* It holds no registration in the cached clone.
|
|
199
|
+
*/
|
|
200
|
+
const removeStandalone = (operation, machine, attemptId, worktree) => Effect.asVoid(commands.run(operation, machine.shell, "sh", [
|
|
201
|
+
"-c",
|
|
202
|
+
REMOVE_CHECKOUT_SCRIPT,
|
|
203
|
+
"sh",
|
|
204
|
+
worktree,
|
|
205
|
+
containerCheckoutMarker(machine.workerDirectory, attemptId),
|
|
206
|
+
]));
|
|
207
|
+
/**
|
|
208
|
+
* Stops the children in `attempt`'s checkout at `worktree`, salvages it with a new
|
|
209
|
+
* credential, records the salvage through `record`, and removes the checkout once its work is
|
|
210
|
+
* pushed. See `recoverWorktree`.
|
|
211
|
+
*/
|
|
212
|
+
const reconcileCheckout = Effect.fn(span("reconcileCheckout"))(function* (attempt, machine, worktree, record, commitAuthor) {
|
|
213
|
+
yield* Effect.annotateCurrentSpan({ attemptId: attempt.attemptId, worker: attempt.worker });
|
|
214
|
+
const isolation = yield* isolationOfCheckout("cleanup", machine, attempt.attemptId, worktree, yield* worker.isolation(machine));
|
|
215
|
+
const reconcile = (git, removeCheckout) => recoverWorktree({ attempt, host: machine.shell.destination, worktree, git, removeCheckout }, record);
|
|
216
|
+
const removeCheckout = (git) => removing(attempt.attemptId, isolation._tag === "Container"
|
|
217
|
+
? removeStandalone("cleanup", machine, attempt.attemptId, worktree)
|
|
218
|
+
: Effect.asVoid(git([
|
|
219
|
+
"--git-dir",
|
|
220
|
+
cachePath(machine, attempt.repository),
|
|
221
|
+
"worktree",
|
|
222
|
+
"remove",
|
|
223
|
+
"--force",
|
|
224
|
+
worktree,
|
|
225
|
+
])));
|
|
226
|
+
if (attempt.succeeded || attempt.permissions === "read") {
|
|
227
|
+
yield* stopChildren("cleanup", machine, worktree, attempt.attemptId, isolation);
|
|
228
|
+
const git = (args) => commands.run("cleanup", machine.shell, "git", args);
|
|
229
|
+
yield* reconcile(git, removeCheckout(git));
|
|
230
|
+
if (isolation._tag === "Container")
|
|
231
|
+
yield* containers.remove(machine.shell, attemptContainerName(attempt.attemptId));
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
const author = yield* commitAuthor;
|
|
235
|
+
const grant = yield* worker.grantFor(attempt.repository);
|
|
236
|
+
yield* Effect.scoped(Effect.gen(function* () {
|
|
237
|
+
const access = yield* grant.acquire(attempt.attemptId, attempt.worker, attempt.permissions, machine, "cleanup");
|
|
238
|
+
yield* stopChildren("cleanup", machine, worktree, attempt.attemptId, isolation);
|
|
239
|
+
const checkout = yield* checkoutHostFor("cleanup", yield* Effect.scope, machine, attempt, worktree, access, isolation, []);
|
|
240
|
+
const git = accessGit("cleanup", access, author, checkout.shell);
|
|
241
|
+
yield* reconcile(git, removeCheckout(git));
|
|
242
|
+
}));
|
|
243
|
+
});
|
|
244
|
+
const recover = Effect.fn(span("recover"))(function* (attempt, record, commitAuthor) {
|
|
245
|
+
yield* Effect.annotateCurrentSpan(recoveryFields(attempt));
|
|
246
|
+
yield* session.stopForRecovery(attempt);
|
|
247
|
+
const located = yield* leftoversOf(attempt);
|
|
248
|
+
if (Option.isNone(located)) {
|
|
249
|
+
yield* Effect.logInfo("The Attempt's machine is gone; nothing is left to reconcile", {
|
|
250
|
+
attemptId: attempt.attemptId,
|
|
251
|
+
worker: attempt.worker,
|
|
252
|
+
});
|
|
253
|
+
yield* session.recoverPostedComments(attempt, Option.none(), record);
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
const { machine, checkouts } = located.value;
|
|
257
|
+
const worktree = `${machine.workerDirectory}/attempts/${safeSegment(attempt.attemptId)}`;
|
|
258
|
+
yield* Effect.addFinalizer((exit) => recovered(attempt, Exit.isSuccess(exit)));
|
|
259
|
+
// Checks the cached listing first to avoid an SSH round trip per persisted Attempt.
|
|
260
|
+
const present = checkouts.has(worktree) && (yield* checkoutExists(machine, worktree));
|
|
261
|
+
yield* checkoutHeld(attempt.attemptId, present);
|
|
262
|
+
yield* session.recoverPostedComments(attempt, present
|
|
263
|
+
? Option.some((spec, windows) => Effect.scoped(Effect.gen(function* () {
|
|
264
|
+
const grant = yield* worker.grantFor(attempt.repository);
|
|
265
|
+
const access = yield* grant.acquire(attempt.attemptId, attempt.worker, attempt.permissions, machine, "cleanup");
|
|
266
|
+
const checkout = yield* checkoutHostFor("cleanup", yield* Effect.scope, machine, attempt, worktree, access, yield* isolationOfCheckout("cleanup", machine, attempt.attemptId, worktree, yield* worker.isolation(machine)), []);
|
|
267
|
+
return yield* harvestPostedComments(spec, harvestCommand("cleanup", worktree, access, yield* checkout.shell), windows);
|
|
268
|
+
})))
|
|
269
|
+
: Option.none(), record);
|
|
270
|
+
if (!present)
|
|
271
|
+
return;
|
|
272
|
+
yield* reconcileCheckout(attempt, machine, worktree, record.salvage, commitAuthor);
|
|
273
|
+
}, Effect.scoped);
|
|
274
|
+
/**
|
|
275
|
+
* Reconciles the checkout at `worktree` on `machine` that the launch of `request` kept while
|
|
276
|
+
* its parent task's stop was unconfirmed. Does nothing if the checkout is gone.
|
|
277
|
+
*/
|
|
278
|
+
const reconcileKept = Effect.fn(span("reconcileKept"))(function* (request, machine, worktree, record) {
|
|
279
|
+
const fields = { attemptId: request.attemptId, worker: request.worker, worktree };
|
|
280
|
+
yield* Effect.annotateCurrentSpan(fields);
|
|
281
|
+
if (!(yield* checkoutExists(machine, worktree))) {
|
|
282
|
+
yield* Effect.logInfo("The kept checkout is gone; nothing to reconcile", fields);
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
yield* reconcileCheckout(keptCheckoutRecovery(request), machine, worktree, record, Effect.succeed(request.commitAuthor));
|
|
286
|
+
});
|
|
287
|
+
const harvest = (workspace, access, shell, windows) => harvestFacts(workspace.spec, harvestCommand("launch", workspace.worktree, access, shell), windows).pipe(Effect.mapError((error) => new InfraFailure({
|
|
288
|
+
message: `Can't harvest the attempt's checkout: ${error.message}`,
|
|
289
|
+
cause: error,
|
|
290
|
+
})));
|
|
291
|
+
/**
|
|
292
|
+
* Checks that a reattached Attempt's parent task was created for this worktree, the worktree
|
|
293
|
+
* still exists, and `isolation` can run commands in it, then stops children left from before
|
|
294
|
+
* the restart. Returns the parent's RunSpec.
|
|
295
|
+
*/
|
|
296
|
+
const takeOver = Effect.fn(span("takeOver"))(function* (request, machine, worktree, isolation) {
|
|
297
|
+
const { cwd, spec } = yield* session.storedRequest(request.attemptId);
|
|
298
|
+
if (cwd !== worktree)
|
|
299
|
+
return yield* executorError(`The reattached attempt's checkout isn't on the machine of this ${label} worker`, new Error(cwd));
|
|
300
|
+
const inspected = yield* commands.inspect("prepare", machine.shell, "test", ["-d", worktree]);
|
|
301
|
+
if (inspected.exitCode === 1)
|
|
302
|
+
return yield* executorError("The reattached attempt's checkout no longer exists", new Error(worktree));
|
|
303
|
+
if (inspected.exitCode !== 0)
|
|
304
|
+
return yield* executorError("Can't inspect the reattached attempt's checkout", new Error(inspected.stderr.trim()));
|
|
305
|
+
yield* isolationOfCheckout("prepare", machine, request.attemptId, worktree, isolation);
|
|
306
|
+
yield* stopChildren("prepare", machine, worktree, request.attemptId, isolation);
|
|
307
|
+
return spec;
|
|
308
|
+
});
|
|
309
|
+
/**
|
|
310
|
+
* Returns the checkout operations of an Attempt in its own container: a standalone repository
|
|
311
|
+
* that borrows the cached clone's objects, with every git command run in the container.
|
|
312
|
+
*/
|
|
313
|
+
const containerCheckout = (request, machine, access, worktree, cache, url, checkout) => {
|
|
314
|
+
const inContainer = (operation, command, args) => access.refresh.pipe(
|
|
315
|
+
// The only cleanup command in the checkout is the salvage's git.
|
|
316
|
+
Effect.andThen(operation === "cleanup" ? checkout.salvageShell : checkout.shell), Effect.flatMap((shell) => commands.run(operation, shell, command, args, {
|
|
317
|
+
environment: { ...access.gitEnvironment, ...commitIdentity(request.commitAuthor) },
|
|
318
|
+
scrub: access.scrub,
|
|
319
|
+
})));
|
|
320
|
+
return {
|
|
321
|
+
add: (commit) => commands
|
|
322
|
+
.run("prepare", machine.shell, "mkdir", ["-p", worktree])
|
|
323
|
+
.pipe(Effect.andThen(inContainer("prepare", "sh", [
|
|
324
|
+
"-c",
|
|
325
|
+
STANDALONE_CHECKOUT_SCRIPT,
|
|
326
|
+
"sh",
|
|
327
|
+
worktree,
|
|
328
|
+
cache,
|
|
329
|
+
url,
|
|
330
|
+
commit,
|
|
331
|
+
])), Effect.asVoid),
|
|
332
|
+
// The container mounts the directory itself, so only its contents go.
|
|
333
|
+
discard: Effect.asVoid(commands.run("prepare", machine.shell, "sh", [
|
|
334
|
+
"-c",
|
|
335
|
+
EMPTY_DIRECTORY_SCRIPT,
|
|
336
|
+
"sh",
|
|
337
|
+
worktree,
|
|
338
|
+
])),
|
|
339
|
+
git: (operation, args) => inContainer(operation, "git", args),
|
|
340
|
+
writeExecutable: (target, content) => Effect.asVoid(inContainer("prepare", "sh", ["-c", WRITE_EXECUTABLE_SCRIPT, "sh", target, content])),
|
|
341
|
+
remove: (cleanup) => cleanup("worktree-directory", removing(request.attemptId, removeStandalone("cleanup", machine, request.attemptId, worktree))),
|
|
342
|
+
};
|
|
343
|
+
};
|
|
344
|
+
/** Returns the `WorkspaceOps` for the machine; git runs with the Attempt's repository access. */
|
|
345
|
+
const workspaceOps = (request, machine, access, layout, checkout) => {
|
|
346
|
+
const host = {
|
|
347
|
+
removePath: (operation, target) => Effect.asVoid(commands.run(operation, machine.shell, "rm", ["-rf", target])),
|
|
348
|
+
cacheExists: Effect.gen(function* () {
|
|
349
|
+
const inspected = yield* commands.inspect("prepare", machine.shell, "test", [
|
|
350
|
+
"-d",
|
|
351
|
+
layout.cache,
|
|
352
|
+
]);
|
|
353
|
+
if (inspected.exitCode === 0)
|
|
354
|
+
return true;
|
|
355
|
+
if (inspected.exitCode === 1)
|
|
356
|
+
return false;
|
|
357
|
+
return yield* executorError(`Can't inspect the cached clone on worker "${request.worker}"`, new Error(inspected.stderr.trim()));
|
|
358
|
+
}),
|
|
359
|
+
git: (operation, args) => accessGit(operation, access, request.commitAuthor)(args),
|
|
360
|
+
};
|
|
361
|
+
return {
|
|
362
|
+
...host,
|
|
363
|
+
ensureRoots: Effect.asVoid(commands.run("prepare", machine.shell, "mkdir", [
|
|
364
|
+
"-p",
|
|
365
|
+
`${machine.workerDirectory}/repos`,
|
|
366
|
+
`${machine.workerDirectory}/attempts`,
|
|
367
|
+
])),
|
|
368
|
+
promoteStaging: Effect.asVoid(commands.run("prepare", machine.shell, "mv", [layout.staging, layout.cache])),
|
|
369
|
+
checkout: checkout.isolation._tag === "Container"
|
|
370
|
+
? containerCheckout(request, machine, access, layout.worktree, layout.cache, worker.repositoryUrl(machine, request.repository), checkout)
|
|
371
|
+
: linkedCheckout(request.attemptId, linkedWorktree(host, layout, (target, content) => Effect.asVoid(commands.run("prepare", machine.shell, "sh", [
|
|
372
|
+
"-c",
|
|
373
|
+
WRITE_EXECUTABLE_SCRIPT,
|
|
374
|
+
"sh",
|
|
375
|
+
target,
|
|
376
|
+
content,
|
|
377
|
+
])))),
|
|
378
|
+
};
|
|
379
|
+
};
|
|
380
|
+
/** Returns `ops` whose removal records the checkout as gone once its directory is removed. */
|
|
381
|
+
const linkedCheckout = (attemptId, ops) => ({
|
|
382
|
+
...ops,
|
|
383
|
+
remove: (cleanup) => ops.remove((resource, effect) => cleanup(resource, resource === "worktree-directory" ? removing(attemptId, effect) : effect)),
|
|
384
|
+
});
|
|
385
|
+
const prepare = Effect.fn(span("prepare"))(function* (request) {
|
|
386
|
+
yield* Effect.annotateCurrentSpan({
|
|
387
|
+
attemptId: request.attemptId,
|
|
388
|
+
worker: request.worker,
|
|
389
|
+
repository: request.repository,
|
|
390
|
+
loop: request.loop,
|
|
391
|
+
permissions: request.permissions,
|
|
392
|
+
reattach: request.reattach,
|
|
393
|
+
});
|
|
394
|
+
if (request.permissions === "read" && Option.isSome(worker.readOnlyAccessGap)) {
|
|
395
|
+
const message = `${label} worker "${request.worker}" can't run loop "${request.loop}", which has permissions: read. ${worker.readOnlyAccessGap.value}.`;
|
|
396
|
+
yield* Effect.logWarning("Refused an Attempt that needs read-only repository access", {
|
|
397
|
+
attemptId: request.attemptId,
|
|
398
|
+
worker: request.worker,
|
|
399
|
+
loop: request.loop,
|
|
400
|
+
permissions: request.permissions,
|
|
401
|
+
message,
|
|
402
|
+
});
|
|
403
|
+
return yield* new WorkerCapabilityError({
|
|
404
|
+
worker: request.worker,
|
|
405
|
+
capability: "credentials",
|
|
406
|
+
message,
|
|
407
|
+
cause: new Error(worker.readOnlyAccessGap.value),
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
const grant = yield* worker.grantFor(request.repository);
|
|
411
|
+
const machine = yield* attemptMachine(request.worker, request.attemptId);
|
|
412
|
+
const isolation = yield* worker.isolation(machine);
|
|
413
|
+
const probeBrain = (shell) => verifyHarnessReadiness(request.worker, machine.provisioned, [request.agent.brain], worker.harnessProbe(machine, shell), logins);
|
|
414
|
+
// An Attempt container doesn't exist yet, so its probe runs once the checkout is prepared.
|
|
415
|
+
if (isolation._tag === "SharedUser")
|
|
416
|
+
yield* probeBrain(machine.shell);
|
|
417
|
+
const host = machine.shell.destination;
|
|
418
|
+
const cache = cachePath(machine, request.repository);
|
|
419
|
+
const worktree = `${machine.workerDirectory}/attempts/${safeSegment(request.attemptId)}`;
|
|
420
|
+
const staging = `${cache}.cloning`;
|
|
421
|
+
yield* Effect.annotateCurrentSpan({ host, isolation: isolation._tag });
|
|
422
|
+
yield* Effect.logInfo(request.reattach
|
|
423
|
+
? `Reattaching the Attempt to its ${label} checkout`
|
|
424
|
+
: `Preparing ${label} Attempt workspace`, {
|
|
425
|
+
attemptId: request.attemptId,
|
|
426
|
+
worker: request.worker,
|
|
427
|
+
host,
|
|
428
|
+
repository: request.repository,
|
|
429
|
+
loop: request.loop,
|
|
430
|
+
permissions: request.permissions,
|
|
431
|
+
isolation: isolation._tag,
|
|
432
|
+
worktree,
|
|
433
|
+
});
|
|
434
|
+
yield* sweepAbandonedWorktrees(request.attemptId, request.worker, machine.shell, machine.workerDirectory);
|
|
435
|
+
// A reattachment reuses its checkout before any credential is granted.
|
|
436
|
+
const reattached = request.reattach
|
|
437
|
+
? Option.some(yield* takeOver(request, machine, worktree, isolation))
|
|
438
|
+
: Option.none();
|
|
439
|
+
const harness = Option.match(reattached, {
|
|
440
|
+
onNone: () => request.agent.brain.harness,
|
|
441
|
+
onSome: (spec) => spec.agent.brain.harness,
|
|
442
|
+
});
|
|
443
|
+
// A checkout kept after a failed remote stop never closes its scope, so its salvage result
|
|
444
|
+
// is completed here instead of by the checkout finalizer.
|
|
445
|
+
const salvaged = yield* Deferred.make();
|
|
446
|
+
const releaseWorkspace = Effect.fn(span("releaseWorkspace"))(function* (resource, exit) {
|
|
447
|
+
yield* Effect.annotateCurrentSpan({
|
|
448
|
+
attemptId: request.attemptId,
|
|
449
|
+
worker: request.worker,
|
|
450
|
+
host,
|
|
451
|
+
});
|
|
452
|
+
// Closes the checkout scope only if stopping the remote children succeeds.
|
|
453
|
+
yield* stopChildren("cleanup", machine, resource.provisioned.workspace.worktree, request.attemptId, isolation);
|
|
454
|
+
yield* Scope.close(resource.scope, exit);
|
|
455
|
+
const salvage = yield* Effect.exit(resource.provisioned.salvaged);
|
|
456
|
+
yield* Deferred.done(salvaged, salvage);
|
|
457
|
+
}, (effect) => effect.pipe(Effect.tapError((error) => Effect.logError("Remote termination failed; Attempt checkout retained for recovery", {
|
|
458
|
+
attemptId: request.attemptId,
|
|
459
|
+
worker: request.worker,
|
|
460
|
+
host,
|
|
461
|
+
worktree,
|
|
462
|
+
message: error.message,
|
|
463
|
+
})), Effect.ignore, Effect.andThen(Deferred.succeed(salvaged, Option.none()))));
|
|
464
|
+
const prepareScope = yield* Effect.scope;
|
|
465
|
+
const acquire = Effect.gen(function* () {
|
|
466
|
+
// Credentials are scoped to the Attempt, not the checkout, so they are released exactly once
|
|
467
|
+
// even when checkout cleanup is skipped.
|
|
468
|
+
const access = yield* grant.acquire(request.attemptId, request.worker, request.permissions, machine, "prepare");
|
|
469
|
+
// Forked before the checkout's release is registered, so the container is removed after
|
|
470
|
+
// the release salvages the checkout in it.
|
|
471
|
+
const containerScope = yield* Scope.fork(prepareScope);
|
|
472
|
+
const checkoutHost = yield* checkoutHostFor("prepare", containerScope, machine, request, worktree, access, isolation, [harness]);
|
|
473
|
+
const ops = workspaceOps(request, machine, access, { cache, staging, worktree }, checkoutHost);
|
|
474
|
+
const checkout = Option.match(reattached, {
|
|
475
|
+
onNone: () => provisionWorktree({
|
|
476
|
+
request,
|
|
477
|
+
url: worker.repositoryUrl(machine, request.repository),
|
|
478
|
+
host,
|
|
479
|
+
layout: { cache, staging, worktree },
|
|
480
|
+
ops,
|
|
481
|
+
}),
|
|
482
|
+
onSome: (spec) => reattachWorktree({ request, host, layout: { worktree }, ops, spec }),
|
|
483
|
+
});
|
|
484
|
+
const { provisioned } = yield* Effect.acquireRelease(Effect.uninterruptibleMask((restore) => Effect.gen(function* () {
|
|
485
|
+
const scope = yield* Scope.make();
|
|
486
|
+
// No child can exist before preparation succeeds, so a partial checkout is always rolled
|
|
487
|
+
// back; only a completed workspace uses the guarded release above.
|
|
488
|
+
const provisioned = yield* restore(checkout).pipe(Scope.provide(scope), Effect.onError((cause) => Scope.close(scope, Exit.failCause(cause))));
|
|
489
|
+
return { provisioned, scope };
|
|
490
|
+
})), releaseWorkspace, { interruptible: true });
|
|
491
|
+
return { provisioned, access, checkoutHost };
|
|
492
|
+
});
|
|
493
|
+
const { provisioned, access, checkoutHost } = yield* (request.reattach ? acquire : fetches.withLock(request.repository)(acquire)).pipe(Effect.mapError((cause) => isExecutorError(cause)
|
|
494
|
+
? cause
|
|
495
|
+
: executorError(`Can't prepare the ${label} attempt workspace`, cause)));
|
|
496
|
+
yield* checkoutHeld(request.attemptId, true);
|
|
497
|
+
if (isolation._tag === "Container")
|
|
498
|
+
yield* probeBrain(yield* checkoutHost.shell);
|
|
499
|
+
const prepared = provisioned.workspace;
|
|
500
|
+
yield* Effect.logInfo(`${label} Attempt workspace ready`, {
|
|
501
|
+
attemptId: request.attemptId,
|
|
502
|
+
worker: request.worker,
|
|
503
|
+
host,
|
|
504
|
+
repository: request.repository,
|
|
505
|
+
baseCommit: prepared.spec.baseCommit,
|
|
506
|
+
resume: Option.map(prepared.spec.resume, ({ ref }) => ref),
|
|
507
|
+
reattach: request.reattach,
|
|
508
|
+
isolation: isolation._tag,
|
|
509
|
+
worktree,
|
|
510
|
+
});
|
|
511
|
+
return {
|
|
512
|
+
workspace: prepared,
|
|
513
|
+
launch: (io) => Effect.scoped(Effect.gen(function* () {
|
|
514
|
+
// Uses the RunSpec's brain, including on reattachment. Each child reads the kind when it
|
|
515
|
+
// starts, so a preflight during the Attempt takes effect.
|
|
516
|
+
const gatewayCredential = worker.gatewayCredential(machine, prepared.spec.agent.brain.harness);
|
|
517
|
+
yield* checkoutHost.recordOutOfMemory(io.outOfMemory);
|
|
518
|
+
const shell = yield* checkoutHost.shell.pipe(Effect.mapError((error) => new InfraFailure({
|
|
519
|
+
message: `Can't start the attempt's container: ${error.message}`,
|
|
520
|
+
cause: error,
|
|
521
|
+
})));
|
|
522
|
+
yield* workerWatches.watch({
|
|
523
|
+
attemptId: request.attemptId,
|
|
524
|
+
worker: request.worker,
|
|
525
|
+
shell: machine.shell,
|
|
526
|
+
report: (notice) => runtime.notify(request.attemptId, notice),
|
|
527
|
+
});
|
|
528
|
+
return yield* session.launch(prepared, io, {
|
|
529
|
+
host: shell,
|
|
530
|
+
machine: machine.provisioned,
|
|
531
|
+
environment: childEnvironment(access.environment, request.commitAuthor, provisioned.gitHooks),
|
|
532
|
+
gatewayCredential,
|
|
533
|
+
harvest: (windows) => harvest(prepared, access, shell, windows),
|
|
534
|
+
harvestComments: (windows) => harvestPostedComments(prepared.spec, harvestCommand("launch", prepared.worktree, access, shell), windows),
|
|
535
|
+
keepForReattach: provisioned.keepForReattach,
|
|
536
|
+
keepUntilStopped: provisioned.keepUntilStopped,
|
|
537
|
+
reconcileKept: (record) => reconcileKept(request, machine, worktree, record),
|
|
538
|
+
});
|
|
539
|
+
})),
|
|
540
|
+
salvaged: Deferred.await(salvaged),
|
|
541
|
+
recordSalvage: provisioned.recordSalvage,
|
|
542
|
+
};
|
|
543
|
+
}, session.prepare);
|
|
544
|
+
return Executor.of({
|
|
545
|
+
kind: worker.kind,
|
|
546
|
+
recover,
|
|
547
|
+
cancel: session.cancel,
|
|
548
|
+
intervene: session.intervene,
|
|
549
|
+
isLive: session.isLive,
|
|
550
|
+
outcome: session.outcome,
|
|
551
|
+
preflight: worker.preflight,
|
|
552
|
+
prepare,
|
|
553
|
+
sweep: worker.sweep ?? Effect.void,
|
|
554
|
+
});
|
|
555
|
+
});
|
|
556
|
+
//# sourceMappingURL=remote.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote.js","sourceRoot":"","sources":["../../src/remote/remote.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAoB,MAAM,0BAA0B,CAAC;AAC/E,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAGxD,OAAO,EAAuB,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAGhF,OAAO,EAAkB,cAAc,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErF,OAAO,EAEL,YAAY,EACZ,qBAAqB,GACtB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AACxF,OAAO,EAAE,iBAAiB,EAA8B,MAAM,uBAAuB,CAAC;AACtF,OAAO,EAEL,eAAe,EACf,QAAQ,EACR,aAAa,EAEb,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC3E,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EACL,kBAAkB,EAElB,oBAAoB,EACpB,cAAc,EAEd,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,cAAc,GAEf,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAEL,oBAAoB,EACpB,u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AO,EAAE,QAAQ,EAAE,MAAM,CAAC;iBAC7E,CAAC,CAAC;YACL,CAAC,CAAC,CACH;YACH,QAAQ,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC;YAClC,aAAa,EAAE,WAAW,CAAC,aAAa;SACzC,CAAC;IACJ,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IAEpB,OAAO,QAAQ,CAAC,EAAE,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,OAAO;QACP,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,OAAO;QACP,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,IAAI;KACnC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { RemoteShell } from "@usine/agents/child-host";
|
|
2
|
+
import { Effect } from "effect";
|
|
3
|
+
import { type ExecutorOperation, ExecutorOperationError } from "../executor.ts";
|
|
4
|
+
import type { RemoteCommands } from "./commands.ts";
|
|
5
|
+
/** Returns the NUL-separated paths in `output`. Fails if one isn't directly under `parent`. */
|
|
6
|
+
export declare const directChildren: (operation: ExecutorOperation, parent: string, output: string) => Effect.Effect<ReadonlyArray<string>, ExecutorOperationError>;
|
|
7
|
+
/**
|
|
8
|
+
* Lists paths directly under a Worker's `attempts` directory, creating it first so a new Worker
|
|
9
|
+
* lists as empty. Verifies that each path is a direct child of `attemptsRoot`.
|
|
10
|
+
*/
|
|
11
|
+
export declare const attemptPathsOn: (commands: RemoteCommands, operation: "cancel" | "cleanup" | "launch" | "preflight" | "prepare", shell: RemoteShell, attemptsRoot: string) => Effect.Effect<readonly string[], ExecutorOperationError, never>;
|
|
12
|
+
/**
|
|
13
|
+
* Returns a sweep that prunes stale cache registrations once per Worker and keeps crash
|
|
14
|
+
* leftovers. Only durable Attempt recovery removes an existing checkout.
|
|
15
|
+
*/
|
|
16
|
+
export declare const abandonedWorktreeSweepFor: (commands: RemoteCommands) => Effect.Effect<(attemptId: string & import("effect/Brand").Brand<"AttemptId">, worker: string & import("effect/Brand").Brand<"WorkerName">, shell: RemoteShell, workerDirectory: string) => Effect.Effect<void, never, never>, never, never>;
|
|
17
|
+
//# sourceMappingURL=sweep.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sweep.d.ts","sourceRoot":"","sources":["../../src/remote/sweep.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAG5D,OAAO,EAAE,MAAM,EAAe,MAAM,QAAQ,CAAC;AAC7C,OAAO,EAAE,KAAK,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAEhF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAuBpD,+FAA+F;AAC/F,eAAO,MAAM,cAAc,cACd,iBAAiB,UACpB,MAAM,UACN,MAAM,KACb,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,sBAAsB,CAY3D,CAAC;AAEJ;;;GAGG;AACH,eAAO,MAAM,cAAc,+MAiBzB,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,yBAAyB,2QA0GrC,CAAC"}
|