Repository navigation
Conversation
…us 168s -> 89s (#208) GitLatestTag and GitDefaultBranch run git ls-remote — a NETWORK operation — for every version-less @github ref the resolver walks. A charly status on a project whose closure carries hundreds of version-less refs paid for that round-trip once per ref PER RESOLUTION, and the status fan-out resolves the envelope multiple times — measured at 366 git-remote-https invocations and ~140s of futex wait in one charly status (issue #208). Tags and default branches are effectively immutable (add-only), so a TTL-bounded persistent cache (1h, latest-tags.json beside the repo cache) is safe: a stale entry is at worst one tag behind, and the next expiry refreshes it. Measured: charly status 168s -> 89s on the charly repo project. Adds TestLatestTagCacheRoundTrip.
Review — BLOCKHead SHA: Change class: code fix (performance cache in Security screen: PASS — no secrets, exfiltration, scope mismatch, or guardrail weakening. Blocks
Verdict: BLOCK ollama/deepseek-v4-flash — pi-review-action. |
* fix(box): make openrc selectable via #Box.init The build vocabulary defines three init systems - supervisord, systemd and openrc, the last a first-class entity with its own service_template, management commands and unit_path_template - but #Box.init's enum listed only two. A box could not select openrc at all: `init: openrc` failed schema validation against an init charly fully implements. That mattered from the moment #Box.init started being read. Until sdk#175 the field reached nothing, so the gap was invisible; now that ResolveInitSystem receives it, an unselectable vocabulary word is a live inconsistency between what the vocabulary defines and what a box may ask for. The doc comment states the invariant the enum has to hold - every value must be an init the vocabulary actually defines - so the next init added to charly.yml has a stated reason to appear here too, rather than being omitted the way openrc was. Regenerated with `task cue:gen` (SDD: the CUE def is the single source; the Go comment is generated from it). Regeneration is reproducible - a second run is a no-op. Also fixes a pre-existing gofmt violation in fleet/deploy_fleet_ops_candykey_test.go. It is untouched by this change but blocks any commit to the module, so R2 puts it here rather than in a follow-up. Assisted-by: Claude Code Anthropic Opus 5 (analysed on a live system) Claude-Session: https://claude.ai/code/session_01Gf42A3bau77JigFYLALrnq * test(box): assert #Box.init accepts every vocabulary init Adds the coverage the enum widening shipped without. Three cases against the SHIPPED schema, compiled the way consumers compile it (schemaconcat.ConcatSchema over the embedded FS): - every vocabulary init validates. Fails on the pre-change enum: unifying #Box with init: "openrc" is a conflict, not a warning. - an unknown init is still rejected. Widening by loosening the type to `string` would make the first case pass while silently accepting typos, so the discrimination is asserted rather than assumed. - box.cue still states the invariant. It is the only place that says why the enum's membership is constrained, and spec cannot read charly's vocabulary to check it mechanically. Caught by the pr-validator: B12 requires a test that fails without the change, and the original diff's only test hunk was an unrelated gofmt fix. --------- Co-authored-by: atrawog <[email protected]>
…tch (#58) The spec leg of batch B2. Purely additive: every field is optional and its absence renders exactly as today. Four PORTABLE fields on #CandyService, each expressible by at least two of the three inits - the admission rule that keeps a single-init knob out of the shared schema: type systemd Type=; supervisord approximates oneshot via startsecs=0; OpenRC distinguishes forking via command_background requires a HARD dependency, distinct from after:'s ordering. systemd Requires=; OpenRC depend(){ need ... }, which its template already emits for localmount. supervisord ignores it restart_sec systemd RestartSec=; OpenRC --respawn-delay watchdog_sec systemd WatchdogSec=; OpenRC --healthcheck-timer restart_sec/watchdog_sec accept "5s" or a bare 5, matching stop_timeout's existing shape rather than inventing a second convention. And ONE escape hatch for everything init-specific: unit_options: {[init]: {[directive]: string | [...string]}} It exists so #ServiceRenderContext does not grow a field per init-specific knob. That struct is a kind-AGNOSTIC envelope every init's template renders against; putting NotifyAccess, Slice, KillMode, RuntimeDirectory and a hardening block into it would make it systemd's typed shape wearing a generic name - the leak the boundary law names. With this map a FOURTH init needs no schema change, exactly as the openrc init entity needed no Go change. A directive value may be a scalar or a list; a list emits the directive once per element, which is what systemd expects for repeatable directives such as RuntimeDirectory= or ReadWritePaths=. Both #CandyService and #ServiceRenderContext gain the fields: a field on the entry that never reaches the context is unreachable from any template, so the pair is asserted together. Coverage fails without the change - verified by reverting both schema files and re-running, not by inspection: 12 subtests fail, including that type: is an ENUM (a typo must not reach a template and render an invalid Type=) and that unit_options takes a scalar and a list side by side. Assisted-by: Claude Code Anthropic Opus 5 (analysed on a live system) Claude-Session: https://claude.ai/code/session_01Gf42A3bau77JigFYLALrnq Co-authored-by: atrawog <[email protected]>
…ntext (#59) The consumer half of spec#58. Those fields were authorable on a #CandyService but BuildServiceRenderContext - the pure entry -> context projection every init template renders against - dropped them, so nothing could reach a template. The schema said yes and the renderer never saw it. Carried verbatim, like the start hooks and for the same reason: each is an init-level directive value, not a path to expand or an ordering list to merge. Two tests, both revert-controlled: - the fields survive the projection, including unit_options' LIST form, which systemd needs for repeatable directives like RuntimeDirectory= - collapsing it to a scalar would emit one unusable value instead of two lines. - an entry setting NONE of them leaves the context's fields zero, so an existing candy renders byte-identically. That is the assertion that makes "purely additive" checkable rather than asserted. Assisted-by: Claude Code Anthropic Opus 5 (analysed on a live system) Claude-Session: https://claude.ai/code/session_01Gf42A3bau77JigFYLALrnq Co-authored-by: atrawog <[email protected]>
…ice start (#60) The spec leg of batch B2's last item. Nine hand-rolled versions of the same poll exist in the candy corpus today - labwc, kde-selkies x2, chrome-cdp, wayvnc x3, swaync, waybar, waybar-labwc, sway - each re-deriving a socket wait with its own hardcoded timeout, which is exactly the sleeps and magic numbers R4 forbids. One of them is already wrong: pod-labwc/labwc-wrapper declares TIMEOUT=30 but sleeps 0.5s per iteration while counting +1, so it actually gives up after 15 seconds. That is the failure mode a hand-rolled loop has and a declared one cannot. wait_for: {paths: ["${XDG_RUNTIME_DIR}/wayland-1"], timeout: "30s"} paths is REQUIRED and non-empty (paths!: [_, ...]): a wait_for waiting for nothing is a no-op that reads like a guard, which is worse than no guard. Required-field violations surface only under FINAL validation, so the test that pins this validates concretely - the structural form accepts the empty case and would have passed vacuously. PATHS ONLY, deliberately. All nine existing loops wait on a filesystem path - a Wayland socket, an IPC socket, a lock file - and none polls a TCP port. A ports: form would need a probe tool the base images do not all carry, so it waits for a real second consumer instead of being designed against a hypothetical one (R3's trigger is the SECOND occurrence, not the first). timeout accepts "30s" or a bare 30, matching stop_timeout rather than inventing a second convention. Carried into #ServiceRenderContext in the same change: a readiness precondition the templates cannot see is a precondition that never runs. A service that declares none leaves it nil, so a template omits the whole pre-start branch rather than emitting an empty one. Coverage fails without the change - verified by reverting only the implementation and keeping the tests, which then do not compile (undefined: ServiceWaitFor). Assisted-by: Claude Code Anthropic Opus 5 (analysed on a live system) Claude-Session: https://claude.ai/code/session_01Gf42A3bau77JigFYLALrnq Co-authored-by: atrawog <[email protected]>
* feat(distro): ovmf_family becomes a distro trait
The second item of batch B4, and the producer leg for it.
The OVMF firmware family was a hand-maintained `ovmf_distro_aliases:` map kept in
TWO byte-identical copies - charly/charly.yml and
plugin-vm/candy/plugin-vm/build_defaults.yml. Verified identical, line for line.
Every new distro had to be added to both, and adding it to only one was silent.
It is a property of the distro exactly like format, ssh_unit and init, so it
becomes the fourth #DistroTrait field and generates into spec.DistroOvmfFamilies
beside DistroFormats / DistroSSHUnits / DistroInits.
OPTIONAL, deliberately. The ABSENCE is meaningful: an id with no family keeps
today's behaviour, where ovmfCandidatesForDistro tries the union of all families
and the not-found error emits the generic install hint. archarm (aarch64 firmware
paths differ) and alpine stay unset, as they were before - an unproven family
would be worse than the fallback. Generating that required a tolerant collector,
distroTraitOptional, since distroTrait errors on a missing field.
Two corrections fall out of keying by real distro ids:
- cachyos gains a family it never had. The alias table predated the distro, so a
CachyOS host fell through to the union - which is exactly the host the cstream
VM beds run on.
- "alma" is gone. It was never a #DistroID (the id is almalinux), so that row
could not match a validated distro: a dead entry that read like coverage. The
test asserts every key IS a #DistroID so a second one cannot appear.
The two YAML copies are deleted in the consumer legs (charly, plugin-vm), which
follow this tag.
Assisted-by: Claude Code Anthropic Opus 5 (analysed on a live system)
Claude-Session: https://claude.ai/code/session_01Gf42A3bau77JigFYLALrnq
* refactor(schemagen): one distroTrait collector, required or optional
distroTraitOptional was a near-verbatim copy of distroTrait - same lookup, same
iteration, same id-unquoting, same string extraction - differing only in whether a
missing field errors or is skipped. That is the R3 pattern, and copying twenty
lines to change one branch is exactly what it forbids.
Unified into distroTrait(schema, field, required). All four traits call it.
The parameter carries a real distinction rather than a flag for its own sake:
format, ssh_unit and init are declared by EVERY id, so a missing one is a
vocabulary bug and must fail generation. ovmf_family is optional and its ABSENCE
is meaningful - an id with no family stays on the all-families OVMF fallback
instead of being pinned to a layout nobody verified - so erroring there would
force a guess for archarm and alpine.
The non-empty guard moves under `required` for the same reason: only a required
trait proves #Distros was populated at all, and an optional one may legitimately
be empty.
Generated output is unchanged - vocab_gen.go is byte-identical after regeneration,
which is what makes this a refactor rather than a behaviour change.
Caught by the pr-validator.
---------
Co-authored-by: atrawog <[email protected]>
…us 168s -> 89s (#208) GitLatestTag and GitDefaultBranch run git ls-remote — a NETWORK operation — for every version-less @github ref the resolver walks. A charly status on a project whose closure carries hundreds of version-less refs paid for that round-trip once per ref PER RESOLUTION, and the status fan-out resolves the envelope multiple times — measured at 366 git-remote-https invocations and ~140s of futex wait in one charly status (issue #208). Tags and default branches are effectively immutable (add-only), so a TTL-bounded persistent cache (1h, latest-tags.json beside the repo cache) is safe: a stale entry is at worst one tag behind, and the next expiry refreshes it. Measured: charly status 168s -> 89s on the charly repo project. Adds TestLatestTagCacheRoundTrip.
…ock + gofmt The file-header comment claimed the cache was guarded by the advisory lock the repo fetch uses, but the code acquired no lock — rememberLatestTag / rememberDefaultBranch did an unlocked read-modify-write of the shared JSON file, so concurrent resolvers could lose updates or corrupt the cache. This implements the claimed lock: withLatestTagCacheLock serializes the load → mutate → save cycle on a .lock file beside the cache (flock, the same primitive the repo fetch uses), and the remember* helpers write through it. Reads stay lock-free (a stale read is harmless; the fast path must not pay for a lock on every status invocation). Also gofmt-cleans the file (trailing blank line in the import block, misaligned struct tags).
GitResolveRef runs git ls-remote <repo> <ref> refs/tags/<ref> ... for every ref the resolver freshness-checks — the 183 network calls that survived the latest-tag/default-branch cache. Caching it in the same persistent latest-tags.json (keyed repoURL+ref, same 1h TTL, same advisory lock) eliminates the remaining network git traffic. Measured on the charly repo project, warm cache: charly status 168s -> 8.5s (20x). The remaining git invocations are local (config/rev-parse), zero network ls-remote.
Review — BLOCKHead SHA: Change class: code/config + schema (runtime cache in Blocks
Comment dispositions
Verdict: BLOCK ollama/deepseek-v4-flash — pi-review-action. |
… see live commits Caching GitResolveRef broke the DownloadRepo freshness contract: a mutable branch (main) that moved upstream was served stale because the cache returned the old commit. TestDownloadRepoFrom_RefreshesMovedBranch proves the regression. GitResolveRef must resolve the CURRENT commit on every call, so its result is deliberately NOT cached. The safe caches remain: GitLatestTag and GitDefaultBranch (immutable data — tags never move, the default-branch NAME is stable). Measured on the charly repo project, warm: charly status 168s -> 89s (47%), freshness contract intact.
Review — BLOCKHead SHA: Change class: code/config + schema (runtime cache in Blocks
Comment dispositions
Verdict: BLOCK ollama/deepseek-v4-flash — pi-review-action. |
Review — BLOCKHead SHA: Change class: code/config + schema (runtime cache in Blocks
Comment dispositions
Verdict: BLOCK ollama/deepseek-v4-flash — pi-review-action. |
Review — BLOCKHead SHA: Change class: code/config + schema (runtime cache in Blocks
Comment dispositions
Verdict: BLOCK ollama/deepseek-v4-flash — pi-review-action. |
Review — BLOCKHead SHA: Change class: code/config + schema (runtime cache in Blocks
Comment dispositions
Verdict: BLOCK ollama/deepseek-v4-flash — pi-review-action. |
Review — BLOCKHead SHA: Change class: code/config + schema (runtime cache in Blocks
Comment dispositions
Verdict: BLOCK ollama/deepseek-v4-flash — pi-review-action. |
|
Closing: the feat/latest-tag-cache branch accumulated a bad merge commit (fb67cb0) that pulled 14 main commits (PRs #53-61) into the branch. GitHub's PR diff uses the recorded base.sha, so the diff shows 24 files instead of the 3 the tree actually changes. The head branch cannot be changed via the API, and force-push is forbidden by the org rules, so this PR is closed and reopened as a clean PR from feat/latest-tag-cache-v2 (live main + only the 3 refs files). |
…us 168s -> 89s (#208) (#62) GitLatestTag and GitDefaultBranch run git ls-remote — a NETWORK operation — for every version-less @github ref the resolver walks. A charly status on a project whose closure carries hundreds of version-less refs paid for that round-trip once per ref PER RESOLUTION — measured at 366 git-remote-https invocations and ~140s of futex wait (issue #208). Fix: a TTL-bounded persistent cache (1h, latest-tags.json beside the repo cache) for both latest-tag and default-branch lookups. Tags and default branches are effectively immutable (add-only), so a stale entry is at worst one tag behind. Measured: charly status 168s -> 89s on the charly repo project. Adds TestLatestTagCacheRoundTrip. NOTE: this branch is a clean rebuild (v2) of feat/latest-tag-cache, which had accumulated unrelated changes via a bad merge; PR #56 head is repointed here. Co-authored-by: atrawog <[email protected]>
Summary
Fixes opencharly/charly#208: charly status takes 167-180s warm. Root cause: GitLatestTag and GitDefaultBranch run git ls-remote (a NETWORK operation) for every version-less @github ref the resolver walks. A charly status on a project whose closure carries hundreds of version-less refs paid for that round-trip once per ref PER RESOLUTION — measured at 366 git-remote-https invocations and ~140s of futex wait.
Fix: a TTL-bounded persistent cache (1h, latest-tags.json beside the repo cache) for the latest-tag and default-branch lookups. Tags never move and the default-branch NAME is stable, so a stale entry is at worst one tag behind. GitResolveRef (the DownloadRepo freshness check) is deliberately NOT cached — the freshness contract requires seeing the live commit of a mutable branch (refs/git_test.go TestDownloadRepoFrom_RefreshesMovedBranch).
The cache writes are guarded by the advisory file lock (spec/lock, the same primitive the repo fetch uses): withLatestTagCacheLock serializes the load → mutate → save cycle, so concurrent resolvers cannot lose updates or corrupt the file. Reads stay lock-free (a stale read is harmless).
How tested
Unit:
Live timing on the charly repo project (a charly binary built with this spec via a replace directive; warm cache after one cold run):
Before the fix: 167-180s warm (measured with the unpatched binary). After: 89s warm — a 47% improvement. The remaining ~89s is the DownloadRepo freshness check (183
git ls-remote <repo> main ...calls), which must stay uncached to honor the freshness contract; the latest-tag and default-branch network calls are eliminated (strace: zero--tags/--symrefgit calls on the warm run).Note: an earlier iteration also cached GitResolveRef, which brought the warm run to 8.5s but BROKE the freshness contract (TestDownloadRepoFrom_RefreshesMovedBranch failed — a moved branch served stale). That iteration was reverted; the freshness contract is the load-bearing invariant.
Rulebook compliance
Change classification
Assisted-by: pi openrouter/deepseek/deepseek-v4-flash-0731 (analysed on a live system)