Files
PaperClipAI/scripts/ci/pi-intel/lifecycle.py
T
DottaandPaperclip 2f90cb31ae ci(runner): retain Intel pack and stop on uncertain cleanup
Archive and verify the complete tested pack before startup checks. Make cleanup uncertainty sticky across test cases, retain scratch after interrupted launches, and enforce the reviewed 16 GiB seven-day artifact storage bound without truncation.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-10-01 16:21:11 -05:00

41 lines
1.3 KiB
Python

"""Sticky launch/cleanup gate shared by execution and the narrow regressions."""
class CleanupUncertain(RuntimeError):
pass
class Lifecycle:
def __init__(self):
self.pending = False
self.uncertain = False
@property
def safe(self):
return not self.pending and not self.uncertain
def begin(self):
if not self.safe:
raise CleanupUncertain('Previous launch/cleanup is unresolved; no next command')
# Set before Popen: an interrupted launch may have no trustworthy handle.
self.pending = True
def failed(self):
self.uncertain = True
def confirmed(self):
if self.uncertain:
raise CleanupUncertain('An earlier cleanup failure cannot be cleared')
self.pending = False
def run_test_cases(cases, run, lifecycle):
failures = []
for label, command in cases:
if not lifecycle.safe:
raise CleanupUncertain('Unresolved owner prohibits subsequent test launch')
try:
run(command, label)
except RuntimeError as error:
failures.append(str(error))
if not lifecycle.safe:
raise CleanupUncertain('Test cleanup uncertain; stopping without another test') from error
return failures