fix(logs): add durable execution diagnostics foundation#3564
fix(logs): add durable execution diagnostics foundation#3564PlaneInABottle wants to merge 8 commits intosimstudioai:stagingfrom
Conversation
PR SummaryMedium Risk Overview Hardens executor lifecycle + finalization sequencing. Block/subflow lifecycle hooks ( Tests updated/added for ordering and failure modes. Adds coverage for empty-parallel lifecycle awaiting, logging-session progress write draining/monotonic marker updates, and ensures success results stay successful even if post-run finalization throws. Written by Cursor Bugbot for commit c3f5d77. This will update automatically on new commits. Configure here. |
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Greptile SummaryThis PR establishes a durable execution diagnostics foundation by persisting Key changes:
Notable behavior change: The response from Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant EC as executeWorkflowCore
participant LS as LoggingSession
participant DB as Database
participant EX as Executor
EC->>LS: safeStart()
EC->>EX: execute() with wrappedOnBlockStart/Complete
loop For each block
EX->>EC: wrappedOnBlockStart(blockId, ...)
EC->>LS: onBlockStart(blockId, startedAt)
LS->>DB: jsonb_set lastStartedBlock (monotonic)
DB-->>LS: ack (tracked in pendingProgressWrites)
LS-->>EC: resolved
EC-->>EX: void userCallback fired separately
EX->>EC: wrappedOnBlockComplete(blockId, output)
EC->>LS: onBlockComplete(blockId, output)
LS->>DB: jsonb_set lastCompletedBlock (monotonic)
LS->>DB: void flushAccumulatedCost (fire-and-forget)
LS-->>EC: resolved
EC-->>EX: void userCallback fired separately
end
EX-->>EC: ExecutionResult
EC->>EC: finalizeExecutionOutcome()
EC->>LS: safeComplete / safeCompleteWithCancellation / safeCompleteWithPause
LS->>LS: drainPendingProgressWrites()
LS->>DB: completeWorkflowExecution (finalizationPath, lastStarted/CompletedBlock, traceSpans)
DB-->>LS: ack
LS-->>EC: resolved
EC->>DB: clearExecutionCancellation
EC->>DB: updateWorkflowRunCounts
EC-->>Caller: ExecutionResult
Last reviewed commit: 9db5e87 |
|
@icecrasher321 I think this is an important one. One scenario I have experienced is stuck workflow. I couldn't find any logs, and it just kept in running. I am planning to introduce few more prs after this one too. |
Store last-started and last-completed block markers with finalization metadata so later read surfaces can explain how a run ended without reconstructing executor state.
Await only the persistence needed to keep diagnostics durable before terminal completion while keeping callback failures from changing execution behavior.
Keep successful fallback output and accumulated cost intact while tightening progress-write draining and deduplicating trace span counting for diagnostics helpers.
9db5e87 to
c6d9195
Compare
Add the missing AuthType export to the hybrid auth mock so the async execution route test exercises the 202 queueing path instead of crashing with a 500 in CI.
Allow same-millisecond marker writes to replace prior markers and drop the unused diagnostics read helper so this PR stays focused on persistence rather than unread foundation code.
Drop the unused helper so this PR only ships the persistence-side status types it actually uses.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Ensure empty-subflow and subflow-error lifecycle callbacks participate in progress-write draining before terminal finalization while still swallowing callback failures.

Summary
workflow_execution_logs, includinglastStartedBlock,lastCompletedBlock, trace metadata, andfinalizationPathWhy
Later jobs and log read-surface fixes depend on a trustworthy execution diagnostics foundation. This PR stores the minimum durable data needed to explain where a run got to and how it ended without pulling in broader API or jobs-surface changes.
Scope
Validation
bun --cwd apps/sim vitest run lib/logs/execution/diagnostics.test.ts lib/logs/execution/logger.test.ts lib/logs/execution/logging-session.test.ts lib/workflows/executor/execution-core.test.tsbunx @biomejs/biome check apps/sim/lib/workflows/executor/execution-core.ts apps/sim/lib/workflows/executor/execution-core.test.ts apps/sim/lib/logs/execution/logging-session.ts apps/sim/lib/logs/execution/logging-session.test.ts apps/sim/lib/logs/execution/logger.ts apps/sim/executor/orchestrators/loop.ts apps/sim/executor/orchestrators/parallel.ts apps/sim/executor/orchestrators/node.ts apps/sim/executor/utils/subflow-utils.ts apps/sim/executor/execution/block-executor.tsfinalizationPath,lastStartedBlock, andlastCompletedBlockFollow-ups