Type to search pages and rules.

Use with Agents

Jobs and Queues

Stack: anyConcern: application

Work that outlives a request runs in a Worker: scheduled jobs from a timetable and reports too heavy for a request, while people clear queued items through claimed listings. This page states how each kind records its work, runs it once, and recovers. A project selects it for recurring, delayed, heavy, or human-cleared work.

Markdown59 provisions
On this page

Activation#

Activation scope: local.

Applicable specification kinds: job, use-case, journey.

The consumer enables jobs for recurring, delayed, or calendar-based work. Each schedule lives on a job record with its kind, schedule, and run fields, as the automation page states. Selecting it replaces litespec/backend/architecture#declare-the-execution-host-for-work-that-outlives-a-request for scheduled work: a Worker runs the scheduler.

For human queues, a project selects jobs for a use case when the use case lists work items people claim or clears items in bulk. Ordinary reads and single-item commands do not select it.

For reports, a use case selects jobs for one documented query or export that the normal request path cannot serve: complex relational SQL, a large result, long processing, output in object storage, or a latency budget beyond a normal request. The use case page carries the measurements that prove the normal path falls short.

Baseline Relationship#

This extension replaces litespec/backend/architecture#declare-the-execution-host-for-work-that-outlives-a-request. The baseline lets a project declare either the WebApi process or a Worker project as the execution host for work that outlives a request. A project selecting jobs runs scheduled work in a Worker outside WebApi request handling, under litespec/ext/jobs#run-scheduled-jobs-in-worker.

The job, setting, and runbook records belong to the core. Schedules bound their retention with setting records and operators recover through runbook records. The request budget and each report bound live in setting records.

A listing query states its claim mode and its score, while a bulk money command states its preview and its confirmBy code. Ordinary queries stay under litespec/backend/persistence#query-through-the-read-session; the report provisions govern only the reads whose cost or duration exceeds that path.

Standards#

Carry the Schedule on the Job Record#

rulerequiredcheckable
litespec/ext/jobs#carry-the-schedule-on-the-job-record
Statement

A scheduled job MUST carry its schedule in structured form with its timezone on its job record.

Applies toartifact: job

Why

The job record states when the work runs: every or cron with its timezone, so tools read the rhythm instead of parsing prose. A schedule kept outside the record runs with no recorded moment attached, and misfire behavior has no stated time to measure against. The automation page states the record fields, and the schedule-invalid check reports a schedule no tool can read.

Checkchecked by a tool

Checked bylitespec model check reports schedule-invalid (level G) for a job schedule that is neither an every duration nor a cron expression; each scheduled job record states its timezone.

Marked checkable: the tool named here checks it.

Run One Command per Item in Selection#

rulerequiredguidance
litespec/ext/jobs#run-one-command-per-item-in-selection
Statement

A job MUST run one command per item in its selection within its batchSize, each in its own unit of work.

Applies toartifact: job

Why

The selection states what each run selects, the batch size bounds how many items one batch takes, and runs names the command run per item. Each item runs as one command in its own unit of work, as litespec/backend/application#issue-per-record-work-from-a-job requires: a failed item replays without replaying its batch.

Checka reviewer answers

Reviewed forWhich job handlers run more than one item in one unit of work, or ignore the batch size in their selection? Look at the job record selection and the handler code.

Marked guidance: a reviewer answers this question.

Resume Driven Work Through the Cursor#

rulerequiredguidance
litespec/ext/jobs#resume-driven-work-through-the-cursor
Statement

A job that works through items in batches MUST name where resume state lives in its cursor.

Applies toartifact: job

Why

A batch that fails halfway resumes instead of restarting: the cursor holds where the run stopped. Without it, the next run replays finished items or skips unfinished ones, and a scenario covering the remainder resumes has no stated position to assert.

Checka reviewer answers

Reviewed forWhich batch jobs name no resume position in their cursor, or have no scenario for the remainder after a halfway failure? Look at the job records and the scenario tests.

Marked guidance: a reviewer answers this question.

Run Manual Jobs Under Their Guard#

rulerequiredcheckable
litespec/ext/jobs#run-manual-jobs-under-their-guard
Statement

A manual job run MUST stay inside its runsWhere under its guard.

Applies toartifact: job

Why

Manual work is interactive platform work with no aggregate, such as a rehearsal harness, so no model bounds where it runs or who runs it. runsWhere names the deployment scope it may touch and the guard names who may run it and when. The automation page states the record fields, and the job-guard-missing check reports a manual job with no guard.

Checkchecked by a tool

Checked bylitespec model check reports job-guard-missing (level G) for a manual job with no guard; each manual run stays inside its runsWhere.

Marked checkable: the tool named here checks it.

Run Scheduled Jobs in Worker#

rulerequiredguidance
litespec/ext/jobs#run-scheduled-jobs-in-worker
Statement

A scheduled job MUST run in Worker outside WebApi request handling.

Applies toartifact: job

Why

Scheduled work runs in a Worker, outside WebApi request handling. The Worker owns the schedule's lifetime and shuts its replicas down in a controlled order. Request handling has neither a scheduler nor a shutdown order for background work.

Checka reviewer answers

Reviewed forWhich scheduled jobs sit outside the Worker sources, or in WebApi request handling? Look at the Worker project and the WebApi endpoints.

Marked guidance: a reviewer answers this question.

Observe Job Cancellation#

rulerequiredguidance
litespec/ext/jobs#observe-job-cancellation
Statement

A scheduled job MUST observe cancellation.

Applies toartifact: job

Why

Each job observes cancellation, so an occurrence ends its current step instead of running past the moment an operator asked it to stop.

Checka reviewer answers

Reviewed forWhich job handlers leave a wait without cancellation, or keep running their current step after cancellation fires? Look at the handler code and its cancellation tests.

Marked guidance: a reviewer answers this question.

Bound Job Duration#

rulerequiredguidance
litespec/ext/jobs#bound-job-duration
Statement

A scheduled job MUST complete within a bounded duration.

Applies toartifact: job

Why

Each job bounds its duration, so a Worker stops without stranding work it can no longer watch.

Checka reviewer answers

Reviewed forWhich job handlers carry no duration bound, or record completions outside it? Look at the handler code and the occurrence store.

Marked guidance: a reviewer answers this question.

Stop Jobs During Graceful Shutdown#

rulerequiredguidance
litespec/ext/jobs#stop-jobs-during-graceful-shutdown
Statement

A scheduled job MUST stop accepting new work during graceful shutdown.

Applies toartifact: job

Why

Each job stops accepting new work during graceful shutdown. An unbounded job turns every deploy into a wait for work that never ends.

Checka reviewer answers

Reviewed forWhich Worker shutdown paths drain running occurrences before they stop schedule polling? Look at the shutdown code in the Worker.

Marked guidance: a reviewer answers this question.

Store Execution Leases#

rulerequiredguidance
litespec/ext/jobs#store-execution-leases
Statement

A scheduled-job store MUST record lease owner, expiry, and fencing value in PostgreSQL.

Applies toartifact: job

Why

Each planned occurrence carries a lease with its owner, expiry, and fencing value in PostgreSQL. The lease names the one replica that may complete that occurrence. The lease field on the job record names the lock each run claims. The outbox extension cites this definition for its own claims.

Checka reviewer answers

Reviewed forWhich lease rows in PostgreSQL lack an owner, an expiry, or a fencing value? Look at the lease table schema.

Marked guidance: a reviewer answers this question.

Renew Only Owned Leases#

rulerequiredguidance
litespec/ext/jobs#renew-only-owned-leases
Statement

A Worker replica MUST renew only its active lease and stop when renewal fails.

Applies toartifact: job

Why

A replica renews only the lease it holds and only while it stays active. A failed renewal means another replica owns the occurrence now. The loser stops instead of completing work it no longer owns.

Checka reviewer answers

Reviewed forWhich replicas renew a lease after a failed renewal, or keep running an occurrence they lost? Look at the replica logs and the renewal tests.

Marked guidance: a reviewer answers this question.

Prevent Duplicate Completion#

rulerequiredguidance
litespec/ext/jobs#prevent-duplicate-completion
Statement

A scheduled-job lease MUST prevent two replicas from completing the same occurrence.

Applies toartifact: job

Why

Overlapping replicas must not complete the same occurrence twice. The lease admits one completion per occurrence. Two completions would bill, notify, or reconcile the same planned work twice.

Checka reviewer answers

Reviewed forWhich lease paths admit more than one completion per occurrence across overlapping replicas? Look at the lease claim code and its concurrency tests.

Marked guidance: a reviewer answers this question.

Generate Monotonic Fencing Values#

rulerequiredguidance
litespec/ext/jobs#generate-monotonic-fencing-values
Statement

A scheduled-job store MUST generate each fencing value monotonically per occurrence.

Applies toartifact: job

Why

Each fencing value rises monotonically per occurrence, so a later claim always presents a higher value than an earlier one. A Worker that lost its lease presents a stale value, and litespec/ext/jobs#restrict-completion-by-fencing-value refuses completion on a stale value.

Checka reviewer answers

Reviewed forWhich fencing values in the store fail to rise per occurrence, or let a stale value complete? Look at the store write path and its fencing tests.

Marked guidance: a reviewer answers this question.

Scope Occurrences and Leases by Tenant#

rulerequiredguidance
litespec/ext/jobs#scope-occurrences-and-leases-by-tenant
Statement

A scheduled-job occurrence and its lease MUST carry tenant scope when the product isolates tenants.

Applies toartifact: job

Why

Products that isolate tenants scope each occurrence and its lease to one tenant. One tenant's schedules then never trigger, block, or expose another tenant's work. Unscoped leases would let a replica mix tenants inside one occurrence.

Checka reviewer answers

Reviewed forWhich occurrence or lease rows lack tenant scope in a product that isolates tenants? Look at the occurrence and lease table schemas.

Marked guidance: a reviewer answers this question.

Dispatch Application Behavior#

rulerequiredguidance
litespec/ext/jobs#dispatch-application-behavior
Statement

A scheduled job MUST dispatch an Application Command or a declared Application port.

Applies toartifact: job

Why

The job record names the use cases it runs, and the use case boundary lives in Application. Each job therefore dispatches an Application Command or a declared Application port. The schedule stays a trigger while the behavior stays owned.

Checka reviewer answers

Reviewed forWhich job handlers call something other than an Application Command or a declared Application port? Look at the handler calls.

Marked guidance: a reviewer answers this question.

Exclude Direct Storage and HTTP Execution#

rulerequiredguidance
litespec/ext/jobs#exclude-direct-storage-and-http-execution
Statement

A scheduled job MUST NOT mutate a Marten session or DbContext directly, bypass Domain behavior, or call WebApi endpoints.

Applies toartifact: job

Why

A job that mutates a Marten session or DbContext directly, bypasses Domain behavior, or calls WebApi endpoints skips the command boundary. That boundary carries authorization, transaction, and validation the job would then lack. Jobs enter through Commands like every other caller.

Checka reviewer answers

Reviewed forWhich job sources mutate a Marten session or DbContext, or call a WebApi endpoint? Look at the job sources and their imports.

Marked guidance: a reviewer answers this question.

Bound Job Retries#

rulerequiredguidance
litespec/ext/jobs#bound-job-retries
Statement

A scheduled job MUST use bounded attempts, cancellation-aware backoff, and a poison state for permanent failure.

Applies toartifact: job

Why

Bounded attempts with cancellation-aware backoff cap what one failed occurrence consumes. A poison state parks the permanently failing occurrence instead of retrying it forever. Without the bound, one poison occurrence eats the Worker's whole capacity.

Checka reviewer answers

Reviewed forWhich schedules declare no bounded attempts, no cancellation-aware backoff, or no poison state? Look at the schedule records and the retry code.

Marked guidance: a reviewer answers this question.

Tolerate Duplicate Execution#

rulerequiredguidance
litespec/ext/jobs#tolerate-duplicate-execution
Statement

A scheduled job Command and side effect MUST tolerate duplicate execution after lease or process failure.

Applies toartifact: job

Why

A lease or process failure can replay a job whose completion stayed uncertain. The job Command and its side effects tolerate that duplicate execution. Work that assumes exactly-once breaks on the first uncertain failure.

Checka reviewer answers

Reviewed forWhich job Commands or side effects record more than one accepted effect after a replayed occurrence? Look at the replay tests.

Marked guidance: a reviewer answers this question.

Treat Unavailable Schedule Stores as Outages#

rulerequiredguidance
litespec/ext/jobs#treat-unavailable-schedule-stores-as-outages
Statement

A Worker MUST treat an unavailable scheduler store as the store outage litespec/ext/outbox#distinguish-dependency-outage defines, with backed-off, rate-limited logging.

Applies toartifact: job

Why

An unavailable scheduler store is an outage of the dependency, not a failed occurrence. The Worker treats it as the store outage litespec/ext/outbox#distinguish-dependency-outage defines, with backed-off, rate-limited logging. Retry and poison outcomes belong to claimed occurrences, not to a store nobody can reach.

Checka reviewer answers

Reviewed forWhich Worker log entries during a store outage are not backed off or rate-limited, or which occurrences are poisoned? Look at the Worker logs and the outage tests.

Marked guidance: a reviewer answers this question.

Persist Occurrence Recovery Points#

rulerequiredguidance
litespec/ext/jobs#persist-occurrence-recovery-points
Statement

A scheduled-job store MUST persist each occurrence's last scheduled, started, and completed time.

Applies toartifact: job

Why

Last scheduled, started, and completed times persist per occurrence. After a restart, those points separate missed work from completed work. Memory alone cannot make that split, because the restart wipes it.

Checka reviewer answers

Reviewed forWhich occurrence rows lack a last scheduled, started, or completed time? Look at the occurrence table schema.

Marked guidance: a reviewer answers this question.

Define Misfire Recovery#

rulerequiredguidance
litespec/ext/jobs#define-misfire-recovery
Statement

A scheduled-job specification MUST define skipped, once-replayed, or interval-replayed behavior for missed occurrences.

Applies toartifact: job

Why

Downtime and delay leave occurrences past their time. The specification states whether each missed occurrence is skipped, replayed once, or replayed per interval. The choice controls the business effect: a skipped reminder stays silent while a replayed one arrives late.

Checka reviewer answers

Reviewed forWhich schedules state no skipped, once-replayed, or interval-replayed behavior for missed occurrences? Look at each schedule record.

Marked guidance: a reviewer answers this question.

Provide Operational Recovery Procedures#

rulerequiredguidance
litespec/ext/jobs#provide-operational-recovery-procedures
Statement

Each schedule MUST have Runbook records for inspection, manual replay, and disable.

Applies toartifact: job

Why

Stalled, failed, or unsafe schedules need controlled operator actions: inspection, manual replay, and disable. Runbook records carry those procedures. An operator without them improvises against the store during the incident.

Each procedure names the interface that performs it. A procedure that says "disable the schedule" without naming a command, an endpoint, or a configuration value remains undiscovered until the incident it was written for. Avoid an interface that writes to the schedule store directly, because it bypasses the occurrence identity litespec/ext/jobs#derive-stable-occurrence-identity depends on.

Example

A disable procedure names the configuration value or the administrative endpoint that stops the schedule. It states what happens to an occurrence already claimed.

Checka reviewer answers

Reviewed forWhich schedules lack a runbook record for inspection, manual replay, or disable? Look at the runbook records beside the schedules.

Marked guidance: a reviewer answers this question.

Derive Stable Occurrence Identity#

rulerequiredguidance
litespec/ext/jobs#derive-stable-occurrence-identity
Statement

A scheduled-job store MUST derive each occurrence identity from its schedule ID and scheduled instant.

Applies toartifact: job

Why

Schedule ID plus scheduled instant gives each planned time one stable identity across retries and replicas. Retries of one occurrence then share their idempotency scope, and two replicas recognize the same occurrence.

Checka reviewer answers

Reviewed forWhich occurrence identities in the store lack the schedule ID or the scheduled instant? Look at the occurrence identity column.

Marked guidance: a reviewer answers this question.

Remove Occurrences Past Retention#

rulerequiredguidance
litespec/ext/jobs#remove-occurrences-past-retention
Statement

A scheduled-job store MUST remove occurrences older than the schedule's retention setting record.

Applies toartifact: job

Why

Occurrences older than the retention setting record leave the store so the key space stays bounded.

The key space grows with the schedule's frequency and its retention. A per-second schedule kept for a year holds more than 30 million rows. Quartz states the same practice for a persistent job store.

Example

A daily schedule that retains occurrences for 90 days holds 90 rows. A minute schedule with the same retention holds more than 100,000 rows. That is a different storage decision.

Checka reviewer answers

Reviewed forWhich stored occurrences are older than their schedule's retention setting record? Look at the store rows beside the setting records.

Marked guidance: a reviewer answers this question.

Persist Occurrence State#

rulerequiredguidance
litespec/ext/jobs#persist-occurrence-state
Statement

A scheduled-job store MUST persist scheduled, processing, completed, and dead-letter state with safe execution details.

Applies toartifact: job

Why

Scheduled, processing, completed, and dead-letter states persist with attempt, lease, start, completion, and safe error data. The persisted state tells operators and recovery code where each occurrence stands. A store without states cannot separate work in flight from work never started.

Checka reviewer answers

Reviewed forWhich occurrence rows lack a scheduled, processing, completed, or dead-letter state, or hold unsafe execution details? Look at the occurrence rows.

Marked guidance: a reviewer answers this question.

Scope Command Idempotency by Occurrence#

rulerequiredguidance
litespec/ext/jobs#scope-command-idempotency-by-occurrence
Statement

A scheduled job MUST use its occurrence identity as the command idempotency scope.

Applies toartifact: job

Why

The occurrence identity scopes the command idempotency key. Every retry of one occurrence then replays the same scheduled business action. A key scoped any wider would merge separate occurrences into one.

Checka reviewer answers

Reviewed forWhich retries of one occurrence use an idempotency scope other than its occurrence identity? Look at the command idempotency keys.

Marked guidance: a reviewer answers this question.

Restrict Completion by Fencing Value#

rulerequiredguidance
litespec/ext/jobs#restrict-completion-by-fencing-value
Statement

A Worker MUST mark completion only while its fencing value remains current.

Applies toartifact: job

Why

The Worker marks completion only while its fencing value stays current. A stale value means another replica owns the occurrence now. Completing past that point would write one replica's result over another's ownership.

Checka reviewer answers

Reviewed forWhich completion writes succeed on a stale fencing value? Look at the store write path and its fencing tests.

Marked guidance: a reviewer answers this question.

Audit Manual Replay#

rulerequiredguidance
litespec/ext/jobs#audit-manual-replay
Statement

A manual replay MUST create a new attempt for the same occurrence identity: an audit record when audit is selected, a standalone record otherwise.

Applies toartifact: job

Why

A manual replay creates a new attempt under the same occurrence identity: an audit record where audit is selected, a standalone record otherwise. The replay keeps the original scheduled instant and its history. A replay recorded as a new occurrence would rewrite when the work was due.

Checka reviewer answers

Reviewed forWhich manual replays add no audited attempt, or add it under a new occurrence identity? Look at the replay command and the audit rows.

Marked guidance: a reviewer answers this question.

Prefer UTC Schedules#

rulerequiredguidance
litespec/ext/jobs#prefer-utc-schedules
Statement

A scheduled job MUST use a UTC schedule unless its specification names a business-local time requirement and its IANA time zone.

Applies toartifact: job

Why

A local schedule runs twice on one date each year and skips an hour on another. A daylight-saving transition does that to a wall clock. That behavior is correct for a job whose meaning is local, such as a nightly statement at 9 AM for a user. It is a defect for every other job. Naming the time zone in the specification states the transition behavior for a later reader.

Checka reviewer answers

Reviewed forWhich schedules state neither UTC nor a business-local time requirement with its IANA time zone? Look at each schedule record.

Marked guidance: a reviewer answers this question.

Define Business-Local Clock Behavior#

rulerequiredguidance
litespec/ext/jobs#define-business-local-clock-behavior
Statement

A business-local schedule MUST record an IANA time-zone identifier and define skipped and repeated local-time behavior.

Applies toartifact: job

Why

Daylight-saving transitions omit one local hour and repeat another. A business-local schedule records its IANA time-zone identifier and defines what happens to occurrences in the skipped and repeated hours. Without that definition, each transition silently drops or doubles the local work.

Checka reviewer answers

Reviewed forWhich business-local schedules lack their IANA zone or the skipped and repeated local-time behavior? Look at each schedule record.

Marked guidance: a reviewer answers this question.

Test Time Transitions#

rulerequiredguidance
litespec/ext/jobs#test-time-transitions
Statement

A scheduled-job test MUST use an injected clock and representative time-zone transitions.

Applies toartifact: job

Why

An injected clock lets tests move time to any transition on demand. Representative time-zone transitions then run deterministically instead of once a year in production. Tests on the real clock can only wait for the transition to arrive.

Checka reviewer answers

Reviewed forWhich job tests use the real clock or skip representative time-zone transitions? Look at the job test sources.

Marked guidance: a reviewer answers this question.

Exclude Machine-Local Time#

rulerequiredguidance
litespec/ext/jobs#exclude-machine-local-time
Statement

Scheduled-job production code MUST NOT depend on machine-local time.

Applies toartifact: job

Why

Machine-local time follows each host's configuration. Production code that reads it schedules differently on a developer machine, in staging, and in production. Schedules read their time from the injected clock and the declared zone instead.

Checka reviewer answers

Reviewed forWhich production job sources read a machine-local clock? Look at the job sources for local time calls.

Marked guidance: a reviewer answers this question.

State the Claim Mode#

rulerequiredguidance
litespec/ext/jobs#state-the-claim-mode
Statement

A work queue MUST state its claim mode as disabled, optional, or required.

Applies toartifact: record:use-case

Why

Two people clearing the same item double-pay, double-approve, or double-refuse. The claim mode says whether items need no claim, accept an optional hold, or require one before action, so the queue never leaves two hands on one item.

Example

The payout queue requires a claim before release, while the review queue leaves claiming optional.

Checka reviewer answers

Reviewed forWhich queue use cases leave their claim field without disabled, optional, or required? Look at the use case pages.

Marked guidance: a reviewer answers this question.

Order Queue Items by Score#

rulerequiredguidance
litespec/ext/jobs#order-queue-items-by-score
Statement

A work queue MUST order its items by a score that cites a calculation rule.

Applies toartifact: record:use-case

Why

A queue without an order is cleared by habit: newest first, loudest first, easiest first. A score citing a calculation rule pins the order to declared inputs, so the riskiest or most valuable item surfaces first by rule instead of by accident.

Example

The dispute queue orders by rule/dispute.urgency-score, which weighs amount, age, and evidence gaps.

Checka reviewer answers

Reviewed forWhich queue listings sort without a score that cites its calculation rule? Look at the listing queries.

Marked guidance: a reviewer answers this question.

Show the Score Beside Each Item#

rulerequiredguidance
litespec/ext/jobs#show-the-score-beside-each-item
Statement

A queue listing MUST show each item score with the inputs that set it.

Applies toartifact: record:use-case

Why

A hidden score is an oracle: people work around an order they cannot see or trust. Showing the score with its inputs lets each person check the order and challenge the inputs instead of the queue.

Example

Each dispute row shows urgency 82: EUR 1,900, 6 days old, evidence missing.

Checka reviewer answers

Reviewed forWhich queue rows show a score without the inputs that set it? Look at the queue rows in the interface.

Marked guidance: a reviewer answers this question.

Release Claims Past Their Lease#

rulerequiredguidance
litespec/ext/jobs#release-claims-past-their-lease
Statement

A claimed item MUST return to the queue when its claim lease expires.

Applies toartifact: record:use-case

Why

Claims are held by people who go home: a claim with no expiry parks the item forever. The lease returns stale claims to the queue, so an abandoned item waits for the next person instead of for nobody.

Example

A payout claimed Friday and untouched returns to the queue when its one-hour lease expires.

Checka reviewer answers

Reviewed forWhich claim tests show no untouched item returning to the queue after its lease expires? Look at the claim tests.

Marked guidance: a reviewer answers this question.

Show a Preview Before Bulk Money Actions#

rulerequiredguidance
litespec/ext/jobs#show-a-preview-before-bulk-money-actions
Statement

A bulk money command MUST render a preview of every affected item before acting.

Applies toartifact: record:use-case

Why

Bulk money moves on many items at once, and one wrong filter multiplies one mistake into hundreds. The preview lists every affected item with its amount, so the person confirms the set they meant instead of the set they typed.

Example

The bulk release previews forty-two payouts totaling EUR 18,400 before asking for confirmation.

Checka reviewer answers

Reviewed forWhich bulk money commands act without rendering every affected item with its amount? Look at the preview step of each command.

Marked guidance: a reviewer answers this question.

Confirm Bulk Money Actions Out of Band#

rulerequiredguidance
litespec/ext/jobs#confirm-bulk-money-actions-out-of-band
Statement

A bulk money command MUST require its confirmBy code from outside the session.

Applies toartifact: record:use-case

Why

A preview confirms the set, but the session itself may be hijacked, shared, or left open. An out-of-band code arrives on a channel the session does not control, so the confirmation proves the person, not just the browser.

Example

The bulk release asks for the six-digit code sent to the finance phone before moving any money.

Checka reviewer answers

Reviewed forWhich bulk money commands move money without asking for the out-of-band code? Look at the command handlers.

Marked guidance: a reviewer answers this question.

Record Reporting Need#

rulerequiredguidance
litespec/ext/jobs#record-reporting-need
Statement

A reporting proposal MUST record the report, representative data volume, plan or limitation, latency target, maximum result, and operator.

Applies toartifact: record:use-case

Why

Reporting infrastructure costs a Worker, storage, and operating attention, so the team writes down the report, a representative data volume, the plan or limitation, the latency target, the maximum result, and the operator before building any of it. The use case page carries that record, and it shows why a normal request projection cannot meet the boundary.

Checka reviewer answers

Reviewed forWhich report use case pages lack the report, volume, plan, target, maximum, or operator? Look at each use case page.

Marked guidance: a reviewer answers this question.

Avoid Speculative Reporting Systems#

rulerequiredguidance
litespec/ext/jobs#avoid-speculative-reporting-systems
Statement

A project MUST NOT create reporting infrastructure for possible future analytics.

Applies toartifact: record:use-case

Why

A reporting system built for analytics the product may never need charges its full operating cost from day one while serving no accepted query. Each report or export earns its infrastructure with a current cost boundary, not a guess about future analysis.

Checka reviewer answers

Reviewed forWhich reporting systems trace to no accepted current query or export? Look at the reporting code and the use case pages.

Marked guidance: a reviewer answers this question.

Parameterize Report SQL#

rulerequiredguidance
litespec/ext/jobs#parameterize-report-sql
Statement

A reporting query MUST parameterize every actor, tenant, filter, range, sort, and pagination value.

Applies toartifact: record:use-case

Why

A report concatenates actor, tenant, filters, ranges, sorting, and pagination into SQL that reads across the database. Binding every one of those values as a parameter keeps tenant and actor isolation intact and closes the injection hole string concatenation opens.

Checka reviewer answers

Reviewed forWhich report queries put actor, tenant, filter, range, sort, or pagination values into SQL text instead of parameters? Look at the query code.

Marked guidance: a reviewer answers this question.

Keep Raw SQL in Infrastructure#

rulerequiredguidance
litespec/ext/jobs#keep-raw-sql-in-infrastructure
Statement

Infrastructure MUST own raw reporting SQL and connection handling.

Applies toartifact: record:use-case

Why

Raw SQL names tables, dialects, and connection handling that belong to one provider. Keeping it in Infrastructure lets Application and Domain state what the report means without depending on how one database phrases it.

Checka reviewer answers

Reviewed forWhich raw report SQL or connection handling sits outside Infrastructure code? Look at the report query sources.

Marked guidance: a reviewer answers this question.

Review Report Plans#

ruleadvisoryguidance
litespec/ext/jobs#review-report-plans
Statement

Each report SHOULD have its query plans and indexes reviewed against representative data.

DeviationA report over a small fixed data set justifies skipping the review.

Applies toartifact: record:use-case

Why

A query that flies over a hundred local rows can scan millions in production. The team reviews query plans and indexes against representative data, so the true cost shows before the report ships rather than after it slows the database.

Checka reviewer answers

Reviewed forWhich reports lack a review record showing query plans and indexes checked against representative data? Look at the review records.

Marked guidance: a reviewer answers this question.

Apply Item-Read Authorization#

rulerequiredguidance
litespec/ext/jobs#apply-item-read-authorization
Statement

A report or export MUST enforce actor, role, ownership, tenant, and sensitive-field rules that apply to item reads.

Applies toartifact: record:use-case

Why

A report that reads ten thousand rows at once crosses the same actor, role, ownership, tenant, and sensitive-field boundaries as ten thousand single reads. Enforcing the item-read rules on the bulk path stops the report from exposing rows its user may not open one by one.

Checka reviewer answers

Reviewed forWhich reports or exports lack an authorization test for the item-read rules? Look at the authorization tests.

Marked guidance: a reviewer answers this question.

Run Budget-Exceeding Exports in Worker#

rulerequiredguidance
litespec/ext/jobs#run-budget-exceeding-exports-in-worker
Statement

An export exceeding its request budget MUST run through Worker, with the budget a setting record the export's use case names.

Applies toartifact: record:use-case

Why

An export that outlasts its request budget holds an HTTP connection open while the user waits and the server counts threads. Running it in a Worker returns the request immediately, and the budget in its setting record tells the team exactly when an export outgrows the request path.

Checka reviewer answers

Reviewed forWhich exports past their request budget run outside a Worker, or lack the budget in a setting record? Look at the export use cases and their setting records.

Marked guidance: a reviewer answers this question.

Protect Export Output#

rulerequiredguidance
litespec/ext/jobs#protect-export-output
Statement

An export worker MUST store output in approved object storage with a named contact, an expiry, and a short-lived authorized download.

Applies toartifact: record:use-case

Why

An export file concentrates sensitive rows into one downloadable object that outlives the request that built it. Approved object storage with a named contact, an expiry, and a short-lived authorized download gives that object controlled access and a defined end instead of a permanent public link.

Checka reviewer answers

Reviewed forWhich export outputs sit outside approved object storage, or lack a named contact, an expiry, or a short-lived authorized download? Look at the export storage configuration.

Marked guidance: a reviewer answers this question.

Scope Export Output to the Tenant#

rulerequiredguidance
litespec/ext/jobs#scope-export-output-to-the-tenant
Statement

An export MUST store its output under a tenant-scoped object-storage path.

Applies toartifact: record:use-case

Why

Export addresses are predictable, and a shared folder lets one tenant guess another tenant's file name. A tenant-scoped storage path puts each tenant's exports under its own prefix, so a guessed address stays inside the guesser's own data.

Checka reviewer answers

Reviewed forWhich exports store output outside a tenant-scoped path in object storage? Look at the export storage paths.

Marked guidance: a reviewer answers this question.

Define Report Limits#

rulerequiredguidance
litespec/ext/jobs#define-report-limits
Statement

A report specification MUST state each bound as a setting record: maximum date range, rows, execution time, concurrent jobs, output size, and storage lifetime.

Applies toartifact: record:use-case

Why

Date range, rows, execution time, concurrent jobs, output size, and storage lifetime each cap one dimension of report cost. Setting records hold all six, so a runaway report hits a documented bound instead of an exhausted database, a full disk, or a surprise invoice.

Checka reviewer answers

Reviewed forWhich report bounds lack a setting record beside the report? Look at each report's setting records.

Marked guidance: a reviewer answers this question.

Declare Export Paging#

rulerequiredguidance
litespec/ext/jobs#declare-export-paging
Statement

An export query MUST state paging with mode of pages or none with its reason.

Applies toartifact: record:use-case

Why

An export reads many rows at once, so it states how the read is bounded: {"mode": "pages", ...} bounds each run, and {"mode": "none", "reason": "..."} states why the export reads all rows at once. Without the declaration, a reviewer cannot tell a bounded export from one that grows with the table.

Checka reviewer answers

Reviewed forWhich export queries lack paging with mode pages or mode none with its reason? Look at the export query beside the report.

Marked guidance: a reviewer answers this question.

Audit Export Reads#

rulerequiredguidance
litespec/ext/jobs#audit-export-reads
Statement

An export query MUST state its audit reason and target.

Applies toartifact: record:use-case

Why

An export file concentrates sensitive rows into one downloadable object, so the use case states why the bulk read is audited and where the audit lands. Without the stated audit, the concentrated read leaves no trace a reviewer can follow.

Checka reviewer answers

Reviewed forWhich export queries lack a stated audit reason and target? Look at the export query beside the report.

Marked guidance: a reviewer answers this question.

Support Report Cancellation#

rulerequiredguidance
litespec/ext/jobs#support-report-cancellation
Statement

A report implementation MUST support cancellation and remove expired outputs.

Applies toartifact: record:use-case

Why

A user who closes the tab leaves the report running, and an export nobody downloads still occupies storage. Cancellation stops the abandoned work, and expiry removes the abandoned file, so neither consumes resources indefinitely.

Checka reviewer answers

Reviewed forWhich report work ignores a cancel request, or keeps expired output? Look at the cancellation tests.

Marked guidance: a reviewer answers this question.

Escape Formula-Leading Export Values#

rulerequiredguidance
litespec/ext/jobs#escape-formula-leading-export-values
Statement

A CSV or spreadsheet export MUST escape formula-leading values unless the team intentionally fills a field with a formula.

Applies toartifact: record:use-case

Why

A value starting with =, +, -, or @ becomes a live formula when the export opens in a spreadsheet, running in the opener's application with the opener's data. Escaping those values keeps data as data, except in a field the team intentionally fills with a formula.

Checka reviewer answers

Reviewed forWhich exported values that start with a formula character go out unescaped, outside the formula fields the team fills on purpose? Look at the CSV and spreadsheet writers.

Marked guidance: a reviewer answers this question.

Define Export Encoding and Columns#

rulerequiredguidance
litespec/ext/jobs#define-export-encoding-and-columns
Statement

An export format MUST use explicit character encoding and a stable column contract.

Applies toartifact: record:use-case

Why

An export without a stated encoding arrives garbled on the first machine that guesses differently, and columns that shift per release break every parser built on them. Explicit encoding with a stable column contract lets consumers parse the file without guessing either.

Checka reviewer answers

Reviewed forWhich export formats lack a character encoding or stable columns in their format record? Look at each format record.

Marked guidance: a reviewer answers this question.

Conventions#

Place Handlers with Owned Behavior#

conventiondefaultguidance
litespec/ext/jobs#place-handlers-with-owned-behavior
Default

Create one job handler under the module that owns its behavior.

ReplacementA project keeps job handlers in one shared jobs folder.

Applies toartifact: job

Why

One job handler lives under the module that owns its behavior. The module owns both the business action and what its schedule means. A handlers folder far from the behavior separates each schedule from its reason.

Checka reviewer answers

Reviewed forWhich job handlers sit outside the module that owns their behavior, when the project keeps no shared jobs folder? Look at the handler folders.

Marked guidance: a reviewer answers this question.

Use Execution Scopes#

conventiondefaultguidance
litespec/ext/jobs#use-execution-scopes
Default

Resolve scoped dependencies inside an execution scope and dispose the scope after the Command completes.

ReplacementA project names another scope boundary for occurrence dependencies in its documentation.

Applies toartifact: job

Why

Each occurrence resolves its scoped dependencies inside one execution scope and disposes it after the Command completes. The scope isolates one occurrence's dependencies from the next. A shared scope would leak one occurrence's state into another.

Checka reviewer answers

Reviewed forWhich occurrences resolve scoped dependencies outside a disposed execution scope, when the project names no other scope boundary? Look at the job execution code and the project documentation.

Marked guidance: a reviewer answers this question.

Separate Schedule Definitions#

conventiondefaultguidance
litespec/ext/jobs#separate-schedule-definitions
Default

Keep schedule definitions separate from Command behavior.

ReplacementA project keeps schedule definitions beside their Command behavior.

Applies toartifact: job

Why

Timing policy changes when operations needs a new rhythm, and Command behavior changes when the business needs a new outcome. Keeping schedule definitions separate from Command behavior lets each change alone. A schedule buried in the handler makes every timing change a code change.

Checka reviewer answers

Reviewed forWhich schedule definitions sit inside Command behavior, when the project keeps them apart from it? Look at the handler code and the schedule records.

Marked guidance: a reviewer answers this question.

Order Unscored Queues by Age#

conventiondefaultguidance
litespec/ext/jobs#order-unscored-queues-by-age
Default

A queue without a score lists its oldest item first.

ReplacementA project names its fallback queue order in its queue documentation.

Applies toartifact: record:use-case

Why

Age is the honest fallback: the item waiting longest goes first. Any other fallback works when the queue states it.

Checka reviewer answers

Reviewed forWhich queues without a score list anything other than oldest first, with no fallback order named in the queue documentation? Look at the queue listings and the queue documentation.

Marked guidance: a reviewer answers this question.

Keep Report Definitions in Application#

conventiondefaultguidance
litespec/ext/jobs#keep-report-definitions-in-application
Default

Keep report definitions in Application under their module.

ReplacementA consumer records a report-definition convention naming where its report definitions live.

Applies toartifact: record:use-case

Why

What a report means and who may run it are business choices. Keeping the definition in Application under its module puts those choices beside the module's other rules instead of buried in query code.

Checka reviewer answers

Reviewed forWhich report definitions sit outside their module, when the report-definition convention names no other place? Look at the report definition sources.

Marked guidance: a reviewer answers this question.

Keep Report Providers in Infrastructure#

conventiondefaultguidance
litespec/ext/jobs#keep-report-providers-in-infrastructure
Default

Keep SQL, row mappings, and storage providers in Infrastructure.

ReplacementA consumer records a report-provider convention naming where its SQL, mappings, and storage code live.

Applies toartifact: record:use-case

Why

SQL text, row mappings, and storage calls change per provider while the report's meaning stays fixed. Keeping them in Infrastructure swaps the provider without touching the report's business rules.

Checka reviewer answers

Reviewed forWhich SQL and storage code sits outside Infrastructure, when the report-provider convention names no other place? Look at the report provider sources.

Marked guidance: a reviewer answers this question.

Separate Worker Orchestration#

conventiondefaultguidance
litespec/ext/jobs#separate-worker-orchestration
Default

Keep Worker orchestration separate from report rules.

ReplacementA consumer records a report-orchestration convention naming where its scheduling and progress tracking live.

Applies toartifact: record:use-case

Why

Scheduling, chunking, and progress tracking run the report without defining it. Keeping Worker orchestration apart from the report's rules lets either change without dragging the other along.

Checka reviewer answers

Reviewed forWhich Worker orchestration code sits inside report rules, when the report-orchestration convention names no other place? Look at the report rule sources.

Marked guidance: a reviewer answers this question.

Dependencies#

Packages: This extension selects no report or object-storage package. Each provider the project uses needs a decision and a manifest pin.

Related extensions: outbox.

Guides: None.