Quarterly bid eligibility refresh
Bid eligibility lives in the spec data. If a spec's kosher certificate expired, or its USDA K-12 attestation is missing, or its last_updated is older than 180 days, a bid response that includes it can be disqualified on review. This workflow catches those before they cost us.
It runs quarterly because spec currency typically rolls over on a quarterly+ cadence. Tighter would be noisy; looser would miss windows.
Risk level 2 (low). Output is staged proposals — no writes to NS, no customer-facing changes.
Trigger conditions
- Quarterly cron on the first of Jan / Apr / Jul / Oct at 09:00 ET.
- Manual re-run from /admin-dashboard.html when a bid is imminent and we want fresh eligibility.
- After a USDA program change that retired or added cert requirements.
- Pre-bid prep for a major bid (B5875 cycle, etc.).
Stale criterion: updated_at < 180 days OR (kosher = Y AND kosher_certificate IS NULL). This catches both passive staleness and active cert misses.
The 2 beats
-
01
Stage propose_spec_update per stale spec
For each row in
stale_specs, aproposed_actionsrow stages withaction_type=propose_spec_update. The proposal includes which fields need refresh and which cert is missing. -
02
Notify Nutrition Admin
A draft email to the nutrition admin lists the stale specs and which need vendor follow-up vs internal action.
What's different after the workflow runs
- Each stale spec has a
propose_spec_updaterow in Mike's queue. - Nutrition admin has a roll-up email.
workflow_runsrecords the quarter's pass.- reflexion_log carries a
bid_eligibility_refreshtagged row.
What can go wrong and how to recover
A clean quarter. The summary email still sends so the nutrition admin sees the all-clear.
External cert validation (kosher cert lookup) occasionally fails. The workflow stages those specs with severity=warn instead of confirming pass/fail.
Email still drafts; Mike can re-route or hold. No SLA on individual stale specs unless a bid is pending.
Adjacent workflows + diagrams
Code paths + invariants
| Concern | Where |
|---|---|
| Workflow contract | workflow_definitions WHERE workflow_type='quarterly_bid_eligibility_refresh' |
| Cron | 0 9 1 */3 * America/New_York |
| Stale criterion | updated_at < 180d OR (kosher='Y' AND kosher_certificate IS NULL) |
| Owner | Nutrition Admin |
| Reflexion tag | bid_eligibility_refresh |
| Risk level | 2 |
| Expected duration | ~90 min |
| Trigger | cron · 0 9 1 */3 * (America/New_York) |