Conversation
There was a problem hiding this comment.
Reviewed the new PostgreSQL persistence lifecycle, schema ownership, encryption binding, and recovery paths.
Findings:
- Recovered batch acknowledgements can still persist non-accepted outcomes through the provider-facing method without reconciliation.
- A recovered finish with no staged operations can be recorded as accepted without reconciliation.
There was a problem hiding this comment.
Reviewed the PostgreSQL persistence lifecycle, recovery behavior, snapshot membership updates, and schema changes.
Findings:
- A staged operation can be finalized after a later accepted operation and revert the effective membership.
- A partially staged batch can have its recovery metadata replaced without any outcome transition.
There was a problem hiding this comment.
Reviewed the PostgreSQL persistence schema, fencing/ownership, encrypted journal recovery, and snapshot paths. No new actionable correctness or security issues found.\n\nValidation: corepack pnpm --filter @jitsu-internal/retl-runner typecheck passed. The package test command could not run in this checkout because the local vitest executable is unavailable.
## Summary JITSU-227. Stacked on #1516 (`feat/jitsu-227-persistence`); merge persistence first. This PR adds the server-side snapshot-mirror library, not an executable runner or production enablement. - Collect and validate the complete source, seal its desired snapshot, then deliver bounded additions before planning removals. - Keep snapshots and diff planning in core. Adapters provide pure identity/payload projection and ordinary writers, with explicit per-batch acceptance and removal support; no snapshot API is added to writer context. - Persist exact normalized request manifests and accepted membership changes. Permanent row rejection stops the run; ambiguous calls preserve recovery evidence. - Recover sealed snapshots through explicit provider reconciliation and session attachment, without re-reading changed SQL or re-normalizing identities. Promote the generation only after accepted finalization, including empty/unchanged snapshots. - Document target-baseline admission, incomplete-source restart, provider contracts, and caller-owned lease renewal/cancellation. Billing, schema changes, source-to-identity association tables, live destination adapters, UI, native replacement, and syncctl/CronJobs are intentionally excluded. The next slice wires the executable Node runner into syncctl/CronJobs. ## Validation - PostgreSQL integration tests use disposable containers and restricted runtime roles, including failure/recovery, stale ownership, removal ordering, and request bounds. - All 105 tests pass with `RETL_MIRROR_SCALE_TEST=1` (80 persistence + 25 mirror). - The opt-in scale test seeds one million synthetic SQL identities to verify bounded diff pagination; it is not a full extraction/encryption/provider-throughput benchmark. - Runner TypeScript check and targeted ESLint pass. No live advertising APIs or production databases were accessed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Scope
Third implementation slice of
JITSU-227, on merged #1509. #1512 was closed by the owner and is deliberately excluded.Adds server-only Node/PostgreSQL delivery persistence under
services/retl-runner; no executable runner, CronJob, provider adapter or live delivery is enabled.reverse_sync_*models in the existing console Prisma schema; no separateretlnamespace or standalone migration. Compact encrypted cursor/store/generation state reusessource_state.prisma db pushmanages all tables, enums, keys and indexes. No supplemental CHECK, custom schema-update wrapper, Docker/Helm changes, or extra deployment bundle.pgtransactions use the same configured schema with a transaction-local search path and narrowly scoped runtime-role grants.DeliveryJournalfacade with no database/keyring/snapshot access. Contiguous checkpoint validation, safe abort boundaries and restartable staged-finish resolution.Billing explicitly excluded
Per owner request, this PR contains no billing-period inputs/validation, activation ledger, usage events/outbox/publisher, billing-service integration, entitlement enforcement, quota reservations, pricing or invoicing. All billing work is deferred to a separate slice.
Receipts remain for delivery recovery, not billing.
accepted_atis the database-clock time at which Jitsu acknowledged the verified outcome, not a remote delivery timestamp or billing-period attribution. Recovery no longer requires a remote timestamp or billing proof; only core reconciliation methods can resolve any unresolved recovered operation, whether accepted, rejected or staged. Accepted recovered finish also requires reconciliation even when no rows were staged. Interrupted finish resolution reuses its saved acknowledgement time.Other boundaries
The caller must already hold the Kubernetes sync lease. Executable runner/syncctl wiring, independent task/log/status observation, lease-renewal loops and cancellation follow in subsequent slices. DB fencing does not promise provider-side fencing or exactly-once remote delivery.
Core projection supplies provider-ready identity/upsert/removal values; no vendor normalization rule is invented here. Mirror planner orchestration, million-member performance validation and the first verified Google adapter remain next. The existing upsert lifecycle still refuses mirror execution. Snapshot page sequences are not warehouse cursors: callers must reproduce an ambiguous page from a stable/replayable source and await acknowledgement before advancing; extraction resumption remains part of runner orchestration.
Controlled config/target/mode changes fail closed until the reset/transfer workflow exists. Retention is explicit and lease-fenced; no background sweep is started by this package.
Validation
Next: core snapshot-mirror orchestration and recovery/performance tests, followed by runnable Node service and syncctl/CronJobs. Billing will be a separate implementation slice.