@usine/executor 0.2.1 → 0.3.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/README.md +115 -37
- package/dist/child-command.d.ts +4 -7
- package/dist/child-command.d.ts.map +1 -1
- package/dist/child-command.js +6 -12
- package/dist/child-command.js.map +1 -1
- package/dist/claude-login-lock.d.ts +8 -0
- package/dist/claude-login-lock.d.ts.map +1 -0
- package/dist/claude-login-lock.js +9 -0
- package/dist/claude-login-lock.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 +63 -0
- package/dist/durable-session.d.ts.map +1 -0
- package/dist/durable-session.js +491 -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 +53 -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 +23 -33
- package/dist/exe-dev/preflight.js.map +1 -1
- package/dist/executor.d.ts +140 -41
- package/dist/executor.d.ts.map +1 -1
- package/dist/executor.js +90 -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 +273 -59
- package/dist/guard.js.map +1 -1
- package/dist/harness-preflight.d.ts +25 -4
- package/dist/harness-preflight.d.ts.map +1 -1
- package/dist/harness-preflight.js +25 -29
- 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 +16 -10
- package/dist/local/local.d.ts.map +1 -1
- package/dist/local/local.js +163 -129
- package/dist/local/local.js.map +1 -1
- package/dist/memory-preflight.d.ts +25 -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 +33 -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 +77 -14
- package/dist/provision.d.ts.map +1 -1
- package/dist/provision.js +357 -55
- 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/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 +194 -0
- package/dist/remote/liveness.js.map +1 -0
- package/dist/remote/machine.d.ts +64 -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 +24 -0
- package/dist/remote/remote.d.ts.map +1 -0
- package/dist/remote/remote.js +308 -0
- package/dist/remote/remote.js.map +1 -0
- package/dist/remote/sweep.d.ts +15 -0
- package/dist/remote/sweep.d.ts.map +1 -0
- package/dist/remote/sweep.js +116 -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 +30 -0
- package/dist/salvage.d.ts.map +1 -0
- package/dist/salvage.js +104 -0
- package/dist/salvage.js.map +1 -0
- package/dist/ssh/credentials.d.ts +40 -0
- package/dist/ssh/credentials.d.ts.map +1 -0
- package/dist/ssh/credentials.js +83 -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 +22 -0
- package/dist/ssh/gateway/attachments.d.ts.map +1 -0
- package/dist/ssh/gateway/attachments.js +154 -0
- package/dist/ssh/gateway/attachments.js.map +1 -0
- package/dist/ssh/gateway/environment.d.ts +52 -0
- package/dist/ssh/gateway/environment.d.ts.map +1 -0
- package/dist/ssh/gateway/environment.js +78 -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 +28 -0
- package/dist/ssh/gateway/preflight.d.ts.map +1 -0
- package/dist/ssh/gateway/preflight.js +234 -0
- package/dist/ssh/gateway/preflight.js.map +1 -0
- package/dist/ssh/model.d.ts +65 -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 +16 -0
- package/dist/ssh/preflight.d.ts.map +1 -0
- package/dist/ssh/preflight.js +47 -0
- package/dist/ssh/preflight.js.map +1 -0
- package/dist/ssh/ssh.d.ts +20 -0
- package/dist/ssh/ssh.d.ts.map +1 -0
- package/dist/ssh/ssh.js +78 -0
- package/dist/ssh/ssh.js.map +1 -0
- package/dist/ssh/workers.d.ts +53 -0
- package/dist/ssh/workers.d.ts.map +1 -0
- package/dist/ssh/workers.js +173 -0
- package/dist/ssh/workers.js.map +1 -0
- package/package.json +12 -4
- 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 @@
|
|
|
1
|
+
{"version":3,"file":"pre-push-hook.js","sourceRoot":"","sources":["../src/pre-push-hook.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC;;;GAGG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,aAAa,CAAC;AAEtD,MAAM,KAAK,GAAG,CAAC,KAAa,EAAU,EAAE,CAAC,IAAI,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC;AAE/E,+FAA+F;AAC/F,MAAM,WAAW,GAAG,CAAC,IAAc,EAAU,EAAE,CAC7C,qCAAqC,IAAI,wEAAwE,CAAC;AAEpH;;;;GAIG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,IAAc,EAAU,EAAE,CACpD,mBAAmB,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,gBAAgB,CAAC;AAE9D;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,WAA6C,EAC7C,KAA4B,EACJ,EAAE,CAC1B,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE;IAClB,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,GAAG,WAAW,EAAE,CAAC;IAClC,MAAM,EAAE,CAAC,SAAS,EAAE,EAAE;QACpB,MAAM,KAAK,GAAG,MAAM,CAAC,WAAW,CAAC,gBAAgB,IAAI,GAAG,CAAC,CAAC;QAC1D,OAAO;YACL,GAAG,WAAW;YACd,gBAAgB,EAAE,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC;YACnC,CAAC,kBAAkB,KAAK,EAAE,CAAC,EAAE,gBAAgB;YAC7C,CAAC,oBAAoB,KAAK,EAAE,CAAC,EAAE,SAAS;SACzC,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -1,5 +1,35 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { AttemptId } from "@usine/core/attempt";
|
|
2
|
+
import * as AttemptChannel from "@usine/core/attempt/channel";
|
|
3
|
+
import { type AttemptFailure, InfraFailure, type RunawayCeiling } from "@usine/core/attempt/failure";
|
|
4
|
+
import { type Duration, Effect, Scope } from "effect";
|
|
2
5
|
import type { CheckoutRequest, ExecutorError, PreparedAttempt } from "./executor.ts";
|
|
3
|
-
|
|
4
|
-
|
|
6
|
+
import { type AttemptGuardSeed } from "./guard.ts";
|
|
7
|
+
import type { ProvisionedWorktree } from "./provision.ts";
|
|
8
|
+
export type AttemptStop = {
|
|
9
|
+
readonly _tag: "Cancel";
|
|
10
|
+
} | {
|
|
11
|
+
readonly _tag: "Runaway";
|
|
12
|
+
readonly ceiling: RunawayCeiling;
|
|
13
|
+
};
|
|
14
|
+
/** The result of an executor's `acquire`: the prepared Attempt and its salvage handles. */
|
|
15
|
+
export interface AcquiredAttempt extends PreparedAttempt {
|
|
16
|
+
readonly salvaged: ProvisionedWorktree["salvaged"];
|
|
17
|
+
readonly recordSalvage: ProvisionedWorktree["recordSalvage"];
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Returns `prepare` and `cancel` for one executor's Attempts, tracked from preparation until
|
|
21
|
+
* release so `cancel` works at any stage. `cancel`, a failed `prepare`, and `launch` each return
|
|
22
|
+
* only after the Attempt's resources are released.
|
|
23
|
+
*
|
|
24
|
+
* - `stop`: stops the live session and returns whether one existed.
|
|
25
|
+
* - `registered`: completes when the launch registers the live session.
|
|
26
|
+
* - `warnParent`: sends the guard's warning steer; can wait for the parent's channel.
|
|
27
|
+
* - `guardSeed`: returns the guard's initial state. If it fails, the launch records salvage,
|
|
28
|
+
* releases the resources, and fails.
|
|
29
|
+
* - `recordUnsupervised`: persists the guard's unsupervised time for a later reattachment.
|
|
30
|
+
*/
|
|
31
|
+
export declare const preparedAttemptsFor: (stop: (attemptId: AttemptId, reason: AttemptStop) => Effect.Effect<boolean, ExecutorError>, warnParent: (attemptId: AttemptId, intervention: AttemptChannel.Intervention) => Effect.Effect<void, AttemptFailure>, registered: (attemptId: AttemptId) => Effect.Effect<void>, guardSeed: (request: CheckoutRequest, io: AttemptChannel.Sink) => Effect.Effect<AttemptGuardSeed, InfraFailure>, recordUnsupervised: (attemptId: AttemptId, unsupervised: Duration.Duration) => Effect.Effect<void, AttemptFailure>) => Effect.Effect<{
|
|
32
|
+
prepare: (acquire: Effect.Effect<AcquiredAttempt, ExecutorError, Scope.Scope>, request: CheckoutRequest) => Effect.Effect<PreparedAttempt, ExecutorError, Scope.Scope>;
|
|
33
|
+
cancel: (attemptId: string & import("effect/Brand").Brand<"AttemptId">) => Effect.Effect<void, import("./executor.ts").CredentialUnavailableError | import("./executor.ts").ExecutorOperationError | import("./executor.ts").WorkerCapabilityError, never>;
|
|
34
|
+
}, never, never>;
|
|
5
35
|
//# sourceMappingURL=prepared-attempt.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepared-attempt.d.ts","sourceRoot":"","sources":["../src/prepared-attempt.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"prepared-attempt.d.ts","sourceRoot":"","sources":["../src/prepared-attempt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,cAAc,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EACL,KAAK,cAAc,EACnB,YAAY,EACZ,KAAK,cAAc,EACpB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAmB,KAAK,QAAQ,EAAE,MAAM,EAAoB,KAAK,EAAE,MAAM,QAAQ,CAAC;AACzF,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrF,OAAO,EAAgB,KAAK,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACjE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAE1D,MAAM,MAAM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{
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
|
|
1
|
+
import * as AttemptChannel from "@usine/core/attempt/channel";
|
|
2
|
+
import { InfraFailure, } from "@usine/core/attempt/failure";
|
|
3
|
+
import { Cause, Deferred, Effect, Exit, Fiber, Ref, Scope } from "effect";
|
|
4
|
+
import { attemptGuard } from "./guard.js";
|
|
5
|
+
/**
|
|
6
|
+
* Returns `prepare` and `cancel` for one executor's Attempts, tracked from preparation until
|
|
7
|
+
* release so `cancel` works at any stage. `cancel`, a failed `prepare`, and `launch` each return
|
|
8
|
+
* only after the Attempt's resources are released.
|
|
9
|
+
*
|
|
10
|
+
* - `stop`: stops the live session and returns whether one existed.
|
|
11
|
+
* - `registered`: completes when the launch registers the live session.
|
|
12
|
+
* - `warnParent`: sends the guard's warning steer; can wait for the parent's channel.
|
|
13
|
+
* - `guardSeed`: returns the guard's initial state. If it fails, the launch records salvage,
|
|
14
|
+
* releases the resources, and fails.
|
|
15
|
+
* - `recordUnsupervised`: persists the guard's unsupervised time for a later reattachment.
|
|
16
|
+
*/
|
|
17
|
+
export const preparedAttemptsFor = (stop, warnParent, registered, guardSeed, recordUnsupervised) => Effect.sync(() => {
|
|
18
|
+
const attempts = new Map();
|
|
19
|
+
const cancel = Effect.fn("PreparedAttempt.cancel")(function* (attemptId) {
|
|
20
|
+
yield* Effect.annotateCurrentSpan({ attemptId });
|
|
21
|
+
const active = attempts.get(attemptId);
|
|
22
|
+
if (active === undefined) {
|
|
23
|
+
yield* Effect.logDebug("Attempt cancellation was a no-op", { attemptId });
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
yield* Ref.set(active.unavailable, true);
|
|
27
|
+
// With a live session, stops it so its terminal envelope and typed errors are kept. Before
|
|
28
|
+
// registration, closing the scope interrupts preparation or process spawn.
|
|
29
|
+
if (!(yield* stop(attemptId, { _tag: "Cancel" }))) {
|
|
30
|
+
yield* Effect.logInfo("Canceling Attempt before its channel is ready", { attemptId });
|
|
31
|
+
yield* active.release(Exit.void);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
yield* active.released;
|
|
35
|
+
}
|
|
36
|
+
}, Effect.uninterruptible);
|
|
37
|
+
/** Runs preparation and the live session in one child scope that closes when the Attempt ends. */
|
|
38
|
+
const prepare = (acquire, request) => Effect.uninterruptibleMask((restore) => Effect.gen(function* () {
|
|
39
|
+
const scope = yield* Scope.fork(yield* Effect.scope);
|
|
40
|
+
const unavailable = yield* Ref.make(false);
|
|
41
|
+
const released = yield* Deferred.make();
|
|
42
|
+
// Scope.close returns immediately when another fiber is already closing the scope, so the
|
|
43
|
+
// owner and a concurrent cancel both wait for `released`, set by the first-registered
|
|
44
|
+
// (last-run) finalizer.
|
|
45
|
+
const release = (exit) => Scope.close(scope, exit).pipe(Effect.andThen(Deferred.await(released)));
|
|
46
|
+
attempts.set(request.attemptId, {
|
|
47
|
+
unavailable,
|
|
48
|
+
release,
|
|
49
|
+
released: Deferred.await(released),
|
|
50
|
+
});
|
|
51
|
+
yield* Scope.addFinalizer(scope, Effect.suspend(() => {
|
|
52
|
+
attempts.delete(request.attemptId);
|
|
53
|
+
return Deferred.succeed(released, undefined);
|
|
54
|
+
}));
|
|
55
|
+
yield* Scope.addFinalizer(scope, Ref.set(unavailable, true));
|
|
56
|
+
// A separate child scope, so the acquiring fiber is interrupted before its resources are
|
|
57
|
+
// released.
|
|
58
|
+
const resources = yield* Scope.fork(scope);
|
|
59
|
+
const acquiring = yield* Effect.forkIn(Scope.provide(acquire, resources), scope);
|
|
60
|
+
const prepared = yield* restore(Fiber.join(acquiring)).pipe(Effect.onError((cause) => release(Exit.failCause(cause))));
|
|
61
|
+
/** Releases the Attempt's resources, then fails if its salvage couldn't be recorded. */
|
|
62
|
+
const releaseSalvaged = (exit) => release(exit).pipe(Effect.andThen(Effect.asVoid(prepared.salvaged)));
|
|
63
|
+
return {
|
|
64
|
+
workspace: prepared.workspace,
|
|
65
|
+
launch: Effect.fn("PreparedAttempt.launch")(function* (io) {
|
|
66
|
+
const attemptId = prepared.workspace.spec.attemptId;
|
|
67
|
+
yield* Effect.annotateCurrentSpan({ attemptId, worker: prepared.workspace.worker });
|
|
68
|
+
if (yield* Ref.getAndSet(unavailable, true)) {
|
|
69
|
+
yield* Effect.logWarning("Attempt was already launched or released", { attemptId });
|
|
70
|
+
return yield* new InfraFailure({
|
|
71
|
+
message: `Attempt ${attemptId} was already launched or released`,
|
|
72
|
+
cause: new Error("prepared attempt is no longer available"),
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
// If the seed can't be read, records salvage and releases the checkout without launching, so
|
|
76
|
+
// the Run's next Attempt starts from it. On interruption, such as process shutdown, the
|
|
77
|
+
// owner's scope handles the checkout.
|
|
78
|
+
const seed = yield* guardSeed(request, io).pipe(Effect.onExit((exit) => Exit.isSuccess(exit) || Cause.hasInterruptsOnly(exit.cause)
|
|
79
|
+
? Effect.void
|
|
80
|
+
: Effect.logWarning("The Attempt's runaway guard cannot start; releasing its checkout without launching it", { attemptId }).pipe(Effect.andThen(prepared.recordSalvage(io.salvage)), Effect.andThen(releaseSalvaged(exit)))));
|
|
81
|
+
const guard = yield* attemptGuard({
|
|
82
|
+
attemptId,
|
|
83
|
+
maxAttemptMinutes: request.maxAttemptMinutes,
|
|
84
|
+
maxAttemptTokens: request.maxAttemptTokens,
|
|
85
|
+
warn: (message) => warnParent(attemptId, new AttemptChannel.Intervention({
|
|
86
|
+
operator: "engine",
|
|
87
|
+
target: new AttemptChannel.ParentTarget(),
|
|
88
|
+
action: new AttemptChannel.Steer({ message }),
|
|
89
|
+
})),
|
|
90
|
+
recordUnsupervised: (unsupervised) => recordUnsupervised(attemptId, unsupervised),
|
|
91
|
+
}, io, seed);
|
|
92
|
+
// Starts the clock only after the launch registers its session. A remote launch first waits
|
|
93
|
+
// for the Worker's liveness watch, and a seed with no time left could trip before there's a
|
|
94
|
+
// session to stop.
|
|
95
|
+
const tripped = registered(attemptId).pipe(Effect.andThen(guard.tripped), Effect.tapError(({ ceiling }) => stop(attemptId, { _tag: "Runaway", ceiling }).pipe(Effect.tapError((error) => Effect.logWarning("Could not stop the runaway Attempt", {
|
|
96
|
+
attemptId,
|
|
97
|
+
ceiling,
|
|
98
|
+
errorTag: error._tag,
|
|
99
|
+
})), Effect.ignore)));
|
|
100
|
+
yield* prepared.recordSalvage(io.salvage);
|
|
101
|
+
// Closing the owner's scope interrupts the session before the checkout and credential
|
|
102
|
+
// finalizers. acquireUseRelease interrupts the forked fiber when the caller waiting on join
|
|
103
|
+
// is interrupted.
|
|
104
|
+
return yield* Effect.acquireUseRelease(Effect.forkIn(Effect.raceFirst(prepared.launch(guard.sink), tripped), scope), Fiber.join, Fiber.interrupt).pipe(Effect.onExit((exit) => releaseSalvaged(exit)));
|
|
105
|
+
}),
|
|
106
|
+
};
|
|
107
|
+
}));
|
|
108
|
+
return { prepare, cancel };
|
|
109
|
+
});
|
|
32
110
|
//# sourceMappingURL=prepared-attempt.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepared-attempt.js","sourceRoot":"","sources":["../src/prepared-attempt.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"prepared-attempt.js","sourceRoot":"","sources":["../src/prepared-attempt.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,cAAc,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAEL,YAAY,GAEb,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,QAAQ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C;IAC9B,CAAC,CAAC,CACH,CAAC;IAEJ,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;AAC7B,CAAC,CAAC,CAAC"}
|
package/dist/provision.d.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
+
import type { AttemptFailure } from "@usine/core/attempt/failure";
|
|
2
|
+
import * as AttemptChannel from "@usine/core/attempt/channel";
|
|
3
|
+
import { type AttemptRecovery, type AttemptSalvage, SalvagePushed } from "@usine/core/attempt/salvage";
|
|
1
4
|
import { RepositoryName } from "@usine/core/repository";
|
|
2
|
-
import { Effect } from "effect";
|
|
5
|
+
import { Effect, Option } from "effect";
|
|
3
6
|
import { ExecutorOperationError, AttemptWorkspace, type CheckoutRequest } from "./executor.ts";
|
|
4
|
-
|
|
5
|
-
/** The bare cache directory name for a repository under `repos/`, shared by every adapter. */
|
|
7
|
+
/** Returns the bare cache directory name for `repository` under `repos/`. */
|
|
6
8
|
export declare const cacheDirectoryName: (repository: RepositoryName) => string;
|
|
7
9
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* never reach `git worktree prune`.
|
|
10
|
+
* Returns whether a `repos/` entry is a bare cache, by name only. Probing `HEAD` fails with
|
|
11
|
+
* ENOTDIR on a stray file, and a `.cloning` leftover or another tool's directory must never be
|
|
12
|
+
* passed to `git worktree prune`.
|
|
12
13
|
*/
|
|
13
14
|
export declare const isCacheDirectoryName: (entry: string) => boolean;
|
|
14
15
|
interface WorkspaceLayout {
|
|
@@ -16,14 +17,16 @@ interface WorkspaceLayout {
|
|
|
16
17
|
readonly staging: string;
|
|
17
18
|
readonly worktree: string;
|
|
18
19
|
}
|
|
19
|
-
/**
|
|
20
|
+
/** Executor-specific operations for the shared provisioning code. */
|
|
20
21
|
export interface WorkspaceOps<E> {
|
|
21
22
|
readonly ensureRoots: Effect.Effect<void, E>;
|
|
22
23
|
readonly removePath: (operation: "prepare" | "cleanup", target: string) => Effect.Effect<void, E>;
|
|
23
24
|
readonly cacheExists: Effect.Effect<boolean, E>;
|
|
24
|
-
/** Atomically
|
|
25
|
+
/** Atomically moves the finished staging clone to the cache path. */
|
|
25
26
|
readonly promoteStaging: Effect.Effect<void, E>;
|
|
26
27
|
readonly git: (operation: "prepare" | "cleanup", args: ReadonlyArray<string>) => Effect.Effect<string, E>;
|
|
28
|
+
/** Writes `content` to `path` on the Worker's machine, creating its directory, and makes it executable. */
|
|
29
|
+
readonly writeExecutable: (path: string, content: string) => Effect.Effect<void, E>;
|
|
27
30
|
}
|
|
28
31
|
export interface ProvisionOptions<E> {
|
|
29
32
|
readonly request: CheckoutRequest;
|
|
@@ -32,12 +35,72 @@ export interface ProvisionOptions<E> {
|
|
|
32
35
|
readonly layout: WorkspaceLayout;
|
|
33
36
|
readonly ops: WorkspaceOps<E>;
|
|
34
37
|
}
|
|
38
|
+
export interface ProvisionedWorktree {
|
|
39
|
+
readonly workspace: AttemptWorkspace;
|
|
40
|
+
/** Waits for the workspace scope to close and returns the salvage, or `None` after a successful Attempt or a clean worktree. */
|
|
41
|
+
readonly salvaged: Effect.Effect<Option.Option<AttemptSalvage>, AttemptFailure>;
|
|
42
|
+
/** Sets the salvage sink; call before launch. If salvage isn't recorded, cleanup keeps the worktree on disk. */
|
|
43
|
+
readonly recordSalvage: (record: AttemptChannel.Sink["salvage"]) => Effect.Effect<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Skips checkout removal when the scope closes, so a restart can reattach the parent task or
|
|
46
|
+
* repeat a harvest whose result was not stored.
|
|
47
|
+
*/
|
|
48
|
+
readonly keepForReattach: Effect.Effect<void>;
|
|
49
|
+
/**
|
|
50
|
+
* The hooks directory for the children's git (`withGitHooks`), set only for a
|
|
51
|
+
* `permissions: read` Loop. If `None`, the repository's own hooks apply.
|
|
52
|
+
*/
|
|
53
|
+
readonly gitHooks: Option.Option<string>;
|
|
54
|
+
}
|
|
55
|
+
interface ReleaseOptions<E> {
|
|
56
|
+
readonly request: CheckoutRequest;
|
|
57
|
+
readonly host: string;
|
|
58
|
+
readonly layout: Pick<WorkspaceLayout, "cache" | "worktree">;
|
|
59
|
+
readonly ops: Pick<WorkspaceOps<E>, "cacheExists" | "git" | "removePath">;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Clones into a staging directory and promotes it on success, fetches the requested revision,
|
|
63
|
+
* and checks out a detached worktree at the resolved commit, applying the previous Attempt's
|
|
64
|
+
* salvage if the request resumes one. Registers the release finalizer before the first
|
|
65
|
+
* filesystem change.
|
|
66
|
+
*/
|
|
67
|
+
export declare const provisionWorktree: <E extends Error>(options: ProvisionOptions<E>) => Effect.Effect<{
|
|
68
|
+
workspace: AttemptWorkspace;
|
|
69
|
+
salvaged: Effect.Effect<Option.Option<SalvagePushed | import("@usine/core/attempt/salvage").SalvageRetained>, import("@usine/core/attempt/failure").AgentFailure | import("@usine/core/attempt/failure").BlockedFailure | import("@usine/core/attempt/failure").ChildSessionBudgetFailure | import("@usine/core/attempt/failure").DefectFailure | import("@usine/core/attempt/failure").InfraFailure | import("@usine/core/attempt/failure").QuestionFailure | import("@usine/core/attempt/failure").RunawayFailure, never>;
|
|
70
|
+
recordSalvage: (record: AttemptChannel.Sink["salvage"]) => Effect.Effect<void, never, never>;
|
|
71
|
+
keepForReattach: Effect.Effect<void, never, never>;
|
|
72
|
+
gitHooks: Option.Option<string>;
|
|
73
|
+
}, E | ExecutorOperationError, import("effect/Scope").Scope>;
|
|
74
|
+
export interface ReattachOptions<E> extends ReleaseOptions<E> {
|
|
75
|
+
readonly ops: Pick<WorkspaceOps<E>, "cacheExists" | "git" | "removePath" | "writeExecutable">;
|
|
76
|
+
/** The RunSpec from the parent's durable request. */
|
|
77
|
+
readonly spec: AttemptChannel.RunSpec;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Reuses an Attempt's checkout after an orchestrator restart without cloning, fetching, or
|
|
81
|
+
* checking out. The same release as a new checkout salvages and removes it when the Attempt
|
|
82
|
+
* ends.
|
|
83
|
+
*/
|
|
84
|
+
export declare const reattachWorktree: <E extends Error>(options: ReattachOptions<E>) => Effect.Effect<{
|
|
85
|
+
workspace: AttemptWorkspace;
|
|
86
|
+
salvaged: Effect.Effect<Option.Option<SalvagePushed | import("@usine/core/attempt/salvage").SalvageRetained>, import("@usine/core/attempt/failure").AgentFailure | import("@usine/core/attempt/failure").BlockedFailure | import("@usine/core/attempt/failure").ChildSessionBudgetFailure | import("@usine/core/attempt/failure").DefectFailure | import("@usine/core/attempt/failure").InfraFailure | import("@usine/core/attempt/failure").QuestionFailure | import("@usine/core/attempt/failure").RunawayFailure, never>;
|
|
87
|
+
recordSalvage: (record: AttemptChannel.Sink["salvage"]) => Effect.Effect<void, never, never>;
|
|
88
|
+
keepForReattach: Effect.Effect<void, never, never>;
|
|
89
|
+
gitHooks: Option.Option<string>;
|
|
90
|
+
}, E, import("effect/Scope").Scope>;
|
|
91
|
+
export interface RecoveryOptions<E> {
|
|
92
|
+
readonly attempt: AttemptRecovery;
|
|
93
|
+
readonly host: string;
|
|
94
|
+
readonly worktree: string;
|
|
95
|
+
readonly cache: string;
|
|
96
|
+
/** Runs git with the Worker's repository credentials. */
|
|
97
|
+
readonly git: (args: ReadonlyArray<string>) => Effect.Effect<string, E>;
|
|
98
|
+
}
|
|
35
99
|
/**
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* requested revision and check out a detached worktree at the resolved commit.
|
|
100
|
+
* Reconciles a checkout left by an earlier process: salvages it without a known base, records
|
|
101
|
+
* the result, and removes the worktree only after its work is pushed. Checkouts of succeeded
|
|
102
|
+
* Attempts and of `permissions: read` Loops are removed without salvage.
|
|
40
103
|
*/
|
|
41
|
-
export declare const
|
|
104
|
+
export declare const recoverWorktree: <E extends Error, RecordError>(options: RecoveryOptions<E>, record: (salvage: AttemptSalvage) => Effect.Effect<void, RecordError>) => Effect.Effect<void, E | RecordError, never>;
|
|
42
105
|
export {};
|
|
43
106
|
//# sourceMappingURL=provision.d.ts.map
|
package/dist/provision.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provision.d.ts","sourceRoot":"","sources":["../src/provision.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"provision.d.ts","sourceRoot":"","sources":["../src/provision.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,KAAK,cAAc,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,aAAa,EACd,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,cAAc,EAA0B,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAAsB,MAAM,EAAQ,MAAM,EAAuB,MAAM,QAAQ,CAAC;AACvF,OAAO,EACL,sBAAsB,EACtB,gBAAgB,EAEhB,KAAK,eAAe,EACrB,MAAM,eAAe,CAAC;AAMvB,6EAA6E;AAC7E,eAAO,MAAM,kBAAkB,eAAgB,cAAc,KAAG,MACT,CAAC;AAExD;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,UAAW,MAAM,KAAG,OACmC,CAAC;AAIzF,UAAU,eAAe;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED,qEAAqE;AACrE,MAAM,WAAW,YAAY,CAAC,CAAC;IAC7B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IAC7C,QAAQ,CAAC,UAAU,EAAE,CAAC,SAAS,EAAE,SAAS,GAAG,SAAS,EAAE,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IAClG,QAAQ,CAAC,WAAW,EAAE,MAAM,CAA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