fix(publication)!: retain cleanup owners across export workflows

Require an ArtifactResourceScope for web script exports and share its lifetime with CLI or MCP shutdown. Retain setup-failed output trees in firmware and Wakaru providers. Preserve completed publications when descriptor cleanup fails, returning the full result after a successful retry or as a partial observation while cleanup remains unresolved.
This commit is contained in:
morluto
2026-10-11 05:17:10 +08:00
parent 3f8c51e9b5
commit be75ed5e4b
15 changed files with 801 additions and 166 deletions
@@ -10,6 +10,7 @@ import {
import { dirname, join } from "node:path";
import { describe, expect, it, onTestFinished } from "vitest";
import { exportWebScripts } from "../../../src/application/WebScriptExportService.js";
import { ArtifactResourceScope } from "../../../src/artifacts/ArtifactResourceScope.js";
import { LocalWebModuleArtifacts } from "../../../src/browser/modules/WebModuleArtifacts.js";
import { projectAnalysisError } from "../../../src/domain/analysisErrorProjection.js";
import { webScriptExportResultSchema } from "../../../src/domain/webScriptExport.js";
@@ -19,16 +20,21 @@ import { scriptScenarioFixture } from "../../fixtures/webScriptCapture.js";
const fixture = async (bytes = Buffer.from('import "./dep.js";')) => {
const root = await createTestTempDirectory("rea-module-artifacts-");
const capturePath = join(root, "capture.json");
const resources = new ArtifactResourceScope();
onTestFinished(() => resources.close());
await writeFile(
capturePath,
JSON.stringify(
scriptScenarioFixture([{ url: "https://app.test/main.js", bytes }]),
),
);
const response = await exportWebScripts({
capture_path: capturePath,
output_directory: join(root, "export"),
});
const response = await exportWebScripts(
{
capture_path: capturePath,
output_directory: join(root, "export"),
},
resources,
);
if (!response.ok) throw response.error;
const result = webScriptExportResultSchema.parse(
response.value.normalized_result,