lazily 0.55.0

Lazy reactive signals with dependency tracking and cache invalidation
Documentation
name: CI

on:
  push:
    branches:
      - main
  pull_request:
  workflow_dispatch:

env:
  CARGO_TERM_COLOR: always

jobs:
  test:
    name: Rust
    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Install Rust stable
        run: rustup toolchain install stable --profile minimal --component clippy --component rustfmt

      - name: Check formatting
        run: cargo +stable fmt --all --check

      - name: Clippy
        run: cargo +stable clippy --locked --all-targets --all-features -- -D warnings

      - name: Build
        run: cargo +stable build --locked --all-targets --all-features

      # lazily-spec is the canonical cross-language wire-protocol source. Clone
      # it as a sibling BEFORE any feature-test step so every test target that
      # reads ../lazily-spec (conformance, collections_conformance,
      # seqcrdt_conformance, schema_compliance) has the canonical fixtures — CI
      # then validates lazily-rs against canonical fixtures and fails on drift
      # (#lzspecconf).
      - name: Fetch canonical lazily-spec conformance fixtures (#lzspecconf)
        run: git clone --depth 1 https://github.com/lazily-hub/lazily-spec.git ../lazily-spec

      - name: Test default features
        run: cargo +stable test --locked

      - name: Test thread-safe feature (#lzthreadsafe)
        run: cargo +stable test --locked --features thread-safe

      - name: Test Tokio feature
        run: cargo +stable test --locked --features "tokio thread-safe"

      - name: Test distributed feature
        run: cargo +stable test --locked --features "distributed serde"

      - name: Test distributed CRDT plane runtime integration (#lzcrdtplane5b)
        run: cargo +stable test --locked --features "distributed webrtc"

      - name: Test signaling client feature
        run: cargo +stable test --locked --features signaling-client

      - name: Test async feature
        run: cargo +stable test --locked --features async

      - name: Test WebRTC DataChannel transport + str0m backend (#webrtcbackend)
        run: cargo +stable test --locked --features webrtc-str0m

      - name: Test WebSocket DataChannel backend (#akp3)
        run: cargo +stable test --locked --features websocket

      - name: Test async resolve-loop windows (#k03k)
        run: cargo +stable test --locked --features "async instrumentation" --test async_resolve_loop

      - name: Test demand-driven reader-kinds + store-without-cascade (Phase 0 #relaycell)
        run: cargo +stable test --locked --features instrumentation --test queue_demand_driven

      - name: Test IPC conformance against canonical spec fixtures (#lzspecconf)
        run: |
          test -d ../lazily-spec/conformance || { echo "::error::../lazily-spec/conformance missing — conformance.rs would silently fall back to local fixtures"; exit 1; }
          cargo +stable test --locked --features ipc --test conformance

      - name: Test JSON Schema compliance against canonical spec schemas (#lzspecschema)
        run: |
          test -d ../lazily-spec/schemas || { echo "::error::../lazily-spec/schemas missing"; exit 1; }
          cargo +stable test --locked --features ipc --test schema_compliance

      - name: Test keyed cell collections conformance against canonical spec fixtures (#lzcellfamily)
        run: |
          test -d ../lazily-spec/conformance/collections || { echo "::error::../lazily-spec/conformance/collections missing — collections_conformance.rs would silently fall back to local fixtures"; exit 1; }
          cargo +stable test --locked --test collections_conformance

      - name: Test reactive-graph disposal/teardown conformance against canonical spec fixtures (#lzspecedgeindex)
        run: |
          test -d ../lazily-spec/conformance/reactive-graph || { echo "::error::../lazily-spec/conformance/reactive-graph missing — reactive_graph_conformance.rs would silently skip the whole disposal/teardown corpus"; exit 1; }
          # The corpus is parameterised over the execution model, and the
          # ThreadSafeContext / AsyncContext models are feature-gated. Running
          # only the default-feature test would silently drop two thirds of the
          # coverage, which is the exact failure mode this corpus exists to kill.
          cargo +stable test --locked --test reactive_graph_conformance
          cargo +stable test --locked --features thread-safe --test reactive_graph_conformance
          cargo +stable test --locked --features async --test reactive_graph_conformance
          # Assert all three models actually ran, rather than trusting a green tick.
          cargo +stable test --locked --features "thread-safe async" --test reactive_graph_conformance -- --nocapture 2>&1 | tee /tmp/rg.log
          # Derive the expected count from the corpus rather than hardcoding it.
          # A literal went stale the moment lazily-spec grew a fixture, and the
          # failure reads as "the corpus did not replay" — which points at the
          # runner rather than at this guard. Deriving keeps the assertion exact
          # (not a >=N floor, which would let a silently-skipped fixture pass)
          # while surviving upstream additions.
          #
          # Every fixture must be ACCOUNTED FOR, which is not the same as replayed:
          # a model may declare a runner limitation in the MODEL_SKIPS ledger, and
          # the runner prints one `SKIP reactive-graph[<model>] <fixture>` line per
          # entry. Those are named and asserted in both directions by the test, so
          # they are the opposite of the silent skip this guard exists to catch —
          # but they are not replays, so they are counted separately. What must
          # hold exactly is replayed + declared-skips == corpus.
          expected=$(ls ../lazily-spec/conformance/reactive-graph/*.json | wc -l)
          test "$expected" -gt 0 || { echo "::error::no reactive-graph fixtures found — the corpus is empty or the path is wrong"; exit 1; }
          for model in Context ThreadSafeContext AsyncContext; do
            replayed=$(sed -n "s/^reactive-graph\[$model\]: \([0-9]\+\) fixtures.*/\1/p" /tmp/rg.log | tail -1)
            test -n "$replayed" || { echo "::error::reactive-graph corpus did not report a summary line for $model — the model never ran"; exit 1; }
            skipped=$(grep -c "^SKIP reactive-graph\[$model\] " /tmp/rg.log || true)
            test "$((replayed + skipped))" -eq "$expected" || { echo "::error::reactive-graph corpus accounted for $replayed replayed + $skipped declared-skipped = $((replayed + skipped)) of $expected fixtures against $model"; exit 1; }
          done

      - name: Test SeqCrdt conformance against canonical spec fixtures (#lzseqcrdt)
        run: |
          test -f ../lazily-spec/conformance/collections/seqcrdt_convergence.json || { echo "::error::seqcrdt_convergence.json missing — seqcrdt_conformance.rs cannot run"; exit 1; }
          cargo +stable test --locked --features distributed --test seqcrdt_conformance

      - name: Test loom model
        run: cargo +stable test --locked --features loom --test thread_safe_loom

  signaling:
    name: Signaling Worker (#yxjw)
    runs-on: ubuntu-latest
    defaults:
      run:
        working-directory: signaling
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Set up Node
        uses: actions/setup-node@v4
        with:
          node-version: "20"

      - name: Install
        run: npm ci

      - name: Typecheck + test
        run: npm run check

  lean:
    name: Lean formal models (#lzleanmodel, #lzformal)
    runs-on: ubuntu-latest
    steps:
      - name: Checkout canonical lazily-spec
        uses: actions/checkout@v4
        with:
          repository: lazily-hub/lazily-spec
          path: lazily-spec

      - name: Build lazily-spec Lean formal model (#lzleanmodel)
        uses: leanprover/lean-action@v1
        with:
          lake-package-directory: lazily-spec/formal/lean
          auto-config: false
          build: true
          test: false
          lint: false

      - name: Checkout canonical lazily-formal
        uses: actions/checkout@v4
        with:
          repository: lazily-hub/lazily-formal
          path: lazily-formal

      - name: Build lazily-formal Lean model (#lzformal)
        uses: leanprover/lean-action@v1
        with:
          lake-package-directory: lazily-formal
          auto-config: false
          build: true
          test: false
          lint: false