Address PR review feedback (#1363)
Greptile + CodeRabbit findings across core/engine/dashboard. Stale findings (written against earlier commits) verified and skipped; valid ones fixed. Engine: - await-input: do not clear pausedReason in the /input route (the node's marker must survive unpause); the node clears it after consuming input. Embed a colon-free epoch watermark in the marker so only post-pause steering comments count as the reply (ISO timestamps collided with the colon separator and the dashboard question parser). - gate nodes without a registered runner now fail closed (throw) instead of silently passing. - a thrown interpreter error in maybeExecuteWorkflowGraph now falls back to the legacy pipeline instead of stranding the task in-progress. - approved-CLI path clears the stale awaiting-cli-approval status/marker. Core: - persist+cascade workflow selection: purge task_workflow_selection rows and compiled workflow_steps on physical task deletes; migration 105 cleans already-orphaned rows; catch-cleanup for materialized steps when the owner write fails; WF-id allocation now in a BEGIN IMMEDIATE transaction. - compiler validates the canonical execute->review->merge seam order (rejects duplicate/misordered seams). - disk-backed reopen round-trip + tightened updatedAt/list assertions. Dashboard: - WorkflowSelector clears stale default/options across project changes and on fetch failure; InlineCreateCard/NewTaskModal reset the workflow on all clear/discard paths and include it in dirty-state. - WorkflowNodeEditor: config-key deletion now persists; removed an invalid eslint-disable that was itself a hard lint error. - TaskCard: single status badge for awaiting-input (no duplicate). - WorkflowResultsTab: reset paused-action UI between pauses; surface resume/approve failures inline. - TaskDetailModal: treat awaiting-user-input/awaiting-cli-approval/paused as not-in-progress for the live-log subscription. - workflow-flow-mapping: don't write synthetic node names back into IR. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -3243,8 +3243,18 @@ export class TaskExecutor {
|
||||
runCustomNode: (node, nodeTask) => this.runGraphCustomNode(node, nodeTask, settings),
|
||||
onEvent: (event) => executorLog.log(`[workflow-graph] ${event.type} ${event.taskId}: ${event.detail}`),
|
||||
});
|
||||
const detail = await this.store.getTask(task.id);
|
||||
const result = await runner.run(detail, settings);
|
||||
let result: WorkflowGraphTaskRunResult;
|
||||
try {
|
||||
const detail = await this.store.getTask(task.id);
|
||||
result = await runner.run(detail, settings);
|
||||
} catch (err) {
|
||||
// A thrown interpreter error must not strand the task in-progress: fall
|
||||
// back to the legacy pipeline so the normal executor lock + flow runs.
|
||||
executorLog.error(
|
||||
`[workflow-graph] ${task.id} interpreter threw — falling back to legacy pipeline: ${err instanceof Error ? err.message : String(err)}`,
|
||||
);
|
||||
return false;
|
||||
}
|
||||
if (result.disposition === "fell-back") {
|
||||
executorLog.log(`[workflow-graph] ${task.id} fell back to legacy pipeline: ${result.reason}`);
|
||||
return false;
|
||||
@@ -3362,20 +3372,44 @@ export class TaskExecutor {
|
||||
// pausedReason). A pre-existing steering comment (e.g. one added at task
|
||||
// creation) must never short-circuit the pause on the node's first run —
|
||||
// otherwise the node consumes a stale comment and never asks the user.
|
||||
const pausedByThisNode = (live.pausedReason ?? "").startsWith(marker);
|
||||
if (!live.paused && pausedByThisNode && steering.length > 0) {
|
||||
// Input has arrived (user replied and unpaused): consume the latest comment.
|
||||
const latest = steering[steering.length - 1] as { text?: string; comment?: string };
|
||||
const answer = (latest?.text ?? latest?.comment ?? "").toString();
|
||||
await this.store.updateTask(live.id, { status: null }, this.getRunContextFor(live.id));
|
||||
await this.store.logEntry(live.id, `Workflow input received for node '${node.id}'`, undefined, this.getRunContextFor(live.id));
|
||||
return { outcome: "success", value: "input-received", contextPatch: { [`input:${node.id}`]: answer } };
|
||||
const pausedReason = live.pausedReason ?? "";
|
||||
const pausedByThisNode = pausedReason.startsWith(marker);
|
||||
if (!live.paused && pausedByThisNode) {
|
||||
// Correlate the reply to THIS pause: the marker embeds a watermark
|
||||
// (`${marker}@${pauseEpochMs}: …`) recorded when the node paused. Only
|
||||
// count steering comments created at/after that watermark as the answer,
|
||||
// so an unpause-without-reply can't consume a comment that predates the
|
||||
// pause. The watermark is epoch milliseconds (colon-free) so it never
|
||||
// collides with the `:` that separates the marker from the question, nor
|
||||
// with the dashboard's colon-delimited question parser.
|
||||
const watermark = (() => {
|
||||
const m = pausedReason.slice(marker.length).match(/^@(\d+)/);
|
||||
const t = m ? Number(m[1]) : NaN;
|
||||
return Number.isFinite(t) ? t : undefined;
|
||||
})();
|
||||
const replies = watermark === undefined
|
||||
? steering
|
||||
: steering.filter((c) => {
|
||||
const created = Date.parse((c as { createdAt?: string }).createdAt ?? "");
|
||||
return Number.isFinite(created) ? created >= watermark : false;
|
||||
});
|
||||
if (replies.length > 0) {
|
||||
// Input has arrived (user replied and unpaused): consume the latest
|
||||
// post-pause comment and clear this node's marker so a future fresh
|
||||
// visit re-asks instead of silently consuming a stale comment.
|
||||
const latest = replies[replies.length - 1] as { text?: string; comment?: string };
|
||||
const answer = (latest?.text ?? latest?.comment ?? "").toString();
|
||||
await this.store.updateTask(live.id, { status: null, pausedReason: null }, this.getRunContextFor(live.id));
|
||||
await this.store.logEntry(live.id, `Workflow input received for node '${node.id}'`, undefined, this.getRunContextFor(live.id));
|
||||
return { outcome: "success", value: "input-received", contextPatch: { [`input:${node.id}`]: answer } };
|
||||
}
|
||||
// Unpaused but no post-pause reply yet — re-park below and keep waiting.
|
||||
}
|
||||
|
||||
await this.store.logEntry(live.id, `Workflow paused for user input: ${question}`, undefined, this.getRunContextFor(live.id));
|
||||
await this.store.updateTask(
|
||||
live.id,
|
||||
{ status: "awaiting-user-input", paused: true, pausedReason: `${marker}: ${question}` },
|
||||
{ status: "awaiting-user-input", paused: true, pausedReason: `${marker}@${Date.now()}: ${question}` },
|
||||
this.getRunContextFor(live.id),
|
||||
);
|
||||
// Failure outcome ends the walk; handleGraphFailure leaves paused tasks
|
||||
@@ -3523,6 +3557,15 @@ export class TaskExecutor {
|
||||
if (!skipApproval && !(await this.store.isWorkflowCliCommandApproved(rawCommand))) {
|
||||
return this.pauseForCliApproval(node, live, rawCommand);
|
||||
}
|
||||
// We are proceeding to execute. If this task was previously paused by
|
||||
// THIS node's CLI-approval gate, clear that status/pausedReason now —
|
||||
// otherwise the task keeps the "awaiting-cli-approval" status through
|
||||
// later graph nodes even though approval already happened (mirrors the
|
||||
// status reset in runAwaitInputNode).
|
||||
const approvalMarker = `workflow-cli-approval:${node.id}`;
|
||||
if ((live.pausedReason ?? "").startsWith(approvalMarker)) {
|
||||
await this.store.updateTask(live.id, { status: null, pausedReason: null }, this.getRunContextFor(live.id));
|
||||
}
|
||||
const env = prompt ? { ...process.env, FUSION_NODE_PROMPT: prompt } : undefined;
|
||||
const out = await this.runRawCliCommand(
|
||||
live,
|
||||
|
||||
@@ -77,7 +77,13 @@ export function createGateHandler(runCustomNode?: WorkflowCustomNodeRunner): Wor
|
||||
|
||||
const hasExecutableConfig =
|
||||
typeof node.config?.prompt === "string" || typeof node.config?.scriptName === "string";
|
||||
if (hasExecutableConfig && runCustomNode) {
|
||||
if (hasExecutableConfig) {
|
||||
// Fail closed: an executable gate with no runner must NOT auto-pass — that
|
||||
// would silently bypass the gate and let the workflow continue. Mirror the
|
||||
// prompt/script handler, which throws in the same situation.
|
||||
if (!runCustomNode) {
|
||||
throw new WorkflowIrError(`No custom-node runner registered for node: ${node.id}`);
|
||||
}
|
||||
return runCustomNode(node, context.task, context.context);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user