fragment_children: restore write mode before unlink on replace failure and publish mode on Windows (FRAGMENT-CHILDREN-STAGE-CLEANUP) #755

Merged
trigger337 merged 1 commit from upstream-pr/755 into main 2026-11-28 11:02:21 +00:00
trigger337 commented 2026-11-24 13:31:13 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by trigger337 on 2026-11-24T13:31:13Z.


In tools/fragment_children.py write_json_report:

  1. os.chmod(staged.name, published_mode(destination)) was skipped on Windows (if os.name != "nt":) because unlinking a temporary file chmod'd to read-only mode in finally: failed with PermissionError on Windows. As a result, Windows output files retained NamedTemporaryFile's private 0600 permissions.
  2. Ensure os.chmod(staged.name, 0o600) before os.unlink in finally:, enabling published_mode(destination) on all platforms and ensuring that temporary staging files are never leaked on failed replacements.
  3. Added regression tests in tests/test_fragment_children.py verifying read-only replacement failure staging cleanup with strict Windows unlink emulation, and Windows published mode application.

agent: yes
AI-assisted: yes

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5473103020 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/755). Originally posted by [trigger337](https://github.com/trigger337) on 2026-11-24T13:31:13Z. --- In `tools/fragment_children.py` `write_json_report`: 1. `os.chmod(staged.name, published_mode(destination))` was skipped on Windows (`if os.name != "nt":`) because unlinking a temporary file chmod'd to read-only mode in `finally:` failed with `PermissionError` on Windows. As a result, Windows output files retained `NamedTemporaryFile`'s private `0600` permissions. 2. Ensure `os.chmod(staged.name, 0o600)` before `os.unlink` in `finally:`, enabling `published_mode(destination)` on all platforms and ensuring that temporary staging files are never leaked on failed replacements. 3. Added regression tests in `tests/test_fragment_children.py` verifying read-only replacement failure staging cleanup with strict Windows unlink emulation, and Windows published mode application. agent: yes AI-assisted: yes
abnalstlll-byte commented 2026-11-24 13:33:34 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by abnalstlll-byte on 2026-11-24T13:33:34Z.

Review: APPROVED


Audited and verified. Clean-room compliant.

  • Restores 0o600 file mode before unlinking staging file on replace failure in tools/fragment_children.py.
  • Applies published_mode across all platforms.
  • Regression tests in tests/test_fragment_children.py PASS.
<!-- greyfinch-sync:ubiquitarianism/leonida:review:6040109179 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/755#pullrequestreview-6040109179). Originally posted by [abnalstlll-byte](https://github.com/abnalstlll-byte) on 2026-11-24T13:33:34Z. **Review:** APPROVED --- Audited and verified. Clean-room compliant. - Restores 0o600 file mode before unlinking staging file on replace failure in tools/fragment_children.py. - Applies published_mode across all platforms. - Regression tests in tests/test_fragment_children.py PASS.
tiguan26 commented 2026-11-25 04:01:54 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by tiguan26 on 2026-11-25T04:01:54Z.

Review: APPROVED


Approving. Merged into current main with no conflicts; the PR's tests pass (Linux, Python 3.13). Same pattern as the rest of the *-STAGE-CLEANUP series: on a failed replace the staged file gets 0o600 back before os.unlink, so a staged copy left read-only (the published mode on Windows) is still removed; and the published mode now also applies on Windows (the os.name guard is gone), using file_mode.published_mode. Only the staging/permission lines change.

AI-assisted (Claude).

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6051680697 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/755#pullrequestreview-6051680697). Originally posted by [tiguan26](https://github.com/tiguan26) on 2026-11-25T04:01:54Z. **Review:** APPROVED --- Approving. Merged into current main with no conflicts; the PR's tests pass (Linux, Python 3.13). Same pattern as the rest of the *-STAGE-CLEANUP series: on a failed replace the staged file gets 0o600 back before os.unlink, so a staged copy left read-only (the published mode on Windows) is still removed; and the published mode now also applies on Windows (the os.name guard is gone), using file_mode.published_mode. Only the staging/permission lines change. AI-assisted (Claude).
MoonEyes commented 2026-11-28 11:02:15 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T11:02:15Z.


Red/green: the PR's tests fail on main and pass with this PR (Linux, Python 3.13.18).
Targeted batch of 23 PRs (their tests, the tests importing the changed modules, the docs tests) on main 3ca0707: no new failure, Linux / Python 3.13.
AI-assisted (Claude Code, Claude Opus 5.5)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7238284166 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/755#issuecomment-7238284166). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T11:02:15Z. --- Red/green: the PR's tests fail on main and pass with this PR (Linux, Python 3.13.18). Targeted batch of 23 PRs (their tests, the tests importing the changed modules, the docs tests) on main 3ca0707: no new failure, Linux / Python 3.13. AI-assisted (Claude Code, Claude Opus 5.5)
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!755
No description provided.