You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Stacked on independently checked formal/control + recovery combined draft #175, which in turn is based on qualified MVP #158. The core api/utils/files.py::_atomic_write_text already fsynced temporary file contents and atomically replaced the name, but did not sync the parent directory. A hard crash could lose the pointer/state rename despite successful API return.
Adds opt-in durable_directory=True to the existing primitive and uses it only for authoritative write_session_dir pointer and write_session_state commits (not high-frequency ordinary writes). Propagates directory fsync errors instead of reporting a false commit. The sequence is: temp write -> file fsync -> atomic rename -> parent-directory fsync -> acknowledge. Does not claim atomicity spanning two separate state files, broker or Wine.
Three synthetic unit regressions verify both authoritative writer call paths perform file + directory fsync, a failed os.replace preserves old state and cleans temporary files, and a failed directory fsync is surfaced without a false success claim. Explicitly added to scripts/ci/test.sh mandatory unit manifest. Updated formal workflow path filter for the new source/test.
Admission
Public-free-tier exact-head lint/unit, frozen external conformance, smoke and full TLC blue + adversarial counterexample gates; no private runner, sovereign hardware, real user data, source declassification, merge or release. Preserve parent #175 qualification and PR #158 DLE authority. Target is Linux/POSIX durable directory semantics; actual host-filesystem guarantees still need environment-specific qualification.
2026-11-21 05:20 CET — durable atomic-state design comparison and consolidation
Concurrent source variants compared against qualified MVP: #177's api/utils/files.py::_atomic_write_text performs file fsync, atomic rename, always parent-directory fsync for all six metadata writer call paths (SESSION_FILE, session state/mode/control policy, instance state/control policy), and propagates durability errors. #178 independently proposed opt-in directory fsync for only the session pointer/state, with separate unit tests. Exact api/utils/files.py source call-site inventory confirmed only low-frequency control/session metadata, no high-volume telemetry/event trace writer. The universal sync approach in #177 is therefore both simpler and more complete for authoritative metadata, without compelling evidence of significant hot-path overhead.
Action: retained DRAFT #177 as sole durability candidate, now exact head 1ad26d6ea66c44cc109baf99fed8ad2971c15eb9. Extended the existing mandatorytests/test_invariants.py unit suite with (1) authoritative write_session_dir file-then-parent sync capture and pointer bytes; (2) interrupted os.replace preserving previous session state and cleaning temporary files. Complements earlier file/state ordering and directory fsync-error propagation tests. No duplicate test runner manifest and no production code changes relative #177's chosen implementation. No native process effects.
DRAFT #178 remains a historical opt-in alternative with its tests, now superseded by #177; close without merge to avoid two competing atomic writer contracts. Need exact-head full public GHA of #1771ad26d6e before release or any merger, and explicit source integration with canonical combined #176. Any merged source must trigger formal check for changed session persistence even if no TLA+ sources changed; add api/utils/files.py to #176 TLC workflow filters when integrating durability. Fsync of parent metadata cannot by itself make the multi-file, multi-process or host/guest transaction atomic; recovery and fencing still required.
mark-e-deyoung
changed the title
[DRAFT] Persist session pointer/state directory entries across crash windows
[SUPERSEDED / UNMERGED] Targeted session durability carried into #177
Nov 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bounded critical-path durability correction
Stacked on independently checked formal/control + recovery combined draft #175, which in turn is based on qualified MVP #158. The core
api/utils/files.py::_atomic_write_textalready fsynced temporary file contents and atomically replaced the name, but did not sync the parent directory. A hard crash could lose the pointer/state rename despite successful API return.Adds opt-in
durable_directory=Trueto the existing primitive and uses it only for authoritativewrite_session_dirpointer andwrite_session_statecommits (not high-frequency ordinary writes). Propagates directory fsync errors instead of reporting a false commit. The sequence is: temp write -> file fsync -> atomic rename -> parent-directory fsync -> acknowledge. Does not claim atomicity spanning two separate state files, broker or Wine.Three synthetic unit regressions verify both authoritative writer call paths perform file + directory fsync, a failed
os.replacepreserves old state and cleans temporary files, and a failed directory fsync is surfaced without a false success claim. Explicitly added toscripts/ci/test.shmandatory unit manifest. Updated formal workflow path filter for the new source/test.Admission
Public-free-tier exact-head lint/unit, frozen external conformance, smoke and full TLC blue + adversarial counterexample gates; no private runner, sovereign hardware, real user data, source declassification, merge or release. Preserve parent #175 qualification and PR #158 DLE authority. Target is Linux/POSIX durable directory semantics; actual host-filesystem guarantees still need environment-specific qualification.