mirror of
https://github.com/morluto/rea.git
synced 2026-11-16 11:43:20 +00:00
refactor(evidence): unify retained inputs across domains (#8299)
Declare logical Evidence sources once and resolve exact retained inputs through shared application workflows across 20 composition tools. Preserve domain-owned authentication, source closure, caller choices, coverage and resource admission. Validation includes public CLI/MCP regressions, local Codex terra/high trials and fresh-import real-artifact workflows. Measurements, failed attempts and coverage limits are recorded in docs/verification/evidence-input-composition-2026-10-31.md. Fixes #8293. Fixes #8281. Assisted-by: Suika (gensokyo-skills:suika-scatter-gather-planning)
This commit is contained in:
1 parent
23de10bb28
commit
a989c0e458
114 files changed
+8532
-1383
No files matched your search
@@ -3,10 +3,10 @@ import { z } from "zod";
|
||||
import { compareUnicodeCodePoints } from "../unicodeCodePointOrder.js";
|
||||
import { logicalPathEscapesRoot } from "../artifactIdentity.js";
|
||||
import { evidenceSchema } from "../evidence.js";
|
||||
import type { EvidenceRequestFrameInput } from "../evidenceInputContract.js";
|
||||
import { javascriptRuntimeUnresolvedLocationSchema } from "./javascriptRuntimeObservation.js";
|
||||
import { javascriptApplicationGraphSchema } from "./javascriptApplicationGraph.js";
|
||||
import { digestSchema } from "../digests.js";
|
||||
import { prefixedDigestSchema } from "../digests.js";
|
||||
import { digestSchema, prefixedDigestSchema } from "../digests.js";
|
||||
import { urlDeclaresQueryOrFragment } from "../urlComponents.js";
|
||||
|
||||
const evidenceIdSchema = prefixedDigestSchema("ev");
|
||||
@@ -95,41 +95,65 @@ function runtimeMappingKey(mapping: RuntimeLocationMapping): string {
|
||||
: `url-prefix\0${mapping.prefix}\0${mapping.artifact_prefix}`;
|
||||
}
|
||||
|
||||
const validateReconciliationIdentities = (
|
||||
input: {
|
||||
readonly static_layers: readonly {
|
||||
readonly role: "application" | "cache" | "assets";
|
||||
readonly analysis: { readonly evidence_id: string };
|
||||
}[];
|
||||
readonly runtime_observations: readonly { readonly evidence_id: string }[];
|
||||
},
|
||||
context: z.RefinementCtx,
|
||||
): void => {
|
||||
if (
|
||||
input.static_layers.filter(({ role }) => role === "application").length !==
|
||||
1
|
||||
)
|
||||
context.addIssue({
|
||||
code: "custom",
|
||||
path: ["static_layers"],
|
||||
message: "Exactly one application static layer is required",
|
||||
});
|
||||
const staticIds = input.static_layers.map(
|
||||
({ analysis }) => analysis.evidence_id,
|
||||
);
|
||||
if (new Set(staticIds).size !== staticIds.length)
|
||||
context.addIssue({
|
||||
code: "custom",
|
||||
path: ["static_layers"],
|
||||
message: "Static layer Evidence must be unique",
|
||||
});
|
||||
const runtimeIds = input.runtime_observations.map(
|
||||
({ evidence_id: id }) => id,
|
||||
);
|
||||
if (new Set(runtimeIds).size !== runtimeIds.length)
|
||||
context.addIssue({
|
||||
code: "custom",
|
||||
path: ["runtime_observations"],
|
||||
message: "Runtime observation Evidence must be unique",
|
||||
});
|
||||
};
|
||||
|
||||
/** Verify layer roles and source uniqueness without copying retained payloads. */
|
||||
export const runtimeReconciliationIdentitiesSchema = z
|
||||
.object({
|
||||
static_layers: z.array(
|
||||
z.object({
|
||||
role: z.enum(["application", "cache", "assets"]),
|
||||
analysis: z.object({ evidence_id: evidenceIdSchema }),
|
||||
}),
|
||||
),
|
||||
runtime_observations: z.array(z.object({ evidence_id: evidenceIdSchema })),
|
||||
})
|
||||
.superRefine(validateReconciliationIdentities);
|
||||
|
||||
/** Evidence-backed static layers and passive captures to reconcile. */
|
||||
export const reconcileJavaScriptRuntimeInputSchema = z
|
||||
.strictObject({
|
||||
static_layers: z.array(staticLayerSchema).min(1),
|
||||
runtime_observations: z.array(evidenceSchema).min(1),
|
||||
})
|
||||
.superRefine((input, context) => {
|
||||
if (
|
||||
input.static_layers.filter(({ role }) => role === "application")
|
||||
.length !== 1
|
||||
)
|
||||
context.addIssue({
|
||||
code: "custom",
|
||||
path: ["static_layers"],
|
||||
message: "Exactly one application static layer is required",
|
||||
});
|
||||
const staticIds = input.static_layers.map(
|
||||
({ analysis }) => analysis.evidence_id,
|
||||
);
|
||||
if (new Set(staticIds).size !== staticIds.length)
|
||||
context.addIssue({
|
||||
code: "custom",
|
||||
path: ["static_layers"],
|
||||
message: "Static layer Evidence must be unique",
|
||||
});
|
||||
const runtimeIds = input.runtime_observations.map(
|
||||
({ evidence_id: id }) => id,
|
||||
);
|
||||
if (new Set(runtimeIds).size !== runtimeIds.length)
|
||||
context.addIssue({
|
||||
code: "custom",
|
||||
path: ["runtime_observations"],
|
||||
message: "Runtime observation Evidence must be unique",
|
||||
});
|
||||
});
|
||||
.superRefine(validateReconciliationIdentities);
|
||||
|
||||
const layerSummarySchema = z.strictObject({
|
||||
layer_id: prefixedDigestSchema("jrl"),
|
||||
@@ -275,6 +299,9 @@ export const javascriptRuntimeReconciliationResultSchema = z.strictObject({
|
||||
export type ReconcileJavaScriptRuntimeInput = z.infer<
|
||||
typeof reconcileJavaScriptRuntimeInputSchema
|
||||
>;
|
||||
/** Admitted ordinary request facts; each source still needs owner authentication. */
|
||||
export type ReconcileJavaScriptRuntimeFrame =
|
||||
EvidenceRequestFrameInput<ReconcileJavaScriptRuntimeInput>;
|
||||
export type JavaScriptRuntimeReconciliationResult = z.infer<
|
||||
typeof javascriptRuntimeReconciliationResultSchema
|
||||
>;
|
||||
|
||||
Reference in new issue
Block a user