[PR #4391] [CLOSED] fix(browser): bound observe_web_session windows to the Node.js timer limit #6211

Closed
opened 2026-10-31 01:12:43 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/4391
Author: @Adolanium
Created: 10/16/2026
Status: ❌ Closed

Base: main ← Head: fix/observe-window-timer-bound


📝 Commits (2)

  • 63d0cc6 fix(browser): bound observe_web_session windows to the Node.js timer limit
  • 809bca8 Merge remote-tracking branch 'upstream/main' into fix/observe-window-timer-bound

📊 Changes

3 files changed (+32 additions, -2 deletions)

View changed files

📝 docs/browser-observation.md (+1 -1)
➕ src/domain/browserSession.test.ts (+30 -0)
📝 src/domain/browserSession.ts (+1 -1)

📄 Description

Summary

Fixes #4392.

observe_web_session accepted any positive observation_ms. Values above 2,147,483,647 overflow Node's timer, so the window ended after about 1 ms but the result still reported end_reason: "window_elapsed" with the large requested_ms. The input schema now rejects those values, as observe_web_execution already does.

Problem and expected behavior

observeWebSessionInputSchema in src/domain/browserSession.ts declared observation_ms: z.number().int().min(1).default(10_000) with no maximum. waitForWindow in src/browser/CdpObservationSession.ts passes the value straight to setTimeout. Node clamps a delay above 2^31-1 to 1 ms and prints TimeoutOverflowWarning. The result then claims a window of the requested length elapsed when it did not.

observeWebExecutionInputSchema in src/domain/webExecution.ts already uses .max(2_147_483_647) for the same field.

Change and scope

  • observeWebSessionInputSchema adds .max(2_147_483_647) to observation_ms. The schema is the owning input boundary: the MCP tool contract in src/contracts/browserToolContracts.ts uses it as inputSchema, and the CLI command in src/cli/browserCommands.ts parses its input with it, so both reject the value with an out_of_range issue that carries maximum.
  • docs/browser-observation.md states the accepted range.

Not included: other observation tools (inspect_web_page, discover_webmcp_tools, Electron and JavaScript runtime observation) wait through delayWithCancellation, which splits long delays into timer-sized chunks, so they are not affected and keep accepting larger values. #3392 (scenario timers overflow) is related but separate and is not changed here.

Follow the contribution scope.
Unresolved scope, authority, side effects, or required verification block
integration. Link the required maintainer scope decision for new providers or
capabilities involving target execution, injection, mutation, or protection
recovery; ordinary fixes within existing boundaries may state "not applicable".
Draft PRs may leave the scope decision pending and the readiness and merge checklists
unchecked. Maintainers can help resolve open questions.

Scope decision: not applicable. This is an input-bound fix for an existing tool.

Contract and boundary impact

  • Semantic owner and earliest changed stage: observeWebSessionInputSchema, request parsing.
  • Contribution scope fit and linked maintainer decision: ordinary fix within existing boundaries; not applicable.
  • CLI and MCP/tool-catalog contract: observation_ms now has maximum: 2147483647 in the advertised input schema. Requests above it fail validation instead of returning a false window_elapsed result.
  • Provider, bridge, target-format, or platform compatibility: none.
  • Evidence, artifact, provenance, or reconstruction contract: a returned window.requested_ms with end_reason: "window_elapsed" now matches a timer that actually ran for that long.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): none.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact (CI generates and validates ignored catalogs and skills/; edit authored instructions in .agents/skills/reverse-engineer-anything/ and never commit build outputs): the generated catalog will show the new maximum. No authored catalog source lists the bound.

Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated: new src/domain/browserSession.test.ts checks that 2,147,483,647 is accepted, that 2,147,483,648 fails with a too_big issue on observation_ms with maximum: 2147483647, and that the input JSON Schema from z.toJSONSchema has minimum: 1 and maximum: 2147483647.
  • Base reproduction or other evidence: executed. With the upstream/main schema the new test fails because 2,147,483,648 is accepted. Separately, setTimeout(…, 2_147_483_648) on Node 24.14.1 printed TimeoutOverflowWarning: 2147483648 does not fit into a 32-bit signed integer. Timeout duration was set to 1. and fired after 7 ms. I did not run observe_web_session against a browser.
  • User-visible CLI/MCP output (if applicable): rea observe-web-session <endpoint> <target> --observation-ms 2147483648 --json should now return invalid_request with the issue { "path": ["observation_ms"], "reason": "out_of_range", "maximum": 2147483647 }. This is source-derived; the CLI boundary tests need a built CLI, which I could not build on this Windows checkout.
  • Remaining proof gaps: no live browser session and no CLI or MCP boundary run. The regression is at the schema.

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

  • npm run test:focused -- src/domain/browserSession.test.ts — 1 test passed.
  • npx vitest run src/domain/browserSession.test.ts with the upstream/main schema — failed (expected true to be false on the rejection check).
  • npx tsc --noEmit --pretty false — no errors.
  • npx oxlint src/domain/browserSession.ts src/domain/browserSession.test.ts — 0 warnings, 0 errors.
  • npx oxfmt --check on the three changed files — formatted.
  • npm run build:cached — did not complete on Windows. It stopped because the packaged Windows native artifact is missing, so the CLI boundary tests were not run.

Compatibility, safety, and release

  • Breaking changes or migration steps: requests with observation_ms above 2,147,483,647 (about 24.8 days) now fail validation. Those requests previously ended after about 1 ms while reporting the full window, so no working call is affected.
  • Real Hopper/Ghidra, browser, or OS coverage: not run.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: none.

Author readiness

Human owner: @Adolanium

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/4391 **Author:** [@Adolanium](https://github.com/Adolanium) **Created:** 10/16/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/observe-window-timer-bound` --- ### 📝 Commits (2) - [`63d0cc6`](https://github.com/morluto/rea/commit/63d0cc63ab8dd1663a902b1a7a68658a775e3305) fix(browser): bound observe_web_session windows to the Node.js timer limit - [`809bca8`](https://github.com/morluto/rea/commit/809bca8f1ad9f53fa6c770d2c6fe01ca681cf245) Merge remote-tracking branch 'upstream/main' into fix/observe-window-timer-bound ### 📊 Changes **3 files changed** (+32 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `docs/browser-observation.md` (+1 -1) ➕ `src/domain/browserSession.test.ts` (+30 -0) 📝 `src/domain/browserSession.ts` (+1 -1) </details> ### 📄 Description ## Summary Fixes #4392. `observe_web_session` accepted any positive `observation_ms`. Values above 2,147,483,647 overflow Node's timer, so the window ended after about 1 ms but the result still reported `end_reason: "window_elapsed"` with the large `requested_ms`. The input schema now rejects those values, as `observe_web_execution` already does. ## Problem and expected behavior `observeWebSessionInputSchema` in `src/domain/browserSession.ts` declared `observation_ms: z.number().int().min(1).default(10_000)` with no maximum. `waitForWindow` in `src/browser/CdpObservationSession.ts` passes the value straight to `setTimeout`. Node clamps a delay above 2^31-1 to 1 ms and prints `TimeoutOverflowWarning`. The result then claims a window of the requested length elapsed when it did not. `observeWebExecutionInputSchema` in `src/domain/webExecution.ts` already uses `.max(2_147_483_647)` for the same field. ## Change and scope - `observeWebSessionInputSchema` adds `.max(2_147_483_647)` to `observation_ms`. The schema is the owning input boundary: the MCP tool contract in `src/contracts/browserToolContracts.ts` uses it as `inputSchema`, and the CLI command in `src/cli/browserCommands.ts` parses its input with it, so both reject the value with an `out_of_range` issue that carries `maximum`. - `docs/browser-observation.md` states the accepted range. Not included: other observation tools (`inspect_web_page`, `discover_webmcp_tools`, Electron and JavaScript runtime observation) wait through `delayWithCancellation`, which splits long delays into timer-sized chunks, so they are not affected and keep accepting larger values. #3392 (scenario timers overflow) is related but separate and is not changed here. Follow the [contribution scope](https://github.com/morluto/rea/blob/main/CONTRIBUTING.md#contribution-scope). Unresolved scope, authority, side effects, or required verification block integration. Link the required maintainer scope decision for new providers or capabilities involving target execution, injection, mutation, or protection recovery; ordinary fixes within existing boundaries may state "not applicable". Draft PRs may leave the scope decision pending and the readiness and merge checklists unchecked. Maintainers can help resolve open questions. Scope decision: not applicable. This is an input-bound fix for an existing tool. ## Contract and boundary impact - Semantic owner and earliest changed stage: `observeWebSessionInputSchema`, request parsing. - Contribution scope fit and linked maintainer decision: ordinary fix within existing boundaries; not applicable. - CLI and MCP/tool-catalog contract: `observation_ms` now has `maximum: 2147483647` in the advertised input schema. Requests above it fail validation instead of returning a false `window_elapsed` result. - Provider, bridge, target-format, or platform compatibility: none. - Evidence, artifact, provenance, or reconstruction contract: a returned `window.requested_ms` with `end_reason: "window_elapsed"` now matches a timer that actually ran for that long. - Target selection, authority, upstream behavior, and cleanup details (if applicable): none. - Generated metadata (`docs/public/product-catalog.json`), package, or installation impact (CI generates and validates ignored catalogs and `skills/`; edit authored instructions in `.agents/skills/reverse-engineer-anything/` and never commit build outputs): the generated catalog will show the new maximum. No authored catalog source lists the bound. Expected effects (check known effects; use documentation-only on its own). Unchecked items do not establish absence; leave uncertainties visible. - [ ] Read existing files or captured data. - [ ] Launch or attach to a process. - [ ] Inject instrumentation or run scripts/code. - [ ] Change process memory, registers, files, or configuration. - [ ] Contact network services. - [ ] Recover protected code or work around protections. - [ ] Documentation or usability only; no target interaction. - [ ] Not sure yet; investigation or maintainer guidance needed. ## Evidence and regression coverage - Tests added or updated: new `src/domain/browserSession.test.ts` checks that 2,147,483,647 is accepted, that 2,147,483,648 fails with a `too_big` issue on `observation_ms` with `maximum: 2147483647`, and that the input JSON Schema from `z.toJSONSchema` has `minimum: 1` and `maximum: 2147483647`. - Base reproduction or other evidence: executed. With the `upstream/main` schema the new test fails because 2,147,483,648 is accepted. Separately, `setTimeout(…, 2_147_483_648)` on Node 24.14.1 printed `TimeoutOverflowWarning: 2147483648 does not fit into a 32-bit signed integer. Timeout duration was set to 1.` and fired after 7 ms. I did not run `observe_web_session` against a browser. - User-visible CLI/MCP output (if applicable): `rea observe-web-session <endpoint> <target> --observation-ms 2147483648 --json` should now return `invalid_request` with the issue `{ "path": ["observation_ms"], "reason": "out_of_range", "maximum": 2147483647 }`. This is source-derived; the CLI boundary tests need a built CLI, which I could not build on this Windows checkout. - Remaining proof gaps: no live browser session and no CLI or MCP boundary run. The regression is at the schema. For evidence-bearing changes: - [x] Observed, derived, and inferred claims remain distinguishable. - [x] Artifact identity, source provenance, and failed attempts remain preserved. - [x] Unsupported, incomplete, unavailable, or uncertain outcomes remain visible. ## Validation performed - `npm run test:focused -- src/domain/browserSession.test.ts` — 1 test passed. - `npx vitest run src/domain/browserSession.test.ts` with the `upstream/main` schema — failed (`expected true to be false` on the rejection check). - `npx tsc --noEmit --pretty false` — no errors. - `npx oxlint src/domain/browserSession.ts src/domain/browserSession.test.ts` — 0 warnings, 0 errors. - `npx oxfmt --check` on the three changed files — formatted. - `npm run build:cached` — did not complete on Windows. It stopped because the packaged Windows native artifact is missing, so the CLI boundary tests were not run. ## Compatibility, safety, and release - Breaking changes or migration steps: requests with `observation_ms` above 2,147,483,647 (about 24.8 days) now fail validation. Those requests previously ended after about 1 ms while reporting the full window, so no working call is affected. - Real Hopper/Ghidra, browser, or OS coverage: not run. - Package or release metadata impact: none. - Security, privacy, process, or containment review: none. ## Author readiness <!-- The human owner completes these declarations before requesting review. The PR author is the owner by default. A different owner must explicitly accept ownership on this PR. AI agents must leave these declarations to a human to dictate to them or there could be catastrophic consequences for many users of REA. Draft PRs may leave them unchecked. These declarations record initial readiness when opening the PR for review; later pushes do not require a new human sign-off. Keep the description and validation evidence current as the work changes. See CONTRIBUTING.md#pull-request-ownership-and-readiness. --> Human owner: @Adolanium - [x] I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work. - [x] I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps. - [x] I declare this PR ready for initial maintainer review. ## Before merge <!-- Draft PRs may leave pending items unchecked. Resolve material scope and authority questions before integration. --> - [ ] This PR addresses a concrete problem or an agreed enhancement. - [ ] Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff. - [ ] The PR has one focused outcome and the title follows `type(scope): outcome`. - [ ] Related issue is linked, or the reason for not linking one is stated above. - [ ] Tests cover changed observable behavior and meaningful failure paths. - [ ] Owning docs, contracts, and generated metadata are updated where needed. - [ ] User-visible CLI/MCP changes include representative output. - [ ] I checked the final diff for secrets, unrelated cleanup, and unsupported claims. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 01:12:43 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#6211
No description provided.