:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
chore(workflows): contract tests for live timing edits on parked runs (#71290)
Harley Alexander7b612b286a2d
diff --git a/nodejs/src/cdp/services/hogflows/hogflow-executor.service.test.ts b/nodejs/src/cdp/services/hogflows/hogflow-executor.service.test.tsindex 3d2d7b7a2054..f11a964474fb 100644--- a/nodejs/src/cdp/services/hogflows/hogflow-executor.service.test.ts+++ b/nodejs/src/cdp/services/hogflows/hogflow-executor.service.test.ts@@ -928,6 +928,79 @@ describe('Hogflow Executor', () => {expect(messages).toContain('Still, Original')expect(messages).not.toContain('Edited')})++ // The cases above wake at the natural time; these wake EARLY — as the timing-edit+ // reschedule sweep (#66380) and the subscription matcher do. Early wake must be+ // behaviourally idempotent: the run re-parks at its unchanged target (never advancing+ // currentAction, so the job row's action_id keeps naming the wait step), or runs the+ // step's new handler when the type changed under it. Bulk-rescheduling parked jobs is+ // only safe while these hold.+ describe('early wakes (reschedule sweep contract)', () => {+ it('a delay woken early with unchanged config re-parks at its original target', async () => {+ const hogFlow = createHogFlow({+ actions: { delay: { type: 'delay', config: { delay_duration: '7d' } } },+ edges: [+ { from: 'trigger', to: 'delay', type: 'continue' },+ { from: 'delay', to: 'exit', type: 'continue' },+ ],+ })+ const invocation = parkAt(hogFlow, 'delay', Duration.fromObject({ days: 2 }).toMillis())++ const result = await executor.execute(invocation)++ expect(result.finished).toBe(false)+ expect(result.invocation.queueScheduledAt?.toMillis()).toBe(+ invocation.state.currentAction!.startedAtTimestamp + Duration.fromObject({ days: 7 }).toMillis()+ )+ expect(result.invocation.state.currentAction?.id).toBe('delay')+ })++ it('a time window woken early with unchanged config re-parks at the original window start', async () => {+ // The window is closed at the fixed test time (2025-01-01T00:00:00Z)+ const hogFlow = createHogFlow({+ actions: {+ window: {+ type: 'wait_until_time_window',+ config: { time: ['10:00', '11:00'], day: 'any', timezone: 'UTC' },+ },+ },+ edges: [+ { from: 'trigger', to: 'window', type: 'continue' },+ { from: 'window', to: 'exit', type: 'continue' },+ ],+ })+ const invocation = parkAt(hogFlow, 'window', 60 * 60 * 1000)++ const result = await executor.execute(invocation)++ expect(result.finished).toBe(false)+ expect(result.invocation.queueScheduledAt?.toUTC().toISO()).toBe('2025-01-01T10:00:00.000Z')+ expect(result.invocation.state.currentAction?.id).toBe('window')+ })++ it("a step whose type changed while a run was parked on it runs the new type's handler on wake", async () => {+ const hogFlow = createHogFlow({+ actions: { delay: { type: 'delay', config: { delay_duration: '7d' } } },+ edges: [+ { from: 'trigger', to: 'delay', type: 'continue' },+ { from: 'delay', to: 'exit', type: 'continue' },+ ],+ })+ const invocation = parkAt(hogFlow, 'delay', Duration.fromObject({ days: 2 }).toMillis())+ editFlow(hogFlow, (flow) => {+ const action = flow.actions.find((a) => a.id === 'delay')!+ action.type = 'wait_until_time_window'+ action.config = { time: 'any', day: 'any', timezone: 'UTC' } as any+ })++ const result = await executor.execute(invocation)++ // The always-open window handler runs and the run advances+ expect(result.finished).toBe(true)+ expect(result.error).toBeUndefined()+ expect(result.invocation.state.currentAction?.id).toBe('exit')+ })+ })})describe('early exit conditions', () => {