Skip to content

fix(artifacts): never count occurrences on an unknown duplicate path as unchanged - #4100

Merged
kaoru0822-kitauji merged 1 commit into
mainfrom
fix/3956-duplicate-path-unchanged-count
Oct 15, 2026
Merged

kaoru0822-kitauji merged 1 commit into
mainfrom
fix/3956-duplicate-path-unchanged-count

Conversation

@kaoru0822-kitauji

Copy link
Copy Markdown
Collaborator

Summary

Fixes #3956. Artifact comparison over-reported summary.unchanged when an inventory contained duplicate logical paths. One unknown change row stands for every occurrence on a duplicate path, but the summary subtracted only one per row. The remaining duplicate occurrences were reported as affirmatively unchanged. Now only occurrences on paths with no left-side change count as unchanged.

Problem and expected behavior

summarize (src/domain/artifactComparison.ts) computed unchanged as left occurrence count − removed − changed − contradiction − unknown, counting change rows. Change rows are keyed by logical_path, and duplicate paths cannot be paired, so they produce a single unknown row with null occurrence IDs.

I reproduced this with the issue's script: a CLI inventory of a ZIP whose central directory repeats x.txt, compared with itself over stdio MCP:

inventory main this PR
., neighbor.txt, x.txt, x.txt (duplicate) unchanged: 3, unknown: 1 unchanged: 2, unknown: 1
., neighbor.txt, x.txt, y.txt (control) unchanged: 4, unknown: 0 unchanged

Only . and neighbor.txt are affirmatively unchanged, as the issue expects. summary.unknown keeps its existing per-path aggregation; the issue does not require a policy change there.

Change and scope

  • summarize now counts left occurrences whose logical_path has no change row other than added (added rows have no left occurrence).
  • For inventories without duplicate paths the result is the same as before, because each non-added row then matches exactly one left occurrence.
  • The old Math.max(0, …) clamp is gone: the new count cannot go negative.

Contract and boundary impact

  • Semantic owner and earliest changed stage: the comparison summary, in summarize.

  • Contribution scope fit and linked maintainer decision: a bug fix within existing behavior; not applicable.

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

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

  • Evidence, artifact, provenance, or reconstruction contract: unchanged no longer counts occurrences whose pairing is unknown.

  • 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: tests/boundary/filesystem/artifactComparison.test.ts, in the existing duplicate-ZIP pages test, now asserts exact summaries.
    • Differing archives: the root changes too, so unchanged: 1, unknown: 1.
    • The issue's case, the duplicate inventory compared with itself: unchanged: 2, unknown: 1.
    • The test fails on main (unchanged: 2 where 1 is expected) and passes with the fix.
  • Real data, built CLI inventory plus stdio MCP compare_artifacts, main vs this PR:
comparison occurrences main this PR
KeepingYouAwake.app vs itself 410 / 410 unchanged 404, unknown 6, 47 ms, 9,041-byte reply identical, 50 ms, 9,041 bytes
KeepingYouAwake.app vs XLD.app 410 / 625 unchanged 1, added 616, removed 401, changed 8, 68 ms, 1,118,237 bytes identical, 68 ms, 1,118,237 bytes

The summaries agree on real bundles without duplicate paths, and timing is unchanged. The new count is a single pass over the left occurrences.

  • Remaining proof gaps: no real third-party archive with duplicate central-directory names was available, so the duplicate case is covered by the issue's crafted ZIP and the test fixture.

Validation performed

  • npx vitest run tests/boundary/filesystem/artifactComparison.test.ts tests/boundary/filesystem/artifactComparisonSummary.test.ts tests/boundary/filesystem/artifactDirectoryIdentity.test.ts tests/boundary/mcp/artifactMcp.test.ts src/application/artifacts src/domain/reconstructionVerification.test.ts src/domain/analysisView src/domain/artifactInventoryEvidence.test.ts src/artifacts/inventory — 16 files, 216 passed.
  • The extended duplicate test against main: 1 failed, as expected.
  • npm run check:fast — passed.
  • The issue's MCP repro and the real-bundle comparisons above.

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: macOS app bundle inventories.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: pure summary computation.

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

…as unchanged

Artifact comparison subtracted change rows from the left occurrence
count to derive summary.unchanged. A duplicate logical path produces one
unknown row that stands for every occurrence on that path, so the extra
occurrences were reported as affirmatively unchanged. The summary now
counts only left occurrences on paths without a left-side change row.

Fixes #3956

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@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-15T12:16:53.252140Z d953d1f 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; no actionable issues were found.

Summary

Fixes summary.unchanged by excluding every left occurrence on a path with a non-added change.

  • Duplicate artifact entries no longer count as unchanged.

Reviews (1) · Last reviewed commit: "fix(artifacts): never count occurrences ..." · Reviewed by Greptile

@kaoru0822-kitauji
kaoru0822-kitauji merged commit d929543 into main Oct 15, 2026
33 checks passed
@kaoru0822-kitauji
kaoru0822-kitauji deleted the fix/3956-duplicate-path-unchanged-count branch October 15, 2026 13:11
@morluto morluto added area: evidence Evidence, artifacts, and reconstruction bug Something isn't working labels Nov 23, 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 bug Something isn't working track:perf Performance track PRs (issues & perf loop)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Duplicate ZIP paths inflate the unchanged artifact comparison count

2 participants