From dd3c260ff2e1a86e63dad1cdb03a9fd011a5b364 Mon Sep 17 00:00:00 2001 From: yaojingang Date: Tue, 16 Jun 2026 03:37:05 +0800 Subject: [PATCH] Share telemetry aggregate protection across report flows --- scripts/yao.py | 4 ++-- scripts/yao_cli_report_commands.py | 20 +------------------- scripts/yao_cli_runtime.py | 19 +++++++++++++++++++ 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/scripts/yao.py b/scripts/yao.py index 26b28fa..0113d5d 100644 --- a/scripts/yao.py +++ b/scripts/yao.py @@ -61,7 +61,7 @@ from yao_cli_report_commands import ( command_world_class_submission_kit, command_world_class_submission_review, ) -from yao_cli_runtime import ROOT, run_script +from yao_cli_runtime import ROOT, run_adoption_drift_if_source_exists, run_script from yao_cli_telemetry import add_telemetry_args, maybe_record_cli_event @@ -428,7 +428,7 @@ def command_workspace_flow(args: argparse.Namespace) -> int: {"phase": "report-refresh", "result": run_script("python_compat_check.py", [str(ROOT)])}, {"phase": "report-refresh", "result": run_script("render_architecture_maintainability.py", [str(ROOT)])}, {"phase": "report-refresh", "result": run_script("compile_skill.py", [str(ROOT)])}, - {"phase": "report-refresh", "result": run_script("render_adoption_drift_report.py", [str(ROOT)])}, + {"phase": "report-refresh", "result": run_adoption_drift_if_source_exists()}, {"phase": "report-refresh", "result": run_script("render_telemetry_hook_recipes.py", [str(ROOT)])}, {"phase": "report-refresh", "result": run_script("render_review_waivers.py", [str(ROOT)])}, {"phase": "report-refresh", "result": run_script("render_review_annotations.py", [str(ROOT)])}, diff --git a/scripts/yao_cli_report_commands.py b/scripts/yao_cli_report_commands.py index 41211b4..d7b8ed0 100644 --- a/scripts/yao_cli_report_commands.py +++ b/scripts/yao_cli_report_commands.py @@ -5,7 +5,7 @@ import json from pathlib import Path from yao_cli_config import baseline_compare_args, local_output_runner_command -from yao_cli_runtime import ROOT, run_script +from yao_cli_runtime import ROOT, run_adoption_drift_if_source_exists, run_script SCRIPT_INTERFACE = "internal-module" @@ -32,24 +32,6 @@ def append_outputs(cmd: list[str], args: argparse.Namespace, *, markdown: bool = cmd.extend(["--generated-at", args.generated_at]) -def run_adoption_drift_if_source_exists() -> dict: - events_path = ROOT / "reports" / "telemetry_events.jsonl" - if events_path.exists(): - return run_script("render_adoption_drift_report.py", [str(ROOT)]) - return { - "command": "render_adoption_drift_report.py skipped: missing reports/telemetry_events.jsonl", - "returncode": 0, - "ok": True, - "stdout": "", - "stderr": "", - "payload": { - "ok": True, - "skipped": True, - "reason": "raw telemetry event logs are local-only; keeping committed adoption_drift_report artifacts", - }, - } - - def render_skill_report_command(args: argparse.Namespace, script_name: str, *, markdown: bool = True, generated_at: bool = False) -> int: cmd = [resolved_skill_dir(args)] append_outputs(cmd, args, markdown=markdown, generated_at=generated_at) diff --git a/scripts/yao_cli_runtime.py b/scripts/yao_cli_runtime.py index 6dfc6bc..e7da843 100644 --- a/scripts/yao_cli_runtime.py +++ b/scripts/yao_cli_runtime.py @@ -43,3 +43,22 @@ def run_script(name: str, args: list[str], cwd: Path | None = None) -> dict: "stderr": proc.stderr, "payload": payload, } + + +def run_adoption_drift_if_source_exists(skill_dir: Path | None = None) -> dict: + target = (skill_dir or ROOT).resolve() + events_path = target / "reports" / "telemetry_events.jsonl" + if events_path.exists(): + return run_script("render_adoption_drift_report.py", [str(target)]) + return { + "command": "render_adoption_drift_report.py skipped: missing reports/telemetry_events.jsonl", + "returncode": 0, + "ok": True, + "stdout": "", + "stderr": "", + "payload": { + "ok": True, + "skipped": True, + "reason": "raw telemetry event logs are local-only; keeping committed adoption_drift_report artifacts", + }, + }