Dedup skill files by exact path, not case-folded path#531
Open
PratikDhanave wants to merge 3 commits into
Open
Dedup skill files by exact path, not case-folded path#531PratikDhanave wants to merge 3 commits into
PratikDhanave wants to merge 3 commits into
Conversation
discoverResourceFiles and discoverScriptFiles deduplicated discovered files using strings.ToLower(filePath) as the seen-set key while keeping the original-case path as the file Name. On a case-sensitive filesystem (e.g. Linux, the primary CI target) two genuinely distinct files in the same skill directory that differ only in case — Data.json vs data.json, or Run.py vs run.py — collapse to one key, so the second is silently dropped. Dedup by the exact path instead, which still guards against visiting the same file twice but no longer conflates distinct files. Adds a black-box test using a case-sensitive fstest.MapFS.
There was a problem hiding this comment.
Pull request overview
This PR fixes file discovery deduplication in the file-system-backed skills source so that it deduplicates by the exact discovered path rather than a case-folded path, preserving distinct files that differ only by case on case-sensitive filesystems (e.g., Linux).
Changes:
- Update
discoverResourceFilesto deduplicate byfilePath(exact path) instead ofstrings.ToLower(filePath). - Update
discoverScriptFilesto deduplicate byfilePath(exact path) instead ofstrings.ToLower(filePath). - Add a regression test using
fstest.MapFSto ensure distinctly-cased resource and script files are both discovered.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| agent/skills/fsskills/source.go | Switch resource/script dedup keys from case-folded paths to exact paths to avoid collapsing distinct files on case-sensitive FS. |
| agent/skills/fsskills/source_script_test.go | Add a black-box regression test validating discovery keeps Data.json/data.json and Run.py/run.py as separate entries. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Problem
discoverResourceFilesanddiscoverScriptFilesdeduplicate discovered files using a case-folded key:but keep the original-case path as the file
Name. On a case-sensitive filesystem (Linux — the primary CI target) two genuinely distinct files in the same skill directory that differ only in case collapse to oneseenkey, so the second is silently dropped:Data.jsonanddata.json→ only one resource discoveredRun.pyandrun.py→ only one script discoveredThe lowercasing isn't needed for the dedup's actual purpose (guarding against the same path being visited twice) and has no comment justifying case-insensitivity.
Fix
Dedup by the exact
filePath. Same-path revisits are still collapsed; distinct files differing only in case are both kept.Test
TestFileSource_CaseSensitiveFS_KeepsDistinctlyCasedFiles(black-box) uses a case-sensitivefstest.MapFS(map keys are always case-sensitive, unlikeos.DirFSon a case-insensitive host such as macOS) containingData.json/data.jsonandRun.py/run.py, and asserts 2 resources and 2 scripts are discovered. Fails onmain(gets 1 each), passes with the fix.