Data backfills
Batch a large update, cap writes per invocation, and resume from the last saved offset.
db.writesCaptor puts execution contracts around backfills and background jobs. Set per-run limits, save completed progress, verify the outcome, and inspect what happened.
npm install captarA job can return normally after doing too much,
or fail with no trustworthy place to restart.
Reserve capacity before a write or request. A run that reaches its per-run limit rejects the next guarded operation.
Backfills save an offset after each successful batch. Restart from that checkpoint with stable inputs and idempotent writes.
Assert an outcome metric and inspect a receipt with status, resource usage, checkpoints, and violations.
Add Captor where the side effects happen. Reserve capacity before work, commit it after success, and report a metric for the outcome check. These examples use the published captar package.
import { run } from 'captar';
const customers = [{ id: 1 }, { id: 2 }, { id: 3 }];
const repaired = new Set<number>();
const { receipt } = await run(
'customer-repair',
{
limits: { resources: { 'db.writes': 3 } },
outcome: { 'records.processed': { equals: customers.length } },
},
async (execution) => {
for (const customer of customers) {
const write = execution.reserve('db.writes', 1);
repaired.add(customer.id); // replace with awaited write
execution.commit(write);
}
execution.metric('records.processed', repaired.size);
}
);
console.log(receipt.status, receipt.resources['db.writes']);Run it from cron, BullMQ, Temporal, a CI job, or a plain Node process.
Batch a large update, cap writes per invocation, and resume from the last saved offset.
db.writesKeep one-off fixes inside an explicit write limit and check the result before calling them done.
records.processedBound outgoing fetch attempts when an external API or retry loop behaves unexpectedly.
http.requestsPut a per-run contract around the work your existing cron or queue worker starts.
per-run policyLimits are enforced where your code calls Captor or uses its supported adapters. Deadlines send an AbortSignal; the underlying work must honor cancellation. Captor cannot undo an already completed side effect.
Read the execution modelNo. Keep your existing cron, queue, workflow engine, or Node process. Captor runs inside the application code that performs the work.
Only operations routed through Captor count. Use reserve/commit in your code, boundedFetch, or the supported Prisma query guard. Work that bypasses those boundaries is not automatically metered.
Yes. A failure between an external side effect and its saved checkpoint can repeat that work. Use stable source ordering, idempotent writes, and transactions where appropriate. Each resumed invocation has a fresh limit.
No. The SDK and JSONL or SQLite receipt stores work locally. The optional platform supports manual import and inspection of receipt files; it does not remotely run your jobs.
Captor is the product name. The published npm package and the import path are currently captar. The package supports Node.js 22 and newer.
Install the open-source SDK, run a local example, then test it against a small, representative workload.