Repository navigation
fix(kit): tolerate an absent substrate ledger on a first deploy into a fresh VM - #343
Conversation
…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.
Review — BLOCKHead SHA: Change class: Go library change (sdk Blocks
Verdict: BLOCK ollama-cloud/deepseek-v4.1-flash — action-review. |
Review — PASSHead SHA: 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. Verdict: PASS ollama-cloud/deepseek-v4.1-flash — action-review. |
…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]>
Summary
AddCandyDeploymentViaandWriteDeployRecordVia(kit/install_ledger.go) returnedexec.GetFile's error verbatim, so a fresh guest — where~/.config/charly/charly.ymllegitimately does not exist yet — hard-failed the firstcharly deploy addinto a newly created VM:The absence is not an error by this package's own design:
mutateRemoteLedgerdocuments that the substrate bytes "may be empty/absent" and builds a fresh document when they are, and themkdir -p ~/.config/charly && cat > …write path creates the file. The guard returned before that tolerance was ever reached.Both
Viaguards are narrowed to the not-found case. Every other read failure — permission denied, a broken channel, a substratecharly.ymlthat 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
kitalready carried the classifier as the unexportedisNotFound(kit/walk.go), behind the sameif err != nil && !IsNotFound(err)shape, serving the env.d managed-block read. This change exports it askit.IsNotFoundand makes it the one canonical classifier:kit/walk.go(2 reads)isNotFoundIsNotFoundkit/install_ledger.go(2 guards)if err != nil { return err }if err != nil && !IsNotFound(err) { return err }deploykit/artifact_retrieve.go(3optional:sites)isMissingArtifactFilekit.IsNotFound— local copy deletedkit.IsNotFoundkeeps every text form the deleted copy matched (No such file or directory,cannot access,not found) and adds the bareno such fileform, so the artifactoptional:behaviour is unchanged; and it useserrors.Is(err, fs.ErrNotExist)in place ofos.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 statusclean) — R10.1. The sdk repo's full gate set (
sdk/AGENTS.md)gofmt -l .printed nothing (no line under its heading) andvet_exit=0. The test run is-count=1with a freshTMPDIR/GOTMPDIR, so no line above is a cache hit standing in for an execution.2. Cross-compile matrix (
CGO_ENABLED=0)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:Restoring the fix and re-running cold:
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_ToleratesOnlyNotFounddrives bothViaentry 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 substratecharly.ymlit could not read.TestIsNotFoundpins the classifier's eleven-case table, including the fourfalsecases.5. R5 self-test — zero live references to the deleted identifier
No hits anywhere in the tree (exit
1is 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):Three of the six are not classifiers at all:
mustNotExistis 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'sisMissingArtifactFileis the duplicate this PR deletes andsdk/kit'sisNotFoundis the copy this PR exports — both shown at their pre-PR pinned state. The only genuinely other predicate isplugin-gh'sghkit.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:
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
charlypin-bump PR (atask sync+ PR — never a hand-edited gitlink) carries it onto a head wherecharly check run check-groupcan provedeploy-addok: truewith the venue ledger created in the guest, andcheck-builder-vm/check-kind-host-vm/check-pkg-uninstallstop aborting at step 3/15. Those four beds are currently red on this exact guard, recorded onopencharly/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 explicitN/A — <reason>where it cannot.plugin(its trigger namessdk/**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) persdk/AGENTS.md.v0.2026276.1822, brought onto charlymainbycharly#778) — not classified as a flake or an environment artefact.Viaguards, bothwalk.goreads, all threedeploykitoptional: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.kit.IsNotFound, with the deleted duplicate named by file and line.deploykitcarried its own string-matching copy of the classifier, and the twoViaguards 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, andTestVia_ToleratesOnlyNotFoundasserts both that propagation and that nothing is written.git clone/cd/-Cstanding in for a capability; it is a library change with no CLI surface.git grep -c 'isMissingArtifactFile'→ exit1(zero hits), pasted with its exit code in §5.main; this lands by PR only, from afeat/-style branch offorigin/main.~/.config/charly/charly.ymlread 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.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.N/A — no binary is built or installed: this changes an sdk library, whose gate is the repo's owngofmt/go vet/go test/ cross-compile set (§1–§2). The CalVer-stamped worktree-local charly binary belongs to the separate charly pin-bump leg.1562bfd993f97432d4dd77d85d30b6b8bcc5419fwith a freshTMPDIR/GOTMPDIR, so no line is a cache hit standing in for an execution.Change classification
kit(a two-guard tolerance fix + one exported predicate) anddeploykit(deletion of a duplicate, three call sites repointed). No schema, no wire type, no CLI surface, no candy.gofmt -l .,go vet ./...,go test -count=1 ./..., and theCGO_ENABLED=0cross-compile matrix — all green on the final committed tree, as pasted above.fully tested and validated.deploykit/artifact_retrieve.gokit/install_ledger.gokit/install_ledger_test.gokit/is_not_found_test.gokit/walk.goCloses #342.
Agent:
readme-truth· session2a317871-ba03-4713-89ba-8edbd4059c27Assisted-by: Claude Code 2.1.288 deepseek-v4.1-flash:cloud (fully tested and validated)