From a1c1dded236e19406541206d7f5c381aeec5495e Mon Sep 17 00:00:00 2001 From: Seongho Bae Date: Mon, 13 Jul 2026 01:25:07 +0900 Subject: [PATCH] fix(opencode): log central fallback scope reasons --- .github/workflows/opencode-review.yml | 22 +++++++++++++++++++--- tests/test_opencode_agent_contract.py | 6 ++++++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/.github/workflows/opencode-review.yml b/.github/workflows/opencode-review.yml index 87ad910e..4980e30f 100644 --- a/.github/workflows/opencode-review.yml +++ b/.github/workflows/opencode-review.yml @@ -1710,6 +1710,7 @@ jobs: run: | set -euo pipefail changed_files_file="$(mktemp)" + fallback_reasons_file="$(mktemp)" eligible=false changed_count=0 max_changed_count=0 @@ -1735,6 +1736,8 @@ jobs: ContextualWisdomLab/.github:.github/workflows/strix.yml | \ ContextualWisdomLab/.github:.jules/bolt.md | \ ContextualWisdomLab/.github:.gitleaksignore | \ + ContextualWisdomLab/.github:ci-review-prompt.md | \ + ContextualWisdomLab/.github:code-reviewer-prompt.md | \ ContextualWisdomLab/.github:opencode.jsonc | \ ContextualWisdomLab/.github:scripts/ci/changed_file_syntax_gate.py | \ ContextualWisdomLab/.github:scripts/ci/opencode_review_approve_gate.sh | \ @@ -1775,15 +1778,20 @@ jobs: return 1 } - if gh pr diff "$PR_NUMBER" --repo "$GH_REPOSITORY" --name-only >"$changed_files_file" && - [ -s "$changed_files_file" ] && - [ "$max_changed_count" -gt 0 ]; then + if ! gh pr diff "$PR_NUMBER" --repo "$GH_REPOSITORY" --name-only >"$changed_files_file"; then + printf 'gh pr diff failed for %s#%s\n' "$GH_REPOSITORY" "$PR_NUMBER" >>"$fallback_reasons_file" + elif [ ! -s "$changed_files_file" ]; then + printf 'no changed files were returned by gh pr diff\n' >>"$fallback_reasons_file" + elif [ "$max_changed_count" -le 0 ]; then + printf 'repository %s is not configured for central fallback scope\n' "$GH_REPOSITORY" >>"$fallback_reasons_file" + else eligible=true while IFS= read -r changed_file; do [ -n "$changed_file" ] || continue changed_count=$((changed_count + 1)) if ! fallback_changed_file_allowed "$changed_file"; then eligible=false + printf 'disallowed changed file: %s\n' "$changed_file" >>"$fallback_reasons_file" fi if fallback_changed_file_counts_as_core "$changed_file"; then central_review_process_core_changed=true @@ -1793,10 +1801,12 @@ jobs: if [ "$changed_count" -eq 0 ] || [ "$changed_count" -gt "$max_changed_count" ]; then eligible=false + printf 'changed_count=%s is outside allowed range 1..%s\n' "$changed_count" "$max_changed_count" >>"$fallback_reasons_file" fi if [ "$GH_REPOSITORY" = "ContextualWisdomLab/.github" ] && [ "$central_review_process_core_changed" != "true" ]; then eligible=false + printf 'no central OpenCode/Strix core file changed\n' >>"$fallback_reasons_file" fi { @@ -1807,6 +1817,12 @@ jobs: printf 'Trusted review-process scope=%s eligible=%s changed_count=%s max_changed_count=%s\n' \ "$scope_label" "$eligible" "$changed_count" "$max_changed_count" sed 's/^/- /' "$changed_files_file" + if [ -s "$fallback_reasons_file" ]; then + printf 'Fallback ineligibility reasons:\n' + sed 's/^/- /' "$fallback_reasons_file" + else + printf 'Fallback ineligibility reasons: none\n' + fi - name: Initialize CodeGraph index for OpenCode env: diff --git a/tests/test_opencode_agent_contract.py b/tests/test_opencode_agent_contract.py index 32d40f8f..8e18d152 100644 --- a/tests/test_opencode_agent_contract.py +++ b/tests/test_opencode_agent_contract.py @@ -561,6 +561,8 @@ def test_workflow_provisions_sandbox_tool_and_reviewer_agent(): assert "approve_low_risk_review_fallback_after_model_exhaustion" not in workflow assert "changed_file_is_low_risk_review_fallback" not in workflow assert "approve_current_head_after_model_unavailable" in workflow + assert "ContextualWisdomLab/.github:ci-review-prompt.md | \\" in workflow + assert "ContextualWisdomLab/.github:code-reviewer-prompt.md | \\" in workflow assert "opencode.jsonc | \\" in workflow assert "ContextualWisdomLab/.github:.jules/bolt.md | \\" in workflow assert "ContextualWisdomLab/.github:scripts/ci/opencode_review_approve_gate.sh | \\" in workflow @@ -576,6 +578,10 @@ def test_workflow_provisions_sandbox_tool_and_reviewer_agent(): assert "central_review_process_core_changed=false" in workflow assert "central_review_process_core_changed=true" in workflow assert 'central_review_process_core_changed" != "true"' in workflow + assert "Fallback ineligibility reasons:" in workflow + assert "disallowed changed file:" in workflow + assert "gh pr diff failed for %s#%s" in workflow + assert "no central OpenCode/Strix core file changed" in workflow assert "steps.central_review_process_fallback_scope.outputs.eligible != 'true'" not in workflow assert workflow.index("Detect central review-process scope") < workflow.index( "Initialize CodeGraph index for OpenCode"