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
@@ -9,6 +9,7 @@ import { createJavaScriptRuntimeObservationEvidence } from "../../../src/applica
import { CdpBrowserProvider } from "../../../src/browser/CdpBrowserProvider.js";
import { CdpElectronProvider } from "../../../src/browser/CdpElectronProvider.js";
import { publishWebScripts } from "../../../src/browser/assets/PublishWebScripts.js";
import { ArtifactResourceScope } from "../../../src/artifacts/ArtifactResourceScope.js";
import { selectScriptCapture } from "../../../src/browser/assets/ScriptCaptureAdapters.js";
import { inspectWebPageInputSchema } from "../../../src/domain/browserObservation.js";
import { inspectElectronPageInputSchema } from "../../../src/domain/javascript/electronObservation.js";
@@ -69,6 +70,8 @@ describe.each(["browser", "electron"] as const)(
"$name through capture and consumers",
async ({ reported, expected }) => {
const root = await fixtureRoot();
const artifactResources = new ArtifactResourceScope();
resources.push(() => artifactResources.close());
const browser = await startFakeCdpBrowser({
...(kind === "electron"
? { electronFileUrl: pathToFileURL(join(root, "index.html")).href }
@@ -129,6 +132,7 @@ describe.each(["browser", "electron"] as const)(
},
selectScriptCapture(result.value),
createHash("sha256").update(captureBytes).digest("hex"),
{ resources: artifactResources },
);
expect(exported.scripts[0]?.source).toMatchObject({
is_module: expected.is_module,