[PR #578] [MERGED] fix(artifacts): resolve parents after archive enumeration #2079

Closed
opened 2026-10-16 21:14:00 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/578
Author: @kaoru0822-kitauji
Created: 10/5/2026
Status: ✅ Merged
Merged: 10/5/2026
Merged by: @morluto

Base: main ← Head: fix/artifact-parent-entry-order


📝 Commits (1)

  • 25d83af fix(artifacts): resolve parents after archive enumeration

📊 Changes

4 files changed (+268 additions, -6 deletions)

View changed files

📝 src/application/ArtifactInventory/scanReader.ts (+7 -6)
➕ tests/boundary/filesystem/artifactInventoryEntryOrder.test.ts (+136 -0)
➕ tests/boundary/mcp/artifactEntryOrderMcp.test.ts (+67 -0)
➕ tests/fixtures/artifactEntryOrder.ts (+58 -0)

📄 Description

Summary

Resolve artifact containment after reader enumeration so ZIP members can precede their directory entries without corrupting parent relationships or virtual-directory identities.

No tracking issue: found with a valid three-entry ZIP during boundary testing; no matching open issue or PR was found.

Problem and expected behavior

A ZIP ordered pkg/sub/data.txt, pkg/sub/, pkg/ previously attached all three occurrences to the archive root. Both nonempty directories received the empty-directory identity, and inspect-artifact exposed incorrect contains relationships while reporting complete substep coverage.

Archive member order must not determine the nearest represented directory parent. With the fix, the same bytes produce root → pkg → pkg/sub → data.txt.

Change and scope

Resolve occurrence parents against the complete path index after enumeration, before virtual-directory materialization. Per-entry path registration, hashing, safety limits, archive validation, and reader cleanup remain in place.

Missing directory entries are not synthesized. The existing nearest-directory policy and nested-ASAR containment semantics are unchanged. Separate implicit-path identity behavior is outside this fix.

Contract and boundary impact

  • Semantic owner and earliest changed stage: application artifact inventory, after reader enumeration and before directory identities/edges are constructed.
  • CLI and MCP/tool-catalog contract: existing shapes and tools; corrected parent IDs and derived containment relationships.
  • Provider, bridge, target-format, or platform compatibility: real ZIP, filesystem directory, and ASAR fixtures exercised on Linux; no provider protocol changes.
  • Evidence, artifact, provenance, or reconstruction contract: affected directory identities now incorporate their actual represented children; observed entry paths, content digests, and source locations remain intact.
  • Process execution, authorization, cleanup, or containment impact: no new execution or authority; path-validation and archive-safety regressions retained.
  • Generated metadata, package, or installation impact: none; generated-document checks pass.

Evidence and regression coverage

  • Six permutations of parent/subdirectory/file entries, with an explicit empty-directory control.
  • Stable directory identities, sorted occurrence paths, containment edges, and repeat-inventory equality.
  • Implicit-directory cases retain the nearest existing directory or root without synthesizing entries.
  • Duplicate file/directory paths in both orders, case-fold collisions, prefix conflicts, and traversal rejection.
  • Filesystem-directory and real-ASAR compatibility controls; MCP boundary regression.
  • On unchanged main bb91abd, the two new regression files produce 8 failures and 8 passing controls. The focused fixed matrix including existing archive safety and ASAR freshness tests passes 25/25.
  • Executed the built CLI and a real stdio MCP client against the child-first ZIP: both return the corrected parent chain. Independent review found no blocking issues, including supplemental cancellation, limits, encrypted-member, symlink, and collision probes.

Evidence review:

  • 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

  • Rebased and tested on current main bb91abd, including #575 and #576.
  • npm run check:pr: static checks passed; 1,855 tests passed, 1 skipped, 40 failed in seven native bridge/lease suites because this sandbox denies Unix-domain socket listening (EPERM). The same seven suites on unchanged bb91abd reproduce 40 failures / 22 passes. This is not a full local test-suite pass.
  • npm run docs:check: passed separately because the full-test failure short-circuits this step in check:pr.
  • npm run check:ci: passed.
  • npm_config_cache=/tmp/rea-npm-cache npm run verify:package: passed, including packaged CLI/MCP checks; cache override was needed for this environment.
  • npm pack --dry-run --cache /tmp/rea-npm-cache: passed.
  • Real CLI inspect-artifact <child-first.zip> --format json and stdio MCP open_binary + inspect_artifact: passed.
  • git diff --check: passed.

Compatibility, safety, and release

  • No schema changes or migration steps. Corrected containment and virtual-directory IDs are intentional for previously misparented entries.
  • Real Hopper/Ghidra and native Windows/macOS execution were not run locally; no such support claim is made.
  • Package/release metadata unchanged.
  • No archive extraction, path-validation relaxation, dependency changes, or unrelated cleanup.

Review checklist

  • One focused outcome with a Conventional Commit title.
  • Reason for no linked issue stated.
  • Regression and meaningful failure-path coverage included.
  • Existing docs/contracts remain accurate; generated metadata checks pass.
  • Representative CLI/MCP behavior executed.
  • Final diff checked for secrets, unrelated changes, and unsupported claims.

🔄 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/578 **Author:** [@kaoru0822-kitauji](https://github.com/kaoru0822-kitauji) **Created:** 10/5/2026 **Status:** ✅ Merged **Merged:** 10/5/2026 **Merged by:** [@morluto](https://github.com/morluto) **Base:** `main` ← **Head:** `fix/artifact-parent-entry-order` --- ### 📝 Commits (1) - [`25d83af`](https://github.com/morluto/rea/commit/25d83afc0a606c8d086eac3088de1f9735030128) fix(artifacts): resolve parents after archive enumeration ### 📊 Changes **4 files changed** (+268 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `src/application/ArtifactInventory/scanReader.ts` (+7 -6) ➕ `tests/boundary/filesystem/artifactInventoryEntryOrder.test.ts` (+136 -0) ➕ `tests/boundary/mcp/artifactEntryOrderMcp.test.ts` (+67 -0) ➕ `tests/fixtures/artifactEntryOrder.ts` (+58 -0) </details> ### 📄 Description ## Summary Resolve artifact containment after reader enumeration so ZIP members can precede their directory entries without corrupting parent relationships or virtual-directory identities. No tracking issue: found with a valid three-entry ZIP during boundary testing; no matching open issue or PR was found. ## Problem and expected behavior A ZIP ordered `pkg/sub/data.txt`, `pkg/sub/`, `pkg/` previously attached all three occurrences to the archive root. Both nonempty directories received the empty-directory identity, and `inspect-artifact` exposed incorrect `contains` relationships while reporting complete substep coverage. Archive member order must not determine the nearest represented directory parent. With the fix, the same bytes produce `root → pkg → pkg/sub → data.txt`. ## Change and scope Resolve occurrence parents against the complete path index after enumeration, before virtual-directory materialization. Per-entry path registration, hashing, safety limits, archive validation, and reader cleanup remain in place. Missing directory entries are not synthesized. The existing nearest-directory policy and nested-ASAR containment semantics are unchanged. Separate implicit-path identity behavior is outside this fix. ## Contract and boundary impact - Semantic owner and earliest changed stage: application artifact inventory, after reader enumeration and before directory identities/edges are constructed. - CLI and MCP/tool-catalog contract: existing shapes and tools; corrected parent IDs and derived containment relationships. - Provider, bridge, target-format, or platform compatibility: real ZIP, filesystem directory, and ASAR fixtures exercised on Linux; no provider protocol changes. - Evidence, artifact, provenance, or reconstruction contract: affected directory identities now incorporate their actual represented children; observed entry paths, content digests, and source locations remain intact. - Process execution, authorization, cleanup, or containment impact: no new execution or authority; path-validation and archive-safety regressions retained. - Generated metadata, package, or installation impact: none; generated-document checks pass. ## Evidence and regression coverage - Six permutations of parent/subdirectory/file entries, with an explicit empty-directory control. - Stable directory identities, sorted occurrence paths, containment edges, and repeat-inventory equality. - Implicit-directory cases retain the nearest existing directory or root without synthesizing entries. - Duplicate file/directory paths in both orders, case-fold collisions, prefix conflicts, and traversal rejection. - Filesystem-directory and real-ASAR compatibility controls; MCP boundary regression. - On unchanged main `bb91abd`, the two new regression files produce **8 failures and 8 passing controls**. The focused fixed matrix including existing archive safety and ASAR freshness tests passes **25/25**. - Executed the built CLI and a real stdio MCP client against the child-first ZIP: both return the corrected parent chain. Independent review found no blocking issues, including supplemental cancellation, limits, encrypted-member, symlink, and collision probes. Evidence review: - [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 - Rebased and tested on current main `bb91abd`, including #575 and #576. - `npm run check:pr`: static checks passed; **1,855 tests passed, 1 skipped, 40 failed in seven native bridge/lease suites** because this sandbox denies Unix-domain socket listening (`EPERM`). The same seven suites on unchanged `bb91abd` reproduce **40 failures / 22 passes**. This is not a full local test-suite pass. - `npm run docs:check`: passed separately because the full-test failure short-circuits this step in `check:pr`. - `npm run check:ci`: passed. - `npm_config_cache=/tmp/rea-npm-cache npm run verify:package`: passed, including packaged CLI/MCP checks; cache override was needed for this environment. - `npm pack --dry-run --cache /tmp/rea-npm-cache`: passed. - Real CLI `inspect-artifact <child-first.zip> --format json` and stdio MCP `open_binary` + `inspect_artifact`: passed. - `git diff --check`: passed. ## Compatibility, safety, and release - No schema changes or migration steps. Corrected containment and virtual-directory IDs are intentional for previously misparented entries. - Real Hopper/Ghidra and native Windows/macOS execution were not run locally; no such support claim is made. - Package/release metadata unchanged. - No archive extraction, path-validation relaxation, dependency changes, or unrelated cleanup. ## Review checklist - [x] One focused outcome with a Conventional Commit title. - [x] Reason for no linked issue stated. - [x] Regression and meaningful failure-path coverage included. - [x] Existing docs/contracts remain accurate; generated metadata checks pass. - [x] Representative CLI/MCP behavior executed. - [x] Final diff checked for secrets, unrelated changes, and unsupported claims. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-16 21:14:00 +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#2079
No description provided.