Skip to content

Plugin repos' candy CI gate validates nothing (charly box validate at a plugin repo root scans an empty set) #459

Closed

Description

@atrawog

The gate

Every plugin repo's deploy.yml ends with:

      - name: The candy manifest validates at the pinned charly
        run: |
          /tmp/charly/bin/charly box validate

run from the repo root.

It validates nothing

A plugin repo has no project charly.yml, so discovery never reaches
candy/<name>/charly.yml. charly box validate scans an empty set and exits 0 on any
manifest.

Measured on opencharly/plugin-punktfunk with a binary built from charly
v2026.241.1535. Injecting a malformed provider class into the manifest:

-                - verb:punktfunk
+                - notaclass:punktfunk
$ cd <plugin repo root> && charly box validate
$ echo $?
0

The same manifest, staged under a project with a discover: block, fails correctly:

$ cd /tmp/validate && charly box validate
charly: error: command "validate": 2 validation errors:
  candy "plugin-punktfunk": CUE schema: ... 2 errors in empty disjunction:
    plugin: field not allowed
    plugin.providers.0: invalid value "notaclass:punktfunk" (out of bound =~"^(kind|deploy|verb|step|build|builder|command|loader|refs|agent-runtime|terminal):[a-z0-9][a-z0-9_-]*$")

Control: opencharly/plugin-vnc behaves identically at its own root, so this is the
template, not one repo.

Consequences

  1. A malformed plugin: block — a bad provider class, a missing source, an
    input_def the schema does not define — reaches main with a green candy check.
  2. The Go module is never built, vetted or tested in CI at all, which for a plugin repo
    is the actual substance.

Fix

Both halves, in the shared template:

      - name: The candy manifest validates at the pinned charly
        run: |
          mkdir -p /tmp/validate/candy
          cp -r candy/<name> /tmp/validate/candy/<name>
          printf 'version: <schema calver>\ndiscover:\n    - path: candy\n      recursive: true\n' > /tmp/validate/charly.yml
          cd /tmp/validate && /tmp/charly/bin/charly box validate

      - name: The plugin module builds, vets and tests
        run: |
          cd candy/<name>
          GOWORK=off go build ./... && GOWORK=off go vet ./... && GOWORK=off go test ./...

      - name: gofmt is clean
        run: |
          cd candy/<name>
          test -z "$(gofmt -l .)" || { gofmt -l .; exit 1; }

opencharly/plugin-punktfunk ships exactly this shape already and can serve as the
reference; the remaining plugin repos need the same treatment as one sweep.

Found while landing the punktfunk verb plugin
(opencharly/plugin-punktfunk#1).

Activity

  1. atrawog commented on Aug 29, 2026

    @atrawog
    ContributorAuthor

    Narrowed down: a plugin repo root is "project-less", so it takes a legacy fixture path

    The gate is empty only when there is no root charly.yml. Re-measured on a copy of
    opencharly/plugin-punktfunk with a binary built from v2026.241.1535+1:

    case root charly.yml manifest charly box validate
    A absent pristine exit 0
    B absent notaclass:punktfunk exit 0 ← gates nothing
    C present, discover: candy notaclass:punktfunk exit 1, correct CUE error

    C's error, for reference:

    plugin.providers.0: invalid value "notaclass:punktfunk"
      (out of bound =~"^(kind|deploy|verb|step|build|builder|command|loader|refs|agent-runtime|terminal):[a-z0-9][a-z0-9_-]*$")
    

    Where it comes from

    validate self-loads the project through loaderkit.LoadUnifiedViaExecutor, and
    plugin-box/validate_config_rules.go is explicit about the empty case:

    Returns (nil, nil, nil, nil) for a project-less directory (mirrors the empty-project
    contract every other resolve path honours) — the caller's rules then loop zero times.

    A plugin repo root has no charly.yml, so it is project-less by that contract, and
    scanLocalCandies falls through to legacyScanCandiesDirScanned, whose own doc comment
    says:

    Kept for test fixtures (and the migration tool) that don't yet have an charly.yml.

    So the 94 plugin repos are, unintentionally, being gated by a path meant for test fixtures
    — which is why a malformed plugin: block sails through.

    (Note charly box list candies is not a usable probe here: it filters plugin candies
    out of its output even in a project where they are unambiguously scanned. The
    malformed-manifest A/B/C table above is the reliable discriminator.)

    What the fix probably is

    Given the contract above, the honest fix is likely not to change project detection —
    it is that a plugin repo should be a project. A four-line root charly.yml:

    version: <schema calver>
    discover:
        - path: candy
          recursive: true

    makes the repo go through the real loader, and the existing stock deploy.yml gate
    starts working with no workflow change at all
    . That is a much smaller per-repo diff than
    rewriting 94 workflows, and it also makes the repo self-describing to charly locally.

    The alternative — making legacyScanCandiesDirScanned apply the CUE schema gate — would fix
    all 94 at once, but it changes the semantics of a path deliberately scoped to fixtures, so
    it needs a maintainer's call rather than a drive-by.

    Either way the Go module still needs gating: go build / go vet / go test / gofmt
    are absent from the stock template entirely, and for a plugin repo that is the substance.
    opencharly/plugin-punktfunk's deploy.yml carries a working version of both halves and
    can be copied.

    I have not implemented the org-wide rollout: 94 PRs (or a semantics change to a fixture
    path) is a maintainer-scale decision about CI load and blast radius, not something to
    unleash from a feature branch.

  2. atrawog commented on Aug 30, 2026

    @atrawog
    ContributorAuthor

    Root cause corrected, and the fix is proven

    My earlier comment guessed the legacy candy/ walk was skipping the CUE gate. That was
    wrong.
    The plain-layer probe disproves it: with no root charly.yml, charly scans no
    candies at all
    — not even a plain layer, which box list candies would otherwise show.

    # candy/plainlayer/charly.yml exists, no root charly.yml
    $ charly box list candies         # (nothing)
    $ charly box validate             # exit 0 even with a bogus field in the candy
    
    # after adding a 4-line root charly.yml with a discover: block
    $ charly box list candies
    plainlayer [testing]
    $ charly box validate
    ... notafield: field not allowed
    

    So the repo is simply project-less, exactly as plugin-box/validate_config_rules.go
    documents, and there is nothing to validate. The gate is not skipping a check — it has no
    input. (box list candies filters plugin candies out of its own output, which is why a
    plain layer was needed to see this.)

    The fix is per-repo, and it is four lines

    version: 2026.240.1943
    discover:
        - path: candy
          recursive: true

    That makes the stock charly box validate step work — no workflow change needed.

    Proven in opencharly/plugin-punktfunk#4: before it, a deliberately malformed
    - notaclass:punktfunk provider entry passed at the repo root; after it, the same manifest
    fails with the correct CUE error. That PR also reverts the staged-project workaround its
    deploy.yml carried, so the repo has one gate rather than two.

    Consumers are unaffected — the risk worth checking, since a consuming project might
    resolve the candy twice (once via the pinned subpath ref, once via the new discover:).
    Tested by injecting the root manifest into the fetched checkout that
    opencharly/distro-cachyos resolves for
    plugin-punktfunk/candy/plugin-punktfunk:v2026.241.1930, then validating that project both
    ways: identical result, exit 0 either way. The file declares no entities, so it changes what
    charly does in the repo and nothing about how the repo is consumed.

    Not the core fix. Making validate treat a candy/-bearing directory as a project was
    considered and rejected: "returns nil for a project-less directory" is a documented contract
    that other resolve paths rely on, so changing it to serve plugin repos would be a semantics
    change with a far wider blast radius than 95 four-line files.

    Scope, measured

    plugin repos: 98; needing a root manifest: 95
    

    98 non-archived, non-fork plugin-* repos; 3 already have a root manifest or ship no
    candy/ tree.

    Sweep

    I have a tested script that enumerates the org, skips repos that already have a root
    manifest or no candy/ dir, and opens one small PR each (list / dry / apply modes;
    list output above is real). Its per-repo body is:

    1. git clone --depth 1, branch fix/root-manifest-gates-the-candy
    2. write the four-line charly.yml above
    3. commit, push, gh pr create referencing this issue

    I have not run apply. 95 PRs into the org is a decision about CI cost and review load
    that belongs to a maintainer, not to a feature branch. Say the word and I will run it, or
    take the recipe above and run it yourself.

    Still worth doing separately

    The stock deploy.yml gates the manifest only — it never builds, vets or tests the Go
    module, which for a plugin repo is the substance. opencharly/plugin-punktfunk's deploy.yml
    carries go build / go vet / go test / gofmt -l and can be copied.

  3. 168 remaining items

  4. atrawog commented on Aug 30, 2026

    @atrawog
    ContributorAuthor

    Done — all 94 plugin repos now have a real candy gate

    Every non-archived, non-fork plugin-* repo carrying a candy/ tree now has a root
    charly.yml, so the stock charly box validate step in its deploy.yml actually scans its
    candy. No workflow changes were needed.

    Verified on main, all 94:

    correct stamp on main: 94 / 94
    bad stamp:  0
    no manifest: 0
    
    candy workflow on main — success: 94  failure: 0  other: 0
    

    Two things went wrong on the way, both fixed

    1. Wrong schema stamp (94 repos). The first pass stamped 2026.240.1943 (current HEAD),
    but these repos' deploy.yml pins charly v2026.238.1242, whose maximum supported schema is
    2026.232.0520. Every candy workflow began failing on main with
    config schema 2026.240.1943 is newer than this charly supports. I should have checked each
    repo's pinned toolchain instead of assuming HEAD. Corrected across all 94 — the stamp is now
    2026.232.0520, the value the peer candy repos already carry, verified against a binary
    built from that exact tag (it accepts 2026.232.0520, rejects 2026.232.0521 and
    2026.240.1943).

    2. Over-broad recursive: true (1 repo). In plugin-generate-packages the recursive walk
    descended into candy/generate-packages/testdata/charly.yml, a Go test fixture, which
    validate rightly rejected (no install content, no plan:). Fixed with recursive: false,
    which matches the plugin layout exactly — candy/<name>/charly.yml is found, nested fixtures
    are not (opencharly/plugin-generate-packages#9). It was the only repo of the 94 with a nested
    charly.yml.

    The gate is real, not merely quiet

    Checked per repo, under each repo's own pinned charly, by breaking its own first provider
    entry. Representative:

    $ charly box validate          # pristine
    exit=0
    
    $ # `- verb:tunnel` -> `- notaclass:tunnel`
    charly: error: command "validate": 2 validation errors:
      candy "plugin-tunnel": CUE schema: .../candy/plugin-tunnel/charly.yml:
      candy "plugin-tunnel": 2 errors in empty disjunction:
      plugin: field not allowed:
    

    Before the root manifest, that same malformed manifest exited 0.

    Still open, separately

    The stock deploy.yml gates the manifest only — it never builds, vets or tests the Go
    module, which for a plugin repo is the substance. opencharly/plugin-punktfunk's
    deploy.yml carries go build / go vet / go test / gofmt -l and can be copied; that is
    a second sweep and a separate decision, not part of this one.

    Two defects surfaced by this work are filed separately: #469 (a remote
    add_candy: ref silently dropping a candy's baked check: steps) and #471
    (plugin.primary: ignored for an @github-pinned candy). Both look like the same family —
    manifest-declared metadata surviving local discovery but not a remote ref.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions