-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
feat(webapp,run-engine): Redis waitpoint coordinator arm behind a per-org mint flag #4793
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
d-cs
wants to merge
33
commits into
feat/waitpoint-envelope-resolver-tri-13441
Choose a base branch
from
feat/waitpoint-mint-flag-wiring-tri-13442
base: feat/waitpoint-envelope-resolver-tri-13441
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
064fba7
feat(run-engine): source completed-waitpoint envelope fields from bot…
d-cs 403a81d
feat(run-engine): build the frozen completed-waitpoint record set
d-cs f4f5df2
feat(run-engine): resolve completed waitpoints from the cycle record set
d-cs 420328d
feat(run-engine,run-store): write the completed-waitpoint record set …
d-cs efb947e
style: apply oxfmt
d-cs 7f9da73
test(run-store): pin that a refused carry-forward mints with its records
d-cs 7011b57
fix(run-engine,run-store): close the review findings on the waitpoint…
d-cs f223c68
feat(webapp): resolve the per-org waitpoint mint kind
d-cs f3f6096
refactor(run-engine): move the BATCH waitpoint create onto the coordi…
d-cs 23530bc
feat(run-engine): present a store waitpoint as the legacy row shape
d-cs c4e21e6
feat(run-engine): add the store arm of the waitpoint coordinator
d-cs 9c4f23d
Merge remote-tracking branch 'origin/main' into feat/waitpoint-mint-f…
d-cs 1f42cf9
fix(run-engine): make both envelope arms honour one omission contract
d-cs 8c4c6af
fix(webapp,run-engine): complete the waitpoint projection and harden …
d-cs 5b4b060
test(run-engine): prove the deriveFromRun branch against a real run row
d-cs 25833b9
Merge remote-tracking branch 'origin/feat/waitpoint-envelope-resolver…
d-cs 1e28906
chore: keep knip green while the mint-flag plumbing is unconsumed
d-cs a22757e
feat(run-engine): route waitpoint work between the two coordinator arms
d-cs 61b4716
feat(run-engine): construct the waitpoint router with an optional sto…
d-cs ec92297
feat(run-engine): mint DATETIME and MANUAL waitpoints by mint kind
d-cs 402522d
feat(run-engine): derive the trigger-time RUN waitpoint from the run …
d-cs 3d81dd5
feat(run-engine): mint the BATCH waitpoint by mint kind and arm its g…
d-cs 6200991
feat(webapp): resolve the waitpoint mint kind at every create call site
d-cs a8654cb
feat(webapp): say when a token's related runs cannot be shown
d-cs 26eb7d2
test(run-engine): route waitpoint tests through a shared engine factory
d-cs 9d5d712
fix(run-store): keep a snapshot's waitpoint links to rows that exist
d-cs 7013512
test(run-engine): run the waitpoint suite against both coordinators
d-cs 5befed2
test(run-engine): prove a run blocked by both coordinators resumes co…
d-cs 0429162
test(run-engine): run the waitpoint suite against both coordinators
d-cs bd7d2d1
fix(run-engine): write the MANUAL projection only for the call that c…
d-cs e18cc63
test(run-engine): run triggerAndWait and batchTriggerAndWait on both …
d-cs e83d119
fix(run-engine): carry batchId on the arm-aware block edge
d-cs 7048097
Merge branch 'feat/waitpoint-envelope-resolver-tri-13441' into feat/w…
d-cs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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
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
66 changes: 66 additions & 0 deletions
66
apps/webapp/app/v3/waitpointMigration/waitpointMintKind.server.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| import { $replica } from "~/db.server"; | ||
| import { env } from "~/env.server"; | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| import { BoundedTtlCache } from "~/services/realtime/boundedTtlCache"; | ||
| import { singleton } from "~/utils/singleton"; | ||
| import { logger } from "~/services/logger.server"; | ||
| import { FEATURE_FLAG } from "~/v3/featureFlags"; | ||
| import { computeWaitpointMintKind, type WaitpointMintKind } from "./waitpointMintKind.js"; | ||
|
|
||
| export type { WaitpointMintKind }; | ||
|
|
||
| // The two unions are declared separately, because the engine never imports from the | ||
| // webapp. Nothing pins them together here on purpose: every call site passes this value | ||
| // into an engine method, so a drift fails at those call sites, where the error is local | ||
| // to the code that actually broke. | ||
|
|
||
| type WaitpointSystemFlag = "legacy" | "redis"; | ||
|
|
||
| const mintCache = singleton( | ||
| "waitpointMintCache", | ||
| () => | ||
| new BoundedTtlCache<WaitpointSystemFlag | null>( | ||
| env.WAITPOINT_MINT_FLAG_CACHE_TTL_MS, | ||
| env.WAITPOINT_MINT_FLAG_CACHE_MAX_ENTRIES | ||
| ) | ||
| ); | ||
|
|
||
| // ENV-BOUND wrapper — the only place env and $replica are read. | ||
| export async function resolveWaitpointMintKind(environment: { | ||
| organizationId: string; | ||
| id: string; | ||
| /** Pass environment.organization.featureFlags from the call site. */ | ||
| orgFeatureFlags?: unknown; | ||
| }): Promise<WaitpointMintKind> { | ||
| return computeWaitpointMintKind(environment, { | ||
| globalDefault: env.WAITPOINT_SYSTEM_DEFAULT, | ||
| onError: (error) => | ||
| logger.error("[waitpointMintKind] flag read failed; minting legacy (fail-safe)", { error }), | ||
| flag: async (orgId, orgFeatureFlags) => { | ||
| // null is a cached "this org has no override", which must stay distinct from a miss: | ||
| // BoundedTtlCache reports a stored undefined as a miss, so never store undefined. | ||
| const cached = mintCache.get(orgId); | ||
| if (cached !== undefined) { | ||
| return cached ?? undefined; | ||
| } | ||
|
|
||
| // Hot-path pass-through: only read the replica when the caller passed no org flags. | ||
| const overrides = | ||
| orgFeatureFlags !== undefined | ||
| ? orgFeatureFlags | ||
| : ( | ||
| await $replica.organization.findFirst({ | ||
| where: { id: orgId }, | ||
| select: { featureFlags: true }, | ||
| }) | ||
| )?.featureFlags; | ||
|
|
||
| const value = (overrides as Record<string, unknown> | null | undefined)?.[ | ||
| FEATURE_FLAG.waitpointSystem | ||
| ]; | ||
| const resolved = value === "redis" || value === "legacy" ? value : null; | ||
|
|
||
| mintCache.set(orgId, resolved); | ||
| return resolved ?? undefined; | ||
| }, | ||
| }); | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.