Skip to content

fix(browser): keep negative script columns Chrome reports - #8684

Merged
morluto merged 2 commits into
morluto:mainfrom
SandstromPL:fix/web-runtime-negative-columns
Nov 3, 2026
Merged

morluto merged 2 commits into
morluto:mainfrom
SandstromPL:fix/web-runtime-negative-columns

Conversation

@SandstromPL

@SandstromPL SandstromPL commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #8674.

observe-web-execution failed for a whole page with unreadable_output ("Too small: expected number to be >=0") when Chrome reported one Debugger.scriptParsed event with a negative column. The reporter saw startColumn: -60, endColumn: -15 for an inline script in WordPress 7.1's helper frame. CDP declares these columns as plain integers. REA's own min(0) refused the whole observation.

REA now keeps the column CDP reports, so the rest of the page is observed. A negative column is documented as one that does not locate a column in url. The passive inspect_web_page and discover_webmcp_tools paths now use the same column rule, so they keep that column instead of reporting it as an invalid protocol value.

Problem and expected behavior

  • Smallest trigger: one Debugger.scriptParsed event, from any frame in the attached page, with startColumn or endColumn below zero. Unowned helper-frame scripts are parsed too, so one such script fails the page.
  • Violated invariant: admission imposed a minimum the protocol does not declare (docs/tool-design.md: limits must follow real protocol constraints). One producer value discarded every other observation.
  • Expected: the observation completes. The script keeps its reported resource_start, and positions in it keep their reported columns.

Change and scope

  • One column representation: cdpResourceColumnSchema (src/domain/cdpObservationSchemas.ts) is z.int() for CDP resource columns. It is used for:

    • Debugger.scriptParsed startColumn and endColumn;
    • initiator stack call-frame columns;
    • a parser initiator's columnNumber;
    • event listener columns;
    • passive console, network-initiator and WebMCP registration columns, read through cdpSourceCoordinates.
  • Domain contract: these column fields accept any integer:

    • src/domain/webRuntime.ts: resource_start.column_number, and callsite/listener location.column_number;
    • src/domain/browserObservationSchemas.ts: console column and network initiator.column;
    • src/domain/webMcpDiscovery.ts: registration_source.column.

    The web runtime descriptions say Chrome can report a negative column, which then does not locate a column in url.

  • Passive capture (from Codex review): cdpSourceCoordinates had its own >= 0 rule. A negative column became null and was reported as invalid_protocol_value, and WebMCP discovery dropped the tool's whole registration_source. It now uses the shared schema for columns, and lines keep their non-negative rule.

  • Docs: docs/web-runtime.md adds this to the existing script-relative conversion guidance, and docs/browser-observation.md to the passive source-location description.

  • Why keep the reported value rather than null or omitting the script:

    • It preserves the producer's fact.
    • Chrome adds a script's start column to positions on its first line. Checked with real Chrome 156: an inline script starting at column 38 reported a first-line fetch call frame at column 38, and a second-line one at column 2. So the documented column_number - resource_start.column_number still gives the script-relative column.
  • Why callsites, listeners and parser initiators are included:

    • They use the same coordinate space. For the reported script (start column -60, 45 characters, one line), every position on its first line would be negative.
    • Fixing only scriptParsed would move the failure to the first request stack or listener in that script.
    • Negative callsite or listener columns were not observed in a real page; this part is source-derived from the offset check above.
  • Intentionally not included:

    • Lines keep min(0), because no negative line was reported.
    • Coverage ranges are script-relative offsets and keep min(0).
    • Why Chrome produced the negative column is not established (see remaining proof gaps).

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.

Contract and boundary impact

  • Semantic owner and earliest changed stage: cdpResourceColumnSchema in src/domain/cdpObservationSchemas.ts owns the column policy.
    • Runtime consumers: CDP admission in CdpScriptContextFacts.ts, CdpRuntimeProtocol.ts (stacks, listeners), CdpNetworkEventFacts.ts (initiators), and CdpRuntimeSources (projects resource_start and locations).
    • Passive consumers: cdpSourceCoordinates in CdpCaptureEventHelpers.ts, for console events, network initiators and WebMCP registrations.
    • Superseded: the four column-specific runtime uses of integer (min(0)), and cdpSourceCoordinates' own column check.
  • Contribution scope fit and linked maintainer decision: an ordinary fix within the existing web runtime tools, so not applicable.
  • CLI and MCP/tool-catalog contract: output schemas drop minimum: 0 from these columns.
    • observe_web_execution and inspect_web_event_listeners: resource_start.column_number and location.column_number, with extended descriptions.
    • inspect_web_page: console column and network initiator.column.
    • discover_webmcp_tools: registration_source.column.
    • Inputs, including trace_web_source_location's script-relative columns, are unchanged.
  • Provider, bridge, target-format, or platform compatibility: Chrome/CDP web runtime observation, passive page capture and WebMCP discovery.
  • Evidence, artifact, provenance, or reconstruction contract: runtime Evidence now retains a negative reported column where the observation previously failed. Passive Evidence retains it where it was previously null and marked incomplete.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): unchanged.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact: none beyond the generated tool schemas.

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. (existing CDP attachment by these tools; unchanged)
  • Inject instrumentation or run scripts/code. (existing Debugger/Profiler instrumentation; unchanged)
  • 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:
    • tests/boundary/mcp/webRuntimeMcp.test.ts (public path): a fake CDP browser replays the reported script (startColumn -60, endColumn -15) and a listener on its first line at column -50.
      • Through an in-memory MCP client and server, inspect_web_event_listeners succeeds. Its structuredContent validates against the advertised output schema with Ajv 2020.
      • The compiled CLI inspect-web-event-listeners --json exits 0.
      • Both keep the listener's location.column_number: -50 and the script's resource_start.column_number: -60.
    • tests/boundary/browser/cdpWebRuntimeReview.test.ts (production provider): observeExecution with the same script, a script-initiated request whose call frame is at column -40, and a parser-initiated request at column -30. It succeeds and keeps all three columns. Requests are emitted inside the armed window through the progress hook, which the public path does not expose.
    • tests/fixtures/webRuntime.ts: the shared negative-column fake browser.
    • tests/boundary/mcp/browserSourceCoordinates.test.ts (public path): a fake CDP browser reports one call frame at line 21, column -40, for a console event, a script-initiated request and a WebMCP registration.
      • inspect_web_page and discover_webmcp_tools succeed through MCP, and their results validate against the advertised output schemas with Ajv 2020.
      • The results keep column: -40 for the console event, the request initiator and registration_source.
      • console_events, network_initiators and webmcp_tools record no invalid_protocol_value.
      • The existing malformed case (line -3, column 7.5) is unchanged and still reports unknown coordinates.
  • Base reproduction or other evidence (executed):
    • With src and docs restored to main (144843c), both new tests fail with the reporter's message, "Too small: expected number to be >=0".
    • Restoring only CdpRuntimeProtocol.ts fails both. Restoring only CdpNetworkEventFacts.ts fails the execution test (parser initiator). Restoring only src/domain/webRuntime.ts fails both at output validation.
    • With src and docs restored to the first commit (ad2d93cd3), the passive test fails: all three columns are null. Restoring only browserObservationSchemas.ts and webMcpDiscovery.ts makes its MCP call return an error.
  • User-visible CLI/MCP output (if applicable): before, unreadable_output with "Too small: expected number to be >=0". After, the observation's Evidence, for example "resource_start": { "line_number": 21, "column_number": -60 }, from the fake browser above.
  • Remaining proof gaps:
    • No real page reproduction. The negative column comes from the reporter's Chrome 156 trace.
    • Local Chrome 156.0 probes did not produce one. They tried document.write into frames, parser-time document.write, DOM-inserted, contextual-fragment and insertAdjacentHTML scripts, and inline event-handler attributes.
    • Those probes did show handler positions in a document.write frame reported against the parent URL at line 0, columns 321–397. That is one reason the description says such columns may not locate a position in url.
    • No WordPress Playground run. No macOS or Windows run.

For boundary fixes, identify the applicable boundary regressions
and lifecycle regressions
covered by the evidence above, and explain relevant gaps.

  • Format assumptions: the unusual valid value (negative integer column) is paired with malformed input on both paths. The existing malformed-Debugger.scriptParsed refusal still stops the runtime window. The passive path's existing malformed case (line -3, column 7.5) still reports null coordinates with invalid_protocol_value.
  • Missing, empty, and unknown values: an unowned helper-frame script keeps its reported metadata and excluded source alongside usable sibling facts.
  • Public success and error delivery: listeners are covered through MCP and the compiled CLI, and passive console, initiator and WebMCP locations through MCP. Execution callsites are covered at the provider boundary only.
  • Lifecycle: no resource ownership or cleanup changes.

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

Run on Linux with Node 24.22.1 (.nvmrc) and npm 11.19.1 (packageManager pins 11.16.0), on upstream/main 144843c:

  • npm run test:focused -- tests/boundary/browser/cdpWebRuntimeReview.test.ts tests/boundary/mcp/webRuntimeMcp.test.ts tests/acceptance/webRuntimeCli.test.ts: 3 files, 37 tests passed.
  • npm run test:focused on the 13 browser boundary files (cdpWebRuntime*, cdpScriptMetadata, cdpCaptureScriptMetadata, cdpConnection, cdpProtocolFailure, browserLifecycleFollowup): 123 tests passed. This was before the listener case moved to the MCP file; that move changed only test files.
  • npm run test:focused -- tests/boundary/mcp/toolSchemaValidity.test.ts tests/boundary/mcp/mcpSchemaValidation.test.ts tests/boundary/mcp/outputSchemaProfile.test.ts tests/boundary/mcp/outputSchemaSemanticConstraints.test.ts (with the web runtime MCP/CLI files): 6 files, 53 tests passed.
  • npm run test:local -- src/application/WebRuntimeService.test.ts src/browser/CdpCaptureValues.test.ts src/browser/execution/CdpExecutionWindow.test.ts src/browser/execution/CdpRuntimeRequests.test.ts src/contracts/toolEffects.test.ts: 5 files, 29 tests passed.
  • npx tsc --noEmit -p ., npm run check:fast and npm run docs:check passed.
  • npx oxfmt --check and npx oxlint on the changed files, and git diff --check: clean.
  • The base-revision and per-file restore runs are listed above.
  • Real Chrome 156 (headless, local generated pages, all requests fulfilled locally): the start-column offset check above and the failed reproduction attempts. The probe scripts are not part of this PR.
  • Follow-up ddaf2e367 (Codex review: passive capture):
    • npm run test:focused on 29 boundary and acceptance files covering console events, initiators, WebMCP registrations, the web runtime and MCP schema validity: 429 tests passed.
    • npm run test:local on 19 passive capture, WebMCP, capture-diff and web runtime unit files: 249 tests passed.
    • npx tsc --noEmit -p ., npm run check:fast, npm run docs:check, npx oxfmt --check, npx oxlint on the changed files and git diff --check passed.
  • Not run: npm run check:pr, a real WordPress page, or a real-browser public CLI/MCP run.

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
    • Output schemas are relaxed, not narrowed. A client that assumed non-negative columns can now receive a negative one where the observation previously failed.
  • Real Hopper/Ghidra, browser, or OS coverage: real Chrome 156 on Linux, for the offset check only. The negative-column case is from the reporter's macOS trace.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: no new data is retained. The value was already in the CDP event.

Author readiness

Human owner: @SandstromPL

  • 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.

🤖 Generated with Claude Code

Chrome reported a Debugger.scriptParsed event with startColumn -60 and
endColumn -15 for an inline script in WordPress's helper frame. CDP declares
these columns as plain integers, but REA's admission required min(0), so one
script failed the whole observe-web-execution run with unreadable_output.

CDP resource columns now share one representation, cdpResourceColumnSchema,
for script start/end columns, initiator call frames, parser initiators and
event listeners. Positions on a script's first line include its start column,
so keeping the reported values keeps the documented script-relative
conversion consistent. The domain contract and web runtime docs state that a
negative column does not locate a column in the resource.

Fixes morluto#8674

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-02T16:41:51.130098Z ddaf2e3 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@greptile-apps

greptile-apps Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The reviewed changes appear safe to merge.

Summary

Keeps negative columns reported by Chrome instead of rejecting the observation.

  • Web-runtime observations keep negative columns reported by Chrome.
  • Passive browser source locations keep negative columns from Chrome.

Reviews (2) · Last reviewed commit: "fix(browser): apply the CDP column polic..." · Reviewed by Greptile

@chatgpt-codex-connector

Copy link
Copy Markdown

💡 Codex Review

export const cdpResourceColumnSchema = z.int();

P2 Badge Reuse the column policy in passive CDP capture

When a negative-start inline script emits a request or console frame on its first line, the passive inspect_web_page path still sends that same CDP columnNumber through cdpSourceCoordinates, where the value >= 0 check in src/browser/CdpCaptureEventHelpers.ts:61-72 turns it into null and marks the inventory invalid_protocol_value; discover_web_mcp_tools uses the same helper. This leaves the new shared resource-column representation limited to web-runtime schemas and causes sibling browser workflows to discard the protocol-valid evidence this fix is intended to preserve, so those helper/output schemas should use the owning policy too.

AGENTS.md reference: AGENTS.md:L29-L29

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

inspect_web_page and discover_webmcp_tools still read CDP columns through
cdpSourceCoordinates, whose own >= 0 check turned a negative column into
null and reported invalid_protocol_value. WebMCP discovery also dropped the
tool's whole registration_source.

cdpResourceColumnSchema now lives with the domain's CDP observation schemas.
Runtime admission, the passive coordinate helper and the runtime, console,
initiator and WebMCP output schemas all use it. Lines keep their
non-negative rule.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@morluto
morluto merged commit 8db538a into morluto:main Nov 3, 2026
47 of 49 checks passed
@morluto morluto added bug Something isn't working area: runtime Process capture and runtime observation labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: runtime Process capture and runtime observation bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] observe-web-execution fails on WordPress 7.1 editor pages because Chrome reports negative script columns

2 participants