feat(python): durable transaction subsystem and Kiro IDE 1.0 adapter
Land the crash-recoverable managed-file transaction engine (journal, staging, commit, restart recovery, opaque snapshots, private artifacts, Windows DACL hardening) and the Kiro IDE 1.0 workspace hook plugin with legacy migration. Repair five defects that kept the suite red (426 failures to zero): - Anchor the transaction state directory at ~/.elydora/transactions instead of the shared system temp directory. The recovery journal now shares fate with the runtimes it repairs, survives temp cleaners, and isolates naturally under per-test fake homes. - Skip pending-transaction recovery when no state directory exists so rejected installs never create runtime directories. - Create the runtime root's parent before hardening it, matching the Go SDK's expand behavior for fresh homes. - Stop using file timestamps as identity evidence: Windows exposes mtime/ctime with delayed cross-handle visibility. Reads now prove stability through a verification re-read; snapshots compare device, inode, size, and SHA-256. - Stop comparing synthetic Windows permission bits across stat boundaries: path stats derive execute bits from file extensions while handle stats do not, which falsely flagged every managed .cmd wrapper. Snapshots store raw modes for restoration and compare portable bits. Reservation cleanup now verifies content before discarding so a concurrent writer's file at a rollback path is preserved, and the install-failure tests assert the precise contract: no agent runtime residue, with the durable state directory allowed to remain. Gates: pytest 807 passed, mypy clean, pip check clean, wheel builds.
This commit is contained in:
1 parent
dce7d1288a
commit
e37418c489
53 files changed
+11855
-531
No files matched your search
@@ -0,0 +1,64 @@
|
||||
"""Identity-bound cleanup for captured opaque rollback files."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from ._opaque_removal import (
|
||||
StagedOpaqueRemoval,
|
||||
_same_captured,
|
||||
stream_opaque_snapshot,
|
||||
)
|
||||
from ._private_artifact import QuarantinedFile
|
||||
|
||||
|
||||
def _capture_cleanup_physical(
|
||||
staged: StagedOpaqueRemoval,
|
||||
source_path: str,
|
||||
) -> None:
|
||||
del staged, source_path
|
||||
|
||||
|
||||
def cleanup_opaque_removal(staged: StagedOpaqueRemoval) -> None:
|
||||
if not staged.committed or staged.rollback_path is None:
|
||||
return
|
||||
expected = staged.rollback_snapshot
|
||||
if expected is None:
|
||||
raise OSError(f"Missing rollback data for {staged.change.label}")
|
||||
rollback_path = staged.rollback_path
|
||||
_capture_cleanup_physical(staged, rollback_path)
|
||||
captured_file = QuarantinedFile.capture(
|
||||
staged.directory,
|
||||
rollback_path,
|
||||
f"{staged.change.label} rollback cleanup",
|
||||
)
|
||||
captured = stream_opaque_snapshot(
|
||||
captured_file.container,
|
||||
captured_file.entry_path,
|
||||
f"{staged.change.label} rollback cleanup",
|
||||
require_owner_only=False,
|
||||
)
|
||||
if not _same_captured(captured, expected):
|
||||
try:
|
||||
captured_file.restore(rollback_path)
|
||||
except Exception as error:
|
||||
preserved = (
|
||||
captured_file.preserve()
|
||||
if captured_file.active
|
||||
else rollback_path
|
||||
)
|
||||
staged.rollback_path = None
|
||||
raise OSError(
|
||||
f"{staged.change.label} changed at cleanup boundary; "
|
||||
f"concurrent data preserved at {preserved}: {error}"
|
||||
) from error
|
||||
staged.rollback_path = None
|
||||
raise OSError(
|
||||
f"{staged.change.label} changed at cleanup boundary; "
|
||||
f"concurrent data preserved at {rollback_path}"
|
||||
)
|
||||
captured_file.discard()
|
||||
staged.rollback_path = None
|
||||
staged.rollback_snapshot = None
|
||||
staged.committed = False
|
||||
|
||||
|
||||
__all__ = ["cleanup_opaque_removal"]
|
||||
Reference in new issue
Block a user