nenu-lang / cron-runnables
PartialCron Runnables
- The Cron node metadata owns the schedule; the source owns the work.
- A Cron file is executable Nenu, not a cron declaration block.
- Cron source can be authored and validated, but App Marché does not execute Cron nodes yet.
Schedule Outside, Logic Inside
A Cron node stores its schedule in App Marché metadata. Its .cron.nenu source contains only executable Nenu statements. There is no cron keyword or source wrapper.
| Cron metadata | Cron source |
|---|---|
| Schedule | Reads and queries |
| Node identity | Conditions and loops |
| Execution trigger | Writes, logs, cache, or failures |
Scheduled Room Summary
This scheduled job rebuilds a cached total from durable open expenses. It needs no invented clock or request input: the schedule triggers it, and the entities provide the data.
crons/rebuild-room-summary.cron.nenu
1need expenses = Expense[]({2 status == ExpenseStatus.Open3}) | limit(200)45number total = 067loop expenses as expense {8 total = total + expense.amount9}1011cache.set("room-open-expense-total", total)12log("Finished room expense summary rebuild")Designing Repeatable Jobs
- Query a bounded batch with deterministic filters and ordering when order matters.
- Make each run safe when no matching records exist.
- Use a transaction when several writes must commit together.
- Log a non-empty literal event name and, when useful, one payload expression.
- Let invalid required reads or explicit
throwend the run as failures.
Common Mistakes
| Wrong | Correct |
|---|---|
cron "0 0 * * *" { ... } | Set the schedule in Cron metadata. |
runnable Cleanup { ... } | Write statements directly. |
Use request without a contract | Use only values supplied by the active runnable context. |
Call standalone now() | Use the built-in namespace form time.now(). |
