@ricsam/r5d-worker 0.0.137 → 0.0.139

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 +359 -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,514 +0,0 @@
1
- import { type PreparedWorkingTreeMirror, type ProjectedWorkingTreeEntry, type WorkingTreeGitlink, type WorkingTreeMirrorPlan, type WorkingTreeMirrorScope, type WorkingTreeSourceMode } from "./working-tree-mirror";
2
- import { type WorkspaceHydrationMergeBasis, type WorkspaceHydrationMergeDecision, type WorkspaceHydrationMountSkip as WorkspaceHydrationMountSkipBase } from "./workspace-hydration-merge";
3
- import { WorkspaceHydrationLedger, type WorkspaceHydrationLedgerEntry } from "./workspace-hydration-ledger";
4
- export declare const WORKSPACE_GIT_BRANCH = "main";
5
- export declare const MAX_WORKSPACE_GIT_DIFF_BYTES: number;
6
- export declare const WORKSPACE_GIT_CONFIRMED_LARGE_DIFF_PUSH_OPTION = "r5d-confirm-large-diff-v1";
7
- export declare const WORKSPACE_GIT_HYDRATED_RECEIPT = "r5d/workspace-hydrated-head";
8
- export declare const WORKSPACE_GIT_HYDRATION_TRANSACTION = "r5d/workspace-hydration-transaction";
9
- export declare const WORKSPACE_GIT_HYDRATION_RECOVERIES = "r5d/workspace-hydration-recoveries";
10
- export declare const WORKSPACE_GIT_CHECKOUT_DURABILITY = "r5d/workspace-checkout-durability";
11
- /** `R5D_MERGE_HYDRATION=0` restores the plain byte mirror for post-publication hydration (docs/merge-hydration-design.md §4). */
12
- export declare const WORKSPACE_MERGE_HYDRATION_SWITCH = "R5D_MERGE_HYDRATION";
13
- /** `R5D_PROCESS_BUSY_FENCE=1` makes a live process or PTY skip its mount again, as every cycle did before merge hydration. */
14
- export declare const WORKSPACE_PROCESS_BUSY_FENCE_SWITCH = "R5D_PROCESS_BUSY_FENCE";
15
- declare function hydrationPreBlobLedger(workspacePath: string): WorkspaceHydrationLedger;
16
- export type WorkspaceHydrationMountSkip = WorkspaceHydrationMountSkipBase & {
17
- retainedPaths?: string[];
18
- };
19
- export type WorkspaceMountSkipReason = WorkspaceHydrationMountSkip["reason"] | "stale_rewrite_detected" | "projection_conflict_deferred";
20
- /** Why a mount was left at its recorded basis this cycle, with the paths involved; a diagnostic beside `skippedMountIds`. */
21
- export type WorkspaceMountSkipReasons = Record<string, {
22
- reason: WorkspaceMountSkipReason;
23
- paths: string[];
24
- retainedPaths?: string[];
25
- }>;
26
- type WorkspaceHydrationMountBasis = {
27
- id: string;
28
- incarnationKey: string;
29
- sourcePath: string;
30
- durabilityRootPath: string;
31
- workspaceRelativePath: string;
32
- sourceMode: WorkingTreeSourceMode;
33
- hydrateDeletionMode: "all" | "git";
34
- preserveLocalOnInitialOuterAbsence: boolean;
35
- preserveLocalOnHydrationBasisChange: boolean;
36
- deleteWhenSourceMissing: boolean;
37
- };
38
- type WorkspaceHydrationMountReceipt = WorkspaceHydrationMountBasis & {
39
- head: string;
40
- };
41
- export type WorkspaceHydrationReceipt = {
42
- version: 3;
43
- mounts: WorkspaceHydrationMountReceipt[];
44
- /** Non-enumerable read-compat marker used only to finish a v1/v2 crash transition. */
45
- legacyHead?: string;
46
- };
47
- type WorkspaceHydrationTransactionManifest = {
48
- /** Version 5 makes guarded recovery explicit before any visible mutation. */
49
- version: 3 | 4 | 5;
50
- transactionId?: string;
51
- targetReceipt: WorkspaceHydrationReceipt | null;
52
- receiptBefore: WorkspaceHydrationReceipt | null;
53
- mounts: Array<{
54
- id: string;
55
- incarnationKey: string;
56
- sourcePath: string;
57
- durabilityRootPath: string;
58
- workspaceRelativePath: string;
59
- existed: boolean;
60
- snapshotName: string;
61
- /**
62
- * Present when the snapshot holds only the entries hydration replaces or
63
- * removes, with the paths it creates listed. Without it the snapshot is a
64
- * complete copy of the mount.
65
- */
66
- scope?: WorkingTreeMirrorScope;
67
- /** Required in v5: guarded mounts never enter unguarded snapshot restore. */
68
- recovery?: "snapshot" | "guarded";
69
- }>;
70
- /** Settled rollback scopes remain evidence; they are never restored again. */
71
- preservedMounts?: WorkspaceHydrationTransactionManifest["mounts"];
72
- };
73
- export type WorkspaceHydrationRecoveryRequired = {
74
- transactionId: string;
75
- transactionPath: string;
76
- mounts: Array<Pick<WorkspaceHydrationTransactionManifest["mounts"][number], "id" | "incarnationKey" | "sourcePath" | "durabilityRootPath" | "workspaceRelativePath"> & {
77
- retainedPaths?: string[];
78
- }>;
79
- receiptBefore: WorkspaceHydrationReceipt | null;
80
- };
81
- export declare class WorkspaceHydrationRecoveryRequiredError extends Error {
82
- readonly hydrationRecovery: WorkspaceHydrationRecoveryRequired;
83
- readonly code = "hydration_recovery_required";
84
- constructor(hydrationRecovery: WorkspaceHydrationRecoveryRequired, options?: ErrorOptions);
85
- }
86
- export type WorkspaceHydrationPreservationResult = {
87
- transactionId: string;
88
- archivePath: string;
89
- receiptBefore: WorkspaceHydrationReceipt | null;
90
- preservedMountIds: string[];
91
- alreadyPreserved: boolean;
92
- retainedEntries?: Array<{
93
- mountId: string;
94
- sourcePath: string;
95
- archivePath: string;
96
- }>;
97
- };
98
- export type WorkspaceGitMount = {
99
- id: string;
100
- /** Durable logical incarnation (for example the project-branch row id). */
101
- hydrationIncarnationKey: string;
102
- sourcePath: string;
103
- /** Existing managed root through which hydrated source directory entries are durably published. */
104
- durabilityRootPath: string;
105
- workspaceRelativePath: string;
106
- sourceMode: WorkingTreeSourceMode;
107
- hydrateDeletionMode: "all" | "git";
108
- /**
109
- * Only an exact creator-local unpublished mount may treat an absent outer
110
- * subtree as bootstrap authority before this clone has a hydration receipt.
111
- * Published/active mounts treat absence as a canonical deletion.
112
- */
113
- preserveLocalOnInitialOuterAbsence?: boolean;
114
- /**
115
- * Preserve a durably copied local tree across an exact checkout-path move.
116
- * This is transient and must clear after that move is published.
117
- */
118
- preserveLocalOnHydrationBasisChange?: boolean;
119
- /**
120
- * Workspace-relative path of the subtree this creator-local mount was copied
121
- * from (its source branch checkout). While the mount's own outer subtree is
122
- * still unpublished, the automatic diff-size guard measures it against that
123
- * source subtree instead of counting the whole copied tree as new content.
124
- */
125
- initialPublicationSourceRelativePath?: string;
126
- /** Remove the outer-workspace subtree when the mounted source was intentionally deleted. */
127
- deleteWhenSourceMissing?: boolean;
128
- busy?: () => boolean;
129
- /**
130
- * True while a worker-tracked process or PTY targets this mount. Not a
131
- * fence (a busy checkout is still projected and hydrated; merge hydration
132
- * folds the inbound change into it): a conflict found on a mount with a
133
- * live process is deferred instead of reported, and the hydration ledger
134
- * records the liveness so a stale-read rewrite by that process is merged
135
- * at the next projection. `R5D_PROCESS_BUSY_FENCE=1` folds it back into
136
- * `busy` (see `mountBusy`).
137
- */
138
- processLive?: () => boolean;
139
- /** Control-thread diagnostics only; never sent to a filesystem job. */
140
- describeHolders?: () => string;
141
- /** Monotonic/opaque visible-mutation token used to catch short writes that begin and end between busy checks. */
142
- mutationToken?: () => string;
143
- /**
144
- * The token a completed cycle observed when it last projected this mount.
145
- * While the current token still equals it and the mount's hydration basis
146
- * is the outer HEAD being projected, the outer subtree already carries the
147
- * visible bytes and the mirror copy is skipped. This is a cross-cycle skip
148
- * only; the per-cycle busy and token re-checks are unchanged.
149
- */
150
- lastProjectedMutationToken?: string;
151
- /** Activity-only fence used before checkout readiness is established on reconnect. */
152
- busyForRecovery?: () => boolean;
153
- };
154
- /**
155
- * The data of a mount, without its control-thread predicates. This is what a
156
- * workspace filesystem job receives: a job never evaluates `busy()` or
157
- * `mutationToken()`; the control thread evaluated them before dispatch and
158
- * holds the mount (see WorkspaceHydrationTransactionHooks.holdMounts) until
159
- * the job ends.
160
- */
161
- export type WorkspaceGitMountData = Pick<WorkspaceGitMount, "id" | "hydrationIncarnationKey" | "sourcePath" | "durabilityRootPath" | "workspaceRelativePath" | "sourceMode" | "hydrateDeletionMode" | "preserveLocalOnInitialOuterAbsence" | "preserveLocalOnHydrationBasisChange" | "initialPublicationSourceRelativePath" | "deleteWhenSourceMissing" | "lastProjectedMutationToken">;
162
- export declare function workspaceGitMountData(mount: WorkspaceGitMount): WorkspaceGitMountData;
163
- /**
164
- * Incident-bound configuration keeps project checkouts unready while the
165
- * canonical remediation owns the workspace. The guarded remediation sync is
166
- * nevertheless allowed to hydrate an existing checkout when its activity-only
167
- * fence is clear; the ordinary `busy` predicate would mistake that deliberate
168
- * unready state for concurrent visible work.
169
- */
170
- export declare function workspaceGitMountsForRemediation(mounts: readonly WorkspaceGitMount[]): WorkspaceGitMount[];
171
- export type WorkspaceHydrationTransactionContext = {
172
- /** Unique per transaction; pairs the begin and end observations. */
173
- transactionId: string;
174
- workspacePath: string;
175
- /** Mounts the transaction may hydrate or carry across the durability barrier. */
176
- mountIds: string[];
177
- };
178
- /**
179
- * Observes a hydration transaction (snapshot, hydration pass, durability
180
- * barrier, receipt) and fences the mounts any workspace filesystem job reads
181
- * or writes. The body runs on the executor thread and on a stalled disk it
182
- * can run for a long time. `beforeTransaction` is awaited after the last
183
- * asynchronous precheck and before the final busy observation, so it may
184
- * announce the operation and yield once; `afterTransaction` runs after the
185
- * body committed or rolled back. `holdMounts` is called synchronously right
186
- * after the busy observation that selected the mounts, before the job is
187
- * dispatched, and its release is called when the job's result or failure
188
- * arrived: while held, command admission for those mounts waits (see
189
- * WorkspaceMountHoldFence), which replaces the guarantee the un-yielding body
190
- * used to give.
191
- */
192
- export type WorkspaceHydrationTransactionHooks = {
193
- beforeTransaction: (context: WorkspaceHydrationTransactionContext) => Promise<void> | void;
194
- afterTransaction: (context: WorkspaceHydrationTransactionContext) => void;
195
- holdMounts: (mountIds: readonly string[], description: string) => () => void;
196
- };
197
- export type WorkspaceGitSyncOutcome = "no_change" | "updated" | "pushed" | "large_diff_blocked" | "conflict_blocked";
198
- export type WorkspaceGitSyncResult = {
199
- outcome: WorkspaceGitSyncOutcome;
200
- startingHead: string | null;
201
- /** The worker-local commit, including an unpublished blocked commit. */
202
- localHead: string | null;
203
- remoteHead: string | null;
204
- publishedHead: string | null;
205
- rebaseCount: number;
206
- /**
207
- * Bytes the automatic publication guard evaluated. A creator-local branch's
208
- * first publication counts only its divergence from the source subtree.
209
- */
210
- diffSizeBytes: number;
211
- affectedPaths: string[];
212
- activeMountIds: string[];
213
- skippedMountIds: string[];
214
- /**
215
- * Mounts merge hydration pinned this cycle (a conflict between a write
216
- * that landed after the projection read and the inbound change, or a write
217
- * racing the hydration) and mounts the stale-rewrite detector refused to
218
- * project, each with the paths involved. Worker-internal until the server
219
- * contract carries it.
220
- */
221
- mountSkipReasons?: WorkspaceMountSkipReasons;
222
- /** Token each active mount carried when this cycle projected it; recorded by the caller to skip unchanged mounts later. */
223
- projectedMutationTokens?: Record<string, string>;
224
- /** Creator-local mounts whose first outer publication was measured against their source subtree. */
225
- initialPublicationMountIds?: string[];
226
- /** Network fetches of the outer workspace head this cycle ran; zero when the advertised head proved them unnecessary. */
227
- remoteHeadFetches?: number;
228
- conflictPaths?: string[];
229
- conflictSnapshotRefs?: {
230
- local: string;
231
- remote: string;
232
- };
233
- conflictKind?: "integration_rebase" | "projection_merge";
234
- verifiedAncestorHeads?: string[];
235
- error?: string;
236
- };
237
- /** A guarded remediation was rejected before it was allowed to hydrate or publish. */
238
- export declare class WorkspaceRemediationAncestryError extends Error {
239
- constructor(message: string);
240
- }
241
- declare function gitCommandArgs(args: string[]): string[];
242
- declare function workspaceCloneCommandArgs(args: string[], remoteUrl: string, credentialHelper?: string | null, credentialUsername?: string | null): string[];
243
- export declare function workspaceGitHydrationIsCurrent(workspacePath: string, mounts?: readonly WorkspaceGitMount[]): boolean;
244
- /**
245
- * Failure-time variant of the currency check. A mount pinned at a valid
246
- * recorded basis is convergent whether or not it is busy right now: the next
247
- * cycle merges it forward from that exact basis and a genuine collision
248
- * surfaces as a projection_merge conflict, never a silent overwrite. Live
249
- * busy-ness must not decide safety here because the same disconnect that
250
- * aborts a sync also clears the process/PTY maps busy-ness is computed from.
251
- * Configuration-time recovery keeps the strict predicate.
252
- */
253
- export declare function workspaceGitHydrationIsRecoverable(workspacePath: string, mounts?: readonly WorkspaceGitMount[]): boolean;
254
- /** Executor job body: recover the durable boundary, then record the transition that follows. */
255
- export declare function runCheckoutTransitionBeginJob(input: {
256
- workspacePath: string;
257
- }): null;
258
- /** Executor job body: make the outer checkout durable and record its head as the durable boundary. */
259
- export declare function runCheckoutTransitionCompleteJob(input: {
260
- workspacePath: string;
261
- }): null;
262
- /** Executor job body: `recoverWorkspaceCheckoutDurability`. */
263
- export declare function runCheckoutDurabilityRecoveryJob(input: {
264
- workspacePath: string;
265
- preserveResolutionInProgress: boolean;
266
- }): null;
267
- /** Executor job body: the outer-tree durability barrier alone. */
268
- export declare function runOuterCheckoutFsyncJob(input: {
269
- workspacePath: string;
270
- }): null;
271
- /** Read-only admission inspection, including before incident configuration fast paths. */
272
- export declare function runHydrationRecoveryInspectJob(input: {
273
- workspacePath: string;
274
- }): WorkspaceHydrationRecoveryRequired | null;
275
- /**
276
- * Explicitly preserve an interrupted guarded transaction. The caller owns
277
- * workspace admission/exclusion. No visible file is restored or deleted and
278
- * no mount is receipted at the partially applied target head. The entire
279
- * transaction directory is archived atomically, including snapshots and any
280
- * interrupted manifest writes, before ordinary merge projection may resume.
281
- */
282
- export declare function runHydrationPreserveInterruptedJob(input: {
283
- workspacePath: string;
284
- expectedTransactionId: string;
285
- }): WorkspaceHydrationPreservationResult;
286
- /** Everything the apply phase needs for a merge-hydrated mount, decided before the manifest was written. */
287
- type WorkspaceHydrationMergePlan = {
288
- prepared: PreparedWorkingTreeMirror;
289
- decision: Extract<WorkspaceHydrationMergeDecision, {
290
- kind: "apply";
291
- }>;
292
- plan: WorkingTreeMirrorPlan;
293
- /** The mount's snapshot directory once the transaction directory is published. */
294
- snapshotPath: string;
295
- basis: WorkspaceHydrationMergeBasis;
296
- };
297
- declare function beginHydrationTransaction(workspacePath: string, mounts: readonly WorkspaceGitMount[], targetReceipt: WorkspaceHydrationReceipt | null, mergeBases?: Readonly<Record<string, WorkspaceHydrationMergeBasis>>): {
298
- manifest: WorkspaceHydrationTransactionManifest;
299
- durabilityScopes: Map<string, readonly string[]>;
300
- mergePlans: Map<string, WorkspaceHydrationMergePlan>;
301
- /** Mounts merge hydration decided not to touch; they have no snapshot, no manifest entry and keep their receipt entry. */
302
- skippedMounts: WorkspaceHydrationMountSkip[];
303
- targetReceipt: WorkspaceHydrationReceipt | null;
304
- };
305
- declare function configureWorkspaceRepository(input: {
306
- workspacePath: string;
307
- remoteUrl: string;
308
- credentialHelper?: string | null;
309
- credentialUsername?: string | null;
310
- gitIdentity: {
311
- name: string;
312
- email: string;
313
- };
314
- }): Promise<void>;
315
- /**
316
- * Rebind only the existing canonical checkout's local Git configuration while
317
- * an incident owns its HEAD. In particular, this deliberately does not fetch,
318
- * recover durability, move refs, reset the index/worktree, or inspect/abort an
319
- * in-progress merge or rebase.
320
- */
321
- export declare function configureExistingWorkspaceGitForRemediation(input: {
322
- workspacePath: string;
323
- remoteUrl: string;
324
- credentialHelper?: string | null;
325
- credentialUsername?: string | null;
326
- gitIdentity: {
327
- name: string;
328
- email: string;
329
- };
330
- }): Promise<void>;
331
- export declare function ensureWorkspaceGitClone(input: {
332
- workspacePath: string;
333
- remoteUrl: string;
334
- credentialHelper?: string | null;
335
- credentialUsername?: string | null;
336
- gitIdentity: {
337
- name: string;
338
- email: string;
339
- };
340
- preserveResolutionInProgress?: boolean;
341
- /** Server-advertised head of the workspace remote; see resolveWorkspaceRemoteHead. */
342
- advertisedRemoteHead?: string | null;
343
- }): Promise<{
344
- localHead: string | null;
345
- remoteHead: string | null;
346
- remoteHeadFetched: boolean;
347
- }>;
348
- type ProjectedMountGitlinks = {
349
- mount: WorkspaceGitMount;
350
- gitlinks: WorkingTreeGitlink[];
351
- };
352
- /**
353
- * Mirror each mount's visible tree into the outer worktree. A submodule
354
- * arrives as an empty directory plus a gitlink the caller must stage with
355
- * `stageWorkspaceGitlinks` before `git add -A`, which can never create one.
356
- */
357
- declare function mirrorMountsToWorkspace(workspacePath: string, mounts: readonly WorkspaceGitMount[], projectedFiles?: Map<string, ProjectedWorkingTreeEntry>): ProjectedMountGitlinks[];
358
- /**
359
- * Executor job body: the complete hydration transaction. Snapshot exactly
360
- * what hydration replaces, hydrate, cross the durability barrier, write the
361
- * commit marker, publish the receipt, remove the transaction; on failure
362
- * restore the snapshot unless the visible tree is already durable. The write
363
- * and fsync ordering is the one the control thread used to run inline.
364
- */
365
- export declare function runHydrationTransactionJob(input: {
366
- workspacePath: string;
367
- hydrationMounts: readonly WorkspaceGitMountData[];
368
- advancedDurabilityMounts: readonly WorkspaceGitMountData[];
369
- targetReceipt: WorkspaceHydrationReceipt | null;
370
- mergeBases?: Readonly<Record<string, WorkspaceHydrationMergeBasis>>;
371
- }): {
372
- hydratedMountIds: string[];
373
- skippedMounts: WorkspaceHydrationMountSkip[];
374
- hydratedEntries: Record<string, Record<string, Omit<WorkspaceHydrationLedgerEntry, "processLiveAcrossHydration">>>;
375
- };
376
- /** Executor job body: hydrate visible mounts before an outer clone exists (no transaction to record). */
377
- export declare function runHydrationRawJob(input: {
378
- workspacePath: string;
379
- mounts: readonly WorkspaceGitMountData[];
380
- }): {
381
- hydratedMountIds: string[];
382
- };
383
- /**
384
- * Executor job body: checkout durability recovery, pending hydration
385
- * transaction restore or completion, and basis-ref repair, in that order.
386
- */
387
- export declare function runHydrationRecoveryJob(input: {
388
- workspacePath: string;
389
- preserveResolutionInProgress: boolean;
390
- }): null;
391
- export declare function hydrateWorkspaceGitMounts(workspacePath: string, mounts: readonly WorkspaceGitMount[], options?: {
392
- ignoreBusy?: boolean;
393
- hydrationHooks?: WorkspaceHydrationTransactionHooks;
394
- }): Promise<{
395
- hydratedMountIds: string[];
396
- skippedMountIds: string[];
397
- }>;
398
- export declare function recoverWorkspaceGitHydration(workspacePath: string, mounts: readonly WorkspaceGitMount[], options?: {
399
- ignoreBusy?: boolean;
400
- deferMountIds?: ReadonlySet<string>;
401
- preserveResolutionInProgress?: boolean;
402
- preserveStaleBases?: boolean;
403
- hydrationHooks?: WorkspaceHydrationTransactionHooks;
404
- }): Promise<void>;
405
- export declare function resetWorkspaceGit(input: {
406
- workspacePath: string;
407
- remoteUrl: string;
408
- credentialHelper?: string | null;
409
- credentialUsername?: string | null;
410
- gitIdentity: {
411
- name: string;
412
- email: string;
413
- };
414
- mounts: readonly WorkspaceGitMount[];
415
- hydrationHooks?: WorkspaceHydrationTransactionHooks;
416
- }): Promise<{
417
- startingHead: string | null;
418
- localHead: string | null;
419
- remoteHead: string | null;
420
- discardedPaths: string[];
421
- activeMountIds: string[];
422
- skippedMountIds: string[];
423
- }>;
424
- /**
425
- * Bytes of the raw `git diff --binary` between two revisions, capped at
426
- * `limit + 1`. `pathspecs` narrows what is measured; callers pass
427
- * `:(exclude,literal)<path>` for paths whose text is not publication content,
428
- * such as a subtree a gitlink replaces (see `pathsReplacedByGitlinks`).
429
- */
430
- declare function diffSizeBytes(workspacePath: string, baseRevision: string | null, headRevision: string, limit: number, pathspecs?: readonly string[]): Promise<number>;
431
- export type SynchronizeWorkspaceGitInput = {
432
- attemptId?: string;
433
- workerLabel: string;
434
- workspacePath: string;
435
- remoteUrl: string;
436
- credentialHelper?: string | null;
437
- credentialUsername?: string | null;
438
- gitIdentity: {
439
- name: string;
440
- email: string;
441
- };
442
- mounts: readonly WorkspaceGitMount[];
443
- commitDetail?: string;
444
- allowLargeDiff?: boolean;
445
- maxDiffBytes?: number;
446
- maxPushAttempts?: number;
447
- /** Publish edits already made in the outer clone without first projecting visible mounts over them. */
448
- skipMountMirror?: boolean;
449
- /** Positive ancestry proof required before a remediation may integrate, publish, or hydrate. */
450
- requiredAncestorHeads?: readonly string[];
451
- /**
452
- * Head of the workspace remote as the server last read it from disk. Equal
453
- * to the local remote-tracking ref, it lets the cycle skip its workspace
454
- * head fetches; see resolveWorkspaceRemoteHead. Omit to always fetch.
455
- */
456
- advertisedRemoteHead?: string | null;
457
- /** Revalidate the worker/config/incident generation after every async boundary. */
458
- assertStillAdmitted?: () => void;
459
- /** Test seam for exercising an incident transition during asynchronous diff measurement. */
460
- measureDiffSize?: typeof diffSizeBytes;
461
- afterWorkspacePublished?: (context: {
462
- publishedHead: string;
463
- activeMountIds: string[];
464
- }) => void | Promise<void>;
465
- /** Announces each synchronous hydration transaction of this cycle; see WorkspaceHydrationTransactionHooks. */
466
- hydrationHooks?: WorkspaceHydrationTransactionHooks;
467
- };
468
- export declare function synchronizeWorkspaceGit(input: SynchronizeWorkspaceGitInput): Promise<WorkspaceGitSyncResult>;
469
- /**
470
- * Executor job body: byte-mirror one visible mount into the outer checkout,
471
- * recording what it read. With `checkOnly` it stops after the ledger pass:
472
- * the cycle decides the mount's route (mirror, merge, or a stale-rewrite
473
- * refusal) before any outer write.
474
- */
475
- export declare function runProjectionMirrorJob(input: {
476
- workspacePath: string;
477
- mount: WorkspaceGitMountData;
478
- hydrationLedger?: Record<string, WorkspaceHydrationLedgerEntry>;
479
- checkOnly?: boolean;
480
- }): {
481
- gitlinks: WorkingTreeGitlink[];
482
- projectedFiles: Record<string, ProjectedWorkingTreeEntry>;
483
- readAtMs: number;
484
- staleRewritePaths: string[];
485
- ledgerMergePaths: string[];
486
- staleRewriteCleared: string[];
487
- };
488
- /** Executor job body: outer-tree edits that follow the mirrors, in the cycle's order. */
489
- export declare function runProjectionOuterApplyJob(input: {
490
- workspacePath: string;
491
- removeMounts: readonly WorkspaceGitMountData[];
492
- materialize: ReadonlyArray<{
493
- workspaceRelativePath: string;
494
- resultTree: string;
495
- }>;
496
- restoreFromHead: readonly WorkspaceGitMountData[];
497
- }): null;
498
- /** Executor job body: persist projected visible mounts, then publish the projection receipt. */
499
- export declare function runProjectionReceiptJob(input: {
500
- workspacePath: string;
501
- fsyncMounts: readonly WorkspaceGitMountData[];
502
- receipt: WorkspaceHydrationReceipt;
503
- }): null;
504
- export declare const workspaceGitSyncTestHarness: {
505
- beginHydrationTransaction: typeof beginHydrationTransaction;
506
- commandArgs: typeof gitCommandArgs;
507
- workspaceCloneCommandArgs: typeof workspaceCloneCommandArgs;
508
- configureWorkspaceRepository: typeof configureWorkspaceRepository;
509
- mirrorMountsToWorkspace: typeof mirrorMountsToWorkspace;
510
- hydrateMountsFromWorkspace: typeof hydrateWorkspaceGitMounts;
511
- hydrationPreBlobLedger: typeof hydrationPreBlobLedger;
512
- resetHydrationPreBlobLedgers(): void;
513
- };
514
- export {};
@@ -1,76 +0,0 @@
1
- import type { ProjectedWorkingTreeEntry } from "./working-tree-mirror";
2
- /**
3
- * What a merge hydration replaced at one checkout path
4
- * (docs/merge-hydration-design.md §3.1): the blob that was there before
5
- * (`preBlob`), the blob hydration wrote (`postBlob`, null when it removed the
6
- * path), the `lstat` it left behind (`stat`, null when removed), and whether
7
- * a worker-tracked process or PTY was alive across that hydration.
8
- *
9
- * At the next projection a path whose stat moved is treated by that flag: a
10
- * process alive across the hydration may have read the file before it and
11
- * written it afterwards, so its bytes are merged against `preBlob` (what it
12
- * read) with `postBlob` as the other side, which turns a stale-read revert
13
- * into the inbound change plus the process's own delta, or a visible
14
- * conflict. Without a live process the change is a plain edit on top of
15
- * `postBlob`; the exact re-emission of `preBlob` is still refused as a stale
16
- * rewrite (§3.3).
17
- */
18
- export type WorkspaceHydrationLedgerEntry = {
19
- preBlob: string;
20
- postBlob: string | null;
21
- stat: Extract<ProjectedWorkingTreeEntry, {
22
- kind: "file";
23
- }> | null;
24
- processLiveAcrossHydration: boolean;
25
- };
26
- /**
27
- * In memory, per mount incarnation and clone. Not persisted: every process
28
- * and PTY the flag refers to is a child of the worker, so a restart ends
29
- * them all and no entry could still merge; the detector half is best effort.
30
- */
31
- export declare class WorkspaceHydrationLedger {
32
- private readonly mounts;
33
- private static key;
34
- /** Entries by mount-relative path for the mount, or an empty map. */
35
- entries(mount: {
36
- id: string;
37
- hydrationIncarnationKey: string;
38
- }): ReadonlyMap<string, WorkspaceHydrationLedgerEntry>;
39
- /** Blob ids by mount-relative path for the mount (the §3.3 detector's input), or an empty map. */
40
- preBlobs(mount: {
41
- id: string;
42
- hydrationIncarnationKey: string;
43
- }): ReadonlyMap<string, string>;
44
- /**
45
- * Record what a merge hydration replaced; earlier entries for other paths
46
- * are kept. A path that already carries a live entry keeps its `preBlob`
47
- * while the new hydration also ran across a live process: the process's
48
- * read predates both hydrations, so what it read is still the first blob.
49
- */
50
- record(mount: {
51
- id: string;
52
- hydrationIncarnationKey: string;
53
- }, entries: ReadonlyMap<string, WorkspaceHydrationLedgerEntry> | Readonly<Record<string, WorkspaceHydrationLedgerEntry>>, options?: {
54
- /**
55
- * Paths whose new `preBlob` is taken even over a live entry: the
56
- * hydration followed a projection that merged the process's own write
57
- * at that path, so the bytes it wrote (not what it originally read)
58
- * are the base its next write derives from.
59
- */
60
- replacePreBlobFor?: readonly string[];
61
- }): void;
62
- /** Forget the mount: its checkout was rewritten by something this ledger did not observe. */
63
- clearMount(mount: {
64
- id: string;
65
- hydrationIncarnationKey: string;
66
- }): void;
67
- /** Forget paths whose checkout content moved on from the hydrated bytes: a later return to the old bytes is a deliberate edit. */
68
- forget(mount: {
69
- id: string;
70
- hydrationIncarnationKey: string;
71
- }, paths: readonly string[]): void;
72
- clear(): void;
73
- get size(): number;
74
- }
75
- /** The name the first version of this module exported; kept for callers that still use it. */
76
- export declare const WorkspaceHydrationPreBlobLedger: typeof WorkspaceHydrationLedger;