Files
aios/scripts/smoke_branch_repair_lease.py

54 lines
1.5 KiB
Python

#!/usr/bin/env python3
"""Minimal local smoke for the lease state machine."""
from __future__ import annotations
import tempfile
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
from branch_repair_lease import TASK_ID, LeaseStore, RepairLeaseManager
class Probe:
def __init__(self) -> None:
self.head = "a" * 40
self.parents: dict[str, str] = {}
self.paths: dict[str, tuple[str, ...]] = {}
def branch_head(self, branch: str) -> str:
return self.head
def parent(self, commit: str) -> str:
return self.parents[commit]
def is_ancestor(self, older: str, newer: str) -> bool:
return older == self.parents.get(newer)
def changed_paths(self, commit: str) -> tuple[str, ...]:
return self.paths[commit]
def commits_between(self, older: str, newer: str) -> tuple[str, ...]:
return (newer,)
def main() -> int:
with tempfile.TemporaryDirectory() as root:
probe = Probe()
manager = RepairLeaseManager(LeaseStore(Path(root) / "leases"), probe)
lease = manager.issue(
task_id=TASK_ID,
owner_identity="smoke-owner",
branch="fix/smoke",
description="smoke",
allowed_paths=("active-runtime/app/example.py",),
)
manager.attach_existing_branch(lease.lease_id, owner_identity="smoke-owner", expected_head_oid=probe.head)
print("GOVERNED_BRANCH_REPAIR_LEASE_SMOKE=PASS")
return 0
if __name__ == "__main__":
raise SystemExit(main())