Skip to content

feat(run-ops): cross-producer ClickHouse version helper + cross-Postgres-version compat tests#4114

Merged
d-cs merged 3 commits into
mainfrom
runops/pr03-clickhouse-tc
Jul 3, 2026
Merged

feat(run-ops): cross-producer ClickHouse version helper + cross-Postgres-version compat tests#4114
d-cs merged 3 commits into
mainfrom
runops/pr03-clickhouse-tc

Conversation

@d-cs

@d-cs d-cs commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

What

  • Adds composeTaskRunVersion to @internal/clickhouse (exported from the package index). It packs a small originGeneration epoch into the top 8 bits of the ReplacingMergeTree version and keeps the producer's own LSN in the low 56 bits, so task_runs_v2 rows replicated from more than one Postgres producer become globally comparable while preserving in-producer ordering. Single-producer setups never call it and keep using the raw LSN version.
  • Adds unit coverage for the helper in taskRuns.test.ts (bit layout, ordering, epoch precedence, range validation).
  • Adds two run-engine tests that exercise the cross-Postgres-version testcontainer fixture:
    • heteroPostgresFixture.test.ts — a smoke test asserting byte-identity and identical ORDER BY (under a pinned ICU collation) across two different Postgres major versions.
    • crossVersionCompat.test.ts — mirrors the run-engine's real raw-SQL surfaces and asserts byte-identical, ordering-identical results across the two versions. Ships with an env-gated block (skipped by default) that can be pointed at a real dedicated database in CI.

Why

Third PR in the run-ops split stack. It is purely additive: it introduces one new exported helper plus tests and changes no runtime call sites, so on its own it has no runtime behavior change. It lays down the version-composition primitive and the cross-version compatibility proof that later PRs in the stack rely on.

Tests

  • New unit tests for composeTaskRunVersion in internal-packages/clickhouse/src/taskRuns.test.ts (run against a real ClickHouse testcontainer).
  • New cross-version tests in internal-packages/run-engine/src/engine/tests/ running against real Postgres containers of two different major versions (no mocks). The env-gated dedicated-database block is skipped unless its URL is set.

Notes

Draft, stacked on #4113 (runops/pr02-db-foundation). Review that first; this diff is against it.

Server-change / changeset note to be added at stack-assembly time.

🤖 Generated with Claude Code

@changeset-bot

changeset-bot Bot commented Jul 2, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 9612579

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@d-cs d-cs self-assigned this Jul 2, 2026
@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 427cf227-0f80-4bf5-8d21-9714260491ae

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch runops/pr03-clickhouse-tc

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

devin-ai-integration[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

@d-cs d-cs force-pushed the runops/pr02-db-foundation branch from 32525bb to 9b2b67d Compare July 2, 2026 18:02
@d-cs d-cs force-pushed the runops/pr03-clickhouse-tc branch from 7e5633b to d331802 Compare July 2, 2026 18:02
@pkg-pr-new

pkg-pr-new Bot commented Jul 2, 2026

Copy link
Copy Markdown

Open in StackBlitz

@trigger.dev/build

npm i https://pkg.pr.new/@trigger.dev/build@9612579

trigger.dev

npm i https://pkg.pr.new/trigger.dev@9612579

@trigger.dev/core

npm i https://pkg.pr.new/@trigger.dev/core@9612579

@trigger.dev/python

npm i https://pkg.pr.new/@trigger.dev/python@9612579

@trigger.dev/react-hooks

npm i https://pkg.pr.new/@trigger.dev/react-hooks@9612579

@trigger.dev/redis-worker

npm i https://pkg.pr.new/@trigger.dev/redis-worker@9612579

@trigger.dev/rsc

npm i https://pkg.pr.new/@trigger.dev/rsc@9612579

@trigger.dev/schema-to-json

npm i https://pkg.pr.new/@trigger.dev/schema-to-json@9612579

@trigger.dev/sdk

npm i https://pkg.pr.new/@trigger.dev/sdk@9612579

commit: 9612579

@d-cs d-cs force-pushed the runops/pr02-db-foundation branch from d1fd926 to dc3d806 Compare July 2, 2026 19:25
@d-cs d-cs force-pushed the runops/pr03-clickhouse-tc branch 2 times, most recently from 857e7d6 to 6062eac Compare July 3, 2026 08:51
@d-cs d-cs force-pushed the runops/pr02-db-foundation branch from 026833a to bb1bd8f Compare July 3, 2026 09:12
@d-cs d-cs force-pushed the runops/pr03-clickhouse-tc branch from 6062eac to 086715f Compare July 3, 2026 09:12
@d-cs d-cs force-pushed the runops/pr02-db-foundation branch from 23edf6d to 739c923 Compare July 3, 2026 09:57
@d-cs d-cs force-pushed the runops/pr03-clickhouse-tc branch from 0c9f1bb to 271eca8 Compare July 3, 2026 09:57
@d-cs d-cs force-pushed the runops/pr02-db-foundation branch from 739c923 to ea51491 Compare July 3, 2026 10:33
@d-cs d-cs force-pushed the runops/pr03-clickhouse-tc branch 2 times, most recently from eaa09cf to bf7ca7d Compare July 3, 2026 10:43
Base automatically changed from runops/pr02-db-foundation to main July 3, 2026 11:05
d-cs and others added 3 commits July 3, 2026 12:07
…ers run-ops dep

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…nation test

The keyset walk paged with createdAt > cursor while ordering DESC, so it
re-fetched newer rows instead of advancing to older ones and terminated
after one page — never exercising the page boundary. Both clients failed
identically, so the equality assertion passed on broken data. Use a
composite (createdAt, id) cursor with the correct direction so paging
walks the full corpus and applies the id tie-break across tie groups.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@d-cs d-cs force-pushed the runops/pr03-clickhouse-tc branch from bf7ca7d to 9612579 Compare July 3, 2026 11:08
@d-cs d-cs marked this pull request as ready for review July 3, 2026 11:22
@d-cs d-cs merged commit a93b101 into main Jul 3, 2026
46 checks passed
@d-cs d-cs deleted the runops/pr03-clickhouse-tc branch July 3, 2026 12:02
d-cs added a commit that referenced this pull request Jul 3, 2026
## 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants