Skip to content

Commit 28fbd0c

Browse files
committed
Fix
1 parent 994a664 commit 28fbd0c

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

apps/sim/executor/utils/run-from-block.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -331,9 +331,10 @@ describe('validateRunFromBlock', () => {
331331
expect(result.error).toContain('Upstream dependency not executed')
332332
})
333333

334-
it('rejects blocks with unexecuted transitive upstream dependencies', () => {
334+
it('allows running from block when immediate predecessor was executed (ignores transitive)', () => {
335335
// A → X → B → C, where X is new (not executed)
336-
// Running from C should fail because X in upstream chain wasn't executed
336+
// Running from C is allowed because B (immediate predecessor) was executed
337+
// C will use B's cached output - doesn't matter that X is new
337338
const dag = createDAG([
338339
createNode('A', [{ target: 'X' }]),
339340
createNode('X', [{ target: 'B' }]),
@@ -344,9 +345,8 @@ describe('validateRunFromBlock', () => {
344345

345346
const result = validateRunFromBlock('C', dag, executedBlocks)
346347

347-
expect(result.valid).toBe(false)
348-
expect(result.error).toContain('Upstream dependency not executed')
349-
expect(result.error).toContain('X')
348+
// Valid because C's immediate predecessor B was executed
349+
expect(result.valid).toBe(true)
350350
})
351351

352352
it('allows blocks with no dependencies even if not previously executed', () => {

apps/sim/executor/utils/run-from-block.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -169,15 +169,18 @@ export function validateRunFromBlock(
169169
if (node.metadata.isSentinel) {
170170
return { valid: false, error: 'Cannot run from sentinel node' }
171171
}
172-
}
173172

174-
// Check that ALL upstream blocks were executed (transitive check)
175-
const { upstreamSet } = computeExecutionSets(dag, blockId)
176-
for (const upstreamId of upstreamSet) {
177-
if (!executedBlocks.has(upstreamId)) {
178-
return {
179-
valid: false,
180-
error: `Upstream dependency not executed: ${upstreamId}`,
173+
// Check immediate upstream dependencies were executed
174+
for (const sourceId of node.incomingEdges) {
175+
const sourceNode = dag.nodes.get(sourceId)
176+
// Skip sentinel nodes - they're internal and not in executedBlocks
177+
if (sourceNode?.metadata.isSentinel) continue
178+
179+
if (!executedBlocks.has(sourceId)) {
180+
return {
181+
valid: false,
182+
error: `Upstream dependency not executed: ${sourceId}`,
183+
}
181184
}
182185
}
183186
}

0 commit comments

Comments
 (0)