Skip to content

Schedulers and enablement

Toolora starts its in-process schedulers from the FastAPI lifespan in backend/server.py and stops them during shutdown. Registration establishes which work this API process can schedule. It does not prove a job has completed, a tenant is eligible or an external action succeeded.

TOOLORA_DISABLE_SCHEDULERS skips these scheduler starts. Runtime heartbeat writes have a separate TOOLORA_DISABLE_RUNTIME_HEARTBEATS control. A declared app state of running is not evidence that every optional component started. Each module also applies its own configuration and existing-instance guard.

Scheduler family Declared work/cadence Additional gate
Fortnox Outbox/pull, sweeps, backfills, walks, projections and reconciliation below Configured integration; FORTNOX_SCHEDULER_DISABLED can opt out
Purchase invoices Legacy mail 60 s; AP/payroll outboxes 30 s; payment feed 60 s; optional cost review 60 s Legacy intake defaults enabled unless explicitly disabled; connector workers need connector URL/token; cost review needs the pilot tenant
Unified mail intake One tick every 300 s, covering bounded sync/original-copy/interpretation work Explicit MAIL_INTAKE_SCHEDULER_ENABLED; binding policy and feature flags still apply
Imports Schedule scan every 30 s IMPORTS_SCHEDULER_DISABLED; individual enabled/due import schedules determine actual work
Customer notifications Durable notification outbox every 15 s CUSTOMER_NOTIFICATIONS_SCHEDULER_DISABLED; recipient/sender/operation policy still applies
Planning AI Recommendation reconciliation every 600 s PLANNING_AI_SCHEDULER_DISABLED; the tick evaluates current feature/configuration eligibility

The purchase and unified-mail paths coexist under guarded rollout settings. A communications-only mailbox does not acquire document intake simply because the mail scheduler runs. Check the binding and feature configuration before claiming that a specific document should have been interpreted.

These jobs are registered by the configured Fortnox scheduler. Times are UTC, not Swedish wall time; daylight-saving changes alter their local presentation. The scheduled functions still select eligible companies and resource work.

Job ID Declared cadence
fortnox_outbox Every 30 seconds
fortnox_pull Every 5 seconds
fortnox_lastmodified_sweep Every 300 seconds
fortnox_invoice_payments Every 300 seconds
fortnox_open_ar_backstop Daily 00:30 UTC
fortnox_backfill_tick Every 60 seconds
fortnox_partition_maintenance Daily 00:05 UTC
fortnox_partition_audit Daily 03:30 UTC
fortnox_walk_invoices Daily 01:30 UTC
fortnox_walk_customers Daily 02:00 UTC
fortnox_walk_suppliers Daily 02:30 UTC
fortnox_walk_vouchers Daily 02:45 UTC
fortnox_walk_supplier_invoices Sunday 01:00 UTC
fortnox_walk_accounts Sunday 03:00 UTC
fortnox_walk_cost_centers Sunday 04:00 UTC
fortnox_parties_sync Daily 05:00 UTC
fortnox_supplier_invoice_gold Daily 05:30 UTC
fortnox_reconciliation Daily 03:00 UTC

A registered backfill tick can do no work when no active backfill exists. Daily list walks, incremental sweeps, local projections and bookkeeping pushes retain different source/receipt meanings. Registration is not permission to test a real Fortnox write. Accounting owns the active adapter/connector split and test-company boundary.

APScheduler’s reviewed defaults coalesce missed runs and use one instance per job within the scheduler. Misfire windows and thread pools differ by family. Those process-local controls do not coordinate multiple API processes. Durable work uses its own database claim, lease, lock or version predicate where implemented; those mechanisms are owned by the worker/RPC, not by APScheduler.

Selected required workers record successful completed ticks in WorkerProgress. A lock-skipped tick or repeated exception must not advance success merely because the scheduler is alive. Readiness compares expected components and current-instance heartbeats; it is not a receipt for every pending invoice or source generation. Stalled-work diagnosis explains the distinction.

For a synthetic pending document, first check global/component/binding enablement, then whether the appropriate tick completed and its durable job progressed. Do not start another scheduler instance to overcome a source or daily-budget refusal. Scheduler/progress tests use isolated process state and substituted workers. The PR records executions and makes no claim to have observed every deployed flag, cron run or provider result.