Skip to content

refactor(source-maps): report decoder failures through ParseFailure - #10690

Merged
morluto merged 1 commit into
mainfrom
refactor/source-map-parse-failure
Nov 15, 2026
Merged

morluto merged 1 commit into
mainfrom
refactor/source-map-parse-failure

Conversation

@morluto

@morluto morluto commented Nov 15, 2026

Copy link
Copy Markdown
Owner

Summary

Source-map decoding reports failures through the shared ParseFailure algebra (format source-map). SourceMapFormatFailure and its format | unsupported | limit | section-overlap reasons are deleted.

  • limit failures carry the selected allowance as limit: { name, maximum } (for example decoded_records, output_bytes), built by one helper, sourceMapLimitFailure, that also appends the existing recovery text.
  • A section-boundary overlap is a malformed failure on the section-boundary field; isSourceMapSectionOverlap is its one reader.
  • parser-format-failure-class loses src/javascript/sourceMaps/SourceMapFormat.ts.

Part of plan W7 (parser kernel). Sibling of #10664, #10665 and #10667.

Problem and expected behavior

SourceMapFormatFailure restated the ParseFailure algebra with its own spellings and folded a malformed sub-case (section-overlap) into the kind, so the codec process had to special-case it back to format. Limit failures carried the allowance only inside message text.

Expected: one algebra; the allowance name and maximum are typed facts; consumers classify through named predicates (isSourceMapFailure, isSourceMapLimit, isSourceMapSectionOverlap) instead of instanceof plus string reasons.

Change and scope

  • src/javascript/sourceMaps/SourceMapFormat.ts: SOURCE_MAP_FORMAT, the predicates above, sourceMapSectionOverlap, sourceMapLimitFailure; every throw site uses malformedInput / unsupportedInput / the helpers.
  • DecodedSourceMap.ts, TraceSourceMap.ts, SourceMapCodecProcess.ts, src/browser/WebSourceMapFetcher.ts: throw and classify through those helpers.
  • SourceMapCodecProcess.ts still writes the same codec reply (reason: "format" | "unsupported" | "limit"); it now derives it from the ParseFailure kind.

Not included: the codec reply wire schema (SourceMapCodecProtocol.ts) and SourceMapReply.ts's public mapping, which are unchanged; no CDP internals are touched.

Contract and boundary impact

  • Semantic owner and earliest changed stage: the source-map decoder produces the failure; SourceMapReply.ts and WebSourceMapFetcher.ts remain the public translations.
  • Contribution scope fit and linked maintainer decision: internal refactor within plan W7.
  • CLI and MCP/tool-catalog contract: unchanged. Public errors, messages and recovery text are the same.
  • Provider, bridge, target-format, or platform compatibility: none.
  • Evidence, artifact, provenance, or reconstruction contract: none.
  • Target selection, authority, upstream behavior, and cleanup details: unchanged.
  • Generated metadata, package, or installation impact: none.

Evidence and regression coverage

  • Tests updated: TraceSourceMap.test.ts (unsupported/malformed kinds, section-overlap through isSourceMapSectionOverlap) and SourceMapAdmission.test.ts (the decoded_records limit asserts limit: { name: "decoded_records", maximum: 4 }).
  • Public behavior: the boundary tests that assert public errors (tests/boundary/javascript/sourceMapDecoder.test.ts, tests/boundary/filesystem/webSourceLocationArtifacts.test.ts, tests/boundary/browser/webSourceMap*.test.ts) pass unchanged.
  • Remaining proof gaps: none known.

Validation performed

  • npm run test:focused -- src/browser/WebSourceMapFetcher.test.ts src/javascript/sourceMaps/SourceMapAdmission.test.ts src/javascript/sourceMaps/SourceMapCommand.test.ts src/javascript/sourceMaps/SourceMapDecoder.test.ts src/javascript/sourceMaps/TraceSourceMap.test.ts tests/boundary/browser/webSourceMapFetcher.test.ts tests/boundary/browser/webSourceMapNestedCoordinates.test.ts tests/boundary/browser/webSourceMapResponseCleanup.test.ts tests/boundary/javascript/sourceMapDecoder.test.ts tests/boundary/filesystem/webSourceLocationArtifacts.test.ts src/artifacts/ReleaseExposureReader.test.ts: the first run found 6 unit assertions still on the old reason field; after updating them, npm run test:focused -- src/javascript/sourceMaps/SourceMapAdmission.test.ts src/javascript/sourceMaps/TraceSourceMap.test.ts passed (38 tests); the other 9 files passed in the first run.
  • node scripts/verify/architecture-guards.mjs --shrink-baselines: passed and lowered the baseline.
  • npm run check:fast: typecheck and lint passed.

Compatibility, safety, and release

  • Breaking changes or migration steps: none. SourceMapFormatFailure was internal.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: no change.

Author readiness

Human owner:

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

SourceMapFormatFailure and its format/unsupported/limit/section-overlap reasons are replaced by ParseFailureError with format source-map. Limits carry the selected allowance name and maximum; a section-boundary overlap is a malformed failure on the section-boundary field. The codec reply protocol and every public error are unchanged.
@chatgpt-codex-connector

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

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-15T00:26:32.076959Z 4422860 PR opened
ℹ️ 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 15, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge; no actionable issue was found.

Summary

Replaces SourceMapFormatFailure with the shared ParseFailureError.

  • Source-map decoding reports failures through shared parse-failure types.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Source-map checks] --> B[ParseFailureError]
  B --> C[Codec reply mapping]
  C --> D[Unchanged public errors]
  B --> E[Browser predicates]
  E --> F[Limit or invalid map result]
Loading

Reviews (1) · Last reviewed commit: "refactor(source-maps): report decoder fa..." · Reviewed by Greptile

@morluto
morluto merged commit 133e776 into main Nov 15, 2026
52 checks passed
@morluto
morluto deleted the refactor/source-map-parse-failure branch November 15, 2026 01:37
@morluto morluto added the area: evidence Evidence, artifacts, and reconstruction label Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: evidence Evidence, artifacts, and reconstruction

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant