Skip to content

fix(kit): tolerate an absent substrate ledger on a first deploy into a fresh VM - #343

Merged
github-actions[bot] merged 1 commit into
mainfrom
fix/ledger-notfound-342
Oct 4, 2026
Merged

github-actions[bot] merged 1 commit into
mainfrom
fix/ledger-notfound-342

Conversation

@aitrawog

@aitrawog aitrawog commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary

AddCandyDeploymentVia and WriteDeployRecordVia (kit/install_ledger.go) returned exec.GetFile's error verbatim, so a fresh guest — where ~/.config/charly/charly.yml legitimately does not exist yet — hard-failed the first charly deploy add into a newly created VM:

charly: error: command "deploy": deploy-dispatch add: deploy plugin: deploy-dispatch: venue ledger deploy record: ssh cat ~/.config/charly/charly.yml: exit status 1 (stderr: cat: /home/arch/.config/charly/charly.yml: No such file or directory)

The absence is not an error by this package's own design: mutateRemoteLedger documents that the substrate bytes "may be empty/absent" and builds a fresh document when they are, and the mkdir -p ~/.config/charly && cat > … write path creates the file. The guard returned before that tolerance was ever reached.

Both Via guards are narrowed to the not-found case. Every other read failure — permission denied, a broken channel, a substrate charly.yml that is not a mapping — still propagates, because treating those as "absent" would let the caller overwrite a file it could not read.

The classifier is not new — it is unified

kit already carried the classifier as the unexported isNotFound (kit/walk.go), behind the same if err != nil && !IsNotFound(err) shape, serving the env.d managed-block read. This change exports it as kit.IsNotFound and makes it the one canonical classifier:

Site Before After
kit/walk.go (2 reads) isNotFound IsNotFound
kit/install_ledger.go (2 guards) if err != nil { return err } if err != nil && !IsNotFound(err) { return err }
deploykit/artifact_retrieve.go (3 optional: sites) local isMissingArtifactFile kit.IsNotFound — local copy deleted

kit.IsNotFound keeps every text form the deleted copy matched (No such file or directory, cannot access, not found) and adds the bare no such file form, so the artifact optional: behaviour is unchanged; and it uses errors.Is(err, fs.ErrNotExist) in place of os.IsNotExist, which is a strict superset (a wrapped not-found now counts too).

How tested

All output below is from the committed tree (1562bfd993f97432d4dd77d85d30b6b8bcc5419f, git status clean) — R10.

1. The sdk repo's full gate set (sdk/AGENTS.md)

### gofmt -l .
### go vet ./...
vet_exit=0
### go test ./... (cold)
ok  	github.com/opencharly/sdk	0.260s
ok  	github.com/opencharly/sdk/agentkit	0.543s
ok  	github.com/opencharly/sdk/buildkit	0.012s
ok  	github.com/opencharly/sdk/candywalk	0.009s
ok  	github.com/opencharly/sdk/charlylib	0.014s
ok  	github.com/opencharly/sdk/checkkit	0.009s
ok  	github.com/opencharly/sdk/cmd/charly-lib-gen	0.007s
ok  	github.com/opencharly/sdk/deploykit	10.297s
ok  	github.com/opencharly/sdk/enginekit	0.010s
?   	github.com/opencharly/sdk/internal/spectest	[no test files]
ok  	github.com/opencharly/sdk/kit	11.572s
ok  	github.com/opencharly/sdk/llmkit	2.097s
ok  	github.com/opencharly/sdk/loaderkit	3.049s
ok  	github.com/opencharly/sdk/packagekit	0.042s
ok  	github.com/opencharly/sdk/vmshared	0.147s
ok  	github.com/opencharly/sdk/workflowkit	0.013s
test_exit=0

gofmt -l . printed nothing (no line under its heading) and vet_exit=0. The test run is -count=1 with a fresh TMPDIR/GOTMPDIR, so no line above is a cache hit standing in for an execution.

2. Cross-compile matrix (CGO_ENABLED=0)

GOARCH=amd64: ok
GOARCH=arm64: ok
GOARCH=arm: ok
GOARCH=386: ok

3. The negative control — the new tests fail against the pre-fix guard

The new tests carry the real executor error text from the issue. Reverting only the two guards to the pre-fix if err != nil { return err } and re-running them:

--- FAIL: TestAddCandyDeploymentVia_ToleratesAbsentLedger (0.00s)
    install_ledger_test.go:129: AddCandyDeploymentVia on an absent ledger: ssh cat ~/.config/charly/charly.yml: exit status 1 (stderr: cat: /home/arch/.config/charly/charly.yml: No such file or directory)
--- FAIL: TestWriteDeployRecordVia_ToleratesAbsentLedger (0.00s)
    install_ledger_test.go:145: WriteDeployRecordVia on an absent ledger: ssh cat ~/.config/charly/charly.yml: exit status 1 (stderr: cat: /home/arch/.config/charly/charly.yml: No such file or directory)
FAIL
FAIL	github.com/opencharly/sdk/kit	0.007s
FAIL

Restoring the fix and re-running cold:

ok  	github.com/opencharly/sdk/kit	11.418s
ok  	github.com/opencharly/sdk/deploykit	10.382s

So the tolerance is executed, not asserted: the tests fail on exactly the failure the issue reports and pass once the guard is narrowed.

4. The guard was narrowed, not deleted

TestVia_ToleratesOnlyNotFound drives both Via entry points with a non-not-found read error (Permission denied) over a substrate that already has a ledger, and asserts (a) the error returns and (b) nothing is written — proving the fix cannot clobber a substrate charly.yml it could not read. TestIsNotFound pins the classifier's eleven-case table, including the four false cases.

5. R5 self-test — zero live references to the deleted identifier

$ git grep -c 'isMissingArtifactFile' -- .
$ echo $?
1

No hits anywhere in the tree (exit 1 is grep's "no match") — the only remaining copies of the old name are in pinned submodule checkouts elsewhere in the umbrella, which this PR does not touch.

6. R3 sweep — no third copy exists

Two commands, both actually executed; output pasted verbatim, not summarised.

(a) The org-wide census — every isNotFound-class function across the org's checked-out repos (the umbrella's submodules, at their pinned commits, which predate this PR, so the two copies this PR unifies still appear here):

$ cd <umbrella> && grep -rn --include='*.go' \
    -E 'func (\([^)]*\) *)?(isNotFound|IsNotFound|isMissing[A-Za-z]*|[A-Za-z]+NotExist)\(' \
    charly sdk spec plugin-* layer-* pod-* distro-*
charly/charly/plugin_executor_reverse_e2e_test.go:246:func mustNotExist(t *testing.T, path, msg string) {
sdk/deploykit/artifact_retrieve.go:274:func isMissingArtifactFile(err error) bool {
sdk/kit/walk.go:390:func isNotFound(err error) bool {
plugin-gh/candy/plugin-gh/gh/ghkit.go:194:func IsNotFound(err error) bool {
plugin-herdr/charly/charly/plugin_executor_reverse_e2e_test.go:246:func mustNotExist(t *testing.T, path, msg string) {
pod-herdr/charly/charly/plugin_executor_reverse_e2e_test.go:246:func mustNotExist(t *testing.T, path, msg string) {

Three of the six are not classifiers at all: mustNotExist is a test helper that asserts a path is absent (the same file vendored into three pinned checkouts), so it is not a predicate a caller routes on. Of the remaining three, sdk/deploykit's isMissingArtifactFile is the duplicate this PR deletes and sdk/kit's isNotFound is the copy this PR exports — both shown at their pre-PR pinned state. The only genuinely other predicate is plugin-gh's ghkit.IsNotFound, an HTTP 404 classifier — a different concern in a different package, with no filesystem semantics to unify.

(b) The same census on this PR's own branch, where the unification has happened:

$ cd <this branch's worktree> && grep -rn --include='*.go' \
    -E 'func (\([^)]*\) *)?(isNotFound|IsNotFound|isMissing[A-Za-z]*|[A-Za-z]+NotExist)\(' .
kit/walk.go:406:func IsNotFound(err error) bool {

Exactly one — kit.IsNotFound. No third filesystem not-found predicate exists in the org, so this is the canonical one.

What this PR does NOT claim

The live end-to-end proof is deliberately not here. The issue scopes it as the next leg: this sdk fix must merge and be tagged, then a separate charly pin-bump PR (a task sync + PR — never a hand-edited gitlink) carries it onto a head where charly check run check-group can prove deploy-add ok: true with the venue ledger created in the guest, and check-builder-vm / check-kind-host-vm / check-pkg-uninstall stop aborting at step 3/15. Those four beds are currently red on this exact guard, recorded on opencharly/charly#762.

Rulebook compliance

Every rule of the repo's R0–R10 set (charly/AGENTS.md — the numbering the org validator uses) is accounted for below: a HOW where the rule applies, an explicit N/A — <reason> where it cannot.

  • R0 — skills first. Skills loaded before the first change: plugin (its trigger names sdk/** explicitly), install-plan (the deploy wire + ledger record path), strict-policy, root-cause-analyzer, git-workflow; plus the sdk repo's own R0 list (plugin, go, install-plan) per sdk/AGENTS.md.
  • R1 — RCA every anomaly. The failure was root-caused to the specific guard and sourced to the release that introduced it (v0.2026276.1822, brought onto charly main by charly#778) — not classified as a flake or an environment artefact.
  • R2 — finish the whole cutover. Every in-scope occurrence is fixed: both Via guards, both walk.go reads, all three deploykit optional: call sites, and the duplicate is deleted rather than left beside the canonical one. Nothing is deferred: the charly-side adoption is a different repository's change (charly's own pin bump), named in "What this PR does NOT claim", not a scope shrink of this one.
  • R3 — no duplication. Proven with real output, not prose: §6 pastes both the org-wide census and this branch's own post-fix census — one predicate, kit.IsNotFound, with the deleted duplicate named by file and line.
  • R4 — no workarounds. This change removes a workaround rather than adding one: deploykit carried its own string-matching copy of the classifier, and the two Via guards bypassed the package's own documented tolerance. No sleeps, blind retries, suppressions, fallback branches, magic fixtures, or serialization that hides a race are introduced; the narrowed guard still propagates every non-not-found error, and TestVia_ToleratesOnlyNotFound asserts both that propagation and that nothing is written.
  • R4a — fix the product first; documentation never routes around a defect. Satisfied by construction: this is the product fix — the defect is removed in the code, and no page, comment, or caveat was edited to describe it instead of removing it. The change adds no git clone / cd / -C standing in for a capability; it is a library change with no CLI surface.
  • R5 — delete legacy completely. The old name is gone: git grep -c 'isMissingArtifactFile' → exit 1 (zero hits), pasted with its exit code in §5.
  • R6 — preserve user work and Git safety. No destructive reset/checkout, no force-push, no pushed-history rewrite, no hook bypass, no direct push to main; this lands by PR only, from a feat/-style branch off origin/main.
  • R7 — prove behaviour, not compilation. Coverage that fails without the change exists and was executed: §3's negative control reverts only the two guards and both new tests FAIL with the issue's exact error text, then pass once restored. Tests that cannot fail would be invalid; these demonstrably fail.
  • R7a — live or skip, never fake a live service. No live-service boundary is crossed in this PR's own tests: they drive injected error values through the package's executor seam, which is pure, deterministic in-repo logic — exactly the case R7a keeps unit-testable. The one real boundary (a guest's absent ~/.config/charly/charly.yml read over SSH) is not faked here; it is exercised for real by the charly beds on the separate pin-bump leg, named in "What this PR does NOT claim" rather than simulated.
  • R8 — preserve emitted artifacts. N/A — no emitted artifact is touched: the diff is two guards, one exported predicate, and tests. No label, plan, config, schema, or generated file is produced or changed.
  • R9 — binary equals source. N/A — no binary is built or installed: this changes an sdk library, whose gate is the repo's own gofmt / go vet / go test / cross-compile set (§1–§2). The CalVer-stamped worktree-local charly binary belongs to the separate charly pin-bump leg.
  • R10 — fresh disposable proof. Every command above ran against the committed tree 1562bfd993f97432d4dd77d85d30b6b8bcc5419f with a fresh TMPDIR/GOTMPDIR, so no line is a cache hit standing in for an execution.

Change classification

  • Change class: Go library change — kit (a two-guard tolerance fix + one exported predicate) and deploykit (deletion of a duplicate, three call sites repointed). No schema, no wire type, no CLI surface, no candy.
  • Verification gate: the sdk repo's own gate set — gofmt -l ., go vet ./..., go test -count=1 ./..., and the CGO_ENABLED=0 cross-compile matrix — all green on the final committed tree, as pasted above.
  • Attribution tier: fully tested and validated.
file +/−
deploykit/artifact_retrieve.go +4/−20
kit/install_ledger.go +8/−2
kit/install_ledger_test.go +79/−2
kit/is_not_found_test.go +46/−0
kit/walk.go +23/−7
total +160/−31, 5 files

Closes #342.

Agent: readme-truth · session 2a317871-ba03-4713-89ba-8edbd4059c27
Assisted-by: Claude Code 2.1.288 deepseek-v4.1-flash:cloud (fully tested and validated)

…a fresh VM

The guard added in v0.2026276.1822 returned exec.GetFile's error verbatim, so a
fresh guest — where ~/.config/charly/charly.yml legitimately does not exist yet —
hard-failed the FIRST deploy with:

  venue ledger deploy record: ssh cat ~/.config/charly/charly.yml: exit status 1
  (stderr: cat: /home/arch/.config/charly/charly.yml: No such file or directory)

The absence was never an error by this package's own design: mutateRemoteLedger
documents that the bytes "may be empty/absent" and builds a fresh document, and the
`mkdir -p` write path creates the file. Both Via guards are now narrowed to the
not-found case; every other read failure still propagates.

The classifier is not new: kit already carried it as the unexported isNotFound
behind the same `if err != nil && !IsNotFound(err)` shape. It is exported as
kit.IsNotFound — the one canonical classifier (R3) — and deploykit's duplicate
isMissingArtifactFile is deleted with its three `optional:` artifact call sites
pointed at it (R5: zero live references to the deleted name). kit.IsNotFound uses
errors.Is(err, fs.ErrNotExist), a superset of the former os.IsNotExist, and keeps
every text form the deploykit copy matched, so artifact `optional:` is unchanged.
@github-actions

github-actions Bot commented Oct 4, 2026

Copy link
Copy Markdown

Review — BLOCK

Head SHA: 1562bfd993f97432d4dd77d85d30b6b8bcc5419f (branch: fix/ledger-notfound-342)

Change class: Go library change (sdk kit + deploykit); declared gate is the sdk gate set (gofmt/go vet/go test/cross-compile), which matches the class. Security screen (T1–T4): no finding.

Blocks

  1. B14(d) — the R3 sweep's output is described, not pasted, and the body claims otherwise. The rule-compliance section asserts R3 is satisfied "with the org-wide sweep pasted above", but §6 ("R3 sweep — no third copy exists") supplies only the command text plus a prose summary — "…finds no other filesystem not-found predicate. The only other IsNotFound in the org is plugin-gh's ghkit.IsNotFound…". No raw grep output appears, and the command as written (… across the org) is not runnable as shown (no paths). B14(d) requires an actually-executed command and its real output; a sweep the body relies on but only narrates is a FRAUD-class finding. Contrast §5, which does paste real output — the asymmetry is the defect. Fix: paste the real command and its real output (or delete the "no third copy exists" claim and the "pasted above" wording).

  2. A1 — rule-compliance section omits applicable rules. The section answers R0/R1/R2/R3/R5/R6/R10 but never addresses R4 (no ad-hoc workarounds — applicable to a Go code change; must be answered with a HOW, or N/A — no sleeps/polls/magic-numbers), and does not mark R4a/R8/R9 with an explicit N/A — <reason>. Add the missing one-line entries so every applicable rule is accounted for.

Verdict: BLOCK


ollama-cloud/deepseek-v4.1-flash — action-review.

View action run

@github-actions

github-actions Bot commented Oct 4, 2026

Copy link
Copy Markdown

Review — PASS

Head SHA: 1562bfd993f97432d4dd77d85d30b6b8bcc5419f (branch: fix/ledger-notfound-342)

Security screen: PASS — no scope mismatch (diff = the described two-guard narrowing + classifier export + duplicate deletion + tests), no secrets/egress/eval, no weakened guardrail, no supply-chain/CI-script edit, no self-modifying-security change.
Checklist: All applicable rules PASS or NA. Change class = sdk Go library (kit + deploykit); gate set (gofmt/go vet/go test -count=1/cross-compile) matches the class; body's file table (+160/−31, 5 files) reconciles with the diffs; negative control + TestVia_ToleratesOnlyNotFound + TestIsNotFound give coverage that fails without the change; §6 census is internally consistent; placement CORRECT (kind-blind sdk mechanism, net duplication removed, no alias growth, no core/sdk re-coupling).
Comments: 1 considered — @github-actions[bot] (2 blocks), both stale-superseded: block 1 ("R3 sweep described, not pasted") is contradicted by the CURRENT §6, which pastes both grep commands and their raw output; block 2 ("rule-compliance omits R4/R4a/R8/R9") is contradicted by the CURRENT section, which answers R4 and R4a with a HOW and marks R8/R9 with explicit N/A — <reason>.

Verdict: PASS


ollama-cloud/deepseek-v4.1-flash — action-review.

View action run

@github-actions
github-actions Bot enabled auto-merge (squash) October 4, 2026 03:51
@github-actions
github-actions Bot merged commit c80ed63 into main Oct 4, 2026
6 of 7 checks passed
charly-auto-merge Bot added a commit that referenced this pull request Oct 4, 2026
github-actions Bot pushed a commit to opencharly/charly that referenced this pull request Oct 4, 2026
…ger on a first deploy) (#785)

The sdk module is the contract surface charly resolves from the Go proxy at a pinned
`require`. v0.2026277.352 is the tag-on-merge tag for `opencharly/sdk#343`, which narrows
both `Via` guards in `kit/install_ledger.go` to the not-found case so that a fresh guest —
where `~/.config/charly/charly.yml` legitimately does not exist yet — no longer hard-fails
the FIRST `charly deploy add` into a newly created VM, and deletes deploykit's duplicate
`isMissingArtifactFile` in favour of the newly exported `kit.IsNotFound`.

ONE atomic commit: the require bump in all four lockstep modules and the R5 prune of the
retired `v0.2026276.1822` sum lines land together, so no intermediate revision carries the
retired hashes.

Adopted with charly's own task surface, never a hand-pinned line: `go get` in `charly/`,
then `charly task mods-tidy`, whose check step asserts that every lockstep module carries
the shared sdk/spec pins.

R10: `check-group` — an existing `disposable: true` bed whose `deploy-add` step is a first
deploy into a freshly created guest, i.e. exactly the `kit.AddCandyDeploymentVia` ->
`GetFile` venue-ledger read this pin makes tolerant. Green on this tree; the pre-pin tree
fails the same step with the missing-ledger error. The pasted A/B is in the PR body.

Co-authored-by: atrawog <[email protected]>
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.

bug: the new GetFile not-found guard in install_ledger.go hard-fails every FIRST deploy into a fresh VM

2 participants