refactor(rewrite): zero-shift injection with original-source error display#607
Merged
rocketman-code merged 2 commits intomainfrom Mar 28, 2026
Merged
Conversation
…splay Replace the injection manifest and regex-based error cleaning with original-source line substitution driven by structured JSON spans. Injection changes: - Zero-shift formatting: guards on brace line, items appended after user code, no new lines added to user source - StringInjector.apply() returns only modified source (no manifest) - Allocator Case 2: init on same line as static (preserves line count) - Allocator Case 3: split into Replace (same line count) + Append (fallback after user code). Fixes zero-shift violation. - negate_cfg: handle #[cfg_attr(PRED, ...)] with depth-aware parsing. Fixes pre-existing bug where fallback was always-true. Error handling changes: - Delete manifest file, manifest IPC, manifest-based string cleaning - Add clean_rendered: for each diagnostic span referencing a modified file, replace the instrumented source line in rendered output with the original source line read from the unmodified file - Tighten is_piano_diagnostic with backtick-delimited patterns to prevent false positives on user identifiers - build_instrumented receives modified file set for span filtering Eliminates 7 bugs: manifest write race (B4), stale accumulation (B6), bare ")" corruption (B2), dead manifest entries (B1), macro guard gap (B3), is_piano_diagnostic false positives (B5), dead _source_len (B7).
16 integration tests covering all injection type x grammar production x diagnostic category combinations. Each test creates a real project with a deliberate compilation error, runs piano build, and asserts the output shows original source at correct line numbers with zero injection artifacts. The matrix is finite because both the Rust grammar (as it interacts with piano injections) and piano's injection set are finite enumerations. Complete coverage of all cells constitutes a constructive proof by exhaustive enumeration. Matrix cells: sync guard (T1-T3), async wrapper (T4-T5), impl-Future (T6/B2 regression), lifecycle (T7-T8), allocator wrap (T9), cfg-gated allocator (T10), macro expansion (T11), piano diagnostic filtering (T12), lifetime error with help suggestion (T13), async borrow (T14), multi-injection combined (T15). Plus renamed multi_injection test.
2b6c03a to
3c218df
Compare
This was referenced Mar 28, 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.
Summary
Test plan