Skip to content

Commit 337e86f

Browse files
committed
test(service-automation): re-judge the two republish-dropped-node pins against the flow version pin
A republish that drops the parked node now finishes the run on the body it started on; the RUN_NOT_FOUND answer and its settle stay pinned for a body that is truly unrecoverable (withdrawn, never stored). Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QUs3BthE1wf1V6QZ6w17Wk
1 parent 0c739f5 commit 337e86f

2 files changed

Lines changed: 55 additions & 10 deletions

File tree

‎packages/services/service-automation/src/engine.test.ts‎

Lines changed: 48 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -714,17 +714,55 @@ describe('AutomationEngine', () => {
714714
expect(resumed.error).toContain("Flow 'vanishing_flow' not found for run");
715715
});
716716

717-
it('should report a resume whose suspended node was edited away as RUN_NOT_FOUND', async () => {
717+
// [#28405] Re-judged: a run resumes on the body it started on, so a
718+
// republish that drops its parked node no longer ends it. The
719+
// RUN_NOT_FOUND answer stays for a body that is truly gone: here the
720+
// flow is withdrawn (which forgets every body this process held) and
721+
// a different body registered, with no metadata history attached.
722+
it('should finish a run whose parked node a republish dropped on the body it started on', async () => {
718723
const captured: { runId?: unknown } = {};
719724
registerPausingNode(captured);
720-
const nodes = [
721-
{ id: 'start', type: 'start', label: 'Start' },
722-
{ id: 'pause', type: 'pause_node', label: 'Pause' },
723-
{ id: 'end', type: 'end', label: 'End' },
725+
const edges = [
726+
{ id: 'e1', source: 'start', target: 'pause' },
727+
{ id: 'e2', source: 'pause', target: 'end' },
724728
];
725729
engine.registerFlow('edited_flow', {
726730
name: 'edited_flow', label: 'Edited Flow', type: 'autolaunched',
727-
nodes,
731+
nodes: [
732+
{ id: 'start', type: 'start', label: 'Start' },
733+
{ id: 'pause', type: 'pause_node', label: 'Pause' },
734+
{ id: 'end', type: 'end', label: 'End' },
735+
],
736+
edges,
737+
});
738+
739+
const paused = await engine.execute('edited_flow');
740+
expect(paused.status).toBe('paused');
741+
// The author republishes the flow without the node the run is
742+
// parked on.
743+
engine.registerFlow('edited_flow', {
744+
name: 'edited_flow', label: 'Edited Flow', type: 'autolaunched',
745+
nodes: [
746+
{ id: 'start', type: 'start', label: 'Start' },
747+
{ id: 'end', type: 'end', label: 'End' },
748+
],
749+
edges: [{ id: 'e1', source: 'start', target: 'end' }],
750+
});
751+
752+
const resumed = await engine.resume(paused.runId!);
753+
expect(resumed.success, JSON.stringify(resumed)).toBe(true);
754+
});
755+
756+
it('should report a resume whose parked node is gone and whose pinned body is unrecoverable as RUN_NOT_FOUND', async () => {
757+
const captured: { runId?: unknown } = {};
758+
registerPausingNode(captured);
759+
engine.registerFlow('edited_flow', {
760+
name: 'edited_flow', label: 'Edited Flow', type: 'autolaunched',
761+
nodes: [
762+
{ id: 'start', type: 'start', label: 'Start' },
763+
{ id: 'pause', type: 'pause_node', label: 'Pause' },
764+
{ id: 'end', type: 'end', label: 'End' },
765+
],
728766
edges: [
729767
{ id: 'e1', source: 'start', target: 'pause' },
730768
{ id: 'e2', source: 'pause', target: 'end' },
@@ -733,8 +771,10 @@ describe('AutomationEngine', () => {
733771

734772
const paused = await engine.execute('edited_flow');
735773
expect(paused.status).toBe('paused');
736-
// The author republishes the flow without the node the run is
737-
// parked on — the pause can never continue.
774+
// The body the run started on is gone from this process (no
775+
// metadata history is attached), and the one registered now has
776+
// no node the pause can continue from.
777+
engine.withdrawFlow('edited_flow');
738778
engine.registerFlow('edited_flow', {
739779
name: 'edited_flow', label: 'Edited Flow', type: 'autolaunched',
740780
nodes: [

‎packages/services/service-automation/src/resume-gone-suspension-settle.test.ts‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,16 @@ describe('a gone-for-good resume settles the run row (full stack, sqlite file)',
194194
expect(isTerminalRunStatus(row.status)).toBe(true);
195195
});
196196

197-
it('parked node edited away: the refused resume moves the row to failed with the cause', async () => {
197+
it('parked node gone with its pinned body unrecoverable: the refused resume moves the row to failed with the cause', async () => {
198198
const { ql, automation } = await boot(await freshFile());
199199
const runId = await parkOnScreen(automation, ql, 'edited_probe');
200200

201-
// The author republishes the flow without the node the run parked on.
201+
// The flow is replaced by a body without the node the run parked on,
202+
// and the body the run started on is gone: withdrawn from this
203+
// process, never stored in the metadata history. [#28405] A plain
204+
// republish no longer reaches this exit — the run would resume on the
205+
// body it started on (`flow-version-pinning.test.ts`).
206+
automation.withdrawFlow('edited_probe');
202207
automation.registerFlow('edited_probe', screenFlow('edited_probe', false) as never);
203208
const resumed = await automation.resume(runId, { output: { x: 'v' } });
204209

0 commit comments

Comments
 (0)