Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions apps/hub/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,17 @@ export async function createHub(config: HubConfig) {
// surviving loss loud (error-level cause, counted) instead of a
// swallowed WRN.
db: withTurnPartPersistGuard(withTurnPartWriteDefaults(db)),
// CL-7418: deliberately no terminal-status settle here. The folded
// routine-fire settle (CL-6778, keyed off routines.routine_run) died
// with the routines cut (CL-4455) and has no native equivalent: a
// scheduled definition owns a single self-anchored workflow_run that
// must stay live across fires — the scheduler launch path throws
// NativeWorkflowDeploymentMissingError for a non-live anchor, and a
// per-tick execution is a repo-local child run with no row of its
// own (vendor's decideTerminalRunFlip skips it as skip_repo_local).
// Stamping the anchor terminal per fire would brick the schedule,
// so a warm-kept fire settles through the runOutcomeStatus /
// FIRE_RUNNING_WINDOW_MS display-side reading instead.
onTurnFinalized: (agentAddress, turn) => {
artifactDeliveryHandlerRef.current?.(agentAddress, turn);
},
Expand Down
78 changes: 78 additions & 0 deletions packages/workflows/src/schedule/run-outcome.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
// A warm-kept scheduled fire still settles. Native ScheduleTrigger
// definitions own one self-anchored workflow_run that must stay live
// across fires (CL-7418), so no server-side stamp ever flips it terminal
// per fire — surfaces read the fire settled through runOutcomeStatus
// past FIRE_RUNNING_WINDOW_MS instead.
import { describe, expect, test } from "bun:test";

import { FIRE_RUNNING_WINDOW_MS, runOutcomeStatus } from "./run-outcome";

const NOW = Date.parse("2026-09-15T12:00:00.000Z");
const OLD = new Date(NOW - FIRE_RUNNING_WINDOW_MS - 1).toISOString();
const FRESH = new Date(NOW - 1_000).toISOString();

describe("warm-kept scheduled fire settling (CL-7418)", () => {
test("a fire with no in-flight turn past the window reads completed", () => {
expect(
runOutcomeStatus(
{ createdAt: OLD, status: "running", endedAt: null, turns: [] },
NOW,
),
).toBe("completed");
});

test("a fire flagged with no in-flight turn past the window reads completed", () => {
expect(
runOutcomeStatus(
{
createdAt: OLD,
status: "running",
endedAt: null,
hasInFlightTurn: false,
},
NOW,
),
).toBe("completed");
});

test("a fresh scheduled tick inside the window stays running", () => {
expect(
runOutcomeStatus(
{ createdAt: FRESH, status: "running", endedAt: null, turns: [] },
NOW,
),
).toBe("running");
});

test("a live tool loop stays running however old the fire", () => {
expect(
runOutcomeStatus(
{
createdAt: OLD,
status: "running",
endedAt: null,
turns: [{ status: "running" }],
},
NOW,
),
).toBe("running");
});

test("an endedAt stamp reads completed even inside the window", () => {
expect(
runOutcomeStatus(
{ createdAt: FRESH, status: "running", endedAt: FRESH, turns: [] },
NOW,
),
).toBe("completed");
});

test("non-running statuses pass through untouched", () => {
expect(
runOutcomeStatus(
{ createdAt: OLD, status: "failed", endedAt: null, turns: [] },
NOW,
),
).toBe("failed");
});
});
Loading