Skip to content

feat(pipeline): replace the handcrafted OpenAI client with the official openai-go SDK + a fully-authored CUE param surface - #26

Merged
github-actions[bot] merged 3 commits into
mainfrom
feat/openai-go-sdk
Sep 16, 2026
Merged

github-actions[bot] merged 3 commits into
mainfrom
feat/openai-go-sdk

Conversation

@atrawog

@atrawog atrawog commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Replaces the engine's hand-written OpenAI client with the official
github.com/openai/openai-go/v3 SDK, makes the whole request surface authorable
through the plugin's own CUE schema, and fixes every defect a measured
end-to-end run of the real eval-pr-plan lane exposed.

Why. The agent runtime hand-rolled the entire OpenAI-compatible wire path
(chatRequest/chatMsg structs, a net/http POST, a 121-line SSE parser) and
hardcoded every request knob. That client could not do vision, dropped
reasoning deltas, sent no max_tokens/response_format/seed/stop, and
silently dropped tool_choice (ollama's compat request struct has no such
field — the docs list it unsupported). It is now gone.

Two parts:

1 — the SDK swap + full configurability (commit 37b23c9).

  • schema/pipeline.cue (SDD single source) → params/cue_types_gen.go: a new
    #LLMParams covering the general OpenAI chat-completions parameters
    (temperature, top_p, max_tokens, max_completion_tokens,
    frequency_penalty, presence_penalty, seed, stop, response_format,
    reasoning_effort, reasoning, stream_options, parallel_tool_calls,
    tool_choice, logprobs, top_logprobs, user, metadata, logit_bias,
    plus an extra escape hatch for undocumented fields). #LLMSpec gains
    organization, project, timeout, idle_timeout, max_retries,
    headers. #ResponseFormat/#Reasoning/#StreamOptions/#NamedToolChoice
    added; #StageLLMSpec gives each #AgentStage an llm: override. Both param
    defs are close()d — an unknown or wrong-typed field is a LOAD error naming
    the CUE path.
  • llm.go (new): resolves env > stage > entity > built-in default
    field-wise, builds the client per call with explicit options, and maps the
    authored params 1:1 onto the SDK union. It uses NewChatCompletionService
    (NOT NewClient) so a stray OPENAI_API_KEY/OPENAI_BASE_URL/
    OPENAI_CUSTOM_HEADERS cannot hijack a lane; an empty resolved key sends NO
    Authorization header (the keyless local ollama needs none).
  • chat() re-implemented on NewStreaming + ChatCompletionAccumulator,
    keeping the RCA'd IDLE bound (a per-chunk watchdog that cancels the request
    ctx — not a whole-generation deadline) and the empty-completion guard.
    ollama's non-standard reasoning delta (which the SDK accumulator drops) is
    read from the raw JSON, so a reasoning-only 200 is reported as a NAMED empty
    completion instead of a bare one — the real shape behind the intermittent
    lane failures.
  • Vision: chatVision/imageDataURL send a screenshot as a base64 image_url
    content part DIRECTLY to the endpoint (ollama supports base64 data URLs only).
  • tools.go: the catalog renders openai.ChatCompletionToolUnionParam.
  • The wire structs (chatMsg, toolCall, toolSchema, functionSchema,
    chatRequest, chatResponse), the old chat() IMPLEMENTATION (the
    hand-built POST + manual SSE parser), and the hand-built tool JSON are
    replaced: chat() now takes the SDK message union and delegates to
    chatMessages (see Part 1 above), and chatMsg survives as the engine's
    internal transcript row fed to toSDKMessages — it is no longer a wire type.

2 — the defects found by measuring (commit ffc3323). Eleven, each
root-caused. Two were per-lane state collisions of the same class the ledger
OBJECT already fixed (RCA 2026.252.2210), never applied to the artifacts they
write:

  • runBatch reported SUCCESS for a failed batch — it printed each lane's
    error then returned 0, nil unconditionally, so a lane ending in the
    LOOP-GUARD escalation still printed OK and exited 0 (R7). A laneReport
    aggregate now makes any failed lane a non-zero exit.
  • ade.go passed the process-global os.Getenv("PR_HEAD_SHA") instead of
    the per-lane value, contradicting the RCA recorded at executor.go; the live
    run logged --var PR_HEAD_SHA=.
  • teardownVenue/teardownLaneBeds duplicated the venue lifecycle in the
    domain-neutral engine
    and got it wrong twice: it hardcoded the eval-omarchy
    golden entity and a check-omarchy-pr-<pr>-vm/-vm-probe domain scheme,
    resolved the bed refs against the PROCESS env (not the lane's run context),
    and used the signal-cancelled ctx (so it was skipped precisely on abort).
    Venue lifecycle now has ONE owner: the ade stage, whose runAdeBed destroys
    its --keep-venue domain via a deferred destroyVenue on a
    context.WithoutCancel-detached context — so a failure, a provider error and a
    SIGTERM all still tear down. The batch-level duplicate is deleted.
  • The hardcoded check-omarchy-pr-<pr>-vm fallback existed in three more
    sites
    (ade.go ×2, adekit.go). #AdeStage.bed is schema-REQUIRED, so an
    empty bed is a caller defect: all three now fail loud instead of silently
    mis-targeting a non-omarchy project.
  • No signal handling — a killed engine orphaned its child check run holding
    the per-bed flock, so every later lane died on "check bed … already running".
    Added signal.NotifyContext.
  • The ledger dump path was fixed (workdir/stage-findings.yml), so
    concurrent lanes overwrote each other's forensics. Now per-lane.
  • StageResult.Duration was measured but dropped from the dump, so the one
    artifact that could answer "where did the time go?" had no timing. Recorded.
  • runCheckRun/teardownBed were dead code and hardcoded
    exec.Command("charly", …). Deleted (R5).
  • probeHeadFreshness shelled out to a hand-rolled gh api and reported a
    bare "gh failed" — the class tools.go's own header RCA'd. Now the canonical
    ghkit client.
  • The pipeline agent-tool group declared nine tools with empty parameter
    schemas and dispatched them with an empty input map, so each passed vacuously
    or failed spuriously, while duplicating the schema-validated probe STAGE
    surface and being unused. Deleted (R3/R5).
  • probeSequencing matched a hardcoded omarchy regex (a vacuous green
    elsewhere) and probeGoldenPresent silently substituted a hardcoded
    omarchy path
    . Both now driven by their declared inputs.
  • The ADE summary was truncated to the last 400 bytes, slicing mid-word and
    dropping the diagnosis. lastLines keeps whole trailing lines.

Also deleted lanes_ok, an unreachable alias of the sequencing gate whose
description claimed it "reports the concurrency budget".

How tested

All output below is from the frozen head b36e5d7135259d0c5a6e93ba9f1e4b57dd737d34 (round 2; the round-1 head/block and its fixes are recorded under "Validator round 1" below).

$ cd candy/plugin-pipeline
$ gofmt -l .
(empty — clean)

$ go vet ./...
(empty — clean)

$ GOTMPDIR=$HOME/.cache/go-tmp TMPDIR=/tmp/cs go test -count=1 ./...
ok  	github.com/opencharly/plugin-pipeline/candy/plugin-pipeline	2.062s

$ GOTMPDIR=$HOME/.cache/go-tmp TMPDIR=/tmp/cs go test -count=1 -race ./...
ok  	github.com/opencharly/plugin-pipeline/candy/plugin-pipeline	3.312s

Params reproducibility (the CI gate recipe — cue exp gengotypes + diff):

$ echo 'package params' > pipeline.cue && cat candy/plugin-pipeline/schema/pipeline.cue >> pipeline.cue
$ cue exp gengotypes .
$ diff cue_types_params_gen.go candy/plugin-pipeline/params/cue_types_gen.go
PARAMS REPRODUCIBLE

Schema closedness, live (a full block passes; an unknown param is rejected by
path).
charly box validate on eval-omarchy with a full llm: block:

charly box validate: OK — checked 200 candies, 21 boxes, 27 deploys, 7 distros, 7 builders; 0 warnings, 0 errors

and with one bogus param added:

charly: error: command "validate": validation error: .../charly.yml:doc0: node "eval-pr-plan":
plugin kind:pipeline: plugin_input fails #PipelineInput:
#PipelineInput.llm.params.bogus_unknown_knob: field not allowed

Live against the real local ollama (go test -run TestLive_Ollama -v), the
real SDK client against the real endpoint:

=== RUN   TestLive_OllamaTextStreaming
    llm_live_test.go:61: LIVE REPLY: "PONG"
--- PASS: TestLive_OllamaTextStreaming (0.64s)
=== RUN   TestLive_OllamaAuthoredParams
    llm_live_test.go:92: LIVE REPLY (authored temp=0.1 max_tokens=64): "READY"
--- PASS: TestLive_OllamaAuthoredParams (0.66s)
=== RUN   TestLive_OllamaReasoningIsCaptured
    llm_live_test.go:114: LIVE REPLY: "2+2 equals 4."
--- PASS: TestLive_OllamaReasoningIsCaptured (0.44s)

The real 12-stage lane, draft PR (all stages executed):

== lane 12055 ==
[agent oracle] cache hit — outputs read from the committed plan (agent not run)
[stage oracle] ok
[stage render] skipped — skipped: @oracle.class == skip
[stage control] skipped — skipped: @oracle.class == skip
[stage eval] skipped — skipped: @oracle.class == skip
[stage media] skipped — skipped: @oracle.class == skip
[stage gate] skipped — skipped: @oracle.class == skip
[stage validate] skipped — skipped: @eval.verdict != PASS && @eval.verdict != FAIL
[stage report] skipped — skipped: @eval.verdict != PASS && @eval.verdict != FAIL
[stage cold-read] skipped — skipped: @eval.verdict != PASS && @eval.verdict != FAIL
[stage record] skipped — skipped: @oracle.class == skip
[stage not-testable] ok
[stage publish] skipped — skipped: $env.EVAL_PUBLISH != approve || @cold-read.verdict == NO_VALIDATION
lane 12055: done
pipeline eval-pr-plan: OK (lanes=1, pool=1)

A real, non-draft PR (omacom/omarchy#12138), timestamped, single lane:

START 18:32:16
   15.2s [chat] model=deepseek-v4.1-flash:cloud ... tool_calls=5 reasoning=135
   90.2s [chat] ... content={"class":"system","golden":"check-omarchy-eval-base-inst:golden",...} tool_calls=0 reasoning=15970
   90.2s [stage oracle] ok
  109.9s [stage render] ok
  286.7s [stage control] ok — check-run exit 0: check-omarchy-pr-12138-control: [check-live] PASS after 14.733s
  482.4s [stage eval] ok — check-run exit 2
  490.0s [chat] ... tool_calls=10 reasoning=564
  630.1s [chat] ... content={"verdict":"BLOCK",...} tool_calls=0 reasoning=30701
  630.1s [stage validate] ok
  653.6s [stage report] ok
  741.7s [stage cold-read] ok
  741.7s [stage record] ok
  741.8s lane 12138: done
  757.6s pipeline eval-pr-plan: OK (lanes=1, pool=1)
END 18:44:54

The R7 fix, live — a bad PR now FAILS and exits non-zero:

$ charly pipeline run eval-pr-plan --pr 999999 --lanes 1
[stage oracle] ok
lane 999999: FAILED ([stage oracle] FAIL-HARD: agent cache: path + key required)
pipeline eval-pr-plan: FAILED (1/1 lanes failed, pool=1)
EXIT CODE = 1

The per-lane dump + duration fixes, live — 2 concurrent lanes produced two
separate ledgers:

$ ls stage-findings*.yml
stage-findings-pr-12135.yml
stage-findings-pr-12137.yml

$ grep '^- duration_seconds:' stage-findings-pr-12137.yml
- duration_seconds: 41      # cold-read
- duration_seconds: 227     # control
- duration_seconds: 237     # eval
- duration_seconds: 11      # oracle
- duration_seconds: 71      # report
- duration_seconds: 248     # validate

$ charly pipeline run eval-pr-plan --prs 12137 12135 --lanes 2
lane 12137: done
lane 12135: done
pipeline eval-pr-plan: OK (lanes=2, pool=2)

Mutation checks (the guards are load-bearing). Each new test was verified to
FAIL without its fix:

  • neutralising the reasoning read → TestConformance_ReasoningOnlyIsNamedEmpty FAILS
  • swapping NewChatCompletionService for NewClient → TestConformance_NoOpenAIEnvBleed FAILS (Authorization="Bearer polluted-key")
  • restoring the unconditional batch success → TestLaneReportExitIsAGate FAILS
  • restoring the fixed dump path → TestLedgerPathIsPerLane FAILS
  • dropping the duration from the dump → TestDumpLedgerRecordsDuration FAILS

Measured timing (recorded because it is the answer to "why does a lane take
that long"):
12m38s per lane at --lanes 1 — LLM agent stages 349s, VM beds
372s, other 36s. The per-bed STEP durations sum to only 61–81s while the
enclosing stage takes 177–196s; the gap is charly check run subprocess
overhead (project resolve + ~10 plugin connections; box validate measures
~13s). 2 lanes → 1.38x over sequential. A 16-lane run is bounded by host
concurrency, not by the LLM: ollama served 16 parallel calls in 2.5s wall and
concurrent charly calls are genuinely parallel.

Validator round 1 (BLOCK) — all three findings fixed, re-verified. The
fresh pr-validator blocked the first head with three findings, each correct:

  1. R3/R5 — the hardcoded check-omarchy-pr-<pr>-vm bed default survived in
    three more sites
    (ade.go ×2, adekit.go), the same lane-coupling removed
    from the batch path. #AdeStage.bed is schema-REQUIRED, so an empty bed is a
    caller defect: all three now fail loud. TestAdeBedIsRequiredNotDefaulted
    (mutation-verified).
  2. R1/R3/R5 — teardownLaneBeds re-broke the per-lane env invariant and was
    skipped on abort.
    Root cause: TWO owners of the venue lifecycle. The
    duplicate resolved bed refs against the process env and used the
    signal-cancelled ctx. Deleted (R5); the ade stage is the one owner, and its
    destroy is now deferred on a context.WithoutCancel-detached ctx so a
    failure, a provider error and a SIGTERM all still tear down.
    TestVenueHasOneOwner (mutation-verified).
  3. B10/A1 — the body's "Deleted" list named symbols the diff re-defines.
    Corrected to say exactly what changed (wire structs + old implementation
    replaced).

Round-2 live proof, eval-pr-plan #12138, --lanes 1, full 12-stage lane:

$ virsh -c qemu:///session list --all --name | grep 12138
(CLEAN — no leak: both venues destroyed by the ONE owner)
$ charly pipeline run eval-pr-plan --pr 12138 --lanes 1
  12.0s [stage oracle] ok
  30.2s [stage render] ok
 209.2s [stage control] ok — check-run exit 0: ... PASS after 15.763s
 408.7s [stage eval] ok — check-run exit 2
 408.9s [stage media] ok
 408.9s [stage gate] ok
 496.1s [stage validate] ok
 507.5s [stage report] ok
 521.9s [stage cold-read] ok
 521.9s [stage record] ok
 521.9s lane 12138: done
 521.9s pipeline eval-pr-plan: OK (lanes=1, pool=1)

Mutations for the round-1 fixes (each FAILS without its fix):
restoring the bed fallback → TestAdeBedIsRequiredNotDefaulted FAILS;
rejoining the signal ctx → TestVenueHasOneOwner FAILS.

Rulebook compliance

  • R1 (RCA every anomaly) — every one of the eleven defects above was
    root-caused before remediation; the two per-lane collisions were traced to the
    already-documented class at executor.go (RCA 2026.252.2210).
  • R3 (no duplication) — one canonical OpenAI client (the SDK); the broken
    duplicate pipeline agent-tool group and the unreachable lanes_ok alias
    deleted rather than taught to shadow the probe stages.
  • R5 (delete legacy completely) — the hand-written wire types, the manual
    SSE parser, the dead runCheckRun/teardownBed, and the broken tool group
    are removed in this same change.
  • R7 (prove the gate) — the batch exit code is now a gate; all gates were
    run on the frozen head and are pasted above.
  • R10 (fresh disposable proof) — the real eval-pr-plan lane was run
    end-to-end against real omacom/omarchy PRs on real disposable VMs, plus real
    ollama over the real SDK client.
  • SDD — schema/pipeline.cue is the single source; params/cue_types_gen.go
    is generated and proven reproducible.
  • No go.work is added; no submodule is edited; no force-push.

Change classification

  • Change class: runtime/behaviour — SDK swap + schema surface + defect fixes.
  • Verification gate: full eval-pr-plan lane (draft + real non-draft PR),
    live ollama, schema validation, go test/-race/vet/gofmt, params regen.
  • Attribution tier: fully tested and validated — all gates passed on the
    final tree and the changed runtime paths were executed live.

Assisted-by: opencode ollama-cloud/deepseek-v4.1-flash (fully tested and validated)

atrawog and others added 2 commits September 16, 2026 17:16
…al openai-go SDK + a fully-authored CUE param surface

The engine's agent runtime hand-rolled the entire OpenAI-compatible wire path
(chatRequest/chatMsg structs, a net/http POST, a 121-line SSE parser) and
hardcoded every request knob. That client could not do vision, dropped
reasoning deltas, sent no max_tokens/response_format/seed/stop, and silently
dropped tool_choice (ollama's compat request struct has no such field). It is
now DELETED and replaced by github.com/openai/openai-go/v3.

SDD: every parameter is authored in charly.yml through the plugin's own CUE
schema (schema/pipeline.cue -> params/cue_types_gen.go, regenerated by
cue exp gengotypes, reproducible).

- schema/pipeline.cue: #LLMSpec gains organization/project/timeout/
  idle_timeout/max_retries/headers/params; NEW #LLMParams (temperature, top_p,
  max_tokens, max_completion_tokens, frequency/presence_penalty, seed, stop,
  response_format, reasoning_effort, reasoning, stream_options,
  parallel_tool_calls, tool_choice, logprobs, top_logprobs, user, metadata,
  logit_bias, and an extra escape hatch); #ResponseFormat/#Reasoning/
  #StreamOptions/#NamedToolChoice; #StageLLMSpec + the #AgentStage llm
  override. Both param defs are closed - an unknown or wrong-typed field is a
  LOAD error naming the CUE path.
- llm.go: resolveLLM applies env > stage > entity > built-in default
  FIELD-WISE; the client is built per call with explicit options. It uses
  NewChatCompletionService (NOT NewClient) so a stray OPENAI_API_KEY /
  OPENAI_BASE_URL / OPENAI_CUSTOM_HEADERS can never hijack a lane; an empty
  resolved key sends NO Authorization header (the keyless local ollama needs
  none); the request params map 1:1 onto the SDK union.
- chat() re-implemented on NewStreaming + ChatCompletionAccumulator, KEEPING the
  RCA'd IDLE bound (a per-chunk watchdog that cancels the request ctx - not a
  whole-generation deadline) and the empty-completion guard. ollama's
  non-standard reasoning delta (which the SDK accumulator drops) is read from
  the raw JSON, so a reasoning-only 200 is reported as a NAMED empty completion
  instead of a bare one - the real shape behind the intermittent lane failures.
- tools.go: the catalog now renders openai.ChatCompletionToolUnionParam; the
  catalog + dispatchTool are unchanged.
- executor.go: rc.llm was map[string]any assigned via mm(p.Llm) - the same
  map-assertion defect already RCA'd for rc.media, which made an authored llm
  block a SILENT no-op. It is now the generated params.LLMSpec, assigned
  directly.
- vision: chatVision/imageDataURL send a screenshot as a base64 image_url
  content part DIRECTLY to the endpoint (ollama supports base64 data URLs only).
  This is the primitive the screenshot-vision check verb will drive.
- tests: the SSE fixtures now speak the SDK's chunk shape; 13 conformance tests
  prove each authored param reaches the wire (incl. vision content parts,
  reasoning-only, empty completion, idle-stall, precedence, NO OpenAI_* env
  bleed, custom headers, response_format, extra) + 3 LIVE R10 tests against real
  ollama. Two mutations prove the guards are load-bearing: neutralising the
  reasoning read reds TestConformance_ReasoningOnlyIsNamedEmpty, and swapping
  NewChatCompletionService for NewClient reds TestConformance_NoOpenAIEnvBleed.

Verification:
  cd candy/plugin-pipeline
  gofmt -l .                                     # clean
  go vet ./...                                   # clean
  go test -count=1 ./...                         # ok (93 tests)
  go test -count=1 -race ./...                   # ok
  cue exp gengotypes . + diff params/cue_types_gen.go   # PARAMS REPRODUCIBLE
  charly box validate (eval-omarchy + a full llm block, local override)
    -> OK; an unknown param -> #PipelineInput.llm.params.bogus_unknown_knob:
    field not allowed

Co-authored-by: agent <[email protected]>
…r-plan lane

Eleven defects, each root-caused. Two of them were MISCONCEPTIONS on my part,
corrected here by measurement rather than inference.

MEASURED BASELINE (the correction). Running the real eval-pr-plan lane on a
real non-draft PR (omacom/omarchy#12138, lanes=1) took 757.6s = 12m38s, NOT
the "30+ minutes" I had asserted from a tool timeout. Timestamped stage
breakdown: oracle 90s, render 20s, control 177s, eval 196s, validate 147s,
report 24s, cold-read 88s, the rest ~0s. A 2-lane run took 1095s with the
lanes finishing at 874s/1079s — a 1.38x speedup over sequential, so
concurrency helps but contends. The per-bed STEP durations sum to only 61-81s
while the enclosing stage takes 177-196s: the gap is charly-subprocess
overhead (project resolve + plugin connect + `box validate`, measured at ~13s
each). And 16 lanes is NOT 16x2 VMs: control and eval are SEQUENTIAL stages
within a lane, so the concurrent VM count is `lanes`, not `lanes*2`.

The fixes:

1. (HIGH) runBatch reported SUCCESS for a FAILED batch. It printed each lane's
   error and then returned `0, nil` unconditionally, so a lane ending in the
   LOOP-GUARD escalation still printed "pipeline eval-pr-plan: OK" and exited
   0 — the exit status carried no information (R7). Extracted a `laneReport`
   aggregate; ANY failed lane is now a non-zero exit and an honest
   "FAILED (n/m lanes failed)" summary. Live-verified: a bad PR now exits 1.

2. (HIGH) ade.go passed the PROCESS-GLOBAL `os.Getenv("PR_HEAD_SHA")` to the
   check-run instead of the per-lane value, directly contradicting the RCA
   already recorded at executor.go ("$env.PR_HEAD_SHA to this lane's head;
   never via os.Setenv"): the live run logged `--var PR_HEAD_SHA=`. `adeVerdict`
   now takes the lane's head from `rc.env`.

3. (HIGH) teardownVenue hardcoded the eval-omarchy golden entity and a
   `check-omarchy-pr-<pr>-vm`/`-vm-probe` domain scheme inside the
   DOMAIN-NEUTRAL engine, and omitted `--if-exists` (so every clean lane logged
   a spurious "no such VM … nothing destroyed"). Replaced with
   `teardownLaneBeds`, which derives the beds from the lane's OWN `ade` stages
   (ref-resolved) and always passes `--if-exists`.

4. (HIGH) No signal handling. The lanes drive child processes that hold the
   per-bed flock and keep a VM alive; the engine passed `context.Background()`
   and installed no handler, so a SIGTERM/SIGINT killed only the engine and the
   orphaned child kept the lock — every later lane then died on "check bed …
   already running in this project". Added `signal.NotifyContext`, so the lane
   contexts cancel and the children tear down.

5. (HIGH) The ledger dump path was FIXED (`workdir/stage-findings.yml`), so
   concurrent lanes overwrote each other: the surviving file held ONE lane's
   stages and a FAILING lane's forensic artifact could be destroyed by a
   sibling. This is the per-lane-state class the ledger OBJECT already fixed
   (RCA 2026.252.2210) — never applied to the dump PATH. Now per-lane
   (`stage-findings-pr-<pr>.yml`).

6. (MEDIUM) The runner has ALWAYS measured `StageResult.Duration` but the dump
   DROPPED it, so the one artifact that could answer "where did the lane's 13
   minutes go?" carried no timing. `#StageFinding` gains
   `duration_seconds` and the dump records it.

7. (MEDIUM) runCheckRun + teardownBed were DEAD code (definition-only) and
   teardownBed hardcoded `exec.Command("charly", …)`, bypassing CHARLY_BIN.
   Deleted (R5).

8. (MEDIUM) probeHeadFreshness shelled out to a hand-rolled `gh api`
   subprocess and reported a bare "gh failed" — the exact defect class
   tools.go's own header RCA'd. It now uses the canonical ghkit client and
   names the repo in its failure.

9. (MEDIUM) The `pipeline` agent-tool group declared NINE tools with EMPTY
   parameter schemas and dispatched them with an EMPTY input map, so each
   either passed vacuously (lock_audit over no trees) or failed spuriously
   (config_audit needs a bed) — the "every call arrived arg-less" class, and it
   DUPLICATED the schema-validated probe STAGE surface while being unused.
   Deleted (R3/R5); `tools: [pipeline]` now resolves to no tools.

10. (MEDIUM) probeSequencing matched a hardcoded
    `guest=charly-check-omarchy-pr-<N>-vm` (a vacuous green for any other
    project) and probeGoldenPresent silently substituted a hardcoded
    eval-omarchy path. Both are now driven by their declared inputs
    (`bed_prefix`, `golden`), and a missing input is an explicit failure.

11. (LOW) The ADE summary was truncated to the last 400 BYTES, slicing
    mid-word and dropping the diagnosis (live: "check-run exit 1:
    eline/candy/plugin-pipeline"). `lastLines` keeps whole trailing lines.

Also: `lanes_ok` was an unreachable alias of the sequencing gate whose
description claimed it "reports the concurrency budget" — deleted.

Tests (all mutation-verified to FAIL without their fix): laneReport exit gate,
per-lane ledger path, duration recording, entity-driven teardown target,
sequencing bed_prefix requirement, golden_present input requirement,
head_freshness canonical client, pipeline-tool-group removal, whole-line
summary tail.

Verification:
  gofmt -l . ; go vet ./... ; go test -count=1 ./... ; go test -race ./...
  cue exp gengotypes . + diff params/cue_types_gen.go   # REPRODUCIBLE
  LIVE: eval-pr-plan #12055 (draft) 12/12 stages green; #12138 (real, non-draft)
        ran the full lane, 757.6s, verdict BLOCK with a populated record;
        a bad PR now exits 1 (was 0).

Co-authored-by: agent <[email protected]>
@github-actions

Copy link
Copy Markdown

Review — BLOCK

Head SHA: ffc33234a3480ccc4308e1e7406ab567853da557 (base 7ea7ae1691fdf59ab38d12bb53be1b3648b0a5cf)

Change class: runtime/behaviour — Go plugin (candy/plugin-pipeline) SDK swap, CUE param surface, batch/ADE/teardown fixes, new dependency.

Security screen: PASS — no T1–T4 findings (no embedded directives in the body/commits, no secrets or egress added, no guardrail weakened; the added dependency is the version-pinned github.com/openai/openai-go/v3 v3.61.0 with coherent go.sum entries). Note: the returned diff was truncated by the harness (65 536 of 98 322 bytes returned; the tail of llm.go and ~9 further changed files — schema/pipeline.cue, params/cue_types_gen.go, tools.go, the new test files — were not returned to me), so the SDD/CUE-regeneration and coverage items are cross-checked only against the body's pasted evidence, not re-derived.

Blocks

  1. R3/R5 — the domain-specific bed default survives in the very file the PR edits, contradicting the PR's own remedy. candy/plugin-pipeline/ade.go, adeVerdict (the if bed == "" { bed = "check-omarchy-pr-" + pr + "-vm" } branch). The body states that teardownVenue "hardcoded … a check-omarchy-pr-<pr>-vm/-vm-probe domain scheme in the domain-neutral engine" and that this was the defect being removed. The diff removes it from cli.go but leaves the identical literal scheme in ade.go — a file and function whose signatures this PR changes. Result: the lane's bed name is now derived in two places with different rules (teardownLaneBeds reads the stage's declared/ref-resolved bed; adeVerdict string-concatenates an omarchy default), so for any ade stage that declares no bed the fallback name cannot be matched by the entity-driven teardown path, and a non-omarchy pipeline gets an omarchy-shaped bed name. Fix: derive the fallback from the stage's declared bed (or fail hard / drop the fallback) so the bed-naming rule lives in one place, and sweep the body's claim to match.

  2. R1/R5 — the per-lane env invariant is re-broken in the new teardown path. candy/plugin-pipeline/cli.go, teardownLaneBeds: rc := &runCtx{pr: pr, calver: calver, workdir: workdir, env: envMap()} resolves the stage bed refs against the process env, not the lane's run context — the exact class of defect this same PR RCA's and fixes in ade.go (--var PR_HEAD_SHA= from os.Getenv) and executor.go (rc.env["PR_HEAD_SHA"]). Since envMap() carries no per-lane PR_NUMBER/PR_HEAD_SHA, any $env.* reference in a lane's ade bed resolves to the operator's value or empty; the resulting charly vm destroy <wrong-name> --if-exists succeeds silently (best-effort, output discarded), so the lane's venue is never torn down. Second defect in the same function: the command is built with exec.CommandContext(ctx, …) where ctx is the signal context created by runBatch (batch.go:15‑30) — once signal.NotifyContext cancels it, Start returns ctx.Err() and the destroy never runs at all, i.e. the hygiene is skipped precisely in the abort/orphan scenario the signal handling was added for. Fix: take the lane's env (as executor.go does) and use a context that is not the cancel-on-signal one for teardown, or state and prove the degradation is intended.

  3. B10/A1 — body claim contradicted by the diff. The body's Part 1 says "Deleted: chatMsg, toolCall, toolSchema, functionSchema, chatRequest, chatResponse, chat(), and the hand-built tool JSON" — but candy/plugin-pipeline/llm.go (new) re-declares chatMsg (new internal row type) and a chat() with a new signature, and the body's own Part 1 says "chat() re-implemented on NewStreaming". A symbol listed as deleted that the diff still defines is a contradiction; correct the accounting to "the wire structs + the old chat() implementation replaced".

Non-blocking flag (B15): the cutover lands as two non-changelog commits (37b23c9 + ffc3323) in one PR; the intended squash collapses them — noted, no partial/Phase-2 work observed.

Verdict: BLOCK


opencode/deepseek-v4.1-flash — action-review.

View action run

@github-actions

Copy link
Copy Markdown

[step: review]

Review — BLOCK

Head SHA: ffc33234a3480ccc4308e1e7406ab567853da557 (base 7ea7ae1691fdf59ab38d12bb53be1b3648b0a5cf)

Change class: runtime/behaviour — Go plugin (candy/plugin-pipeline) SDK swap, CUE param surface, batch/ADE/teardown fixes, new dependency.

Security screen: PASS — no T1–T4 findings (no embedded directives in the body/commits, no secrets or egress added, no guardrail weakened; the added dependency is the version-pinned github.com/openai/openai-go/v3 v3.61.0 with coherent go.sum entries). Note: the returned diff was truncated by the harness (65 536 of 98 322 bytes returned; the tail of llm.go and ~9 further changed files — schema/pipeline.cue, params/cue_types_gen.go, tools.go, the new test files — were not returned to me), so the SDD/CUE-regeneration and coverage items are cross-checked only against the body's pasted evidence, not re-derived.

Blocks

  1. R3/R5 — the domain-specific bed default survives in the very file the PR edits, contradicting the PR's own remedy. candy/plugin-pipeline/ade.go, adeVerdict (the if bed == "" { bed = "check-omarchy-pr-" + pr + "-vm" } branch). The body states that teardownVenue "hardcoded … a check-omarchy-pr-<pr>-vm/-vm-probe domain scheme in the domain-neutral engine" and that this was the defect being removed. The diff removes it from cli.go but leaves the identical literal scheme in ade.go — a file and function whose signatures this PR changes. Result: the lane's bed name is now derived in two places with different rules (teardownLaneBeds reads the stage's declared/ref-resolved bed; adeVerdict string-concatenates an omarchy default), so for any ade stage that declares no bed the fallback name cannot be matched by the entity-driven teardown path, and a non-omarchy pipeline gets an omarchy-shaped bed name. Fix: derive the fallback from the stage's declared bed (or fail hard / drop the fallback) so the bed-naming rule lives in one place, and sweep the body's claim to match.

  2. R1/R5 — the per-lane env invariant is re-broken in the new teardown path. candy/plugin-pipeline/cli.go, teardownLaneBeds: rc := &runCtx{pr: pr, calver: calver, workdir: workdir, env: envMap()} resolves the stage bed refs against the process env, not the lane's run context — the exact class of defect this same PR RCA's and fixes in ade.go (--var PR_HEAD_SHA= from os.Getenv) and executor.go (rc.env["PR_HEAD_SHA"]). Since envMap() carries no per-lane PR_NUMBER/PR_HEAD_SHA, any $env.* reference in a lane's ade bed resolves to the operator's value or empty; the resulting charly vm destroy <wrong-name> --if-exists succeeds silently (best-effort, output discarded), so the lane's venue is never torn down. Second defect in the same function: the command is built with exec.CommandContext(ctx, …) where ctx is the signal context created by runBatch (batch.go:15‑30) — once signal.NotifyContext cancels it, Start returns ctx.Err() and the destroy never runs at all, i.e. the hygiene is skipped precisely in the abort/orphan scenario the signal handling was added for. Fix: take the lane's env (as executor.go does) and use a context that is not the cancel-on-signal one for teardown, or state and prove the degradation is intended.

  3. B10/A1 — body claim contradicted by the diff. The body's Part 1 says "Deleted: chatMsg, toolCall, toolSchema, functionSchema, chatRequest, chatResponse, chat(), and the hand-built tool JSON" — but candy/plugin-pipeline/llm.go (new) re-declares chatMsg (new internal row type) and a chat() with a new signature, and the body's own Part 1 says "chat() re-implemented on NewStreaming". A symbol listed as deleted that the diff still defines is a contradiction; correct the accounting to "the wire structs + the old chat() implementation replaced".

Non-blocking flag (B15): the cutover lands as two non-changelog commits (37b23c9 + ffc3323) in one PR; the intended squash collapses them — noted, no partial/Phase-2 work observed.

Verdict: BLOCK


opencode/deepseek-v4.1-flash — action-review.

View action run

…no hardcoded bed default

The fresh pr-validator BLOCKED PR #26 with three findings. All three were
correct; each is fixed by its root cause, not patched.

BLOCK 1 (R3/R5) — the hardcoded `check-omarchy-pr-<pr>-vm` bed default survived
in three more sites (`ade.go` runAdeBed + adeVerdict, `adekit.go` bedPlanOps),
the same lane-coupling the change removes from the batch path. ROOT CAUSE:
`#AdeStage.bed` is schema-REQUIRED, so an empty bed is a CALLER DEFECT and the
fallsback were dead defensive code that (a) baked a lane's private naming scheme
into the domain-neutral engine, (b) silently mis-targeted any other project, and
(c) made the bed-naming rule live in two places with different rules. All three
now FAIL LOUD with "ade: bed required". Test: TestAdeBedIsRequiredNotDefaulted
(mutation-verified: restoring the fallback reds it).

BLOCK 2 (R1/R3/R5) — `teardownLaneBeds` re-broke the per-lane env invariant and
was skipped exactly on abort. ROOT CAUSE: venue lifecycle had TWO owners.
`runAdeBed` already destroys its `--keep-venue` domain; the batch-level copy was
a duplicate that resolved bed refs against the PROCESS env (`envMap()`) instead
of the lane's run context, and used the signal-cancelled ctx, so once
`signal.NotifyContext` fired the destroy never ran at all. Fixed by R3/R5:
DELETE the duplicate — the `ade` stage is the ONE owner — and make the one owner
abort-safe: `destroyVenue` is deferred and runs on a
`context.WithoutCancel`-detached context, so a failure, a provider error and a
SIGTERM all still tear the venue down (the previous early return on a
non-ExitError leaked the VM). Tests: TestVenueHasOneOwner (mutation-verified:
rejoining the signal ctx reds it).

BLOCK 3 (B10/A1) — the PR body claimed `chatMsg`/`chat()` were "Deleted" while
the diff re-defines both. ROOT CAUSE: the accounting conflated "the WIRE structs
+ the old implementation" with "the symbols". The body now says exactly what
changed: the wire structs and the old hand-built `chat()` implementation are
replaced; `chat()` is re-implemented on the SDK and `chatMsg` survives as the
engine's internal transcript row (no longer a wire type).

Verification (frozen tree):
  gofmt -l .            # clean
  go vet ./...          # clean
  go test -count=1 ./...        # ok
  go test -count=1 -race ./...  # ok
  cue exp gengotypes . + diff params/cue_types_gen.go   # REPRODUCIBLE
  LIVE eval-pr-plan #12138, lanes=1: full 12-stage lane green in 521.9s
    (control 209s, eval 409s), and BOTH venues destroyed by the one owner —
    `virsh list --all | grep 12138` => CLEAN (no leak). The prior batch-level
    teardown leaked in exactly the abort case this fixes.

Co-authored-by: agent <[email protected]>
@github-actions

Copy link
Copy Markdown

Review — PASS

Head SHA: b36e5d7135259d0c5a6e93ba9f1e4b57dd737d34 (base 7ea7ae1691fdf59ab38d12bb53be1b3648b0a5cf)

Security screen: PASS — no T1–T4 findings. No embedded directive aimed at the validator (the body only describes the prior review), no secrets/egress added, no guardrail/rulebook/validator-spec change; the new dep is version-pinned github.com/openai/openai-go/v3 v3.61.0 with coherent go.sum entries. Placement gate: capability (LLM client, batch gate, ADE venue owner) stays in the candy plugin — no core/alias/kit imports added; placement: CORRECT.

Checklist: All applicable rules PASS or NA.

Prior-comment dispositions (re-derived against the CURRENT diff):

Tool-limit disclosure (rule 4): the harness returned 65 536 of 98 322 diff bytes — the tail of llm.go and schema/pipeline.cue, params/cue_types_gen.go, tools.go and the new test files were not returned. Those items are dispositioned tool-limited against the body's pasted evidence, which is internally consistent with the returned diff (new SDK code paths, laneReport exit contract, ledgerPath per-lane file names, duration_seconds dump row, and resolveLLM field names all match the live outputs).

Verdict: PASS


opencode/deepseek-v4.1-flash — action-review.

View action run

@github-actions

Copy link
Copy Markdown

[step: review]

Review — PASS

Head SHA: b36e5d7135259d0c5a6e93ba9f1e4b57dd737d34 (base 7ea7ae1691fdf59ab38d12bb53be1b3648b0a5cf)

Security screen: PASS — no T1–T4 findings. No embedded directive aimed at the validator (the body only describes the prior review), no secrets/egress added, no guardrail/rulebook/validator-spec change; the new dep is version-pinned github.com/openai/openai-go/v3 v3.61.0 with coherent go.sum entries. Placement gate: capability (LLM client, batch gate, ADE venue owner) stays in the candy plugin — no core/alias/kit imports added; placement: CORRECT.

Checklist: All applicable rules PASS or NA.

Prior-comment dispositions (re-derived against the CURRENT diff):

Tool-limit disclosure (rule 4): the harness returned 65 536 of 98 322 diff bytes — the tail of llm.go and schema/pipeline.cue, params/cue_types_gen.go, tools.go and the new test files were not returned. Those items are dispositioned tool-limited against the body's pasted evidence, which is internally consistent with the returned diff (new SDK code paths, laneReport exit contract, ledgerPath per-lane file names, duration_seconds dump row, and resolveLLM field names all match the live outputs).

Verdict: PASS


opencode/deepseek-v4.1-flash — action-review.

View action run

@github-actions
github-actions Bot enabled auto-merge (squash) September 16, 2026 18:25
@github-actions
github-actions Bot merged commit 4fc1311 into main Sep 16, 2026
2 checks passed
charly-auto-merge Bot added a commit that referenced this pull request Sep 16, 2026
github-actions Bot pushed a commit to opencharly/eval-omarchy that referenced this pull request Sep 16, 2026
…ledger dump (#79)

Advances the eval-pr lane to the merged plugin-pipeline tag
`v2026.259.1825` (opencharly/plugin-pipeline#26), which replaces the
hand-written OpenAI client with the official `openai/openai-go/v3` SDK and
makes the whole request surface authorable through the plugin's CUE schema.

Consumer consequences carried in the same change:

- candy/eval-pr/charly.yml: the pipeline pin v2026.259.0809 ->
  v2026.259.1825.
- .gitignore: the engine now writes the per-run ledger dump ONE FILE PER LANE
  (`stage-findings-pr-<pr>.yml`) so concurrent batch lanes cannot overwrite
  each other's forensics; the previous exact-name pattern
  (`stage-findings.yml`) no longer matched, so the new dumps showed up as
  untracked run artifacts. Widened to `stage-findings*.yml`, which covers both
  the per-lane and the no-PR form.
- docs/evidence-and-media.md: the artifact table names the per-lane file and
  notes that each row records the stage's status and duration.

The bump is the same shape as #78 (pin advance, no candy `version:` change).

Verification (local):

  $ EVAL_UMBRELLA=<umbrella> charly box validate
  Downloading github.com/opencharly/plugin-pipeline:v2026.259.1825...
  plugin plugin-pipeline: served from .../[email protected]/...
  charly box validate: OK — checked 200 candies, 21 boxes, 33 deploys,
  7 distros, 7 builders; 0 warnings, 0 errors

  $ charly pipeline run eval-pr-plan --pr 12055 --lanes 1
   10.7s [stage oracle] ok
   10.7s [stage render] skipped — skipped: @oracle.class == skip
   10.7s [stage control] skipped — skipped: @oracle.class == skip
   10.7s [stage eval] skipped — skipped: @oracle.class == skip
   10.7s [stage media] skipped — skipped: @oracle.class == skip
   10.7s [stage gate] skipped — skipped: @oracle.class == skip
   10.7s [stage validate] skipped — skipped: @eval.verdict != PASS && @eval.verdict != FAIL
   10.7s [stage report] skipped — skipped: @eval.verdict != PASS && @eval.verdict != FAIL
   10.7s [stage cold-read] skipped — skipped: @eval.verdict != PASS && @eval.verdict != FAIL
   10.7s [stage record] skipped — skipped: @oracle.class == skip
   10.8s [stage not-testable] ok
   10.8s [stage publish] skipped — skipped: $env.EVAL_PUBLISH != approve || @cold-read.verdict == NO_VALIDATION
   10.8s lane 12055: done
   10.8s pipeline eval-pr-plan: OK (lanes=1, pool=1)

  $ ls stage-findings*.yml
  stage-findings-pr-12055.yml      # the merged plugin's per-lane dump
  $ git status --short
  (the dumps are ignored — the .gitignore fix works)

Rulebook compliance: R1 (every anomaly RCA'd before remediation); R3 (the
consumer follows the engine's single naming rule); R5 (the stale ignore
pattern + doc row are removed, not left alongside); R10 (live lane run pasted
above).

Change classification: contract/pin + consumer config + docs. Verification
gate: charly box validate + a live eval-pr-plan lane. Attribution:
fully tested and validated for the pin/lane path; the doc row is a
projection of the verified runtime behavior.

*Assisted-by: opencode ollama-cloud/deepseek-v4.1-flash (fully tested and validated)*

Co-authored-by: atrawog <[email protected]>
@aitrawog
aitrawog deleted the feat/openai-go-sdk branch September 25, 2026 19:33
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