~ knotless Search/
↑↓ move↵ open⇧↵ all results

zat.dev/stream

jetstream v2 in zig · mirror of https://tangled.org/zat.dev/stream

0
0
88 lines · 3.5 KB Raw History
# .tangled/workflows/admission.yml — TRIGGER the gate; never run it here.
#
# This workflow used to run the whole 21-suite gate inside a microVM. It no
# longer does, for one reason: nothing stopped it from running concurrently
# with a gate started any other way. On 2026-08-09 two full gates ran on the
# same box at once (a microVM guest and a bare-metal run), pushing the worker
# cgroup past its memory.high 534,646 times and silently throttling both.
#
# The gate now has exactly one entry point: the `stream-admission` Prefect
# deployment, which carries concurrency_limit=1 (ENQUEUE). A second trigger
# queues behind the first instead of competing with it. Running the gate
# anywhere else re-opens the hole this closes.
#
# It also runs on bare metal there (32 cores, no VM tax): the lifecycle oracle
# took 2533s in the stock guest, 900s at 12 vCPU, ~420s native.
#
# Secret (repo settings): PREFECT_API_AUTH_STRING.

# A push runs this only when it touches something the binary, the image or the
# gate is built from. Site, docs and receipt commits do not: on 2026-11-13 nine
# site-only pushes each compiled RocksDB three times in ci.yml and started a
# bare-metal gate here, which saturated the CI host. The site ships with `just
# site` and is checked by site.yml.
when:
  - event: ["push"]
    branch: ["main"]
    paths:
      - "build.zig"
      - "build.zig.zon"
      - "Dockerfile"
      - ".dockerignore"
      - "justfile"
      - "src/**"
      - "tools/**"
      - "scripts/**"
      - "examples/**"
      - "tests/**/*.py"
      - "tests/fixtures/**"
      - "tests/upstream_oracle/**"
      - "tests/*.csv"
      - "tests/*.Dockerfile"
      - "deploy/ops/**"
      - "deploy/security/**"
      - "deploy/grafana/**"
      - "deploy/prometheus/**"
      - "strata/service/**"
      - ".tangled/workflows/admission.yml"
  - event: ["manual"]

engine: nixery

dependencies:
  nixpkgs:
    - curl
    - coreutils
    - python3
    - openssl
    - jq

steps:
  - name: trigger the bare-metal gate
    command: |
      set -euo pipefail
      python3 scripts/test-ci-public-ca.py
      ca_dir=$(mktemp -d)
      trap 'rm -rf "$ca_dir"' EXIT
      python3 scripts/ci-public-ca.py "${SSL_CERT_FILE:-/etc/ssl/certs/ca-bundle.crt}" "$ca_dir/ca-certificates.crt"
      export SSL_CERT_FILE="$ca_dir/ca-certificates.crt" SSL_CERT_DIR="$ca_dir" CURL_CA_BUNDLE="$ca_dir/ca-certificates.crt"
      PREFECT_API_URL=https://prefect-server.waow.tech/api
      : "${PREFECT_API_AUTH_STRING:?add the PREFECT_API_AUTH_STRING repo secret}"

      # create flow run FROM DEPLOYMENT: this is the endpoint that stamps the
      # work queue and sets state=Scheduled, which is what makes a worker pick
      # it up. POST /flow_runs/ would create an inert Pending run instead.
      auth=$(printf '%s' "$PREFECT_API_AUTH_STRING" | base64 -w0)
      deployment=$(curl --disable --proto '=https' -fsS \
        "$PREFECT_API_URL/deployments/name/stream-admission/stream-admission" \
        -H "Authorization: Basic $auth" | jq -er '.id')

      curl --disable --proto '=https' -fsS -X POST \
        "$PREFECT_API_URL/deployments/$deployment/create_flow_run" \
        -H "Authorization: Basic $auth" \
        -H 'Content-Type: application/json' \
        -d "{\"parameters\": {\"sha\": \"$TANGLED_COMMIT_SHA\", \"only\": [], \"skip\": [], \"build_image\": true},
             \"tags\": [\"spindle\", \"$TANGLED_COMMIT_SHA\"]}" \
        | head -c 400
      echo
      echo "queued; the gate is serialised by the deployment's concurrency limit"