Skip to content

fix(running-in-ci): warn against escaping backticks in single-quoted heredocs - #423

Merged
max-sixty merged 1 commit into
mainfrom
fix/issue-422
May 11, 2026
Merged

max-sixty merged 1 commit into
mainfrom
fix/issue-422

Conversation

@tend-agent

Copy link
Copy Markdown
Collaborator

Problem

Bot-authored issue/PR/comment bodies have been shipping with literal backslashes in front of every backtick — e.g. \`foo\` instead of `foo` — when the body is composed via gh ... --body "$(cat <<'EOF' ... EOF)". The corruption is authored by the model: it treats backticks inside <<'EOF' heredocs as if command substitution were active and prepends \ defensively. Single-quoted heredocs disable command substitution, so the backslash survives the heredoc as data and renders as a literal backslash before each backtick.

Solution

Extend the existing exclamation-mark guidance in running-in-ci to also call out backticks. The fix shape is the same as the existing rule: when a body contains many code spans, compose it with the Write tool and pass it via --body-file.

One new paragraph adjacent to the existing bang-escape paragraph in plugins/tend-ci-runner/skills/running-in-ci/SKILL.md. Kept brief and parallel to the surrounding text per the skill-authoring guidance in CLAUDE.md.

Testing

This is a skill-text update — no code path exercised. The corruption pattern is reproducible by reading any of the cited corrupted bot bodies. After this lands, the guidance is co-located with the existing bang-escape rule, so a future run that hits a backtick-heavy body has the rule in-context.


Closes #422 — automated triage

@max-sixty
max-sixty merged commit a670bbc into main May 11, 2026
5 checks passed
@max-sixty
max-sixty deleted the fix/issue-422 branch May 11, 2026 10:13
max-sixty pushed a commit that referenced this pull request May 15, 2026
…rule (#495)

## Summary

Extend the existing `<<'EOF' ... EOF` backtick-escape rule to cover
nested fenced code blocks. The current rule warns about escaping *inline
code spans* (`` \`foo\` ``); the same single-quoted-heredoc mechanic
also corrupts *nested fences* when the model defensively escapes the
inner three-backtick fence (`` \`\`\`bash ``) to keep it from closing
the outer fence. The fix is the standard markdown idiom: use a longer
outer fence (four or five backticks) so the inner three-backtick fence
renders intact without escaping.

## Evidence

[PRQL/prql#5900](PRQL/prql#5900) (`tend
ci-fix: transient classifier ignores repeat occurrences`, opened by
prql-bot 2026-05-15T08:56:34Z). The body wraps a proposed skill addition
in a `` ```markdown `` outer fence and contains an inner `` ```bash ``
fence plus several inline code spans. The model escaped the inner fence
and all inline backticks inside the inner section, producing visibly
corrupted markdown — the rendered body shows `` \`\`\`bash ``, ``
\`rustup-init\` ``, `` \`composer connect timeout\` ``, `` \`docker pull
rate limit\` ``, `` \`gh issue search\` ``, and trailing `` \`\`\` ``
(six distinct corrupted spans). Direct API spot-check:

````
$ gh api repos/PRQL/prql/issues/5900 --jq '.body' | grep -c '\\`'
6
````

This is the first such occurrence in the PRQL evidence gist's tracked
corruption-scan history (prior ticks all reported `backslash-backtick:
clean`); the [evidence
log](https://gist.github.com/tend-agent/5686b1fca82c08d385d9031a79be4a3e)
for May 2026 records the scans.

## Classification

- **Failure class**: structural. The trigger is deterministic — a body
composed in a single-quoted heredoc that contains a nested fenced block
+ the model's defensive instinct to escape the inner fence. Replayed,
this produces the same corruption every time. The existing rule already
classifies the inline-code-span variant as authored (not
preprocessor-injected); the nested-fence variant is the same shape with
a different originating model habit.
- **Evidence level**: structural / 1 occurrence — sufficient under
[`review-gates.md`](https://github.com/max-sixty/tend/blob/main/plugins/tend-ci-runner/skills/review-reviewers/review-gates.md):
*"Structural: no decision point — the same conditions produce the same
failure every time... One clear occurrence is sufficient evidence for a
targeted fix."*
- **Change magnitude**: targeted fix — one sentence appended to an
existing paragraph. Within the Gate-2 magnitude budget for
structural-fix scope.

## Change

`plugins/tend-ci-runner/skills/running-in-ci/SKILL.md`: extend the
existing backtick-escape paragraph (already covering inline spans like
`` \`foo\` ``) with a second sentence covering nested fenced blocks.
Recommend a longer outer fence (four or five backticks outside, three
inside) as the standard remedy. Adds a parenthetical noting that
`--body-file` via the Write tool helps with delivery but not authoring —
the model still has to author with bare backticks, since Write preserves
data verbatim.

## Notes

- #5900 itself is left as-is for now; its body is readable and stands as
the in-evidence example for this fix. A clean re-author can follow once
this skill update lands.
- This change does not touch the inline-code-span rule (#423) or the
bang-escape rules (#404, #427, #381, #432) — same paragraph, different
shape, same delivery channel.

Co-authored-by: tend-agent <[email protected]>
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.

Opus 4.7 over-escapes backticks in single-quoted heredocs, corrupting bot comment bodies

2 participants