Repository navigation
Refuse a draft written under another Spec commit at resume and save - #224
Merged
Merged
Conversation
…223) load_draft and publish_draft now raise DraftFileError(spec_commit_mismatch) when the draft's spec_commit is not the pinned SPEC_COMMIT; save_draft refuses such answers. The stored commit is never rewritten and the stale draft is left as it is. Fixes #223 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Scma6W3LC11s3qjXHZuGDm
This was referenced Nov 8, 2026
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.
Fixes #223
What
run/draft_file.py: new_require_current_spec(answers), called in_resume()(soload_draftandpublish_draft) right after the strict read, and insave_draft()after the strict round trip. Ifanswers.spec_commit != SPEC_COMMITit raisesDraftFileErrorwith codespec_commit_mismatch. The message names both commits, says the publishedmorphobricks.tomlis untouched, and says to start a fresh draft from the folders.docs/contract.md§18 (reading, resume, saving rules) andCHANGELOG.mdupdated. Docstrings ofDraftFileError,save_draft,load_draftand the module list the new code.Why
answers_from_bytes()accepts any 40-hexspec_commit, and_resume()checked onlybase_sha256. A draft written under another Spec revision was resumed and published with its old confirmations (repeats, ID choices) as if given under the current rules.Owner decision (2026-11-08)
A draft whose
spec_commitdiffers from the current pinnedSPEC_COMMITis refused at resume. The published file is untouched, and the caller derives a fresh draft from the folders. Library code does not silently rewrite or delete the stale draft.Regression evidence
New
tests/test_draft_spec_commit.py(6 tests). Complete valid draft with onlyspec_commitchanged to another valid 40-hex SHA:load_draftrefuses withspec_commit_mismatch, message names both commits, draft bytes identical;publish_draftrefuses, absentmorphobricks.tomlstays absent, draft bytes identical;publish_draftrefuses, existingmorphobricks.tomlbyte-identical, draft bytes identical;save_draftwith a mismatching commit refuses and writes nothing (also keeps an earlier draft byte-identical);Old code (src stashed, new tests kept): 5 failed, 1 passed (the control). New code: 6 passed.
Checks
python tools/check.py: ruff check and format clean, pytest 4575 passed, 4 skipped (4 skips are the pre-existing case-sensitivity / file-permission ones), code rules pass (no file over 600 lines, baselines not grown).Generated by Claude Code