Commit be37baf
committed
fix(orch): mark paused-at-gate sessions as awaiting_input (#42)
The v2.0.0-rc3 finalizer-asymmetry fix (PR #41) correctly handled
graph-completed-without-pause: every non-streaming run now calls
_finalize_session_status_async() to flip the row to a terminal status.
But the *paused* branch was left as a status-write no-op: when the
graph paused at a HITL gate, the session row stayed at its pre-pause
status ('new' / 'in_progress') instead of transitioning to
'awaiting_input'. UIs that filter by status='awaiting_input' (the
approvals queue, the sessions rail Active group, /sessions in-flight
listing) missed paused sessions entirely.
This was the sibling case of CRITICAL #1 and was filed as #42 after
the rc3 ship.
The fix adds a new lock-guarded helper that mirrors
_finalize_session_status_async on the paused side:
Orchestrator._mark_session_paused_async(session_id) -> str | None
It loads the row, captures the from-status, flips status to
'awaiting_input', saves, and emits both status_changed (per-session
event log) and session.status_changed (cross-session SSE) events via
the existing _emit_status_changed_event helper. It is a no-op when
the row is already at 'awaiting_input', already at a terminal status
(guard against a late paused-write unwinding a finalize that landed
in between), or the row is missing.
Four call sites updated to use it: the three start_session +
stream_session + retry_session paths in orchestrator.py, and the
OrchestratorService._run() background task in service.py.
Regression coverage in tests/test_finalizer_paths.py:
- _PausedAtGateGraph fake graph that returns from ainvoke and
reports a non-empty `next` tuple to aget_state (mirrors langgraph
1.x's interrupt-boundary state).
- test_orchestrator_start_session_marks_paused_run_awaiting_input:
direct (non-streaming) path produces status='awaiting_input' on
the row AND emits status_changed + session.status_changed events.
- test_service_background_start_session_marks_paused_run_awaiting_input:
same guarantee through the OrchestratorService._run() task.
- test_mark_session_paused_is_no_op_when_already_awaiting_input:
no spurious event emission.
- test_mark_session_paused_is_no_op_on_terminal_status: guard
against a late paused-write unwinding a completed terminal flip.
Two pre-existing shim tests updated to stub the new method:
- tests/test_retry_session_locked_post_policy.py _StubOrch
- tests/test_triggers/test_orchestrator_trigger_kwarg.py
(orchestrator built via __new__, bypasses __init__)
Verified:
- ASR_WEB_DIST=/tmp/empty uv run pytest --no-cov -> 1349 passed, 8 skipped
- uv run ruff check src/ tests/ -> clean
- uv run pyright src/runtime -> clean
- cd web && npm run typecheck/lint/test:unit/build/check:size -> green
- dist/* regenerated (HARD-08)1 parent 8be7ea2 commit be37baf
8 files changed
Lines changed: 411 additions & 12 deletions
File tree
- dist
- apps
- src/runtime
- tests
- test_triggers
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6458 | 6458 | | |
6459 | 6459 | | |
6460 | 6460 | | |
6461 | | - | |
| 6461 | + | |
| 6462 | + | |
| 6463 | + | |
| 6464 | + | |
| 6465 | + | |
6462 | 6466 | | |
6463 | 6467 | | |
6464 | 6468 | | |
| |||
14882 | 14886 | | |
14883 | 14887 | | |
14884 | 14888 | | |
| 14889 | + | |
| 14890 | + | |
| 14891 | + | |
| 14892 | + | |
| 14893 | + | |
| 14894 | + | |
| 14895 | + | |
| 14896 | + | |
| 14897 | + | |
| 14898 | + | |
| 14899 | + | |
| 14900 | + | |
| 14901 | + | |
| 14902 | + | |
| 14903 | + | |
| 14904 | + | |
| 14905 | + | |
| 14906 | + | |
| 14907 | + | |
| 14908 | + | |
| 14909 | + | |
| 14910 | + | |
| 14911 | + | |
| 14912 | + | |
| 14913 | + | |
| 14914 | + | |
| 14915 | + | |
| 14916 | + | |
| 14917 | + | |
| 14918 | + | |
| 14919 | + | |
| 14920 | + | |
| 14921 | + | |
| 14922 | + | |
| 14923 | + | |
| 14924 | + | |
| 14925 | + | |
| 14926 | + | |
| 14927 | + | |
| 14928 | + | |
| 14929 | + | |
| 14930 | + | |
| 14931 | + | |
| 14932 | + | |
| 14933 | + | |
| 14934 | + | |
| 14935 | + | |
| 14936 | + | |
14885 | 14937 | | |
14886 | 14938 | | |
14887 | 14939 | | |
| |||
15082 | 15134 | | |
15083 | 15135 | | |
15084 | 15136 | | |
15085 | | - | |
| 15137 | + | |
| 15138 | + | |
| 15139 | + | |
15086 | 15140 | | |
15087 | 15141 | | |
15088 | 15142 | | |
| |||
15140 | 15194 | | |
15141 | 15195 | | |
15142 | 15196 | | |
| 15197 | + | |
| 15198 | + | |
15143 | 15199 | | |
| 15200 | + | |
15144 | 15201 | | |
15145 | 15202 | | |
15146 | 15203 | | |
| |||
15422 | 15479 | | |
15423 | 15480 | | |
15424 | 15481 | | |
15425 | | - | |
| 15482 | + | |
| 15483 | + | |
15426 | 15484 | | |
| 15485 | + | |
15427 | 15486 | | |
15428 | 15487 | | |
15429 | 15488 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6511 | 6511 | | |
6512 | 6512 | | |
6513 | 6513 | | |
6514 | | - | |
| 6514 | + | |
| 6515 | + | |
| 6516 | + | |
| 6517 | + | |
| 6518 | + | |
6515 | 6519 | | |
6516 | 6520 | | |
6517 | 6521 | | |
| |||
14935 | 14939 | | |
14936 | 14940 | | |
14937 | 14941 | | |
| 14942 | + | |
| 14943 | + | |
| 14944 | + | |
| 14945 | + | |
| 14946 | + | |
| 14947 | + | |
| 14948 | + | |
| 14949 | + | |
| 14950 | + | |
| 14951 | + | |
| 14952 | + | |
| 14953 | + | |
| 14954 | + | |
| 14955 | + | |
| 14956 | + | |
| 14957 | + | |
| 14958 | + | |
| 14959 | + | |
| 14960 | + | |
| 14961 | + | |
| 14962 | + | |
| 14963 | + | |
| 14964 | + | |
| 14965 | + | |
| 14966 | + | |
| 14967 | + | |
| 14968 | + | |
| 14969 | + | |
| 14970 | + | |
| 14971 | + | |
| 14972 | + | |
| 14973 | + | |
| 14974 | + | |
| 14975 | + | |
| 14976 | + | |
| 14977 | + | |
| 14978 | + | |
| 14979 | + | |
| 14980 | + | |
| 14981 | + | |
| 14982 | + | |
| 14983 | + | |
| 14984 | + | |
| 14985 | + | |
| 14986 | + | |
| 14987 | + | |
| 14988 | + | |
| 14989 | + | |
14938 | 14990 | | |
14939 | 14991 | | |
14940 | 14992 | | |
| |||
15135 | 15187 | | |
15136 | 15188 | | |
15137 | 15189 | | |
15138 | | - | |
| 15190 | + | |
| 15191 | + | |
| 15192 | + | |
15139 | 15193 | | |
15140 | 15194 | | |
15141 | 15195 | | |
| |||
15193 | 15247 | | |
15194 | 15248 | | |
15195 | 15249 | | |
| 15250 | + | |
| 15251 | + | |
15196 | 15252 | | |
| 15253 | + | |
15197 | 15254 | | |
15198 | 15255 | | |
15199 | 15256 | | |
| |||
15475 | 15532 | | |
15476 | 15533 | | |
15477 | 15534 | | |
15478 | | - | |
| 15535 | + | |
| 15536 | + | |
15479 | 15537 | | |
| 15538 | + | |
15480 | 15539 | | |
15481 | 15540 | | |
15482 | 15541 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6523 | 6523 | | |
6524 | 6524 | | |
6525 | 6525 | | |
6526 | | - | |
| 6526 | + | |
| 6527 | + | |
| 6528 | + | |
| 6529 | + | |
| 6530 | + | |
6527 | 6531 | | |
6528 | 6532 | | |
6529 | 6533 | | |
| |||
14947 | 14951 | | |
14948 | 14952 | | |
14949 | 14953 | | |
| 14954 | + | |
| 14955 | + | |
| 14956 | + | |
| 14957 | + | |
| 14958 | + | |
| 14959 | + | |
| 14960 | + | |
| 14961 | + | |
| 14962 | + | |
| 14963 | + | |
| 14964 | + | |
| 14965 | + | |
| 14966 | + | |
| 14967 | + | |
| 14968 | + | |
| 14969 | + | |
| 14970 | + | |
| 14971 | + | |
| 14972 | + | |
| 14973 | + | |
| 14974 | + | |
| 14975 | + | |
| 14976 | + | |
| 14977 | + | |
| 14978 | + | |
| 14979 | + | |
| 14980 | + | |
| 14981 | + | |
| 14982 | + | |
| 14983 | + | |
| 14984 | + | |
| 14985 | + | |
| 14986 | + | |
| 14987 | + | |
| 14988 | + | |
| 14989 | + | |
| 14990 | + | |
| 14991 | + | |
| 14992 | + | |
| 14993 | + | |
| 14994 | + | |
| 14995 | + | |
| 14996 | + | |
| 14997 | + | |
| 14998 | + | |
| 14999 | + | |
| 15000 | + | |
| 15001 | + | |
14950 | 15002 | | |
14951 | 15003 | | |
14952 | 15004 | | |
| |||
15147 | 15199 | | |
15148 | 15200 | | |
15149 | 15201 | | |
15150 | | - | |
| 15202 | + | |
| 15203 | + | |
| 15204 | + | |
15151 | 15205 | | |
15152 | 15206 | | |
15153 | 15207 | | |
| |||
15205 | 15259 | | |
15206 | 15260 | | |
15207 | 15261 | | |
| 15262 | + | |
| 15263 | + | |
15208 | 15264 | | |
| 15265 | + | |
15209 | 15266 | | |
15210 | 15267 | | |
15211 | 15268 | | |
| |||
15487 | 15544 | | |
15488 | 15545 | | |
15489 | 15546 | | |
15490 | | - | |
| 15547 | + | |
| 15548 | + | |
15491 | 15549 | | |
| 15550 | + | |
15492 | 15551 | | |
15493 | 15552 | | |
15494 | 15553 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1091 | 1091 | | |
1092 | 1092 | | |
1093 | 1093 | | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
| 1120 | + | |
| 1121 | + | |
| 1122 | + | |
| 1123 | + | |
| 1124 | + | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + | |
| 1128 | + | |
| 1129 | + | |
| 1130 | + | |
| 1131 | + | |
| 1132 | + | |
| 1133 | + | |
| 1134 | + | |
| 1135 | + | |
| 1136 | + | |
| 1137 | + | |
| 1138 | + | |
| 1139 | + | |
| 1140 | + | |
| 1141 | + | |
1094 | 1142 | | |
1095 | 1143 | | |
1096 | 1144 | | |
| |||
1291 | 1339 | | |
1292 | 1340 | | |
1293 | 1341 | | |
1294 | | - | |
| 1342 | + | |
| 1343 | + | |
| 1344 | + | |
1295 | 1345 | | |
1296 | 1346 | | |
1297 | 1347 | | |
| |||
1349 | 1399 | | |
1350 | 1400 | | |
1351 | 1401 | | |
| 1402 | + | |
| 1403 | + | |
1352 | 1404 | | |
| 1405 | + | |
1353 | 1406 | | |
1354 | 1407 | | |
1355 | 1408 | | |
| |||
1631 | 1684 | | |
1632 | 1685 | | |
1633 | 1686 | | |
1634 | | - | |
| 1687 | + | |
| 1688 | + | |
1635 | 1689 | | |
| 1690 | + | |
1636 | 1691 | | |
1637 | 1692 | | |
1638 | 1693 | | |
| |||
0 commit comments