mirror of
https://github.com/morluto/rea.git
synced 2026-12-02 11:33:10 +00:00
bd353e7e5cc54d445f1866c02211d4c2beb1db65
5
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
bd353e7e5c |
fix(errors)!: producers declare retry class, refusal recovery and real error codes (#15372)
* fix(errors)!: derive retryable from the producer's declared retry class `retryable` means the unchanged request may succeed, but it was computed downstream as an OR of a code table and five class rules. Every error classification now declares a retry class (same_call, change_first, never, unknown_outcome); `retryable` is `same_call` after one incomplete-cleanup check, and the RETRYABLE_CODES table is deleted. Producer corrections: - update_unknown revision conflicts are change_first and report details.current_revision; duplicate record_unknown reports details.existing_unknown_id. - close_gdb_session's explicit-disposition refusal is change_first. - Per-call artifact reader limits are change_first (never when the limit cannot rise). - An exited or unreachable Hopper bridge, and a Hopper start that another REA session owns, are change_first. - File-descriptor exhaustion (EMFILE/ENFILE) outside process launch is occupied host capacity (same_call) for private workspaces, model and GPU readers and JavaScript application reads. - apktool JVM native-thread exhaustion follows the shared capacity default. BREAKING CHANGE: these refusals now report `retryable: false` (descriptor pressure now reports `retryable: true` as `resource_constraint`). Callers that repeated them unchanged should follow the remediation first: re-read the unknown and retry with details.current_revision, dispose GDB inferiors, raise the reported reader limit, or restart the Hopper provider. * fix(errors): require producers to name recovery for conforming refusals A refusal whose arguments match the input schema was presented as a schema error whenever its producer left out remediation, and many producers did. AnalysisInputError's options are now a union: a conforming refusal must supply both its outcome (userMessage) and next step (remediationAction), so the compiler lists every producer; only contract violations may fall back to the schema guidance. Producers fixed: unknown Frida session and script, decompile_all output-directory state, the duplicate unknown build computer factory (collapsed), stale Cutter sessions, Mach-O architecture selection, output roots that already exist, selected files the host refuses, Ghidra lookups the bridge could not resolve, YARA path refusals, unresolved native symbol names, apt key files and withheld sign-in state. A missing selected APK is now target_unavailable like every other selected-file reader. The capability fallback "Choose another analysis or target" is deleted; a capability refusal without its own recovery names details.reason and binary_session. Refs #15312 * fix(errors): classify caller selections and target bytes by their real failure Several refusals reported a code that reads as corruption or a crash: - a missing unknown_id and a missing Evidence reference now report invalid_request instead of execution_failure and evidence_integrity_mismatch; - close_binary with snapshot_path in a resource-only session reports invalid_request instead of evidence_integrity_mismatch; - ADB push onto an existing device path and pulls into an occupied output directory are conforming invalid_request refusals naming overwrite or output_directory, not unreadable_output; - damaged APK ZIP, signing-block, signer and central-directory structures are malformed targets, not invalid input; - NuGet and VSIX bytes without a ZIP signature are unrecognized, not malformed; - a historical source graph file whose entries contradict its root commitment is an integrity failure, not invalid input; - a CDP protocol failure states what happened instead of the unclassified fallback message. Refs #15319 * feat(errors): expose the producer's retry class as retry_class Every error projection now carries retry_class (same_call, change_first, never or unknown_outcome) beside retryable, which stays true exactly for same_call. The field is additive: the error schema accepts errors retained by earlier releases without it. Refs #15323 * fix(errors): address review of the folded error-contract PRs Keep a provider's own capability message as its remediation; the binary_session fallback applies only to a bare declared reason. Delete the unused conformingInputRefusal helper. Compose both retry fields for a refused publication whose cleanup is incomplete. Report descriptor exhaustion from a JavaScript directory opendir as occupied capacity. Let an exited Hopper startup attempt without a setup failure code retry unchanged. Declare retry for the Ghidra superseded checkpoint and unknown IDA readiness. Redact ambiguous selector candidates. Give a Ghidra document miss its own recovery. Drop an unchanged-files claim the journal repair cannot make. Name each withheld sign-in refusal's step. Hash the source graph commitment before the cancellation yield. Keep the browser protocol_error message neutral. Add tests for mutation-audit survivors C3, C5, P2, P4, P8, H1, H4 and H5. * fix(errors): keep a missing Evidence reference an integrity failure and state only the observed commitment mismatch * test(desktop): assert the unknown build computer refusal's remediation, not its message The refusal now carries its next step in remediation.action instead of the message, so the closed-computer checks assert the exact code, message and remediation facts. * fix(errors): keep producer retry choices apart from cleanup and fixed ceilings A capture's retryable flag no longer folds in pending cleanup, so the projection applies the cleanup rule once and a transient capture with pending cleanup reports change_first instead of never. A release-fixed artifact allowance reports never, and a stale admitted session identity reports change_first (reopen, then retry); both have catalogue rows. The bare capability-unavailable remediation names binary_session only for a binary-analysis session, so standalone bridges such as Cutter are pointed at their own reason. * test(vsix): expect a non-ZIP selection to be refused as unrecognized This PR reports bytes without a ZIP signature as another format (unrecognized), not a damaged package; the exact-reason assertion added on main still expected malformed. * test(delivery): expect the capacity refusal's retry class in delivered failure facts The exact failure facts asserted on main predate the projection's retry_class; occupied capacity reports same_call. * fix(errors): mark a sent Hopper cancellation unknown and missing Evidence recoverable A cancellation Hopper already received may still apply, so its retry class is unknown_outcome instead of same_call; an unsent cancellation keeps same_call. A missing EvidenceReferenceError is change_first, since importing the referenced records lets the same request succeed; other reference failures stay never. Both have catalogue rows. * fix(hopper): ask for changed launch arguments before retrying an unencodable launch A launcher path or argument that cannot be encoded as an AppleScript literal meets the same pre-launch guard on every attempt, so the start refusal is change_first and its retry_action is unknown; a start failure without a declared reason stays same_call. * fix(errors): keep a one-shot cleanup failure's retry class with its cleanup state A one-shot reply that reports cleanup_incomplete spread the primary or cleanup projection and overrode only retryable, so a timed-out read whose close also failed carried retry_class same_call. The reply now reads its retry class from the typed composed failure, and never offers the same call before cleanup settles. * test(evtx): expect an unreadable selected log to be refused with its own recovery This PR treats a well-formed path the host refused as a regular file as conforming input with its own remediation; the evtx boundary test still expected a schema-recovery refusal. * test(javascript): expect a broken source-graph commitment as an integrity failure This PR reports a well-formed historical source graph whose entries disagree with its root_sha256 as evidence_integrity_mismatch, not an input issue; the exact refusal assertion added on main still expected invalid_request. |
||
|
|
88fd8a9df0 |
test: drop detail requests the budget seed made redundant (#14615)
PR #14252 added explicit complete-detail requests across tests before the vitest REA_AGENT_RESULT_BUDGET_BYTES seed and the complete-Evidence harness existed. Restore the pre-#14252 form where the seed or the harness already delivers complete Evidence. Keep the requests that are load-bearing: delivery, summary and budget tests, tools whose omitted detail is summary, and callers that neither the seed nor the harness reaches (unwrapped SDK clients on servers with an explicit environment, and in-process CLIs). Those were found by running the touched files with the shipped budget lowered to its 4 KiB minimum. |
||
|
|
123b693f08 |
feat(delivery)!: bound default results by an agent result budget (#14252)
* feat(delivery)!: bound default results by an agent result budget Omitted detail now returns complete Evidence only when it fits the new delivery.agent_result_budget_bytes runtime setting (default 49152 compact JSON bytes, about 12k tokens at an estimated 4 bytes per token). Larger results are retained and delivered as the producer's summary with a limitation naming the budget and the recovery call; nothing is refused or truncated. inspect_analysis_view gains an evidence-json view that pages the exact JSON text of retained Evidence. The CLI applies the same budget and publishes the complete bundle with --evidence_output. inspect_managed_members type_names now also narrows member_refs and exported_types, and inspect-byte-entropy gains CLI evidence delivery. BREAKING CHANGE: An omitted detail no longer always returns complete Evidence inline on MCP or the CLI for tools with a detail selector (including inspect_managed_members, inspect_managed_artifact, inspect_byte_entropy, inspect_artifact, analyze_javascript_application, list_procedures, list_strings and the other operations listed in src/domain/agentBudgetOperations.ts). Over the budget they return the retained summary; pass detail complete (--detail complete) for complete inline delivery. inspect_managed_members type_names narrows member_refs and exported_types. Fixes #14172 Fixes #14180 Part of #14187 Part of #14156 * test(schemas): record advertised summaries for budgeted detail * fix(delivery): keep budgeted summaries canonical and carry delivery facts beside them Review fixes for the agent result budget: - Deliver the producer's own summary record, identical to detail summary, so its identity holds in summary consumers such as compare_artifacts. The budget, sizes, retention and the exact paging call travel as delivery facts: a second MCP text block and _meta, or a delivery field in CLI output. - Capture the caller's detail for application-validated tools too, so inspect_binary_layout and similar tools are budgeted. - Keep recovery facts when a budgeted summary itself exceeds the frame. - Size an omitted evidence-json limit by escaped UTF-8 bytes and never split a surrogate pair, even in a one-unit page. - Add the REA_AGENT_RESULT_BUDGET_BYTES launch seed; the shared test environment raises it for semantic tests, and budget tests clear it. - Align tool descriptions and verifiers that read complete Evidence. * fix(delivery): retain the budgeted summary like an explicit summary * fix(delivery): read the budget seed from the captured environment and count delivery facts in the frame - The agent result budget seed is read from the environment the server or CLI invocation captured: ToolResultDelivery takes it at construction, and a CLI invocation binds it in its publication context. The ambient process environment is no longer read. - The frame check reserves the bytes of the delivery block and _meta that are added after encoding, so a budgeted response cannot exceed the frame. - Conformance workflows that resend complete Evidence raise the budget through the shared inline-Evidence environment, as do the artifact and binary layout verifiers. * fix(delivery)!: request complete Evidence explicitly and never spill CLI overflow - Shared test and verifier environments no longer raise the agent result budget. Every test and verifier workflow that reads complete Evidence from a budgeted tool now requests it with detail complete or --detail complete, including the real-provider verifiers outside PR CI (Ghidra, Hopper, IDA, Kuna and client verifiers). Default delivery is exercised as shipped. - Budgeting applies only to tools with a detail selector, so every budgeted call has a complete opt-out. - CLI overflow without --evidence_output writes nothing; its delivery facts carry exact rerun argv for --detail complete and --evidence_output, omitted when the command declares sensitive values. * test(delivery): prove captured budget seeds with valid in-range values * test: state complete-detail requests once and fix codemod regressions - Add tests/support/completeDetail.ts with COMPLETE_DETAIL and completeArguments so tests that read complete Evidence request it in one place, keeping functions within max-lines-per-function without raising the limit. - Restore provider-client tests (GhidraClient, Hopper health): their callTool("name", ...) calls are bridge requests, not MCP tools, and take no detail. - Update the game-scale type inventory test for member_refs narrowing. * test: request complete Evidence in shared JavaScript analysis helpers and remaining CLI workflows * test: request complete Evidence by default in the shared test transports The shared MCP client helpers (createTestMcp, connectLocalToolsMcp and the CLI fixture's shared MCP session) and the CLI runners (the cli fixture and the shared CLI session) now apply one named default, completeEvidenceByDefault. A budgeted tool called with neither detail nor view gets detail complete; the CLI does the same with --detail complete, chosen by the command's tool contract. A budgeted operation that resolves to no contract fails loudly at load. Tests whose subject is delivery opt out with delivery "budgeted". This is a test-harness choice; production delivery is unchanged and the budget tests prove the default path. Per-call complete-detail edits are reverted in the 204 test files whose transports all apply the default. Explicit requests remain where a test drives its own SDK client, server, CLI instance or process, and where the detail choice is the test's subject. * test: resolve CLI complete-detail defaults from the CLI registry The Real Apple and browser verifiers read complete Evidence through artifactCliEvidence, which ran the compiled CLI without a detail choice and got the budgeted {summary, delivery} output. The helper now requests complete Evidence for commands that take --detail, read from the compiled CLI's own registry (scripts/lib/complete-evidence-cli.mjs). The test harness default had a sibling bug: it treated every cli-flagged budgeted contract as taking --detail, but only Evidence-delivery commands do (inspect-binary-layout does not). It now reads the source CLI registry too, and covers every command the CLI budgets. * test(verifiers): request complete Evidence at each verifier's SDK client and CLI argv The real-browser failure was the same missing normalized_result as the Apple one: browser-capture-metadata-budget-e2e reads analyze-web-bundle through artifactCliEvidence, fixed in the previous commit. The shared verifier module, scripts/lib/complete-evidence.mjs, now owns both transports: - completeEvidenceClient wraps each verifier's SDK Client once, so every callTool to a budgeted tool with neither detail nor view requests complete Evidence, whatever local call helper a verifier uses (86 clients, including the Ghidra, Hopper, IDA and Kuna verifiers' argument-less list_procedures and inspect_native_load_image calls). - completeEvidenceCliArguments covers the remaining verifier CLI argv that chose no detail, such as function, decompile, analyze and the Android and Apple commands. Commands and tools that are not budgeted are sent as written. * test(delivery): await async completeEvidenceCliArguments helper in boundary test * test(delivery): request complete detail in Electron CLI artifact format test * docs(delivery): document delivery.rerun as add-only argument arrays * test(schemas): record advertised summaries for the unified delivery budget Tool descriptions now name the agent result budget, and the evidence-json default page is derived from the 32 KiB default, which changes the advertised input digests of the 28 affected tools. Recorded from the Build package job's output. * test(delivery): pin the budget boundary and keep failures unbudgeted Main's retainedSummaryDelivery tests pinned the size decision at exactly 32,768 and 32,769 UTF-8 JSON bytes. Unifying that decision into budgetedSummaryBytes deleted them, and their port never landed, so the byte measurement went unchecked. Restore them against budgetedSummaryBytes at the configured budget and one byte over, for the default and a runtime budget, with ASCII, escaped and multibyte text, plus each condition of the decision. Off-by-one mutants (< for <=, a cap one byte short) fail six cases; measuring UTF-16 code units instead of UTF-8 bytes fails the multibyte cases. An MCP case pins that a target failure from a budgeted tool under the minimum budget is identical with detail omitted and complete, with no delivery facts. * test(verifiers): route literal CLI argv for budgeted commands through complete Evidence real-browser failed with "Scenario CLI did not report external disconnect ownership": runScenarioCli ran capture-browser-scenario without --detail, so an over-budget capture came back as its summary, which has no browser.cleanup. The earlier sweep counted these files as covered because their MCP clients were wrapped, but their CLI argv was not. Route the shared runScenarioCli helper (five callers), the local cli helpers in the module, source-map and script-export verifiers, and every other literal argv for a budgeted CLI command without --detail or --view (EVM interface, binary layout, packet capture, devicetree, DOM destinations, Ghidra relocation symbols, WABT cleanup, Termux browser) through completeEvidenceCliArguments. A sweep of scripts/ for budgeted command literals with --json and no detail selection now finds none. * fix(verifiers): leave clients without callTool unwrapped The native verifier cleanup test drives native-value-e2e with a connection double whose Client has only connect and close. completeEvidenceClient bound client.callTool unconditionally, so wrapping threw a TypeError before connect ran. That TypeError replaced the primary connection failure the test asserts is preserved, and all four fault cases failed in Test shard 5 and Portable tests. A client without callTool has no tool call to complete, so the helper now returns it unchanged. Locally all five fault modes of the fixture now exit 0. * fix(delivery): keep the catalog recorder on shipped helpers and expect view-implied summary The verifier sweep wrapped record-mcp-catalog.mjs in completeEvidenceClient, which lives in an unshipped helper. deferredRuntime copies only the package's shipped files plus the recorder, so the recorder failed to load (ERR_MODULE_NOT_FOUND) and its cleanup recorder never wrote. The recorder only lists tools and prompts, so the wrapper had no effect; it is removed. This branch makes a view with no --detail select summary delivery, as MCP does for a view. Three CLI cases still expected the old view refusal; with a view alone the missing input is now the summary bundle, so they expect evidence_output, and a view with --detail complete still refuses the view. * fix(delivery): request complete Evidence where callers need the whole result Budgeted delivery made four callers receive a summary they cannot use: - The GitHub Actions example uploads the analysis as a CI artifact, so it now asks for --detail complete; over budget it had saved a summary. - javascriptIntegrityPolicyCli spawns the CLI itself, outside the test harness default, and reads normalized_result; it now applies the same completeEvidenceCliArguments default. - nativeObservationViewsMcp builds its own client to prove complete observations overflow into a paging continuation; it now applies the harness default so each call asks for complete Evidence. - The CLI parity goldens are re-recorded for the --detail and --evidence_output options the budgeted commands now advertise. * fix(tests): give processes tests spawn the largest agent result budget About 90 tests spawn scripts/rea.mjs or a server directly, outside the harness default that asks for complete Evidence, and read analysis facts from the result. Over the default budget they received a summary instead; javascriptChildHandleOwnership failed this way. The Vitest environment now seeds REA_AGENT_RESULT_BUDGET_BYTES with the largest accepted value, so a spawned CLI or server delivers complete Evidence, as the in-process default does. Delivery tests keep their own budget: agentResultBudgetMcp builds its server without the seed, so its default-budget cases still exercise the shipped default. * fix(tests): give budgeted harness tests the shipped agent result budget The test environment seeds the largest agent result budget so spawned processes deliver complete Evidence. In-memory servers built by createApplicationMcpHarness (and connectGhidraMcp, which uses it) inherit process.env too, so a test that chose testDelivery "budgeted" kept the seed: the 600-row list_procedures case and the omitted-detail web page views returned complete Evidence instead of a summary. testDeliveryEnvironment now owns that choice: a budgeted test's server environment drops the seed and uses the shipped default. The application harness applies it to every server it builds. * fix(tests): expect view-implied summary delivery in the Playwright trace refusal A view with no --detail now selects summary delivery, so its refusal names the missing evidence_output bundle; --detail complete still refuses the view. The trace test still expected a view refusal in both cases. |
||
|
|
858ff73880 |
perf(tests): give MCP test clients the shared lazy schema validation (#10960)
* perf(tests): give MCP test clients the shared lazy schema validation The MCP SDK client compiles every listed tool's output schema on its first tool call. With the SDK's default Ajv options, REA's catalog costs gigabytes of allocation per client (inspect_analysis_view alone: 1.7 s and ~500 MiB retained), so native MCP files peaked at 1-2 GiB per worker. tests/fixtures/mcpSchemaValidation already owns lazy, reference-preserving validation. Route the native MCP, process-boundary and shared harness clients through it, share compiled validators across clients in a worker (bounded LRU keyed by schema text), and add a counted architecture guard so default-validation test clients cannot spread; the remaining copies are the baseline. * fix(guards): read call arguments past parentheses inside string literals * perf(tests): give MCP boundary test clients the shared schema validation (#11022) * perf(tests): give MCP boundary test clients the shared schema validation * perf(tests): give the remaining MCP test clients the shared schema validation (#11025) * fix(guards): read an MCP client's validator option from parsed code The default-validation counter searched each new Client(...) call's text for jsonSchemaValidator, so an inline comment, a string literal or a client name naming the option hid a default client. Parse the source with @babel/parser and count NewExpressions of Client whose object-literal arguments have no jsonSchemaValidator property; a source that does not parse counts every textual call. The guard reads raw test sources, and the generated-child-script allowlist entry, which no longer counts as a call, is removed. * fix(guards): read an MCP client's options only from a whole object-literal argument The default-validation counter skipped files without the text 'new Client(', so a comment between the tokens hid a client, and it took any depth-two key as an option, so 'enabled ? { jsonSchemaValidator } : {}' passed while its false branch uses the SDK default. The skip now only requires the name Client, and the validator counts only when it is a key of an object literal that is a whole argument; anything else counts as the default. |
||
|
|
c010fafe45 | test(cli): align fixtures with current owning contracts |