From 56c38a04ce05515bacc2d36a4abbf845cc876105 Mon Sep 17 00:00:00 2001 From: "Brent E. Edwards" Date: Fri, 20 Feb 2026 21:46:46 +0000 Subject: [PATCH] fix(ci): remove stale AutomationLevel refs from benchmarks and prevent ANSI in JSON output - Remove AutomationLevel imports from cli_robot_flow_bench.py and persistence_robot_bench.py (enum was removed by master's automation refactor); replace with AutomationProfileRef where needed. - Use typer.echo() instead of console.print() for machine-readable output (JSON/YAML/plain) in config.py and session.py to prevent Rich from injecting ANSI escape codes that corrupt json.loads(). - Set NO_COLOR=1 in noxfile unit_tests, integration_tests, and coverage_report sessions as a belt-and-suspenders safeguard for all CLI commands that route format_output through Rich. --- benchmarks/cli_robot_flow_bench.py | 3 --- benchmarks/persistence_robot_bench.py | 8 ++++++-- noxfile.py | 5 +++++ src/cleveragents/cli/commands/config.py | 6 +++--- src/cleveragents/cli/commands/session.py | 6 +++--- 5 files changed, 17 insertions(+), 11 deletions(-) diff --git a/benchmarks/cli_robot_flow_bench.py b/benchmarks/cli_robot_flow_bench.py index 415e6f437..32cd84f19 100644 --- a/benchmarks/cli_robot_flow_bench.py +++ b/benchmarks/cli_robot_flow_bench.py @@ -26,7 +26,6 @@ try: InMemoryChangeSetStore, ) from cleveragents.domain.models.core.plan import ( - AutomationLevel, AutomationProfileProvenance, AutomationProfileRef, NamespacedName, @@ -48,7 +47,6 @@ except ModuleNotFoundError: InMemoryChangeSetStore, ) from cleveragents.domain.models.core.plan import ( - AutomationLevel, AutomationProfileProvenance, AutomationProfileRef, NamespacedName, @@ -107,7 +105,6 @@ def _mock_plan( action_name="local/bench-lifecycle-action", phase=phase, processing_state=state, - automation_level=AutomationLevel.MANUAL, project_links=[ProjectLink(project_name="proj-bench")], arguments={"target_coverage": 80}, arguments_order=["target_coverage"], diff --git a/benchmarks/persistence_robot_bench.py b/benchmarks/persistence_robot_bench.py index f56cac196..44a03a641 100644 --- a/benchmarks/persistence_robot_bench.py +++ b/benchmarks/persistence_robot_bench.py @@ -22,7 +22,8 @@ from cleveragents.domain.models.core.action import ( ArgumentType, ) from cleveragents.domain.models.core.plan import ( - AutomationLevel, + AutomationProfileProvenance, + AutomationProfileRef, NamespacedName, Plan, PlanIdentity, @@ -90,7 +91,10 @@ def _make_bench_plan( description="Robot bench plan", phase=PlanPhase.ACTION, processing_state=ProcessingState.QUEUED, - automation_level=AutomationLevel.MANUAL, + automation_profile=AutomationProfileRef( + profile_name="trusted", + provenance=AutomationProfileProvenance.PLAN, + ), strategy_actor="local/strat", execution_actor="local/exec", project_links=[ProjectLink(project_name="local/proj-bench")], diff --git a/noxfile.py b/noxfile.py index 093fd0e24..ae470a070 100644 --- a/noxfile.py +++ b/noxfile.py @@ -359,6 +359,9 @@ def unit_tests(session: nox.Session): ] session.env["PYTHONPATH"] = str(Path("src").resolve()) + # Prevent Rich from injecting ANSI escape codes into machine-readable + # CLI output (JSON/YAML) which causes json.loads() failures on CI. + session.env["NO_COLOR"] = "1" session.run(*args) @@ -399,6 +402,7 @@ def integration_tests(session: nox.Session): """ session.install("-e", ".[tests]") session.env["CLEVERAGENTS_AUTO_APPLY_MIGRATIONS"] = "true" + session.env["NO_COLOR"] = "1" # Override PYTHONPATH so the editable install (src/) for this project # is used instead of any inherited PYTHONPATH from the outer environment. session.env["PYTHONPATH"] = "src" @@ -496,6 +500,7 @@ def coverage_report(session: nox.Session): os.makedirs("build", exist_ok=True) session.env["PYTHONPATH"] = str(Path("src").resolve()) + session.env["NO_COLOR"] = "1" session.env["COVERAGE_RCFILE"] = "pyproject.toml" session.env["COVERAGE_FILE"] = "build/.coverage" # Tell behave-parallel workers to run under coverage --parallel-mode diff --git a/src/cleveragents/cli/commands/config.py b/src/cleveragents/cli/commands/config.py index 5df44b17f..3e33c8f6f 100644 --- a/src/cleveragents/cli/commands/config.py +++ b/src/cleveragents/cli/commands/config.py @@ -259,7 +259,7 @@ def config_set( } if fmt != OutputFormat.RICH.value: - console.print(format_output(result, fmt)) + typer.echo(format_output(result, fmt)) return prev_display = str(previous) if previous is not None else "(unset)" @@ -313,7 +313,7 @@ def config_get( for entry in result["resolution_chain"]: if hasattr(entry.get("value"), "__fspath__"): entry["value"] = str(entry["value"]) - console.print(format_output(result, fmt)) + typer.echo(format_output(result, fmt)) return console.print( @@ -428,7 +428,7 @@ def config_list( for entry in settings_list: if hasattr(entry["value"], "__fspath__"): entry["value"] = str(entry["value"]) - console.print(format_output(settings_list, fmt)) + typer.echo(format_output(settings_list, fmt)) return table = Table(title=f"Configuration ({len(settings_list)} settings)") diff --git a/src/cleveragents/cli/commands/session.py b/src/cleveragents/cli/commands/session.py index 1799ccc1c..cf478c5d7 100644 --- a/src/cleveragents/cli/commands/session.py +++ b/src/cleveragents/cli/commands/session.py @@ -142,7 +142,7 @@ def create( data = _session_summary_dict(session) if fmt != OutputFormat.RICH.value: - console.print(format_output(dict(data), fmt)) + typer.echo(format_output(dict(data), fmt)) return details = ( @@ -186,7 +186,7 @@ def list_sessions( data = _session_list_dict(sessions) if fmt != OutputFormat.RICH.value: - console.print(format_output(data, fmt)) + typer.echo(format_output(data, fmt)) return # Rich table @@ -240,7 +240,7 @@ def show( data = session.as_cli_dict() if fmt != OutputFormat.RICH.value: - console.print(format_output(dict(data), fmt)) + typer.echo(format_output(dict(data), fmt)) return # Session summary panel