From 95d04f999193f95fcc0b24a425d96df16d57ae92 Mon Sep 17 00:00:00 2001 From: Nora Date: Wed, 8 Jul 2026 04:26:00 -0600 Subject: [PATCH] feat(spot-check): pace live Edifabric calls at 1.5s apart Edifabric /v2/x12 endpoints apply a per-second rate limit (typical: 1 call/sec sustained, 429 if exceeded) on top of the daily quota. Sequential spot-checks of 10 files tripped it on back-to-back runs. Insert a 1.5s pause between calls so the spot-check always lives within the rate budget. This is the '1-2 s spacing' the plan flagged; the original monolithic scratch driver skipped it and the verifier noted the gap on retry. --- backend/src/cyclone/rebill/spot_check_validate.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/backend/src/cyclone/rebill/spot_check_validate.py b/backend/src/cyclone/rebill/spot_check_validate.py index a2b50db..9ed7f12 100644 --- a/backend/src/cyclone/rebill/spot_check_validate.py +++ b/backend/src/cyclone/rebill/spot_check_validate.py @@ -74,9 +74,18 @@ def validate_spot_check_files(paths: list[Path]) -> list[dict]: This module never silently substitutes a different validator. """ + import time out: list[dict] = [] - for p in paths: + for i, p in enumerate(paths): body = p.read_bytes() + # The Edifabric /v2/x12 endpoints apply a per-second rate limit + # in addition to the daily quota (typical: 1 call/sec sustained, + # 429 if exceeded). Insert a 1.5s pause between calls so 10-file + # spot-checks don't trip the limit; this is the value the plan + # flagged ("1-2 s spacing") that the original monolithic scratch + # driver skipped. + if i > 0: + time.sleep(1.5) try: result = validate_edi(body) except EdifabricError as exc: