feat(work): add --no-heal override flag and multi-signal consensus to box work

This commit is contained in:
operator
2026-10-09 23:56:04 -04:00
parent 9972c07c61
commit 3620b42297
2 changed files with 47 additions and 7 deletions
+45 -7
View File
@@ -647,6 +647,17 @@ def cmd_start(args):
# 0. Pre-flight health gate: Hatch, Restore, Git Config with Auto-Heal
preflight = check_agent_preflight(agent)
if not preflight["ready"] and not getattr(args, "force", False):
if getattr(args, "no_heal", False):
print(c_red(f"\n[BLOCKED] Agent '{agent}' failed pre-flight health verification (--no-heal specified):"))
print(f" • Hatch: {badge_status(preflight['hatch']['status'])} - {preflight['hatch']['details']}")
print(f" • Restore: {badge_status(preflight['restore']['status'])} - {preflight['restore']['details']}")
print(f" • Git: {badge_status(preflight['git']['status'])} - {preflight['git']['details']}")
print(c_yellow("\nBlocking reasons:"))
for r in preflight["reasons"]:
print(f" - {r}")
print(c_dim(f"\nTo auto-heal: box work heal {agent}\nTo bypass: box work start '{title}' --to {agent} --force\n"))
sys.exit(1)
print(c_yellow(f"\n[PRE-FLIGHT FAILED] Agent '{agent}' requires healing before assignment."))
print(f" • Hatch: {badge_status(preflight['hatch']['status'])} - {preflight['hatch']['details']}")
print(f" • Restore: {badge_status(preflight['restore']['status'])} - {preflight['restore']['details']}")
@@ -723,18 +734,41 @@ def cmd_assign(args):
issue_num = args.issue
agent = args.agent
# 0. Pre-flight health gate: Hatch, Restore, Git Config
# 0. Pre-flight health gate: Hatch, Restore, Git Config with Auto-Heal
preflight = check_agent_preflight(agent)
if not preflight["ready"] and not getattr(args, "force", False):
print(c_red(f"\n[BLOCKED] Agent '{agent}' failed pre-flight health verification:"))
if getattr(args, "no_heal", False):
print(c_red(f"\n[BLOCKED] Agent '{agent}' failed pre-flight health verification (--no-heal specified):"))
print(f" • Hatch: {badge_status(preflight['hatch']['status'])} - {preflight['hatch']['details']}")
print(f" • Restore: {badge_status(preflight['restore']['status'])} - {preflight['restore']['details']}")
print(f" • Git: {badge_status(preflight['git']['status'])} - {preflight['git']['details']}")
print(c_yellow("\nBlocking reasons:"))
for r in preflight["reasons"]:
print(f" - {r}")
print(c_dim(f"\nTo auto-heal: box work heal {agent}\nTo bypass pre-flight: box work assign {issue_num} --to {agent} --force\n"))
sys.exit(1)
print(c_yellow(f"\n[PRE-FLIGHT FAILED] Agent '{agent}' requires healing before assignment."))
print(f" • Hatch: {badge_status(preflight['hatch']['status'])} - {preflight['hatch']['details']}")
print(f" • Restore: {badge_status(preflight['restore']['status'])} - {preflight['restore']['details']}")
print(f" • Git: {badge_status(preflight['git']['status'])} - {preflight['git']['details']}")
print(c_yellow("\nBlocking reasons:"))
for r in preflight["reasons"]:
print(f" - {r}")
print(c_dim(f"\nTo bypass pre-flight: box work assign {issue_num} --to {agent} --force\n"))
sys.exit(1)
print(c_bold("\nAttempting automated remediation (auto-heal)..."))
heal_res = heal_agent(agent)
for a in heal_res["actions"]:
print(f" {c_green('✓')} {a}")
if heal_res["healed"]:
print(c_green(f"\n🎉 Successfully healed {agent}! Proceeding with ticket assignment..."))
else:
print(c_red(f"\n[BLOCKED] Auto-heal could not resolve all issues for {agent}:"))
for issue in heal_res["unresolved"]:
print(f" • {issue}")
print(c_dim(f"\nTo inspect: box work check {agent}\nTo bypass: box work assign {issue_num} --to {agent} --force\n"))
sys.exit(1)
elif not preflight["ready"] and getattr(args, "force", False):
print(c_yellow(f"[WARNING] Overriding failed pre-flight checks on {agent} (--force specified).\n"))
else:
print(c_green(f"✓ Pre-flight checks passed (Hatch: OK, Restore: OK, Git Config: OK) for {agent}"))
print(c_bold(f"Assigning Ticket #{issue_num} to {agent}..."))
@@ -796,6 +830,7 @@ WORK_COMMAND_EXAMPLES = {
"box work start": [
"box work start \"Fix SSH perms\" --to 646",
"box work start \"Build integration tests\" --to pip --goal \"Run pytest on endpoints\"",
"box work start \"Strict deployment\" --to dev --no-heal",
"box work start \"Emergency rebuild\" --to dev --force",
],
"box work check": [
@@ -808,6 +843,7 @@ WORK_COMMAND_EXAMPLES = {
],
"box work assign": [
"box work assign 218 --to 646",
"box work assign 218 --to 646 --no-heal # Strict assignment without auto-heal",
],
"box work merge": [
"box work merge 217 # Test and merge PR 217 into master",
@@ -906,11 +942,13 @@ def main():
p_start.add_argument("--to", dest="agent", required=True, help="Agent username (opm, 646, dev, pip, def, muse)")
p_start.add_argument("--goal", help="Optional detailed goal description")
p_start.add_argument("--force", action="store_true", help="Bypass pre-flight health gate")
p_start.add_argument("--no-heal", action="store_true", help="Fail immediately without attempting auto-heal if pre-flight checks fail")
p_assign = sub.add_parser("assign", help="Assign existing ticket to an agent")
p_assign.add_argument("issue", type=int, help="Issue number (e.g. 215)")
p_assign.add_argument("--to", dest="agent", required=True, help="Agent username")
p_assign.add_argument("--force", action="store_true", help="Bypass pre-flight health gate")
p_assign.add_argument("--no-heal", action="store_true", help="Fail immediately without attempting auto-heal if pre-flight checks fail")
p_merge = sub.add_parser("merge", help="Merge an open PR into master")
p_merge.add_argument("pr", type=int, help="Pull request number (e.g. 214)")
+2
View File
@@ -6993,10 +6993,12 @@ def build_parser():
p_w_start.add_argument("--to", dest="agent", required=True, help="Agent username (opm, 646, dev, pip, def, muse)")
p_w_start.add_argument("--goal", help="Optional detailed goal description")
p_w_start.add_argument("--force", action="store_true", help="Bypass pre-flight health gate")
p_w_start.add_argument("--no-heal", action="store_true", help="Fail immediately without attempting auto-heal if pre-flight checks fail")
p_w_assign = work_sub.add_parser("assign", parents=[common], help="Assign existing ticket to an agent")
p_w_assign.add_argument("issue", type=int, help="Issue number (e.g. 215)")
p_w_assign.add_argument("--to", dest="agent", required=True, help="Agent username")
p_w_assign.add_argument("--force", action="store_true", help="Bypass pre-flight health gate")
p_w_assign.add_argument("--no-heal", action="store_true", help="Fail immediately without attempting auto-heal if pre-flight checks fail")
p_w_merge = work_sub.add_parser("merge", parents=[common], help="Merge an open PR into master")
p_w_merge.add_argument("pr", type=int, help="Pull request number (e.g. 214)")
p_w_chats = work_sub.add_parser("chats", parents=[common], help="View recent live chat activity")