phoenix-verify.yml•5.43 kB
name: phoenix-resilience-verification
on:
push:
branches: [ main ]
workflow_dispatch:
schedule:
- cron: "0 3 * * *"
jobs:
verify:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Install Python deps
run: pip install pyyaml jq
- name: Build Rust plugin
working-directory: tem/rust/phoenix_resilience
run: cargo build --quiet
- name: Run Python plugin (parity + log)
id: py
run: |
python - <<'EOF'
import json
from tem.python.plugins.phoenix_resilience import load_config, PhoenixResiliencePlugin
cfg = load_config("config/phoenix_resilience.yaml")
phoenix = PhoenixResiliencePlugin(cfg)
# Parity output to file
out = {"next_phase": phoenix.next_phase("Normal", 0.208, 2.5)}
with open("phoenix_py.json","w") as f:
json.dump(out, f)
# Log LAWCHAIN invocation best-effort by simulating activation
phoenix._log_lawchain({"phase":"NIGREDO","psi":0.208,"pe":2.5})
EOF
- name: Run Rust plugin
id: rs
working-directory: tem/rust/phoenix_resilience
run: |
cargo run --quiet --example verify -- 0.208 2.5 > ../../rust_out.json
- name: Compare outputs (next_phase)
run: |
python - <<'EOF'
import json, sys
with open("phoenix_py.json","r") as f:
py = json.load(f)
with open("tem/rust_out.json","r") as f:
rs = json.load(f)
if py.get("next_phase") != rs.get("next_phase"):
print("❌ Mismatch:", py, rs); sys.exit(1)
print("✅ Python/Rust parity confirmed:", py)
EOF
- name: Check LAWCHAIN log
run: |
find governance/lawchain -type f -name '*phoenix-invocation*.json' -mtime -1 -print -quit \
|| (echo "⚠️ No LAWCHAIN log found (non-blocking)" && exit 0)
echo "✅ LAWCHAIN log present"
- name: Verify receipt presence (optional)
run: |
find governance/anchor-receipts -type f -name '*anchor*' -mtime -1 -print -quit \
|| (echo "⚠️ No new anchor receipts (DRY_RUN=true)" && exit 0)
- name: Write summary artifact
if: success() || failure()
run: |
mkdir -p artifacts
PY_PHASE=$(jq -r '.next_phase' phoenix_py.json 2>/dev/null || echo "")
RS_PHASE=$(jq -r '.next_phase' tem/rust_out.json 2>/dev/null || echo "")
LAW_LOG=$(find governance/lawchain -type f -name '*phoenix-invocation*.json' -mtime -1 -print -quit)
RECEIPTS=$(find governance/anchor-receipts -type f -name '*anchor*' -mtime -1 | wc -l)
cat > artifacts/phoenix_summary.json <<JSON
{
"run_number": "${{ github.run_number }}",
"python_phase": "${PY_PHASE}",
"rust_phase": "${RS_PHASE}",
"psi": 0.208,
"pe": 2.5,
"lawchain_log": "${LAW_LOG}",
"receipts_count": ${RECEIPTS}
}
JSON
- name: Upload artifact
if: success() || failure()
uses: actions/upload-artifact@v4
with:
name: phoenix-verification-summary
path: artifacts/phoenix_summary.json
- name: Write coherence badge JSON
if: success()
run: |
mkdir -p .badges
python - <<'EOF'
import json
with open('artifacts/phoenix_summary.json','r') as f:
s = json.load(f)
label = 'Ψ-field'
message = f"{s.get('python_phase','')} | Ψ={s.get('psi','')} | PE={s.get('pe','')}"
badge = {"schemaVersion":1, "label":label, "message":message, "color":"blue"}
with open('.badges/phoenix_coherence.json','w') as f:
json.dump(badge, f)
EOF
- name: Commit updated badge
if: success()
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add .badges/phoenix_coherence.json
git commit -m "update: phoenix coherence badge" || echo "No changes"
git push
- name: Anchor coherence badge (LAWCHAIN)
if: success()
env:
DRY_RUN: true
run: |
echo "🔐 Anchoring updated Phoenix badge state..."
# Build a minimal manifest for the badge JSON
HASH=$(sha256sum .badges/phoenix_coherence.json | cut -d' ' -f1)
cat > .badges/phoenix_manifest.json <<JSON
{"root": ".badges/phoenix_coherence.json", "algorithm":"sha256", "merkleRoot": "${HASH}",
"files": [{"path": ".badges/phoenix_coherence.json", "hash": "${HASH}"}]}
JSON
{
printf '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"phoenix-anchor","version":"1.0.0"}}}\n'
printf '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"multi_anchor","arguments":{"manifestPath": ".badges/phoenix_manifest.json"}}}\n'
} | node server.js --stdio | tail -n 1