fix(setup): retain regular-file cleanup ownership through workflows

Thread the existing resource scope through skill and client configuration reads. Keep failed-close handles owned, wait for admitted reads, and surface unresolved cleanup alongside doctor, uninstall and update results.

Validated focused setup/doctor/update and filesystem boundary checks, temporary-file hygiene, packaged setup/update/uninstall workflows, and static checks. No external provider installation was performed.
This commit is contained in:
morluto
2026-10-12 05:57:35 +08:00
parent 9c8511409c
commit dcfc5d403a
15 changed files with 707 additions and 143 deletions
+18
View File
@@ -18,6 +18,7 @@ import {
type NpmInstallationHost,
} from "./UpdateRuntime.js";
import type { IntegrationMaintenance } from "./UpdateMaintenance.js";
import { isUpdateFailure } from "./UpdateFailure.js";
class FakeUpdateHost implements UpdateHost {
release: Result<string, ReleaseLookupFailure> = ok("3.3.0");
@@ -37,6 +38,7 @@ class FakeUpdateHost implements UpdateHost {
verifiedInstallation: UpdateInstallation | undefined;
maintenanceInspected = false;
output: UpdateOutput | undefined;
cleanupFailure: string | undefined;
installation = (): Promise<UpdateInstallation | undefined> => {
this.installationInspected = true;
@@ -63,6 +65,8 @@ class FakeUpdateHost implements UpdateHost {
this.maintenanceInspected = true;
return Promise.resolve(this.maintenance);
};
close = (): Promise<string | undefined> =>
Promise.resolve(this.cleanupFailure);
}
describe("REA update", () => {
@@ -79,6 +83,20 @@ describe("REA update", () => {
expect(host.maintenanceInspected).toBe(false);
});
it("preserves update status while marking incomplete resource cleanup as failure", async () => {
const host = new FakeUpdateHost();
host.cleanupFailure = "Regular file remains open: /fixture/skill/SKILL.md";
const result = await runUpdate("3.3.0", host);
expect(result).toMatchObject({
status: "current",
currentVersion: "3.3.0",
cleanupFailure: host.cleanupFailure,
});
expect(isUpdateFailure(result)).toBe(true);
});
it("reports an unknown current installation honestly", async () => {
const host = new FakeUpdateHost();
host.installationResult = undefined;