Repository navigation
feat(kit): strict ledger enumeration that reports a malformed charly.yml - #184
Conversation
readLedger deliberately swallows a read/parse failure and yields an empty ledger. That is the right contract for callers which treat "no ledger yet" and "unreadable ledger" alike, and ListDeployIDs / ListCandyNames inherit it -- but it is the wrong contract for a user-facing command, which then prints "nothing deployed" for a file it simply could not parse. Add readLedgerStrict and the ListDeployIDsStrict / ListCandyNamesStrict variants: an ABSENT file is still not an error (nothing has been deployed on this host), only an unreadable or unparseable one is, and the message names the path and the cause. Found while migrating plugin-substrate onto the non-strict listers: its old code propagated a wrapped error from the candy path, so moving to ListCandyNames would have silently dropped that error path. Rather than accept the regression or keep a second YAML parser per consumer, give kit the contract the consumer actually needs. Tests pin both halves, including the discriminating contrast that the non-strict lister reports the same malformed file as merely empty. Claude-Session: https://claude.ai/code/session_01Gf42A3bau77JigFYLALrnq
Review — BLOCKHead SHA: Change class: code (additive library API — Blocks
Notes (non-blocking)
Verdict: BLOCK ollama/deepseek-v4-flash — pi-review-action. |
|
Block 1 is fair and is fixed — I asserted "full module suite and Block 2 I believe is mistaken, and I would rather point at the rulebook than quietly comply, because the requested change would move the footer away from the documented form.
The canonical example's parenthetical is So in this rulebook There is also direct precedent from this same validator today: opencharly/plugin-deploy-pod#2 passed with the byte-identical footer, and the PASS verdict called it out explicitly —
That is the same harness, the same model string, and the same parenthetical shape as here. I have therefore left the footer as-is. If the intent is genuinely to move the org to numeric confidences, that is a change to |
Review — PASSHead SHA: Security screen: PASS — additive library code; no secrets, no network/egress, no weakened guardrails, no scope mismatch; description accounts for every diff item. Checklist: All applicable rules PASS or NA. Prior reviewer blocks re-derived against CURRENT state:
Placement: CORRECT — strict listers extend the existing kind-blind ledger-enumeration mechanism in Verdict: PASS ollama/deepseek-v4-flash — pi-review-action. |
tag Validator findings on sdk#317: - The fallback test (TestVersionlessRefFallbackUsesCachedClient) only had its comment changed — its body still warmed/called LatestTag and asserted nothing. It now warms gitClient().DefaultBranch, runs CollectRemoteRefsOpts with the nil seam, and asserts the collected version is the DEFAULT BRANCH (non-empty, not a v-tag). - TestVersionlessRefUsesCachedDefaultBranch asserted mere non-emptiness; it now pins the SAME value the warm call returned. - Spec pin bumped to v0.2026271.743 (spec#184 merged: RefsCollectSeams.LatestTag removed; this PR drops its sole writer in the paired commit). Assisted-by: opencode ollama-cloud/deepseek-v4.1-flash (fully tested and validated)
…CH, not the latest tag (supersedes #317) (#318) * fix(loaderkit)!: version-less remote refs resolve to the DEFAULT BRANCH, not the latest tag A version-less remote candy ref (`@github.com/owner/repo`, no `:tag`) means "the current tip of that repo", so it must TRACK the default branch. Resolving it to the repo's newest tag silently served a STALE build whenever the repo had newer work on its default branch than on its last tag — and, worse, the stale tag's provider SHADOWED a project's own explicit pin for the same word: a bed that pinned a plugin to a branch was served the repo's old TAGGED build instead, so the pinned fix never ran (opencharly/charly#715 — cost many bed runs and a wrong RCA). The default branch is a MUTABLE ref, so it re-resolves per access (refs.IsMutableRef) and a stale export refreshes; a repo with no resolvable default branch errors loudly. The resolution goes through a package-level `resolveDefaultBranch` seam (defaulting to the cached gitClient().DefaultBranch), so it stays unit-testable offline. Tests updated to the corrected contract. Assisted-by: opencode ollama-cloud/deepseek-v4.1-flash (fully tested and validated) * refactor(loaderkit): drop the now-dead LatestTag seam writer The version-less resolution no longer uses seams.LatestTag; opencharly/spec#184 removes the field itself. Drop the sole writer here so the cutover carries no dead setter. (The spec pin bump to spec#184's tag lands once spec#184 merges, producer-first.) * fix(loaderkit): repair the versionless-ref tests + bump spec to the #184 tag Validator findings on sdk#317: - The fallback test (TestVersionlessRefFallbackUsesCachedClient) only had its comment changed — its body still warmed/called LatestTag and asserted nothing. It now warms gitClient().DefaultBranch, runs CollectRemoteRefsOpts with the nil seam, and asserts the collected version is the DEFAULT BRANCH (non-empty, not a v-tag). - TestVersionlessRefUsesCachedDefaultBranch asserted mere non-emptiness; it now pins the SAME value the warm call returned. - Spec pin bumped to v0.2026271.743 (spec#184 merged: RefsCollectSeams.LatestTag removed; this PR drops its sole writer in the paired commit). Assisted-by: opencode ollama-cloud/deepseek-v4.1-flash (fully tested and validated) * test(loaderkit): make the versionless tests actually gate the behavior Validator findings on sdk#317: - TestVersionlessRefUsesCachedDefaultBranch never called CollectRemoteRefsOpts; renamed to TestCachedDefaultBranchServesWithoutGit (it covers the client cache). - TestVersionlessRefFallbackUsesCachedClient: dropped the dead local-repo fixture, pinned the collected version to the warmed DefaultBranch value, marked LIVE-OR-SKIP. Assisted-by: opencode ollama-cloud/deepseek-v4.1-flash (fully tested and validated) * test(loaderkit): make the fallback test exercise the REAL changed path + sweep a stale comment sdk#318 BLOCK findings: - The fallback test did not run the changed path (it warmed a bare URL the resolver never uses, so the resolution fell to raw git). It now runs the REAL CollectRemoteRefsOpts to warm the cached default branch, installs a failing git shim, and re-runs — proving the changed resolution served the cache with no raw git, and pinning the resolved version to the warm value. Executed output: "Resolved @github.com/opencharly/plugin-deploy-vm -> main (default branch)". - refs_versionless_test.go: swept the stale "stub tag resolver" comment (R5). Assisted-by: opencode ollama-cloud/deepseek-v4.1-flash (fully tested and validated)
Summary
readLedgerdeliberately swallows a read/parse failure and yields an empty ledger. That is the right contract for callers which treat "no ledger yet" and "unreadable ledger" alike — andListDeployIDs/ListCandyNamesinherit it. It is the wrong contract for a user-facing command, which then prints "nothing deployed" for a file it simply could not parse.This adds the error-reporting twin:
An absent file is still not an error — nothing has been deployed on this host. Only an unreadable or unparseable one is, and the message names the path and the cause (
parse ledger <path>: …).Why this exists — found by getting it wrong
While migrating
plugin-substrateonto the non-strict listers (opencharly/plugin-substrate#4) I claimed the substitution was "behaviour-preserving by construction". It was not, and the review caught it. The old consumer code propagated a wrapped error from the candy path:Moving that to
kit.ListCandyNameswould have silently dropped the error path — a malformedcharly.ymlreported as "no candies" instead of as a parse failure. That is the same silent-wrong-answer shape the ledger relocation already produced once (os.Stat("")→ ENOENT → zero rows with a nil error), so accepting it would have been a regression I had spent the day arguing against.The consumer's error handling was also already asymmetric on
main— the deploys path swallowed its error (return reply, nil) while the candies path propagated it. Rather than preserve that asymmetry, keep a second YAML parser per consumer, or quietly drop the loud half, givekitthe contract the consumer actually needs so both paths can be uniformly loud.How tested
The first test carries the discriminating contrast — it asserts that the non-strict lister reports the very same malformed file as merely empty, which is the whole reason the strict variants exist. Without that assertion the tests would pass against an implementation that never distinguished the two cases.
Full module suite, uncached (
go clean -testcachefirst):go vet:go vetprints nothing on success, so the exit status is the evidence — included rather than an empty block, since a blank paste is indistinguishable from a command that was never run.Rulebook compliance
readLedgerStrictrather than duplicating the parse, and consumers no longer need a private YAML parser to get an error.main, no hook bypass.Change classification
go vet, with a discriminating test contrasting strict and non-strict behaviour on the same fixtureanalysed on a live system— the new paths are exercised by tests on real files including the malformed and absent cases, but this is library API with no runtime consumer until plugin-substrate#4 bumps its pin, so no disposable bed reaches it yet. Deliberately not claimingfully tested and validated.Assisted-by: Claude Code Anthropic Opus 5 (analysed on a live system)