mirror of
https://github.com/morluto/rea.git
synced 2026-12-03 21:46:01 +00:00
refactor(application): migrate 7 standalone format services onto executeArtifactInspection (#13861)
Closes #13860
This commit is contained in:
1 parent
a6847ae362
commit
97a95103d4
7 files changed
+269
-368
No files matched your search
@@ -1,16 +1,14 @@
|
||||
import type { ExecutionOptions } from "../../ports/AnalysisProvider.js";
|
||||
import type { V8CodeCachePort } from "../../ports/v8CodeCache/V8CodeCachePort.js";
|
||||
import type { AnalysisError } from "../../domain/analysisErrorBase.js";
|
||||
import { AnalysisOutputError } from "../../domain/analysisErrorCore.js";
|
||||
import { createEvidence, type Evidence } from "../../domain/evidence.js";
|
||||
import {
|
||||
inspectV8CodeCacheInputSchema,
|
||||
v8CodeCacheSchema,
|
||||
type V8CodeCache,
|
||||
} from "../../domain/v8/v8CodeCache.js";
|
||||
import { err, type Result } from "../../domain/result.js";
|
||||
import { completeProviderEvidence } from "../ProviderOperationExecution.js";
|
||||
import { parseAnalysisInput } from "../AnalysisInput.js";
|
||||
import type { Result } from "../../domain/result.js";
|
||||
import { executeArtifactInspection } from "../ArtifactInspectionExecution.js";
|
||||
|
||||
const OPERATION = "inspect_v8_code_cache";
|
||||
|
||||
@@ -22,57 +20,49 @@ export class V8CodeCacheService {
|
||||
return this.provider.close();
|
||||
}
|
||||
|
||||
async inspect(
|
||||
inspect(
|
||||
rawInput: unknown,
|
||||
options?: ExecutionOptions,
|
||||
): Promise<Result<Evidence, AnalysisError>> {
|
||||
const input = parseAnalysisInput(
|
||||
OPERATION,
|
||||
rawInput,
|
||||
inspectV8CodeCacheInputSchema,
|
||||
options?.signal,
|
||||
);
|
||||
if (!input.ok) return input;
|
||||
const result = await this.provider.inspect(input.value, options);
|
||||
if (!result.ok) return result;
|
||||
const report = v8CodeCacheSchema.safeParse(result.value);
|
||||
if (
|
||||
!report.success ||
|
||||
report.data.artifact.path !== input.value.path ||
|
||||
!validReport(report.data, input.value)
|
||||
)
|
||||
return err(
|
||||
new AnalysisOutputError(
|
||||
OPERATION,
|
||||
return executeArtifactInspection(
|
||||
{
|
||||
operation: OPERATION,
|
||||
inputSchema: inspectV8CodeCacheInputSchema,
|
||||
outputSchema: v8CodeCacheSchema,
|
||||
provider: this.provider,
|
||||
invalidOutputMessage:
|
||||
"V8 code cache provider returned malformed output or changed artifact identity.",
|
||||
),
|
||||
);
|
||||
const value = report.data;
|
||||
return completeProviderEvidence(
|
||||
createEvidence(
|
||||
{
|
||||
path: value.artifact.path,
|
||||
format: "file",
|
||||
sha256: value.artifact.sha256,
|
||||
},
|
||||
this.provider.identity,
|
||||
{
|
||||
operation: OPERATION,
|
||||
parameters: input.value,
|
||||
result: value,
|
||||
confidence: "observed",
|
||||
limitations: value.limitations,
|
||||
locations: [
|
||||
{ kind: "artifact-path" as const, path: value.artifact.path },
|
||||
toParameters: (input) => input,
|
||||
validateReport: (report, parameters) =>
|
||||
report.artifact.path === parameters.path &&
|
||||
validReport(report, parameters),
|
||||
buildEvidence: (value, identity, parameters) =>
|
||||
createEvidence(
|
||||
{
|
||||
kind: "file-offset-range" as const,
|
||||
start: value.payload.offset,
|
||||
end: value.payload.offset + value.payload.bytes,
|
||||
path: value.artifact.path,
|
||||
format: "file",
|
||||
sha256: value.artifact.sha256,
|
||||
},
|
||||
],
|
||||
},
|
||||
),
|
||||
options?.signal,
|
||||
identity,
|
||||
{
|
||||
operation: OPERATION,
|
||||
parameters,
|
||||
result: value,
|
||||
confidence: "observed",
|
||||
limitations: value.limitations,
|
||||
locations: [
|
||||
{ kind: "artifact-path" as const, path: value.artifact.path },
|
||||
{
|
||||
kind: "file-offset-range" as const,
|
||||
start: value.payload.offset,
|
||||
end: value.payload.offset + value.payload.bytes,
|
||||
},
|
||||
],
|
||||
},
|
||||
),
|
||||
},
|
||||
rawInput,
|
||||
options,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user