Repository navigation
Re-Check the Remote Before a Pull Write, Time the Temporary File, and Fail a Leaky Selftest - #4195
Conversation
… Fail a Leaky Selftest Pull lists the vault again before each write and refuses an item that changed after the plan, as push and archive do. A pulled file's mtime is set on the closed temporary file before the rename, so a failure leaves the target unchanged on every platform. A selftest that cannot delete its scratch vault exits 2. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Pull now lists the vault after its confirmation prompt, so it takes the same session re-check push, archive and selftest take. A session that ended during the prompt is refused at exit 1 with nothing written. The then_op switch had no other caller and is removed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
A recorded local strict-review pass covers head |
|
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 37 minutes. View limit details
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. |
There was a problem hiding this comment.
🔵 Needs a closer look
Because the pull path and temporary-file timestamping involve platform-sensitive secret writes, native Windows behavior still requires human verification before approval.
No open issues 🎉
What changed in this PR
This PR hardens the secrets synchronization workflow against stale pull state and unsafe timestamp handling, while improving selftest cleanup reporting. The review identifies a remaining gap because cleanup trusts the delete command status without verifying that the scratch vault was removed.
Changes:
- Re-checks remote pull items and the 1Password session before writing.
- Sets timestamps on temporary files before atomic replacement.
- Reports selftest cleanup failures with exit code 2.
- Adds regression tests and updates the documentation.
| File | Description |
|---|---|
| tests/test_secrets_sync.py | Adds regression coverage for remote pull races, session expiry, timestamp failures, and leaked selftest vaults. |
| scripts/secrets_sync.py | Implements pull-time remote and session rechecks, pre-rename timestamping, and selftest cleanup failure reporting. |
| scripts/README.md | Documents pull rechecks, session validation, and the selftest cleanup exit status. |
Review effort: Lite
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #4195 +/- ##
========================================
Coverage 78.05% 78.05%
========================================
Files 42 42
Lines 15317 15319 +2
========================================
+ Hits 11955 11958 +3
+ Misses 3362 3361 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@coderabbitai review |
|
/review |
Action not completed
|
|
Filed as #4188. The verdict asks for native Windows verification of the pull path and the temporary-file timestamp. #4188 already tracks verifying secrets_sync.py and the op host tool natively on Windows, and it stays open across this PR and the promotion. This change makes Windows take the same os.utime-on-the-closed-temporary-path step Linux takes, before os.replace, instead of setting the time by path after the rename. On Windows, os.utime on a closed path is the supported form (os.supports_fd does not include utime there). It has not been run on Windows, which is #4188's to do. |
…#4194) ## Summary Promotes the 1Password secrets sync tool and its review fixes from `develop` to `main`. - #4165: adds `scripts/secrets_sync.py`. It syncs secret files between a home directory and 1Password through the `op` CLI, with one vault per bucket and one Document item per file. - #4193: fixes the three review findings deferred from #4165, so the tool can ship. - Staleness is judged by a content-time tag, so a mode-only retag no longer reads as newer content. - Push refuses a title another bucket already holds. - Pull refuses to replace a file another user owns. - It also adds stale-plan refusals on push, pull and archive, a named recovery for an update interrupted between its content and tag writes, and a re-time on pull for files the #4165 code wrote. - #4195: answers this promotion's review. Pull re-checks the remote item and the session after its prompt, a pulled file's mtime is set before the rename, and a selftest that leaves its scratch vault behind exits 2. - #4196: answers the promotion's second review round. An update at an equal content time moves the time forward, and push re-checks other buckets after its prompt. Native Windows verification of the tool stays tracked in #4188, which this promotion leaves open. Closes #4190 Closes #4191 Closes #4192 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Summary
Answers three of the four findings the hosted review raised on the promotion, #4194. The fourth, a vault adopted after the plan, is declined with evidence in its thread.
opafter its prompt, it also re-checks the session there, and the unusedthen_opswitch is removed.write_secretsets it on the closed temporary file beforeos.replace, which keeps it. So a failure leaves the target unchanged on every platform, not only whereos.utimetakes a descriptor.Verification
python3 tests/test_secrets_sync.py: 154 tests, OK. Each new or changed case also ran against develop's script and failed there..husky/pre-commithook are clean.🤖 Generated with Claude Code