@ricsam/r5d-worker 0.0.137 → 0.0.138

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 (236) hide show
  1. package/README.md +4 -94
  2. package/dist/cjs/package.json +1 -1
  3. package/dist/mjs/main.mjs +46 -7543
  4. package/dist/mjs/package.json +1 -1
  5. package/dist/mjs/personal/action-scheduler.mjs +31 -0
  6. package/dist/mjs/personal/client.mjs +215 -0
  7. package/dist/mjs/personal/runtime.mjs +328 -0
  8. package/dist/mjs/personal/tcp.mjs +217 -0
  9. package/dist/mjs/runtime/adapter.mjs +42 -0
  10. package/dist/mjs/runtime/client.mjs +95 -0
  11. package/dist/mjs/runtime/daemon.mjs +131 -0
  12. package/dist/mjs/runtime/executor.mjs +436 -0
  13. package/dist/mjs/runtime/index.mjs +15 -0
  14. package/dist/mjs/runtime/protocol.mjs +139 -0
  15. package/dist/mjs/runtime/pty-host.mjs +156 -0
  16. package/dist/mjs/runtime/pty.mjs +127 -0
  17. package/dist/mjs/runtime/releases/artifacts.mjs +201 -0
  18. package/dist/mjs/runtime/releases/grants.mjs +93 -0
  19. package/dist/mjs/runtime/releases/main.mjs +101 -0
  20. package/dist/mjs/runtime/releases/manager.mjs +541 -0
  21. package/dist/mjs/runtime/releases/process.mjs +88 -0
  22. package/dist/mjs/runtime/releases/retirement.mjs +18 -0
  23. package/dist/mjs/runtime/releases/rpc-client.mjs +184 -0
  24. package/dist/mjs/runtime/releases/rpc-main.mjs +213 -0
  25. package/dist/mjs/runtime/releases/rpc-protocol.mjs +103 -0
  26. package/dist/mjs/runtime/storage.mjs +156 -0
  27. package/dist/mjs/runtime/workspace/artifacts.mjs +121 -0
  28. package/dist/mjs/runtime/workspace/authority.mjs +1355 -0
  29. package/dist/mjs/runtime/workspace/contracts.mjs +60 -0
  30. package/dist/mjs/runtime/workspace/file-write.mjs +23 -0
  31. package/dist/mjs/runtime/workspace/files.mjs +308 -0
  32. package/dist/mjs/runtime/workspace/http-body.mjs +45 -0
  33. package/dist/mjs/runtime/workspace/storage-client.mjs +59 -0
  34. package/dist/mjs/runtime/workspace/storage-wire.mjs +53 -0
  35. package/dist/types/main.d.ts +0 -1167
  36. package/dist/types/personal/action-scheduler.d.ts +23 -0
  37. package/dist/types/personal/client.d.ts +14 -0
  38. package/dist/types/personal/runtime.d.ts +121 -0
  39. package/dist/types/personal/tcp.d.ts +14 -0
  40. package/dist/types/runtime/client.d.ts +3 -1
  41. package/dist/types/runtime/executor.d.ts +6 -1
  42. package/dist/types/runtime/protocol.d.ts +176 -4
  43. package/dist/types/runtime/pty.d.ts +1 -0
  44. package/dist/types/runtime/releases/artifacts.d.ts +51 -0
  45. package/dist/types/runtime/releases/grants.d.ts +16 -0
  46. package/dist/types/runtime/releases/manager.d.ts +145 -0
  47. package/dist/types/runtime/releases/process.d.ts +14 -0
  48. package/dist/types/runtime/releases/retirement.d.ts +15 -0
  49. package/dist/types/runtime/releases/rpc-client.d.ts +52 -0
  50. package/dist/types/runtime/releases/rpc-main.d.ts +10 -0
  51. package/dist/types/runtime/releases/rpc-protocol.d.ts +1139 -0
  52. package/dist/types/runtime/workspace/artifacts.d.ts +30 -0
  53. package/dist/types/runtime/workspace/authority.d.ts +338 -0
  54. package/dist/types/runtime/workspace/contracts.d.ts +86 -0
  55. package/dist/types/runtime/workspace/file-write.d.ts +14 -0
  56. package/dist/types/runtime/workspace/files.d.ts +21 -0
  57. package/dist/types/runtime/workspace/http-body.d.ts +9 -0
  58. package/dist/types/runtime/workspace/storage-client.d.ts +23 -0
  59. package/dist/types/runtime/workspace/storage-wire.d.ts +138 -0
  60. package/package.json +8 -6
  61. package/dist/cjs/atomic-rename.cjs +0 -303
  62. package/dist/cjs/browser-upload.cjs +0 -73
  63. package/dist/cjs/cli-update.cjs +0 -108
  64. package/dist/cjs/command-launcher.cjs +0 -423
  65. package/dist/cjs/control-command-policy.cjs +0 -177
  66. package/dist/cjs/git-blob-hash.cjs +0 -41
  67. package/dist/cjs/git-identity.cjs +0 -39
  68. package/dist/cjs/git-process-environment.cjs +0 -133
  69. package/dist/cjs/inline-output.cjs +0 -62
  70. package/dist/cjs/main.cjs +0 -7517
  71. package/dist/cjs/managed-paths.cjs +0 -215
  72. package/dist/cjs/plan-lint.cjs +0 -165
  73. package/dist/cjs/plan-parser.cjs +0 -127
  74. package/dist/cjs/plan-paths.cjs +0 -53
  75. package/dist/cjs/port-forward-client.cjs +0 -206
  76. package/dist/cjs/process-tree.cjs +0 -117
  77. package/dist/cjs/project-checkout-garbage.cjs +0 -219
  78. package/dist/cjs/project-mirror-fetch-policy.cjs +0 -82
  79. package/dist/cjs/project-mirror-refs-token.cjs +0 -85
  80. package/dist/cjs/project-workspace-state.cjs +0 -972
  81. package/dist/cjs/project-worktrees.cjs +0 -1713
  82. package/dist/cjs/pty-output-coalescer.cjs +0 -87
  83. package/dist/cjs/recovery-journal-protocol.cjs +0 -56
  84. package/dist/cjs/recovery-journal-runtime.cjs +0 -133
  85. package/dist/cjs/recovery-journal-thread.cjs +0 -9
  86. package/dist/cjs/recovery-journal.cjs +0 -742
  87. package/dist/cjs/recovery-output-window.cjs +0 -77
  88. package/dist/cjs/recovery-protocol.cjs +0 -31
  89. package/dist/cjs/recovery-store.cjs +0 -252
  90. package/dist/cjs/registry-auth.cjs +0 -310
  91. package/dist/cjs/repository-transition-policy.cjs +0 -49
  92. package/dist/cjs/runtime-version.cjs +0 -88
  93. package/dist/cjs/session-file-mutations.cjs +0 -61
  94. package/dist/cjs/supervisor.cjs +0 -147
  95. package/dist/cjs/three-way-merge.cjs +0 -346
  96. package/dist/cjs/working-tree-mirror.cjs +0 -1872
  97. package/dist/cjs/workspace-automatic-sync-policy.cjs +0 -79
  98. package/dist/cjs/workspace-branch-incarnation-policy.cjs +0 -37
  99. package/dist/cjs/workspace-command-sync-policy.cjs +0 -112
  100. package/dist/cjs/workspace-command-targets.cjs +0 -63
  101. package/dist/cjs/workspace-filesystem-executor-thread.cjs +0 -36
  102. package/dist/cjs/workspace-filesystem-executor.cjs +0 -327
  103. package/dist/cjs/workspace-filesystem-job-types.cjs +0 -144
  104. package/dist/cjs/workspace-filesystem-jobs.cjs +0 -59
  105. package/dist/cjs/workspace-git-sync.cjs +0 -3595
  106. package/dist/cjs/workspace-hydration-ledger.cjs +0 -83
  107. package/dist/cjs/workspace-hydration-merge.cjs +0 -448
  108. package/dist/cjs/workspace-hydration-recovery-state.cjs +0 -53
  109. package/dist/cjs/workspace-incident-state.cjs +0 -37
  110. package/dist/cjs/workspace-merge-projection.cjs +0 -628
  111. package/dist/cjs/workspace-mount-boundary.cjs +0 -71
  112. package/dist/cjs/workspace-mount-hold-fence.cjs +0 -120
  113. package/dist/cjs/workspace-mutation-gate.cjs +0 -127
  114. package/dist/cjs/workspace-path-move.cjs +0 -195
  115. package/dist/cjs/workspace-preserve-only-policy.cjs +0 -36
  116. package/dist/cjs/workspace-project-config-policy.cjs +0 -53
  117. package/dist/cjs/workspace-projection-ledger.cjs +0 -81
  118. package/dist/cjs/workspace-publication-evidence.cjs +0 -46
  119. package/dist/cjs/workspace-sync-coalescer.cjs +0 -58
  120. package/dist/mjs/atomic-rename.mjs +0 -261
  121. package/dist/mjs/browser-upload.mjs +0 -42
  122. package/dist/mjs/command-launcher.mjs +0 -393
  123. package/dist/mjs/control-command-policy.mjs +0 -146
  124. package/dist/mjs/git-blob-hash.mjs +0 -16
  125. package/dist/mjs/git-identity.mjs +0 -15
  126. package/dist/mjs/git-process-environment.mjs +0 -105
  127. package/dist/mjs/inline-output.mjs +0 -37
  128. package/dist/mjs/managed-paths.mjs +0 -174
  129. package/dist/mjs/plan-lint.mjs +0 -129
  130. package/dist/mjs/plan-parser.mjs +0 -94
  131. package/dist/mjs/plan-paths.mjs +0 -25
  132. package/dist/mjs/port-forward-client.mjs +0 -172
  133. package/dist/mjs/project-checkout-garbage.mjs +0 -178
  134. package/dist/mjs/project-mirror-fetch-policy.mjs +0 -56
  135. package/dist/mjs/project-mirror-refs-token.mjs +0 -53
  136. package/dist/mjs/project-workspace-state.mjs +0 -937
  137. package/dist/mjs/project-worktrees.mjs +0 -1657
  138. package/dist/mjs/pty-output-coalescer.mjs +0 -61
  139. package/dist/mjs/recovery-journal-protocol.mjs +0 -30
  140. package/dist/mjs/recovery-journal-runtime.mjs +0 -112
  141. package/dist/mjs/recovery-journal-thread.mjs +0 -8
  142. package/dist/mjs/recovery-journal.mjs +0 -694
  143. package/dist/mjs/recovery-output-window.mjs +0 -53
  144. package/dist/mjs/recovery-protocol.mjs +0 -6
  145. package/dist/mjs/recovery-store.mjs +0 -217
  146. package/dist/mjs/registry-auth.mjs +0 -269
  147. package/dist/mjs/repository-transition-policy.mjs +0 -22
  148. package/dist/mjs/runtime-version.mjs +0 -54
  149. package/dist/mjs/session-file-mutations.mjs +0 -37
  150. package/dist/mjs/supervisor.mjs +0 -114
  151. package/dist/mjs/three-way-merge.mjs +0 -318
  152. package/dist/mjs/working-tree-mirror.mjs +0 -1817
  153. package/dist/mjs/workspace-automatic-sync-policy.mjs +0 -48
  154. package/dist/mjs/workspace-branch-incarnation-policy.mjs +0 -13
  155. package/dist/mjs/workspace-command-sync-policy.mjs +0 -84
  156. package/dist/mjs/workspace-command-targets.mjs +0 -37
  157. package/dist/mjs/workspace-filesystem-executor-thread.mjs +0 -38
  158. package/dist/mjs/workspace-filesystem-executor.mjs +0 -287
  159. package/dist/mjs/workspace-filesystem-job-types.mjs +0 -116
  160. package/dist/mjs/workspace-filesystem-jobs.mjs +0 -55
  161. package/dist/mjs/workspace-git-sync.mjs +0 -3553
  162. package/dist/mjs/workspace-hydration-ledger.mjs +0 -58
  163. package/dist/mjs/workspace-hydration-merge.mjs +0 -414
  164. package/dist/mjs/workspace-hydration-recovery-state.mjs +0 -29
  165. package/dist/mjs/workspace-incident-state.mjs +0 -12
  166. package/dist/mjs/workspace-merge-projection.mjs +0 -594
  167. package/dist/mjs/workspace-mount-boundary.mjs +0 -37
  168. package/dist/mjs/workspace-mount-hold-fence.mjs +0 -95
  169. package/dist/mjs/workspace-mutation-gate.mjs +0 -103
  170. package/dist/mjs/workspace-path-move.mjs +0 -160
  171. package/dist/mjs/workspace-preserve-only-policy.mjs +0 -11
  172. package/dist/mjs/workspace-project-config-policy.mjs +0 -27
  173. package/dist/mjs/workspace-projection-ledger.mjs +0 -57
  174. package/dist/mjs/workspace-publication-evidence.mjs +0 -21
  175. package/dist/mjs/workspace-sync-coalescer.mjs +0 -34
  176. package/dist/types/atomic-rename.d.ts +0 -78
  177. package/dist/types/browser-upload.d.ts +0 -7
  178. package/dist/types/command-launcher.d.ts +0 -104
  179. package/dist/types/control-command-policy.d.ts +0 -53
  180. package/dist/types/git-blob-hash.d.ts +0 -10
  181. package/dist/types/git-identity.d.ts +0 -9
  182. package/dist/types/git-process-environment.d.ts +0 -9
  183. package/dist/types/inline-output.d.ts +0 -3
  184. package/dist/types/managed-paths.d.ts +0 -19
  185. package/dist/types/plan-lint.d.ts +0 -16
  186. package/dist/types/plan-parser.d.ts +0 -38
  187. package/dist/types/plan-paths.d.ts +0 -36
  188. package/dist/types/port-forward-client.d.ts +0 -8
  189. package/dist/types/project-checkout-garbage.d.ts +0 -86
  190. package/dist/types/project-mirror-fetch-policy.d.ts +0 -84
  191. package/dist/types/project-mirror-refs-token.d.ts +0 -53
  192. package/dist/types/project-workspace-state.d.ts +0 -188
  193. package/dist/types/project-worktrees.d.ts +0 -397
  194. package/dist/types/pty-output-coalescer.d.ts +0 -20
  195. package/dist/types/recovery-journal-protocol.d.ts +0 -35
  196. package/dist/types/recovery-journal-runtime.d.ts +0 -12
  197. package/dist/types/recovery-journal-stall-fixture.d.ts +0 -1
  198. package/dist/types/recovery-journal-thread.d.ts +0 -1
  199. package/dist/types/recovery-journal.d.ts +0 -248
  200. package/dist/types/recovery-output-window.d.ts +0 -19
  201. package/dist/types/recovery-protocol.d.ts +0 -59
  202. package/dist/types/recovery-store.d.ts +0 -52
  203. package/dist/types/registry-auth.d.ts +0 -47
  204. package/dist/types/repository-transition-policy.d.ts +0 -26
  205. package/dist/types/runtime-version.d.ts +0 -1
  206. package/dist/types/session-file-mutations.d.ts +0 -22
  207. package/dist/types/supervisor-daemonized-fixture.d.ts +0 -1
  208. package/dist/types/supervisor-launcher-cleanup-fixture.d.ts +0 -1
  209. package/dist/types/supervisor-signal-fixture.d.ts +0 -1
  210. package/dist/types/supervisor.d.ts +0 -23
  211. package/dist/types/three-way-merge.d.ts +0 -77
  212. package/dist/types/working-tree-mirror.d.ts +0 -424
  213. package/dist/types/workspace-automatic-sync-policy.d.ts +0 -57
  214. package/dist/types/workspace-branch-incarnation-policy.d.ts +0 -14
  215. package/dist/types/workspace-command-sync-policy.d.ts +0 -57
  216. package/dist/types/workspace-command-targets.d.ts +0 -37
  217. package/dist/types/workspace-filesystem-executor-thread.d.ts +0 -1
  218. package/dist/types/workspace-filesystem-executor.d.ts +0 -123
  219. package/dist/types/workspace-filesystem-job-types.d.ts +0 -302
  220. package/dist/types/workspace-filesystem-jobs.d.ts +0 -7
  221. package/dist/types/workspace-git-sync.d.ts +0 -514
  222. package/dist/types/workspace-hydration-ledger.d.ts +0 -76
  223. package/dist/types/workspace-hydration-merge.d.ts +0 -103
  224. package/dist/types/workspace-hydration-recovery-state.d.ts +0 -10
  225. package/dist/types/workspace-incident-state.d.ts +0 -19
  226. package/dist/types/workspace-merge-projection.d.ts +0 -69
  227. package/dist/types/workspace-mount-boundary.d.ts +0 -10
  228. package/dist/types/workspace-mount-hold-fence.d.ts +0 -42
  229. package/dist/types/workspace-mutation-gate.d.ts +0 -42
  230. package/dist/types/workspace-path-move.d.ts +0 -21
  231. package/dist/types/workspace-preserve-only-policy.d.ts +0 -15
  232. package/dist/types/workspace-project-config-policy.d.ts +0 -48
  233. package/dist/types/workspace-projection-ledger.d.ts +0 -59
  234. package/dist/types/workspace-publication-evidence.d.ts +0 -17
  235. package/dist/types/workspace-sync-coalescer.d.ts +0 -28
  236. /package/dist/types/{credential-authority-lock-fixture.d.ts → runtime/releases/main.d.ts} +0 -0
@@ -1,123 +0,0 @@
1
- import { type WorkspaceFilesystemJobInput, type WorkspaceFilesystemJobKind, type WorkspaceFilesystemJobProgress, type WorkspaceFilesystemJobResult } from "./workspace-filesystem-job-types";
2
- /**
3
- * Bounded executor for the worker's workspace filesystem transactions.
4
- *
5
- * One thread runs one job at a time; the control thread only ever awaits.
6
- * The point is the incident this was written for: a single `pread64` or
7
- * `pwrite64` blocked in the kernel on a stalled network disk used to freeze
8
- * the worker's only event loop for minutes, so no heartbeat, cancel or Stop
9
- * could run. On the executor thread that same blocked syscall stalls exactly
10
- * one job while the control thread keeps serving the socket.
11
- *
12
- * A thread rather than a helper process because a thread cannot outlive the
13
- * process: when the worker dies, its in-flight syscall completes and nothing
14
- * else is written afterwards, which is the crash model every recovery path
15
- * already handles. Nothing is ever abandoned: a running job's promise settles
16
- * only with the thread's reply or the thread's exit, so the gate its caller
17
- * holds is held for the job's true duration. Only jobs that have not started
18
- * can fail on the queue-wait bound.
19
- *
20
- * A thread that exits while a job is running leaves an unknown partial
21
- * mutation behind. The executor then fails closed: the job and everything
22
- * queued fail, no further job is accepted, and `onFailure` lets the worker
23
- * take its established restart path, whose startup recovery (manifests,
24
- * receipts, snapshot recovery) runs before any ordinary mutation. No
25
- * replacement thread is started over that state in this process.
26
- */
27
- export declare const WORKSPACE_FILESYSTEM_EXECUTOR_MAX_QUEUED = 32;
28
- export declare const WORKSPACE_FILESYSTEM_EXECUTOR_QUEUE_TIMEOUT_MS: number;
29
- export declare const WORKSPACE_FILESYSTEM_EXECUTOR_STALL_LOG_INTERVAL_MS = 30000;
30
- export declare class WorkspaceFilesystemExecutorError extends Error {
31
- readonly name = "WorkspaceFilesystemExecutorError";
32
- }
33
- /** The executor thread exited (crashed or was terminated) while a job was running. */
34
- export declare class WorkspaceFilesystemExecutorThreadExitedError extends WorkspaceFilesystemExecutorError {
35
- readonly exitCode: number | null;
36
- readonly description: string;
37
- constructor(exitCode: number | null, description: string, cause?: unknown);
38
- }
39
- export type WorkspaceFilesystemExecutorStatus = {
40
- running: {
41
- kind: WorkspaceFilesystemJobKind;
42
- description: string;
43
- startedAtMs: number;
44
- ageMs: number;
45
- } | null;
46
- queued: number;
47
- /** Set once the thread exited under a running job; every job is then rejected until the worker restarts. */
48
- failed: string | null;
49
- };
50
- export type WorkspaceFilesystemExecutorOptions = {
51
- /** Module the thread executes; must resolve next to the packaged executor module. */
52
- threadModulePath: string;
53
- log?: (line: string) => void;
54
- now?: () => number;
55
- maxQueued?: number;
56
- queueTimeoutMs?: number;
57
- stallLogIntervalMs?: number;
58
- };
59
- export declare class WorkspaceFilesystemExecutor {
60
- private readonly threadModulePath;
61
- private readonly log;
62
- private readonly now;
63
- private readonly maxQueued;
64
- private readonly queueTimeoutMs;
65
- private readonly stallLogIntervalMs;
66
- private worker;
67
- private readonly queue;
68
- private running;
69
- private nextJobId;
70
- private failed;
71
- private closed;
72
- /** Invoked once when the executor fails closed (thread exit under a running job). */
73
- onFailure: ((error: WorkspaceFilesystemExecutorThreadExitedError) => void) | undefined;
74
- constructor(options: WorkspaceFilesystemExecutorOptions);
75
- /**
76
- * Run one job to completion on the executor thread. Resolves with the
77
- * job's result; rejects with the job's own error (properties preserved),
78
- * with a queue-wait or capacity error when the job never started, or with
79
- * WorkspaceFilesystemExecutorThreadExitedError when the thread died under it.
80
- */
81
- run<K extends WorkspaceFilesystemJobKind>(kind: K, input: WorkspaceFilesystemJobInput<K>, options?: {
82
- onProgress?: (progress: WorkspaceFilesystemJobProgress) => void;
83
- }): Promise<WorkspaceFilesystemJobResult<K>>;
84
- status(): WorkspaceFilesystemExecutorStatus;
85
- /**
86
- * Stop accepting jobs, fail everything still queued and ask the thread to
87
- * stop. A running job settles when the thread actually exits; a thread
88
- * blocked in the kernel only exits with the process, which is the point.
89
- */
90
- close(): void;
91
- private describeRunning;
92
- private expireQueued;
93
- private dispatch;
94
- private settleRunning;
95
- private ensureWorker;
96
- private lastThreadError;
97
- private onReply;
98
- private onExit;
99
- }
100
- /** The packaged thread module lives next to this module with the same extension (.ts in source, .cjs/.mjs in the package). */
101
- export declare function workspaceFilesystemExecutorThreadModulePath(): string;
102
- /** What the engine modules dispatch through; the thread executor in production. */
103
- export type WorkspaceFilesystemJobRunner = Pick<WorkspaceFilesystemExecutor, "run">;
104
- /**
105
- * The worker process's executor. Like the workspace mutation gate it is
106
- * process-global: in-process reconnects share it, so a job started by a
107
- * previous connection generation is still the one running when the next
108
- * generation's configuration queues behind it.
109
- */
110
- export declare function workspaceFilesystemExecutor(): WorkspaceFilesystemJobRunner;
111
- /** The worker runtime's fail-closed hook: installed once on the process executor (created if needed). */
112
- export declare function installWorkspaceFilesystemExecutorFailureHandler(handler: (error: WorkspaceFilesystemExecutorThreadExitedError) => void): void;
113
- /**
114
- * Test seam. Engine tests that inject faults or count syscalls by replacing
115
- * `node:fs` functions in their own thread cannot observe a body running on
116
- * the executor thread; inside `runJobsInline` the same operation table runs
117
- * on the calling thread instead. The boundary itself is tested with the real
118
- * thread in workspace-filesystem-executor.test.ts. Never used in production.
119
- */
120
- export declare const workspaceFilesystemExecutorTestHarness: {
121
- runJobsInline<T>(body: () => Promise<T>): Promise<T>;
122
- processExecutor(): WorkspaceFilesystemExecutor | null;
123
- };
@@ -1,302 +0,0 @@
1
- import type { ProjectWorktreeBranch, ProjectWorktreeSnapshot, ProjectWorktreeSnapshotProgress, ProjectWorktreeSnapshotScope, ProjectWorktreeWorkingTreeMode } from "./project-worktrees";
2
- import type { ProjectedWorkingTreeEntry, WorkingTreeGitlink } from "./working-tree-mirror";
3
- import type { WorkspaceHydrationLedgerEntry } from "./workspace-hydration-ledger";
4
- import type { WorkspaceGitMountData, WorkspaceHydrationReceipt, WorkspaceHydrationRecoveryRequired, WorkspaceHydrationPreservationResult, WorkspaceHydrationMountSkip } from "./workspace-git-sync";
5
- import type { WorkspaceHydrationMergeBasis } from "./workspace-hydration-merge";
6
- import type { WorkspaceMergeProjectionMount, WorkspaceMergeProjectionResult } from "./workspace-merge-projection";
7
- import type { ProjectCheckoutPathMoveBranch } from "./workspace-path-move";
8
- /**
9
- * The closed set of filesystem transactions the worker runs on its executor
10
- * thread. Every input is plain data (paths, mount descriptors, receipts); the
11
- * busy predicates, mutation tokens, hooks and gates that decide *whether* a
12
- * job may run stay on the control thread. Every body is the synchronous code
13
- * that used to run on the control thread, unchanged in its write and fsync
14
- * ordering. A job kind outside this table is rejected by both threads.
15
- */
16
- export type WorkspaceFilesystemJobTable = {
17
- /** `recoverWorkspaceCheckoutDurability`: rebuild an interrupted outer checkout boundary. */
18
- checkout_durability_recovery: {
19
- input: {
20
- workspacePath: string;
21
- preserveResolutionInProgress: boolean;
22
- };
23
- result: null;
24
- };
25
- /** Checkout durability recovery, pending hydration transaction restore/completion, basis-ref repair. */
26
- hydration_recovery: {
27
- input: {
28
- workspacePath: string;
29
- preserveResolutionInProgress: boolean;
30
- };
31
- result: null;
32
- };
33
- /** Read-only pending guarded transaction evidence for configuration admission. */
34
- hydration_recovery_inspect: {
35
- input: {
36
- workspacePath: string;
37
- };
38
- result: WorkspaceHydrationRecoveryRequired | null;
39
- };
40
- /** Explicit exact-identity recovery: preserve visible data and archive all interrupted guarded transaction evidence. */
41
- hydration_preserve_interrupted: {
42
- input: {
43
- workspacePath: string;
44
- expectedTransactionId: string;
45
- };
46
- result: WorkspaceHydrationPreservationResult;
47
- };
48
- /**
49
- * The complete hydration transaction: snapshot, hydrate, fsync, commit
50
- * marker, receipt; restore on failure. A mount listed in `mergeBases` is
51
- * merge-hydrated (docs/merge-hydration-design.md): files changed in the
52
- * checkout since the projection read are three-way merged instead of
53
- * overwritten, and a conflict or a write racing the hydration pins the
54
- * mount at its previous receipt entry (`skippedMounts`) instead of
55
- * failing the transaction.
56
- */
57
- hydration_transaction: {
58
- input: {
59
- workspacePath: string;
60
- hydrationMounts: WorkspaceGitMountData[];
61
- advancedDurabilityMounts: WorkspaceGitMountData[];
62
- targetReceipt: WorkspaceHydrationReceipt | null;
63
- mergeBases?: Record<string, WorkspaceHydrationMergeBasis>;
64
- };
65
- result: {
66
- hydratedMountIds: string[];
67
- skippedMounts: WorkspaceHydrationMountSkip[];
68
- /**
69
- * Per merge-hydrated mount, what hydration replaced at each path: the
70
- * previous and written blobs and the `lstat` it left behind (the
71
- * hydration ledger's record, minus the process-liveness flag the
72
- * control thread adds).
73
- */
74
- hydratedEntries: Record<string, Record<string, Omit<WorkspaceHydrationLedgerEntry, "processLiveAcrossHydration">>>;
75
- };
76
- };
77
- /** Pre-clone hydration of visible mounts without a transaction (no outer Git directory yet). */
78
- hydration_raw: {
79
- input: {
80
- workspacePath: string;
81
- mounts: WorkspaceGitMountData[];
82
- };
83
- result: {
84
- hydratedMountIds: string[];
85
- };
86
- };
87
- /** Recover the durable checkout boundary and record the transition that follows. */
88
- checkout_transition_begin: {
89
- input: {
90
- workspacePath: string;
91
- };
92
- result: null;
93
- };
94
- /** Make the outer checkout durable and record its head as the durable boundary. */
95
- checkout_transition_complete: {
96
- input: {
97
- workspacePath: string;
98
- };
99
- result: null;
100
- };
101
- /** Durability barrier over the outer checkout tree without changing the record. */
102
- outer_checkout_fsync: {
103
- input: {
104
- workspacePath: string;
105
- };
106
- result: null;
107
- };
108
- /** Three-way merge projection of one stale mount (ours snapshot + merge-tree). */
109
- projection_merge: {
110
- input: {
111
- workspacePath: string;
112
- mount: WorkspaceMergeProjectionMount;
113
- basisHead: string;
114
- currentHead: string;
115
- attemptId: string;
116
- /** What the last merge hydration replaced, by mount-relative path (see WorkspaceHydrationLedger). */
117
- hydrationLedger?: Record<string, WorkspaceHydrationLedgerEntry>;
118
- };
119
- result: WorkspaceMergeProjectionResult;
120
- };
121
- /**
122
- * Byte mirror of one visible mount into the outer checkout. Returns what it
123
- * read for every file (merge hydration's stat basis), or the paths that
124
- * hold a stale rewrite, in which case nothing was mirrored.
125
- */
126
- projection_mirror: {
127
- input: {
128
- workspacePath: string;
129
- mount: WorkspaceGitMountData;
130
- hydrationLedger?: Record<string, WorkspaceHydrationLedgerEntry>;
131
- /** Stop after the ledger pass; mirror nothing. */
132
- checkOnly?: boolean;
133
- };
134
- result: {
135
- gitlinks: WorkingTreeGitlink[];
136
- projectedFiles: Record<string, ProjectedWorkingTreeEntry>;
137
- /** Wall-clock time the mirror finished reading; projected stats younger than this minus a window are not trusted. */
138
- readAtMs: number;
139
- staleRewritePaths: string[];
140
- /**
141
- * Ledger paths a process alive across their hydration rewrote: nothing
142
- * was mirrored, and the mount must be projected through the merge path
143
- * with those paths merged against what the process read.
144
- */
145
- ledgerMergePaths: string[];
146
- /** Ledger paths whose checkout content moved on from both the replaced and the hydrated bytes. */
147
- staleRewriteCleared: string[];
148
- };
149
- };
150
- /** Outer-tree edits after the mirrors: tombstone removal, merged subtree materialization, deferred restores. */
151
- projection_outer_apply: {
152
- input: {
153
- workspacePath: string;
154
- removeMounts: WorkspaceGitMountData[];
155
- materialize: Array<{
156
- workspaceRelativePath: string;
157
- resultTree: string;
158
- }>;
159
- restoreFromHead: WorkspaceGitMountData[];
160
- };
161
- result: null;
162
- };
163
- /** Persist projected visible mounts and publish the projection receipt. */
164
- projection_receipt: {
165
- input: {
166
- workspacePath: string;
167
- fsyncMounts: WorkspaceGitMountData[];
168
- receipt: WorkspaceHydrationReceipt;
169
- };
170
- result: null;
171
- };
172
- /** `snapshotBranchTrees`: copy every checkout a reconciliation may rewrite. */
173
- project_snapshot_create: {
174
- input: {
175
- projectRoot: string;
176
- branches: ProjectWorktreeBranch[];
177
- temporaryRoot: string;
178
- scope: ProjectWorktreeSnapshotScope;
179
- ownerSessionId: string;
180
- };
181
- result: ProjectWorktreeSnapshot;
182
- };
183
- /** Mirror captured checkouts back over the reconciled worktrees. */
184
- project_snapshot_apply: {
185
- input: {
186
- mirrors: Array<{
187
- snapshotPath: string;
188
- targetPath: string;
189
- }>;
190
- };
191
- result: null;
192
- };
193
- /** `persistReconciledProjectAndConsumeSnapshot`. */
194
- project_snapshot_persist: {
195
- input: {
196
- snapshot: ProjectWorktreeSnapshot;
197
- durabilityPaths: string[] | null;
198
- };
199
- result: null;
200
- };
201
- /** `rollbackProjectWorktreeSnapshot`. */
202
- project_snapshot_rollback: {
203
- input: {
204
- snapshot: ProjectWorktreeSnapshot;
205
- };
206
- result: null;
207
- };
208
- /** `recoverStaleProjectWorktreeSnapshots` at startup. */
209
- project_snapshots_recover: {
210
- input: {
211
- projectsRoot: string;
212
- temporaryRoot: string;
213
- currentProcessId: number;
214
- currentOwnerSessionId: string;
215
- };
216
- result: {
217
- restored: string[];
218
- removed: string[];
219
- failed: Array<{
220
- path: string;
221
- error: string;
222
- }>;
223
- };
224
- };
225
- /** `createLinkedProjectBranch`: branch ref, linked worktree, index seed and working-tree copy. */
226
- project_branch_create: {
227
- input: {
228
- projectRoot: string;
229
- sourceBranchName: string;
230
- branchName: string;
231
- workingTree: ProjectWorktreeWorkingTreeMode;
232
- };
233
- result: {
234
- branchPath: string;
235
- baseCommitHash: string;
236
- };
237
- };
238
- /** `preserveProjectCheckoutPathMove`. */
239
- project_checkout_path_move: {
240
- input: {
241
- oldProjectRoot: string;
242
- newProjectRoot: string;
243
- projectsDurabilityRoot: string;
244
- outerWorkspaceRoot: string;
245
- branches: ProjectCheckoutPathMoveBranch[];
246
- };
247
- result: {
248
- preservedBranchNames: string[];
249
- };
250
- };
251
- };
252
- export type WorkspaceFilesystemJobKind = keyof WorkspaceFilesystemJobTable;
253
- export type WorkspaceFilesystemJobInput<K extends WorkspaceFilesystemJobKind> = WorkspaceFilesystemJobTable[K]["input"];
254
- export type WorkspaceFilesystemJobResult<K extends WorkspaceFilesystemJobKind> = WorkspaceFilesystemJobTable[K]["result"];
255
- export type WorkspaceFilesystemJobProgress = ProjectWorktreeSnapshotProgress;
256
- export type WorkspaceFilesystemJobContext = {
257
- progress: (progress: WorkspaceFilesystemJobProgress) => void;
258
- };
259
- export type WorkspaceFilesystemJobOperations = {
260
- [K in WorkspaceFilesystemJobKind]: (input: WorkspaceFilesystemJobInput<K>, context: WorkspaceFilesystemJobContext) => WorkspaceFilesystemJobResult<K>;
261
- };
262
- export declare const WORKSPACE_FILESYSTEM_JOB_KINDS: readonly WorkspaceFilesystemJobKind[];
263
- export declare function isWorkspaceFilesystemJobKind(value: unknown): value is WorkspaceFilesystemJobKind;
264
- /** Short, path-bearing description used in stall diagnostics and errors. */
265
- export declare function describeWorkspaceFilesystemJob<K extends WorkspaceFilesystemJobKind>(kind: K, input: WorkspaceFilesystemJobInput<K>): string;
266
- /** Errors cross the thread boundary as data; the properties callers inspect are preserved. */
267
- export type WorkspaceFilesystemSerializedError = {
268
- name: string;
269
- message: string;
270
- stack?: string;
271
- code?: string;
272
- branchMayExist?: true;
273
- cleanupFailures?: string[];
274
- hydrationRecovery?: WorkspaceHydrationRecoveryRequired;
275
- errors?: WorkspaceFilesystemSerializedError[];
276
- cause?: WorkspaceFilesystemSerializedError;
277
- };
278
- export declare function serializeWorkspaceFilesystemError(error: unknown, depth?: number): WorkspaceFilesystemSerializedError;
279
- export declare function restoreWorkspaceFilesystemError(serialized: WorkspaceFilesystemSerializedError): Error;
280
- /** Control thread → executor thread. */
281
- export type WorkspaceFilesystemThreadRequest = {
282
- type: "run";
283
- id: number;
284
- kind: WorkspaceFilesystemJobKind;
285
- input: unknown;
286
- /** The control thread's environment at dispatch; the thread runs the job under exactly this. */
287
- environment: Record<string, string>;
288
- };
289
- /** Executor thread → control thread. */
290
- export type WorkspaceFilesystemThreadReply = {
291
- type: "progress";
292
- id: number;
293
- progress: WorkspaceFilesystemJobProgress;
294
- } | {
295
- type: "result";
296
- id: number;
297
- result: unknown;
298
- } | {
299
- type: "failure";
300
- id: number;
301
- error: WorkspaceFilesystemSerializedError;
302
- };
@@ -1,7 +0,0 @@
1
- import type { WorkspaceFilesystemJobOperations } from "./workspace-filesystem-job-types";
2
- /**
3
- * The operation table of the workspace filesystem executor thread. It is the
4
- * only thing the thread can run; every entry is an existing synchronous
5
- * transaction body. Imported by the thread entry module only.
6
- */
7
- export declare const workspaceFilesystemJobOperations: WorkspaceFilesystemJobOperations;