feat(core): add shard-routable run-ops id format and resolveShard - #4750
Conversation
|
WalkthroughThe change adds version-2 run-ops IDs with validated shard characters, shared timestamp handling, parsing, and generation. Merge Risk: 🔵 Low · up to The PR adds inert gen-2 run-ops ID parsing and shard resolution without a production caller, but new test paths still use mocked system time and omit required crumb markers; it is mergeable with explicit owner follow-up on these bounded concerns. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
5c36a45 to
70a3df0
Compare
@trigger.dev/build
trigger.dev
@trigger.dev/core
@trigger.dev/python
@trigger.dev/react-hooks
@trigger.dev/redis-worker
@trigger.dev/rsc
@trigger.dev/schema-to-json
@trigger.dev/sdk
commit: |
A gen-2 id keeps the 26-char layout but carries a routing shard key at index 24 and version "2" at index 25, so a store can be picked from the id alone with no directory lookup. The version char is one character, so the v1 and gen-2 shape checks are mutually exclusive by construction. resolveShard is total: a gen-2 body returns its shard key, a v1 body returns "new", and everything else returns "legacy" without throwing. classifyResidency keeps its signature and now reports gen-2 ids as part of the dedicated family. Nothing mints gen-2 ids yet. The only behavior change is that a 26-char body ending in "2" now routes by its shard key instead of falling back to legacy.
da7ebab to
f229dda
Compare
Summary
Adds a second generation of run-ops id, plus the resolver that reads a store key straight out of an id. A gen-2 id keeps the existing 26-character layout, but the character at index 24 becomes a routing shard key instead of a region code, and the version character at index 25 becomes
"2". Nothing mints gen-2 ids yet, so this is inert on merge.Design
The version character is a single character, so the gen-1 and gen-2 shape checks can never both match. That is what makes the two generations provably disjoint rather than disjoint by convention.
resolveShardis total: it returns a key for any input string, including an empty or malformed one, and never throws.classifyResidencykeeps its signature and its two values, and now reports gen-2 ids as part of the dedicated family, so existing consumers of that boolean are unaffected.The body stays 26 characters rather than 27 deliberately. The older 27-character format is still in the wild and has to keep resolving to legacy, and a longer gen-2 shape would need probabilistic disambiguation against it. A rare misroute is not an acceptable property for a routing key.
The one behavior change is that a 26-character body ending in
"2"now routes by its shard key instead of falling back to legacy. Two test assertions pinned the old result and are updated here. A repository-wide search confirms they are the only two of their kind.Verified against the full run-store corpus (68 files, 370 tests) with no test-file changes there, plus the run-engine residency and waitpoint suites. No changeset: the new surface has no caller, so a version bump would tell a user nothing.