Skip to main content

@0xintuition/pipeline-runtime

Version: V2
View Markdown

What it's for​

Promise utilities for bounded concurrency, cancellation, circuit breaking, caching, and provider observation. It supplies shared execution contracts; it does not store a graph or start a processing service.

When to use it​

Use it when a host needs ordered concurrent work or a consistent outcome vocabulary across providers. Use atom runtime to compose classification and enrichment engines. Effect services and retry layers belong to your application; these functions accept Promise callbacks.

Install​

npm install @0xintuition/pipeline-runtime@0.1.1

Use ESM import or CommonJS require() on Node 20 or newer. On Node 20.19+ / 22.12+, both resolve to the same module instance, preserving shared error-class identity. Earlier supported runtimes load separate copies when formats are mixed. The documentation examples use Node 22.21.0. See module-format compatibility.

Entry points​

All public modules
SubpathPurpose
.Shared errors, provider contracts, test helpers, and TMDB endpoint builder
./bounded-textRead streaming response text within a byte limit
./cacheCancellable cache contract and memory TTL adapter
./errorsShared pipeline error vocabulary
./provider-observerProvider observation events and contracts
./provider-metrics-contractMetric labels, normalization, and series contract
./retry-afterParse and bound retry delays
./letterboxdLetterboxd host policy and circuit state
./letterboxd-pageParse Letterboxd page identity
./tmdbTMDB endpoint policy
./testing/prometheus-expositionValidate Prometheus exposition; optional Node tool invocation
./outcomeOutcome union, cancellation, and timeout helpers
./circuit-breakerCircuit breaker, snapshots, and admission errors
./concurrencyOrdered bounded Promise execution
./provider-metrics-contract.expectedExpected provider metric series counts
./provider-registryProvider definitions and operation contracts
./provider-request-observationObserve and record provider requests
./request-slotProvider request admission contracts
./testing/provider-goldenProvider golden-fixture helpers
./testing/held-request-slotControlled request-slot test helpers
./testing/virtual-clockDeterministic clock for tests
./provider-metricsAlias of the provider metrics contract

Depends on and works with​

Runtime package dependencies: none. Peer dependencies: none.

Classification, enrichment, and atom runtime consume these contracts. A memory cache is process-local; an adapter is not a provisioned database. Provider-specific host policies do not replace your application's complete egress policy.

Example​

This fixed input needs no network or credentials. The result keeps input order even when callbacks finish in a different order.

import { forEachBounded } from '@0xintuition/pipeline-runtime/concurrency';

const controller = new AbortController();
export const outcomes = await forEachBounded(
['recording', 'artist', 'release'],
async (label, signal) => {
signal.throwIfAborted();
return label.toUpperCase();
},
{ concurrency: 2, signal: controller.signal },
);

for (const outcome of outcomes) {
if (outcome.kind === 'success') console.log(outcome.value);
else console.log(outcome.kind);
}

Successful outcomes carry value. The full outcome union also includes failure, defect, timeout, and interrupted. In forEachBounded, a synchronous callback throw is a defect and a returned Promise rejection is a failure. Parent cancellation rejects the batch with its abort reason, prevents queued work, and signals active callbacks; callbacks must honor that signal to stop I/O.

CircuitBreaker.execute admits one probe after its reset window. Its failure filter determines whether an admitted failure or cancellation counts toward opening the circuit; cancellation before admission starts no work. Inspect snapshot() without changing state.

See also How the pieces fit, Classify and enrich atoms.

Source​

Package README, public exports, and concurrency implementation.

Applies to V2 · @0xintuition/pipeline-runtime 0.1.1