mirror of
https://github.com/morluto/rea.git
synced 2026-11-23 12:49:00 +00:00
* refactor(process): compose supervision and provider-client cleanup failures through the shared owner * refactor(native): compose LLDB, native UI and signature cleanup failures through the shared owner (#10908) * refactor(native): compose LLDB, native UI and signature cleanup failures through the shared owner * refactor(server): compose close, reset and session-status cleanup failures through the shared owner (#10915) * refactor(dotnet): compose managed snapshot cleanup failures through the shared owner (#10917) * refactor(dotnet): compose managed snapshot cleanup failures through the shared owner * refactor(flutter): compose build cleanup failures through the shared owner (#10918) * refactor(flutter): compose build cleanup failures through the shared owner * refactor(apple): compose asset catalog and keyed archive cleanup failures through the shared owner (#10919) * refactor(ghidra): join session cleanup failures through the shared owner (#10920) * refactor(ghidra): join session cleanup failures through the shared owner * refactor(desktop): compose build-setup cleanup failures through the shared owner (#10921) * refactor(desktop): compose build-setup cleanup failures through the shared owner * refactor(cutter): compose bridge service cleanup failures through the shared owner (#10922) * refactor(cutter): compose bridge service cleanup failures through the shared owner * refactor(electron): compose fuse and file-scope cleanup failures through the shared owner (#10923) * refactor(electron): compose fuse and file-scope cleanup failures through the shared owner * refactor(browser): compose scenario, web-bundle and capture cleanup failures through the shared owner (#10924) * refactor(application): compose uninstall, session retirement and decompile-all cleanup failures through the shared owner (#10933) * refactor(application): compose uninstall, session retirement and decompile-all cleanup failures through the shared owner * refactor(ghidra): compose Java probe, NativeAOT snapshot and provider-client cleanup failures through the shared owner (#10927) * refactor(ghidra): compose Java probe, NativeAOT snapshot and provider-client cleanup failures through the shared owner * refactor(hopper): compose provider close cleanup failures through the shared owner (#10928) * refactor(hopper): compose provider close cleanup failures through the shared owner * refactor(javascript): compose analysis worker runtime and inspection failures through the shared owner (#10929) * refactor(javascript): compose analysis worker runtime and inspection failures through the shared owner * refactor(kuna): compose project-cache and target-command cleanup failures through the shared owner (#10930) * refactor(kuna): compose project-cache and target-command cleanup failures through the shared owner * refactor(native): compose macOS provider, pwndbg and pwntools cleanup failures through the shared owner (#10931) * refactor(native): compose macOS provider, pwndbg and pwntools cleanup failures through the shared owner * refactor(wasm): compose WABT artifact cleanup failures through the shared owner (#10932) * refactor(wasm): compose WABT artifact cleanup failures through the shared owner * refactor(application): compose analysis-view cancellation and retained-content cleanup failures through the shared owner (#10941) * refactor(application): compose analysis-view cancellation and retained-content cleanup failures through the shared owner * refactor(kuna): compose span-close cancellation cleanup through the shared owner (#10942) * refactor(decompile): bind the initialization failure with its cleanup through the shared owner (#10965) * refactor(decompile): bind the initialization failure with its cleanup through the shared owner * refactor(cli): bind environment serve listener and close failures through the shared owner (#10966) * refactor(cli): bind environment serve listener and close failures through the shared owner * refactor(kuna): bind project export and span-read failures with their cleanup through the shared owner (#10967) * refactor(kuna): bind project export and span-read failures with their cleanup through the shared owner * refactor(cutter): bind descriptor read failures with their cleanup through the shared owner (#10968) * refactor(cutter): bind descriptor read failures with their cleanup through the shared owner * refactor(ida): bind workspace file failures with their cleanup through the shared owner (#10969) * refactor(ida): bind workspace file failures with their cleanup through the shared owner * refactor(rizin): bind debug finalization failures with their cleanup through the shared owner (#10970) * refactor(rizin): bind debug finalization failures with their cleanup through the shared owner * refactor(application): compose close rejections with unknown completion through one owner (#10971) * refactor(application): compose close rejections with unknown completion through one owner * refactor(hopper): compose startup and launcher close rejections through the shared owner (#10972) * refactor(hopper): compose startup and launcher close rejections through the shared owner * refactor(desktop): compose task-file close rejections through the shared owner (#10973) * fix(hopper): confirm reported close failures when a later close of the client succeeds * fix(hopper): keep owned close failures reading their own owner on retry HopperClient bound every failed close part to its client retry, so a launcher aggregate that already follows its child failures stayed pending after the launcher released them. AnalysisCleanupRelease.bindUnowned now owns the rule that a retry claims only ownerless failures; BinarySession's local copy of it is removed. * fix(hopper): release each close part's earlier failures when that part succeeds One shared retry release made the session part's earlier failures wait for the launcher part too, so a later close whose session cleanup succeeded kept reporting the session's released resources. HopperClient keeps one release per part (session, launcher), and each part confirms its own failures when it succeeds.
143 lines
6.3 KiB
TypeScript
143 lines
6.3 KiB
TypeScript
import type { BrowserScenario } from "../domain/browserScenario.js";
|
|
import { PLAYWRIGHT_RESPONSE_BODY_PROVENANCE_LIMITATION } from "../domain/browserNetworkEvidence.js";
|
|
import type {
|
|
BrowserScenarioCaptureData,
|
|
BrowserScenarioPartialObservation,
|
|
} from "../domain/browserScenarioCapture.js";
|
|
import type {
|
|
BrowserScenarioEvent,
|
|
BrowserScenarioStep,
|
|
} from "../domain/browserScenarioCaptureValues.js";
|
|
import type { BrowserScenarioSessionPort } from "./BrowserScenarioSessionPort.js";
|
|
import { AnalysisError } from "../domain/analysisErrorBase.js";
|
|
import { browserCleanupObservation } from "../domain/browserObservationError.js";
|
|
import { analysisErrorWithCleanupDependencies } from "../domain/analysisErrorCleanup.js";
|
|
import { ProviderCleanupError } from "../domain/providerCleanupError.js";
|
|
import { ProviderAdapterError } from "../domain/providerAdapterError.js";
|
|
import { PLAYWRIGHT_BROWSER_SCENARIO_PROVIDER_IDENTITY } from "./providerIdentities.js";
|
|
|
|
const OPERATION = "capture_browser_scenario" as const;
|
|
|
|
const browserScenarioLimitations = (
|
|
session: BrowserScenarioSessionPort,
|
|
scenario: BrowserScenario,
|
|
events: readonly BrowserScenarioEvent[],
|
|
): string[] => {
|
|
const capturedResponseBody =
|
|
scenario.capture.network.response_body &&
|
|
events.some(
|
|
(event) =>
|
|
event.kind === "network-content" &&
|
|
event.phase === "response" &&
|
|
event.body.state === "captured" &&
|
|
(event.body.representation === "playwright-response-body-bytes" ||
|
|
event.body.representation === "browser-decoded-response-bytes"),
|
|
);
|
|
return [
|
|
"Event sequence records provider receipt order; simultaneous browser causality is not inferred.",
|
|
"Network content is retained only when selected; Playwright response-body bytes are API results and are not guaranteed to match wire bytes.",
|
|
"Request bytes are limited to what Playwright exposes; not_exposed does not establish body absence or multipart file coverage.",
|
|
"Network content reads settle within 5 seconds each and the observer does not request bodies from unfinished responses.",
|
|
...(capturedResponseBody
|
|
? [PLAYWRIGHT_RESPONSE_BODY_PROVENANCE_LIMITATION]
|
|
: []),
|
|
"Playwright scenario events do not expose request initiator stacks; receipt order does not prove causality.",
|
|
"Storage values are hashed only after declared-secret redaction.",
|
|
...(scenario.actions.some(({ action }) => action === "request")
|
|
? [
|
|
"Request steps sent their declared requests through the page's own fetch with its cookies and session, following no redirects; they are REA-initiated, not user-interface activity, and header values of at least 8 characters they read from page cookies or local storage are redacted like declared secrets from records made after they were read.",
|
|
]
|
|
: []),
|
|
...(scenario.storage.local_storage.length === 0 &&
|
|
scenario.storage.session_storage.length === 0
|
|
? []
|
|
: [
|
|
"Non-cookie storage seeds use CDP pre-script instrumentation; only pauses in the scenario's private seed script are resumed by this observer.",
|
|
]),
|
|
...(session.eventLimitations?.() ?? []),
|
|
...(session.storageLimitations?.() ?? []),
|
|
...(session.mode === "connect"
|
|
? [
|
|
"CDP attachment cannot recover pre-attach events or guarantee launch-time context options.",
|
|
`Attached locale ${scenario.environment.locale} applies to Intl formatting only; navigator.language(s) and Accept-Language remain caller-controlled. Use launch mode for matching page and request languages.`,
|
|
"Detaching a CDP page session may clear caller-owned navigator.platform emulation. REA cannot snapshot the caller's complete user-agent/client-hint state before attachment; use launch mode to avoid mutating that external browser.",
|
|
]
|
|
: []),
|
|
];
|
|
};
|
|
|
|
/** Project one session into the common capture fields used by success and failure. */
|
|
export const browserScenarioCaptureData = (input: {
|
|
readonly session: BrowserScenarioSessionPort;
|
|
readonly scenario: BrowserScenario;
|
|
readonly startedAt: number;
|
|
readonly steps: readonly BrowserScenarioStep[];
|
|
readonly cleanup:
|
|
| "terminated-owned-process"
|
|
| "disconnected-external"
|
|
| "incomplete";
|
|
readonly limitations?: readonly string[];
|
|
}): BrowserScenarioCaptureData => {
|
|
const events = input.session.events();
|
|
return {
|
|
browser: {
|
|
mode: input.session.mode,
|
|
process_ownership: input.session.processOwnership,
|
|
cleanup: input.cleanup,
|
|
product: input.session.product,
|
|
version: input.session.version,
|
|
},
|
|
scenario: {
|
|
start_origin: new URL(input.scenario.start_url.url).origin,
|
|
action_count: input.scenario.actions.length,
|
|
secret_references: input.scenario.secrets
|
|
.map(({ secret_id: id }) => id)
|
|
.sort(),
|
|
network_content: input.scenario.capture.network,
|
|
event_families: [...new Set(input.scenario.capture.events)].sort(),
|
|
limits: input.scenario.capture.limits,
|
|
},
|
|
duration_ms: Math.max(0, Math.round(performance.now() - input.startedAt)),
|
|
steps: [...input.steps],
|
|
events,
|
|
limitations: [
|
|
...browserScenarioLimitations(
|
|
input.session,
|
|
input.scenario,
|
|
events.items,
|
|
),
|
|
...(input.limitations ?? []),
|
|
],
|
|
};
|
|
};
|
|
|
|
/** Retain operation diagnostics and capture data after cleanup settles. */
|
|
export const browserScenarioOperationFailure = (
|
|
cause: unknown,
|
|
partialObservation: BrowserScenarioPartialObservation,
|
|
cleanupFailure?: { readonly cause: unknown },
|
|
): AnalysisError => {
|
|
const primary =
|
|
cause instanceof AnalysisError
|
|
? cause
|
|
: new ProviderAdapterError(
|
|
PLAYWRIGHT_BROWSER_SCENARIO_PROVIDER_IDENTITY.id,
|
|
OPERATION,
|
|
{ cause },
|
|
);
|
|
primary.retainPartialObservation(partialObservation);
|
|
if (cleanupFailure === undefined) return primary;
|
|
const observation = browserCleanupObservation(cleanupFailure.cause);
|
|
const cleanup =
|
|
cleanupFailure.cause instanceof AnalysisError &&
|
|
cleanupFailure.cause.cleanupIncomplete
|
|
? cleanupFailure.cause
|
|
: new ProviderCleanupError(
|
|
PLAYWRIGHT_BROWSER_SCENARIO_PROVIDER_IDENTITY.id,
|
|
observation.resources,
|
|
{ reason: observation.reason },
|
|
{ operation: "close_browser_scenario", cause: cleanupFailure.cause },
|
|
);
|
|
return analysisErrorWithCleanupDependencies(primary, cleanup, OPERATION);
|
|
};
|