Skip to content

check run writes an INVALID summary.yml when a check's text exceeds the writer's budget (unterminated YAML scalar) #1308

Done
opencharly/plugin-check
#159

Description

@aitrawog

Category

category:delivery

Type

type:fix

Remedy / files the remedy will touch

the bed runner's summary emitter (summary.yml writer: the truncation of check text/stderr strings) — truncate losslessly and escape, or emit through a YAML marshaller

Cited design decision or org-rulebook rule (or none)

none

Classification

Blocking — it blocks the filer's own progress, so the filer claims it at filing and fixes it.

Evidence (verified: commands with output, file:line, measurements)

Reproduced 2026-11-27 by the bed run of opencharly/distro-arch#85 (check-tmux-pod):
run dir .check/check-tmux-pod/2026.331.1546/.

$ sed -n 214,219p summary.yml | cat -A | cut -c1-160
        reason: exit=0$
      - id: "plan:candy:github.com/opencharly/layer-tmux:3"$
        status: PASS$
        text: "tmux star

The text: scalar is cut mid-word (tmux star) and the closing quote is never written.

$ python3 -c "import yaml; yaml.safe_load(open('summary.yml'))"
yaml.scanner.ScannerError: while scanning a quoted scalar
  in "summary.yml", line 217, column 15
found unexpected end of stream
  in "summary.yml", line 217, column 25

$ wc -l summary.yml
218 summary.yml

So the run's machine-readable verdict is UNPARSEABLE. The same run's phase log also truncates a
failing step's stderr (... agent channel: FAIL terminal:tmux request=… targ…), which is the
only evidence for that failure — the RCA evidence is discarded by the writer.

Impact measured: check-tmux-pod's run of opencharly/distro-arch#85 cannot be graded from
summary.yml at all (any YAML reader fails), and the agent-channel failure it recorded cannot be
root-caused from the artifact.

Mechanism

a string field longer than the writer's budget is cut mid-scalar WITHOUT closing the quote, so the whole summary.yml is invalid YAML; every consumer (the gate, clean, CI) fails to parse a run that actually completed

Missed control

the summary is assembled by string concatenation, so no test asserts it round-trips through a YAML parser; a long check description or a failing step's stderr is enough to break it

Blast radius

every bed whose check text or stderr exceeds the budget writes an unreadable summary — measured on check-tmux-pod, where the only evidence for an agent-channel failure is also truncated away

Root fix

marshal the summary with a YAML library (or escape+terminate every truncated string) and add a test that a long text/stderr round-trips

Spike (its result, or none with the reason)

none: the observation is the instrument (yaml.safe_load raises on the produced file); the remedy is a writer change

Agent: jolly-comet-ses_de3fa473bffeFiBo62whHxDPE5 · OpenCode session ses_de3fa473bffeFiBo62whHxDPE5
Assisted-by: OpenCode DeepSeek V4.1 Flash (analysed on a live system)

Activity

  1. aitrawog commented on Nov 27, 2026

    @aitrawog
    ContributorAuthor

    CLAIM

    Filed as blocking: it blocks this session's own progress, so this session claims it at filing and fixes it.

    Agent: jolly-comet-ses_de3fa473bffeFiBo62whHxDPE5 · OpenCode session ses_de3fa473bffeFiBo62whHxDPE5
    Assisted-by: OpenCode DeepSeek V4.1 Flash (analysed on a live system)

  2. added
    category:delivery
    on Nov 27, 2026
  3. self-assigned this
    on Nov 27, 2026
  4. added
    type:fix
    on Nov 27, 2026
  5. aitrawog commented on Nov 27, 2026

    @aitrawog
    ContributorAuthor

    STATUS

    Correction that changes the RCA, from locating the writer:

    • Writer: writeBedSummary in opencharly/plugin-check's candy/plugin-check/bed_run.go:1731, string-concatenating YAML via a yamlScalar helper.
    • yamlScalar (evidence.go:147) is correct: it returns strconv.Quote(s) for anything needing quoting, so it cannot emit an unterminated scalar.
    • And the artifact does not just have an unquoted value — the file ENDS at that line:
    $ wc -l summary.yml
    218 summary.yml
    $ tail -1 summary.yml
            text: "tmux star
    

    So the summary was cut off mid-write, not mis-quoted: the writer never reached its next field, which is why there is no closing quote (the " belongs to %q of a value it was still emitting).

    What coincides: that run took the filesystem to its quota (/tmp reported disk quota exceeded during the same session, and a cp in this very worktree failed with it minutes later). A short write that ignores the flush error would produce exactly this artifact.

    So the fix is not "escape the scalar" — it is "the summary write must be atomic and its errors must not be swallowed" (write to a temp file, Sync, rename; surface the error). I am leaving the issue's evidence as-is rather than rewriting its mechanism mid-thread; this comment is the pointer for whoever takes it, and the reproducer is the same run dir.

    Agent: jolly-comet-ses_de3fa473bffeFiBo62whHxDPE5 · OpenCode session ses_de3fa473bffeFiBo62whHxDPE5
    Assisted-by: OpenCode DeepSeek V4.1 Flash (analysed on a live system)

  6. aitrawog commented on Nov 27, 2026

    @aitrawog
    ContributorAuthor

    CLAIM

    Claiming: I filed it, it is blocking (it is why opencharly/distro-arch#85's bed cannot be RCA'd), and I own the fix.

    Where it lives — established since filing, and it corrects the original mechanism:

    • the writer is writeBedSummary in opencharly/plugin-check (candy/plugin-check/bed_run.go:1731);
    • its yamlScalar helper (evidence.go:147) is CORRECT — it uses strconv.Quote, so it cannot emit an unterminated scalar;
    • and the artifact is not merely unquoted, it ends: wc -l summary.yml → 218, last line text: "tmux star.

    So the summary is cut off mid-write, and the fix is an atomic, error-surfacing write (temp file → sync → rename) rather than string escaping. The failing step's stderr is truncated in the same artifact, which is what makes this blocking rather than cosmetic: it discards the only evidence for the agent-channel failure recorded on distro-arch#85.

    Producer-first: the fix goes to plugin-check, then the charly/plugin pins that adopt it.

    Agent: jolly-comet-ses_de3fa473bffeFiBo62whHxDPE5 · OpenCode session ses_de3fa473bffeFiBo62whHxDPE5
    Assisted-by: OpenCode DeepSeek V4.1 Flash (analysed on a live system)

  7. aitrawog commented on Nov 27, 2026

    @aitrawog
    ContributorAuthor

    STATUS

    Fix in review: opencharly/plugin-check#158 — summary.yml is now written atomically (temp file in the same directory, fsync, rename), so a short write can no longer replace the verdict with a truncated document, and the real error is returned instead of printed while the caller proceeds.

    Confirmed root cause while fixing it: writeBedSummary used a plain os.WriteFile, and the scalar helper is correct (strconv.Quote) — the file simply ENDS mid-write (wc -l → 218, last line text: "tmux star), which is why no escaping change could have helped.

    The test pins the invariants the old call violated (byte-complete content, no temp residue, a refused write leaves no partial document). Stated honestly in the PR: the production trigger is an ENOSPC short write, which the unit gate cannot synthesise without a size-limited filesystem — the live artifact is the red.

    Once released, this unblocks the bed evidence for opencharly/distro-arch#85 and for #1309 (the post-update passwd regression), whose RCA needs a failing step's full stderr.

    Agent: jolly-comet-ses_de3fa473bffeFiBo62whHxDPE5 · OpenCode session ses_de3fa473bffeFiBo62whHxDPE5
    Assisted-by: OpenCode DeepSeek V4.1 Flash (fully tested and validated)

  8. aitrawog commented on Nov 27, 2026

    @aitrawog
    ContributorAuthor

    RESOLVED — fixed by opencharly/plugin-check#159 (merged 38ebda72c3c5, tag v2026.331.2239).

    The bed runner now writes summary.yml atomically: temp file in the same directory → write → Sync → Close → Chmod → Rename, with the temp removed on every failure path, so a short write can no longer leave a truncated document behind (the earlier artifact ended mid-scalar at line 218 and no YAML reader could parse it).

    Verified on plugin-check main:

    $ gh api repos/opencharly/plugin-check/contents/candy/plugin-check/bed_run.go?ref=main | base64 -d | grep -c writeFileAtomic
    3
    

    and proven on the PR's own head by a real disposable: true bed run (check-pod-overlay): PASS (steps=16, skipped_checks=3), and its summary.yml parses (status: PASS | steps: 16) with 0 temp residue.

    The regression test reproduces a POST-open short write (RLIMIT_FSIZE child writing 8 KiB) and fails on the old os.WriteFile with the previous document was destroyed by a short write, so the change is distinguished by a test that could fail.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

category:deliverytype:fix

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions