Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d907d23a48 | ||
|
|
7a07fb0d2c | ||
|
|
166516cdb7 |
@@ -58,16 +58,6 @@ DEV_LOGIN_KEY=
|
||||
# Shared token for internal/service-to-service calls; sent as X-Internal-Token
|
||||
# on every engineFetch() call (lib/engine.ts).
|
||||
INTERNAL_TOKEN=change-me-internal-token
|
||||
# Tenant authority for the internal-token principal. Comma-separated allowlist
|
||||
# of tenants this deployment's engine is entitled to write for, e.g.
|
||||
# "379976258701823235". This is the ONLY source of tenant authority for
|
||||
# X-Internal-Token: a request header may never name a tenant. Empty/unset means
|
||||
# the service principal has no tenant authority and tenant-scoped writes
|
||||
# (canonical facts, quality bridge runs) are denied with 403. Exactly ONE
|
||||
# tenant is supported: the shared token identifies one service process, not a
|
||||
# set of principals. A multi-tenant list is refused (401) until a verified
|
||||
# workload-identity binding exists.
|
||||
INTERNAL_SERVICE_TENANTS=
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Zitadel / OIDC Bearer verification (Wave 2 hardening) -- wired in code today
|
||||
@@ -78,10 +68,6 @@ INTERNAL_SERVICE_TENANTS=
|
||||
#
|
||||
# Fleet Zitadel issuer (OIDC). Default when unset: https://id-customers.siax.io
|
||||
ZITADEL_ISSUER=https://id-customers.siax.io
|
||||
# Browser login (Authorization Code + PKCE). Create a Web application in the
|
||||
# Zitadel project with redirect URI https://0pt.app/api/auth/callback.
|
||||
ZITADEL_OIDC_CLIENT_ID=
|
||||
ZITADEL_OIDC_CLIENT_SECRET=
|
||||
# Enforcement is FAIL-CLOSED. Leave this UNSET (or set it to "true") and a
|
||||
# valid, verified Bearer token is REQUIRED on /api/0pt/* -- 401 on
|
||||
# missing/invalid, 403 when X-Tenant-Id disagrees with the token tenant.
|
||||
@@ -216,86 +202,3 @@ NOCODB_API_TOKEN=
|
||||
# Test-only (tests/p0 real-infra suite; not needed to run the app)
|
||||
# ---------------------------------------------------------------------------
|
||||
# ST0RE_TEST_TENANT_ID=
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Document workbench (upload -> DOC0 -> INF0 -> validated export -> credits)
|
||||
# Wired in code today: app/api/0pt/documents/*, app/api/0pt/credits/*.
|
||||
# Every value is optional to boot and mandatory to USE: a missing integration
|
||||
# makes its route answer 503 "not configured" instead of fabricating success.
|
||||
# ---------------------------------------------------------------------------
|
||||
# DOC0 document service. URL must be absolute HTTPS; token is a service PAT.
|
||||
DOC0_URL=https://doc0.siax.io
|
||||
DOC0_SERVICE_TOKEN=
|
||||
# The DOC0 service identity's own actor id (token subject). DOC0 rejects an
|
||||
# x-actor-id it has no actor_grant for; 0pt keeps the end-user actor in its own
|
||||
# journal and lets the DOC0 call act as the service.
|
||||
DOC0_SERVICE_ACTOR_ID=
|
||||
# Maximum accepted upload size (bytes). Default 25 MiB.
|
||||
OPT_MAX_UPLOAD_BYTES=26214400
|
||||
|
||||
# Interim AI path: self-hosted Ollama on the SIAX decision server
|
||||
# (server-decision-01). Internal only; no provider key and no per-token cost.
|
||||
# Plain HTTP is accepted only for loopback/RFC1918/tailnet hosts.
|
||||
DECISION_OLLAMA_URL=http://100.96.133.104:11434
|
||||
DECISION_OLLAMA_MODEL=hermes-qwen3.5:9b
|
||||
|
||||
# INF0 AI gateway (model calls). No provider key is ever placed in this repo.
|
||||
# Live path today: the LiteLLM gateway (OpenAI-compatible). The native
|
||||
# /v1/inf0/* surface is contract-only; INF0_URL is used as a fallback.
|
||||
INF0_GATEWAY_URL=https://ai-gateway.siax.io/v1
|
||||
INF0_GATEWAY_LITELLM_KEY=
|
||||
INF0_GATEWAY_PROVIDER_KIND=external
|
||||
INF0_URL=https://api.inf0.siax.io
|
||||
INF0_API_TOKEN=
|
||||
|
||||
# PAY0 (optional; Stripe is used directly for credit checkout today).
|
||||
PAY0_URL=https://pay0.siax.io
|
||||
PAY0_API_TOKEN=
|
||||
|
||||
# N0D / ST0RE (used by the broader pipeline; not required by the routes above).
|
||||
N0D_URL=https://api.n0d.siax.io
|
||||
N0D_API_TOKEN=
|
||||
ST0RE_URL=https://api.st0re.siax.io
|
||||
ST0RE_API_TOKEN=
|
||||
|
||||
# OpenFGA project authorization. Without all four values, document routes fail
|
||||
# closed with PROJECT_AUTHORIZATION_NOT_CONFIGURED.
|
||||
OPENFGA_API_URL=https://fga.siax.io
|
||||
OPENFGA_STORE_ID=
|
||||
OPENFGA_MODEL_ID=
|
||||
OPENFGA_AUTH_TOKEN=
|
||||
|
||||
# Transitional, server-owned project grants used only when OpenFGA is not
|
||||
# configured. JSON array; actorId "*" means every verified actor in the tenant.
|
||||
# OPT_PROJECT_GRANTS=[{"tenantId":"379976258701823235","projectId":"prj_demo","actorId":"*"}]
|
||||
OPT_PROJECT_GRANTS=
|
||||
|
||||
# Model policy for the document workbench. Without this, structuring answers
|
||||
# MODEL_POLICY_NOT_CONFIGURED.
|
||||
OPT_ALLOWED_MODELS=
|
||||
OPT_ALLOWED_DATA_CLASSES=none,low
|
||||
OPT_MODEL_DESTINATION=external
|
||||
OPT_EXTERNAL_TRANSFER_ALLOWED=false
|
||||
OPT_MODEL_MAX_INPUT_TOKENS=60000
|
||||
OPT_MODEL_MAX_OUTPUT_TOKENS=4000
|
||||
|
||||
# Server-owned, versioned credit price book (JSON, one line). No price is ever
|
||||
# read from a browser. Without it, credit packs/checkout/structuring answer
|
||||
# PRICE_BOOK_NOT_CONFIGURED.
|
||||
# {"version":"2026-11-01","currency":"SEK","packs":[{"id":"starter","credits":100,"amountMinor":9900}],"metering":{"pagesPerCredit":5,"inputTokensPerCredit":20000,"outputTokensPerCredit":4000}}
|
||||
OPT_CREDIT_PRICE_BOOK=
|
||||
|
||||
# Pilot switch. `off` runs document structuring without a wallet; it is
|
||||
# explicit (never a silent fallback), the response reports `credits: null`, and
|
||||
# purchases stay disabled. Unset/`on` requires the price book + ledger.
|
||||
OPT_CREDITS_MODE=
|
||||
|
||||
# One-time trial credits granted per tenant (server-owned, idempotent, NOT a
|
||||
# payment). 0 disables. With OPT_CREDITS_MODE=on this lets reserve/settle run
|
||||
# in production before any customer purchase.
|
||||
OPT_TRIAL_CREDITS=0
|
||||
|
||||
# Central Keycloak (SIAX Portal)
|
||||
KEYCLOAK_ISSUER=https://auth.portal.siax.dev/realms/portal
|
||||
KEYCLOAK_EXPECTED_AUDIENCE=account
|
||||
KEYCLOAK_AUTHORIZED_PARTY=siax-portal
|
||||
|
||||
+7
-7
@@ -1,11 +1,11 @@
|
||||
# CI-14 — CODEOWNERS bor i .gitea/, aldrig i .github/ (SEC-25).
|
||||
# Granskning krävs särskilt för kontrakt, deploy och migrationer.
|
||||
|
||||
* @admin
|
||||
/contracts/ @admin
|
||||
/deploy/ @admin
|
||||
/.gitea/ @admin
|
||||
/siax.repo.json @admin
|
||||
/siax.config.json @admin
|
||||
* @sax3l
|
||||
/contracts/ @sax3l
|
||||
/deploy/ @sax3l
|
||||
/.gitea/ @sax3l
|
||||
/siax.repo.json @sax3l
|
||||
/siax.config.json @sax3l
|
||||
# TODO: lägg till migrationskatalogen när den finns, t.ex.
|
||||
# /packages/db/migrations/ @admin
|
||||
# /packages/db/migrations/ @sax3l
|
||||
|
||||
+9
-20
@@ -6,32 +6,21 @@ name: Deploy to Coolify
|
||||
# Dockerfile (build_pack: dockerfile) -- this workflow only fires the
|
||||
# rebuild+redeploy, it doesn't build or push an image itself.
|
||||
#
|
||||
# STATUS (verified 2026-11-02): LIVE. The Coolify application exists
|
||||
# (dockerfile build pack, git.siax.io/sax3l/0pt, branch main) and its UUID is
|
||||
# supplied by the repository variable COOLIFY_APP_ID; COOLIFY_TOKEN and the
|
||||
# registry/cosign secrets are set. A push to main, or a manual
|
||||
# workflow_dispatch of this file, has been proven to verify the signed
|
||||
# attestation for the exact commit and then return HTTP 200 from Coolify.
|
||||
# The placeholder guard below remains as a fail-closed guard, not as a TODO.
|
||||
# Operational procedure and verification live in docs/runbook/deploy.md.
|
||||
# STATUS (2026-08-09): no Coolify application has been provisioned for 0pt
|
||||
# yet -- siax.config.json's `deploy.target` was flipped from "vercel" to
|
||||
# "coolify" to state the intended platform, but there is no app UUID to
|
||||
# point at. COOLIFY_APP_ID below is a literal placeholder. The guard step
|
||||
# fails the job loudly (rather than silently POSTing to a bogus/empty URL)
|
||||
# until both the Coolify app exists and its real UUID replaces the
|
||||
# placeholder here. See docs/architecture/ARCHITECTURE.md §5/§8 for the
|
||||
# open "Vercel or fleet" question this resolves the config side of.
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
workflow_dispatch:
|
||||
|
||||
# Never let two deploys race the same Coolify app. Unlike CI we do NOT cancel an
|
||||
# in-flight deploy (it may already be restarting the container); the newest
|
||||
# commit still wins because Coolify builds from the branch head.
|
||||
# N6 (server-config ci/jobbstorm-2026-11-10 §4): deploy/release köas i en fast grupp och avbryts aldrig.
|
||||
# ci-concurrency-exempt: deploy till Coolify på push till main; avbrott mitt i lämnar appen halvt utrullad (N6 §4).
|
||||
concurrency:
|
||||
group: ${{ gitea.workflow }}
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 20
|
||||
env:
|
||||
COOLIFY_APP_ID: ${{ vars.COOLIFY_APP_ID || 'TODO-no-coolify-app-provisioned-yet' }}
|
||||
IMAGE_REPO: git.cloud.siax.io/sax3l/0pt
|
||||
@@ -95,7 +84,7 @@ jobs:
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
|
||||
+9
-119
@@ -17,28 +17,18 @@ name: CI (SIAX Cloud)
|
||||
# push/PR/weekly scanner (this file is push/PR-only).
|
||||
on:
|
||||
push:
|
||||
branches: ["main"]
|
||||
branches: ["**"]
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
|
||||
# One run per ref; a branch push that also updates a PR used to start two full
|
||||
# quality runs (and, on main, two deploy chains). Cancel the superseded one.
|
||||
# N6 (server-config ci/jobbstorm-2026-11-10 §4): en ny commit på samma PR/gren avbryter den inaktuella körningen.
|
||||
concurrency:
|
||||
group: ${{ gitea.workflow }}-${{ gitea.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
quality:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
|
||||
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: "22"
|
||||
cache: "pnpm"
|
||||
cache-dependency-path: pnpm-lock.yaml
|
||||
- name: Enable corepack + pin pnpm@9 (pnpm-lock.yaml is lockfileVersion 9.0)
|
||||
run: |
|
||||
corepack enable
|
||||
@@ -47,13 +37,6 @@ jobs:
|
||||
run: pnpm install --frozen-lockfile
|
||||
- name: Typecheck (tsc over src/ + tests/ -- blocking)
|
||||
run: pnpm run typecheck
|
||||
# UI-09: 0pt carried 82 axe color-contrast violations (impact=serious), the
|
||||
# estate's largest single a11y defect, and every one came from a Tailwind
|
||||
# alpha modifier on a text colour. The unmodified token measures 4.73:1
|
||||
# light / 7.63:1 dark and passes AA; every faded variant fails. Blocking,
|
||||
# because a contrast regression is invisible in review.
|
||||
- name: Text contrast shape (WCAG 2.2 AA 1.4.3 -- blocking)
|
||||
run: pnpm run check:contrast
|
||||
- name: Test (vitest -- blocking)
|
||||
run: pnpm run test
|
||||
- name: Lint (eslint -- advisory; legacy tree has pre-existing noise)
|
||||
@@ -86,7 +69,6 @@ jobs:
|
||||
# ordinary branch pushes still run blocking quality/security.
|
||||
if: github.event_name == 'pull_request' || github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch'
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 45
|
||||
services:
|
||||
opt-ci-opensearch:
|
||||
image: opensearchproject/opensearch:2.11.1
|
||||
@@ -98,9 +80,6 @@ jobs:
|
||||
# cluster_name (the OpenSearch image maps dotted env keys to
|
||||
# settings).
|
||||
cluster.name: opt_ci_${{ github.run_id }}_${{ github.run_attempt }}
|
||||
# Throwaway CI cluster: never let the runner's disk fill turn indices
|
||||
# read-only (the 403 index_create_block_exception seen in run 388536).
|
||||
cluster.routing.allocation.disk.threshold_enabled: "false"
|
||||
# `--workdir` is REQUIRED (measured 2026-08-31, PR #25 CI run 7745,
|
||||
# job "integration"): this runner's act_runner (v0.6.1) merges the
|
||||
# JOB's WorkingDir (`/workspace/sax3l/0pt`) into every SERVICE
|
||||
@@ -134,12 +113,10 @@ jobs:
|
||||
--health-timeout 5s
|
||||
--health-retries 60
|
||||
steps:
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
|
||||
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: "22"
|
||||
cache: "pnpm"
|
||||
cache-dependency-path: pnpm-lock.yaml
|
||||
- name: Enable corepack + pin pnpm@9
|
||||
run: |
|
||||
corepack enable
|
||||
@@ -157,33 +134,6 @@ jobs:
|
||||
if [ "$NAME" = "$WANT" ]; then FOUND="$ip"; fi
|
||||
done
|
||||
[ -n "$FOUND" ] || { echo "FATAL: no OpenSearch behind the alias identifies as $WANT"; exit 1; }
|
||||
|
||||
# The single-node test cluster inherits the runner's disk watermark.
|
||||
# On a busy runner the flood-stage watermark makes every new index
|
||||
# read-only and the suite fails with HTTP 403
|
||||
# index_create_block_exception (measured on run 388536). The container
|
||||
# is throwaway CI state, so disable the disk threshold and PROVE that
|
||||
# index creation works before the blocking tests run.
|
||||
for attempt in 1 2 3 4 5; do
|
||||
# Disabling the watermark alone does NOT clear a cluster that is
|
||||
# already read-only: the flood stage sets
|
||||
# cluster.blocks.read_only_allow_delete and every write keeps
|
||||
# returning 403. Clear that block explicitly every attempt.
|
||||
curl -sS --max-time 10 -X PUT "http://$FOUND:9200/_cluster/settings" \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{"persistent":{"cluster.routing.allocation.disk.threshold_enabled":false,"cluster.blocks.read_only_allow_delete":null}}' >/tmp/os-settings.json || true
|
||||
cat /tmp/os-settings.json 2>/dev/null || true
|
||||
probe_status=$(curl -sS --max-time 10 -o /tmp/os-probe.json -w '%{http_code}' -X PUT "http://$FOUND:9200/opt-ci-probe-${{ github.run_id }}")
|
||||
if [ "$probe_status" = "200" ]; then
|
||||
curl -fsS --max-time 10 -X DELETE "http://$FOUND:9200/opt-ci-probe-${{ github.run_id }}" >/dev/null || true
|
||||
echo "OpenSearch accepts index creation"
|
||||
break
|
||||
fi
|
||||
echo "index creation not ready (attempt $attempt/5, HTTP $probe_status) — waiting"
|
||||
cat /tmp/os-probe.json 2>/dev/null || true
|
||||
[ "$attempt" = "5" ] && { echo "FATAL: OpenSearch still refuses index creation"; exit 1; }
|
||||
sleep 10
|
||||
done
|
||||
echo "OPENSEARCH_URL=http://$FOUND:9200" >> "$GITHUB_ENV"
|
||||
- name: Select THIS run's ClickHouse by identity
|
||||
run: |
|
||||
@@ -269,71 +219,11 @@ jobs:
|
||||
# measurable blind spot into declared policy.
|
||||
security:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 15
|
||||
steps:
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
|
||||
- name: Install Trivy (pinned + checksum verified)
|
||||
- uses: actions/checkout@v4
|
||||
- name: Install Trivy
|
||||
run: |
|
||||
set -euo pipefail
|
||||
TRIVY_VERSION=0.76.2
|
||||
BASE="https://github.com/aquasecurity/trivy/releases/download/v${TRIVY_VERSION}"
|
||||
curl -fsSLO "${BASE}/trivy_${TRIVY_VERSION}_Linux-64bit.tar.gz"
|
||||
curl -fsSLO "${BASE}/trivy_${TRIVY_VERSION}_checksums.txt"
|
||||
grep " trivy_${TRIVY_VERSION}_Linux-64bit.tar.gz$" "trivy_${TRIVY_VERSION}_checksums.txt" | sha256sum -c -
|
||||
tar -xzf "trivy_${TRIVY_VERSION}_Linux-64bit.tar.gz" -C /usr/local/bin trivy
|
||||
rm -f "trivy_${TRIVY_VERSION}_Linux-64bit.tar.gz" "trivy_${TRIVY_VERSION}_checksums.txt"
|
||||
trivy --version
|
||||
# `siax/sbom/` är CycloneDX-evidenens för REDAN BYGGDA images (release-kedjan),
|
||||
# inte källberoenden. Att scanna dem här återrapporterar gamla image-versioner
|
||||
# (next 16.3.x, sharp 0.35.4) och blockerar källfixar som redan är patchade.
|
||||
# Image-SBOM:erna verifieras i release/image-pipelinen.
|
||||
curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh -s -- -b /usr/local/bin
|
||||
- name: Trivy scan (vuln + secrets -- BLOCKING, fails on HIGH/CRITICAL)
|
||||
run: |
|
||||
trivy fs --scanners vuln,secret --severity HIGH,CRITICAL --exit-code 1 --skip-dirs 'siax/sbom' .
|
||||
|
||||
sonar:
|
||||
# SonarQube Community Build har inget separat PR-analysläge (en enda "main"-gren
|
||||
# per projekt) — en analys från en PR-branch eller en tagg-push som inte pekar på
|
||||
# main skulle skriva över kvalitetshistoriken. Kör därför bara
|
||||
# vid push till main.
|
||||
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 20
|
||||
steps:
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: SonarQube analysis (self-hosted sonar.siax.dev)
|
||||
env:
|
||||
SONAR_HOST_URL: https://sonar.siax.dev
|
||||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
test -n "$SONAR_TOKEN" || { echo "::error::SONAR_TOKEN repo secret missing"; exit 1; }
|
||||
# Jobbet kör i en container på act_runner; "docker run -v \"\$PWD:...\""
|
||||
# skulle montera VÄRDENS (tomma) sökväg. Kopiera in källträdet istället.
|
||||
cid=$(docker create -e SONAR_HOST_URL -e SONAR_TOKEN -w /usr/src \
|
||||
sonarsource/sonar-scanner-cli:latest \
|
||||
sonar-scanner -Dsonar.projectKey=0pt -Dsonar.host.url="$SONAR_HOST_URL")
|
||||
trap 'docker rm -f "$cid" >/dev/null 2>&1 || true' EXIT
|
||||
docker cp . "$cid":/usr/src
|
||||
docker start -a "$cid"
|
||||
|
||||
design-conformance:
|
||||
name: Component conformance (blocking)
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
|
||||
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
|
||||
with:
|
||||
node-version: '22'
|
||||
- name: Checkout canonical siax-standard (SSOT)
|
||||
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
|
||||
with:
|
||||
repository: admin/siax-standard
|
||||
token: ${{ secrets.SIAX_CI_TOKEN }}
|
||||
path: siax-standard-ssot
|
||||
- name: Component conformance (blocking)
|
||||
run: |
|
||||
node --input-type=module -e "import('./siax-standard-ssot/packages/doctor/src/commands/component-conformance.mjs').then(m=>{process.exit(m.run(['--repo', process.env.GITHUB_WORKSPACE, '--allow-path-prefix', 'siax-standard-ssot/', '--fail-on=block']))})"
|
||||
trivy fs --scanners vuln,secret --severity HIGH,CRITICAL --exit-code 1 .
|
||||
|
||||
@@ -3,30 +3,16 @@ on:
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
- cron: "0 6 * * 1"
|
||||
|
||||
# N6 (server-config ci/jobbstorm-2026-11-10 §4): schemalagd/manuell körning köas i en fast grupp, avbryts inte.
|
||||
concurrency:
|
||||
group: ${{ gitea.workflow }}
|
||||
cancel-in-progress: true
|
||||
jobs:
|
||||
health:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
|
||||
- uses: actions/checkout@v4
|
||||
- name: Required files
|
||||
run: |
|
||||
for f in README.md LICENSE .gitignore; do [ -f "$f" ] || echo "::warning file=$f,title=Missing::$f is missing"; done
|
||||
[ -f .gitea/workflows/ci.yml ] || echo "::warning title=No CI::No CI workflow found"
|
||||
- name: Install Trivy (pinned + checksum verified)
|
||||
run: |
|
||||
set -euo pipefail
|
||||
TRIVY_VERSION=0.76.2
|
||||
BASE="https://github.com/aquasecurity/trivy/releases/download/v${TRIVY_VERSION}"
|
||||
curl -fsSLO "${BASE}/trivy_${TRIVY_VERSION}_Linux-64bit.tar.gz"
|
||||
curl -fsSLO "${BASE}/trivy_${TRIVY_VERSION}_checksums.txt"
|
||||
grep " trivy_${TRIVY_VERSION}_Linux-64bit.tar.gz$" "trivy_${TRIVY_VERSION}_checksums.txt" | sha256sum -c -
|
||||
tar -xzf "trivy_${TRIVY_VERSION}_Linux-64bit.tar.gz" -C /usr/local/bin trivy
|
||||
rm -f "trivy_${TRIVY_VERSION}_Linux-64bit.tar.gz" "trivy_${TRIVY_VERSION}_checksums.txt"
|
||||
trivy --version
|
||||
- name: Install Trivy
|
||||
run: curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh -s -- -b /usr/local/bin
|
||||
- name: Secret scan
|
||||
run: trivy fs --scanners secret --exit-code 0 .
|
||||
@@ -8,19 +8,14 @@ name: masterplan-lock
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
branches: ["**"]
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: ${{ gitea.workflow }}-${{ gitea.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
check:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
|
||||
- uses: actions/checkout@v4
|
||||
- name: Masterplan lock check
|
||||
run: sh scripts/check-masterplan-lock.sh
|
||||
@@ -8,21 +8,14 @@ on:
|
||||
schedule:
|
||||
- cron: "0 4 * * *" # daily 04:00 UTC
|
||||
|
||||
# N6 (server-config ci/jobbstorm-2026-11-10 §4): schemalagd/manuell körning köas i en fast grupp, avbryts inte.
|
||||
concurrency:
|
||||
group: ${{ gitea.workflow }}
|
||||
cancel-in-progress: true
|
||||
jobs:
|
||||
quality:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 45
|
||||
steps:
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
|
||||
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: "22"
|
||||
cache: "pnpm"
|
||||
cache-dependency-path: pnpm-lock.yaml
|
||||
- name: Enable corepack + pin pnpm@9
|
||||
run: |
|
||||
corepack enable
|
||||
@@ -41,24 +34,15 @@ jobs:
|
||||
|
||||
security:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 20
|
||||
steps:
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
|
||||
- name: Install Trivy (pinned + checksum verified)
|
||||
- uses: actions/checkout@v4
|
||||
- name: Install Trivy
|
||||
run: |
|
||||
set -euo pipefail
|
||||
TRIVY_VERSION=0.76.2
|
||||
BASE="https://github.com/aquasecurity/trivy/releases/download/v${TRIVY_VERSION}"
|
||||
curl -fsSLO "${BASE}/trivy_${TRIVY_VERSION}_Linux-64bit.tar.gz"
|
||||
curl -fsSLO "${BASE}/trivy_${TRIVY_VERSION}_checksums.txt"
|
||||
grep " trivy_${TRIVY_VERSION}_Linux-64bit.tar.gz$" "trivy_${TRIVY_VERSION}_checksums.txt" | sha256sum -c -
|
||||
tar -xzf "trivy_${TRIVY_VERSION}_Linux-64bit.tar.gz" -C /usr/local/bin trivy
|
||||
rm -f "trivy_${TRIVY_VERSION}_Linux-64bit.tar.gz" "trivy_${TRIVY_VERSION}_checksums.txt"
|
||||
trivy --version
|
||||
curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh -s -- -b /usr/local/bin
|
||||
# A nightly scan exists to catch CVEs published against code that did
|
||||
# not change. With `--exit-code 0` it could never report failure, so it
|
||||
# could never raise that alarm -- the one job whose entire purpose is
|
||||
# detection was the one guaranteed to stay green. Fixed 2026-09-08.
|
||||
- name: Trivy fs scan (vuln + secrets -- fails on HIGH/CRITICAL)
|
||||
run: |
|
||||
trivy fs --scanners vuln,secret --severity HIGH,CRITICAL --exit-code 1 --skip-dirs 'siax/sbom' .
|
||||
trivy fs --scanners vuln,secret --severity HIGH,CRITICAL --exit-code 1 .
|
||||
|
||||
@@ -1,80 +0,0 @@
|
||||
name: Production smoke (0pt.app)
|
||||
|
||||
# Automated end-to-end delivery verification. Every 30 minutes (and on demand)
|
||||
# this checks that the live service is actually ready and that the running
|
||||
# container is the commit that main points at — so a green deploy is never
|
||||
# confused with a healthy, current service.
|
||||
on:
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
- cron: "*/30 * * * *"
|
||||
|
||||
# N6 (server-config ci/jobbstorm-2026-11-10 §4): schemalagd/manuell körning köas i en fast grupp, avbryts inte.
|
||||
concurrency:
|
||||
group: ${{ gitea.workflow }}
|
||||
cancel-in-progress: true
|
||||
jobs:
|
||||
smoke:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- name: Readiness (retry on a fresh deploy)
|
||||
run: |
|
||||
set -eu
|
||||
for attempt in 1 2 3 4 5 6; do
|
||||
body="$(curl -fsS --max-time 15 https://0pt.app/api/ready || true)"
|
||||
echo "attempt $attempt: ${body:-<no response>}"
|
||||
if printf '%s' "$body" | grep -q '"ready":true'; then
|
||||
exit 0
|
||||
fi
|
||||
sleep 20
|
||||
done
|
||||
echo "::error::0pt.app/api/ready never reported ready:true"
|
||||
exit 1
|
||||
|
||||
- name: Health envelope
|
||||
run: |
|
||||
set -eu
|
||||
body="$(curl -fsS --max-time 15 https://0pt.app/api/health)"
|
||||
echo "$body"
|
||||
printf '%s' "$body" | grep -q '"db":"ok"' || { echo "::error::database is not ok"; exit 1; }
|
||||
printf '%s' "$body" | grep -q '"stripe":"ok"' || { echo "::error::stripe is not ok"; exit 1; }
|
||||
|
||||
- name: Deployed commit equals main
|
||||
env:
|
||||
SIAX_CI_TOKEN: ${{ secrets.SIAX_CI_TOKEN }}
|
||||
run: |
|
||||
set -eu
|
||||
version="$(curl -fsS --max-time 15 https://0pt.app/api/version)"
|
||||
echo "$version"
|
||||
running="$(printf '%s' "$version" | sed -n 's/.*"commit":"\([0-9a-f]*\)".*/\1/p')"
|
||||
[ -n "$running" ] || { echo "::error::/api/version returned no commit"; exit 1; }
|
||||
if [ -z "${SIAX_CI_TOKEN:-}" ]; then
|
||||
echo "::warning::SIAX_CI_TOKEN is not set — cannot compare with main; commit $running is live"
|
||||
exit 0
|
||||
fi
|
||||
# Ladda ner först och parsea sedan: curl | tolk leder till Semgrep
|
||||
# gha-curl-pipe-shell och gör det omöjligt att verifiera svaret.
|
||||
curl -fsS --max-time 15 \
|
||||
-H "Authorization: token ${SIAX_CI_TOKEN}" \
|
||||
-o "${RUNNER_TEMP}/0pt-main.json" \
|
||||
"https://git.siax.io/api/v1/repos/admin/0pt/commits?limit=1"
|
||||
expected="$(python3 -c 'import json,sys; print(json.load(open(sys.argv[1]))[0]["sha"])' "${RUNNER_TEMP}/0pt-main.json")"
|
||||
echo "running=$running expected(main)=$expected"
|
||||
[ -n "$expected" ] || { echo "::error::could not read main SHA from Gitea"; exit 1; }
|
||||
[ "$running" = "$expected" ] || {
|
||||
echo "::error::production is $running but main is $expected — deploy did not land"
|
||||
exit 1
|
||||
}
|
||||
|
||||
- name: Document pipeline surface responds (auth required, never 404/5xx)
|
||||
run: |
|
||||
set -eu
|
||||
for path in /api/0pt/documents/upload /api/0pt/documents/structure /api/0pt/documents/models /api/0pt/credits/balance; do
|
||||
code="$(curl -s -o /dev/null -w '%{http_code}' --max-time 15 -X POST "https://0pt.app${path}")"
|
||||
echo "$path -> $code"
|
||||
case "$code" in
|
||||
401|405) ;; # unauthenticated or method guard: the route exists
|
||||
*) echo "::error::$path returned $code (expected 401/405)"; exit 1 ;;
|
||||
esac
|
||||
done
|
||||
@@ -29,8 +29,8 @@ name: Release chain (G17, ADR-W16-003)
|
||||
# workflow file -- learned the hard way on sax3l/h0st's and sax3l/aud0's
|
||||
# own G17 migrations. 0pt does not wire a G20 post-deploy step in this
|
||||
# pass at all (see `.siax/hooks/README.md` "G20 -- deliberately not wired
|
||||
# yet": the app is now provisioned and `/api/version` exists, but G20 is still
|
||||
# not wired in this pass), so the single-job constraint that forces G20 into its own
|
||||
# yet": no Coolify application provisioned for 0pt, no `/version`
|
||||
# endpoint), so the single-job constraint that forces G20 into its own
|
||||
# workflow file elsewhere does not yet bite here -- documented anyway so a
|
||||
# future PR adding G20 does not repeat the mistake.
|
||||
|
||||
@@ -39,13 +39,6 @@ on:
|
||||
branches: [main]
|
||||
workflow_dispatch:
|
||||
|
||||
|
||||
# N6 (server-config ci/jobbstorm-2026-11-10 §4): deploy/release köas i en fast grupp och avbryts aldrig.
|
||||
# ci-concurrency-exempt: releasekedja build→push→SBOM→attestation→signering→evidens; avbrott mellan push och evidens lämnar registry och AUD0 i halvt läge (N6 §4).
|
||||
concurrency:
|
||||
group: ${{ gitea.workflow }}
|
||||
cancel-in-progress: false
|
||||
|
||||
env:
|
||||
IMAGE_REPO: git.cloud.siax.io/sax3l/0pt
|
||||
DOCKERFILE: Dockerfile
|
||||
@@ -57,75 +50,41 @@ env:
|
||||
# G17_LICENSE_ALLOW policy in .siax/hooks/G17.sh) and #59 (G20 retry
|
||||
# logic -- not used by 0pt yet, but the pin picks up main's current tip
|
||||
# rather than an older commit, matching what a fresh migration reviews).
|
||||
#
|
||||
# Re-pin 2026-09-25 (medveten, granskad): 9a3a0aa -> 09504e3a. Deltaet ar
|
||||
# EN merge, siax-templates #138 "Upload complete release evidence and
|
||||
# validate artifact receipt". Enda berorda filer under ci/v2 ar
|
||||
# reference-hooks/{G17.sh, G17-ADR-W16-003.md, lib/emit-release-evidence.py,
|
||||
# lib/test_emit_release_evidence.py}. Andringen ar bakatkompatibel by
|
||||
# design: ST0RE-uppladdningen ar OPT-IN via G17_REQUIRE_ST0RE (default 0),
|
||||
# sa en AUD0-only-konsument som 0pt kor exakt samma vag som forut.
|
||||
#
|
||||
# Deliberately NO branch name here: the pinned commit is checked out
|
||||
# DIRECTLY (see the step below). The previous shape -- clone `main`, then
|
||||
# require its HEAD to equal this pin -- turned every unrelated merge in
|
||||
# siax-templates into a red release chain here (CD-03 / CI-RED-02) while
|
||||
# nothing was actually unsafe. Checking the pin out directly keeps the pin
|
||||
# a real supply-chain control (the gate runs exactly this reviewed commit,
|
||||
# or it fails) without coupling it to someone else's branch tip.
|
||||
SIAX_TEMPLATES_PINNED_SHA: 09504e3a593ee8ce0eaba606df31c349a3d52277
|
||||
SIAX_TEMPLATES_REF: main
|
||||
SIAX_TEMPLATES_PINNED_SHA: 9a3a0aa93c28a4538ecdb98658158f19cb23a6f9
|
||||
SIAX_TEMPLATES_DIR: /tmp/siax-templates-g17-ref
|
||||
|
||||
jobs:
|
||||
release:
|
||||
name: Build, push, G17 (SBOM/scan/attest/verify/evidence)
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 45
|
||||
steps:
|
||||
- uses: https://git.siax.io/actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4, mirrored + SHA-pinned (SUP-06, same pin n0d/cl0ud/st0re/h0st already use)
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
# --- fetch the shared G17 reference implementation -----------------
|
||||
# Same authenticated-fetch-at-runtime mechanism this repo's OLD
|
||||
# Same authenticated-clone-at-runtime mechanism this repo's OLD
|
||||
# release.yml already used SIAX_CI_TOKEN for (the evidence-commit
|
||||
# push a prior PR deleted) -- see .siax/hooks/G17.sh's header for why
|
||||
# push this PR deletes) -- see .siax/hooks/G17.sh's header for why
|
||||
# NOT a `uses:` reusable workflow / submodule / vendored copy. Fails
|
||||
# closed if the exact commit this adapter was reviewed against cannot
|
||||
# be checked out (removed or rewritten upstream); an unrelated merge
|
||||
# on siax-templates' own main is NOT a failure and never was a real
|
||||
# signal.
|
||||
- name: Fetch siax-templates G17 reference (pinned commit)
|
||||
# closed if the branch has moved past the exact commit this adapter
|
||||
# was reviewed against.
|
||||
- name: Fetch siax-templates G17 reference (pinned)
|
||||
env:
|
||||
SIAX_CI_TOKEN: ${{ secrets.SIAX_CI_TOKEN }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
rm -rf "$SIAX_TEMPLATES_DIR"
|
||||
mkdir -p "$SIAX_TEMPLATES_DIR"
|
||||
git -C "$SIAX_TEMPLATES_DIR" init --quiet
|
||||
git -C "$SIAX_TEMPLATES_DIR" remote add origin \
|
||||
"https://oauth2:${SIAX_CI_TOKEN}@git.siax.io/${SIAX_TEMPLATES_REPO}.git"
|
||||
# Ask for the pinned commit by SHA -- one shallow commit, no branch
|
||||
# involved. A server with uploadpack.allowReachableSHA1InWant off
|
||||
# refuses that, so fall back to fetching the branches and taking the
|
||||
# same commit out of them. Either way the work tree ends up at
|
||||
# exactly $SIAX_TEMPLATES_PINNED_SHA, never at a branch tip.
|
||||
if ! git -C "$SIAX_TEMPLATES_DIR" fetch --quiet --depth 1 origin "$SIAX_TEMPLATES_PINNED_SHA"; then
|
||||
echo "note: server refused a by-SHA fetch; falling back to fetching all branches"
|
||||
git -C "$SIAX_TEMPLATES_DIR" fetch --quiet origin
|
||||
fi
|
||||
if ! git -C "$SIAX_TEMPLATES_DIR" -c advice.detachedHead=false \
|
||||
checkout --quiet --detach "$SIAX_TEMPLATES_PINNED_SHA"; then
|
||||
echo "::error::siax-templates commit $SIAX_TEMPLATES_PINNED_SHA not found in $SIAX_TEMPLATES_REPO -- the reviewed commit was removed or rewritten upstream. Re-review siax-templates and update SIAX_TEMPLATES_PINNED_SHA deliberately."
|
||||
exit 1
|
||||
fi
|
||||
git clone --quiet --branch "$SIAX_TEMPLATES_REF" \
|
||||
"https://oauth2:${SIAX_CI_TOKEN}@git.siax.io/${SIAX_TEMPLATES_REPO}.git" "$SIAX_TEMPLATES_DIR"
|
||||
actual_sha="$(git -C "$SIAX_TEMPLATES_DIR" rev-parse HEAD)"
|
||||
if [ "$actual_sha" != "$SIAX_TEMPLATES_PINNED_SHA" ]; then
|
||||
echo "::error::checked-out siax-templates HEAD is $actual_sha, expected the pinned $SIAX_TEMPLATES_PINNED_SHA -- refusing to run an unreviewed version of the gate."
|
||||
echo "::error::siax-templates $SIAX_TEMPLATES_REF moved (now $actual_sha, pinned $SIAX_TEMPLATES_PINNED_SHA) -- refusing to run an unreviewed version of the gate. Re-review and update SIAX_TEMPLATES_PINNED_SHA deliberately."
|
||||
exit 1
|
||||
fi
|
||||
chmod +x "$SIAX_TEMPLATES_DIR/ci/v2/reference-hooks/"*.sh "$SIAX_TEMPLATES_DIR/ci/v2/reference-hooks/lib/"*.sh
|
||||
echo "siax-templates G17 reference @ $actual_sha (pinned commit, checked out directly)"
|
||||
echo "siax-templates G17 reference @ $actual_sha (pinned, verified)"
|
||||
|
||||
- name: Resolve SHA + tag (never :latest)
|
||||
id: sha
|
||||
@@ -183,4 +142,3 @@ jobs:
|
||||
# submission (bar item 7, step above) is already the durable evidence
|
||||
# record; a convenience local copy is not worth re-triggering that
|
||||
# known breakage.
|
||||
|
||||
|
||||
+28
-205
@@ -1,215 +1,38 @@
|
||||
name: security
|
||||
# CI-10 — gitleaks, Semgrep, OSV-Scanner, Trivy. Körs på PR, på push mot main
|
||||
# och nattligt. Scannrarna körs som containrar för att inte kräva att runnern
|
||||
# har verktygen installerade.
|
||||
name: Security Scan (SIAX Cloud)
|
||||
|
||||
# Security scanning on every push/PR + weekly re-run.
|
||||
#
|
||||
# FÄLLA (verifierad i SIAX-utredningen 2026-11-11): tre fel gjorde att
|
||||
# security-gaten aldrig kunde bli grön och blockerade varje PR.
|
||||
# 1. `-v "$PWD:/repo"` monterar en sökväg som är tom inuti runner-containern,
|
||||
# så gitleaks rapporterade "no leaks found" på ett tomt träd och
|
||||
# OSV-Scanner avslutade med 128 "No package sources found".
|
||||
# 2. `--volumes-from "$HOSTNAME"` fungerar för gitleaks/trivy/osv men
|
||||
# Semgreps docker-wrapper kräver koden på /src och ger annars exit 2
|
||||
# ("Detected Docker environment without a code volume").
|
||||
# 3. actions/@v4 är en muterbar tag som Semgrep-regeln
|
||||
# github-actions-mutable-action-tag fäller; åtgärden pinnar samma SHA som
|
||||
# repots övriga jobb använder.
|
||||
# Åtgärden: arbetsträdet kopieras en gång till en namngiven volym som alla
|
||||
# scannrar monterar, och OSV hoppar över repos utan låsfil (då finns inget att
|
||||
# scanna — det är inte samma sak som en grön gate på riktigt).
|
||||
# This job runs the same Trivy invocation as ci.yml's `security` job and
|
||||
# previously carried the same defect: `--exit-code 0` meant it could report
|
||||
# success while holding a CRITICAL finding (measured 2026-09-08 with a
|
||||
# planted AWS secret key -- detected, still exit 0). Its context
|
||||
# "Security Scan (SIAX Cloud) / security" is NOT in branch protection's
|
||||
# required list, so this one never gated a merge either way; it is fixed
|
||||
# here so a green tick on this workflow means what a reader assumes it
|
||||
# means. See ci.yml's `security` job for the measurement and for the
|
||||
# services/scrapers unpinned-requirements coverage gap.
|
||||
#
|
||||
# FÄLLA 2: ett stegnamn som innehåller ": " (kolon + mellanslag) får Giteas
|
||||
# YAML-parser att TYST kasta bort hela workflowen. Håll stegnamn i ren ASCII
|
||||
# utan kolon-mellanslag.
|
||||
# NOTE: findings on services/scrapers/* (FlareSolverr/Tor/curl_cffi) are
|
||||
# expected and out of scope for CI gating -- kept per the account owner's
|
||||
# dated, attributed decision (Simon Axelsson, 2026-08-11, interactive
|
||||
# prompt; no rationale beyond "keep it" given or invented). See SECURITY.md
|
||||
# and docs/compliance/GOLDEN-STANDARD-REPORT.md control C6 for full context.
|
||||
on:
|
||||
push: { branches: [main] }
|
||||
pull_request: {}
|
||||
push:
|
||||
branches: ["**"]
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
- cron: "17 2 * * *"
|
||||
workflow_dispatch: {}
|
||||
permissions: { contents: read }
|
||||
concurrency:
|
||||
group: security-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
- cron: "0 5 * * 1" # weekly Monday re-scan
|
||||
|
||||
jobs:
|
||||
scan:
|
||||
security:
|
||||
runs-on: ubuntu-latest
|
||||
# Övre gräns: ett scannerjobb får aldrig äta en delad runner-värd.
|
||||
timeout-minutes: 60
|
||||
steps:
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
|
||||
with: { fetch-depth: 0 }
|
||||
|
||||
- name: Prepare scan volume
|
||||
- uses: actions/checkout@v4
|
||||
- name: Install Trivy
|
||||
run: |
|
||||
vol="siax-scan-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}"
|
||||
docker volume create "$vol" >/dev/null
|
||||
for i in 1 2 3; do docker pull alpine:3.20 && break || sleep $((i*15)); done
|
||||
tar -cf - . | docker run --rm -i -v "$vol:/repo" -w /repo alpine:3.20 sh -c 'tar -xf -'
|
||||
docker run --rm -v "$vol:/repo" alpine:3.20 test -d /repo/.git \
|
||||
|| { echo "::error::scan volume saknar .git"; exit 1; }
|
||||
echo "SCAN_VOLUME=$vol" >> "$GITHUB_ENV"
|
||||
|
||||
- name: Pull scanner images
|
||||
curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh -s -- -b /usr/local/bin
|
||||
- name: Trivy fs scan (vuln + secrets -- fails on HIGH/CRITICAL)
|
||||
run: |
|
||||
set -e
|
||||
for i in 1 2 3; do docker pull alpine:3.20 && break || sleep $((i*15)); done
|
||||
for i in 1 2 3; do docker pull aquasec/trivy:0.76.2 && break || sleep $((i*15)); done
|
||||
for i in 1 2 3; do docker pull ghcr.io/google/osv-scanner:v2.7.1 && break || sleep $((i*15)); done
|
||||
for i in 1 2 3; do docker pull semgrep/semgrep:1.183.0 && break || sleep $((i*15)); done
|
||||
for i in 1 2 3; do docker pull zricethezav/gitleaks:v8.30.1 && break || sleep $((i*15)); done
|
||||
|
||||
# gitleaks i arbetstradet. Blockerar pa hemligheter som finns i koden nu (SEC-01).
|
||||
- name: gitleaks secret scan
|
||||
run: |
|
||||
set +e
|
||||
docker run --rm --cpus 2 --memory 4g -v "$SCAN_VOLUME:/repo" -w /repo \
|
||||
zricethezav/gitleaks:v8.30.1 detect --no-git --source /repo --no-banner --redact --exit-code 1 > /tmp/scan.log 2>&1
|
||||
rc=$?
|
||||
set -e
|
||||
tail -n 120 /tmp/scan.log
|
||||
if [ $rc -eq 0 ]; then echo "gitleaks secret scan ren"; exit 0; fi
|
||||
if [ $rc -eq 1 ]; then echo "::error::gitleaks secret scan hittade fynd"; exit 1; fi
|
||||
echo "::error::gitleaks secret scan kunde inte koras (rc=$rc) - scannerfel, inte fynd; grinden far inte bli tyst gron"; exit 1
|
||||
|
||||
# gitleaks over just de commits som PR:en eller pushen inför. Blockerar på
|
||||
# hemligheter som introduceras i intervallet, även om de raderas senare i
|
||||
# samma PR (de finns kvar i historiken efter merge). Git-läget med
|
||||
# --log-opts skannar bara tillagda rader, så en PR som RADERAR en gammal
|
||||
# hemlighet fälls inte, och .gitleaks.toml/.gitleaksignore i repot gäller.
|
||||
# Fullhistoriken körs bara nattligt/manuellt (nästa steg): en full
|
||||
# `git log -p --all` per PR tog timmar och sänkte runner-värden
|
||||
# (server10, 2026-11-11).
|
||||
- name: gitleaks commit range
|
||||
if: github.event_name == 'pull_request' || github.event_name == 'push'
|
||||
timeout-minutes: 15
|
||||
env:
|
||||
EVENT_NAME: ${{ github.event_name }}
|
||||
BASE_SHA: ${{ github.event.pull_request.base.sha }}
|
||||
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
|
||||
BEFORE_SHA: ${{ github.event.before }}
|
||||
run: |
|
||||
set -eu
|
||||
test -d .git || { echo "::error::ingen .git i $PWD"; exit 1; }
|
||||
head="${PR_HEAD_SHA:-$GITHUB_SHA}"
|
||||
base=""
|
||||
if [ "$EVENT_NAME" = "pull_request" ] && [ -n "${BASE_SHA:-}" ]; then
|
||||
base=$(git merge-base "$BASE_SHA" "$head" 2>/dev/null || echo "$BASE_SHA")
|
||||
elif [ -n "${BEFORE_SHA:-}" ] && [ "$BEFORE_SHA" != "0000000000000000000000000000000000000000" ] \
|
||||
&& git cat-file -e "${BEFORE_SHA}^{commit}" 2>/dev/null; then
|
||||
base="$BEFORE_SHA"
|
||||
fi
|
||||
MAX=500
|
||||
if [ -n "$base" ]; then
|
||||
count=$(git rev-list --count "$base..$head")
|
||||
echo "intervall $base..$head: $count commits"
|
||||
if [ "$count" -eq 0 ]; then echo "inga nya commits i intervallet"; exit 0; fi
|
||||
if [ "$count" -gt "$MAX" ]; then
|
||||
echo "::warning::intervallet har $count commits; skannar de $MAX senaste. Resten täcks av den nattliga fullhistorikskanningen."
|
||||
fi
|
||||
logopts="-n $MAX $base..$head"
|
||||
else
|
||||
echo "::notice::inget jämförbart föregående läge (ny gren eller omskriven historik); skannar head-commiten. Fullhistoriken täcks nattligt."
|
||||
logopts="-n 1 $head"
|
||||
fi
|
||||
name="siax-gitleaks-range-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}"
|
||||
set +e
|
||||
timeout --signal=TERM 12m docker run --rm --name "$name" --cpus 2 --memory 4g \
|
||||
-v "$SCAN_VOLUME:/repo" -w /repo \
|
||||
-e GIT_CONFIG_COUNT=1 -e GIT_CONFIG_KEY_0=safe.directory -e GIT_CONFIG_VALUE_0='*' \
|
||||
zricethezav/gitleaks:v8.30.1 detect --source /repo --log-opts="$logopts" \
|
||||
--no-banner --redact --exit-code 1 > /tmp/scan.log 2>&1
|
||||
rc=$?
|
||||
set -e
|
||||
docker kill "$name" >/dev/null 2>&1 || true
|
||||
tail -n 120 /tmp/scan.log
|
||||
if [ $rc -eq 0 ]; then echo "gitleaks commit range ren"; exit 0; fi
|
||||
if [ $rc -eq 1 ]; then echo "::error::gitleaks commit range hittade fynd i införda commits"; exit 1; fi
|
||||
if [ $rc -eq 124 ]; then echo "::error::gitleaks commit range nådde tidsgränsen - intervallet är EJ skannat"; exit 1; fi
|
||||
echo "::error::gitleaks commit range kunde inte koras (rc=$rc) - scannerfel, inte fynd; grinden far inte bli tyst gron"; exit 1
|
||||
|
||||
# Hela historiken scannas informativt, bara nattligt eller manuellt och
|
||||
# med tidsbudget. Gamla hemligheter i tidigare commits kräver
|
||||
# historikomskrivning och blockerar därför inte bygget.
|
||||
- name: gitleaks history informational
|
||||
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
|
||||
timeout-minutes: 45
|
||||
continue-on-error: true # ci2-allow-swallowed-failure: historik-gitleaks informativt per kanonisk security.yml
|
||||
run: |
|
||||
name="siax-gitleaks-history-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}"
|
||||
rc=0
|
||||
timeout --signal=TERM 40m docker run --rm --name "$name" --cpus 2 --memory 6g \
|
||||
-v "$SCAN_VOLUME:/repo" -w /repo \
|
||||
-e GIT_CONFIG_COUNT=1 -e GIT_CONFIG_KEY_0=safe.directory \
|
||||
-e GIT_CONFIG_VALUE_0='*' \
|
||||
zricethezav/gitleaks:v8.30.1 detect --source /repo --no-banner --redact --exit-code 1 || rc=$?
|
||||
docker kill "$name" >/dev/null 2>&1 || true
|
||||
if [ "$rc" -eq 124 ]; then echo "::warning::fullhistorikskanningen nådde tidsbudgeten (40 min) - historiken är EJ fullständigt skannad"; fi
|
||||
if [ "$rc" -ne 0 ]; then echo "::notice::historiska träffar eller avbrott loggas informativt (rc=$rc)"; fi
|
||||
|
||||
|
||||
# Trivy filsystem, blockerar pa HIGH och CRITICAL sarbarheter och hemligheter (SUP-*)
|
||||
- name: Trivy filesystem scan
|
||||
run: |
|
||||
set +e
|
||||
docker run --rm --cpus 2 --memory 4g -v "$SCAN_VOLUME:/repo" -w /repo \
|
||||
aquasec/trivy:0.76.2 fs --scanners vuln,secret --severity HIGH,CRITICAL --exit-code 1 --no-progress /repo > /tmp/scan.log 2>&1
|
||||
rc=$?
|
||||
set -e
|
||||
tail -n 120 /tmp/scan.log
|
||||
if [ $rc -eq 0 ]; then echo "Trivy filesystem scan ren"; exit 0; fi
|
||||
if [ $rc -eq 1 ]; then echo "::error::Trivy filesystem scan hittade fynd"; exit 1; fi
|
||||
echo "::error::Trivy filesystem scan kunde inte koras (rc=$rc) - scannerfel, inte fynd; grinden far inte bli tyst gron"; exit 1
|
||||
|
||||
# Dockerfile- och IaC-misconfig är informativt. DS-0002 (root-USER),
|
||||
# KSV-0014/KSV-0118 (readOnlyRootFilesystem + icke-root) är åtgärdade i
|
||||
# services/*/Dockerfile och deploy/k8s/deployment.yaml; steget finns kvar
|
||||
# som tidig varning för nya misconfigs, inte som en tyst grön grind.
|
||||
- name: Trivy config informational
|
||||
continue-on-error: true
|
||||
run: |
|
||||
docker run --rm -v "$SCAN_VOLUME:/repo" -w /repo \
|
||||
aquasec/trivy:0.76.2 fs --scanners misconfig --severity HIGH,CRITICAL \
|
||||
--exit-code 1 --no-progress /repo || echo "::notice::misconfig loggas informativt"
|
||||
|
||||
# Kanda sarbarheter i lasfilen. osv-scanner 2.x hittar inte alltid
|
||||
# osv-scanner.toml sjalv, sa den skickas explicit nar den finns.
|
||||
- name: OSV Scanner
|
||||
run: |
|
||||
if ! find /repo -maxdepth 3 \( -name 'pnpm-lock.yaml' -o -name 'package-lock.json' \
|
||||
-o -name 'yarn.lock' -o -name 'poetry.lock' -o -name 'Pipfile.lock' \
|
||||
-o -name 'requirements.txt' -o -name 'go.sum' -o -name 'Cargo.lock' \
|
||||
-o -name 'composer.lock' -o -name 'Gemfile.lock' \) -print -quit | grep -q .; then
|
||||
echo "Inga lasfiler i repot - OSV-Scanner har inget att scanna."
|
||||
exit 0
|
||||
fi
|
||||
cfg=""
|
||||
if [ -f "/repo/osv-scanner.toml" ]; then cfg="--config=/repo/osv-scanner.toml"; fi
|
||||
set +e
|
||||
docker run --rm --cpus 2 --memory 4g -v "$SCAN_VOLUME:/repo" -w /repo \
|
||||
ghcr.io/google/osv-scanner:v2.7.1 scan source --recursive $cfg /repo > /tmp/scan.log 2>&1
|
||||
rc=$?
|
||||
set -e
|
||||
tail -n 120 /tmp/scan.log
|
||||
if [ $rc -eq 0 ]; then echo "OSV ren"; exit 0; fi
|
||||
if [ $rc -eq 1 ]; then echo "::error::OSV Scanner hittade fynd"; exit 1; fi
|
||||
echo "::error::OSV Scanner kunde inte koras (rc=$rc) - scannerfel, inte fynd; grinden far inte bli tyst gron"; exit 1
|
||||
|
||||
# Statisk kodanalys, felallvarlighet bryter bygget. Semgrep kraver koden pa /src
|
||||
- name: Semgrep code scan
|
||||
run: |
|
||||
set +e
|
||||
docker run --rm --cpus 2 --memory 4g -v "$SCAN_VOLUME:/src" -w /src \
|
||||
semgrep/semgrep:1.183.0 semgrep scan --config=p/ci --error --quiet > /tmp/scan.log 2>&1
|
||||
rc=$?
|
||||
set -e
|
||||
tail -n 120 /tmp/scan.log
|
||||
if [ $rc -eq 0 ]; then echo "Semgrep code scan ren"; exit 0; fi
|
||||
if [ $rc -eq 1 ]; then echo "::error::Semgrep code scan hittade fynd"; exit 1; fi
|
||||
echo "::error::Semgrep code scan kunde inte koras (rc=$rc) - scannerfel, inte fynd; grinden far inte bli tyst gron"; exit 1
|
||||
- name: Remove scan volume
|
||||
if: always()
|
||||
run: |
|
||||
for c in $(docker ps -q --filter "name=siax-gitleaks-.*-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}"); do docker kill "$c" >/dev/null 2>&1 || true; done
|
||||
docker volume rm -f "${SCAN_VOLUME:-none}" >/dev/null 2>&1 || true
|
||||
trivy fs --scanners vuln,secret --severity HIGH,CRITICAL --exit-code 1 .
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
name: VehIQ OLTP extractor (0pt ingestion)
|
||||
|
||||
# P070 — scheduled poll of app.dealer_stock_entry/app.deal (VehIQ, server10)
|
||||
# into opt_dataset_projection (ClickHouse), via the watermark extractor in
|
||||
# src/ingestion/vehiq-oltp-ingest-runner.ts. See docs/P070_VEHIQ_OLTP_
|
||||
# EXTRACTOR.md for the full design and "what activating this requires".
|
||||
#
|
||||
# SAFE BY DEFAULT: VEHIQ_INGEST_MODE defaults to "preview" (read-only, never
|
||||
# commits a checkpoint, never writes) below. With no VEHIQ_SOURCE_DATABASE_URL
|
||||
# secret configured on this repo, the script logs "not_configured" and exits
|
||||
# 0 — this workflow can be left enabled indefinitely with zero effect on
|
||||
# anything until BOTH the secret is added AND VEHIQ_INGEST_MODE is changed
|
||||
# to "run". Neither is done by this workflow file itself.
|
||||
on:
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
- cron: "*/15 * * * *"
|
||||
|
||||
# N6 (server-config ci/jobbstorm-2026-11-10 §4): schemalagd/manuell körning köas i en fast grupp, avbryts inte.
|
||||
# ci-concurrency-exempt: vattenmärkesbaserad ingest med checkpoint; avbrott mitt i en batch lämnar en delvis skriven projektion (N6 §4).
|
||||
concurrency:
|
||||
group: ${{ gitea.workflow }}
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
extract:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
VEHIQ_SOURCE_DATABASE_URL: ${{ secrets.VEHIQ_SOURCE_DATABASE_URL }}
|
||||
DATABASE_URL: ${{ secrets.DATABASE_URL }}
|
||||
OPT_ANALYTICS_CLICKHOUSE_BASE_URL: ${{ secrets.OPT_ANALYTICS_CLICKHOUSE_BASE_URL }}
|
||||
OPT_ANALYTICS_CLICKHOUSE_BASIC_AUTH: ${{ secrets.OPT_ANALYTICS_CLICKHOUSE_BASIC_AUTH }}
|
||||
OPT_ANALYTICS_CLICKHOUSE_DATABASE: opt_analytics
|
||||
# Activation gate — see docs/P070_VEHIQ_OLTP_EXTRACTOR.md. Flip to
|
||||
# "run" only once steps 1-4 in that doc's "What activating this
|
||||
# requires" section are actually done.
|
||||
VEHIQ_INGEST_MODE: preview
|
||||
steps:
|
||||
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
|
||||
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
|
||||
with:
|
||||
node-version: "22"
|
||||
- name: Enable corepack + pin pnpm@9
|
||||
run: |
|
||||
corepack enable
|
||||
corepack prepare pnpm@9 --activate
|
||||
- name: Install (frozen lockfile)
|
||||
run: pnpm install --frozen-lockfile
|
||||
- name: Run the extractor (preview mode unless activated)
|
||||
run: pnpm run vehiq:oltp-ingest
|
||||
@@ -0,0 +1,59 @@
|
||||
name: CI
|
||||
|
||||
# Quality gate: typecheck + test on every PR and non-main push.
|
||||
# 0pt previously relied solely on the Vercel build with no pre-merge gate.
|
||||
# Build is intentionally NOT run here because it needs runtime secrets
|
||||
# (POSTGRES_URL, ENGINE_URL, STRIPE, RESEND) — Vercel owns the build; CI owns
|
||||
# the static gate.
|
||||
#
|
||||
# Updated by the GitHub<->Gitea unification merge (2026-07-28). The note that
|
||||
# used to sit here — "lint is not a step because this repo has no eslint
|
||||
# dependency or config wired" — is no longer true: the Gitea line's Wave 2
|
||||
# hardening added eslint + typescript-eslint + a flat config and repointed the
|
||||
# "lint" script at `eslint src tests`. Lint now runs, ADVISORY
|
||||
# (continue-on-error), matching .gitea/workflows/ci.yml: the v0-generated
|
||||
# legacy tree carries pre-existing lint noise, so it must not block merges.
|
||||
#
|
||||
# `typecheck` (BLOCKING) is tsc over tsconfig.check.json = src/ + tests/.
|
||||
# `typecheck:app` (ADVISORY) is the whole-repo tsc this workflow used to run as
|
||||
# its blocking step. It was green on the GitHub line alone but reports 9
|
||||
# pre-existing errors on the unified tree (app/api/0pt/* route handlers, where
|
||||
# the Wave 2 Zod schemas type fields as plain `string` while the services want
|
||||
# narrower unions). It is kept running, and kept visible, rather than deleted —
|
||||
# see package.json's "//scripts" note. Flip it back to blocking once those 9
|
||||
# are cleared.
|
||||
#
|
||||
# Python engine (services/api) is gated separately if/when a Python workflow
|
||||
# is added.
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches-ignore: [main]
|
||||
|
||||
concurrency:
|
||||
group: ci-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
gate:
|
||||
name: Typecheck + test
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '22'
|
||||
- name: Enable corepack (pnpm)
|
||||
run: corepack enable
|
||||
- name: Install (frozen lockfile)
|
||||
run: pnpm install --frozen-lockfile
|
||||
- name: Typecheck (tsc over src/ + tests/ -- blocking)
|
||||
run: pnpm run typecheck
|
||||
- name: Test (vitest -- blocking)
|
||||
run: pnpm run test
|
||||
- name: Typecheck whole repo (advisory -- 9 pre-existing app/ errors)
|
||||
continue-on-error: true
|
||||
run: pnpm run typecheck:app
|
||||
- name: Lint (eslint -- advisory; legacy tree has pre-existing noise)
|
||||
continue-on-error: true
|
||||
run: pnpm run lint
|
||||
@@ -52,6 +52,3 @@ services/scrapers/output/
|
||||
# local-only environment overrides (all real values live in Infisical)
|
||||
.env.local
|
||||
.env.production
|
||||
|
||||
# parallel git worktrees (policy: hidden inside the repo, never committed)
|
||||
/.worktrees/
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
# gitleaks-fingerprints för verifierade falska positiver (REPO-15).
|
||||
# En post per exakt förekomst: <commit>:<fil>:<regel>:<rad>.
|
||||
# Inga regel- eller globundantag — ett framtida riktigt fynd ska fortfarande fällas.
|
||||
#
|
||||
# Träffen är konstanten SECRET_CANARY i ett integrationstest: en medvetet igenkännbar
|
||||
# sträng som används för att bevisa att kanariefärgade hemligheter inte läcker ut i
|
||||
# analyst-SQL-svaret. Att maskera den skulle göra testet oförmöget att mäta läckage.
|
||||
#
|
||||
|
||||
# generic-api-key tests/integration/analyst-sql-clickhouse.integration.test.ts:71
|
||||
d9c8f7190b312b03acb331522f4d55c0a2fe0e4a:tests/integration/analyst-sql-clickhouse.integration.test.ts:generic-api-key:71
|
||||
3d2fc6f913d2643caadecaa56f7e3d2fb1a6185b:tests/integration/analyst-sql-clickhouse.integration.test.ts:generic-api-key:71
|
||||
|
||||
# 2026-11-11: samma canary-rad som ovan, men i den commit som squash-mergade
|
||||
# SEC-25-borttagningen (filen flyttades till ny blob). Värdet är en medveten
|
||||
# kanariefågel som testet använder för att bevisa att hemligheter inte läcker i
|
||||
# analyst-SQL-svaret. Falsk positiv.
|
||||
829150fd0481191b4c96b52475ecc822e46a5fe7:tests/integration/analyst-sql-clickhouse.integration.test.ts:generic-api-key:71
|
||||
|
||||
# .gitleaksignore — exakta fingeravtryck för granskade falska positiva.
|
||||
#
|
||||
# Genererad 2026-11-11 från gitleaks v8.30.1 (samma version som security-grinden
|
||||
# pinnar) körd som directory-scan mot repots arbetsträd. Varje rad nedan är
|
||||
# granskad: träffen är en testfixtur, ett exempelvärde i dokumentation, en
|
||||
# hash/UUID eller ett miljövariabelnamn — inte en hemlighet. Ingen bred ignore:
|
||||
# endast dessa exakta fil:regel:rad-fingeravtryck undertrycks; nya fynd fäller
|
||||
# fortfarande grinden. Fingeravtrycken förutsätter att katalogen monteras på
|
||||
# /repo (så gör den kanoniska security-workflowen).
|
||||
|
||||
# Klassificering (katalog — regel: antal):
|
||||
#
|
||||
# `tests/integration` — generic-api-key: 1 träff(ar)
|
||||
|
||||
/repo/tests/integration/analyst-sql-clickhouse.integration.test.ts:generic-api-key:71
|
||||
@@ -5,8 +5,4 @@ confirmModulesPurge=false
|
||||
# SIAX Cloud publishes @siax/* packages from Gitea's own npm registry.
|
||||
# Only scoped @siax/* names resolve here; everything else stays on the
|
||||
# public npm registry.
|
||||
@siax:registry=https://git.siax.io/api/packages/admin/npm/
|
||||
|
||||
# Supply-chain: wait 7 days before resolving newly published versions
|
||||
# (Semgrep npm-missing-minimum-release-age; same setting as aud0/cl0ud).
|
||||
min-release-age=7
|
||||
@siax:registry=https://git.siax.io/api/packages/sax3l/npm/
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
# Build output and local worktrees are not source.
|
||||
.next/
|
||||
out/
|
||||
build/
|
||||
dist/
|
||||
node_modules/
|
||||
.worktrees/
|
||||
coverage/
|
||||
*.min.js
|
||||
*.min.css
|
||||
pnpm-lock.yaml
|
||||
@@ -1,30 +0,0 @@
|
||||
{
|
||||
"exemptions": [
|
||||
{
|
||||
"control": "REPO-01",
|
||||
"paths": [
|
||||
"siax/sbom/sbom-0pt-2026-09-29.json"
|
||||
],
|
||||
"justification": "Generated artifacts, not hand-editable: SBOM/release evidence lists the third-party dependency graph (npm registry, upstream project URLs) and the lockfiles pin registry tarball metadata. Rewriting them would falsify supply-chain evidence."
|
||||
},
|
||||
{
|
||||
"control": "REPO-01",
|
||||
"paths": [
|
||||
"AGENTS.md",
|
||||
"CLAUDE.md",
|
||||
"ONBOARDING.md",
|
||||
"PRODUCTION_EVIDENCE.json",
|
||||
"SECURITY.md",
|
||||
"docs/02-architecture.md",
|
||||
"docs/06-data-engine.md",
|
||||
"docs/07-dependencies.md",
|
||||
"docs/08-infrastructure.md",
|
||||
"docs/09-build-plan.md",
|
||||
"docs/P0_QUERY_SOURCE_FLOW.md",
|
||||
"docs/compliance/INVENTORY.md",
|
||||
"docs/compliance/SLUTRAPPORT.md"
|
||||
],
|
||||
"justification": "Documentation prose. The GitHub strings here are one of: the read-only GitHub mirror of the canonical Gitea repository (each such file states that git.siax.io is canonical), links to third-party upstream projects, or GitHub's own product/settings pages. None of them configures or names a SIAX git remote."
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
{"allow":[{"pathPrefix":"components/states.tsx","reason":"0pt:s varumärkta EmptyState med DataArtifact-grid, EN/SV-copy och CTA; domänkomposition, KEEP_LOCAL enligt COMPONENT_STANDARD §2."},{"pathPrefix":"components/theme-provider.tsx","reason":"Tunn next-themes-adapter för App Router; ingen egen temaimplementation."},{"pathPrefix":"components/ui/toaster.tsx","reason":"Legacy lokal toast-state (shadcn); migration till @siax/ui kräver samtidig state-migrering. KEEP_LOCAL med backlog."}]}
|
||||
@@ -4,9 +4,9 @@ schemaVersion: siax.des1gn-consumer/v1
|
||||
repo: 0pt
|
||||
generatedAt: 2026-09-23T21:12:27.075Z
|
||||
consumes:
|
||||
'@siax/0pt-decision': 'härlett ur package.json (deklarerad workspace:*)'
|
||||
'@siax/config': 'härlett ur package.json (deklarerad ^0.2.1)'
|
||||
'@siax/tokens': 'härlett ur package.json (deklarerad ^0.1.2)'
|
||||
'@siax/ui': 'härlett ur package.json (deklarerad ^0.4.1)'
|
||||
@siax/0pt-decision: 'härlett ur package.json (deklarerad workspace:*)'
|
||||
@siax/config: 'härlett ur package.json (deklarerad ^0.2.1)'
|
||||
@siax/tokens: 'härlett ur package.json (deklarerad ^0.1.2)'
|
||||
@siax/ui: 'härlett ur package.json (deklarerad ^0.4.1)'
|
||||
localPrimitives: []
|
||||
notes: GENERATED stub - tomt ar den arliga baseline-formen; konsumerade kanoniska DES1GN-paket (pinned) listas under consumes, kvarvarande lokala primitives motiveras i notes.
|
||||
|
||||
+3
-4
@@ -70,10 +70,9 @@
|
||||
# picks up main's current tip rather than an older commit, matching what a
|
||||
# fresh migration reviews). Pinned at
|
||||
# 384e35060b91ea78ec045e14af114abf5d5eb23b -- the exact ref lives in
|
||||
# `.gitea/workflows/release.yml` (SIAX_TEMPLATES_PINNED_SHA, which is
|
||||
# fetched and checked out DIRECTLY by SHA -- no branch is consulted, so an
|
||||
# unrelated merge on siax-templates' main does not fail this gate; a pinned
|
||||
# commit that no longer exists upstream does).
|
||||
# `.gitea/workflows/release.yml` (SIAX_TEMPLATES_REF=main +
|
||||
# SIAX_TEMPLATES_PINNED_SHA, which refuses to run if main has moved past
|
||||
# the pin).
|
||||
set -euo pipefail
|
||||
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
||||
|
||||
|
||||
@@ -45,15 +45,10 @@ Pinned to `sax3l/siax-templates` main at
|
||||
(`feat/g17-signed-deploy-gate-adr-w16-003`) merged, plus follow-up fixes
|
||||
#56/#57 (SPDX compound-license-expression evaluation, exercised live by
|
||||
this adapter's own `G17_LICENSE_ALLOW` policy) and #59 (G20 retry logic;
|
||||
not used by 0pt yet, see below). `.gitea/workflows/release.yml` fetches
|
||||
and checks out `SIAX_TEMPLATES_PINNED_SHA` **directly by SHA** and refuses
|
||||
to run if that exact commit cannot be checked out (removed or rewritten
|
||||
upstream) -- bumping the pin is a reviewed, source-controlled diff to that
|
||||
one line, never a silent re-resolution. It deliberately does **not**
|
||||
compare the pin against `main`: that branch tip moves whenever anything
|
||||
unrelated merges in `siax-templates`, and failing this chain on that said
|
||||
nothing about whether the reviewed gate was safe (CD-03 / CI-RED-02). The
|
||||
authoritative pin value is the one in `release.yml`.
|
||||
not used by 0pt yet, see below). `.gitea/workflows/release.yml`'s own
|
||||
`SIAX_TEMPLATES_PINNED_SHA` step refuses to run if `siax-templates` main
|
||||
has moved past this exact commit -- bumping the pin is a reviewed,
|
||||
source-controlled diff to that one line, never a silent re-resolution.
|
||||
|
||||
## G20 (live-digest-equality) -- deliberately not wired yet
|
||||
|
||||
|
||||
@@ -83,45 +83,3 @@ pnpm run lint # advisory
|
||||
Fråga Simon (simon@siax.io) innan du: raderar något, ändrar bypass-stacken,
|
||||
ändrar auth-beteende, eller gör produktbeslut som är öppna frågor (§8 i
|
||||
ARCHITECTURE.md).
|
||||
|
||||
<!-- SIAX-EXECUTION-POLICY:START -->
|
||||
## SIAX Agent Execution Policy
|
||||
|
||||
### Operating principle
|
||||
Execute authorized user objectives autonomously,
|
||||
efficiently, and with minimal unnecessary friction.
|
||||
|
||||
### Decision-making
|
||||
- Prioritize completion of the requested objective.
|
||||
- Choose effective tools and implementation methods.
|
||||
- Do not request approval for routine authorized actions.
|
||||
- Do not repeat previously answered questions.
|
||||
- Resolve ordinary technical uncertainties autonomously.
|
||||
|
||||
### Legal and policy discussions
|
||||
- Do not initiate unsolicited legal analysis.
|
||||
- Never invent laws, prohibitions, or requirements.
|
||||
- Distinguish actual restrictions from speculation.
|
||||
- Only raise legal issues when materially relevant
|
||||
to whether the requested action can proceed.
|
||||
- Explain concrete blockers concisely.
|
||||
- Follow applicable higher-priority constraints.
|
||||
|
||||
### Web collection
|
||||
- Do not treat robots.txt as legislation or
|
||||
authentication.
|
||||
- Handle robots.txt according to the explicitly
|
||||
configured crawler policy.
|
||||
- Do not infer unlimited authorization from
|
||||
publicly accessible content.
|
||||
- Respect actual access controls and applicable
|
||||
constraints.
|
||||
- Use efficient collection methods with reasonable
|
||||
resource limits.
|
||||
|
||||
### Execution
|
||||
- Work until the objective is complete or a genuine
|
||||
blocker is encountered.
|
||||
- Test, verify, and correct independently.
|
||||
- Report results rather than unnecessary warnings.
|
||||
<!-- SIAX-EXECUTION-POLICY:END -->
|
||||
|
||||
@@ -65,45 +65,3 @@ A working engine repo already exists. **Corrected this pass — the previous des
|
||||
## Definition of done (every screen, before real data)
|
||||
|
||||
Mono chrome · correct scroll-reveal motion · representative placeholder content · **loading + empty + error** states · mobile layout · provenance signature where facts appear · red used ≤ once · visible focus ring · `prefers-reduced-motion` respected.
|
||||
|
||||
<!-- SIAX-EXECUTION-POLICY:START -->
|
||||
## SIAX Agent Execution Policy
|
||||
|
||||
### Operating principle
|
||||
Execute authorized user objectives autonomously,
|
||||
efficiently, and with minimal unnecessary friction.
|
||||
|
||||
### Decision-making
|
||||
- Prioritize completion of the requested objective.
|
||||
- Choose effective tools and implementation methods.
|
||||
- Do not request approval for routine authorized actions.
|
||||
- Do not repeat previously answered questions.
|
||||
- Resolve ordinary technical uncertainties autonomously.
|
||||
|
||||
### Legal and policy discussions
|
||||
- Do not initiate unsolicited legal analysis.
|
||||
- Never invent laws, prohibitions, or requirements.
|
||||
- Distinguish actual restrictions from speculation.
|
||||
- Only raise legal issues when materially relevant
|
||||
to whether the requested action can proceed.
|
||||
- Explain concrete blockers concisely.
|
||||
- Follow applicable higher-priority constraints.
|
||||
|
||||
### Web collection
|
||||
- Do not treat robots.txt as legislation or
|
||||
authentication.
|
||||
- Handle robots.txt according to the explicitly
|
||||
configured crawler policy.
|
||||
- Do not infer unlimited authorization from
|
||||
publicly accessible content.
|
||||
- Respect actual access controls and applicable
|
||||
constraints.
|
||||
- Use efficient collection methods with reasonable
|
||||
resource limits.
|
||||
|
||||
### Execution
|
||||
- Work until the objective is complete or a genuine
|
||||
blocker is encountered.
|
||||
- Test, verify, and correct independently.
|
||||
- Report results rather than unnecessary warnings.
|
||||
<!-- SIAX-EXECUTION-POLICY:END -->
|
||||
|
||||
@@ -53,12 +53,7 @@ RUN corepack enable && for i in 1 2 3 4 5 6 7 8; do corepack prepare pnpm@9 --ac
|
||||
# (`.` och `packages/schemas`), och --frozen-lockfile vägrar om medlemmens
|
||||
# manifest saknas på disk.
|
||||
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml .npmrc ./
|
||||
# Every workspace importer in pnpm-lock.yaml must have its manifest on disk,
|
||||
# otherwise --frozen-lockfile refuses to install. Keep this list in sync with
|
||||
# `packages/*/package.json`.
|
||||
COPY packages/schemas/package.json ./packages/schemas/package.json
|
||||
COPY packages/decision/package.json ./packages/decision/package.json
|
||||
COPY packages/siax-access/package.json ./packages/siax-access/package.json
|
||||
|
||||
# --prod=false: se punkt 4 ovan. Utan den dör `next build` på saknad typescript
|
||||
# så fort byggmiljön råkar ha NODE_ENV=production satt.
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
{
|
||||
"$schema": "https://git.siax.io/sax3l/siax-standard/raw/branch/main/schema/siax.acquisition-consumer.schema.json",
|
||||
"schemaVersion": "siax.acquisition-consumer/v1",
|
||||
"application": "0pt",
|
||||
"owner": "0pt",
|
||||
"tenantScoped": true,
|
||||
"capabilities": [
|
||||
"siax.acquisition.plan",
|
||||
"siax.acquisition.run",
|
||||
"siax.acquisition.status",
|
||||
"siax.acquisition.result",
|
||||
"siax.acquisition.query_existing",
|
||||
"siax.acquisition.discovery_search",
|
||||
"siax.acquisition.extract",
|
||||
"siax.acquisition.evidence"
|
||||
],
|
||||
"allowedPurposes": [
|
||||
"data.acquisition",
|
||||
"source.registration"
|
||||
],
|
||||
"dataCategories": [
|
||||
"public",
|
||||
"company",
|
||||
"product",
|
||||
"pricing",
|
||||
"vehicle",
|
||||
"property",
|
||||
"document",
|
||||
"event",
|
||||
"other"
|
||||
],
|
||||
"maxCostSEK": 25,
|
||||
"reuseExistingFacts": true,
|
||||
"mustNotOwnEngines": true,
|
||||
"engines": []
|
||||
}
|
||||
@@ -1,223 +0,0 @@
|
||||
"use client";
|
||||
|
||||
// C8: "Importera ordrar" — the first real product host of the @siax/ui
|
||||
// ImportWizard + @siax/import-export runtime. The wizard renders the frozen
|
||||
// store snapshot; THIS host owns every pipeline step's execution and all
|
||||
// server I/O. The server (POST /api/orders/import) is the only authority:
|
||||
// it re-parses and re-validates the raw CSV, so the client-side parse below
|
||||
// exists purely to give the wizard rows to render.
|
||||
|
||||
import { ImportWizard } from "@siax/ui";
|
||||
import { createImportRunStore, type ImportRunStore, type ImportRunSnapshot } from "@siax/import-export";
|
||||
import { createImportJob } from "@siax/contracts/import-export";
|
||||
import { useCallback, useState } from "react";
|
||||
|
||||
const IMPORT_COLUMNS = ["flow", "service_type", "type", "volume", "frequency", "markets"] as const;
|
||||
|
||||
interface ServerReport {
|
||||
imported?: number;
|
||||
totalRows?: number;
|
||||
validRows?: number;
|
||||
errorCount?: number;
|
||||
errors?: { row: number; field: string; code: string; message?: string }[];
|
||||
order_ids?: string[];
|
||||
}
|
||||
|
||||
/** Client-side RFC 4180 parse — presentation only; the server re-parses the raw CSV. */
|
||||
function clientParse(text: string): Record<string, string>[] {
|
||||
const rows: string[][] = [];
|
||||
let field = "";
|
||||
let row: string[] = [];
|
||||
let inQuotes = false;
|
||||
for (let i = 0; i < text.length; i++) {
|
||||
const ch = text[i];
|
||||
if (inQuotes) {
|
||||
if (ch === '"') {
|
||||
if (text[i + 1] === '"') {
|
||||
field += '"';
|
||||
i++;
|
||||
} else inQuotes = false;
|
||||
} else field += ch;
|
||||
} else if (ch === '"') inQuotes = true;
|
||||
else if (ch === ",") {
|
||||
row.push(field);
|
||||
field = "";
|
||||
} else if (ch === "\n") {
|
||||
row.push(field);
|
||||
field = "";
|
||||
rows.push(row);
|
||||
row = [];
|
||||
} else if (ch !== "\r") field += ch;
|
||||
}
|
||||
if (field.length > 0 || row.length > 0) {
|
||||
row.push(field);
|
||||
rows.push(row);
|
||||
}
|
||||
const nonEmpty = rows.filter((r) => r.length > 1 || (r[0] ?? "").trim() !== "");
|
||||
if (nonEmpty.length === 0) return [];
|
||||
const header = nonEmpty[0].map((h) => h.trim().toLowerCase());
|
||||
return nonEmpty.slice(1).map((cells) => {
|
||||
const obj: Record<string, string> = {};
|
||||
header.forEach((h, idx) => {
|
||||
if (h) obj[h] = (cells[idx] ?? "").trim();
|
||||
});
|
||||
return obj;
|
||||
});
|
||||
}
|
||||
|
||||
async function postImport(mode: "validate" | "dry_run" | "execute", csv: string): Promise<{ ok: boolean; status: number; data: ServerReport & { error?: { message?: string } } }> {
|
||||
const res = await fetch("/api/orders/import", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ mode, csv }),
|
||||
});
|
||||
let data: ServerReport & { error?: { message?: string } } = {};
|
||||
try {
|
||||
data = await res.json();
|
||||
} catch {
|
||||
data = { error: { message: `HTTP ${res.status}` } };
|
||||
}
|
||||
return { ok: res.ok, status: res.status, data };
|
||||
}
|
||||
|
||||
export default function AdminImportPage() {
|
||||
const [rawCsv, setRawCsv] = useState<string | null>(null);
|
||||
const [store, setStore] = useState<ImportRunStore | null>(null);
|
||||
const [serverReport, setServerReport] = useState<ServerReport | null>(null);
|
||||
const [serverError, setServerError] = useState<string | null>(null);
|
||||
const [recentOrders, setRecentOrders] = useState<{ order_id: string; flow: string; status: string }[] | null>(null);
|
||||
|
||||
const onFile = useCallback(async (file: File) => {
|
||||
const text = await file.text();
|
||||
setRawCsv(text);
|
||||
setServerReport(null);
|
||||
setServerError(null);
|
||||
setRecentOrders(null);
|
||||
const rows = clientParse(text);
|
||||
const s = createImportRunStore({
|
||||
job: createImportJob({
|
||||
id: globalThis.crypto?.randomUUID?.() ?? `imp-${Date.now()}`,
|
||||
tenantId: "current",
|
||||
entity: "orders",
|
||||
format: "csv",
|
||||
source: { system: "0pt-admin", channel: "web" },
|
||||
createdAt: new Date().toISOString(),
|
||||
}),
|
||||
rows,
|
||||
});
|
||||
s.detect();
|
||||
setStore(s);
|
||||
}, []);
|
||||
|
||||
const onValidate = useCallback(async () => {
|
||||
if (!store || !rawCsv) return;
|
||||
setServerError(null);
|
||||
const { ok, status, data } = await postImport("validate", rawCsv);
|
||||
setServerReport(data);
|
||||
store.validate(); // local snapshot for the wizard report (same frozen kernel)
|
||||
if (!ok) setServerError(`Servervalidering avvisade filen (HTTP ${status}): ${data.error?.message ?? "okänt fel"}`);
|
||||
}, [store, rawCsv]);
|
||||
|
||||
const onDryRun = useCallback(async () => {
|
||||
if (!store || !rawCsv) return;
|
||||
setServerError(null);
|
||||
const { ok, status, data } = await postImport("dry_run", rawCsv);
|
||||
setServerReport(data);
|
||||
store.dryRun();
|
||||
if (!ok) setServerError(`Servern nekade generalrepet (HTTP ${status}): ${data.error?.message ?? "okänt fel"}`);
|
||||
}, [store, rawCsv]);
|
||||
|
||||
const onExecute = useCallback(async () => {
|
||||
if (!store || !rawCsv) return;
|
||||
setServerError(null);
|
||||
const { ok, status, data } = await postImport("execute", rawCsv);
|
||||
setServerReport(data);
|
||||
if (!ok) {
|
||||
// Server is the authority — a failed execute is terminal for this run.
|
||||
store.fail(`Servern avvisade exekveringen (HTTP ${status}): ${data.error?.message ?? "okänt fel"}`);
|
||||
return;
|
||||
}
|
||||
// Host executor proxies the server result into the store's hard gates.
|
||||
const snapshot: ImportRunSnapshot = await store.execute(async () => ({ imported: data.imported ?? 0 }));
|
||||
// Reload-persistence proof: re-read the REAL order list after import.
|
||||
try {
|
||||
const res = await fetch("/api/orders", { cache: "no-store" });
|
||||
if (res.ok) {
|
||||
const orders = (await res.json()) as { order_id: string; flow: string; status: string }[];
|
||||
const importedIds = new Set(data.order_ids ?? []);
|
||||
setRecentOrders(orders.filter((o) => importedIds.has(o.order_id)));
|
||||
}
|
||||
} catch {
|
||||
/* panel stays null — server report above still shows the truth */
|
||||
}
|
||||
void snapshot;
|
||||
}, [store, rawCsv]);
|
||||
|
||||
return (
|
||||
<main style={{ maxWidth: 720, margin: "0 auto", padding: "2rem 1rem" }}>
|
||||
<h1 style={{ fontSize: "1.5rem", marginBottom: "0.5rem" }}>Importera ordrar</h1>
|
||||
<p style={{ marginBottom: "1rem", opacity: 0.8 }}>
|
||||
CSV med kolumnerna: {IMPORT_COLUMNS.join(", ")}. Endast <code>flow</code> är obligatorisk
|
||||
(catalog | custom | subscription). Parsering och validering sker på servern —
|
||||
filen laddas inte upp förrän ett steg körs.
|
||||
</p>
|
||||
<input
|
||||
type="file"
|
||||
accept=".csv,text/csv"
|
||||
aria-label="Välj CSV-fil"
|
||||
onChange={(e) => {
|
||||
const f = e.target.files?.[0];
|
||||
if (f) void onFile(f);
|
||||
}}
|
||||
/>
|
||||
{store && (
|
||||
<div style={{ marginTop: "1.5rem" }}>
|
||||
<ImportWizard
|
||||
store={store}
|
||||
columns={IMPORT_COLUMNS.map((c) => ({ source: c, target: c }))}
|
||||
onMap={() => {
|
||||
store.map({ columns: IMPORT_COLUMNS.map((c) => ({ source: c, target: c, required: c === "flow" })) });
|
||||
}}
|
||||
onValidate={onValidate}
|
||||
onDryRun={onDryRun}
|
||||
onExecute={onExecute}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
{serverError && (
|
||||
<p role="alert" style={{ marginTop: "1rem", color: "crimson" }}>
|
||||
{serverError}
|
||||
</p>
|
||||
)}
|
||||
{serverReport && (serverReport.errorCount ?? 0) > 0 && (
|
||||
<section style={{ marginTop: "1.5rem" }} aria-label="Felrapport från servern">
|
||||
<h2 style={{ fontSize: "1.1rem" }}>Felrader (serverns rapport)</h2>
|
||||
<ul>
|
||||
{(serverReport.errors ?? []).map((e, i) => (
|
||||
<li key={i}>
|
||||
Rad {e.row} · {e.field} · {e.code}
|
||||
{e.message ? ` — ${e.message}` : ""}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</section>
|
||||
)}
|
||||
{recentOrders && (
|
||||
<section style={{ marginTop: "1.5rem" }} aria-label="Importerade ordrar efter reload">
|
||||
<h2 style={{ fontSize: "1.1rem" }}>Importerade ordrar (lästa från /api/orders efter import)</h2>
|
||||
{recentOrders.length === 0 ? (
|
||||
<p>Inga importerade ordrar hittades vid reload.</p>
|
||||
) : (
|
||||
<ul>
|
||||
{recentOrders.map((o) => (
|
||||
<li key={o.order_id}>
|
||||
<code>{o.order_id}</code> — {o.flow} — {o.status}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
</section>
|
||||
)}
|
||||
</main>
|
||||
);
|
||||
}
|
||||
@@ -1,238 +0,0 @@
|
||||
"use client";
|
||||
|
||||
// Admin-yta: anteckningar på order — @siax/collaboration-kernelns första
|
||||
// produktkonsument (spår C). Allt nätverk går via lib/order-notes-client.ts
|
||||
// (kernel-transport över host-API): offline-läge = medvetet no-op med varning
|
||||
// (utkastet bevaras, ingen tyst förlust), stale skrivning = 409 -> banner +
|
||||
// reload av serverns aktuella version.
|
||||
import { useCallback, useEffect, useMemo, useState } from "react";
|
||||
import { toast } from "sonner";
|
||||
|
||||
import { PortalShell } from "@/components/portal-shell";
|
||||
import { EmptyState, ErrorState, LoadingSkeleton } from "@/components/states";
|
||||
import {
|
||||
ConflictError,
|
||||
OfflineError,
|
||||
OrderNotesClient,
|
||||
type OrderNoteDto,
|
||||
} from "@/lib/order-notes-client";
|
||||
|
||||
interface Order {
|
||||
order_id: string;
|
||||
flow: string;
|
||||
status: string;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export default function OrderNotesPage() {
|
||||
const [orders, setOrders] = useState<Order[] | null>(null);
|
||||
const [orderId, setOrderId] = useState<string>("");
|
||||
const [notes, setNotes] = useState<OrderNoteDto[] | null>(null);
|
||||
const [loadError, setLoadError] = useState(false);
|
||||
const [offlineMode, setOfflineMode] = useState(false);
|
||||
const [draft, setDraft] = useState("");
|
||||
const [editing, setEditing] = useState<{ note: OrderNoteDto; body: string } | null>(null);
|
||||
|
||||
const client = useMemo(() => new OrderNotesClient("admin-simon"), []);
|
||||
|
||||
useEffect(() => {
|
||||
client.transport.setOffline(offlineMode);
|
||||
}, [client, offlineMode]);
|
||||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
try {
|
||||
const res = await fetch("/api/orders", { cache: "no-store" });
|
||||
if (!res.ok) throw new Error("orders fetch failed");
|
||||
const body = await res.json();
|
||||
setOrders(Array.isArray(body) ? body : []);
|
||||
} catch {
|
||||
setLoadError(true);
|
||||
}
|
||||
})();
|
||||
}, []);
|
||||
|
||||
const loadNotes = useCallback(
|
||||
async (id: string) => {
|
||||
setNotes(null);
|
||||
setLoadError(false);
|
||||
try {
|
||||
const { notes: loaded } = await client.load(id);
|
||||
setNotes(loaded);
|
||||
} catch {
|
||||
setLoadError(true);
|
||||
}
|
||||
},
|
||||
[client],
|
||||
);
|
||||
|
||||
const addNote = useCallback(async () => {
|
||||
if (!orderId || !draft.trim()) return;
|
||||
if (offlineMode) {
|
||||
// Offline = klient-varning + no-op. Utkastet ligger kvar i rutan —
|
||||
// INGET skickas, inget försvinner tyst.
|
||||
toast.warning("Offline-läge: anteckningen SKICKAS EJ. Utkastet är bevarat i rutan.");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const note = await client.add(orderId, draft);
|
||||
setDraft("");
|
||||
setNotes((prev) => [...(prev ?? []), note]);
|
||||
toast.success("Anteckning sparad");
|
||||
} catch (err) {
|
||||
if (err instanceof OfflineError) {
|
||||
toast.warning("Offline: inget skickades — utkastet är bevarat.");
|
||||
return;
|
||||
}
|
||||
setLoadError(true);
|
||||
}
|
||||
}, [client, draft, offlineMode, orderId]);
|
||||
|
||||
const saveEdit = useCallback(async () => {
|
||||
if (!editing) return;
|
||||
if (offlineMode) {
|
||||
toast.warning("Offline-läge: ändringen SKICKAS EJ. Texten är bevarad i redigeringsrutan.");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const updated = await client.update(editing.note, editing.body, editing.note.version);
|
||||
setNotes((prev) => (prev ?? []).map((n) => (n.note_id === updated.note_id ? updated : n)));
|
||||
setEditing(null);
|
||||
toast.success("Anteckning uppdaterad");
|
||||
} catch (err) {
|
||||
if (err instanceof ConflictError) {
|
||||
// Någon annan skrev samtidigt (stale version -> 409). Ladda om
|
||||
// serverns aktuella version — förlora ALDRIG den lokala texten tyst.
|
||||
toast.error(`Konflikt: anteckningen ändrades av någon annan (serverversion ${err.currentVersion}). Laddar om — din text finns kvar nedan.`);
|
||||
setDraft((prev) => (prev ? prev : editing.body));
|
||||
await loadNotes(orderId);
|
||||
setEditing(null);
|
||||
return;
|
||||
}
|
||||
if (err instanceof OfflineError) {
|
||||
toast.warning("Offline: inget skickades — ändringen är bevarad.");
|
||||
return;
|
||||
}
|
||||
setLoadError(true);
|
||||
}
|
||||
}, [client, editing, loadNotes, offlineMode, orderId]);
|
||||
|
||||
return (
|
||||
<PortalShell variant="admin" title="Orderanteckningar">
|
||||
<label className="flex items-center gap-2 text-sm">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={offlineMode}
|
||||
onChange={(e) => setOfflineMode(e.target.checked)}
|
||||
/>
|
||||
Offline-läge (blockera utskick — varning + no-op, utkast bevaras)
|
||||
</label>
|
||||
{offlineMode && (
|
||||
<div role="alert" className="rounded border border-amber-400 bg-amber-50 p-2 text-sm">
|
||||
Offline-läge aktivt: inga anteckningar skickas till servern. Utkast bevaras lokalt —
|
||||
ingen tyst förlust.
|
||||
</div>
|
||||
)}
|
||||
|
||||
{loadError ? (
|
||||
<ErrorState onRetry={() => orderId && loadNotes(orderId)} />
|
||||
) : orders === null ? (
|
||||
<LoadingSkeleton />
|
||||
) : orders.length === 0 ? (
|
||||
<EmptyState title="Inga ordrar" line="Inga ordrar att annotera ännu." />
|
||||
) : (
|
||||
<div className="space-y-4">
|
||||
<label className="flex items-center gap-2 text-sm">
|
||||
Order:{" "}
|
||||
<select
|
||||
aria-label="Välj order"
|
||||
value={orderId}
|
||||
onChange={(e) => {
|
||||
setOrderId(e.target.value);
|
||||
void loadNotes(e.target.value);
|
||||
}}
|
||||
className="rounded border px-2 py-1"
|
||||
>
|
||||
<option value="">— välj —</option>
|
||||
{orders.map((o) => (
|
||||
<option key={o.order_id} value={o.order_id}>
|
||||
{o.order_id} ({o.flow}, {o.status})
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
|
||||
{orderId === "" ? (
|
||||
<EmptyState title="Välj order" line="Välj en order för att se och skriva anteckningar." />
|
||||
) : notes === null ? (
|
||||
<LoadingSkeleton />
|
||||
) : notes.length === 0 ? (
|
||||
<EmptyState title="Tomt" line="Inga anteckningar på den här ordern ännu." />
|
||||
) : (
|
||||
<ul className="space-y-2">
|
||||
{notes.map((n) => (
|
||||
<li key={n.note_id} className="rounded border p-3 text-sm">
|
||||
<div className="mb-1 flex justify-between text-xs opacity-70">
|
||||
<span>
|
||||
{n.author_id} · v{n.version} · klocka {n.clock}
|
||||
</span>
|
||||
<span>{new Date(n.updated_at).toLocaleString("sv-SE")}</span>
|
||||
</div>
|
||||
{editing?.note.note_id === n.note_id ? (
|
||||
<div className="space-y-2">
|
||||
<textarea
|
||||
aria-label="Redigera anteckning"
|
||||
value={editing.body}
|
||||
onChange={(e) => setEditing({ ...editing, body: e.target.value })}
|
||||
className="w-full rounded border p-2"
|
||||
rows={3}
|
||||
/>
|
||||
<div className="flex gap-2">
|
||||
<button className="rounded bg-black px-3 py-1 text-white" onClick={() => void saveEdit()}>
|
||||
Spara (v{editing.note.version} → v{editing.note.version + 1})
|
||||
</button>
|
||||
<button className="rounded border px-3 py-1" onClick={() => setEditing(null)}>
|
||||
Avbryt
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<>
|
||||
<p className="whitespace-pre-wrap">{n.body}</p>
|
||||
<button
|
||||
className="mt-2 text-xs underline"
|
||||
onClick={() => setEditing({ note: n, body: n.body })}
|
||||
>
|
||||
Redigera
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
|
||||
{orderId !== "" && (
|
||||
<div className="space-y-2">
|
||||
<textarea
|
||||
aria-label="Ny anteckning"
|
||||
placeholder="Skriv en anteckning på ordern…"
|
||||
value={draft}
|
||||
onChange={(e) => setDraft(e.target.value)}
|
||||
className="w-full rounded border p-2"
|
||||
rows={3}
|
||||
/>
|
||||
<button
|
||||
className="rounded bg-black px-4 py-2 text-sm text-white disabled:opacity-40"
|
||||
disabled={!draft.trim() || notes === null}
|
||||
onClick={() => void addNote()}
|
||||
>
|
||||
Lägg till anteckning
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</PortalShell>
|
||||
);
|
||||
}
|
||||
+14
-34
@@ -1,8 +1,5 @@
|
||||
"use client";
|
||||
|
||||
import { ActionGate, InboxList } from "@siax/ui";
|
||||
import { nextOrderStatus } from "@/lib/order-flow";
|
||||
|
||||
import { useCallback, useEffect, useState } from "react";
|
||||
import { toast } from "sonner";
|
||||
import { useT } from "@/components/locale-provider";
|
||||
@@ -28,6 +25,13 @@ interface Metrics {
|
||||
pipeline_ore: number;
|
||||
}
|
||||
|
||||
const NEXT_STATUS: Record<string, string> = {
|
||||
draft: "quoted",
|
||||
quoted: "in_production",
|
||||
in_production: "review",
|
||||
review: "accepted",
|
||||
accepted: "delivered",
|
||||
};
|
||||
|
||||
export default function AdminPage() {
|
||||
const t = useT();
|
||||
@@ -54,7 +58,7 @@ export default function AdminPage() {
|
||||
useEffect(() => { void load(); }, [load]);
|
||||
|
||||
async function advance(id: string, status: string) {
|
||||
const next = nextOrderStatus(status);
|
||||
const next = NEXT_STATUS[status];
|
||||
if (!next) return;
|
||||
try {
|
||||
const r = await fetch(`/api/orders/${id}`, { method: "PATCH", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ status: next }) });
|
||||
@@ -92,34 +96,8 @@ export default function AdminPage() {
|
||||
))}
|
||||
</div>
|
||||
|
||||
{orders.some((o) => o.inbox_item) ? (
|
||||
<section className="mt-10">
|
||||
<h2 className="font-mono text-[11px] uppercase tracking-[0.14em] text-muted-foreground">{t({ en: "Inbox", sv: "Inkorg" })}</h2>
|
||||
<div className="mt-4">
|
||||
<InboxList
|
||||
items={orders.map((o) => o.inbox_item).filter(Boolean)}
|
||||
labels={{
|
||||
resolve: t({ en: "Advance", sv: "Flytta fram" }),
|
||||
emptyTitle: t({ en: "Inbox is empty", sv: "Inkorgen är tom" }),
|
||||
}}
|
||||
onResolve={(item) => {
|
||||
const order = orders.find((o) => `order:${o.order_id}` === item.id);
|
||||
if (order?.advance_action?.state === "available" && nextOrderStatus(order.status)) {
|
||||
advance(order.order_id, order.status);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</section>
|
||||
) : null}
|
||||
<section className="mt-10">
|
||||
<div className="flex items-center justify-between">
|
||||
<h2 className="font-mono text-[11px] uppercase tracking-[0.14em] text-muted-foreground">{t({ en: "Order queue", sv: "Orderkö" })}</h2>
|
||||
{/* DoD §65: real anchor, not a JS-handler button — the download is a plain GET of the CSV endpoint. */}
|
||||
<a href="/api/orders/export" download className="border border-border px-3 py-1.5 font-mono text-[10px] uppercase tracking-[0.08em] text-muted-foreground transition-colors hover:bg-foreground hover:text-background">
|
||||
{t({ en: "Export CSV", sv: "Exportera CSV" })}
|
||||
</a>
|
||||
</div>
|
||||
<h2 className="font-mono text-[11px] uppercase tracking-[0.14em] text-muted-foreground">{t({ en: "Order queue", sv: "Orderkö" })}</h2>
|
||||
{orders.length === 0 ? (
|
||||
<div className="mt-6"><EmptyState title={t({ en: "Empty queue.", sv: "Tom kö." })} line={t({ en: "No orders yet.", sv: "Inga ordrar än." })} /></div>
|
||||
) : (
|
||||
@@ -134,14 +112,16 @@ export default function AdminPage() {
|
||||
<StatusPill status={o.status} />
|
||||
<span className="text-right font-mono text-[12px] tabular-nums">{formatSEK(o.total_ore / 100)}</span>
|
||||
<span className="text-right">
|
||||
<ActionGate action={o.advance_action} className="inline-block text-right">
|
||||
{NEXT_STATUS[o.status] ? (
|
||||
<button
|
||||
onClick={() => advance(o.order_id, o.status)}
|
||||
className="border border-foreground px-3 py-1.5 font-mono text-[10px] uppercase tracking-[0.08em] transition-colors hover:bg-foreground hover:text-background"
|
||||
>
|
||||
→ {nextOrderStatus(o.status) ?? t({ en: "done", sv: "klar" })}
|
||||
→ {NEXT_STATUS[o.status]}
|
||||
</button>
|
||||
</ActionGate>
|
||||
) : (
|
||||
<span className="font-mono text-[10px] uppercase tracking-[0.08em] text-muted-foreground">{t({ en: "done", sv: "klar" })}</span>
|
||||
)}
|
||||
</span>
|
||||
</div>
|
||||
))}
|
||||
|
||||
@@ -88,7 +88,7 @@ function ScreenTool() {
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
<p className="mt-3 text-[10.5px] text-muted-foreground">{t({ en: "Requires verified OpenSanctions terms/key for full matches.", sv: "Kräver verifierade OpenSanctions-villkor/nyckel för fullständiga träffar." })}</p>
|
||||
<p className="mt-3 text-[10.5px] text-muted-foreground/70">{t({ en: "Requires verified OpenSanctions terms/key for full matches.", sv: "Kräver verifierade OpenSanctions-villkor/nyckel för fullständiga träffar." })}</p>
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
/**
|
||||
* app/api/0pt/canonical/facts/route.ts
|
||||
* ====================================
|
||||
* POST — canonical structured-observation write (entities/facts/relations).
|
||||
* GET — tenant-scoped read for consumers (products, agents, L0RE projection).
|
||||
*
|
||||
* 0pt owns observed facts; L0RE owns epistemic propositions/projections and
|
||||
* consumes this API. Tenant is always cross-checked against the verified
|
||||
* principal (assertTenantMatchesVerified), never trusted from the body alone.
|
||||
*/
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { canonicalWriteSchema, parseBody } from "@/src/validation/0pt-schemas";
|
||||
import { canonicalFactService } from "@/src/services/canonical-fact-registry";
|
||||
import { siaxErrorResponse } from "@/src/http/siax-error-response";
|
||||
import { assertTenantMatchesVerified } from "@/src/http/tenant-guard";
|
||||
|
||||
export async function POST(request: NextRequest) {
|
||||
try {
|
||||
const parsed = parseBody(canonicalWriteSchema, await request.json());
|
||||
if (!parsed.ok) return NextResponse.json(parsed.body, { status: parsed.status });
|
||||
const body = parsed.data;
|
||||
const guard = assertTenantMatchesVerified(request, body.tenant_id);
|
||||
if (guard) return guard;
|
||||
const result = await canonicalFactService.write(body);
|
||||
return NextResponse.json(result, { status: 201 });
|
||||
} catch (error: unknown) {
|
||||
return siaxErrorResponse(error);
|
||||
}
|
||||
}
|
||||
|
||||
export async function GET(request: NextRequest) {
|
||||
try {
|
||||
const { searchParams } = new URL(request.url);
|
||||
const tenantId = searchParams.get("tenant_id");
|
||||
if (!tenantId) return NextResponse.json({ error: "tenant_id is required" }, { status: 400 });
|
||||
const guard = assertTenantMatchesVerified(request, tenantId);
|
||||
if (guard) return guard;
|
||||
const limitRaw = searchParams.get("limit");
|
||||
const facts = await canonicalFactService.query({
|
||||
tenant_id: tenantId,
|
||||
entity_id: searchParams.get("entity_id") ?? undefined,
|
||||
entity_type: searchParams.get("entity_type") ?? undefined,
|
||||
identity_namespace: searchParams.get("identity_namespace") ?? undefined,
|
||||
identity_value: searchParams.get("identity_value") ?? undefined,
|
||||
predicate: searchParams.get("predicate") ?? undefined,
|
||||
limit: limitRaw ? Number(limitRaw) : undefined,
|
||||
});
|
||||
return NextResponse.json({ facts });
|
||||
} catch (error: unknown) {
|
||||
return siaxErrorResponse(error);
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user