Skip to content

skills: serve the bundled snapshot when no skills folder is set - #8199

Merged
simonfaltum merged 5 commits into
mainfrom
skills/rbund-skills-commands-serve-the-bundled-snapsh
Nov 30, 2026
Merged

simonfaltum merged 5 commits into
mainfrom
skills/rbund-skills-commands-serve-the-bundled-snapsh

Conversation

@simonfaltum

@simonfaltum simonfaltum commented Nov 30, 2026 •

Copy link
Copy Markdown
Member

Changes

skills list, read, read-file, list-files and search now serve the copy bundled in the binary when DATABRICKS_SKILLS_DIR is not set. A folder in DATABRICKS_SKILLS_DIR still wins. If the bundled snapshot has no skills, as in every dev build today, Resolve still returns the same "no source" error, so output and errors are unchanged. LocalCatalog (used by help hints) follows Resolve, so the two read the same source.

skills read prints the bundled copy's provenance line through the shared provenanceLine (other catalogs keep read's own wording), so the bundled copy shows "bundled copy" and no fetched time. SetBundledFSForTest lets tests serve a non-empty snapshot without filling the embed folder.

Why

A released binary has no skills to serve without a folder. This is the first working version: it serves the bundled copy before the live release, cache and fallback chain exist. Those will sit in front of the bundled copy. The feature stays behind DATABRICKS_SKILLS_PREVIEW.

Tests

  • New unit tests: no dir plus empty snapshot gives no source; no dir plus a fixture snapshot serves the bundled copy; the folder wins over the bundled copy; LocalCatalog agrees; list and read label the copy and omit the fetched time.
  • go test ./libs/skills/... ./cmd/skills/... and go test ./acceptance -run 'TestAccept/cmd/skills' pass with no golden changes.

This pull request and its description were written by Isaac.

Resolve returns the bundled source when DATABRICKS_SKILLS_DIR is unset and
the snapshot has skills. An empty snapshot still reports no source. LocalCatalog
follows Resolve. skills read prints provenance through the shared line, so the
bundled copy shows no fetched time.

Co-authored-by: Isaac <no-reply@databricks.com>
@eng-dev-ecosystem-bot

eng-dev-ecosystem-bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Integration test report

Commit: cb4b064

Run: 46444688829

Env 💚​RECOVERED ✅​pass 🙈​skip Time
💚​ aws linux-2core-8gb 1 90 6 1:52
💚​ aws-windows-latest-4core-16gb 1 90 6 3:32
💚​ azure linux-2core-8gb 1 90 6 1:59
💚​ azure-windows-latest-4core-16gb 1 90 6 3:47
💚​ gcp linux-2core-8gb 1 90 6 2:00
💚​ gcp-windows-latest-4core-16gb 1 90 6 3:23
Test Name aws linux-2core-8gb aws-windows-latest-4core-16gb azure linux-2core-8gb azure-windows-latest-4core-16gb gcp linux-2core-8gb gcp-windows-latest-4core-16gb
💚​ TestAccept 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R
Top 3 slowest tests (at least 2 minutes):
duration env testname
3:46 azure-windows-latest-4core-16gb TestAccept
3:30 aws-windows-latest-4core-16gb TestAccept
3:22 gcp-windows-latest-4core-16gb TestAccept

… test

Co-authored-by: Isaac <no-reply@databricks.com>
@simonfaltum

Copy link
Copy Markdown
Member Author

Pushed 9d8d254 for the review findings. Added a guard test (non-empty bundled copy, preview unset: GroupSkills returns nil, WriteGroupHint writes nothing). The bundled copy's provenance line is now "Skills come from bundled copy (release X). The skills may be out of date.", with no refresh claim; real stale catalogs keep their wording. list-files now forwards file sizes for the bundled copy. The three no-source tests set an empty bundled FS, and the newBundledSource comment is corrected.

@simonfaltum
simonfaltum marked this pull request as ready for review November 30, 2026 13:28
@simonfaltum
simonfaltum requested a review from a team as a code owner November 30, 2026 13:28
@simonfaltum
simonfaltum requested review from denik and rclarey November 30, 2026 13:28

@review-oss-bot review-oss-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review at 9d8d254. Each finding was verified against the code.

No blocking issues found. 4 non-blocking comment(s) below.

This PR makes skills list, read, read-file, list-files and search fall back to the bundled snapshot when DATABRICKS_SKILLS_DIR is unset, and routes LocalCatalog through Resolve. The fallback logic and the folder-wins precedence look right. One thing doesn't match the description: switching skills read to the shared provenanceLine changes its stale-cache message, and the test was edited to accept the new text. A few doc comments also no longer describe what the code does.

Comments outside the changed lines

  • [nit] libs/skills/bundled_source.go: The bundledSnapshot comment (lines 11-12) says it is the fallback for when the release can't be reached. bundledSource.Catalog (lines 65-67) says it "is only used when the release cannot be reached", and Catalog.Stale in skills.go:73-76 says the same. After this change, Resolve serves the bundled copy whenever DATABRICKS_SKILLS_DIR is unset, without trying any release. The new comment at list.go:84 says as much ("No refresh was tried"). Can these comments be updated to say what happens now?

Comment thread cmd/skills/read.go Outdated
}
if catalog.Stale {
cmdio.LogString(ctx, readProvenance(catalog))
cmdio.LogString(ctx, provenanceLine(catalog))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nice to have] skills read now uses provenanceLine, which was written for skills list. For a stale cached catalog that isn't the bundled copy (for example Label: "release cache" with a FetchedAt set), stderr now ends with "so the list may be out of date." The old text was "so the content may be out of date." That reads oddly for a command that prints one skill, and it contradicts the description's "output and errors are unchanged". TestRunReadStaleCatalogWritesProvenanceToStderr (read_test.go:135) was changed to expect the new wording. Could the caller pass the noun in, or could the shared line use neutral wording like the bundled branch's "The skills may be out of date"?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in e0eb4bb. skills read keeps its own wording ("so the content may be out of date") for a stale cached catalog, so its old output and TestRunReadStaleCatalogWritesProvenanceToStderr are back to the original text. Only the bundled copy takes the shared neutral line, which claims no failed refresh.

Comment thread cmd/skills/list.go
if catalog.Label == libskills.BundledLabel {
return fmt.Sprintf("Skills come from %s (release %s). The skills may be out of date.", label, catalog.Version)
}
if catalog.FetchedAt.IsZero() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nit] The bundled copy now returns at line 85. Per Catalog.FetchedAt in skills.go, it is the only source with a zero fetch time, so this FetchedAt.IsZero() branch has no real input left. The test had to switch to a made-up "cached" label to reach it. The doc comment at lines 80-81 ("A bundled copy has no fetch time, so the line leaves it out") now describes the wrong branch. Should this branch go, or should the comment name the source it is kept for?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed in e0eb4bb. The bundled copy is the only source with a zero fetch time and it returns earlier, so the zero-time branch is gone, along with its made-up "cached" test. The doc comment now describes the bundled branch.

Comment thread libs/skills/resolve.go Outdated
// set.
// LocalCatalog returns the freshest catalog that needs no network call: the
// folder in DATABRICKS_SKILLS_DIR when it is set, otherwise the bundled copy.
// It returns nil when neither has skills. It follows Resolve, so the two agree

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nit] "It returns nil when neither has skills" isn't quite what happens. When DATABRICKS_SKILLS_DIR is set, the bundled copy is never consulted. A folder whose manifest lists no skills returns a non-nil empty catalog, not nil. Maybe: "It returns nil when no folder is set and the bundled copy has no skills."

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in e0eb4bb. The doc now reads "It returns nil when no folder is set and the bundled copy has no skills."

simonfaltum and others added 2 commits November 30, 2026 13:37
…int tests

Co-authored-by: Isaac <no-reply@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>

@rugpanov rugpanov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed head c232ab1.

Risk: LOW. The skills command group is hidden, and cmd/cmd.go:87 registers it only when DATABRICKS_SKILLS_PREVIEW is set. The committed snapshot is an empty manifest, so Resolve still returns ErrNoSource in released builds. The change affects only the source choice and the stderr provenance text of the preview commands, and a revert undoes it.

Pending checks at c232ab1: Integration Tests, task test (windows, direct), task test (macos, direct). No check failed.

The change does what the description says, and it stays behind the preview gate. The inline comments are not blocking.

Comment thread cmd/skills/list.go
if catalog.FetchedAt.IsZero() {
return fmt.Sprintf("Skills come from %s (release %s). The source could not be refreshed, so the list may be out of date.",
label, catalog.Version)
if catalog.Label == libskills.BundledLabel {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nice to have] provenanceLine now selects the wording by catalog.Label, not by catalog.FetchedAt.IsZero(). The Catalog.FetchedAt doc says that a zero time means "unknown" for any source. If a later source returns a stale catalog with a zero FetchedAt and another label, skills list and skills search print fetched 0001-01-01T00:00:00Z. No source does this today, but on main the IsZero() branch and TestProvenanceLineOmitsUnknownFetchTime prevented it. readProvenance in cmd/skills/read.go:140 has the same label check. Keep the bundled wording for BundledLabel, and also keep an IsZero() branch that leaves out the fetch time. Add back a test for a zero time with another label.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Restored an IsZero() branch in both provenanceLine and readProvenance so a non-bundled stale catalog with an unknown fetch time omits the fetch time, and added TestProvenanceLineOmitsUnknownFetchTime.

}

// FileSize forwards to the snapshot, so list-files reports sizes for it too.
func (s *bundledSource) FileSize(ctx context.Context, skill, file string) (int64, error) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nice to have] No test calls the new bundledSource.FileSize, and no test runs skills list-files on the bundled copy. If the empty-snapshot guard or the size forward breaks, CI does not find it. Add a case to TestBundledSourceFromFixture that calls FileSize on a file of the fixture skill. Also cover the empty snapshot.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a FileSize case to TestBundledSourceFromFixture and TestBundledSourceFileSizeEmptySnapshot for the empty snapshot guard.

Comment thread libs/skills/bundled_source.go Outdated
if _, err := s.Catalog(ctx); err != nil {
return 0, err
}
return s.src.(FileSizer).FileSize(ctx, skill, file)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nit] s.src.(FileSizer) has no ok check. It is safe today, because newBundledSource always sets src to the *fsSource from NewFSSource. If a later change wraps src in a Source without FileSize, skills list-files -o json panics on the bundled copy. Use the , ok form and return ErrNoSize when the assertion fails, or declare the field as *fsSource.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switched to the ok form and return ErrNoSize when the source has no FileSize.

…tion, test bundled FileSize

Co-authored-by: Isaac <no-reply@databricks.com>
@simonfaltum
simonfaltum added this pull request to the merge queue Nov 30, 2026
Merged via the queue into main with commit bfcdd1f Nov 30, 2026
27 checks passed
@simonfaltum
simonfaltum deleted the skills/rbund-skills-commands-serve-the-bundled-snapsh branch November 30, 2026 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants