Auto-attach original spec context to implement-spec prompt#76
Merged
Conversation
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`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
original_specmodule understeps/implement_spec/that resolves branch context from a prior run, an open PR, or commits-only history, and renders the appropriate## Original specMarkdown fragment into the LLM promptfind_original_run_on_branchtoruns.pyto locate the earliest draft run that seeded a given branch, enabling follow-updraft create --branch <existing>runs to recover the original intent<run_dir>/implement-spec.logbefore eachengine.run_llmcall for auditability across retriesTest plan
tests/draft/test_original_spec.pyexercisesresolve_case,render_original_spec, andpreamble_labelacross all cases: new branch, prior run with readable/deleted spec, open PR, commits-only, corruptstate.json, missingbranch_source, and earliest-run selectiontests/draft/test_code_spec.pycovers_log_promptappend behavior, two-retry ordering, OSError warning path,_log_prompt-before-run_llmcall order, heading renames, four-placeholder substitution, and bundled template marker presencetests/draft/test_commands.pycovers preamble emission, suppression on resolver error, and silence forNonelabel