|
| 1 | +name: Finalize Strix contextual-orchestrator PR |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - feat/strix-orchestrator-free-zdr |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + pull-requests: write |
| 11 | + |
| 12 | +concurrency: |
| 13 | + group: apply-strix-orchestrator-free-zdr-v3 |
| 14 | + cancel-in-progress: false |
| 15 | + |
| 16 | +jobs: |
| 17 | + finalize: |
| 18 | + if: "${{ github.event.head_commit.message == 'ci(strix): finalize gateway implementation and PR' }}" |
| 19 | + runs-on: ubuntu-latest |
| 20 | + timeout-minutes: 30 |
| 21 | + env: |
| 22 | + GH_TOKEN: ${{ secrets.PR_REVIEW_MERGE_TOKEN || secrets.OPENCODE_APPROVE_TOKEN || github.token }} |
| 23 | + FEATURE_BRANCH: feat/strix-orchestrator-free-zdr |
| 24 | + REPOSITORY: ContextualWisdomLab/.github |
| 25 | + steps: |
| 26 | + - name: Harden runner |
| 27 | + uses: step-security/harden-runner@b09bb98e06d4d774595224525879c09bc6e98c40 # v2.20.1 |
| 28 | + with: |
| 29 | + egress-policy: audit |
| 30 | + disable-file-monitoring: true |
| 31 | + |
| 32 | + - name: Checkout exact feature branch |
| 33 | + uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 |
| 34 | + with: |
| 35 | + ref: feat/strix-orchestrator-free-zdr |
| 36 | + fetch-depth: 0 |
| 37 | + persist-credentials: true |
| 38 | + |
| 39 | + - name: Apply or verify production patch and remove bootstrap workflows |
| 40 | + shell: bash |
| 41 | + run: | |
| 42 | + set -euo pipefail |
| 43 | + starting_head="$(git rev-parse HEAD)" |
| 44 | + marker='Provision contextual-orchestrator Strix sidecar' |
| 45 | + bootstrap='scripts/ci/apply_strix_orchestrator_followup.py' |
| 46 | +
|
| 47 | + verify_tree() { |
| 48 | + python3 tests/test_strix_contextual_orchestrator_contract.py |
| 49 | + bash scripts/ci/strix_required_workflow_smoke.sh |
| 50 | + bash -n scripts/ci/contextual_orchestrator_review_sidecar.sh |
| 51 | + python3 -m py_compile tests/test_strix_contextual_orchestrator_contract.py |
| 52 | + ruby -e 'require "yaml"; YAML.load_file(ARGV[0])' .github/workflows/strix.yml |
| 53 | + git diff --check |
| 54 | + } |
| 55 | +
|
| 56 | + cleanup_bootstrap() { |
| 57 | + rm -f \ |
| 58 | + .github/workflows/apply-strix-orchestrator-followup.yml \ |
| 59 | + .github/workflows/apply-strix-orchestrator-followup-v2.yml \ |
| 60 | + .github/workflows/apply-strix-orchestrator-followup-v3.yml \ |
| 61 | + .github/workflows/apply-strix-orchestrator-followup-v4.yml \ |
| 62 | + .github/workflows/finalize-strix-orchestrator-pr.yml \ |
| 63 | + scripts/ci/apply_strix_orchestrator_followup.py |
| 64 | + } |
| 65 | +
|
| 66 | + commit_cleanup() { |
| 67 | + remote_head="$(git ls-remote origin "refs/heads/${FEATURE_BRANCH}" | awk '{print $1}')" |
| 68 | + if [ "$remote_head" != "$starting_head" ]; then |
| 69 | + echo "::error::Branch advanced concurrently from ${starting_head} to ${remote_head}; refusing a non-fast-forward update." |
| 70 | + exit 1 |
| 71 | + fi |
| 72 | + git config user.name 'ContextualWisdomLab Automation' |
| 73 | + git config user.email 'automation@contextualwisdomlab.invalid' |
| 74 | + git add -A |
| 75 | + if git diff --cached --quiet; then |
| 76 | + return 0 |
| 77 | + fi |
| 78 | + git commit -m 'chore(ci): remove completed Strix gateway bootstrap' |
| 79 | + git push origin "HEAD:${FEATURE_BRANCH}" |
| 80 | + } |
| 81 | +
|
| 82 | + if grep -Fq "$marker" .github/workflows/strix.yml; then |
| 83 | + verify_tree |
| 84 | + cleanup_bootstrap |
| 85 | + git diff --check |
| 86 | + commit_cleanup |
| 87 | + exit 0 |
| 88 | + fi |
| 89 | +
|
| 90 | + if [ ! -f "$bootstrap" ]; then |
| 91 | + echo '::error::Gateway production marker is absent and no tracked applicator remains.' |
| 92 | + exit 1 |
| 93 | + fi |
| 94 | +
|
| 95 | + python3 <<'PY' |
| 96 | + from pathlib import Path |
| 97 | + import re |
| 98 | +
|
| 99 | + path = Path('scripts/ci/apply_strix_orchestrator_followup.py') |
| 100 | + text = path.read_text(encoding='utf-8') |
| 101 | + function_pattern = re.compile( |
| 102 | + r"def replace_once\(path: Path, old: str, new: str\) -> None:\n" |
| 103 | + r".*?" |
| 104 | + r"(?=\n\ndef regex_once)", |
| 105 | + re.DOTALL, |
| 106 | + ) |
| 107 | + replacement = '''def replace_once(path: Path, old: str, new: str) -> None: |
| 108 | + """Replace every exact occurrence of a bootstrap-only tracked fragment.""" |
| 109 | + |
| 110 | + text = path.read_text(encoding="utf-8") |
| 111 | + count = text.count(old) |
| 112 | + if count < 1: |
| 113 | + raise SystemExit( |
| 114 | + f"{path.relative_to(ROOT)}: replacement anchor is absent: {old[:120]!r}" |
| 115 | + ) |
| 116 | + path.write_text(text.replace(old, new), encoding="utf-8")''' |
| 117 | + text, count = function_pattern.subn(replacement, text, count=1) |
| 118 | + if count != 1: |
| 119 | + raise SystemExit(f'could not replace replace_once implementation: matches={count}') |
| 120 | + |
| 121 | + cleanup_anchor = ' BOOTSTRAP_SCRIPT.unlink()\n' |
| 122 | + cleanup_block = ''' BOOTSTRAP_SCRIPT.unlink() |
| 123 | + for completed_bootstrap in ( |
| 124 | + ROOT / ".github/workflows/apply-strix-orchestrator-followup-v2.yml", |
| 125 | + ROOT / ".github/workflows/apply-strix-orchestrator-followup-v3.yml", |
| 126 | + ROOT / ".github/workflows/apply-strix-orchestrator-followup-v4.yml", |
| 127 | + ROOT / ".github/workflows/finalize-strix-orchestrator-pr.yml", |
| 128 | + ): |
| 129 | + if completed_bootstrap.exists(): |
| 130 | + completed_bootstrap.unlink() |
| 131 | +''' |
| 132 | + if cleanup_anchor not in text: |
| 133 | + raise SystemExit('could not locate bootstrap cleanup anchor') |
| 134 | + text = text.replace(cleanup_anchor, cleanup_block, 1) |
| 135 | + path.write_text(text, encoding='utf-8') |
| 136 | + PY |
| 137 | + |
| 138 | + python3 -m py_compile "$bootstrap" |
| 139 | + python3 "$bootstrap" |
| 140 | + |
| 141 | + - name: Create or update review-ready pull request |
| 142 | + shell: bash |
| 143 | + run: | |
| 144 | + set -euo pipefail |
| 145 | + final_head="$(git rev-parse HEAD)" |
| 146 | + remote_head="$(git ls-remote origin "refs/heads/${FEATURE_BRANCH}" | awk '{print $1}')" |
| 147 | + if [ "$final_head" != "$remote_head" ]; then |
| 148 | + echo "::error::Local final head ${final_head} is not the remote branch head ${remote_head}." |
| 149 | + exit 1 |
| 150 | + fi |
| 151 | + if ! git show "${final_head}:.github/workflows/strix.yml" | grep -Fq 'Provision contextual-orchestrator Strix sidecar'; then |
| 152 | + echo '::error::Final head does not contain the gateway production marker.' |
| 153 | + exit 1 |
| 154 | + fi |
| 155 | + for retired in \ |
| 156 | + .github/workflows/apply-strix-orchestrator-followup.yml \ |
| 157 | + .github/workflows/apply-strix-orchestrator-followup-v2.yml \ |
| 158 | + .github/workflows/apply-strix-orchestrator-followup-v3.yml \ |
| 159 | + .github/workflows/apply-strix-orchestrator-followup-v4.yml \ |
| 160 | + .github/workflows/finalize-strix-orchestrator-pr.yml \ |
| 161 | + scripts/ci/apply_strix_orchestrator_followup.py; do |
| 162 | + if git cat-file -e "${final_head}:${retired}" 2>/dev/null; then |
| 163 | + echo "::error::Completed bootstrap file remains tracked: ${retired}" |
| 164 | + exit 1 |
| 165 | + fi |
| 166 | + done |
| 167 | +
|
| 168 | + body_file="$RUNNER_TEMP/strix-orchestrator-pr.md" |
| 169 | + cat > "$body_file" <<EOF |
| 170 | + ## Summary |
| 171 | +
|
| 172 | + Route normal required Strix security scans through the pinned, vendored |
| 173 | + \`contextual-orchestrator\` sidecar and its fail-closed |
| 174 | + \`orchestrator/free\` ZDR-first zero-cost pool. |
| 175 | +
|
| 176 | + - The five established provider credentials are registered only inside the |
| 177 | + sidecar process-local KV. |
| 178 | + - Strix receives a short-lived, masked bearer token and an exact IPv4 |
| 179 | + loopback OpenAI-compatible base URL. |
| 180 | + - Provider/model discovery and fallback have one authority: the gateway. |
| 181 | + - Existing NVIDIA NIM, OpenRouter, GitHub Models, direct OpenAI, and Vertex |
| 182 | + selectors remain available only as explicit \`repository_dispatch.strix_llm\` |
| 183 | + diagnostics. |
| 184 | + - Missing credentials, empty discovery, unhealthy startup, invalid loopback |
| 185 | + identity, provider exhaustion, and incomplete reports remain non-passing. |
| 186 | +
|
| 187 | + ## Root cause |
| 188 | +
|
| 189 | + DiskSage #264 produced successful product, release, SAST, and security checks, |
| 190 | + while central Strix exhausted NVIDIA 429, NVIDIA fallback 404, OpenRouter 502, |
| 191 | + and direct OpenAI \`insufficient_quota\` paths without an authoritative |
| 192 | + vulnerability artifact. Serialization reduced concurrency but left routing |
| 193 | + authority duplicated inside Strix instead of using the already-merged gateway. |
| 194 | +
|
| 195 | + ## Exact-head evidence |
| 196 | +
|
| 197 | + - Head: \`${final_head}\` |
| 198 | + - RED contract observed against the predecessor direct-provider default. |
| 199 | + - GREEN: gateway workflow contract, bounded required-workflow smoke, sidecar |
| 200 | + Bash syntax, Python compile, YAML parse, and diff hygiene passed before push. |
| 201 | + - Bootstrap workflows and patch applicator are absent from the final tree. |
| 202 | + - No force push, branch-protection bypass, self-approval, or provider failure |
| 203 | + neutralization is used. |
| 204 | +
|
| 205 | + ## Documentation and traceability |
| 206 | +
|
| 207 | + - \`docs/adr/0004-strix-contextual-orchestrator-authority.md\` |
| 208 | + - \`docs/doctoring/strix-contextual-orchestrator-gateway.md\` |
| 209 | + - \`docs/product-technical-gap-baseline.md\` |
| 210 | + - \`CHANGELOG.md\` |
| 211 | + - Figma File ID: N/A — central control-plane workflow, no customer UI. |
| 212 | +
|
| 213 | + ## Merge gate |
| 214 | +
|
| 215 | + Merge only after this unchanged exact head has terminal required Checks, |
| 216 | + zero valid unresolved review findings, and qualifying independent approval. |
| 217 | + Predecessor or consumer-repository Strix evidence is not transferable. |
| 218 | + EOF |
| 219 | +
|
| 220 | + pr_number="$(gh pr list --repo "$REPOSITORY" --state open --head "$FEATURE_BRANCH" --json number --jq '.[0].number // empty')" |
| 221 | + if [ -z "$pr_number" ]; then |
| 222 | + gh pr create \ |
| 223 | + --repo "$REPOSITORY" \ |
| 224 | + --base main \ |
| 225 | + --head "$FEATURE_BRANCH" \ |
| 226 | + --title 'fix(strix): route default scans through contextual-orchestrator' \ |
| 227 | + --body-file "$body_file" \ |
| 228 | + --draft |
| 229 | + pr_number="$(gh pr list --repo "$REPOSITORY" --state open --head "$FEATURE_BRANCH" --json number --jq '.[0].number // empty')" |
| 230 | + fi |
| 231 | + if [ -z "$pr_number" ]; then |
| 232 | + echo '::error::Could not resolve the pull request after create/update.' |
| 233 | + exit 1 |
| 234 | + fi |
| 235 | + gh pr edit "$pr_number" --repo "$REPOSITORY" --title 'fix(strix): route default scans through contextual-orchestrator' --body-file "$body_file" |
| 236 | + is_draft="$(gh pr view "$pr_number" --repo "$REPOSITORY" --json isDraft --jq '.isDraft')" |
| 237 | + if [ "$is_draft" = 'true' ]; then |
| 238 | + gh pr ready "$pr_number" --repo "$REPOSITORY" |
| 239 | + fi |
| 240 | + if ! gh pr merge "$pr_number" --repo "$REPOSITORY" --auto --squash; then |
| 241 | + echo '::notice::Auto-merge was not enabled; protected Checks and independent review remain authoritative.' |
| 242 | + fi |
| 243 | + echo "Review-ready PR: ${REPOSITORY}#${pr_number} @ ${final_head}" |
0 commit comments