Prepare inactive task-only finalization timeout adapter
This commit is contained in:
+30
@@ -0,0 +1,30 @@
|
||||
"""UNAPPLIED owner-side proposal; no activation or automatic authorization."""
|
||||
import json
|
||||
|
||||
def install(Runner):
|
||||
previous = Runner.process
|
||||
def process(self, task_id, role, service, argv, cwd, *args, **kwargs):
|
||||
target = (self.config["project"] == "the-tree-p22-02-contract"
|
||||
and task_id == "P22-02" and role == "implementer" and service == "codex")
|
||||
if target:
|
||||
task = self.task(task_id)
|
||||
contract = json.loads(task["contract"])
|
||||
if not (task["state"] == "implementing" and task["repairs"] == 3
|
||||
and contract["max_repair_attempts"] == 3
|
||||
and contract["base_commit"] == "10c62e1fa7b71576598583f434824b59816d4705"
|
||||
and contract["spec_sha256"] == "f252de3c5cff7ebfa62322ae2f2df09fb80a44bc59eb286b76d4acb4c12ca875"):
|
||||
raise ValueError("Exact owner-authorized finalization context required")
|
||||
row = self.db.execute("SELECT data FROM events WHERE task_id=? AND event='owner_authorized_p22_finalization' ORDER BY id DESC LIMIT 1", (task_id,)).fetchone()
|
||||
approval = json.loads(row[0]) if row else {}
|
||||
if not (approval.get("direct_human_reply") and approval.get("cap") == 3
|
||||
and approval.get("retained_used") == 2
|
||||
and approval.get("effective_implementer_timeout_seconds") == 1800):
|
||||
raise ValueError("No recorded direct human permission for timeout change")
|
||||
if self.config["policy"]["timeout_seconds"] != 900 or kwargs.get("timeout") not in (None, 900):
|
||||
raise ValueError("Unexpected original timeout context")
|
||||
kwargs["timeout"] = 1800
|
||||
self.event(task_id, "owner_scoped_finalization_timeout", {"role": role,
|
||||
"service": service, "argv": argv, "cwd": str(cwd), "effective_timeout_seconds": 1800,
|
||||
"project_policy_timeout_unchanged": 900, "repairs": 3, "global_policy_changed": False})
|
||||
return previous(self, task_id, role, service, argv, cwd, *args, **kwargs)
|
||||
Runner.process = process
|
||||
Reference in New Issue
Block a user