Repository navigation
feat(service): wait_for — a declared readiness precondition on a service start - #60
Merged
Merged
Conversation
…ice start
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
Review — PASSHead SHA: Security screen: PASS — no scope mismatch, no secrets/exfiltration, no weakened guardrails, no supply-chain changes; diff matches the description exactly. Checklist: All applicable rules PASS or NA.
Verdict: PASS ollama/deepseek-v4-flash — pi-review-action. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
specleg of batch B2's last item, and the highest-leverage one: it exists to delete realduplication rather than to add surface.
Nine hand-rolled versions of the same poll exist in the candy corpus today — labwc,
kde-selkies ×2, chrome-cdp, wayvnc ×3, 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:
And one of them is already wrong.
pod-labwc/labwc-wrapper:It declares 30 seconds and sleeps 0.5s per iteration while counting
+1, so it actually gives upafter 15. That is the failure mode a hand-rolled loop has and a declared one cannot.
Two design decisions worth stating
pathsis required and non-empty (paths!: [_, ...]). Await_forwaiting for nothing is ano-op that reads like a guard, which is worse than no guard at all.
That requirement is only enforceable under final validation — the structural form accepts the
empty case. My first version of the test used the structural helper and passed vacuously; it is
now
unifyDefFinal, and it caught the schema genuinely not requiring the field untilpaths!wasused.
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 toolthe base images do not all carry, so it waits for a real second consumer rather than being designed
against a hypothetical one. R3's trigger is the second occurrence.
timeoutaccepts"30s"or a bare30, matchingstop_timeoutrather than inventing a secondconvention.
How tested
Coverage that fails without the change
Reverting only the implementation (both schema files, the generated Go, and the projection) while
keeping the tests — they do not even compile:
An earlier attempt at this control used
git stash, which stashed the tests too and passedvacuously — the same trap as the validation helper. The control above reverts implementation files
by name.
Gates
Rulebook compliance
/charly-image:layer(theservice:schema and init polymorphism) loaded before editing.passing vacuously under structural validation, and the
git stashcontrol being vacuous.stop_timeout's string-or-intshape rather than adding a parallel convention.
declaration each init lowers natively.
git statuschecked; branch off freshmain; no force-push, no bypass.Change classification
cue:gen+ module suite + lint + revert-controlled coverage.analysed on a live system— the schema and projection are exerciseddirectly, but nothing lowers
wait_forinto a real pre-start yet.Not covered — and why the migration is separate
The lowering. Each init lowers this in its own idiom: systemd
ExecStartPre=, supervisord arendered pre-exec ahead of
command=, OpenRCstart_pre(). That is theplugin-init+charlylegs, landing next, and the reason this PR claims nothing about emitted units.
The point of lowering it per-init rather than emitting a wrapper is that the wait becomes
supervised: a timeout fails the unit and surfaces in its status, instead of a wrapper exiting
non-zero and looking like a crash.
Migrating the nine wrappers is deliberately not bundled here. Their honest gate is
check-selkies-labwc-podand friends staying green while the loops are deleted — beds that buildpixelflux from source and Chrome from the AUR. Bundling an unrunnable gate into this cutover would
make the whole thing unprovable; the migration is its own unit, and the
labwctimeout bug above isits first fix.
Assisted-by: Claude Code Anthropic Opus 5 (analysed on a live system)