The agentic + event-driven layer of County OS. Everything here is auditable and human-in-the-loop where it touches decisions.
POST /api/automations (header x-automation-secret), or the dashboard "Run now" action (runAutomationsNow). Implemented in web/src/lib/automations/run.ts. Jobs:
overdue_permit flag.closing_opportunity flag.expiring_contract flag.scanAllFeeds() (below).web/src/lib/feeds/ingest.ts -> scanAllFeeds(). For each active feed it fits a least-squares trend, projects forward, and if the value is forecast to cross (or has crossed) the feed's threshold it raises a deduplicated feed_forecast flag (severity action if already breached, watch if forecast). Feeds are fed by CSV upload (console) or the live ingest API.
POST /api/cron/synthetic (header x-automation-secret). Pings the resident portal, public + spending portals, and the Open311 services endpoint; records up/down + latency to synthetic_checks; raises a synthetic_down flag (severity action) on any 5xx. Surfaced on the dashboard Platform health panel.
web/src/lib/procurement/evaluate-bids.ts. Claude Haiku scores each bid on a solicitation against budget, peer bids, and supplier diversity, writes a one-sentence rationale, and auto-shortlists the top two. A procurement officer reviews before any award; the AI never awards.
automation_runs - one row per job per run (scanned, flagged, summary).automation_flags - open/resolved flags with kind, severity, entity, message. Resolved from the dashboard panel (resolveFlag).Point any scheduler at the endpoints with the secret header:
/api/cron/self-heal): existing data-integrity sweepThe agentic LLM work uses Claude Haiku (fast, low cost). All AI calls fail safe: if ANTHROPIC_API_KEY is unset, the feature degrades to a no-op rather than erroring.