Skip to content

Commit adaa4cd

Browse files
authored
Merge pull request #1755 from fullsend-ai/agent/1752-defer-ready-to-code-label
fix(#1752): defer ready-to-code label until after label_actions
2 parents 972ce7f + 0fb3793 commit adaa4cd

2 files changed

Lines changed: 80 additions & 2 deletions

File tree

internal/scaffold/fullsend-repo/scripts/post-triage-test.sh

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,72 @@ run_test_no_pattern "label-actions-all-refused-no-reason" \
309309
'{"action":"sufficient","reasoning":"all clear","clarity_scores":{"symptom":0.9,"cause":0.85,"reproduction":0.9,"impact":0.8,"overall":0.87},"triage_summary":{"title":"Fix crash","severity":"high","category":"bug","problem":"Crash","root_cause_hypothesis":"Buffer overflow","reproduction_steps":["step 1"],"environment":"Linux","impact":"All users","recommended_fix":"Fix buffer","proposed_test_case":"test_crash"},"comment":"## Triage Summary\n\nReady.","label_actions":{"reason":"Should not appear.","actions":[{"action":"add","label":"ready-to-code"}]}}' \
310310
"Should not appear."
311311

312+
# run_test_label_order verifies that a pattern appears AFTER another pattern
313+
# in the gh call log (i.e., ordering of API calls).
314+
run_test_label_order() {
315+
local test_name="$1"
316+
local json_content="$2"
317+
local before_pattern="$3"
318+
local after_pattern="$4"
319+
320+
local run_dir="${TMPDIR}/run-${test_name}"
321+
mkdir -p "${run_dir}/iteration-1/output"
322+
echo "${json_content}" > "${run_dir}/iteration-1/output/agent-result.json"
323+
: > "${GH_LOG}"
324+
325+
local exit_code=0
326+
(cd "${run_dir}" && bash "${POST_SCRIPT}") > "${TMPDIR}/stdout.log" 2>&1 || exit_code=$?
327+
328+
if [[ ${exit_code} -ne 0 ]]; then
329+
echo "FAIL: ${test_name} — exit code ${exit_code}"
330+
cat "${TMPDIR}/stdout.log"
331+
FAILURES=$((FAILURES + 1))
332+
return
333+
fi
334+
335+
local before_line after_line
336+
before_line=$(grep -nF "${before_pattern}" "${GH_LOG}" | head -1 | cut -d: -f1)
337+
after_line=$(grep -nF "${after_pattern}" "${GH_LOG}" | head -1 | cut -d: -f1)
338+
339+
if [[ -z "${before_line}" ]]; then
340+
echo "FAIL: ${test_name} — before pattern '${before_pattern}' not found"
341+
echo "Actual calls:"
342+
cat "${GH_LOG}"
343+
FAILURES=$((FAILURES + 1))
344+
return
345+
fi
346+
347+
if [[ -z "${after_line}" ]]; then
348+
echo "FAIL: ${test_name} — after pattern '${after_pattern}' not found"
349+
echo "Actual calls:"
350+
cat "${GH_LOG}"
351+
FAILURES=$((FAILURES + 1))
352+
return
353+
fi
354+
355+
if [[ "${before_line}" -ge "${after_line}" ]]; then
356+
echo "FAIL: ${test_name} — '${before_pattern}' (line ${before_line}) should appear before '${after_pattern}' (line ${after_line})"
357+
echo "Actual calls:"
358+
cat "${GH_LOG}"
359+
FAILURES=$((FAILURES + 1))
360+
return
361+
fi
362+
363+
echo "PASS: ${test_name}"
364+
}
365+
366+
# Verify ready-to-code is applied AFTER informational labels from label_actions
367+
# to prevent the ready-to-code webhook event from being superseded (#1752).
368+
run_test_label_order "ready-to-code-applied-after-label-actions" \
369+
'{"action":"sufficient","reasoning":"all clear","clarity_scores":{"symptom":0.9,"cause":0.85,"reproduction":0.9,"impact":0.8,"overall":0.87},"triage_summary":{"title":"Fix crash","severity":"high","category":"bug","problem":"Crash","root_cause_hypothesis":"Buffer overflow","reproduction_steps":["step 1"],"environment":"Linux","impact":"All users","recommended_fix":"Fix buffer","proposed_test_case":"test_crash"},"comment":"## Triage Summary\n\nReady.","label_actions":{"reason":"Component label.","actions":[{"action":"add","label":"area/api"},{"action":"add","label":"priority/high"}]}}' \
370+
"labels[]=priority/high" \
371+
"labels[]=ready-to-code"
372+
373+
# Verify ready-to-code is still applied when there are no label_actions.
374+
run_test "ready-to-code-applied-without-label-actions" \
375+
'{"action":"sufficient","reasoning":"all clear","clarity_scores":{"symptom":0.9,"cause":0.85,"reproduction":0.9,"impact":0.8,"overall":0.87},"triage_summary":{"title":"Fix crash","severity":"high","category":"bug","problem":"Crash","root_cause_hypothesis":"Buffer overflow","reproduction_steps":["step 1"],"environment":"Linux","impact":"All users","recommended_fix":"Fix buffer","proposed_test_case":"test_crash"},"comment":"## Triage Summary\n\nReady."}' \
376+
"gh api repos/test-org/test-repo/issues/42/labels -f labels[]=ready-to-code --silent"
377+
312378
# --- Summary ---
313379

314380
echo ""

internal/scaffold/fullsend-repo/scripts/post-triage.sh

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,11 @@ is_control_label() {
9090

9191
# --- Action-specific validation and control labels ---
9292

93+
# Deferred label: when set, applied after label_actions so it fires last.
94+
# This prevents the ready-to-code webhook event from being superseded by
95+
# subsequent label events in the dispatch concurrency group (see #1752).
96+
DEFERRED_LABEL=""
97+
9398
case "${ACTION}" in
9499
insufficient)
95100
if [[ -z "${COMMENT}" ]]; then
@@ -160,8 +165,8 @@ case "${ACTION}" in
160165
echo "Category: ${CATEGORY}"
161166
case "${CATEGORY}" in
162167
bug|documentation|performance)
163-
echo "Applying ready-to-code label (${CATEGORY})..."
164-
add_label "ready-to-code"
168+
echo "Deferring ready-to-code label (${CATEGORY}) until after label_actions..."
169+
DEFERRED_LABEL="ready-to-code"
165170
;;
166171
feature)
167172
echo "Applying feature + triaged labels..."
@@ -232,6 +237,13 @@ if [[ "${HAS_LABEL_ACTIONS}" == "true" ]]; then
232237
fi
233238
fi
234239

240+
# --- Apply deferred label (must be last label mutation) ---
241+
242+
if [[ -n "${DEFERRED_LABEL}" ]]; then
243+
echo "Applying deferred label '${DEFERRED_LABEL}'..."
244+
add_label "${DEFERRED_LABEL}"
245+
fi
246+
235247
# --- Post comment ---
236248

237249
echo "Posting comment..."

0 commit comments

Comments
 (0)