Skip to content

refactor(prompt): make prompt construction template-driven#625

Draft
mariusvniekerk wants to merge 1 commit intomainfrom
gotmpl
Draft

refactor(prompt): make prompt construction template-driven#625
mariusvniekerk wants to merge 1 commit intomainfrom
gotmpl

Conversation

@mariusvniekerk
Copy link
Copy Markdown
Collaborator

@mariusvniekerk mariusvniekerk commented Apr 5, 2026

Why

Prompt construction in internal/prompt had accumulated too much behavior in Go-side string assembly, which made the actual prompt structure hard to reason about, easy to regress during cleanup, and split across multiple sources of truth. This refactor moves the prompt format itself into templates so the rendered prompt shape is defined where it is authored, while preserving existing review behavior and fixing the regressions uncovered during the migration and subsequent roborev reviews.

Summary

  • make prompt construction template-driven end to end by moving assembled prompt bodies, prompt sections, and agent-specific system prompts onto embedded .md.gotmpl templates backed by typed view data
  • preserve existing prompt behavior while fixing cleanup regressions in dirty and range prompt fitting, including truncated diff fallbacks, optional-context retention, and fallback selection quality
  • resolve the accumulated roborev findings on gotmpl so the branch ends with no open review jobs

Test Plan

  • go fmt ./...
  • go vet ./...
  • go test ./...

@roborev-ci
Copy link
Copy Markdown

roborev-ci bot commented Apr 5, 2026

roborev: Combined Review (9e36436)

Verdict: No medium-or-higher issues found across the submitted reviews.

The reviewed changes appear clean. Both substantive review outputs reported no issues, and the security review explicitly found no externally exploitable concerns in the modified paths under this repo’s local-only trust model.


Synthesized from 3 reviews (agents: codex, gemini | types: default, security)

@roborev-ci
Copy link
Copy Markdown

roborev-ci bot commented Apr 7, 2026

roborev: Combined Review (04449e4)

Summary verdict: Changes are mostly sound, but there is one medium-severity regression in range prompt trimming that should be fixed before merge.

Medium

  • internal/prompt/prompt_body_templates.go:287
    trimOptionalSections no longer considers InRangeReviews, even though buildRangePrompt now stores per-commit reviews in optional.InRangeReviews. When a range prompt exceeds budget, the fitter can now strip subjects and current range entries before dropping this optional context, which regresses prior behavior where the optional block was trimmed first.
    Fix: include InRangeReviews in trimOptionalSections, trim it before mutating Current range metadata, and add a regression test for oversized range prompts with populated per-commit reviews.

Synthesized from 3 reviews (agents: codex, gemini | types: default, security)

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