[PR #1493] [MERGED] perf(artifacts)!: name each edge's child through its occurrence #2923

Closed
opened 2026-10-17 21:11:52 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: main ← Head: perf/artifact-edges-reference-occurrences


📝 Commits (1)

  • 060df51 perf(artifacts)!: name each edge's child through its occurrence

📊 Changes

8 files changed (+45 additions, -39 deletions)

View changed files

📝 src/artifacts/inventory/ArtifactGraphConstruction.ts (+1 -3)
📝 src/domain/artifactComparison.ts (+7 -6)
📝 src/domain/artifactGraph.ts (+4 -3)
📝 src/domain/artifactIdentity.ts (+17 -10)
📝 src/domain/artifactInventoryEvidence.ts (+13 -12)
📝 tests/boundary/filesystem/artifactInventoryEntryOrder.test.ts (+1 -2)
📝 tests/boundary/filesystem/asarInventoryContainment.test.ts (+1 -2)
📝 tests/boundary/providers/native/artifactProvider.directoryInventory.test.ts (+1 -1)

📄 Description

Summary

createArtifactEdges makes exactly one edge per occurrence that has an artifact. Each edge copied that occurrence's artifact_id as child_artifact_id and its logical_path as logical_path, next to the occurrence_id that already names the occurrence. On Visual Studio Code.app all 10,004 edges match their occurrence on both fields. Those two copies were about 1.9 MB of a 13 MB inspect_artifact result.

This change:

  • Schema: edges keep edge_id, ordinal, parent_artifact_id, relation, occurrence_id, producer. child_artifact_id and logical_path are removed. The schema comment says the child and path are the occurrence's. parent_artifact_id stays because it is not always the parent occurrence's artifact: source maps point at their script, and about 2% of edges differ.
  • Edge IDs are unchanged. artifactEdgeId(edge, occurrence) still hashes the same five values, reading child and path from the occurrence.
  • Validation: validateEdge now requires the referenced occurrence to exist and to have a known artifact.
  • Comparison: relationsByPath reads the child artifact and path from the occurrence. It skips an edge whose occurrence is missing, which can only happen in an incomplete inventory. Comparison already reports such inventories as truncated or unknown.

Measured effect

rea inspect-artifact <app> --format json against main:

app main this branch
Transmission.app 1,095,316 967,885 (−11.6%)
Visual Studio Code.app 15,366,749 13,479,855 (−12.3%)

This is independent of #1492 (Evidence locations). The two savings add up.

Breaking change

  • Inventory edges no longer carry child_artifact_id or logical_path; read them from the occurrence named by occurrence_id.
  • graph_sha256 and manifest_id change, because they hash the edge records.
  • Inventory or inspection Evidence recorded by earlier versions fails the graph commitment check when compared.

Verification

  • npx vitest run src/domain src/artifacts passes (120 files, 1,565 tests).
  • npm run test:focused passes on every test under tests/ that uses inventoryArtifact, ArtifactProvider, inspect_artifact, compare_artifacts, or the Apple/Android/managed application graph projections (45 files, 377 tests). That includes artifactMcp's inventory comparison and tests/composition/analysis-sessions/artifactComparison.
  • Three boundary tests that asserted child_artifact_id/logical_path on edges now assert occurrence_id.
  • npm run check:fast and npm run docs:check pass.
  • I ran the CLI by hand against two real app bundles to get the numbers above.
  • No real Hopper or Ghidra verification was needed.

🤖 Generated with Claude Code


🔄 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/1493 **Author:** [@kaoru0822-kitauji](https://github.com/kaoru0822-kitauji) **Created:** 10/10/2026 **Status:** ✅ Merged **Merged:** 10/10/2026 **Merged by:** [@kaoru0822-kitauji](https://github.com/kaoru0822-kitauji) **Base:** `main` ← **Head:** `perf/artifact-edges-reference-occurrences` --- ### 📝 Commits (1) - [`060df51`](https://github.com/morluto/rea/commit/060df516d687b9e2c5d71c82fa6542ac40dbf96c) perf(artifacts)!: name each edge's child through its occurrence ### 📊 Changes **8 files changed** (+45 additions, -39 deletions) <details> <summary>View changed files</summary> 📝 `src/artifacts/inventory/ArtifactGraphConstruction.ts` (+1 -3) 📝 `src/domain/artifactComparison.ts` (+7 -6) 📝 `src/domain/artifactGraph.ts` (+4 -3) 📝 `src/domain/artifactIdentity.ts` (+17 -10) 📝 `src/domain/artifactInventoryEvidence.ts` (+13 -12) 📝 `tests/boundary/filesystem/artifactInventoryEntryOrder.test.ts` (+1 -2) 📝 `tests/boundary/filesystem/asarInventoryContainment.test.ts` (+1 -2) 📝 `tests/boundary/providers/native/artifactProvider.directoryInventory.test.ts` (+1 -1) </details> ### 📄 Description ## Summary `createArtifactEdges` makes exactly one edge per occurrence that has an artifact. Each edge copied that occurrence's `artifact_id` as `child_artifact_id` and its `logical_path` as `logical_path`, next to the `occurrence_id` that already names the occurrence. On Visual Studio Code.app all 10,004 edges match their occurrence on both fields. Those two copies were about 1.9 MB of a 13 MB `inspect_artifact` result. This change: - **Schema:** edges keep `edge_id`, `ordinal`, `parent_artifact_id`, `relation`, `occurrence_id`, `producer`. `child_artifact_id` and `logical_path` are removed. The schema comment says the child and path are the occurrence's. `parent_artifact_id` stays because it is not always the parent occurrence's artifact: source maps point at their script, and about 2% of edges differ. - **Edge IDs are unchanged.** `artifactEdgeId(edge, occurrence)` still hashes the same five values, reading child and path from the occurrence. - **Validation:** `validateEdge` now requires the referenced occurrence to exist and to have a known artifact. - **Comparison:** `relationsByPath` reads the child artifact and path from the occurrence. It skips an edge whose occurrence is missing, which can only happen in an incomplete inventory. Comparison already reports such inventories as truncated or unknown. ## Measured effect `rea inspect-artifact <app> --format json` against `main`: | app | main | this branch | |---|---|---| | Transmission.app | 1,095,316 | 967,885 (−11.6%) | | Visual Studio Code.app | 15,366,749 | 13,479,855 (−12.3%) | This is independent of #1492 (Evidence `locations`). The two savings add up. ## Breaking change - Inventory edges no longer carry `child_artifact_id` or `logical_path`; read them from the occurrence named by `occurrence_id`. - `graph_sha256` and `manifest_id` change, because they hash the edge records. - Inventory or inspection Evidence recorded by earlier versions fails the graph commitment check when compared. ## Verification - `npx vitest run src/domain src/artifacts` passes (120 files, 1,565 tests). - `npm run test:focused` passes on every test under `tests/` that uses `inventoryArtifact`, `ArtifactProvider`, `inspect_artifact`, `compare_artifacts`, or the Apple/Android/managed application graph projections (45 files, 377 tests). That includes `artifactMcp`'s inventory comparison and `tests/composition/analysis-sessions/artifactComparison`. - Three boundary tests that asserted `child_artifact_id`/`logical_path` on edges now assert `occurrence_id`. - `npm run check:fast` and `npm run docs:check` pass. - I ran the CLI by hand against two real app bundles to get the numbers above. - No real Hopper or Ghidra verification was needed. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-17 21:11:52 +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#2923
No description provided.