refactor!: enforce canonical evidence and provider boundaries
Deliver complete Evidence directly through MCP with required nullable analysis profiles and immutable per-server delivery settings. Bind selected environments at construction and require typed cleanup outcomes with retained retry ownership. Remove test-only routing, duplicate session and snapshot metadata, producer-field repairs, and ambiguous provider arguments. Separate artifact byte identity from occurrence classification and retain typed source-map and partial native facts across CLI, MCP, and verifier consumers. BREAKING CHANGE: obsolete Evidence envelopes, session aliases, incomplete snapshots, and missing normalized producer facts are no longer accepted.
This commit is contained in:
@@ -26,6 +26,25 @@ export const cdpStringValue = (value: unknown): string | undefined =>
|
||||
export const numberValue = (value: unknown): number | undefined =>
|
||||
typeof value === "number" && Number.isFinite(value) ? value : undefined;
|
||||
|
||||
/** Preserve partial script declarations; omitted or invalid fields remain unknown. */
|
||||
export const scriptMetadataValues = (
|
||||
value: UnknownRecord | undefined,
|
||||
): {
|
||||
readonly hash: string | null;
|
||||
readonly length: number | null;
|
||||
readonly isModule: boolean | null;
|
||||
} => {
|
||||
const length = numberValue(value?.length);
|
||||
return {
|
||||
hash: cdpStringValue(value?.hash) ?? null,
|
||||
length:
|
||||
length !== undefined && Number.isSafeInteger(length) && length >= 0
|
||||
? length
|
||||
: null,
|
||||
isModule: typeof value?.isModule === "boolean" ? value.isModule : null,
|
||||
};
|
||||
};
|
||||
|
||||
export const requiredRecord = (value: unknown): UnknownRecord => {
|
||||
const record = recordValue(value);
|
||||
if (record === undefined)
|
||||
@@ -33,6 +52,20 @@ export const requiredRecord = (value: unknown): UnknownRecord => {
|
||||
return record;
|
||||
};
|
||||
|
||||
/** Require producer source text; an absent source is distinct from an empty script. */
|
||||
export const requiredScriptSource = (
|
||||
value: unknown,
|
||||
operation: BrowserObservationOperation,
|
||||
): string => {
|
||||
const source = cdpStringValue(recordValue(value)?.scriptSource);
|
||||
if (source === undefined)
|
||||
throw new BrowserObservationError(operation, "protocol_error", {
|
||||
detail:
|
||||
"Debugger.getScriptSource returned malformed source text: scriptSource must be a string.",
|
||||
});
|
||||
return source;
|
||||
};
|
||||
|
||||
export const isHttpUrl = (value: string | undefined): boolean => {
|
||||
if (value === undefined) return false;
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user