@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,424 +0,0 @@
1
- import fs from "node:fs";
2
- import { type AtomicRenamePrimitives } from "./atomic-rename";
3
- export type WorkingTreeSourceMode = "all" | "git";
4
- export type WorkingTreeDeletionMode = "all" | "git";
5
- export type WorkingTreeMirrorDurability = "per_entry" | "deferred_private_staging";
6
- export type TreeEntry = {
7
- kind: "directory";
8
- mode: number;
9
- } | {
10
- kind: "file";
11
- mode: number;
12
- size: number;
13
- } | {
14
- kind: "symlink";
15
- mode: number;
16
- target: string;
17
- }
18
- /**
19
- * A submodule (D4): the enclosing repository records a commit at this path
20
- * and never its contents. A leaf for every operation here: nothing beneath
21
- * it is inspected, copied, captured, removed, or restored.
22
- */
23
- | {
24
- kind: "gitlink";
25
- objectId: string;
26
- };
27
- export type WorkingTreeGitlink = {
28
- relativePath: string;
29
- objectId: string;
30
- };
31
- /** One index record of a Git checkout, in the form `git update-index --index-info` accepts back. */
32
- export type WorkingTreeIndexRecord = {
33
- mode: string;
34
- objectId: string;
35
- stage: number;
36
- relativePath: string;
37
- };
38
- /**
39
- * Index entries a Git-target mirror changes: the records it removes or
40
- * overwrites (a restore puts them back) and the gitlinks it writes (a restore
41
- * drops them first).
42
- */
43
- export type WorkingTreeIndexChanges = {
44
- removed: WorkingTreeIndexRecord[];
45
- written: WorkingTreeGitlink[];
46
- };
47
- export type WorkingTreeInspectionOptions = {
48
- /**
49
- * Gitlinks the enclosing repository records under an all-mode root, keyed
50
- * by relative path. Git checks a submodule out as an empty directory, so
51
- * the filesystem alone cannot show one; the entry replaces whatever is on
52
- * disk at that path. Ignored in Git mode, where the index is read directly.
53
- */
54
- gitlinks?: ReadonlyMap<string, string>;
55
- /**
56
- * Receives the `lstat` of every inspected entry, keyed by relative path.
57
- * Merge hydration compares these against the stats a later mutation finds
58
- * on disk, so a write that lands between inspection and mutation is seen.
59
- */
60
- stats?: Map<string, fs.Stats>;
61
- };
62
- /**
63
- * What a projection read for one source entry: enough of the `lstat` to tell
64
- * later whether the same path changed since (a rewrite moves ctime, and a
65
- * rename-over changes the inode), or the symlink target, or the gitlink
66
- * pointer. Recorded by the projection mirror and by merge projection and
67
- * consumed by merge hydration.
68
- */
69
- export type ProjectedWorkingTreeEntry = {
70
- kind: "file";
71
- size: number;
72
- mode: number;
73
- mtimeMs: number;
74
- ctimeMs: number;
75
- ino: number;
76
- } | {
77
- kind: "symlink";
78
- target: string;
79
- } | {
80
- kind: "gitlink";
81
- objectId: string;
82
- };
83
- /** The stat fields a projection records, from an `lstat` or `fstat` of a regular file. */
84
- export declare function projectedFileEntry(stat: fs.Stats): Extract<ProjectedWorkingTreeEntry, {
85
- kind: "file";
86
- }>;
87
- /** True when a current `lstat` still describes the projected regular file: same inode, size, mode and timestamps. */
88
- export declare function projectedFileEntryMatches(entry: Extract<ProjectedWorkingTreeEntry, {
89
- kind: "file";
90
- }>, stat: fs.Stats): boolean;
91
- /** True when two `lstat` results describe the same unchanged entry (kind, inode, size, mode, timestamps). */
92
- export declare function workingTreeStatsMatch(left: fs.Stats, right: fs.Stats): boolean;
93
- /** True when two `lstat` results name the same inode. */
94
- export declare function sameWorkingTreeInode(left: fs.Stats, right: fs.Stats): boolean;
95
- /**
96
- * True when the entry a switch displaced is the very inode its expectation
97
- * described, still holding what that expectation saw: same identity, kind,
98
- * mode, size and mtime. Its ctime is not compared, because the exchange or
99
- * rename that moved it aside set the ctime itself; the expectation's ctime
100
- * was already checked immediately before the switch.
101
- */
102
- export declare function displacedEntryMatches(expected: fs.Stats, displaced: fs.Stats): boolean;
103
- /**
104
- * An entry a guarded pass displaced and kept, by absolute path, with the
105
- * `lstat` it had the moment it was displaced. It is the exact inode that was
106
- * at the path (not a copy), so a rollback can put it back without touching
107
- * its bytes and so a write through a descriptor opened before the switch is
108
- * still visible on it when the pass settles.
109
- */
110
- export type WorkingTreeRetainedEntry = {
111
- path: string;
112
- stat: fs.Stats;
113
- content?: string;
114
- };
115
- /**
116
- * Another writer's entry a guarded pass displaced and could not put back at
117
- * its path without displacing yet another write: it is kept where it is and
118
- * reported instead of being removed. `later_writer`: a newer entry took the
119
- * path while this one was being restored. `reappeared`: while the path was
120
- * momentarily empty during a fallback replacement, something was created
121
- * there; the displaced entry is kept because that creator may have meant to
122
- * modify it. `unrestorable`: no primitive could restore it (a directory on a
123
- * filesystem without a native no-replace rename).
124
- */
125
- export type WorkingTreeRetainedForeignEntry = {
126
- relativePath: string;
127
- path: string;
128
- reason: "later_writer" | "reappeared" | "unrestorable";
129
- };
130
- /**
131
- * Thrown by a guarded mirror when the target entry it is about to replace,
132
- * remove or create no longer matches the state observed when the mirror was
133
- * prepared: something else wrote there in between. The caller rolls the
134
- * mount back through the journal instead of finishing over the writer. When
135
- * the pass had to keep a displaced writer's entry aside (see
136
- * `WorkingTreeRetainedForeignEntry`) the error lists it.
137
- */
138
- export declare class WorkingTreeTargetChangedError extends Error {
139
- readonly relativePath: string;
140
- readonly retained: WorkingTreeRetainedForeignEntry[];
141
- constructor(relativePath: string, options?: {
142
- detail?: string;
143
- retained?: WorkingTreeRetainedForeignEntry[];
144
- });
145
- }
146
- /**
147
- * One mutation a guarded mirror made, in order. `replaced` is the entry that
148
- * was there before (null when the path was created) and `after` the `lstat`
149
- * of the entry the mirror left behind (null when it removed the path); it is
150
- * the mirror's own entry, identified by inode, never a later writer's.
151
- * `displaced` is the replaced or removed entry itself, retained until the
152
- * pass settles or its rollback finishes. A rollback undoes an entry only
153
- * while the path still shows `after`; anything else means another writer
154
- * came later and keeps what it wrote.
155
- */
156
- export type WorkingTreeMirrorJournalEntry = {
157
- relativePath: string;
158
- replaced: TreeEntry | null;
159
- after: fs.Stats | null;
160
- /** Immutable bytes owned by the pass, never inferred from the visible path after publication. */
161
- afterContent?: string;
162
- displaced?: WorkingTreeRetainedEntry;
163
- };
164
- export type WorkingTreeMirrorJournal = {
165
- entries: WorkingTreeMirrorJournalEntry[];
166
- /** The Git index changes the pass applied (its last step); a rollback puts them back. */
167
- indexApplied?: WorkingTreeIndexChanges;
168
- /** Writers' entries the pass or its rollback displaced and kept aside; never removed by the mirror. */
169
- retained?: WorkingTreeRetainedForeignEntry[];
170
- };
171
- /** Content a guarded mirror writes at a path instead of copying the source entry (a merged file). */
172
- export type WorkingTreeMirrorOverride = {
173
- content: Buffer;
174
- mode: number;
175
- };
176
- export type WorkingTreeMirrorGuards = {
177
- /**
178
- * The target `lstat` each path must still show immediately before it is
179
- * mutated (null: the path must still be absent). Paths not listed are
180
- * switched against whatever they hold at that moment. A mismatch throws
181
- * WorkingTreeTargetChangedError before anything is written at that path.
182
- * The pass updates an entry once it has satisfied it (a removal it made
183
- * itself leaves the path expected absent), so a path mutated in two steps
184
- * is checked against the pass's own intermediate state.
185
- */
186
- expectations?: Map<string, fs.Stats | null>;
187
- /** Known pre-hydration Git blob IDs, when the merge decision already read the bytes. */
188
- preBlobs?: ReadonlyMap<string, string>;
189
- /** Merged bytes written in place of the source entry's bytes. */
190
- overrides?: ReadonlyMap<string, WorkingTreeMirrorOverride>;
191
- /** Every mutation is appended here for `rollbackWorkingTreeMirrorJournal`. */
192
- journal?: WorkingTreeMirrorJournal;
193
- };
194
- /**
195
- * Points in a guarded pass at which another writer could interleave, exposed
196
- * so tests can place a deterministic write there. `before_switch` and
197
- * `before_remove` fire after the path's expectation was verified and
198
- * immediately before the exchange, rename or unlink; `after_switch` and
199
- * `after_remove` immediately after it, before the displaced entry is
200
- * inspected; `before_yield` before a mismatched displaced entry is put back;
201
- * `before_settle` before the pass re-inspects its retained entries; the
202
- * rollback variants bracket the rollback's own switches. Never set in
203
- * production.
204
- */
205
- export type WorkingTreeMirrorRacePhase = "before_switch" | "after_switch" | "before_yield" | "before_remove" | "after_remove" | "before_settle" | "before_rollback_switch" | "before_rollback_remove";
206
- export type WorkingTreeMirrorRaceEvent = {
207
- phase: WorkingTreeMirrorRacePhase;
208
- relativePath: string;
209
- targetPath: string;
210
- };
211
- /** Test seam for deterministic race regressions; pass null to clear. */
212
- export declare function setWorkingTreeMirrorRaceHook(hook: ((event: WorkingTreeMirrorRaceEvent) => void) | null): void;
213
- /**
214
- * Destructive native-tree moves cannot silently apply the Git-target filter:
215
- * doing so would delete legitimate case-sensitive POSIX filenames after the
216
- * filtered copy. Exact native `.git` metadata is intentionally disposable;
217
- * every portable alias must be remediated before the old tree is retired.
218
- */
219
- export declare function assertWorkingTreeHasNoPortableGitMetadataAliases(root: string): void;
220
- type RelativePathInspection = {
221
- kind: "entry";
222
- absolutePath: string;
223
- stat: fs.Stats;
224
- } | {
225
- kind: "missing";
226
- } | {
227
- kind: "blocked";
228
- blockingPath: string;
229
- };
230
- export type WorkingTreePathInspection = RelativePathInspection;
231
- /** `lstat` a target-relative path without following any ancestor symlink; see the mirror's own traversal rules. */
232
- export declare function inspectWorkingTreePath(root: string, relativePath: string): WorkingTreePathInspection;
233
- export declare function inspectWorkingTree(root: string, mode: WorkingTreeSourceMode, options?: WorkingTreeInspectionOptions): Map<string, TreeEntry>;
234
- /** The primitives a guarded pass or rollback on `targetRoot` would use, after probing its filesystem. */
235
- export declare function workingTreeAtomicRenameSupport(targetRoot: string): AtomicRenamePrimitives["support"];
236
- /**
237
- * Where a guarded pass on `targetRoot` keeps staged and displaced entries.
238
- * Entries left there after a crash are evidence for recovery: each name ends
239
- * with the percent-encoded target-relative path of the entry it held.
240
- */
241
- export declare function workingTreeDisplacedRetentionDirectory(targetRoot: string): string | null;
242
- type MirrorTarget = {
243
- existing: Map<string, TreeEntry>;
244
- /** Present for Git targets: their index and the submodule directories a mirror must leave alone. */
245
- git: {
246
- indexRecords: WorkingTreeIndexRecord[];
247
- submodules: Map<string, string | null>;
248
- /** Submodule directories that hold anything at all; never removed, and their index entries stay. */
249
- occupied: Set<string>;
250
- } | null;
251
- };
252
- export type WorkingTreeMirrorInput = {
253
- sourceRoot: string;
254
- targetRoot: string;
255
- sourceMode: WorkingTreeSourceMode;
256
- deletionMode: WorkingTreeDeletionMode;
257
- /** Gitlinks the enclosing repository records for an all-mode source (see `inspectWorkingTree`). */
258
- sourceGitlinks?: ReadonlyMap<string, string>;
259
- };
260
- /**
261
- * Both trees of a mirror, inspected once. `desired` is every source entry
262
- * (shielded ones included), `existing` the target's deletion-mode entry set,
263
- * and `existingStats` the `lstat` of each existing entry as it was seen.
264
- * Merge hydration decides per path from this and applies through
265
- * `applyWorkingTreeMirror` with guards that compare against those stats.
266
- */
267
- export type PreparedWorkingTreeMirror = {
268
- sourceRoot: string;
269
- targetRoot: string;
270
- deletionMode: WorkingTreeDeletionMode;
271
- desired: Map<string, TreeEntry>;
272
- existing: Map<string, TreeEntry>;
273
- existingStats: Map<string, fs.Stats>;
274
- git: MirrorTarget["git"];
275
- shielded: Set<string>;
276
- };
277
- export declare function prepareWorkingTreeMirror(input: WorkingTreeMirrorInput): PreparedWorkingTreeMirror;
278
- /**
279
- * Restrict what an apply pass touches. Without a selection the mirror makes
280
- * the target equal to the source (every desired path written, every existing
281
- * path outside the desired set removed). With one, only `write` paths are
282
- * copied (or replaced by an override), only `remove` paths are removed, and
283
- * `desiredForIndex` is the tree the Git index is reconciled to; every other
284
- * path is left exactly as it is. Desired directories are still ensured.
285
- */
286
- export type WorkingTreeMirrorSelection = {
287
- write: ReadonlySet<string>;
288
- remove: ReadonlySet<string>;
289
- desiredForIndex: ReadonlyMap<string, TreeEntry>;
290
- };
291
- export type WorkingTreeMirrorApplyOptions = {
292
- durability?: WorkingTreeMirrorDurability;
293
- guards?: WorkingTreeMirrorGuards;
294
- selection?: WorkingTreeMirrorSelection;
295
- /** Collect the projection record of every copied or verified source entry. */
296
- projected?: Map<string, ProjectedWorkingTreeEntry>;
297
- };
298
- export declare function applyWorkingTreeMirror(prepared: PreparedWorkingTreeMirror, options?: WorkingTreeMirrorApplyOptions): {
299
- paths: string[];
300
- gitlinks: WorkingTreeGitlink[];
301
- };
302
- export declare function mirrorWorkingTree(input: WorkingTreeMirrorInput & {
303
- /**
304
- * Defer destination fsync only while building an unpublished private tree.
305
- * The caller must durably fsync that complete tree before publishing it or
306
- * mutating the source authority.
307
- */
308
- durability?: WorkingTreeMirrorDurability;
309
- /** Collect the projection record of every copied or verified source entry. */
310
- projected?: Map<string, ProjectedWorkingTreeEntry>;
311
- }): {
312
- paths: string[];
313
- gitlinks: WorkingTreeGitlink[];
314
- };
315
- /** Canonical relative form used by mirror plans and scopes, or null when the value is unsafe. */
316
- export declare function normalizeWorkingTreeRelativePath(value: string): string | null;
317
- export type WorkingTreeMirrorPlan = {
318
- /**
319
- * Every target path the mirror creates, rewrites, or verifies, ancestor
320
- * directories included. A gitlink is verified as a directory; paths a
321
- * submodule directory on the target shields are left out.
322
- */
323
- desired: Map<string, TreeEntry>;
324
- /**
325
- * Target entries the mirror removes or overwrites, as they are before it
326
- * runs. A directory entry means the whole subtree goes, ignored files
327
- * included; entries beneath it are folded into it. Never a gitlink: a
328
- * submodule directory stays, and only its index entry can change.
329
- */
330
- replaced: Map<string, TreeEntry>;
331
- /** Desired paths that have no target entry yet. */
332
- absent: string[];
333
- /** Index entries the mirror changes on a Git target; empty for any other target. */
334
- index: WorkingTreeIndexChanges;
335
- };
336
- /**
337
- * Compute exactly which target entries `mirrorWorkingTree` would remove,
338
- * overwrite, or create for the same input, without changing anything. The
339
- * removal set is the target's deletion-mode file set minus the desired paths.
340
- * A desired path replaces its target entry when the kinds differ, a symlink
341
- * points elsewhere, or a file's bytes or mode differ; an equal entry is left
342
- * alone, so the plan covers only what the mirror actually touches. A Git
343
- * target's ignored trees appear only where a desired path lands on them, and
344
- * its submodule directories only as index changes.
345
- */
346
- export declare function planWorkingTreeMirror(input: WorkingTreeMirrorInput): WorkingTreeMirrorPlan;
347
- /**
348
- * The plan for an apply pass over `prepared`, optionally restricted to a
349
- * selection (see `applyWorkingTreeMirror`): with one, only the selected
350
- * removals and writes count, an override always replaces its target entry,
351
- * and `desired` lists the selected writes plus the desired directories.
352
- */
353
- export declare function planPreparedWorkingTreeMirror(prepared: PreparedWorkingTreeMirror, options?: {
354
- selection?: WorkingTreeMirrorSelection;
355
- overrides?: ReadonlyMap<string, WorkingTreeMirrorOverride>;
356
- }): WorkingTreeMirrorPlan;
357
- /**
358
- * Undo the mutations a guarded apply pass journaled, in reverse order. A
359
- * replaced or removed entry the pass still retains (its very inode) is
360
- * switched back into place; one already released is rebuilt from the
361
- * snapshot `captureWorkingTreeMirrorPlan` took of the plan's replaced
362
- * entries. Every restore is itself a guarded switch: an entry is undone only
363
- * while the path still shows exactly what the mirror left there (or is still
364
- * absent where the mirror removed it), verified by the switch as it happens;
365
- * a path that another writer has touched since is left alone and reported in
366
- * `abandoned`. Directories the mirror created are removed only when empty.
367
- * Returns the target-relative paths it touched for the durability barrier,
368
- * and, when there are any, the writer's entries it had to keep aside.
369
- */
370
- export declare function rollbackWorkingTreeMirrorJournal(input: {
371
- journal: WorkingTreeMirrorJournal;
372
- targetRoot: string;
373
- snapshotRoot: string;
374
- }): {
375
- paths: string[];
376
- abandoned: string[];
377
- retained?: WorkingTreeRetainedForeignEntry[];
378
- };
379
- export type WorkingTreeMirrorScope = {
380
- /** Desired paths that did not exist before the mirror ran; a restore removes them. */
381
- absent: string[];
382
- /** Directories captured whole; a restore makes them identical to the snapshot again. */
383
- trees: string[];
384
- /** Index entries the mirror changed on a Git target; a restore drops the written gitlinks and puts the removed records back. */
385
- index?: WorkingTreeIndexChanges;
386
- };
387
- /**
388
- * Copy the entries a mirror plan replaces into `snapshotRoot` at their
389
- * target-relative paths, so that `restoreWorkingTreeMirrorScope` can undo the
390
- * mirror. Files and symlinks are copied individually and a replaced directory
391
- * is copied whole; ancestor directories appear only as containers. Returns
392
- * the scope that must be kept beside the snapshot.
393
- */
394
- export declare function captureWorkingTreeMirrorPlan(input: {
395
- plan: WorkingTreeMirrorPlan;
396
- targetRoot: string;
397
- snapshotRoot: string;
398
- durability?: WorkingTreeMirrorDurability;
399
- }): WorkingTreeMirrorScope;
400
- /**
401
- * Undo a mirror whose plan was captured with `captureWorkingTreeMirrorPlan`:
402
- * remove everything the mirror may have created, sweep its interrupted
403
- * temporary files, and put every captured entry back. Entries the plan did
404
- * not cover (a Git target's ignored files, for instance) are never read or
405
- * written. Safe to repeat after a partial run. Returns the target-relative
406
- * paths it removed or restored, for the caller's durability barrier.
407
- */
408
- export declare function restoreWorkingTreeMirrorScope(input: {
409
- snapshotRoot: string;
410
- targetRoot: string;
411
- scope: WorkingTreeMirrorScope;
412
- }): {
413
- paths: string[];
414
- };
415
- /**
416
- * Make the listed target-relative entries durable together with the directory
417
- * entries that name them: every listed regular file and real directory is
418
- * fsynced, and so is each listed path's parent directory and the root.
419
- * Symlinks and missing paths contribute only their parent, which is what
420
- * records their creation or removal. Ancestors are never followed through
421
- * symlinks. Nothing outside the listed paths is read.
422
- */
423
- export declare function fsyncWorkingTreePaths(root: string, relativePaths: Iterable<string>): void;
424
- export {};
@@ -1,57 +0,0 @@
1
- type ProjectTarget = {
2
- type: "project";
3
- projectId: string;
4
- branchName: string;
5
- };
6
- type WorkspaceTarget = {
7
- type: "workspace";
8
- rootProfile: "visible_projects" | "canonical_sync";
9
- };
10
- type PendingCreatedBranch = {
11
- projectId: string;
12
- branchName: string;
13
- };
14
- export declare const PENDING_CREATED_BRANCH_AUTOMATIC_SYNC_GRACE_MS = 120000;
15
- export type PendingCreatedBranchAutomaticSyncDeferral = {
16
- kind: "active_target";
17
- } | {
18
- kind: "creation_grace";
19
- retryAfterMs: number;
20
- };
21
- export declare function pendingCreatedBranchKey(projectId: string, branchName: string): string;
22
- export declare function hasActiveVisibleProjectsWorkspaceTarget(activeTargets: Iterable<ProjectTarget | WorkspaceTarget>): boolean;
23
- export declare function projectBranchHasActiveWorkspaceTarget(projectId: string, branchName: string, activeTargets: Iterable<ProjectTarget | WorkspaceTarget>): boolean;
24
- /**
25
- * Activity fence evaluated from inside the workspace mutation gate's exclusive
26
- * sync lease. Canonical-sync targets are deliberately absent: an immediately
27
- * reserved follow-up remediation command may already be queued, but the gate
28
- * proves that it cannot overlap this sync. A credential-bearing process group
29
- * that survived command teardown is tracked separately and still fails closed.
30
- */
31
- export declare function projectBranchMountBusyDuringExclusiveSync(input: {
32
- projectId: string;
33
- branchName: string;
34
- executionDisabled: boolean;
35
- worktreeOperationInProgress: boolean;
36
- retainedCanonicalProcessGroup: boolean;
37
- activeTargets: Iterable<ProjectTarget | WorkspaceTarget>;
38
- }): boolean;
39
- /** Fence visible activity and any retained canonical descendant that outlived its command lease. */
40
- export declare function workspacePlansMountBusyDuringExclusiveSync(activeTargets: Iterable<ProjectTarget | WorkspaceTarget>, retainedCanonicalProcessGroup?: boolean): boolean;
41
- /**
42
- * Keep automatic intent pending while an agent process is active on a
43
- * creator-local branch: the branch's mount would be skipped as busy anyway,
44
- * and the cycle's subprocess and disk work would only compete with that
45
- * process's next command. Its terminal trigger (or a later periodic/connect
46
- * cycle) publishes afterward. (The sync cycle itself now yields the event
47
- * loop while it runs; this deferral is about not starting pointless work,
48
- * not about loop starvation.)
49
- */
50
- export declare function shouldDeferAutomaticWorkspaceSyncForPendingBranch(pendingCreatedBranches: readonly PendingCreatedBranch[], activeTargets: Iterable<ProjectTarget | WorkspaceTarget>): boolean;
51
- /**
52
- * Automatic publication yields briefly after local branch creation so the
53
- * server can durably record the branch and reserve its first agent process.
54
- * Explicit/reconnect synchronization does not use this policy.
55
- */
56
- export declare function pendingCreatedBranchAutomaticSyncDeferral(pendingCreatedBranches: readonly PendingCreatedBranch[], activeTargets: Iterable<ProjectTarget | WorkspaceTarget>, publicationNotBeforeByBranch: ReadonlyMap<string, number>, nowMs?: number): PendingCreatedBranchAutomaticSyncDeferral | null;
57
- export {};
@@ -1,14 +0,0 @@
1
- type BranchIncarnation = {
2
- branchId?: string;
3
- };
4
- /**
5
- * Deletion is idempotent only while no same-name state belongs to another
6
- * durable row. Call this inside the workspace mutation lease, before creating
7
- * a tombstone or touching a checkout/ref.
8
- */
9
- export declare function assertProjectBranchDeletionIncarnation(input: {
10
- requiredBranchId: string;
11
- configuredBranch?: BranchIncarnation;
12
- pendingLocalBranch?: BranchIncarnation;
13
- }): void;
14
- export {};
@@ -1,57 +0,0 @@
1
- export type WorkspaceCommandTarget = {
2
- type: "project";
3
- projectId: string;
4
- branchName: string;
5
- } | {
6
- type: "workspace";
7
- rootProfile: "visible_projects" | "canonical_sync";
8
- };
9
- type WorkspaceCommandMutationCoordinator = {
10
- runMutation<T>(operation: () => Promise<T> | T): Promise<T>;
11
- acquireMutation(): Promise<() => void>;
12
- };
13
- export type WorkspaceSyncCompletionBarrier = {
14
- afterCurrent(): Promise<void>;
15
- /**
16
- * Null when no workspace filesystem job holds any of the targets' mounts
17
- * right now; otherwise a promise that settles once every current holder
18
- * released them (rejecting with WorkspaceMountHoldAbortedError when
19
- * `signal` aborts first). Workspace targets have no mount and never hold.
20
- */
21
- mountHold(targets: readonly WorkspaceCommandTarget[], signal?: AbortSignal): Promise<void> | null;
22
- };
23
- /**
24
- * A project command may reserve as soon as no workspace filesystem job holds
25
- * its mount: per-mount hydration and projection observe busy-ness before they
26
- * dispatch a job and hold the mount until the job ended, so a reservation
27
- * taken here is never interleaved with a job reading or writing the mount. A
28
- * visible-projects workspace command spans every project, so it keeps the
29
- * whole-cycle barrier. Canonical remediation is serialized separately by the
30
- * mutation gate. Commands without a workspace effect (incident-9 control
31
- * commands among them) never come here and never wait.
32
- *
33
- * A command may declare several targets (its own checkout plus the sibling
34
- * checkouts its session claimed). Every listed mount is reserved together:
35
- * the reservation happens only in a synchronous stretch in which none of
36
- * them is held, so a claimed mount that is mid-hydration delays the command
37
- * exactly as its own mount would.
38
- */
39
- export declare function reserveWorkspaceCommandAfterCurrentSync(target: WorkspaceCommandTarget | readonly WorkspaceCommandTarget[], coordinator: WorkspaceSyncCompletionBarrier, reserve: () => void, options?: {
40
- signal?: AbortSignal;
41
- }): Promise<void>;
42
- /**
43
- * Commands in visible checkouts behave like independent Git clients and may
44
- * overlap periodic synchronization. Canonical remediation commands mutate the
45
- * sync checkout itself, so they must remain serialized with synchronization.
46
- */
47
- export declare function shouldSerializeWorkspaceCommand(target: WorkspaceCommandTarget): boolean;
48
- export declare function runWorkspaceCommand<T>(target: WorkspaceCommandTarget, coordinator: WorkspaceCommandMutationCoordinator, operation: () => Promise<T> | T): Promise<T>;
49
- /**
50
- * Run a command whose target was reserved before asynchronous preparation.
51
- * For a serialized canonical command, the reservation must disappear inside
52
- * the mutation operation: removing it after `runMutation` resolves is too
53
- * late because releasing the lease can synchronously wake a queued sync.
54
- */
55
- export declare function runReservedWorkspaceCommand<T>(target: WorkspaceCommandTarget, coordinator: WorkspaceCommandMutationCoordinator, operation: () => Promise<T> | T, releaseReservation: () => void): Promise<T>;
56
- export declare function acquireWorkspaceCommandMutation(target: WorkspaceCommandTarget, coordinator: WorkspaceCommandMutationCoordinator): Promise<(() => void) | undefined>;
57
- export {};
@@ -1,37 +0,0 @@
1
- /**
2
- * Declared additional targets of a command, PTY or one-shot exec.
3
- *
4
- * A server that forwards a session's live `checkout` claims attaches the
5
- * claimed sibling checkouts as `additionalTargets`. The worker treats every
6
- * listed project branch exactly like the command's own target for admission
7
- * (every mount is reserved and waits on the hold fence), busy detection and
8
- * mutation tokens, for the whole lifetime of the process: the list is fixed
9
- * when the command is admitted and only the process exit removes it. The
10
- * primary target alone keeps environment attribution, the plans-mount
11
- * predicate and credential-bearing process-group ownership.
12
- */
13
- export type WorkspaceCommandProjectTarget = {
14
- type: "project";
15
- projectId: string;
16
- branchName: string;
17
- };
18
- export type WorkspaceCommandAnyTarget = WorkspaceCommandProjectTarget | {
19
- type: "workspace";
20
- ownerUserId: string;
21
- rootProfile: "visible_projects" | "canonical_sync";
22
- };
23
- export type WorkspaceCommandTargetValidators = {
24
- validateProjectId: (projectId: string) => void;
25
- validateBranchName: (branchName: string) => void;
26
- };
27
- /**
28
- * The additional targets a message declares, checked and deduplicated: only
29
- * project branches, each structurally valid, none equal to the primary
30
- * target. A malformed entry is a protocol violation and fails the command
31
- * before admission rather than silently narrowing its fence.
32
- */
33
- export declare function normalizeCommandAdditionalTargets(primary: WorkspaceCommandAnyTarget, additional: unknown, validators: WorkspaceCommandTargetValidators): WorkspaceCommandProjectTarget[];
34
- /** Every target a command fences, primary first. */
35
- export declare function commandTargets<T extends WorkspaceCommandAnyTarget>(primary: T, additional: readonly WorkspaceCommandProjectTarget[]): Array<T | WorkspaceCommandProjectTarget>;
36
- /** Log suffix naming the additional checkouts a command fences; empty when there are none. */
37
- export declare function describeCommandAdditionalTargets(additional: readonly WorkspaceCommandProjectTarget[]): string;
@@ -1 +0,0 @@
1
- export {};