Repository navigation
feat(pipeline): schema-first emit stage + schema-validated ledger dump - #25
Conversation
Add a kind: emit stage — the generic schema-first artifact writer. A structured
value (ref-resolved; array/map types preserved) is validated against an authored
CUE schema (a plugin def, a committed .cue file, or a literal source) with
Concreteness required BEFORE any bytes are written, then marshalled through the
CUE YAML encoder. String leaves may carry ${var} markers (indent/bullets), so a
prose field is composed without a hand-written YAML template. An invalid
artifact is therefore impossible: the stage fails informatively instead of
shipping bytes no reader can parse.
Why: the generate stage renders a free-form template, and a single unquoted
scalar containing ': ' (e.g. 'what: Docs-only change: ...') produced YAML no
parser could read. A lane that then re-reads its own committed record (the
render-once cache) crashed on the NEXT run with 'unreadable committed plan'.
Also: the per-run ledger dump (stage-findings.yml) is now written schema-first
against #StageFindings instead of hand-rolled fmt.Fprintf.
- #EmitStage in schema/pipeline.cue (schema: def|file|literal, value, vars, out, format)
- emit.go: runEmit + emitSchema + resolveEmitValue/renderStringLeaf + marshalSchemaFirst
- dumpLedger validates #StageFindings before write
- render.go: runAuthoredValidator extracted (one validator path, R3)
- plugin.go: emit added to the structural kind check
- tests: schema-first record (colon scalar round-trip), schema violation rejects,
literal/file schema, string-leaf template
Review — BLOCKHead SHA: Change class: code/config — plugin candy ( Blocks
Verdict: BLOCK opencode/deepseek-v4.1-flash — action-review. |
[step: review]Review — BLOCKHead SHA: Change class: code/config — plugin candy ( Blocks
Verdict: BLOCK opencode/deepseek-v4.1-flash — action-review. |
… markers, dump test
- R3/A1: marshalSchemaFirst now takes the COMPILED schema value and is called by
BOTH runEmit (yaml) and dumpLedger; the inline encode→unify→validate→encode
sequence in runEmit is deleted. emitSchemaDef added for the internal-dump form.
- R1/R4: renderStringLeaf HARD-ERRORS on an unknown transform and on an
unresolved ${name} (a value that resolves through the ref grammar is fine);
the false 'leave the marker for the schema to catch' comment is gone. A CUE
string leaf cannot catch a leftover marker.
- R10: TestDumpLedger_SchemaFirst added (a row with ':' and a multi-line message
round-trips through yaml.Unmarshal) plus TestEmitStage_RejectsUnresolvedMarker
and TestEmitStage_RejectsUnknownTransform.
- R1: #EmitStage documents all THREE schema forms (def name / .cue file / literal
source); params regenerated (reproducible).
Review — BLOCKHead SHA: Change class: code/config — Comment intake (2 comments, both the same prior review at head
Blocks
Verdict: BLOCK opencode/deepseek-v4.1-flash — action-review. |
[step: review]Review — BLOCKHead SHA: Change class: code/config — Comment intake (2 comments, both the same prior review at head
Blocks
Verdict: BLOCK opencode/deepseek-v4.1-flash — action-review. |
…er emit steps Second validator round — the two advertised-but-untested emit inputs now have coverage that fails without them: - TestEmitStage_FileDefSelector (path.cue#Def selects the named def) - TestEmitStage_JSONFormat + TestEmitStage_JSONFormatRejectsSchemaViolation - runEmit's comment steps renumbered 1/2/3 (step 3 vanished in the single-writer refactor).
Review — BLOCKHead SHA: Change class: code/config — Comment intake (4 comments = 2 distinct prior reviews, each posted twice; all re-derived against the current diff):
Blocks
Verdict: BLOCK opencode/deepseek-v4.1-flash — action-review. |
[step: review]Review — BLOCKHead SHA: Change class: code/config — Comment intake (4 comments = 2 distinct prior reviews, each posted twice; all re-derived against the current diff):
Blocks
Verdict: BLOCK opencode/deepseek-v4.1-flash — action-review. |
…class) The emit failure message advertised the generate transform set (incl. negate), but renderStringLeaf only handles indent/bullets/yaml/json — negate fell to default and rendered the un-negated scalar, silently writing a wrong value a CUE string leaf cannot catch. emit now uses its OWN accepted set (emitValidTransforms: json/yaml/indent/bullets); :negate is a hard error like any other unknown transform. TestEmitStage_RejectsNegateTransform pins it.
Review — BLOCKHead SHA: Change class: code/config — Comment intake (6 comments = 3 distinct prior reviews, each posted twice; all re-derived against the current diff at
Blocks
Verdict: BLOCK opencode/deepseek-v4.1-flash — action-review. |
[step: review]Review — BLOCKHead SHA: Change class: code/config — Comment intake (6 comments = 3 distinct prior reviews, each posted twice; all re-derived against the current diff at
Blocks
Verdict: BLOCK opencode/deepseek-v4.1-flash — action-review. |
…orms
The doc comment still listed 'scalar' as a reused generate transform; the accepted
set is emitValidTransforms (json/yaml/indent/bullets), with a bare ${name} as the
scalar default. Comment now matches the guard and the error message.
Review — BLOCKHead SHA: Change class: code/config — Comment intake (8 comments = 4 distinct prior reviews, each posted twice; all re-derived against the current diff at
Blocks
Verdict: BLOCK opencode/deepseek-v4.1-flash — action-review. |
[step: review]Review — BLOCKHead SHA: Change class: code/config — Comment intake (8 comments = 4 distinct prior reviews, each posted twice; all re-derived against the current diff at
Blocks
Verdict: BLOCK opencode/deepseek-v4.1-flash — action-review. |
Review — BLOCKHead SHA: Change class: code/config — Comment intake (8 comments = 4 distinct prior reviews, each posted twice; all re-derived against the current diff at
Blocks
Verdict: BLOCK opencode/deepseek-v4.1-flash — action-review. |
[step: review]Review — BLOCKHead SHA: Change class: code/config — Comment intake (8 comments = 4 distinct prior reviews, each posted twice; all re-derived against the current diff at
Blocks
Verdict: BLOCK opencode/deepseek-v4.1-flash — action-review. |
Review — BLOCKHead SHA: Change class: code/config — Comment intake (12 comments = 6 postings covering 5 distinct prior reviews; all re-derived against the current diff at
Blocks
Verdict: BLOCK opencode/deepseek-v4.1-flash — action-review. |
[step: review]Review — BLOCKHead SHA: Change class: code/config — Comment intake (12 comments = 6 postings covering 5 distinct prior reviews; all re-derived against the current diff at
Blocks
Verdict: BLOCK opencode/deepseek-v4.1-flash — action-review. |
…te's
The served schema comment (mirrored into params/cue_types_gen.go) claimed a string
leaf uses 'the SAME per-marker grammar as generate'; emit deliberately has its OWN
accepted set (json/yaml/indent/bullets; bare ${name} = scalar default; negate
rejected). Reword the comment so the authoritative doc matches the guard and the
error message; regenerate params (reproducible).
Review — BLOCKHead SHA: Change class: code/config — Comment intake (payload truncated at the tail of the final duplicate; all distinct prior reviews re-derived against the current diff at
Blocks
Verdict: BLOCK opencode/deepseek-v4.1-flash — action-review. |
[step: review]Review — BLOCKHead SHA: Change class: code/config — Comment intake (payload truncated at the tail of the final duplicate; all distinct prior reviews re-derived against the current diff at
Blocks
Verdict: BLOCK opencode/deepseek-v4.1-flash — action-review. |
The previous head fixed #EmitStage but left the same false claim in runEmit's
step-1 comment and TestEmitStage_StringLeafTemplate's doc, and resolveEmitValue's
list omitted :json. All now state the SHARED MARKER SYNTAX with emit's OWN
transform set (json/yaml/indent/bullets; bare ${name} = scalar default; negate
rejected). A claim-keyed grep for the parity wording returns nothing.
Review — PASSHead SHA: Change class: code/config — plugin candy ( Comment intake (7 distinct prior reviews / 14 postings, each re-derived against the CURRENT diff — all dispositions
Security screen: PASS (no secrets/egress/eval; no guardrail, CI, branch-protection or rulebook change; no new dependency or version pin). Verdict: PASS opencode/deepseek-v4.1-flash — action-review. |
[step: review]Review — PASSHead SHA: Change class: code/config — plugin candy ( Comment intake (7 distinct prior reviews / 14 postings, each re-derived against the CURRENT diff — all dispositions
Security screen: PASS (no secrets/egress/eval; no guardrail, CI, branch-protection or rulebook change; no new dependency or version pin). Verdict: PASS opencode/deepseek-v4.1-flash — action-review. |
Review — PASSHead SHA: Change class: code/config — Security screen: PASS (T1–T4 — no secrets/egress/eval/obfuscation; no guardrail, CI, branch-protection or rulebook change; no new dependency or version pin; PR content treated as data only). Comment intake (12 postings, 6 distinct prior reviews — all re-derived against the CURRENT diff/body at Verdict: PASS opencode/deepseek-v4.1-flash — action-review. |
[step: review]Review — PASSHead SHA: Change class: code/config — Security screen: PASS (T1–T4 — no secrets/egress/eval/obfuscation; no guardrail, CI, branch-protection or rulebook change; no new dependency or version pin; PR content treated as data only). Comment intake (12 postings, 6 distinct prior reviews — all re-derived against the CURRENT diff/body at Verdict: PASS opencode/deepseek-v4.1-flash — action-review. |
opencharly/plugin-pipeline#25 merged + tagged v2026.259.0809: the schema-first emit stage, the schema-validated ledger dump, and the single schema-first writer. The eval-pr-plan record/not-testable stages depend on it.
) * feat(eval): schema-first record emission + org pr-validator grading Two changes to the eval-pr-plan lane: 1. Grade the PR by the ORG pr-validator criteria with the lane running the R10. The entry omarchy-eval skill carries the APPLICABILITY MAP that scopes the org pr-validator spec (pr-validator-agent, layer-charly-internals-extra) to an upstream omacom/omarchy PR, and a new `validate` agent stage grades every item from the LANE's ledger (the gate facts) — never from the author's pasted evidence (the pr-validator's usual assumption). The record carries validate.verdict + the T1-T4 security screen + the per-item checklist. 2. charly WRITES the record — never a hand-written or string-templated YAML. The record/not-testable stages are now `kind: emit` with schema: candy/eval-pr/record.cue (#EvalRecord / #NotTestableRecord): the structured value is validated against CUE with Concreteness required BEFORE the write, then marshalled by the CUE YAML encoder. A colon in an unquoted scalar can no longer produce an unreadable record (RCA 2026.259), and the oracle's render-once cache re-reads it correctly. Docs (README/AGENTS/CONTRIBUTING/VISION) updated; the charly-writes-YAML rule added to AGENTS.md and the entry skill. Depends on opencharly/plugin-pipeline PR #25 (the emit stage + schema-first ledger dump). * chore(eval): bump plugin-pipeline to v2026.259.0809 (the emit stage) opencharly/plugin-pipeline#25 merged + tagged v2026.259.0809: the schema-first emit stage, the schema-validated ledger dump, and the single schema-first writer. The eval-pr-plan record/not-testable stages depend on it. * fix(eval): close every record.cue nesting level + correct the schema-path claim pr-validator BLOCK fixes: - #EvalRecord/#NotTestableRecord now close() EVERY nested struct (oracle/ control/eval/gates/validate/media/cold_read), so an unknown field at ANY depth is a stage failure. Proven: a record with gates.media_ok renamed to media_ok_typo now fails (field not allowed); the real record still validates. - The header comment claimed schema: eval/pr-<N>/record.cue (no such file); the real contract is candy/eval-pr/record.cue (bare path -> first #Def) for the record stage and candy/eval-pr/record.cue#NotTestableRecord for the not-testable stage. Both now documented. * refactor(eval): extract #EvalOracle, shared by both record defs (R3) pr-validator BLOCK fix: the 8-field oracle block was copy-pasted verbatim into #EvalRecord and #NotTestableRecord. Now one #EvalOracle def referenced by both (the file already shared #EvalCheck/#EvalStep), so a field added to one record's oracle cannot drift from the other. * fix(eval): explicit #EvalRecord selection + point-only validate prompt (R3) pr-validator BLOCK fixes: - the record stage now selects candy/eval-pr/record.cue#EvalRecord explicitly (matching the not-testable stage's file#Def form), so the shipped selection is unambiguous; a negative case is pasted proving an unknown field at the top or nested level hard-errors THROUGH the emit stage. - the validate stage prompt no longer restates the T1-T4 screen/R1/R3/R4/R5 checks: it points at the applicability map already loaded (the entry omarchy-eval skill) and carries only the lane's substitution + output format. - the entry skill no longer claims it 'does not restate' the spec; it states the map is a deliberately SCOPED restatement (the distros corpus cannot load the internals agent spec), with the org spec authoritative. * docs(eval): record.cue header matches the shipped file#Def selection Both record stages now name their def explicitly (#EvalRecord / #NotTestableRecord); the header no longer describes the record stage as using the bare path. * docs(eval): name the explicit file#Def schema form in the skill too The entry skill still showed schema: candy/eval-pr/record.cue (bare path); both shipped stages now use file#Def. Comment/prose-only sweep. * docs(eval): the applicability map is the lane's scoped authority, derived from the org spec Sweep the last single-source contradiction: the entry skill called the org spec 'the single source' while the map is the authority the validate stage grades against. Now: org spec = ORIGIN/authoritative criteria; the map = the lane's SCOPED authority for WHAT to grade, derived from the spec (stated why: the distros corpus cannot load the internals agent spec). The cold-reader no longer says it 'does not restate' — it points at the map. * fix(eval): close #EvalCheck/#EvalStep element defs (unknown element fields) pr-validator BLOCK: the schema's 'EVERY level is close()d' claim was false for #EvalCheck and #EvalStep, so an unknown field inside a checks[]/steps[] element was silently accepted. Both are now close({...}). Proven: the real #EvalRecord and #NotTestableRecord still validate, and a record with oracle.checks[0].bogus_elem fails (field not allowed). --------- Co-authored-by: agent <[email protected]>
Summary
Adds a
kind: emitstage to the pipeline engine — the generic schema-first artifact writer. A structured value (assembled from the reference grammar, with array/map leaf types preserved) is validated against an authored CUE schema with Concreteness required BEFORE any bytes are written, then marshalled through the CUE YAML encoder. The schema may be (1) a plugin def (#Foo), (2) a committed.cuefile (path.cueorpath.cue#Def), or (3) a literal CUE source. String leaves may carry${var}markers (indent/bullets/…), so a prose field is composed without a hand-written YAML template.Why. The
generatestage renders a free-form string template — a writer the caller cannot validate at authoring time. A single unquoted scalar containing": "(e.g.what: Docs-only change: …) produces YAML no parser can read; a lane that then re-reads its own committed record (the render-once cache) crashed on the NEXT run withunreadable committed plan. Schema-first emission makes that class impossible: a value that violates the schema fails the stage informatively instead of shipping bytes no reader can consume.Also changed: the per-run ledger dump (
stage-findings.yml) is now written schema-first against#StageFindings, and theREADME.mdrun-line's stage list namesade/emit.How tested
All commands below were run on the FINAL tree (head
3348d3a), incandy/plugin-pipeline.1. Format / vet / test:
2. The changed emit/ledger paths, verbose (11 tests;
-vprints=== RUN+--- PASS):TestEmitStage_SchemaFirstRecordis the exact regression (awhatscalar containing": "round-trips throughyaml.Unmarshal);TestDumpLedger_SchemaFirstcovers the second changed behavior (a row message with":"and an embedded newline round-trips); the reject tests prove no artifact is written on a schema/marker/transform violation.3. Params reproducibility (the CI gate recipe, run locally):
4. Exercised live by the built plugin, on a
disposable: truetarget (opencharly/eval-omarchy, PR 11803). The consumer switched itsrecord/not-testablestages tokind: emitwithschema: candy/eval-pr/record.cue; the engine was served from this branch viaCHARLY_REPO_OVERRIDE=github.com/opencharly/plugin-pipeline=<this checkout>(charly compiles the overridden source), and the lane ran a disposable golden-VM clone (check-omarchy-eval-base-inst:golden,disposable: true):The emitted record is valid YAML and schema-required fields are present (
yq e '.'accepted it):The render-once cache — the case that previously crashed on the free-form record — now re-reads the emitted record:
The consumer PR (opencharly/eval-omarchy) links these changes.
Head diff:
Rulebook compliance
plugin,go,checkskills loaded.marshalSchemaFirst, taking a compiled schema) shared by the emit stage and the ledger dump; ONE validator path (runAuthoredValidator) shared bygenerateandemit.generatestage remains only for the bed template (whose consumer runscharly box validate).gofmt/vet/testrun on the final tree and pasted.params/cue_types_gen.goregenerated fromschema/pipeline.cue; the CI reproducibility recipe passes.CHARLY_REPO_OVERRIDE.emitstage live on adisposable: truegolden-VM clone.Change classification
gofmt/vet/test+ the params-reproducibility recipe + the consumer's live disposable-bed lane run.runEmit,renderStringLeaf,marshalSchemaFirst,dumpLedger) executed live in unit tests and in the consumer lane.Assisted-by: opencode ollama-cloud/deepseek-v4.1-flash (fully tested and validated)