[PR #4032] [MERGED] fix(browser): preserve source-map media types #6004

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

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/4032
Author: @eco-null
Created: 10/15/2026
Status: ✅ Merged
Merged: 10/22/2026
Merged by: @morluto

Base: main ← Head: fix/browser-typescript-source-media


📝 Commits (1)

  • 5b7d896 fix(browser): preserve source-map media types

📊 Changes

3 files changed (+49 additions, -18 deletions)

View changed files

📝 src/browser/WebSourceMapFetcher.ts (+13 -12)
📝 tests/boundary/browser/webSourceMapFetcher.test.ts (+17 -1)
📝 tests/boundary/mcp/browserMcp.test.ts (+19 -5)

📄 Description

Summary

Fixes #3945. Original source-map artifacts now use the resolved URL pathname to choose their media type, matching the parser's existing language selection.

Problem and expected behavior

main.ts?revision=2 was returned as text/javascript, while main.js?filename=main.ts was incorrectly labeled text/typescript. Query strings and fragments must remain part of the source identity without being interpreted as filename extensions.

Change and scope

Reuse the existing URL-path interpretation for both parsing and artifact media types. Compute the media type once per original source and use that same value for serialized-budget accounting and artifact construction. Preserve full source URLs, text, byte lengths, SHA-256 digests and existing source-map limits. No new schema or capability.

Contract and boundary impact

  • Semantic owner and earliest changed stage: WebSourceMapFetcher, original-source artifact normalization.
  • Contribution scope fit and linked maintainer decision: ordinary bug fix within existing passive analysis; additional decision not applicable.
  • CLI and MCP/tool-catalog contract: unchanged schemas/catalog; corrected original_sources[].artifact.media_type values.
  • Provider, bridge, target-format, or platform compatibility: existing source-map workflow; no additional provider or platform requirement.
  • Evidence, artifact, provenance, or reconstruction contract: exact source URLs and text/digests remain preserved; Evidence commitments reflect corrected metadata.
  • Target selection, authority, upstream behavior, and cleanup: existing caller-selected CDP and approved source-map HTTP endpoints only; no browser launch, target-code execution or new effects.
  • Generated metadata, package, or installation impact: none.

Expected effects of the existing workflow:

  • 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

Executed on Windows x64, Node 24.18.0/npm 11.16.0, base 6688ed6db7f4f0765851fd2e649c8273059334a2:

  • Before the production change, 10 new HTTP-boundary cases failed: four TypeScript extensions with a query, the same four with a fragment, and two JavaScript controls whose query/fragment ends in .ts. The expanded MCP regression also failed; 86 other tests passed.
  • After the fix, 127 tests in six files pass, including the compiled CLI and SDK MCP source-map workflow with a redirect, all four query-bearing TypeScript extensions, a fragment, ordinary-name controls and an extensionless control.
  • HTTP-boundary checks preserve complete URLs, text, bytes and SHA-256. Adjacent tests cover malformed maps, cancellation, cleanup, redirects, nested coordinates, HTTP status and representation budgets.

Validation performed

  • npm run test:focused -- tests/boundary/browser/webSourceMapFetcher.test.ts tests/boundary/mcp/browserMcp.test.ts src/browser/WebSourceMapFetcher.test.ts tests/boundary/browser/webSourceMapResponseCleanup.test.ts tests/boundary/browser/webSourceMapNestedCoordinates.test.ts tests/boundary/browser/webSourceMapHttpStatus.test.ts — 127 passed.
  • npm run check — passed typecheck, lint, formatting, knip, metadata and architecture guards (lint: 0 errors, 1,455 warnings).
  • npm run check:fast — passed through pre-push hook.
  • npm run verify:test-discovery — all 1,326 test files discovered exactly once.
  • git diff --check — passed.

Upstream CI run 38705652933 completed successfully for head 5b7d89669d088ad4281d02c3959ee753b817f5b1, including all five test shards, static/source checks, package build, bundled Windows controls, Linux native package baseline, Portable tests, the real-browser job and CI required. Skipped conditional jobs do not establish coverage.

The source review reported no blocking source finding and independently ran 122 fixture tests; it held approval pending the title gate. That gate now passed for unchanged head 5b7d89669d088ad4281d02c3959ee753b817f5b1: PR title run 39015750944 completed successfully on 2026-10-18 at 23:09:43 UTC. Both Conventional PR title and CI required are successful; the prior review remains COMMENTED, not approval.

Compatibility, safety, and release

No breaking schema, package or migration changes. The original local Windows proof used owned loopback HTTP/WebSocket CDP fixtures and SDK in-memory MCP transport; it did not rerun local stdio MCP, a real installed browser, macOS/Linux, the full local suite or performance/token measurements. Subsequent upstream CI coverage is recorded above. This change adds no target-code execution.

Author readiness

Human owner: @eco-null

AI-assisted contribution. Human owner @eco-null has completed the three initial-readiness declarations below; they are preserved.

  • 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 (documented TypeScript labeling is restored; schemas/catalog unchanged).
  • User-visible CLI/MCP changes include representative output.
  • AI-assisted technical review checked the final diff for secrets, unrelated cleanup and unsupported claims; the human owner's initial-readiness declarations are recorded above.

🔄 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/4032 **Author:** [@eco-null](https://github.com/eco-null) **Created:** 10/15/2026 **Status:** ✅ Merged **Merged:** 10/22/2026 **Merged by:** [@morluto](https://github.com/morluto) **Base:** `main` ← **Head:** `fix/browser-typescript-source-media` --- ### 📝 Commits (1) - [`5b7d896`](https://github.com/morluto/rea/commit/5b7d89669d088ad4281d02c3959ee753b817f5b1) fix(browser): preserve source-map media types ### 📊 Changes **3 files changed** (+49 additions, -18 deletions) <details> <summary>View changed files</summary> 📝 `src/browser/WebSourceMapFetcher.ts` (+13 -12) 📝 `tests/boundary/browser/webSourceMapFetcher.test.ts` (+17 -1) 📝 `tests/boundary/mcp/browserMcp.test.ts` (+19 -5) </details> ### 📄 Description ## Summary Fixes #3945. Original source-map artifacts now use the resolved URL pathname to choose their media type, matching the parser's existing language selection. ## Problem and expected behavior `main.ts?revision=2` was returned as `text/javascript`, while `main.js?filename=main.ts` was incorrectly labeled `text/typescript`. Query strings and fragments must remain part of the source identity without being interpreted as filename extensions. ## Change and scope Reuse the existing URL-path interpretation for both parsing and artifact media types. Compute the media type once per original source and use that same value for serialized-budget accounting and artifact construction. Preserve full source URLs, text, byte lengths, SHA-256 digests and existing source-map limits. No new schema or capability. ## Contract and boundary impact - Semantic owner and earliest changed stage: `WebSourceMapFetcher`, original-source artifact normalization. - Contribution scope fit and linked maintainer decision: ordinary bug fix within existing passive analysis; additional decision not applicable. - CLI and MCP/tool-catalog contract: unchanged schemas/catalog; corrected `original_sources[].artifact.media_type` values. - Provider, bridge, target-format, or platform compatibility: existing source-map workflow; no additional provider or platform requirement. - Evidence, artifact, provenance, or reconstruction contract: exact source URLs and text/digests remain preserved; Evidence commitments reflect corrected metadata. - Target selection, authority, upstream behavior, and cleanup: existing caller-selected CDP and approved source-map HTTP endpoints only; no browser launch, target-code execution or new effects. - Generated metadata, package, or installation impact: none. Expected effects of the existing workflow: - [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. - [x] 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 Executed on Windows x64, Node 24.18.0/npm 11.16.0, base `6688ed6db7f4f0765851fd2e649c8273059334a2`: - Before the production change, 10 new HTTP-boundary cases failed: four TypeScript extensions with a query, the same four with a fragment, and two JavaScript controls whose query/fragment ends in `.ts`. The expanded MCP regression also failed; 86 other tests passed. - After the fix, 127 tests in six files pass, including the compiled CLI and SDK MCP source-map workflow with a redirect, all four query-bearing TypeScript extensions, a fragment, ordinary-name controls and an extensionless control. - HTTP-boundary checks preserve complete URLs, text, bytes and SHA-256. Adjacent tests cover malformed maps, cancellation, cleanup, redirects, nested coordinates, HTTP status and representation budgets. ## Validation performed - `npm run test:focused -- tests/boundary/browser/webSourceMapFetcher.test.ts tests/boundary/mcp/browserMcp.test.ts src/browser/WebSourceMapFetcher.test.ts tests/boundary/browser/webSourceMapResponseCleanup.test.ts tests/boundary/browser/webSourceMapNestedCoordinates.test.ts tests/boundary/browser/webSourceMapHttpStatus.test.ts` — 127 passed. - `npm run check` — passed typecheck, lint, formatting, knip, metadata and architecture guards (lint: 0 errors, 1,455 warnings). - `npm run check:fast` — passed through pre-push hook. - `npm run verify:test-discovery` — all 1,326 test files discovered exactly once. - `git diff --check` — passed. Upstream [CI run 38705652933](https://github.com/morluto/rea/actions/runs/38705652933) completed successfully for head `5b7d89669d088ad4281d02c3959ee753b817f5b1`, including all five test shards, static/source checks, package build, bundled Windows controls, Linux native package baseline, Portable tests, the real-browser job and `CI required`. Skipped conditional jobs do not establish coverage. The source review reported no blocking source finding and independently ran 122 fixture tests; it held approval pending the title gate. That gate now passed for unchanged head `5b7d89669d088ad4281d02c3959ee753b817f5b1`: [PR title run 39015750944](https://github.com/morluto/rea/actions/runs/39015750944) completed successfully on 2026-10-18 at 23:09:43 UTC. Both `Conventional PR title` and `CI required` are successful; the prior review remains COMMENTED, not approval. ## Compatibility, safety, and release No breaking schema, package or migration changes. The original local Windows proof used owned loopback HTTP/WebSocket CDP fixtures and SDK in-memory MCP transport; it did not rerun local stdio MCP, a real installed browser, macOS/Linux, the full local suite or performance/token measurements. Subsequent upstream CI coverage is recorded above. This change adds no target-code execution. ## Author readiness Human owner: @eco-null AI-assisted contribution. Human owner @eco-null has completed the three initial-readiness declarations below; they are preserved. - [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 - [x] This PR addresses a concrete problem or an agreed enhancement. - [x] Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff. - [x] The PR has one focused outcome and the title follows `type(scope): outcome`. - [x] Related issue is linked, or the reason for not linking one is stated above. - [x] Tests cover changed observable behavior and meaningful failure paths. - [x] Owning docs, contracts, and generated metadata are updated where needed (documented TypeScript labeling is restored; schemas/catalog unchanged). - [x] User-visible CLI/MCP changes include representative output. - [x] AI-assisted technical review checked the final diff for secrets, unrelated cleanup and unsupported claims; the human owner's initial-readiness declarations are recorded above. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 01:11:06 +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#6004
No description provided.