Skip to content

fix(pr-summary): refuse a missing or file --root instead of creating it - #5217

Merged
EffortlessSteven merged 1 commit into
mainfrom
claude/dogfood-pr-summary-missing-root
Oct 4, 2026
Merged

EffortlessSteven merged 1 commit into
mainfrom
claude/dogfood-pr-summary-missing-root

Conversation

@EffortlessSteven

Copy link
Copy Markdown
Member

Requested by Steven · project thread

Summary

Found while dogfooding the 0.11 quickstart. On main (dbe408e):

$ ripr pr-summary --root /tmp/typo/repo        # directory does not exist
Wrote target/ripr/pr/summary.md
Wrote target/ripr/reports/pr-evidence-summary.json
Wrote target/ripr/reports/pr-evidence-summary.md
exit=0                                          # and /tmp/typo/repo/target/... now exists

$ ripr pr-summary --root ./Cargo.toml           # a file
ripr: failed to create parent dir for target/ripr/pr/summary.md: Not a directory (os error 20)
exit=2

A mistyped root got created on disk, and the command wrote an all-not_available summary 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 --root commands (check, pilot, init, config validate, agent *):

ripr: pr-summary root /tmp/typo/repo is not a directory; pass `--root` naming an existing repository directory
exit=2

How: run_pr_summary checks repo.is_dir() right after resolving the selected root. It runs before both the write path and --check.

Swarm / Source Boundary

  • ordinary feature, analyzer, editor, docs, spec, fixture, badge, dependency, or repo-ops development for ripr-swarm

Source-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-root
Stack parent or prerequisite PR: none
Proposed replacement of PR: none

Scope

  • crates/ripr/src/app/pr_summary/mod.rs: root directory guard
  • crates/ripr/tests/cli_smoke.rs: pr_summary_refuses_missing_or_file_root_without_creating_it

Scope Classification

  • One production behavior

Production delta: a missing or file --root is 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

  • none

Policy Impact

  • none

Proof

cargo test -p ripr --test cli_smoke pr_summary   # 8 passed (incl. new test; existing foreign-CWD and malformed-flag tests)
cargo fmt --check                                # exit 0
cargo xtask precommit                            # see comment below (local run was in progress at publication)

Discriminating check: I ran the main binary (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 raw os error 20 message. The new test asserts exit 2, a pr-summary root ... is not a directory message, empty stdout, and no created directories, so it fails on main.

Note: in my first local run of the pr_summary filter, the pre-existing pr_summary_rejects_malformed_path_flags_without_outputs failed once with No 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-summary no longer creates or summarizes a nonexistent root. Must not claim: anything about other commands' root handling.

Rollback

Revert the single commit.

Static Language Check

  • Static output avoids killed, survived, untested, proven, and adequate.

CI Economics

n/a

Engineering Check

  • No new panic, unwrap, expect, todo, or unimplemented in production code.
  • No new panic, unwrap, expect, todo, or unimplemented in tests.
  • Errors are reported with actionable context.

🤖 Generated with Claude Code

https://claude.ai/code/session_01S5D7B2JxJ754s1p6ktir1Y


Generated by Claude Code

`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
@EffortlessSteven EffortlessSteven self-assigned this Oct 4, 2026
@coderabbitai

coderabbitai Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

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
  • Configuration used: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 879283d9-70b8-471c-8763-02312a0e29ba
📥 Commits

Reviewing files that changed from the base of the PR and between 9da89e2 and 2dabe15.

📒 Files selected for processing (2)
  • crates/ripr/src/app/pr_summary/mod.rs
  • crates/ripr/tests/cli_smoke.rs
🔗 Linked repositories identified

CodeRabbit 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

  • Bug Fixes
    • PR summaries now stop with a clear error when the selected root is missing or is a file, rather than a directory. No summary output is produced for these invalid roots, including when using --check.
  • Tests
    • Added checks that invalid roots return an error, write no output to standard output, and do not create directories.

Walkthrough

run_pr_summary now rejects a selected root that is not an existing directory before generating or writing summary outputs. A smoke test checks missing and file roots, with and without --check.

Changes

PR summary root validation

Layer / File(s) Summary
Root validation and coverage
crates/ripr/src/app/pr_summary/mod.rs, crates/ripr/tests/cli_smoke.rs
run_pr_summary returns an error when the selected root is not a directory. The smoke test checks exit status, stderr, stdout, and whether the command creates the missing root or a target directory.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 2dabe

The command now refuses invalid roots without creating output paths. No merge-blocking issue is identified.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. (1 skipped: 1 …
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely describes the main change: refusing missing or file-valued --root paths for pr-summary.
Description check ✅ Passed The description covers the change, scope, acceptance criterion, proof, claim boundary, and rollback. It is mostly complete, though the Spec-Test-Code Traceability section and full Gates checklist are …
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

A rabbit checks the root with care,
No folder? No summary is there.
A file root gets a clear reply,
No stray paths appear nearby.
Then hops away beneath the sky.

Comment @coderabbitai help to get the list of available commands.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member Author

Local proof on head 2dabe1582: cargo xtask precommit exited 0 (run with CARGO_BUILD_JOBS=1 CARGO_INCREMENTAL=0 because the shared host was OOM-killing parallel rustc). cargo fmt --check exited 0. cargo test -p ripr --test cli_smoke pr_summary: 8 passed. Earlier precommit attempts died from host OOM and a full disk; those were infrastructure failures, not source failures.


Generated by Claude Code

@EffortlessSteven EffortlessSteven left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@EffortlessSteven
EffortlessSteven marked this pull request as ready for review October 4, 2026 03:04
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@EffortlessSteven
EffortlessSteven merged commit 5767333 into main Oct 4, 2026
33 of 34 checks passed
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-04T03:06:17.126840Z 2dabe15 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@EffortlessSteven
EffortlessSteven deleted the claude/dogfood-pr-summary-missing-root branch October 4, 2026 03:04

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.root resolves to a symlink to a non-directory or a symlink to a file (TOCTOU via is_dir).; refuted because: Even if a TOCTOU exists, the trailing create_dir_all would 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants