feat(system): stderr routing migration Phase 3 — 10 branches migrated (FPLAN-0033)

Migrated error()/warning() calls across 10 branches to use CLI display API
which routes to stderr. 48 files modified across ai_mail, api, backup, daemon,
flow, memory, prax, seedgo, spawn, trigger. Seedgo stderr_routing standard
created (24th standard) with full-file scanning. System average 49% → 69%.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
AIOSAI
2026-03-14 00:41:38 -07:00
co-authored by Claude Opus 4.6
parent 154e92d13e
commit 97952124b5
48 changed files with 666 additions and 226 deletions
+4 -4
View File
@@ -34,7 +34,7 @@ from aipass.prax import logger
from aipass.flow.apps.handlers.json import json_handler
# CLI services for display and error handling
from aipass.cli.apps.modules import console
from aipass.cli.apps.modules import console, error, warning
# Internal: Registry handlers
from aipass.flow.apps.handlers.registry.load_registry import load_registry
@@ -90,7 +90,7 @@ def _display_messages(messages: List[Dict[str, Any]]):
console.print(format_plan_error(error_text, plan_num, details=details))
elif msg_type == "warning":
console.print(f"[yellow]{msg['text']}[/yellow]")
warning(msg['text'])
elif msg_type == "dim":
console.print(f"[dim]{msg['text']}[/dim]")
@@ -102,7 +102,7 @@ def _display_messages(messages: List[Dict[str, Any]]):
console.print(f"[green]{msg['text']}[/green]")
elif msg_type == "error_text":
console.print(f"[red]{msg['text']}[/red]")
error(msg['text'])
elif msg_type == "header":
console.print(format_plan_deletion_header(msg["plan_key"], msg["plan_info"]))
@@ -119,7 +119,7 @@ def _display_messages(messages: List[Dict[str, Any]]):
console.print(f" * FPLAN-{plan['plan_num']}: {plan['subject']}")
elif msg_type == "confirm_warning":
console.print(f"\n[bold red]WARNING: This will close all {msg['count']} plans![/bold red]")
error(f"WARNING: This will close all {msg['count']} plans!")
elif msg_type == "closing_all":
console.print(f"\n[bold]Closing all {msg['count']} plan(s)...[/bold]")
+2 -2
View File
@@ -44,7 +44,7 @@ from aipass.prax.apps.modules.logger import system_logger as logger
from aipass.flow.apps.handlers.json import json_handler
# CLI services for display
from aipass.cli.apps.modules import console
from aipass.cli.apps.modules import console, warning
# Registry handlers (cross-domain - OK for modules)
from aipass.flow.apps.handlers.registry.load_registry import load_registry
@@ -195,7 +195,7 @@ def create_plan(
if msg_type == "dim":
console.print(f"[dim]{msg['text']}[/dim]")
elif msg_type == "warning":
console.print(f"[yellow]{msg['text']}[/yellow]")
warning(msg['text'])
elif msg_type == "display":
console.print(msg["text"])
return ok, num, loc, tmpl, error
+5 -5
View File
@@ -20,7 +20,7 @@ from typing import List
# Infrastructure imports (module does the logging)
from aipass.prax.apps.modules.logger import system_logger as logger
from aipass.cli.apps.modules import console, header, success, error
from aipass.cli.apps.modules import console, header, success, error, warning
# Handler imports (local handlers in handlers/dplan/)
from aipass.flow.apps.handlers.dplan.create import create_plan
@@ -458,7 +458,7 @@ def _handle_close(args: List[str]) -> bool:
console.print(f"[dim] Memory Bank archival running in background[/dim]")
except Exception as e:
logger.warning(f"[dev_flow] Failed to spawn background processing: {e}")
console.print(f"[yellow] Background archival failed to start - will retry on next close[/yellow]")
warning("Background archival failed to start - will retry on next close")
# Step 3/3: Done
console.print(f"[dim][3/3][/dim] Finalizing...")
@@ -476,7 +476,7 @@ def _handle_close_all() -> bool:
open_plans = get_open_plans()
if not open_plans:
console.print("\n[yellow]No open plans to close[/yellow]\n")
warning("No open plans to close")
return True
console.print(f"\n[bold yellow]Found {len(open_plans)} open plan(s) to close:[/bold yellow]")
@@ -511,7 +511,7 @@ def _handle_close_all() -> bool:
else:
failure_count += 1
logger.warning(f"[dev_flow] Failed to close DPLAN-{p['number']:03d}: {err}")
console.print(f"[red] Failed: {err}[/red]")
error(f" Failed: {err}")
# Push dashboard
try:
@@ -530,7 +530,7 @@ def _handle_close_all() -> bool:
console.print(f"\n[dim]Background processing started for {success_count} plan(s)[/dim]")
except Exception as e:
logger.warning(f"[dev_flow] Failed to spawn background processing: {e}")
console.print(f"\n[yellow]Background processing failed to start[/yellow]")
warning("Background processing failed to start")
console.print("\n" + "=" * 60)
console.print("[bold green]CLOSE ALL COMPLETE[/bold green]")
@@ -25,7 +25,7 @@ from pathlib import Path
FLOW_ROOT = Path(__file__).resolve().parents[2]
# External: CLI console (Rich display) and Prax logger
from aipass.cli.apps.modules import console
from aipass.cli.apps.modules import console, error, warning
from aipass.prax.apps.modules.logger import system_logger as logger
MODULE_NAME = "dplan_post_close_runner"
@@ -58,7 +58,7 @@ def handle_command(command: str, args: list) -> bool:
# Run the post-close processing directly (foreground)
if not _acquire_lock():
console.print("[yellow]Another instance is already running[/yellow]")
warning("Another instance is already running")
return True
try:
@@ -66,7 +66,7 @@ def handle_command(command: str, args: list) -> bool:
console.print(f"[green]Processing complete:[/green] {result.get('processed', 0)} processed, {result.get('errors', 0)} errors")
except Exception as e:
logger.error(f"[{MODULE_NAME}] Background processing failed: {e}")
console.print(f"[red]Processing failed: {e}[/red]")
error(f"Processing failed: {e}")
finally:
_release_lock()
+4 -4
View File
@@ -43,7 +43,7 @@ from aipass.prax.apps.modules.logger import system_logger as logger
from aipass.flow.apps.handlers.json import json_handler
# CLI services for display
from aipass.cli.apps.modules import console
from aipass.cli.apps.modules import console, error, warning
# Registry handlers
from aipass.flow.apps.handlers.registry.load_registry import load_registry
@@ -149,13 +149,13 @@ def list_plans(filter_type: str = "open") -> bool:
# Module handles display
if result.get("empty") and result.get("success"):
console.print("[yellow]No plans found in registry[/yellow]")
warning("No plans found in registry")
return True
if not result.get("success"):
error_msg = result.get("error", "Unknown error")
try:
console.print(f"[red]ERROR: {error_msg}[/red]")
error(f"ERROR: {error_msg}")
except BrokenPipeError:
pass
return False
@@ -204,7 +204,7 @@ def handle_command(command: str, args: List[str]) -> bool:
if filter_arg in ["open", "closed", "all"]:
filter_type = filter_arg
else:
console.print(f"[yellow]Unknown filter '{filter_arg}', defaulting to 'open'[/yellow]")
warning(f"Unknown filter '{filter_arg}', defaulting to 'open'")
console.print("[dim]Valid filters: open, closed, all[/dim]")
# STEP 2: Execute workflow
@@ -28,7 +28,7 @@ _PKG_ROOT = Path(__file__).resolve().parents[3] # file.py → modules/ → apps
FLOW_ROOT = _PKG_ROOT / "flow"
# External: CLI console (Rich display) and Prax logger
from aipass.cli.apps.modules import console
from aipass.cli.apps.modules import console, error, warning
from aipass.prax.apps.modules.logger import system_logger as logger
MODULE_NAME = "post_close_runner"
@@ -63,7 +63,7 @@ def handle_command(command: str, args: list) -> bool:
# Run the post-close processing directly (foreground)
if not _acquire_lock():
console.print("[yellow]Another instance is already running[/yellow]")
warning("Another instance is already running")
return True
try:
@@ -71,7 +71,7 @@ def handle_command(command: str, args: list) -> bool:
console.print("[green]Processing complete[/green]")
except Exception as e:
logger.error(f"[{MODULE_NAME}] Background processing failed: {e}")
console.print(f"[red]Processing failed: {e}[/red]")
error(f"Processing failed: {e}")
finally:
_release_lock()
@@ -53,7 +53,7 @@ from aipass.prax.apps.modules.logger import system_logger as logger
from aipass.flow.apps.handlers.json import json_handler
# CLI services for display
from aipass.cli.apps.modules import console
from aipass.cli.apps.modules import console, error, warning
# Registry handlers
from aipass.flow.apps.handlers.registry.load_registry import load_registry
@@ -115,11 +115,11 @@ def start_monitoring():
# Module handles display
status = result.get("status", "")
if status == "already_running":
console.print("[yellow]Monitor is already running[/yellow]")
warning("Monitor is already running")
elif status == "started":
console.print(f"[green]OK[/green] {result['message']}")
elif status == "error":
console.print(f"[red]{result['message']}[/red]")
error(result['message'])
return result.get("success", False)
@@ -135,7 +135,7 @@ def stop_monitoring():
if status == "stopped":
console.print("[green]OK[/green] Monitor stopped")
elif status == "not_running":
console.print("[yellow]Monitor is not running[/yellow]")
warning("Monitor is not running")
return result.get("success", False)
@@ -252,7 +252,7 @@ def handle_command(command: str, args: List[str]) -> bool:
return True
else:
console.print(f"[red]Unknown subcommand: {subcommand}[/red]")
error(f"Unknown subcommand: {subcommand}")
console.print()
console.print("Available commands:")
console.print(" • scan - One-time scan and heal registry")
+2 -2
View File
@@ -33,7 +33,7 @@ from aipass.prax.apps.modules.logger import system_logger as logger
from aipass.flow.apps.handlers.json import json_handler
# CLI services for display and error handling
from aipass.cli.apps.modules import console
from aipass.cli.apps.modules import console, warning
# Internal: Registry handlers
from aipass.flow.apps.handlers.registry.load_registry import load_registry
@@ -84,7 +84,7 @@ def _display_messages(messages: List[Dict[str, Any]]):
console.print(format_restore_error(error_type, plan_key, details=details))
elif msg_type == "warning":
console.print(f"[yellow]{msg['text']}[/yellow]")
warning(msg['text'])
elif msg_type == "dim":
console.print(f"[dim]{msg['text']}[/dim]")