@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/mjs/main.mjs
CHANGED
|
@@ -847,6 +847,33 @@ function tryGit(args, options = {}) {
|
|
|
847
847
|
return false;
|
|
848
848
|
}
|
|
849
849
|
}
|
|
850
|
+
async function runGitAsync(args, options = {}) {
|
|
851
|
+
const command = workerGitCommand.commandArgs(args);
|
|
852
|
+
const subprocess = Bun.spawn(command, {
|
|
853
|
+
cwd: options.cwd,
|
|
854
|
+
stdin: "ignore",
|
|
855
|
+
stdout: "pipe",
|
|
856
|
+
stderr: "pipe",
|
|
857
|
+
env: workerGitProcessEnvironment()
|
|
858
|
+
});
|
|
859
|
+
const [stdout, stderr, exitCode] = await Promise.all([
|
|
860
|
+
new Response(subprocess.stdout).text(),
|
|
861
|
+
new Response(subprocess.stderr).text(),
|
|
862
|
+
subprocess.exited
|
|
863
|
+
]);
|
|
864
|
+
if (exitCode !== 0) {
|
|
865
|
+
throw new Error(`git ${args.join(" ")} failed: ${stderr.trim() || stdout.trim() || `exit ${exitCode}`}`);
|
|
866
|
+
}
|
|
867
|
+
return stdout.trim();
|
|
868
|
+
}
|
|
869
|
+
async function tryGitAsync(args, options = {}) {
|
|
870
|
+
try {
|
|
871
|
+
await runGitAsync(args, options);
|
|
872
|
+
return true;
|
|
873
|
+
} catch {
|
|
874
|
+
return false;
|
|
875
|
+
}
|
|
876
|
+
}
|
|
850
877
|
function getGitBlobHashForContent(content) {
|
|
851
878
|
const buffer = typeof content === "string" ? Buffer.from(content, "utf8") : content;
|
|
852
879
|
return createHash("sha1").update(`blob ${buffer.length}\0`).update(buffer).digest("hex");
|
|
@@ -3818,10 +3845,14 @@ async function startWorker(options) {
|
|
|
3818
3845
|
}
|
|
3819
3846
|
return mounts;
|
|
3820
3847
|
};
|
|
3821
|
-
const workspaceLocalHead = () =>
|
|
3822
|
-
|
|
3848
|
+
const workspaceLocalHead = async () => {
|
|
3849
|
+
if (!fs.existsSync(path.join(workspaceShadowRoot, ".git"))) return null;
|
|
3850
|
+
if (!await tryGitAsync(["rev-parse", "--verify", "HEAD"], { cwd: workspaceShadowRoot })) return null;
|
|
3851
|
+
return runGitAsync(["rev-parse", "HEAD"], { cwd: workspaceShadowRoot });
|
|
3852
|
+
};
|
|
3853
|
+
const workspaceGitStatus = async () => {
|
|
3823
3854
|
try {
|
|
3824
|
-
return
|
|
3855
|
+
return await runGitAsync(["status", "--porcelain"], { cwd: workspaceShadowRoot });
|
|
3825
3856
|
} catch {
|
|
3826
3857
|
return "";
|
|
3827
3858
|
}
|
|
@@ -3834,7 +3865,7 @@ async function startWorker(options) {
|
|
|
3834
3865
|
})
|
|
3835
3866
|
)
|
|
3836
3867
|
].sort();
|
|
3837
|
-
const ensureConfiguredProjects = () => {
|
|
3868
|
+
const ensureConfiguredProjects = async () => {
|
|
3838
3869
|
for (const project of projectConfigById.values()) {
|
|
3839
3870
|
validateProjectId(project.projectId);
|
|
3840
3871
|
assertRepositoryTransitionState(project);
|
|
@@ -3871,7 +3902,7 @@ async function startWorker(options) {
|
|
|
3871
3902
|
}
|
|
3872
3903
|
try {
|
|
3873
3904
|
const connection = projectConnection(project);
|
|
3874
|
-
const states = ensureProjectWorktrees({
|
|
3905
|
+
const states = await ensureProjectWorktrees({
|
|
3875
3906
|
projectRoot,
|
|
3876
3907
|
snapshotRoot: projectWorktreeSnapshotsRoot,
|
|
3877
3908
|
primaryBranchName: primaryProjectBranch(project),
|
|
@@ -3920,13 +3951,13 @@ async function startWorker(options) {
|
|
|
3920
3951
|
}
|
|
3921
3952
|
}
|
|
3922
3953
|
};
|
|
3923
|
-
const collectAheadOfOriginBranches = () => {
|
|
3954
|
+
const collectAheadOfOriginBranches = async () => {
|
|
3924
3955
|
const aheadBranches = [];
|
|
3925
3956
|
for (const project of projectConfigById.values()) {
|
|
3926
3957
|
if (project.executionDisabled || !readyProjectIds.has(project.projectId) || project.branches.length === 0) continue;
|
|
3927
3958
|
const connection = projectConnection(project);
|
|
3928
3959
|
const primaryPath = configuredProjectBranchPath(projectsRoot, project, primaryProjectBranch(project));
|
|
3929
|
-
if (!
|
|
3960
|
+
if (!await tryGitAsync(
|
|
3930
3961
|
[
|
|
3931
3962
|
...gitTransportSecurityArgs(connection.originUrl, connection.credentialHelper, connection.originCredentialUsername),
|
|
3932
3963
|
"fetch",
|
|
@@ -3950,11 +3981,11 @@ async function startWorker(options) {
|
|
|
3950
3981
|
primaryBranchName: primaryProjectBranch(project),
|
|
3951
3982
|
defaultBranch: project.defaultBranch
|
|
3952
3983
|
})}`;
|
|
3953
|
-
if (
|
|
3954
|
-
const counts =
|
|
3984
|
+
if (await tryGitAsync(["show-ref", "--verify", "--quiet", originRef], { cwd: branchPath })) {
|
|
3985
|
+
const counts = (await runGitAsync(["rev-list", "--left-right", "--count", `${originRef}...HEAD`], { cwd: branchPath })).split(/\s+/).map(Number);
|
|
3955
3986
|
ahead = Number.isSafeInteger(counts[1]) ? counts[1] : 0;
|
|
3956
|
-
} else if (
|
|
3957
|
-
const count = Number(
|
|
3987
|
+
} else if (await tryGitAsync(["cat-file", "-e", `${branch.baseCommitHash}^{commit}`], { cwd: branchPath })) {
|
|
3988
|
+
const count = Number(await runGitAsync(["rev-list", "--count", `${branch.baseCommitHash}..HEAD`], { cwd: branchPath }));
|
|
3958
3989
|
ahead = Number.isSafeInteger(count) ? count : 0;
|
|
3959
3990
|
}
|
|
3960
3991
|
if (ahead > 0) aheadBranches.push({ projectId: project.projectId, branchName: branch.branchName, ahead });
|
|
@@ -3970,19 +4001,19 @@ async function startWorker(options) {
|
|
|
3970
4001
|
(left, right) => left.projectId.localeCompare(right.projectId) || left.branchName.localeCompare(right.branchName)
|
|
3971
4002
|
);
|
|
3972
4003
|
};
|
|
3973
|
-
const captureProjectHeadsForWorkspacePublication = () => {
|
|
4004
|
+
const captureProjectHeadsForWorkspacePublication = async () => {
|
|
3974
4005
|
const heads = /* @__PURE__ */ new Map();
|
|
3975
4006
|
for (const project of projectConfigById.values()) {
|
|
3976
4007
|
if (!readyProjectIds.has(project.projectId)) continue;
|
|
3977
4008
|
for (const branch of project.branches) {
|
|
3978
4009
|
const branchPath = configuredProjectBranchPath(projectsRoot, project, branch.branchName);
|
|
3979
4010
|
if (!hasProjectWorktree(branchPath)) continue;
|
|
3980
|
-
heads.set(projectMountId(project.projectId, branch.branchName),
|
|
4011
|
+
heads.set(projectMountId(project.projectId, branch.branchName), await runGitAsync(["rev-parse", "HEAD"], { cwd: branchPath }));
|
|
3981
4012
|
}
|
|
3982
4013
|
}
|
|
3983
4014
|
return heads;
|
|
3984
4015
|
};
|
|
3985
|
-
const pushChangedProjectHeads = (activeMountIds, publishedHead, publicationHeads, suppressedMountIds = /* @__PURE__ */ new Set()) => {
|
|
4016
|
+
const pushChangedProjectHeads = async (activeMountIds, publishedHead, publicationHeads, suppressedMountIds = /* @__PURE__ */ new Set()) => {
|
|
3986
4017
|
const active = new Set(activeMountIds);
|
|
3987
4018
|
for (const project of projectConfigById.values()) {
|
|
3988
4019
|
if (!readyProjectIds.has(project.projectId) || !repositoryMirrorWritesAllowed(project)) continue;
|
|
@@ -3998,7 +4029,7 @@ async function startWorker(options) {
|
|
|
3998
4029
|
}
|
|
3999
4030
|
if (changed.size === 0) continue;
|
|
4000
4031
|
const connection = projectConnection(project);
|
|
4001
|
-
const results = pushProjectMirrorHeads({
|
|
4032
|
+
const results = await pushProjectMirrorHeads({
|
|
4002
4033
|
projectRoot: configuredProjectRoot(projectsRoot, project),
|
|
4003
4034
|
branchNames: project.branches.map(({ branchName }) => branchName),
|
|
4004
4035
|
mirrorUrl: connection.mirrorUrl,
|
|
@@ -4029,7 +4060,7 @@ async function startWorker(options) {
|
|
|
4029
4060
|
if (!active.has(deletion.id)) continue;
|
|
4030
4061
|
if (!repositoryMirrorWritesAllowed(projectConfigById.get(deletion.projectId))) continue;
|
|
4031
4062
|
if (!deletion.projectDeleted) {
|
|
4032
|
-
deleteProjectMirrorBranch({
|
|
4063
|
+
await deleteProjectMirrorBranch({
|
|
4033
4064
|
gitDirectory: deletion.gitDirectory,
|
|
4034
4065
|
branchName: deletion.branchName,
|
|
4035
4066
|
mirrorUrl: deletion.mirrorUrl,
|
|
@@ -4050,7 +4081,7 @@ async function startWorker(options) {
|
|
|
4050
4081
|
lastObservedProjectHeads.delete(key);
|
|
4051
4082
|
}
|
|
4052
4083
|
};
|
|
4053
|
-
const observeProjectHeadsBeforeOuterWorkspace = (input) => {
|
|
4084
|
+
const observeProjectHeadsBeforeOuterWorkspace = async (input) => {
|
|
4054
4085
|
const bundles = [];
|
|
4055
4086
|
for (const project of projectConfigById.values()) {
|
|
4056
4087
|
if (project.executionDisabled || !readyProjectIds.has(project.projectId) || project.branches.length === 0) continue;
|
|
@@ -4062,7 +4093,7 @@ async function startWorker(options) {
|
|
|
4062
4093
|
projectId: project.projectId,
|
|
4063
4094
|
projectRoot,
|
|
4064
4095
|
primaryBranchName,
|
|
4065
|
-
observations: observeProjectMirrorHeads({
|
|
4096
|
+
observations: await observeProjectMirrorHeads({
|
|
4066
4097
|
projectRoot,
|
|
4067
4098
|
primaryBranchName,
|
|
4068
4099
|
branchNames: project.branches.map(({ branchName }) => branchName),
|
|
@@ -4082,7 +4113,7 @@ async function startWorker(options) {
|
|
|
4082
4113
|
}
|
|
4083
4114
|
return bundles;
|
|
4084
4115
|
};
|
|
4085
|
-
const applyObservedProjectHeadsAfterInboundWorkspace = (bundles, activeMountIds, requireObservedHeads) => {
|
|
4116
|
+
const applyObservedProjectHeadsAfterInboundWorkspace = async (bundles, activeMountIds, requireObservedHeads) => {
|
|
4086
4117
|
const active = new Set(activeMountIds);
|
|
4087
4118
|
for (const bundle of bundles) {
|
|
4088
4119
|
const project = projectConfigById.get(bundle.projectId);
|
|
@@ -4090,7 +4121,7 @@ async function startWorker(options) {
|
|
|
4090
4121
|
const observations = bundle.observations.filter(({ branchName }) => active.has(projectMountId(project.projectId, branchName)));
|
|
4091
4122
|
if (observations.length === 0) continue;
|
|
4092
4123
|
try {
|
|
4093
|
-
const refreshed = applyObservedProjectMirrorHeads({
|
|
4124
|
+
const refreshed = await applyObservedProjectMirrorHeads({
|
|
4094
4125
|
projectRoot: bundle.projectRoot,
|
|
4095
4126
|
primaryBranchName: bundle.primaryBranchName,
|
|
4096
4127
|
observations,
|
|
@@ -4100,7 +4131,7 @@ async function startWorker(options) {
|
|
|
4100
4131
|
for (const observation of observations) {
|
|
4101
4132
|
if (!observation.shouldMove || !observation.mirrorHead) continue;
|
|
4102
4133
|
const checkoutPath = configuredProjectBranchPath(projectsRoot, project, observation.branchName);
|
|
4103
|
-
const currentHead =
|
|
4134
|
+
const currentHead = await runGitAsync(["rev-parse", "HEAD"], { cwd: checkoutPath });
|
|
4104
4135
|
if (currentHead !== observation.mirrorHead) {
|
|
4105
4136
|
throw new Error(
|
|
4106
4137
|
`Project ${project.projectId}/${observation.branchName} did not apply observed hidden mirror head ${observation.mirrorHead}`
|
|
@@ -4123,7 +4154,7 @@ async function startWorker(options) {
|
|
|
4123
4154
|
}
|
|
4124
4155
|
}
|
|
4125
4156
|
};
|
|
4126
|
-
const mapWorkspaceGitResult = (attemptId, trigger, result) => {
|
|
4157
|
+
const mapWorkspaceGitResult = async (attemptId, trigger, result) => {
|
|
4127
4158
|
const activeProjectBranchPublications = activeProjectBranchPublicationEvidence([...projectConfigById.values()], result.activeMountIds);
|
|
4128
4159
|
return {
|
|
4129
4160
|
type: "workspace_sync",
|
|
@@ -4136,7 +4167,7 @@ async function startWorker(options) {
|
|
|
4136
4167
|
...result.publishedHead ? { publishedHead: result.publishedHead } : {},
|
|
4137
4168
|
rebaseCount: result.rebaseCount,
|
|
4138
4169
|
diffSizeBytes: result.diffSizeBytes,
|
|
4139
|
-
gitStatus: workspaceGitStatus(),
|
|
4170
|
+
gitStatus: await workspaceGitStatus(),
|
|
4140
4171
|
affectedProjects: affectedProjects(result.affectedPaths),
|
|
4141
4172
|
affectedPaths: result.affectedPaths,
|
|
4142
4173
|
activeMountIds: result.activeMountIds,
|
|
@@ -4151,23 +4182,26 @@ async function startWorker(options) {
|
|
|
4151
4182
|
...result.error ? { error: result.error } : {}
|
|
4152
4183
|
};
|
|
4153
4184
|
};
|
|
4154
|
-
const failedWorkspaceSyncResult = (attemptId, trigger, error) =>
|
|
4155
|
-
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
|
|
4159
|
-
|
|
4160
|
-
|
|
4161
|
-
|
|
4162
|
-
|
|
4163
|
-
|
|
4164
|
-
|
|
4165
|
-
|
|
4166
|
-
|
|
4167
|
-
|
|
4168
|
-
|
|
4169
|
-
|
|
4170
|
-
|
|
4185
|
+
const failedWorkspaceSyncResult = async (attemptId, trigger, error) => {
|
|
4186
|
+
const localHead = await workspaceLocalHead();
|
|
4187
|
+
return {
|
|
4188
|
+
type: "workspace_sync",
|
|
4189
|
+
attemptId,
|
|
4190
|
+
workerLabel: label,
|
|
4191
|
+
trigger,
|
|
4192
|
+
outcome: "failed",
|
|
4193
|
+
startingHead: localHead,
|
|
4194
|
+
...localHead ? { localHead } : {},
|
|
4195
|
+
rebaseCount: 0,
|
|
4196
|
+
diffSizeBytes: 0,
|
|
4197
|
+
gitStatus: await workspaceGitStatus(),
|
|
4198
|
+
affectedProjects: [],
|
|
4199
|
+
affectedPaths: [],
|
|
4200
|
+
discardedPaths: [],
|
|
4201
|
+
localChangesDiscarded: false,
|
|
4202
|
+
error: error instanceof Error ? error.message : String(error)
|
|
4203
|
+
};
|
|
4204
|
+
};
|
|
4171
4205
|
const performWorkspaceSync = async (input) => {
|
|
4172
4206
|
if (!workspaceRemoteUrl || !workspaceCredentialHelper || !workspaceCredentialUsername || !workspaceGitIdentity) {
|
|
4173
4207
|
throw new Error("Worker workspace configuration has not been received");
|
|
@@ -4180,11 +4214,11 @@ async function startWorker(options) {
|
|
|
4180
4214
|
if (resetHasBusyLiveMount) {
|
|
4181
4215
|
throw new Error("Workspace reset cannot observe project mirror heads while a live mount is busy; remediation remains active");
|
|
4182
4216
|
}
|
|
4183
|
-
const observedProjectHeads2 = observeProjectHeadsBeforeOuterWorkspace({
|
|
4217
|
+
const observedProjectHeads2 = await observeProjectHeadsBeforeOuterWorkspace({
|
|
4184
4218
|
allowNonFastForward: true,
|
|
4185
4219
|
failClosed: true
|
|
4186
4220
|
});
|
|
4187
|
-
const reset = resetWorkspaceGit({
|
|
4221
|
+
const reset = await resetWorkspaceGit({
|
|
4188
4222
|
workspacePath: workspaceShadowRoot,
|
|
4189
4223
|
remoteUrl: workspaceRemoteUrl,
|
|
4190
4224
|
credentialHelper: workspaceCredentialHelper,
|
|
@@ -4192,7 +4226,7 @@ async function startWorker(options) {
|
|
|
4192
4226
|
gitIdentity: workspaceGitIdentity,
|
|
4193
4227
|
mounts: configuredMounts
|
|
4194
4228
|
});
|
|
4195
|
-
applyObservedProjectHeadsAfterInboundWorkspace(observedProjectHeads2, reset.activeMountIds, true);
|
|
4229
|
+
await applyObservedProjectHeadsAfterInboundWorkspace(observedProjectHeads2, reset.activeMountIds, true);
|
|
4196
4230
|
return {
|
|
4197
4231
|
type: "workspace_sync",
|
|
4198
4232
|
attemptId: input.attemptId,
|
|
@@ -4204,7 +4238,7 @@ async function startWorker(options) {
|
|
|
4204
4238
|
...reset.remoteHead ? { publishedHead: reset.remoteHead } : {},
|
|
4205
4239
|
rebaseCount: 0,
|
|
4206
4240
|
diffSizeBytes: 0,
|
|
4207
|
-
gitStatus: workspaceGitStatus(),
|
|
4241
|
+
gitStatus: await workspaceGitStatus(),
|
|
4208
4242
|
affectedProjects: affectedProjects(reset.discardedPaths),
|
|
4209
4243
|
affectedPaths: reset.discardedPaths,
|
|
4210
4244
|
activeMountIds: reset.activeMountIds,
|
|
@@ -4215,13 +4249,13 @@ async function startWorker(options) {
|
|
|
4215
4249
|
}
|
|
4216
4250
|
const outerRemediation = input.trigger.type === "remediation" || input.trigger.type === "remediation_confirm";
|
|
4217
4251
|
const mounts = outerRemediation ? workspaceGitMountsForRemediation(configuredMounts) : configuredMounts;
|
|
4218
|
-
const observedProjectHeads = outerRemediation ? [] : observeProjectHeadsBeforeOuterWorkspace({ allowNonFastForward: false, failClosed: false });
|
|
4252
|
+
const observedProjectHeads = outerRemediation ? [] : await observeProjectHeadsBeforeOuterWorkspace({ allowNonFastForward: false, failClosed: false });
|
|
4219
4253
|
const inboundMoveMountIds = new Set(
|
|
4220
4254
|
observedProjectHeads.flatMap(
|
|
4221
4255
|
({ projectId, observations }) => observations.filter(({ shouldMove }) => shouldMove).map(({ branchName }) => projectMountId(projectId, branchName))
|
|
4222
4256
|
)
|
|
4223
4257
|
);
|
|
4224
|
-
const publicationHeads = outerRemediation ? /* @__PURE__ */ new Map() : captureProjectHeadsForWorkspacePublication();
|
|
4258
|
+
const publicationHeads = outerRemediation ? /* @__PURE__ */ new Map() : await captureProjectHeadsForWorkspacePublication();
|
|
4225
4259
|
const result = await synchronizeWorkspaceGit({
|
|
4226
4260
|
attemptId: input.attemptId,
|
|
4227
4261
|
workerLabel: label,
|
|
@@ -4236,13 +4270,13 @@ async function startWorker(options) {
|
|
|
4236
4270
|
skipMountMirror: outerRemediation,
|
|
4237
4271
|
requiredAncestorHeads: input.requiredAncestorHeads,
|
|
4238
4272
|
assertStillAdmitted: input.assertStillAdmitted,
|
|
4239
|
-
afterWorkspacePublished: outerRemediation ? void 0 : ({ activeMountIds, publishedHead }) => {
|
|
4240
|
-
pushChangedProjectHeads(activeMountIds, publishedHead, publicationHeads, inboundMoveMountIds);
|
|
4273
|
+
afterWorkspacePublished: outerRemediation ? void 0 : async ({ activeMountIds, publishedHead }) => {
|
|
4274
|
+
await pushChangedProjectHeads(activeMountIds, publishedHead, publicationHeads, inboundMoveMountIds);
|
|
4241
4275
|
}
|
|
4242
4276
|
});
|
|
4243
4277
|
input.assertStillAdmitted?.();
|
|
4244
4278
|
if (["no_change", "updated", "pushed"].includes(result.outcome) && !outerRemediation) {
|
|
4245
|
-
applyObservedProjectHeadsAfterInboundWorkspace(observedProjectHeads, result.activeMountIds, false);
|
|
4279
|
+
await applyObservedProjectHeadsAfterInboundWorkspace(observedProjectHeads, result.activeMountIds, false);
|
|
4246
4280
|
}
|
|
4247
4281
|
return mapWorkspaceGitResult(input.attemptId, input.trigger, result);
|
|
4248
4282
|
};
|
|
@@ -4273,7 +4307,7 @@ async function startWorker(options) {
|
|
|
4273
4307
|
};
|
|
4274
4308
|
if (!deferredWorkspaceSyncTriggerIsAllowed(deferredWorkspaceConfiguration, activeWorkspaceIncidentId, input.trigger)) {
|
|
4275
4309
|
const result2 = {
|
|
4276
|
-
...failedWorkspaceSyncResult(
|
|
4310
|
+
...await failedWorkspaceSyncResult(
|
|
4277
4311
|
attemptId,
|
|
4278
4312
|
input.trigger,
|
|
4279
4313
|
new Error(
|
|
@@ -4300,7 +4334,7 @@ async function startWorker(options) {
|
|
|
4300
4334
|
queueEnteredAt = Date.now();
|
|
4301
4335
|
syncStartedAt = Date.now();
|
|
4302
4336
|
if (!deferredWorkspaceSyncTriggerIsAllowed(deferredWorkspaceConfiguration, activeWorkspaceIncidentId, input.trigger)) {
|
|
4303
|
-
return failedWorkspaceSyncResult(
|
|
4337
|
+
return await failedWorkspaceSyncResult(
|
|
4304
4338
|
attemptId,
|
|
4305
4339
|
input.trigger,
|
|
4306
4340
|
new Error(
|
|
@@ -4339,7 +4373,7 @@ async function startWorker(options) {
|
|
|
4339
4373
|
},
|
|
4340
4374
|
exitCode: 1
|
|
4341
4375
|
});
|
|
4342
|
-
return failedWorkspaceSyncResult(attemptId, input.trigger, error);
|
|
4376
|
+
return await failedWorkspaceSyncResult(attemptId, input.trigger, error);
|
|
4343
4377
|
}
|
|
4344
4378
|
});
|
|
4345
4379
|
} finally {
|
|
@@ -4438,7 +4472,7 @@ async function startWorker(options) {
|
|
|
4438
4472
|
if (incidentDeferral.error) {
|
|
4439
4473
|
workspaceConfigured = false;
|
|
4440
4474
|
return {
|
|
4441
|
-
result: failedWorkspaceSyncResult(crypto.randomUUID(), { type: "connect" }, incidentDeferral.error),
|
|
4475
|
+
result: await failedWorkspaceSyncResult(crypto.randomUUID(), { type: "connect" }, incidentDeferral.error),
|
|
4442
4476
|
pending: incidentDeferredProjectCheckouts(message.projects),
|
|
4443
4477
|
aheadOfOriginBranches: []
|
|
4444
4478
|
};
|
|
@@ -4466,7 +4500,7 @@ async function startWorker(options) {
|
|
|
4466
4500
|
canonicalRemediationActive: canonicalWorkspaceMutationIsActive(activeWorkspaceMutationTargets())
|
|
4467
4501
|
})) {
|
|
4468
4502
|
return {
|
|
4469
|
-
result: failedWorkspaceSyncResult(
|
|
4503
|
+
result: await failedWorkspaceSyncResult(
|
|
4470
4504
|
crypto.randomUUID(),
|
|
4471
4505
|
{ type: "connect" },
|
|
4472
4506
|
new Error("Workspace credential rotation is deferred until the active canonical remediation command finishes")
|
|
@@ -4525,7 +4559,7 @@ async function startWorker(options) {
|
|
|
4525
4559
|
} catch (error) {
|
|
4526
4560
|
const wrapped = error instanceof RegistryAuthConfigurationError ? error : new RegistryAuthConfigurationError(error);
|
|
4527
4561
|
return {
|
|
4528
|
-
result: failedWorkspaceSyncResult(crypto.randomUUID(), { type: "connect" }, wrapped),
|
|
4562
|
+
result: await failedWorkspaceSyncResult(crypto.randomUUID(), { type: "connect" }, wrapped),
|
|
4529
4563
|
pending: [],
|
|
4530
4564
|
aheadOfOriginBranches: []
|
|
4531
4565
|
};
|
|
@@ -4702,7 +4736,7 @@ async function startWorker(options) {
|
|
|
4702
4736
|
}));
|
|
4703
4737
|
const nextProjectConfigById = new Map(effectiveProjects.map((project) => [project.projectId, project]));
|
|
4704
4738
|
if (incidentDeferral.incidentId) {
|
|
4705
|
-
configureExistingWorkspaceGitForRemediation({
|
|
4739
|
+
await configureExistingWorkspaceGitForRemediation({
|
|
4706
4740
|
workspacePath: workspaceShadowRoot,
|
|
4707
4741
|
remoteUrl: message.workspaceRemoteUrl,
|
|
4708
4742
|
credentialHelper: nextWorkspaceCredentialHelper,
|
|
@@ -4721,7 +4755,7 @@ async function startWorker(options) {
|
|
|
4721
4755
|
result: deferredIncidentWorkspaceConfigurationResult({
|
|
4722
4756
|
attemptId: crypto.randomUUID(),
|
|
4723
4757
|
workerLabel: label,
|
|
4724
|
-
head: workspaceLocalHead(),
|
|
4758
|
+
head: await workspaceLocalHead(),
|
|
4725
4759
|
skippedMountIds: buildWorkspaceMounts().map(({ id }) => id)
|
|
4726
4760
|
}),
|
|
4727
4761
|
pending: pending2,
|
|
@@ -4729,7 +4763,7 @@ async function startWorker(options) {
|
|
|
4729
4763
|
deferredWorkspaceSyncForIncidentId: incidentDeferral.incidentId
|
|
4730
4764
|
};
|
|
4731
4765
|
}
|
|
4732
|
-
ensureWorkspaceGitClone({
|
|
4766
|
+
await ensureWorkspaceGitClone({
|
|
4733
4767
|
workspacePath: workspaceShadowRoot,
|
|
4734
4768
|
remoteUrl: message.workspaceRemoteUrl,
|
|
4735
4769
|
credentialHelper: nextWorkspaceCredentialHelper,
|
|
@@ -4749,7 +4783,7 @@ async function startWorker(options) {
|
|
|
4749
4783
|
sourcePath: recoverySourceOverrides.get(mount.id) ?? mount.sourcePath,
|
|
4750
4784
|
busy: mount.busyForRecovery ?? mount.busy
|
|
4751
4785
|
}));
|
|
4752
|
-
recoverWorkspaceGitHydration(workspaceShadowRoot, recoveryMounts, { preserveStaleBases: true });
|
|
4786
|
+
await recoverWorkspaceGitHydration(workspaceShadowRoot, recoveryMounts, { preserveStaleBases: true });
|
|
4753
4787
|
for (const project of message.projects) {
|
|
4754
4788
|
for (const { branchName } of project.preserveOnlyBranches) {
|
|
4755
4789
|
if (stillPendingCreatedBranches.has(pendingCreatedBranchKey(project.projectId, branchName))) {
|
|
@@ -4786,7 +4820,7 @@ async function startWorker(options) {
|
|
|
4786
4820
|
}
|
|
4787
4821
|
stageDurableWorkspaceDeletions();
|
|
4788
4822
|
const mountsBeforeGit = buildWorkspaceMounts();
|
|
4789
|
-
hydrateWorkspaceGitMounts(
|
|
4823
|
+
await hydrateWorkspaceGitMounts(
|
|
4790
4824
|
workspaceShadowRoot,
|
|
4791
4825
|
mountsBeforeGit.filter((mount) => !mount.deleteWhenSourceMissing && !fs.existsSync(mount.sourcePath) && mount.busy?.() !== true),
|
|
4792
4826
|
// These mounts are intentionally hydrated before their project Git
|
|
@@ -4795,7 +4829,7 @@ async function startWorker(options) {
|
|
|
4795
4829
|
// checkout initialization from erasing synchronized dirt.
|
|
4796
4830
|
{ ignoreBusy: true }
|
|
4797
4831
|
);
|
|
4798
|
-
ensureConfiguredProjects();
|
|
4832
|
+
await ensureConfiguredProjects();
|
|
4799
4833
|
const configurationSyncAdmissionGeneration = workerAdmissionGeneration;
|
|
4800
4834
|
const assertConfigurationSyncStillAdmitted = () => {
|
|
4801
4835
|
if (receiptGeneration !== workspaceConfigurationReceiptGeneration || configurationSyncAdmissionGeneration !== workerAdmissionGeneration || !workspaceConfigurationIncidentSnapshotIsCurrent(incidentDeferral.incidentId, activeWorkspaceIncidentId) || currentWorkerSocket !== ws || ws.readyState !== WebSocket.OPEN) {
|
|
@@ -4840,12 +4874,12 @@ async function startWorker(options) {
|
|
|
4840
4874
|
const pending = [...pendingCheckouts.values()].sort(
|
|
4841
4875
|
(left, right) => left.projectId.localeCompare(right.projectId) || left.branchName.localeCompare(right.branchName)
|
|
4842
4876
|
);
|
|
4843
|
-
return { result, pending, aheadOfOriginBranches: collectAheadOfOriginBranches() };
|
|
4877
|
+
return { result, pending, aheadOfOriginBranches: await collectAheadOfOriginBranches() };
|
|
4844
4878
|
});
|
|
4845
4879
|
} catch (error) {
|
|
4846
4880
|
if (receiptGeneration !== workspaceConfigurationReceiptGeneration) {
|
|
4847
4881
|
return {
|
|
4848
|
-
result: failedWorkspaceSyncResult(crypto.randomUUID(), { type: "connect" }, error),
|
|
4882
|
+
result: await failedWorkspaceSyncResult(crypto.randomUUID(), { type: "connect" }, error),
|
|
4849
4883
|
pending: incidentDeferredProjectCheckouts(message.projects),
|
|
4850
4884
|
aheadOfOriginBranches: []
|
|
4851
4885
|
};
|
|
@@ -4877,7 +4911,7 @@ async function startWorker(options) {
|
|
|
4877
4911
|
pendingCheckouts.set(projectBranchKey(pending.projectId, pending.branchName), pending);
|
|
4878
4912
|
}
|
|
4879
4913
|
return {
|
|
4880
|
-
result: failedWorkspaceSyncResult(crypto.randomUUID(), { type: "connect" }, error),
|
|
4914
|
+
result: await failedWorkspaceSyncResult(crypto.randomUUID(), { type: "connect" }, error),
|
|
4881
4915
|
pending: [...pendingCheckouts.values()].sort(
|
|
4882
4916
|
(left, right) => left.projectId.localeCompare(right.projectId) || left.branchName.localeCompare(right.branchName)
|
|
4883
4917
|
),
|
package/dist/mjs/package.json
CHANGED