@ricsam/r5d-worker 0.0.136 → 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 (240) hide show
  1. package/README.md +4 -94
  2. package/dist/cjs/package.json +1 -1
  3. package/dist/mjs/main.mjs +46 -7537
  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 +17 -0
  41. package/dist/types/runtime/daemon.d.ts +8 -0
  42. package/dist/types/runtime/executor.d.ts +35 -0
  43. package/dist/types/runtime/index.d.ts +5 -0
  44. package/dist/types/runtime/protocol.d.ts +544 -0
  45. package/dist/types/runtime/pty.d.ts +30 -0
  46. package/dist/types/runtime/releases/artifacts.d.ts +51 -0
  47. package/dist/types/runtime/releases/grants.d.ts +16 -0
  48. package/dist/types/runtime/releases/manager.d.ts +145 -0
  49. package/dist/types/runtime/releases/process.d.ts +14 -0
  50. package/dist/types/runtime/releases/retirement.d.ts +15 -0
  51. package/dist/types/runtime/releases/rpc-client.d.ts +52 -0
  52. package/dist/types/runtime/releases/rpc-main.d.ts +10 -0
  53. package/dist/types/runtime/releases/rpc-protocol.d.ts +1139 -0
  54. package/dist/types/runtime/storage.d.ts +21 -0
  55. package/dist/types/runtime/test-harness.d.ts +53 -0
  56. package/dist/types/runtime/workspace/artifacts.d.ts +30 -0
  57. package/dist/types/runtime/workspace/authority.d.ts +338 -0
  58. package/dist/types/runtime/workspace/contracts.d.ts +86 -0
  59. package/dist/types/runtime/workspace/file-write.d.ts +14 -0
  60. package/dist/types/runtime/workspace/files.d.ts +21 -0
  61. package/dist/types/runtime/workspace/http-body.d.ts +9 -0
  62. package/dist/types/runtime/workspace/storage-client.d.ts +23 -0
  63. package/dist/types/runtime/workspace/storage-wire.d.ts +138 -0
  64. package/package.json +8 -6
  65. package/dist/cjs/atomic-rename.cjs +0 -303
  66. package/dist/cjs/browser-upload.cjs +0 -73
  67. package/dist/cjs/cli-update.cjs +0 -108
  68. package/dist/cjs/command-launcher.cjs +0 -423
  69. package/dist/cjs/control-command-policy.cjs +0 -177
  70. package/dist/cjs/git-blob-hash.cjs +0 -41
  71. package/dist/cjs/git-identity.cjs +0 -39
  72. package/dist/cjs/git-process-environment.cjs +0 -133
  73. package/dist/cjs/inline-output.cjs +0 -62
  74. package/dist/cjs/main.cjs +0 -7511
  75. package/dist/cjs/managed-paths.cjs +0 -215
  76. package/dist/cjs/plan-lint.cjs +0 -165
  77. package/dist/cjs/plan-parser.cjs +0 -127
  78. package/dist/cjs/plan-paths.cjs +0 -53
  79. package/dist/cjs/port-forward-client.cjs +0 -206
  80. package/dist/cjs/process-tree.cjs +0 -117
  81. package/dist/cjs/project-checkout-garbage.cjs +0 -219
  82. package/dist/cjs/project-mirror-fetch-policy.cjs +0 -82
  83. package/dist/cjs/project-mirror-refs-token.cjs +0 -85
  84. package/dist/cjs/project-workspace-state.cjs +0 -972
  85. package/dist/cjs/project-worktrees.cjs +0 -1713
  86. package/dist/cjs/pty-output-coalescer.cjs +0 -87
  87. package/dist/cjs/recovery-journal-protocol.cjs +0 -56
  88. package/dist/cjs/recovery-journal-runtime.cjs +0 -133
  89. package/dist/cjs/recovery-journal-thread.cjs +0 -9
  90. package/dist/cjs/recovery-journal.cjs +0 -742
  91. package/dist/cjs/recovery-output-window.cjs +0 -77
  92. package/dist/cjs/recovery-protocol.cjs +0 -31
  93. package/dist/cjs/recovery-store.cjs +0 -252
  94. package/dist/cjs/registry-auth.cjs +0 -310
  95. package/dist/cjs/repository-transition-policy.cjs +0 -49
  96. package/dist/cjs/runtime-version.cjs +0 -88
  97. package/dist/cjs/session-file-mutations.cjs +0 -61
  98. package/dist/cjs/supervisor.cjs +0 -147
  99. package/dist/cjs/three-way-merge.cjs +0 -346
  100. package/dist/cjs/working-tree-mirror.cjs +0 -1872
  101. package/dist/cjs/workspace-automatic-sync-policy.cjs +0 -79
  102. package/dist/cjs/workspace-branch-incarnation-policy.cjs +0 -37
  103. package/dist/cjs/workspace-command-sync-policy.cjs +0 -112
  104. package/dist/cjs/workspace-command-targets.cjs +0 -63
  105. package/dist/cjs/workspace-filesystem-executor-thread.cjs +0 -36
  106. package/dist/cjs/workspace-filesystem-executor.cjs +0 -327
  107. package/dist/cjs/workspace-filesystem-job-types.cjs +0 -144
  108. package/dist/cjs/workspace-filesystem-jobs.cjs +0 -59
  109. package/dist/cjs/workspace-git-sync.cjs +0 -3450
  110. package/dist/cjs/workspace-hydration-ledger.cjs +0 -66
  111. package/dist/cjs/workspace-hydration-merge.cjs +0 -433
  112. package/dist/cjs/workspace-hydration-recovery-state.cjs +0 -53
  113. package/dist/cjs/workspace-incident-state.cjs +0 -37
  114. package/dist/cjs/workspace-merge-projection.cjs +0 -467
  115. package/dist/cjs/workspace-mount-boundary.cjs +0 -71
  116. package/dist/cjs/workspace-mount-hold-fence.cjs +0 -120
  117. package/dist/cjs/workspace-mutation-gate.cjs +0 -127
  118. package/dist/cjs/workspace-path-move.cjs +0 -195
  119. package/dist/cjs/workspace-preserve-only-policy.cjs +0 -36
  120. package/dist/cjs/workspace-project-config-policy.cjs +0 -53
  121. package/dist/cjs/workspace-projection-ledger.cjs +0 -81
  122. package/dist/cjs/workspace-publication-evidence.cjs +0 -46
  123. package/dist/cjs/workspace-sync-coalescer.cjs +0 -58
  124. package/dist/mjs/atomic-rename.mjs +0 -261
  125. package/dist/mjs/browser-upload.mjs +0 -42
  126. package/dist/mjs/command-launcher.mjs +0 -393
  127. package/dist/mjs/control-command-policy.mjs +0 -146
  128. package/dist/mjs/git-blob-hash.mjs +0 -16
  129. package/dist/mjs/git-identity.mjs +0 -15
  130. package/dist/mjs/git-process-environment.mjs +0 -105
  131. package/dist/mjs/inline-output.mjs +0 -37
  132. package/dist/mjs/managed-paths.mjs +0 -174
  133. package/dist/mjs/plan-lint.mjs +0 -129
  134. package/dist/mjs/plan-parser.mjs +0 -94
  135. package/dist/mjs/plan-paths.mjs +0 -25
  136. package/dist/mjs/port-forward-client.mjs +0 -172
  137. package/dist/mjs/project-checkout-garbage.mjs +0 -178
  138. package/dist/mjs/project-mirror-fetch-policy.mjs +0 -56
  139. package/dist/mjs/project-mirror-refs-token.mjs +0 -53
  140. package/dist/mjs/project-workspace-state.mjs +0 -937
  141. package/dist/mjs/project-worktrees.mjs +0 -1657
  142. package/dist/mjs/pty-output-coalescer.mjs +0 -61
  143. package/dist/mjs/recovery-journal-protocol.mjs +0 -30
  144. package/dist/mjs/recovery-journal-runtime.mjs +0 -112
  145. package/dist/mjs/recovery-journal-thread.mjs +0 -8
  146. package/dist/mjs/recovery-journal.mjs +0 -694
  147. package/dist/mjs/recovery-output-window.mjs +0 -53
  148. package/dist/mjs/recovery-protocol.mjs +0 -6
  149. package/dist/mjs/recovery-store.mjs +0 -217
  150. package/dist/mjs/registry-auth.mjs +0 -269
  151. package/dist/mjs/repository-transition-policy.mjs +0 -22
  152. package/dist/mjs/runtime-version.mjs +0 -54
  153. package/dist/mjs/session-file-mutations.mjs +0 -37
  154. package/dist/mjs/supervisor.mjs +0 -114
  155. package/dist/mjs/three-way-merge.mjs +0 -318
  156. package/dist/mjs/working-tree-mirror.mjs +0 -1817
  157. package/dist/mjs/workspace-automatic-sync-policy.mjs +0 -48
  158. package/dist/mjs/workspace-branch-incarnation-policy.mjs +0 -13
  159. package/dist/mjs/workspace-command-sync-policy.mjs +0 -84
  160. package/dist/mjs/workspace-command-targets.mjs +0 -37
  161. package/dist/mjs/workspace-filesystem-executor-thread.mjs +0 -38
  162. package/dist/mjs/workspace-filesystem-executor.mjs +0 -287
  163. package/dist/mjs/workspace-filesystem-job-types.mjs +0 -116
  164. package/dist/mjs/workspace-filesystem-jobs.mjs +0 -55
  165. package/dist/mjs/workspace-git-sync.mjs +0 -3407
  166. package/dist/mjs/workspace-hydration-ledger.mjs +0 -42
  167. package/dist/mjs/workspace-hydration-merge.mjs +0 -399
  168. package/dist/mjs/workspace-hydration-recovery-state.mjs +0 -29
  169. package/dist/mjs/workspace-incident-state.mjs +0 -12
  170. package/dist/mjs/workspace-merge-projection.mjs +0 -433
  171. package/dist/mjs/workspace-mount-boundary.mjs +0 -37
  172. package/dist/mjs/workspace-mount-hold-fence.mjs +0 -95
  173. package/dist/mjs/workspace-mutation-gate.mjs +0 -103
  174. package/dist/mjs/workspace-path-move.mjs +0 -160
  175. package/dist/mjs/workspace-preserve-only-policy.mjs +0 -11
  176. package/dist/mjs/workspace-project-config-policy.mjs +0 -27
  177. package/dist/mjs/workspace-projection-ledger.mjs +0 -57
  178. package/dist/mjs/workspace-publication-evidence.mjs +0 -21
  179. package/dist/mjs/workspace-sync-coalescer.mjs +0 -34
  180. package/dist/types/atomic-rename.d.ts +0 -78
  181. package/dist/types/browser-upload.d.ts +0 -7
  182. package/dist/types/command-launcher.d.ts +0 -104
  183. package/dist/types/control-command-policy.d.ts +0 -53
  184. package/dist/types/git-blob-hash.d.ts +0 -10
  185. package/dist/types/git-identity.d.ts +0 -9
  186. package/dist/types/git-process-environment.d.ts +0 -9
  187. package/dist/types/inline-output.d.ts +0 -3
  188. package/dist/types/managed-paths.d.ts +0 -19
  189. package/dist/types/plan-lint.d.ts +0 -16
  190. package/dist/types/plan-parser.d.ts +0 -38
  191. package/dist/types/plan-paths.d.ts +0 -36
  192. package/dist/types/port-forward-client.d.ts +0 -8
  193. package/dist/types/project-checkout-garbage.d.ts +0 -86
  194. package/dist/types/project-mirror-fetch-policy.d.ts +0 -84
  195. package/dist/types/project-mirror-refs-token.d.ts +0 -53
  196. package/dist/types/project-workspace-state.d.ts +0 -188
  197. package/dist/types/project-worktrees.d.ts +0 -397
  198. package/dist/types/pty-output-coalescer.d.ts +0 -20
  199. package/dist/types/recovery-journal-protocol.d.ts +0 -35
  200. package/dist/types/recovery-journal-runtime.d.ts +0 -12
  201. package/dist/types/recovery-journal-thread.d.ts +0 -1
  202. package/dist/types/recovery-journal.d.ts +0 -248
  203. package/dist/types/recovery-output-window.d.ts +0 -19
  204. package/dist/types/recovery-protocol.d.ts +0 -59
  205. package/dist/types/recovery-store.d.ts +0 -52
  206. package/dist/types/registry-auth.d.ts +0 -47
  207. package/dist/types/repository-transition-policy.d.ts +0 -26
  208. package/dist/types/runtime-version.d.ts +0 -1
  209. package/dist/types/session-file-mutations.d.ts +0 -22
  210. package/dist/types/supervisor-daemonized-fixture.d.ts +0 -1
  211. package/dist/types/supervisor-launcher-cleanup-fixture.d.ts +0 -1
  212. package/dist/types/supervisor-signal-fixture.d.ts +0 -1
  213. package/dist/types/supervisor.d.ts +0 -23
  214. package/dist/types/three-way-merge.d.ts +0 -77
  215. package/dist/types/working-tree-mirror.d.ts +0 -424
  216. package/dist/types/workspace-automatic-sync-policy.d.ts +0 -57
  217. package/dist/types/workspace-branch-incarnation-policy.d.ts +0 -14
  218. package/dist/types/workspace-command-sync-policy.d.ts +0 -57
  219. package/dist/types/workspace-command-targets.d.ts +0 -37
  220. package/dist/types/workspace-filesystem-executor-thread.d.ts +0 -1
  221. package/dist/types/workspace-filesystem-executor.d.ts +0 -123
  222. package/dist/types/workspace-filesystem-job-types.d.ts +0 -288
  223. package/dist/types/workspace-filesystem-jobs.d.ts +0 -7
  224. package/dist/types/workspace-git-sync.d.ts +0 -495
  225. package/dist/types/workspace-hydration-ledger.d.ts +0 -43
  226. package/dist/types/workspace-hydration-merge.d.ts +0 -95
  227. package/dist/types/workspace-hydration-recovery-state.d.ts +0 -10
  228. package/dist/types/workspace-incident-state.d.ts +0 -19
  229. package/dist/types/workspace-merge-projection.d.ts +0 -60
  230. package/dist/types/workspace-mount-boundary.d.ts +0 -10
  231. package/dist/types/workspace-mount-hold-fence.d.ts +0 -42
  232. package/dist/types/workspace-mutation-gate.d.ts +0 -42
  233. package/dist/types/workspace-path-move.d.ts +0 -21
  234. package/dist/types/workspace-preserve-only-policy.d.ts +0 -15
  235. package/dist/types/workspace-project-config-policy.d.ts +0 -48
  236. package/dist/types/workspace-projection-ledger.d.ts +0 -59
  237. package/dist/types/workspace-publication-evidence.d.ts +0 -17
  238. package/dist/types/workspace-sync-coalescer.d.ts +0 -28
  239. /package/dist/types/{credential-authority-lock-fixture.d.ts → runtime/adapter.d.ts} +0 -0
  240. /package/dist/types/{recovery-journal-stall-fixture.d.ts → runtime/releases/main.d.ts} +0 -0
@@ -1,397 +0,0 @@
1
- import { type ProjectMirrorMount, type ProjectMirrorRefsTokens } from "./project-mirror-refs-token";
2
- import type { WorkspaceFilesystemJobContext } from "./workspace-filesystem-job-types";
3
- export declare const PROJECT_WORKTREE_SNAPSHOT_PREFIX = "r5d-project-worktrees-";
4
- declare const PROJECT_WORKTREE_SNAPSHOT_MANIFEST_VERSION: 1;
5
- /**
6
- * Distinguishes this control thread's live snapshots from stale ones left by
7
- * an earlier process that reused the PID. The control thread passes it to
8
- * every snapshot job, so the executor thread never invents its own.
9
- */
10
- export declare const PROJECT_WORKTREE_SNAPSHOT_OWNER_SESSION_ID: `${string}-${string}-${string}-${string}-${string}`;
11
- /**
12
- * `project` snapshots cover every configured branch and restore by replacing
13
- * the whole project root. `branches` snapshots cover only the checkouts one
14
- * reconciliation rewrites and restore those paths individually, so a rollback
15
- * never touches a checkout the transaction did not.
16
- */
17
- export type ProjectWorktreeSnapshotScope = "project" | "branches";
18
- export type ProjectWorktreeSnapshotManifest = {
19
- version: typeof PROJECT_WORKTREE_SNAPSHOT_MANIFEST_VERSION;
20
- state: "building" | "prepared" | "restoring" | "consumed";
21
- scope: ProjectWorktreeSnapshotScope;
22
- ownerProcessId: number;
23
- ownerSessionId: string;
24
- projectRoot: string;
25
- branches: Array<{
26
- branchName: string;
27
- snapshotPresent: boolean;
28
- }>;
29
- createdAt: string;
30
- };
31
- export type ProjectWorktreeSnapshot = {
32
- root: string;
33
- manifest: ProjectWorktreeSnapshotManifest;
34
- paths: Map<string, string>;
35
- };
36
- export type ProjectWorktreeSnapshotProgress = {
37
- operation: "snapshot" | "restore";
38
- phase: "scanning" | "copying" | "moving" | "syncing" | "cleaning";
39
- projectRoot: string;
40
- branchName?: string;
41
- completedBranches: number;
42
- totalBranches: number;
43
- completedBytes: number;
44
- totalBytes?: number;
45
- };
46
- export type ProjectWorktreeBranch = {
47
- branchId?: string;
48
- branchName: string;
49
- baseCommitHash: string;
50
- sourceBranchName?: string | null;
51
- };
52
- export type ProjectWorktreeState = {
53
- branchName: string;
54
- branchPath: string;
55
- head: string;
56
- mirrorHead: string | null;
57
- ahead: number | null;
58
- behind: number | null;
59
- };
60
- /**
61
- * Creation failed after its branch ref may have been written, and rollback
62
- * could not prove that every local artifact was removed. Callers must retain
63
- * their durable creation intent so a later cleanup can recover it.
64
- */
65
- export declare class ProjectBranchCreationRollbackIncompleteError extends Error {
66
- readonly branchMayExist: true;
67
- readonly cleanupFailures: readonly string[];
68
- constructor(branchName: string, cleanupFailures: readonly string[], cause: unknown);
69
- }
70
- export declare function projectBranchMayExistAfterCreateFailure(error: unknown): boolean;
71
- export declare function projectWorktreeConfigurationFingerprint(input: {
72
- checkoutPathSegments: readonly string[];
73
- projectPath: string;
74
- repoHttpUrl: string | null;
75
- repoAuthHeader: string | null;
76
- defaultBranch: string;
77
- repositoryTransitionId?: string | null;
78
- executionDisabled?: boolean;
79
- mirrorWritesDisabled?: boolean;
80
- preserveOnlyBranches?: readonly {
81
- branchId?: string;
82
- branchName: string;
83
- }[];
84
- branches: readonly ProjectWorktreeBranch[];
85
- gitIdentity: {
86
- name: string;
87
- email: string;
88
- } | null;
89
- }): string;
90
- declare function gitCommandArgs(args: string[]): string[];
91
- export declare function hasLinkedProjectWorktreeLayout(input: {
92
- projectRoot: string;
93
- primaryBranchName: string;
94
- branches: readonly Pick<ProjectWorktreeBranch, "branchName">[];
95
- }): boolean;
96
- export declare function recoverStaleProjectWorktreeSnapshots(input: {
97
- projectsRoot: string;
98
- temporaryRoot?: string;
99
- processAlive?: (processId: number) => boolean;
100
- currentProcessId?: number;
101
- currentOwnerSessionId?: string;
102
- onProgress?: (progress: ProjectWorktreeSnapshotProgress) => void;
103
- }): {
104
- restored: string[];
105
- removed: string[];
106
- failed: Array<{
107
- path: string;
108
- error: string;
109
- }>;
110
- };
111
- export declare function projectOriginBranchName(input: {
112
- branchName: string;
113
- primaryBranchName: string;
114
- defaultBranch: string;
115
- }): string;
116
- declare function configureRepository(input: {
117
- primaryPath: string;
118
- originUrl: string;
119
- primaryBranchName?: string;
120
- defaultBranch?: string;
121
- branches?: readonly Pick<ProjectWorktreeBranch, "branchName">[];
122
- credentialHelper?: string | null;
123
- originCredentialUsername?: string | null;
124
- gitIdentity?: {
125
- name: string;
126
- email: string;
127
- } | null;
128
- }): Promise<void>;
129
- export declare function ensureProjectWorktrees(input: {
130
- projectRoot: string;
131
- primaryBranchName: string;
132
- defaultBranch?: string;
133
- branches: readonly ProjectWorktreeBranch[];
134
- originUrl: string;
135
- mirrorUrl: string;
136
- credentialHelper?: string | null;
137
- originCredentialUsername?: string | null;
138
- mirrorCredentialUsername?: string | null;
139
- gitIdentity?: {
140
- name: string;
141
- email: string;
142
- } | null;
143
- exactMirrorBranches?: ReadonlySet<string>;
144
- snapshotRoot?: string;
145
- onSnapshotProgress?: (progress: ProjectWorktreeSnapshotProgress) => void;
146
- }): Promise<ProjectWorktreeState[]>;
147
- export declare function projectWorktreeOperationInProgress(checkoutPath: string): boolean;
148
- /**
149
- * How a new linked worktree's working tree starts. `carry` materializes the
150
- * source checkout's Git-visible working state, uncommitted changes included;
151
- * `clean` checks out the source branch's current commit and nothing else.
152
- */
153
- export type ProjectWorktreeWorkingTreeMode = "carry" | "clean";
154
- export declare function createLinkedProjectBranch(input: {
155
- projectRoot: string;
156
- sourceBranchName: string;
157
- branchName: string;
158
- workingTree: ProjectWorktreeWorkingTreeMode;
159
- }): {
160
- branchPath: string;
161
- baseCommitHash: string;
162
- };
163
- /**
164
- * A retained pending intent is ownership proof for artifacts left by an
165
- * interrupted earlier attempt. Remove those artifacts idempotently before
166
- * recreating; if cleanup still fails, the caller keeps the same intent and can
167
- * retry again later.
168
- */
169
- export declare function createOrRetryLinkedProjectBranch(input: {
170
- projectRoot: string;
171
- primaryBranchName: string;
172
- sourceBranchName: string;
173
- branchName: string;
174
- workingTree: ProjectWorktreeWorkingTreeMode;
175
- pendingRetry: boolean;
176
- }): Promise<{
177
- branchPath: string;
178
- baseCommitHash: string;
179
- }>;
180
- export type ProjectCheckoutState = "linked" | "missing" | "not_a_worktree";
181
- export type ProjectCheckoutInventory = {
182
- /** Branches whose checkout is this project's primary clone or one of its linked worktrees. */
183
- linkedBranchNames: string[];
184
- missingCheckouts: Array<{
185
- branchName: string;
186
- checkoutPath: string;
187
- reason: Exclude<ProjectCheckoutState, "linked">;
188
- }>;
189
- };
190
- /**
191
- * Classify one configured branch checkout without spawning git, cheap enough
192
- * to run for every configured branch on every sync cycle. The primary
193
- * checkout is `linked` when its `.git` is a directory; another branch is
194
- * `linked` when its `.git` pointer file resolves into that primary clone's
195
- * `.git/worktrees` registry and the registered directory still exists.
196
- * `missing` means the checkout path is absent. Everything else (a hydrated
197
- * directory that never became a checkout, a foreign clone, a pointer to a
198
- * pruned registration) is `not_a_worktree`.
199
- */
200
- export declare function classifyProjectCheckout(input: {
201
- projectRoot: string;
202
- primaryBranchName: string;
203
- branchName: string;
204
- }): ProjectCheckoutState;
205
- /**
206
- * Partition a ready project's configured branches into checkouts a sync cycle
207
- * may use and checkouts it must skip. A primary clone that is not linked takes
208
- * every branch with it: nothing can be observed or published through it.
209
- */
210
- export declare function inventoryProjectCheckouts(input: {
211
- projectRoot: string;
212
- primaryBranchName: string;
213
- branchNames: readonly string[];
214
- }): ProjectCheckoutInventory;
215
- export declare const PROJECT_REMOVED_CHECKOUTS_DIRECTORY = ".r5d-removed";
216
- export declare function deleteLinkedProjectBranch(input: {
217
- projectRoot: string;
218
- primaryBranchName: string;
219
- branchName: string;
220
- }): {
221
- branchName: string;
222
- /** Where a path that was not this project's linked worktree was set aside instead of being deleted. */
223
- movedAsidePath?: string;
224
- /**
225
- * Where the linked worktree's tree now waits for garbage collection. The
226
- * branch is already gone from Git; the caller hands this path to the
227
- * collector so the recursive removal runs outside every workspace lease.
228
- */
229
- stagedForCollectionPath?: string;
230
- };
231
- /**
232
- * Retire a whole project: one rename into the namespace garbage directory
233
- * (the tree, primary Git objects included, is removed by the collector
234
- * outside every lease), or nothing when the root is already gone.
235
- */
236
- export declare function removeProjectWorktrees(input: {
237
- projectsRoot: string;
238
- projectRoot: string;
239
- branchNames: readonly string[];
240
- }): {
241
- stagedForCollectionPath?: string;
242
- };
243
- export declare function deleteProjectMirrorBranch(input: {
244
- gitDirectory: string;
245
- branchName: string;
246
- mirrorUrl: string;
247
- credentialHelper?: string | null;
248
- credentialUsername?: string | null;
249
- }): Promise<void>;
250
- export declare function pushProjectMirrorHeads(input: {
251
- projectRoot: string;
252
- branchNames: readonly string[];
253
- mirrorUrl: string;
254
- credentialHelper?: string | null;
255
- credentialUsername?: string | null;
256
- onlyBranches?: ReadonlySet<string>;
257
- /** Exact pre-projection commits to publish after the outer tree is reachable. */
258
- publicationHeads?: ReadonlyMap<string, string>;
259
- /** Hidden-mirror tips observed before the corresponding outer projection. */
260
- expectedMirrorHeads: ReadonlyMap<string, string | null>;
261
- /** Durable branch incarnations used to scope server-authored handoff refs. */
262
- branchIds: ReadonlyMap<string, string>;
263
- }): Promise<Array<{
264
- branchName: string;
265
- head: string;
266
- pushed: boolean;
267
- reason?: string;
268
- }>>;
269
- export declare function assertProjectMirrorHeadsPushed(results: readonly {
270
- branchName: string;
271
- pushed: boolean;
272
- reason?: string;
273
- }[]): void;
274
- type ProjectMirrorHeadUpdateInput = {
275
- projectRoot: string;
276
- primaryBranchName: string;
277
- branchNames: readonly string[];
278
- mirrorUrl: string;
279
- credentialHelper?: string | null;
280
- credentialUsername?: string | null;
281
- /** Rechecked after fetch and ancestry inspection, immediately before refs or the index move. */
282
- branchMutationAllowed?: (branchName: string, checkoutPath: string) => boolean;
283
- };
284
- export type ProjectMirrorHeadObservation = {
285
- branchName: string;
286
- previousHead: string;
287
- mirrorHead: string | null;
288
- mode: "fast_forward" | "reseed" | "server_synced";
289
- serverSyncedWorkspaceHeads: string[];
290
- shouldMove: boolean;
291
- };
292
- /**
293
- * Fetch and pin the exact hidden-mirror tips that may be applied after a
294
- * causally later outer-workspace fetch and hydration. Observation deliberately
295
- * does not mutate a live branch or its index.
296
- *
297
- * With `refreshRemote: false` the network fetch is skipped and the tips come
298
- * from the locally cached `refs/r5d/mirror/*` / `refs/r5d/server-synced/*`
299
- * refs of an earlier fetch. That is safe in the stale direction (a newer
300
- * mirror tip waits for a later cycle, exactly like a tip that lands mid-cycle
301
- * today) and in the fresh direction (hidden-mirror publication is tree-first,
302
- * so any locally cached tip's covering outer tree was published before the
303
- * fetch that cached it, hence before this cycle's outer fetch).
304
- */
305
- export declare function observeProjectMirrorHeads(input: Omit<ProjectMirrorHeadUpdateInput, "branchMutationAllowed"> & {
306
- allowNonFastForward: boolean;
307
- branchIds?: ReadonlyMap<string, string>;
308
- refreshRemote?: boolean;
309
- /**
310
- * Fetch only these mounts' branch heads and handoff refs, because
311
- * per-mount token gating found every other mount current. Undefined
312
- * fetches the whole mirror; an empty set fetches nothing, exactly like
313
- * `refreshRemote: false`.
314
- */
315
- fetchOnlyBranches?: ReadonlySet<string>;
316
- }): Promise<ProjectMirrorHeadObservation[]>;
317
- /**
318
- * Compute the tokens the locally cached mirror state covers — the project
319
- * token and one token per mount — from one listing of `refs/r5d/mirror/*` and
320
- * `refs/r5d/server-synced/*`, with the formula shared with the server. After a
321
- * fetch these name exactly the canonical state the fetch transferred; after a
322
- * successful lease push (which updates `refs/r5d/mirror/*` above) they predict
323
- * the server's next advertisement unless something else also moved the
324
- * canonical repository, in which case the mismatch fails open into a fetch.
325
- */
326
- export declare function computeLocalProjectMirrorRefsTokens(input: {
327
- projectRoot: string;
328
- primaryBranchName: string;
329
- mounts: readonly ProjectMirrorMount[];
330
- }): Promise<ProjectMirrorRefsTokens>;
331
- /** Apply only previously observed object ids; this function never refetches. */
332
- export declare function applyObservedProjectMirrorHeads(input: {
333
- projectRoot: string;
334
- primaryBranchName: string;
335
- observations: readonly ProjectMirrorHeadObservation[];
336
- /** Rechecked immediately before refs or the index move. */
337
- branchMutationAllowed?: (branchName: string, checkoutPath: string) => boolean;
338
- /** Proves the visible outer workspace has hydrated the server commit's exact source generation. */
339
- serverSyncedWorkspaceCovered?: (observation: ProjectMirrorHeadObservation) => Promise<boolean>;
340
- }): Promise<Array<{
341
- branchName: string;
342
- previousHead: string;
343
- mirrorHead: string | null;
344
- moved: boolean;
345
- }>>;
346
- export declare function fastForwardProjectHeadsFromMirror(input: ProjectMirrorHeadUpdateInput): Promise<Array<{
347
- branchName: string;
348
- previousHead: string;
349
- mirrorHead: string | null;
350
- fastForwarded: boolean;
351
- }>>;
352
- export declare function reseedProjectHeadsFromMirror(input: ProjectMirrorHeadUpdateInput): Promise<Array<{
353
- branchName: string;
354
- previousHead: string;
355
- mirrorHead: string | null;
356
- reseeded: boolean;
357
- }>>;
358
- /** Executor job body: `snapshotBranchTrees` with progress relayed to the control thread. */
359
- export declare function runProjectSnapshotCreateJob(input: {
360
- projectRoot: string;
361
- branches: ProjectWorktreeBranch[];
362
- temporaryRoot: string;
363
- scope: ProjectWorktreeSnapshotScope;
364
- ownerSessionId: string;
365
- }, context: WorkspaceFilesystemJobContext): ProjectWorktreeSnapshot;
366
- /** Executor job body: mirror captured checkouts back over reconciled worktrees. */
367
- export declare function runProjectSnapshotApplyJob(input: {
368
- mirrors: Array<{
369
- snapshotPath: string;
370
- targetPath: string;
371
- }>;
372
- }): null;
373
- /** Executor job body: `persistReconciledProjectAndConsumeSnapshot`. */
374
- export declare function runProjectSnapshotPersistJob(input: {
375
- snapshot: ProjectWorktreeSnapshot;
376
- durabilityPaths: string[] | null;
377
- }): null;
378
- /** Executor job body: `rollbackProjectWorktreeSnapshot`. */
379
- export declare function runProjectSnapshotRollbackJob(input: {
380
- snapshot: ProjectWorktreeSnapshot;
381
- }): null;
382
- export declare const projectWorktreesTestHarness: {
383
- commandArgs: typeof gitCommandArgs;
384
- configureRepository: typeof configureRepository;
385
- createPreparedSnapshot(input: {
386
- projectRoot: string;
387
- branches: readonly ProjectWorktreeBranch[];
388
- temporaryRoot: string;
389
- scope?: ProjectWorktreeSnapshotScope;
390
- }): {
391
- root: string;
392
- };
393
- consumeSnapshot(snapshotRoot: string): void;
394
- persistProjectAndConsumeSnapshot(snapshotRoot: string, afterProjectTreeFsync?: () => void): void;
395
- snapshotState(snapshotRoot: string): ProjectWorktreeSnapshotManifest["state"];
396
- };
397
- export {};
@@ -1,20 +0,0 @@
1
- export interface PtyOutputCoalescerOptions {
2
- send: (data: string) => void;
3
- flushIntervalMs?: number;
4
- maxBufferBytes?: number;
5
- now?: () => number;
6
- schedule?: (callback: () => void, delayMs: number) => () => void;
7
- }
8
- export interface PtyOutputCoalescer {
9
- push(data: string): void;
10
- flush(): void;
11
- }
12
- export declare const DEFAULT_PTY_OUTPUT_FLUSH_INTERVAL_MS = 8;
13
- export declare const DEFAULT_PTY_OUTPUT_MAX_BUFFER_BYTES: number;
14
- /**
15
- * Batches PTY output into fewer, larger relay messages. An isolated chunk
16
- * (an interactive keystroke echo) is sent immediately so coalescing adds no
17
- * input latency; only sustained bursts (build logs, `cat` of a large file)
18
- * are buffered, bounded by the flush interval and the buffer byte cap.
19
- */
20
- export declare function createPtyOutputCoalescer(options: PtyOutputCoalescerOptions): PtyOutputCoalescer;
@@ -1,35 +0,0 @@
1
- /** Messages between the control thread and the recovery journal thread. */
2
- export declare const WORKER_RECOVERY_JOURNAL_OPS: readonly ["admit", "readmitUnknownBranchDeletion", "record", "unknown", "unknownRun", "acknowledgeResult", "acknowledgeOutput", "acknowledgeTerminal", "cancelSession", "isRequestCancelled", "operations", "recoveryState", "terminals", "outputReplayBegin", "outputReplayNext", "outputReplayEnd"];
3
- export type WorkerRecoveryJournalOp = (typeof WORKER_RECOVERY_JOURNAL_OPS)[number];
4
- export declare function isWorkerRecoveryJournalOp(value: unknown): value is WorkerRecoveryJournalOp;
5
- export type WorkerRecoveryJournalEntry = {
6
- seq: number;
7
- op: WorkerRecoveryJournalOp;
8
- args: unknown[];
9
- };
10
- export type WorkerRecoveryJournalBatchRequest = {
11
- type: "batch";
12
- id: number;
13
- entries: WorkerRecoveryJournalEntry[];
14
- };
15
- export type WorkerRecoveryJournalSerializedError = {
16
- name: string;
17
- message: string;
18
- stack?: string;
19
- };
20
- export type WorkerRecoveryJournalThreadReply = {
21
- type: "ready";
22
- ledgerId: string;
23
- } | {
24
- type: "batch_result";
25
- id: number;
26
- results: Array<{
27
- seq: number;
28
- value: unknown;
29
- }>;
30
- } | {
31
- type: "batch_failure";
32
- id: number;
33
- error: WorkerRecoveryJournalSerializedError;
34
- };
35
- export declare function serializeWorkerRecoveryJournalError(error: unknown): WorkerRecoveryJournalSerializedError;
@@ -1,12 +0,0 @@
1
- import type { MessagePort } from "node:worker_threads";
2
- /**
3
- * The recovery journal thread's loop. It owns the one WorkerRecoveryStore
4
- * handle of the process and applies the control thread's entries strictly in
5
- * sequence, one durable commit per batch. Everything the store guarantees
6
- * (acceptance before effects, offsets, terminal lengths, unknown gating,
7
- * acknowledgement retention, cancel snapshots) is unchanged; only the thread
8
- * running it moved. `beforeBatch` exists for the stall fixture used by tests.
9
- */
10
- export declare function serveRecoveryJournal(port: MessagePort, filename: string, hooks?: {
11
- beforeBatch?: () => void;
12
- }): void;
@@ -1 +0,0 @@
1
- export {};