Repository navigation
fix(output): publish report and pilot outputs atomically (#4542) - #4589
Conversation
file_write::write truncated the destination and then wrote it, so an interrupted run, a full disk or a cancelled CI step left a torn report where the previous complete one was, and ripr pilot used plain fs::write. Write to an exclusively created temporary file beside the destination, keep the old file's permissions, fsync, then rename over it; non-regular and symlinked destinations are still refused. write_with streams pilot's repo-exposure.json the same way. create_new alone makes the temporary file safe, so targets without known no-follow flag values no longer refuse output writes. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014WDSj54AyARNwy6oUuYXnx
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
Warning Review limit reachedNext included review available in 53 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Advanced Run ID: 📒 Files selected for processing (5)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e0fe494b76
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
file_write no longer carries its own temp-and-rename copy. atomic_file gains replace_streamed, sharing one core with write/write_cache: an exclusively created temp file with a short fixed-shape name, so a destination name near the 255-byte limit still writes. A read-only destination is refused with PermissionDenied, as the old in-place write was, instead of being replaced by the rename. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014WDSj54AyARNwy6oUuYXnx
…-2rk3d2-atomic-out # Conflicts: # CHANGELOG.md
EffortlessSteven
left a comment
There was a problem hiding this comment.
Exact-head review of 44cee16: REVIEW_READY.
What I inspected
- The full diff (5 files).
atomic_file::replace_with:- Error stages keep every existing message text for
writeandwrite_cache, and the existing tests cover them. - The temp file is created with
create_newunder a short name. - Permissions are copied after the fill; fsync happens before the rename.
- The temp file is removed on every error path.
- Error stages keep every existing message text for
file_write::validate_destination: refuses non-regular and read-only destinations.review_comments_receiptis the other caller, and it now also refuses read-only destinations.- Pilot: every artifact goes through
write_artifact, andrepo-exposure.jsonstreams with its render error preserved. - The symlink race is answered on its thread:
renamereplaces the link and never writes through it.
Oracle grip
- The CLI
ulimit -ftest fails when truncate-in-place is restored. - The read-only, long-name, directory and symlink cases are asserted with no leftover temp files.
CI and review
- CI is green on this head: GitHub-hosted Rust gates, Rust-only lane, ub-review, cargo-deny.
- The last change is a main merge that touched only CHANGELOG, as a union of the entries.
- All Codex and Devin threads are resolved.
- CodeRabbit, Gemini and droid-review reviews are missing, not clean.
Generated by Claude Code
…-2rk3d2-atomic-out # Conflicts: # CHANGELOG.md
…-2rk3d2-atomic-out # Conflicts: # CHANGELOG.md # crates/ripr/tests/cli_smoke.rs
EffortlessSteven
left a comment
There was a problem hiding this comment.
Exact-head note for b170eec, two merges of origin/main.
- CHANGELOG is a union.
tests/cli_smoke.rs: both sides appended tests at the end of the file. I kept both, this PR'sinterrupted_report_write_keeps_the_previous_complete_reportand main's #4480 input-limit tests, and each has its own closing.cargo check -p riprexits 0.cli_smoke -- interrupted_report_write input_limit dev_zero: 4 passed.--lib -- file_write atomic_file: 11 passed.
Production code is unchanged since the last review. The CodeRabbit, Gemini and droid-review reviews are still missing, which is not the same as clean.
Generated by Claude Code
…-2rk3d2-atomic-out # Conflicts: # CHANGELOG.md # crates/ripr/src/cli/commands/pilot.rs # crates/ripr/src/output/file_write.rs
…-2rk3d2-atomic-out # Conflicts: # CHANGELOG.md
…c writes) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014WDSj54AyARNwy6oUuYXnx
Requested by Steven · project thread
Summary
Before: every
--out/--out-mdreport writer (throughoutput::file_write::writeandcli::commands::write_text_file) truncated the destination and then wrote it;ripr pilotused plainfs::write. If the process died mid-write (Ctrl-C, a cancelled CI step,SIGXFSZ) or the disk filled, the previous complete report was replaced by an empty or half-written file. Receipt:reports gap-ledgerunderulimit -f 1left 1024 bytes of unparseable JSON where a good 1989-byte ledger had been. A concurrent reader such asripr lspcould read a torn file.After: report and pilot outputs are published through the existing owner,
crate::atomic_file: an exclusively created (create_new) temporary file with a short fixed-shape name beside the destination, the old file's permissions carried over, fsync, rename. Readers see the old file or the complete new one. Symlinked, non-regular and read-only destinations are refused before anything is written, as the old in-place write refused them.How:
atomic_filehas one core,replace_with, behindwrite,write_cacheand the new streamingreplace_streamed.file_write::write_withisvalidate_destinationplusreplace_streamed, and pilot'srepo-exposure.jsonstreams through it.Fixes #4542.
Swarm / Source Boundary
ripr-swarmSource-of-truth Links
Proposal: n/a
Spec: n/a
ADR: n/a
Plan item: 0.11 shared-state hunt
Governing issue or accepted claim: #4542
Acceptance delta (one sentence): an interrupted or failed report or pilot write leaves the previous complete file in place.
Candidate Relationships
Candidate branch:
claude/project-thread-2rk3d2-atomic-outStack parent or prerequisite PR: none
Proposed replacement of PR: none
Scope
crates/ripr/src/atomic_file.rs: sharedreplace_withcore,replace_streamed,create_newtemp.crates/ripr/src/output/file_write.rs: delegates; refuses read-only destinations; tests.crates/ripr/src/cli/commands/pilot.rs: pilot artifacts go throughfile_write.crates/ripr/tests/cli_smoke.rs: end-to-end interrupted-write test.Scope Classification
Non-goals:
app/pr_summary,app/impacted_evidence,app/annotationsandcli/rerunstill usefs::write; follow-up..ripr-atomic-*.tmpbeside the destination; the destination is intact.review_comments_receiptkeeps its own publish path; it sharesvalidate_destination, so it now also refuses read-only destinations.Support-tier Impact
Policy Impact
Proof
Tests:
output::file_write::tests::{replaces_a_longer_file_completely_and_leaves_no_temp, a_destination_name_near_the_filename_limit_is_still_written, a_read_only_destination_is_refused_and_left_untouched, a_refused_destination_is_left_untouched, ...},cli_smoke::interrupted_report_write_keeps_the_previous_complete_report, existingatomic_fileandcheck_artifacttests (error texts unchanged).Windows was not run locally; hosted Windows CI covers
fs::renamereplace semantics.Claim Boundary
Rollback
Revert the commit.
Static Language Check
killed,survived,untested,proven, andadequate.Engineering Check
panic,unwrap,expect,todo, orunimplemented.Gates
cargo fmt --checkcargo xtask precommitcargo clippy -p ripr --all-targets -- -D warningsReview
Codex P2 and the Devin findings are addressed and resolved. CodeRabbit (rate limit), Gemini (quota) and droid-review (queued) reviews are missing, not clean.
🤖 Generated with Claude Code
https://claude.ai/code/session_014WDSj54AyARNwy6oUuYXnx