Skip to content

fix(artifacts): never treat a directory named *.map as a source map - #4131

Merged
kaoru0822-kitauji merged 1 commit into
mainfrom
fix/3909-sourcemap-directory-edge
Oct 15, 2026
Merged

kaoru0822-kitauji merged 1 commit into
mainfrom
fix/3909-sourcemap-directory-edge

Conversation

@kaoru0822-kitauji

Copy link
Copy Markdown
Collaborator

Summary

Fixes #3909. Artifact inventory gave an archive directory named like a source map, such as main.js.map/, a maps-source edge whose parent was the sibling main.js. The same occurrence was correctly classified as a directory container. Edges now use the occurrence's own classification, so the directory is contained by its archive. Real source-map files keep maps-source.

Problem and expected behavior

createArtifactEdges (src/artifacts/inventory/ArtifactGraphConstruction.ts) decided "source map" from logical_path.endsWith(".map"), and relationFor repeated the same suffix rule. Both ignored the producer's parsed fact. createOccurrence classifies a directory entry as artifact_kind: "container" (or framework) with artifact_format: "directory". Only regular files are path-classified as source-map.

Reproduced with the issue's ZIP (main.js plus the empty directory main.js.map/) through inspect-artifact --json, together with a real file source-map control:

ZIP main this PR
main.js + directory main.js.map/ directory container/directory, maps-source, parent main.js, 7,963 bytes, 503 ms directory container/directory, contains, parent archive root, 7,960 bytes, 522 ms
main.js + file main.js.map (control) source-map, maps-source, parent main.js, 7,934 bytes unchanged (426–433 ms)

Change and scope

  • isSourceMap is now occurrence.artifact_kind === "source-map", the classification the inventory producer already owns, including after content digestion. Matching sibling lookup, ambiguity and identity limitations are unchanged for real source maps.
  • The relation is chosen once: slice-of; maps-source for a source map with a unique identified target, otherwise contains; embeds or contains for everything else.
  • relationFor no longer handles .map. That duplicate rule is removed.

Contract and boundary impact

  • Semantic owner and earliest changed stage: inventory edge construction now consumes the occurrence classification owned by createOccurrence and the content digest, instead of re-deriving it from the path.

  • Contribution scope fit and linked maintainer decision: a bug fix within the existing static, read-only boundary; not applicable.

  • CLI and MCP/tool-catalog contract: schemas unchanged.

  • Provider, bridge, target-format, or platform compatibility: provider-independent artifact inventory.

  • Evidence, artifact, provenance, or reconstruction contract: no false derivation edge for directories. Directory containment is preserved.

  • Target selection, authority, upstream behavior, and cleanup details: not applicable.

  • Generated metadata, package, or installation impact: none.

  • Read existing files or captured data.

Evidence and regression coverage

  • Tests added or updated: src/artifacts/inventory/ArtifactGraphConstruction.test.ts adds a case with an identified app/main.js file and an identified app/main.js.map directory. It asserts the directory's container/directory classification, a contains edge to its parent, and no limitations. It fails on main and passes with the fix. The existing source-map relationship cases (missing, unread, unique and duplicate targets) still pass.
  • Real data: the shipped @modelcontextprotocol/server dist/ (34 real .js.map files), zipped with /usr/bin/zip and inventoried through the CLI:
build occurrences relations edges digest elapsed output
main 85 contains 50, maps-source 34 f97a72ad743bdb00 500 ms 100,685 bytes
this PR 85 contains 50, maps-source 34 f97a72ad743bdb00 500–576 ms 100,685 bytes

Real source maps and the full edge set are byte-identical, and timing is unchanged.

  • Remaining proof gaps: none known.

Validation performed

  • npx vitest run src/artifacts/inventory/ArtifactGraphConstruction.test.ts — 25 passed; against main, 1 failed as expected.
  • npx vitest run src/artifacts tests/boundary/filesystem/artifactComparison.test.ts tests/boundary/filesystem/artifactDirectoryIdentity.test.ts tests/boundary/mcp/artifactMcp.test.ts tests/boundary/providers/native/artifactProvider.archiveInventory.test.ts src/domain/artifactInventoryEvidence.test.ts — 21 files, 204 passed.
  • npm run check:fast — passed.
  • CLI runs on the issue's ZIP, the file control and the real package archive, as tabulated.

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: static inventory only.

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.

🤖 Generated with Claude Code

Artifact inventory decided source-map edges from the `.map` path suffix,
so an archive directory such as `main.js.map/` received a maps-source
edge whose parent was the sibling `main.js`, although the same
occurrence was classified as a directory container. Edge construction
now uses the occurrence's own artifact_kind, and the duplicate suffix
rule in relationFor is removed; such directories are contained by their
parent, and real source-map files keep maps-source.

Fixes #3909

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kaoru0822-kitauji kaoru0822-kitauji added the track:perf Performance track PRs (issues & perf loop) label Oct 15, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 15, 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-10-15T13:43:42.285634Z 0ae520a 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 Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; it fixes directory containment without breaking ordinary source-map links.

Summary

The PR fixes false source-map relationships for directories named *.map by using the occurrence’s existing classification.

  • Directories named .map stay inside their archive.

Reviews (1) · Last reviewed commit: "fix(artifacts): never treat a directory ..." · Reviewed by Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

track:perf Performance track PRs (issues & perf loop)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] inventory assigns source-map relationships to directory entries

1 participant