prism-inference 0.1.21

Bounded Rust CPU inference and tokenization for Prism-compatible GGUF models
name: Runtime regression
on:
  push:
    branches: [main]
    paths-ignore:
      - '*.md'
      - 'docs/**'
      - '.rumdl.toml'
      - '.github/workflows/markdown.yml'
      - 'server/**'
      - 'tools/rust-trial/**'
      - 'tools/conformance-policy/**'
      - 'tools/validation/**'
      - 'scripts/New-ReleaseBundle.ps1'
      - 'tests/Test-ReleaseBundle.ps1'
      - 'tests/Test-RustNightly.ps1'
      - 'config/rust-nightly-trial.json'
  workflow_dispatch:
permissions:
  contents: read
  actions: read
env:
  CARGO_UNSTABLE_CHECKSUM_FRESHNESS: 'true'
  CARGO_BUILD_FINGERPRINT: content
concurrency:
  group: runtime-regression-${{ github.ref }}-${{ github.event_name == 'push' && 'latest' || github.run_id }}
  cancel-in-progress: ${{ github.event_name == 'push' }}
jobs:
  changes:
    if: github.ref == 'refs/heads/main'
    runs-on: ubuntu-24.04-arm
    timeout-minutes: 5
    outputs:
      plan: ${{ steps.impact.outputs.plan }}
      conformance: ${{ steps.impact.outputs.conformance }}
      codec: ${{ steps.impact.outputs.codec }}
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          persist-credentials: false
          fetch-depth: 0
      - name: Verify affected-crate selection and aggregate-gate contracts
        shell: bash
        run: python3 -B -m unittest discover -s .github/ci -p 'test_*.py'
      - name: Select affected runtime conformance groups
        id: impact
        shell: bash
        env:
          BEFORE: ${{ github.event.before }}
          GITHUB_TOKEN: ${{ github.token }}
        run: python3 .github/ci/impact.py --before "$BEFORE" --after "$GITHUB_SHA" --workflow runtime-regression.yml
  rust-regression:
    if: github.ref == 'refs/heads/main' && needs.changes.outputs.conformance == 'true'
    needs: changes
    runs-on: windows-11-arm
    timeout-minutes: 10
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          persist-credentials: false
      - uses: ./.github/actions/rust-toolchain
        with:
          toolchain: nightly-2026-10-22-aarch64-pc-windows-msvc
      - name: Identify native regression build storage
        shell: pwsh
        run: |

          if (-not $IsWindows -or [Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture -ne 'Arm64') { throw 'Runtime regression requires native Windows ARM64.' }
          "PRISM_REGRESSION_HOST=$env:ImageOS-$env:ImageVersion-$([Environment]::OSVersion.Version)" >> $env:GITHUB_ENV
          "CARGO_TARGET_DIR=$(Join-Path $env:RUNNER_TEMP 'Prism-RuntimeRegressionTarget')" >> $env:GITHUB_ENV
      - name: Reuse the bounded regression compiler cache
        uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
        with:
          path: |

            ~/.cargo/registry/index
            ~/.cargo/registry/cache
            ${{ env.CARGO_TARGET_DIR }}
          key: prism-regression-v1-${{ runner.os }}-${{ runner.arch }}-${{ env.PRISM_REGRESSION_HOST }}-nightly-2026-10-22-${{ hashFiles('Cargo.toml', 'Cargo.lock', 'rust-toolchain.toml', '.cargo/**', 'src/**', 'tools/ternary/**', 'tools/gguf/**', 'tools/native-hash/**', 'tools/prism/**', 'tests/upstream_prism/**', 'tests/fixtures/**') }}-content-v1
          restore-keys: |

            prism-regression-v1-${{ runner.os }}-${{ runner.arch }}-${{ env.PRISM_REGRESSION_HOST }}-nightly-2026-10-22-
      - name: Build this revision's Rust source assertion harness
        shell: pwsh
        run: |

          $ErrorActionPreference = 'Stop'
          $PSNativeCommandUseErrorActionPreference = $true
          cargo +nightly-2026-10-22-aarch64-pc-windows-msvc build --locked --release --package prism-inference --example upstream_prism
      - name: Require every selected runtime regression
        shell: pwsh
        working-directory: ${{ runner.temp }}
        run: |

          $ErrorActionPreference = 'Stop'
          $PSNativeCommandUseErrorActionPreference = $true
          python -B (Join-Path $env:GITHUB_WORKSPACE '.github/ci/runtime_regression.py') --harness (Join-Path $env:CARGO_TARGET_DIR 'release/examples/upstream_prism.exe') --evidence (Join-Path $env:RUNNER_TEMP 'Prism-RuntimeRegression')
      - name: Retain compact regression results and failure logs
        if: always()
        uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
        with:
          name: prism-runtime-regression-${{ github.sha }}-${{ github.run_id }}
          path: ${{ runner.temp }}/Prism-RuntimeRegression
          if-no-files-found: error
          retention-days: 7
  codec-native:
    if: github.ref == 'refs/heads/main' && needs.changes.outputs.codec == 'true'
    needs: changes
    runs-on: windows-11-arm
    timeout-minutes: 15
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          persist-credentials: false
      - uses: ./.github/actions/rust-toolchain
        with:
          toolchain: nightly-2026-10-22-aarch64-pc-windows-msvc
      - name: Reuse the immutable released runtime archive
        uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
        with:
          path: ${{ runner.temp }}/Prism-CodecDownloads
          key: prism-codec-download-v1-${{ runner.os }}-${{ hashFiles('tools/codec-probe/native.lock.json') }}
      - name: Reuse native codec probe compiler artifacts
        uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
        with:
          path: |

            ~/.cargo/registry/index
            ~/.cargo/registry/cache
            ${{ runner.temp }}/Prism-CodecTarget
          key: prism-codec-v1-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('Cargo.toml', 'Cargo.lock', 'tools/codec-probe/**', 'tools/ternary/**', 'rust-toolchain.toml') }}-content-v1
          restore-keys: |

            prism-codec-v1-${{ runner.os }}-${{ runner.arch }}-
      - name: Check the probe and consume every preserved synthetic native codec input
        shell: pwsh
        working-directory: ${{ runner.temp }}
        run: |

          Set-StrictMode -Version Latest
          $ErrorActionPreference = 'Stop'
          $PSNativeCommandUseErrorActionPreference = $true
          if (-not $IsWindows -or [Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture -ne 'Arm64') { throw 'Native codec acceptance requires Windows ARM64.' }
          $checks = Join-Path $env:RUNNER_TEMP ('Prism-CodecChecks-' + [guid]::NewGuid().ToString('N'))
          "PRISM_CODEC_EVIDENCE=$checks" >> $env:GITHUB_ENV
          [void][IO.Directory]::CreateDirectory($checks)
          $target = Join-Path $env:RUNNER_TEMP 'Prism-CodecTarget'
          $manifest = Join-Path $env:GITHUB_WORKSPACE 'Cargo.toml'
          Start-Transcript -LiteralPath (Join-Path $checks 'codec-workflow.log') | Out-Null
          try {
            cargo +nightly-2026-10-22-aarch64-pc-windows-msvc fetch --manifest-path $manifest --locked
            & (Join-Path $env:GITHUB_WORKSPACE 'tests/Test-Rust.ps1') -Package bonsai-codec-probe -Phase build -TargetDirectory $target -EvidenceDirectory (Join-Path $checks 'rust') -Offline | ConvertTo-Json -Depth 8
            Import-Module (Join-Path $env:GITHUB_WORKSPACE 'scripts/Bonsai.Common.psm1')
            $lock = Get-Content -LiteralPath (Join-Path $env:GITHUB_WORKSPACE 'tools/codec-probe/native.lock.json') -Raw | ConvertFrom-Json
            $downloads = Join-Path $env:RUNNER_TEMP 'Prism-CodecDownloads'
            [void][IO.Directory]::CreateDirectory($downloads)
            $archive = Join-Path $downloads $lock.Runtime.asset.filename
            $null = Receive-LockedArtifact -Uri $lock.Runtime.asset.url -Path $archive -Bytes $lock.Runtime.asset.bytes -Sha256 $lock.Runtime.asset.sha256 -TimeoutSeconds 600
            & (Join-Path $env:GITHUB_WORKSPACE 'tests/Test-PrismCodec.ps1') -RuntimeArchive $archive -ProbeToolPath (Join-Path $target 'release/bonsai-codec-probe.exe') -EvidenceDirectory (Join-Path $checks 'native')
          } finally { Stop-Transcript | Out-Null }
      - name: Retain codec corpus, ABI, package and process receipts
        if: always() && env.PRISM_CODEC_EVIDENCE != ''
        uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
        with:
          name: prism-native-codec-${{ github.sha }}-${{ github.run_id }}
          path: |

            ${{ env.PRISM_CODEC_EVIDENCE }}/*.log
            ${{ env.PRISM_CODEC_EVIDENCE }}/rust
            ${{ env.PRISM_CODEC_EVIDENCE }}/native/*.json
            ${{ env.PRISM_CODEC_EVIDENCE }}/native/*.log
            ${{ env.PRISM_CODEC_EVIDENCE }}/native/*.stdout
            ${{ env.PRISM_CODEC_EVIDENCE }}/native/*.stderr
          if-no-files-found: error
  runtime-regression:
    if: always() && github.ref == 'refs/heads/main'
    needs: [changes, rust-regression, codec-native]
    runs-on: ubuntu-24.04-arm
    timeout-minutes: 2
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          persist-credentials: false
      - name: Require all selected regression jobs
        shell: bash
        env:
          CI_NEEDS: ${{ toJSON(needs) }}
        run: python3 .github/ci/gate.py --workflow runtime-regression