Repository navigation
fix(cli): keep the existing config when ripr init cannot finish writing (#4883) - #4887
Conversation
…ng (#4883) --force removed ripr.toml before writing the replacement, so a full disk left a truncated fragment and printed "Overwrote existing" first. Replace through atomic_file (rename, no symlink follow) and remove a partial create_new file on a failed write. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014WDSj54AyARNwy6oUuYXnx
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 23 minutes. View limit detailsLimit details: You’ve used the included review currently available. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Advanced Run ID: 📒 Files selected for processing (4)
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. |
EffortlessSteven
left a comment
There was a problem hiding this comment.
Exact-head self-review of 3e2f814. No blocking findings.
- Owner. The publish step goes through the existing
atomic_file::write: acreate_newtemp file, the old file's permissions, fsync, rename. No parallel writer is added. - Symlink safety (#1948/#2101). Overwrite renames over the directory entry, and the new symlink test confirms the link's target is untouched. Create keeps
create_newand only removes a file it created itself, after a failedwrite_all. --ci github. An existing workflow file takes the same Overwrite path, so it is protected the same way.- Output.
Overwrote existingnow prints after the write, and the duplicateWroteline on overwrite is gone. No test depended on either line. - Oracle. The size-limit test fails on the old code (receipt in the PR body).
CodeRabbit (rate limit), Gemini (quota) and droid-review reviews are missing, not clean. Hosted CI is pending.
Generated by Claude Code
There was a problem hiding this comment.
Code Review
This pull request improves the robustness of the ripr init command by ensuring that --force replaces the configuration file atomically, preventing truncated files in case of write failures like a full disk. Additionally, a plain ripr init now cleans up and removes any partially written configuration files if the write fails. The review feedback suggests explicitly calling sync_all() on the file handle in write_init_target to ensure that asynchronous writeback errors are caught and handled before the file is closed.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3e2f814411
ℹ️ 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".
There was a problem hiding this comment.
Confirmed findings
- Codex flag: atomic_file::write copies old entry's permissions, but uses std::fs::metadata which follows symlinks; world-readable symlink target yields perms into the generated file. Public route change.
- Cleanup unlinks by path; if a concurrent writer replaces
ripr.tomlbetweencreate_newand the error-cleanup remove, the user's replacement is deleted. Real risk under the new diff. - Both new tests are cfg(unix). The Overwrite path is shared across platforms and rename behavior on Windows differs (ReplaceFile vs rename). Architecture does not block, but cross-platform parity of the fragment-leaves-previous guarantee is unverified.
Verification questions
- Confirm cHANGELOG entry claims 'a plain ripr init removes a file it could not finish writing'; but if remove_file itself fails, partial file stays and only the write error is reported.
- Confirm create branch in write_init_target still opens with create_new, preserving #1948 invariant, but on partial write removes file by path not inode; concurrent replacement is lost.
- Confirm new unix-only tests do not exercise Windows behavior for the shared Overwrite path; rename semantics and open-handle behavior differ.
- Confirm both new tests are #[cfg(unix)]; shared Overwrite path runs on Windows but rename/open-handle semantics differ; no Windows regression coverage.
- Confirm eNOSPC/EFBIG can surface on
close()/sync_all()rather thanwrite_all. Code only checkswrite_allthen drops the handle, leaving a truncated file when the OS only fails at writeback.
Refuted
- Concurrent writer race makes --force unsafe: rename discards another process's save between plan and rename.; refuted because: The new code is the same atomic-publish pattern already used elsewhere in the codebase; introducing a lock or version check here would expand the diff beyond a smallest-complete fix for #4883 and is a policy/scope decision, not a boundary error. Not a blocker for this PR's claimed behavior.
- sync_all needed to catch async writeback errors per gemini-code-assist suggestion; refuted because: Out of tests-red-green lane scope; this is a correctness/architecture point about ENOSPC visibility, not a red/green test weakness.
- Overwrite path lost the duplicate
Wroteline and may break callers that grep it.; refuted because: Diff removes theprintln!("Wrote ...")only from the Overwrite branch'swrite_init_targetreturn path; Overwrite now printsOverwrote existing ...post-write and noWrote. No seeded review or test depends on the duplicate line; owner self-review explicitly notes 'No test depended on either line'.
Evidence gaps
- Model proof intent was rejected by deterministic validation.
…missions (#4883 review) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014WDSj54AyARNwy6oUuYXnx
EffortlessSteven
left a comment
There was a problem hiding this comment.
Exact-head review of ad4da01. Disposition: no blocking findings; merge waits on required CI.
What I inspected (4 files, +341/-31):
atomic_file::publish_with:- Replace renames over the destination. It copies permissions only when
symlink_metadatareports a regular file. - NoReplace publishes with
hard_linkand then removes the temp file.CreateNewErrorseparates a staging failure from a publish failure.
- Replace renames over the destination. It copies permissions only when
init:--forcegoes throughatomic_file::write.- A fresh config goes through
create_new. AlreadyExists is reported and never overwrites. - Filesystems without hard links fall back to
create_new+write_all+sync_all, and the error names a cleanup failure. - "Wrote" and "Overwrote" print only after the publish succeeds.
- Oracles:
- The size-limited init tests use EFBIG as a stand-in for ENOSPC.
- For
--forcethey check the previous config is kept byte for byte, with no.tmpand no "Overwrote" line. For a fresh init they check no file and no staged temp remain, and that a rerun succeeds. - The symlink test checks that the target is untouched and that its 0o604 mode is not inherited.
- Unit tests cover create-new refusal, a dangling symlink, and symlink permissions.
Local results:
cargo clippy -p ripr --all-targets --locked -D warnings: 0.cargo xtask precommit: 0.cli_smoke init_: 14/14 passed.atomic_file/file_writeunit tests: all passed exceptoutput_dir_tests::unwritable_parent_create_names_the_flag, a known root-container chmod failure from main's #4774 test.
Review threads: all 7 answered. Devin's --force race is declined with the reason given in the thread.
Review providers: CodeRabbit is missing (rate-limited) and droid-review is missing (queued). Neither counts as a clean review.
Generated by Claude Code
…-2rk3d2-atomic-rest # Conflicts: # CHANGELOG.md
# Conflicts: # CHANGELOG.md
…rofiles (#4978) (#5170) `init_that_cannot_finish_writing_keeps_the_previous_config` (#4887) runs `ripr init` twice under `trap '' XFSZ; ulimit -f 1`. With SIGXFSZ ignored the child exits normally and its LLVM profile write at exit is cut to 512 bytes inside target/llvm-cov-target. `llvm-profdata merge` (default failure mode `any`) then rejects the whole set: two consecutive-PID "file header is corrupt" warnings and "no profile can be merged", the rust-coverage signature on every main push since #4887 merged. Route both `ulimit -f` children through one helper that points the child's LLVM_PROFILE_FILE at /dev/null. That profile can never be complete under the cap; every other process keeps its profile. Claude-Session: https://claude.ai/code/session_01S5D7B2JxJ754s1p6ktir1Y Co-authored-by: Claude <noreply@anthropic.com>
Summary
Before:
ripr init --forcedeleted the existingripr.tomlbefore writing the new one, and printedOverwrote existing …before the write ran. With a full disk or a file-size limit, the user's config was replaced by a 512-byte fragment. A rerun then refused to replace the fragment without--force, and the fragment could still parse as a config missing its later sections. A plainripr initleft the same fragment behind.After:
--forcereplaces the config atomically throughatomic_file::write, so the old file stays until the rename.initstages the config in a same-directory temp file and publishes it with a no-replace hard link, so a failed write leaves noripr.tomland never touches a file another process created.WroteandOverwrote existing …print only after the publish succeeds.How:
atomic_filegainscreate_new, which uses the same staging aswritebut publishes withhard_link.symlink_metadatashows a regular file.create_newwrite,sync_alland cleanup. If the cleanup fails, the error names it.ripr init --forcebypasses the #1948 create_new symlink guard — plain fs::write follows symlinks #2101).Fixes #4883.
Swarm / Source Boundary
ripr-swarmSource-of-truth Links
Plan item: 0.11 shared-state hunt
Governing issue or accepted claim: #4883
Acceptance delta (one sentence): a failed
ripr initwrite leaves the previous config, or no file, never a fragment.Candidate Relationships
Candidate branch:
claude/project-thread-2rk3d2-atomic-restStack parent or prerequisite PR: none
Scope
crates/ripr/src/atomic_file.rs:create_new,CreateNewError, and the symlink-safe permission copy.crates/ripr/src/cli/commands/init.rs:write_init_targetandapply_init_plan.crates/ripr/tests/cli_smoke.rs: two unix tests.CHANGELOG.md.Scope Classification
Non-goals:
--forceis overwritten;--forcemeans replace.initcan still leave a partial file.Support-tier Impact
Policy Impact
Proof
init_that_cannot_finish_writing_keeps_the_previous_configrunsinitundertrap '' XFSZ; ulimit -f 1.--force, it checks the previous config is intact, no.tmpis left, and noOverwroteline prints.init, it checks no file and no staged temp remain, and a rerun succeeds.init.rsrestored, it fails.init_force_replaces_a_symlinked_config_without_writing_its_target: the link target is untouched, and the target's 0o604 mode is not inherited.Claim Boundary
ripr initnever leaves a truncated config after a write error.--forcepreserves another writer's save.Rollback
Revert the commit.
Static Language Check
killed,survived,untested,proven, andadequate.Engineering Check
panic,unwrap,expect,todo, orunimplemented.Gates
cargo fmt --checkcargo xtask precommit🤖 Generated with Claude Code
https://claude.ai/code/session_014WDSj54AyARNwy6oUuYXnx