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.

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)

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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

matrx_scheduler-0.3.62.tar.gz (71.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

matrx_scheduler-0.3.62-py3-none-any.whl (57.9 kB view details)

Uploaded Python 3

File details

Details for the file matrx_scheduler-0.3.62.tar.gz.

File metadata

  • Download URL: matrx_scheduler-0.3.62.tar.gz
  • Upload date:
  • Size: 71.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for matrx_scheduler-0.3.62.tar.gz
Algorithm Hash digest
SHA256 21d8fafaa850a9d73a348999833c322fda79e1b93c91b3cc3711cbc16606e6aa
MD5 7e54f9c22157d0bec2ba28c0016b36af
BLAKE2b-256 31b7188a8e367719c154211fead9cc33d9b02c5125e4ebf23009394801e89933

See more details on using hashes here.

Provenance

The following attestation bundles were made for matrx_scheduler-0.3.62.tar.gz:

Publisher: publish-package.yml on AI-Matrix-Engine/aidream

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file matrx_scheduler-0.3.62-py3-none-any.whl.

File metadata

File hashes

Hashes for matrx_scheduler-0.3.62-py3-none-any.whl
Algorithm Hash digest
SHA256 76edffc780e9ab9497b0e7f88137fa5872a20d1ad3d9102cb1158f1cf9a5de3d
MD5 91ae060f154d1d6525a0bbc1729da20f
BLAKE2b-256 69c9dffa2e0c4834bffb7fa8c1d20665d9198ae38c70349be786ee789af1dd61

See more details on using hashes here.

Provenance

The following attestation bundles were made for matrx_scheduler-0.3.62-py3-none-any.whl:

Publisher: publish-package.yml on AI-Matrix-Engine/aidream

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.3.74

2 files

0.3.73

2 files

0.3.72

2 files

0.3.71

2 files

0.3.70

2 files

0.3.69

2 files

0.3.68

2 files

0.3.67

2 files

0.3.66

2 files

0.3.65

2 files

0.3.64

2 files

0.3.63

2 files

This release

0.3.62 This release

2 files

0.3.61

2 files

0.3.60

2 files

0.3.59

2 files

0.3.58

2 files

0.3.57

2 files

0.3.56

2 files

0.3.55

2 files

0.3.54

2 files

0.3.53

2 files

0.3.52

2 files

0.3.51

2 files

0.3.50

2 files

0.3.49

2 files

0.3.48

2 files

0.3.47

2 files

0.3.46

2 files

0.3.45

2 files

0.3.44

2 files

0.3.43

2 files

0.3.42

2 files

0.3.41

2 files

0.3.40

2 files

0.3.39

2 files

0.3.38

2 files

0.3.37

2 files

0.3.36

2 files

0.3.35

2 files

0.3.34

2 files

0.3.33

2 files

0.3.32

2 files

0.3.31

2 files

0.3.30

2 files

0.3.29

2 files

0.3.28

2 files

0.3.27

2 files

0.3.26

2 files

0.3.25

2 files

0.3.24

2 files

0.3.23

2 files

0.3.22

2 files

0.3.21

2 files

0.3.20

2 files

0.3.19

2 files

0.3.18

2 files

0.3.17

2 files

0.3.16

2 files

0.3.15

2 files

0.3.14

2 files

0.3.13

2 files

0.3.12

2 files

0.3.11

2 files

0.3.10

2 files

0.3.9

2 files

0.3.8

2 files

0.3.7

2 files

0.3.6

2 files

0.3.5

2 files

0.3.4

2 files

0.3.3

2 files

0.3.2

2 files

0.3.1

2 files

0.3.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page