Skip to content

fix(report): a step renders on ONE line, so a reader can pair its status with its id - #283

Merged
github-actions[bot] merged 1 commit into
mainfrom
fix/report-one-line-per-step
Oct 29, 2026
Merged

github-actions[bot] merged 1 commit into
mainfrom
fix/report-one-line-per-step

Conversation

@aitrawog

Copy link
Copy Markdown
Contributor

Summary

The text report is a LINE format: a reader pairs each step's status with its id by parsing
one line per step, and the report states its own step count in the rollup it prints
underneath. renderStep wrote a step's text and its message VERBATIM, so a step whose text
carried a newline SPANNED several lines and its id bracket landed on a line of its own. The
report's step lines then disagreed with the report's own rollup, and a reader that checks
the two refuses the WHOLE report and credits nothing from it.

Head f222b752eb80838777e2afbf6540c3c552677a38 — 2 files changed, 259 insertions(+), 5 deletions(-)

$ git rev-parse HEAD
f222b752eb80838777e2afbf6540c3c552677a38
$ git diff --shortstat origin/main...HEAD
 2 files changed, 259 insertions(+), 5 deletions(-)

Where it was found. opencharly/layer-docs-site#13's R10 bed, charly check run check-docs. All five of its check phases SKIP — "the child's report could not be read: 21
step line(s) against the 22 step(s) its own rollup counted"
— and the run exits 3. The base
tree of that repo, WITHOUT the change that found it, produces the identical skip with the
identical numbers and the identical exit code, so the defect is pre-existing and lives HERE,
in the producer of the format.

What lands.

  • OneLine — the one flattening rule for the report: every run of whitespace, a newline
    included, becomes one space. A step's keyword, text, id and message all go through it.
  • renderStep writes the flattened fields, so a step is exactly one line and its status and
    its id are on the SAME line.
  • The TAP reporter flattens the same way — a test point is one line too. Its diagnostic
    block is %q-quoted, so a multi-line message cannot break a point.
  • The JSON and JUnit reports are STRUCTURED and carry the step's text as data; they keep the
    text verbatim, and the JUnit attribute is XML-escaped by the encoder.
  • truncate cuts on a CHARACTER boundary. It used to cut on BYTES, so a multi-byte rune
    could be cut in half and the report carried invalid UTF-8 — a line a reader cannot
    decode, in a report whose whole value is that a reader can read it. The 200 limit now
    counts characters rather than bytes.

How tested

The work happened on fix/report-one-line-per-step in this repo's own session worktree, off
fresh origin/main (49c9a98), and the tree every gate ran in is the tree the commit
carries.

$ git status --short; echo "STATUS_RC=$?"
STATUS_RC=0
$ GOWORK=off go build ./...; echo "BUILD_RC=$?"
BUILD_RC=0
$ GOWORK=off go test ./... > /tmp/spec-test.log 2>&1; echo "TEST_RC=$?"
TEST_RC=0
$ grep -cE "^ok " /tmp/spec-test.log
25
$ out=$(gofmt -l .); if [ -n "$out" ]; then echo "gofmt would rewrite: $out"; else echo "gofmt: clean"; fi
gofmt: clean
$ GOTOOLCHAIN=go1.26.8 GOWORK=off golangci-lint run ./...; echo "LINT_RC=$?"
0 issues.
LINT_RC=0

The linter runs against the go1.26 toolchain this module's go directive names, exactly as
the repo's CI does it (setup-go reads go.mod, then go install builds the pinned
golangci-lint). A linter built with a NEWER Go cannot read this module's dependency graph:
golang.org/x/net v0.52.0 ships a go1.27-only file, and the go1.26 go/types refuses it
and the linter's loader panics. That is a local toolchain pairing, not a finding in this
diff — the CI run on main (49c9a98) is green.

The regeneration gate is a no-op on the committed tree, and its own reproducibility check
passes:

$ charly task cue-gen; echo "CUEGEN_RC=$?"
task cue-gen: 2 step(s), 0 failed, 0 skipped
  [pass] run — gengotypes + schemagen the generated Go
      exit=0
  [pass] check — regen is reproducible — TestGenReproducible passes on the committed tree
      exit=0
CUEGEN_RC=0
$ git status --short

The coverage fails without the change. The OLD renderer — origin/main's — cannot
satisfy the shape the readers parse. The same fixture is driven against the old renderer
and against the committed one:

$ (restore origin/main's report/report.go into a copy of the committed tree, adding
   OneLine to it so the new tests COMPILE — the old renderer does not call it) &&
  GOWORK=off go test ./report/...
--- FAIL: TestFormatStepResultsText_OneLinePerStep (0.00s)
    report_test.go:78: the report carries 8 step line(s) for 2 step(s); a step must be ONE line:
          SKIP  run command=case "${BUILD_ARCH}" in
          x86_64)  PNPM_ARCH="x64" ;;
          aarch64) PNPM_ARCH="arm64" ;;
        esac
        curl -fsSL "https://example.invalid/pnpm" -o /usr/local/bin/pnpm  [plan:candy:github.com/opencharly/layer-nodejs:0]  skipped — verify-only mode (mutating step)
          FAIL  check the site builds  [docs-site-index-built]  npm ci failed
        npm ERR! code EUSAGE
        npm ERR! A complete log of this run can be found in: /root/.npm/_logs/1.log

        2 steps: 0 passed, 1 failed, 1 skipped
--- FAIL: TestFormatStepResultsTAP_OnePointPerStep (0.00s)
    report_test.go:164: the TAP report carries a line that is not a TAP construct — a step spilled over its own point:
        TAP version 13
        1..2
        ok 1 - run command=case "${BUILD_ARCH}" in
          x86_64)  PNPM_ARCH="x64" ;;
          aarch64) PNPM_ARCH="arm64" ;;
        esac
        curl -fsSL "https://example.invalid/pnpm" -o /usr/local/bin/pnpm
        not ok 2 - check the site builds
          ---
          origin: "docs-site-app"
          step_id: "docs-site-index-built"
          verb: ""
          message: "npm ci failed\nnpm ERR! code EUSAGE\nnpm ERR! A complete log of this run can be found in: /root/.npm/_logs/1.log"
          ...
--- FAIL: TestTruncate_CutsOnARuneBoundary (0.00s)
    report_test.go:202: truncate produced invalid UTF-8: "→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→\xe2…"
FAIL
FAIL	github.com/opencharly/spec/report	0.003s
FAIL

The same three tests on the committed tree:

$ GOWORK=off go test ./report/...; echo "TEST_RC=$?"
ok  	github.com/opencharly/spec/report	0.003s
TEST_RC=0

The report the change produces — one line per step, the status and the id on the SAME
line, the rollup agreeing with the lines the report carries:

  SKIP  run command=case "${BUILD_ARCH}" in x86_64) PNPM_ARCH="x64" ;; aarch64) PNPM_ARCH="arm64" ;; esac curl -fsSL "https://example.invalid/pnpm" -o /usr/local/bin/pnpm  [plan:candy:github.com/opencharly/layer-nodejs:0]  skipped — verify-only mode (mutating step)
  FAIL  check the site builds  [docs-site-index-built]  npm ci failed npm ERR! code EUSAGE npm ERR! A complete log of this run can be found in: /root/.npm/_logs/1.log

2 steps: 0 passed, 1 failed, 1 skipped

No verbatim write of a step's text survives — every write of a step's text, keyword, id
or message in the module goes through the one flattening rule:

$ grep -rn "step.Text\|step.Result.Message" --include=*.go . | grep -v _test.go
report/report.go:81:	if step.Result.Status == spec.StatusFail && exec.IsContainerInfraResult(step.Result.Message) {
report/report.go:89:	msg := OneLine(step.Result.Message)
report/report.go:94:		status, OneLine(step.Keyword), OneLine(step.Text), OneLine(step.StepID), retryInfo, truncate(msg, 200))
report/report.go:129:		fmt.Fprintf(w, "%s %d - %s %s\n", directive, i+1, OneLine(step.Keyword), OneLine(step.Text))
report/report.go:135:			fmt.Fprintf(w, "  message: %q\n", step.Result.Message)
report/report.go:188:			Name:      step.Keyword + " " + step.Text,
report/report.go:195:				Message: step.Result.Message,
report/report.go:200:			tc.Skipped = &junitSkipped{Message: step.Result.Message}
grep exit=0

The three lines that keep the text verbatim are deliberate and each is safe by construction:
line 81 is the infra discriminator (it reads the message, it does not print it), line 135 is
the TAP diagnostic block's %q-quoted message (a quote escapes the newline), and lines
188–200 are the JUnit report, which is structured — its attribute is XML-escaped by the
encoder and its element content is not a line format.

Rulebook compliance

  • R0 — this repository's own AGENTS.md was read before acting in it (Part II feat(spec): CUE-source ResolvedBox/BuilderMap/AggregatedCandyCaps (#55 step3 unit 3a) #4), and
    /charly-internals:go, /charly-internals:git-workflow,
    /charly-internals:root-cause-analyzer and /charly-internals:strict-policy were loaded
    before the first edit and before the git actions. The change is Go source work in a
    module whose gate its AGENTS.md names.
  • R1 — the anomaly was analysed before the remediation, and the analysis named the
    mechanism (the producer does not guarantee the shape the consumers parse), the missed
    control (nothing asserted "a step is one line", and no test rendered a step whose text
    carries a newline), the blast radius (every bed whose plan carries a multi-line step, and
    the TAP report), and the root fix (the producer flattens, and this module's own tests
    assert the shape). The defect was not introduced by the change that found it — the
    base tree reproduces it identically — and it is fixed HERE, producer-first, in the repo
    that owns the format. A second finding on the same surface, truncate cutting on bytes,
    is fixed in the same change; it is in the same function family and the change's own
    claim — a report line is well-formed text a reader can decode — is false without it. No
    warning was tolerated anywhere: the test run, the build, the linter and the regeneration
    gate all report zero.
  • R2 — one implementation: OneLine is the single flattening rule, and the text
    reporter and the TAP reporter both go through it. There is no second copy of the rule and
    no second copy of the truncation.
  • R3 — no workaround: the fix is the real rule at the producer, with three tests that
    fail on the old renderer; there is no sleep, no retry, no suppression and no fallback
    branch. The reader is not taught to cope — it is given the shape it already requires.
  • R4 — the product came first: the renderer and its tests are fixed and proven before
    the prose, and the only prose this change touches is the code's own comment, which
    describes a control that exists.
  • R5 — nothing is left behind: the verbatim write of a step's text is gone from both
    line formats, and the claim-keyed sweep is pasted above. No alias, shim, TODO or
    deprecated path is introduced, and no legacy name survives anywhere in the module.
  • R6 — the work happened in this repository's own session worktree, on
    fix/report-one-line-per-step, off fresh origin/main; no other session's work, branch
    or worktree was touched, and no destructive git action was taken. The commit was made
    before the first push, and nothing is amended or force-pushed after it.
  • R7 — the coverage fails without the change: the old renderer fails all three new
    tests, with the rendered report pasted above showing the eight lines it produced for two
    steps. The changed path — the report renderer — executed live, and its real output is
    pasted above in full.
  • R8 — nothing live is mocked: the fixture is a real []spec.StepResult rendered
    through the real reporter into a real buffer, and the proof is the program's own output.
    No service is involved, and none is stubbed.
  • R9 — N/A — this module ships a Go library, not a binary: no charly binary is built
    or installed here, so there is nothing to stamp. The one binary the gate ran
    (charly task cue-gen) is the worktree-local, CalVer-stamped build from opencharly/charly's
    own worktree, never a shared install.
  • R10 — the change class is a Go library change in a module that carries no
    disposable: true bed, so the gate is the one its AGENTS.md names — go build ./...,
    go test ./..., gofmt, golangci-lint and charly task cue-gen — and all of it ran on
    the committed tree with zero warnings. The end-to-end proof that this fix makes a REAL bed
    GREEN is the consumer leg of the producer-first chain (charly's spec pin bump, then the
    check-docs bed), and it is that leg's job to carry it.

Change classification

A bug fix in a library: the report format's producer now guarantees the shape the format's
consumers parse. It removes nothing that was usable and adds no new surface beyond one
exported helper, so no cutover machinery applies — the report's contract is unchanged in
NAME and in FIELD, and only the shape of a rendered step's text is corrected, to the shape
the readers already require. The gate is this module's own; the merge gate is the org-wide
charly/pr-validator.

Filed issues

None filed by this change — every finding it raised is fixed in it. The consumer-side
consequence is tracked where it lives: opencharly/layer-docs-site#13 (whose check-docs bed
SKIPs until this fix reaches the binary) and opencharly/plugin-check#135 (the report format
is a contract, and the verdict reader parses it as TEXT).

Agent: charly

Assisted-by: Claude Code minimax/minimax-m3.1-flash:cloud (fully tested and validated)

…tus with its id

The text report is a LINE format: a reader pairs each step's status with its id by
parsing one line per step, and the report states its own step count in the rollup it
prints underneath.

renderStep wrote step.Text and the step's message VERBATIM, so a step whose text
carried a newline SPANNED several lines and its id bracket landed on a line of its
own. The report's step lines then disagreed with the report's own rollup, and a
reader that checks the two refuses the WHOLE report and credits NOTHING from it.

It was found while running opencharly/layer-docs-site#13's R10 bed: all five of
`charly check run check-docs`'s check phases SKIP with "the child's report could
not be read: 21 step line(s) against the 22 step(s) its own rollup counted", and
the run's exit code is 3. The base tree — WITHOUT that change — produces the
identical skip with the identical numbers, so the defect is pre-existing and lives
here, in the producer of the format.

The PRODUCER owns the format, so the producer guarantees the shape it publishes:

  * OneLine is the ONE flattening rule for the report — every run of whitespace,
    a newline included, becomes one space. A step's keyword, text, id and message
    all go through it.
  * Flattening also collapses every run of TWO OR MORE spaces, so the two-space
    separator before a step's id bracket is the only one on the line: a reader can
    split the line on it without a bracket inside the text stealing the split.
  * The TAP reporter is a line format too — a test point is one line — so it
    flattens the same way. The JSON and JUnit reports are structured and are
    unaffected.

A second finding on the same surface, fixed in the same change: truncate cut on
BYTES, so a multi-byte rune could be cut in half and the report carried invalid
UTF-8 — a line a reader cannot decode, in a report whose whole value is that a
reader can read it. It now cuts on a CHARACTER boundary.

Before/after, on the same fixture (a plan step whose `run:` block is a multi-line
script, and a failure message that quotes a multi-line output):

  before — the report carries 8 step line(s) for 2 step(s), the id of the first
           step sits on a line that carries no status, and the TAP report spills
           a step over its own point;
  after  — one line per step, the status and the id on the SAME line, and the
           rollup agreeing with the lines the report carries.

Assisted-by: Claude Code minimax/minimax-m3.1-flash:cloud (fully tested and validated)
@github-actions

Copy link
Copy Markdown

Review — PASS

Verification of the change

report/report.go

  • OneLine (strings.Fields → Join) is a single, correct flattening rule: it collapses every run of Unicode whitespace (including \n, \t, NBSP) to one space and trims ends. Applying it to Keyword, Text, StepID, and Message in renderStep guarantees one physical line per step, and because it also removes runs of two spaces, the " [" id separator becomes unambiguous — matching the contract the tests assert.
  • The status word is not flattened, but it derives from Status.String() and cannot contain whitespace; the %-5s padding is safe.
  • truncate now measures with utf8.RuneCountInString and slices []rune(s)[:n], guarded by the early-return when RuneCount <= n. This cannot slice past the end and cannot split a multi-byte rune, so it emits valid UTF-8. The + "…" suffix yields n+1 runes, consistent with the test.
  • TAP point line flattens Keyword/Text; the diagnostic block keeps %q-quoted values, which escape \n, so a multi-line message cannot break a point. The unchanged verbatim writes (line 81 reads the message; line 135 is %q; JUnit attribute is XML-escaped) are correctly left verbatim and are safe by construction, exactly as the body states.

report/report_test.go

  • TestFormatStepResultsText_OneLinePerStep asserts the load-bearing shape: exactly len(results)+2 lines, a blank line before the rollup, the rollup count, exactly one status line per step, the id bracket on exactly one line, that line carrying the status, and the " [" separator count of 1. This fails on the old verbatim renderer (as the body's pasted output shows) and passes on the new one.
  • TestFormatStepResultsTAP_OnePointPerStep uses a tapConstruct regex that accepts only header/plan/point/diagnostic lines; a spilled step would match none and fail. Point-number parsing and whole-text (OneLine) containment are correct.
  • TestTruncate_CutsOnARuneBoundary proves valid UTF-8 and n+1 rune length on the → fixture — fails on a byte cut.
  • TestOneLine_FlattensEveryWhitespaceRun locks the rule and asserts no residual double space.
  • Imports are all used; no dead code, shim, alias, or leftover verbatim path in either line format.

Body honesty

  • File/shortstat claims match the diff exactly: 2 files, +37+222 = 259 insertions, 5 deletions.
  • The "no verbatim write survives" sweep is consistent with the diff: the three retained verbatim sites are the infra discriminator (read, not printed), the %q diagnostic, and structured JSON/JUnit — all safe.
  • The old-renderer failure transcript is internally consistent with the tests present (same fixtures, same three test names) and the "committed tree passes" claim follows from the assertions.

Comments

  • No comments were provided, so there is no sign-off to weigh and no external claim to reconcile. The change stands on its own evidence.

No correctness, honesty, coverage, security, or scope defect is found in the current diff.

Verdict: PASS


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

View action run

@github-actions
github-actions Bot enabled auto-merge (squash) October 29, 2026 03:26
@github-actions
github-actions Bot merged commit 4266c8b into main Oct 29, 2026
4 checks passed
charly-auto-merge Bot added a commit that referenced this pull request Oct 29, 2026
github-actions Bot pushed a commit to opencharly/charly that referenced this pull request Oct 29, 2026
…o a reader can pair its status with its id) (#1086)

`github.com/opencharly/spec` is compiled into the charly binary, so the pinned module
version IS the behaviour of `charly check run` — of the bed record every R10 proof rests
on.

At the pinned version (v0.2026296.1036) a step whose text carries a newline spanned
SEVERAL lines of the child's report: `spec/report`'s `renderStep` wrote `step.Text`
verbatim, so the step's `[id]` bracket landed on a line of its own and no line carried
both the status and the id. `plugin-check`'s reader matches ONE line per step, so it
credited nothing for that step, the child's report carried 21 step lines against the 22
its own rollup counted, and — since plugin-check#134 — a report that disagrees with
itself is refused WHOLE. Every check phase of the bed then SKIPs and the run exits 3.

That is exactly what opencharly/layer-docs-site#13's `check-docs` bed hit: all five of
its check phases SKIP with "the child's report could not be read: 21 step line(s)
against the 22 step(s) its own rollup counted". The base tree of that repo, WITHOUT
that repo's own change, produces the identical skip with the identical numbers and the
identical exit code 3 — so the defect is pre-existing and lives in the PRODUCER of the
report format.

The producer is fixed, producer-first, in opencharly/spec#283 (squash 4266c8b, module
tag v0.2026302.327): `spec/report` now renders every step on EXACTLY one line — the text
and the message flattened through one rule — so the status and the id are on the SAME
line, and `truncate` cuts on a character boundary so a report line is always decodable.
The producer's own tests assert the invariant and FAIL against the old renderer.

`charly/go.mod:142` moves `github.com/opencharly/spec` from v0.2026296.1036 to
v0.2026302.327. The three lockstep modules move with it — tools/generate-packages,
tools/golden-cloudinit and tools/golden-compile — by `charly task mods-tidy`, because
tools/gomod-canonical's TestContractPinsMatchShared requires every in-repo module that
requires a contract module to list the SAME shared sdk and spec pins.

The sdk pin is unchanged (v0.2026297.1851, which requires spec v0.2026280.2244):
v0.2026302.327 is the maximum the module graph selects, so no sdk move is behind it and
no cascade follows.

Assisted-by: Claude Code minimax/minimax-m3.1-flash:cloud (fully tested and validated)
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