orch: require explicit dispatch execution mode

This commit is contained in:
2026-03-20 19:27:30 +08:00
parent 7840b2767f
commit 5859ff219e
43 changed files with 277 additions and 312 deletions
Binary file not shown.
+13 -4
View File
@@ -90,6 +90,7 @@ attempt_no="$(jq -r '.data.attempt.attempt_no // empty' "${dispatch_json}")"
assigned_to="$(jq -r '.data.attempt.assigned_to // .data.task.default_to // empty' "${dispatch_json}")"
thread_id="$(jq -r '.data.attempt.thread_id // .data.thread.thread_id // empty' "${dispatch_json}")"
worktree_path="$(jq -r '.data.attempt.worktree_path // empty' "${dispatch_json}")"
execution_mode="$(jq -r '.data.message.payload_json.execution_mode // empty' "${dispatch_json}")"
base_ref="$(jq -r '.data.attempt.base_ref // empty' "${dispatch_json}")"
task_title="$(jq -r '.data.task.title // empty' "${dispatch_json}")"
task_summary="$(jq -r '.data.task.summary // empty' "${dispatch_json}")"
@@ -100,9 +101,17 @@ if [ -z "${run_id}" ] || [ -z "${task_id}" ] || [ -z "${assigned_to}" ] || [ -z
exit 1
fi
mode="analysis"
if [ -n "${worktree_path}" ]; then
mode="code"
if [ "${execution_mode}" != "analysis" ] && [ "${execution_mode}" != "code" ]; then
printf 'dispatch json is missing a supported execution_mode in message.payload_json\n' >&2
exit 1
fi
if [ "${execution_mode}" = "code" ] && [ -z "${worktree_path}" ]; then
printf 'dispatch json is inconsistent: execution_mode=code requires a worktree_path\n' >&2
exit 1
fi
if [ "${execution_mode}" = "analysis" ] && [ -n "${worktree_path}" ]; then
printf 'dispatch json is inconsistent: execution_mode=analysis must not include a worktree_path\n' >&2
exit 1
fi
cat <<EOF
@@ -114,7 +123,7 @@ You are assigned one existing attempt:
- attempt_no: ${attempt_no}
- assigned_to: ${assigned_to}
- thread_id: ${thread_id}
- execution_mode: ${mode}
- execution_mode: ${execution_mode}
EOF
if [ -n "${task_title}" ]; then