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.
This commit is contained in:
@@ -365,8 +365,15 @@ def main():
|
|||||||
|
|
||||||
log("=== Monitor complete ===")
|
log("=== Monitor complete ===")
|
||||||
|
|
||||||
|
num_changes = len(all_changes)
|
||||||
print(json.dumps({"changes": all_changes}, ensure_ascii=False, indent=2))
|
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__":
|
if __name__ == "__main__":
|
||||||
exit(main())
|
exit(main())
|
||||||
|
|||||||
Reference in New Issue
Block a user