Commit add55b4
improvement(executor): correctness-by-construction for workflow logs (#4382)
* improvement(executor): correctness-by-construction for workflow logs
Replace the post-hoc reconciliation layer with a deterministic emission
protocol: drain pending callback promises at terminal boundaries, mint a
per-invocation blockExecutionId, and key console entries by that ID.
Eliminates races between block:* and execution:* events without changing
per-block latency.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* test(executor): remove stale fire-and-forget assertion
The deleted test asserted wrappedOnBlockStart returns before the user
callback resolves. After the Stage 1 drain refactor, wrappedOnBlockStart
must await the user callback so the executor's trackCallback set covers
SSE writes — otherwise the drain at terminal-event time can't guarantee
block:* flushes before execution:*.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* test(console-store): cover blockExecutionId keying and idempotency
Locks in the new console store invariants:
- Primary lookup via entryIdByBlockExecutionId fires no legacy warn
- Unknown blockExecutionId falls back to legacy keying and warns
- No-blockExecutionId updates use legacy path silently
- addConsole twice with same blockExecutionId returns the existing entry
- Distinct blockExecutionIds (loop iterations) produce distinct entries
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* fix(executor): capture BlockExecutor locally so finally drains its own instance
Previously this.blockExecutor was overwritten on every buildExecutionPipeline
call. Concurrent or re-entrant execute()/executeFromBlock() calls would have
their finally block drain the wrong instance, allowing the first execution's
block events to land after its terminal event. Returning { engine, blockExecutor }
and capturing both locally makes the drain pinned to the same instance the
engine.run() ran against.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* test(terminal): capture store logger by label, not first warn-bearing mock
The previous capture used `.find` over all createLogger results, which
returned whichever module created a logger first — not the store's
logger — causing the legacy-keying warn assertion to see 0 calls.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>1 parent bdaf112 commit add55b4
14 files changed
Lines changed: 384 additions & 458 deletions
File tree
- apps/sim
- app
- api/workflows/[id]/execute
- workspace/[workspaceId]/w/[workflowId]
- hooks
- utils
- executor
- execution
- lib/workflows/executor
- stores/terminal/console
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
919 | 919 | | |
920 | 920 | | |
921 | 921 | | |
922 | | - | |
| 922 | + | |
| 923 | + | |
923 | 924 | | |
924 | 925 | | |
925 | 926 | | |
| |||
945 | 946 | | |
946 | 947 | | |
947 | 948 | | |
| 949 | + | |
948 | 950 | | |
949 | 951 | | |
950 | 952 | | |
| |||
955 | 957 | | |
956 | 958 | | |
957 | 959 | | |
958 | | - | |
| 960 | + | |
| 961 | + | |
959 | 962 | | |
960 | 963 | | |
961 | 964 | | |
| |||
969 | 972 | | |
970 | 973 | | |
971 | 974 | | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
972 | 980 | | |
973 | 981 | | |
974 | 982 | | |
| |||
1002 | 1010 | | |
1003 | 1011 | | |
1004 | 1012 | | |
| 1013 | + | |
1005 | 1014 | | |
1006 | 1015 | | |
1007 | 1016 | | |
| |||
1036 | 1045 | | |
1037 | 1046 | | |
1038 | 1047 | | |
| 1048 | + | |
1039 | 1049 | | |
1040 | 1050 | | |
1041 | 1051 | | |
| |||
1165 | 1175 | | |
1166 | 1176 | | |
1167 | 1177 | | |
1168 | | - | |
1169 | 1178 | | |
1170 | 1179 | | |
1171 | 1180 | | |
| |||
1179 | 1188 | | |
1180 | 1189 | | |
1181 | 1190 | | |
1182 | | - | |
1183 | 1191 | | |
1184 | 1192 | | |
1185 | 1193 | | |
| |||
1244 | 1252 | | |
1245 | 1253 | | |
1246 | 1254 | | |
1247 | | - | |
1248 | 1255 | | |
1249 | 1256 | | |
1250 | 1257 | | |
| |||
Lines changed: 5 additions & 23 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
230 | 230 | | |
231 | 231 | | |
232 | 232 | | |
233 | | - | |
234 | 233 | | |
235 | 234 | | |
236 | 235 | | |
237 | | - | |
| 236 | + | |
238 | 237 | | |
239 | 238 | | |
240 | 239 | | |
241 | | - | |
| 240 | + | |
242 | 241 | | |
243 | 242 | | |
244 | 243 | | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | | - | |
250 | | - | |
| 244 | + | |
251 | 245 | | |
252 | 246 | | |
253 | | - | |
| 247 | + | |
254 | 248 | | |
255 | 249 | | |
256 | 250 | | |
257 | | - | |
| 251 | + | |
258 | 252 | | |
259 | 253 | | |
260 | 254 | | |
| |||
1036 | 1030 | | |
1037 | 1031 | | |
1038 | 1032 | | |
1039 | | - | |
1040 | | - | |
1041 | 1033 | | |
1042 | 1034 | | |
1043 | 1035 | | |
| |||
1240 | 1232 | | |
1241 | 1233 | | |
1242 | 1234 | | |
1243 | | - | |
1244 | 1235 | | |
1245 | 1236 | | |
1246 | 1237 | | |
| |||
1267 | 1258 | | |
1268 | 1259 | | |
1269 | 1260 | | |
1270 | | - | |
1271 | 1261 | | |
1272 | 1262 | | |
1273 | 1263 | | |
| |||
1684 | 1674 | | |
1685 | 1675 | | |
1686 | 1676 | | |
1687 | | - | |
1688 | | - | |
1689 | 1677 | | |
1690 | 1678 | | |
1691 | 1679 | | |
| |||
1755 | 1743 | | |
1756 | 1744 | | |
1757 | 1745 | | |
1758 | | - | |
1759 | 1746 | | |
1760 | 1747 | | |
1761 | 1748 | | |
| |||
1768 | 1755 | | |
1769 | 1756 | | |
1770 | 1757 | | |
1771 | | - | |
1772 | 1758 | | |
1773 | 1759 | | |
1774 | 1760 | | |
| |||
1915 | 1901 | | |
1916 | 1902 | | |
1917 | 1903 | | |
1918 | | - | |
1919 | | - | |
1920 | 1904 | | |
1921 | 1905 | | |
1922 | 1906 | | |
| |||
2017 | 2001 | | |
2018 | 2002 | | |
2019 | 2003 | | |
2020 | | - | |
2021 | 2004 | | |
2022 | 2005 | | |
2023 | 2006 | | |
| |||
2038 | 2021 | | |
2039 | 2022 | | |
2040 | 2023 | | |
2041 | | - | |
2042 | 2024 | | |
2043 | 2025 | | |
2044 | 2026 | | |
| |||
0 commit comments