fix(schematic): validate mutations before commit - #527
Merged
neusse merged 1 commit intoSep 11, 2026
Merged
Conversation
15 tasks
19 tasks
10 tasks
19 tasks
9 tasks
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.
Closes #499
Problem
The component edit, annotation, grouping, and shared hierarchy mutation paths could commit a schematic and only then discover that the saved result did not match the bound request. They returned a refusal even though the file had already changed, which made a retry unsafe.
Change
edit_schematic_component,add_component_annotation, andgroup_components.mutation_outcome_uncertainevidence when a completed write cannot be proven, explicitly warning that the file may have changed.Schematic::from_sourceso prospective text can be parsed without disk I/O.Atomicity evidence
Regression tests invoke the real handlers against KiCad-authored fixtures and inject a one-shot prospective writer mismatch. Every refusal is
stale_target, the original target remains byte-identical, and an absent component target is not created.Required negative controls were also run locally:
component_mutation_handlers_refuse_bad_prospective_results_without_writingfailed because the handler no longer returned the pre-commit refusal.hierarchy_handlers_refuse_bad_prospective_results_without_writingfailed for the same reason.Validation
cargo fmt --all -- --checkcargo clippy --workspace --locked --all-targets -- -D warningscargo test --workspace --locked --lib --testscargo test --workspace --locked --doccargo xtask fix-doc-counts --checkTool counts remain current: 21 toolsets, 226 registered tools, 233 total tools.
Sequencing and compatibility
This was reconstructed on current
mainafter #489 and #485 merged, as requested. PR #524 overlaps the hierarchy helper and should reconstruct/rebase on the resulting main after this lands.No tool or argument is removed or renamed.
mutation_outcome_uncertainis an additive structured error response documented for the next minor release.Rollback
Reverting this commit restores the previous write-then-verify behavior; no persisted schema or migration is introduced.