Skip to content

docs: correct two comments asserting the removed directory: field - #117

Merged
atrawog merged 3 commits into
mainfrom
feat/directory-comment-sweep
Aug 3, 2026
Merged

atrawog merged 3 commits into
mainfrom
feat/directory-comment-sweep

Conversation

@atrawog

@atrawog atrawog commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary of changes

Two Go comments in this repo asserted a directory: candy field that does not exist. Comment-only; zero executable lines changed.

  • loaderkit/finalize_candy.go:62 — said candy_file globbing "honors directory:". It is anchored at the candy's scanned SourceDir; there is nothing to honor.
  • deploykit/candy_stage.go:26 — called the non-default-SourceDir branch a "directory: override".

Review round 1 blocked my first replacement of the second one as differently-wrong, and was right. I wrote that the branch fires for "a remote (@github) or submodule-vendored candy". It cannot: CandyCopySource early-returns on if layer.GetRemote() as its first statement, and loaderkit/scan_candy.go sets Remote unconditionally on the @github fetch path — so remote candies return .build/_candy/… and never evaluate that branch. Submodule-vendored candies arrive via @github import pins, so they are remote by the same route. I had corrected a false comment with a plausible-sounding replacement I had not traced.

What actually reaches it is a local candy whose SourceDir is not <root>/candy/<ref> — an inline candy takes its declaring charly.yml's directory as SourceDir (scanFromParsed), and a discover: entry can point somewhere other than candy/. The comment now says that, with a deliberately partial enumeration rather than a list I cannot defend.

Change class

docs-only (Go comments).

How R10-tested — exact gate, commands, and pasted output

  • The gate for this change class: non-runtime standards — the premise re-derived from source, a compile + test check, the comment-only proof, and the per-submodule R5 sweep.
  • Eval beds run: N/A (comment-only; no code path changes).
  • Fresh rebuild: N/A (no binary built from this repo).
  • Did the CHANGED code path execute live? N/A — no code changed. The branch's reachability was traced statically and is the subject of the fix.
  • Concurrency: N/A.
$ GOWORK=off go build ./... ; echo "exit=$?"
exit=0

$ GOWORK=off go test ./deploykit/... ./loaderkit/...
ok  	github.com/opencharly/sdk/deploykit	0.442s
ok  	github.com/opencharly/sdk/loaderkit	0.007s

$ git diff --stat origin/main...HEAD
 deploykit/candy_stage.go    | 7 ++++++-
 loaderkit/finalize_candy.go | 2 +-
 2 files changed, 7 insertions(+), 2 deletions(-)

$ git diff -U0 origin/main...HEAD | grep -E "^[+-]" | grep -v "^[+-][+-]" | grep -vE "^\s*[+-]\s*//"   # non-comment lines
(no output = comment-only)

Attribution tier

documentation reviewed — the diff is entirely comments, proven above by the non-comment-line filter returning nothing.

Harness rulebook compliance

  • R0 skills: /charly-internals:plugin, /charly-image:layer, /charly-internals:git-workflow.
  • R1 RCA + zero warnings: the four stale comments were found because a reviewer re-ran a sweep I had scoped to *.md, which cannot match a Go comment by construction. The root cause was the scope. The round-1 finding here was likewise root-caused (early return on GetRemote()) rather than reworded.
  • R2 no out-of-scope: this repo had no open leg; rather than deferring its two hits, this PR exists so all four land together.
  • R3 / R4: N/A — nothing executable.
  • R5 hard cutover + grep: whole-tree per-submodule sweep (git grep does not cross gitlinks) shows only negating references surviving — the loader's hard-error string, plugin-box's "was removed", this file's "Not a directory: redirect", and the skill documenting the removal — plus Traefik's unrelated directory: file-provider key and … directory: error strings.
  • R6 git safety: branch off the merge base, git status checked, commits appended, no force-push.
  • R7–R10: N/A — comment-only; no runtime path; no bed applies.
  • RDD / ADE / SDD: RDD — the field's absence and the branch's reachability were both proven from source rather than assumed; round 1 is the case study in what happens when they are not.
  • Kernel/plugin boundary law: N/A.
  • CHANGELOG: none — a comment-only sweep with no behaviour or API surface has nothing to record; the narrative lands in the charly and plugins entries. Round 1 confirmed this is acceptable here.

Cross-repo landing order

docs#2 merged (v2026.215.1210). This PR and plugins#119 are independent; charly#203 lands last. charly#203 pins no sdk commit from this branch, so this merge orphans nothing.


Assisted-by: Claude Code Claude Opus 5 (documentation reviewed)

Review of the sibling plugins PR ran a whole-tree sweep and found four live
present-tense comments still describing a `directory:` candy field that does not
exist - it is absent from spec/schema/candy.cue, from the generated spec types
and from the loader, and charly/layers.go hard-errors on it. Two of the four are
here.

candy_stage.go called the non-default-SourceDir branch a "directory: override".
The branch is real but the attribution is not: SourceDir differs from the default
for remote (@github) and submodule-vendored candies, never a redirect field.

finalize_candy.go said candy_file globbing "honors directory:". It is anchored at
the candy's scanned SourceDir; there is nothing to honor.

Comment-only; no behaviour change.

Assisted-by: Claude Code Claude Opus 5 (documentation reviewed)
@atrawog

atrawog commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

Verdict: CHANGES REQUESTED

Fresh evaluator; I authored none of this and verified every claim independently. The premise is sound and one of the two comments is correct — but the candy_stage.go replacement is factually wrong, in exactly the "differently-wrong" way that motivated this PR.


PASS — the premise (verified independently, not taken from the body)

The directory: candy field genuinely does not exist. Re-derived from source:

  • spec/schema/candy.cue — the only directory hit is working_directory? (line 167), a service field. No candy-level directory: in any spec/schema/*.cue.
  • No yaml:"directory" struct tag anywhere (per-submodule sweep over . spec sdk plugins box/*).
  • No .Directory field read or Directory struct field in any Go file, any submodule.
  • charly/layers.go:364 hard-errors in rejectLegacyCandyKeys: candy manifest uses the removed `directory:` field — the candy directory is implicit.
  • No charly.yml uses it. (The one YAML hit, candy/traefik/traefik.yml:21, is Traefik's own dynamic-config directory: — unrelated.)

So both original comments were wrong and correcting them is right.

PASS — loaderkit/finalize_candy.go:62

// Check candy_file (anchored at the candy's scanned SourceDir) is accurate. The code globs filepath.Join(sc.Model.SourceDir, pattern), and SourceDir is set at loaderkit/scan_candy.go:112 to the scanned dir, documented at scan_candy.go:51 as "the charly.yml's own directory". Correct as written.

PASS — comment-only, compiles, sweep clean

  • git diff main...71d5af5 changes 2 files, +4/-2, all comment lines. Zero executable lines.
  • GOWORK=off go build ./... → exit 0. GOWORK=off go test ./... → exit 0, no failures.
  • R5 sweep, whole-tree and per-submodule, no file-type filter, over . spec sdk plugins box/*: every surviving `directory:` reference is negating or historical (charly/layers.go's error string, candy/plugin-box/validate_rules.go:98 "was removed", the two CHANGELOGs, the docs-site skill, and this PR's own parenthetical). No live assertion survives.
  • Template sections all present; Assisted-by: Claude Code Claude Opus 5 (documentation reviewed) is well-formed, and documentation reviewed is the right tier for a comment-only diff.

BLOCKING — deploykit/candy_stage.go:26 is inaccurate

The new comment:

// SourceDir differs from the default candy dir — a remote (@github) or submodule-vendored
// candy — so resolve it relative to the build root. (This is NOT a `directory:` redirect:
// that field was removed and is now a hard load error, charly/layers.go.)

A remote (@github) candy can never reach this branch. Nine lines above, CandyCopySource returns early:

if layer.GetRemote() {
    return ".build/_candy/" + CandyStageDirName(layer)
}

GetRemote() is a.v.Remote (deploykit/spec_candy_adapter.go:52), and Remote is set at exactly two production sites, both of which mark remote candies:

  • sdk/loaderkit/scan_candy.go:90 — ScanRemoteCandy, the explicit @github fetch path, sets v.Remote = true unconditionally.
  • charly/unified.go:327 — a from:-directory candy whose resolved path falls outside the project root is also marked Remote.

So every @github candy early-returns at the staged .build/_candy/ path and never evaluates the filepath.Rel branch the comment annotates.

Proven, not just read — a temporary probe against the real CandyCopySource (removed again; tree is clean):

=== RUN   TestValidatorProbeRemoteNeverReachesRelBranch
    remote  (@github, non-default SourceDir) -> ".build/_candy/cuda.2026.167.1200"
    local   (non-default SourceDir)          -> "box/fedora/candy/vendored"
    inline  (SourceDir == project root)      -> "."
--- PASS

The remote candy was constructed with a non-default SourceDir (/home/u/.cache/charly/repos/...) — precisely the shape the comment attributes to this branch — and still took the early return.

This is the same defect class the PR sets out to fix: a plausible-sounding attribution that the code does not support. Per R1, a comment asserting behaviour the code does not have is a divergence regardless of whether it names a removed field.

What actually reaches the branch

A local (non-Remote) candy whose scanned SourceDir is not <projectDir>/candy/<ref>:

  • an inline candy declared in a charly.yml — ScanInlineCandy(name, rootDir, …) sets SourceDir to the declaring file's directory, so filepath.Rel yields "." (the probe's third line);
  • a from:-directory candy pointing at another in-tree directory (charly/unified.go:300-330), staying inside the project root — outside it, Remote is set and it early-returns;
  • a discover: path override placing candies somewhere other than candy/<name>.

That framing also explains the strings.HasPrefix(rel, "..") guard on line 30: out-of-root candies are already Remote, so the guard is a defensive fallback rather than the primary path — which the current comment's "remote" wording actively obscures.

Note "submodule-vendored" is doubtful too, at least for this project: charly.yml discovers only path: candy, and the distro submodules are reached through @github import pins (arch/cachyos/fedora), i.e. as remote candies — early return again. If a submodule-vendored local candy is a real supported shape, it needs a concrete in-tree example; otherwise drop the phrase.

Suggested replacement, sticking to what the code supports:

// A LOCAL candy scanned from somewhere other than the default candy/<ref> dir —
// an inline candy (SourceDir is its declaring charly.yml's dir), a `from:` directory
// candy, or a `discover:` path override — so resolve it relative to the build root.
// (Remote candies never get here: they return .build/_candy/ above, and an out-of-root
// `from:` candy is marked Remote too, charly/unified.go. This is NOT a `directory:`
// redirect: that field was removed and is now a hard load error, charly/layers.go.)

Non-blocking, but worth fixing in the same push

The evidence block is formatted as a terminal transcript yet is partly composed rather than pasted. $ GOWORK=off go build ./... is followed by a hand-written build exit: 0 (a successful go build prints nothing), and the per-submodule sweep's "output" is a prose parenthetical, not the command's real output. I re-ran both and the underlying claims are true — so this is a presentation defect, not a false claim. Still, given round 1 of the sibling PR failed for exactly this, please paste real output.

Confirmed as raised — not findings

  • No CHANGELOG entry: acceptable. This repo's CHANGELOG/ records releases, and a comment-only sweep with no behaviour change and no schema/API surface has nothing to record; the narrative lands in the charly and plugins entries. Not a gap.
  • No bed: correct. Nothing executable changed; the documentation-only class runs the non-runtime standards, which I re-ran above.
  • Tag scheme: noted; unused, since I am not merging.

Fix the candy_stage.go comment and push a fix commit to feat/directory-comment-sweep (do not force-push or recreate the PR) — the status resets and I will re-run.

atrawog added 2 commits August 3, 2026 14:38
Review blocked the first replacement as differently-wrong, and it was right. I
said the non-default-SourceDir branch fires for "a remote (@github) or
submodule-vendored candy". A remote candy can never reach it: CandyCopySource
early-returns on `if layer.GetRemote()` as its FIRST statement, nine lines above,
and loaderkit/scan_candy.go sets Remote unconditionally on the @github fetch
path. Submodule-vendored candies arrive through @github import pins too, so they
are remote by the same route and also return early.

I traded one wrong story for another - correcting a false comment with a
plausible-sounding replacement I had not traced.

What actually reaches the branch is a LOCAL candy whose SourceDir is not
<root>/candy/<ref>: an inline candy takes its declaring charly.yml's directory as
SourceDir (scanFromParsed), and a discover: entry can point somewhere other than
candy/. The comment now says that, and the enumeration is deliberately partial
rather than a list I cannot defend.

loaderkit/finalize_candy.go was verified accurate as first written and is
unchanged.

GOWORK=off go build ./... exit 0; go test ./deploykit/... ./loaderkit/... pass;
diff is comment-only (zero executable lines).

Assisted-by: Claude Code Claude Opus 5 (documentation reviewed)
@atrawog
atrawog merged commit 9ab0ce9 into main Aug 3, 2026
@atrawog
atrawog deleted the feat/directory-comment-sweep branch August 3, 2026 12:52
atrawog added a commit that referenced this pull request Aug 3, 2026
…es, cloud-init provisioning fixes

Relocate the sdk import-purity leg of #55: value types (ResolvedBox, BundleConfig,
ledger records, CloudInitRuntimeParams, the matcher/capability engine) move to
CUE-sourced spec/spec, with thin re-export aliases kept in sdk so the 85+
out-of-tree plugin candies compile unchanged during the migration window.
Engine test suites relocate from charly to sit beside the engines they prove
(deploykit, kit, loaderkit). The cloud-init provisioning chain switches to a
scoped pacman refresh (-Sy --needed) plus an idempotent sshd try-restart
guard, replacing a full -Syu that destabilized live VM guests.

Chain: spec#13 (merged v0.2026215.1748) -> sdk (this PR) -> plugins#123 /
pkg-arch#6 (both merged) -> charly#204 (the super terminus, open, depends on
this merge).

Round-1 pr-validator FAIL (a live unparam finding in a newly-added test file,
deploykit/effective_version_test.go) fixed by dropping the dead
spec.CandyView parameter from newTestCandy across all 4 call sites; verified
independently on a fresh clone with an isolated golangci-lint cache: 0
issues. Full module gate (go build/vet/test, gofmt, golangci-lint) re-run
green by two independent validator passes (pre- and post- gh pr
update-branch, empty file overlap with the concurrent #117 doc fix).

Assisted-by: Claude Code Claude Fable 5 (analysed on a live system)
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