Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions .github/workflows/opencode-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 | \
Expand Down Expand Up @@ -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
Expand All @@ -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

{
Expand All @@ -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:
Expand Down
6 changes: 6 additions & 0 deletions tests/test_opencode_agent_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand Down
Loading