Skip to content

Auto-attach original spec context to implement-spec prompt#76

Merged
vm-mishchenko merged 2 commits into
mainfrom
260514-spec-auto-attach-original-spec
May 14, 2026
Merged

Auto-attach original spec context to implement-spec prompt#76
vm-mishchenko merged 2 commits into
mainfrom
260514-spec-auto-attach-original-spec

Conversation

@vm-mishchenko
Copy link
Copy Markdown
Owner

Summary

  • Adds original_spec module under steps/implement_spec/ that resolves branch context from a prior run, an open PR, or commits-only history, and renders the appropriate ## Original spec Markdown fragment into the LLM prompt
  • Adds find_original_run_on_branch to runs.py to locate the earliest draft run that seeded a given branch, enabling follow-up draft create --branch <existing> runs to recover the original intent
  • Logs the fully-rendered prompt (with attempt index and timestamp) to <run_dir>/implement-spec.log before each engine.run_llm call for auditability across retries

Test plan

  • New test module tests/draft/test_original_spec.py exercises resolve_case, render_original_spec, and preamble_label across all cases: new branch, prior run with readable/deleted spec, open PR, commits-only, corrupt state.json, missing branch_source, and earliest-run selection
  • Extended tests/draft/test_code_spec.py covers _log_prompt append behavior, two-retry ordering, OSError warning path, _log_prompt-before-run_llm call order, heading renames, four-placeholder substitution, and bundled template marker presence
  • Extended tests/draft/test_commands.py covers preamble emission, suppression on resolver error, and silence for None label

When a run is created on a branch that was seeded from a prior draft
run, surface the original spec to the LLM so it has the full intent
behind the feature—not just the current (possibly narrowed) spec.

- Add `original_spec` module that resolves and renders the preamble
  from a prior run, an open PR, or commits-only history
- Add `find_original_run_on_branch` to locate the earliest draft run
  that created a given branch
- Inject `{{ORIGINAL_SPEC}}` placeholder into the implement-spec
  template and render it before each LLM invocation
- Log the rendered prompt (with attempt/timestamp) to the step log
  so retries are fully auditable
- Emit a `original-spec: attached from <label>` diagnostic to stderr
  at `draft create` time; silenced when nothing is found or resolver
  errors
- Rename "Verify commands" / "Test failures" headings to "Verified
  commands" / "Verified errors" for consistency
Some environments write timestamps with a "Z" suffix which
`parse_human` cannot handle. Add a fallback that normalises the
"Z" to "+00:00" before parsing with `datetime.fromisoformat`.
@vm-mishchenko vm-mishchenko marked this pull request as ready for review May 14, 2026 22:07
@vm-mishchenko vm-mishchenko merged commit a604427 into main May 14, 2026
1 check passed
@vm-mishchenko vm-mishchenko deleted the 260514-spec-auto-attach-original-spec branch May 14, 2026 23:13
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