feat(browser): capture correlated network content and lifecycle evidence (#797)
* feat(browser): capture correlated network content and lifecycle evidence Keep request identities and redirect relationships across ordered scenario events. Capture selected browser-exposed bytes and duplicate headers through modular readers, settle bounded reads before cleanup, and preserve unavailable states. Keep content-selection mismatches and legacy network coverage unknown during comparison. Verify real CLI/MCP, installed package, and browser lifecycle paths. Refs #774 Assisted-by: Yukari (gensokyo-skills:yukari-boundary-analysis) Assisted-by: Kogasa (gensokyo-skills:kogasa-surprise-testing) * fix(browser): align capture defaults and redact encoded media metadata Correct the complete documented request and legacy default expectation caught by CI. Cover and redact encoded declared values in captured body media types. Assisted-by: Yukari (gensokyo-skills:yukari-boundary-analysis) Assisted-by: Kogasa (gensokyo-skills:kogasa-surprise-testing) * test(browser): verify polling capture cutoff completeness Accept incomplete event coverage only when the continuously polling fixture has explicit unfinished requests; retain failures for other missing or truncated sections. Include actual completeness and unfinished transactions in diagnostics. Assisted-by: Yukari (gensokyo-skills:yukari-boundary-analysis) Assisted-by: Kogasa (gensokyo-skills:kogasa-surprise-testing)
This commit is contained in:
@@ -98,11 +98,54 @@ export const actionState = (step: BrowserScenarioStep) => ({
|
||||
export const eventsFor = (
|
||||
capture: BrowserScenarioCapture,
|
||||
stepIndex: number,
|
||||
): readonly unknown[] =>
|
||||
capture.events.items.flatMap(
|
||||
({ sequence: _sequence, step_index: eventStepIndex, ...event }) =>
|
||||
eventStepIndex === stepIndex ? [event] : [],
|
||||
): readonly unknown[] => {
|
||||
const sourceSteps = new Map(
|
||||
capture.events.items.map(({ sequence, step_index }) => [
|
||||
sequence,
|
||||
step_index,
|
||||
]),
|
||||
);
|
||||
return capture.events.items.flatMap<unknown>(
|
||||
({ sequence: _sequence, step_index: eventStepIndex, ...event }) => {
|
||||
if (event.kind === "network-content") {
|
||||
const { source_event_sequence: sourceSequence, ...content } = event;
|
||||
return sourceSteps.get(sourceSequence) === stepIndex ? [content] : [];
|
||||
}
|
||||
return eventStepIndex === stepIndex ? [event] : [];
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
/** Different content selection is missing comparability, not an observed website change. */
|
||||
export const networkContentCoverageReason = (
|
||||
before: BrowserScenarioCapture,
|
||||
after: BrowserScenarioCapture,
|
||||
): string | undefined => {
|
||||
const left = before.scenario.network_content;
|
||||
const right = after.scenario.network_content;
|
||||
if (left === undefined || right === undefined) {
|
||||
const events = [...before.events.items, ...after.events.items];
|
||||
if (
|
||||
events.some((event) => event.kind === "network-content") ||
|
||||
((left === undefined) !== (right === undefined) &&
|
||||
events.some(
|
||||
(event) =>
|
||||
event.kind === "request" ||
|
||||
event.kind === "response" ||
|
||||
event.kind === "request-failed" ||
|
||||
event.kind === "request-finished" ||
|
||||
event.kind === "request-unfinished",
|
||||
))
|
||||
)
|
||||
return "Network content selection is unknown in a legacy capture; capture both sides with matching content selection.";
|
||||
return undefined;
|
||||
}
|
||||
return left.request_body !== right.request_body ||
|
||||
left.response_body !== right.response_body ||
|
||||
left.header_values !== right.header_values
|
||||
? "Network content selections differ; capture both sides with matching content selection before comparing network evidence."
|
||||
: undefined;
|
||||
};
|
||||
|
||||
/** Wrap one value as captured comparison evidence. */
|
||||
export const captured = <Value>(value: Value): CaptureState<Value> => ({
|
||||
|
||||
Reference in New Issue
Block a user