@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.
Files changed (250) hide show
  1. package/LICENSE +661 -21
  2. package/README.md +212 -37
  3. package/dist/child-command.d.ts +5 -8
  4. package/dist/child-command.d.ts.map +1 -1
  5. package/dist/child-command.js +10 -14
  6. package/dist/child-command.js.map +1 -1
  7. package/dist/child-environment.d.ts +19 -0
  8. package/dist/child-environment.d.ts.map +1 -0
  9. package/dist/child-environment.js +18 -0
  10. package/dist/child-environment.js.map +1 -0
  11. package/dist/claude-login-lock.d.ts +9 -0
  12. package/dist/claude-login-lock.d.ts.map +1 -0
  13. package/dist/claude-login-lock.js +15 -0
  14. package/dist/claude-login-lock.js.map +1 -0
  15. package/dist/cloudflare/client.d.ts +50 -0
  16. package/dist/cloudflare/client.d.ts.map +1 -0
  17. package/dist/cloudflare/client.js +108 -0
  18. package/dist/cloudflare/client.js.map +1 -0
  19. package/dist/cloudflare/cloudflare.d.ts +17 -0
  20. package/dist/cloudflare/cloudflare.d.ts.map +1 -0
  21. package/dist/cloudflare/cloudflare.js +704 -0
  22. package/dist/cloudflare/cloudflare.js.map +1 -0
  23. package/dist/cloudflare/model.d.ts +42 -0
  24. package/dist/cloudflare/model.d.ts.map +1 -0
  25. package/dist/cloudflare/model.js +2 -0
  26. package/dist/cloudflare/model.js.map +1 -0
  27. package/dist/cloudflare/shell/environment.d.ts +12 -0
  28. package/dist/cloudflare/shell/environment.d.ts.map +1 -0
  29. package/dist/cloudflare/shell/environment.js +12 -0
  30. package/dist/cloudflare/shell/environment.js.map +1 -0
  31. package/dist/cloudflare/shell/shell.d.ts +2 -0
  32. package/dist/cloudflare/shell/shell.d.ts.map +1 -0
  33. package/dist/cloudflare/shell/shell.js +155 -0
  34. package/dist/cloudflare/shell/shell.js.map +1 -0
  35. package/dist/credential-environment.d.ts +20 -0
  36. package/dist/credential-environment.d.ts.map +1 -0
  37. package/dist/credential-environment.js +20 -0
  38. package/dist/credential-environment.js.map +1 -0
  39. package/dist/durable-session.d.ts +81 -0
  40. package/dist/durable-session.d.ts.map +1 -0
  41. package/dist/durable-session.js +550 -0
  42. package/dist/durable-session.js.map +1 -0
  43. package/dist/exe-dev/commands.d.ts +23 -13
  44. package/dist/exe-dev/commands.d.ts.map +1 -1
  45. package/dist/exe-dev/commands.js +11 -57
  46. package/dist/exe-dev/commands.js.map +1 -1
  47. package/dist/exe-dev/exe-dev.d.ts +9 -3
  48. package/dist/exe-dev/exe-dev.d.ts.map +1 -1
  49. package/dist/exe-dev/exe-dev.js +61 -128
  50. package/dist/exe-dev/exe-dev.js.map +1 -1
  51. package/dist/exe-dev/grants.d.ts.map +1 -1
  52. package/dist/exe-dev/grants.js +35 -15
  53. package/dist/exe-dev/grants.js.map +1 -1
  54. package/dist/exe-dev/model.d.ts +15 -19
  55. package/dist/exe-dev/model.d.ts.map +1 -1
  56. package/dist/exe-dev/model.js +9 -12
  57. package/dist/exe-dev/model.js.map +1 -1
  58. package/dist/exe-dev/preflight.d.ts +8 -4
  59. package/dist/exe-dev/preflight.d.ts.map +1 -1
  60. package/dist/exe-dev/preflight.js +26 -35
  61. package/dist/exe-dev/preflight.js.map +1 -1
  62. package/dist/executor.d.ts +292 -44
  63. package/dist/executor.d.ts.map +1 -1
  64. package/dist/executor.js +187 -19
  65. package/dist/executor.js.map +1 -1
  66. package/dist/guard.d.ts +57 -7
  67. package/dist/guard.d.ts.map +1 -1
  68. package/dist/guard.js +274 -59
  69. package/dist/guard.js.map +1 -1
  70. package/dist/harness-preflight.d.ts +27 -5
  71. package/dist/harness-preflight.d.ts.map +1 -1
  72. package/dist/harness-preflight.js +32 -31
  73. package/dist/harness-preflight.js.map +1 -1
  74. package/dist/keyed-lock.d.ts +2 -3
  75. package/dist/keyed-lock.d.ts.map +1 -1
  76. package/dist/keyed-lock.js +2 -3
  77. package/dist/keyed-lock.js.map +1 -1
  78. package/dist/leftovers.d.ts +9 -0
  79. package/dist/leftovers.d.ts.map +1 -0
  80. package/dist/leftovers.js +14 -0
  81. package/dist/leftovers.js.map +1 -0
  82. package/dist/local/credentials.d.ts +21 -0
  83. package/dist/local/credentials.d.ts.map +1 -0
  84. package/dist/local/credentials.js +39 -0
  85. package/dist/local/credentials.js.map +1 -0
  86. package/dist/local/leftovers.d.ts +8 -0
  87. package/dist/local/leftovers.d.ts.map +1 -0
  88. package/dist/local/leftovers.js +23 -0
  89. package/dist/local/leftovers.js.map +1 -0
  90. package/dist/local/local.d.ts +17 -11
  91. package/dist/local/local.d.ts.map +1 -1
  92. package/dist/local/local.js +205 -132
  93. package/dist/local/local.js.map +1 -1
  94. package/dist/memory-preflight.d.ts +27 -0
  95. package/dist/memory-preflight.d.ts.map +1 -0
  96. package/dist/memory-preflight.js +83 -0
  97. package/dist/memory-preflight.js.map +1 -0
  98. package/dist/pre-push-hook.d.ts +20 -0
  99. package/dist/pre-push-hook.d.ts.map +1 -0
  100. package/dist/pre-push-hook.js +33 -0
  101. package/dist/pre-push-hook.js.map +1 -0
  102. package/dist/prepared-attempt.d.ts +41 -3
  103. package/dist/prepared-attempt.d.ts.map +1 -1
  104. package/dist/prepared-attempt.js +109 -31
  105. package/dist/prepared-attempt.js.map +1 -1
  106. package/dist/provision.d.ts +129 -15
  107. package/dist/provision.d.ts.map +1 -1
  108. package/dist/provision.js +428 -69
  109. package/dist/provision.js.map +1 -1
  110. package/dist/remote/commands.d.ts +51 -0
  111. package/dist/remote/commands.d.ts.map +1 -0
  112. package/dist/remote/commands.js +94 -0
  113. package/dist/remote/commands.js.map +1 -0
  114. package/dist/remote/container.d.ts +90 -0
  115. package/dist/remote/container.d.ts.map +1 -0
  116. package/dist/remote/container.js +480 -0
  117. package/dist/remote/container.js.map +1 -0
  118. package/dist/remote/leftovers.d.ts +14 -0
  119. package/dist/remote/leftovers.d.ts.map +1 -0
  120. package/dist/remote/leftovers.js +22 -0
  121. package/dist/remote/leftovers.js.map +1 -0
  122. package/dist/remote/liveness.d.ts +33 -0
  123. package/dist/remote/liveness.d.ts.map +1 -0
  124. package/dist/remote/liveness.js +196 -0
  125. package/dist/remote/liveness.js.map +1 -0
  126. package/dist/remote/machine.d.ts +110 -0
  127. package/dist/remote/machine.d.ts.map +1 -0
  128. package/dist/remote/machine.js +2 -0
  129. package/dist/remote/machine.js.map +1 -0
  130. package/dist/remote/remote.d.ts +28 -0
  131. package/dist/remote/remote.d.ts.map +1 -0
  132. package/dist/remote/remote.js +556 -0
  133. package/dist/remote/remote.js.map +1 -0
  134. package/dist/remote/sweep.d.ts +17 -0
  135. package/dist/remote/sweep.d.ts.map +1 -0
  136. package/dist/remote/sweep.js +117 -0
  137. package/dist/remote/sweep.js.map +1 -0
  138. package/dist/renewable-credential.d.ts +17 -0
  139. package/dist/renewable-credential.d.ts.map +1 -0
  140. package/dist/renewable-credential.js +58 -0
  141. package/dist/renewable-credential.js.map +1 -0
  142. package/dist/salvage.d.ts +38 -0
  143. package/dist/salvage.d.ts.map +1 -0
  144. package/dist/salvage.js +198 -0
  145. package/dist/salvage.js.map +1 -0
  146. package/dist/ssh/api-keys.d.ts +36 -0
  147. package/dist/ssh/api-keys.d.ts.map +1 -0
  148. package/dist/ssh/api-keys.js +72 -0
  149. package/dist/ssh/api-keys.js.map +1 -0
  150. package/dist/ssh/codex-homes.d.ts +21 -0
  151. package/dist/ssh/codex-homes.d.ts.map +1 -0
  152. package/dist/ssh/codex-homes.js +78 -0
  153. package/dist/ssh/codex-homes.js.map +1 -0
  154. package/dist/ssh/container.d.ts +32 -0
  155. package/dist/ssh/container.d.ts.map +1 -0
  156. package/dist/ssh/container.js +282 -0
  157. package/dist/ssh/container.js.map +1 -0
  158. package/dist/ssh/credentials.d.ts +43 -0
  159. package/dist/ssh/credentials.d.ts.map +1 -0
  160. package/dist/ssh/credentials.js +86 -0
  161. package/dist/ssh/credentials.js.map +1 -0
  162. package/dist/ssh/gateway/admin.d.ts +45 -0
  163. package/dist/ssh/gateway/admin.d.ts.map +1 -0
  164. package/dist/ssh/gateway/admin.js +129 -0
  165. package/dist/ssh/gateway/admin.js.map +1 -0
  166. package/dist/ssh/gateway/attachments.d.ts +31 -0
  167. package/dist/ssh/gateway/attachments.d.ts.map +1 -0
  168. package/dist/ssh/gateway/attachments.js +168 -0
  169. package/dist/ssh/gateway/attachments.js.map +1 -0
  170. package/dist/ssh/gateway/environment.d.ts +71 -0
  171. package/dist/ssh/gateway/environment.d.ts.map +1 -0
  172. package/dist/ssh/gateway/environment.js +148 -0
  173. package/dist/ssh/gateway/environment.js.map +1 -0
  174. package/dist/ssh/gateway/forward.d.ts +74 -0
  175. package/dist/ssh/gateway/forward.d.ts.map +1 -0
  176. package/dist/ssh/gateway/forward.js +247 -0
  177. package/dist/ssh/gateway/forward.js.map +1 -0
  178. package/dist/ssh/gateway/preflight.d.ts +67 -0
  179. package/dist/ssh/gateway/preflight.d.ts.map +1 -0
  180. package/dist/ssh/gateway/preflight.js +320 -0
  181. package/dist/ssh/gateway/preflight.js.map +1 -0
  182. package/dist/ssh/limits.d.ts +60 -0
  183. package/dist/ssh/limits.d.ts.map +1 -0
  184. package/dist/ssh/limits.js +84 -0
  185. package/dist/ssh/limits.js.map +1 -0
  186. package/dist/ssh/model.d.ts +153 -0
  187. package/dist/ssh/model.d.ts.map +1 -0
  188. package/dist/ssh/model.js +2 -0
  189. package/dist/ssh/model.js.map +1 -0
  190. package/dist/ssh/preflight.d.ts +35 -0
  191. package/dist/ssh/preflight.d.ts.map +1 -0
  192. package/dist/ssh/preflight.js +87 -0
  193. package/dist/ssh/preflight.js.map +1 -0
  194. package/dist/ssh/provisioner/boat.d.ts +33 -0
  195. package/dist/ssh/provisioner/boat.d.ts.map +1 -0
  196. package/dist/ssh/provisioner/boat.js +247 -0
  197. package/dist/ssh/provisioner/boat.js.map +1 -0
  198. package/dist/ssh/provisioner/hetzner.d.ts +32 -0
  199. package/dist/ssh/provisioner/hetzner.d.ts.map +1 -0
  200. package/dist/ssh/provisioner/hetzner.js +337 -0
  201. package/dist/ssh/provisioner/hetzner.js.map +1 -0
  202. package/dist/ssh/provisioner/host-key.d.ts +11 -0
  203. package/dist/ssh/provisioner/host-key.d.ts.map +1 -0
  204. package/dist/ssh/provisioner/host-key.js +57 -0
  205. package/dist/ssh/provisioner/host-key.js.map +1 -0
  206. package/dist/ssh/provisioner/http.d.ts +45 -0
  207. package/dist/ssh/provisioner/http.d.ts.map +1 -0
  208. package/dist/ssh/provisioner/http.js +72 -0
  209. package/dist/ssh/provisioner/http.js.map +1 -0
  210. package/dist/ssh/provisioner/machines.d.ts +48 -0
  211. package/dist/ssh/provisioner/machines.d.ts.map +1 -0
  212. package/dist/ssh/provisioner/machines.js +686 -0
  213. package/dist/ssh/provisioner/machines.js.map +1 -0
  214. package/dist/ssh/provisioner/model.d.ts +92 -0
  215. package/dist/ssh/provisioner/model.d.ts.map +1 -0
  216. package/dist/ssh/provisioner/model.js +37 -0
  217. package/dist/ssh/provisioner/model.js.map +1 -0
  218. package/dist/ssh/ssh.d.ts +23 -0
  219. package/dist/ssh/ssh.d.ts.map +1 -0
  220. package/dist/ssh/ssh.js +145 -0
  221. package/dist/ssh/ssh.js.map +1 -0
  222. package/dist/ssh/worker-records.d.ts +18 -0
  223. package/dist/ssh/worker-records.d.ts.map +1 -0
  224. package/dist/ssh/worker-records.js +100 -0
  225. package/dist/ssh/worker-records.js.map +1 -0
  226. package/dist/ssh/workers.d.ts +80 -0
  227. package/dist/ssh/workers.d.ts.map +1 -0
  228. package/dist/ssh/workers.js +247 -0
  229. package/dist/ssh/workers.js.map +1 -0
  230. package/package.json +25 -9
  231. package/dist/exe-dev/channel.d.ts +0 -12
  232. package/dist/exe-dev/channel.d.ts.map +0 -1
  233. package/dist/exe-dev/channel.js +0 -42
  234. package/dist/exe-dev/channel.js.map +0 -1
  235. package/dist/exe-dev/shell.d.ts +0 -12
  236. package/dist/exe-dev/shell.d.ts.map +0 -1
  237. package/dist/exe-dev/shell.js +0 -31
  238. package/dist/exe-dev/shell.js.map +0 -1
  239. package/dist/exe-dev/sweep.d.ts +0 -10
  240. package/dist/exe-dev/sweep.d.ts.map +0 -1
  241. package/dist/exe-dev/sweep.js +0 -117
  242. package/dist/exe-dev/sweep.js.map +0 -1
  243. package/dist/invalid-frame.d.ts +0 -17
  244. package/dist/invalid-frame.d.ts.map +0 -1
  245. package/dist/invalid-frame.js +0 -111
  246. package/dist/invalid-frame.js.map +0 -1
  247. package/dist/run-host-session.d.ts +0 -27
  248. package/dist/run-host-session.d.ts.map +0 -1
  249. package/dist/run-host-session.js +0 -303
  250. package/dist/run-host-session.js.map +0 -1
@@ -1,14 +1,15 @@
1
- import { RepositoryName } from "@usine/core/repository";
2
- import { Effect } from "effect";
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";
4
+ import { RepositoryName, CommitSha } from "@usine/core/repository";
5
+ import { Effect, Option } from "effect";
3
6
  import { ExecutorOperationError, AttemptWorkspace, type CheckoutRequest } from "./executor.ts";
4
- export declare const safeSegment: (value: string) => string;
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
- * Whether a `repos/` entry is one of our bare caches, decided by the name we
9
- * mint rather than by probing contents: a `HEAD` lookup fails with ENOTDIR on
10
- * a stray file, and a `.cloning` leftover or a tool's scratch directory must
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,15 +17,41 @@ interface WorkspaceLayout {
16
17
  readonly staging: string;
17
18
  readonly worktree: string;
18
19
  }
19
- /** The adapter-specific primitives; everything else about provisioning is shared. */
20
+ /** Runs one cleanup step, and logs and ignores its failure, so later steps still run. */
21
+ export type CleanupStep<E> = <A>(resource: string, effect: Effect.Effect<A, E>) => Effect.Effect<void>;
22
+ /** The Attempt's checkout: how it is created and removed, and where git runs in it. */
23
+ export interface CheckoutOps<E> {
24
+ /** Creates the checkout at the layout's worktree, detached at `commit`. */
25
+ readonly add: (commit: CommitSha) => Effect.Effect<void, E>;
26
+ /** Removes a checkout that `add` created during preparation, so `add` can create it again. */
27
+ readonly discard: Effect.Effect<void, E>;
28
+ /**
29
+ * Runs git in the checkout with the Attempt's repository credentials and `commitIdentity` for
30
+ * the request's `commitAuthor`, which authors the salvage commit and commits the rebased
31
+ * salvage. `args` name the checkout with `-C`.
32
+ */
33
+ readonly git: (operation: "prepare" | "cleanup", args: ReadonlyArray<string>) => Effect.Effect<string, E>;
34
+ /** Writes `content` to `path` inside the checkout, creating its directory, and makes it executable. */
35
+ readonly writeExecutable: (path: string, content: string) => Effect.Effect<void, E>;
36
+ /** Removes the checkout when the Attempt releases it, running each step through `cleanup`. */
37
+ readonly remove: (cleanup: CleanupStep<E>) => Effect.Effect<void>;
38
+ }
39
+ /** Executor-specific operations for the shared provisioning code. */
20
40
  export interface WorkspaceOps<E> {
21
41
  readonly ensureRoots: Effect.Effect<void, E>;
22
42
  readonly removePath: (operation: "prepare" | "cleanup", target: string) => Effect.Effect<void, E>;
23
43
  readonly cacheExists: Effect.Effect<boolean, E>;
24
- /** Atomically promote the finished staging clone to the cache path. */
44
+ /** Atomically moves the finished staging clone to the cache path. */
25
45
  readonly promoteStaging: Effect.Effect<void, E>;
46
+ /** Runs git on the cached clone with the Attempt's repository credentials. */
26
47
  readonly git: (operation: "prepare" | "cleanup", args: ReadonlyArray<string>) => Effect.Effect<string, E>;
48
+ readonly checkout: CheckoutOps<E>;
27
49
  }
50
+ /**
51
+ * Returns the checkout as a linked worktree of the cached clone, created and removed with
52
+ * `git worktree`. `ops.git` runs every git command, in the checkout too.
53
+ */
54
+ export declare const linkedWorktree: <E>(ops: Pick<WorkspaceOps<E>, "cacheExists" | "git" | "removePath">, layout: Pick<WorkspaceLayout, "cache" | "worktree">, writeExecutable: (path: string, content: string) => Effect.Effect<void, E>) => CheckoutOps<E>;
28
55
  export interface ProvisionOptions<E> {
29
56
  readonly request: CheckoutRequest;
30
57
  readonly url: string;
@@ -32,12 +59,99 @@ export interface ProvisionOptions<E> {
32
59
  readonly layout: WorkspaceLayout;
33
60
  readonly ops: WorkspaceOps<E>;
34
61
  }
62
+ export interface ProvisionedWorktree {
63
+ readonly workspace: AttemptWorkspace;
64
+ /** Waits for the workspace scope to close and returns the salvage, or `None` after a successful Attempt or a clean worktree. */
65
+ readonly salvaged: Effect.Effect<Option.Option<AttemptSalvage>, AttemptFailure>;
66
+ /** Sets the salvage sink; call before launch. If salvage isn't recorded, cleanup keeps the worktree on disk. */
67
+ readonly recordSalvage: (record: AttemptChannel.Sink["salvage"]) => Effect.Effect<void>;
68
+ /**
69
+ * Skips checkout removal when the scope closes, so a restart can reattach the parent task or
70
+ * repeat a harvest whose result was not stored.
71
+ */
72
+ readonly keepForReattach: Effect.Effect<void>;
73
+ /**
74
+ * Skips salvage and checkout removal when the scope closes, because the parent task may still
75
+ * run in the checkout. The executor reconciles it once a stop is confirmed (#523).
76
+ */
77
+ readonly keepUntilStopped: Effect.Effect<void>;
78
+ /**
79
+ * The hooks directory for the children's git (`withGitHooks`), set only for a
80
+ * `permissions: read` Loop. If `None`, the repository's own hooks apply.
81
+ */
82
+ readonly gitHooks: Option.Option<string>;
83
+ }
84
+ interface ReleaseOptions<E> {
85
+ readonly request: CheckoutRequest;
86
+ readonly host: string;
87
+ readonly layout: Pick<WorkspaceLayout, "worktree">;
88
+ readonly ops: Pick<WorkspaceOps<E>, "checkout">;
89
+ }
90
+ /**
91
+ * Clones into a staging directory and promotes it on success, fetches the requested revision,
92
+ * and checks out a detached worktree at the resolved commit, applying the previous Attempt's
93
+ * salvage if the request resumes one. Registers the release finalizer before the first
94
+ * filesystem change.
95
+ */
96
+ export declare const provisionWorktree: <E extends Error>(options: ProvisionOptions<E>) => Effect.Effect<{
97
+ workspace: AttemptWorkspace;
98
+ salvaged: Effect.Effect<Option.Option<import("@usine/core/attempt/salvage").SalvagePartlyPushed | SalvagePushed | import("@usine/core/attempt/salvage").SalvageRejected | 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>;
99
+ recordSalvage: (record: AttemptChannel.Sink["salvage"]) => Effect.Effect<void, never, never>;
100
+ keepForReattach: Effect.Effect<void, never, never>;
101
+ keepUntilStopped: Effect.Effect<void, never, never>;
102
+ gitHooks: Option.Option<string>;
103
+ }, E | ExecutorOperationError, import("effect/Scope").Scope>;
104
+ export interface ReattachOptions<E> extends ReleaseOptions<E> {
105
+ /** The RunSpec from the parent's durable request. */
106
+ readonly spec: AttemptChannel.RunSpec;
107
+ }
108
+ /**
109
+ * Reuses an Attempt's checkout after an orchestrator restart without cloning, fetching, or
110
+ * checking out. The same release as a new checkout salvages and removes it when the Attempt
111
+ * ends.
112
+ */
113
+ export declare const reattachWorktree: <E extends Error>(options: ReattachOptions<E>) => Effect.Effect<{
114
+ workspace: AttemptWorkspace;
115
+ salvaged: Effect.Effect<Option.Option<import("@usine/core/attempt/salvage").SalvagePartlyPushed | SalvagePushed | import("@usine/core/attempt/salvage").SalvageRejected | 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>;
116
+ recordSalvage: (record: AttemptChannel.Sink["salvage"]) => Effect.Effect<void, never, never>;
117
+ keepForReattach: Effect.Effect<void, never, never>;
118
+ keepUntilStopped: Effect.Effect<void, never, never>;
119
+ gitHooks: Option.Option<string>;
120
+ }, E, import("effect/Scope").Scope>;
121
+ export interface RecoveryOptions<E> {
122
+ readonly attempt: AttemptRecovery;
123
+ readonly host: string;
124
+ readonly worktree: string;
125
+ /**
126
+ * Runs git in the checkout with the Worker's repository credentials. For an Attempt that is
127
+ * salvaged, it also sets the `commitIdentity` that authors the salvage commit.
128
+ */
129
+ readonly git: (args: ReadonlyArray<string>) => Effect.Effect<string, E>;
130
+ /** Removes the checkout and its registration in the cached clone. */
131
+ readonly removeCheckout: Effect.Effect<void, E>;
132
+ }
133
+ /**
134
+ * Returns the recovery of an unsuccessful Attempt's checkout that its launch kept while the parent
135
+ * task's stop was unconfirmed.
136
+ */
137
+ export declare const keptCheckoutRecovery: (request: CheckoutRequest) => AttemptRecovery;
138
+ /** Returns the span and log fields of `attempt`, with whether its recorded salvage was rejected. */
139
+ export declare const recoveryFields: (attempt: AttemptRecovery) => {
140
+ attemptId: import("@usine/core/attempt").AttemptId;
141
+ worker: import("@usine/core/worker").WorkerName;
142
+ repository: RepositoryName;
143
+ ref: import("@usine/core/attempt/salvage").SalvageRef;
144
+ permissions: import("@usine/core/loop").LoopPermissions;
145
+ succeeded: boolean;
146
+ open: boolean;
147
+ rejected: boolean;
148
+ };
35
149
  /**
36
- * The clone-to-worktree sequence every Executor shares: clone into a staging
37
- * sibling and promote it on success, so an interrupted clone never leaves a
38
- * half-initialized cache that later fetches would poison; then fetch the
39
- * requested revision and check out a detached worktree at the resolved commit.
150
+ * Reconciles a checkout left by an earlier process, or kept while its parent task's stop was
151
+ * unconfirmed: salvages it without a known base, records the result, and removes the worktree
152
+ * only after its work is pushed. Checkouts of succeeded Attempts and of `permissions: read` Loops
153
+ * are removed without salvage.
40
154
  */
41
- export declare const provisionWorktree: <E>(options: ProvisionOptions<E>) => Effect.Effect<AttemptWorkspace, E | ExecutorOperationError, import("effect/Scope").Scope>;
155
+ 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
156
  export {};
43
157
  //# sourceMappingURL=provision.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"provision.d.ts","sourceRoot":"","sources":["../src/provision.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAa,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,MAAM,EAAU,MAAM,QAAQ,CAAC;AACxC,OAAO,EACL,sBAAsB,EACtB,gBAAgB,EAEhB,KAAK,eAAe,EACrB,MAAM,eAAe,CAAC;AAEvB,eAAO,MAAM,WAAW,UAAW,MAAM,KAAG,MAAoD,CAAC;AAIjG,8FAA8F;AAC9F,eAAO,MAAM,kBAAkB,eAAgB,cAAc,KAAG,MACT,CAAC;AAExD;;;;;GAKG;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,qFAAqF;AACrF,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,CA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