[PR #5663] [CLOSED] fix(browser): retain null console timestamp on invalid protocol value #7020

Closed
opened 2026-11-01 21:44:46 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/5663
Author: @Priyanshu-choudhary
Created: 10/20/2026
Status: ❌ Closed

Base: main ← Head: fix/issue-5656-console-timestamp


📝 Commits (1)

  • 8df74c6 fix(browser): retain null console timestamp on invalid protocol value

📊 Changes

4 files changed (+179 additions, -2 deletions)

View changed files

📝 src/browser/CdpCaptureEventHandlers.ts (+5 -1)
➕ src/browser/CdpCaptureEvents.console.test.ts (+172 -0)
📝 src/domain/browserObservationSchemas.ts (+1 -1)
📝 tests/boundary/browser/cdpBrowserProvider.sensitive_data.test.ts (+1 -0)

📄 Description

Summary

Fixes #5656

The inspect-web-page capture owner previously normalized Runtime.consoleAPICalled events with an absent or non-finite timestamp to timestamp: 0 without recording an exclusion in the console completeness ledger, fabricating an epoch time. This change preserves valid finite timestamps exactly, normalizes missing or non-finite timestamps to null, and records an invalid_protocol_value exclusion for console_events.

Problem and expected behavior

When Runtime.consoleAPICalled events were ingested with an absent or non-finite timestamp, handleConsoleAPICalled evaluated numberValue(params.timestamp) ?? 0 and the schema required z.number(). A real producer value of 0 produced the same Evidence, preventing consumers from distinguishing missing timestamps from an observed epoch time.

Expected behavior:

  • Preserve valid finite producer values exactly (including zero and negative values).
  • When timestamp is absent or non-finite (e.g. NaN, Infinity, strings, null), retain the console event with timestamp: null and record console_events as incomplete with an invalid_protocol_value exclusion.
  • Represent nullable timestamp in the owning browserConsoleEventSchema.

Change and scope

  • In src/domain/browserObservationSchemas.ts, update browserConsoleEventSchema's timestamp from z.number() to z.number().nullable().
  • In src/browser/CdpCaptureEventHandlers.ts (handleConsoleAPICalled), extract timestamp = numberValue(params.timestamp). If timestamp === undefined, call state.completeness.exclude("console_events", "invalid_protocol_value"). Store timestamp: timestamp ?? null on the console event.
  • In src/browser/CdpCaptureEvents.console.test.ts, add unit tests covering valid finite timestamps (positive, 0, negative), missing/non-finite timestamps (NaN, Infinity, string), and schema validation.
  • In tests/boundary/browser/cdpBrowserProvider.sensitive_data.test.ts, verify the preserved timestamp value across the boundary.

Contribution scope: Not applicable (bug fix within existing capture boundaries).

Contract and boundary impact

  • Semantic owner and earliest changed stage: inspect-web-page CDP event ingestion handler (handleConsoleAPICalled) and browserConsoleEventSchema
  • Contribution scope fit and linked maintainer decision: Not applicable
  • CLI and MCP/tool-catalog contract: browserConsoleEventSchema.timestamp is now nullable (number | null)
  • Provider, bridge, target-format, or platform compatibility: None
  • Evidence, artifact, provenance, or reconstruction contract: Retains null timestamp when unknown rather than synthesizing epoch zero; marks console_events section incomplete with invalid_protocol_value
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): None
  • Generated metadata impact: None

Expected effects:

  • 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:
    • src/browser/CdpCaptureEvents.console.test.ts
    • tests/boundary/browser/cdpBrowserProvider.sensitive_data.test.ts
  • Base reproduction or other evidence:
    • Ingesting Runtime.consoleAPICalled without a timestamp or with timestamp: NaN previously produced timestamp: 0 with an empty exclusion list. With this change, timestamp: null is produced and invalid_protocol_value is recorded under console_events exclusions and unavailable_sections.
  • User-visible CLI/MCP output (if applicable): console.events[].timestamp is null when missing/invalid in CDP events.
  • Remaining proof gaps: None for capture handler and schema logic.

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 check:fast — passed (typecheck and lint)
  • npm run format:check — passed
  • npm run docs:check — passed
  • npm run verify:test-discovery — passed (all 1839 test files discovered)
  • npx vitest run src/browser/CdpCaptureEvents.console.test.ts src/browser/CdpCaptureEvents.redirectBodyShape.test.ts src/browser/CdpCaptureCompleteness.test.ts tests/boundary/browser/cdpBrowserProvider.sensitive_data.test.ts — passed (13 tests in 4 files)

Compatibility, safety, and release

  • Breaking changes or migration steps: None (widening timestamp from number to number | null in event schema)
  • Real Hopper/Ghidra, browser, or OS coverage: Source and boundary unit tests with fake CDP wire fixture
  • Package or release metadata impact: None
  • Security, privacy, process, or containment review: None

Author readiness

  • I have reviewed the complete diff and understand the changes.
  • I have provided accurate evidence of verification and noted meaningful gaps.
  • I declare this PR is ready for maintainer review.

🔄 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/5663 **Author:** [@Priyanshu-choudhary](https://github.com/Priyanshu-choudhary) **Created:** 10/20/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/issue-5656-console-timestamp` --- ### 📝 Commits (1) - [`8df74c6`](https://github.com/morluto/rea/commit/8df74c64d60417b4c3c5143983f008cefe8c14e0) fix(browser): retain null console timestamp on invalid protocol value ### 📊 Changes **4 files changed** (+179 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `src/browser/CdpCaptureEventHandlers.ts` (+5 -1) ➕ `src/browser/CdpCaptureEvents.console.test.ts` (+172 -0) 📝 `src/domain/browserObservationSchemas.ts` (+1 -1) 📝 `tests/boundary/browser/cdpBrowserProvider.sensitive_data.test.ts` (+1 -0) </details> ### 📄 Description ## Summary Fixes #5656 The `inspect-web-page` capture owner previously normalized `Runtime.consoleAPICalled` events with an absent or non-finite timestamp to `timestamp: 0` without recording an exclusion in the console completeness ledger, fabricating an epoch time. This change preserves valid finite timestamps exactly, normalizes missing or non-finite timestamps to `null`, and records an `invalid_protocol_value` exclusion for `console_events`. ## Problem and expected behavior When `Runtime.consoleAPICalled` events were ingested with an absent or non-finite `timestamp`, `handleConsoleAPICalled` evaluated `numberValue(params.timestamp) ?? 0` and the schema required `z.number()`. A real producer value of `0` produced the same Evidence, preventing consumers from distinguishing missing timestamps from an observed epoch time. Expected behavior: - Preserve valid finite producer values exactly (including zero and negative values). - When timestamp is absent or non-finite (e.g. `NaN`, `Infinity`, strings, `null`), retain the console event with `timestamp: null` and record `console_events` as incomplete with an `invalid_protocol_value` exclusion. - Represent nullable timestamp in the owning `browserConsoleEventSchema`. ## Change and scope - In `src/domain/browserObservationSchemas.ts`, update `browserConsoleEventSchema`'s `timestamp` from `z.number()` to `z.number().nullable()`. - In `src/browser/CdpCaptureEventHandlers.ts` (`handleConsoleAPICalled`), extract `timestamp = numberValue(params.timestamp)`. If `timestamp === undefined`, call `state.completeness.exclude("console_events", "invalid_protocol_value")`. Store `timestamp: timestamp ?? null` on the console event. - In `src/browser/CdpCaptureEvents.console.test.ts`, add unit tests covering valid finite timestamps (positive, 0, negative), missing/non-finite timestamps (`NaN`, `Infinity`, string), and schema validation. - In `tests/boundary/browser/cdpBrowserProvider.sensitive_data.test.ts`, verify the preserved timestamp value across the boundary. Contribution scope: Not applicable (bug fix within existing capture boundaries). ## Contract and boundary impact - Semantic owner and earliest changed stage: `inspect-web-page` CDP event ingestion handler (`handleConsoleAPICalled`) and `browserConsoleEventSchema` - Contribution scope fit and linked maintainer decision: Not applicable - CLI and MCP/tool-catalog contract: `browserConsoleEventSchema.timestamp` is now nullable (`number | null`) - Provider, bridge, target-format, or platform compatibility: None - Evidence, artifact, provenance, or reconstruction contract: Retains `null` timestamp when unknown rather than synthesizing epoch zero; marks `console_events` section incomplete with `invalid_protocol_value` - Target selection, authority, upstream behavior, and cleanup details (if applicable): None - Generated metadata impact: None Expected effects: - [x] 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: - `src/browser/CdpCaptureEvents.console.test.ts` - `tests/boundary/browser/cdpBrowserProvider.sensitive_data.test.ts` - Base reproduction or other evidence: - Ingesting `Runtime.consoleAPICalled` without a `timestamp` or with `timestamp: NaN` previously produced `timestamp: 0` with an empty exclusion list. With this change, `timestamp: null` is produced and `invalid_protocol_value` is recorded under `console_events` exclusions and `unavailable_sections`. - User-visible CLI/MCP output (if applicable): `console.events[].timestamp` is `null` when missing/invalid in CDP events. - Remaining proof gaps: None for capture handler and schema logic. 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 check:fast` — passed (typecheck and lint) - `npm run format:check` — passed - `npm run docs:check` — passed - `npm run verify:test-discovery` — passed (all 1839 test files discovered) - `npx vitest run src/browser/CdpCaptureEvents.console.test.ts src/browser/CdpCaptureEvents.redirectBodyShape.test.ts src/browser/CdpCaptureCompleteness.test.ts tests/boundary/browser/cdpBrowserProvider.sensitive_data.test.ts` — passed (13 tests in 4 files) ## Compatibility, safety, and release - Breaking changes or migration steps: None (widening timestamp from number to number | null in event schema) - Real Hopper/Ghidra, browser, or OS coverage: Source and boundary unit tests with fake CDP wire fixture - Package or release metadata impact: None - Security, privacy, process, or containment review: None ## Author readiness - [ ] I have reviewed the complete diff and understand the changes. - [ ] I have provided accurate evidence of verification and noted meaningful gaps. - [ ] I declare this PR is ready for maintainer review. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-01 21:44:46 +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#7020
No description provided.