Repository navigation
[DECO-29941] skills: serve the live release, then the cache, then the bundled copy - #8267
simonfaltum wants to merge 1 commit into
Conversation
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 (9fe8d20) ✅ | latest (v1.28.0) ❌latest (v1.28.0): TestAccept/cmd/skills/dir-no-network: branch ✅ | main (9fe8d20) ✅ | latest (v1.28.0) ❌latest (v1.28.0): TestAccept/cmd/skills/live: branch ✅ | main (9fe8d20) ❌ | latest (v1.28.0) ❌main (9fe8d20): latest (v1.28.0): TestAccept/cmd/skills/unreachable: branch ✅ | main (9fe8d20) ❌ | latest (v1.28.0) ❌main (9fe8d20): latest (v1.28.0): |
✅ Integration test reportCommit: 2b3a60e
Top 3 slowest tests (at least 2 minutes):
|
… bundled copy Resolve returns the fallback chain, so the skills commands read the published release and fall back to the disk cache and then the bundled snapshot when the release cannot be reached. DATABRICKS_SKILLS_DIR still wins and makes no network call. A catalog that is not live prints a provenance line on stderr from every command. Co-authored-by: Isaac <no-reply@databricks.com>
|
🤖 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) |
b92e990 to
2b3a60e
Compare
denik
left a comment
There was a problem hiding this comment.
🤖 Automated review of 2b3a60e16 by Opus 5.5, Fable 5.2 and GPT-6.2 Astra; each finding verified against the code.
Verdict: the chain wiring works on the main path, with no blocking issues. Five Should-fix points are inline: a duplicated provenance line offline, the lookup-failure fallback release served and cached as fresh, the bundled copy no longer serving reads once a catalog is cached, an extra manifest GET per file read, and acceptance tests that don't reach the production cache path (one of them can't fail).
Other findings, ranked:
- Should fix
libs/skills/release_source.go:43:Atrebuilds the ref as"v" + version, so withDATABRICKS_SKILLS_REF=1.2.0the catalog is read from<base>/1.2.0and the files from<base>/v1.2.0. Returningsunchanged when the ref is pinned avoids it. - Should fix
libs/skills/release_source.go:85: a cli-compat pin (Pinned: true) doesn't constrain the fallback. If the pinned release A is unreachable, the chain serves the cached or bundled B the pin rolled back from (and a fresh cached B for up to 10 minutes without asking live). - Should fix
libs/skills/cache.go:197: a legitimately empty release file (e.g.scripts/__init__.py) is always a cache miss, so it is refetched on every read and fails offline when the bundled release differs. - Should fix
libs/skills/resolve.go:83: withDATABRICKS_SKILLS_REFset,LocalCatalognow returns nil, so help footers lose the skill hints they printed from the bundled copy at the merge base. Intended for pinned eval runs? - Should fix
libs/aitools/installer/installer.go:224:DisplaySkillsVersionnow goes throughReleaseVersion, soinstalledSkillsReleaseparses a recordedv2/v1.2to""instead ofv2.0.0, andcheckSkillsDowngradestops refusing. Narrow (non-canonical refs only), but it is outside the preview flag and untested. - Should fix
cmd/skills/list_test.go:352:offlineContextredirects only the skills host. WithoutDATABRICKS_FORCE_EMBEDDED_COMPAT,ResolveReleasecan still fetch the compatibility manifest from GitHub when no fresh local copy exists, so these offline tests aren't hermetic. - Nit
cmd/skills/read.go:84: the JSONsourcenames the printed catalog even when the bytes came from the bundled copy. - Nit comments that are now wrong:
libs/skills/skills.go:6-9(only ref.go and cache.go read the ref and base-URL variables) andlibs/skills/bundled_source.go:12-14("Resolve serves it today").
| // another copy than the catalog the command printed, as when the read fell back | ||
| // to the bundled copy. | ||
| func printReadProvenance(ctx context.Context, src libskills.Source, catalog *libskills.Catalog) { | ||
| if served := libskills.Served(src); served != nil && served != catalog { |
There was a problem hiding this comment.
🤖 Should fix: offline with no cached catalog, skills read <name> and skills read-file print the same provenance line twice. Catalog returns the bundled catalog, then ReadFile goes through fallBack, which always stores a fresh withReason copy (libs/skills/chain.go:274). So served != catalog is true by pointer although both describe the bundled copy. TestReadServesBundledCopyWithoutFetchTime uses assert.Contains, so it passes.
Suggest: in fallBack, keep read.cat when it already is the bundled catalog (or compare label and version here instead of pointers), and assert the exact stderr in that test.
| if err != nil { | ||
| return nil, "", unreachable(err) | ||
| } | ||
| if rel.LookupErr != nil { |
There was a problem hiding this comment.
🤖 Should fix: when the latest-release lookup fails, this reads the fallback release (compat, embedded or build-time) and returns it as a live catalog without Stale. The chain then stamps it FetchedAt = now and caches it (chain.go:128-130). The version file runs ahead of the tags while a release is being cut (ref.go:26-29), so this happens around every skills release.
Scenario: the cache holds 0.2.58, fetched 11 minutes ago. The pointer names 0.2.59, which has no tag yet. The CLI serves the older fallback release with no provenance line and caches it as the newest entry, so for the next commands Latest() and LocalCatalog return it ahead of 0.2.58. No production source sets Stale on a live catalog, so the !live.Stale guard this PR reworks doesn't cover this case.
Suggest: set Stale and a Reason from rel.LookupErr in releaseSource.Catalog, and have the chain prefer a newer cached catalog over it. A chain test with a failing LatestSkillsReleaseRefFn would pin it.
| return nil, nil, fmt.Errorf("bundled copy: %w", err) | ||
| } | ||
| } | ||
| if bundled.Version != cat.Version { |
There was a problem hiding this comment.
🤖 Should fix: once a catalog is cached, the bundled copy can no longer serve skills the user hasn't read yet. Scenario: one online skills list caches the 0.2.58 catalog (files are cached only when read). Later, offline, skills list shows the cached skills, but skills read <a skill not read before> fails with "the bundled copy is release 0.2.50, not release 0.2.58", although the binary contains that skill. At the merge base the same offline read was served from the bundled copy.
Is failing intended here? One option: when the live source is down and the cached release lacks the file, serve the catalog and the file from the bundled copy, with its provenance line.
| ctx, cancel := context.WithTimeout(ctx, releaseTimeout) | ||
| defer cancel() | ||
| src, _, err := openRelease(ctx) | ||
| src, _, err := openRelease(ctx, s.ref) |
There was a problem hiding this comment.
🤖 Should fix (extra request per file): each ReadFile opens a new fsSource, and fsSource.filePath fetches manifest.json again (fs.go:100) only to find the file's repo_dir, after Catalog already fetched and validated it. A cold skills read makes: GET version pointer, HEAD manifest, GET manifest, GET rules, GET manifest again, GET SKILL.md. With a fresh cached catalog, every uncached file read is still two GETs where one would do.
Suggest: keep the validated manifest in the source At returns for the command's lifetime (or store RepoDir with the cached catalog), and add a read step to the live acceptance test that counts the manifest requests.
|
|
||
| Env.DATABRICKS_SKILLS_DIR = "" | ||
| Env.DATABRICKS_SKILLS_REF = "v1.0.0" | ||
| Env.DATABRICKS_SKILLS_TEST_PINNED_CACHE = "1" |
There was a problem hiding this comment.
🤖 Should fix (test coverage): the only acceptance test through the chain runs a mode users never get. With DATABRICKS_SKILLS_TEST_PINNED_CACHE and a pinned ref, the cache uses the skills-pinned/<hash> folder and caches no files (libs/skills/cache.go:75). In production, a pinned ref or a custom base URL gets no cache at all. So the default path has no acceptance coverage: the latest-release lookup, the release-keyed skills folder, file caching, At(version), and read/read-file through the chain, including the second provenance line. The description's "a pinned source caches catalogs under a folder keyed by the source" also holds only with the test variable set.
Related: dir-no-network/script:7 checks -f out.requests.txt in the working directory, but the harness records requests in $OUT_REQUESTS, which is in a separate output directory (acceptance/acceptance_test.go:1030, acceptance/internal/prepare_server.go:267). That branch never runs, so the test passes whatever reaches the server. if [ -f "$OUT_REQUESTS" ] fixes it.
Suggest: have the test switch select the production layout (release-keyed folder, file caching) with the ref unpinned, since the lookup reads main/metaplugin/version.meta.json from the same base URL. Add a 503 on the manifest for the outage and a read step.
🥞 Stacked PR
Use this link to review incremental changes.
Changes
databricks skillsserved only a local folder, so the commands could not serve the published skills release.Resolvenow returns the fallback chain: the published release, then the disk cache, then the snapshot bundled into the binary.DATABRICKS_SKILLS_DIRstill wins and makes no network call, which evals and tests rely on.Stale) prints one provenance line on stderr from every command: where it came from (cached or bundled copy), its release, its age and why the live release was not used. A catalog fromDATABRICKS_SKILLS_DIRprints nothing.Catalogfirst and reads its files at the release of that catalog, so a newer release cannot swap files under an older served catalog. An unpinned run makes one latest-release lookup.release.txt, written by the release build), so the bundled fallback matches the live release's version.DATABRICKS_SKILLS_REFor a custom base URL) caches catalogs under a folder keyed by the source and never caches its files.ReleaseVersionis one helper for the release tag, shared with the installer'sDisplaySkillsVersion, sovendor-fixis no longer shown asendor-fix.Staleis not stamped fresh or cached, so the next call reaches the live source again.Why
The release source, the cache and the bundled snapshot existed only as separate pieces. Until
Resolvereturns the chain, no command benefits from them.Decisions to review
DATABRICKS_SKILLS_REFnever falls back to the bundled copy, since the bundled copy is another release. It fails with the unreachable error instead.skills list-files --output jsonomits sizes for a live or cached catalog on purpose: the chain forwardsFileSizeonly for the bundled copy, because a release is read over HTTP and a cached file may not be on disk.Not in this PR
unportableSkillcheck before caching, ordering cached releases by release version instead of fetch time, and sharing one env-var list inNewCache. They come in a follow-up PR.Tests
libs/skillsandcmd/skills: fallback on a refused connection, no fallback on cancel or 404, two releases that share manifest version "2" getting separate cache folders, files read at the served release, the bundled fallback serving when the release is unreachable, and the pinned-ref case.cmd/skills/live(a local server stands in for the release: first call serves the catalog with no provenance line, a second call makes no request, and with the server down and a stale cache the cached copy is served with the provenance line),cmd/skills/unreachable(no release, cache or bundled skills: non-zero exit naming the cause),cmd/skills/dir-no-network.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.