Resume Interrupted OAuth Rotations for Tailscale Operator
This push adds a revision‑checking gate and fsync‑protected receipt handling to the Tailscale operator OAuth rotator, ensuring that interrupted rotations can safely resume without corrupting cross‑repo contract state.
New imports and constants for cross‑repo rotation
The script now imports hashlib and defines a constant TAILNET_POLICY that points to a policy file, plus a tuple ROTATION_CONTRACT_PATHS that lists the directories and files involved in the rotation across several repositories. These constants let the helper locate the operator secret, the policy, and the contract paths in a single deterministic walk, rather than hard‑coding relative locations.
Receipt directory fsync and save_receipt refactor
A new helper sync_receipt_directory opens the parent directory fd, calls os.fsync, then closes the fd, guaranteeing that the filesystem metadata is persisted before any receipt write. The save_receipt function was updated to call sync_receipt_directory instead of in‑lining the fsync logic, reducing duplication and making the fsync intent explicit.
Receipt revision checking and source reading
The check_receipt_revision function compares a record’s stored revision against an expected revision, allowing the rotator to reject stale receipts and resume only from the correct point. The source text of the operator secret is read wholesale with ROOT / OPERATOR_SECRET.read_text(), and the policy is loaded from the new TAILNET_POLICY path instead of the previous hard‑coded location, making the rotation portable across forks and CI environments.