Skip to content

[SUPERSEDED / UNMERGED] Durable metadata writer carried by MVP #176 - #177

Closed
mark-e-deyoung wants to merge 3 commits into
mvp/ic1-integration-20261117from
fix/mvp-durable-atomic-state-20261121
Closed

mark-e-deyoung wants to merge 3 commits into
mvp/ic1-integration-20261117from
fix/mvp-durable-atomic-state-20261121

Conversation

@mark-e-deyoung

Copy link
Copy Markdown
Collaborator

Evidence-based cross-layer durability fix

api/utils/files.py::_atomic_write_text previously wrote and fsynced temporary bytes and os.replaced the destination but did not fsync the parent directory. The file data can be durable without the post-rename directory entry being power-loss durable. This is a separate local persistence seam from the formal control/handover PRs #173/#174 and their combined qualification PR #176.

This narrowly adds parent-directory fsync after atomic rename. Directory sync failure propagates to the caller; the write may already be visible, so caller recovery must not assume rollback. No claim of multi-file distributed transaction atomicity.

Two synthetic tests in the existing mandatory tests/test_invariants.py assert actual file-then-directory fsync ordering, no temporary-file leak, and error propagation on simulated directory sync failure.

Qualification

Run source-exact lint/unit, external frozen conformance and smoke against owning MVP #158 and independently assess filesystem compatibility. Stay DRAFT, no merge or release until exact-head public GHA terminal. No private/source leak, paid cloud or user hardware. After acceptance, reconcile this change with combined #176 under one authoritative MVP candidate.

Copy link
Copy Markdown
Collaborator Author

2026-11-21 ~05:12 CET — first combined CI failure isolated and corrected, durable local-state batch launched

Combined integration draft #176 first exact head 3511a0c93f01a12c91cc8ddc873204b15d5d9f07: public full CI #44864557862 completed FAILURE in Pre-flight unit: 267 passed / 1 failed. Failure was tests/test_lifecycle_hardened.py::test_sessions_resume_concurrent_calls_idempotent, which still mocked link_wine_user_dir although production recovery deliberately uses _link_profile_checked. It is an integration transfer omission, not failure of the verified profile-link policy: six of the seven source blobs from independently passing recovery PR #174 matched exactly; the seventh test file remained the prior MVP version because a seven-file tool batch hit its call cap at the final operation. Measured source blobs individually. Corrected just that test file to the exact previously qualified PR #174 blob 993931f31a1c366b6eddd78aa1877aa4437973ed, producing new combined PR #176 HEAD 9a13d8b3da4df7517ebea43991fc034cdc1c62f3. No runtime check weakened; re-run triggered by normal PR push. All other prior combined exact-head focused workflows SUCCESS: Formal TLC+both mandatory negative controls #44864557848, BuildKit #44864557816, RPC redaction #44864557872, provenance #44864557935, public evidence #44864557928/#44864557891, disposable contracts #44864557840; unit isolation was still in progress at previous readback. Do not label current exact head fully green until verified.

Independent persistence durability defect batch: new DRAFT #177, based on qualified MVP #158, exact HEAD cee039d198dbe23c86696a3fd3e87e925dffd3be. api/utils/files.py::_atomic_write_text had fsync(tempfile)+os.replace but no fsync(parent directory), so success did not certify durable rename after power loss. Added dir fd open/fsync/close after rename, propagates failure (new destination bytes may already be visible so no fake rollback), and two synthetic tests in the existing explicit unit manifest's tests/test_invariants.py verifying file-before-directory sync, fail-closed directory-sync error and cleanup. Public CI #44864757163 in progress; no exact-head PASS assertion. Separate draft avoids restarting combined #176 Wine build while diagnosis proceeds.

Remaining: native in-flight guest/host effects, multi-process CAS/fencing, orphan inactive markers, real recorder finalization, source-qualified private WinInspect C++ #468 and real HWND #166 remain held. No merge, release, private GHA minutes, user hardware, paid compute, source disclosure, or fixture bypass.

Copy link
Copy Markdown
Collaborator Author

2026-11-21 05:16 CET — concurrent actor/source-custody reconciliation, no blind duplicate merge

Two independently authored combined candidates detected. #175 exact 4f7f9bd194198705216fe20c399586a9355474a2 (stacked on #173) and #176 exact 9a13d8b3da4df7517ebea43991fc034cdc1c62f3 (based directly on owning MVP #158). Read-only live GitHub source blob comparison established ALL SEVEN crash-recovery implementation/test blobs BYTE-IDENTICAL: api/core/handover_recovery.py, api/server.py, api/routers/lifecycle.py, scripts/ci/test.sh, tests/test_api_contracts.py, tests/test_handover_restart_recovery.py, tests/test_lifecycle_hardened.py. #176 already corrected its first known one-file mock transfer error and achieved native TLC+adversarial checks #44864855878 SUCCESS; #175 #44864642285 native TLC SUCCESS, full CI in progress. They are NOT two different safety implementations; avoid double merge/review.

One meaningful divergence: #175's .github/workflows/formal-cross-layer-tlc.yml blob fbb52287d303d3c32320861095fa954a90de4474 triggers TLC for api/core/broker.py, api/core/handover_recovery.py, api/routers/input.py, api/routers/lifecycle.py, api/server.py, pertinent tests and scripts/ci/test.sh, in addition to formal/**; #176's workflow blob 6bf7ad7b91788c50c3ddef7ba249fdab8d685cc2 is the original narrow formal-only filter. This coverage requirement should survive whichever integrated PR becomes authoritative: code-level safety changes must trigger formal qualification even when no TLA+ source changes.

Another concurrent scope collision: #177 cee039d198dbe23c86696a3fd3e87e925dffd3be fsyncs the parent directory for all api/utils/files.py::_atomic_write_text uses and adds 2 mandatory tests/test_invariants.py regressions. #178 720fd9c0630009818e7530be54df7a79b995af30 (stacked on #175) uses opt-in durable_directory=True ONLY on write_session_dir/ write_session_state to avoid changed fsync latency on unrelated high-frequency writers, with 3 explicit mandatory tests/test_session_state_durability.py cases (file+directory, interrupted replace, directory sync fail closed) and TLC trigger expansion for persistence. Neither version has terminal exact-head full CI yet. Decide a single authoritative durability path after performance/compatibility and proof comparison; avoid duplicate parent-directory fsync implementations or silent closure of active other-actor PRs.

Suggested repo hygiene: converge on ONE combined source branch (prefer directly MVP-based #176 if it incorporates #175's wider TLC trigger and reaches exact-head CI); preserve the standalone qualified #173/#174 as DLE source lineage. Keep independent durability tests until one design chosen, then close superseded other-actor drafts unmerged only with documented reason/receipts. All sources public-safe; WinInspect-native #468/#166 remains release-held; no merge/release/private Actions spend.

Copy link
Copy Markdown
Collaborator Author

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 mandatory tests/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 #177 1ad26d6e 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 added a commit that referenced this pull request Nov 21, 2026
Import exact source/test blobs from independently CI-green #177 into the
combined formal/recovery MVP candidate #176. Preserve authoritatively
qualified state sync semantics and trigger TLC for persistence changes.
No release promotion; all combined exact-head gates must run again.

Copy link
Copy Markdown
Collaborator Author

2026-11-21 — DLE lineage reconciliation / source supersession, no merge

This isolated source workcell is fully represented in the canonical MVP cross-layer integration #176 at exact 3cdfdc2299f732d2d2e23139b6a05a919e4106b5. Independent source evidence: both exact source/test blob SHAs are byte-identical in #176. Original independent exact-head public acceptance: CI #44865205705, terminal SUCCESS. Combined #176 at exact target subsequently passed full CI #44872891236 and TLC #44872891144 alongside its focused public guards.

Original head 1ad26d6ea66c44cc109baf99fed8ad2971c15eb9 is preserved in immutable GitHub commits and PR discussion. Close this PR UNMERGED, superseded, retaining source custody and reproducible evidence but eliminating duplicate merge candidates; do not delete branches or rewrite history. The owning MVP #158 is still DRAFT, and combined #176 plus the downstream consumer+reap candidate #181 are not promoted to public main, hardware or production. No release gate waived, no paid/private Actions minutes or private C++ source disclosed.

@mark-e-deyoung mark-e-deyoung changed the title [DRAFT] Durable atomic session state-file commits on MVP [SUPERSEDED / UNMERGED] Durable metadata writer carried by MVP #176 Nov 21, 2026
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.

1 participant