@ricsam/r5d-worker 0.0.97 → 0.0.100
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.
- package/dist/cjs/main.cjs +37 -5
- package/dist/cjs/package.json +1 -1
- package/dist/cjs/working-tree-mirror.cjs +256 -4
- package/dist/cjs/workspace-git-sync.cjs +179 -87
- package/dist/mjs/main.mjs +37 -5
- package/dist/mjs/package.json +1 -1
- package/dist/mjs/working-tree-mirror.mjs +250 -3
- package/dist/mjs/workspace-git-sync.mjs +188 -88
- package/dist/types/main.d.ts +181 -0
- package/dist/types/working-tree-mirror.d.ts +80 -1
- package/dist/types/workspace-git-sync.d.ts +25 -0
- package/package.json +1 -1
|
@@ -20,7 +20,14 @@ export type TreeEntry = {
|
|
|
20
20
|
* every portable alias must be remediated before the old tree is retired.
|
|
21
21
|
*/
|
|
22
22
|
export declare function assertWorkingTreeHasNoPortableGitMetadataAliases(root: string): void;
|
|
23
|
-
export declare function inspectWorkingTree(root: string, mode: WorkingTreeSourceMode
|
|
23
|
+
export declare function inspectWorkingTree(root: string, mode: WorkingTreeSourceMode, options?: {
|
|
24
|
+
/**
|
|
25
|
+
* Leave an uninitialized submodule (index gitlink whose directory is
|
|
26
|
+
* empty) out of a Git-mode inspection. Its empty directory is what keeps
|
|
27
|
+
* `git status` clean, so a deletion set must never remove it.
|
|
28
|
+
*/
|
|
29
|
+
omitUnpopulatedGitlinks?: boolean;
|
|
30
|
+
}): Map<string, TreeEntry>;
|
|
24
31
|
export declare function mirrorWorkingTree(input: {
|
|
25
32
|
sourceRoot: string;
|
|
26
33
|
targetRoot: string;
|
|
@@ -35,3 +42,75 @@ export declare function mirrorWorkingTree(input: {
|
|
|
35
42
|
}): {
|
|
36
43
|
paths: string[];
|
|
37
44
|
};
|
|
45
|
+
/** Canonical relative form used by mirror plans and scopes, or null when the value is unsafe. */
|
|
46
|
+
export declare function normalizeWorkingTreeRelativePath(value: string): string | null;
|
|
47
|
+
export type WorkingTreeMirrorPlan = {
|
|
48
|
+
/** Every target path the mirror creates, rewrites, or verifies, ancestor directories included. */
|
|
49
|
+
desired: Map<string, TreeEntry>;
|
|
50
|
+
/**
|
|
51
|
+
* Target entries the mirror removes or overwrites, as they are before it
|
|
52
|
+
* runs. A directory entry means the whole subtree goes, ignored files
|
|
53
|
+
* included; entries beneath it are folded into it.
|
|
54
|
+
*/
|
|
55
|
+
replaced: Map<string, TreeEntry>;
|
|
56
|
+
/** Desired paths that have no target entry yet. */
|
|
57
|
+
absent: string[];
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Compute exactly which target entries `mirrorWorkingTree` would remove,
|
|
61
|
+
* overwrite, or create for the same input, without changing anything. The
|
|
62
|
+
* removal set is the target's deletion-mode file set minus the desired paths.
|
|
63
|
+
* A desired path replaces its target entry when the kinds differ, a symlink
|
|
64
|
+
* points elsewhere, or a file's bytes or mode differ; an equal entry is left
|
|
65
|
+
* alone, so the plan covers only what the mirror actually touches. A Git
|
|
66
|
+
* target's ignored trees appear only where a desired path lands on them.
|
|
67
|
+
*/
|
|
68
|
+
export declare function planWorkingTreeMirror(input: {
|
|
69
|
+
sourceRoot: string;
|
|
70
|
+
targetRoot: string;
|
|
71
|
+
sourceMode: WorkingTreeSourceMode;
|
|
72
|
+
deletionMode: WorkingTreeDeletionMode;
|
|
73
|
+
}): WorkingTreeMirrorPlan;
|
|
74
|
+
export type WorkingTreeMirrorScope = {
|
|
75
|
+
/** Desired paths that did not exist before the mirror ran; a restore removes them. */
|
|
76
|
+
absent: string[];
|
|
77
|
+
/** Directories captured whole; a restore makes them identical to the snapshot again. */
|
|
78
|
+
trees: string[];
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Copy the entries a mirror plan replaces into `snapshotRoot` at their
|
|
82
|
+
* target-relative paths, so that `restoreWorkingTreeMirrorScope` can undo the
|
|
83
|
+
* mirror. Files and symlinks are copied individually and a replaced directory
|
|
84
|
+
* is copied whole; ancestor directories appear only as containers. Returns
|
|
85
|
+
* the scope that must be kept beside the snapshot.
|
|
86
|
+
*/
|
|
87
|
+
export declare function captureWorkingTreeMirrorPlan(input: {
|
|
88
|
+
plan: WorkingTreeMirrorPlan;
|
|
89
|
+
targetRoot: string;
|
|
90
|
+
snapshotRoot: string;
|
|
91
|
+
durability?: WorkingTreeMirrorDurability;
|
|
92
|
+
}): WorkingTreeMirrorScope;
|
|
93
|
+
/**
|
|
94
|
+
* Undo a mirror whose plan was captured with `captureWorkingTreeMirrorPlan`:
|
|
95
|
+
* remove everything the mirror may have created, sweep its interrupted
|
|
96
|
+
* temporary files, and put every captured entry back. Entries the plan did
|
|
97
|
+
* not cover (a Git target's ignored files, for instance) are never read or
|
|
98
|
+
* written. Safe to repeat after a partial run. Returns the target-relative
|
|
99
|
+
* paths it removed or restored, for the caller's durability barrier.
|
|
100
|
+
*/
|
|
101
|
+
export declare function restoreWorkingTreeMirrorScope(input: {
|
|
102
|
+
snapshotRoot: string;
|
|
103
|
+
targetRoot: string;
|
|
104
|
+
scope: WorkingTreeMirrorScope;
|
|
105
|
+
}): {
|
|
106
|
+
paths: string[];
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* Make the listed target-relative entries durable together with the directory
|
|
110
|
+
* entries that name them: every listed regular file and real directory is
|
|
111
|
+
* fsynced, and so is each listed path's parent directory and the root.
|
|
112
|
+
* Symlinks and missing paths contribute only their parent, which is what
|
|
113
|
+
* records their creation or removal. Ancestors are never followed through
|
|
114
|
+
* symlinks. Nothing outside the listed paths is read.
|
|
115
|
+
*/
|
|
116
|
+
export declare function fsyncWorkingTreePaths(root: string, relativePaths: Iterable<string>): void;
|
|
@@ -49,6 +49,26 @@ export type WorkspaceGitMount = {
|
|
|
49
49
|
* unready state for concurrent visible work.
|
|
50
50
|
*/
|
|
51
51
|
export declare function workspaceGitMountsForRemediation(mounts: readonly WorkspaceGitMount[]): WorkspaceGitMount[];
|
|
52
|
+
export type WorkspaceHydrationTransactionContext = {
|
|
53
|
+
/** Unique per transaction; pairs the begin and end observations. */
|
|
54
|
+
transactionId: string;
|
|
55
|
+
workspacePath: string;
|
|
56
|
+
/** Mounts the transaction may hydrate or carry across the durability barrier. */
|
|
57
|
+
mountIds: string[];
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Observes the synchronous body of a hydration transaction (snapshot,
|
|
61
|
+
* hydration pass, durability barrier, receipt). That body deliberately never
|
|
62
|
+
* yields, so the worker cannot answer control-socket messages while it runs,
|
|
63
|
+
* and on a slow disk it can run for hours. `beforeTransaction` is awaited
|
|
64
|
+
* after the last asynchronous precheck and before the final busy observation,
|
|
65
|
+
* so it may announce the operation and yield once; `afterTransaction` runs
|
|
66
|
+
* after the body committed or rolled back.
|
|
67
|
+
*/
|
|
68
|
+
export type WorkspaceHydrationTransactionHooks = {
|
|
69
|
+
beforeTransaction: (context: WorkspaceHydrationTransactionContext) => Promise<void> | void;
|
|
70
|
+
afterTransaction: (context: WorkspaceHydrationTransactionContext) => void;
|
|
71
|
+
};
|
|
52
72
|
export type WorkspaceGitSyncOutcome = "no_change" | "updated" | "pushed" | "large_diff_blocked" | "conflict_blocked";
|
|
53
73
|
export type WorkspaceGitSyncResult = {
|
|
54
74
|
outcome: WorkspaceGitSyncOutcome;
|
|
@@ -137,6 +157,7 @@ export declare function ensureWorkspaceGitClone(input: {
|
|
|
137
157
|
declare function mirrorMountsToWorkspace(workspacePath: string, mounts: readonly WorkspaceGitMount[]): void;
|
|
138
158
|
export declare function hydrateWorkspaceGitMounts(workspacePath: string, mounts: readonly WorkspaceGitMount[], options?: {
|
|
139
159
|
ignoreBusy?: boolean;
|
|
160
|
+
hydrationHooks?: WorkspaceHydrationTransactionHooks;
|
|
140
161
|
}): Promise<{
|
|
141
162
|
hydratedMountIds: string[];
|
|
142
163
|
skippedMountIds: string[];
|
|
@@ -146,6 +167,7 @@ export declare function recoverWorkspaceGitHydration(workspacePath: string, moun
|
|
|
146
167
|
deferMountIds?: ReadonlySet<string>;
|
|
147
168
|
preserveResolutionInProgress?: boolean;
|
|
148
169
|
preserveStaleBases?: boolean;
|
|
170
|
+
hydrationHooks?: WorkspaceHydrationTransactionHooks;
|
|
149
171
|
}): Promise<void>;
|
|
150
172
|
export declare function resetWorkspaceGit(input: {
|
|
151
173
|
workspacePath: string;
|
|
@@ -157,6 +179,7 @@ export declare function resetWorkspaceGit(input: {
|
|
|
157
179
|
email: string;
|
|
158
180
|
};
|
|
159
181
|
mounts: readonly WorkspaceGitMount[];
|
|
182
|
+
hydrationHooks?: WorkspaceHydrationTransactionHooks;
|
|
160
183
|
}): Promise<{
|
|
161
184
|
startingHead: string | null;
|
|
162
185
|
localHead: string | null;
|
|
@@ -194,6 +217,8 @@ export declare function synchronizeWorkspaceGit(input: {
|
|
|
194
217
|
publishedHead: string;
|
|
195
218
|
activeMountIds: string[];
|
|
196
219
|
}) => void | Promise<void>;
|
|
220
|
+
/** Announces each synchronous hydration transaction of this cycle; see WorkspaceHydrationTransactionHooks. */
|
|
221
|
+
hydrationHooks?: WorkspaceHydrationTransactionHooks;
|
|
197
222
|
}): Promise<WorkspaceGitSyncResult>;
|
|
198
223
|
export declare const workspaceGitSyncTestHarness: {
|
|
199
224
|
commandArgs: typeof gitCommandArgs;
|