Audience: Small businesses, freelancers, accountants, operations managers
The problem
Chasing overdue invoices is operational drag that slips through the cracks — especially when your "alert system" is a manual spreadsheet filter or a forgotten reminder. Building a reliable automated alert in raw Python or a LangGraph agent means recurring orchestration cost plus fragile control flow.
The AINL solution
examples/autonomous_ops/invoice_aging.lang is a production-style AINL workflow that runs daily, queries the database, and alerts on overdue exposure:
# invoice_aging.lang (core pattern)
D InvoiceRec (id: str, due_date: int, status: str, amount: float)
S main
X d30 (core.mul 30 86400)
X cutoff (core.sub (core.now) d30)
R db F "Invoice" ->invoices
Filter invoices where (core.and
(core.ne invoice.status "paid")
(core.lt invoice.due_date cutoff)
) ->overdue
X count (core.len overdue)
X total_amount (core.sum (map overdue (lambda i i.amount)))
If (core.eq count 0) ->L_ok ->L_alert
L_alert:
R email G "Invoice Aging Alert" (core.join [
"Overdue invoices: " (core.stringify count)
" totalling $" (core.stringify total_amount)
])
Ret "alerted"
L_ok:
Ret "ok"
Why compile it
- No model tokens at runtime — the logic is deterministic; whether to alert is decided by the data, not re-prompted each day
- Typed data model —
D InvoiceRecenforces schema at compile time, not at 2 AM when the job runs - Auditable — every run produces a JSONL trace; finance teams can replay exactly what was queried and what was sent
- Composable —
includearetryorslack_notifymodule without rewriting the core logic
Extend it
Add a 60-day escalation tier, a Slack channel alert, or a weekly summary report — just add nodes to the graph and re-compile. The rest stays untouched.
pip install ainativelang
git clone https://github.com/sbhooley/ainativelang.git
ainl check examples/autonomous_ops/invoice_aging.lang --strict
