prefect server in zig

fix scheduler idempotency test race condition

root cause: test was observing partial scheduler tick. each flow run
insertion commits separately, so test could see 25 runs mid-tick and
then 50 when tick completed - appearing as a failure.

fix: wait for count to stabilize before recording baseline, ensuring
we measure after the scheduler tick completes rather than during it.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

+12 -2
+12 -2
scripts/test-api-sequence
··· 1018 1018 deployment_id = deployment.get("id") 1019 1019 log(f" deployment: {deployment_id}") 1020 1020 1021 - # poll for scheduler to create first run (instead of fixed sleep) 1022 - log("[bold]waiting for scheduler to create runs...[/bold]") 1021 + # poll for scheduler to create runs and wait for tick to complete 1022 + # we need to wait for count to stabilize, not just see the first run 1023 + log("[bold]waiting for scheduler tick to complete...[/bold]") 1023 1024 count_after_first = wait_for_runs(deployment_id, min_count=1) 1025 + # wait for count to stabilize (scheduler tick may still be inserting) 1026 + for _ in range(10): 1027 + time_mod.sleep(0.2) 1028 + resp = client.post("/flow_runs/filter", json={"limit": 100}) 1029 + if resp.status_code == 200: 1030 + matching = [r for r in resp.json() if r.get("deployment_id") == deployment_id] 1031 + if len(matching) == count_after_first: 1032 + break # count stable 1033 + count_after_first = len(matching) 1024 1034 log(f" runs after first tick: {count_after_first}") 1025 1035 1026 1036 if count_after_first == 0: