Skip to content

fix(generator): stop padding blank lines inside block prompts - #1090

Merged
max-sixty merged 3 commits into
mainfrom
fix-block-prompt-blank
Aug 30, 2026
Merged

max-sixty merged 3 commits into
mainfrom
fix-block-prompt-blank

Conversation

@max-sixty

@max-sixty max-sixty commented Aug 30, 2026 •

Copy link
Copy Markdown
Owner

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. 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-nightly regenerates with uvx tend@latest init and opens a PR when
NON_STAMP_DIFF is non-zero. That guard filters only the
# Generated by tend X.Y.Z header, so the -/+ whitespace pair counts
2 and the PR gets created. That PR's lint job runs
pre-commit/[email protected], which defaults to --all-files, so
trailing-whitespace rewrites the file and fails the job — a valueless
red PR every night until this ships in a release.

The whole class, not the one instance

Jinja's indent cannot render a block scalar without leaking one of
these, because it prepends the indent unconditionally when first=True:

adopter prompt: what leaks which hook
"alpha\n\nbeta" interior blank padded to 12 spaces trailing-whitespace
"\nalpha" blank first line padded trailing-whitespace
"alpha\n\n" file ends \n\n end-of-file-fixer
"alpha\n \n" last line flattens to blank, file ends \n\n end-of-file-fixer

All four go through an indent_block filter that indents only non-blank
lines and clips trailing ones — which a | block scalar does anyway, so
no 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_all skips
ci-fix without watched_workflows and install-test without its flag, and
codex 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, restoring
first=True, or narrowing the clip to rstrip("\n") each fails all four
parametrizations.

pytest-regtest normalizes trailing whitespace before comparing, so the
recorded outputs could not have caught this and do not change here.

This was written by Claude Code on behalf of max-sixty

`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 tend-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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. With rstrip() it returns ' alpha'.
  • Rendering the config above through Config.load + generate_all gives content.endswith("\n\n") == True; with rstrip(), 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.

Comment thread generator/src/tend/workflows.py Resolved
Comment thread generator/tests/test_generate.py Resolved
`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_
@max-sixty
max-sixty merged commit ce9e7cd into main Aug 30, 2026
10 checks passed
@max-sixty
max-sixty deleted the fix-block-prompt-blank branch August 30, 2026 06:19
max-sixty added a commit that referenced this pull request Aug 30, 2026
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_
max-sixty pushed a commit to max-sixty/worktrunk that referenced this pull request Aug 30, 2026
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]>
max-sixty pushed a commit to max-sixty/leaf that referenced this pull request Aug 30, 2026
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]>
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.

2 participants