Skip to main content

matrx-scheduler

Server-side execution engine for the matrx scheduling spine (sch_* tables in Supabase). Provides:

  • a scanner loop that claims due tasks atomically,
  • a runner that drives the host's agent_runner / tool_runner,
  • an authoritative cron parser + next-due computation,
  • and (since 0.3) an HTTP API surface (FastAPI) for task / trigger / run CRUD, manual fires, scanner status, and cron preview.

Any host application (aidream is the reference) wires it up via configure() and either runs the scanner directly, mounts the HTTP routes, or both.

What it does (under the hood)

  • Polls sch_task for rows where next_due_at <= now() and the host surface is in surfaces[] (or 'any').
  • Atomically claims a candidate by inserting a sch_run with claim_token and claim_expires_at (the lease).
  • Drives the matrx-ai agent runner (host-injected) against the claimed task, or the host's tool_runner for kind='tool'.
  • Writes back results (status, result_summary, output_ref, etc.).
  • Recomputes the next fire time on recurring triggers; the DB cascade updates sch_task.next_due_at automatically.

Capability-within, injection-without

matrx-scheduler doesn't import from a host app. It exposes a configure() function the host calls at startup, passing in:

  • supabase_client — service-role client used by the SCANNER to read sch_task across users and update lease state.
  • surface — the string this host identifies as in sch_task.surfaces[] (e.g. 'server' for aidream, 'desktop' for matrx-local).
  • agent_runner — callable that runs an agent (kind='agent' tasks).
  • tool_runner — optional callable for kind='tool' tasks. Hosts that don't claim tool tasks (e.g. aidream itself) leave this unset.
  • user_supabase_factory — optional callable (user_jwt) -> AsyncClient used by the HTTP routes to build per-request user-scoped clients. If not provided, the package falls back to an env-based factory keyed on SUPABASE_MATRIX_URL + SUPABASE_MATRIX_PUBLISHABLE_KEY.
  • get_app_context, emitter_factory, scan_interval_seconds, lease_seconds — see the _ext.configure docstring.

Install with the host extra (pip install matrx-scheduler[host]) when using it inside a full host app. Add the api extra (pip install matrx-scheduler[api]) to mount the HTTP routes.

HTTP API

Available since 0.3. Optional — drop the import if you only want the scanner.

from fastapi import FastAPI
import matrx_scheduler

app = FastAPI()

# Host startup wiring (any host).
matrx_scheduler.configure(
    supabase_client=service_role_client,
    surface="server",  # or "desktop", "extension", ...
    agent_runner=my_agent_runner,
    user_supabase_factory=my_user_client_factory,  # optional
)
await matrx_scheduler.start_scanner()

# Mount the HTTP routes.
matrx_scheduler.api.include_routers(app, prefix="/scheduler")

Endpoints

All routes use matrx_connect.AppContext via Depends(context_dep). Every write goes through a per-request Supabase client built from the caller's JWT; RLS is the only line of authority on row ownership. The service-role client (used by the scanner) is never accessible from these routes.

Cross-owner responses are expected authorization refusals. The defensive owner-mismatch diagnostic is logged at WARNING, not ERROR, so routine denied requests do not create production-failure telemetry families.

Method Path Purpose
POST /scheduler/tasks Create a task (optionally with agent_task + trigger)
GET /scheduler/tasks List tasks (filter by kind, enabled)
GET /scheduler/tasks/{id} Get task hydrated with agent_task, triggers, runs
PATCH /scheduler/tasks/{id} Patch task fields (title, enabled, tags, etc.)
DELETE /scheduler/tasks/{id} Soft-delete (set enabled=false)
POST /scheduler/tasks/{id}/run-now Enqueue a manual run via sch_enqueue_manual_run
GET /scheduler/triggers?task_id=... List triggers for a task
POST /scheduler/triggers Create a trigger on an existing task
PATCH /scheduler/triggers/{id} Patch a trigger (recomputes next_due_at if type/config changed)
DELETE /scheduler/triggers/{id} Hard-delete a trigger
GET /scheduler/runs?task_id=...&status=... List run history
GET /scheduler/runs/{id} Get one run
POST /scheduler/cron/validate Validate a cron expression + preview next N fires
POST /scheduler/cron/preview-fires Preview next-fire times for any trigger config
POST /scheduler/compute-next-due-at Compute the single next due_at for a trigger config
GET /scheduler/status Scanner health (admin only)

PATCH distinguishes an omitted nullable field from an explicit JSON null. Sending {"description": null} or {"expires_at": null} clears that field; omitting it leaves the stored value unchanged. This distinction is enforced with Pydantic's model_fields_set, never by dropping every None value.

Co-existence with aidream's /scheduling/*

aidream had a small router at /scheduling/* (cron validation, run-now, admin force-disable) before this surface existed. The package routes use /scheduler/* (singular) so they don't collide. aidream can mount both simultaneously, or migrate clients to the package routes opportunistically. matrx-local mounts only the package routes; it has no /scheduling/* routes to begin with.

See docs/SCHEDULING.md in the matrx-frontend repo for the full data-model spec, trigger taxonomy, and lifecycle.

Release files for matrx-scheduler 0.3.225

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for matrx-scheduler 0.3.225
File Size Uploaded
matrx_scheduler-0.3.225.tar.gz 106.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for matrx-scheduler 0.3.225
File Interpreter ABI Platform
matrx_scheduler-0.3.225-py3-none-any.whl Python 3 none any Details

Total release size: 187.3 kB

Release files / matrx_scheduler-0.3.225.tar.gz

Download URL matrx_scheduler-0.3.225.tar.gz
Size 106.1 kB
Tags Source
SHA-256 checksum
How to use checksums
74f595e1bf7798213f40cfe01c5d7eca2852203b0e002b27dab712ad6ff3d939
BLAKE2b-256 checksum
How to use checksums
45654e1f945d90eff291e12945b6104883db81af8fdb465afe19b2eeb5d04414
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 15, 2026.

Transparency log

Release files / matrx_scheduler-0.3.225-py3-none-any.whl

Download URL matrx_scheduler-0.3.225-py3-none-any.whl
Size 81.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dba0f7508482c8ba3cb1e830920b0004bee3e42167ae7d6f79a556d10634d45a
BLAKE2b-256 checksum
How to use checksums
b44f5403cfb9d7653e187e7df1fbf8ac2cf931420c55574a8ca869aeaaa26384
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 15, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.3.225 This release

2 release files

0.3.99

2 release files

0.3.98

2 release files

0.3.97

2 release files

0.3.96

2 release files

0.3.95

2 release files

0.3.94

2 release files

0.3.93

2 release files

0.3.92

2 release files

0.3.91

2 release files

0.3.90

2 release files

0.3.89

2 release files

0.3.88

2 release files

0.3.87

2 release files

0.3.86

2 release files

0.3.85

2 release files

0.3.84

2 release files

0.3.83

2 release files

0.3.82

2 release files

0.3.81

2 release files

0.3.80

2 release files

0.3.79

2 release files

0.3.78

2 release files

0.3.77

2 release files

0.3.76

2 release files

0.3.75

2 release files

0.3.74

2 release files

0.3.73

2 release files

0.3.72

2 release files

0.3.71

2 release files

0.3.70

2 release files

0.3.69

2 release files

0.3.68

2 release files

0.3.67

2 release files

0.3.66

2 release files

0.3.65

2 release files

0.3.64

2 release files

0.3.63

2 release files

0.3.62

2 release files

0.3.61

2 release files

0.3.60

2 release files

0.3.59

2 release files

0.3.58

2 release files

0.3.57

2 release files

0.3.56

2 release files

0.3.55

2 release files

0.3.54

2 release files

0.3.53

2 release files

0.3.52

2 release files

0.3.51

2 release files

0.3.50

2 release files

0.3.49

2 release files

0.3.48

2 release files

0.3.47

2 release files

0.3.46

2 release files

0.3.45

2 release files

0.3.44

2 release files

0.3.43

2 release files

0.3.42

2 release files

0.3.41

2 release files

0.3.40

2 release files

0.3.39

2 release files

0.3.38

2 release files

0.3.37

2 release files

0.3.36

2 release files

0.3.35

2 release files

0.3.34

2 release files

0.3.33

2 release files

0.3.32

2 release files

0.3.31

2 release files

0.3.30

2 release files

0.3.29

2 release files

0.3.28

2 release files

0.3.27

2 release files

0.3.26

2 release files

0.3.25

2 release files

0.3.24

2 release files

0.3.23

2 release files

0.3.22

2 release files

0.3.21

2 release files

0.3.20

2 release files

0.3.19

2 release files

0.3.18

2 release files

0.3.17

2 release files

0.3.16

2 release files

0.3.15

2 release files

0.3.14

2 release files

0.3.13

2 release files

0.3.12

2 release files

0.3.11

2 release files

0.3.10

2 release files

0.3.9

2 release files

0.3.8

2 release files

0.3.7

2 release files

0.3.6

2 release files

0.3.5

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page