@ricsam/r5d-worker 0.0.132 → 0.0.133
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/atomic-rename.cjs +303 -0
- package/dist/cjs/git-blob-hash.cjs +41 -0
- package/dist/cjs/main.cjs +187 -38
- package/dist/cjs/package.json +1 -1
- package/dist/cjs/three-way-merge.cjs +346 -0
- package/dist/cjs/working-tree-mirror.cjs +1049 -64
- package/dist/cjs/workspace-command-sync-policy.cjs +8 -4
- package/dist/cjs/workspace-command-targets.cjs +63 -0
- package/dist/cjs/workspace-filesystem-job-types.cjs +11 -1
- package/dist/cjs/workspace-filesystem-jobs.cjs +2 -0
- package/dist/cjs/workspace-git-sync.cjs +846 -61
- package/dist/cjs/workspace-hydration-ledger.cjs +66 -0
- package/dist/cjs/workspace-hydration-merge.cjs +433 -0
- package/dist/cjs/workspace-hydration-recovery-state.cjs +53 -0
- package/dist/cjs/workspace-merge-projection.cjs +81 -10
- package/dist/cjs/workspace-project-config-policy.cjs +19 -12
- package/dist/mjs/atomic-rename.mjs +261 -0
- package/dist/mjs/git-blob-hash.mjs +16 -0
- package/dist/mjs/main.mjs +196 -39
- package/dist/mjs/package.json +1 -1
- package/dist/mjs/three-way-merge.mjs +318 -0
- package/dist/mjs/working-tree-mirror.mjs +1035 -64
- package/dist/mjs/workspace-command-sync-policy.mjs +8 -4
- package/dist/mjs/workspace-command-targets.mjs +37 -0
- package/dist/mjs/workspace-filesystem-job-types.mjs +11 -1
- package/dist/mjs/workspace-filesystem-jobs.mjs +4 -0
- package/dist/mjs/workspace-git-sync.mjs +854 -62
- package/dist/mjs/workspace-hydration-ledger.mjs +42 -0
- package/dist/mjs/workspace-hydration-merge.mjs +399 -0
- package/dist/mjs/workspace-hydration-recovery-state.mjs +29 -0
- package/dist/mjs/workspace-merge-projection.mjs +85 -11
- package/dist/mjs/workspace-project-config-policy.mjs +16 -10
- package/dist/types/atomic-rename.d.ts +78 -0
- package/dist/types/git-blob-hash.d.ts +10 -0
- package/dist/types/main.d.ts +21 -2
- package/dist/types/three-way-merge.d.ts +77 -0
- package/dist/types/working-tree-mirror.d.ts +270 -7
- package/dist/types/workspace-command-sync-policy.d.ts +12 -6
- package/dist/types/workspace-command-targets.d.ts +37 -0
- package/dist/types/workspace-filesystem-job-types.d.ts +46 -4
- package/dist/types/workspace-git-sync.d.ts +125 -3
- package/dist/types/workspace-hydration-ledger.d.ts +43 -0
- package/dist/types/workspace-hydration-merge.d.ts +95 -0
- package/dist/types/workspace-hydration-recovery-state.d.ts +10 -0
- package/dist/types/workspace-merge-projection.d.ts +19 -1
- package/dist/types/workspace-project-config-policy.d.ts +17 -3
- package/package.json +2 -2
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
import { WorkspaceMountHoldAbortedError } from "./workspace-mount-hold-fence.mjs";
|
|
2
|
-
function requiresCurrentSyncBarrier(
|
|
3
|
-
return target.type === "workspace" && target.rootProfile === "visible_projects";
|
|
2
|
+
function requiresCurrentSyncBarrier(targets) {
|
|
3
|
+
return targets.some((target) => target.type === "workspace" && target.rootProfile === "visible_projects");
|
|
4
|
+
}
|
|
5
|
+
function asTargetList(target) {
|
|
6
|
+
return Array.isArray(target) ? target : [target];
|
|
4
7
|
}
|
|
5
8
|
async function reserveWorkspaceCommandAfterCurrentSync(target, coordinator, reserve, options = {}) {
|
|
9
|
+
const targets = asTargetList(target);
|
|
6
10
|
while (true) {
|
|
7
|
-
if (requiresCurrentSyncBarrier(
|
|
11
|
+
if (requiresCurrentSyncBarrier(targets)) {
|
|
8
12
|
const currentSync = coordinator.afterCurrent();
|
|
9
13
|
await raceWithAbort(currentSync, options.signal);
|
|
10
14
|
if (currentSync !== coordinator.afterCurrent()) continue;
|
|
11
15
|
}
|
|
12
16
|
if (options.signal?.aborted) throw new WorkspaceMountHoldAbortedError(abortReason(options.signal));
|
|
13
|
-
const hold = coordinator.mountHold(
|
|
17
|
+
const hold = coordinator.mountHold(targets, options.signal);
|
|
14
18
|
if (hold) {
|
|
15
19
|
await hold;
|
|
16
20
|
continue;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
function targetKey(target) {
|
|
2
|
+
return `${target.projectId}\0${target.branchName}`;
|
|
3
|
+
}
|
|
4
|
+
function normalizeCommandAdditionalTargets(primary, additional, validators) {
|
|
5
|
+
if (additional === void 0 || additional === null) return [];
|
|
6
|
+
if (!Array.isArray(additional)) throw new Error("Command additional targets must be a list of project branches");
|
|
7
|
+
const seen = new Set(primary.type === "project" ? [targetKey(primary)] : []);
|
|
8
|
+
const normalized = [];
|
|
9
|
+
for (const entry of additional) {
|
|
10
|
+
if (!entry || typeof entry !== "object" || entry.type !== "project") {
|
|
11
|
+
throw new Error("Command additional targets must be project branches");
|
|
12
|
+
}
|
|
13
|
+
const { projectId, branchName } = entry;
|
|
14
|
+
if (typeof projectId !== "string" || typeof branchName !== "string")
|
|
15
|
+
throw new Error("Command additional target is missing its project or branch");
|
|
16
|
+
validators.validateProjectId(projectId);
|
|
17
|
+
validators.validateBranchName(branchName);
|
|
18
|
+
const target = { type: "project", projectId, branchName };
|
|
19
|
+
const key = targetKey(target);
|
|
20
|
+
if (seen.has(key)) continue;
|
|
21
|
+
seen.add(key);
|
|
22
|
+
normalized.push(target);
|
|
23
|
+
}
|
|
24
|
+
return normalized;
|
|
25
|
+
}
|
|
26
|
+
function commandTargets(primary, additional) {
|
|
27
|
+
return [primary, ...additional];
|
|
28
|
+
}
|
|
29
|
+
function describeCommandAdditionalTargets(additional) {
|
|
30
|
+
if (additional.length === 0) return "";
|
|
31
|
+
return ` (also fencing ${additional.map((target) => `${target.projectId}/${target.branchName}`).join(", ")})`;
|
|
32
|
+
}
|
|
33
|
+
export {
|
|
34
|
+
commandTargets,
|
|
35
|
+
describeCommandAdditionalTargets,
|
|
36
|
+
normalizeCommandAdditionalTargets
|
|
37
|
+
};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
const WORKSPACE_FILESYSTEM_JOB_KINDS = [
|
|
2
2
|
"checkout_durability_recovery",
|
|
3
3
|
"hydration_recovery",
|
|
4
|
+
"hydration_recovery_inspect",
|
|
5
|
+
"hydration_preserve_interrupted",
|
|
4
6
|
"hydration_transaction",
|
|
5
7
|
"hydration_raw",
|
|
6
8
|
"checkout_transition_begin",
|
|
@@ -30,13 +32,19 @@ function describeWorkspaceFilesystemJob(kind, input) {
|
|
|
30
32
|
switch (kind) {
|
|
31
33
|
case "checkout_durability_recovery":
|
|
32
34
|
case "hydration_recovery":
|
|
35
|
+
case "hydration_recovery_inspect":
|
|
33
36
|
case "checkout_transition_begin":
|
|
34
37
|
case "checkout_transition_complete":
|
|
35
38
|
case "outer_checkout_fsync":
|
|
36
39
|
return `${kind.replaceAll("_", " ")} of ${input.workspacePath}`;
|
|
40
|
+
case "hydration_preserve_interrupted": {
|
|
41
|
+
const recovery = input;
|
|
42
|
+
return `preservation of hydration transaction ${recovery.expectedTransactionId} in ${recovery.workspacePath}`;
|
|
43
|
+
}
|
|
37
44
|
case "hydration_transaction": {
|
|
38
45
|
const hydration = input;
|
|
39
|
-
|
|
46
|
+
const merged = Object.keys(hydration.mergeBases ?? {}).length;
|
|
47
|
+
return `hydration of ${summarizeIds(hydration.hydrationMounts.map(({ id }) => id))}${merged > 0 ? ` (${merged} merge-hydrated)` : ""} (durability ${summarizeIds(hydration.advancedDurabilityMounts.map(({ id }) => id))})`;
|
|
40
48
|
}
|
|
41
49
|
case "hydration_raw":
|
|
42
50
|
return `pre-clone hydration of ${summarizeIds(input.mounts.map(({ id }) => id))}`;
|
|
@@ -77,6 +85,7 @@ function serializeWorkspaceFilesystemError(error, depth = 0) {
|
|
|
77
85
|
if (typeof error.stack === "string") serialized.stack = error.stack;
|
|
78
86
|
if (typeof record.code === "string") serialized.code = record.code;
|
|
79
87
|
if (record.branchMayExist === true) serialized.branchMayExist = true;
|
|
88
|
+
if (record.hydrationRecovery) serialized.hydrationRecovery = structuredClone(record.hydrationRecovery);
|
|
80
89
|
if (Array.isArray(record.cleanupFailures) && record.cleanupFailures.every((failure) => typeof failure === "string")) {
|
|
81
90
|
serialized.cleanupFailures = [...record.cleanupFailures];
|
|
82
91
|
}
|
|
@@ -95,6 +104,7 @@ function restoreWorkspaceFilesystemError(serialized) {
|
|
|
95
104
|
if (serialized.code !== void 0) error.code = serialized.code;
|
|
96
105
|
if (serialized.branchMayExist) error.branchMayExist = true;
|
|
97
106
|
if (serialized.cleanupFailures) error.cleanupFailures = [...serialized.cleanupFailures];
|
|
107
|
+
if (serialized.hydrationRecovery) error.hydrationRecovery = structuredClone(serialized.hydrationRecovery);
|
|
98
108
|
return error;
|
|
99
109
|
}
|
|
100
110
|
export {
|
|
@@ -12,6 +12,8 @@ import {
|
|
|
12
12
|
runCheckoutTransitionCompleteJob,
|
|
13
13
|
runHydrationRawJob,
|
|
14
14
|
runHydrationRecoveryJob,
|
|
15
|
+
runHydrationRecoveryInspectJob,
|
|
16
|
+
runHydrationPreserveInterruptedJob,
|
|
15
17
|
runHydrationTransactionJob,
|
|
16
18
|
runOuterCheckoutFsyncJob,
|
|
17
19
|
runProjectionMirrorJob,
|
|
@@ -23,6 +25,8 @@ import { preserveProjectCheckoutPathMove } from "./workspace-path-move.mjs";
|
|
|
23
25
|
const workspaceFilesystemJobOperations = {
|
|
24
26
|
checkout_durability_recovery: (input) => runCheckoutDurabilityRecoveryJob(input),
|
|
25
27
|
hydration_recovery: (input) => runHydrationRecoveryJob(input),
|
|
28
|
+
hydration_recovery_inspect: (input) => runHydrationRecoveryInspectJob(input),
|
|
29
|
+
hydration_preserve_interrupted: (input) => runHydrationPreserveInterruptedJob(input),
|
|
26
30
|
hydration_transaction: (input) => runHydrationTransactionJob(input),
|
|
27
31
|
hydration_raw: (input) => runHydrationRawJob(input),
|
|
28
32
|
checkout_transition_begin: (input) => runCheckoutTransitionBeginJob(input),
|