Skip to content

feat(plugin): registry discovery — search, info, and a generated index - #451

Merged
scttfrdmn merged 2 commits into
mainfrom
feat/plugin-discovery-index
Jul 29, 2026
Merged

scttfrdmn merged 2 commits into
mainfrom
feat/plugin-discovery-index

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Closes the discovery half of #448.

The problem

Resolution could already answer "fetch me the plugin named X." Nothing could answer "what plugins exist?" — you had to know a name in advance, from the registry README or word of mouth. Worse, a typo and a plugin that had never been written were indistinguishable: both surfaced as an identical 404.

What this adds

spawn plugin search [query] — lists the official registry, matching the query against names and descriptions, name hits first. Flags a plugin that wants root, since that's the most consequential thing about a plugin you haven't installed yet.

NAME                      VERSION  DESCRIPTION
cloudwatch-agent          v1.0.0   Install and start the Amazon CloudWatch agent... [root]
jupyterlab                v1.0.0   Install and start JupyterLab for browser-based notebooks... [root]
tailscale                 v2.1.0   Join the instance to your Tailscale network... [root]

  index: spore-host/spore-plugins, generated 14h ago
  install: spawn plugin install <name> --instance <id>

spawn plugin info <name> — version, description, config keys with required ones marked, and declared capability surface. Suggests near-matches on a miss, which is the other half of what the index is for (plugin info jupyter → "did you mean: jupyterlab").

It only prints a capability line the spec actually declared. Silence means "not declared" — printing root: no for a plugin whose spec omits permissions would assert something the spec never said.

spawn plugin gen-index (hidden) — the generator, in the same arrangement as spawn plugin manifest: it lives here, and the registry's CI invokes it. That way the index is derived by the same ParseSpec the installer uses and cannot describe a spec differently from the spec itself, and spore-plugins' CI keeps its rule of never reimplementing spec logic. --generated-at takes the commit time, so regenerating an unchanged registry is byte-identical and CI commits no churn (there's a test for that; config params come from a map, so it was a real risk).

Design notes

  • The index is derived, never hand-maintained. A spec that fails to parse is a hard error rather than a skipped entry — a silently omitted plugin reads as "that plugin doesn't exist", which is the exact failure mode this PR exists to fix.
  • Caching is honest about age. 6h TTL under ~/.spawn/cache, served when the network is unreachable rather than failing, so plugin search works on a plane. But every listing prints its provenance and age, and the offline fallback warns explicitly. A cached index that is merely old is useful; one that silently pretends to be current is not.
  • Nothing here is a security boundary. Install independently fetches and verifies the real plugin.yaml. A poisoned cache can at worst misdescribe a listing — never cause different code to run.

Scope: official registry only, deliberately

officialSigSANRegex in pkg/plugin/signature.go pins signature verification to the spore-plugins release workflow's OIDC identity. A third-party plugin therefore cannot be signature-verified as spawn is currently built. So a third-party index entry could never be backed by the trust signal a verified field implies, and listing one would make `verified: false` an endorsement with nothing behind it. Deferred as a separate decision, not overlooked — it needs a trust model first (PR review, commit-SHA pinning, or a distinct third-party signing path).

Also: registry URLs are now pinned by tests

Found while working on the resolution path. The official registry keeps specs at `plugins//plugin.yaml`; a third-party `github:` repo keeps `/plugin.yaml` at its root. The existing provenance test asserted `strings.HasSuffix(path, "/demo/plugin.yaml")` — which passes for both layouts, so neither was actually pinned and a regression in either would have surfaced only as an install-time 404 in the field.

Tightened that assertion to an exact path and added registry_specpath_test.go covering both layouts, the versioned-tag path ([email protected] → fetched at the demo-v1.0.0 tag, not main), and traversal rejection — including that validation happens before any request is issued.

One small behavior fix falls out: component validation now runs ahead of the "installing plugin from unverified source" warning, so a ref we're about to reject is no longer announced as one we're installing.

Verification

  • Full make check green; the lint findings printed are pre-existing in files this PR doesn't touch (cmd/bot.go, cmd/launch_preflight.go, pkg/aws/windows_password.go).
  • Generator run against all 12 real plugins in the spore-plugins checkout; two runs with a fixed --generated-at produced byte-identical output.
  • Exercised the CLI end-to-end against that generated index: search (all / query / no-match), info (hit / typo / nonexistent), --output json on both, and the offline stale-cache fallback (which correctly reported cache age 209d separately from index generation time). The primed cache was removed afterward; no residue.
  • No AWS resources involved — discovery is registry-only and launches nothing.

Follow-up

index.json doesn't exist upstream yet, so until the companion spore-plugins PR (index workflow + initial index) lands, these commands report that the registry hasn't published an index and point out that installing by name still works. That PR comes next, since its CI consumes a released spawn binary.

@codecov

codecov Bot commented Jul 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 45.83333% with 221 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cmd/plugin_search.go 17.74% 153 Missing ⚠️
pkg/plugin/indexcache.go 54.03% 42 Missing and 15 partials ⚠️
pkg/plugin/index.go 88.04% 7 Missing and 4 partials ⚠️

📢 Thoughts on this report? Let us know!

@scttfrdmn

Copy link
Copy Markdown
Contributor Author

Trivy fails here for CVE-2026-56852 in golang.org/x/text, which is unrelated to this PR — it touches no go.mod. The advisory was published after main's last green Security run and fails on every branch.

Fixed separately in #452 (all green). Once that merges, rebasing this branch clears the failure. Every other check here passes: Test, E2E Tier 0, Semgrep, gitleaks, Go Vulnerability Check, codecov/patch.

…index

Closes the discovery half of #448. Resolution could already answer "fetch the
plugin named X", but nothing could answer "what plugins exist": you had to know
a name in advance, and a typo was indistinguishable from a plugin that had never
been written, since both surfaced as a 404.

- `spawn plugin search [query]` lists the official registry, matching names and
  descriptions, and flags a plugin that wants root before you install it.
- `spawn plugin info <name>` shows version, description, config keys (marking
  required ones), and declared capability surface, suggesting near-matches on a
  miss. It only prints a capability line the spec actually declared — silence
  means "not declared", never "declares no root".
- `spawn plugin gen-index` (hidden) is the generator, in the same arrangement as
  `spawn plugin manifest`: it lives here and the registry's CI invokes it, so the
  index is derived by the same parser that installs plugins and cannot describe a
  spec differently from the spec itself. `--generated-at` takes the commit time so
  regenerating an unchanged registry is byte-identical and CI commits no churn.

The index is cached under ~/.spawn/cache with a 6h TTL, and served when the
network is unreachable rather than failing — but every listing prints where it
came from and how old it is, and an offline fallback warns explicitly. A cached
index that is merely old is useful; one that silently pretends to be current is
not. Nothing here is a security boundary: install independently fetches and
verifies the real plugin.yaml, so a poisoned cache can at worst misdescribe a
listing, never cause different code to run.

Scope is the official registry only. Signature verification is pinned to the
spore-plugins release workflow's OIDC identity (officialSigSANRegex), so a
third-party entry could never be backed by the trust signal a `verified` field
implies, and listing one would make `verified: false` an endorsement with
nothing behind it. Deferred deliberately, not overlooked.

Also pins resolved registry URLs by test. The official registry keeps specs at
plugins/<name>/plugin.yaml while a third-party github: repo keeps <name>/plugin.yaml
at its root; the existing provenance test matched a suffix both layouts satisfy,
so neither was pinned and a regression would have surfaced only as an
install-time 404. Tightened that assertion and added exact-path coverage for both
layouts, the versioned-tag path, and traversal rejection. Moving component
validation ahead of the unverified-source warning also stops a ref we're about to
reject from being announced as one we're installing.
`gen-index` was Hidden, which made it undetectable: cobra falls through to
`plugin --help` for an unknown subcommand and exits 0, so a registry CI probing
`plugin gen-index --help` to decide whether the released spawn supports it would
get a pass from a binary that doesn't. Caught by the companion spore-plugins PR,
whose guard passed and then failed on `unknown flag: --source`.

Unhiding also matches `plugin manifest`, the other registry-side generator
invoked by that repo's CI, and gives the probe something to grep for — the same
technique lint.yml already uses to detect `validate --strict`.
@scttfrdmn
scttfrdmn force-pushed the feat/plugin-discovery-index branch from b630ed0 to a7a6534 Compare July 29, 2026 17:11
@scttfrdmn
scttfrdmn merged commit 6dae99b into main Jul 29, 2026
7 checks passed
@scttfrdmn
scttfrdmn deleted the feat/plugin-discovery-index branch July 29, 2026 17:15
scttfrdmn added a commit to spore-host/spore-plugins that referenced this pull request Jul 29, 2026
* feat(index): publish a generated discovery index

Adds index.json — the manifest `spawn plugin search` and `spawn plugin info`
read — plus the CI that keeps it current. Registry half of spore-host/spawn#448;
the commands themselves are spore-host/spawn#451.

The index is derived from the specs by `spawn plugin gen-index`, never
hand-edited, so it cannot describe a plugin differently from its plugin.yaml.
As with lint.yml, spawn is the single source of truth for spec rules and this
workflow reimplements none of them.

index.yml regenerates on any push touching plugins/*/plugin.yaml and commits the
result back to main. On a pull request it checks the committed index instead of
pushing — a fork can't push, and a spec change should be reviewed together with
the index entry it produces.

generatedAt is stamped from the last commit to a SPEC, not from HEAD or from
"now". HEAD would be circular: committing the index moves HEAD, which changes the
stamp, so the index could never be current with itself and every run would commit
a no-op diff. Keying off the specs makes generation idempotent — verified here by
regenerating twice for byte-identical output, and the committed index carries the
stamp the workflow will compute, so its first run finds nothing to do.

Docs: README gains a "Finding a plugin" section pointing at the commands, since
its hand-kept table lists 4 of the 12 plugins here and that drift is what a
generated index removes. AUTHORING gains the mapping from spec fields to what
discovery shows, because description, config types/required, and
permissions.instance.{root,ports} are now user-facing before install — and a spec
that omits permissions shows nothing rather than "needs nothing", so declaring
them accurately is how users get an honest picture.

* fix(index): probe for gen-index by grepping plugin help

`gen-index --help` is not a usable capability probe: on a spawn that lacks the
subcommand, cobra falls through to `plugin --help` and exits 0, so the guard
passed against a binary that then failed on `unknown flag: --source`.

Grep the parent help instead, as lint.yml already does for `validate --strict`.
Verified against the currently released spawn (v0.36.12): the probe correctly
reports no support and fails fast with the actionable message.
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.

1 participant