mirror of
https://github.com/morluto/rea.git
synced 2026-11-14 18:52:48 +00:00
refactor: centralize input validation and schema interpretation
Migrate twelve application service files to the existing provider input owner, preserving schema causes, cancellation precedence, caller selection, and retained Evidence. Keep flows with distinct error policies separate. Replace the DeepSeek verifier's recursive object scan with schema-position traversal using the canonical keyword and local-reference owners. Literal pattern fields no longer cause false regex failures; patternProperties keys are checked alongside actual pattern constraints in native regex modes. Validation: 271 focused workflow/service tests and six verifier regressions passed; static checks, discovery, and actual Node source-loader smoke passed. The baseline scanner reproduced the new regressions. Installed DeepSeek client execution was not run.
This commit is contained in:
1 parent
8a65787507
commit
6c35d74a7d
15 files changed
+324
-240
No files matched your search
@@ -1,10 +1,8 @@
|
||||
import { parseProviderOperationInput } from "../ProviderOperationExecution.js";
|
||||
import type { ExecutionOptions } from "../AnalysisProvider.js";
|
||||
import type { SqliteDatabasePort } from "./SqliteDatabasePort.js";
|
||||
import type { AnalysisError } from "../../domain/analysisErrorBase.js";
|
||||
import {
|
||||
AnalysisCancelledError,
|
||||
AnalysisOutputError,
|
||||
} from "../../domain/analysisErrorCore.js";
|
||||
import { AnalysisOutputError } from "../../domain/analysisErrorCore.js";
|
||||
import {
|
||||
createEvidence,
|
||||
type Evidence,
|
||||
@@ -21,7 +19,6 @@ import {
|
||||
sqliteSchemaScope,
|
||||
sqliteInspectionParameters,
|
||||
} from "../../domain/sqlite/sqliteDatabase.js";
|
||||
import { analysisInputErrorFromIssues } from "../../domain/inputIssueProjection.js";
|
||||
import { err, ok, type Result } from "../../domain/result.js";
|
||||
|
||||
const OPERATION = "inspect_sqlite_database";
|
||||
@@ -82,27 +79,21 @@ export class SqliteDatabaseService {
|
||||
rawInput: unknown,
|
||||
options?: ExecutionOptions,
|
||||
): Promise<Result<Evidence, AnalysisError>> {
|
||||
if (options?.signal?.aborted)
|
||||
return err(
|
||||
new AnalysisCancelledError(OPERATION, {
|
||||
cause: options.signal.reason,
|
||||
}),
|
||||
);
|
||||
const input = inspectSqliteDatabaseInputSchema.safeParse(rawInput);
|
||||
if (!input.success)
|
||||
return err(
|
||||
analysisInputErrorFromIssues(OPERATION, input.error.issues, rawInput, {
|
||||
cause: input.error,
|
||||
}),
|
||||
);
|
||||
const inspected = await this.provider.inspect(input.data, options);
|
||||
const input = parseProviderOperationInput(
|
||||
OPERATION,
|
||||
rawInput,
|
||||
inspectSqliteDatabaseInputSchema,
|
||||
options?.signal,
|
||||
);
|
||||
if (!input.ok) return input;
|
||||
const inspected = await this.provider.inspect(input.value, options);
|
||||
if (!inspected.ok) return inspected;
|
||||
const execution = inspected.value;
|
||||
const report = sqliteDatabaseSchema.safeParse(execution.result);
|
||||
if (
|
||||
!report.success ||
|
||||
execution.subject == null ||
|
||||
!matchesSelectedDatabase(report.data, input.data, execution.subject)
|
||||
!matchesSelectedDatabase(report.data, input.value, execution.subject)
|
||||
)
|
||||
return err(
|
||||
new AnalysisOutputError(
|
||||
@@ -113,7 +104,7 @@ export class SqliteDatabaseService {
|
||||
return ok(
|
||||
createEvidence(execution.subject, execution.provider, {
|
||||
operation: OPERATION,
|
||||
parameters: sqliteInspectionParameters(input.data),
|
||||
parameters: sqliteInspectionParameters(input.value),
|
||||
result: report.data,
|
||||
...(execution.rawResult === null
|
||||
? {}
|
||||
|
||||
Reference in new issue
Block a user