fix(tuning): actually apply approved proposals (codex P1)#34
Merged
Conversation
--apply previously only logged decisions; now writes the approved persona/memory edits via atomic_write, respecting tools.md write_paths. --dry-run added for safe preview. parse_report_proposals now extracts proposed_diff from the diff code fence in the report body so the applier has the actual change. Instructional diffs (comment-heavy, multi-step) are flagged as manual-apply with a skip_reason rather than failing silently. The CHANGELOG entry that wrongly claimed v0.3 doesn't auto-write has been corrected. Adds 14 regression tests covering: diff applicability gating, context-line insertion, new-file creation, the core apply→file-write path, dry-run no-write guarantee, write_path enforcement, instructional diff skipping, diff round-trip through parse_report_proposals, and applied=True in history when a file is written. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
docs/spec/11-tuning.mdis unambiguous —--applymust write approved diffs. The implementation guide shows the exactapply_diff(target, p.proposed_diff, helper)call. A previous session wrote a CHANGELOG entry claiming "v0.3 does not auto-write" but this was rationalization of a bug, not intent.apply_proposalsnow reads each accepted proposal'sproposed_diffand writes the target file viaatomic_write, enforcingtools.mdwrite_paths.parse_report_proposalsnow also extractsproposed_difffrom the diff code fence in the report body (was left empty before).manual apply requiredwith askip_reasonin history rather than failing silently.--dry-runwith--applypreviews what would change without writing.Changed files
atomic_agents/tuning.py—parse_report_proposals(diff extraction), new helpers_load_write_paths,_diff_is_auto_applicable,_apply_diff_to_file, full rewrite ofapply_proposalsbody, CLI outputtests/test_tuning.py— 14 new regression tests (310 total, all green)CHANGELOG.md— corrects the wrong "v0.3 does not auto-write" claimTest plan
uv run python -m pytest tests/test_tuning.py -v→ 39/39 passuv run python -m pytest --tb=short→ 310/310 passtest_apply_writes_accepted_proposal_to_file—summary["applied"] == 1and file actually contains the difftest_apply_does_not_write_on_dry_run— file unchanged, history writtentest_apply_respects_write_path_enforcement— skipped with write_path violation reasontest_apply_skips_instructional_diffs— skipped with manual-apply reasontest_parse_report_proposals_extracts_diff— diff round-trip workstest_apply_history_records_applied_true_when_written—applied=Truein history🤖 Generated with Claude Code