@ricsam/r5d-worker 0.0.86 → 0.0.87
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 +98 -64
- package/dist/cjs/package.json +1 -1
- package/dist/cjs/project-worktrees.cjs +183 -104
- package/dist/cjs/workspace-git-sync.cjs +491 -189
- package/dist/mjs/main.mjs +98 -64
- package/dist/mjs/package.json +1 -1
- package/dist/mjs/project-worktrees.mjs +183 -104
- package/dist/mjs/workspace-git-sync.mjs +491 -189
- package/dist/types/project-worktrees.d.ts +12 -12
- package/dist/types/workspace-automatic-sync-policy.d.ts +7 -4
- package/dist/types/workspace-git-sync.d.ts +9 -9
- package/package.json +1 -1
package/dist/cjs/main.cjs
CHANGED
|
@@ -839,6 +839,33 @@ function tryGit(args, options = {}) {
|
|
|
839
839
|
return false;
|
|
840
840
|
}
|
|
841
841
|
}
|
|
842
|
+
async function runGitAsync(args, options = {}) {
|
|
843
|
+
const command = workerGitCommand.commandArgs(args);
|
|
844
|
+
const subprocess = Bun.spawn(command, {
|
|
845
|
+
cwd: options.cwd,
|
|
846
|
+
stdin: "ignore",
|
|
847
|
+
stdout: "pipe",
|
|
848
|
+
stderr: "pipe",
|
|
849
|
+
env: (0, import_git_process_environment.workerGitProcessEnvironment)()
|
|
850
|
+
});
|
|
851
|
+
const [stdout, stderr, exitCode] = await Promise.all([
|
|
852
|
+
new Response(subprocess.stdout).text(),
|
|
853
|
+
new Response(subprocess.stderr).text(),
|
|
854
|
+
subprocess.exited
|
|
855
|
+
]);
|
|
856
|
+
if (exitCode !== 0) {
|
|
857
|
+
throw new Error(`git ${args.join(" ")} failed: ${stderr.trim() || stdout.trim() || `exit ${exitCode}`}`);
|
|
858
|
+
}
|
|
859
|
+
return stdout.trim();
|
|
860
|
+
}
|
|
861
|
+
async function tryGitAsync(args, options = {}) {
|
|
862
|
+
try {
|
|
863
|
+
await runGitAsync(args, options);
|
|
864
|
+
return true;
|
|
865
|
+
} catch {
|
|
866
|
+
return false;
|
|
867
|
+
}
|
|
868
|
+
}
|
|
842
869
|
function getGitBlobHashForContent(content) {
|
|
843
870
|
const buffer = typeof content === "string" ? Buffer.from(content, "utf8") : content;
|
|
844
871
|
return (0, import_node_crypto.createHash)("sha1").update(`blob ${buffer.length}\0`).update(buffer).digest("hex");
|
|
@@ -3810,10 +3837,14 @@ async function startWorker(options) {
|
|
|
3810
3837
|
}
|
|
3811
3838
|
return mounts;
|
|
3812
3839
|
};
|
|
3813
|
-
const workspaceLocalHead = () =>
|
|
3814
|
-
|
|
3840
|
+
const workspaceLocalHead = async () => {
|
|
3841
|
+
if (!import_node_fs.default.existsSync(import_node_path.default.join(workspaceShadowRoot, ".git"))) return null;
|
|
3842
|
+
if (!await tryGitAsync(["rev-parse", "--verify", "HEAD"], { cwd: workspaceShadowRoot })) return null;
|
|
3843
|
+
return runGitAsync(["rev-parse", "HEAD"], { cwd: workspaceShadowRoot });
|
|
3844
|
+
};
|
|
3845
|
+
const workspaceGitStatus = async () => {
|
|
3815
3846
|
try {
|
|
3816
|
-
return
|
|
3847
|
+
return await runGitAsync(["status", "--porcelain"], { cwd: workspaceShadowRoot });
|
|
3817
3848
|
} catch {
|
|
3818
3849
|
return "";
|
|
3819
3850
|
}
|
|
@@ -3826,7 +3857,7 @@ async function startWorker(options) {
|
|
|
3826
3857
|
})
|
|
3827
3858
|
)
|
|
3828
3859
|
].sort();
|
|
3829
|
-
const ensureConfiguredProjects = () => {
|
|
3860
|
+
const ensureConfiguredProjects = async () => {
|
|
3830
3861
|
for (const project of projectConfigById.values()) {
|
|
3831
3862
|
validateProjectId(project.projectId);
|
|
3832
3863
|
(0, import_repository_transition_policy.assertRepositoryTransitionState)(project);
|
|
@@ -3863,7 +3894,7 @@ async function startWorker(options) {
|
|
|
3863
3894
|
}
|
|
3864
3895
|
try {
|
|
3865
3896
|
const connection = projectConnection(project);
|
|
3866
|
-
const states = (0, import_project_worktrees.ensureProjectWorktrees)({
|
|
3897
|
+
const states = await (0, import_project_worktrees.ensureProjectWorktrees)({
|
|
3867
3898
|
projectRoot,
|
|
3868
3899
|
snapshotRoot: projectWorktreeSnapshotsRoot,
|
|
3869
3900
|
primaryBranchName: primaryProjectBranch(project),
|
|
@@ -3912,13 +3943,13 @@ async function startWorker(options) {
|
|
|
3912
3943
|
}
|
|
3913
3944
|
}
|
|
3914
3945
|
};
|
|
3915
|
-
const collectAheadOfOriginBranches = () => {
|
|
3946
|
+
const collectAheadOfOriginBranches = async () => {
|
|
3916
3947
|
const aheadBranches = [];
|
|
3917
3948
|
for (const project of projectConfigById.values()) {
|
|
3918
3949
|
if (project.executionDisabled || !readyProjectIds.has(project.projectId) || project.branches.length === 0) continue;
|
|
3919
3950
|
const connection = projectConnection(project);
|
|
3920
3951
|
const primaryPath = configuredProjectBranchPath(projectsRoot, project, primaryProjectBranch(project));
|
|
3921
|
-
if (!
|
|
3952
|
+
if (!await tryGitAsync(
|
|
3922
3953
|
[
|
|
3923
3954
|
...(0, import_git_process_environment.gitTransportSecurityArgs)(connection.originUrl, connection.credentialHelper, connection.originCredentialUsername),
|
|
3924
3955
|
"fetch",
|
|
@@ -3942,11 +3973,11 @@ async function startWorker(options) {
|
|
|
3942
3973
|
primaryBranchName: primaryProjectBranch(project),
|
|
3943
3974
|
defaultBranch: project.defaultBranch
|
|
3944
3975
|
})}`;
|
|
3945
|
-
if (
|
|
3946
|
-
const counts =
|
|
3976
|
+
if (await tryGitAsync(["show-ref", "--verify", "--quiet", originRef], { cwd: branchPath })) {
|
|
3977
|
+
const counts = (await runGitAsync(["rev-list", "--left-right", "--count", `${originRef}...HEAD`], { cwd: branchPath })).split(/\s+/).map(Number);
|
|
3947
3978
|
ahead = Number.isSafeInteger(counts[1]) ? counts[1] : 0;
|
|
3948
|
-
} else if (
|
|
3949
|
-
const count = Number(
|
|
3979
|
+
} else if (await tryGitAsync(["cat-file", "-e", `${branch.baseCommitHash}^{commit}`], { cwd: branchPath })) {
|
|
3980
|
+
const count = Number(await runGitAsync(["rev-list", "--count", `${branch.baseCommitHash}..HEAD`], { cwd: branchPath }));
|
|
3950
3981
|
ahead = Number.isSafeInteger(count) ? count : 0;
|
|
3951
3982
|
}
|
|
3952
3983
|
if (ahead > 0) aheadBranches.push({ projectId: project.projectId, branchName: branch.branchName, ahead });
|
|
@@ -3962,19 +3993,19 @@ async function startWorker(options) {
|
|
|
3962
3993
|
(left, right) => left.projectId.localeCompare(right.projectId) || left.branchName.localeCompare(right.branchName)
|
|
3963
3994
|
);
|
|
3964
3995
|
};
|
|
3965
|
-
const captureProjectHeadsForWorkspacePublication = () => {
|
|
3996
|
+
const captureProjectHeadsForWorkspacePublication = async () => {
|
|
3966
3997
|
const heads = /* @__PURE__ */ new Map();
|
|
3967
3998
|
for (const project of projectConfigById.values()) {
|
|
3968
3999
|
if (!readyProjectIds.has(project.projectId)) continue;
|
|
3969
4000
|
for (const branch of project.branches) {
|
|
3970
4001
|
const branchPath = configuredProjectBranchPath(projectsRoot, project, branch.branchName);
|
|
3971
4002
|
if (!hasProjectWorktree(branchPath)) continue;
|
|
3972
|
-
heads.set(projectMountId(project.projectId, branch.branchName),
|
|
4003
|
+
heads.set(projectMountId(project.projectId, branch.branchName), await runGitAsync(["rev-parse", "HEAD"], { cwd: branchPath }));
|
|
3973
4004
|
}
|
|
3974
4005
|
}
|
|
3975
4006
|
return heads;
|
|
3976
4007
|
};
|
|
3977
|
-
const pushChangedProjectHeads = (activeMountIds, publishedHead, publicationHeads, suppressedMountIds = /* @__PURE__ */ new Set()) => {
|
|
4008
|
+
const pushChangedProjectHeads = async (activeMountIds, publishedHead, publicationHeads, suppressedMountIds = /* @__PURE__ */ new Set()) => {
|
|
3978
4009
|
const active = new Set(activeMountIds);
|
|
3979
4010
|
for (const project of projectConfigById.values()) {
|
|
3980
4011
|
if (!readyProjectIds.has(project.projectId) || !(0, import_repository_transition_policy.repositoryMirrorWritesAllowed)(project)) continue;
|
|
@@ -3990,7 +4021,7 @@ async function startWorker(options) {
|
|
|
3990
4021
|
}
|
|
3991
4022
|
if (changed.size === 0) continue;
|
|
3992
4023
|
const connection = projectConnection(project);
|
|
3993
|
-
const results = (0, import_project_worktrees.pushProjectMirrorHeads)({
|
|
4024
|
+
const results = await (0, import_project_worktrees.pushProjectMirrorHeads)({
|
|
3994
4025
|
projectRoot: configuredProjectRoot(projectsRoot, project),
|
|
3995
4026
|
branchNames: project.branches.map(({ branchName }) => branchName),
|
|
3996
4027
|
mirrorUrl: connection.mirrorUrl,
|
|
@@ -4021,7 +4052,7 @@ async function startWorker(options) {
|
|
|
4021
4052
|
if (!active.has(deletion.id)) continue;
|
|
4022
4053
|
if (!(0, import_repository_transition_policy.repositoryMirrorWritesAllowed)(projectConfigById.get(deletion.projectId))) continue;
|
|
4023
4054
|
if (!deletion.projectDeleted) {
|
|
4024
|
-
(0, import_project_worktrees.deleteProjectMirrorBranch)({
|
|
4055
|
+
await (0, import_project_worktrees.deleteProjectMirrorBranch)({
|
|
4025
4056
|
gitDirectory: deletion.gitDirectory,
|
|
4026
4057
|
branchName: deletion.branchName,
|
|
4027
4058
|
mirrorUrl: deletion.mirrorUrl,
|
|
@@ -4042,7 +4073,7 @@ async function startWorker(options) {
|
|
|
4042
4073
|
lastObservedProjectHeads.delete(key);
|
|
4043
4074
|
}
|
|
4044
4075
|
};
|
|
4045
|
-
const observeProjectHeadsBeforeOuterWorkspace = (input) => {
|
|
4076
|
+
const observeProjectHeadsBeforeOuterWorkspace = async (input) => {
|
|
4046
4077
|
const bundles = [];
|
|
4047
4078
|
for (const project of projectConfigById.values()) {
|
|
4048
4079
|
if (project.executionDisabled || !readyProjectIds.has(project.projectId) || project.branches.length === 0) continue;
|
|
@@ -4054,7 +4085,7 @@ async function startWorker(options) {
|
|
|
4054
4085
|
projectId: project.projectId,
|
|
4055
4086
|
projectRoot,
|
|
4056
4087
|
primaryBranchName,
|
|
4057
|
-
observations: (0, import_project_worktrees.observeProjectMirrorHeads)({
|
|
4088
|
+
observations: await (0, import_project_worktrees.observeProjectMirrorHeads)({
|
|
4058
4089
|
projectRoot,
|
|
4059
4090
|
primaryBranchName,
|
|
4060
4091
|
branchNames: project.branches.map(({ branchName }) => branchName),
|
|
@@ -4074,7 +4105,7 @@ async function startWorker(options) {
|
|
|
4074
4105
|
}
|
|
4075
4106
|
return bundles;
|
|
4076
4107
|
};
|
|
4077
|
-
const applyObservedProjectHeadsAfterInboundWorkspace = (bundles, activeMountIds, requireObservedHeads) => {
|
|
4108
|
+
const applyObservedProjectHeadsAfterInboundWorkspace = async (bundles, activeMountIds, requireObservedHeads) => {
|
|
4078
4109
|
const active = new Set(activeMountIds);
|
|
4079
4110
|
for (const bundle of bundles) {
|
|
4080
4111
|
const project = projectConfigById.get(bundle.projectId);
|
|
@@ -4082,7 +4113,7 @@ async function startWorker(options) {
|
|
|
4082
4113
|
const observations = bundle.observations.filter(({ branchName }) => active.has(projectMountId(project.projectId, branchName)));
|
|
4083
4114
|
if (observations.length === 0) continue;
|
|
4084
4115
|
try {
|
|
4085
|
-
const refreshed = (0, import_project_worktrees.applyObservedProjectMirrorHeads)({
|
|
4116
|
+
const refreshed = await (0, import_project_worktrees.applyObservedProjectMirrorHeads)({
|
|
4086
4117
|
projectRoot: bundle.projectRoot,
|
|
4087
4118
|
primaryBranchName: bundle.primaryBranchName,
|
|
4088
4119
|
observations,
|
|
@@ -4092,7 +4123,7 @@ async function startWorker(options) {
|
|
|
4092
4123
|
for (const observation of observations) {
|
|
4093
4124
|
if (!observation.shouldMove || !observation.mirrorHead) continue;
|
|
4094
4125
|
const checkoutPath = configuredProjectBranchPath(projectsRoot, project, observation.branchName);
|
|
4095
|
-
const currentHead =
|
|
4126
|
+
const currentHead = await runGitAsync(["rev-parse", "HEAD"], { cwd: checkoutPath });
|
|
4096
4127
|
if (currentHead !== observation.mirrorHead) {
|
|
4097
4128
|
throw new Error(
|
|
4098
4129
|
`Project ${project.projectId}/${observation.branchName} did not apply observed hidden mirror head ${observation.mirrorHead}`
|
|
@@ -4115,7 +4146,7 @@ async function startWorker(options) {
|
|
|
4115
4146
|
}
|
|
4116
4147
|
}
|
|
4117
4148
|
};
|
|
4118
|
-
const mapWorkspaceGitResult = (attemptId, trigger, result) => {
|
|
4149
|
+
const mapWorkspaceGitResult = async (attemptId, trigger, result) => {
|
|
4119
4150
|
const activeProjectBranchPublications = (0, import_workspace_publication_evidence.activeProjectBranchPublicationEvidence)([...projectConfigById.values()], result.activeMountIds);
|
|
4120
4151
|
return {
|
|
4121
4152
|
type: "workspace_sync",
|
|
@@ -4128,7 +4159,7 @@ async function startWorker(options) {
|
|
|
4128
4159
|
...result.publishedHead ? { publishedHead: result.publishedHead } : {},
|
|
4129
4160
|
rebaseCount: result.rebaseCount,
|
|
4130
4161
|
diffSizeBytes: result.diffSizeBytes,
|
|
4131
|
-
gitStatus: workspaceGitStatus(),
|
|
4162
|
+
gitStatus: await workspaceGitStatus(),
|
|
4132
4163
|
affectedProjects: affectedProjects(result.affectedPaths),
|
|
4133
4164
|
affectedPaths: result.affectedPaths,
|
|
4134
4165
|
activeMountIds: result.activeMountIds,
|
|
@@ -4143,23 +4174,26 @@ async function startWorker(options) {
|
|
|
4143
4174
|
...result.error ? { error: result.error } : {}
|
|
4144
4175
|
};
|
|
4145
4176
|
};
|
|
4146
|
-
const failedWorkspaceSyncResult = (attemptId, trigger, error) =>
|
|
4147
|
-
|
|
4148
|
-
|
|
4149
|
-
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
|
|
4153
|
-
|
|
4154
|
-
|
|
4155
|
-
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
|
|
4159
|
-
|
|
4160
|
-
|
|
4161
|
-
|
|
4162
|
-
|
|
4177
|
+
const failedWorkspaceSyncResult = async (attemptId, trigger, error) => {
|
|
4178
|
+
const localHead = await workspaceLocalHead();
|
|
4179
|
+
return {
|
|
4180
|
+
type: "workspace_sync",
|
|
4181
|
+
attemptId,
|
|
4182
|
+
workerLabel: label,
|
|
4183
|
+
trigger,
|
|
4184
|
+
outcome: "failed",
|
|
4185
|
+
startingHead: localHead,
|
|
4186
|
+
...localHead ? { localHead } : {},
|
|
4187
|
+
rebaseCount: 0,
|
|
4188
|
+
diffSizeBytes: 0,
|
|
4189
|
+
gitStatus: await workspaceGitStatus(),
|
|
4190
|
+
affectedProjects: [],
|
|
4191
|
+
affectedPaths: [],
|
|
4192
|
+
discardedPaths: [],
|
|
4193
|
+
localChangesDiscarded: false,
|
|
4194
|
+
error: error instanceof Error ? error.message : String(error)
|
|
4195
|
+
};
|
|
4196
|
+
};
|
|
4163
4197
|
const performWorkspaceSync = async (input) => {
|
|
4164
4198
|
if (!workspaceRemoteUrl || !workspaceCredentialHelper || !workspaceCredentialUsername || !workspaceGitIdentity) {
|
|
4165
4199
|
throw new Error("Worker workspace configuration has not been received");
|
|
@@ -4172,11 +4206,11 @@ async function startWorker(options) {
|
|
|
4172
4206
|
if (resetHasBusyLiveMount) {
|
|
4173
4207
|
throw new Error("Workspace reset cannot observe project mirror heads while a live mount is busy; remediation remains active");
|
|
4174
4208
|
}
|
|
4175
|
-
const observedProjectHeads2 = observeProjectHeadsBeforeOuterWorkspace({
|
|
4209
|
+
const observedProjectHeads2 = await observeProjectHeadsBeforeOuterWorkspace({
|
|
4176
4210
|
allowNonFastForward: true,
|
|
4177
4211
|
failClosed: true
|
|
4178
4212
|
});
|
|
4179
|
-
const reset = (0, import_workspace_git_sync.resetWorkspaceGit)({
|
|
4213
|
+
const reset = await (0, import_workspace_git_sync.resetWorkspaceGit)({
|
|
4180
4214
|
workspacePath: workspaceShadowRoot,
|
|
4181
4215
|
remoteUrl: workspaceRemoteUrl,
|
|
4182
4216
|
credentialHelper: workspaceCredentialHelper,
|
|
@@ -4184,7 +4218,7 @@ async function startWorker(options) {
|
|
|
4184
4218
|
gitIdentity: workspaceGitIdentity,
|
|
4185
4219
|
mounts: configuredMounts
|
|
4186
4220
|
});
|
|
4187
|
-
applyObservedProjectHeadsAfterInboundWorkspace(observedProjectHeads2, reset.activeMountIds, true);
|
|
4221
|
+
await applyObservedProjectHeadsAfterInboundWorkspace(observedProjectHeads2, reset.activeMountIds, true);
|
|
4188
4222
|
return {
|
|
4189
4223
|
type: "workspace_sync",
|
|
4190
4224
|
attemptId: input.attemptId,
|
|
@@ -4196,7 +4230,7 @@ async function startWorker(options) {
|
|
|
4196
4230
|
...reset.remoteHead ? { publishedHead: reset.remoteHead } : {},
|
|
4197
4231
|
rebaseCount: 0,
|
|
4198
4232
|
diffSizeBytes: 0,
|
|
4199
|
-
gitStatus: workspaceGitStatus(),
|
|
4233
|
+
gitStatus: await workspaceGitStatus(),
|
|
4200
4234
|
affectedProjects: affectedProjects(reset.discardedPaths),
|
|
4201
4235
|
affectedPaths: reset.discardedPaths,
|
|
4202
4236
|
activeMountIds: reset.activeMountIds,
|
|
@@ -4207,13 +4241,13 @@ async function startWorker(options) {
|
|
|
4207
4241
|
}
|
|
4208
4242
|
const outerRemediation = input.trigger.type === "remediation" || input.trigger.type === "remediation_confirm";
|
|
4209
4243
|
const mounts = outerRemediation ? (0, import_workspace_git_sync.workspaceGitMountsForRemediation)(configuredMounts) : configuredMounts;
|
|
4210
|
-
const observedProjectHeads = outerRemediation ? [] : observeProjectHeadsBeforeOuterWorkspace({ allowNonFastForward: false, failClosed: false });
|
|
4244
|
+
const observedProjectHeads = outerRemediation ? [] : await observeProjectHeadsBeforeOuterWorkspace({ allowNonFastForward: false, failClosed: false });
|
|
4211
4245
|
const inboundMoveMountIds = new Set(
|
|
4212
4246
|
observedProjectHeads.flatMap(
|
|
4213
4247
|
({ projectId, observations }) => observations.filter(({ shouldMove }) => shouldMove).map(({ branchName }) => projectMountId(projectId, branchName))
|
|
4214
4248
|
)
|
|
4215
4249
|
);
|
|
4216
|
-
const publicationHeads = outerRemediation ? /* @__PURE__ */ new Map() : captureProjectHeadsForWorkspacePublication();
|
|
4250
|
+
const publicationHeads = outerRemediation ? /* @__PURE__ */ new Map() : await captureProjectHeadsForWorkspacePublication();
|
|
4217
4251
|
const result = await (0, import_workspace_git_sync.synchronizeWorkspaceGit)({
|
|
4218
4252
|
attemptId: input.attemptId,
|
|
4219
4253
|
workerLabel: label,
|
|
@@ -4228,13 +4262,13 @@ async function startWorker(options) {
|
|
|
4228
4262
|
skipMountMirror: outerRemediation,
|
|
4229
4263
|
requiredAncestorHeads: input.requiredAncestorHeads,
|
|
4230
4264
|
assertStillAdmitted: input.assertStillAdmitted,
|
|
4231
|
-
afterWorkspacePublished: outerRemediation ? void 0 : ({ activeMountIds, publishedHead }) => {
|
|
4232
|
-
pushChangedProjectHeads(activeMountIds, publishedHead, publicationHeads, inboundMoveMountIds);
|
|
4265
|
+
afterWorkspacePublished: outerRemediation ? void 0 : async ({ activeMountIds, publishedHead }) => {
|
|
4266
|
+
await pushChangedProjectHeads(activeMountIds, publishedHead, publicationHeads, inboundMoveMountIds);
|
|
4233
4267
|
}
|
|
4234
4268
|
});
|
|
4235
4269
|
input.assertStillAdmitted?.();
|
|
4236
4270
|
if (["no_change", "updated", "pushed"].includes(result.outcome) && !outerRemediation) {
|
|
4237
|
-
applyObservedProjectHeadsAfterInboundWorkspace(observedProjectHeads, result.activeMountIds, false);
|
|
4271
|
+
await applyObservedProjectHeadsAfterInboundWorkspace(observedProjectHeads, result.activeMountIds, false);
|
|
4238
4272
|
}
|
|
4239
4273
|
return mapWorkspaceGitResult(input.attemptId, input.trigger, result);
|
|
4240
4274
|
};
|
|
@@ -4265,7 +4299,7 @@ async function startWorker(options) {
|
|
|
4265
4299
|
};
|
|
4266
4300
|
if (!deferredWorkspaceSyncTriggerIsAllowed(deferredWorkspaceConfiguration, activeWorkspaceIncidentId, input.trigger)) {
|
|
4267
4301
|
const result2 = {
|
|
4268
|
-
...failedWorkspaceSyncResult(
|
|
4302
|
+
...await failedWorkspaceSyncResult(
|
|
4269
4303
|
attemptId,
|
|
4270
4304
|
input.trigger,
|
|
4271
4305
|
new Error(
|
|
@@ -4292,7 +4326,7 @@ async function startWorker(options) {
|
|
|
4292
4326
|
queueEnteredAt = Date.now();
|
|
4293
4327
|
syncStartedAt = Date.now();
|
|
4294
4328
|
if (!deferredWorkspaceSyncTriggerIsAllowed(deferredWorkspaceConfiguration, activeWorkspaceIncidentId, input.trigger)) {
|
|
4295
|
-
return failedWorkspaceSyncResult(
|
|
4329
|
+
return await failedWorkspaceSyncResult(
|
|
4296
4330
|
attemptId,
|
|
4297
4331
|
input.trigger,
|
|
4298
4332
|
new Error(
|
|
@@ -4331,7 +4365,7 @@ async function startWorker(options) {
|
|
|
4331
4365
|
},
|
|
4332
4366
|
exitCode: 1
|
|
4333
4367
|
});
|
|
4334
|
-
return failedWorkspaceSyncResult(attemptId, input.trigger, error);
|
|
4368
|
+
return await failedWorkspaceSyncResult(attemptId, input.trigger, error);
|
|
4335
4369
|
}
|
|
4336
4370
|
});
|
|
4337
4371
|
} finally {
|
|
@@ -4430,7 +4464,7 @@ async function startWorker(options) {
|
|
|
4430
4464
|
if (incidentDeferral.error) {
|
|
4431
4465
|
workspaceConfigured = false;
|
|
4432
4466
|
return {
|
|
4433
|
-
result: failedWorkspaceSyncResult(crypto.randomUUID(), { type: "connect" }, incidentDeferral.error),
|
|
4467
|
+
result: await failedWorkspaceSyncResult(crypto.randomUUID(), { type: "connect" }, incidentDeferral.error),
|
|
4434
4468
|
pending: incidentDeferredProjectCheckouts(message.projects),
|
|
4435
4469
|
aheadOfOriginBranches: []
|
|
4436
4470
|
};
|
|
@@ -4458,7 +4492,7 @@ async function startWorker(options) {
|
|
|
4458
4492
|
canonicalRemediationActive: canonicalWorkspaceMutationIsActive(activeWorkspaceMutationTargets())
|
|
4459
4493
|
})) {
|
|
4460
4494
|
return {
|
|
4461
|
-
result: failedWorkspaceSyncResult(
|
|
4495
|
+
result: await failedWorkspaceSyncResult(
|
|
4462
4496
|
crypto.randomUUID(),
|
|
4463
4497
|
{ type: "connect" },
|
|
4464
4498
|
new Error("Workspace credential rotation is deferred until the active canonical remediation command finishes")
|
|
@@ -4517,7 +4551,7 @@ async function startWorker(options) {
|
|
|
4517
4551
|
} catch (error) {
|
|
4518
4552
|
const wrapped = error instanceof import_registry_auth.RegistryAuthConfigurationError ? error : new import_registry_auth.RegistryAuthConfigurationError(error);
|
|
4519
4553
|
return {
|
|
4520
|
-
result: failedWorkspaceSyncResult(crypto.randomUUID(), { type: "connect" }, wrapped),
|
|
4554
|
+
result: await failedWorkspaceSyncResult(crypto.randomUUID(), { type: "connect" }, wrapped),
|
|
4521
4555
|
pending: [],
|
|
4522
4556
|
aheadOfOriginBranches: []
|
|
4523
4557
|
};
|
|
@@ -4694,7 +4728,7 @@ async function startWorker(options) {
|
|
|
4694
4728
|
}));
|
|
4695
4729
|
const nextProjectConfigById = new Map(effectiveProjects.map((project) => [project.projectId, project]));
|
|
4696
4730
|
if (incidentDeferral.incidentId) {
|
|
4697
|
-
(0, import_workspace_git_sync.configureExistingWorkspaceGitForRemediation)({
|
|
4731
|
+
await (0, import_workspace_git_sync.configureExistingWorkspaceGitForRemediation)({
|
|
4698
4732
|
workspacePath: workspaceShadowRoot,
|
|
4699
4733
|
remoteUrl: message.workspaceRemoteUrl,
|
|
4700
4734
|
credentialHelper: nextWorkspaceCredentialHelper,
|
|
@@ -4713,7 +4747,7 @@ async function startWorker(options) {
|
|
|
4713
4747
|
result: deferredIncidentWorkspaceConfigurationResult({
|
|
4714
4748
|
attemptId: crypto.randomUUID(),
|
|
4715
4749
|
workerLabel: label,
|
|
4716
|
-
head: workspaceLocalHead(),
|
|
4750
|
+
head: await workspaceLocalHead(),
|
|
4717
4751
|
skippedMountIds: buildWorkspaceMounts().map(({ id }) => id)
|
|
4718
4752
|
}),
|
|
4719
4753
|
pending: pending2,
|
|
@@ -4721,7 +4755,7 @@ async function startWorker(options) {
|
|
|
4721
4755
|
deferredWorkspaceSyncForIncidentId: incidentDeferral.incidentId
|
|
4722
4756
|
};
|
|
4723
4757
|
}
|
|
4724
|
-
(0, import_workspace_git_sync.ensureWorkspaceGitClone)({
|
|
4758
|
+
await (0, import_workspace_git_sync.ensureWorkspaceGitClone)({
|
|
4725
4759
|
workspacePath: workspaceShadowRoot,
|
|
4726
4760
|
remoteUrl: message.workspaceRemoteUrl,
|
|
4727
4761
|
credentialHelper: nextWorkspaceCredentialHelper,
|
|
@@ -4741,7 +4775,7 @@ async function startWorker(options) {
|
|
|
4741
4775
|
sourcePath: recoverySourceOverrides.get(mount.id) ?? mount.sourcePath,
|
|
4742
4776
|
busy: mount.busyForRecovery ?? mount.busy
|
|
4743
4777
|
}));
|
|
4744
|
-
(0, import_workspace_git_sync.recoverWorkspaceGitHydration)(workspaceShadowRoot, recoveryMounts, { preserveStaleBases: true });
|
|
4778
|
+
await (0, import_workspace_git_sync.recoverWorkspaceGitHydration)(workspaceShadowRoot, recoveryMounts, { preserveStaleBases: true });
|
|
4745
4779
|
for (const project of message.projects) {
|
|
4746
4780
|
for (const { branchName } of project.preserveOnlyBranches) {
|
|
4747
4781
|
if (stillPendingCreatedBranches.has((0, import_workspace_automatic_sync_policy.pendingCreatedBranchKey)(project.projectId, branchName))) {
|
|
@@ -4778,7 +4812,7 @@ async function startWorker(options) {
|
|
|
4778
4812
|
}
|
|
4779
4813
|
stageDurableWorkspaceDeletions();
|
|
4780
4814
|
const mountsBeforeGit = buildWorkspaceMounts();
|
|
4781
|
-
(0, import_workspace_git_sync.hydrateWorkspaceGitMounts)(
|
|
4815
|
+
await (0, import_workspace_git_sync.hydrateWorkspaceGitMounts)(
|
|
4782
4816
|
workspaceShadowRoot,
|
|
4783
4817
|
mountsBeforeGit.filter((mount) => !mount.deleteWhenSourceMissing && !import_node_fs.default.existsSync(mount.sourcePath) && mount.busy?.() !== true),
|
|
4784
4818
|
// These mounts are intentionally hydrated before their project Git
|
|
@@ -4787,7 +4821,7 @@ async function startWorker(options) {
|
|
|
4787
4821
|
// checkout initialization from erasing synchronized dirt.
|
|
4788
4822
|
{ ignoreBusy: true }
|
|
4789
4823
|
);
|
|
4790
|
-
ensureConfiguredProjects();
|
|
4824
|
+
await ensureConfiguredProjects();
|
|
4791
4825
|
const configurationSyncAdmissionGeneration = workerAdmissionGeneration;
|
|
4792
4826
|
const assertConfigurationSyncStillAdmitted = () => {
|
|
4793
4827
|
if (receiptGeneration !== workspaceConfigurationReceiptGeneration || configurationSyncAdmissionGeneration !== workerAdmissionGeneration || !workspaceConfigurationIncidentSnapshotIsCurrent(incidentDeferral.incidentId, activeWorkspaceIncidentId) || currentWorkerSocket !== ws || ws.readyState !== WebSocket.OPEN) {
|
|
@@ -4832,12 +4866,12 @@ async function startWorker(options) {
|
|
|
4832
4866
|
const pending = [...pendingCheckouts.values()].sort(
|
|
4833
4867
|
(left, right) => left.projectId.localeCompare(right.projectId) || left.branchName.localeCompare(right.branchName)
|
|
4834
4868
|
);
|
|
4835
|
-
return { result, pending, aheadOfOriginBranches: collectAheadOfOriginBranches() };
|
|
4869
|
+
return { result, pending, aheadOfOriginBranches: await collectAheadOfOriginBranches() };
|
|
4836
4870
|
});
|
|
4837
4871
|
} catch (error) {
|
|
4838
4872
|
if (receiptGeneration !== workspaceConfigurationReceiptGeneration) {
|
|
4839
4873
|
return {
|
|
4840
|
-
result: failedWorkspaceSyncResult(crypto.randomUUID(), { type: "connect" }, error),
|
|
4874
|
+
result: await failedWorkspaceSyncResult(crypto.randomUUID(), { type: "connect" }, error),
|
|
4841
4875
|
pending: incidentDeferredProjectCheckouts(message.projects),
|
|
4842
4876
|
aheadOfOriginBranches: []
|
|
4843
4877
|
};
|
|
@@ -4869,7 +4903,7 @@ async function startWorker(options) {
|
|
|
4869
4903
|
pendingCheckouts.set(projectBranchKey(pending.projectId, pending.branchName), pending);
|
|
4870
4904
|
}
|
|
4871
4905
|
return {
|
|
4872
|
-
result: failedWorkspaceSyncResult(crypto.randomUUID(), { type: "connect" }, error),
|
|
4906
|
+
result: await failedWorkspaceSyncResult(crypto.randomUUID(), { type: "connect" }, error),
|
|
4873
4907
|
pending: [...pendingCheckouts.values()].sort(
|
|
4874
4908
|
(left, right) => left.projectId.localeCompare(right.projectId) || left.branchName.localeCompare(right.branchName)
|
|
4875
4909
|
),
|
package/dist/cjs/package.json
CHANGED