Repository navigation
fix(generator): stop padding blank lines inside block prompts - #1090
Conversation
`block_prompt` rendered its text through `indent(12, blank=True)`, which pads a blank line out to twelve spaces. Adopters run pre-commit's trailing-whitespace hook over their generated workflows, so the file they commit could never match what `init` emits — the next regeneration puts the padding back. Nothing hit it until #1074 gave `tend-notifications` the first multi-line prompt to go through the macro. The two forms parse identically inside a YAML block scalar, so this is churn, not a behavior change. pytest-regtest normalizes trailing whitespace before comparing, so the snapshots could not have caught this. The assertion is explicit instead, folded into the test that already guards the end-of-file-fixer hook, since both are the same failure: whitespace an adopter's pre-commit rewrites. > _This was written by Claude Code on behalf of max-sixty_
Review of the first commit turned up two gaps. `indent(12, first=True)` still pads a *blank* first line, because Jinja prepends the indent unconditionally when `first=True` — so dropping `blank=True` closed the instance #1074 hit, not the class. A prompt ending in a blank line had the same shape, tripping end-of-file-fixer instead. Both now go through an `indent_block` filter that indents only non-blank lines and clips trailing ones, which a `|` block scalar does anyway. The test reached seven workflows on one harness: `generate_all` skips ci-fix without `watched_workflows` and install-test without its flag, so neither was covered, and codex was not either. It now runs all eight across both harnesses, with a nightly prompt carrying leading, interior, and trailing blank lines. Restoring `blank=True`, restoring `first=True`, or dropping the trailing-line clip each fails all four parametrizations. > _This was written by Claude Code on behalf of max-sixty_
tend-agent
left a comment
There was a problem hiding this comment.
The class this closes has one member left, on the path where it costs the most.
_indent_block clips trailing lines with rstrip("\n"), so a prompt whose final line is whitespace-only slips through: the per-line rstrip() flattens it to an empty line, and since block_prompt renders last in tend-nightly.yaml, the file ends on a blank line — the end-of-file-fixer half of the same failure, reintroduced by the fix for the trailing-whitespace half.
It's reachable from ordinary adopter config, not just a hand-built escape sequence. A literal block scalar whose last line carries stray spaces:
workflows:
nightly:
prompt: |
sweep the repo
parses to 'sweep the repo\n \n', and generate_all emits a tend-nightly.yaml ending in \n\n. Suggested one-token fix inline, plus the prompt extension that guards it.
Verification
Against the head commit, on this checkout:
_indent_block("alpha\n\n ", 12)returns' alpha\n\n'— trailing blank retained. Withrstrip()it returns' alpha'.- Rendering the config above through
Config.load+generate_allgivescontent.endswith("\n\n") == True; withrstrip(),False. - Leading and interior blanks are unaffected either way:
_indent_block("\n\nalpha\n\nbeta\n\n", 12)is'\n\n alpha\n\n beta'in both. - The suggested test change fails all four parametrizations against the current implementation and passes against
rstrip(), so it is load-bearing in both directions. - Full
uv run pytest(763 tests) passes with the suggested change applied.
The rest of the change holds up under mutation: padding blank lines (restoring blank=True) and dropping the newline clip each fail all four parametrizations, so the new coverage is real rather than incidental. The other indent(..., first=True) call sites — check_script, condition|trim, run_body — are fed generator-owned text, so the prompt path really is the only adopter-supplied string reaching a block scalar.
`rstrip("\n")` left a final line of spaces standing; the per-line
`rstrip()` then flattened it to an empty one, so `tend-nightly.yaml` —
where the prompt renders last — ended on a blank line. That is the
end-of-file half of the same failure, reintroduced by the fix for the
trailing-whitespace half.
It needs no contrived input: a block-scalar prompt whose last line carries
stray spaces parses to `"...\n \n"` and reaches it. `rstrip()` covers
both, and the nightly prompt in the test now ends that way.
> _This was written by Claude Code on behalf of max-sixty_
Release step 11 for [0.1.22](https://github.com/max-sixty/tend/releases/tag/0.1.22): moves Tend's eight generated workflows and the hand-maintained `review-reviewers.yaml` onto `max-sixty/tend/[email protected]`. `init` rewrites only the generated `tend-*.yaml` files, so the reviewer workflow is restamped by hand. The whole diff is the version stamp and the action ref. No behavior changes ride along — 0.1.22 carries one generator fix ([#1090](#1090)) and its effect here is an absence: `tend-notifications.yaml` no longer gains the padded blank line that 0.1.21 emitted, so `pre-commit run --all-files` rewrites nothing after `init`. That was the property the fix restored, and this PR is where it is observable. > _This was written by Claude Code on behalf of max-sixty_
Automated nightly regeneration of tend's workflow files. **tend version:** 0.1.20 → 0.1.22 ## Notable changes - **Notifications now run off a recovery queue** (max-sixty/tend#1074). The pre-check drops the old layered inbox sweep (shadowed-run and closed-bot-PR marking) in favour of a single paginated snapshot taken before a 10-minute cutoff, passes that cutoff through to the agent, and keeps repository watching enabled with an idempotent `PUT .../subscription` on every cycle. The job also gains a serial `tend-notifications` concurrency group. - **`tend-review` re-targets instead of skipping** (max-sixty/tend#1082). The "skip when the live HEAD is already examined" gate step and its `if:` guards are gone; a live session now re-targets when HEAD moves. The concurrency group adds `queue: max` so a push can't evict a pending `ready_for_review` run. - **Skills check the default branch for a landed fix before opening a PR** (max-sixty/tend#1070), and `review-runs` gains the run census as a second stranded-trigger drain input (max-sixty/tend#1073). - **Poll/rerun script fixes** (max-sixty/tend#1053, max-sixty/tend#1055): `tend-review` no longer gates the CI poll, and an unresolvable commit fails fast rather than passing silently. - **Generator fixes**: `watched_workflows` and `branches` are validated as string lists (max-sixty/tend#1076), and block prompts no longer get padded blank lines (max-sixty/tend#1090). Full upstream diff: max-sixty/tend@0.1.20...0.1.22 Co-authored-by: worktrunk-bot <[email protected]>
Automated nightly regeneration of tend's workflow files. **tend version:** 0.1.20 → 0.1.22 **Notable changes** - Notifications recover work missed while the unread queue was stale, and the job now runs under its own `tend-notifications` concurrency group so overlapping schedules serialize instead of racing (max-sixty/tend#1074). - Skills check the default branch for a landed fix before opening a PR, cutting duplicate PRs for work that already merged (max-sixty/tend#1070). - `review-runs` gains the run census as a second stranded-trigger drain input (max-sixty/tend#1073), and reviews re-target when HEAD moves rather than being discarded (max-sixty/tend#1082). - The CI poll no longer lets `tend-review` gate it, and the commit-resolution script fails fast instead of proceeding on an unresolved SHA (max-sixty/tend#1053, max-sixty/tend#1055). - The generator validates `watched_workflows` and `branches` as string lists, and stops padding blank lines inside block prompts (max-sixty/tend#1076, max-sixty/tend#1090). max-sixty/tend@0.1.20...0.1.22 **Beyond the regeneration:** 0.1.22's `tend-review.yaml` sets `concurrency.queue: max`, which GitHub accepts but the pinned `actionlint` hook rejects, so this PR also adds a scoped `-ignore` for that one schema message to `.pre-commit-config.yaml` — otherwise `lint` is red and the PR can't merge on its own CI. Tracked upstream as max-sixty/tend#1094. --------- Co-authored-by: leaf-agent <[email protected]>
block_promptrendered its text throughindent(12, blank=True), whichpads a blank line out to twelve spaces. Adopters run pre-commit's
trailing-whitespacehook over their generated workflows, so the filethey commit could never match what
initemits — the next regenerationputs the padding back.
Nothing hit it until #1074
gave
tend-notificationsthe first multi-line prompt to go through themacro. Every form here parses to the same string inside a YAML block
scalar, so this is churn, not a behavior change.
Why it matters beyond the diff
tend-nightlyregenerates withuvx tend@latest initand opens a PR whenNON_STAMP_DIFFis non-zero. That guard filters only the# Generated by tend X.Y.Zheader, so the-/+whitespace pair counts2 and the PR gets created. That PR's
lintjob runspre-commit/[email protected], which defaults to--all-files, sotrailing-whitespacerewrites the file and fails the job — a valuelessred PR every night until this ships in a release.
The whole class, not the one instance
Jinja's
indentcannot render a block scalar without leaking one ofthese, because it prepends the indent unconditionally when
first=True:prompt:"alpha\n\nbeta""\nalpha""alpha\n\n"\n\n"alpha\n \n"\n\nAll four go through an
indent_blockfilter that indents only non-blanklines and clips trailing ones — which a
|block scalar does anyway, sono prompt value changes.
Testing
The assertion is folded into the test that already guarded the
end-of-file-fixer hook, since both are the same failure: whitespace an
adopter's pre-commit rewrites.
That test reached seven workflows on one harness —
generate_allskipsci-fix without
watched_workflowsand install-test without its flag, andcodex was never exercised. It now covers all eight across both harnesses,
with a nightly prompt carrying leading, interior, and trailing blank lines
and a whitespace-only last line. Restoring
blank=True, restoringfirst=True, or narrowing the clip torstrip("\n")each fails all fourparametrizations.
pytest-regtest normalizes trailing whitespace before comparing, so the
recorded outputs could not have caught this and do not change here.