fix(setup): preserve skill files and report rollback failures
Track attempted writes, preserve original content and modes from one regular-file observation, and continue rollback after individual failures. Return tagged failure details and retained backup paths through setup. Validation: setup filesystem and recovery tests, combined compile/typecheck/lint/format/metadata/architecture checks. Filesystem fault injection covers backup, ambiguous publication, and rollback failures.
This commit is contained in:
+18
-14
@@ -26,6 +26,7 @@ import {
|
||||
import { AnalysisError } from "../domain/analysisErrorBase.js";
|
||||
import { analysisErrorWithCleanupFailure } from "../domain/analysisErrorCleanup.js";
|
||||
import { ProviderCleanupError } from "../domain/providerCleanupError.js";
|
||||
import type { SetupSkillInstallError } from "./SetupSkill.js";
|
||||
|
||||
/** Discover, approve, and apply setup actions idempotently. */
|
||||
export const runSetup = async (
|
||||
@@ -315,18 +316,20 @@ const runSetupWorkflow = async (
|
||||
: { onProgress: options.onProgress }),
|
||||
});
|
||||
if (clientFailure !== undefined) return fail(clientFailure);
|
||||
if (
|
||||
planSelection.installSkill &&
|
||||
!(await installSkillAction(
|
||||
if (planSelection.installSkill) {
|
||||
const skillFailure = await installSkillAction(
|
||||
host,
|
||||
options,
|
||||
appliedActions,
|
||||
selectedSkillClientIds,
|
||||
))
|
||||
)
|
||||
return fail(
|
||||
"REA analysis skill could not be installed or verified. Check permissions for its planned skill directories, then rerun setup.",
|
||||
);
|
||||
if (skillFailure !== undefined) {
|
||||
return {
|
||||
...(await fail(skillFailure.remediation)),
|
||||
code: "skill_install_failed",
|
||||
};
|
||||
}
|
||||
}
|
||||
const doctor = summarizeDoctor(await host.doctor(readinessScope));
|
||||
const remediation = combineRemediation(
|
||||
finalSetupRemediation(
|
||||
@@ -417,7 +420,7 @@ const installSkillAction = async (
|
||||
options: SetupOptions,
|
||||
appliedActions: string[],
|
||||
skillClientIds: readonly string[],
|
||||
): Promise<boolean> => {
|
||||
): Promise<SetupSkillInstallError | undefined> => {
|
||||
const label = "REA reverse-engineering skill";
|
||||
emitProgress(options, {
|
||||
actionId: "install_skill",
|
||||
@@ -425,22 +428,23 @@ const installSkillAction = async (
|
||||
state: "started",
|
||||
});
|
||||
const skill = await host.installSkill(skillClientIds);
|
||||
if (skill === "failed") {
|
||||
if (!skill.ok) {
|
||||
emitProgress(options, {
|
||||
actionId: "install_skill",
|
||||
label,
|
||||
state: "failed",
|
||||
detail: skill.error.message,
|
||||
});
|
||||
return false;
|
||||
return skill.error;
|
||||
}
|
||||
if (skill === "installed") appliedActions.push("installed_skill");
|
||||
if (skill.value === "installed") appliedActions.push("installed_skill");
|
||||
emitProgress(options, {
|
||||
actionId: "install_skill",
|
||||
label,
|
||||
state: skill === "installed" ? "completed" : "warning",
|
||||
...(skill === "unchanged" ? { detail: "Already current" } : {}),
|
||||
state: skill.value === "installed" ? "completed" : "warning",
|
||||
...(skill.value === "unchanged" ? { detail: "Already current" } : {}),
|
||||
});
|
||||
return true;
|
||||
return undefined;
|
||||
};
|
||||
|
||||
const setupFailure = async (
|
||||
|
||||
Reference in New Issue
Block a user