Skip to content

timecycle_pairs: --out report gets the umask's mode bits, not mkstemp's 0600 - #7572

Open
best2135 wants to merge 1 commit into
ItsNotRexed:mainfrom
best2135:hunt/timecycle_pairs-report-mode
Open

best2135 wants to merge 1 commit into
ItsNotRexed:mainfrom
best2135:hunt/timecycle_pairs-report-mode

Conversation

@best2135

Copy link
Copy Markdown

Claimed on #7333 (timecycle_pairs).

What was wrong. _write_json_atomic stages the report with tempfile.mkstemp, which creates the file 0600, and os.replaces it onto --out. Every other report writer that stages this way gives the staged file the destination's bits through file_mode.published_mode (#1082); this one did not, so a new report came out 0600 where open(path, "w") gives 0644 under umask 022, and a replaced report lost its previous mode (a 0640 report became 0600).

Hand-built input. tp._write_json_atomic(path, {}) in a fresh temp folder with umask 022 gave 0o600; after the fix it gives 0o644, the same as a plain open() in that folder. A report that already exists with mode 0640 keeps 0640. Two new tests in tests/test_timecycle_pairs.py (ReportModeTests) cover the new-file and replaced-file cases; both failed before the change.

Tests (Linux, Python 3.14, CPU only, no GPU):

AI-assisted.

🤖 Generated with Claude Code

…bits, not mkstemp's 0600

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@morodirule

Copy link
Copy Markdown

Tested 1a4c18f on Arch Linux, Python 3.14.10, CPU only: pass — tests/test_timecycle_pairs.py 6/6 OK (incl. both new ReportModeTests; pytest agrees). Negative control: tool swapped to merge-base → both new tests fail ('0o600' != '0o640', mkstemp's 0600 leaks); restored, green again. No game files. AI-assisted.

@devnull34 devnull34 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified: passes all tests in tests/test_timecycle_pairs.py. Calling published_mode(path) before os.replace ensures atomic staging via mkstemp does not restrict the target report's mode bits to 0600.

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.

3 participants