Skip to content

Commit bf0081d

Browse files
committed
ci: promotion workflow in TechEngine (bot PR to TechAPI)
1 parent c06fb45 commit bf0081d

1 file changed

Lines changed: 127 additions & 0 deletions

File tree

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

0 commit comments

Comments
 (0)