c266e96c87
## What Introduces the run-store routing seam and the run-engine read seams that let run lifecycle operations be dispatched to either the control-plane database or a separately-generated run-ops database, depending on where a run/batch resides. - **run-store** (`internal-packages/run-store`): adds `runOpsStore.ts` and substantially expands `PostgresRunStore.ts` so the store can resolve residency and route reads/writes to the correct backing client. `types.ts` grows the routing/residency types; `NoopRunStore.ts` is removed. - **run-engine** (`internal-packages/run-engine`): adds `engine/controlPlaneResolver.ts` and routes the per-system read paths (dequeue, enqueue, waitpoint, checkpoint, run-attempt, ttl, delayed-run, execution-snapshot, pending-version, debounce, batch) through the resolver/store instead of talking to a single Prisma client directly. `engine/errors.ts`, `engine/types.ts`, and `engine/index.ts` are extended to support injecting the store/resolver. Three fixes are included on top of the seam work: - `c6cadd85f` — routes read-your-writes to the owning store's **writer**, not its lagging replica, so an operation immediately reading back what it just wrote sees a consistent result. - `05c912e05` — normalizes run-ops-generation Prisma errors to the control-plane error class at the store **write boundary**, so `instanceof` checks and the `P2002` → 422 handling continue to work across the separately-generated run-ops Prisma client. - `88d12907f` — resolves NEW-resident batches in `ApiBatchResultsPresenter` by routing the batch read through the store, so a dedicated-DB batch resolves instead of returning 404. The change is heavily test-first: the bulk of the diff is new unit/integration coverage for the store routing, residency, and each run-engine system's control-plane resolver path. ## Why PR4 of the run-ops split stack (PR1–PR3 land the ClickHouse test-container and earlier plumbing). This PR is the read-path foundation: it adds the seam and read-routing but leaves the write path to route through the same seam in a later PR. Behavior-changing where the three fixes above touch existing read-your-writes / error-normalization / batch-resolution paths; otherwise additive (new store module, new resolver, injectable dependencies with existing single-client behavior preserved when no dedicated store is configured). ## Tests Extensive new vitest coverage under `run-store/src/*.test.ts` (routing, residency, dual-schema select, cross-generation error normalization, read-after-write, idempotency dedup, mixed residency, waitpoint co-location) and `run-engine/src/engine/**/*.test.ts` (per-system `controlPlaneResolver` tests, injectability, block-edge residency, waitpoint read residency, trigger-create routing, lifecycle router). Testcontainers-backed; no mocks. ## Notes Draft, **stacked on #4114** (`runops/pr03-clickhouse-tc`). Review that first; this diff is against it. Server-change / changeset note to be added at stack-assembly time. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
36 lines
1.2 KiB
TypeScript
36 lines
1.2 KiB
TypeScript
export { RunEngine } from "./engine/index.js";
|
|
export {
|
|
RunDuplicateIdempotencyKeyError,
|
|
RunOneTimeUseTokenError,
|
|
ServiceValidationError as EngineServiceValidationError,
|
|
} from "./engine/errors.js";
|
|
export type { EventBusEventArgs, EventBusEvents } from "./engine/eventBus.js";
|
|
export type { AuthenticatedEnvironment } from "./shared/index.js";
|
|
export type {
|
|
PendingVersionRunIdLookup,
|
|
PendingVersionRunIdLookupOptions,
|
|
PendingVersionRunIdLookupResult,
|
|
} from "./engine/services/pendingVersionLookup.js";
|
|
export { NoopPendingVersionRunIdLookup } from "./engine/services/pendingVersionLookup.js";
|
|
export { PassthroughControlPlaneResolver } from "./engine/controlPlaneResolver.js";
|
|
export type {
|
|
ControlPlaneResolver,
|
|
ResolvedEngineEnv,
|
|
ResolvedAuthenticatedEnv,
|
|
ResolvedWorkerVersion,
|
|
} from "./engine/controlPlaneResolver.js";
|
|
|
|
// Batch Queue exports
|
|
export { BatchQueue, BatchCompletionTracker } from "./batch-queue/index.js";
|
|
export type {
|
|
BatchQueueOptions,
|
|
InitializeBatchOptions,
|
|
CompleteBatchResult,
|
|
BatchItem,
|
|
BatchMeta,
|
|
BatchItemFailure,
|
|
BatchItemPayload,
|
|
ProcessBatchItemCallback,
|
|
BatchCompletionCallback,
|
|
} from "./batch-queue/types.js";
|