Skip to content

fix(generator): render typed Parameters/Returns columns without polish (#30)#31

Merged
silversurfer562 merged 1 commit into
mainfrom
fix/30-reference-template-richer-without-polish
May 15, 2026
Merged

fix(generator): render typed Parameters/Returns columns without polish (#30)#31
silversurfer562 merged 1 commit into
mainfrom
fix/30-reference-template-richer-without-polish

Conversation

@silversurfer562
Copy link
Copy Markdown
Member

Summary

  • Fixes Regeneration silently drops parameter/return columns and frontmatter when polish is bypassed #30: regeneration of .help/templates/<feature>/reference.md silently drops the Parameters and Returns columns + human description when the LLM polish pass is bypassed.
  • Threads typed argument and return data from the AST through the Jinja template so the 4-column table renders without depending on polish.
  • Polish keeps its job (rewriting prose) but is no longer load-bearing for structural columns.

What changed

  • _collect_function now also stores params: str and returns: str on each function_signatures entry, computed from the existing formatted signature via a small _split_signature helper. No new AST traversal.
  • _render_template (the .help/ path) now passes function_signatures and class_signatures into the Jinja render call alongside the legacy public_functions / public_classes.
  • meta_templates/reference.md.j2:
    • Renders feature.description directly under the title, so the intro from features.yaml survives without polish.
    • Renders a Function | Parameters | Returns | Description | File table from function_signatures when available, falling back to the previous 3-column shape from public_functions when only the legacy data is present.

Why

A regression slipped into attune-rag's main branch this week — see attune-rag d39e39d. Regenerating .help/templates/benchmark/reference.md with polish bypassed dropped Parameters / Returns columns and the human description. The diff looked normal at review time (frontmatter + headings + a function table) so it merged.

The data the user lost was already present on _SourceInfo.function_signatures from the AST — it just wasn't being threaded into the Jinja render call.

Before / after

Before (raw Jinja, polish bypassed):

```markdown

Benchmark reference

Functions

Function Description File
`main()` `src/attune_rag/benchmark.py`
```

After (raw Jinja, polish still bypassed):

```markdown

Benchmark reference

Precision/recall/faithfulness benchmark runner — gates CI on configurable thresholds; supports custom query files and optional faithfulness scoring via --with-faithfulness

Functions

Function Parameters Returns Description File
`main` `argv: list[str] | None = None` `int` Run benchmark suite and return exit code `src/attune_rag/benchmark.py`
```

Test plan

  • New TestSplitSignature unit tests: typed params + return, no-return, complex pipe-union return, defensive no-match shape.
  • New TestReferenceTemplateColumns asserts the rendered reference template contains the 4-column header, typed parameters, return annotation, and the feature description — without polish.
  • Updated reference golden snapshot reflects the new shape.
  • Dogfood help tests (tests/test_dogfood_help.py) still pass.
  • Polish-cache-isolated full run: only one pre-existing failure (test_task_template_matches_snapshot — cache cross-contamination with a real API key in .env, reproducible on main, unrelated to this change).

🤖 Generated with Claude Code

#30)

The Jinja meta-template for `reference.md` only emitted a 3-column
table (`Function | Description | File`). The richer 4-column table
seen in committed help templates was synthesized by the LLM polish
pass. When polish was bypassed (no API key, lenient mode, or a
silently-swallowed failure), regeneration produced a structurally
lossier file that looked normal in a diff and slipped through PR
review. See attune-author#30 and attune-rag commit d39e39d.

This commit makes the structural data flow without depending on the
LLM:

- Capture `params` and `returns` on each entry in
  `_SourceInfo.function_signatures` via a small `_split_signature`
  helper that parses the already-formatted signature string. No new
  AST traversal — reuses `_format_function_signature` output.
- Thread `function_signatures` (and `class_signatures`) into the
  Jinja render call in `_render_template` so help templates can
  render typed data.
- Update `meta_templates/reference.md.j2`:
  - Render `feature.description` directly under the title so the
    human-written intro from `features.yaml` survives without polish.
  - Render a 4-column `Function | Parameters | Returns | Description |
    File` table from `function_signatures` when available, falling
    back to the 3-column shape from `public_functions` for callers
    that pass the legacy data only.

Polish still has a job (rewriting prose, smoothing tone). It is no
longer the only source of structural columns, so a polish bypass
degrades prose quality rather than silently deleting typed data the
AST already has.

Tests:
- New `TestSplitSignature` unit tests cover the parser (typed
  params + return, no-return, complex pipe-union returns, defensive
  no-match shape).
- New `TestReferenceTemplateColumns` asserts the rendered reference
  template contains the 4-column header, typed parameters from the
  AST, the return annotation, and the feature description — all
  *without* polish.
- Updated reference golden snapshot to reflect the new shape.

Closes #30.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@silversurfer562 silversurfer562 merged commit a2f99c2 into main May 15, 2026
12 checks passed
@silversurfer562 silversurfer562 deleted the fix/30-reference-template-richer-without-polish branch May 15, 2026 18:12
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.

Regeneration silently drops parameter/return columns and frontmatter when polish is bypassed

1 participant