Skip to content

feat(polish): emit polish: skipped frontmatter on lenient fallback#33

Merged
silversurfer562 merged 1 commit into
mainfrom
feat/polish-status-frontmatter
May 15, 2026
Merged

feat(polish): emit polish: skipped frontmatter on lenient fallback#33
silversurfer562 merged 1 commit into
mainfrom
feat/polish-status-frontmatter

Conversation

@silversurfer562
Copy link
Copy Markdown
Member

Summary

When polish falls back to returning raw Jinja content (no API key, swallowed LLM error in lenient mode), inject a `polish: skipped` line into the YAML frontmatter so the bypass is visible in PR diffs. Closes the "optionally" hardening item from #30.

Why

Without this marker, a polish bypass is structurally indistinguishable from a normal generation — same headings, same frontmatter shape — and slips past review. That's how attune-rag d39e39d landed in degraded form (lost `Parameters` / `Returns` columns and the human description). Surfacing the bypass directly in the rendered output makes the regression visible at the point of review.

What changed

  • `polish.py`: new `_mark_polish_skipped` helper inserts `polish: skipped` into the YAML frontmatter after `status:` (idempotent — won't double-write if already marked). Called only in the lenient-fallback branch. The success path and the cache-hit path are unchanged.
  • Non-YAML output (project-doc templates with HTML-comment footers) passes through unchanged. Surfacing bypass there would need a different mechanism and is deliberately out of scope.

Test plan

  • `test_lenient_bypass_marks_yaml_frontmatter` — marker is injected; body preserved verbatim.
  • `test_lenient_bypass_is_idempotent_when_already_marked` — re-running doesn't double-write.
  • `test_lenient_bypass_passes_through_non_frontmatter_content` — non-YAML unchanged.
  • Golden snapshots updated to reflect the new marker (snapshots are recorded under the lenient-by-default conftest fixture).
  • Full suite (with empty polish cache): all passing.

Notes on ordering

Stacks cleanly with #32 (test-isolation: polish cache → tmp dir). With #32 not yet merged, snapshot tests on this branch only pass deterministically if the local `~/.attune/polish_cache` is empty. CI sees an empty cache so it'll be fine. Recommend merging #32 first.

🤖 Generated with Claude Code

Surface a polish bypass in the rendered YAML frontmatter so the
degradation shows up in PR diffs. Without this marker, raw-Jinja
output is structurally identical to a normal generation (same
headings, same frontmatter shape) and slips past review — see
attune-author#30 and attune-rag d39e39d, where a regeneration with
polish silently bypassed merged in degraded form.

The marker is only added when polish falls back to returning raw
content in lenient mode (no API key, swallowed LLM error). The
success path and the cache-hit path are unchanged.

Helper is idempotent: re-running polish on an already-marked file
does not double-write. Non-YAML output (project-doc templates with
HTML-comment footers) passes through unchanged — surfacing bypass
there would need a different mechanism and is deliberately out of
scope here.

Tests:
- ``test_lenient_bypass_marks_yaml_frontmatter`` — bypass injects
  the marker; body is preserved verbatim.
- ``test_lenient_bypass_is_idempotent_when_already_marked`` —
  re-running does not double-write.
- ``test_lenient_bypass_passes_through_non_frontmatter_content`` —
  non-YAML content unchanged.
- Updated golden snapshots reflect the new marker (snapshots are
  recorded under the lenient-by-default conftest fixture).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@silversurfer562 silversurfer562 merged commit d805062 into main May 15, 2026
12 checks passed
@silversurfer562 silversurfer562 deleted the feat/polish-status-frontmatter branch May 15, 2026 18:13
silversurfer562 added a commit that referenced this pull request May 15, 2026
…eck Phase 1 (#34)

Bumps pyproject.toml from 0.11.1 → 0.13.0 and converts the CHANGELOG
Unreleased section into the 0.13.0 release notes.

Skipping 0.12.0 — the internal release/v0.12.0 branch carried the
polish fact-check Phase 1 work but was never published to PyPI.
That work now ships in 0.13.0 alongside the regenerator fixes
prompted by attune-rag d39e39d.

Headline changes:
- #31 — reference templates carry typed Parameters/Returns columns
  without depending on the LLM polish pass (closes #30)
- #32 — test fixture isolates the polish cache per session to
  prevent shared-state flakes in golden snapshot tests
- #33 — polish bypass surfaced in YAML frontmatter (polish: skipped)
- #28 — polish fact-check Phase 1 (already on main from prior PR)

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
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