fix(parser): harden Rust cfg(test) exclusion and remove file size cap#29
Open
tuannx wants to merge 1 commit into
Open
fix(parser): harden Rust cfg(test) exclusion and remove file size cap#29tuannx wants to merge 1 commit into
tuannx wants to merge 1 commit into
Conversation
Red-team review findings against the Rust parser: 1. Comment/doc-comment between #[cfg(test)] and its item broke test exclusion — tree-sitter emits comments as named children which cleared pending_attributes before the mod_item was reached. Fix: skip line_comment/block_comment nodes without clearing. 2. #[cfg(test)] on non-mod items (functions, structs, impls) was silently ignored — is_cfg_test was computed but only checked for mod_item. Fix: skip ALL items annotated with #[cfg(test)]. 3. Removed _MAX_FILE_BYTES (1MB) cap — no other parser has it, it silently drops real code (generated protobuf/diesel schemas), and the per-file except boundary is the actual backstop. Regression tests cover all three fixes: comment-between-attribute, cfg(test) on fn/struct/impl, and >1MB file survival.
tuannx
force-pushed
the
fix/rust-parser-red-team-findings
branch
from
July 23, 2026 14:48
8b7e248 to
9dd08b3
Compare
Contributor
Architecture Drift ReportAlgorithm: PKG | Entities: 722 | Components: 7 Drift from Baseline
Changes
Smells (1)
Generated by arcade-agent |
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
Red-team review findings against the Rust parser in #18. Three fixes:
1. Comment between
#[cfg(test)]and item broke test exclusionTree-sitter emits
line_comment/block_commentas named children. A comment between the attribute and its item clearedpending_attributesbefore themod_itemwas reached, so#[cfg(test)] mod testswas NOT skipped.Fix: Skip comment nodes without clearing
pending_attributes.2.
#[cfg(test)]on non-mod items was silently ignoredis_cfg_testwas computed for ALL node types but only checked in themod_itembranch. Functions, structs, and impls annotated with#[cfg(test)]were extracted as production entities.Fix: Skip ALL items when
is_cfg_testis true (earlycontinuebefore the type dispatch).3. Removed
_MAX_FILE_BYTES(1MB) capexcept Exceptionboundary is the actual backstopRegression tests
test_rust_parser_skips_cfg_test_with_comment_between_attribute_and_itemtest_rust_parser_skips_cfg_test_on_non_mod_itemstest_rust_parser_handles_large_files_without_capValidation