From c82dbc5654b4b358df1a4fb5c3dc23bb41c37354 Mon Sep 17 00:00:00 2001 From: Marius Mutu Date: Tue, 21 Apr 2026 07:05:37 +0000 Subject: [PATCH] feat(anaf): emit GSTACK-CRON marker and exit 0 on successful run The Echo-Core scheduler's report_on='changes' contract parses ^GSTACK-CRON: changes=\d+$ from stdout to decide whether to forward the run's output to a channel. monitor_v2.py now prints that marker as its final stdout line with num_changes from the current run. Also switches the success return value from len(all_changes) to 0. Previously, any run that detected changes (N>0) exited with a non-zero status, which the scheduler treats as an error (always forwarded, ignoring report_on). Exit code now signals only fatal errors; the marker carries the change count. --- tools/anaf-monitor/monitor_v2.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tools/anaf-monitor/monitor_v2.py b/tools/anaf-monitor/monitor_v2.py index 6d5742a..4d87c22 100644 --- a/tools/anaf-monitor/monitor_v2.py +++ b/tools/anaf-monitor/monitor_v2.py @@ -364,9 +364,16 @@ def main(): update_dashboard_status(len(all_changes) > 0, len(all_changes), all_changes) log("=== Monitor complete ===") - + + num_changes = len(all_changes) print(json.dumps({"changes": all_changes}, ensure_ascii=False, indent=2)) - return len(all_changes) + # GSTACK-CRON marker: contract with Echo-Core scheduler (report_on="changes"). + # The shell-kind scheduler parses the last line matching + # ^GSTACK-CRON: changes=\d+$ to decide whether to forward stdout. + # A successful run (even with N>0 changes) must exit 0 — the scheduler + # reports non-zero exit codes as errors unconditionally. + print(f"GSTACK-CRON: changes={num_changes}") + return 0 if __name__ == "__main__": exit(main())