Skip to content

Re-Check the Remote Before a Pull Write, Time the Temporary File, and Fail a Leaky Selftest - #4195

Merged
ptr727 merged 2 commits into
developfrom
feature/secrets-sync-promotion-fixes
Nov 15, 2026
Merged

ptr727 merged 2 commits into
developfrom
feature/secrets-sync-promotion-fixes

Conversation

@ptr727

@ptr727 ptr727 commented Nov 15, 2026

Copy link
Copy Markdown
Owner

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.

  • Pull re-checks the remote before each write. After its confirmation prompt, pull lists the vault again and refuses an item that changed, vanished or was replaced since the plan, as push and archive already do. Because pull now calls op after its prompt, it also re-checks the session there, and the unused then_op switch is removed.
  • The pulled file's mtime is set before the rename. write_secret sets it on the closed temporary file before os.replace, which keeps it. So a failure leaves the target unchanged on every platform, not only where os.utime takes a descriptor.
  • A selftest that leaves its scratch vault behind exits 2. It still prints every measurement and the delete-by-hand guidance.

Verification

  • python3 tests/test_secrets_sync.py: 154 tests, OK. Each new or changed case also ran against develop's script and failed there.
  • ruff format, ruff check, mypy and the .husky/pre-commit hook are clean.
  • The local strict review ran twice. Its one finding, the missing session re-check, is fixed in d6120f9, and the pass covering this head raised none.

🤖 Generated with Claude Code

ptr727 and others added 2 commits November 15, 2026 10:47
… 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]>
Copilot AI lite review requested due to automatic review settings November 15, 2026 18:52
@ptr727

ptr727 commented Nov 15, 2026

Copy link
Copy Markdown
Owner Author

A recorded local strict-review pass covers head d6120f9822c082d5335e25455239731fe11256b4, the content this pull request carries at that commit against develop, and it recorded 0 findings.

@coderabbitai

coderabbitai Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 82c6fec and d6120f9.

Files selected for processing: 3

  • scripts/README.md
  • scripts/secrets_sync.py
  • tests/test_secrets_sync.py
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

Copilot AI 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.

🔵 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

codecov Bot commented Nov 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.05%. Comparing base (82c6fec) to head (d6120f9).

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     
Flag Coverage Δ
python-3.13 78.05% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ptr727

ptr727 commented Nov 15, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@ptr727

ptr727 commented Nov 15, 2026

Copy link
Copy Markdown
Owner Author

/review

@coderabbitai

coderabbitai Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@ptr727

ptr727 commented Nov 15, 2026

Copy link
Copy Markdown
Owner Author

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.

@ptr727
ptr727 merged commit b6c6bed into develop Nov 15, 2026
14 checks passed
@ptr727
ptr727 deleted the feature/secrets-sync-promotion-fixes branch November 15, 2026 19:09
ptr727 added a commit that referenced this pull request Nov 15, 2026
…#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)
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