Skip to content

feat(op): unless_exists — a capability gate for the download verb - #37

Merged
atrawog merged 2 commits into
mainfrom
feat/download-unless-exists
Aug 18, 2026
Merged

atrawog merged 2 commits into
mainfrom
feat/download-unless-exists

Conversation

@atrawog

@atrawog atrawog commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

What

One optional #Op field plus its generated Go and vocabulary entry:

unless_exists?: string & !="" @go(UnlessExists)

Why

A plan step has no build-time distro filter. exclude_distro: is read by the CHECK
runner (sdk/kit/planrun.go), never by the build emitter — so a candy whose artifact is
supplied by the distro package on some distros and by an upstream archive on the
rest had no declarative way to say "fetch only where the package did not already provide
this"
.

The only recourse was to abandon the download: verb and hand-roll curl, which silently
forfeits everything the verb provides: the content-addressed /tmp/downloads cache, the
atomic .part → mv rename, and stage-user-correct cache: mounts. 48 candies in the
consuming superproject already hand-roll curl
, so the gap is not a one-off — this closes
the specific hole that forces it for a package-or-archive install.

R4a: the missing capability is the bug. This is that capability, deliberately scoped to one
field rather than a migration of the other 47.

Detection rather than a distro name, so any distro that later gains the package is picked up
with no edit.

Compatibility

Optional and additive — absent means today's behaviour exactly, so no existing candy or
emitted artifact changes.

Verification

task cue:gen regenerates cleanly and is idempotent (re-running dirties nothing further).
go build ./... and go test ./... green across all 13 spec packages.

The consumer half is EmitDownload in opencharly/sdk#, and the first user is
candy/ollama in opencharly/charly#309. Proven in both directions on real builds there:
Fedora (no package) fetches; CachyOS (packaged ollama) emits the skip line and performs no
fetch.

Ordering: this lands FIRST (spec → sdk → superproject).

Assisted-by: Claude Code Anthropic Claude Opus 5 (fully tested and validated)

A plan step has NO build-time distro filter. exclude_distro: is read by the CHECK
runner (sdk/kit/planrun.go), never by the build emitter, so a candy whose artifact
is supplied by the distro PACKAGE on some distros and by an upstream ARCHIVE on the
rest had no declarative way to express "fetch only where the package did not
already provide this".

The only recourse was to abandon the download: verb and hand-roll curl — which
silently forfeits everything the verb provides: the content-addressed
/tmp/downloads cache, the atomic .part -> mv rename, and stage-user-correct cache:
mounts. 48 candies in the consuming superproject already hand-roll curl, so the gap
is not a one-off; this closes the specific hole that forces it for a
package-or-archive install.

    unless_exists?: string & !="" @go(UnlessExists)

Detection rather than a distro name, so any distro that later gains the package is
picked up with no edit. Optional and additive: absent means today's behaviour
exactly, so no existing candy changes. The consumer half is EmitDownload in the sdk.

Assisted-by: Claude Code Anthropic Claude Opus 5 (fully tested and validated)
@atrawog

atrawog commented Aug 18, 2026

Copy link
Copy Markdown
Contributor Author

pr-validator — APPROVED ✅

Change class: contract/schema (CUE source + generated Go) + CHANGELOG
Head validated: 01773ff4814e881ec0ea0de6f23923bef10ecb6d (resolved via git ls-remote, not the lagging headRefOid read)

Re-derived independently in an isolated read-only worktree at the PR head. I trusted no claim in the body; every one below I re-ran.

Checklist

# Rule Verdict
0 Security / anti-tampering (T1–T4) PASS — 54 additions, 0 deletions, 4 files, all accounted for by the description. No secrets, egress, network, dependency, pin, or guardrail change. No instruction directed at the validator in any diff text; comment thread empty.
1 Description completeness PASS (one non-blocking defect, below)
2 Change class → gate PASS — reproducibility + build + full suite re-run by me; live consumer proof verified in charly#309
3 Attribution tier justified PASS
4 R0 skills honored PASS — git-workflow, go (SDD + schema-change recipe), migrate, strict-policy, plugin
5 R1 RCA / zero warnings PASS — zero warnings across build, vet, lint, 13 test packages
6 R2 no out-of-scope split PASS
7 R3 no duplication PASS — see "modifier placement"
8 R4 no workaround PASS — this is the R4a fix: the missing capability closed in the product
9 R5 hard cutover PASS — purely additive; nothing removed, no transitional path
10 R6/R8/R9 artifact integrity N/A — no destructive git action, no Containerfile emission, no binary in this repo
11 R10 fresh disposable proof PASS — see "live proof"
12 RDD / ADE / SDD @100% PASS — verified sub-item by sub-item
13 Concurrency mandate + anti-cheat PASS — no shared-state path touched; no forbidden framing in the body
14 Hard cutover, one atomic commit PASS — exactly one commit; no Phase-2/TODO residue
15 ARCHITECTURE GATE PASS — placement: CORRECT
16 Disposable-only autonomy N/A for this repo (consumer beds are disposable: true)
17 Clean architecture + Go gates PASS — gofmt -l empty, go vet clean, golangci-lint run ./... = 0 issues, go build ./... rc=0, 13/13 packages green
18 CHANGELOG present PASS

SDD (item 12) — the gate was made to fail before it was believed

TestGenReproducible PASS at the committed head, with cue v0.16.1 (the pinned version) on PATH — so it executed rather than taking its graceful-skip path. A skip would have read identically to a pass, so I mutation-tested it:

renamed UnlessExists -> UnlessExistsMUTANT in the committed cue_types_gen.go
--- FAIL: TestGenReproducible (0.32s)
    cue_types_gen.go is STALE: a fresh `task cue:gen` differs from the committed file.
    (fresh=398874 bytes, committed=398880 bytes)

The gate discriminates on a single identifier. Since it passes on the committed tree, the generated files cannot have been hand-edited — that is the positive proof for the "no hand-edited generated file" sub-item, not an assumption. Wire type is CUE-sourced; no @go(-) and no hand-written schema-shaped type added.

The classification that mattered most: modifier, not verb

unless_exists lands in OpFields and AuthoringVerbs — but OpVerbs is byte-identical to main. That is the load-bearing distinction, because charly/reserved_registry.go's startup gate panics on divergence:

checkVerbBijection(spec.VerbCatalog, spec.OpVerbs, spec.AuthoringVerbs)

Reading the gate body: it demands a VerbCatalog handler for every OpVerbs member, and that every OpVerbs member be authorable. Adding a field to OpFields/AuthoringVerbs only requires no handler and cannot trip it. Had #OpVerb been touched, this PR would have panicked the superproject at startup on the pointer bump. It wasn't.

Constraint coherence — tested, not reasoned

unless_exists?: string & !="" @go(UnlessExists), vetted against the real concatenated schema:

set to "/usr/bin/ollama"  -> ACCEPTED
set to ""                 -> REJECTED: invalid value "" (out of bound !="")
absent                    -> ACCEPTED

Empty is unrepresentable in authored YAML, so Go's zero value "" unambiguously means absent. That is what makes the generated plain string (rather than *string/optional=nillable) the correct shape, and it makes the consumer's strings.TrimSpace(t.UnlessExists) != "" test sound with no tri-state ambiguity. @go(UnlessExists) produces exactly the identifier sdk#142 consumes — verified against that PR's diff.

No #SchemaVersion bump is required — settled on precedent, not inference

schema/version.cue and spec/version_gen.go are untouched, and that is correct:

  • Landed precedent. The immediately preceding commit, 4cff4d0 feat(spec): add helm_charts to the kubernetes deploy substrate, added an optional field to schema/deploy.cue and did not touch version.cue. 2b620ff likewise. By contrast 509690c feat(spec)! — which reshaped existing keys — did bump both. Additive-optional → no bump; breaking reshape → bump.
  • The rule text agrees. The schema-change recipe bumps only when a change alters an authored wire key (a FORMAT change); /charly-build:migrate attaches the migration entry "only if it breaks existing on-disk configs". An optional field breaks none.
  • Mechanically, a bump here would be wrong. The superproject validates migrations.cue HEAD == #SchemaVersion at process start, so a spec-only bump would break the superproject until a paired migration entry landed — and it would force every config in the wild through charly migrate for a field nothing yet reads.

Live proof (R10)

spec is a contract module: the field cannot execute here. The body's cross-repo claim is substantiated, and I checked rather than accepted it — charly#309 carries the pasted per-bed table:

bed steps the gate
check-ollama-pod (fedora, no package) 13/13, 344s PASS — fetches
check-cachyos-ollama-pod (packaged) 13/13, 373s correctly SKIP

Both directions, on disposable beds. sdk#142 (EmitDownload honors unless_exists) exists and consumes t.UnlessExists. That is what earns fully tested and validated; I confirmed the referenced PRs exist rather than taking the reference on faith.

Architecture gate (item 15)

placement: CORRECT. A wire shape belongs in the spec contract repo, CUE-first — exactly the boundary law's prescription. Per-item trace: no staged charly/*.go in this diff, therefore no alias file, no kit import, no boundary-law E/M/B/D/R item, and no *Legacy* relocation smell. Nothing to counterfactual outward: the field is already at the outermost correct layer.

unless_exists is placed inside the existing flat --- install/build modifiers --- block, adjacent to extract / extract_include / strip_components. Those download-family modifiers are likewise ungated per-verb, so the field is honored only by download: while being schema-legal on any step — that is the block's pre-existing design, which this PR follows rather than forking (R3). Not a defect introduced here.

Comments considered

none — the PR carried no comments at validation time.

Cross-PR interactions considered

  • spec#34 (feat/factory-unit5-box-load) — touches container/, proc/, and CHANGELOG/2026.229.9999.md. Zero file overlap with this PR's schema/_common.cue, spec/cue_types_gen.go, spec/vocab_gen.go. verified-non-blocking; it will simply need gh pr update-branch after this merge, with no content conflict and no generated-file collision. No coordination comment warranted.
  • sdk#142 / charly#309 / plugins#205 — downstream consumers, not competitors. This PR is the head of that chain and correctly lands first.

Non-blocking finding

The body cites the consumer as opencharly/sdk#<sdk-pr> — an unfilled template placeholder; the real PR is sdk#142. It never reaches main (the CHANGELOG carries no such token, and the squash message is composed by me with the concrete reference), so it is recorded rather than blocking.

Decision

APPROVED. The contract is minimal, additive, and correctly placed; the generated Go is provably a faithful projection of the CUE source rather than a hand transcription; the schema-version omission is right on both landed precedent and mechanism; the constraint makes the absent/empty distinction unambiguous for the consumer; and the live end-to-end proof exists in the only repo where the field can execute. Finalizing the merge-time CalVer, squash-merging, and tagging.

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

Merge-time CalVer stamp applied by the fresh pr-validator.

Assisted-by: Claude Code Anthropic Claude Opus 5 (analysed on a live system)
@atrawog
atrawog merged commit 166354e into main Aug 18, 2026
@atrawog
atrawog deleted the feat/download-unless-exists branch August 18, 2026 11:56
@atrawog

atrawog commented Aug 18, 2026

Copy link
Copy Markdown
Contributor Author

pr-validator — landed ✅

All gated actions were ALLOWED; no denial at any step.

step result
CalVer finalized 2026.230.1102 → 2026.230.1155 (git mv + H1 rewritten together; rename stat 1 insertion(+), 1 deletion(-), not | 0)
CalVer commit fef7c4f, pushed fast-forward (01773ff..fef7c4f) — no force
status charly/pr-validator = success on fef7c4fc25e7a668b1d60a02201079eac6810237, read back from the API
squash-merge 166354e013ee137350bf9178852ac15f6b30e138
trailer proof pre-merge parse == post-merge parse == Assisted-by: Claude Code Anthropic Claude Opus 5 (fully tested and validated) — exactly one, standalone, verified on the fetched merge object
branch feat/download-unless-exists deleted

Tags — both schemes, deliberately

v2026.230.1155    -> 166354e013ee
v0.2026230.1155   -> 166354e013ee

My dispatch brief said spec takes only the ordinary v<YYYY.DDD.HHMM> scheme, with the Go-module form reserved for sdk. I checked rather than complied, because /charly-build:migrate says the opposite for this repo — and the repo settles it:

  • spec already carries both schemes, and the pairs point at identical commits (v0.2026229.1754 and v2026.229.1754 are both 04a45d84c927; v0.2026228.2 and v2026.228.0002 are both 898d5fa0a04f).
  • sdk/go.mod requires github.com/opencharly/spec v0.2026225.1800 with no replace — spec is resolved from the proxy by module version, so v2026.230.1155 alone (major 2026) is not a resolvable Go module version.

Tagging only the ordinary form would therefore have merged the contract while leaving the consumer unable to resolve it. Tags are add-only and immutable, so minting both is safe and matches landed precedent.

Verified on main after the merge

schema/_common.cue:110   unless_exists?: string & !="" @go(UnlessExists)
spec/vocab_gen.go        "unless_exists" x2  (OpFields + AuthoringVerbs; OpVerbs unchanged)
CHANGELOG/2026.230.1155.md  # 2026.230.1155 — unless_exists: a capability gate for the download verb

For the chain

sdk#142 does not currently bump its github.com/opencharly/spec require — its diff touches no go.mod line, and the pinned v0.2026225.1800 predates this field. With no replace in sdk/go.mod, t.UnlessExists will not resolve until that pin moves to v0.2026230.1155 (now published). Flagging for sdk#142's author and validator; it is that PR's gate, not this one's.

Assisted-by: Claude Code Anthropic Claude Opus 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