Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
10 changes: 2 additions & 8 deletions .github/workflows/opencode-review-dispatch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@ permissions:
contents: read

jobs:
required-workflow-bootstrap:
Comment thread
seonghobae marked this conversation as resolved.
name: required-workflow-bootstrap
runs-on: ubuntu-latest
steps:
- run: echo "OpenCode repository-dispatch review run materialized."

validate-pr-metadata:
name: validate-pr-metadata
if: github.event_name == 'repository_dispatch'
Expand Down Expand Up @@ -7600,14 +7594,14 @@ jobs:
&& needs.validate-pr-metadata.outputs.target_repository != ''
&& needs.validate-pr-metadata.outputs.head_sha != ''
env:
GH_TOKEN: ${{ needs.validate-pr-metadata.outputs.target_repository == github.repository && github.token || secrets.PR_REVIEW_MERGE_TOKEN || secrets.OPENCODE_APPROVE_TOKEN || steps.opencode_app_token.outputs.token || github.token }}
GH_TOKEN: ${{ secrets.PR_REVIEW_MERGE_TOKEN || secrets.OPENCODE_APPROVE_TOKEN || steps.opencode_app_token.outputs.token || github.token }}
Comment thread
seonghobae marked this conversation as resolved.
Outdated
GH_REPOSITORY: ${{ needs.validate-pr-metadata.outputs.target_repository }}
PR_NUMBER: ${{ needs.validate-pr-metadata.outputs.pr_number }}
PR_HEAD_SHA: ${{ needs.validate-pr-metadata.outputs.head_sha }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
OPENCODE_MODEL_POOL_OUTCOME: ${{ steps.opencode_review_model_pool.outputs.review_status }}
COVERAGE_EVIDENCE_RESULT: ${{ needs.coverage-evidence.result }}
OPENCODE_STATUS_TOKEN_SOURCE: ${{ needs.validate-pr-metadata.outputs.target_repository == github.repository && 'github-token' || secrets.PR_REVIEW_MERGE_TOKEN != '' && 'PR_REVIEW_MERGE_TOKEN' || secrets.OPENCODE_APPROVE_TOKEN != '' && 'OPENCODE_APPROVE_TOKEN' || steps.opencode_app_token.outputs.available == 'true' && 'opencode-app' || 'github-token' }}
OPENCODE_STATUS_TOKEN_SOURCE: ${{ secrets.PR_REVIEW_MERGE_TOKEN != '' && 'PR_REVIEW_MERGE_TOKEN' || secrets.OPENCODE_APPROVE_TOKEN != '' && 'OPENCODE_APPROVE_TOKEN' || steps.opencode_app_token.outputs.available == 'true' && 'opencode-app' || 'github-token' }}
Comment thread
devin-ai-integration[bot] marked this conversation as resolved.
Outdated
OPENCODE_CHANGED_FILES_FILE: ${{ runner.temp }}/opencode-changed-files.txt
OPENCODE_ARTIFACT_MANIFEST_SHA256: ${{ steps.seal_artifacts.outputs.manifest_sha256 }}
OPENCODE_SOURCE_WORKDIR: ${{ runner.temp }}/opencode-pr-head
Expand Down
134 changes: 134 additions & 0 deletions .github/workflows/tmp-pr1619-causal-repair.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
name: Temporary PR 1619 causal repair

on:
push:
branches:
- fix/current-main-remove-opencode-dispatch-bootstrap-20260902
paths:
- .github/workflows/tmp-pr1619-causal-repair.yml

permissions: {}

concurrency:
group: tmp-pr1619-causal-repair
cancel-in-progress: false

jobs:
repair:
runs-on: ubuntu-24.04
timeout-minutes: 20
permissions:
contents: write
steps:
- name: Check out exact repair head
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
fetch-depth: 0

- name: Reconstruct intended delta from live protected main and remove helper
shell: bash
env:
EXPECTED_REF: fix/current-main-remove-opencode-dispatch-bootstrap-20260902
run: |
set -euo pipefail
cleanup_on_failure() {
rc="$?"
if [ "$rc" -ne 0 ]; then
trap - EXIT
git reset --hard "${GITHUB_SHA}"
rm -f .github/workflows/tmp-pr1619-causal-repair.yml
git config user.name 'contextualwisdomlab-automation'
git config user.email 'contextualwisdomlab-automation@users.noreply.github.com'
git add .github/workflows/tmp-pr1619-causal-repair.yml
if ! git diff --cached --quiet; then
git commit -m 'chore(ci): remove failed temporary PR 1619 writer'
git fetch origin "${EXPECTED_REF}"
if [ "$(git rev-parse FETCH_HEAD)" = "${GITHUB_SHA}" ]; then
git push origin "HEAD:${EXPECTED_REF}"
else
echo '::error::Writer branch moved; refusing cleanup push.'
fi
fi
fi
exit "$rc"
}
trap cleanup_on_failure EXIT

test "${GITHUB_REF_NAME}" = "${EXPECTED_REF}"
test "$(git rev-parse HEAD)" = "${GITHUB_SHA}"

git fetch origin main
main_sha="$(git rev-parse FETCH_HEAD)"
test -n "$main_sha"
git fetch origin "${EXPECTED_REF}"
test "$(git rev-parse FETCH_HEAD)" = "${GITHUB_SHA}"

# Reconstruct the durable files from current protected main, then
# reapply only PR #1619's still-valid semantic delta. This discards the
# stale same-repository credential regression while preserving current main.
git checkout "$main_sha" -- \
.github/workflows/opencode-review-dispatch.yml \
tests/test_opencode_agent_contract.py \
tests/test_pr_review_autofix_nvidia_nim_contract.py

python - <<'PY'
from pathlib import Path

workflow_path = Path('.github/workflows/opencode-review-dispatch.yml')
workflow = workflow_path.read_text(encoding='utf-8')
bootstrap = ''' required-workflow-bootstrap:\n name: required-workflow-bootstrap\n runs-on: ubuntu-latest\n steps:\n - run: echo "OpenCode repository-dispatch review run materialized."\n\n'''
if workflow.count(bootstrap) != 1:
raise SystemExit('current main bootstrap shape changed; refusing lossy mutation')
workflow = workflow.replace(bootstrap, '', 1)
if 'required-workflow-bootstrap:' in workflow:
raise SystemExit('orphaned dispatch bootstrap still present')
workflow_path.write_text(workflow, encoding='utf-8')

test_path = Path('tests/test_opencode_agent_contract.py')
test_text = test_path.read_text(encoding='utf-8')
old = ''' assert "required-workflow-bootstrap:" in workflow\n assert "OpenCode repository-dispatch review run materialized." in workflow\n bootstrap_start = workflow.index(" required-workflow-bootstrap:\\n")\n bootstrap_end = workflow.index("\\n validate-pr-metadata:", bootstrap_start)\n bootstrap_job = workflow[bootstrap_start:bootstrap_end]\n assert "\\n if:" not in bootstrap_job\n'''
new = ''' # This repository_dispatch-only workflow is not the org-required\n # pull_request_target entrypoint, so an unconditional bootstrap job here only\n # consumes Actions capacity without providing authoritative review evidence.\n assert "required-workflow-bootstrap:" not in workflow\n'''
if test_text.count(old) != 1:
raise SystemExit('current main bootstrap contract test shape changed; refusing mutation')
test_path.write_text(test_text.replace(old, new, 1), encoding='utf-8')
PY

workflow_blob="$(git hash-object .github/workflows/opencode-review-dispatch.yml)"
python - "$workflow_blob" <<'PY'
import re
import sys
from pathlib import Path

blob = sys.argv[1]
path = Path('tests/test_pr_review_autofix_nvidia_nim_contract.py')
text = path.read_text(encoding='utf-8')
text, count = re.subn(
r'REVIEW_DISPATCH_BLOB_SHA = "[0-9a-f]{40}"',
f'REVIEW_DISPATCH_BLOB_SHA = "{blob}"',
text,
count=1,
)
if count != 1:
raise SystemExit('unable to update exact dispatch blob contract')
path.write_text(text, encoding='utf-8')
PY

PYTHONPATH=. python -m pytest -q \
tests/test_opencode_agent_contract.py \
tests/test_pr_review_autofix_nvidia_nim_contract.py
git diff --check

rm .github/workflows/tmp-pr1619-causal-repair.yml
Comment thread
devin-ai-integration[bot] marked this conversation as resolved.
Outdated
test ! -e .github/workflows/tmp-pr1619-causal-repair.yml
git diff --check

git config user.name 'contextualwisdomlab-automation'
git config user.email 'contextualwisdomlab-automation@users.noreply.github.com'
git add .github/workflows/opencode-review-dispatch.yml \
tests/test_opencode_agent_contract.py \
tests/test_pr_review_autofix_nvidia_nim_contract.py \
.github/workflows/tmp-pr1619-causal-repair.yml
git commit -m 'fix(opencode): reconstruct bootstrap removal from current main'
git fetch origin "${EXPECTED_REF}"
test "$(git rev-parse FETCH_HEAD)" = "${GITHUB_SHA}"
git push origin "HEAD:${EXPECTED_REF}"
22 changes: 8 additions & 14 deletions tests/test_opencode_agent_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,12 +469,12 @@ def test_opencode_ignores_superseded_cancelled_rollup_checks():
def test_opencode_target_coverage_materializes_only_after_authorized_dispatch():
"""Keep PR-controlled test execution off the pull_request_target path."""
workflow = Path(".github/workflows/opencode-review-dispatch.yml").read_text(encoding="utf-8")
assert "required-workflow-bootstrap:" in workflow
assert "OpenCode repository-dispatch review run materialized." in workflow
bootstrap_start = workflow.index(" required-workflow-bootstrap:\n")
bootstrap_end = workflow.index("\n validate-pr-metadata:", bootstrap_start)
bootstrap_job = workflow[bootstrap_start:bootstrap_end]
assert "\n if:" not in bootstrap_job
# required-workflow-bootstrap is the trusted-source-resolution sentinel needed
# only where the org ruleset targets a pull_request_target entrypoint
# (opencode-review.yml). This repository_dispatch-only workflow is not itself
# a required-workflow path, so it must not carry a copy-pasted, need-less
# orphan of that job.
assert "required-workflow-bootstrap:" not in workflow
assert (
"github.event.pull_request.head.repo.full_name == github.repository"
not in workflow
Expand Down Expand Up @@ -2399,17 +2399,11 @@ def test_opencode_runs_merge_scheduler_after_review_without_repo_local_dispatch(
" - name: Dispatch Noema after current-head OpenCode approval", 1
)[0]
assert (
"GH_TOKEN: ${{ needs.validate-pr-metadata.outputs.target_repository == "
"github.repository && github.token || secrets.PR_REVIEW_MERGE_TOKEN || "
"GH_TOKEN: ${{ secrets.PR_REVIEW_MERGE_TOKEN || "
"secrets.OPENCODE_APPROVE_TOKEN || steps.opencode_app_token.outputs.token || "
"github.token }}"
) in status_step
assert (
"OPENCODE_STATUS_TOKEN_SOURCE: ${{ "
"needs.validate-pr-metadata.outputs.target_repository == github.repository && "
"'github-token' || secrets.PR_REVIEW_MERGE_TOKEN != '' && "
"'PR_REVIEW_MERGE_TOKEN'"
) in status_step
assert "OPENCODE_STATUS_TOKEN_SOURCE" in status_step
Comment thread
devin-ai-integration[bot] marked this conversation as resolved.
Outdated
assert "steps.opencode_app_token.outputs.available == 'true' && 'opencode-app'" in status_step
assert "OPENCODE_CHANGED_FILES_FILE" in status_step
assert "OPENCODE_ARTIFACT_MANIFEST_SHA256" in status_step
Expand Down
2 changes: 1 addition & 1 deletion tests/test_pr_review_autofix_nvidia_nim_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
DOCTORING_RECORD = Path("docs/doctoring/hourly-nvidia-nim-autofix.md")
CHANGELOG = Path("CHANGELOG.md")
REVIEW_DISPATCH_WORKFLOW = Path(".github/workflows/opencode-review-dispatch.yml")
REVIEW_DISPATCH_BLOB_SHA = "cc0b84dff19195a7e209e9f78cd5ee80bfc58d53"
REVIEW_DISPATCH_BLOB_SHA = "0814541a9d79e72298fe4fea463224688bb6bd54"
Comment thread
github-actions[bot] marked this conversation as resolved.
Outdated


def _workflow_text(path: Path) -> str:
Expand Down
Loading