|
| 1 | +name: verify-network |
| 2 | + |
| 3 | +# Network verification tiers (source-URL liveness + external cross-reference) and |
| 4 | +# verified promotion. NEVER runs on pull_request — these tiers hit external sites, |
| 5 | +# are rate-limited, and must not gate a merge. Scheduled + manual only. Promotions |
| 6 | +# are written on a branch and opened as a PR for human review; the job hard-guards |
| 7 | +# that nothing but `verified` flags and the ledger changed. |
| 8 | + |
| 9 | +on: |
| 10 | + workflow_dispatch: |
| 11 | + inputs: |
| 12 | + apply: |
| 13 | + description: "Flip verified->true and open a PR (otherwise dry-run only)" |
| 14 | + type: boolean |
| 15 | + default: false |
| 16 | + max_urls: |
| 17 | + description: "Frontier records to URL-check" |
| 18 | + default: "2000" |
| 19 | + max_crossref: |
| 20 | + description: "Yellow/red records to cross-reference" |
| 21 | + default: "500" |
| 22 | + schedule: |
| 23 | + - cron: "0 4 * * 1" # Mondays 04:00 UTC |
| 24 | + |
| 25 | +permissions: |
| 26 | + contents: write |
| 27 | + pull-requests: write |
| 28 | + |
| 29 | +jobs: |
| 30 | + verify-network: |
| 31 | + runs-on: ubuntu-latest |
| 32 | + env: |
| 33 | + PYTHONIOENCODING: utf-8 |
| 34 | + steps: |
| 35 | + - uses: actions/checkout@v4 |
| 36 | + with: |
| 37 | + fetch-depth: 0 |
| 38 | + |
| 39 | + - uses: actions/setup-python@v5 |
| 40 | + with: |
| 41 | + python-version: "3.12" |
| 42 | + |
| 43 | + # Resumable caches (URL + crossref). Recomputable, so a miss is harmless. |
| 44 | + - name: Restore verify caches |
| 45 | + uses: actions/cache@v4 |
| 46 | + with: |
| 47 | + path: data/_verify/state |
| 48 | + key: verify-state-${{ github.run_id }} |
| 49 | + restore-keys: verify-state- |
| 50 | + |
| 51 | + - name: Tier 0 score (writes scores cache) |
| 52 | + run: python -m app.verify score |
| 53 | + |
| 54 | + - name: Tier 1 source-URL liveness |
| 55 | + run: python -m app.verify check-urls --max ${{ github.event.inputs.max_urls || '2000' }} |
| 56 | + |
| 57 | + - name: Tier 2 external cross-reference |
| 58 | + run: python -m app.verify crossref --max ${{ github.event.inputs.max_crossref || '500' }} |
| 59 | + |
| 60 | + - name: Tier 3 promote (dry-run) |
| 61 | + run: python -m app.verify promote |
| 62 | + |
| 63 | + - name: Tier 3 promote (apply) |
| 64 | + if: ${{ github.event.inputs.apply == 'true' }} |
| 65 | + run: python -m app.verify promote --apply |
| 66 | + |
| 67 | + - name: Structural validator self-check |
| 68 | + if: ${{ github.event.inputs.apply == 'true' }} |
| 69 | + run: python -m app.validate |
| 70 | + |
| 71 | + # Guard: the only tracked changes may be `verified` toggles in data/**.json |
| 72 | + # plus the promotion ledger. Anything else fails the run loudly. |
| 73 | + - name: Guard diff scope |
| 74 | + if: ${{ github.event.inputs.apply == 'true' }} |
| 75 | + run: | |
| 76 | + python - <<'PY' |
| 77 | + import subprocess, sys |
| 78 | + out = subprocess.run(["git", "diff", "--unified=0", "--", "data/"], |
| 79 | + capture_output=True, text=True).stdout |
| 80 | + bad = [] |
| 81 | + for line in out.splitlines(): |
| 82 | + if line.startswith(("+++", "---", "@@", "diff ", "index ")): |
| 83 | + continue |
| 84 | + if line.startswith(("+", "-")) and line[1:].strip(): |
| 85 | + body = line[1:].strip().rstrip(",") |
| 86 | + if body not in ('"verified": true', '"verified": false'): |
| 87 | + bad.append(line) |
| 88 | + if bad: |
| 89 | + print("Unexpected non-verified changes:") |
| 90 | + print("\n".join(bad[:50])) |
| 91 | + sys.exit(1) |
| 92 | + print("diff scope OK: only verified toggles") |
| 93 | + PY |
| 94 | +
|
| 95 | + - name: Open promotion PR |
| 96 | + if: ${{ github.event.inputs.apply == 'true' }} |
| 97 | + env: |
| 98 | + GH_TOKEN: ${{ secrets.TECHAPI_TOKEN || secrets.GITHUB_TOKEN }} |
| 99 | + run: | |
| 100 | + set -e |
| 101 | + if git diff --quiet -- data/; then |
| 102 | + echo "no promotions to commit"; exit 0 |
| 103 | + fi |
| 104 | + branch="verify/promote-${{ github.run_id }}" |
| 105 | + git config user.name "github-actions[bot]" |
| 106 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 107 | + git checkout -b "$branch" |
| 108 | + git add data/ |
| 109 | + git commit -m "data(verify): promote records to verified via cross-reference |
| 110 | +
|
| 111 | + Auto-promotions from the verification layer (green+live-T1 or crossref-confirm). |
| 112 | + Each flip is verified:false->true only; see data/_verify/ledger.jsonl. Refs #1" |
| 113 | + git push origin "$branch" |
| 114 | + gh pr create --base main --head "$branch" \ |
| 115 | + --title "data(verify): verified promotions ($(date -u +%Y-%m-%d))" \ |
| 116 | + --body "Automated verified promotions from \`app.verify promote\`. Each change flips only the \`verified\` flag; structural validator passed and diff scope guarded. Review before merge. Refs #1" |
0 commit comments