Skip to content

Commit 53bc149

Browse files
committed
Make dogfood review gate handle terminal attention states
1 parent 1f30485 commit 53bc149

File tree

2 files changed

+71
-2
lines changed

2 files changed

+71
-2
lines changed

internal/cli/assistant_dogfood_script_test.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ esac
7474
fakeDX := filepath.Join(fakeBinDir, "assistant-dx.sh")
7575
writeExecutable(t, fakeDX, `#!/usr/bin/env bash
7676
set -euo pipefail
77+
printf '%s\n' "$*" >> "${AMUX_DX_CALL_LOG:?missing AMUX_DX_CALL_LOG}"
7778
cmd="${1:-}"
7879
sub="${2:-}"
7980
case "$cmd $sub" in
@@ -88,6 +89,12 @@ case "$cmd $sub" in
8889
fi
8990
jq -cn --arg ws "$ws_id" '{ok:true,command:"workspace.create",status:"ok",summary:"Workspace created.",next_action:"",suggested_command:"",data:{id:$ws,assistant:"codex"},quick_actions:[]}'
9091
;;
92+
"status --workspace")
93+
jq -cn '{ok:true,command:"status",status:"attention",summary:"Implement pass reached bounded terminal state.",next_action:"Proceed to review.",suggested_command:"",data:{task:{overall_status:"partial"}},quick_actions:[]}'
94+
;;
95+
"review --workspace")
96+
jq -cn '{ok:true,command:"review",status:"ok",summary:"Review completed.",next_action:"Continue.",suggested_command:"",data:{},quick_actions:[]}'
97+
;;
9198
*)
9299
jq -cn '{ok:true,command:"noop",status:"ok",summary:"ok",next_action:"",suggested_command:"",data:{},quick_actions:[]}'
93100
;;
@@ -106,9 +113,12 @@ esac
106113
env := os.Environ()
107114
env = withEnv(env, "PATH", fakeBinDir+":"+os.Getenv("PATH"))
108115
env = withEnv(env, "AMUX_ASSISTANT_DOGFOOD_DX_SCRIPT", fakeDX)
116+
env = withEnv(env, "AMUX_DX_CALL_LOG", filepath.Join(fakeBinDir, "dx-calls.log"))
109117
env = withEnv(env, "AMUX_ASSISTANT_DOGFOOD_CHANNEL_EPHEMERAL_AGENT", "false")
110118
env = withEnv(env, "AMUX_ASSISTANT_DOGFOOD_CHANNEL_REQUIRE_PROOF", "false")
111119
env = withEnv(env, "AMUX_ASSISTANT_DOGFOOD_REQUIRE_CHANNEL_EXECUTION", "false")
120+
env = withEnv(env, "AMUX_ASSISTANT_DOGFOOD_REVIEW_GATE_TIMEOUT_SECONDS", "1")
121+
env = withEnv(env, "AMUX_ASSISTANT_DOGFOOD_REVIEW_GATE_POLL_SECONDS", "0")
112122
cmd.Env = env
113123
out, err := cmd.CombinedOutput()
114124
if err != nil {
@@ -127,4 +137,27 @@ esac
127137
if strings.Contains(string(out), "failed to resolve ws1 id from project_add") {
128138
t.Fatalf("script still relied on project_add workspace id:\n%s", string(out))
129139
}
140+
141+
callLogRaw, err := os.ReadFile(filepath.Join(fakeBinDir, "dx-calls.log"))
142+
if err != nil {
143+
t.Fatalf("read dx call log: %v", err)
144+
}
145+
callLog := string(callLogRaw)
146+
if strings.Contains(callLog, "workflow dual") {
147+
t.Fatalf("dogfood should not invoke removed workflow command, got:\n%s", callLog)
148+
}
149+
if !strings.Contains(callLog, "start --workspace ws-primary") || !strings.Contains(callLog, "--allow-new-run") {
150+
t.Fatalf("dogfood should run implement step with --allow-new-run, got:\n%s", callLog)
151+
}
152+
if !strings.Contains(callLog, "status --workspace ws-primary --assistant codex") {
153+
t.Fatalf("dogfood should gate review on workspace status checks, got:\n%s", callLog)
154+
}
155+
if !strings.Contains(callLog, "review --workspace ws-primary") {
156+
t.Fatalf("dogfood should run review step for primary workspace, got:\n%s", callLog)
157+
}
158+
for _, line := range strings.Split(callLog, "\n") {
159+
if strings.Contains(line, "review --workspace ws-primary") && strings.Contains(line, "--no-monitor") {
160+
t.Fatalf("dogfood review step should monitor to terminal status, got:\n%s", callLog)
161+
}
162+
}
130163
}

skills/amux/scripts/assistant-dogfood.sh

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Runs a real Assistant/amux dogfood flow end-to-end:
1717
- continue coding
1818
- create second workspace + start
1919
- terminal run + logs
20-
- workflow dual
20+
- bounded implement + review pass
2121
- git ship
2222
- status
2323
EOF
@@ -219,6 +219,38 @@ run_dx() {
219219
printf '%s\t%s\n' "$slug" "$(cat "$status_file")"
220220
}
221221

222+
wait_for_workspace_ready_for_review() {
223+
local workspace="$1"
224+
local assistant="$2"
225+
local timeout_s="${AMUX_ASSISTANT_DOGFOOD_REVIEW_GATE_TIMEOUT_SECONDS:-240}"
226+
local poll_s="${AMUX_ASSISTANT_DOGFOOD_REVIEW_GATE_POLL_SECONDS:-5}"
227+
local start_ts elapsed attempt status overall json_file
228+
start_ts="$(date +%s)"
229+
attempt=0
230+
231+
while true; do
232+
attempt=$((attempt + 1))
233+
run_dx "dual_gate_status_${attempt}" status --workspace "$workspace" --assistant "$assistant"
234+
json_file="$REPORT_DIR/dual_gate_status_${attempt}.json"
235+
status="$(jq -r '.status // ""' <"$json_file" 2>/dev/null || true)"
236+
overall="$(jq -r '.data.task.overall_status // ""' <"$json_file" 2>/dev/null || true)"
237+
238+
if [[ "$status" == "ok" || "$overall" == "completed" || "$overall" == "session_exited" || "$overall" == "partial" || "$overall" == "partial_budget" || "$overall" == "timed_out" ]]; then
239+
return 0
240+
fi
241+
if [[ "$status" == "needs_input" ]]; then
242+
run_dx "dual_gate_continue_${attempt}" continue --workspace "$workspace" --assistant "$assistant" --text "Continue from current state and finish this run with a concise completion summary." --enter --wait-timeout 70s --idle-threshold 10s
243+
fi
244+
245+
elapsed="$(( $(date +%s) - start_ts ))"
246+
if (( elapsed >= timeout_s )); then
247+
echo "timed out waiting for workspace $workspace implement run to reach terminal state before review (status=$status overall=$overall)" >&2
248+
return 1
249+
fi
250+
sleep "$poll_s"
251+
done
252+
}
253+
222254
run_assistant_local_ping() {
223255
local slug="$1"
224256
local session_id="$2"
@@ -439,7 +471,11 @@ run_dx terminal_run_ws1 terminal run --workspace "$WS1_ID" --text "go run main.g
439471
sleep 1
440472
run_dx terminal_logs_ws1 terminal logs --workspace "$WS1_ID" --lines 40
441473

442-
run_dx workflow_dual_ws1 workflow dual --workspace "$WS1_ID" --implement-assistant "$ASSISTANT" --implement-prompt "Append one concise mobile-coding tip to README.md and proceed even if there are unrelated uncommitted changes." --review-assistant "$ASSISTANT" --review-prompt "Review for clarity and correctness." --max-steps 1 --turn-budget 100 --wait-timeout 70s --idle-threshold 10s --auto-continue-impl true
474+
run_dx dual_impl_ws1 start --workspace "$WS1_ID" --assistant "$ASSISTANT" --prompt "Append one concise mobile-coding tip to README.md and proceed even if there are unrelated uncommitted changes." --max-steps 1 --turn-budget 100 --wait-timeout 70s --idle-threshold 10s --allow-new-run
475+
if ! wait_for_workspace_ready_for_review "$WS1_ID" "$ASSISTANT"; then
476+
exit 1
477+
fi
478+
run_dx dual_review_ws1 review --workspace "$WS1_ID" --assistant "$ASSISTANT" --prompt "Review for clarity and correctness." --max-steps 1 --turn-budget 100 --wait-timeout 70s --idle-threshold 10s
443479

444480
run_dx git_ship_ws1 git ship --workspace "$WS1_ID" --message "dogfood: scripted assistant pass"
445481
run_dx status_ws1 status --workspace "$WS1_ID" --capture-agents 8 --capture-lines 80

0 commit comments

Comments
 (0)