Skip to content

test(run-store,webapp): cover the run-ops router at three shards - #4805

Merged
d-cs merged 3 commits into
mainfrom
test/fake-slot-shard-parameterization-tri-13433
Aug 28, 2026
Merged

test(run-store,webapp): cover the run-ops router at three shards#4805
d-cs merged 3 commits into
mainfrom
test/fake-slot-shard-parameterization-tri-13433

Conversation

@d-cs

@d-cs d-cs commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator

Summary

Several of the run-ops router's rules only apply above two stores, and the fake-slot suites only ever built two, so those rules were untestable by construction. clearIdempotencyKey is the sole caller of the "every other shard" helper, and with two stores that helper returns a single entry, which hides a take-the-first bug. The absent-id partition has the same blind spot: a gen-2 id and a cuid select the same store when only one other store exists.

Three suites now run at two shards and at three, with the expected value indexed by topology wherever the rule genuinely changes. The fourth stays at two and says why in the file, because its N-shard behaviour is already pinned in runOpsStore.shardMap.test.ts.

Two webapp tests defined their own local RoutingRunStore. They compiled against a two-store model whatever the real class did, and one described a routing rule the code never implemented. Both now build the real router over the two Postgres stores they already create.

Validating a test-only change

Every new assertion passed the first time it ran, which proves nothing. Each was checked by breaking the router in the way the test claims to guard, then confirming the failure lands in the three-shard arm while the two-shard arm still passes:

  • take-the-first fan-out in the "every other shard" helper
  • gen-2 keys moved to the front of the merge precedence order
  • the absent-id partition sending every id to the gen-1 pair, which fails as expected +0 to be 1, the shape a silently under-counted waitpoint takes
  • residency routing disabled entirely, caught by 3 of the 5 webapp tests

Each mutation was reverted. No production code changes.

One note for anyone extending these: the webapp resolves @internal/run-store to dist/, not to source, so a source edit without a rebuild makes those two tests assert against the previous router and pass.

d-cs added 2 commits August 27, 2026 15:59
The fake-slot router suites only ever built two stores, so several rules that
only apply above two were untestable by construction. clearIdempotencyKey is
the sole caller of the "every other shard" helper, and with two stores that
helper returns a single entry, which hides a take-the-first bug. The absent-id
partition has the same blind spot: a gen-2 id and a cuid select the same store
when only one other store exists.

Three suites now run at two shards and at three. Each new assertion was checked
by mutating the router to the failure it guards, confirming the three-shard arm
fails while the two-shard arm still passes, then reverting.

Two webapp tests defined their own local RoutingRunStore. They compiled against
a two-store model whatever the real class did, and one described a routing rule
the code never implemented. Both now build the real router over the two
Postgres stores they already create.

No production code changes.
@changeset-bot

changeset-bot Bot commented Aug 27, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 800e8c6

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 Aug 27, 2026
@coderabbitai

coderabbitai Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: ae901401-f8cb-4f7c-811d-59af83b85891

📥 Commits

Reviewing files that changed from the base of the PR and between 0440909 and 800e8c6.

📒 Files selected for processing (2)
  • apps/webapp/test/performTaskRunAlertsStoreRouting.test.ts
  • apps/webapp/test/updateMetadataStoreRoutingHetero.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.

📜 Recent review details
⏰ Context from checks skipped due to timeout. (32)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (16, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (23, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (21, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (24, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (20, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (19, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (8, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (22, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (18, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (14, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (3, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (11, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (15, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (7, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (17, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (13, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (2, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (6, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (1, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (5, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (10, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (12, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (4, 24)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (9, 24)
  • GitHub Check: e2e-webapp / 🧪 E2E Tests: Webapp (2, 2)
  • GitHub Check: e2e-webapp / 🧪 E2E Tests: Webapp (1, 2)
  • GitHub Check: typecheck / typecheck
  • GitHub Check: fk-cascade-guard / fk-cascade-guard
  • GitHub Check: internal / 🧪 Unit Tests: Internal
  • GitHub Check: runops-guard / runops-guard
  • GitHub Check: code-quality / code-quality
  • GitHub Check: Analyze (javascript-typescript)
🧰 Additional context used
📓 Path-based instructions (11)
We use vitest exclusively. **Never mock anything** - use testcontainers instead.

📄 CodeRabbit inference engine (AGENTS.md)

Files:

  • apps/webapp/test/updateMetadataStoreRoutingHetero.test.ts
  • apps/webapp/test/performTaskRunAlertsStoreRouting.test.ts
Test files must not import `app/env.server.ts`; pass configuration as options instead.

📄 CodeRabbit inference engine (apps/webapp/CLAUDE.md)

Files:

  • apps/webapp/test/updateMetadataStoreRoutingHetero.test.ts
  • apps/webapp/test/performTaskRunAlertsStoreRouting.test.ts
**Prefer static imports over dynamic imports.** Only use dynamic `import()` when:

📄 CodeRabbit inference engine (AGENTS.md)

Files:

  • apps/webapp/test/updateMetadataStoreRoutingHetero.test.ts
  • apps/webapp/test/performTaskRunAlertsStoreRouting.test.ts
Add crumbs as you write code — not just when debugging. Mark lines with

📄 CodeRabbit inference engine (AGENTS.md)

Files:

  • apps/webapp/test/updateMetadataStoreRoutingHetero.test.ts
  • apps/webapp/test/performTaskRunAlertsStoreRouting.test.ts
Use zod for validation in packages/core and apps/webapp

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Files:

  • apps/webapp/test/updateMetadataStoreRoutingHetero.test.ts
  • apps/webapp/test/performTaskRunAlertsStoreRouting.test.ts
Do not import `env.server.ts` directly or indirectly into test files; instead pass environment-dependent values through options/parameters to make code testable

📄 CodeRabbit inference engine (.cursor/rules/webapp.mdc)

Files:

  • apps/webapp/test/updateMetadataStoreRoutingHetero.test.ts
  • apps/webapp/test/performTaskRunAlertsStoreRouting.test.ts
Access environment variables through the `env` export of `env.server.ts` instead of directly accessing `process.env`

📄 CodeRabbit inference engine (.cursor/rules/webapp.mdc)

Files:

  • apps/webapp/test/updateMetadataStoreRoutingHetero.test.ts
  • apps/webapp/test/performTaskRunAlertsStoreRouting.test.ts
Use vitest for all tests in the Trigger.dev repository

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Files:

  • apps/webapp/test/updateMetadataStoreRoutingHetero.test.ts
  • apps/webapp/test/performTaskRunAlertsStoreRouting.test.ts
Use function declarations instead of default exports

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Files:

  • apps/webapp/test/updateMetadataStoreRoutingHetero.test.ts
  • apps/webapp/test/performTaskRunAlertsStoreRouting.test.ts
Use types over interfaces for TypeScript

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Files:

  • apps/webapp/test/updateMetadataStoreRoutingHetero.test.ts
  • apps/webapp/test/performTaskRunAlertsStoreRouting.test.ts
When creating or editing OTEL metrics (counters, histograms, gauges), ensure metric attributes have low cardinality by using only enums, booleans, bounded error codes, or bounded shard IDs

📄 CodeRabbit inference engine (.cursor/rules/otel-metrics.mdc)

Files:

  • apps/webapp/test/updateMetadataStoreRoutingHetero.test.ts
  • apps/webapp/test/performTaskRunAlertsStoreRouting.test.ts
🔇 Additional comments (2)
apps/webapp/test/performTaskRunAlertsStoreRouting.test.ts (1)

2-12: LGTM!

Also applies to: 30-43, 261-262

apps/webapp/test/updateMetadataStoreRoutingHetero.test.ts (1)

2-28: LGTM!

Also applies to: 26-30, 261-262


Walkthrough

Webapp tests now use the production RoutingRunStore over real PostgresRunStore instances. Run-store tests cover compatibility and three-shard topologies with gen-2 support. The tests validate residency routing, fallback fan-out, idempotency resets, mixed-residency queries, transaction handling, pagination, duplicate-ID metrics, primary-client escalation, and keyed waitpoint partitioning. One suite documents its deliberate two-store scope.

Merge Risk: ⚪ Minimal · up to 800e8

This PR expands coverage for existing two- and three-shard routing behavior and uses the production router in webapp tests without changing runtime behavior. No actionable merge-blocking risk remains beyond normal checks and review.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 54.55% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 6 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The description clearly explains the test-only changes, affected suites, routing behaviors, validation steps, and the absence of production code changes. It does not use every template section, but th…
Title check ✅ Passed The title clearly identifies the test scope, the run-store and webapp areas, and the main change: coverage of the run-ops router across three shards.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description clearly explains the test-only changes, affected suites, routing behaviors, validation steps, and the absence of production code changes. It does not use every template section, but the missing checklist, changelog, and screenshots are non-critical for this test-focused change.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/fake-slot-shard-parameterization-tri-13433

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.

coderabbitai[bot]

This comment was marked as resolved.

@d-cs
d-cs marked this pull request as ready for review August 28, 2026 10:17

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

Production builds the NEW run-ops store with schemaVariant "dedicated", but
both hetero routing tests omitted it, so the store defaulted to "legacy". The
two variants take different read paths: findRun routes through the dedicated
relation-stripping adapter only when the variant is set, so the tests were
exercising the legacy path for a store that is dedicated in production.

Verified the branch is now reached by making the dedicated arm throw, which
failed 3 of the 5 tests.
@d-cs
d-cs merged commit adcf0e7 into main Aug 28, 2026
54 checks passed
@d-cs
d-cs deleted the test/fake-slot-shard-parameterization-tri-13433 branch August 28, 2026 10:51
claude Bot pushed a commit that referenced this pull request Aug 28, 2026
Resolves the two conflicts in the store-routing tests. Upstream (#4805) replaced
each file's hand-rolled test-local RoutingRunStore shim with the real
RoutingRunStore from @internal/run-store, so the shim's removeTags forwarder this
branch had added is obsolete; the real router already carries removeTags.

Co-Authored-By: Claude <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