Repository navigation
perf(python): reuse the source-fact parse for the foreign index's attribute writes (#10914) - #10929
Conversation
…ribute writes (#10914) The workspace foreign-write index parsed every Python file a second time to list its assigned attributes. The source-fact pass already parses each file, so it records those names (from the original source, also for test files whose helpers it inlines) and the index reads them, parsing only files the fact pass did not see. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FYNejJJF82dVq4XHXddgrd
|
Warning Review limit reachedEnable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing. Next included review available in 39 minutes. View limit details
Comment |
There was a problem hiding this comment.
Code Review
This pull request optimizes the Python workspace foreign-write index by reading each file's assigned attributes from the source-fact parse instead of parsing every workspace file a second time, which improves performance. A review comment suggests simplifying a match statement in module_value.rs using Option::cloned and Option::unwrap_or_else to make the code more concise and idiomatic.
|
Independent source/currentness review at 177bf80: no blocking production defect found in this bounded review. The admitted original AST feeds the same assigned-attribute collector; parse/budget failures remain None, missing map entries retain fallback parsing, and map keys/source bytes derive from the same workspace read. The merged parametrization collection-error logic remains in collect_tests_from_statements and is not altered by the cache map. Existing prior-head findings were reconciled rather than restarting benchmarks or qualification. Nonblocking coverage correction: module_value_tests.rs:1044–1045's test_limit uses No new runtime/benchmark claim is made by this source review. Owner performance measurements retain their stated runner/input limits. Existing hosted qualification is still separate; no additional CI campaign or formal PR approval was submitted. Reconciliation of subsequent ub-review questions (same head): module_value.rs:534–550 explicitly uses Option<&Option<Vec>>; Some(None) preserves failed-parse/dynamic behavior, while outer None alone reparses. The API therefore does distinguish these states. python.rs:1002–1012,1032–1033,1237–1244 retain the same relative PathBuf and workspace source map, without a new normalization boundary. module_constants.rs:525–532 calls the shared source_facts::parse_module_result policy (source_facts.rs:577–586); the reused collector is at665–667 and original helper facts are restored at678–680. These are source-supported answers, not new runtime or exhaustive caller coverage claims. Owner benchmark/equivalence measurements remain attributed; current hosted goldens/corpora passes are narrower evidence. The helper-test coverage limitation above remains real. Corrected the earlier plain_test line pointer to138–148; the finding is unchanged. Successor review, 8568ff1 (tree b083ae5fe429cef2c36983f605f85c949a3b195d): complete two-file delta inspected. The fixture now uses a module-level RATE assignment and literal check(3), explicitly asserts that inlining returns Some, and checks original RATE write facts. The earlier helper-inlining coverage concern is resolved. module_value.rs:534–553's cloned/unwrap_or_else refactor preserves absent / Some(None) / Some(writes) distinctions and only lazily reparses missing entries. No blocking source/currentness finding; unaffected prior reasoning retained. Owner's 82 tests/precommit result is attributed, not a new independent execution claim. The old 177bf80 campaign was cancelled after the head changed; its failed current-eligibility check is not a source/test regression. Existing replacement qualification40690639091 must finish for8568ff18. No additional campaign was dispatched by this reviewer. |
There was a problem hiding this comment.
Confirmed findings
- The foreign index consumes source-fact assignments and falls back to parsing only when a file is absent from the map.
Verification questions
- Confirm the PR claims byte-identical findings on pandas and Django pins, but the available packet contains no completed hosted qualification receipt; the stated measurements are local and noisy.
- Confirm the new tests exercise supplied-map discrimination and equality against self-parsing, but do not lock the key-domain/path normalization contract across the producer and consumer.
- Confirm test-helper inlining preserves assignment facts from the original source rather than substituting rewritten helper-call assignments.
- Confirm the source-fact boundary owns assignment extraction, but ForeignIndex also retains a fallback parser, duplicating parse-policy ownership and requiring map-presence semantics to stay synchronized.
- Confirm the fallback is needed for files absent from the source-fact map, but the API does not distinguish absent from present-with-None; correctness currently depends on the producer inserting every parsed or failed file.
- Confirm the new tests compare shared and independently parsed indexes, but the packet does not show exhaustive caller or sibling-path coverage for ForeignIndex construction outside the changed PythonAdapter route.
Refuted
- A malformed source could be silently treated as having no assigned attributes in the shared route.; refuted because: The source-fact snapshot initializes assigned_attributes to None and assigns Some(...) only after a successful parse; scan_source preserves present Some(None) as unknown/dynamic rather than an empty set.
- Malformed or fact-unseen files might be misclassified because the shared map uses Option values.; refuted because: Some(None) represents a failed parse and is consumed as no assigned attributes; map absence invokes assigned_attributes(source), preserving fallback parsing.
- The production path still needs to parse files missing from the supplied map.; refuted because: scan_source intentionally falls back to assigned_attributes(source), so build_with_assigned preserves behavior for files absent from the source-fact pass.
Evidence gaps
- The PR's byte-identical-output claim is supported by the PR body and seeded thread, but the available review packet has no completed cargo-test receipt or independent golden-output artifact.
- Model proof intent was rejected by deterministic validation.
…branch (#10914) The test file's helper call used a non-literal argument after an assignment, which the inliner refuses, so the fixture never reached the branch that restores the original source's attribute writes. The test now calls the helper with a literal, writes the attribute at module level, and asserts both that the file inlines and that its recorded writes are the original's. Also takes the Option::cloned simplification. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FYNejJJF82dVq4XHXddgrd
|
Coverage finding repaired in 8568ff1. The test file now writes
The Gemini Generated by Claude Code |
There was a problem hiding this comment.
Decision
- Needs one verification check before upstream.
Verification questions
- Confirm producer and consumer use the same relative PathBuf key, but the reviewed code does not independently lock path normalization when the workspace source iterator supplies absolute paths or alternate spellings.
Refuted
- The map cannot distinguish absent files from files whose parse failed, causing incorrect fallback behavior.; refuted because: The map value is Option<Vec>; a missing key triggers fallback parsing, whereas a present None is retained and remains equivalent to the prior assigned_attributes result on parse failure.
- The shared facts change the ownership boundary in a way that duplicates parse policy or requires an architectural rewrite.; refuted because: Assignment extraction remains in source_facts.rs, the index only consumes the result, and fallback parsing is retained for files not represented in the map; the change is localized and does not introduce a competing production path.
- Supplying a map entry with None could suppress the independent parser and lose assignment information.; refuted because: None is treated as a successful source-fact result with no available assignment facts, while map absence triggers assigned_attributes(source); this matches the source-fact parse-failure contract and avoids reparsing failed files.
Evidence gaps
- The local byte-identical pandas and Django results are not backed by a completed hosted qualification receipt, so the changelog should not be read as hosted qualification evidence.
- Model proof intent was rejected by deterministic validation.
- Byte-identical output on the pandas and Django pins is claimed from local measurements, but no hosted qualification receipt is available in this packet.
- Hosted qualification is not present in the packet, so byte-identical pandas/Django output and the performance improvement are not independently established here.
Review of record — head 8568ff1Disposition: nothing blocking; merging. Correctness
Key domain (verifier question)
Tests
Perf / output (local, attributed)
Proof
Threads and providers
Generated by Claude Code |
Summary
ForeignIndex, Python ForeignWrites::scan reparses the whole workspace once per changed Python file #10125) parsed every workspace file a second time to list the attributes it assigns.assigned_attributes, and the index reads them.buildkeeps parsing everything.Swarm / Source Boundary
ripr-swarmSource-of-truth Links
Proposal: n/a
Spec: n/a
ADR: n/a
Plan item: Python scale / real-repo DX
Governing issue or accepted claim: #10914
Acceptance delta (one sentence): The Python foreign index takes each file's assigned attributes from the source-fact parse instead of parsing the workspace again, with byte-identical findings on the pandas and Django pins.
Candidate Relationships
Candidate branch (GitHub PR head is authoritative after publication): claude/project-thread-w6b15g
Stack parent or prerequisite PR (if any): none
Proposed replacement of PR (if any; not yet accepted): none
Acceptance retained from a replaced candidate (if any): none
Accepted winner and losing candidate disposition (when decided): n/a
Scope
source_facts.rs: newPythonSourceFacts.assigned_attributes.assigned_attributes(source)returns.module_value.rs:ForeignIndex::build_with_assignedreads the map;scan_sourcefalls back to parsing for files missing from it;buildis now test-only.python.rs: the fact fold collects the map and passes it to the index.module_constants.rs:assigned_attribute_namesis nowpub(super).Scope Classification
Production delta:
Evidence/support delta:
the_source_fact_parse_gives_the_foreign_index_the_same_attribute_writeschecks a workspace with:excluding(own)from the shared map equals the self-parsing index for every file.the_foreign_index_reads_supplied_attribute_writes_instead_of_parsingdiscriminates: a supplied write the text does not contain changesmay_rebind, so the map is actually used.Single acceptance criterion:
Non-goals:
Support-tier Impact
Policy Impact
Proof
Local measurement, release build, 4 cores, warm,
--base HEAD~1 --mode draft:Profile that chose this step: on pandas, the index's CPU-s were 3.4 for the second assigned-attribute parse, 1.5 for table uses, and 0.9 for the dict-literal lex, against 2.9 for the fact parse.
Result, failures, or skipped proof:
Claim Boundary
Rollback
Spec-Test-Code Traceability
python/module_value_tests.rsForeignIndex::build_with_assigned,extract_source_factsStatic Language Check
killed,survived,untested,proven, andadequate.CI Economics
n/a
Engineering Check
panic,unwrap,expect,todo, orunimplementedin production code.panic,unwrap,expect,todo, orunimplementedin tests.Gates
cargo fmt --checkand the policy gates (viacargo xtask precommit)cargo test -p ripr --lib pythonGenerated by Claude Code