@xeonr/pipelines-sdk
v0.6.0
Published
TypeScript SDK for xeonr pipelines: start runs and enqueue jobs, and run worker handlers inside your own Node.js process.
Readme
@xeonr/pipelines-sdk
The TypeScript SDK for xeonr pipelines (Trellis PIPE-5). It does two things:
- Client: start runs and enqueue jobs on the public API (
CreateRun,CreateJob), read them and cancel them. - Worker: run your service's handlers inside your own Node.js process. The worker claims your handlers' attempts from pipelines-api, and the platform handles retries, delays, timeouts, leases, cancel, logs and the console. You run no runner, no image and no container-platform.
This is not the step SDK (@xeonr/runner-sdk, defineStep inside an image).
Pipelines is a platform service for consuming services; end users never use
it. A tenant is a consuming service: the one platform team it runs all of
its pipelines under (the forge's is team forge). The SDK calls as that
service's Auth service account, a member of the tenant's team, and every write
(jobs, runs, queues, schedules, pools, packages) is for a tenant the service
account is a member of.
Runtime: Node.js 20, 22 and 24, ESM only. CI runs on 24. The smoke test of the built package also passes on 20 and 22.
Install
pnpm add @xeonr/pipelines-sdk @bufbuild/protobuf @connectrpc/connectAuth
Calls carry an Auth access token for your service's service account. The
token comes from the jwt-bearer grant (auth.service-to-service), the same
exchange as go-platform's authn.NewTokenSource. jwtBearer caches the token
and refreshes it single-flight, 30 s before it expires. If a refresh fails
while the old token is still valid, the old token is used.
import { jwtBearer } from "@xeonr/pipelines-sdk";
const token = jwtBearer({
tokenUrl: "https://auth.xeonr.io/api/v1/oauth/token",
assertion: () => process.env.PIPELINES_SA_ASSERTION!, // re-read on each refresh
scopes: ["pipelines:run:edit", "pipelines:run:read", "pipelines:worker:edit", "pipelines:package:edit", "pipelines:pool:edit"],
});You can also pass any () => string | Promise<string> as token. On
unauthenticated, the SDK drops the cached token and retries the call once
with a fresh one.
| Scope | Needed for |
|---|---|
| pipelines:run:edit | createRun, createJob, cancelRun |
| pipelines:run:read | getRun, getRunGraph, listRuns |
| pipelines:worker:edit | the worker's claim loop (WorkerService) |
| pipelines:package:edit, pipelines:pool:edit | a worker that registers itself at boot (the default) |
A worker may claim only its owner's handlers. The API checks this at claim.
Run a worker
import { defineHandler, Worker, jwtBearer } from "@xeonr/pipelines-sdk";
const TEAM = "urn:xeonr:auth:team:0f3c9a2e-8f1b-4c2d-9e6a-1b2c3d4e5f60";
export const sendEmail = defineHandler<{ to: string; template: string }, { messageId: string }>({
name: "acme/send-email", // <namespace>/<name>; the namespace is your team's
version: "1.2.0", // published at boot; bump it when the manifest changes
inputs: [{ name: "to", type: 1, required: true }, { name: "template", type: 1, required: true }],
outputs: [{ name: "messageId", type: 1 }],
concurrency: 4, // at most 4 of these at once in this process
async run({ input, signal, log, attempt }) {
log.info("sending", { to: input.to, attempt: attempt.number });
const res = await fetch("https://mail.internal/send", { method: "POST", body: JSON.stringify(input), signal });
if (!res.ok) throw new Error(`mail service answered ${res.status}`); // fails this attempt only
return { messageId: (await res.json()).id }; // kv outputs
},
});
const worker = new Worker({
baseUrl: "https://pipelines.xeonr.io",
token,
tenant: TEAM,
pool: { name: "acme-app" }, // every replica of the app uses the same pool
concurrency: 16, // across all handlers; also the pool's capacity per instance
});
worker.handle(sendEmail);
await worker.start(); // publishes handler versions, declares the sdk pool, starts claiming
process.on("SIGTERM", () => void worker.stop({ timeoutMs: 30_000 }));
await worker.wait(); // rejects if the worker stopped on an auth errorAt boot, start() publishes each handler as a kind: worker package
(RegistryService.PublishVersion) and declares the sdk pool (SetPool).
Pass register: false and pool.id if something else does that.
What the worker does for each attempt
- Claim. It long-polls
ClaimAttemptsfor its handlers. No claim is allowed to push the worker past its overallconcurrencyor a handler'sconcurrency: each poll reserves its slots up front. EachWorkerhas its own instance id (worker.workerId, a UUID), which it claims with and echoes inAttemptRef.worker_idon every later call, so one replica cannot write to another's attempt. - Secrets, then start. When the node was granted secrets, it first
fetches them with
GetAttemptSecrets, sealed to a key only this claim holds (one fresh X25519 key per claim slot). Then it callsStartAttempt, which also returns the attempt token for the handler's blob and token calls. Your code runs only after that succeeds. - Heartbeat. It renews the lease at the interval the claim gives, from the claim until completion.
- Run. It calls your handler with an
AbortSignal. The signal fires with anAttemptAbortedErrorwhosecausesays why:cancelled: a heartbeat answered cancel;deadline: the node's timeout passed;lost: the lease was lost;shutdown:stop()ran past its timeout.
- Log.
ctx.logships the attempt's log in order withAppendLogs, idempotent on seq, and honours the attempt's log cap. If the server lost chunks it had acknowledged, it says so without_of_rangenaming the seq it expects: the worker resends from there if it still holds them, and otherwise carries on from that seq after one line saying how many bytes of output were lost. - Complete. It calls
CompleteAttemptwith the kv outputs inline, or with a termination:
| How the handler ended | Termination | Failure class (set by the platform) |
|---|---|---|
| Returned outputs | EXITED (0) | none |
| Threw or rejected; parseInput threw | HANDLER_ERROR, kind from the error (below) | HANDLER_ERROR |
| Returned outputs that are not valid kv | HANDLER_ERROR, kind PERMANENT | HANDLER_ERROR |
| Still running at its deadline | TIMED_OUT | TIMEOUT |
| Stopped after a cancel | CANCELLED | CANCELLED |
| Aborted by stop() past its timeout | INTERRUPTED | INTERRUPTED |
| Lease lost | nothing reported | ABANDONED, decided by the platform; run again automatically only on an interruptible node or job |
The platform picks the failure class and decides whether to retry, using the
node's retry.when. By default it retries only transient classes:
ABANDONED, RUNNER_CRASHED, IMAGE_PULL, STAGING_FAILED, INTERRUPTED
and INTERNAL.
A handler says whether its failure can pass by what it throws. The class
stays HANDLER_ERROR either way; this sets
CompleteAttemptRequest.handler_failure_kind:
import { PermanentError, TransientError } from "@xeonr/pipelines-sdk";
if (res.status === 503) throw new TransientError("mail service unavailable"); // retried under the default policy
if (res.status === 422) throw new PermanentError("template not found"); // never retried, whatever retry.when says
throw new Error("anything else"); // unspecified: retry.when alone decidesThe marker is found on the thrown error or anywhere in its cause chain, so
wrapping one (new Error("send failed", { cause: new PermanentError(...) }))
keeps it. A worker can narrow a node's policy this way, never widen it: an
explicit retry.when still applies to a TransientError, and retry.max
and backoff bound every retry.
A thrown error or rejected promise fails that attempt, never the process.
JavaScript cannot kill a handler that ignores its signal. Such a handler gets
the cancel grace (or stop's graceMs). After that its slot is freed and
anything it does later is ignored.
Secrets, blobs and job identity tokens
A handler can do more than take kv inputs and return kv outputs. It names the secrets it reads, declares blob slots among its inputs and outputs, and the worker does the rest through the attempt's own token, which it never hands to your code:
const render = defineHandler<{ url: string }, { pages: number }>({
name: "acme/render",
version: "1.0.0",
secrets: ["RENDER_TOKEN"], // manifest required_secrets
inputs: [
{ name: "url", type: SlotType.KV, required: true },
{ name: "source", type: SlotType.BLOB },
],
outputs: [
{ name: "pages", type: SlotType.KV },
{ name: "thumb", type: SlotType.BLOB, required: true },
],
async run(ctx) {
const token = ctx.secret("RENDER_TOKEN"); // SecretUnavailableError if not delivered
const src = await ctx.readBlob("source"); // verified against its sha256
const png = await draw(src, token, ctx.signal);
await ctx.putBlob("thumb", png, { filename: "thumb.png", mediaType: "image/png" });
return { pages: 1 };
},
});| On ctx | What it does |
|---|---|
| secret(name), secretBytes(name), hasSecret(name) | A secret the node granted, delivered sealed to this claim before the attempt started. A node may grant only the names in the handler's secrets. A grant marked optional that the platform withheld (no such secret, or its policy refused) is absent, and secret throws SecretUnavailableError. Every value (4 bytes or more) is replaced with *** in the attempt's log and completion message. |
| blobInputs | The blobs the claim listed: input, index, filename, size, sha256, media type. |
| blobUrl(input, {index, node}) | A short-lived presigned GET (GetBlobInput), minted now. A capability: hand it only to what must fetch it. |
| openBlob(input, ...), readBlob(input, ...) | The bytes, streamed or whole. The stream errors if they do not match the recorded size and sha256. |
| putBlob(slot, body, {filename, mediaType}) | Commits a blob output. Bytes, an ArrayBuffer or a Blob of 16 MiB or less go in one PUT (CreateBlobOutput). Anything larger, or a ReadableStream / async iterable of unknown size, goes in parts (CreateMultipartUpload). Both are finalised with their size and sha256. Finalise blob outputs before the handler returns. |
| idToken(audience) | A job identity token (CreateIdToken) for an audience the node lists in id_token_audiences and the tenant's audience policy allows. |
Transfers go through WorkerOptions.fetch (default the global fetch).
A network error, a 5xx or a 429 from the store is retried a few times. A
refusal from pipelines-api (invalid_argument, not_found,
permission_denied) is thrown as a PermanentError, so the attempt is not
retried for it. failed_precondition means the attempt token was revoked:
the attempt is no longer this worker's, so the handler's signal is aborted
(lost) and nothing is reported.
A transport you build yourself must leave a call's Authorization header
alone when it is already set: that is how the attempt token travels.
createPipelinesTransport and authInterceptor already do this.
Errors from pipelines-api
The worker reads each error by its Connect code (errorKind):
failed_precondition: the attempt is no longer this worker's. The handler is aborted (lost) and nothing more is reported.invalid_argumentonStartAttemptorCompleteAttempt: final, not retried.unauthenticatedorpermission_denied: not transient. The worker stops claiming, callsonError, andwait()rejects once in-flight attempts end.out_of_rangeonAppendLogs: not fatal. It names the seq the server expects, and the log resends or renumbers from there (see step 5). Anout_of_rangethat names no seq drops the rest of that attempt's log; the attempt carries on.- Anything else (
unavailable,deadline_exceeded,internal, network errors): retried with backoff. A heartbeat that cannot get through before the lease runs out loses the attempt.
Graceful shutdown
stop({ timeoutMs, graceMs }) works in four steps:
- It stops claiming and aborts any held long-polls.
- Attempts that were claimed but never started are handed back with
ReleaseAttempt. They are offered again at once, to any worker, as the same attempt, with nothing spent. A release answeredfailed_preconditionwas no longer this worker's, which counts as done. - Running handlers get
timeoutMsto finish (default 30 s). Their real outcome is reported. - Handlers still running after that are aborted with
shutdown. They getgraceMsmore (default 5 s), then their attempts are completed withTERMINATION_INTERRUPTED. That is transient, so the platform retries it by default. On a node markedinterruptible, the retry does not count againstretry.max.
Stages, progress, issues and spans
A handler can tell the console how far it has got, and what went wrong with individual items, without failing:
export const scanLibrary = defineHandler<{ libraryId: string }>({
name: "acme/scan-library",
version: "2.0.0",
title: "Scan library",
// Published in the manifest, so a console draws every stage before the attempt starts.
stages: [
{ key: "read", name: "Reading folders" },
{ key: "probe", name: "Probing files", weight: 4 }, // dominates the overall bar
],
async run(ctx) {
ctx.stage("read");
const files = await listFiles(ctx.input.libraryId);
ctx.stage("probe"); // finishes "read"
for (const [i, f] of files.entries()) {
await ctx.span("probe", async (span) => {
span.setAttribute("file", f.path);
try {
await probe(f);
} catch (err) {
ctx.issue({ severity: "warning", subject: f.path, subjectKind: "media.file", subjectId: f.id, message: `${f.path} could not be probed` });
}
});
ctx.progress({ processed: i + 1, total: files.length });
}
},
});ctx.stage(key)enters a stage and finishes the one before it. The last stage is finished asSUCCEEDEDwhen the handler returns, orFAILEDwhen it fails. A key the handler does not declare is added at run time with weight 0. The calls areWorkerService.SetProgresswithstage.ctx.progress({ processed, total, failed, fraction, message })is coalesced: the latest value about once a second (reportIntervalMs), and a forced final report before the attempt completes.ctx.issue({ severity, subject, subjectKind, subjectId, message, detail })is batched, up to 100 perAppendIssues. The run carries the counts by severity, andclient.listIssues(runId)reads them.ctx.span(name, fn, attributes?)records an OpenTelemetry-shaped span of the attempt's trace (ReportSpans). Spans nest withspan.span(...), and a throw marks a spanerror.client.getRunTrace(runId)reads the whole trace.
None of this can fail a handler. Every error sending progress, issues or spans is logged at debug and dropped.
Queues
Jobs are admitted through queues: each belongs to one tenant, with limits and
fairness between the tenant's lanes (its jobs' fairness keys). A queue is not
where work runs; pools and workers are. A job with no queue goes to the
tenant's default queue, which has no limits until the tenant sets one.
const worker = new Worker({
baseUrl, token, tenant: TEAM, pool: { name: "acme-app" },
// Declared at start with SetQueue, every writable field replaced; a pause survives.
queues: [
{ name: "emails", maxConcurrency: 20, maxConcurrencyPerTenant: 5, rateLimit: { limit: 100, windowMs: 60_000 } },
{ name: "imports", maxConcurrency: 2, defaultRetry: { max: 3, when: [FailureClass.HANDLER_ERROR] }, defaultTimeoutMs: 30 * 60_000 },
],
});
await pipelines.createJob({ tenant: TEAM, handler: "acme/send-email", idempotencyKey: "welcome:4821", queue: "emails" });- An unknown queue name is
not_found. AretryortimeoutMsover the queue'sdefaultRetry/defaultTimeoutMsisinvalid_argument. When unset, the queue's defaults apply. QueuesClienthassetQueue,getQueue,listQueues,pauseQueue,resumeQueue,getQueueStats,listQueueJobs,deleteQueueandrequeueJob.declareQueues(client, decls)is the helper the worker uses. AQueuesClientis for one tenant (new QueuesClient({ baseUrl, token, tenant })); the worker declares its queues for its owntenant.- Dead letters.
listQueueJobs(id, { states: [RunState.FAILED] })lists them, andrequeueJob(runId)(RetryNodeon nodejob) offers one again on its queue. - Fairness. The next claim goes to the eligible lane (no fairness key, or
one key) with the fewest running attempts in the queue; ties go to the
longest-waiting job.
maxConcurrencyPerTenantcaps each lane.
createJob also takes interruptible: true for a handler that is safe to
run again from the start. A worker shutting down then spends no retry on it,
and a worker that vanished (ABANDONED) gets it run again. The platform
re-runs an abandoned attempt only for an interruptible node.
Schedules
const worker = new Worker({
baseUrl, token, tenant: TEAM, pool: { name: "acme-app" },
schedules: [
// Each occurrence of the cron, in its time zone, starts a job to one of this worker's handlers.
{ name: "reports.daily", cron: "0 4 * * *", cronLabel: "Every day at 4am", timeZone: "Europe/London", job: { handler: "acme/report" } },
// Fan out: the enumeration handler returns the targets at each occurrence.
{ name: "servers.backup", cron: "*/30 * * * *", job: { handler: "acme/backup" }, enumerate: { handler: "acme/list-servers" } },
],
});
worker.handle(report).handle(backup).handle(
defineEnumerator({ name: "acme/list-servers", version: "1.0.0", run: async () => (await servers()).map((s) => ({ key: `server:${s.id}`, args: { id: s.id } })) }),
);- A schedule whose job or enumeration handler the worker does not register
is refused at
start(), before anything is published. - The platform's rules: one run per occurrence and target, however many
replicas evaluate it. After an outage, only the latest missed occurrence
within
catchupWindowMsfires (misfire). A target with a run still pending is skipped unlessqueueWhilePending. An owner's override of the cron or enabled flag survives redeclaration. SchedulesClienthassetSchedule,getSchedule,listSchedules,setScheduleOverride,pauseSchedule,resumeSchedule,deleteSchedule,runScheduleNowandlistScheduleOccurrences; likeQueuesClientit is for onetenant, and the worker declares schedules for its own.declareSchedulesis the helper.
Enqueue jobs and start runs
import { FailureClass, PipelinesClient } from "@xeonr/pipelines-sdk";
const pipelines = new PipelinesClient({ baseUrl: "https://pipelines.xeonr.io", token });
// One handler, run once: CreateJob (the plan's EnqueueJob). Idempotent per tenant.
const { run } = await pipelines.createJob({
tenant: TEAM,
handler: "acme/send-email",
payload: { to: "[email protected]", template: "welcome" },
idempotencyKey: "welcome-email:user-4821",
delayMs: 10 * 60_000, // not offered to a worker before ten minutes have passed
queue: "emails", // admitted through this tenant queue (see Queues)
retry: { max: 3, when: [FailureClass.HANDLER_ERROR] }, // the job's node policy; unset is the platform default
timeoutMs: 5 * 60_000, // bounds one attempt
});
// A full run that mixes an image node and a worker node, passing an output between them.
await pipelines.createRun({
idempotencyKey: "thumbs:upload-91",
tenant: TEAM,
resource: { kind: "acme.upload", id: "upload-91" },
definition: {
nodes: [
{ id: "extract", action: { case: "uses", value: { name: "acme/extract", version: "1.0.0" } } },
{
id: "notify",
action: { case: "handler", value: "acme/send-email" },
needs: [{ node: "extract" }], // a reference adds no edge: name the node in needs
with: { to: { kind: { case: "stringValue", value: "${{ steps.extract.outputs.kv.owner }}" } } },
retry: { max: 3, when: [FailureClass.HANDLER_ERROR] },
},
],
},
});
// A published version of a stored pipeline instead of an inline definition.
await pipelines.createRun({
idempotencyKey: "nightly:2026-11-12",
tenant: TEAM,
resource: { kind: "acme.library", id: "lib-7" },
pipeline: { name: "nightly-scan", scope: { kind: "acme.library", id: "lib-7" } }, // version 0: the latest
variables: { depth: 2 },
});
await pipelines.getRun(run.id);
await pipelines.cancelRun(run.id, "superseded");pipelines.runs is the generated RunsService client, for anything not
wrapped. The generated messages are importable from
@xeonr/pipelines-sdk/gen/xeonr/pipelines/v1/*_pb.
Stored pipelines
StoredPipelinesClient wraps PipelinesService (the Go SDK's
Client.DeclarePipeline and friends). declarePipeline sets the draft
and publishes it, idempotent per content, as a service does at start:
import { StoredPipelinesClient } from "@xeonr/pipelines-sdk";
const stored = new StoredPipelinesClient({ baseUrl, token });
const { pipeline, version, unchanged } = await stored.declarePipeline({
tenant, scope: { kind: "acme.repo", id: "web" }, name: "build",
spec: { definition: { name: "build", nodes: [/* ... */] } },
});
await client.createRun({ tenant, idempotencyKey, resource, pipeline: { id: pipeline.id } });It also has setPipeline, getPipeline (by id, or tenant, scope and
name), listPipelines, publishPipeline, listPipelineVersions,
getPipelineVersion, archivePipeline and validateDefinition. Scopes:
pipelines:pipeline:edit and pipelines:pipeline:read.
Tenant policies and the sink
TenantPoliciesClient wraps TenantPoliciesService and SinksService
for the tenant's own service accounts: the tier policy
(setTierPolicy/getTierPolicy, including cpNamespaces), the job
identity audiences (setAudiencePolicy, whose package limits are kept
unless replacePackages), retention, fact attesters, and the run event
sink (setSink/getSink/deleteSink). Each set replaces its policy
whole. Scopes: pipelines:policy:read/:edit, pipelines:sink:read/:edit.
Test your handlers: @xeonr/pipelines-sdk/testing
FakePipelines is an in-memory pipelines-api: a real Connect router behind an
in-memory transport. The real Worker and PipelinesClient run against it
unchanged.
import { FakePipelines, FAKE_TENANT } from "@xeonr/pipelines-sdk/testing";
const fake = new FakePipelines({ leaseMs: 600, heartbeatIntervalMs: 50 });
const worker = new Worker({ transport: fake.transport(), tenant: FAKE_TENANT, pool: { name: "test" } });
worker.handle(sendEmail);
await worker.start();
const client = new PipelinesClient({ transport: fake.transport() });
const { run } = await client.createJob({ tenant: FAKE_TENANT, handler: "acme/send-email", idempotencyKey: "t1", payload: { to: "a@b", template: "x" } });
const done = await fake.waitForRun(run.id);
expect(done.nodes.get("job")!.kv).toEqual({ messageId: "…" });
await worker.stop();
fake.close();The fake models:
- accounts (a token with a tenant and scopes), and namespace and pool ownership;
- publish, pools, jobs with delay, idempotency, retry and timeout, and runs (references only into a node's needs closure);
- the claim long-poll, the worker id on every ref, leases and their lapse
(
expireLease),ReleaseAttempt, heartbeats and cancel; - logs, with
out_of_rangenaming the expected seq for a gap, andloseLogChunksto play a server that lost acknowledged chunks; - the server's mapping from termination to failure class,
handler_failure_kind, retries by class, and free interruptions on aninterruptiblenode; - external (image) nodes you settle with
completeNode; - error injection (
inject("Heartbeat", Code.Unavailable, 2)).
It also models queues (limits, pause, rate limits, fairness, dead letters), issues, staged progress, spans and the run trace, and schedules on a clock you control:
fake.clock.set(new Date("2026-11-12T03:59:30Z"));
fake.clock.advance(60_000); // fires the 04:00 occurrence
fake.schedules.occurrences(scheduleId); // what fired, skipped or was refusedLike the api, the fake refuses payload keys the handler's manifest does not
declare as inputs. It retries an ABANDONED attempt only on an
interruptible node.
It serves PipelinesService too, so code that starts stored pipelines can be
tested without a server. Use the generated client against it:
import { createClient } from "@connectrpc/connect";
import { PipelinesService } from "@xeonr/pipelines-sdk/gen/xeonr/pipelines/v1/pipelines_pb";
const stored = createClient(PipelinesService, fake.transport());
const scope = { kind: "acme.library", id: "lib-7" };
const { pipeline } = await stored.setPipeline({ pipeline: { tenant: FAKE_TENANT, scope, name: "nightly-scan", draft: { definition } } });
await stored.publishPipeline({ pipelineId: pipeline!.id }); // version 1
const { run } = await client.createRun({ idempotencyKey: "n1", tenant: FAKE_TENANT, resource: scope, pipeline: { id: pipeline!.id } });What it models of them, as pipelines-api does:
- Stored pipelines: drafts saved as given, guarded by
expected_draft_revisionand narrowed byupdate_mask; publish checks the draft asCreateRunwould and freezes version N+1 (or answersunchanged), filling nodes' retry and timeout from the policy; archive. A run of a version (by id, by name, orsnapshot_id) has originPUBLISHED, its variables checked and defaulted, and its resource held to the pipeline's scope orresource_kinds.max_concurrent_runsholds further runsQUEUED. A schedule's pipeline target starts a version. - Sub-pipeline nodes: pinned to a version when the snapshot is made
(a cycle, nesting over three deep, another tenant's or an unpublished
pipeline, an unknown variable or output node are
invalid_argument). Each attempt is one child run (RUN_TRIGGER_PARENT,parent_run_id) about the parent's resource; its outputs map back to the node. A failed child fails the attempt asDOWNSTREAM_FAILED, and a cancel of the parent cancels it. for_eachnodes, on handler and sub-pipeline nodes: the list from a literal, a variable or an upstream kv output;${{ item }},${{ item.<path> }}and${{ item_index }}inwith;max_items,max_paralleland the threeon_failurepolicies; each element retried on its own; outputs as lists in element order (null for a failed element);RetryNoderuns only the failed elements again.
It models secrets and blobs (PIPE-169):
fake.setSecret(name, value), and grants (optionalincluded) delivered sealed to the claim's key; a required secret that does not exist fails the attemptSECRETS_UNAVAILABLE;- the attempt token and its revocation;
- blob outputs (one PUT or multipart, with
blobPartSizeBytes), checked at finalise; - blob inputs from
${{ steps.<node>.outputs.blobs.<slot> }}; GetBlobOutput;CreateIdTokenfor the node'sid_token_audiences, an unsigned JWT.
Its presigned URLs are served only by fake.fetch: pass it as the worker's
fetch.
It does not model tiers, routing between pools,
exclusions, for_each on an external (image) node, or a variable schema
beyond its top-level type. ValidateDefinition answers the first problem
it finds, where the api lists every one.
Conformance suite
src/conformance/suite.ts holds the cases both SDKs must pass against
pipelines-api, with the ids, steps and expectations of the Go SDK's
CONFORMANCE.md (xeonr/pipelines/sdk-go), which is the canonical list:
| Id | Case |
|---|---|
| C1 | Enqueue runs a job in-process (idempotent, kv output, log line) |
| C2 | A delayed job does not start early |
| C3 | Retry by class (transient-marked, unmarked, listed) |
| C4 | A permanent failure is not retried |
| C5 | A cancel stops the handler |
| C6 | A lost lease is retried on another replica (an interruptible job) |
| C7 | Shutdown releases unstarted attempts |
| C8 | Another owner's handlers are unclaimable |
| C9 | A job goes through its queue (and one naming none, default) |
| C10 | An unknown queue is not_found |
| C11 | A job over its queue's ceiling is refused (invalid_argument) |
| C12 | max_concurrency holds across workers |
| C13 | Pause, then resume |
| C14 | A dead letter is requeued |
| C15 | A handler's reports (stages, progress, issues, a span) reach the run |
| C16 | A handler reads its granted secrets (an optional one withheld; the value masked in the log) |
| C17 | A handler commits blob outputs by slot and filename (one PUT and multipart) |
| C18 | A handler reads a blob input (by URL and streamed) |
| C19 | A handler mints a job identity token (and an unlisted audience is refused) |
The cases run against the fake in every pnpm test, as sdk-go's CI runs its
suite against its own fake. That checks the cases hold together, not that
pipelines-api conforms. To run them against a real pipelines-api, set these
variables (otherwise the suite is skipped):
| Variable | Value |
|---|---|
| PIPELINES_API_URL | the api's base URL |
| PIPELINES_TOKEN | an access token; or PIPELINES_SA_ASSERTION with PIPELINES_TOKEN_URL |
| PIPELINES_TENANT | the owner's team URN, which owns the queues |
| PIPELINES_NAMESPACE | optional: a registry namespace the team owns or may claim, default sdkconf |
| PIPELINES_OTHER_TOKEN, PIPELINES_OTHER_TENANT | optional: another team's service account, for C8 |
| PIPELINES_LEASE_MS | optional: the server's lease, default 60000 |
| PIPELINES_ID_TOKEN_AUDIENCE | optional: an audience the tenant's policy allows, for C19 |
C16 needs a secret set through SecretsService, which seals it to the api's
key, so it runs only against the fake.
The service accounts need pipelines:worker:edit, pipelines:package:edit,
pipelines:pool:edit, pipelines:run:edit, pipelines:run:read,
pipelines:queue:read and pipelines:queue:edit, and must be members of
their tenant's team.
PIPELINES_API_URL=... PIPELINES_TOKEN=... PIPELINES_TENANT=... pnpm vitest run src/conformance/api.test.tsDependencies
| Package | Why |
|---|---|
| @connectrpc/connect-node (dependency) | the Connect transport over Node's HTTP |
| tweetnacl, @noble/hashes (dependencies) | opening the sealed box an attempt's secrets arrive in (X25519, XSalsa20-Poly1305, blake2b nonce) |
| @connectrpc/connect, @bufbuild/protobuf (peers) | the generated clients and messages; peers, so your app has one copy |
Nothing else at runtime. The token exchange and blob transfers use the global fetch.
Development
pnpm install
pnpm typecheck && pnpm lint && pnpm test && pnpm buildThe Connect code is generated from the BSR before every typecheck, lint, test
and build. The modules are proto.prod.wtf/xeonr/pipelines and
xeonr/pipelines-private, pinned in buf.gen.yaml. Nothing generated is
committed (ui.no-generated-code). Log in once with
buf registry login proto.prod.wtf. To pick up a contract change, bump the
pins in buf.gen.yaml.
Releasing means bumping version in package.json on main. CI publishes
any version the registry does not have yet.
See CLAUDE.md for the plan, the tickets and Plumb.
