fix(artifacts): retain ASAR resources through cleanup failures

Give snapshot capture, header admission, packed members, and container streams one file-handle owner. Serialize adoption with reader shutdown, retain failed closes for retry, and remove snapshots only after descriptor cleanup succeeds.

Cover unread members, pending opens, zero-byte members, and paired format/cleanup failures. Keep intentionally unrecoverable test fixtures hygienic and strengthen managed identity and process cleanup-authority expectations.

Validation: full npm run check; 99 targeted tests and temporary-directory hygiene; exact discovery of 877 test files. No real vendor-provider verification was performed.
This commit is contained in:
morluto
2026-10-12 05:05:21 +08:00
parent 290d301ec7
commit eb97da3388
7 changed files with 670 additions and 222 deletions
@@ -280,7 +280,11 @@ describe("managed native boundary inspection", () => {
describe("independent managed metadata facets", () => {
it("preserves identity, members, and imports when embedded resources are malformed", () => {
const bytes = buildManagedPeFixture({ pinvoke: {}, readyToRun: true });
const bytes = buildManagedPeFixture({
mvid: Buffer.from("3aebc60edc4a544b1f458b4ed40b33b1", "hex"),
pinvoke: {},
readyToRun: true,
});
bytes.writeUInt32LE(0x7fff_0000, 0x0200 + 24);
const target = managedPeFixtureTarget(bytes);
const artifact = inspectManagedArtifactBytes(bytes, target);
@@ -288,7 +292,7 @@ describe("independent managed metadata facets", () => {
const native = inspectManagedNativeBoundariesBytes(bytes, target);
for (const result of [artifact, members, native]) {
expect(result.module?.mvid).toBeTruthy();
expect(result.module?.mvid).toBe("0ec6eb3a-4adc-4b54-1f45-8b4ed40b33b1");
expect(result.metadata.status).toBe("partial");
expect(result.coverage).toMatchObject({
state: "partial",