|
| 1 | +name: Issue dev loop evidence |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: [dev] |
| 6 | + types: [opened, synchronize, reopened, ready_for_review] |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: read |
| 10 | + |
| 11 | +concurrency: |
| 12 | + group: issue-dev-loop-evidence-${{ github.event.pull_request.number }} |
| 13 | + cancel-in-progress: true |
| 14 | + |
| 15 | +jobs: |
| 16 | + bootstrap-evidence: |
| 17 | + if: >- |
| 18 | + github.event_name == 'pull_request' && |
| 19 | + github.head_ref == 'codex/issue-dev-loop' && |
| 20 | + github.event.pull_request.head.repo.full_name == github.repository && |
| 21 | + github.event.pull_request.user.login == 'codeacme17' |
| 22 | + runs-on: ubuntu-latest |
| 23 | + timeout-minutes: 45 |
| 24 | + steps: |
| 25 | + - name: Check out bootstrap PR head |
| 26 | + uses: actions/checkout@v6 |
| 27 | + with: |
| 28 | + ref: ${{ github.event.pull_request.head.sha }} |
| 29 | + fetch-depth: 0 |
| 30 | + persist-credentials: false |
| 31 | + |
| 32 | + - name: Assert immutable bootstrap head |
| 33 | + run: test "$(git rev-parse HEAD)" = "${{ github.event.pull_request.head.sha }}" |
| 34 | + |
| 35 | + - name: Set up pnpm |
| 36 | + uses: pnpm/action-setup@v6 |
| 37 | + |
| 38 | + - name: Set up Node |
| 39 | + uses: actions/setup-node@v6 |
| 40 | + with: |
| 41 | + node-version: 24 |
| 42 | + cache: pnpm |
| 43 | + |
| 44 | + - name: Install dependencies |
| 45 | + run: pnpm install --frozen-lockfile --ignore-scripts |
| 46 | + |
| 47 | + - name: Run bootstrap verification |
| 48 | + run: pnpm verify |
| 49 | + |
| 50 | + evidence: |
| 51 | + if: github.event_name == 'pull_request' && startsWith(github.event.pull_request.head.ref, 'codex/issue-') && github.event.pull_request.head.ref != 'codex/issue-dev-loop' |
| 52 | + runs-on: ubuntu-latest |
| 53 | + timeout-minutes: 45 |
| 54 | + steps: |
| 55 | + - name: Check out owner-merged control plane |
| 56 | + uses: actions/checkout@v6 |
| 57 | + with: |
| 58 | + ref: ${{ github.event.pull_request.base.sha }} |
| 59 | + fetch-depth: 0 |
| 60 | + path: control |
| 61 | + persist-credentials: false |
| 62 | + |
| 63 | + - name: Check out exact PR head |
| 64 | + uses: actions/checkout@v6 |
| 65 | + with: |
| 66 | + repository: ${{ github.event.pull_request.head.repo.full_name }} |
| 67 | + ref: ${{ github.event.pull_request.head.sha }} |
| 68 | + fetch-depth: 0 |
| 69 | + path: candidate |
| 70 | + persist-credentials: false |
| 71 | + |
| 72 | + - name: Set up trusted Node |
| 73 | + uses: actions/setup-node@v6 |
| 74 | + with: |
| 75 | + node-version: 24 |
| 76 | + |
| 77 | + - name: Resolve loop run |
| 78 | + id: run |
| 79 | + env: |
| 80 | + PR_HEAD_REF: ${{ github.event.pull_request.head.ref }} |
| 81 | + run: >- |
| 82 | + node control/loops/issue-dev-loop/scripts/resolve-run.mjs --loop-root candidate/loops/issue-dev-loop --branch "$PR_HEAD_REF" |
| 83 | +
|
| 84 | + - name: Require one active run |
| 85 | + run: test "${{ steps.run.outputs.has_run }}" = "true" |
| 86 | + |
| 87 | + - name: Check out frozen owner-merged baseline |
| 88 | + uses: actions/checkout@v6 |
| 89 | + with: |
| 90 | + ref: ${{ steps.run.outputs.base_sha }} |
| 91 | + fetch-depth: 1 |
| 92 | + path: trusted |
| 93 | + persist-credentials: false |
| 94 | + |
| 95 | + - name: Assert immutable head and trusted baseline |
| 96 | + env: |
| 97 | + FROZEN_BASE_SHA: ${{ steps.run.outputs.base_sha }} |
| 98 | + LIVE_BASE_SHA: ${{ github.event.pull_request.base.sha }} |
| 99 | + PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }} |
| 100 | + run: | |
| 101 | + test "$(git -C candidate rev-parse HEAD)" = "${PR_HEAD_SHA}" |
| 102 | + test "$(git -C trusted rev-parse HEAD)" = "${FROZEN_BASE_SHA}" |
| 103 | + git -C control merge-base --is-ancestor "${FROZEN_BASE_SHA}" "${LIVE_BASE_SHA}" |
| 104 | +
|
| 105 | + - name: Protect trusted control plane |
| 106 | + if: steps.run.outputs.has_run == 'true' |
| 107 | + run: >- |
| 108 | + node trusted/loops/issue-dev-loop/scripts/validate-candidate-control-plane.mjs --loop-root candidate/loops/issue-dev-loop --run-id "${{ steps.run.outputs.run_id }}" --base-sha "${{ steps.run.outputs.base_sha }}" --head-sha "${{ github.event.pull_request.head.sha }}" |
| 109 | +
|
| 110 | + - name: Protect append-only loop history |
| 111 | + if: steps.run.outputs.has_run == 'true' |
| 112 | + run: >- |
| 113 | + node trusted/loops/issue-dev-loop/scripts/validate-history.mjs --loop-root candidate/loops/issue-dev-loop --base-ref "${{ steps.run.outputs.base_sha }}" |
| 114 | +
|
| 115 | + - name: Build trusted verifier image |
| 116 | + run: >- |
| 117 | + docker build --tag echo-ui-loop-verifier:${{ github.run_id }}-${{ github.run_attempt }} --file trusted/loops/issue-dev-loop/scripts/verifier.Dockerfile trusted/loops/issue-dev-loop/scripts |
| 118 | +
|
| 119 | + - name: Prepare isolated candidate and baseline volumes |
| 120 | + shell: bash |
| 121 | + run: | |
| 122 | + candidate_volume="issue-dev-loop-candidate-${{ github.run_id }}-${{ github.run_attempt }}" |
| 123 | + baseline_volume="issue-dev-loop-baseline-${{ github.run_id }}-${{ github.run_attempt }}" |
| 124 | + image="echo-ui-loop-verifier:${{ github.run_id }}-${{ github.run_attempt }}" |
| 125 | + docker volume create "${candidate_volume}" |
| 126 | + docker volume create "${baseline_volume}" |
| 127 | + docker run --rm \ |
| 128 | + --mount "type=volume,src=${candidate_volume},dst=/work" \ |
| 129 | + --mount "type=bind,src=${GITHUB_WORKSPACE}/candidate,dst=/source,readonly" \ |
| 130 | + "${image}" \ |
| 131 | + sh -ceu 'cp -a /source/. /work/; cd /work; pnpm install --frozen-lockfile --ignore-scripts' |
| 132 | + docker run --rm \ |
| 133 | + --mount "type=volume,src=${baseline_volume},dst=/work" \ |
| 134 | + --mount "type=bind,src=${GITHUB_WORKSPACE}/trusted,dst=/source,readonly" \ |
| 135 | + "${image}" \ |
| 136 | + sh -ceu 'cp -a /source/. /work/; cd /work; pnpm install --frozen-lockfile --ignore-scripts' |
| 137 | +
|
| 138 | + - name: Run authoritative verification |
| 139 | + id: verify |
| 140 | + shell: bash |
| 141 | + run: | |
| 142 | + mkdir -p "${RUNNER_TEMP}/issue-dev-evidence" |
| 143 | + started_at="$(date -u +%Y-%m-%dT%H:%M:%SZ)" |
| 144 | + candidate_volume="issue-dev-loop-candidate-${{ github.run_id }}-${{ github.run_attempt }}" |
| 145 | + baseline_volume="issue-dev-loop-baseline-${{ github.run_id }}-${{ github.run_attempt }}" |
| 146 | + image="echo-ui-loop-verifier:${{ github.run_id }}-${{ github.run_attempt }}" |
| 147 | + set +e |
| 148 | + docker run --rm --network none \ |
| 149 | + --mount "type=volume,src=${candidate_volume},dst=/work" \ |
| 150 | + "${image}" \ |
| 151 | + pnpm verify 2>&1 | tee "${RUNNER_TEMP}/issue-dev-evidence/pnpm-verify.log" |
| 152 | + candidate_exit_code="${PIPESTATUS[0]}" |
| 153 | + set -e |
| 154 | + baseline_status=blocked |
| 155 | + baseline_exit_code=1 |
| 156 | + if [[ "${candidate_exit_code}" == "0" ]]; then |
| 157 | + set +e |
| 158 | + docker run --rm --network none \ |
| 159 | + --mount "type=volume,src=${baseline_volume},dst=/work" \ |
| 160 | + "${image}" \ |
| 161 | + pnpm test 2>&1 | tee "${RUNNER_TEMP}/issue-dev-evidence/owner-merged-baseline-tests.log" |
| 162 | + baseline_exit_code="${PIPESTATUS[0]}" |
| 163 | + set -e |
| 164 | + if [[ "${baseline_exit_code}" == "0" ]]; then |
| 165 | + baseline_status=passed |
| 166 | + else |
| 167 | + baseline_status=failed |
| 168 | + fi |
| 169 | + fi |
| 170 | + if [[ "${candidate_exit_code}" == "0" && "${baseline_exit_code}" == "0" ]]; then |
| 171 | + exit_code=0 |
| 172 | + else |
| 173 | + exit_code=1 |
| 174 | + fi |
| 175 | + finished_at="$(date -u +%Y-%m-%dT%H:%M:%SZ)" |
| 176 | + if [[ "${exit_code}" == "0" ]]; then verdict=passed; else verdict=failed; fi |
| 177 | + echo "started_at=${started_at}" >> "${GITHUB_OUTPUT}" |
| 178 | + echo "finished_at=${finished_at}" >> "${GITHUB_OUTPUT}" |
| 179 | + echo "exit_code=${exit_code}" >> "${GITHUB_OUTPUT}" |
| 180 | + echo "verdict=${verdict}" >> "${GITHUB_OUTPUT}" |
| 181 | + echo "baseline_status=${baseline_status}" >> "${GITHUB_OUTPUT}" |
| 182 | +
|
| 183 | + - name: Remove isolated verifier volumes |
| 184 | + if: always() |
| 185 | + run: | |
| 186 | + docker volume rm --force "issue-dev-loop-candidate-${{ github.run_id }}-${{ github.run_attempt }}" |
| 187 | + docker volume rm --force "issue-dev-loop-baseline-${{ github.run_id }}-${{ github.run_attempt }}" |
| 188 | +
|
| 189 | + - name: Generate exact-head manifest |
| 190 | + if: steps.run.outputs.has_run == 'true' && always() |
| 191 | + run: >- |
| 192 | + node trusted/loops/issue-dev-loop/scripts/generate-evidence.mjs --loop-root candidate/loops/issue-dev-loop --run-id "${{ steps.run.outputs.run_id }}" --head-sha "${{ github.event.pull_request.head.sha }}" --trusted-workflow-sha "${{ steps.run.outputs.base_sha }}" --workflow-base-sha "${{ github.event.pull_request.base.sha }}" --workflow-run-sha "${{ github.event.pull_request.head.sha }}" --status "${{ steps.verify.outputs.verdict || 'blocked' }}" --baseline-status "${{ steps.verify.outputs.baseline_status || 'blocked' }}" --started-at "${{ steps.verify.outputs.started_at || github.event.pull_request.updated_at }}" --finished-at "${{ steps.verify.outputs.finished_at || github.event.pull_request.updated_at }}" --output "${RUNNER_TEMP}/issue-dev-evidence/manifest.json" |
| 193 | +
|
| 194 | + - name: Upload review evidence |
| 195 | + if: steps.run.outputs.has_run == 'true' && always() |
| 196 | + id: artifact |
| 197 | + uses: actions/upload-artifact@v4 |
| 198 | + with: |
| 199 | + name: issue-dev-loop-${{ steps.run.outputs.run_id }}-${{ github.event.pull_request.head.sha }} |
| 200 | + path: | |
| 201 | + ${{ runner.temp }}/issue-dev-evidence |
| 202 | + candidate/loops/issue-dev-loop/screen-shots/${{ steps.run.outputs.run_id }} |
| 203 | + candidate/loops/issue-dev-loop/logs/runs/${{ steps.run.outputs.run_id }} |
| 204 | + if-no-files-found: error |
| 205 | + retention-days: 30 |
| 206 | + |
| 207 | + - name: Publish artifact link |
| 208 | + if: steps.run.outputs.has_run == 'true' && always() |
| 209 | + run: echo "Evidence artifact — ${{ steps.artifact.outputs.artifact-url }}" >> "${GITHUB_STEP_SUMMARY}" |
| 210 | + |
| 211 | + - name: Enforce verification result |
| 212 | + if: steps.verify.outputs.exit_code != '0' |
| 213 | + run: exit 1 |
0 commit comments