Skip to content

Commit 54efdaf

Browse files
d-csTrigger.dev RepoOps
authored andcommitted
chore(run-store,run-engine): remove unused updateManyWaitpoints and RunEngine.getWaitpoint
Removes two internal methods that nothing called: the run store's `updateManyWaitpoints` and the run engine's `getWaitpoint`. Mono-RevId: e96257f2662a8c9b7b026bb4f591bf5ddd90ba7a
1 parent 5799042 commit 54efdaf

19 files changed

Lines changed: 55 additions & 291 deletions

‎apps/webapp/test/api.v1.waitpoints.tokens.test.ts‎

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,10 @@ describe("waitpoint-token create engine seam — residency-keyed id contract", (
116116

117117
expect(ownerEngine(result.waitpoint.id)).toBe("LEGACY");
118118

119-
const resolved = await engine.getWaitpoint({
120-
waitpointId: result.waitpoint.id,
121-
environmentId: env.id,
122-
projectId: env.project.id,
123-
});
119+
const resolved = await engine.runStore.findWaitpoint(
120+
{ where: { id: result.waitpoint.id } },
121+
engine.prisma
122+
);
124123
expect(resolved).not.toBeNull();
125124
expect(resolved?.id).toBe(result.waitpoint.id);
126125
} finally {
@@ -361,11 +360,10 @@ describe("waitpoint-token create engine seam — NEW residency via a run-ops run
361360
expect(onNew).not.toBeNull();
362361
expect(onLegacy).toBeNull();
363362

364-
const resolved = await engine.getWaitpoint({
365-
waitpointId: waitpoint.id,
366-
environmentId: env.environment.id,
367-
projectId: env.project.id,
368-
});
363+
const resolved = await engine.runStore.findWaitpoint(
364+
{ where: { id: waitpoint.id } },
365+
engine.prisma
366+
);
369367
expect(resolved?.id).toBe(waitpoint.id);
370368
expect(await p14.waitpoint.findUnique({ where: { id: waitpoint.id } })).toBeNull();
371369
} finally {

‎internal-packages/run-engine/src/engine/index.ts‎

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2869,39 +2869,6 @@ export class RunEngine {
28692869
);
28702870
}
28712871

2872-
async getWaitpoint({
2873-
waitpointId,
2874-
environmentId,
2875-
}: {
2876-
environmentId: string;
2877-
projectId: string;
2878-
waitpointId: string;
2879-
}): Promise<Waitpoint | null> {
2880-
const waitpoint = await this.runStore.findWaitpoint(
2881-
{
2882-
where: { id: waitpointId },
2883-
include: {
2884-
blockingTaskRuns: {
2885-
select: {
2886-
taskRun: {
2887-
select: {
2888-
id: true,
2889-
friendlyId: true,
2890-
},
2891-
},
2892-
},
2893-
},
2894-
},
2895-
},
2896-
this.prisma
2897-
);
2898-
2899-
if (!waitpoint) return null;
2900-
if (waitpoint.environmentId !== environmentId) return null;
2901-
2902-
return waitpoint;
2903-
}
2904-
29052872
async readExistingStoreDateTimeWaitpointByKey(params: {
29062873
runId?: string;
29072874
environmentId: string;

‎internal-packages/run-engine/src/engine/systems/waitpointSystem.test.ts‎

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,6 @@ class CountingRunStore extends PostgresRunStore {
8888
this.calls.push("forWaitpointCompletion");
8989
return super.forWaitpointCompletion(waitpointId, context);
9090
}
91-
override async updateManyWaitpoints(
92-
args: Prisma.WaitpointUpdateManyArgs,
93-
tx?: any
94-
): Promise<Prisma.BatchPayload> {
95-
this.calls.push("updateManyWaitpoints");
96-
return super.updateManyWaitpoints(args, tx);
97-
}
9891
// The completion write goes through markWaitpointCompleted (the replay-safe completion method), so
9992
// it is the DB step the guard must precede on every completion route.
10093
override async markWaitpointCompleted(
@@ -1042,7 +1035,7 @@ async function triggerChildResumingParent(
10421035
* completeWaitpoint's FIRST statement is the residency guard
10431036
* (this.$.runStore.forWaitpointCompletion). Every route that reaches
10441037
* completeWaitpoint therefore records exactly one `forWaitpointCompletion`
1045-
* BEFORE its `updateManyWaitpoints`. A missed unblock route in production is a
1038+
* BEFORE its `markWaitpointCompleted`. A missed unblock route in production is a
10461039
* silent permanent run hang, so Group 1 enumerates EVERY route exhaustively —
10471040
* the 7 callers plus the 2 in-file wrappers — and proves the
10481041
* guard fires on each, not a representative sample.
@@ -1052,12 +1045,8 @@ describe("WaitpointSystem completion fan-out + residency store-selection guard",
10521045
// than) the first completion DB write on the same store.
10531046
function expectGuardFiredBeforeUpdate(calls: string[]) {
10541047
const guardIdx = calls.indexOf("forWaitpointCompletion");
1055-
// The completion DB write is markWaitpointCompleted (some routes may also touch
1056-
// updateManyWaitpoints); take whichever completion write lands first.
1057-
const writeIdx = ["markWaitpointCompleted", "updateManyWaitpoints"]
1058-
.map((m) => calls.indexOf(m))
1059-
.filter((i) => i >= 0)
1060-
.sort((a, b) => a - b)[0];
1048+
// The completion DB write is markWaitpointCompleted.
1049+
const writeIdx = calls.indexOf("markWaitpointCompleted");
10611050
expect(guardIdx).toBeGreaterThanOrEqual(0);
10621051
expect(writeIdx).toBeGreaterThanOrEqual(0);
10631052
expect(guardIdx).toBeLessThanOrEqual(writeIdx);
@@ -1722,7 +1711,7 @@ describe("WaitpointSystem completion fan-out + residency store-selection guard",
17221711

17231712
// Cross-seam completion applied to the OWNING store: a run-ops waitpoint resides on the dedicated
17241713
// run-ops (NEW) DB, a cuid waitpoint on the legacy/control-plane DB. Driving the completion at the
1725-
// store seam (forWaitpointCompletion -> updateManyWaitpoints, as the engine does) must apply each
1714+
// store seam (forWaitpointCompletion -> markWaitpointCompleted, as the engine does) must apply each
17261715
// completion to its owning store only.
17271716
heteroPostgresTest(
17281717
"cross-seam completion lands on the owning store only",
@@ -1765,15 +1754,9 @@ describe("WaitpointSystem completion fan-out + residency store-selection guard",
17651754

17661755
const completedAt = new Date();
17671756
const runOpsOwner = await router.forWaitpointCompletion(runOpsId, { routeKind: "MANUAL" });
1768-
await runOpsOwner.updateManyWaitpoints({
1769-
where: { id: runOpsId, status: "PENDING" },
1770-
data: { status: "COMPLETED", completedAt },
1771-
});
1757+
await runOpsOwner.markWaitpointCompleted(runOpsId, { completedAt });
17721758
const ownerCuid = await router.forWaitpointCompletion(cuidId, { routeKind: "MANUAL" });
1773-
await ownerCuid.updateManyWaitpoints({
1774-
where: { id: cuidId, status: "PENDING" },
1775-
data: { status: "COMPLETED", completedAt },
1776-
});
1759+
await ownerCuid.markWaitpointCompleted(cuidId, { completedAt });
17771760

17781761
// run-ops id completed on the dedicated run-ops (NEW) DB only.
17791762
expect((await prisma17.waitpoint.findUniqueOrThrow({ where: { id: runOpsId } })).status).toBe(

‎internal-packages/run-engine/src/engine/tests/storeDateTimeTokenCompatibility.test.ts‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -233,11 +233,7 @@ describe("storeDateTimeTokenCompatibility", () => {
233233
organizationId: env.organization.id,
234234
});
235235
expect(
236-
await engine.getWaitpoint({
237-
waitpointId: manual.waitpoint.id,
238-
environmentId: env.id,
239-
projectId: env.project.id,
240-
})
236+
await engine.runStore.findWaitpoint({ where: { id: manual.waitpoint.id } }, engine.prisma)
241237
).toMatchObject({ id: manual.waitpoint.id, type: "MANUAL" });
242238
} finally {
243239
await engine.quit();

‎internal-packages/run-engine/src/engine/tests/waitpointPublicRouter.test.ts‎

Lines changed: 5 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,9 @@ vi.setConfig({ testTimeout: 60_000 });
1414
// real implementation. Dependency injection of a real store over a real container — not a mock.
1515
class CountingPostgresRunStore extends PostgresRunStore {
1616
public readonly counts = {
17-
findWaitpoint: 0,
1817
createWaitpoint: 0,
1918
};
2019

21-
// The read client passed into the most recent findWaitpoint call (args[1]).
22-
public lastFindWaitpointClient: unknown = undefined;
23-
24-
override findWaitpoint(...args: Parameters<PostgresRunStore["findWaitpoint"]>) {
25-
this.counts.findWaitpoint++;
26-
this.lastFindWaitpointClient = args[1];
27-
return super.findWaitpoint(...args);
28-
}
29-
3020
override createWaitpoint(...args: Parameters<PostgresRunStore["createWaitpoint"]>) {
3121
this.counts.createWaitpoint++;
3222
return super.createWaitpoint(...args);
@@ -123,62 +113,6 @@ async function createBatch(prisma: any, environment: any) {
123113
}
124114

125115
describe("RunEngine public waitpoint router", () => {
126-
// getWaitpoint routes its read through the store seam, preserving the env-mismatch guard.
127-
containerTest("getWaitpoint reads through the store", async ({ prisma, redisOptions }) => {
128-
const environment = await setupAuthenticatedEnvironment(prisma, "PRODUCTION");
129-
const store = new CountingPostgresRunStore({
130-
prisma,
131-
readOnlyPrisma: prisma,
132-
});
133-
const engine = new RunEngine(engineOptions(redisOptions, prisma, { store }));
134-
135-
try {
136-
const { waitpoint } = await engine.createManualWaitpoint({
137-
environmentId: environment.id,
138-
projectId: environment.project.id,
139-
});
140-
141-
const before = store.counts.findWaitpoint;
142-
const found = await engine.getWaitpoint({
143-
waitpointId: waitpoint.id,
144-
environmentId: environment.id,
145-
projectId: environment.project.id,
146-
});
147-
148-
// routed through the store exactly once
149-
expect(store.counts.findWaitpoint).toBe(before + 1);
150-
assertNonNullable(found);
151-
expect(found.id).toBe(waitpoint.id);
152-
// the include shape is preserved (blockingTaskRuns is present, even if empty)
153-
expect((found as any).blockingTaskRuns).toBeDefined();
154-
expect(Array.isArray((found as any).blockingTaskRuns)).toBe(true);
155-
156-
// the read is pinned to the PRIMARY client, not defaulted to the replica
157-
expect(store.lastFindWaitpointClient).toBe(prisma);
158-
159-
// env-mismatch guard still returns null
160-
const mismatch = await engine.getWaitpoint({
161-
waitpointId: waitpoint.id,
162-
environmentId: "env_does_not_exist",
163-
projectId: environment.project.id,
164-
});
165-
expect(mismatch).toBeNull();
166-
167-
// a non-existent waitpointId drives the `if (!waitpoint) return null` branch
168-
const beforeMissing = store.counts.findWaitpoint;
169-
const missing = await engine.getWaitpoint({
170-
waitpointId: "waitpoint_does_not_exist",
171-
environmentId: environment.id,
172-
projectId: environment.project.id,
173-
});
174-
expect(missing).toBeNull();
175-
// not-found was reached THROUGH the store (not short-circuited)
176-
expect(store.counts.findWaitpoint).toBe(beforeMissing + 1);
177-
} finally {
178-
await engine.quit();
179-
}
180-
});
181-
182116
// blockRunWithCreatedBatch routes its BATCH waitpoint create through the store (non-tx path),
183117
// links the run, and preserves the P2002 duplicate-idempotency-key -> null path.
184118
containerTest(
@@ -424,12 +358,11 @@ describe("RunEngine public waitpoint router", () => {
424358
});
425359
assertNonNullable(waitpoint);
426360

427-
// getWaitpoint reads back the row it wrote (with the include shape)
428-
const fetched = await engine.getWaitpoint({
429-
waitpointId: waitpoint.id,
430-
environmentId: environment.id,
431-
projectId: environment.project.id,
432-
});
361+
// the store reads back the row it wrote
362+
const fetched = await engine.runStore.findWaitpoint(
363+
{ where: { id: waitpoint.id } },
364+
engine.prisma
365+
);
433366
assertNonNullable(fetched);
434367
expect(fetched.id).toBe(waitpoint.id);
435368
expect(fetched.type).toBe("BATCH");

‎internal-packages/run-store/src/PostgresRunStore.dedicatedRepro.test.ts‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,23 +1294,23 @@ describe("run-ops split — store-level behavior against the REAL dedicated sche
12941294
);
12951295

12961296
// ===========================================================================================
1297-
// `getWaitpoint`'s WAITPOINT_DEDICATED relations
1297+
// A waitpoint read's WAITPOINT_DEDICATED relations
12981298
// ({ blockingTaskRuns, connectedRuns, completedExecutionSnapshots }) are hydrated by the dedicated
12991299
// store on its OWN client only (PostgresRunStore.findWaitpoint → WAITPOINT_DEDICATED
13001300
// hydrators, all keyed by `waitpointId` on the store's single client). But a
13011301
// waitpoint's blocking edge, run connection and completing snapshot all CO-LOCATE WITH THE RUN
13021302
// (blockRunWithWaitpointEdges routes by runId; the CompletedWaitpoint + WaitpointRunConnection
13031303
// join rows are written on the run's DB). A cuid token blocking
13041304
// a run-ops run therefore has every group-A TARGET on the OTHER DB → the single-client hydrator finds
1305-
// nothing → engine.getWaitpoint (include blockingTaskRuns→taskRun) silently returns an
1306-
// empty `blockingTaskRuns`. Fix: the router (RoutingRunStore.findWaitpoint/findManyWaitpoints) strips
1305+
// nothing → a waitpoint read that includes `blockingTaskRuns` with the nested `taskRun` silently
1306+
// returns an empty `blockingTaskRuns`. Fix: the router (RoutingRunStore.findWaitpoint/findManyWaitpoints) strips
13071307
// these relation keys from the per-leg query and re-resolves the targets across BOTH DBs, mirroring
13081308
// findManyTaskRunWaitpoints' edge fan-out.
13091309
// ===========================================================================================
13101310

13111311
// A cuid token on #legacy blocking a run-ops run on #new. The block edge + run connection live
1312-
// on #new (the run's DB). getWaitpoint's include{ blockingTaskRuns: { select: { taskRun } } } must
1313-
// surface the cross-DB blocked run. Single-store guard proves the #legacy hydrator alone misses it.
1312+
// on #new (the run's DB). A waitpoint read that includes `blockingTaskRuns` with the nested `taskRun`
1313+
// must surface the cross-DB blocked run. Single-store guard proves the #legacy hydrator alone misses it.
13141314
heteroRunOpsPostgresTest(
13151315
"findWaitpoint include blockingTaskRuns surfaces a cross-DB blocked run via the router",
13161316
async ({ prisma14, prisma17 }) => {

‎internal-packages/run-store/src/PostgresRunStore.dedicatedSelect.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ async function runBlockingTaskRunsScenario(
307307
projectId: env.project.id,
308308
});
309309

310-
// The run-engine call shape (engine.getWaitpoint).
310+
// A waitpoint read that includes `blockingTaskRuns` with the nested `taskRun`.
311311
const waitpoint = await store.findWaitpoint({
312312
where: { id: waitpointId },
313313
include: {

‎internal-packages/run-store/src/PostgresRunStore.infraRetryBudget.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ postgresTest(
7373
readInfraRetry: { options, onRetry: () => replica++ },
7474
});
7575

76-
// markWaitpointCompleted is the retried writer op (updateManyWaitpoints is not retried); it runs
77-
// waitpoint.updateMany on the writer, which the one-shot blip faults once, charging the writer budget.
76+
// markWaitpointCompleted is the retried writer op; it runs waitpoint.updateMany on the writer,
77+
// which the one-shot blip faults once, charging the writer budget.
7878
await store.markWaitpointCompleted(wpId, {
7979
output: { value: "{}", type: "application/json", isError: false },
8080
});

‎internal-packages/run-store/src/PostgresRunStore.ts‎

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ const hydrateCompletedWaitpoints: DedicatedRelationHydrator = async (client, par
340340
);
341341

342342
// Runs a waitpoint is blocking: TaskRunWaitpoint rows keyed by waitpointId. A nested `taskRun`
343-
// select (the run-engine's getWaitpoint shape) is resolved from the scalar TaskRunWaitpoint.taskRunId.
343+
// select is resolved from the scalar TaskRunWaitpoint.taskRunId.
344344
const hydrateBlockingTaskRuns: DedicatedRelationHydrator = async (client, parents, projection) => {
345345
const parentIds = parents.map((p) => p.id as string);
346346
const byParent = new Map<string, unknown[]>(parentIds.map((id) => [id, []]));
@@ -2596,17 +2596,6 @@ export class PostgresRunStore implements RunStore {
25962596
return prisma.waitpoint.update(args) as Promise<Prisma.WaitpointGetPayload<T>>;
25972597
}
25982598

2599-
async updateManyWaitpoints(
2600-
args: Prisma.WaitpointUpdateManyArgs,
2601-
tx?: PrismaClientOrTransaction
2602-
): Promise<Prisma.BatchPayload> {
2603-
// Generic update: NOT retried. It accepts arbitrary update args, which may be non-idempotent (e.g.
2604-
// a Prisma increment), so replaying it on a blip is unsafe. Replay-safe waitpoint completion has
2605-
// its own retried path, markWaitpointCompleted.
2606-
const prisma = tx ?? this.prisma;
2607-
return prisma.waitpoint.updateMany(args);
2608-
}
2609-
26102599
async markWaitpointCompleted(
26112600
waitpointId: string,
26122601
completion: {

‎internal-packages/run-store/src/PostgresRunStore.waitpointBlipResilience.test.ts‎

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -160,34 +160,6 @@ postgresBlipTest(
160160
}
161161
);
162162

163-
postgresBlipTest(
164-
"generic updateManyWaitpoints is NOT retried on a blip (propagates)",
165-
{ timeout: 60_000 },
166-
async ({ prisma }) => {
167-
const client = prisma as PrismaClient;
168-
const { project, environment } = await seedEnvironment(client, "wpgen");
169-
await createPendingWaitpoint(client, "wp_gen", project.id, environment.id);
170-
171-
let retries = 0;
172-
const faulting = withOneShotBlip(prisma, "waitpoint", "updateMany");
173-
const store = new PostgresRunStore({
174-
prisma: faulting as never,
175-
readOnlyPrisma: faulting as never,
176-
infraRetry: { options: infraRetry.options, onRetry: () => retries++ },
177-
});
178-
179-
// The generic update accepts arbitrary (possibly non-idempotent) args, so it is never retried: the
180-
// injected blip surfaces to the caller and onRetry never fires.
181-
await expect(
182-
store.updateManyWaitpoints({
183-
where: { id: "wp_gen", status: "PENDING" },
184-
data: { status: "COMPLETED", completedAt: new Date() },
185-
})
186-
).rejects.toThrow();
187-
expect(retries).toBe(0);
188-
}
189-
);
190-
191163
postgresBlipTest(
192164
"deleteManyTaskRunWaitpoints retries a mid-statement connection loss and recovers (retry fires once)",
193165
{ timeout: 60_000 },

0 commit comments

Comments
 (0)