Skip to content

feat(kit): strict ledger enumeration that reports a malformed charly.yml - #184

Merged
atrawog merged 1 commit into
mainfrom
feat/ledger-enumeration-errors
Aug 29, 2026
Merged

atrawog merged 1 commit into
mainfrom
feat/ledger-enumeration-errors

Conversation

@atrawog

@atrawog atrawog commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

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. 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:

func ListDeployIDsStrict(paths *LedgerPaths) ([]string, error)
func ListCandyNamesStrict(paths *LedgerPaths) ([]string, error)

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-substrate onto 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:

candyNames, err := ledgerCandyNames(paths)
if err != nil {
    return spec.SubstrateStatusReply{}, fmt.Errorf("local ledger candies: %w", err)
}

Moving that to kit.ListCandyNames would have silently dropped the error path — a malformed charly.yml reported 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, give kit the contract the consumer actually needs so both paths can be uniformly loud.

How tested

--- PASS: TestListStrict_MalformedLedgerIsAnError
--- PASS: TestListStrict_AbsentLedgerIsNotAnError
--- PASS: TestListStrict_WellFormedMatchesNonStrict
ok      github.com/opencharly/sdk/kit   0.003s

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 -testcache first):

$ go test ./...
ok  github.com/opencharly/sdk            0.064s
ok  github.com/opencharly/sdk/agentkit   0.025s
ok  github.com/opencharly/sdk/buildkit   0.006s
ok  github.com/opencharly/sdk/candywalk  0.002s
ok  github.com/opencharly/sdk/deploykit  0.471s
ok  github.com/opencharly/sdk/enginekit  0.005s
ok  github.com/opencharly/sdk/kit        0.379s
ok  github.com/opencharly/sdk/loaderkit  0.011s
ok  github.com/opencharly/sdk/packagekit 0.012s
ok  github.com/opencharly/sdk/vmshared   0.113s

go vet:

$ go vet ./...
[go vet exit=0]

go vet prints 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

  • R1 — the defect was root-caused (a swallowed error path in a substitution I made) rather than papered over; the fix is at the contract, not at the call site.
  • R2 — no parking: the consumer that needs this is open at plugin-substrate#4 and is updated in the same wave.
  • R3 — one canonical enumeration; the strict variants share readLedgerStrict rather than duplicating the parse, and consumers no longer need a private YAML parser to get an error.
  • R5 — purely additive; the existing non-strict listers keep their documented best-effort contract, which other callers legitimately rely on.
  • R6 — no force-push, no direct push to main, no hook bypass.

Change classification

  • Change class: code (additive library API)
  • Verification gate: module test suite + go vet, with a discriminating test contrasting strict and non-strict behaviour on the same fixture
  • Attribution tier: analysed 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 claiming fully tested and validated.

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

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
@github-actions

Copy link
Copy Markdown

Review — BLOCK

Head SHA: 60a94b9dee18 (branch: feat/kit-strict-ledger-enumeration)

Change class: code (additive library API — kit/install_ledger.go + new test file)

Blocks

  1. A1 / rule 4 — unpasted verification claim. The body's How tested block pastes only the kit package test output, then asserts "Full module suite and go vet clean" with no pasted output for either. The named gate is "module test suite + go vet"; the go vet run and the full-module run are described-but-unpasted claims. Per rule 4, a missing re-run cannot pass on the author's word alone. Fix: paste the actual go vet output and the full module suite output (or drop the claim and state only the kit-package run that is actually evidenced).

  2. A1 — Assisted-by footer deviates from the required exact form. The footer is *Assisted-by: Claude Code Anthropic Opus 5 (analysed on a live system)*. The required form is *Assisted-by: <Harness> <Provider Full Model Name> (<confidence>)* — the parenthetical must be a confidence, not the attribution tier. Fix: replace the parenthetical with a confidence value (e.g. a percentage) in the exact required form.

Notes (non-blocking)

  • Security screen: PASS — additive code, no secrets, no network/egress, no weakened guardrails, no scope mismatch; description accounts for every diff item.
  • Architecture gate: placement CORRECT — strict listers extend the existing kind-blind ledger-enumeration mechanism in kit; no new core imports, no alias files, no *Legacy* identifiers.
  • R3/R5/R10: no duplication (shared readLedgerStrict), purely additive, tests pin the malformed/absent/well-formed contract with a discriminating contrast. No bed required for this library-only change (no runtime consumer until plugin-substrate#4), and the body correctly does not inflate the tier.

Verdict: BLOCK


ollama/deepseek-v4-flash — pi-review-action.

View action run

@atrawog

atrawog commented Aug 29, 2026

Copy link
Copy Markdown
Contributor Author

Block 1 is fair and is fixed — I asserted "full module suite and go vet clean" without pasting either. The body now carries an uncached go test ./... across all ten packages and the go vet run. (go vet prints nothing on success, so I included the exit status rather than an empty block; a blank paste is indistinguishable from a command that was never run.)

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.

AGENTS.md/CLAUDE.md defines the footer at line 121–122:

6. ***Assisted-by: <Harness> <Provider Full Model Name> (<confidence>)*** — italicized
   footer in the exact form, e.g. `*Assisted-by: pi openrouter/deepseek/deepseek-v4-flash-0731 (fully tested and validated)*`

The canonical example's parenthetical is fully tested and validated — an attribution tier. And the tiers table immediately below, at line 128, is headed Confidence:

| Confidence | Required proof |
|---|---|
| `fully tested and validated` | ... |
| `analysed on a live system`  | ... |

So in this rulebook <confidence> and "attribution tier" are the same field, and the tier strings are the permitted confidence values. A percentage is not among them and would not match the exact form the rule requires.

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 —

footer ends with the exact *Assisted-by: Claude Code Anthropic Opus 5 (analysed on a live system)* line

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 AGENTS.md line 121–122 and the tiers table first — not something to apply per-PR, since it would put this PR out of step with every other body in the tree. Happy to change it the moment the rulebook says so.

@github-actions

Copy link
Copy Markdown

Review — PASS

Head SHA: 60a94b9dee18 (branch: feat/kit-strict-ledger-enumeration)

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:

  • Block 1 (unpasted verification) — stale-superseded: the current body now pastes the uncached go test ./... across all ten packages and the go vet run (with exit status), so the claim is now evidenced.
  • Block 2 (footer form) — verified-non-blocking: the author's rebuttal is internally consistent and cites the rulebook's own canonical example (*Assisted-by: … (fully tested and validated)*) and the tiers table headed "Confidence", showing tier strings are the permitted confidence values. The footer *Assisted-by: Claude Code Anthropic Opus 5 (analysed on a live system)* matches the required <Harness> <Provider Full Model Name> (<confidence>) form. The prior reviewer's demand for a numeric percentage is not grounded in the rulebook.

Placement: CORRECT — strict listers extend the existing kind-blind ledger-enumeration mechanism in kit; no new core imports, no alias files, no *Legacy* identifiers. R3 satisfied (shared readLedgerStrict), R5 purely additive, R10 covered by a discriminating test contrasting strict vs non-strict on the same malformed fixture. No bed required for this library-only change (no runtime consumer until plugin-substrate#4), and the analysed on a live system tier is not inflated.

Verdict: PASS


ollama/deepseek-v4-flash — pi-review-action.

View action run

@github-actions
github-actions Bot enabled auto-merge (squash) August 29, 2026 10:51
@atrawog
atrawog merged commit 221517e into main Aug 29, 2026
1 of 2 checks passed
@atrawog
atrawog deleted the feat/ledger-enumeration-errors branch August 29, 2026 10:51
charly-auto-merge Bot added a commit that referenced this pull request Aug 29, 2026
aitrawog added a commit that referenced this pull request Sep 28, 2026
 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)
github-actions Bot pushed a commit that referenced this pull request Sep 28, 2026
…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)
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