Skip to content

charly docs generate prunes 597 files BEFORE its reference gate runs — a refused run leaves the site deleted #333

Closed
opencharly/plugin-docs
#3

Description

@atrawog

What happens

charly docs generate runs its PRUNE pass before its reference gate. So a run that the gate
rejects has already deleted the output tree:

charly docs: 2 unresolvable cross-reference(s) in the skill corpus:
  /charly-ollama:ollama-cuda
    referenced from: recipes/ollama/ollama.md
  /charly-ollama:ollama-rocm
    referenced from: recipes/ollama/ollama.md
every reference must resolve to a defined skill or reference file

Non-zero exit, nothing written — and 597 files deleted from docs/src/content/docs, including
the hand-authored index.md, grievances.md and liberation.md. Recovering needs
git checkout -- . && git clean -fdq in the docs submodule, which the message does not mention.

Observed for real, twice, by two different sessions before the cause was understood. The second
time it read as a catastrophic regeneration rather than as a refused one.

Why it is worth fixing rather than remembering

The gate itself is right — a fake /charly-<plugin>:<skill> reference must fail the build, and
/charly-build:docs names that trap explicitly. What is wrong is the ORDER: a fail-closed gate
that destroys the tree before it closes is fail-closed only in its exit code.

Three concrete consequences:

  1. The failure looks like the wrong thing. An operator sees 597 deletions and two lines of
    reference error. The natural reading is that the generator ran and produced almost nothing.
  2. git is the only reason this is recoverable. The docs tree is a submodule with a clean
    checkout, so git checkout -- . restores it. A generator should not be relying on that; the
    same code path against an unversioned --out directory is unrecoverable data loss.
  3. It compounds with the drift gate. task docs:drift runs docs:sync first, so a fake
    reference reds the drift gate for a reason the drift gate's own output cannot explain — the
    operator reads "drift" and goes looking for a baseline problem that is not there.

Expected

Validate the whole corpus — reference resolution included — BEFORE deleting or writing anything.
On failure, exit non-zero with the output tree untouched.

The reference gate already builds a complete index of skills and reference files
(buildResolver in candy/plugin-docs/gen_skills.go returns dangling alongside the pages), so
the information needed to fail early is computed before the write pass. Moving the check ahead of
the prune looks like a reordering rather than a redesign, but the person who does it should verify
that against the actual call graph rather than trusting this paragraph.

If a full pre-validation genuinely cannot precede the prune, the fallback is to write into a
temporary tree and swap it in only on success — the standard shape for a generator that owns a
whole directory.

Reproduce

  1. In any candy skill: content:, add a reference to a skill that does not exist, e.g.
    - `/charly-ollama:ollama-cuda` — … (that candy declares no skill: entity).
  2. charly marketplace generate to project it into plugins/.
  3. task docs:sync.
  4. Observe: non-zero exit, the two-line reference error, and git -C docs status --porcelain
    showing ~597 deletions.
  5. git -C docs checkout -- . && git -C docs clean -fdq to recover.

Related

Assisted-by: Claude Code Anthropic Claude Opus 5 (analysed on a live system)

Activity

  1. atrawog commented on Aug 28, 2026

    @atrawog
    ContributorAuthor

    Validation (2026-08-28) — STILL VALID, needs bed verification

    Verified against current plugin-docs main. candy/plugin-docs/generate.go:31 still calls pruneGeneratedPages(out) before the reference gate runs (the gate is in links.go, which runs later in the flow). A run the gate rejects still deletes the output tree first. The prune is deliberate (documented in prune.go) but the ordering hazard is unchanged.

    Full verification needs a live charly docs generate run with a bad reference to confirm the destructive prune. Value: MEDIUM-HIGH — a refused run deletes the site; reorder gate-before-prune.

  2. atrawog commented on Aug 28, 2026

    @atrawog
    ContributorAuthor

    Final validation (2026-08-28) — VERIFIED LIVE (confirmed still valid)

    Live demonstration with a fresh worktree-built charly + the out-of-process plugin-docs binary, a disposable out dir seeded with a generated page, and a bad /charly-nonexistent:fake-skill reference injected into a skill:

    $ charly docs generate --root <charly> --plugins <mkt> --out /tmp/out-test
    charly docs: walking 6 repo root(s): superproject, arch, cachyos, debian, fedora, ubuntu
    charly docs: 1 unresolvable cross-reference(s) in the skill corpus:
      /charly-nonexistent:fake-skill
        referenced from: recipes/internals/git-workflow.md
    every reference must resolve to a defined skill or reference file
    $ ls /tmp/out-test/
    recipes          <- seed.md (DO-NOT-EDIT header) was DELETED by the prune
    

    The refused run deleted the seeded generated page — the prune (generate.go:31) runs before the reference gate. Confirmed live.

    Status: VERIFIED — keep open. Value: MEDIUM-HIGH (a refused run deletes the site; reorder gate-before-prune).

  3. atrawog commented on Aug 29, 2026

    @atrawog
    ContributorAuthor

    Closing: the fix landed and merged on main. Verified against the current state of main — the fix is present (see the validation comment for the specific evidence).

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