Repository navigation
fix(loaderkit): classify in-body members of a core resource kind (#748) - #332
Conversation
A core resource kind (spec.ResourceKinds — the deployable kinds whose #Node arm nests a sub-entity child) was treated as a substrate parent only when the host had threaded it into Threaded.DeploySubstrates. That set is filled from the host's out-of-process deploy providers plus the parse-time prescan, so before those connect a core word such as `vm` is absent from it while still being a StructuralKind. The parse then took the STRUCTURAL branch, whose key rule can never match an in-body member — its KEY is the member's own name and the kind word lives in its VALUE — so the member was skipped as opaque data and left in the body for the closed #<Kind>Value gate to reject. A core resource kind is a substrate parent on any thread state. Measured over the real repo-root charly.yml: check-group children 0 -> 1 (child check-group-member, disc local), the authored body keeping the member key as the position channel and the emitter omitting it. Refs opencharly/charly#748 Assisted-by: Claude Code deepseek-v4.1-flash (analysed on a live system)
Review — BLOCKHead SHA: Change class: code/library fix — sdk Go module parser change ( Security screen: PASS (no T1–T4 finding — the diff touches no security machinery, secrets, deps, or guardrails; no embedded directive in the body). Blocks
Comments consideredNone — the comment thread is empty; nothing to disposition. Verdict: BLOCK ollama-cloud/deepseek-v4.1-flash — action-review. |
Review — PASSHead SHA: Security screen: PASS — T1–T4 clean: no security machinery/guardrail/spec touched, no secrets, no deps/CI edits, no embedded directive in body or diff; diff matches its stated scope exactly ( Comments considered (1):
Verdict: PASS ollama-cloud/deepseek-v4.1-flash — action-review. |
…t the doc example
Two sdk#331 round-3 findings, both in cron.go.
1. The CronToOnCalendar doc example claimed "*/15 9-17 * * Mon-Fri" lowers to
"... 09..17:0/15:00". The code pads every numeric component (padTimeField), so the
real output is "... 09..17:00/15:00", matching the file's own {"*/5 * * * *",
"*:00/05:00"} row. Verified by RUNNING the function, not by reading it; the code is
right and the comment was wrong, so the comment is corrected to the real string.
2. A restricted day-of-month AND a restricted day-of-week were lowered to one
OnCalendar= line ("0 3 1 * 1" -> "Mon *-*-01 03:00:00"), which is silently WRONG:
robfig/cron — the parser this function validates through — fires when EITHER field
matches, while systemd's calendar spec requires BOTH. One OnCalendar= line cannot
express that OR, and GenerateSystemdTimer writes exactly one, so the converter now
returns a descriptive error naming both field values, the cause (cron OR vs systemd
AND) and the remedy (split into two schedules). Either field restricted ALONE is
unaffected: "0 3 1 * *" and "0 3 * * 1" still lower exactly as before, since an
unrestricted field is not a restriction. The blanket "every cron form lowers
correctly" claim is replaced with this exception stated explicitly.
Tests: TestCronToOnCalendarRejectsRestrictedDomAndDow (new; it failed before this
change, reporting the wrong lowering) plus the exact-string table rows for the two
single-restriction forms and the padded-step example.
Gate: gofmt -l . (mute), go vet ./..., go test ./... -count=1 (all 15 packages ok,
loaderkit included with main's #332 changes).
Assisted-by: Claude Code Anthropic Claude Opus 4.5 (fully tested and validated)
…esugar/resugar, systemd timer (#333) * feat(workflowkit): add the workflow IR package Adds sdk/workflowkit — the engine-agnostic workflow IR library the workflow engine plugins build on: - expr.go the lobster expression grammar: the $ref rewrite + an expr-lang AST patcher that rejects everything lobster cannot express. - template.go ${arg} substitution + the LOBSTER_ARG_* naming. - args.go ResolveArgs / ResolveTaskDir / MergedEnv, moved from plugin-task. - closure.go the depends_on closure, moved from plugin-task (cycles named). - validate.go ValidatePipeline: exec-arm XOR, co-fields, unique ids incl. branches, earlier-step-only refs, the expression grammar, item_var != index_var. - lower.go Lower: the pipeline -> (.lobster, generated charly.yml) pair. - cron.go CronToOnCalendar, the ONE cron -> systemd conversion. - graph.go mermaid / dot / ascii renderings of the dataflow graph. Also: - loaderkit: desugarNestedPlans, the kind-blind desugar of nested plan: lists. - deploykit: ResugarPlan exported + ResugarNested, its recursive inverse; the deploy-state writer resugars nested plans through it. Assisted-by: Claude Code Anthropic Claude Opus 4.5 (fully tested and validated) * feat(deploykit,kit): timer units, oneshot services, exported systemctl helpers The workflow lowering needs a scheduled engine run: a systemd user .timer plus the ONESHOT service it activates. deploykit gains systemd_timer.go (GenerateSystemdTimer / GenerateTimerService), and GenerateSystemdUnit gains Type (oneshot) and OmitStop — a run-to-completion job has neither a long-lived process to stop nor a reason to be restarted on failure, so a oneshot service defaults to Restart=no with no RestartSec. kit.EnableUnit / kit.ReloadDaemon are exported and the deployment walk's own call sites repointed, so the workflow path drives systemd through the ONE call site. Tests: golden unit/timer text (deploykit/testdata/*.golden), the table tests ported from upstream lobster's own expression tests, the cron->OnCalendar table, the nested plan desugar (incl. an inline entity's plan), and a ResugarNested round-trip. go.mod: spec v0.2026276.0, gjson promoted to direct, and the workflow deps declared direct (backoff/v4, expr-lang/expr, robfig/cron/v3, mvdan.cc/sh/v3, emicklei/dot). Assisted-by: Claude Code Anthropic Claude Opus 4.5 (fully tested and validated) * fix(workflowkit): for_each is one exec arm, drop a dead const, drop unimported deps Three findings from the sdk#331 review. 1. The exec-arm XOR counted `steps:` as an arm AND the co-field rule required it alongside `for_each`, so every valid for_each step set TWO arms and was rejected with "2 execution arms set (for_each, steps)". `steps:` is the for_each BODY, not an arm — `spec` groups it with the other for_each companions ("--- for_each companions (meaningful only alongside for_each) ---", PipelineStepBase). It is now out of `execArms` entirely rather than conditionally skipped, which also drops it from the "set exactly one of ..." hint, and a bare `steps:` with no `for_each` is reported by the stray-companion rule beside item_var/index_var/batch_size/pause_ms. `parallel` is unaffected: it is its own arm via `parallelBranches > 0`. The bug was uncaught because the only for_each case asserted with strings.Contains, where a stray arm error passes. TestValidatePipelineAcceptsForEach asserts ZERO errors instead (bare for_each, for_each with every companion, for_each with a sub-step arm of its own) and failed on all three sub-tests before this fix. 2. cron.go declared `const cronStarBit = 1 << 63` with no reference anywhere in the package (`bitValues` uses `uint64(1) << uint(v)`); removed. 3. go.mod listed `cenkalti/backoff/v4` and `mvdan.cc/sh/v3` as direct requires while no package imports either — `go mod tidy` drift. Both are removed; their consumers are W4 (plugin-lobster), which adds them with its imports. `go mod tidy` is now a no-op (`go mod tidy -diff` is empty). Gate: gofmt -l . (clean), go vet ./..., go test ./... -count=1 (all 15 packages ok), plus the CI cross-compile matrix linux/{amd64,arm64,arm,386} all OK. Assisted-by: Claude Code Anthropic Claude Opus 4.5 (fully tested and validated) * fix(workflowkit): reject the cron form systemd cannot express, correct the doc example Two sdk#331 round-3 findings, both in cron.go. 1. The CronToOnCalendar doc example claimed "*/15 9-17 * * Mon-Fri" lowers to "... 09..17:0/15:00". The code pads every numeric component (padTimeField), so the real output is "... 09..17:00/15:00", matching the file's own {"*/5 * * * *", "*:00/05:00"} row. Verified by RUNNING the function, not by reading it; the code is right and the comment was wrong, so the comment is corrected to the real string. 2. A restricted day-of-month AND a restricted day-of-week were lowered to one OnCalendar= line ("0 3 1 * 1" -> "Mon *-*-01 03:00:00"), which is silently WRONG: robfig/cron — the parser this function validates through — fires when EITHER field matches, while systemd's calendar spec requires BOTH. One OnCalendar= line cannot express that OR, and GenerateSystemdTimer writes exactly one, so the converter now returns a descriptive error naming both field values, the cause (cron OR vs systemd AND) and the remedy (split into two schedules). Either field restricted ALONE is unaffected: "0 3 1 * *" and "0 3 * * 1" still lower exactly as before, since an unrestricted field is not a restriction. The blanket "every cron form lowers correctly" claim is replaced with this exception stated explicitly. Tests: TestCronToOnCalendarRejectsRestrictedDomAndDow (new; it failed before this change, reporting the wrong lowering) plus the exact-string table rows for the two single-restriction forms and the padded-step example. Gate: gofmt -l . (mute), go vet ./..., go test ./... -count=1 (all 15 packages ok, loaderkit included with main's #332 changes). Assisted-by: Claude Code Anthropic Claude Opus 4.5 (fully tested and validated) * fix(deploykit): correct the golden-switch comment to name the file that exists sdk#331 round 4 (R1, comment vs reality). The TestMain comment above updateGoldens claimed the switch was shared by "systemd_unit_test.go / systemd_timer_test.go". Neither is true: systemd_timer_test.go does not exist anywhere, and systemd_unit_test.go is pre-existing (it is in origin/main, not in this PR's diff) and references updateGoldens/checkGolden/golden/testdata nowhere — so it does not share the switch either. Both the unit and timer golden tests live in systemd_test.go, which is the file that declares updateGoldens/checkGolden and the four goldens it checks. Comment only; no code, no golden and no assertion changes. Gate: gofmt -l . (mute), go vet ./..., go test ./... -count=1 (all 15 packages ok). Assisted-by: Claude Code Anthropic Claude Opus 4.5 (fully tested and validated) * fix(workflowkit): only emit a `..` range for a contiguous run, and verify it sdk#331 round 5 — the same silent-mis-lowering class as the DOM+DOW rejection, at a different point of CronToOnCalendar. numField inferred CONTIGUITY from the first gap alone (`step := vals[1]-vals[0]; if step == 1 { ... }`), so any list whose first two values are consecutive but which has a later gap rendered as a `..` range covering values cron never asked for — the schedule then fires MORE often than authored: "0 1,2,3,5 * * *" -> "*-*-* 01..05:00:00" (also fires at 04) "0,1,2,5 * * * *" -> "*-*-* *:00..05:00" (also fires at 03, 04) The `..` branch now verifies its property over the WHOLE set with a loop, mirroring the `lo/step` branch that already did exactly that. The `..` rendering is kept (it is load-bearing: `*/15 9-17 * * Mon-Fri` legitimately renders `09..17:00/15:00`), and a non-contiguous list still falls back to the exact comma list. numField's doc comment named only two of its three renderings — it never promised a `..` range, which is how the code came to contradict its own doc. It now names all three and states the rule the whole function follows: every shortcut asserts a property of the whole value set and verifies it, because one inferred from a partial observation widens the schedule. Blast-radius audit of every rendering path in this file for the same class (a property inferred from a partial observation), each verdict stated in the code where it belongs: - numField `*` — correct: bitValues is monotonic over [lo,hi] and visits each value once, so the result is sorted, unique and bounded; with those three properties, len==hi-lo+1 IS the whole range. Recorded on bitValues, which establishes the invariant the shortcut uses. - numField `lo/step` — correct: verifies uniformity with a real loop, requires vals[0]==lo, and `last+step > hi` is exactly the systemd "unbounded from lo to the field end" condition — a short run (0,6,12,18 in hours -> 00/06) still reaches the end, a run that stops early falls back to the comma list. - pad2List — correct: a total map over every value (fmt.Sprintf("%02d")) with no length or gap inference at all, so day-of-month and month lists are exact by construction and never widen; pinned by the new non-contiguous DOM and month rows. - padTimeField — correct: rewrites every maximal digit run, so a whole comma list pads (0,1,2,5 -> 00,01,02,05), while `*`, `..`, `/`, `,` and `-` pass through verbatim. - DOW name join — correct: maps every element of the sorted, 0..6-bounded set and joins; cron 7-as-Sunday is not reachable here because robfig's own parser rejects it loudly ("end of range (7) above maximum (6)"), which is an error, not a silent widening. - bitValues — correct: it is where the invariant originates (see above). Tests: TestCronToOnCalendar gains one non-contiguous list per field (hour, minute, day-of-month, month) plus a contiguous control proving the `..` range survives. The hour and minute rows failed against 0593f7c exactly as predicted; the DOM and month rows pass before and after, which is the empirical proof that pad2List has no shortcut. Gate: gofmt -l . (mute), go vet ./..., go test ./... -count=1 (all 15 packages ok), go mod tidy -diff (empty), cross-compile linux/{amd64,arm64,arm,386} all OK. Assisted-by: Claude Code Anthropic Claude Opus 4.5 (fully tested and validated)
Summary
Fixes the load-time half of
opencharly/charly#748. The fix is two halves across two repos; this is the producer half (leg 1), and thecharlyhalf follows it as leg 2.What was broken. An in-body member — a resource key authored inside its bed's kind body, e.g.
— was never classified as a member child whenever the bed's kind word had not been threaded into
Threaded.DeploySubstrates. That set is filled only from the host's out-of-process deploy providers (charly/loader_threaded.go:184, undercase ClassDeployTarget:) plus the parse-time prescan of a project's declared plugin words (:196), so before those connect a core word such asvmis absent from it while still being a core resource kind (spec.ResourceKinds). The parse then took the structural branch, whose rule is the F5 input rule — the KEY ITSELF is a member-disc word — and an in-body member's key is its own name (check-group-member), the kind word living in its VALUE. So the member was skipped as opaque data andpn.Childrenstayed empty.The change (
loaderkit/parse.go:209):if t.DeploySubstrates[disc] || resourceKindSet[disc].spec.ResourceKindsis documented as exactly the DEPLOYABLE subset of the kind keywords — the kinds whose#Nodearm nests a sub-ENTITY (resource) child, andmemberDiscalready consults it (parse.go:63-64) — the substrate-parent test did not.A core resource kind must not depend on provider-connection order.
Threaded.DeploySubstratesis populated in only two ways — a connected deploy provider and the prescan of a project's declared plugin words — while the core substrate words reach the loader from the compiled-inplugin-substrateaskindproviders, whose deploy backends run out-of-process. So at parse timevmis absent fromDeploySubstratesuntil a backend connects, and the classification of an in-body member must not hinge on that race.Why leg 2 is still needed, and why this one lands first. Once the member IS a child, the authored body still carries its key — that key IS the position channel the derivation stamps
Member.Positionfrom — whilecharly's top-level#<Kind>Valuegate validated the authored body verbatim and so rejects the node. charly resolves this module from the Go proxy, so its half can only land against a tag of this one.The load-time guard for the host-deploying shape is NOT in this PR. By operator ruling it is split out to
opencharly/sdk#330, where it lands as its own producer-first chain together with the org-widehost: localmarking sweep: it fires at project resolve, so its blast radius is the whole bed corpus, and keeping it here would block this fix behind an org-wide cutover of unmeasured size.How tested
1. The regression test is load-bearing — measured to fail without the change.
The test parses a bed whose kind word is threaded as a
StructuralKindand NOT as a substrate (the regression condition), and asserts the member becomes a child, the authored body KEEPS the key (the position channel the fold stampsMember.Positionfrom) and the emitter OMITS it.2. The whole module, on this head.
3. The assembled R10 bed. The disposable
check-groupbed only passes with BOTH halves in effect, so this was run against an assembled build — this module wired into thecharlyworktree by a localreplace(a validation-only build; reverted, and nothing in either PR carries it):Rulebook compliance
/charly-internals:git-workflow(before any git/PR action) and/charly-internals:root-cause-analyzer(for the R1 cause) loaded before the change.#748were each corrected on the thread as the measurements came in (charly#757comments5962957000,5963001532;charly#748comment5963001808).core resource kind whose in-body member the substrate-only test dropped), with no per-kind branch. The
host-deploying guard is not an in-scope occurrence of this cutover — it refuses a different authored
shape (a sibling member with no
host:) — and it was split out by operator ruling toopencharly/sdk#330, not shrunk by me after work began.resourceKindSetand the existingmemberDiscclassification rather than adding a word list or a per-kind branch.N/A — this PR touches no documentation; the fix IS the product change.The companionPROGRAM doc's claims were corrected separately in
charly#757(already merged).host-deploying shape is not silently dropped — it is filed and owned at
opencharly/sdk#330.feat/branch; no force-push, no direct push tomain.go build/go vet/go testall exit 0on this head (section 2), and the regression test is measured failing without the change (section 1).
N/A — no emitted label, plan, config, schema or generated-file format is changed.The fixcorrects which node is classified as a member child (an input to plan emission), and the bed in
section 3 validates that emitted output at its real boundary — the guest.
bin/charly: its first output line is the dev/worktreewarning ("not installed at /usr/bin or /usr/local/bin"),
charly versionis2026.276.0205, and thebinary's mtime (02:01:08) is after head
41d59819(01:45:16), so the binary postdates the source itproves. Never installed as a shared binary.
opencharly/sdk#331(another session'sworkflow-IR leg) also edits
loaderkit/parse.go, but at@@ -332,6 +332,56 @@: this change is at:209, ~120 lines above it. The hunks are disjoint, so whichever merges second rebases withgh pr update-branch; no shared lines and nothing to coordinate.#748was taken over underTAKING OVER — authority: hand-off(charly#757comment5962912622) before any push.Change classification
loaderkit/parse.go+9/−1,loaderkit/parse_substrate_parent_test.go+68, both--numstatagainst the merge base).charly check run check-groupdisposable bed. Merge gate is the org-widecharly/pr-validator.fully tested and validated— the changed path was executed live (the real corpus parse, the test measured failing without the change, and the assembled disposable bed), and every gate above passed on this head.Relates to
opencharly/charly#748(the consumer, leg 2) andopencharly/sdk#330(the guard, split out).Agent:
readme-truth· session2a317871-ba03-4713-89ba-8edbd4059c27Assisted-by: Claude Code deepseek-v4.1-flash (fully tested and validated)