Repository navigation
fix(artifacts): keep case-distinct archive names in inventory - #1480
Conversation
ZIP member names are case-sensitive. Inventory was folding them with a filesystem case rule, so shrunk APKs never became evidence for the Android application graph. Logical registration now keeps both spellings and records an English Unicode case-folding limitation. Extraction fails only when the destination directory already holds the other spelling.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 312263a215
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| groups.flatMap((candidate, candidateIndex) => | ||
| candidateIndex === index ? [] : candidate, | ||
| ), |
There was a problem hiding this comment.
Avoid expanding case-collision subtrees quadratically
When an archive contains large case-variant directory trees such as Foo/{a1...aN} and foo/{b1...bN}, this cross-products every terminal beneath one spelling with every terminal beneath the other. The resulting sets and per-occurrence others.join(...) strings require O(N²) memory, so a modest untrusted ZIP can exhaust the process before inventory is returned. Record the collision at the affected directory segment, or retain a bounded representative rather than materializing every descendant pair.
AGENTS.md reference: AGENTS.md:L42-L42
Useful? React with 👍 / 👎.
| for (const spellings of node.spellingsByFold.values()) | ||
| if (spellings.length > 1) noteFoldedSpellings(node, spellings, collisions); | ||
| for (const child of node.bySpelling.values()) | ||
| recordCaseCollisions(child, collisions); |
There was a problem hiding this comment.
Walk the path trie without recursive stack growth
For a ZIP entry with thousands of short path components, recordCaseCollisions recurses once per component even when there are no collisions. Such a name can fit within ZIP's filename field while exceeding Node's call-stack depth, causing an otherwise accepted inventory to fail with a RangeError; use an iterative traversal or enforce a documented format-derived depth limit.
AGENTS.md reference: AGENTS.md:L42-L42
Useful? React with 👍 / 👎.
| expect(extracted.ok).toBe(true); | ||
| expect(await readFile(join(output, "Main.js"), "utf8")).toBe("upper"); | ||
| expect(await readFile(join(output, "main.js"), "utf8")).toBe("lower"); |
There was a problem hiding this comment.
Make the extraction assertion filesystem-aware
On the checked windows-curated job (.github/workflows/ci.yml:414-420), this test runs on the default case-insensitive Windows filesystem. Creating main.js after Main.js therefore makes SafeOutputTree.write report the destination case collision and roll back, so extracted.ok is false and this required CI lane fails. Keep the inventory assertions cross-platform, but only expect successful extraction after detecting a case-sensitive destination; otherwise assert the intended collision failure.
Useful? React with 👍 / 👎.
|
TL;DR: The fix works. Coffee 2.27 now loads with both I tested the merge Coffee 2.27 (Apache-2.0), CLI
A fix to my count in #1470: I said 39 pairs. It is 39 groups, with 79 names. One group is a triple: MCP over stdio (Node 24)
More F-Droid apps (Node 24)Each APK's SHA-256 matches F-Droid's signed index.
WordleSolver has no case pairs. Its inventory is the same on both commits. Its graph only gains the two new notes. Stay Put shows why the signing note matters. It has only a newer-style signature. That signature lives in a block that zip readers skip. So the graph lists no signing files, yet the APK is signed. The new note says just that. I also renamed a copy of the WordleSolver APK to I also ran the new tests against the Not run
Thanks, morluto, for the quick fix and the clear signing note. Edit: The sources for WordleSolver do not agree on its licence. F-Droid says Coffee detailsThe inventory output on
Commandsrea inspect-artifact coffee.apk --format json
rea inspect-artifact coffee.apk --integrity-policy record-and-continue --format json
# graph input: {"inventory_evidence":[<normalized_result.substeps[0].evidence>]}
rea project-android-application-graph graph-in.json --format json
rea extract-artifact coffee.apk --format json
npm run test:focused -- \
tests/boundary/providers/native/artifactProvider.archiveSafety.test.ts \
tests/boundary/providers/native/artifactProvider.failureDetail.test.ts \
tests/composition/android/application.test.tsMCP order: Test setup
🤖 Generated with Claude Code (Opus 5.5) 🦊 |
…o#1480) ZIP member names are case-sensitive. Inventory was folding them with a filesystem case rule, so shrunk APKs never became evidence for the Android application graph. Logical registration now keeps both spellings and records an English Unicode case-folding limitation. Extraction fails only when the destination directory already holds the other spelling. Co-authored-by: Cursor Agent <[email protected]>
Summary
Fixes #1470. Shrunk release APKs can contain ZIP names that differ only in case, such as
res/2F.xmlandres/2f.xml. Inventory treated that as an unsafe path, soinspect-artifactfailed andproject-android-application-graphhad no evidence. Both names now stay in the inventory, with a limitation that a case-insensitive destination cannot store both.Problem and expected behavior
ArtifactPathRegistryfolded every ZIP segment with English case folding during inventory. ZIP names are case-sensitive, and Android resource shrinking uses both cases. The failure was reported as a path the analyst should correct, and--integrity-policy record-and-continuedid not apply.Inventory should keep both logical names. Extraction should fail only when the destination directory cannot keep both spellings.
Change and scope
Logical registration is exact spelling. Exact duplicates and same-spelling file/directory prefixes still fail. After the scan, each affected occurrence and the inventory record that English (en-US) Unicode case folding collides those names. That note is not a filesystem observation and is not an integrity contradiction.
SafeOutputTreeis the materialization boundary. It still refuses a second write of one logical path. If creating a segment fails and the parent listing already holds another English-case spelling, extraction names both paths, points back at the inventory, and rolls the tree back. Case-sensitive volumes write both files.The Android projection no longer compares component formats with
android-manifest,android-resources,dex, orjvm-class. Inventory never emits those labels. Classification stays on the path rules. Every projection states that ZIP inventory cannot see the APK Signing Block, so an empty signing array does not mean unsigned, and that a bridge basis comes from the native path and is repeated for every managed component..aabis no longer classified asapk. An app bundle with ZIP magic is azip. JADX and the application graph already require an APK.Not included: an APK Signing Block parser, split-APK sets, a JADX-to-graph join, or DEX/binary-XML magic detection.
Contract and boundary impact
ArtifactPathRegistryduring inventory; destination collision inSafeOutputTreeduring extraction.artifact_operation_failed/path. Unsafe paths still tell the analyst to correct the artifact. A destination case collision returns the spelling pair and says the inventory retains both names..aabresolves aszipinstead ofapk.docs/public/product-catalog.json), package, or installation impact: none.Evidence and regression coverage
Main.jsandmain.js), path-failure presentation, and an APK withres/2F.xmlandres/2f.xmlthat inventories and projects.a.jsafterA.js. That case now inventories both entries.inspect-artifactsucceeds for case-distinct ZIP names and includes the case-folding limitation. Extraction on a case-insensitive volume fails withDestination filesystem cannot store both <path> and <other>; inventory retains both logical names.For evidence-bearing changes:
Validation performed
npm run test:local -- tests/composition/android/application.test.ts— 6 passednpm run test:focused -- tests/boundary/providers/native/artifactProvider.archiveSafety.test.ts tests/boundary/providers/native/artifactProvider.failureDetail.test.ts— 8 passednpm run check:fast— typecheck and lint passedReal JADX was not required. The graph change consumes inventory evidence only.
Compatibility, safety, and release
.aabpath that was previously labeledapkis nowzip, so Android package tools and the application graph refuse it as a non-APK.Review checklist
type(scope): outcome.