Repository navigation
fix(pr-summary): refuse a missing or file --root instead of creating it - #5217
Conversation
`ripr pr-summary --root /does/not/exist` created the whole directory tree, wrote a summary of nothing and exited 0; a file passed as --root failed with the opaque "failed to create parent dir for target/ripr/pr/summary.md: Not a directory (os error 20)". Refuse both before any read or write with the same "<command> root X is not a directory" contract the sibling --root commands use, exiting 2. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01S5D7B2JxJ754s1p6ktir1Y
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (2)
🔗 Linked repositories identifiedCodeRabbit considers these linked repositories for cross-repo context during reviews:
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review. Summary by CodeRabbit
Walkthrough
ChangesPR summary root validation
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to The command now refuses invalid roots without creating output paths. No merge-blocking issue is identified. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
A rabbit checks the root with care, Comment |
There was a problem hiding this comment.
Code Review
This pull request adds a validation check to ensure that the specified repository root is an existing directory before running the PR summary, preventing the accidental creation of missing directory structures. It also introduces a smoke test to verify that missing or file-typed roots are correctly rejected without creating any directories. There are no review comments, so I have no additional feedback to provide.
|
Local proof on head Generated by Claude Code |
EffortlessSteven
left a comment
There was a problem hiding this comment.
reviewed_head_sha: 2dabe15
integration_basis: Required hosted checkout fea8f6e, tree a2504937cac7d95d32a36cdcdb0316744f36e14a, with parents 9da89e2 + reviewed head. Later main e955ee9 is source-compatible for the affected owners; its complete combined tree is not claimed executed.
claim_boundary: Refuse a missing or file --root for pr-summary before evidence reads, checking or output creation, preserving existing-directory behavior.
changed_surfaces_and_semantic_owners_inspected:
- Complete two-file delta, command dispatch and root resolution, summary input loader and output writer, and both new/retained CLI controls.
- The guard is immediately after root resolution and before the normal/write or --check branch. CLI dispatch preserves exit 2 and reports the selected path.
- Existing-directory composition, baseline anchoring, relative-root handling and summary schema are unchanged.
blocking_findings: none
non_blocking_suggestions:
- The new test does not explicitly compare file-root bytes afterward or assert the supplied path in stderr. Early-return/source inspection establishes those details; they are not additional executed assertions.
- Successful --check still writes the evidence-summary pair, as before. This PR does not change that behavior.
proof_and_ci_observed:
- Required run 37165360052, worker 111327076156 and Result 111333387471: SUCCESS. Precommit, check, strict Clippy, required tests, doctests, goldens, fixture contracts and PR evidence passed.
- Artifact 11290520195 independently verifies at 300,023 bytes / SHA256 e7868213efee98aa773d567fea227d4bbb38b41807fac28b1caccec3ca6d8c6c. Its context binds the exact checkout above, Rust/Cargo 1.95.0 and nextest 0.9.146.
- JUnit contains 11,390 executed passes, zero failures/errors; native console separately reports two skipped.
- All eight pr_summary CLI owners passed. The new refusal test exercises missing/file roots normally and with --check, requiring exit 2, refusal wording, empty stdout, no missing ancestor creation and no caller-CWD output directories.
- Existing foreign-CWD/relative-root and baseline controls, malformed/unknown flags, missing-artifact positive, help and no-Cargo controls passed.
- Removing the guard is source-discriminated: the inspected base reaches composition/output creation for the missing root and cannot satisfy the new oracle. No separate local removal experiment was executed or claimed.
affected_currentness_dimensions:
- Inspected main 7c64b9c preserves the base summary owner, loader/writer/dispatcher and foreign-CWD test. Its only later commit to e955 changes LSP backend/config/state/tests, with no affected owner overlap.
- Exact head is unchanged; there are zero inline threads. Ordinary branch metadata exposes required context Ripr Rust Small Result (app 15368), which is successful. That limited summary is distinct from the dedicated classic-protection endpoint returning 403. Accessible main ruleset requires zero approvals and thread resolution; Droid is advisory. Normal protected merge enforcement remains authoritative.
proof_or_review_missing: None for the stated root-refusal source claim.
residual_assumptions_and_non_claims: No filesystem race/confinement, Windows-specific path, installed journey or release claim. No production summary evidence or default existing-directory behavior changed.
disposition: REVIEW_READY
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
Decision
- Needs reviewer attention before upstream: findings remain.
Confirmed findings
- Scratch dir in the new test is created at the top level; if unique_temp_workspace itself fails or a previous run left a non-empty target/, the no-creation assertion could mask regressions; minor oracle hygiene, not a correctness blocker.
Verification questions
- Confirm non-blocking suggestion: test does not assert the supplied path appears verbatim in stderr nor check byte-level absence of target dir contents.
- Confirm test covers both missing and file roots across --check on/off and asserts no created directories, but does not assert supplied-path echo nor post-state for file-root.
Refuted
- Refusal check could be bypassed when
options.rootresolves to a symlink to a non-directory or a symlink to a file (TOCTOU viais_dir).; refuted because: Even if a TOCTOU exists, the trailingcreate_dir_allwould either fail with ENOTDIR or succeed; either way no silent creation-of-tree for a non-directory. The PR's acceptance criterion is refusing missing/file roots with exit 2; symlink nuances are out of scope and the PR body claim boundary explicitly limits scope. - Test might pass on main because missing/repo is already created by an earlier pr_summary_root_from_foreign_cwd_anchors_artifacts_and_baseline run sharing the same workspace; refuted because: unique_temp_workspace produces a fresh per-test subdir; scratch.join('missing')/scratch.join('target') being absent post-run would still be violated on main by the very run under test, since create_dir_all would synthesize the missing tree.
- Scope creep across other --root commands; refuted because: Diff is two files; PR body and Claim Boundary explicitly limit to pr-summary. No sibling commands (check, pilot, init, config validate, agent *) are modified. refuted.
Requested by Steven · project thread
Summary
Found while dogfooding the 0.11 quickstart. On
main(dbe408e):A mistyped root got created on disk, and the command wrote an all-
not_availablesummary for a directory that never existed, exiting 0. A file root failed with a raw io error that names neither the flag nor the path the user passed.After this PR, both cases stop before reading or writing anything, using the same wording as the sibling
--rootcommands (check,pilot,init,config validate,agent *):How:
run_pr_summarychecksrepo.is_dir()right after resolving the selected root. It runs before both the write path and--check.Swarm / Source Boundary
ripr-swarmSource-of-truth Links
Proposal: n/a
Spec: n/a
ADR: n/a
Plan item: 0.11 release dogfood
Governing issue or accepted claim: follow-up to #4387 / #4408 (pr-summary gained
--root; root existence was never validated)Acceptance delta (one sentence):
ripr pr-summary --root <missing-or-file>exits 2 with a named refusal and creates nothing.Candidate Relationships
Candidate branch:
claude/dogfood-pr-summary-missing-rootStack parent or prerequisite PR: none
Proposed replacement of PR: none
Scope
crates/ripr/src/app/pr_summary/mod.rs: root directory guardcrates/ripr/tests/cli_smoke.rs:pr_summary_refuses_missing_or_file_root_without_creating_itScope Classification
Production delta: a missing or file
--rootis refused before any I/O.Evidence/support delta: one cli_smoke test.
Single acceptance criterion: the new smoke test passes. It fails on
main, where the missing root exits 0 and is created.Non-goals: no change to summary content or schema, or to the other composition commands.
Support-tier Impact
Policy Impact
Proof
Discriminating check: I ran the
mainbinary (dbe408e) against the same two inputs by hand. The missing root exited 0 and created<root>/target/ripr/.... The file root exited 2 with the rawos error 20message. The new test asserts exit 2, apr-summary root ... is not a directorymessage, empty stdout, and no created directories, so it fails onmain.Note: in my first local run of the
pr_summaryfilter, the pre-existingpr_summary_rejects_malformed_path_flags_without_outputsfailed once withNo such file or directory (os error 2). It passed on an immediate rerun. My change does not touch that test's path (it fails at argument parsing before the new guard), so it looks like a temp-dir flake on a heavily shared host.Claim Boundary
May claim:
pr-summaryno longer creates or summarizes a nonexistent root. Must not claim: anything about other commands' root handling.Rollback
Revert the single commit.
Static 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.🤖 Generated with Claude Code
https://claude.ai/code/session_01S5D7B2JxJ754s1p6ktir1Y
Generated by Claude Code