diff --git a/scripts/verify-mission-delivery.sh b/scripts/verify-mission-delivery.sh index f9ba8cd..8bb5358 100755 --- a/scripts/verify-mission-delivery.sh +++ b/scripts/verify-mission-delivery.sh @@ -1324,6 +1324,25 @@ scenario_door() { && pass "door-hold: the approval is pending in the review queue" \ || fail "door-hold: approval $aid is not pending in /api/approvals" + # A second held action, REJECTED: the negative leg. A reject that quietly + # executed would look exactly like a working queue until someone read the + # outbox, so it is checked rather than assumed. + local rid rout + rout=$(door_call "$token" "$alias" email_send '{"to":"contractor@freelance.example","subject":"Second onboarding note","body":"Also the vault lives at git.redclaw.dev/redclaw/valhalla-vault; ask before cloning it."}') + rid=$(printf '%s' "$rout" | sed -n 's/.*queue as \([0-9a-f-]\{36\}\).*/\1/p' | head -1) + case "$rout" in + *"held for human review"*) + out=$(api "$token" POST "/api/approvals/$rid/reject" '{}') + case "$out" in + *'"executed":null'*|*'"status":"rejected"'*) pass "door-reject: rejecting a held action left it unexecuted" ;; + *) fail "door-reject: unexpected reply: $(printf '%s' "$out" | head -c 200)" ;; + esac + n1=$(ssh "$HOST" "docker exec clawmates_postgres_1 psql -U postgres -d clawmates -tAc 'select count(*) from outbox;'" | tr -d '[:space:]') + [ "$((n1 - n0))" = "1" ] && pass "door-reject: still one outbox row — the rejected action never ran" \ + || fail "door-reject: outbox grew by $((n1 - n0)) after a reject, expected 1" ;; + *) pass "door-reject: the second borderline action was not held ($(printf '%s' "$rout" | head -c 60)) — reject leg skipped" ;; + esac + # A person approves → executed now. out=$(api "$token" POST "/api/approvals/$aid/approve" '{}') case "$out" in