|
|
@@ -1671,6 +1671,49 @@ def main():
|
|
|
check(wait_task_done(auth, offline_task, timeout=60) is not None,
|
|
|
"requeued task completes again on the healthy daemon")
|
|
|
|
|
|
+
|
|
|
+ print("== R5 B1: /start parent context ==")
|
|
|
+ # A fresh subtask dispatch carries the parent object (plan clamped).
|
|
|
+ conn = db()
|
|
|
+ conn.execute("update tasks set plan = ? where id = ?",
|
|
|
+ ("# Parent plan\n\n" + "step. " * 1200, auto_parent))
|
|
|
+ conn.commit()
|
|
|
+ conn.close()
|
|
|
+ act(auth, slot_public(auth, "/tasks", "tasks")["create"], {
|
|
|
+ "project_id": "1",
|
|
|
+ "title": "Lineage subtask",
|
|
|
+ "priority": "3",
|
|
|
+ })
|
|
|
+ lineage_task = int([t["id"] for t in slot_public(auth, "/tasks", "tasks")["tasks"]
|
|
|
+ if t["title"] == "Lineage subtask"][0])
|
|
|
+ conn = db()
|
|
|
+ conn.execute("update tasks set parent_task_id = ?, description = 'torque to spec'"
|
|
|
+ " where id = ?", (auto_parent, lineage_task))
|
|
|
+ conn.commit()
|
|
|
+ conn.close()
|
|
|
+ check(wait_for(lambda: any(int(p.get("task", {}).get("id") or 0) == lineage_task
|
|
|
+ for p in fake.start_payloads) or False,
|
|
|
+ timeout=60, what="lineage subtask dispatches") is not None,
|
|
|
+ "lineage subtask dispatches")
|
|
|
+ lineage_push = [p for p in fake.start_payloads
|
|
|
+ if int(p.get("task", {}).get("id") or 0) == lineage_task][-1]
|
|
|
+ parent_obj = lineage_push.get("parent")
|
|
|
+ check(parent_obj is not None
|
|
|
+ and int(parent_obj.get("id") or 0) == auto_parent
|
|
|
+ and parent_obj.get("title") == "Auto parent"
|
|
|
+ and parent_obj.get("status") in ("suspended", "working", "done"),
|
|
|
+ "subtask /start carries the parent object")
|
|
|
+ check(parent_obj.get("description") == "torque to spec"
|
|
|
+ or "Parent plan" in (parent_obj.get("plan") or ""),
|
|
|
+ "parent description/plan content flows through")
|
|
|
+ check(len(parent_obj.get("plan") or "") <= 4000,
|
|
|
+ "parent plan clamped to ~4000 chars (%d)"
|
|
|
+ % len(parent_obj.get("plan") or ""))
|
|
|
+ root_pushes = [p for p in fake.start_payloads
|
|
|
+ if int(p.get("task", {}).get("id") or 0) == offline_task]
|
|
|
+ check(all("parent" not in p for p in root_pushes),
|
|
|
+ "root task /start carries no parent object")
|
|
|
+
|
|
|
finally:
|
|
|
# Exit-code diagnostic: distinguishes a crashed app (negative
|
|
|
# returncode, e.g. -11 SIGSEGV) from a clean shutdown. When
|