by Ta-Tech Solutions All documents

Automation & Triggers

The agentic + event-driven layer of County OS. Everything here is auditable and human-in-the-loop where it touches decisions.

Scheduled automations runner

POST /api/automations (header x-automation-secret), or the dashboard "Run now" action (runAutomationsNow). Implemented in web/src/lib/automations/run.ts. Jobs:

  1. Overdue permits - permits open past the 14-day SLA -> overdue_permit flag.
  2. Closing opportunities - opportunities with a deadline within 7 days -> closing_opportunity flag.
  3. Expiring contracts - contracts expiring within 30 days (or marked expiring) -> expiring_contract flag.
  4. Janitor (safe cleanup) - auto-closes past-deadline opportunities; flags duplicate vendors for human merge. The only mutation automation performs, and it is non-destructive.
  5. Feed forecasts - runs scanAllFeeds() (below).

Predictive feed forecasting

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.

Synthetic monitor

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.

AI bid evaluation (agentic, human-in-the-loop)

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.

Audit + resolution

Cron wiring

Point any scheduler at the endpoints with the secret header:

Cost

The 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.

PreviousAgency Module Matrix
CivicLoop - Ta-Tech Solutions - Architecture & Design Documentation