diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 2da5724b..ed4b6eaa 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -1,6 +1,10 @@ # Gitea Actions (same syntax as GitHub Actions). Runs on the self-hosted forge # runner; no external provider. The check job covers the SQL layer through the # PGlite harness (no Docker); the supabase job replays it on the real stack. +# +# Rust (plan R0, docs/development/RUST.md): every cargo command runs inside the +# reference builder image built from docker/rust-builder.Dockerfile, so CI and a +# developer machine use the same toolchain and the production VPS never needs Rust. name: ci on: @@ -9,8 +13,22 @@ on: pull_request: jobs: + rust: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Reference Rust builder image (runner needs a Docker daemon) + run: docker build -f docker/rust-builder.Dockerfile -t faunosteo_rust_builder:1.99.0 docker + - name: fmt, clippy, tests, ts-rs export, cargo-deny (licenses, bans, sources) + run: bash docker/rust-run.sh bash docker/rust-check.sh + - name: Committed TypeScript types match the Rust contracts + run: git diff --exit-code -- packages/core-wasm/types + - name: Browser module builds (size printed; the budget is asserted by the vitest proofs) + run: bash docker/rust-run.sh bash docker/wasm-build.sh + check: runs-on: ubuntu-latest + needs: rust steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 @@ -19,6 +37,8 @@ jobs: - name: Activate pnpm (version from package.json "packageManager") run: corepack enable && corepack prepare --activate - run: pnpm install --frozen-lockfile + - name: Browser module for the core-wasm proofs (same builder image as the rust job) + run: docker build -f docker/rust-builder.Dockerfile -t faunosteo_rust_builder:1.99.0 docker && bash docker/rust-run.sh bash docker/wasm-build.sh - run: pnpm typecheck - run: pnpm test:run - run: pnpm lint @@ -29,8 +49,14 @@ jobs: needs: check steps: - uses: actions/checkout@v4 - - name: Docker image builds (runner needs a Docker daemon) + - name: Application image builds (runner needs a Docker daemon) run: docker build -t faunosteo:ci . + - name: Worker sandbox tests and seccomp derivation on the musl binary that ships + run: docker build -f crates/worker/Dockerfile --target test -t faunosteo_worker:test . + - name: Worker runtime image builds and starts (configuration check, no job loop before R1) + run: | + docker build -f crates/worker/Dockerfile -t faunosteo_worker:ci . + docker run --rm --read-only --cap-drop ALL --security-opt no-new-privileges:true faunosteo_worker:ci run --check supabase: runs-on: ubuntu-latest diff --git a/.gitea/workflows/release-images.yml b/.gitea/workflows/release-images.yml new file mode 100644 index 00000000..64b9b8a2 --- /dev/null +++ b/.gitea/workflows/release-images.yml @@ -0,0 +1,38 @@ +# Production images, built in CI and identified by digest (D-R13, owner amendment of +# 2026-10-12): the VPS pulls them and never compiles. Manual only (workflow_dispatch), never +# on push: no publication or promotion of a production image without an explicit run and +# a validation. Nothing here deploys; DEPLOY.md "Image deploy (prepared)" is the runbook. +# +# Secrets expected on the forge: REGISTRY (host, e.g. the Gitea container registry of this +# forge), REGISTRY_USER, REGISTRY_TOKEN (write:package scope). Images are pushed as +# //faunosteo_app: and faunosteo_worker:; the digests are +# printed in the job summary and are what the VPS pins. +name: release-images + +on: + workflow_dispatch: + inputs: + sheet_bundle: + description: 'SHEET_BUNDLE for the app image (none = production default, draft = preview)' + required: false + default: 'none' + +jobs: + images: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Registry login + run: echo "${{ secrets.REGISTRY_TOKEN }}" | docker login "${{ secrets.REGISTRY }}" -u "${{ secrets.REGISTRY_USER }}" --password-stdin + - name: Build and push the application image + run: | + image="${{ secrets.REGISTRY }}/${{ github.repository_owner }}/faunosteo_app:${{ github.sha }}" + docker build --build-arg SHEET_BUNDLE="${{ github.event.inputs.sheet_bundle }}" -t "$image" . + docker push "$image" + echo "app: $(docker inspect --format='{{index .RepoDigests 0}}' "$image")" >> "$GITHUB_STEP_SUMMARY" + - name: Build and push the worker image + run: | + image="${{ secrets.REGISTRY }}/${{ github.repository_owner }}/faunosteo_worker:${{ github.sha }}" + docker build -f crates/worker/Dockerfile -t "$image" . + docker push "$image" + echo "worker: $(docker inspect --format='{{index .RepoDigests 0}}' "$image")" >> "$GITHUB_STEP_SUMMARY" diff --git a/.gitea/workflows/rust-advisories.yml b/.gitea/workflows/rust-advisories.yml new file mode 100644 index 00000000..52f24c2f --- /dev/null +++ b/.gitea/workflows/rust-advisories.yml @@ -0,0 +1,17 @@ +# RustSec advisories, out of the blocking path on purpose (RUST_ARCHITECTURE_REVIEW VIII.3): +# an advisory published for an unrelated crate must not redden every branch. The run is +# nightly and manual; the release gate (Step 27) reads its last result. +name: rust-advisories + +on: + schedule: + - cron: '17 3 * * *' + workflow_dispatch: + +jobs: + advisories: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - run: docker build -f docker/rust-builder.Dockerfile -t faunosteo_rust_builder:1.99.0 docker + - run: bash docker/rust-run.sh cargo deny check advisories diff --git a/docker/csp-proof/run.mjs b/docker/csp-proof/run.mjs new file mode 100644 index 00000000..5ff51936 --- /dev/null +++ b/docker/csp-proof/run.mjs @@ -0,0 +1,17 @@ +import { chromium } from 'playwright-core' +const exe = process.env.CHROME +const browser = await chromium.launch({ executablePath: exe, headless: true }) +for (const [name, port] of [['without wasm-unsafe-eval', 8091], ['with wasm-unsafe-eval', 8092]]) { + const page = await browser.newPage() + const logs = [] + page.on('console', (m) => logs.push(`${m.type()}: ${m.text()}`)) + page.on('pageerror', (e) => logs.push(`pageerror: ${e.message}`)) + const resp = await page.goto(`http://127.0.0.1:${port}/`) + const csp = resp.headers()['content-security-policy'] + await page.waitForFunction(() => document.title !== 'pending', null, { timeout: 10000 }).catch(() => {}) + const wasmResp = await page.request.get(`http://127.0.0.1:${port}/pkg/faunosteo_wasm_bg.wasm`) + console.log(`== ${name}: title="${await page.title()}" csp-has-wasm-unsafe-eval=${csp.includes('wasm-unsafe-eval')} wasm-content-type=${wasmResp.headers()['content-type']}`) + for (const l of logs) console.log(' ' + l.slice(0, 220)) + await page.close() +} +await browser.close() diff --git a/docker/csp-proof/run.sh b/docker/csp-proof/run.sh new file mode 100755 index 00000000..70e327b3 --- /dev/null +++ b/docker/csp-proof/run.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +# R0 proof (D-R13): the browser module instantiates under the production CSP only with +# 'wasm-unsafe-eval'. Serves packages/core-wasm/pkg through the production nginx image with +# the DEPLOY.md header (as is, then with the keyword) and loads the page in headless Chromium. +# +# pnpm wasm:build +# CHROME=/path/to/chrome bash docker/csp-proof/run.sh # needs playwright-core on NODE_PATH +# +# Recorded result (2026-10-12, Chrome for Testing 156, nginx:1.31-alpine): docs/development/RUST.md ยง5. +set -euo pipefail +cd "$(dirname "$0")/../.." +work="$(mktemp -d)" +mkdir -p "$work/site" +cp -r packages/core-wasm/pkg "$work/site/" +cp docker/csp-proof/site/index.html docker/csp-proof/site/main.js "$work/site/" +prod_csp="$(grep -m1 '^add_header Content-Security-Policy' DEPLOY.md | sed -E 's/^add_header Content-Security-Policy "(.*)" always;$/\1/')" +wasm_csp="${prod_csp/script-src \'self\'/script-src \'self\' \'wasm-unsafe-eval\'}" +for variant in without with; do + if [ "$variant" = without ]; then csp="$prod_csp"; else csp="$wasm_csp"; fi + sed "s/\${PORT}/8080/; s|^ # SPA fallback| add_header Content-Security-Policy \"$csp\" always;\n # SPA fallback|" docker/nginx.conf > "$work/csp-$variant.conf" +done +cleanup() { docker rm -f faunosteo_csp_without faunosteo_csp_with >/dev/null 2>&1 || true; } +trap cleanup EXIT +cleanup +docker run -d --rm --name faunosteo_csp_without -p 127.0.0.1:8091:8080 -v "$work/site:/usr/share/nginx/html:ro" -v "$work/csp-without.conf:/etc/nginx/conf.d/default.conf:ro" nginx:1.31-alpine >/dev/null +docker run -d --rm --name faunosteo_csp_with -p 127.0.0.1:8092:8080 -v "$work/site:/usr/share/nginx/html:ro" -v "$work/csp-with.conf:/etc/nginx/conf.d/default.conf:ro" nginx:1.31-alpine >/dev/null +sleep 1.5 +node docker/csp-proof/run.mjs diff --git a/docker/csp-proof/site/index.html b/docker/csp-proof/site/index.html new file mode 100644 index 00000000..07b75384 --- /dev/null +++ b/docker/csp-proof/site/index.html @@ -0,0 +1,2 @@ +pending + diff --git a/docker/csp-proof/site/main.js b/docker/csp-proof/site/main.js new file mode 100644 index 00000000..acd9e22b --- /dev/null +++ b/docker/csp-proof/site/main.js @@ -0,0 +1,2 @@ +import init, { core_version } from './pkg/faunosteo_wasm.js' +try { await init(); document.title = 'OK ' + core_version() } catch (e) { document.title = 'FAIL ' + (e && e.message) }