Skip to content

Commit f5458ee

Browse files
committed
fix(verify): make status idempotent to stop the sync loop
cmd_status rewrote generated_at every run, so verify-status always committed a new status.json, which re-dispatched techapi-updated and re-ran itself (~every 3 min). Preserve the prior timestamp when the verification numbers are unchanged so the file stays byte-identical and nothing is committed. Refs #1
1 parent fac7c86 commit f5458ee

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

app/verify/cli.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,12 +296,27 @@ def cmd_status(args: argparse.Namespace) -> int:
296296
},
297297
"by_category": by_category,
298298
}
299+
out = args.output or (VERIFY_DIR / "status.json")
300+
# Idempotence: only `generated_at` changes between runs when the verification
301+
# numbers are unchanged. Preserve the previous timestamp so the file stays
302+
# byte-identical — otherwise every run rewrites it, commits, and (via the
303+
# techapi-updated dispatch) re-triggers verify-status in an endless loop.
304+
if not args.stdout and out.exists():
305+
try:
306+
prev = json.loads(out.read_text(encoding="utf-8"))
307+
unchanged = {k: v for k, v in status.items() if k != "generated_at"} == {
308+
k: v for k, v in prev.items() if k != "generated_at"
309+
}
310+
if unchanged and isinstance(prev.get("generated_at"), str):
311+
status["generated_at"] = prev["generated_at"]
312+
except (OSError, ValueError):
313+
pass
314+
299315
blob = json.dumps(status, indent=2, ensure_ascii=False) + "\n"
300316

301317
if args.stdout:
302318
print(blob, end="")
303319
else:
304-
out = args.output or (VERIFY_DIR / "status.json")
305320
ensure_verify_dirs()
306321
out.write_text(blob, encoding="utf-8")
307322
print(f"wrote verification status: {out} "

0 commit comments

Comments
 (0)