mirror of
https://github.com/morluto/rea.git
synced 2026-11-05 06:15:59 +00:00
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:
1 parent
b529bd84d7
commit
fc7f042c8c
21 files changed
+61
-17
No files matched your search
@@ -12,7 +12,7 @@ import type { Result } from "../../domain/result.js";
|
||||
/** Stable read and CPython pyc decoding, independent of a disassembler session. */
|
||||
export interface PythonPycPort {
|
||||
readonly identity: ProviderIdentity;
|
||||
close?(): Promise<void>;
|
||||
close(): Promise<void>;
|
||||
inspect(
|
||||
input: InspectPythonPycInput,
|
||||
options?: ExecutionOptions,
|
||||
|
||||
@@ -69,6 +69,7 @@ const report: PythonPyc = {
|
||||
it("rejects a relative path and extra arguments before reading", async () => {
|
||||
let calls = 0;
|
||||
const service = new PythonPycService({
|
||||
close: async () => {},
|
||||
identity,
|
||||
inspect: () => {
|
||||
calls += 1;
|
||||
@@ -89,6 +90,7 @@ it("rejects a relative path and extra arguments before reading", async () => {
|
||||
|
||||
it("records the selected artifact and the header plus marshal ranges", async () => {
|
||||
const result = await new PythonPycService({
|
||||
close: async () => {},
|
||||
identity,
|
||||
inspect: () => Promise.resolve(ok(report)),
|
||||
}).inspect({ path: report.artifact.path });
|
||||
@@ -110,6 +112,7 @@ it("retains completed pyc Evidence and the opaque caller reason on late cancella
|
||||
const controller = new AbortController();
|
||||
const reason = new AnalysisInputError("opaque caller metadata");
|
||||
const service = new PythonPycService({
|
||||
close: async () => {},
|
||||
identity,
|
||||
inspect: () => {
|
||||
controller.abort(reason);
|
||||
@@ -135,6 +138,7 @@ it("retains a pre-admission cancellation reason without calling the pyc provider
|
||||
const reason = new Error("caller stopped before pyc admission");
|
||||
let calls = 0;
|
||||
const service = new PythonPycService({
|
||||
close: async () => {},
|
||||
identity,
|
||||
inspect: async () => {
|
||||
calls++;
|
||||
@@ -155,6 +159,7 @@ it("retains a pre-admission cancellation reason without calling the pyc provider
|
||||
it("preserves malformed provider output instead of relabeling it as a late abort", async () => {
|
||||
const controller = new AbortController();
|
||||
const service = new PythonPycService({
|
||||
close: async () => {},
|
||||
identity,
|
||||
inspect: async () => {
|
||||
controller.abort(new Error("later caller stop"));
|
||||
|
||||
@@ -23,7 +23,7 @@ export class PythonPycService {
|
||||
constructor(readonly provider: PythonPycPort) {}
|
||||
|
||||
close(): Promise<void> {
|
||||
return this.provider.close?.() ?? Promise.resolve();
|
||||
return this.provider.close();
|
||||
}
|
||||
|
||||
async inspect(
|
||||
|
||||
Reference in new issue
Block a user