Skip to content

feat(run-store,testcontainers): execution-snapshot read comparator and shared test utilities - #4772

Merged
d-cs merged 17 commits into
mainfrom
feat/snapshot-comparator-tri-13450
Aug 25, 2026
Merged

feat(run-store,testcontainers): execution-snapshot read comparator and shared test utilities#4772
d-cs merged 17 commits into
mainfrom
feat/snapshot-comparator-tri-13450

Conversation

@d-cs

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

Copy link
Copy Markdown
Collaborator

Summary

Adds the read comparator for the in-progress migration of the run execution-snapshot log from Postgres to Redis. The comparator samples a single read against both stores, normalizes the two results to one shape, and reports any per-field difference with a tagged metric. It never serves a read itself: the diff layer imports only types, so it cannot hold a store client, and a test enforces that by failing if any value import appears.

Also adds a combined Postgres-and-Redis test fixture and two shared test utilities (a cluster-slot assertion and a generic fault-injection harness) that the parallel Redis-store work reuses.

Everything here is inert. Nothing constructs the comparator, so merging changes no runtime behavior. It becomes active only when a later change turns on compare mode.

Notes

The divergence classes separate real differences (scalar, ordering, waitpoint id set, validity, missing on one side) from two expected classes that must not be driven to zero: a rotated idempotency key, and a Redis-only surplus at a since-cursor tie. The since comparison is direction sensitive: a Postgres-only entry at the cursor is always a lost write, never an expected tie.

d-cs added 11 commits August 24, 2026 17:15
Reverts the cycleKey export, snapshotBackfill read/mapper/apply, and the CLI
wrapper (Tasks 6-9). Forward self-heal (re-enable snapshot writes) plus Redis
drain covers a redis-only rollback's correctness, and the ClickHouse audit tail
covers history, so a reverse Redis->Postgres backfill reconstructs rows nothing
reads before they age out. Removes the item from the plan's redis-only go/no-go
gate pending plan-owner sign-off. Comparator, fixture, and shared test utils
(Tasks 1-5) are unaffected.
@changeset-bot

changeset-bot Bot commented Aug 25, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: f5590a5

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

coderabbitai Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

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: 1571bcfd-c7a3-42aa-9894-d98c0905c753

📥 Commits

Reviewing files that changed from the base of the PR and between c7751d0 and 960f18c.

📒 Files selected for processing (1)
  • internal-packages/run-store/src/snapshotComparator.isolation.test.ts

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

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

📄 CodeRabbit inference engine (AGENTS.md)

Files:

  • internal-packages/run-store/src/snapshotComparator.isolation.test.ts
**Prefer static imports over dynamic imports.** Only use dynamic `import()` when:

📄 CodeRabbit inference engine (AGENTS.md)

Files:

  • internal-packages/run-store/src/snapshotComparator.isolation.test.ts
Add crumbs as you write code — not just when debugging. Mark lines with

📄 CodeRabbit inference engine (AGENTS.md)

Files:

  • internal-packages/run-store/src/snapshotComparator.isolation.test.ts
Use vitest for all tests in the Trigger.dev repository

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

Files:

  • internal-packages/run-store/src/snapshotComparator.isolation.test.ts
Use function declarations instead of default exports

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

Files:

  • internal-packages/run-store/src/snapshotComparator.isolation.test.ts
Use types over interfaces for TypeScript

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

Files:

  • internal-packages/run-store/src/snapshotComparator.isolation.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:

  • internal-packages/run-store/src/snapshotComparator.isolation.test.ts
🔇 Additional comments (1)
internal-packages/run-store/src/snapshotComparator.isolation.test.ts (1)

33-34: 🎯 Functional Correctness

The regular expression leaves value after replacing type as, so the detector still records the import. The TypeScript 7.0.2 compiler also accepts import { type as value } as valid syntax.


Walkthrough

The run-store package adds a public SnapshotComparator. It normalizes PostgreSQL and Redis snapshots, compares latest and historical records, classifies divergences, samples reads, and records metrics. Tests cover comparison rules and import isolation. The testcontainers package adds Redis cluster-slot helpers, fault injection, shared PostgreSQL and Redis fixtures, exports, and integration tests. Existing Redis tests now use the shared slot helper.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description gives a clear and relevant summary, but it does not follow the repository template. It omits the issue reference, checklist, testing steps, changelog, and screenshots sections. Add the required template sections. Include the issue reference, completed checklist items, specific testing steps and results, a short changelog entry, and screenshots or an explicit statement that screenshots are not applicable.
Docstring Coverage ⚠️ Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 14 functions across 11 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main changes: the run-store execution-snapshot read comparator and shared testcontainers utilities.
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.
✨ 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 feat/snapshot-comparator-tri-13450

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 25, 2026 10:18
@pkg-pr-new

pkg-pr-new Bot commented Aug 25, 2026

Copy link
Copy Markdown

Open in StackBlitz

@trigger.dev/build

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

trigger.dev

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

@trigger.dev/core

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

@trigger.dev/python

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

@trigger.dev/react-hooks

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

@trigger.dev/redis-worker

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

@trigger.dev/rsc

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

@trigger.dev/schema-to-json

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

@trigger.dev/sdk

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

commit: 649c996

@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.

Open in Devin Review

…shared test utilities

Carry unrecognised source keys through snapshot normalization so an unknown
field surfaces as a divergence instead of being silently dropped. Bound the
comparator metric op to a fixed union. Hash cluster-slot keys as UTF-8 bytes,
strip line comments in the import-isolation scan, and validate the fault
harness times argument.
coderabbitai[bot]

This comment was marked as resolved.

…n imports on raw source

Use an own-property check and skip __proto__/constructor/prototype so an
inherited-name field surfaces as a divergence and no key can pollute the
prototype. Scan import statements on the raw source (line-anchored) so
comment stripping cannot hide a real import.

@coderabbitai coderabbitai 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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
internal-packages/run-store/src/snapshotComparator.isolation.test.ts (1)

29-32: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Handle aliases in inline type-only imports.

For import { type Foo as Bar } from "pkg", the replacement removes only type Foo and leaves as Bar. The subsequent check can classify as as a value specifier, although TypeScript 7.0.2 accepts this type-only import.

Parse each named specifier and ignore the complete type Foo as Bar form.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 6d991186-9b6b-43a7-b7fd-afe9fa0e7a3f

📥 Commits

Reviewing files that changed from the base of the PR and between 26b6e9a and 8766d54.

📒 Files selected for processing (3)
  • internal-packages/run-store/src/snapshotComparator.isolation.test.ts
  • internal-packages/run-store/src/snapshotComparator.test.ts
  • internal-packages/run-store/src/snapshotComparator.ts

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

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

📄 CodeRabbit inference engine (AGENTS.md)

Files:

  • internal-packages/run-store/src/snapshotComparator.isolation.test.ts
  • internal-packages/run-store/src/snapshotComparator.test.ts
**Prefer static imports over dynamic imports.** Only use dynamic `import()` when:

📄 CodeRabbit inference engine (AGENTS.md)

Files:

  • internal-packages/run-store/src/snapshotComparator.isolation.test.ts
  • internal-packages/run-store/src/snapshotComparator.test.ts
  • internal-packages/run-store/src/snapshotComparator.ts
Add crumbs as you write code — not just when debugging. Mark lines with

📄 CodeRabbit inference engine (AGENTS.md)

Files:

  • internal-packages/run-store/src/snapshotComparator.isolation.test.ts
  • internal-packages/run-store/src/snapshotComparator.test.ts
  • internal-packages/run-store/src/snapshotComparator.ts
Use vitest for all tests in the Trigger.dev repository

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

Files:

  • internal-packages/run-store/src/snapshotComparator.isolation.test.ts
  • internal-packages/run-store/src/snapshotComparator.test.ts
Use function declarations instead of default exports

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

Files:

  • internal-packages/run-store/src/snapshotComparator.isolation.test.ts
  • internal-packages/run-store/src/snapshotComparator.test.ts
  • internal-packages/run-store/src/snapshotComparator.ts
Use types over interfaces for TypeScript

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

Files:

  • internal-packages/run-store/src/snapshotComparator.isolation.test.ts
  • internal-packages/run-store/src/snapshotComparator.test.ts
  • internal-packages/run-store/src/snapshotComparator.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:

  • internal-packages/run-store/src/snapshotComparator.isolation.test.ts
  • internal-packages/run-store/src/snapshotComparator.test.ts
  • internal-packages/run-store/src/snapshotComparator.ts
🪛 ast-grep (0.45.2)
internal-packages/run-store/src/snapshotComparator.ts

[error] 87-90: Recursive/iterative merge copies attacker-controllable keys from a source object into a target via a computed property assignment without rejecting dangerous keys, allowing prototype pollution. Skip or block "proto", "constructor", and "prototype" keys (e.g. if (key === "__proto__" || key === "constructor" || key === "prototype") continue;), use a null-prototype object (Object.create(null)), or use a safe merge utility instead.
Context: for (const k of Object.keys(source)) {
if (DANGEROUS_KEYS.has(k)) continue;
if (!KNOWN_KEYS.has(k) && !hasOwn(target, k)) target[k] = source[k];
}
Note: [CWE-1321] Improperly Controlled Modification of Object Prototype Attributes ('Prototype Pollution').

(prototype-pollution-recursive-merge-typescript)

🪛 GitHub Check: code-quality / code-quality
internal-packages/run-store/src/snapshotComparator.test.ts

[failure] 146-146: eslint(prefer-object-has-own)
internal-packages/run-store/src/snapshotComparator.test.ts:146:12: Disallow use of Object.prototype.hasOwnProperty.call() and prefer use of Object.hasOwn().

internal-packages/run-store/src/snapshotComparator.ts

[failure] 86-86: eslint(prefer-object-has-own)
internal-packages/run-store/src/snapshotComparator.ts:86:51: Disallow use of Object.prototype.hasOwnProperty.call() and prefer use of Object.hasOwn().

🪛 OpenGrep (1.26.0)
internal-packages/run-store/src/snapshotComparator.isolation.test.ts

[ERROR] 26-26: Dynamic command passed to child_process.exec/execSync. Use child_process.execFile or spawn with an argument array instead.

(coderabbit.command-injection.exec-js)


[ERROR] 39-39: Dynamic command passed to child_process.exec/execSync. Use child_process.execFile or spawn with an argument array instead.

(coderabbit.command-injection.exec-js)

🔇 Additional comments (1)
internal-packages/run-store/src/snapshotComparator.ts (1)

85-90: 📐 Maintainability & Code Quality

Do not replace these checks with Object.hasOwn(). The run-store source and test configurations use the ES2020 library. Object.hasOwn() requires ES2022 and would fail TypeScript checking unless the configuration changes.

…Keys

The normalizer only ever sets known keys, so a non-known source key is never
already present; the check was unnecessary and tripped the lint rule against
hasOwnProperty. Skipping the prototype-pollution keys still holds.
devin-ai-integration[bot]

This comment was marked as resolved.

…scanner

Strip an `as` alias along with the `type Foo` specifier so an aliased
type-only import isn't misread as a value import.
devin-ai-integration[bot]

This comment was marked as resolved.

Derive the Postgres waitpointIdSet from completedWaitpointOrder (index-bearing)
to match the Redis read surface, whose distinctIds is the dedupe of the same
ordered set. Comparing it against the full completedWaitpoints relation flagged
a spurious divergence for a non-indexed completed waitpoint (a single wait).
@d-cs
d-cs merged commit 45eaaa7 into main Aug 25, 2026
52 checks passed
@d-cs
d-cs deleted the feat/snapshot-comparator-tri-13450 branch August 25, 2026 13:01
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