Bind one labelled 1b recovery to the same reviewed guard and settle old cost once
This commit is contained in:
1 parent
2f8d87872a
commit
709becdd73
4 files changed
+1017
No files matched your search
@@ -0,0 +1,64 @@
|
||||
"""Bind the reviewed 1b implementation to the one labelled recovery root."""
|
||||
|
||||
from copy import deepcopy
|
||||
from pathlib import Path
|
||||
from types import FunctionType
|
||||
|
||||
import phase3_item1b_fold0 as original_entry
|
||||
import phase3_item1b_fold0_deadline as deadline
|
||||
from phase2_home_freeze_io import verify
|
||||
|
||||
|
||||
ROOT = deadline.ROOT.with_name("phase3-item1b-fold0-labelled-recovery-2026-11-19")
|
||||
ENTRY = Path(__file__).resolve()
|
||||
UUID = "GPU-f1c9fd5a-e917-56e0-21fb-24035ba44a36"
|
||||
ORIGINAL_CONTRACT = "25cb8ce8ba1b43695fb5c229459033d6c5f0c79a9e67e156b9e78353b9a89971"
|
||||
ORIGINAL_TERMINAL = "703cac3af80d53b13f908b18d86c260d52562797dcd0610cd307a5af92e56f2d"
|
||||
|
||||
|
||||
def authorized_contract():
|
||||
old = deadline.contract(deadline.checked(deadline.ROOT / "contract.json", ORIGINAL_CONTRACT))
|
||||
terminal = deadline.read(deadline.checked(deadline.ROOT / "complete.json", ORIGINAL_TERMINAL))
|
||||
if terminal["status"] != "STOPPED" or terminal["trigger"] != "FOREIGN_GPU_OCCUPANT":
|
||||
raise PermissionError("The exact stopped attempt is required")
|
||||
recovery = deepcopy(old)
|
||||
recovery["gpu_uuid"] = UUID
|
||||
for name in ("item", "phase3"):
|
||||
previous = old["budget"][f"prior_{name}_gpu_seconds"]
|
||||
settled = terminal[f"cumulative_{name}_gpu_seconds"]
|
||||
if previous + terminal["new_gpu_seconds"] != settled:
|
||||
raise ValueError(f"Historical {name} settlement differs")
|
||||
recovery["budget"][f"prior_{name}_gpu_seconds"] = settled
|
||||
return recovery
|
||||
|
||||
|
||||
def contract(path):
|
||||
current = deadline.contract(path)
|
||||
if current != authorized_contract():
|
||||
raise PermissionError("Only the original science, new physical card and settled ledger are allowed")
|
||||
return current
|
||||
|
||||
|
||||
def dispatch_guard(root, path):
|
||||
# Keep the guard bytecode and its supervisors. Its child command uses this
|
||||
# launcher so both workers return to the same checked execution root.
|
||||
namespace = dict(deadline.dispatch_guard.__globals__, __file__=str(ENTRY), contract=contract)
|
||||
return FunctionType(deadline.dispatch_guard.__code__, namespace, "dispatch_guard")(root, path)
|
||||
|
||||
|
||||
def review(root):
|
||||
proof = verify(root, "implementation")
|
||||
if proof["files"].get(str(ENTRY)) != deadline.sha(ENTRY):
|
||||
raise PermissionError("The recovery launcher must be included in the reviewed implementation")
|
||||
contract(root / "contract.json")
|
||||
return original_entry.validate_review(root)
|
||||
|
||||
|
||||
def main():
|
||||
namespace = dict(original_entry.main.__globals__, ROOT=ROOT, contract=contract,
|
||||
dispatch_guard=dispatch_guard, validate_review=review)
|
||||
return FunctionType(original_entry.main.__code__, namespace, "main")()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Reference in new issue
Block a user