Repository navigation
[DECO-29941] skills: do not cache unportable skills, and name the pin env vars once - #8278
Conversation
… env vars once A skill whose files collide on a case-insensitive filesystem or use names Windows cannot hold is read live each time instead of cached, using the installer's portability check, which moves to libs/skills as UnportableSkill. DATABRICKS_SKILLS_REF and DATABRICKS_SKILLS_BASE_URL are named once. Cached releases stay ordered by fetch time so a rollback to an older release is served; a test covers it. Co-authored-by: Isaac <no-reply@databricks.com>
Regression test report ✅Commit: Selected 4 changed tests (limit=20, 0 not selected) 4 tests: regression=2 unreleased=2 coverage=0 failing=0
TestAccept/cmd/aitools/agent-hints: branch ✅ | main (d927dbe) ✅ | latest (v1.28.0) ❌latest (v1.28.0): TestAccept/cmd/skills/dir-no-network: branch ✅ | main (d927dbe) ✅ | latest (v1.28.0) ❌latest (v1.28.0): TestAccept/cmd/skills/live: branch ✅ | main (d927dbe) ❌ | latest (v1.28.0) ❌main (d927dbe): latest (v1.28.0): TestAccept/cmd/skills/unreachable: branch ✅ | main (d927dbe) ❌ | latest (v1.28.0) ❌main (d927dbe): latest (v1.28.0): |
✅ Integration test reportCommit: 5b24f91
Top 3 slowest tests (at least 2 minutes):
|
|
🤖 Hi @denik, this PR is part of our skills-sources work. We talked it through with Russell Clarey from eng-deco-cli here: #8158 (review) |
There was a problem hiding this comment.
Automated review at 5b24f91. Each finding was verified against the code.
No blocking issues found. 4 non-blocking comment(s) and 1 question(s) below.
This PR moves the installer's portability check to libs/skills as UnportableSkill, stops chain.ReadFile from caching files of skills that fail it, puts the pin env var names in one place, and adds a test that pins fetch-time ordering after a rollback. The installer move and the env var change keep behavior the same. One gap remains in the new cache gate: a path the catalog does not list is still read from the cache, so the case aliasing the PR sets out to prevent can still happen. The other comments are doc comments that no longer match the code.
Questions
- The PR also moves
refEnv/baseURLEnvfrom resolve.go to ref.go, rewords the package doc, and addsTestChainRolledBackReleaseIsServedAsLatestplus areadCatalogscomment that only pin existing ordering. None of this is needed for the no-cache fix, and AGENTS.md asks for one change per PR. Should these go in a separate PR, or stay here as small follow-ups? (non-blocking)
Comments outside the changed lines
- [nit]
libs/skills/chain.go:50:NewChain's doc still says ReadFile "serves the cached file when there is one, and otherwise reads the file … and caches it". That is no longer true for an unportable skill or one the catalog does not list. Those are read live on every call and fall back only to the bundled copy when offline. Can you add a sentence about this exception, so a caller doesn't expect offline reads of such a skill to come from the cache? - [nit]
libs/skills/portable.go:365: The doc comment came over unchanged and still describes only install and update ("Install skips such a skill… the paths recorded in the install state"). Now that it is exported fromlibs/skills, it also decides whetherchain.ReadFilecaches a skill. TheskillNamePatterncomment at line 355 still talks about "the installer's state file". Can the comment say what makes a skill unportable and then name both callers?
| return data, nil | ||
| // A skill that is not portable to every OS is read live each time: on a | ||
| // case-insensitive filesystem the cache could return another file's bytes. | ||
| cacheFiles := portableSkill(read.cat, skill) |
There was a problem hiding this comment.
[nice to have] portableSkill only checks the files the catalog lists. It never checks that file is one of them, and cache.readFile only checks cacheable. Take a skill alpha that lists only SKILL.md. On macOS or Windows, once SKILL.md is cached, databricks skills read-file alpha skill.md opens files/alpha/SKILL.md and returns its bytes. The live source would return ErrUnknownFile (fsSource.filePath in fs.go). Can the cache read and write be limited to slices.Contains(s.Files, file), so an unlisted path always goes live and is never stored?
There was a problem hiding this comment.
🤖 Should fix +1, three independent reviews found this too, and it reproduces: on a case-folding tmpfs, read-file alpha skill.md returns SKILL.md's bytes once SKILL.md is cached, and unknown skill file while the cache is cold. So the answer depends on whether the cache is warm. On Windows, SKILL.md. and SKILL.md (trailing dot or space) also pass cacheable() and open the same file. The slices.Contains(s.Files, file) check in portableSkill closes all of these, and on Linux a symlink skill.md -> SKILL.md in the cache folder is enough for a unit test.
| // cache.go reads them to turn the cache off for a pinned source. They sit in | ||
| // this package for now, next to the installer code that already uses them. | ||
| // DATABRICKS_SKILLS_REF and DATABRICKS_SKILLS_BASE_URL are named once, by refEnv | ||
| // and baseURLEnv in ref.go; resolve.go and cache.go read them to turn the cache |
There was a problem hiding this comment.
[nit] cache.go doesn't use refEnv/baseURLEnv to turn the cache off. sourceKey hashes them to name the pinned source's folder, and the cache is turned off through pinnedSource in resolve.go. resolve.go also reads refEnv in bundledFallback to drop the bundled copy. Maybe: "resolve.go reads them to recognize a pinned source (no bundled fallback, cache off unless pinnedCacheEnv is set), and cache.go hashes them into the pinned source's cache folder."
denik
left a comment
There was a problem hiding this comment.
🤖 Automated review of 5b24f91e2 by Opus 5.5, Fable 5.2 and GPT-6.2 Astra; each finding verified against the code.
No blocking issues. The gate does what the description says for two listed paths that collide. The installer move is verbatim apart from the exported name, and TestChainDoesNotCacheFilesOfAnUnportableSkill fails on the base chain.go. The main gap is the one review-oss-bot raised at chain.go:214: a requested path the skill doesn't list still reaches the cache. I added a reply in that thread.
Other points:
- Should fix (test)
libs/skills/chain.go:215: nothing tests the read-sideif cacheFiles. With only that guard removed, everylibs/skillstest still passes, because the new test starts with an empty cache. That guard is what keeps an unportableAlphafrom readingalpha's cached file on a case-insensitive filesystem. A test could seed an entry atc.cache.filePath(...)for an unportable skill and assert that the read goes live. - Optional design:
libs/skills/cache.go:214(filePath): a cache key built from a hash of[skill, file](snapshot.HashFromContentis already used incache.go) would make an entry match only byte-identical names. That closes the whole aliasing class by construction: case, trailing dots and spaces, NTFS 8.3 short names, NFC/NFD on APFS. It would also keep caching unportable skills, which are now neither cached nor served offline unless the bundled copy is the same release. With the current approach, NFC/NFD and 8.3 pairs in one skill remain a residual risk thatUnportableSkilldoesn't catch.
+1 to review-oss-bot's doc-comment nits on NewChain and UnportableSkill.
🥞 Stacked PR
Changes
Follow-ups to the skills cache wiring in the PR below it in the stack, two of the three the review left open:
SKILL.mdandskill.md) or use names Windows cannot hold (trailing dots, spaces, device names) is no longer cached. The chain reads its files live each time. The check is the installer'sunportableSkill, moved tolibs/skillsasUnportableSkillso both can use it; the installer calls it from there with no change in behavior.DATABRICKS_SKILLS_REFandDATABRICKS_SKILLS_BASE_URLare named once (refEnv,baseURLEnvinref.go) instead of as string literals inref.goandcache.go.Why
The cache stores a file under the skill's name and file path. On a case-insensitive filesystem two listed paths can be one file, so a read of one could return the other's bytes. The installer already refuses such skills; the cache now does the same.
Decisions to review
TestChainRolledBackReleaseIsServedAsLatestand a comment onreadCatalogspin this.UnportableSkill's tests stay in the installer package, where its table of cases already lives, and go through the exported function. Moving them would add about 200 changed lines and no coverage.Tests
TestChainDoesNotCacheFilesOfAnUnportableSkill: two reads of a skill withSKILL.mdandskill.mdgo live both times and store nothing.TestChainRolledBackReleaseIsServedAsLatest: after a rollback to an older release, it is served live and as the unreachable fallback.go test ./libs/skills/... ./cmd/skills/... ./libs/aitools/... ./cmd/aitools/..., thecmd/skills,help/skillsandcmd/aitoolsacceptance areas, and./task --force fmt-q lint-qpass.The
skillscommands exist only whenDATABRICKS_SKILLS_PREVIEWis set, so nothing changes for anyone else.This pull request and its description were written by Isaac.