Skip to content

feat(sdk): workflowkit (lobster IR helpers + lowering), nested plan desugar/resugar, systemd timer - #333

Merged
github-actions[bot] merged 7 commits into
mainfrom
feat/workflow-ir-w1
Oct 3, 2026
Merged

github-actions[bot] merged 7 commits into
mainfrom
feat/workflow-ir-w1

Conversation

@aitrawog

@aitrawog aitrawog commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Wave W1 of the workflow-IR work: the sdk half of making kind:pipeline speak lobster
syntax while executing the full charly plugin grammar.

Tracks opencharly/charly#758 (the workflow-IR epic) — this is wave W1 of its producer-first chain.

Supersedes #331 — which the gate auto-closed at the block limit (AI_REVIEW_AUTO_CLOSE_AFTER=5).
The closure was a policy action, not a code finding: re-running the validator against the same
head only grows the thread. The closed thread is no longer acted on; this is the live one.
Every finding from a BLOCK verdict on #331 is fixed here, each in a single commit (never
re-argued, never a partial fix): round 1 → f8ab8cc, round 3 → a5b81bf, round 4 → 0593f7c,
round 5 → 6052e1f. This PR's head carries all of them.

  • sdk/workflowkit (NEW, 8 files) — the kind-blind IR helpers the lobster engine and the
    lowering both build on:
    expr.go (lobster $ref grammar over expr-lang/expr + gjson), template.go
    (${arg} + LOBSTER_ARG_*), args.go (ResolveArgs/ResolveTaskDir), closure.go
    (DFS cycle path), validate.go (ValidatePipeline), lower.go (Lower),
    cron.go (CronToOnCalendar), graph.go (mermaid/dot/ascii), plus 8 test files and
    6 .golden fixtures.
  • loaderkit/parse.go — desugarNestedPlans: a recursive, kind-blind desugar of any nested
    plan: sequence of mappings, stopping at member-kind keys.
  • deploykit — resugarPlan → exported ResugarPlan; new ResugarNested(node, primaries)
    (the recursive inverse); SystemdUnitConfig gains Type/OmitStop; new
    systemd_timer.go with GenerateSystemdTimer + GenerateTimerService.
  • kit — enableUnit/reloadDaemon exported as EnableUnit/ReloadDaemon, internal
    callers repointed.
  • Tests outside workflowkit — deploykit/systemd_test.go plus its four
    deploykit/testdata/*.golden (systemd-oneshot.service, systemd-unit.service,
    systemd-timer.service, systemd-timer.timer), and loaderkit/nested_desugar_test.go.
  • go.mod / go.sum — exactly five direct requires change: spec v0.2026273.203 →
    v0.2026276.0 (the W0 tag); tidwall/gjson v1.19.0 promoted to direct; and three
    additions, each with an importing file in this diff — expr-lang/expr v1.17.8 (expr.go),
    robfig/cron/v3 v3.0.1 (cron.go), emicklei/dot v1.11.0 (graph.go). go mod tidy -diff
    is empty.

Three decisions worth naming, each taken from a live read rather than an assumption:

  1. The systemd timer lives in deploykit, not in the new plugin. GenerateSystemdUnit
    emits Type=simple with a conditional ExecStop, and its argv escaper is unexported.
    A timer-triggered job needs a oneshot with no stop. Putting GenerateSystemdTimer in
    deploykit reuses that escaper without exporting an escaping primitive into the public
    API
    .
  2. The lowered charly.yml flat-imports the project's charly.yml BY FILE PATH. The
    loader reads a flat (non-@) import entry straight with os.ReadFile and never joins it
    against a directory, so a flat import pointing at a directory silently fails; only an
    @-namespaced entry is stat'ed and joined with the unified file name. A file path is the
    one form that works. The generated file carries that reasoning as a comment.
  3. The lowering emits --output, never plugin-task's internal --json. --json is
    plugin-task's user-facing listing shape; --output (added by W3) is the final step's
    raw stdout, which is what lobster's $id.json must parse. W1's own goldens assert
    generated text only, so no live flag is needed at this gate.

Lower produces the env: {REF_n: $id.path} + -p REF_n="$REF_n" pair so a lobster ref
reaches the charly step shell-safely, and quotes charly: argv with spec.ShellQuote
(no hand-rolled quoting).

Review round 1 — BLOCK, all four findings fixed in ONE commit (f8ab8cc)

The first verdict blocked. Every finding is addressed in a single commit; none was re-argued.

  1. A real bug in this wave's core deliverable. validateStepBase listed steps among the
    mutually-exclusive execArms, while spec.PipelineStepBase groups steps under
    "--- for_each companions (meaningful only alongside for_each) ---" — it is the for_each body,
    not an arm. Every valid for_each step therefore set two arms and was rejected with
    2 execution arms set (for_each, steps), i.e. the validator rejected every valid for_each
    pipeline. The PR's own tests missed it because the one for_each case asserted with
    strings.Contains, which masked the spurious error. Fix: steps is removed from execArms and
    moved into the existing stray-companion rule (guarded by v.forEach == "" beside
    item_var/index_var/batch_size/pause_ms), so a bare steps: with no for_each is still
    rejected — one rule for all five companions. parallel is untouched (its own arm via
    parallelBranches > 0).
  2. Dead code dropped. cron.go's const cronStarBit = 1 << 63 was referenced by nothing;
    bitValues reconstructs the bit-set from the field width, so it had no use site.
  3. go.mod drift removed. cenkalti/backoff/v4 and mvdan.cc/sh/v3 were direct requires with no
    importing file in the diff. Their consumers are W4 (plugin-lobster), which adds them together
    with their imports. go mod tidy -diff is now empty; 10 stale go.sum lines went with them.
  4. This body's inventory was corrected — it had claimed "workflowkit … 9 files … plus 5 test
    files"; the diff adds 8 source files and 8 test files (6 goldens, which was right).

New test TestValidatePipelineAcceptsForEach (3 sub-tests: bare for_each; for_each with every
companion; for_each whose sub-steps carry arms of their own). It asserts zero errors, not a
substring. It FAILED against 641f074 with exactly the spurious-arm error:

=== RUN   TestValidatePipelineAcceptsForEach/bare_for_each
    validate_test.go:61: ValidatePipeline rejected a valid bare for_each pipeline:
      step "fan": 2 execution arms set (for_each, steps) — set exactly one of
      run/pipeline/workflow/parallel/for_each/input/steps/plan/charly/approval
--- FAIL: TestValidatePipelineAcceptsForEach (0.00s)

and passes at f8ab8cc, together with the pre-existing TestValidatePipelineRules table including
its new steps_without_for_each case.

Review round 2 — two A1 body findings, both fixed here

Round 2 blocked on the body alone; it re-derived all four round-1 findings against f8ab8cc and
marked every one fixed (steps out of execArms + the zero-error test; cronStarBit gone;
the two unimported requires gone; the counts reconciled), and recorded placement: CORRECT. Both
round-2 findings were mine and are corrected in this revision:

  1. This Summary's go.mod bullet was stale against the commit it describes — it still listed
    cenkalti/backoff/v4 and mvdan.cc/sh/v3 as added, the two the round-1 fix removed. It now
    names exactly the five requires that change.
  2. The Summary under-accounted the diff: it never named deploykit/systemd_test.go, its four
    deploykit/testdata/*.golden, or loaderkit/nested_desugar_test.go. All are now listed.

Full file accounting — 35 files, +2911/-27:

group files
workflowkit 8 source + 8 _test.go + 6 .golden = 22
deploykit deploy_nodeform.go, systemd_unit.go (M); systemd_timer.go, systemd_test.go (A); 4 testdata/*.golden (A) = 8
loaderkit parse.go (M), nested_desugar_test.go (A) = 2
kit walk.go (M) = 1
module go.mod, go.sum (M) = 2

Review round 3 — BLOCK on the merged head 7bfa61d: two CODE findings

Placement re-confirmed CORRECT; every round-1 and round-2 finding re-derived as fixed.
Round 3 raised two code findings, both in workflowkit/cron.go, and both fixed in ONE commit
(a5b81bf):

  1. The doc example stated an output the code cannot produce. The comment claimed
    "*/15 9-17 * * Mon-Fri" -> "Mon,Tue,Wed,Thu,Fri *-*-* 09..17:0/15:00". padTimeField zero-pads
    every numeric component of a rendered field, so the minute step start is 00, not 0 — and the
    file's own table already proved the convention ({"*/5 * * * *", "*-*-* *:00/05:00"}). The
    example also padded the hours (09..17) while leaving the minute step unpadded: internally
    inconsistent, not merely stale. Verified by running the function, not by reasoning:

    "*/15 9-17 * * Mon-Fri"  -> "Mon,Tue,Wed,Thu,Fri *-*-* 09..17:00/15:00" err=<nil>
    "*/5 * * * *"            -> "*-*-* *:00/05:00"                        err=<nil>
    

    The code was right and the comment was wrong, so the comment was corrected and an
    exact-string table row now pins the documented example.

  2. A silently WRONG lowering at cron's divergence from systemd. 0 3 1 * 1 lowered to
    Mon *-*-01 03:00:00 — a restricted day-of-month and a restricted day-of-week on one
    OnCalendar= line. That is wrong semantics: robfig/cron — the parser this function validates
    through — fires when EITHER field matches
    when both are restricted, while systemd's
    OnCalendar= requires BOTH
    . A single line cannot express cron's OR, so the output was
    correct-looking and wrong, and the doc's blanket claim that "every cron form lowers correctly"
    was false exactly there.

    Fix: reject with a descriptive diagnostic, not a second line and not a chosen
    interpretation. CronToOnCalendar returns a single string and GenerateSystemdTimer
    (deploykit/systemd_timer.go:63) writes exactly one OnCalendar=%s line by documented
    contract, so emitting two alternatives would change both APIs — out of scope for this wave. The
    guard is if !domAll && !dowAll (domAll = all 31 days, dowAll = all 7), so it fires only
    when both fields are restricted; an unrestricted field is not a restriction, and the
    single-restriction forms are pinned byte-for-byte in the table:

    "0 3 1 * *"  -> "*-*-01 03:00:00"        (DOM only — unchanged)
    "0 3 * * 1"  -> "Mon *-*-* 03:00:00"     (DOW only — unchanged)
    "0 3 1 * 1"  -> ERROR (the message names both values and the cause)
    

    New test TestCronToOnCalendarRejectsRestrictedDomAndDow — asserts an error, that it quotes
    the expression, names both field values, and explains the either/both divergence with the
    "split it into two schedules" remedy. It FAILED against 7bfa61d:

    === RUN   TestCronToOnCalendarRejectsRestrictedDomAndDow
        cron_test.go:62: CronToOnCalendar("0 3 1 * 1") = "Mon *-*-01 03:00:00" with no error:
          cron ORs day-of-month/day-of-week while systemd ANDs them, so a single OnCalendar=
          cannot express this
    --- FAIL: TestCronToOnCalendarRejectsRestrictedDomAndDow (0.00s)
    

    and passes at a5b81bf, with the full TestCronToOnCalendar table (19 rows) green.

    The doc's blanket claim is gone, replaced by the three working examples plus an explicit
    paragraph naming the rejected form, why it is rejected, and that single-restriction forms are
    unaffected.

No in-repo caller is affected: the only non-test references to CronToOnCalendar are doc
references in deploykit/systemd_timer.go, whose contract (it receives a pre-resolved
OnCalendar string) already places the resolution — and therefore the possible error — at the
caller, which is W4's.

Review round 4 — BLOCK on a5b81bf: ONE finding, a wrong comment

Everything else re-derived as fixed. The round-4 verdict re-derived all four round-1 findings,
both round-2 A1 findings, and all four round-3 findings as fixed at a5b81bf; verified the
accounting then in force (+2881/-27) as truthful against the 35 file headers — the
round-5 fix later added +30 lines, taking the total to +2911/-27; and confirmed the
analysed on a live system tier as honest, not inflated. Security screen PASS, placement
CORRECT.

The one block was R1 — comment ↔ reality, deploykit/systemd_test.go:12, which read:

// systemd_unit_test.go / systemd_timer_test.go share this `-update` switch: ...

Both named files were wrong, and I verified it against the tree rather than taking it on trust:

  • systemd_timer_test.go does not exist anywhere.
  • systemd_unit_test.go does exist but is pre-existing (present in origin/main, absent from
    this PR's diff) and references updateGoldens / checkGolden / golden / testdata
    nowhere — so it does not share the switch either.
  • updateGoldens is declared and used only in deploykit/systemd_test.go, which checks exactly
    four goldens. grep -rn 'updateGoldens\|checkGolden' deploykit/ now returns eight hits, all in
    systemd_test.go
    .

Fixed in 0593f7c — a three-line comment change and nothing else:

// The unit and timer golden tests both live in this file and share this `-update` switch:
// the emitted text is what the operator reads and what systemd parses, so a change to it
// must be a reviewable diff, never a silent drift.

This is the second consecutive round blocked on the same defect class, and it is worth naming
because it is where this wave's remaining risk lives: round 3 blocked on a cron.go comment
asserting an output the code could not produce; round 4 blocks on a systemd_test.go comment
asserting files that do not exist. Both are comments asserting state that does not hold — and a
reader believes them. In an otherwise-clean 35-file wave, the residue was in the prose, not the
code. Every comment in this diff that names a file, symbol, or output has now been checked against
the tree.

Review round 5 — BLOCK, and the finding was a REAL bug (6052e1f)

The gate auto-closed the predecessor on this verdict. The finding was valid and is fixed here.

workflowkit/cron.go numField inferred contiguity from the FIRST gap only. The .. branch read
step := vals[1] - vals[0] and, on step == 1, emitted a RANGE — 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 fires more often than authored:

CronToOnCalendar("0 1,2,3,5 * * *")  ->  "*-*-* 01..05:00:00"   also fires at hour 04  WRONG
CronToOnCalendar("0,1,2,5 * * * *")  ->  "*-*-* *:00..05:00"    also fires at 03, 04    WRONG

This is the same silent-mis-lowering class as the round-3 DOM+DOW finding, at a different point of
the same function — and the sibling lo/step branch directly above it verifies its property with a
loop while the .. branch merely assumed it. numField's own doc comment named only * and lo/step
and said "else a comma list", so the code contradicted its own doc as well as CronToOnCalendar's
"lists, ranges, steps and names all lower correctly".

Fix 1 — the .. branch now verifies contiguity over the whole set, mirroring the /step branch's
existing shape:

if step == 1 {
    contiguous := true
    for i, v := range vals {
        if v != vals[0]+i { contiguous = false; break }
    }
    if contiguous {
        return strconv.Itoa(vals[0]) + ".." + strconv.Itoa(vals[len(vals)-1])
    }
}

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 falls back to the exact comma list.

Fix 2 — numField's doc comment now names all three renderings (*, lo..hi for a contiguous
run, lo/step, else a comma list) and states the rule the function now follows.

Fix 3 — the blast-radius audit (the duty the round-3 fix skipped). Every rendering path in
cron.go was audited for the same class — a property inferred from a partial observation — with a
stated verdict: numField's * branch (correct — bitValues is monotonic and visits each value once,
so the result is sorted/unique/bounded, and with those properties count-equals-range is the whole
range); the lo/step branch (correct — verifies uniformity, requires vals[0] == lo, and
last+step > hi encodes systemd's "unbounded from lo to the field end"); pad2List (correct — a
total %02d map with no length or gap inference at all); padTimeField (correct — rewrites every
digit run, so a whole comma list pads, while *, .., /, , and - pass through); the DOW join
(correct — and cron's 7-as-Sunday is unreachable because robfig's parser rejects it loudly). No
third instance of the class was found.

Fix 4 — the class is now pinned per field, so no field can silently widen:

{"0 1,2,3,5 * * *",  "*-*-* 01,02,03,05:00:00"},   // non-contiguous HOUR
{"0,1,2,5 * * * *",  "*-*-* *:00,01,02,05:00"},    // non-contiguous MINUTE
{"0 3 1,2,3,5 * *",  "*-*-01,02,03,05 03:00:00"},  // non-contiguous DAY-OF-MONTH
{"0 3 1 1,2,3,5 *",  "*-01,02,03,05-01 03:00:00"}, // non-contiguous MONTH
{"0-5 * * * *",      "*-*-* *:00..05:00"},         // contiguous control: `..` kept

The hour and minute rows failed against 0593f7c exactly as predicted:

    cron_test.go:51: CronToOnCalendar("0 1,2,3,5 * * *") = "*-*-* 01..05:00:00", want "*-*-* 01,02,03,05:00:00"
    cron_test.go:51: CronToOnCalendar("0,1,2,5 * * * *") = "*-*-* *:00..05:00", want "*-*-* *:00,01,02,05:00"
--- FAIL: TestCronToOnCalendar (0.00s)

The DOM and month rows pass before and after — the empirical proof that pad2List has no shortcut.

How tested — final head 6052e1f (branch feat/workflow-ir-w1)

main advanced while this PR was open (PR #332, which also touches loaderkit/parse.go), so the
branch was brought up to date with gh pr update-branch (never a force-push), producing the merge
commit 7bfa61d. Because the two changes share loaderkit/parse.go, the gate below was re-run on
the merged tree
, not carried over from the pre-merge head. The round-3 fix (a5b81bf) then
touched only workflowkit/cron.go and workflowkit/cron_test.go, and the round-4 fix (0593f7c)
only a three-line comment in deploykit/systemd_test.go, and the round-5 fix (6052e1f) only
workflowkit/cron.go and workflowkit/cron_test.go — so the diff against the updated main
remains 35 files, +2911/-27, the same 35-file list (+29 from the round-3 fix and the +30
contiguity check from the round-5 fix; round 4 changed no line counts).

Ran exactly this repo's CI gate on the final committed tree
(GOWORK=off GOTMPDIR=~/.cache/go-tmp TMPDIR=/tmp/cs):

$ gofmt -l .
$ echo rc=$?
rc=0
$ go vet ./...
$ echo rc=$?
rc=0
$ go test ./... -count=1
ok  	github.com/opencharly/sdk	0.323s
ok  	github.com/opencharly/sdk/agentkit	0.688s
ok  	github.com/opencharly/sdk/buildkit	0.026s
ok  	github.com/opencharly/sdk/candywalk	0.016s
ok  	github.com/opencharly/sdk/charlylib	0.018s
ok  	github.com/opencharly/sdk/checkkit	0.037s
ok  	github.com/opencharly/sdk/cmd/charly-lib-gen	0.006s
ok  	github.com/opencharly/sdk/deploykit	5.139s
ok  	github.com/opencharly/sdk/enginekit	0.012s
ok  	github.com/opencharly/sdk/kit	11.739s
ok  	github.com/opencharly/sdk/llmkit	2.114s
ok  	github.com/opencharly/sdk/loaderkit	1.002s
ok  	github.com/opencharly/sdk/packagekit	0.052s
ok  	github.com/opencharly/sdk/vmshared	0.145s
ok  	github.com/opencharly/sdk/workflowkit	0.016s
$ go mod tidy -diff
$ echo rc=$?
rc=0

The three cron tests on this head: TestCronToOnCalendar, TestCronToOnCalendarRejectsBadInput,
and the new TestCronToOnCalendarRejectsRestrictedDomAndDow — all PASS. The Lower goldens are
TestLowerGolden, TestLowerCharlyStep, TestLowerNestedPlan, TestLowerRejectsInvalid. The repo
also carries a cross-compile job; it was re-run on this head too — linux/{amd64,arm64,arm,386}
with CGO_ENABLED=0 → OK on all four. go mod tidy -diff is empty on this head (rc=0).

R10 — the assembled bed is CARRIED to W6, and this is NOT a waiver. This repo is a pure
library with no charly.yml; the beds that gate it (B1/B2/B3/B5) compose plugin-lobster and
the plugin-pipeline cutover, neither of which exists until W4/W6. The bed therefore
cannot run against this tag, and W6 must paste B1/B2/B3/B5 against it; if anything there
fails, the failure reopens this scope rather than W6's. No library waiver is claimed.

Rulebook compliance

Every rule R0–R10 is answered below; none is left implicit.

  • R0 — Skills first. The dispatcher-selected skills were loaded before the first action, and
    charly's own rulebook (charly/AGENTS.md) was read for the R-rules this section answers.
  • R1 — RCA every anomaly. Every non-obvious decision above was read from live source
    (systemd_unit.go, walk.go, cli.go, migrations.cue), not inferred. The two round-3
    findings were both R1 items and are fixed rather than narrated: the cron.go example that
    stated an output the code cannot produce, and the DOM+DOW lowering that silently encoded
    systemd's AND where cron means OR.
  • R2 — Finish the whole cutover. Within sdk the cutover is complete — the moved helpers exist
    exactly once, here. The duplicate copies live in plugin-task, a different repository; their
    deletion is W3, a named, sequenced PR that is blocked on this tag and cannot land before it.
    That is a cross-repo producer/consumer sequence, not a deferral, a partial rename, or a hidden
    follow-up inside this repo.
  • R3 — No duplication. resugarPlan is exported and its caller repointed rather than
    duplicated; the desugar/resugar pair is one implementation each. Lower and the validator are the
    single implementation of their behaviour, consumed by more than one plugin.
  • R4 — No workarounds. No sleeps, blind retries, suppressions, or fallback branches. The
    import: constraint was solved by using the loader's real contract, not by writing around it.
    The DOM+DOW case is rejected with a diagnostic rather than silently mis-lowered — a loud
    failure, not a workaround.
  • R4a — Fix the product first; documentation never routes around a defect. Applied in both
    directions on the round-3 findings, by first establishing which side holds the intent:
    the 0/15 example was a prose error (the code's 00/15 padding is intended and its own
    table proves it), so the comment was corrected; the DOM+DOW lowering was a code defect, so
    the code was fixed and the doc's blanket "every cron form lowers correctly" claim was
    narrowed to match. No doc was edited to hide a bug.
  • R5 — Delete legacy completely. The unexported helpers were renamed to exported ones, not
    shadowed by copies; the retired forms are removed in the same change, not left alongside.
  • R6 — Git safety. No force-push, no hook bypass, no direct push to main. The BEHIND branch
    was recovered with gh pr update-branch, never a force-push.
  • R7 — Prove the gate, not the plan. The gate is proven on the final committed tree
    (6052e1f), never on a plan, a description, or an edited working state: gofmt -l .,
    go vet ./..., go test ./... -count=1, go mod tidy -diff and the four-target cross-compile
    were all re-run on that exact commit and their output is pasted verbatim above.
    ./charly/bin/charly task verify is the umbrella's pinning gate and has no sdk-local
    meaning — sdk is not the umbrella root and records no gitlinks; the umbrella runs it at its own
    task sync wave, and this PR pins nothing.
  • R8 — Preserve emitted artifacts. Every user-visible output this change produces — the
    lowered charly.yml, the workflow.lobster text, and the systemd unit/timer text — is pinned by
    an exact golden file (TestLowerGolden, TestLowerCharlyStep, TestLowerNestedPlan, and the
    four deploykit/testdata/*.golden), so a change in emitted bytes fails the gate rather than
    shipping. The stronger check, running the generated charly.yml through
    charly box validate, is a bed step in B1's pipeline-emit-lowering and therefore belongs to the
    carried bed (see R10), not to this repo's unit gate; this PR does not claim it.
  • R9 — Binary equals source. N/A — reason: sdk is a pure Go library with no charly.yml
    and no binary; this change builds and installs nothing, so there is no worktree-local binary whose
    version or gitlink consistency could drift.
  • R10 — Fresh disposable proof. Stated above, with the carry named: the assembled bed is carried
    to W6 by name, and W6 must paste B1/B2/B3/B5 against this tag.

R3 is transiently open, deliberately. plugin-task still holds its own copies of
resolveParams/resolveTaskDir/expandVars/closure. Deleting them is W3's step, in a
different repo; until W3 lands the two copies coexist by design, not by oversight.

Change classification

  • Change class: library (kind-blind SDK helpers) — additive.
  • Verification gate: the three CI commands above, run on the final tree.
  • Attribution tier: analysed on a live system — the changed code paths (the lowering,
    the expression grammar, the desugar/resugar pair, the timer generator) are executed live by
    the unit and golden tests with retained output, but the full R10 bed did not pass and is
    carried to W6 as stated above.

Agent: workflow-ir · session session_01MSxu48GQwoQuBkfwQrkntk
Assisted-by: Claude Code deepseek-v4.1-flash:cloud (analysed on a live system)

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)
…l 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)
…nimported 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)
…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)
…at 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)
…rify 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)
@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown

Review — BLOCK

Head SHA: 6052e1f689c3a4f0471d68194f8bf101365eb9fb (branch: feat/workflow-ir-w1)

Change class: library/SDK code (additive) — new workflowkit package, plus deploykit/loaderkit/kit edits and go.mod/go.sum.

Comment thread: empty (0 comments) — nothing to re-derive; no maintainer sign-off is required for this non-security-machinery change.

Security screen: PASS (no T1–T4 finding). No secrets/egress, no guardrail weakening, no scope mismatch — every diff item is named in the body; the three new modules (emicklei/dot, expr-lang/expr, robfig/cron/v3) are plain libraries each imported by a file in this diff, and gjson is only promoted indirect→direct. I verified the substantive round-1…round-5 fixes still hold in the CURRENT diff (steps absent from execArms and present in the stray-companion rule; no cronStarBit; no cenkalti/backoff/mvdan.cc/sh requires; the numField contiguity loop; the DOM+DOW rejection; the corrected systemd_test.go comment).

Blocks

  1. A1 / R1 — the body states two contradictory line totals for the same 35-file diff.

    • "Full file accounting" says 35 files, +2911/-27.
    • "How tested — final head 6052e1f" says 35 files, +2881/-27, and the round-4 narrative doubles down: "verified the +2881/-27 accounting as truthful against the 35 file headers".
      The 35 ### FILE: headers sum to exactly +2911/-27 (workflowkit 2298, deploykit 446, loaderkit 142, kit 12, go.mod+go.sum 13; deletions 27). So +2881 is wrong/stale — the round-5 fix's added lines are not reflected — and the round-4 claim to have verified +2881 "against the 35 file headers" is false against the current headers. A body asserting a figure its own headers contradict is a documentation-divergence-from-reality incident (R1). Fix: reconcile the "How tested" sentence (and the round-4 narrative) to +2911/-27, and account for the round-5 line delta in the "remains N files, +X/-Y" sentence.
  2. A1 — the body's rule-coverage claim is self-contradicted. The body states "Every rule R0–R10 is answered below; none is left implicit", but the section answers R0, R1, R2, R3, R4, R4a, R5, R6, R8, R9, R10 — R7 is absent. Either answer R7 with a one-line HOW (or N/A — <reason>), or drop the "R0–R10, none implicit" claim.

Verdict: BLOCK


ollama-cloud/deepseek-v4.1-flash — action-review.

View action run

@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown

Review — PASS

Head SHA: 6052e1f689c3a4f0471d68194f8bf101365eb9fb (branch: feat/workflow-ir-w1)

Security screen: PASS
Checklist: All applicable rules PASS or NA.
Comments: 1 considered — the sole comment is a validator BLOCK by @github-actions[bot] on this head. Both its A1 findings are re-derived against the CURRENT body and are stale-superseded: (a) the line-total contradiction — the body now states +2911/-27 in both "Full file accounting" and "How tested", and the 35 ### FILE: headers sum to exactly +2911/-27 (446 deploykit + 142 loaderkit + 12 kit + 13 module + 2298 workflowkit additions; 27 deletions); the +2881/-27 figure survives only as the explicitly-labelled round-4 historical value ("then in force"), reconciled with the round-5 +30 delta; (b) the missing R7 — R7 is present and answered ("Prove the gate, not the plan"). No finding survives. The carried R10 bed (producer-first: the gating beds compose plugin-lobster/plugin-pipeline, which do not exist until W4/W6) is named to W6 with the specific beds B1/B2/B3/B5, so it is a named, sequenced carry rather than the forbidden unnamed follow-up.

Verdict: PASS


ollama-cloud/deepseek-v4.1-flash — action-review.

View action run

@github-actions
github-actions Bot enabled auto-merge (squash) October 3, 2026 01:50
@github-actions
github-actions Bot merged commit 6626958 into main Oct 3, 2026
6 of 7 checks passed
charly-auto-merge Bot added a commit that referenced this pull request Oct 3, 2026
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