Repository navigation
fix(artifacts): record each case collision once at its diverging segment - #1505
Merged
Merged
Conversation
Inventory paired every path under one case spelling with every path under each other spelling and listed all of them on each occurrence. An archive with Foo/ and foo/ subtrees of N files each produced N-entry lists on 2N occurrences: 4,000 such ZIP members yielded a 120 MB inspect_artifact result and close to 1 GB of memory. The trie walks also recursed once per path component, so a ZIP name with tens of thousands of components threw RangeError. A collision is now recorded at the segment where spellings diverge and shared down that subtree by an iterative walk. Each occurrence names the colliding prefix and the first other spelling, plus a count of further spellings, each of which is its own occurrence. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
10 tasks done
darsrc
pushed a commit
to darsrc/rea
that referenced
this pull request
Oct 10, 2026
…ent (morluto#1505) Inventory paired every path under one case spelling with every path under each other spelling and listed all of them on each occurrence. An archive with Foo/ and foo/ subtrees of N files each produced N-entry lists on 2N occurrences: 4,000 such ZIP members yielded a 120 MB inspect_artifact result and close to 1 GB of memory. The trie walks also recursed once per path component, so a ZIP name with tens of thousands of components threw RangeError. A collision is now recorded at the segment where spellings diverge and shared down that subtree by an iterative walk. Each occurrence names the colliding prefix and the first other spelling, plus a count of further spellings, each of which is its own occurrence.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This addresses the two
ArtifactPaths.tsreview findings left open on #1480. (The third finding, about the Windows extraction test, was fixed in b12d0c6.)Quadratic growth.
noteFoldedSpellingscollected every terminal under each case spelling and gave each one a set of all terminals under the other spellings. Each occurrence then received one limitation joining those paths. WithFoo/andfoo/holding N files each, that is 2N occurrences each listing N paths.Repro, a ZIP with
Foo/a{i}.txtandfoo/b{i}.txt, usingrea inspect-artifact x.zip --format json:A somewhat larger untrusted ZIP would exhaust the process before inventory returns.
Recursion.
recordCaseCollisionsandterminalsUnderrecursed once per path component. A ZIP name with about 30,000 one-letter components still fits the 65,535-byte name field, and it threwRangeError: Maximum call stack size exceeded.Change
A collision is recorded once, at the segment where the spellings diverge. A linked chain shares it with every path in that subtree. The trie is walked with an explicit stack.
Each affected occurrence names the colliding prefix and the first other spelling in code-point order, plus a count when there are more spellings:
Logical path Main.js collides under English (en-US) Unicode case folding with main.js; …Logical path res/foo/b.txt is under res/foo, which collides under English (en-US) Unicode case folding with res/Foo; …… with A.txt and 1 other spelling; …Every spelling is still its own occurrence with its own limitation, so the full set stays in the result. The inventory-level limitation and extraction behavior are unchanged.
Verification
src/artifacts/ArtifactPaths.test.tscovers the file message, a directory collision on descendants, the count form, a 2×5,000 subtree with one bounded limitation per occurrence, and a 30,000-component name. Onmainfour of the five fail: the stack test withRangeError, and the subtree test runs 4.2 s with N-entry lists.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.tspasses (14 tests).npm run check:fastandnpm run docs:checkpass.🤖 Generated with Claude Code