Files
Profa c0ba2b4d86 fix: rename scripts to .cjs/.mjs for ESM compatibility
package.json has "type": "module" so .js files are treated as ESM.
Scripts using require() renamed to .cjs, scripts using import to .mjs.
Fixes Test Dashboard CI failure.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 16:58:50 +00:00

124 lines
4.0 KiB
YAML

# Coherence-Gated Quality Engineering CI
# ADR-052: Mathematical verification of belief coherence
#
# This workflow verifies that all QE operations maintain mathematical coherence
# using Prime Radiant WASM engines (with JS fallback for CI environments).
name: Coherence Verification
on:
push:
branches: [main]
paths:
- 'src/**'
- 'tests/**'
- '.github/workflows/coherence.yml'
pull_request:
branches: [main]
paths:
- 'src/**'
- 'tests/**'
# Minimal permissions following principle of least privilege
permissions:
contents: read
actions: read
jobs:
coherence-check:
name: Coherence Verification
runs-on: ubuntu-latest
permissions:
contents: read
# Export outputs for dependent jobs
outputs:
is_coherent: ${{ steps.coherence.outputs.is_coherent }}
energy: ${{ steps.coherence.outputs.energy }}
used_fallback: ${{ steps.coherence.outputs.used_fallback }}
badge: ${{ steps.coherence.outputs.badge }}
badge_color: ${{ steps.coherence.outputs.badge_color }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build project
run: npm run build
- name: Run coherence check
id: coherence
run: |
node scripts/coherence-check.mjs > coherence-result.json 2>&1 || true
# Extract results
IS_COHERENT=$(jq -r '.isCoherent // false' coherence-result.json 2>/dev/null || echo "false")
ENERGY=$(jq -r '.energy // "N/A"' coherence-result.json 2>/dev/null || echo "N/A")
USED_FALLBACK=$(jq -r '.usedFallback // false' coherence-result.json 2>/dev/null || echo "true")
echo "is_coherent=$IS_COHERENT" >> $GITHUB_OUTPUT
echo "energy=$ENERGY" >> $GITHUB_OUTPUT
echo "used_fallback=$USED_FALLBACK" >> $GITHUB_OUTPUT
# Determine badge
if [ "$IS_COHERENT" = "true" ]; then
if [ "$USED_FALLBACK" = "true" ]; then
echo "badge=fallback" >> $GITHUB_OUTPUT
echo "badge_color=yellow" >> $GITHUB_OUTPUT
else
echo "badge=verified" >> $GITHUB_OUTPUT
echo "badge_color=brightgreen" >> $GITHUB_OUTPUT
fi
else
echo "badge=violation" >> $GITHUB_OUTPUT
echo "badge_color=red" >> $GITHUB_OUTPUT
fi
- name: Run coherence tests
run: npm run test:safe -- tests/integrations/coherence/ tests/learning/coherence-integration.test.ts --reporter=verbose
continue-on-error: true
coherence-status:
name: Coherence Status
runs-on: ubuntu-latest
needs: coherence-check
permissions:
contents: read
steps:
- name: Check coherence result
run: |
echo "Coherence Check Results:"
echo "========================"
echo "Is Coherent: ${{ needs.coherence-check.outputs.is_coherent }}"
echo "Energy: ${{ needs.coherence-check.outputs.energy }}"
echo "Used Fallback: ${{ needs.coherence-check.outputs.used_fallback }}"
echo "Badge: ${{ needs.coherence-check.outputs.badge }} (${{ needs.coherence-check.outputs.badge_color }})"
# Determine overall status
if [ "${{ needs.coherence-check.outputs.is_coherent }}" = "true" ]; then
echo ""
echo "Coherence verification PASSED"
exit 0
elif [ "${{ needs.coherence-check.outputs.used_fallback }}" = "true" ]; then
echo ""
echo "Coherence check used fallback mode (WASM unavailable)"
echo "This is acceptable for CI but full WASM verification is recommended"
exit 0
else
echo ""
echo "::error::Coherence verification FAILED"
exit 1
fi