Watching your workflows

Queues

From docs/queues.md at commit 548821a.

Spinto 0.1.0. These docs follow the main branch. Spinto isn't on crates.io yet, so you install it from a clone.

Introduction

spinto::queues::Queues reads what the queue runtime already keeps and returns spinto.v1 records (src/contracts/queues.rs, mirrored in resources/js/contracts/queues.ts). It only reads, and Spinto stores nothing about queues:

use spinto::contracts::queues::FailedJobFilters;
use spinto::queues::Queues;

let queues = Queues::new();

let depths = queues.depths().await;
let failed = queues.failed_jobs(&FailedJobFilters::default()).await?;
let batch = queues.batch("01a2351e-104c-7291-903b-66490fac79ed").await?;
Record Read from
QueueDepth QueueManager::sizes(connection, queue)
FailedJobs The table config.queue.failed names, failed_jobs by default
BatchSummary, BatchDetail The tables config.queue.batches names, job_batches and job_batch_jobs by default, and laravel::queue::find_batch
QueueCapabilities All of the above, plus the environment Laravel Cloud and OpenTelemetry read

Every record carries provenance. Its store is the config.queue entry it came from, such as queue.connections.database, queue.failed or queue.batches. Its source is runtimeApi for sizes and queueStore for table rows.

Queue Depth

depths() asks each connection in config.queue.connections about its own queue. The runtime can’t list every queue in use, so depth(connection, queue) counts any other queue by name.

Each QueueDepth has pending, delayed and reserved counts, the oldestPendingAt time, its age in oldestPendingAgeMs, and an accuracy. Spinto shows 0 only when the driver counted zero. A value the driver didn’t report is a Known absence with a reason:

Driver Counts Oldest pending job
database exact yes, or none when nothing is pending
redis exact yes, or none when nothing is pending
sqs, cloud approximate, from SQS’s ApproximateNumberOf… attributes unsupported: SQS doesn’t say
sync, discard unsupported: these drivers keep no jobs unsupported
A custom driver that returns None unsupported unsupported
A driver that fails or takes longer than 3 seconds unknown, with the redacted error unknown

The sync and discard connections answer sizes with zeros the runtime makes up, so Spinto never shows those zeros. A driver whose Cargo feature isn’t compiled, such as redis without the redis feature, fails, so its counts are unknown.

Failed Jobs

failed_jobs(&filters) lists the failed job table’s rows, newest first, 25 to a page and at most 100. Filter by connection and queue, and pass the previous page’s nextCursor as cursor. total counts up to 10,000 matching rows and is unknown beyond that.

Each FailedJob has:

  • id, the row’s ID, and jobId, the ID that queue:failed, queue:retry and queue:forget use.
  • name, the payload’s display_name, or job when there is no display name. Like a batch’s name, a worker’s host and queues, and every job name the job history shows, it goes through the payload policy’s value patterns, so a credential in it reads [redacted].
  • error, through the reader’s redaction (see Security): the first line, the redacted message, and its pointers.
  • payload, the job’s payload redacted the way a run’s input is. SPINTO_PAYLOADS=hidden hides it.
  • contextKeys, the names of the dispatching context’s logged values. Their values are removed, as they are for runs, and a name that looks like a credential reads [redacted N], as a payload key does.
  • batchId, when the job belonged to a batch. It matches a member’s jobId in that batch.

When config.queue.failed is FailedJobs::Discard, the page is unsupported: the application keeps no failed jobs.

Hidden Context

laravel::context::add_hidden values travel in each job’s payload in clear text, under hidden_context. Spinto removes every hidden_context key, at any depth, before redaction, so neither the names nor the values appear in a page, a fixture or an MCP result. tests/queues_derive.rs and tests/queues_postgres.rs check this against a real payload.

Laravel Cloud’s Failed Jobs

Jobs that fail on the cloud connection are kept by Laravel Cloud, never in the failed job table. When the application has a cloud connection, FailedJobs.cloud links to Laravel Cloud, and filtering by that connection returns an unsupported page that says so instead of an empty list.

Batches

batches(&filters) lists job_batches newest first. Batch IDs are UUIDv7, so the cursor is the last ID shown. batch(id) reads one batch and its members from job_batch_jobs, up to 1,000. membersByStatus counts every member.

A batch’s state is cancelled when cancelledAt is set, finished when finishedAt is set, and inProgress otherwise. pendingJobs counts the jobs still to run, so a finished batch has none. The runtime’s own pending_jobs counts a failed job until a retry of it succeeds; Spinto subtracts failedJobs from it. processedJobs counts the jobs that succeeded or were skipped, so totalJobs is processedJobs + pendingJobs + failedJobs. A batch finishes when every job that hasn’t failed has succeeded. A batch dispatched without allow_failures() is cancelled at its first failure.

Evidence Checks

BatchDetail.evidence holds two checks, in the same style as a run’s:

Check Pass when
runtime-agreement laravel::queue::find_batch returns the same name (compared as Spinto shows it, after the value patterns), counts, and created, cancelled and finished times as the row. Its pending count is pendingJobs + failedJobs
members-agreement There is one member row per job, pendingJobs equals the pending members, and failedJobs equals the failed members

A worker can settle a member between two reads, so Spinto reads an unfinished batch once more before it reports a failed check. A batch with more than 1,000 members adds a member-limit check marked blocked.

Commands

Spinto is read-only. Each record lists the Artisan-style commands that apply as disabled actions, with the command in cliEquivalent:

Command Shown
queue:retry <job ID> On each failed job
queue:forget <job ID> On each failed job
queue:retry all, queue:flush On the failed job list, when the application keeps failed jobs
queue:retry <Laravel Cloud failed jobs URL> On the failed job list, when the application has a cloud connection
queue:retry-batch <batch ID> On a batch with failed jobs that isn’t cancelled. The runtime refuses to retry a cancelled batch
queue:prune-batches --hours=24 On a finished batch
queue:prune-batches --cancelled=24 On a cancelled batch

Capabilities

Capabilities.queues, which Reader::capabilities() and get_runtime_capabilities return, says what this deployment can show. Each entry that isn’t supported says why:

Field Meaning
sizes Each connection’s driver and its accuracy, read the same way as Queue Depth
failedJobs The failed job table and its schema check, or unsupported for FailedJobs::Discard
cloudFailedJobs The Laravel Cloud link when there is a cloud connection
batches The batch tables and their schema check
jobHistory Whether Spinto’s spinto_observations table exists. No driver keeps a job after it succeeds, so job history needs Spinto’s observer
tracing The OpenTelemetry endpoint variable that configures a trace exporter, from OTEL_EXPORTER_OTLP_TRACES_ENDPOINT or OTEL_EXPORTER_OTLP_ENDPOINT, unless OTEL_SDK_DISABLED=true or OTEL_TRACES_EXPORTER=none. Spinto can’t see whether the application was compiled with the opentelemetry feature
platform laravelCloud when LARAVEL_CLOUD=1 is set or a cloud connection exists, which is what Laravel Cloud’s managed queues add, and selfHosted otherwise. signals lists what was seen

MCP Tools

The queue tools are read-only and redact exactly as the pages do. They read what the application keeps. The Laravel Cloud MCP server covers what Laravel Cloud manages, such as managed-queue failed jobs, pausing and clearing queues, and logs.

Tool Reads
list_queues Every connection’s own queue with its counts. queues adds others as connection:queue, such as database:emails
list_failed_jobs Failed jobs, filtered by connection and queue, paged by cursor and limit. Payloads are left out unless payloads is true
inspect_batch One batch by batch_id, with its members, commands and evidence checks

Configuration

Variable Default Meaning
SPINTO_CLOUD_URL https://cloud.laravel.com Your environment’s page in Laravel Cloud, so links open there instead of on the dashboard’s home page. Must start with https://, or the boot stops

Spinto reads the queue connections, the failed job table and the batch tables from config.queue, so no other setting is needed.

Tests and Fixtures

tests/queues_derive.rs tests the pure functions in src/queues/derive.rs. tests/queues_postgres.rs runs the example’s demo:batch command on PostgreSQL with a real queue:work. Before the worker starts, in the middle of the batch, and after it, the test compares every record with the raw rows, with queue:failed and with find_batch, and then reads the same records over MCP:

cargo build
SPINTO_QUEUES_DATABASE_URL=postgres://127.0.0.1/spinto_queues_test \
    cargo test --test queues_postgres -- --ignored --nocapture

The test drops every table in that database. With SPINTO_WRITE_FIXTURES=1, it rewrites tests/fixtures/queues.*.json and tests/fixtures/capabilities.json, which tests/queues_fixtures.rs round-trips. The fixtures prove presentation only, never runtime compatibility.