refactor(lifecycle): require cleanup for offline providers

Require resource-owning provider ports to expose cleanup and migrate test adapters to delegate or explicitly close their own resources.
This commit is contained in:
morluto committed 2026-10-27 06:49:07 +08:00
1 parent b529bd84d7
commit fc7f042c8c
21 files changed
+61 -17

No files matched your search

+1 -1
View File
@@ -12,7 +12,7 @@ import type { Result } from "../../domain/result.js";
/** Replaceable offline metadata reader with no target-execution or decryption authority. */
export interface Il2cppMetadataPort {
readonly identity: ProviderIdentity;
close?(): Promise<void>;
close(): Promise<void>;
inspect(
input: Il2cppMetadataProviderInput,
options?: ExecutionOptions,
@@ -23,6 +23,7 @@ const report = createEmptyIl2cppMetadataFixture();
const serviceReturning = (value: Il2cppMetadata, calls = { count: 0 }) =>
new Il2cppMetadataService({
close: async () => {},
identity,
inspect: () => {
calls.count += 1;
@@ -104,6 +105,7 @@ it("reports cancellation before and after reading", async () => {
const during = new AbortController();
const service = new Il2cppMetadataService({
close: async () => {},
identity,
inspect: () => {
during.abort();
@@ -158,7 +160,11 @@ it("preserves source Evidence and requested output choices when publication fail
path: "/output/seeds.tsv",
});
const service = new Il2cppMetadataService(
{ identity, inspect: async () => ok(linkedReport()) },
{
close: async () => {},
identity,
inspect: async () => ok(linkedReport()),
},
seedWriter(async () => err(failure)),
);
const result = await service.inspectWithGhidraSeeds(selectedPair, {
@@ -192,7 +198,11 @@ it("retains a published seed receipt if cancellation arrives after the atomic wr
generic_instances: null,
};
const service = new Il2cppMetadataService(
{ identity, inspect: async () => ok(linkedReport()) },
{
close: async () => {},
identity,
inspect: async () => ok(linkedReport()),
},
seedWriter(async () => {
controller.abort(reason);
return ok(receipt);
@@ -44,7 +44,7 @@ export class Il2cppMetadataService {
async close(): Promise<void> {
let failure: AnalysisError | undefined;
for (const close of [
() => this.provider.close?.(),
() => this.provider.close(),
() => this.seeds?.close(),
]) {
try {