Repository navigation
python: stream the diff walk into a bounded selection (#10594) - #10655
Conversation
The walk previously collected and sorted every discovered .py path before the cap chose the analyzed set, so discovery memory scaled with workspace size. WorkspaceFileSelection keeps changed files plus a max-heap of the earliest-sorting context paths, never more than the cap, and yields the same set and refused count whatever the directory iteration order. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FYNejJJF82dVq4XHXddgrd
Co-Authored-By: Claude Opus 5.5 (1M context) <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 33 minutes. View limit details
Comment |
|
Review of record (source): no blocking findings. Head The source and oracle were reviewed independently on the same diff when it sat on
REVIEW_INCOMPLETE pending hosted qualification on this head. Generated by Claude Code |
There was a problem hiding this comment.
Code Review
This pull request refactors the Python workspace file discovery process to stream discovered files into a bounded selection (WorkspaceFileSelection) using a max-heap (BinaryHeap) instead of collecting and sorting all files first. This optimization ensures that memory usage during discovery remains bounded by the file-count cap plus changed files, regardless of the workspace size, while maintaining order independence and determinism. As there are no review comments provided, I have no additional feedback to offer.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FYNejJJF82dVq4XHXddgrd
There was a problem hiding this comment.
Decision
- Needs one verification check before upstream.
Verification questions
- Confirm the proof measures the context heap rather than all discovery memory, so the broad 'plus changed files' memory claim is not directly instrumented.
Refuted
- The sink API might introduce a second traversal or duplicate implementation of workspace discovery.; refuted because: Rejected: production code performs one visit_workspace_with_handwritten walk; the collecting helper is test-only and delegates to the same visitor.
- The change may exceed the advertised workspace discovery memory bound.; refuted because: The production selection stores only changed paths plus a context heap of at most max_files; the per-path PathBuf values and recursion stack remain bounded by the selected file count rather than all discovered paths.
Parked follow-ups
- The public API claim is limited to discovery-path memory; byte budgets and read-failure behavior remain delegated to read_workspace_sources_capped.
Evidence gaps
- Model proof intent was rejected by deterministic validation.
- Automated proof remains dependent on the scheduled cargo-test receipt because the ripr sensor failed with exit code 2.
|
Run 40303932921 failed in Generated by Claude Code |
|
The verification question from the github-actions review is confirmed as stated. Generated by Claude Code |
There was a problem hiding this comment.
Decision
- Needs one verification check before upstream.
Verification questions
- Confirm the new test validates expected selection directly but does not compare the streaming implementation against the removed truncate_workspace_files oracle for equivalent inputs.
Refuted
- The sink API may duplicate traversal or leave production callers on the collecting path.; refuted because: Production calls visit_workspace_with_handwritten once; collect_workspace_python_files_with_handwritten is cfg(test)-only and delegates to that same visitor.
- The broad memory claim is directly measured for all discovery state.; refuted because: The prior verification question was answered in the seeded thread: peak_context measures the workspace-sized heap, while changed files are structurally diff-sized. The PR claim is explicitly bounded to path-discovery memory.
- The sink API creates a second production traversal or retains all discovered paths.; refuted because: Production PythonAdapter directly invokes visit_workspace_with_handwritten once and feeds WorkspaceFileSelection::push. The collecting helper is test-only, and selection retains only changed paths plus at most max_files context paths.
Parked follow-ups
- The advertised memory boundary is structural for changed paths and measured for context paths; broad discovery-memory wording is limited but should remain accurately scoped.
Evidence gaps
- The scheduled cargo-test receipt remains the only outstanding executable proof; the ripr sensor failed with exit code 2 rather than reporting a source defect.
- Automated validation is still pending because the ripr sensor failed; the scheduled cargo-test receipt is required to substantiate the claimed test result.
- Model proof intent was rejected by deterministic validation.
- Clean automated qualification for the current head is not yet evidenced in the supplied packet.
|
On the second verification question: the removed Generated by Claude Code |
|
|
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FYNejJJF82dVq4XHXddgrd
There was a problem hiding this comment.
Decision
- Needs verification checks before upstream.
Verification questions
- Confirm the implementation retains every changed path and at most the configured context budget, but the refusal count is computed from the number of discovered paths rather than the number of context files refused.
- Confirm the new order-independence test covers shuffled versus sorted discovery, but it does not directly exercise the production analyze_diff route for duplicate paths or multiple changed-file cases beyond the separate unit test.
- Confirm the bounded-selection helper owns discovery-retention state, while the traversal helper only streams admitted paths; this is the narrowest boundary for the stated memory improvement.
- Confirm the sink API does not introduce a second workspace-discovery implementation or leave production callers using an unbounded collector.
- Confirm the selected-set boundary preserves the previous cap semantics even when changed files exceed the cap.
Refuted
- The memory claim is wholly unmeasured or includes workspace-sized changed-path storage.; refuted because: The assertion measures the workspace-sized context heap; changed-path storage contains only diff paths and is structurally bounded. The PR claim explicitly describes discovery memory as cap plus changed files, so this is a narrow residual wording/instrumentation limitation rather than a demonstrated regression.
- The helper boundary is too narrow or requires broader production changes.; refuted because: The memory-bearing state is entirely encapsulated by WorkspaceFileSelection, and the existing traversal needed only a callback parameter; no unrelated adapter behavior is reorganized.
- The sink API leaves production on an unbounded collecting path or causes a second traversal.; refuted because: The collecting helper is test-only; production invokes the visitor once and streams paths into bounded selection.
Evidence gaps
- Model proof intent was rejected by deterministic validation.
|
Answers to the github-actions verification questions on
Generated by Claude Code |
|
Final review of record: REVIEW_READY at head
Merging by squash at this exact head. Generated by Claude Code |
Summary
WorkspaceFileSelectioninstead of collecting and sorting every discovered.pypath before the cap selects. Selection keeps the changed files plus a max-heap holding at mostRIPR_PYTHON_MAX_WORKSPACE_FILESof the earliest context paths, so discovery memory no longer grows with workspace size.visit_workspace_with_handwrittentakes a&mut dyn FnMut(PathBuf)sink.collect_workspace_python_files_with_handwrittenbecomes test-only.Swarm / Source Boundary
dependency, or repo-ops development for
ripr-swarmSource-of-truth Links
Proposal: n/a
Spec: RIPR-SPEC-0028
ADR: n/a
Plan item: n/a
Governing issue or accepted claim: #10594
Acceptance delta (one sentence): Python diff-mode discovery holds at most the file cap plus the changed files in memory, with the same analyzed set and refusal count as before.
Candidate Relationships
Candidate branch:
claude/project-thread-w6b15gStack parent or prerequisite PR: #10574 (merged)
Scope
crates/ripr/src/analysis/language/python/{bounded_read.rs,workspace.rs,python_tests.rs},python.rs,docs/LANGUAGE_ADAPTER_PREVIEW.md, changelog fragment, traceability fragments.Proof
workspace_file_selection_is_order_independent_and_holds_at_most_the_cap: 2,000 paths in sorted and shuffled order with cap 5. It asserts the peak context buffer stays at or below 5, the kept set is the same in both orders, and the refused count is correct. It also covers more changed files than the cap.peak_contextassertion.cargo test -p ripr --lib python: 1570 passed.cargo clippy -p ripr --all-targets -D warnings: clean.cargo xtask precommit: pass.Claim Boundary
This bounds path discovery memory only. Byte budgets, read failures and the analyzed-set semantics are unchanged.
Rollback
Revert this PR. #10574's behavior returns, with O(N) discovery memory.
Spec-Test-Code Traceability
.ripr/traceability.d/10594-python-walk-streams-bounded-selection.toml. The 10461 fragment is updated for the renamed test.Gates
cargo xtask precommitpassed locally on2369e906.Generated by Claude Code