Skip to content

Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.

ci: unify smoke/soak/test venues onto canonical leg entries

Martin Vogel3fc93d12da71
diff --git a/.github/workflows/_smoke.yml b/.github/workflows/_smoke.yml
index c635ebd4a..1ef35f101 100644
--- a/.github/workflows/_smoke.yml
+++ b/.github/workflows/_smoke.yml
@@ -100,58 +100,40 @@ jobs:
with:
name: binaries-${{ matrix.goos }}-${{ matrix.goarch }}
- - name: Extract binary
+ - name: Extract release artifact
run: |
SUFFIX=${{ matrix.variant == 'ui' && '-ui' || '' }}
- tar -xzf codebase-memory-mcp${SUFFIX}-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz
- chmod +x codebase-memory-mcp
+ mkdir -p "$RUNNER_TEMP/cbm-artifact"
+ tar -xzf codebase-memory-mcp${SUFFIX}-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz \
+ -C "$RUNNER_TEMP/cbm-artifact"
+ chmod +x "$RUNNER_TEMP/cbm-artifact/codebase-memory-mcp"
- - name: Start artifact server
+ # ONE harness for every venue. This is the same wrapper local CI and PR CI
+ # run, handed the DOWNLOADED artifact instead of a local build: it stages
+ # the release fixture, serves it on a kernel-assigned port, and runs
+ # smoke-test.sh under the isolated profile/TEMP the other venues use.
+ # It replaces an inline copy of that staging logic which had drifted from
+ # the wrapper (no env isolation, no user-PATH guard, fixed port).
+ - name: Smoke test (shared wrapper)
run: |
- mkdir -p /tmp/smoke-server
- cp codebase-memory-mcp /tmp/smoke-server/
- OS=${{ matrix.goos }}; ARCH=${{ matrix.goarch }}
- SUFFIX=${{ matrix.variant == 'ui' && '-ui' || '' }}
- tar -czf "/tmp/smoke-server/codebase-memory-mcp${SUFFIX}-${OS}-${ARCH}.tar.gz" \
- -C /tmp/smoke-server codebase-memory-mcp
- if [ -n "$SUFFIX" ]; then
- cp "/tmp/smoke-server/codebase-memory-mcp${SUFFIX}-${OS}-${ARCH}.tar.gz" \
- "/tmp/smoke-server/codebase-memory-mcp-${OS}-${ARCH}.tar.gz"
- fi
- # The linux binary self-updates from the fully-static "-portable" asset
- # (build_update_url in src/cli/cli.c appends -portable on linux; _build.yml's
- # build-linux-portable job ships it), so the smoke server must serve that name
- # too -- otherwise `update` 404s and Phase 14 fails. Mirror the tarball(s) under
- # the -portable name on linux only.
- if [ "$OS" = "linux" ]; then
- cp "/tmp/smoke-server/codebase-memory-mcp${SUFFIX}-${OS}-${ARCH}.tar.gz" \
- "/tmp/smoke-server/codebase-memory-mcp${SUFFIX}-${OS}-${ARCH}-portable.tar.gz"
- if [ -n "$SUFFIX" ]; then
- cp "/tmp/smoke-server/codebase-memory-mcp${SUFFIX}-${OS}-${ARCH}-portable.tar.gz" \
- "/tmp/smoke-server/codebase-memory-mcp-${OS}-${ARCH}-portable.tar.gz"
- fi
- fi
- cd /tmp/smoke-server
- sha256sum *.tar.gz > checksums.txt 2>/dev/null || shasum -a 256 *.tar.gz > checksums.txt
- python3 -m http.server 18080 -d /tmp/smoke-server &
-
- - name: Smoke test
- run: scripts/smoke-test.sh ./codebase-memory-mcp
+ scripts/smoke-local.sh \
+ "$RUNNER_TEMP/cbm-artifact/codebase-memory-mcp" ${{ matrix.variant }}
env:
- SMOKE_DOWNLOAD_URL: http://localhost:18080
- SMOKE_UPDATE_FIXTURE_DIR: /tmp/smoke-server
+ CBM_SMOKE_ARTIFACT_DIR: ${{ runner.temp }}/cbm-artifact
- name: Security audits
run: |
- scripts/security-strings.sh ./codebase-memory-mcp
- scripts/security-install.sh ./codebase-memory-mcp
- scripts/security-network.sh ./codebase-memory-mcp
+ BIN="$RUNNER_TEMP/cbm-artifact/codebase-memory-mcp"
+ scripts/security-strings.sh "$BIN"
+ scripts/security-install.sh "$BIN"
+ scripts/security-network.sh "$BIN"
- name: MCP robustness test (linux-amd64 standard only)
if: matrix.variant == 'standard' && matrix.goos == 'linux' && matrix.goarch == 'amd64'
run: |
- scripts/security-fuzz.sh ./codebase-memory-mcp
- scripts/security-fuzz-random.sh ./codebase-memory-mcp 60
+ BIN="$RUNNER_TEMP/cbm-artifact/codebase-memory-mcp"
+ scripts/security-fuzz.sh "$BIN"
+ scripts/security-fuzz-random.sh "$BIN" 60
- name: ClamAV scan (Linux)
if: startsWith(matrix.os, 'ubuntu')
@@ -165,7 +147,7 @@ jobs:
grep -q "DatabaseMirror" /etc/clamav/freshclam.conf 2>/dev/null || \
echo "DatabaseMirror database.clamav.net" | sudo tee -a /etc/clamav/freshclam.conf > /dev/null
sudo freshclam --quiet
- clamscan --no-summary ./codebase-memory-mcp
+ clamscan --no-summary "$RUNNER_TEMP/cbm-artifact/codebase-memory-mcp"
- name: ClamAV scan (macOS)
if: startsWith(matrix.os, 'macos')
@@ -178,7 +160,7 @@ jobs:
echo "DatabaseMirror database.clamav.net" >> "$CLAMAV_ETC/freshclam.conf"
fi
freshclam --quiet --no-warnings 2>/dev/null || freshclam --quiet 2>/dev/null || echo "WARNING: freshclam update failed"
- clamscan --no-summary ./codebase-memory-mcp
+ clamscan --no-summary "$RUNNER_TEMP/cbm-artifact/codebase-memory-mcp"
smoke-windows:
needs: setup-matrix
@@ -205,66 +187,53 @@ jobs:
with:
name: binaries-windows-${{ matrix.arch }}
- - name: Extract binary
+ - name: Extract release artifact
shell: msys2 {0}
run: |
SUFFIX=${{ matrix.variant == 'ui' && '-ui' || '' }}
ARCH=${{ matrix.arch }}
- unzip -o "codebase-memory-mcp${SUFFIX}-windows-${ARCH}.zip"
- test -s codebase-memory-mcp.exe
- test -s codebase-memory-mcp.payload.exe
+ ARTIFACT_DIR="$(cygpath -u "$RUNNER_TEMP")/cbm-artifact"
+ mkdir -p "$ARTIFACT_DIR"
+ unzip -o "codebase-memory-mcp${SUFFIX}-windows-${ARCH}.zip" -d "$ARTIFACT_DIR"
+ test -s "$ARTIFACT_DIR/codebase-memory-mcp.exe"
+ test -s "$ARTIFACT_DIR/codebase-memory-mcp.payload.exe"
+ # Pre-flight both images from a profile-rooted directory: the shared
+ # runner workspace is deliberately not a valid launcher bundle root.
PROFILE_ROOT="$(cygpath -u "$USERPROFILE")"
LAUNCH_DIR="$(mktemp -d "$PROFILE_ROOT/cbm-release-version.XXXXXX")"
trap 'rm -rf "$LAUNCH_DIR"' EXIT
- cp codebase-memory-mcp.exe codebase-memory-mcp.payload.exe "$LAUNCH_DIR/"
+ cp "$ARTIFACT_DIR/codebase-memory-mcp.exe" \
+ "$ARTIFACT_DIR/codebase-memory-mcp.payload.exe" "$LAUNCH_DIR/"
"$LAUNCH_DIR/codebase-memory-mcp.payload.exe" --version
"$LAUNCH_DIR/codebase-memory-mcp.exe" --version
- - name: Start artifact server
- shell: msys2 {0}
- run: |
- mkdir -p /tmp/smoke-server
- cp codebase-memory-mcp.exe codebase-memory-mcp.payload.exe \
- LICENSE install.ps1 THIRD_PARTY_NOTICES.md /tmp/smoke-server/
- SUFFIX=${{ matrix.variant == 'ui' && '-ui' || '' }}
- ARCH=${{ matrix.arch }}
- cd /tmp/smoke-server
- zip -q "codebase-memory-mcp${SUFFIX}-windows-${ARCH}.zip" \
- codebase-memory-mcp.exe codebase-memory-mcp.payload.exe \
- LICENSE install.ps1 THIRD_PARTY_NOTICES.md
- if [ -n "$SUFFIX" ]; then
- cp "codebase-memory-mcp${SUFFIX}-windows-${ARCH}.zip" "codebase-memory-mcp-windows-${ARCH}.zip"
- fi
- sha256sum *.zip > checksums.txt
- # Pin to explicit IPv4: on windows-11-arm, `localhost` resolves to ::1 (IPv6)
- # for msys2 curl while python's http.server is IPv4-only -> instant connect
- # failure in smoke Phase 12a. --bind 127.0.0.1 + a 127.0.0.1 URL pin both ends.
- python3 -m http.server 18080 --bind 127.0.0.1 -d /tmp/smoke-server &
-
- - name: Smoke test
+ # ONE harness for every venue: the same script win.sh smoke-install and
+ # pr.yml run, handed the DOWNLOADED artifact instead of a local build. It
+ # stages the release fixture under a disposable profile root, serves it on
+ # a kernel-assigned port, guards AND verifies the user-PATH registry
+ # mutation, and neutralizes every agent-config destination before running
+ # smoke-test.sh. It replaces an inline copy of that staging which had none
+ # of the isolation and never verified the PATH mutation it performed.
+ - name: Smoke test (shared wrapper)
shell: msys2 {0}
- run: |
- PROFILE_ROOT="$(cygpath -u "$USERPROFILE")"
- SMOKE_DIR="$(mktemp -d "$PROFILE_ROOT/cbm-release-smoke.XXXXXX")"
- trap 'rm -rf "$SMOKE_DIR"' EXIT
- cp codebase-memory-mcp.exe codebase-memory-mcp.payload.exe "$SMOKE_DIR/"
- CBM_CACHE_DIR="$(cygpath -m "$SMOKE_DIR/cache")" \
- SMOKE_TEMP_ROOT="$SMOKE_DIR" \
- scripts/smoke-test.sh "$SMOKE_DIR/codebase-memory-mcp.exe"
env:
- SMOKE_DOWNLOAD_URL: http://127.0.0.1:18080
- SMOKE_UPDATE_FIXTURE_DIR: /tmp/smoke-server
SMOKE_ARCH: ${{ matrix.arch }}
+ SMOKE_VARIANT: ${{ matrix.variant }}
+ run: |
+ export CBM_SMOKE_ARTIFACT_DIR="$(cygpath -u "$RUNNER_TEMP")/cbm-artifact"
+ bash test-infrastructure/vm/vm-smoke.sh
- name: Security audits
shell: msys2 {0}
run: |
- scripts/security-strings.sh ./codebase-memory-mcp.exe
- scripts/security-strings.sh ./codebase-memory-mcp.payload.exe
+ ARTIFACT_DIR="$(cygpath -u "$RUNNER_TEMP")/cbm-artifact"
+ scripts/security-strings.sh "$ARTIFACT_DIR/codebase-memory-mcp.exe"
+ scripts/security-strings.sh "$ARTIFACT_DIR/codebase-memory-mcp.payload.exe"
PROFILE_ROOT="$(cygpath -u "$USERPROFILE")"
SECURITY_DIR="$(mktemp -d "$PROFILE_ROOT/cbm-release-security.XXXXXX")"
trap 'rm -rf "$SECURITY_DIR"' EXIT
- cp codebase-memory-mcp.exe codebase-memory-mcp.payload.exe "$SECURITY_DIR/"
+ cp "$ARTIFACT_DIR/codebase-memory-mcp.exe" \
+ "$ARTIFACT_DIR/codebase-memory-mcp.payload.exe" "$SECURITY_DIR/"
TMPDIR="$SECURITY_DIR" \
scripts/security-install.sh "$SECURITY_DIR/codebase-memory-mcp.exe"
@@ -272,8 +241,9 @@ jobs:
shell: pwsh
run: |
& "C:\Program Files\Windows Defender\MpCmdRun.exe" -SignatureUpdate 2>$null
+ $artifactDir = Join-Path $env:RUNNER_TEMP "cbm-artifact"
foreach ($binary in @("codebase-memory-mcp.exe", "codebase-memory-mcp.payload.exe")) {
- $result = & "C:\Program Files\Windows Defender\MpCmdRun.exe" -Scan -ScanType 3 -File "$PWD\$binary" -DisableRemediation
+ $result = & "C:\Program Files\Windows Defender\MpCmdRun.exe" -Scan -ScanType 3 -File (Join-Path $artifactDir $binary) -DisableRemediation
$code = $LASTEXITCODE
Write-Host $result
# MpCmdRun -Scan exit codes: 0 = clean, 2 = threat found. Any OTHER non-zero
@@ -304,25 +274,39 @@ jobs:
with:
name: binaries-linux-${{ matrix.arch }}-portable
- - name: Extract and smoke test
+ - name: Extract release artifact
run: |
SUFFIX=${{ matrix.variant == 'ui' && '-ui' || '' }}
- tar -xzf codebase-memory-mcp${SUFFIX}-linux-${{ matrix.arch }}-portable.tar.gz
- chmod +x codebase-memory-mcp
- scripts/smoke-test.sh ./codebase-memory-mcp
+ mkdir -p "$RUNNER_TEMP/cbm-artifact"
+ tar -xzf codebase-memory-mcp${SUFFIX}-linux-${{ matrix.arch }}-portable.tar.gz \
+ -C "$RUNNER_TEMP/cbm-artifact"
+ chmod +x "$RUNNER_TEMP/cbm-artifact/codebase-memory-mcp"
+
+ # Same wrapper as every other venue. This leg previously called
+ # smoke-test.sh with no fixture server, which silently SKIPPED the
+ # download/checksum/install-script phases (12-13) — the portable binary is
+ # what every linux install and update actually delivers, so those are
+ # exactly the phases it most needs to run.
+ - name: Smoke test (shared wrapper)
+ run: |
+ scripts/smoke-local.sh \
+ "$RUNNER_TEMP/cbm-artifact/codebase-memory-mcp" ${{ matrix.variant }}
+ env:
+ CBM_SMOKE_ARTIFACT_DIR: ${{ runner.temp }}/cbm-artifact
# The -portable binary is what all linux install/update paths now deliver;
# it MUST start on old glibc (Debian 11 / RHEL 8 / Ubuntu 20.04). Runs it
# in debian:bullseye (glibc 2.31) — the standard dynamic binary would fail
# here with `GLIBC_2.38 not found`.
- name: Old-glibc compatibility
- run: scripts/ci/check-glibc-compat.sh ./codebase-memory-mcp
+ run: scripts/ci/check-glibc-compat.sh "$RUNNER_TEMP/cbm-artifact/codebase-memory-mcp"
- name: Security audits
run: |
- scripts/security-strings.sh ./codebase-memory-mcp
- scripts/security-install.sh ./codebase-memory-mcp
- scripts/security-network.sh ./codebase-memory-mcp
+ BIN="$RUNNER_TEMP/cbm-artifact/codebase-memory-mcp"
+ scripts/security-strings.sh "$BIN"
+ scripts/security-install.sh "$BIN"
+ scripts/security-network.sh "$BIN"
# ── Packaging check (non-gating) ──────────────────────────────────
# Builds pkg/glama/Dockerfile — the image Glama builds to score the
diff --git a/.github/workflows/_soak.yml b/.github/workflows/_soak.yml
index 7d7a1d4b5..7c1ed16f3 100644
--- a/.github/workflows/_soak.yml
+++ b/.github/workflows/_soak.yml
@@ -5,9 +5,13 @@ on:
workflow_call:
inputs:
duration_minutes:
- description: 'Soak duration in minutes'
+ description: 'Soak duration in minutes (per leg)'
type: number
default: 10
+ legs:
+ description: "Soak legs for the quick jobs, passed to scripts/soak-legs.sh --legs (e.g. 'quick,query-leak' or 'query-leak' for a long #581-only run)"
+ type: string
+ default: 'quick,query-leak'
run_asan:
description: 'Run ASan soak in addition to quick soak'
type: boolean
@@ -47,12 +51,13 @@ jobs:
cc: cc
cxx: c++
runs-on: ${{ matrix.os }}
- # BUG FIX: this was hard-coded to 30, but the caller (nightly-soak.yml)
- # passes duration_minutes: 240. GitHub killed the job at 30 min, so the
- # "4h nightly soak" was SILENTLY TRUNCATED to 30 min and never once ran
- # multi-hour. Budget must always exceed the passed duration; 300 covers
- # the 240-min nightly with headroom (build + analysis + idle phases).
- timeout-minutes: 300
+ # Budget doctrine (this line has been silently violated TWICE): the job
+ # timeout must exceed the WORST-CASE run length, and duration_minutes is
+ # per LEG. Two 240-min legs (the nightly) need ~480 min + build + analysis;
+ # the previous 300 silently killed the second leg at the timeout — the same
+ # truncation class as the original hard-coded 30. Keep a literal (the
+ # inputs context is not reliably available at job-setup time): 560.
+ timeout-minutes: 560
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Install deps (Linux)
@@ -60,15 +65,11 @@ jobs:
run: sudo apt-get update && sudo apt-get install -y zlib1g-dev python3 git
- name: Build
run: scripts/build.sh ${{ inputs.version && format('--version {0}', inputs.version) || '' }} CC=${{ matrix.cc }} CXX=${{ matrix.cxx }}
- - name: Soak (${{ inputs.duration_minutes }} min)
- run: scripts/soak-test.sh build/c/codebase-memory-mcp ${{ inputs.duration_minutes }}
- # #581 guard: read-only soak (never reindex/mutate) so any memory growth is
- # a query-path leak, not WAL/indexing. Reuses the build above.
- - name: Query-leak soak (#581, read-only)
- env:
- CBM_SOAK_MODE: query-leak
- RESULTS_DIR: soak-results-query-leak
- run: scripts/soak-test.sh build/c/codebase-memory-mcp ${{ inputs.duration_minutes }} --skip-crash-test
+ # The soak SEQUENCE and its guards live in the ONE canonical entry
+ # scripts/soak-legs.sh — never in workflow YAML. Leg selection is a
+ # workflow input so a long #581-only run needs no separate workflow.
+ - name: Soak legs (${{ inputs.legs }}, ${{ inputs.duration_minutes }} min each)
+ run: scripts/soak-legs.sh --legs "${{ inputs.legs }}" build/c/codebase-memory-mcp ${{ inputs.duration_minutes }}
- name: Upload metrics
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
@@ -86,10 +87,9 @@ jobs:
soak-quick-windows:
runs-on: windows-latest
- # BUG FIX (same 30→240 mismatch as soak-quick above): the caller passes
- # duration_minutes: 240, so a 30-min cap truncated the nightly soak here
- # too. 300 covers the 240-min nightly with headroom.
- timeout-minutes: 300
+ # Budget doctrine (see soak-quick): duration_minutes is per LEG, so two
+ # 240-min legs need ~480 min + build; 300 silently killed the second leg.
+ timeout-minutes: 560
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- uses: msys2/setup-msys2@66cd2cce69caa17b53920067426061ca1de3a884 # v2
@@ -103,25 +103,28 @@ jobs:
make
git
coreutils
+ # Same protected root the test legs and the VM soak use. Without it the
+ # soak ran under the runner's inherited LocalAppData\Temp ACLs while the
+ # local soak ran hardened — the two venues were soaking different shapes.
+ - name: Create protected per-user temp root
+ shell: pwsh
+ run: |
+ $root = & scripts/ci/new-protected-temp-root.ps1 `
+ -Prefix 'cbm-ci-tmp-' `
+ -ProtectDir (Join-Path $env:GITHUB_WORKSPACE "build\c")
+ "CBM_CI_TEMP_ROOT=$root" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
- name: Build
shell: msys2 {0}
run: scripts/build.sh ${{ inputs.version && format('--version {0}', inputs.version) || '' }} CC=clang CXX=clang++
- - name: Soak (${{ inputs.duration_minutes }} min)
+ # Both release-gating legs via the ONE canonical soak entry; only the
+ # protected-TEMP provisioning is venue text. soak-legs.sh resolves .exe.
+ - name: Soak legs (${{ inputs.legs }}, ${{ inputs.duration_minutes }} min each)
shell: msys2 {0}
run: |
- BIN=build/c/codebase-memory-mcp
- [ -f "${BIN}.exe" ] && BIN="${BIN}.exe"
- scripts/soak-test.sh "$BIN" ${{ inputs.duration_minutes }}
- # #581 guard on Windows — the platform the bug is reported on.
- - name: Query-leak soak (#581, read-only)
- shell: msys2 {0}
- env:
- CBM_SOAK_MODE: query-leak
- RESULTS_DIR: soak-results-query-leak
- run: |
- BIN=build/c/codebase-memory-mcp
- [ -f "${BIN}.exe" ] && BIN="${BIN}.exe"
- scripts/soak-test.sh "$BIN" ${{ inputs.duration_minutes }} --skip-crash-test
+ export TEMP="$(cygpath -m "$CBM_CI_TEMP_ROOT")"
+ export TMP="$TEMP"
+ export TMPDIR="$(cygpath -u "$CBM_CI_TEMP_ROOT")"
+ scripts/soak-legs.sh --legs "${{ inputs.legs }}" build/c/codebase-memory-mcp ${{ inputs.duration_minutes }}
- name: Upload metrics
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
@@ -141,7 +144,8 @@ jobs:
# Native ARM64 Windows soak (CLANGARM64, no sanitizer — ASan is unavailable
# on native ARM64 Windows). Builds from source like soak-quick-windows.
runs-on: windows-11-arm
- timeout-minutes: 300
+ # Budget doctrine (see soak-quick): per-leg duration, two legs, 560.
+ timeout-minutes: 560
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- uses: msys2/setup-msys2@66cd2cce69caa17b53920067426061ca1de3a884 # v2
@@ -155,25 +159,28 @@ jobs:
make
git
coreutils
+ # Same protected root the test legs and the VM soak use. Without it the
+ # soak ran under the runner's inherited LocalAppData\Temp ACLs while the
+ # local soak ran hardened — the two venues were soaking different shapes.
+ - name: Create protected per-user temp root
+ shell: pwsh
+ run: |
+ $root = & scripts/ci/new-protected-temp-root.ps1 `
+ -Prefix 'cbm-ci-tmp-' `
+ -ProtectDir (Join-Path $env:GITHUB_WORKSPACE "build\c")
+ "CBM_CI_TEMP_ROOT=$root" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
- name: Build
shell: msys2 {0}
run: scripts/build.sh ${{ inputs.version && format('--version {0}', inputs.version) || '' }} CC=clang CXX=clang++
- - name: Soak (${{ inputs.duration_minutes }} min)
+ # Both release-gating legs via the ONE canonical soak entry; only the
+ # protected-TEMP provisioning is venue text. soak-legs.sh resolves .exe.
+ - name: Soak legs (${{ inputs.legs }}, ${{ inputs.duration_minutes }} min each)
shell: msys2 {0}
run: |
- BIN=build/c/codebase-memory-mcp
- [ -f "${BIN}.exe" ] && BIN="${BIN}.exe"
- scripts/soak-test.sh "$BIN" ${{ inputs.duration_minutes }}
- # #581 guard on Windows — the platform the bug is reported on.
- - name: Query-leak soak (#581, read-only)
- shell: msys2 {0}
- env:
- CBM_SOAK_MODE: query-leak
- RESULTS_DIR: soak-results-query-leak
- run: |
- BIN=build/c/codebase-memory-mcp
- [ -f "${BIN}.exe" ] && BIN="${BIN}.exe"
- scripts/soak-test.sh "$BIN" ${{ inputs.duration_minutes }} --skip-crash-test
+ export TEMP="$(cygpath -m "$CBM_CI_TEMP_ROOT")"
+ export TMP="$TEMP"
+ export TMPDIR="$(cygpath -u "$CBM_CI_TEMP_ROOT")"
+ scripts/soak-legs.sh --legs "${{ inputs.legs }}" build/c/codebase-memory-mcp ${{ inputs.duration_minutes }}
- name: Upload metrics
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
@@ -234,7 +241,10 @@ jobs:
- name: ASan soak (15 min)
env:
ASAN_OPTIONS: "detect_leaks=1:halt_on_error=0:log_path=soak-results/asan"
- run: scripts/soak-test.sh build/c/codebase-memory-mcp 15
+ # Single-leg variant of the canonical soak entry: the ASan build is too
+ # slow for the two-leg sequence; leg selection is a documented flag, not
+ # a divergent inline procedure.
+ run: scripts/soak-legs.sh --legs quick build/c/codebase-memory-mcp 15
- name: Upload metrics
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
@@ -272,10 +282,8 @@ jobs:
shell: msys2 {0}
env:
ASAN_OPTIONS: "detect_leaks=0:halt_on_error=0:log_path=soak-results/asan"
- run: |
- BIN=build/c/codebase-memory-mcp
- [ -f "${BIN}.exe" ] && BIN="${BIN}.exe"
- scripts/soak-test.sh "$BIN" 15
+ # Single-leg variant of the canonical soak entry (see the unix ASan job).
+ run: scripts/soak-legs.sh --legs quick build/c/codebase-memory-mcp 15
- name: Upload metrics
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
diff --git a/.github/workflows/_test.yml b/.github/workflows/_test.yml
index 70bd67bec..270e541f4 100644
--- a/.github/workflows/_test.yml
+++ b/.github/workflows/_test.yml
@@ -222,8 +222,10 @@ jobs:
export PATH=/usr/lib/ccache:$PATH
sudo sysctl -w vm.mmap_rnd_bits=28 || true
fi
- export CCACHE_COMPILERCHECK=content
- make -f Makefile.cbm test-tsan CC=${{ matrix.cc }} CXX=${{ matrix.cxx }}
+ # The TSan leg lives in the canonical test entry (same file the
+ # compose test-tsan service runs); env.sh supplies the verified
+ # ccache masquerade.
+ scripts/test.sh --tsan CC=${{ matrix.cc }} CXX=${{ matrix.cxx }}
env:
CCACHE_DIR: ${{ github.workspace }}/.ccache
CCACHE_MAXSIZE: 1500M
@@ -259,41 +261,15 @@ jobs:
git
- name: Create protected per-user temp root
- # The daemon suites fail closed on the MSYS-shared /tmp and on the
- # runner's inherited LocalAppData\Temp ACLs. Give the whole harness a
- # per-user root under the profile with an owner-stamped, protected
- # current-SID DACL, matching the launcher/daemon trust policy.
+ # One implementation, shared with _soak.yml and the VM leg
+ # (test-infrastructure/vm/vm-run-tests.sh) — see the script's header for
+ # why the harness cannot run under a shared or ACL-inherited temp.
shell: pwsh
run: |
- $root = Join-Path $env:USERPROFILE ("cbm-ci-tmp-" + [guid]::NewGuid().ToString("N"))
- New-Item -ItemType Directory -Path $root | Out-Null
- $sid = [System.Security.Principal.WindowsIdentity]::GetCurrent().User
- $acl = [System.Security.AccessControl.DirectorySecurity]::new()
- $acl.SetOwner($sid)
- $acl.SetAccessRuleProtection($true, $false)
- $rule = [System.Security.AccessControl.FileSystemAccessRule]::new(
- $sid,
- [System.Security.AccessControl.FileSystemRights]::FullControl,
- ([System.Security.AccessControl.InheritanceFlags]::ContainerInherit -bor
- [System.Security.AccessControl.InheritanceFlags]::ObjectInherit),
- [System.Security.AccessControl.PropagationFlags]::None,
- [System.Security.AccessControl.AccessControlType]::Allow)
- $acl.AddAccessRule($rule) | Out-Null
- Set-Acl -LiteralPath $root -AclObject $acl
+ $root = & scripts/ci/new-protected-temp-root.ps1 `
+ -Prefix 'cbm-ci-tmp-' `
+ -ProtectDir (Join-Path $env:GITHUB_WORKSPACE "build\c")
"CBM_CI_TEMP_ROOT=$root" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
- # Pre-create the build directory with the same protected DACL so
- # every build product inherits it. The workspace drive root grants
- # Authenticated Users Modify by inheritance — a shape real user
- # checkouts (under the profile) do not have — and the activation
- # transaction's source-directory policy correctly refuses it, which
- # would fail the install-flow tests on the environment, not the code.
- $build = Join-Path $env:GITHUB_WORKSPACE "build\c"
- New-Item -ItemType Directory -Path $build -Force | Out-Null
- $bacl = [System.Security.AccessControl.DirectorySecurity]::new()
- $bacl.SetOwner($sid)
- $bacl.SetAccessRuleProtection($true, $false)
- $bacl.AddAccessRule($rule) | Out-Null
- Set-Acl -LiteralPath $build -AclObject $bacl
- name: Compiler cache (content-verified)
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
@@ -324,7 +300,9 @@ jobs:
export TEMP="$(cygpath -m "$CBM_CI_TEMP_ROOT")"
export TMP="$TEMP"
export TMPDIR="$(cygpath -u "$CBM_CI_TEMP_ROOT")"
- scripts/test.sh CC=clang CXX=clang++ ${{ matrix.os == 'windows-11-arm' && '"SANITIZE=-fsanitize=undefined -fsanitize-trap=undefined -fstack-protector-strong -fno-omit-frame-pointer"' || '' }}
+ # No per-leg flag logic here: test.sh itself applies the CLANGARM64
+ # trap-UBSan default, so local and CI build identical test binaries.
+ scripts/test.sh CC=clang CXX=clang++
env:
CBM_TEST_SHARD: ${{ matrix.shard }}
CBM_TEST_LEG: ${{ matrix.os }}-${{ matrix.msystem }}
@@ -369,51 +347,19 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
+ # The union proof lives in the canonical scripts/ci entry, not inline
+ # YAML (venue-parity contract) — checkout (into repo/, so the manifest
+ # download below stays untouched) provides the script.
+ - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
+ with:
+ path: repo
+
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: shard-manifest-*
path: manifests
-
- name: Verify cross-shard union per leg
- run: |
- set -eu
- files=$(find manifests -name shard-manifest.txt | sort)
- if [ -z "$files" ]; then
- echo "FAIL: no shard manifests were uploaded" >&2
- exit 1
- fi
- rc=0
- for leg in $(grep -h '^leg=' $files | sort -u | sed 's/^leg=//'); do
- leg_files=$(grep -l "^leg=$leg\$" $files)
- n=$(grep -h '^shard=' $leg_files | sed 's|.*/||' | sort -u)
- if [ "$(printf '%s\n' "$n" | wc -l)" -ne 1 ]; then
- echo "FAIL: $leg shards disagree on shard count: $n" >&2
- rc=1
- continue
- fi
- indices=$(grep -h '^shard=' $leg_files | sed 's/^shard=//;s|/.*||' | sort -n)
- if [ "$indices" != "$(seq 1 "$n")" ]; then
- echo "FAIL: $leg shard indices [$indices] != 1..$n" >&2
- rc=1
- continue
- fi
- list_sha=$(grep -h '^list_sha256=' $leg_files | sed 's/^list_sha256=//' | sort -u)
- if [ "$(printf '%s\n' "$list_sha" | wc -l)" -ne 1 ]; then
- echo "FAIL: $leg shards saw different suite lists" >&2
- rc=1
- continue
- fi
- union_sha=$(for f in $leg_files; do
- sed -n '/^--- slice ---$/,$p' "$f" | tail -n +2
- done | sort | sha256sum | awk '{print $1}')
- if [ "$union_sha" != "$list_sha" ]; then
- echo "FAIL: $leg union of shard slices != full suite list (GATE-QUALITY LOSS)" >&2
- rc=1
- continue
- fi
- echo "OK: $leg — $n shard(s), union of slices == full suite list"
- done
- exit "$rc"
+ run: repo/scripts/ci/verify-shard-union.sh manifests
# Windows product-surface regression guards. Distinct from test-windows above
# (the sanitizer C suite): these drive a real product binary + embedded HTTP UI
diff --git a/.github/workflows/nightly-soak.yml b/.github/workflows/nightly-soak.yml
index e3a83109b..4c8abeb28 100644
--- a/.github/workflows/nightly-soak.yml
+++ b/.github/workflows/nightly-soak.yml
@@ -1,4 +1,11 @@
-# Weekly soak test: 4h sustained load + ASan leak detection
+# Soak dispatcher — the weekly scheduled soak AND every on-demand soak run.
+#
+# Absorbs the retired soak.yml (the standalone "multi-hour #581" workflow): its
+# reasons to exist — a job budget that actually covers a 4h run, and the
+# query-leak mode that never reindexes so the #581 leak can accumulate — are
+# now _soak.yml facts (timeout 560, legs input). A long #581-only run is
+# `legs: query-leak` here, not a separate workflow with its own copy of the
+# soak procedure. NON-GATING: never a required check, never blocks a merge.
name: Nightly Soak
on:
@@ -7,9 +14,22 @@ on:
workflow_dispatch:
inputs:
duration_minutes:
- description: 'Soak duration in minutes (default: 240 = 4h)'
+ description: 'Soak duration in minutes PER LEG (default: 240 = 4h)'
type: number
default: 240
+ legs:
+ description: 'Soak legs (query-leak = the #581 detector alone)'
+ type: choice
+ options: ['quick,query-leak', 'quick', 'query-leak']
+ default: 'quick,query-leak'
+ run_asan:
+ description: 'Also run the 15-min ASan soak legs'
+ type: boolean
+ default: true
+ # Iteration convenience carried over from soak.yml: pushing a qa/soak-**
+ # branch starts a real run from that branch's own copy of the workflows.
+ push:
+ branches: ['qa/soak-**']
permissions:
contents: read
@@ -18,5 +38,8 @@ jobs:
soak:
uses: ./.github/workflows/_soak.yml
with:
+ # On schedule/push events the inputs context is empty — fall back to the
+ # weekly defaults (4h, both legs, ASan on).
duration_minutes: ${{ inputs.duration_minutes || 240 }}
- run_asan: true
+ legs: ${{ inputs.legs || 'quick,query-leak' }}
+ run_asan: ${{ github.event_name != 'workflow_dispatch' || inputs.run_asan }}
diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml
index 3d49534b5..5a05399c5 100644
--- a/.github/workflows/pr.yml
+++ b/.github/workflows/pr.yml
@@ -156,16 +156,10 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
+ # Needs a checkout (unlike before): the gate logic lives in the canonical
+ # scripts/ci entry, not inline YAML (venue-parity contract).
+ - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: All PR stages must have succeeded
env:
RESULTS: ${{ toJSON(needs) }}
- run: |
- echo "$RESULTS" | python3 -c "
- import json, sys
- needs = json.load(sys.stdin)
- bad = {k: v['result'] for k, v in needs.items() if v['result'] not in ('success', 'skipped')}
- if bad:
- print('CI NOT OK:', bad)
- sys.exit(1)
- print('CI OK:', ', '.join(needs))
- "
+ run: scripts/ci/require-all-green.sh
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index f4df5409c..60f705260 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -110,39 +110,10 @@ jobs:
with:
subject-path: checksums.txt
+ # SBOM content lives in the canonical scripts/ci entry, not inline YAML
+ # (venue-parity contract): vendored versions are reviewable there.
- name: Generate SBOM
- run: |
- python3 -c "
- import json, glob, os
- n_grammars = len([d for d in glob.glob('internal/cbm/vendored/grammars/*') if os.path.isdir(d)])
- sbom = {
- 'spdxVersion': 'SPDX-2.3',
- 'dataLicense': 'CC0-1.0',
- 'SPDXID': 'SPDXRef-DOCUMENT',
- 'name': 'codebase-memory-mcp-${{ inputs.version }}',
- 'documentNamespace': 'https://github.com/DeusData/codebase-memory-mcp/releases/${{ inputs.version }}',
- 'creationInfo': {
- 'created': '$(date -u +%Y-%m-%dT%H:%M:%SZ)',
- 'creators': ['Tool: codebase-memory-mcp-release-pipeline']
- },
- 'packages': [
- {'SPDXID': 'SPDXRef-Package-sqlite3', 'name': 'sqlite3', 'versionInfo': '3.51.3', 'licenseDeclared': 'blessing', 'downloadLocation': 'https://sqlite.org', 'filesAnalyzed': False},
- {'SPDXID': 'SPDXRef-Package-yyjson', 'name': 'yyjson', 'versionInfo': '0.12.0', 'licenseDeclared': 'MIT', 'downloadLocation': 'https://github.com/ibireme/yyjson', 'filesAnalyzed': False},
- {'SPDXID': 'SPDXRef-Package-mimalloc', 'name': 'mimalloc', 'versionInfo': '3.3.2', 'licenseDeclared': 'MIT', 'downloadLocation': 'https://github.com/microsoft/mimalloc', 'filesAnalyzed': False},
- {'SPDXID': 'SPDXRef-Package-xxhash', 'name': 'xxhash', 'versionInfo': '0.8.3', 'licenseDeclared': 'BSD-2-Clause', 'downloadLocation': 'https://github.com/Cyan4973/xxHash', 'filesAnalyzed': False},
- {'SPDXID': 'SPDXRef-Package-tre', 'name': 'tre', 'versionInfo': '0.8.0', 'licenseDeclared': 'BSD-2-Clause', 'downloadLocation': 'https://github.com/laurikari/tre', 'filesAnalyzed': False},
- {'SPDXID': 'SPDXRef-Package-tree-sitter', 'name': 'tree-sitter', 'versionInfo': '0.24.4', 'licenseDeclared': 'MIT', 'downloadLocation': 'https://github.com/tree-sitter/tree-sitter', 'filesAnalyzed': False},
- {'SPDXID': 'SPDXRef-Package-lz4', 'name': 'lz4', 'versionInfo': '1.10.0', 'licenseDeclared': 'BSD-2-Clause', 'downloadLocation': 'https://github.com/lz4/lz4', 'filesAnalyzed': False},
- {'SPDXID': 'SPDXRef-Package-zstd', 'name': 'zstd', 'versionInfo': '1.5.7', 'licenseDeclared': 'BSD-3-Clause', 'downloadLocation': 'https://github.com/facebook/zstd', 'filesAnalyzed': False},
- {'SPDXID': 'SPDXRef-Package-simplecpp', 'name': 'simplecpp', 'versionInfo': '1.x', 'licenseDeclared': '0BSD', 'downloadLocation': 'https://github.com/danmar/simplecpp', 'filesAnalyzed': False},
- {'SPDXID': 'SPDXRef-Package-verstable', 'name': 'verstable', 'versionInfo': '2.2.1', 'licenseDeclared': 'MIT', 'downloadLocation': 'https://github.com/JacksonAllan/Verstable', 'filesAnalyzed': False},
- {'SPDXID': 'SPDXRef-Package-wyhash', 'name': 'wyhash', 'versionInfo': 'final-4.3', 'licenseDeclared': 'Unlicense', 'downloadLocation': 'https://github.com/wangyi-fudan/wyhash', 'filesAnalyzed': False},
- {'SPDXID': 'SPDXRef-Package-nomic-embed-code', 'name': 'nomic-embed-code-token-embeddings', 'versionInfo': '1.0', 'licenseDeclared': 'Apache-2.0', 'downloadLocation': 'https://huggingface.co/nomic-ai/nomic-embed-code', 'filesAnalyzed': False, 'comment': 'Derived int8 token embeddings; see vendored/nomic/NOTICE'},
- {'SPDXID': 'SPDXRef-Package-tree-sitter-grammars', 'name': 'tree-sitter-grammars-aggregate', 'versionInfo': f'{n_grammars}-grammars', 'licenseDeclared': 'MIT', 'downloadLocation': 'NOASSERTION', 'filesAnalyzed': False, 'comment': f'Aggregate of {n_grammars} vendored tree-sitter grammars, compiled statically. Predominantly MIT; non-MIT families present include CC0-1.0 (clojure, fennel), Apache-2.0 (elixir, erlang, gleam, hcl, ini, jinja2, just, pkl, sway, wit), ISC (pine, templ), Unlicense (fish); first-party grammars (c) DeusData, MIT. This summary is non-exhaustive; the authoritative complete per-grammar license list is internal/cbm/vendored/grammars/MANIFEST.md, and full license texts ship in THIRD_PARTY_NOTICES.md inside each archive.'}
- ]
- }
- json.dump(sbom, open('sbom.json', 'w'), indent=2)
- "
+ run: python3 scripts/ci/generate-sbom.py "${{ inputs.version }}"
- name: Attest SBOM
uses: actions/attest-sbom@c604332985a26aa8cf1bdc465b92731239ec6b9e # v4.1.0
diff --git a/.github/workflows/soak.yml b/.github/workflows/soak.yml
deleted file mode 100644
index 451968e0f..000000000
--- a/.github/workflows/soak.yml
+++ /dev/null
@@ -1,130 +0,0 @@
-# Real multi-hour soak — #581 query-only memory-leak reproducer.
-#
-# WHY THIS EXISTS (separate from _soak.yml / nightly-soak.yml):
-# The nightly path was structurally incapable of running a real long soak:
-# 1. nightly-soak.yml passes duration_minutes: 240, but _soak.yml's
-# soak-quick / soak-asan jobs hard-cap `timeout-minutes: 30` (45 for
-# ASan). GitHub kills the job at 30 min → the "4h" soak NEVER ran past
-# 30 min. (Fixed in _soak.yml too, but this workflow guarantees the
-# right budget for the long #581 run.)
-# 2. scripts/soak-test.sh's default mode reindexes every 2 min;
-# index_repository triggers cbm_mem_collect (mimalloc page return),
-# which sweeps the query-only leak — masking #581 even on a long run.
-# This workflow drives CBM_SOAK_MODE=query-leak, which never reindexes
-# and never mutates files, so the leak can accumulate and be detected
-# by soak-test.sh's RSS slope / ratio / ceiling analysis.
-#
-# NON-GATING: workflow_dispatch + push to qa/soak-** only. Never a required
-# check, never blocks a merge.
-#
-# CRITICAL: timeout-minutes = duration + 60. A 240-min soak gets ~300 min.
-name: Soak (multi-hour #581)
-
-on:
- workflow_dispatch:
- inputs:
- duration_minutes:
- description: 'Soak duration in minutes (default: 240 = 4h)'
- type: number
- default: 240
- mode:
- description: 'Soak mode (query-leak = #581 detector, no reindex/mutate)'
- type: choice
- options: ['default', 'query-leak']
- default: 'query-leak'
- # Iteration convenience: pushing a qa/soak-** branch starts a real run from
- # that branch's own copy of this file (no main merge needed). Non-gating.
- push:
- branches: ['qa/soak-**']
-
-permissions:
- contents: read
-
-jobs:
- # ── Unix: full matrix (linux amd64+arm64, darwin arm64+amd64) ──────────────
- soak-unix:
- strategy:
- fail-fast: false
- matrix:
- include:
- - os: ubuntu-latest
- cc: gcc
- cxx: g++
- - os: ubuntu-24.04-arm
- cc: gcc
- cxx: g++
- - os: macos-14
- cc: cc
- cxx: c++
- - os: macos-15-intel
- cc: cc
- cxx: c++
- runs-on: ${{ matrix.os }}
- # Fixed budget (NOT the 30 min that silently truncated nightly). 320 min covers
- # the 240-min default soak + build + analysis. `timeout-minutes` is evaluated at
- # workflow setup where the `inputs` context is null on push events, so an
- # inputs-based expression here is a startup failure — keep it a literal.
- # (A workflow_dispatch run with duration > ~250 min should bump this.)
- timeout-minutes: 320
- steps:
- - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
-
- - name: Install deps (Linux)
- if: startsWith(matrix.os, 'ubuntu')
- run: sudo apt-get update && sudo apt-get install -y zlib1g-dev python3 git
-
- - name: Build (prod binary)
- run: scripts/build.sh CC=${{ matrix.cc }} CXX=${{ matrix.cxx }}
-
- - name: Soak
- env:
- # On push events there are no inputs → fall back to shell defaults
- # (240 min / query-leak) so a qa/soak-** push runs the real #581 soak.
- CBM_SOAK_MODE: ${{ inputs.mode || 'query-leak' }}
- DURATION_MINUTES: ${{ inputs.duration_minutes || '240' }}
- run: scripts/soak-test.sh build/c/codebase-memory-mcp "${DURATION_MINUTES}"
-
- - name: Upload metrics
- if: always()
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
- with:
- name: soak-${{ matrix.os }}-${{ inputs.mode || 'query-leak' }}
- path: soak-results/
- retention-days: 14
-
- # ── Windows: the platform #581 actually crashes on (50+ GB → crash) ───────
- soak-windows:
- runs-on: windows-latest
- timeout-minutes: 320
- steps:
- - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- - uses: msys2/setup-msys2@66cd2cce69caa17b53920067426061ca1de3a884 # v2
- with:
- msystem: CLANG64
- path-type: inherit
- install: >-
- mingw-w64-clang-x86_64-clang
- mingw-w64-clang-x86_64-zlib
- mingw-w64-clang-x86_64-python3
- make
- git
- coreutils
- - name: Build (prod binary)
- shell: msys2 {0}
- run: scripts/build.sh CC=clang CXX=clang++
- - name: Soak
- shell: msys2 {0}
- env:
- CBM_SOAK_MODE: ${{ inputs.mode || 'query-leak' }}
- DURATION_MINUTES: ${{ inputs.duration_minutes || '240' }}
- run: |
- BIN=build/c/codebase-memory-mcp
- [ -f "${BIN}.exe" ] && BIN="${BIN}.exe"
- scripts/soak-test.sh "$BIN" "${DURATION_MINUTES}"
- - name: Upload metrics
- if: always()
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
- with:
- name: soak-windows-${{ inputs.mode || 'query-leak' }}
- path: soak-results/
- retention-days: 14
diff --git a/scripts/README.md b/scripts/README.md
new file mode 100644
index 000000000..9e9a5d42d
--- /dev/null
+++ b/scripts/README.md
@@ -0,0 +1,65 @@
+# scripts/ — the canonical leg entries
+
+**The doctrine (enforced, not advisory):** *a venue may provision a machine;
+only a canonical leg script may exercise the product.* Local CI, PR CI, the
+dry run and the release all call the SAME files below — venues differ only in
+host specs, architecture and inputs, never in what a leg does. Platform
+differences (arm64 sanitizer flags, the Windows launcher, the linux portable
+binary) live INSIDE these scripts, once, never per-venue.
+`tests/test_venue_parity_contract.sh` (run as Step 0j of every test leg) turns
+any violation — inline harness logic in a workflow, a bypassed wrapper, a
+missing `--help` — into a red build.
+
+Every entry answers `--help` (authoritative, agent-oriented: modes, env, exit
+codes) and rejects unknown flags with exit 2 + `Please consult --help.`
+
+## The legs
+
+| leg | entry | what a run gives you |
+|---|---|---|
+| **test** | `test.sh` | DEFAULT = the venue leg: static contracts (Step 0a–0j) + CLEAN ASan+UBSan build + all suites via the parallel harness + prod-binary guards. `--suites a,b` = iteration mode (incremental rebuild, subset, seconds). `--tsan` = the ThreadSanitizer leg. CLANGARM64 gets CI's trap-UBSan flags automatically. |
+| **build** | `build.sh` | CLEAN production build (+ launcher on Windows). ccache via `env.sh` makes repeats fast; `CCACHE_COMPILERCHECK=content` guarantees a hit is byte-identical to a cold compile — never stale. `--with-ui`, `--version`, `STATIC=1`, `BUILD_DIR=`. |
+| **lint** | `lint.sh` | clang-tidy + cppcheck + clang-format (+ no-skips policy). `--ci` = the CI gate set (no clang-tidy). Drives the same make targets as `make lint`/`lint-ci`. |
+| **smoke (unix)** | `smoke-local.sh` | Stages a full release fixture, serves it on a kernel-assigned port, runs `smoke-test.sh` (ALL phases incl. download/install/update E2E) inside a disposable HOME/XDG/TMP sandbox. `ui` variant makes a missing embedded UI a FAILURE. `CBM_SMOKE_ARTIFACT_DIR` = smoke an extracted release artifact verbatim (release mode). |
+| **smoke (windows)** | `../test-infrastructure/vm/vm-smoke.sh` | Same contract for the launcher+payload pair, plus the user-PATH registry guard (prepare/verify/cleanup). |
+| **smoke-invariants** | `smoke-invariants.sh` | The "shipped binary does not fail" battery (MCP handshake, all tools invocable, malformed-input resilience) — no fixture server, no install E2E. `smoke.yml` runs it on the WIDEST build-from-source matrix (incl. older-glibc legs the release artifacts cannot cover). |
+| **soak** | `soak-legs.sh` | The release-gating soak SEQUENCE: `quick` then `query-leak` (the #581 detector — never reindexes, so RSS growth = query-path leak), each guarded by a completion-summary check. `--legs quick` for the ASan single-leg variant. Duration is per leg. |
+
+Internal harnesses — never called directly by a venue (the contract forbids
+it): `smoke-test.sh` (phases; wrappers provide fixture server + sandbox),
+`soak-test.sh` (one soak run; `soak-legs.sh` provides the sequence + guards),
+`run-tests-parallel.sh` (reached through `test.sh`).
+
+## Conventions
+
+- **Exit codes:** 0 = pass · 2 = usage error · 90 = guard (a run died without
+ its completion summary — never counts as green) · anything else = the leg's
+ real failure.
+- **Iteration is a flag, not a side-tool:** the fast paths (`--suites`,
+ `--legs`) are modes of the SAME entry the gates run, so a dev loop can never
+ drift from the venue behaviour.
+- **Env sandboxing:** the smoke wrappers neutralize every agent-config
+ destination override; a smoke can never scribble on your real config.
+
+## Recommended workflows
+
+- **Iterating on a change:** `scripts/test.sh --suites <suite>` (seconds,
+ incremental, same ASan+UBSan flags as the gate). List suites:
+ `build/c/test-runner --list-suites`. Debugging a Windows-on-ARM trap:
+ re-run with `SANITIZE=` for a plain build, or use the emulated
+ `win.sh ubsan-*` pair for full diagnostics.
+- **Before any push (the 3-OS ladder):** `scripts/test.sh` (macOS, full) →
+ `./test-infrastructure/run.sh full` (Linux + TSan + smoke) →
+ `test-infrastructure/vm/win.sh test-par` + `guards` + `smoke-install`
+ (+ `soak` when the change touches memory/daemon paths).
+- **Concurrency-touching change:** add `scripts/test.sh --tsan` early — the
+ same leg CI gates on.
+- **Release-shaped verification:** `CBM_SMOKE_ARTIFACT_DIR=<extracted artifact>
+ scripts/smoke-local.sh <binary> [ui]` smokes exactly what would ship.
+- **A leg is red in CI but green locally:** first suspect environment shape,
+ not code — the preflights (`win.sh` automatic; `scripts/ci/preflight-docker.sh`)
+ and `test-infrastructure/README.md`'s residuals list cover the knowable
+ differences.
+
+See `scripts/ci/README.md` for the CI plumbing and
+`test-infrastructure/README.md` for the venue map.
diff --git a/scripts/build.sh b/scripts/build.sh
index 1b9003b28..575477a94 100755
--- a/scripts/build.sh
+++ b/scripts/build.sh
@@ -4,6 +4,7 @@
# Usage:
# scripts/build.sh # Standard binary
# scripts/build.sh --with-ui # Binary with embedded UI
+# scripts/build.sh --help # Full usage
# scripts/build.sh --version v0.8.0 # With version stamp
# scripts/build.sh --arch x86_64 # Force x86_64 build
# scripts/build.sh CC=gcc-14 CXX=g++-14 # Override compiler
@@ -16,6 +17,45 @@ set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
cd "$ROOT"
+usage() {
+ cat <<'EOF'
+Usage: scripts/build.sh [--with-ui] [--version V] [--arch ARCH] [VAR=VAL ...]
+
+The canonical production-build entry: identical in local CI, PR CI, dry run
+and release. Always a CLEAN build of BUILD_DIR (build/c by default) — the
+content-verified compiler cache (ccache via scripts/env.sh) makes repeat
+builds fast without ever reusing a stale object: every object is re-derived
+from current sources; a cache hit is byte-identical to a cold compile by
+construction (CCACHE_COMPILERCHECK=content).
+
+Options:
+ --with-ui Embed the web UI (builds the frontend first; needs node).
+ --version V Stamp the version string (release venue passes the tag).
+ --arch ARCH Force target arch (arm64 | x86_64), e.g. under Rosetta.
+ -h, --help This text.
+
+Make passthrough (VAR=VAL, forwarded verbatim):
+ CC= CXX= Compiler override (venues pass their matrix compiler).
+ BUILD_DIR= Build in an isolated directory — REQUIRED when a clean
+ product build must not wipe build/c's test-runner (e.g.
+ build/smoke for the local ladder smoke).
+ STATIC=1 Fully static portable build (Alpine/musl leg).
+ EXTRA_CFLAGS= EXTRA_LDFLAGS= Sanitizer soak builds (see _soak.yml).
+
+Environment:
+ CBM_NO_CCACHE=1 Disable the compiler cache (build correctness is identical;
+ only speed changes).
+
+Callers: _build.yml (all release artifacts) · pr.yml pr-smoke · every
+docker-compose build/smoke service · win.sh build (Windows VM ladder).
+EOF
+}
+for arg in "$@"; do
+ case "$arg" in
+ -h|--help) usage; exit 0 ;;
+ esac
+done
+
# Pre-parse --arch flag before sourcing env.sh
for arg in "$@"; do
case "$arg" in
@@ -60,6 +100,12 @@ for arg in "$@"; do
;;
--arch|--arch=*)
;; # already handled
+ -*)
+ # STRICT: an unknown flag never falls through into make where it
+ # would fail cryptically (or worse, be absorbed).
+ echo "build.sh: unknown option '$arg'. Please consult --help." >&2
+ exit 2
+ ;;
BUILD_DIR=*)
BUILD_DIR="${arg#BUILD_DIR=}"
EXTRA_MAKE_ARGS+=("$arg")
@@ -68,12 +114,17 @@ for arg in "$@"; do
export "${arg}"
EXTRA_MAKE_ARGS+=("$arg")
;;
+ *=*)
+ EXTRA_MAKE_ARGS+=("$arg") # VAR=VAL make passthrough
+ ;;
*)
- # Check if this is the value for --version
+ # Bare words are only ever the value of --version; anything else is
+ # a usage error, not a silent make argument.
if [[ "${prev_arg:-}" == "--version" ]]; then
VERSION="$arg"
else
- EXTRA_MAKE_ARGS+=("$arg")
+ echo "build.sh: unexpected argument '$arg'. Please consult --help." >&2
+ exit 2
fi
;;
esac
diff --git a/scripts/ci/README.md b/scripts/ci/README.md
new file mode 100644
index 000000000..2d482ebba
--- /dev/null
+++ b/scripts/ci/README.md
@@ -0,0 +1,18 @@
+# scripts/ci/ — venue plumbing (single implementations)
+
+Support scripts that keep the venues in the SAME shape. Each exists because
+the logic used to live inline in workflow YAML or was hand-duplicated between
+CI and the local infrastructure — both of which the venue-parity contract
+(`tests/test_venue_parity_contract.sh`) now forbids. Everything here answers
+`--help` (PowerShell: comment-based help, `Get-Help <script>`).
+
+| script | job | called by |
+|---|---|---|
+| `new-protected-temp-root.ps1` | Create the owner-stamped, inheritance-protected per-user TEMP root the daemon/install suites require (shared `/tmp` and default runner TEMP grant Authenticated-Users mutation rights, which the trust policy correctly refuses — running there produces security refusals, not signal). `-ProtectDir` stamps build dirs the same way. | `_test.yml`, `_soak.yml`, `vm-run-tests.sh` |
+| `clean-test-residue.ps1` | Sweep `cbm-*` residue from the Windows VM and assert runner-like free disk (default 14 GB — the GitHub runner's SSD). Long-path `\\?\` fallback for the guard suites' adversarial trees; every removal VERIFIED (an earlier version counted attempts and reported 86 swept while 11 GB remained). BLOCKS below the floor: a disk that fills mid-run reads as a product bug. | `win.sh` before every build/run |
+| `preflight-docker.sh` | Same idea for Colima/docker: prune runner-unlike residue, assert free space on the filesystem backing the docker data root (not the VM's `/`). Build cache + named volumes KEPT (the local analogue of actions/cache); `--deep` drops them. | `test-infrastructure/run.sh` |
+| `check-glibc-compat.sh` | Run a linux binary in debian:bullseye (glibc 2.31) — the portable binary must start on old glibc. | `_smoke.yml` portable legs |
+| `generate-sbom.py` | The release SPDX SBOM (vendored versions reviewable here, diffable by vendoring PRs — was inline YAML). | `release.yml` |
+| `require-all-green.sh` | The aggregate gate: fail unless every needed job succeeded or legitimately skipped (was inline YAML). | `pr.yml ci-ok` |
+| `verify-shard-union.sh` | Prove sharded test legs lost nothing: shard count agreement, indices 1..n, identical suite lists, union of slices == full list (was inline YAML). | `_test.yml` shard-completeness |
+| `check-virustotal.sh` | Release-asset VirusTotal lookups. | `release.yml` |
diff --git a/scripts/ci/clean-test-residue.ps1 b/scripts/ci/clean-test-residue.ps1
new file mode 100644
index 000000000..abc3eae24
--- /dev/null
+++ b/scripts/ci/clean-test-residue.ps1
@@ -0,0 +1,84 @@
+<#
+.SYNOPSIS
+Sweep cbm test residue from a Windows test host and assert a runner-like free
+disk, before any test/smoke/soak run.
+
+.DESCRIPTION
+A GitHub-hosted runner is ephemeral: every job starts on a fresh image with a
+known-free disk. The local Windows VM is long-lived, so each run leaves temp
+roots, staged bundles and ~100 MB binary copies behind. Left alone that drift
+is not merely untidy - it changes the environment under test, and a disk that
+has quietly filled produces ERROR_DISK_FULL deep inside the install path, which
+reads as a product failure rather than an environment one. That misdiagnosis
+has already cost a full session.
+
+So every run starts from the same shape the runner would give it: residue gone,
+free space asserted. Refusing to start is correct - an unusable environment is a
+run blocker to escalate, never something to quietly run anyway on a bad disk.
+
+Sweeps only cbm-prefixed directories under the profile and TEMP. The checkout
+(C:\cbm) is not under either, and is never touched.
+
+.PARAMETER MinFreeGB
+Free space required before a run. Defaults to 14, the SSD size a GitHub-hosted
+Windows runner advertises, so the local venue cannot run under conditions the
+CI venue would never see.
+
+.PARAMETER SkipGate
+Sweep and report, but do not fail when free space is short. For inspection only.
+#>
+[CmdletBinding()]
+param(
+ [double]$MinFreeGB = 14,
+ [switch]$SkipGate
+)
+
+$ErrorActionPreference = 'Stop'
+
+function Get-FreeGB {
+ [math]::Round((Get-PSDrive C).Free / 1GB, 2)
+}
+
+# The guard suites deliberately build adversarial trees - names with spaces and
+# non-representable characters, deep .cbm-retired/generations nesting - whose
+# full paths exceed MAX_PATH. Remove-Item cannot address those and fails with
+# DirectoryNotFoundException, so `rd` under the \\?\ prefix (which bypasses the
+# 260-char limit) is the fallback. Every removal is then VERIFIED: an earlier
+# revision counted attempts, not successes, and cheerfully reported 86 swept
+# directories while 11 GB of them were still sitting on the disk.
+function Remove-ResidueDir([string]$Path) {
+ Remove-Item -LiteralPath $Path -Recurse -Force -ErrorAction SilentlyContinue
+ if (-not (Test-Path -LiteralPath $Path)) { return $true }
+ & cmd.exe /c "rd /s /q `"\\?\$Path`"" 2>&1 | Out-Null
+ return -not (Test-Path -LiteralPath $Path)
+}
+
+$before = Get-FreeGB
+$removed = 0
+$failed = @()
+$roots = @($env:USERPROFILE, $env:TEMP) | Where-Object { $_ } | Select-Object -Unique
+
+foreach ($root in $roots) {
+ if (-not (Test-Path -LiteralPath $root)) { continue }
+ Get-ChildItem -LiteralPath $root -Directory -Filter 'cbm-*' -ErrorAction SilentlyContinue |
+ ForEach-Object {
+ if (Remove-ResidueDir $_.FullName) {
+ $removed++
+ } else {
+ $failed += $_.FullName
+ }
+ }
+}
+
+$after = Get-FreeGB
+Write-Output "residue-dirs-removed=$removed residue-dirs-failed=$($failed.Count) free-gb-before=$before free-gb-after=$after"
+foreach ($f in $failed) { Write-Warning "could not sweep: $f" }
+
+if (-not $SkipGate -and $after -lt $MinFreeGB) {
+ $msg = "BLOCKED: $after GB free, need $MinFreeGB GB. " +
+ "A GitHub runner never starts this low, so a run here would not be " +
+ "comparable - and a disk that fills mid-run surfaces as a bogus " +
+ "product failure rather than an environment one. Free space, re-run."
+ Write-Error $msg
+ exit 1
+}
diff --git a/scripts/ci/generate-sbom.py b/scripts/ci/generate-sbom.py
new file mode 100644
index 000000000..31f333c14
--- /dev/null
+++ b/scripts/ci/generate-sbom.py
@@ -0,0 +1,57 @@
+#!/usr/bin/env python3
+"""Generate the release SPDX SBOM (sbom.json).
+
+Canonical release step (called by release.yml). Lived inline in workflow YAML
+until 2026-07-26 — vendored-dependency versions belong in a reviewable,
+venue-independent script, and the venue-parity contract forbids logic in
+workflow run-blocks.
+
+Usage: scripts/ci/generate-sbom.py <version> (e.g. v0.9.1)
+
+Keep versionInfo entries in sync with the vendored trees; the authoritative
+per-grammar license list is internal/cbm/vendored/grammars/MANIFEST.md.
+"""
+from __future__ import annotations
+
+import datetime
+import glob
+import json
+import os
+import sys
+
+if len(sys.argv) != 2 or sys.argv[1] in {"-h", "--help"}:
+ print(__doc__.strip(), file=sys.stderr)
+ sys.exit(0 if len(sys.argv) == 2 else 2)
+
+version = sys.argv[1]
+n_grammars = len(
+ [d for d in glob.glob("internal/cbm/vendored/grammars/*") if os.path.isdir(d)]
+)
+sbom = {
+ "spdxVersion": "SPDX-2.3",
+ "dataLicense": "CC0-1.0",
+ "SPDXID": "SPDXRef-DOCUMENT",
+ "name": f"codebase-memory-mcp-{version}",
+ "documentNamespace": f"https://github.com/DeusData/codebase-memory-mcp/releases/{version}",
+ "creationInfo": {
+ "created": datetime.datetime.now(datetime.timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ"),
+ "creators": ["Tool: codebase-memory-mcp-release-pipeline"],
+ },
+ "packages": [
+ {"SPDXID": "SPDXRef-Package-sqlite3", "name": "sqlite3", "versionInfo": "3.51.3", "licenseDeclared": "blessing", "downloadLocation": "https://sqlite.org", "filesAnalyzed": False},
+ {"SPDXID": "SPDXRef-Package-yyjson", "name": "yyjson", "versionInfo": "0.12.0", "licenseDeclared": "MIT", "downloadLocation": "https://github.com/ibireme/yyjson", "filesAnalyzed": False},
+ {"SPDXID": "SPDXRef-Package-mimalloc", "name": "mimalloc", "versionInfo": "3.3.2", "licenseDeclared": "MIT", "downloadLocation": "https://github.com/microsoft/mimalloc", "filesAnalyzed": False},
+ {"SPDXID": "SPDXRef-Package-xxhash", "name": "xxhash", "versionInfo": "0.8.3", "licenseDeclared": "BSD-2-Clause", "downloadLocation": "https://github.com/Cyan4973/xxHash", "filesAnalyzed": False},
+ {"SPDXID": "SPDXRef-Package-tre", "name": "tre", "versionInfo": "0.8.0", "licenseDeclared": "BSD-2-Clause", "downloadLocation": "https://github.com/laurikari/tre", "filesAnalyzed": False},
+ {"SPDXID": "SPDXRef-Package-tree-sitter", "name": "tree-sitter", "versionInfo": "0.24.4", "licenseDeclared": "MIT", "downloadLocation": "https://github.com/tree-sitter/tree-sitter", "filesAnalyzed": False},
+ {"SPDXID": "SPDXRef-Package-lz4", "name": "lz4", "versionInfo": "1.10.0", "licenseDeclared": "BSD-2-Clause", "downloadLocation": "https://github.com/lz4/lz4", "filesAnalyzed": False},
+ {"SPDXID": "SPDXRef-Package-zstd", "name": "zstd", "versionInfo": "1.5.7", "licenseDeclared": "BSD-3-Clause", "downloadLocation": "https://github.com/facebook/zstd", "filesAnalyzed": False},
+ {"SPDXID": "SPDXRef-Package-simplecpp", "name": "simplecpp", "versionInfo": "1.x", "licenseDeclared": "0BSD", "downloadLocation": "https://github.com/danmar/simplecpp", "filesAnalyzed": False},
+ {"SPDXID": "SPDXRef-Package-verstable", "name": "verstable", "versionInfo": "2.2.1", "licenseDeclared": "MIT", "downloadLocation": "https://github.com/JacksonAllan/Verstable", "filesAnalyzed": False},
+ {"SPDXID": "SPDXRef-Package-wyhash", "name": "wyhash", "versionInfo": "final-4.3", "licenseDeclared": "Unlicense", "downloadLocation": "https://github.com/wangyi-fudan/wyhash", "filesAnalyzed": False},
+ {"SPDXID": "SPDXRef-Package-nomic-embed-code", "name": "nomic-embed-code-token-embeddings", "versionInfo": "1.0", "licenseDeclared": "Apache-2.0", "downloadLocation": "https://huggingface.co/nomic-ai/nomic-embed-code", "filesAnalyzed": False, "comment": "Derived int8 token embeddings; see vendored/nomic/NOTICE"},
+ {"SPDXID": "SPDXRef-Package-tree-sitter-grammars", "name": "tree-sitter-grammars-aggregate", "versionInfo": f"{n_grammars}-grammars", "licenseDeclared": "MIT", "downloadLocation": "NOASSERTION", "filesAnalyzed": False, "comment": f"Aggregate of {n_grammars} vendored tree-sitter grammars, compiled statically. Predominantly MIT; non-MIT families present include CC0-1.0 (clojure, fennel), Apache-2.0 (elixir, erlang, gleam, hcl, ini, jinja2, just, pkl, sway, wit), ISC (pine, templ), Unlicense (fish); first-party grammars (c) DeusData, MIT. This summary is non-exhaustive; the authoritative complete per-grammar license list is internal/cbm/vendored/grammars/MANIFEST.md, and full license texts ship in THIRD_PARTY_NOTICES.md inside each archive."},
+ ],
+}
+json.dump(sbom, open("sbom.json", "w"), indent=2)
+print(f"sbom.json written ({n_grammars} grammars, version {version})")
diff --git a/scripts/ci/new-protected-temp-root.ps1 b/scripts/ci/new-protected-temp-root.ps1
new file mode 100644
index 000000000..713ec342b
--- /dev/null
+++ b/scripts/ci/new-protected-temp-root.ps1
@@ -0,0 +1,74 @@
+<#
+.SYNOPSIS
+Create a protected per-user temp root and print its path.
+
+.DESCRIPTION
+The daemon and install-flow suites fail closed on the MSYS-shared /tmp and on a
+runner's inherited LocalAppData\Temp ACLs: both grant mutation rights to
+Authenticated Users, which the launcher/daemon trust policy correctly refuses.
+Running them there produces security refusals, not test signal. Every venue
+therefore gives the harness a per-user root beneath the profile carrying an
+owner-stamped, protected current-SID DACL.
+
+This is the single implementation. It was duplicated between
+.github/workflows/_test.yml and test-infrastructure/vm/vm-run-tests.sh - which
+let the two venues drift - and _soak.yml carried no copy at all, so CI soaked
+under the default runner TEMP while the local soak ran hardened.
+
+.PARAMETER Prefix
+Directory-name prefix for the root. Also selects what -PruneStale sweeps, so
+each venue keeps its own namespace.
+
+.PARAMETER ProtectDir
+Extra directories to create and stamp with the same protected DACL. The
+workspace drive root grants Authenticated Users Modify by inheritance - a shape
+real user checkouts under the profile do not have - so build outputs living
+there need the same treatment or the activation transaction's source-directory
+policy refuses them.
+
+.PARAMETER PruneStale
+Remove earlier roots sharing this prefix before creating the new one. Intended
+for the long-lived VM, where roots accumulate; a fresh runner has none.
+#>
+[CmdletBinding()]
+param(
+ [string]$Prefix = 'cbm-tmp-',
+ [string[]]$ProtectDir = @(),
+ [switch]$PruneStale
+)
+
+$ErrorActionPreference = 'Stop'
+
+if ($PruneStale) {
+ Get-ChildItem -LiteralPath $env:USERPROFILE -Directory -Filter "$Prefix*" `
+ -ErrorAction SilentlyContinue |
+ Remove-Item -Recurse -Force -ErrorAction SilentlyContinue
+}
+
+$sid = [System.Security.Principal.WindowsIdentity]::GetCurrent().User
+$rule = [System.Security.AccessControl.FileSystemAccessRule]::new(
+ $sid,
+ [System.Security.AccessControl.FileSystemRights]::FullControl,
+ ([System.Security.AccessControl.InheritanceFlags]::ContainerInherit -bor
+ [System.Security.AccessControl.InheritanceFlags]::ObjectInherit),
+ [System.Security.AccessControl.PropagationFlags]::None,
+ [System.Security.AccessControl.AccessControlType]::Allow)
+
+function Set-ProtectedAcl([string]$Path) {
+ $acl = [System.Security.AccessControl.DirectorySecurity]::new()
+ $acl.SetOwner($sid)
+ $acl.SetAccessRuleProtection($true, $false)
+ $acl.AddAccessRule($rule) | Out-Null
+ Set-Acl -LiteralPath $Path -AclObject $acl
+}
+
+$root = Join-Path $env:USERPROFILE ($Prefix + [guid]::NewGuid().ToString('N'))
+New-Item -ItemType Directory -Path $root | Out-Null
+Set-ProtectedAcl $root
+
+foreach ($dir in $ProtectDir) {
+ New-Item -ItemType Directory -Path $dir -Force | Out-Null
+ Set-ProtectedAcl $dir
+}
+
+Write-Output $root
diff --git a/scripts/ci/preflight-docker.sh b/scripts/ci/preflight-docker.sh
new file mode 100644
index 000000000..5572c7298
--- /dev/null
+++ b/scripts/ci/preflight-docker.sh
@@ -0,0 +1,105 @@
+#!/usr/bin/env bash
+# Bring the container venue to the shape a GitHub runner would hand us, before
+# any docker-backed test/smoke run.
+#
+# A GitHub-hosted runner is ephemeral: fresh image, known-free disk, no leftover
+# containers or volumes from a previous job. Colima is long-lived, so exited
+# containers and orphaned volumes accumulate and the disk drifts down. That
+# drift is not cosmetic — a disk that fills mid-run fails deep inside the
+# install path and reads as a product bug rather than an environment one.
+#
+# Default sweep is the state a runner would never have carried in: stopped
+# containers, dangling images, unused volumes. The build cache is KEPT by
+# default — a runner restores an equivalent cache via actions/cache, so wiping
+# it locally would diverge from CI, not converge with it. --deep drops it too.
+#
+# Usage: preflight-docker.sh [--deep] [--min-free-gb N] [--skip-gate]
+set -euo pipefail
+
+# A German (or any comma-decimal) locale makes awk print "76,38" and then parse
+# it back as 76, so the free-space gate would silently compare the wrong number.
+# Pin the numeric locale for every awk/df in this script.
+export LC_ALL=C
+
+usage() {
+ cat <<'EOF'
+Usage: scripts/ci/preflight-docker.sh [--deep] [--min-free-gb N] [--skip-gate]
+
+Bring the Colima/docker venue to the shape a GitHub runner would hand us,
+before any container-backed test/smoke/soak run (test-infrastructure/run.sh
+calls this automatically; CBM_SKIP_PREFLIGHT=1 opts out for a quick re-run).
+
+Sweeps stopped containers, dangling images and unused anonymous volumes, then
+asserts free space on the filesystem backing the docker data root. The build
+cache and NAMED compose volumes are KEPT by default — they are this venue's
+analogue of actions/cache, so wiping them would diverge from CI, not converge.
+
+Options:
+ --deep Also drop the build cache, named volumes and every unused
+ image (full cold start).
+ --min-free-gb N Free-space floor (default 14 — the runner's SSD size).
+ Below it the script BLOCKS with exit 1: a disk that fills
+ mid-run fails deep inside the install path and reads as a
+ product bug, so refusing to start is the correct outcome.
+ --skip-gate Sweep and report, but never block (inspection only).
+ -h, --help This text.
+EOF
+}
+
+DEEP=0
+MIN_FREE_GB=14
+SKIP_GATE=0
+while [ $# -gt 0 ]; do
+ case "$1" in
+ --deep) DEEP=1 ;;
+ --min-free-gb) MIN_FREE_GB="${2:?--min-free-gb needs a value}"; shift ;;
+ --skip-gate) SKIP_GATE=1 ;;
+ -h | --help) usage; exit 0 ;;
+ *) echo "preflight-docker: unknown argument '$1'. Please consult --help." >&2; exit 2 ;;
+ esac
+ shift
+done
+
+if ! docker info >/dev/null 2>&1; then
+ echo "preflight-docker: docker is not reachable — start Colima first" >&2
+ echo " (Docker Desktop is broken on this machine; Colima is the runtime)" >&2
+ exit 2
+fi
+
+free_gb() {
+ # Measure the filesystem that actually backs the docker data root, not the
+ # VM's `/`: on Colima they are different mounts, and `/` reported 18 GB free
+ # while 12.5 GB of images lived elsewhere. The host's own free space is
+ # irrelevant to a container that fills the VM's disk.
+ local root
+ root="$(docker info --format '{{.DockerRootDir}}' 2>/dev/null || echo /var/lib/docker)"
+ docker run --rm -v /:/hostroot alpine:3 \
+ df -P "/hostroot${root}" 2>/dev/null |
+ awk 'NR==2 {printf "%.2f", $4/1048576}'
+}
+
+before="$(free_gb || echo 0)"
+echo "=== preflight-docker: sweeping runner-unlike residue ==="
+# Anonymous volumes only: the NAMED compose volumes are this venue's warm cache
+# (the local analogue of actions/cache), so dropping them would diverge from CI
+# rather than converge with it. --deep takes them too.
+docker container prune -f
+docker volume prune -f
+docker image prune -f
+if [ "$DEEP" -eq 1 ]; then
+ echo "--- deep: dropping build cache, named volumes and every unused image ---"
+ docker builder prune -af
+ docker volume prune -af
+ docker image prune -af
+fi
+after="$(free_gb || echo 0)"
+echo "preflight-docker: free-gb-before=${before} free-gb-after=${after}"
+docker system df
+
+if [ "$SKIP_GATE" -eq 0 ] &&
+ awk -v a="$after" -v m="$MIN_FREE_GB" 'BEGIN {exit !(a < m)}'; then
+ echo "BLOCKED: ${after} GB free, need ${MIN_FREE_GB} GB. A GitHub runner never" >&2
+ echo " starts this low, so this run would not be comparable. Re-run with" >&2
+ echo " --deep to reclaim the build cache, or free space on the Colima VM." >&2
+ exit 1
+fi
diff --git a/scripts/ci/require-all-green.sh b/scripts/ci/require-all-green.sh
new file mode 100644
index 000000000..bb9c5a33f
--- /dev/null
+++ b/scripts/ci/require-all-green.sh
@@ -0,0 +1,31 @@
+#!/usr/bin/env bash
+# require-all-green.sh — the aggregate gate step: fail unless every needed job
+# succeeded (or was legitimately skipped).
+#
+# Canonical CI step (called by pr.yml ci-ok with RESULTS = toJSON(needs)).
+# Lived inline in workflow YAML until 2026-07-26; the venue-parity contract
+# forbids logic in workflow run-blocks. `skipped` counts as OK because gated
+# jobs (e.g. pr-smoke on docs-only PRs) skip by design — a matrix rename can
+# still never silently deadlock a merge, which is this gate's purpose.
+#
+# Usage: RESULTS='<json of the needs context>' scripts/ci/require-all-green.sh
+set -euo pipefail
+
+case "${1:-}" in
+-h | --help)
+ sed -n '2,11p' "$0" | sed 's/^# \{0,1\}//'
+ exit 0
+ ;;
+esac
+
+: "${RESULTS:?set RESULTS to the toJSON(needs) context}"
+
+printf '%s' "$RESULTS" | python3 -c "
+import json, sys
+needs = json.load(sys.stdin)
+bad = {k: v['result'] for k, v in needs.items() if v['result'] not in ('success', 'skipped')}
+if bad:
+ print('CI NOT OK:', bad)
+ sys.exit(1)
+print('CI OK:', ', '.join(needs))
+"
diff --git a/scripts/ci/verify-shard-union.sh b/scripts/ci/verify-shard-union.sh
new file mode 100644
index 000000000..70b91ef4b
--- /dev/null
+++ b/scripts/ci/verify-shard-union.sh
@@ -0,0 +1,61 @@
+#!/usr/bin/env bash
+# verify-shard-union.sh — prove the sharded test legs lost nothing.
+#
+# Canonical CI step (called by _test.yml's shard-completeness job on the
+# downloaded shard-manifest-* artifacts). Lived inline in workflow YAML until
+# 2026-07-26; the venue-parity contract forbids logic in workflow run-blocks.
+#
+# For every leg it asserts: all shards agree on the shard count, indices form
+# exactly 1..n, every shard saw the same full suite list, and the UNION of the
+# shard slices equals that list — a rename/re-shard can never silently drop a
+# suite (gate-quality loss) without failing here.
+#
+# Usage: scripts/ci/verify-shard-union.sh <manifests-dir>
+set -eu
+
+case "${1:-}" in
+-h | --help)
+ sed -n '2,13p' "$0" | sed 's/^# \{0,1\}//'
+ exit 0
+ ;;
+esac
+
+MANIFEST_DIR="${1:?usage: verify-shard-union.sh <manifests-dir> (see --help)}"
+
+files=$(find "$MANIFEST_DIR" -name shard-manifest.txt | sort)
+if [ -z "$files" ]; then
+ echo "FAIL: no shard manifests were uploaded" >&2
+ exit 1
+fi
+rc=0
+for leg in $(grep -h '^leg=' $files | sort -u | sed 's/^leg=//'); do
+ leg_files=$(grep -l "^leg=$leg\$" $files)
+ n=$(grep -h '^shard=' $leg_files | sed 's|.*/||' | sort -u)
+ if [ "$(printf '%s\n' "$n" | wc -l)" -ne 1 ]; then
+ echo "FAIL: $leg shards disagree on shard count: $n" >&2
+ rc=1
+ continue
+ fi
+ indices=$(grep -h '^shard=' $leg_files | sed 's/^shard=//;s|/.*||' | sort -n)
+ if [ "$indices" != "$(seq 1 "$n")" ]; then
+ echo "FAIL: $leg shard indices [$indices] != 1..$n" >&2
+ rc=1
+ continue
+ fi
+ list_sha=$(grep -h '^list_sha256=' $leg_files | sed 's/^list_sha256=//' | sort -u)
+ if [ "$(printf '%s\n' "$list_sha" | wc -l)" -ne 1 ]; then
+ echo "FAIL: $leg shards saw different suite lists" >&2
+ rc=1
+ continue
+ fi
+ union_sha=$(for f in $leg_files; do
+ sed -n '/^--- slice ---$/,$p' "$f" | tail -n +2
+ done | sort | sha256sum | awk '{print $1}')
+ if [ "$union_sha" != "$list_sha" ]; then
+ echo "FAIL: $leg union of shard slices != full suite list (GATE-QUALITY LOSS)" >&2
+ rc=1
+ continue
+ fi
+ echo "OK: $leg — $n shard(s), union of slices == full suite list"
+done
+exit "$rc"
diff --git a/scripts/lint.sh b/scripts/lint.sh
index bb2b0ec1e..b2220af67 100755
--- a/scripts/lint.sh
+++ b/scripts/lint.sh
@@ -16,14 +16,41 @@ cd "$ROOT"
# shellcheck source=env.sh
source "$ROOT/scripts/env.sh"
+usage() {
+ cat <<'EOF'
+Usage: scripts/lint.sh [--ci] [VAR=VAL ...]
+
+The canonical lint entry: CI (_lint.yml) calls this script; it drives the same
+Makefile.cbm lint targets `make lint`/`make lint-ci` run, plus the no-skips
+policy check. Runs clang-tidy + cppcheck + clang-format by default.
+
+Options:
+ --ci CI mode: cppcheck + clang-format only (no clang-tidy) —
+ exactly what _lint.yml gates on. `make lint-ci` uses this.
+ VAR=VAL Forwarded to make, e.g. CLANG_FORMAT=clang-format-20.
+ NOTE: the project formatter is the Homebrew LLVM build; a
+ standalone clang-format-20 produces false whole-file drift.
+ -h, --help This text.
+EOF
+}
+
# Check for --ci flag (skip clang-tidy for platforms without it)
CI_ONLY=false
MAKE_ARGS=()
for arg in "$@"; do
- if [ "$arg" = "--ci" ]; then
+ if [ "$arg" = "-h" ] || [ "$arg" = "--help" ]; then
+ usage; exit 0
+ elif [ "$arg" = "--ci" ]; then
CI_ONLY=true
else
- MAKE_ARGS+=("$arg")
+ # STRICT: only VAR=VAL make passthrough beyond the known flags.
+ case "$arg" in
+ *=*) MAKE_ARGS+=("$arg") ;;
+ *)
+ echo "lint.sh: unknown argument '$arg'. Please consult --help." >&2
+ exit 2
+ ;;
+ esac
fi
done
diff --git a/scripts/smoke-invariants.sh b/scripts/smoke-invariants.sh
index 7d7f283bf..3a4f9ce09 100755
--- a/scripts/smoke-invariants.sh
+++ b/scripts/smoke-invariants.sh
@@ -27,9 +27,30 @@
set -u
# ── Args / setup ──────────────────────────────────────────────────────────
+usage() {
+ cat <<'EOF'
+Usage: scripts/smoke-invariants.sh <binary>
+
+Canonical entry for the "the shipped PROD binary does not fail" invariant
+battery — a fast, portable smoke distinct from the full release smoke
+(smoke-local.sh / vm-smoke.sh): no fixture server, no install/update E2E, just
+the binary itself. Checks version/help, the MCP initialize handshake (#513),
+every tool invocable, malformed-input resilience, clean EOF exit, shared-lib
+resolution, and an install dry-run. Prints PASS/FAIL per invariant; exit 0 iff
+ALL pass.
+
+Caller: .github/workflows/smoke.yml — the widest-matrix build-from-source
+battery (incl. older-glibc ubuntu-22.04 legs the release artifacts cannot
+cover). Fine to run locally against any built binary.
+EOF
+}
+case "${1:-}" in
+-h|--help) usage; exit 0 ;;
+-*) echo "smoke-invariants: unknown option '$1'. Please consult --help." >&2; exit 2 ;;
+esac
BINARY="${1:-}"
if [ -z "$BINARY" ]; then
- echo "usage: smoke-invariants.sh <binary>" >&2
+ echo "smoke-invariants: missing <binary>. Please consult --help." >&2
exit 2
fi
if [ ! -x "$BINARY" ]; then
diff --git a/scripts/smoke-local.sh b/scripts/smoke-local.sh
index 523834565..9a38dd96d 100755
--- a/scripts/smoke-local.sh
+++ b/scripts/smoke-local.sh
@@ -8,7 +8,46 @@ set -euo pipefail
# <binary> product binary to smoke (e.g. build/c/codebase-memory-mcp)
# ui optional: mirror the -ui variant asset naming
-BINARY="${1:?Usage: smoke-local.sh <binary> [ui]}"
+usage() {
+ cat <<'EOF'
+Usage: scripts/smoke-local.sh <binary> [standard|ui]
+
+The canonical unix smoke entry: identical in local CI, PR CI, dry run and
+release. Stages a complete release fixture (binary + LICENSE + install.sh +
+THIRD_PARTY_NOTICES.md), serves it on a kernel-assigned port, then runs
+scripts/smoke-test.sh (all phases, including the download/checksum/install/
+update E2E) inside a disposable HOME/XDG/TMPDIR sandbox with every agent-config
+destination override neutralized.
+
+Arguments:
+ <binary> Product binary to smoke (e.g. build/c/codebase-memory-mcp).
+ ui Mirror the -ui asset naming AND require the embedded UI:
+ Phase 15's "no assets" outcome becomes a FAILURE
+ (SMOKE_REQUIRE_UI=1), so a standard binary cannot pass a ui run.
+
+Environment:
+ CBM_SMOKE_ARTIFACT_DIR Release mode: an EXTRACTED release artifact
+ directory. Sidecars (LICENSE, install.sh, THIRD_PARTY_NOTICES.md)
+ are validated and served from THERE instead of regenerated, so
+ the release venue smokes exactly the bytes it publishes; an
+ incomplete archive fails the smoke. Unset (default): sidecars
+ come from this checkout (local/PR mode).
+
+Callers: pr.yml pr-smoke (ubuntu/macos) · _smoke.yml smoke-unix +
+smoke-linux-portable (with CBM_SMOKE_ARTIFACT_DIR) · compose smoke services.
+Windows uses the sibling test-infrastructure/vm/vm-smoke.sh.
+EOF
+}
+case "${1:-}" in
+-h|--help) usage; exit 0 ;;
+-*) echo "smoke-local: unknown option '$1'. Please consult --help." >&2; exit 2 ;;
+esac
+if [ $# -gt 2 ]; then
+ echo "smoke-local: too many arguments. Please consult --help." >&2
+ exit 2
+fi
+
+BINARY="${1:?smoke-local: missing <binary> argument. Please consult --help.}"
VARIANT="${2:-standard}"
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
BINARY="$(cd "$(dirname "$BINARY")" && pwd)/$(basename "$BINARY")"
@@ -17,12 +56,30 @@ if [ ! -x "$BINARY" ]; then
echo "smoke-local: binary is not executable: $BINARY" >&2
exit 2
fi
+# A ui run must be handed a binary that actually carries the embedded assets;
+# the suffix alone only renames the archive. SMOKE_REQUIRE_UI turns Phase 15's
+# documented "no embedded assets" SKIP into a failure, so asking for ui and
+# supplying a standard binary can no longer pass quietly.
case "$VARIANT" in
-standard) SUFFIX="" ;;
-ui) SUFFIX="-ui" ;;
-*) echo "smoke-local: variant must be 'standard' or 'ui'" >&2; exit 2 ;;
+standard) SUFFIX="" ; REQUIRE_UI=0 ;;
+ui) SUFFIX="-ui" ; REQUIRE_UI=1 ;;
+*) echo "smoke-local: variant must be 'standard' or 'ui'. Please consult --help." >&2; exit 2 ;;
esac
+# Unset (the local + PR default): synthesize the release sidecars from this
+# checkout. Set: take them from an EXTRACTED release artifact, so the release
+# venue serves the files it is about to publish rather than regenerated copies.
+ARTIFACT_DIR="${CBM_SMOKE_ARTIFACT_DIR:-}"
+if [ -n "$ARTIFACT_DIR" ]; then
+ ARTIFACT_DIR="$(cd "$ARTIFACT_DIR" && pwd)"
+ for required in LICENSE install.sh THIRD_PARTY_NOTICES.md; do
+ [ -s "$ARTIFACT_DIR/$required" ] || {
+ echo "smoke-local: release artifact is missing $required" >&2
+ exit 2
+ }
+ done
+fi
+
case "$(uname -s)" in
Darwin) OS=darwin ;;
Linux) OS=linux ;;
@@ -65,8 +122,13 @@ trap cleanup EXIT
mkdir -p "$FIXTURE_DIR" "$SMOKE_TEMP_DIR" "$SMOKE_HOME" "$SMOKE_XDG_CONFIG" \
"$SMOKE_APPDATA" "$SMOKE_LOCALAPPDATA"
cp "$BINARY" "$FIXTURE_DIR/codebase-memory-mcp"
-cp "$ROOT/LICENSE" "$ROOT/install.sh" "$FIXTURE_DIR/"
-"$ROOT/scripts/gen-third-party-notices.sh" "$FIXTURE_DIR/THIRD_PARTY_NOTICES.md"
+if [ -n "$ARTIFACT_DIR" ]; then
+ cp "$ARTIFACT_DIR/LICENSE" "$ARTIFACT_DIR/install.sh" \
+ "$ARTIFACT_DIR/THIRD_PARTY_NOTICES.md" "$FIXTURE_DIR/"
+else
+ cp "$ROOT/LICENSE" "$ROOT/install.sh" "$FIXTURE_DIR/"
+ "$ROOT/scripts/gen-third-party-notices.sh" "$FIXTURE_DIR/THIRD_PARTY_NOTICES.md"
+fi
EXPECTED_ARTIFACT="codebase-memory-mcp${SUFFIX}-${OS}-${ARCH}.tar.gz"
tar -czf "$FIXTURE_DIR/$EXPECTED_ARTIFACT" -C "$FIXTURE_DIR" \
@@ -158,4 +220,5 @@ env \
SMOKE_DOWNLOAD_URL="http://127.0.0.1:$PORT" \
SMOKE_UPDATE_FIXTURE_DIR="$FIXTURE_DIR" \
SMOKE_ARCH="$ARCH" \
+ SMOKE_REQUIRE_UI="$REQUIRE_UI" \
"$ROOT/scripts/smoke-test.sh" "$BINARY"
diff --git a/scripts/smoke-test.sh b/scripts/smoke-test.sh
index 16873893d..1a277a85d 100755
--- a/scripts/smoke-test.sh
+++ b/scripts/smoke-test.sh
@@ -11,10 +11,32 @@ set -euo pipefail
# The explicit optional mode runs only version + agent config install/uninstall
# checks (useful when validating installer-only changes).
-BINARY="${1:?usage: smoke-test.sh <binary-path> [--agent-config-only]}"
+case "${1:-}" in
+-h|--help)
+ cat <<'HELPEOF'
+Usage: scripts/smoke-test.sh <binary-path> [--agent-config-only]
+
+INTERNAL harness — do not call directly in a venue. The canonical entries are
+scripts/smoke-local.sh (unix) and test-infrastructure/vm/vm-smoke.sh (Windows):
+they stage the release fixture, start the fixture server, and sandbox
+HOME/TEMP/agent-config destinations. Called bare, the download/checksum/
+install-script phases (12-13) SKIP for lack of a fixture server, and the run
+mutates the REAL profile — the venue-parity contract forbids that in any venue.
+
+Arguments:
+ <binary-path> product binary to smoke
+ --agent-config-only only version + agent-config install/uninstall phases
+
+Environment (set by the wrappers): SMOKE_DOWNLOAD_URL, SMOKE_UPDATE_FIXTURE_DIR,
+SMOKE_TEMP_ROOT, SMOKE_ARCH, SMOKE_REQUIRE_UI (ui variant: Phase 15 skip => FAIL).
+HELPEOF
+ exit 0
+ ;;
+esac
+BINARY="${1:?smoke-test: missing <binary-path>. Please consult --help.}"
SMOKE_MODE="${2:-}"
if [ -n "$SMOKE_MODE" ] && [ "$SMOKE_MODE" != "--agent-config-only" ]; then
- echo "usage: smoke-test.sh <binary-path> [--agent-config-only]" >&2
+ echo "smoke-test: unknown argument '$SMOKE_MODE'. Please consult --help." >&2
exit 2
fi
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")/.." && pwd)"
@@ -3314,6 +3336,21 @@ fi
# ── Phase 15: UI HTTP server reachability ──
# Only runs if the binary was built with embedded UI assets.
+#
+# SMOKE_REQUIRE_UI=1 (set by the wrappers for a -ui variant) makes the
+# no-assets outcome a FAILURE instead of a SKIP: a ui run that smoked a
+# standard binary under a ui name would otherwise pass green, and a skip that
+# cannot fail is not a gate.
+SMOKE_REQUIRE_UI="${SMOKE_REQUIRE_UI:-0}"
+smoke_ui_missing() {
+ if [ "$SMOKE_REQUIRE_UI" = "1" ]; then
+ echo "FAIL $1: SMOKE_REQUIRE_UI=1 but this binary serves no embedded UI assets"
+ kill "$UI_PID" 2>/dev/null || true
+ exit 1
+ fi
+ echo "SKIP $1: $2"
+}
+
echo ""
echo "=== Phase 15: UI HTTP server ==="
@@ -3340,7 +3377,7 @@ if [ "$UI_READY" -eq 1 ] || kill -0 "$UI_PID" 2>/dev/null; then
if echo "$UI_BODY" | grep -qi "<html"; then
echo "OK 15a: UI serves HTML at /"
elif [ -z "$UI_BODY" ]; then
- echo "SKIP 15a: UI not reachable (binary may not have embedded assets)"
+ smoke_ui_missing "15a" "UI not reachable (binary may not have embedded assets)"
else
echo "FAIL 15a: UI root did not return HTML"
kill "$UI_PID" 2>/dev/null || true
@@ -3355,7 +3392,7 @@ if [ "$UI_READY" -eq 1 ] || kill -0 "$UI_PID" 2>/dev/null; then
if echo "$RPC_BODY" | grep -q "jsonrpc"; then
echo "OK 15b: /rpc returns JSON-RPC response"
elif [ -z "$RPC_BODY" ]; then
- echo "SKIP 15b: /rpc not reachable"
+ smoke_ui_missing "15b" "/rpc not reachable"
else
echo "FAIL 15b: /rpc did not return JSON-RPC"
kill "$UI_PID" 2>/dev/null || true
@@ -3365,7 +3402,7 @@ if [ "$UI_READY" -eq 1 ] || kill -0 "$UI_PID" 2>/dev/null; then
kill "$UI_PID" 2>/dev/null || true
wait "$UI_PID" 2>/dev/null || true
else
- echo "SKIP Phase 15: binary exited immediately (no UI assets embedded)"
+ smoke_ui_missing "Phase 15" "binary exited immediately (no UI assets embedded)"
fi
rm -f "$UI_INPUT"
diff --git a/scripts/soak-legs.sh b/scripts/soak-legs.sh
new file mode 100644
index 000000000..6f7944e7e
--- /dev/null
+++ b/scripts/soak-legs.sh
@@ -0,0 +1,116 @@
+#!/usr/bin/env bash
+# soak-legs.sh — THE canonical soak leg entry. Every venue calls this file.
+#
+# Runs the soak SEQUENCE — the quick soak, then the read-only #581 query-leak
+# detector — with the completion-summary guard applied to each leg. Before this
+# file existed the sequence was hand-copied six times across _soak.yml, once in
+# vm-run-tests.sh and once in docker-compose.yml; venues drifted (CI soaked
+# without the query-leak guard's temp hardening, local soaked without the
+# query-leak leg at all). Venue-specific text is now limited to provisioning;
+# the sequence lives here and only here.
+#
+# Callers: .github/workflows/_soak.yml (all platforms) · win.sh soak (via
+# vm-run-tests.sh --soak) · test-infrastructure/run.sh soak-linux (compose).
+set -euo pipefail
+
+usage() {
+ cat <<'EOF'
+Usage: scripts/soak-legs.sh [--legs LIST] <binary> <duration-minutes>
+
+The canonical soak entry: identical in local CI, PR CI, dry run and release.
+Runs each requested leg through scripts/soak-test.sh and hard-fails any leg
+that exits zero without printing its completion summary (a crashed or killed
+soak must never read as green).
+
+Legs (default: quick,query-leak — the release-gating sequence):
+ quick scripts/soak-test.sh <binary> <minutes>
+ Default soak: periodic reindex + query churn + crash-recovery.
+ Results in soak-results/.
+ query-leak CBM_SOAK_MODE=query-leak, --skip-crash-test, results in
+ soak-results-query-leak/. The #581 detector: after the initial
+ index it NEVER reindexes or mutates, so any RSS growth is a
+ query-path leak, not WAL/indexing churn.
+
+Options:
+ --legs LIST Comma-separated subset, e.g. --legs quick. The ASan soak jobs
+ use this (a 15-min single-leg soak under ASan); local iteration
+ may too. Order is preserved; unknown names fail fast.
+ -h, --help This text.
+
+Environment:
+ ASAN_OPTIONS etc. pass through to the binary unchanged.
+ RESULTS_DIR is owned by this script (per-leg); do not pre-set it.
+
+Examples:
+ scripts/soak-legs.sh build/c/codebase-memory-mcp 10 # both legs, 10m each
+ scripts/soak-legs.sh --legs quick build/c/codebase-memory-mcp 15 # ASan-style
+EOF
+}
+
+LEGS="quick,query-leak"
+while [ $# -gt 0 ]; do
+ case "$1" in
+ --legs) LEGS="${2:?--legs needs a comma-separated list}"; shift ;;
+ --legs=*) LEGS="${1#--legs=}" ;;
+ -h | --help) usage; exit 0 ;;
+ --*) echo "soak-legs: unknown option '$1'. Please consult --help." >&2; exit 2 ;;
+ *) break ;;
+ esac
+ shift
+done
+
+BINARY="${1:?soak-legs: missing <binary>. Please consult --help.}"
+DURATION="${2:?soak-legs: missing <duration-minutes>. Please consult --help.}"
+case "$DURATION" in
+'' | *[!0-9]*) echo "soak-legs: duration must be a positive integer (minutes). Please consult --help." >&2; exit 2 ;;
+esac
+[ "$DURATION" -gt 0 ] || { echo "soak-legs: duration must be positive" >&2; exit 2; }
+# Windows builds produce <name>.exe; resolve it here so every venue passes the
+# same plain path and carries no per-platform binary-name logic of its own.
+if [ ! -x "$BINARY" ] && [ -x "${BINARY}.exe" ]; then
+ BINARY="${BINARY}.exe"
+fi
+[ -x "$BINARY" ] || { echo "soak-legs: binary '$BINARY' missing or not executable — build first" >&2; exit 2; }
+
+ROOT="$(cd "$(dirname "$0")/.." && pwd)"
+
+run_leg() {
+ local leg="$1"
+ local log
+ log="$(mktemp "${TMPDIR:-/tmp}/cbm-soak-leg-XXXXXX.log")"
+ echo "=== soak-legs: leg=${leg} binary=${BINARY} duration=${DURATION}m ==="
+ local rc=0
+ case "$leg" in
+ quick)
+ "$ROOT/scripts/soak-test.sh" "$BINARY" "$DURATION" 2>&1 | tee "$log"
+ rc="${PIPESTATUS[0]}"
+ ;;
+ query-leak)
+ CBM_SOAK_MODE=query-leak RESULTS_DIR=soak-results-query-leak \
+ "$ROOT/scripts/soak-test.sh" "$BINARY" "$DURATION" --skip-crash-test 2>&1 | tee "$log"
+ rc="${PIPESTATUS[0]}"
+ ;;
+ *)
+ echo "soak-legs: unknown leg '$leg' (known: quick, query-leak)" >&2
+ rm -f -- "$log"
+ return 2
+ ;;
+ esac
+ # A soak whose log lacks the completion summary did not validly run to the
+ # end, whatever its exit code says — same guard class as the test runner's.
+ if ! grep -Fq '=== soak-test: PASSED ===' "$log"; then
+ echo "GUARD: soak leg '${leg}' produced no completion summary; treating as" \
+ "failure (soak rc=$rc)" >&2
+ rm -f -- "$log"
+ return 90
+ fi
+ rm -f -- "$log"
+ return "$rc"
+}
+
+IFS=',' read -r -a leg_list <<<"$LEGS"
+[ "${#leg_list[@]}" -gt 0 ] || { echo "soak-legs: --legs resolved to nothing" >&2; exit 2; }
+for leg in "${leg_list[@]}"; do
+ run_leg "$leg"
+done
+echo "=== soak-legs: all legs passed (${LEGS}) ==="
diff --git a/scripts/soak-test.sh b/scripts/soak-test.sh
index 25db7a82e..be5891a44 100755
--- a/scripts/soak-test.sh
+++ b/scripts/soak-test.sh
@@ -16,8 +16,36 @@
set -euo pipefail
-BINARY="${1:?Usage: soak-test.sh <binary> <duration_minutes>}"
-DURATION_MIN="${2:?Usage: soak-test.sh <binary> <duration_minutes>}"
+case "${1:-}" in
+-h|--help)
+ cat <<'HELPEOF'
+Usage: scripts/soak-test.sh <binary> <duration_minutes> [--skip-crash-test]
+
+INTERNAL harness — do not call directly in a venue. The canonical entry is
+scripts/soak-legs.sh, which runs the release-gating leg SEQUENCE (quick +
+query-leak) with a completion-summary guard per leg; the venue-parity contract
+forbids direct calls in any venue.
+
+Arguments:
+ <binary> product binary to soak
+ <duration_minutes> positive integer, per run
+ --skip-crash-test skip the crash-recovery phase (query-leak leg sets this)
+
+Environment:
+ CBM_SOAK_MODE default | query-leak (#581 detector: never reindex/mutate
+ after the initial index, so RSS growth = query-path leak)
+ RESULTS_DIR metrics output dir (default soak-results; soak-legs.sh owns
+ this per leg)
+
+Pass/fail: RSS slope / ratio / ceiling analysis; prints
+"=== soak-test: PASSED ===" or "=== soak-test: FAILED ===" and exits 0/1.
+HELPEOF
+ exit 0
+ ;;
+esac
+
+BINARY="${1:?soak-test: missing <binary>. Please consult --help.}"
+DURATION_MIN="${2:?soak-test: missing <duration_minutes>. Please consult --help.}"
SKIP_CRASH="${3:-}"
BINARY=$(cd "$(dirname "$BINARY")" && pwd)/$(basename "$BINARY")
diff --git a/scripts/test.sh b/scripts/test.sh
index cabdf3c3d..8a047af2a 100755
--- a/scripts/test.sh
+++ b/scripts/test.sh
@@ -1,32 +1,127 @@
#!/usr/bin/env bash
-# test.sh — Clean build + run all C tests with ASan + UBSan.
-#
-# Usage:
-# scripts/test.sh # Auto-detect everything
-# scripts/test.sh --arch x86_64 # Force x86_64 build
-# scripts/test.sh CC=gcc-14 CXX=g++-14 # Override compiler
-#
-# This script is the SINGLE source of truth for running tests.
-# Used identically in local development and CI workflows.
+# test.sh — THE canonical test leg. Every venue (local ladder, PR CI, dry run,
+# release) runs tests through this file; iteration happens through its flags,
+# never through a second entry point.
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
cd "$ROOT"
-# Parse --arch flag before sourcing env.sh
+usage() {
+ cat <<'EOF'
+Usage: scripts/test.sh [--suites LIST] [--arch ARCH] [VAR=VAL ...]
+
+The canonical test entry: identical in local CI, PR CI, dry run and release.
+DEFAULT (no --suites) is exactly what CI runs: static contract checks
+(Step 0a-0j), a CLEAN sanitizer build, every suite via the parallel harness,
+then the prod-binary regression guards (Steps 4-6).
+
+Modes:
+ (default) The venue leg. Clean build (scripts/clean.sh) + all suites +
+ all contract steps. This is the shape every gate runs.
+ --suites LIST ITERATION mode: comma- or space-separated suite names, e.g.
+ --suites daemon,daemon_ipc. Rebuilds the test-runner
+ INCREMENTALLY (make dependency tracking, no clean) and runs
+ only those suites — seconds, not minutes. Skips the contract
+ steps and prod-binary guards; the full default run remains
+ the merge gate. Suite names: build/c/test-runner --list-suites.
+ --tsan ThreadSanitizer leg (data-race gate): builds and runs the
+ widened TSan runner via make test-tsan — the same leg CI's
+ tsan jobs and the compose test-tsan service run.
+
+Options:
+ --arch ARCH Force target arch (arm64 | x86_64), e.g. under Rosetta.
+ -h, --help This text.
+
+Make passthrough (VAR=VAL, forwarded verbatim):
+ CC= CXX= Compiler override, e.g. CC=gcc-14 CXX=g++-14.
+ BUILD_DIR= Build in an isolated directory (containers/sanitizer variants).
+ SANITIZE= Override sanitizer flags. Platform defaults when unset:
+ unix/CLANG64 use the Makefile's ASan+UBSan test flags;
+ CLANGARM64 (Windows on ARM, no ASan runtime) gets CI's
+ trap-UBSan set (-fsanitize=undefined -fsanitize-trap=undefined
+ -fstack-protector-strong -fno-omit-frame-pointer) applied HERE
+ so local and CI build identical test binaries. Pass SANITIZE=
+ (empty) for a plain build when debugging a trap.
+
+Environment:
+ CBM_TEST_SEQUENTIAL=1 Single-process runner instead of the parallel harness.
+ CBM_RUN_HANG_TEST=1 Opt-in C++ index-hang regression (#410, needs prod).
+ CBM_NO_CCACHE=1 Disable the content-verified compiler cache.
+ CBM_TEST_SHARD/_LEG Set by CI's sharded legs; leave unset locally.
+
+Examples:
+ scripts/test.sh # the full venue leg (what CI runs)
+ scripts/test.sh --suites daemon_ipc # one suite, incremental, seconds
+ scripts/test.sh --suites "arena hash_table" CC=clang CXX=clang++
+ scripts/test.sh SANITIZE= --suites daemon_ipc # plain build for trap debugging
+EOF
+}
+
+# Parse --help / --suites / --tsan / --arch before sourcing env.sh.
+# STRICT: an unknown flag or a stray word is an immediate usage error, never
+# silently swallowed — agents must know exactly what a run will do.
+SUITES=""
+TSAN=0
+prev_arg=""
for arg in "$@"; do
case "$arg" in
+ -h|--help) usage; exit 0 ;;
+ --tsan) :;;
+ --suites) :;; # next arg is the value, handled below
+ --suites=*) SUITES="${arg#--suites=}" ;;
--arch) :;; # next arg is the value, handled below
+ --arch=*) :;; # handled below
+ -*)
+ echo "test.sh: unknown option '$arg'. Please consult --help." >&2
+ exit 2
+ ;;
arm64|x86_64)
- # Check if previous arg was --arch
- if [[ "${prev_arg:-}" == "--arch" ]]; then
- export CBM_ARCH="$arg"
+ if [[ "${prev_arg:-}" != "--arch" && "${prev_arg:-}" != "--suites" ]]; then
+ echo "test.sh: unexpected argument '$arg' (did you mean --arch $arg?). Please consult --help." >&2
+ exit 2
+ fi
+ ;;
+ *=*) :;; # VAR=VAL make passthrough, validated below
+ *)
+ if [[ "${prev_arg:-}" != "--suites" ]]; then
+ echo "test.sh: unexpected argument '$arg'. Please consult --help." >&2
+ exit 2
fi
;;
esac
prev_arg="$arg"
done
+for arg in "$@"; do
+ case "$arg" in
+ --tsan) TSAN=1 ;;
+ arm64|x86_64)
+ if [[ "${prev_arg2:-}" == "--arch" ]]; then
+ export CBM_ARCH="$arg"
+ fi
+ ;;
+ *)
+ if [[ "${prev_arg2:-}" == "--suites" ]]; then
+ SUITES="$arg"
+ fi
+ ;;
+ esac
+ prev_arg2="$arg"
+done
+# Normalize comma separation to the runner's space-separated argv form.
+SUITES="${SUITES//,/ }"
+case "${prev_arg:-}" in
+ --suites|--arch)
+ echo "test.sh: '$prev_arg' needs a value. Please consult --help." >&2
+ exit 2
+ ;;
+esac
+if [ "$TSAN" -eq 1 ] && [ -n "$SUITES" ]; then
+ echo "test.sh: --tsan and --suites are separate modes (the TSan leg has its own suite set). Please consult --help." >&2
+ exit 2
+fi
+prev_arg=""
# Also support --arch=value
for arg in "$@"; do
@@ -49,18 +144,59 @@ source "$ROOT/scripts/path-safety.sh"
# make swallowed the second flag's leading -f as its makefile option.
MAKE_ARGS=()
BUILD_DIR="build/c"
+SANITIZE_GIVEN=0
+prev_arg=""
for arg in "$@"; do
case "$arg" in
CC=*|CXX=*) export "${arg}" ;;
--arch|--arch=*) ;; # already handled
arm64|x86_64) ;; # already handled
+ --tsan) ;; # already handled
+ --suites|--suites=*) ;; # already handled (value skipped via prev_arg below)
BUILD_DIR=*) BUILD_DIR="${arg#BUILD_DIR=}"; MAKE_ARGS+=("$arg") ;;
- *=*) MAKE_ARGS+=("$arg") ;; # forward any VAR=VAL to make
+ SANITIZE=*) SANITIZE_GIVEN=1; MAKE_ARGS+=("$arg") ;;
+ *=*)
+ if [[ "${prev_arg:-}" != "--suites" ]]; then
+ MAKE_ARGS+=("$arg") # forward any VAR=VAL to make
+ fi
+ ;;
esac
+ prev_arg="$arg"
done
+# Platform default absorbed FROM CI (previously inline in _test.yml, so the
+# local arm64 leg silently built without it — that divergence is why the SQLite
+# page-cache misalignment was fatal only on the windows-11-arm runner): native
+# ARM64 Windows has no ASan runtime, so its sanitizer gate is UBSan in trap
+# mode + stack protector. Applied here, once, for every venue; an explicit
+# SANITIZE=... (or SANITIZE=) argument overrides.
+if [ "$SANITIZE_GIVEN" -eq 0 ] && [ "${MSYSTEM:-}" = "CLANGARM64" ]; then
+ MAKE_ARGS+=("SANITIZE=-fsanitize=undefined -fsanitize-trap=undefined -fstack-protector-strong -fno-omit-frame-pointer")
+fi
+
print_env "test.sh"
+# ── TSan mode (--tsan): the data-race gate ──
+# One entry for every venue: CI's tsan jobs and the compose test-tsan service
+# both run this instead of carrying their own make invocation.
+if [ "$TSAN" -eq 1 ]; then
+ echo "=== test.sh: TSan leg (make test-tsan) ==="
+ make -j"$NPROC" -f Makefile.cbm "$BUILD_DIR/test-runner-tsan" ${MAKE_ARGS[@]+"${MAKE_ARGS[@]}"}
+ make -f Makefile.cbm test-tsan ${MAKE_ARGS[@]+"${MAKE_ARGS[@]}"}
+ exit "$?"
+fi
+
+# ── Iteration mode (--suites): incremental rebuild + subset run ──
+# The documented fast path: no clean, no contract steps, no prod-binary
+# guards — those all still gate every merge through the default full run.
+if [ -n "$SUITES" ]; then
+ echo "=== test.sh: ITERATION mode — suites: $SUITES (incremental build) ==="
+ make -j"$NPROC" -f Makefile.cbm "$BUILD_DIR/test-runner" ${MAKE_ARGS[@]+"${MAKE_ARGS[@]}"}
+ # shellcheck disable=SC2086 # suite list is deliberately word-split
+ "$BUILD_DIR/test-runner" $SUITES
+ exit "$?"
+fi
+
# Step 0: fast build/security harness regressions run before the compiler-heavy
# suite. The Windows package surface is static here; native launcher behavior is
# exercised by scripts/test-windows.ps1.
@@ -91,6 +227,9 @@ bash "$ROOT/tests/test_smoke_fixture_contract.sh"
echo "=== Step 0i: parallel suite scheduler contract ==="
bash "$ROOT/tests/test_parallel_harness_contract.sh"
+echo "=== Step 0j: venue parity contract (one harness, every venue) ==="
+bash "$ROOT/tests/test_venue_parity_contract.sh"
+
# Verify compiler supports target arch
verify_compiler "$CC"
diff --git a/test-infrastructure/README.md b/test-infrastructure/README.md
new file mode 100644
index 000000000..ee2b1e699
--- /dev/null
+++ b/test-infrastructure/README.md
@@ -0,0 +1,42 @@
+# test-infrastructure/ — the local venues
+
+The local half of the 3-OS CI ladder. **Every leg here runs the SAME canonical
+scripts CI runs** (`scripts/test.sh`, `build.sh`, `smoke-local.sh`,
+`soak-legs.sh`, `vm-smoke.sh` — see `scripts/README.md`); this directory only
+provisions containers and the Windows VM. The venue-parity contract
+(`tests/test_venue_parity_contract.sh`, Step 0j of every test leg) fails the
+build if a venue grows its own harness logic — here or in the workflows.
+
+## Entry points
+
+| venue | entry | notes |
+|---|---|---|
+| Linux (arm64 + amd64) + cross-compile | `./run.sh <leg>` (`--help` for the leg list) | Colima only — Docker Desktop is broken on this machine. A clean-disk preflight (`scripts/ci/preflight-docker.sh`) runs before every leg: GitHub runners are ephemeral with a known-free 14 GB disk, so the long-lived VM is swept back to that shape first. |
+| Real Windows (UTM ARM64 VM) | `vm/win.sh <command>` (`win.sh help`) | Same preflight idea (`scripts/ci/clean-test-residue.ps1`), plus CI's protected per-user TEMP root. Wine (`run.sh windows`) is a compile check only — never a substitute for the VM. |
+| macOS | run the canonical scripts natively | `scripts/test.sh`, `scripts/build.sh`, `scripts/smoke-local.sh …` |
+
+## The ladder (before any push)
+
+1. `scripts/test.sh` — macOS native (or `--suites …` while iterating)
+2. `./test-infrastructure/run.sh full` — Linux arm64 test/build/TSan/smoke/portable + mingw cross-compile (+ `amd64`, `soak-linux` as needed)
+3. `vm/win.sh test-par` · `guards` · `smoke-install` · `soak` — the real-Windows legs
+
+Infra unavailable = a run blocker to escalate — never a silent bypass.
+
+## Fidelity guarantees (what makes local predictive of CI)
+
+- **Same scripts, same sequence, same flags** — platform specifics (e.g. the
+ CLANGARM64 trap-UBSan default) live inside the canonical entries, applied
+ identically everywhere.
+- **Same environment shape** — protected TEMP roots, sandboxed smoke, clean
+ builds with the content-verified ccache (a hit is byte-identical to a cold
+ compile; caches only accelerate, never change results).
+- **Same starting disk** — preflights sweep residue and BLOCK below the
+ runner's 14 GB floor (a quietly full disk fails inside install paths and
+ masquerades as a product bug).
+- **Known, deliberate residuals** — runner physics (4 vCPU vs local cores,
+ shared tenancy), Defender ON in the VM vs OFF on GitHub runners, no TSan on
+ Windows anywhere, no ASan runtime on native ARM64 Windows (trap-UBSan +
+ PageHeap stand in).
+
+See `vm/README.md` for VM provisioning and day-to-day VM mechanics.
diff --git a/test-infrastructure/docker-compose.yml b/test-infrastructure/docker-compose.yml
index 9e2a62239..600abbbc1 100644
--- a/test-infrastructure/docker-compose.yml
+++ b/test-infrastructure/docker-compose.yml
@@ -70,7 +70,9 @@ services:
# seccomp profile — unconfined is safe here (the container runs only our own
# test code). The no-randomize personality inherits to the make child.
security_opt: ["seccomp=unconfined"]
- entrypoint: ["setarch", "-R", "make", "-f", "Makefile.cbm", "test-tsan"]
+ # The TSan leg lives in the canonical test entry (scripts/test.sh --tsan),
+ # same as CI's tsan jobs; the no-randomize personality inherits through it.
+ entrypoint: ["setarch", "-R", "bash", "scripts/test.sh", "--tsan"]
command: ["CC=gcc", "CXX=g++", "BUILD_DIR=build/linux-arm64-tsan"]
test-tsan-amd64:
@@ -88,7 +90,8 @@ services:
CCACHE_DIR: /root/.ccache
CCACHE_MAXSIZE: 1500M
security_opt: ["seccomp=unconfined"]
- entrypoint: ["setarch", "-R", "make", "-f", "Makefile.cbm", "test-tsan"]
+ # Canonical test entry, TSan mode — same file as CI's tsan jobs.
+ entrypoint: ["setarch", "-R", "bash", "scripts/test.sh", "--tsan"]
command: ["CC=gcc", "CXX=g++", "BUILD_DIR=build/linux-amd64-tsan"]
# ── Linux production build (-O2 -Werror) ───────────────────
@@ -165,6 +168,24 @@ services:
scripts/build.sh CC=gcc CXX=g++ BUILD_DIR=build/linux-amd64 &&
scripts/smoke-local.sh ./build/linux-amd64/codebase-memory-mcp
+ # ── Soak (both CI legs) ────────────────────────────────────
+ # The sequence (quick + #581 query-leak) lives in the canonical entry
+ # scripts/soak-legs.sh — the same file _soak.yml and the Windows VM run.
+ # The local ladder previously had NO unix soak at all. Duration follows
+ # CBM_SOAK_MINUTES (default 10, matching the dry run).
+ soak:
+ build:
+ context: ..
+ dockerfile: test-infrastructure/Dockerfile
+ platform: linux/arm64
+ volumes:
+ - ..:/src
+ entrypoint: ["/bin/bash", "-c"]
+ command:
+ - |
+ scripts/build.sh CC=gcc CXX=g++ BUILD_DIR=build/linux-arm64 &&
+ scripts/soak-legs.sh ./build/linux-arm64/codebase-memory-mcp ${CBM_SOAK_MINUTES:-10}
+
# ── Windows smoke (cross-compile + Wine) ──────────────────
smoke-windows:
build:
@@ -216,7 +237,7 @@ services:
scripts/build.sh CC=gcc CXX=g++ STATIC=1 BUILD_DIR=build/alpine &&
file build/alpine/codebase-memory-mcp | grep -q "statically linked" &&
echo "=== Verified: statically linked ===" &&
- scripts/smoke-test.sh ./build/alpine/codebase-memory-mcp
+ scripts/smoke-local.sh ./build/alpine/codebase-memory-mcp
# ── Lint ────────────────────────────────────────────────────
lint:
diff --git a/test-infrastructure/run.sh b/test-infrastructure/run.sh
index 0c1b536e9..e15e0fa87 100755
--- a/test-infrastructure/run.sh
+++ b/test-infrastructure/run.sh
@@ -27,7 +27,8 @@
# ./test-infrastructure/run.sh all # above + amd64 + Windows Wine smoke
# ./test-infrastructure/run.sh portable # Alpine portable build + smoke only
# ./test-infrastructure/run.sh windows # Windows cross-compile only
-# ./test-infrastructure/run.sh soak-windows # native Windows VM, 10 min
+# ./test-infrastructure/run.sh soak-linux # arm64 soak: quick + query-leak
+# ./test-infrastructure/run.sh soak-windows # native Windows VM, both legs
# ./test-infrastructure/run.sh test # Linux arm64 test only (no perf)
# ./test-infrastructure/run.sh perf # Linux arm64 perf/incremental only
# ./test-infrastructure/run.sh tsan # Linux arm64 ThreadSanitizer race gate
@@ -57,6 +58,44 @@ set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
COMPOSE="docker compose -f $ROOT/test-infrastructure/docker-compose.yml"
+usage() {
+ cat <<'EOF'
+Usage: test-infrastructure/run.sh [leg]
+
+The Linux (and cross-compile) local-CI ladder, on Colima. Every leg runs the
+SAME canonical scripts CI runs (scripts/test.sh, build.sh, smoke-local.sh,
+soak-legs.sh) inside pinned containers; this wrapper only picks the container
+and platform. A clean-disk preflight (scripts/ci/preflight-docker.sh) runs
+first — CBM_SKIP_PREFLIGHT=1 skips it, CBM_PREFLIGHT_ARGS=--deep widens it.
+
+Legs:
+ full (default) arm64: test + build + TSan + smoke + portable smoke
+ + Windows mingw cross-compile check
+ all full + amd64 legs + Windows cross-compile/Wine check
+ test|build|smoke|tsan single arm64 legs
+ amd64|test-amd64|tsan-amd64 amd64 legs (tsan-amd64 needs real amd64 HW)
+ perf arm64 incremental-perf leg (CBM_SKIP_PERF unset)
+ shell|shell-alpine interactive debug shell inside the image
+ portable|portable-test Alpine musl static build legs
+ soak-linux both CI soak legs (quick + #581 query-leak) via
+ scripts/soak-legs.sh; CBM_SOAK_MINUTES per leg (default 10)
+ soak-windows delegates to the real-Windows VM (win.sh soak 10)
+
+Environment:
+ CBM_SOAK_MINUTES soak-linux duration per leg (default 10)
+ CBM_LOCAL_CI_CPUS opt-in CPU cap for smoke/soak starvation checks only
+ (the regular suite always runs full-parallel)
+ CBM_SKIP_PREFLIGHT=1 / CBM_PREFLIGHT_ARGS=--deep preflight controls
+ windows|smoke-windows mingw cross-compile + Wine version check
+ lint containerized cppcheck + clang-format (CI image)
+ -h, --help This text.
+
+Real-Windows legs (test/guards/smoke-install/soak) live in
+test-infrastructure/vm/win.sh — Wine is a compile check only.
+EOF
+}
+case "${1:-}" in -h|--help) usage; exit 0 ;; esac
+
print_real_windows_gate() {
echo "=== Container/cross-compile legs passed ==="
echo "=== Real-Windows gate remains: vm/win.sh sync, test, guards, smoke-install ==="
@@ -79,6 +118,17 @@ if ! docker compose version >/dev/null 2>&1; then
exit 1
fi
+# A GitHub runner starts every job on a fresh image with a known-free disk;
+# Colima is long-lived and accumulates exited containers and orphaned volumes.
+# Sweep that back to the runner's shape and assert free space before any leg,
+# so a disk that has quietly filled fails here rather than surfacing as a bogus
+# product failure deep inside an install path. CBM_PREFLIGHT_ARGS=--deep also
+# reclaims the build cache; CBM_SKIP_PREFLIGHT=1 opts out for a quick re-run.
+if [ "${CBM_SKIP_PREFLIGHT:-0}" != "1" ]; then
+ # shellcheck disable=SC2086 # deliberate word-splitting of opt-in flags
+ "$ROOT/scripts/ci/preflight-docker.sh" ${CBM_PREFLIGHT_ARGS:-}
+fi
+
case "${1:-full}" in
full)
echo "=== Linux arm64: test + build ==="
@@ -123,6 +173,14 @@ case "${1:-full}" in
echo "=== Linux arm64: smoke test (build + run all phases) ==="
$COMPOSE run --rm smoke
;;
+ soak-linux)
+ # Both CI legs (quick + #581 query-leak). Duration via CBM_SOAK_MINUTES,
+ # default 10 to match the dry run. Kept out of `full`/`all` for the same
+ # reason soak-windows is: it is a ~20-minute endurance gate, not part of
+ # the fast ladder.
+ echo "=== Linux arm64: soak (quick + query-leak, ${CBM_SOAK_MINUTES:-10}m each) ==="
+ $COMPOSE run --rm soak
+ ;;
portable)
echo "=== Linux portable: Alpine static build + smoke ==="
$COMPOSE run --rm smoke-portable
@@ -176,7 +234,7 @@ case "${1:-full}" in
$COMPOSE run --rm --entrypoint bash test-portable
;;
*)
- echo "Usage: $0 {full|test|perf|tsan|tsan-amd64|build|smoke|portable|portable-test|windows|smoke-windows|soak-windows|amd64|all|lint|shell|shell-alpine}"
- exit 1
+ echo "run.sh: unknown leg '${1:-}'. Please consult --help." >&2
+ exit 2
;;
esac
diff --git a/test-infrastructure/vm/README.md b/test-infrastructure/vm/README.md
index 77fb53340..4551501bf 100644
--- a/test-infrastructure/vm/README.md
+++ b/test-infrastructure/vm/README.md
@@ -18,7 +18,9 @@ seconds-fast local loop with full stderr/debugger visibility.
|---|---|---|
| `windows-bootstrap.ps1` | inside the VM, once | OpenSSH + host key + CI owner-policy mirror |
| `provision-windows.sh` | on the host | zero → fully-built, idempotent (disk-loss recovery) |
-| `win.sh` | on the host | daily driver: build / test / guards / install-E2E / shell |
+| `win.sh` | on the host | daily driver (`win.sh help`): routes every venue-grade command through the canonical leg scripts (`scripts/build.sh`, `scripts/test.sh`, `vm-smoke.sh`, `soak-legs.sh`) with clean-disk preflight |
+| `vm-run-tests.sh` | inside the VM | provisioning wrapper (protected TEMP root + completion guard) around the canonical test/soak entries |
+| `vm-smoke.sh` | inside the VM / CI msys2 | THE canonical Windows smoke (also run verbatim by PR CI and `_smoke.yml`) |
Host-local config (never committed): `~/.claude/cbm-vm/config` with
`CBM_VM_HOST=<ip>`, `CBM_VM_USER=<user>`, and the
diff --git a/test-infrastructure/vm/vm-run-tests.sh b/test-infrastructure/vm/vm-run-tests.sh
index 5f20ec6d7..b87cce060 100644
--- a/test-infrastructure/vm/vm-run-tests.sh
+++ b/test-infrastructure/vm/vm-run-tests.sh
@@ -17,10 +17,38 @@
# completion summary is a hard failure regardless of exit code.
set -uo pipefail
-RUNNER="${CBM_VM_RUNNER:-build/c/test-runner}"
+usage() {
+ cat <<'EOF'
+Usage: bash test-infrastructure/vm/vm-run-tests.sh <suite...> | --par | --soak <minutes>
+
+VM-side provisioning wrapper (runs ON the Windows VM, invoked by win.sh —
+call `win.sh test|test-par|soak` from the host, not this file). Supplies the
+CI-shaped protected per-user temp root (scripts/ci/new-protected-temp-root.ps1)
+and full-output logging with a completion-summary guard, then routes into the
+CANONICAL entries:
+
+ <suite...> scripts/test.sh --suites <list> (iteration mode)
+ --par scripts/test.sh (the full venue leg)
+ --soak <mins> scripts/soak-legs.sh (both CI soak legs)
+
+Environment:
+ CBM_VM_RUNNER sanitizer-variant runner path (ubsan/trap-ubsan builds);
+ switches to direct-runner mode for those iteration tools.
+ CBM_VM_SOAK_BINARY product binary for --soak (default build/c/codebase-memory-mcp.exe)
+ CBM_VM_TEST_LOG VM-side log path (default /tmp/win-test.log)
+
+Exit codes: 0 success · 2 usage · 90 = GUARD: no completion summary (a run
+that died without its summary must never read as green) · else the leg's code.
+EOF
+}
+case "${1:-}" in
+-h | --help) usage; exit 0 ;;
+esac
+
+RUNNER="${CBM_VM_RUNNER:-}"
LOG="${CBM_VM_TEST_LOG:-/tmp/win-test.log}"
-[ $# -ge 1 ] || { echo "usage: vm-run-tests.sh <suite...> | --par" >&2; exit 2; }
+[ $# -ge 1 ] || { echo "vm-run-tests: missing arguments. Please consult --help." >&2; exit 2; }
if [ "$1" = "--soak" ]; then
[ $# -eq 2 ] || { echo "usage: vm-run-tests.sh --soak <positive-minutes>" >&2; exit 2; }
duration="$2"
@@ -32,34 +60,28 @@ if [ "$1" = "--soak" ]; then
binary="${CBM_VM_SOAK_BINARY:-build/c/codebase-memory-mcp.exe}"
[ -x "$binary" ] || { echo "ERROR: binary '$binary' missing — build first" >&2; exit 2; }
artifact="$binary"
-else
+elif [ -n "$RUNNER" ]; then
+ # Explicit CBM_VM_RUNNER = the sanitizer-variant iteration mode (ubsan /
+ # trap-ubsan runners built into their own BUILD_DIRs by win.sh). Those
+ # builds carry non-default flags, so they keep the direct-runner path.
[ -x "$RUNNER" ] || { echo "ERROR: runner '$RUNNER' missing — build first" >&2; exit 2; }
artifact="$RUNNER"
+else
+ # Default path: suites run through the canonical scripts/test.sh (which
+ # builds its own runner, same as CI's test jobs). ACL-protect the build
+ # directory it will use.
+ artifact="build/c/test-runner"
fi
# Stale roots from earlier runs are removed up front; the current root is kept
-# after the run for post-mortem inspection.
-root_windows="$(powershell -NoProfile -Command '
- $ErrorActionPreference = "Stop"
- Get-ChildItem -LiteralPath $env:USERPROFILE -Directory -Filter "cbm-vm-tmp-*" -ErrorAction SilentlyContinue |
- Remove-Item -Recurse -Force -ErrorAction SilentlyContinue
- $root = Join-Path $env:USERPROFILE ("cbm-vm-tmp-" + [guid]::NewGuid().ToString("N"))
- New-Item -ItemType Directory -Path $root | Out-Null
- $sid = [System.Security.Principal.WindowsIdentity]::GetCurrent().User
- $acl = [System.Security.AccessControl.DirectorySecurity]::new()
- $acl.SetOwner($sid)
- $acl.SetAccessRuleProtection($true, $false)
- $rule = [System.Security.AccessControl.FileSystemAccessRule]::new(
- $sid,
- [System.Security.AccessControl.FileSystemRights]::FullControl,
- ([System.Security.AccessControl.InheritanceFlags]::ContainerInherit -bor
- [System.Security.AccessControl.InheritanceFlags]::ObjectInherit),
- [System.Security.AccessControl.PropagationFlags]::None,
- [System.Security.AccessControl.AccessControlType]::Allow)
- $acl.AddAccessRule($rule) | Out-Null
- Set-Acl -LiteralPath $root -AclObject $acl
- Write-Output $root
-' | tr -d '\r')"
+# after the run for post-mortem inspection. The root itself is created by the
+# same script CI uses (scripts/ci/new-protected-temp-root.ps1) so the two venues
+# cannot drift apart on the ACL shape the daemon suites are validated against.
+root_windows="$(MSYS2_ARG_CONV_EXCL='*' powershell.exe -NoProfile \
+ -ExecutionPolicy Bypass \
+ -File "$(cygpath -w scripts/ci/new-protected-temp-root.ps1)" \
+ -Prefix 'cbm-vm-tmp-' -PruneStale \
+ -ProtectDir "$(cygpath -w "$(dirname "$artifact")")" | tr -d '\r')"
[ -n "$root_windows" ] || { echo "ERROR: protected temp root creation failed" >&2; exit 2; }
TEMP="$(cygpath -m "$root_windows")"
@@ -85,25 +107,33 @@ MSYS2_ARG_CONV_EXCL='*' icacls "${runner_dir_w}\\*" /reset /T /C /Q >/dev/null 2
echo "=== vm-run-tests: runner=$RUNNER temp=$TEMP suites: $* ==="
if [ "$1" = "--soak" ]; then
- echo "=== vm-run-tests: binary=$binary temp=$TEMP soak=${duration}m ==="
- scripts/soak-test.sh "$binary" "$duration" 2>&1 | tee "$LOG"
- rc="${PIPESTATUS[0]}"
- if ! grep -Fq '=== soak-test: PASSED ===' "$LOG"; then
- echo "GUARD: native Windows soak produced no completion summary; treating as failure " \
- "(soak rc=$rc)" >&2
- exit 90
- fi
- exit "$rc"
+ # The sequence (quick + #581 query-leak) and its completion guards live in
+ # the canonical entry scripts/soak-legs.sh — the same file _soak.yml and the
+ # compose soak service run. This wrapper only supplies the CI-shaped
+ # protected temp root (above) and the persistent VM-side log.
+ echo "=== vm-run-tests: soak binary=$binary temp=$TEMP ${duration}m/leg ==="
+ scripts/soak-legs.sh "$binary" "$duration" 2>&1 | tee "$LOG"
+ exit "${PIPESTATUS[0]}"
fi
-# --par runs the repo's full parallel harness (wave + tail scheduling,
-# per-shard union guard, manifest) under this same protected environment;
-# explicit suite names keep the direct single-runner invocation.
-if [ "$1" = "--par" ]; then
- bash scripts/run-tests-parallel.sh "$RUNNER" 2>&1 | tee "$LOG"
+# Both paths run the CANONICAL test entry scripts/test.sh under this protected
+# environment — the same file every CI test leg runs:
+# --par the full venue leg (clean build + contracts + parallel suites)
+# <suite...> scripts/test.sh --suites — the documented iteration mode
+# Only an explicit CBM_VM_RUNNER (sanitizer-variant builds) bypasses test.sh.
+if [ -n "$RUNNER" ]; then
+ if [ "$1" = "--par" ]; then
+ bash scripts/run-tests-parallel.sh "$RUNNER" 2>&1 | tee "$LOG"
+ rc="${PIPESTATUS[0]}"
+ else
+ "$RUNNER" "$@" 2>&1 | tee "$LOG"
+ rc="${PIPESTATUS[0]}"
+ fi
+elif [ "$1" = "--par" ]; then
+ scripts/test.sh CC=clang CXX=clang++ 2>&1 | tee "$LOG"
rc="${PIPESTATUS[0]}"
else
- "$RUNNER" "$@" 2>&1 | tee "$LOG"
+ scripts/test.sh --suites "$*" CC=clang CXX=clang++ 2>&1 | tee "$LOG"
rc="${PIPESTATUS[0]}"
fi
diff --git a/test-infrastructure/vm/vm-smoke.sh b/test-infrastructure/vm/vm-smoke.sh
index c4030d4b1..8d3d7de79 100755
--- a/test-infrastructure/vm/vm-smoke.sh
+++ b/test-infrastructure/vm/vm-smoke.sh
@@ -1,5 +1,8 @@
#!/usr/bin/env bash
-# vm-smoke.sh — run the PR smoke inside the Windows VM exactly as CI does.
+# vm-smoke.sh — the ONE Windows smoke harness. Every venue calls this script:
+# local CI (win.sh smoke-install), PR CI (pr.yml pr-smoke) and the release
+# venues (_smoke.yml). They differ only in host specs, architecture, and which
+# binaries they hand it — never in what the smoke does.
#
# Stages and serves a complete Windows release fixture from a profile-rooted
# directory. MSYS2 /tmp and the shared runner workspace are intentionally not
@@ -10,22 +13,81 @@
# Or from the host: test-infrastructure/vm/win.sh smoke-install
set -euo pipefail
+usage() {
+ cat <<'EOF'
+Usage: [env] bash test-infrastructure/vm/vm-smoke.sh
+
+The canonical WINDOWS smoke entry: identical in local CI (win.sh
+smoke-install), PR CI (pr.yml) and the release venues (_smoke.yml). Stages a
+complete launcher+payload release fixture under a disposable profile root,
+serves it on a kernel-assigned port, prepares/verifies/cleans the user-PATH
+registry via windows-user-path-guard.ps1, neutralizes every agent-config
+destination override, then runs scripts/smoke-test.sh (all phases).
+
+Run inside the VM's CLANGARM64 shell (or a CI msys2 shell) from the repo root.
+
+Environment:
+ SMOKE_ARCH arm64 (default) | amd64 — selects the served artifact name.
+ SMOKE_VARIANT standard (default) | ui. ui requires the embedded UI:
+ Phase 15's "no assets" SKIP becomes a FAILURE, so a standard
+ binary cannot pass a ui run.
+ CBM_SMOKE_ARTIFACT_DIR
+ Release mode: an EXTRACTED windows release artifact
+ (codebase-memory-mcp.exe + .payload.exe + LICENSE +
+ install.ps1 + THIRD_PARTY_NOTICES.md). All five are required
+ and served verbatim — an incomplete archive fails the smoke.
+ Unset (default): stages the freshly built launcher/payload
+ out of build/c and synthesizes the sidecars (local/PR mode).
+
+On failure the smoke root is preserved for post-mortem (path printed).
+EOF
+}
+case "${1:-}" in
+-h|--help) usage; exit 0 ;;
+?*) echo "vm-smoke: unexpected argument '$1' (configuration is via environment). Please consult --help." >&2; exit 2 ;;
+esac
+
cd "$(dirname "$0")/../.."
ROOT="$PWD"
-for binary in build/c/codebase-memory-mcp-launcher.exe build/c/codebase-memory-mcp.exe; do
- [ -x "$binary" ] || { echo "build first; missing $binary" >&2; exit 2; }
-done
+
+# Two staging sources, one smoke. Unset (the local + PR default): stage the
+# freshly built launcher/payload out of build/c and synthesize the release
+# sidecars. Set: stage an EXTRACTED release artifact verbatim, so the release
+# venue smokes the bytes it is about to publish rather than a local rebuild of
+# them. Requiring the sidecars here also makes an incomplete archive a smoke
+# failure instead of a discovery made after publishing.
+ARTIFACT_DIR="${CBM_SMOKE_ARTIFACT_DIR:-}"
+if [ -n "$ARTIFACT_DIR" ]; then
+ ARTIFACT_DIR="$(cd "$ARTIFACT_DIR" && pwd)"
+ for required in codebase-memory-mcp.exe codebase-memory-mcp.payload.exe \
+ LICENSE install.ps1 THIRD_PARTY_NOTICES.md; do
+ [ -s "$ARTIFACT_DIR/$required" ] ||
+ { echo "vm-smoke: release artifact is missing $required" >&2; exit 2; }
+ done
+ LAUNCHER_SRC="$ARTIFACT_DIR/codebase-memory-mcp.exe"
+ PAYLOAD_SRC="$ARTIFACT_DIR/codebase-memory-mcp.payload.exe"
+else
+ LAUNCHER_SRC="build/c/codebase-memory-mcp-launcher.exe"
+ PAYLOAD_SRC="build/c/codebase-memory-mcp.exe"
+ for binary in "$LAUNCHER_SRC" "$PAYLOAD_SRC"; do
+ [ -x "$binary" ] || { echo "build first; missing $binary" >&2; exit 2; }
+ done
+fi
SMOKE_ARCH="${SMOKE_ARCH:-arm64}"
SMOKE_VARIANT="${SMOKE_VARIANT:-standard}"
case "$SMOKE_ARCH" in
arm64 | amd64) ;;
-*) echo "vm-smoke: SMOKE_ARCH must be arm64 or amd64" >&2; exit 2 ;;
+*) echo "vm-smoke: SMOKE_ARCH must be arm64 or amd64. Please consult --help." >&2; exit 2 ;;
esac
+# A ui run must be handed a binary that actually carries the embedded assets;
+# the suffix alone only renames the archive. SMOKE_REQUIRE_UI turns Phase 15's
+# documented "no embedded assets" SKIP into a failure, so asking for ui and
+# supplying a standard binary can no longer pass quietly.
case "$SMOKE_VARIANT" in
-standard) SUFFIX="" ;;
-ui) SUFFIX="-ui" ;;
-*) echo "vm-smoke: SMOKE_VARIANT must be standard or ui" >&2; exit 2 ;;
+standard) SUFFIX="" ; REQUIRE_UI=0 ;;
+ui) SUFFIX="-ui" ; REQUIRE_UI=1 ;;
+*) echo "vm-smoke: SMOKE_VARIANT must be standard or ui. Please consult --help." >&2; exit 2 ;;
esac
PROFILE_ROOT="$(cygpath -u "$USERPROFILE")"
@@ -87,12 +149,20 @@ MSYS2_ARG_CONV_EXCL='*' powershell.exe -NoProfile -ExecutionPolicy Bypass \
-RunId "$PATH_RUN_ID" \
-SnapshotPath "$(cygpath -w "$PATH_SNAPSHOT")" \
-SmokeRoot "$(cygpath -w "$SMOKE_DIR")"
-cp build/c/codebase-memory-mcp-launcher.exe "$SMOKE_DIR/codebase-memory-mcp.exe"
-cp build/c/codebase-memory-mcp.exe "$SMOKE_DIR/codebase-memory-mcp.payload.exe"
+cp "$LAUNCHER_SRC" "$SMOKE_DIR/codebase-memory-mcp.exe"
+cp "$PAYLOAD_SRC" "$SMOKE_DIR/codebase-memory-mcp.payload.exe"
cp "$SMOKE_DIR/codebase-memory-mcp.exe" \
- "$SMOKE_DIR/codebase-memory-mcp.payload.exe" \
- LICENSE install.ps1 "$FIXTURE_DIR/"
-scripts/gen-third-party-notices.sh "$FIXTURE_DIR/THIRD_PARTY_NOTICES.md"
+ "$SMOKE_DIR/codebase-memory-mcp.payload.exe" "$FIXTURE_DIR/"
+# The install/update phases fetch these out of the served archive, so they must
+# be the artifact's own copies whenever one was supplied — regenerating them
+# here would smoke a sidecar the release never ships.
+if [ -n "$ARTIFACT_DIR" ]; then
+ cp "$ARTIFACT_DIR/LICENSE" "$ARTIFACT_DIR/install.ps1" \
+ "$ARTIFACT_DIR/THIRD_PARTY_NOTICES.md" "$FIXTURE_DIR/"
+else
+ cp LICENSE install.ps1 "$FIXTURE_DIR/"
+ scripts/gen-third-party-notices.sh "$FIXTURE_DIR/THIRD_PARTY_NOTICES.md"
+fi
EXPECTED_ARTIFACT="codebase-memory-mcp${SUFFIX}-windows-${SMOKE_ARCH}.zip"
(
@@ -176,6 +246,7 @@ env \
SMOKE_DOWNLOAD_URL="http://127.0.0.1:$PORT" \
SMOKE_UPDATE_FIXTURE_DIR="$FIXTURE_DIR" \
SMOKE_ARCH="$SMOKE_ARCH" \
+ SMOKE_REQUIRE_UI="$REQUIRE_UI" \
scripts/smoke-test.sh "$SMOKE_DIR/codebase-memory-mcp.exe"
MSYS2_ARG_CONV_EXCL='*' powershell.exe -NoProfile -ExecutionPolicy Bypass \
diff --git a/test-infrastructure/vm/win.sh b/test-infrastructure/vm/win.sh
index 2bba1dbc2..6d9d781d5 100755
--- a/test-infrastructure/vm/win.sh
+++ b/test-infrastructure/vm/win.sh
@@ -13,7 +13,7 @@
# win.sh test <suite...> # run test-runner suites (native ARM64)
# win.sh guards # clean UI product build + Windows guards
# win.sh smoke-install # real managed-install E2E (Phase 8 class)
-# win.sh soak [minutes] # native daemon endurance gate (default 10m)
+# win.sh soak [minutes] # both CI soak legs: quick + #581 query-leak
# win.sh sh <command...> # arbitrary command in CLANGARM64 env
# win.sh push-file <local> <vm> # scp one file into the VM (WIP iteration)
# win.sh test-par # full suite, parallel on all VM cores
@@ -22,6 +22,60 @@
# win.sh pageheap on|off # OS heap verification for native runs
set -euo pipefail
+# help must not require a configured VM: agents discovering the tooling read
+# --help before anything exists. Handled before config/ssh setup.
+print_help() {
+ cat <<'EOF'
+Usage: test-infrastructure/vm/win.sh <command> [args]
+
+Daily driver for the real-Windows leg of local CI (UTM ARM64 VM over ssh).
+Every venue-grade command routes through the CANONICAL leg scripts — the same
+files CI runs (scripts/build.sh, scripts/test.sh, vm-smoke.sh, soak-legs.sh);
+this wrapper only provisions (ssh, clock sync, clean-disk preflight, protected
+temp root). Config: ~/.claude/cbm-vm/config (CBM_VM_HOST, CBM_VM_USER,
+CBM_VM_HOST_KEY_SHA256); key: ~/.claude/cbm-vm/id_ed25519; first-time setup:
+test-infrastructure/vm/provision-windows.sh.
+
+Commands (venue-grade — canonical entries, preflight enforced):
+ update fetch+reset the VM repo to the pushed branch, rebuild
+ sync mirror this uncommitted worktree to the VM, rebuild
+ build scripts/build.sh (CLEAN + content-verified ccache)
+ test <suite...> scripts/test.sh --suites (iteration mode: incremental
+ rebuild, subset run, seconds; list suites with
+ `win.sh sh 'build/c/test-runner --list-suites'`)
+ test-par scripts/test.sh — THE full Windows ladder leg (clean
+ build + contracts + all suites + guards, as CI runs it)
+ guards clean UI product build + Windows guard suite (CI shape)
+ smoke-install scripts/build.sh + vm-smoke.sh — exactly PR CI's
+ windows smoke job
+ soak [minutes] both CI soak legs via scripts/soak-legs.sh (default 10)
+
+Sanitizer variants (documented iteration tools; direct-runner mode):
+ ubsan-build|ubsan-test <suite...> x86_64 UBSan under emulation (full
+ diagnostics; CI's exact x64 arch)
+ trap-ubsan-build|trap-ubsan-test <...> native ARM64 trap-mode UBSan (a UB
+ hit is a SIGILL trap; diagnose via
+ the emulated ubsan pair)
+ pageheap on|off OS heap verification for the native runner (IFEO)
+
+Plumbing (no preflight):
+ status reachability + repo + build state
+ sh <command...> arbitrary command in the CLANGARM64 shell
+ push-file <src> <dst> scp one file into the VM (WIP iteration)
+ help this text
+
+Environment:
+ CBM_VM_BRANCH branch for update (default: current local branch)
+ CBM_VM_MIN_FREE_GB preflight free-disk floor (default 14, runner spec)
+ CBM_VM_SKIP_PREFLIGHT=1 bootstrap-only escape (checkout predates the script)
+
+Exit codes: 0 success · 2 usage error · other = the canonical leg's own code.
+EOF
+}
+case "${1:-}" in
+help | -h | --help) print_help; exit 0 ;;
+esac
+
CONFIG="${HOME}/.claude/cbm-vm/config"
KEY="${HOME}/.claude/cbm-vm/id_ed25519"
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
@@ -62,10 +116,36 @@ vm() { local env="$1"; shift
"${SSH[@]}" "C:\\msys64\\msys2_shell.cmd -defterm -no-start -${env} -c \"set -e -o pipefail; $*\""; }
vm_cmd() { "${SSH[@]}" "$@"; } # plain cmd.exe (CI-shaped environment)
+# A GitHub runner is ephemeral: every job starts on a fresh image with a
+# known-free disk. This VM is long-lived, so each run leaves temp roots and
+# ~100 MB staged binary copies behind. Sweep them and assert runner-like free
+# space BEFORE any build or run, so the local venue never tests a shape CI
+# would not produce — and so a disk that has quietly filled fails here, loudly,
+# instead of surfacing as a bogus ERROR_DISK_FULL inside the install path.
+# CBM_VM_SKIP_PREFLIGHT=1 exists for ONE case: bootstrapping a VM whose
+# checkout predates this script, where `update`/`sync` must run before the
+# script can exist there. Sweep manually first — it is not a way to run on a
+# disk that failed the gate.
+vm_preflight() {
+ [ "${CBM_VM_SKIP_PREFLIGHT:-0}" = "1" ] && {
+ echo "=== win.sh: preflight SKIPPED (CBM_VM_SKIP_PREFLIGHT=1) ==="
+ return 0
+ }
+ vm_cmd "powershell -NoProfile -ExecutionPolicy Bypass -File \
+C:\\cbm\\scripts\\ci\\clean-test-residue.ps1 -MinFreeGB ${CBM_VM_MIN_FREE_GB:-14}"
+}
+
cmd="${1:-status}"; shift || true
-if [ "$cmd" != "status" ]; then
- cbm_vm_sync_windows_clock "${SSH[@]}"
-fi
+case "$cmd" in
+status | help | -h | --help) ;;
+*) cbm_vm_sync_windows_clock "${SSH[@]}" ;;
+esac
+# Inspection and plumbing commands need no clean disk; anything that builds or
+# runs on the VM does.
+case "$cmd" in
+status | sh | push-file | pageheap | help | -h | --help) ;;
+*) vm_preflight ;;
+esac
case "$cmd" in
status)
"${SSH[@]}" "echo VM_REACHABLE & ver"
@@ -107,13 +187,20 @@ sync)
exec "$0" build
;;
build)
- vm clangarm64 "cd /c/cbm && make -j${JOBS} -f Makefile.cbm CC='ccache clang' CXX='ccache clang++' SANITIZE= cbm build/c/test-runner > /tmp/win-build.log 2>&1 && echo BUILD_OK || (echo BUILD_FAIL; tail -20 /tmp/win-build.log; exit 1)"
+ # The canonical build entry, exactly as CI runs it: a CLEAN scripts/build.sh
+ # (product binary + launcher). ccache engages through env.sh's masquerade
+ # (content-verified, so a warm cache only accelerates, never goes stale) —
+ # NOT via CC='ccache clang', which bypassed the verified-cache env layer.
+ # The test-runner is no longer built here: the test leg (scripts/test.sh)
+ # builds its own runner, same as CI's test jobs.
+ vm clangarm64 "cd /c/cbm && scripts/build.sh CC=clang CXX=clang++ > /tmp/win-build.log 2>&1 && echo BUILD_OK || (echo BUILD_FAIL; tail -20 /tmp/win-build.log; exit 1)"
;;
test)
[ $# -ge 1 ] || { echo "usage: win.sh test <suite...>" >&2; exit 2; }
- # vm-run-tests.sh gives the suites CI's protected per-user temp root
- # (daemon suites fail closed on the MSYS-shared /tmp), streams the FULL
- # output, and refuses to report success without the runner's completion
+ # Suites run through the CANONICAL scripts/test.sh --suites (incremental
+ # rebuild, subset run — the documented iteration mode), under CI's
+ # protected per-user temp root via vm-run-tests.sh, which streams FULL
+ # output and refuses to report success without the runner's completion
# summary. A `| tail -40` here once hid 40 real Windows failures.
vm clangarm64 "cd /c/cbm && bash test-infrastructure/vm/vm-run-tests.sh $*"
;;
@@ -138,9 +225,12 @@ guards)
vm_cmd "cd /d C:\\cbm && set PATH=C:\\msys64\\clangarm64\\bin;C:\\msys64\\usr\\bin;%PATH%&& powershell -NoProfile -ExecutionPolicy Bypass -File scripts\\test-windows.ps1 -GuardsOnly -Binary build\\guards\\codebase-memory-mcp.exe -Launcher build\\guards\\codebase-memory-mcp-launcher.exe -Make C:\\msys64\\usr\\bin\\make.exe"
;;
smoke-install)
- # Real managed install E2E with FULL stderr visible — the exact class the
- # CI smoke Phase 8 exercises, isolated beneath a disposable profile root.
- vm clangarm64 "cd /c/cbm && bash test-infrastructure/vm/vm-smoke.sh"
+ # EXACTLY the PR CI smoke job (pr.yml pr-smoke windows): a clean canonical
+ # build, then the canonical Windows smoke wrapper. The clean build wipes
+ # build/c (including any test-runner) just as CI's separate jobs imply;
+ # ccache keeps the rebuild to minutes — parity was the explicit user call
+ # over incremental speed here.
+ vm clangarm64 "cd /c/cbm && scripts/build.sh CC=clang CXX=clang++ && bash test-infrastructure/vm/vm-smoke.sh"
;;
soak)
duration="${1:-10}"
@@ -207,13 +297,18 @@ pageheap)
esac
;;
test-par)
- # Full-suite parallel run on all VM cores via the repo's parallel harness,
+ # THE Windows ladder test leg: the full canonical scripts/test.sh (clean
+ # sanitizer build + contract steps 0a-0j + all suites via the parallel
+ # harness + prod-binary guards) — exactly what CI's windows test legs run —
# under the CI-shaped protected temp root with FULL output (this leg once
# ran under the MSYS-shared /tmp and piped through `tail -25` — the same
# truncated-blindness class that hid 40 Windows failures from `test`).
vm clangarm64 "cd /c/cbm && CBM_VM_TEST_LOG=/tmp/win-test-par.log bash test-infrastructure/vm/vm-run-tests.sh --par"
;;
+help | -h | --help)
+ print_help
+ ;;
*)
- echo "unknown command: $cmd (see header for usage)" >&2; exit 2
+ echo "win.sh: unknown command '$cmd'. Please consult --help." >&2; exit 2
;;
esac
diff --git a/tests/test_venue_parity_contract.sh b/tests/test_venue_parity_contract.sh
new file mode 100644
index 000000000..26de4b668
--- /dev/null
+++ b/tests/test_venue_parity_contract.sh
@@ -0,0 +1,356 @@
+#!/usr/bin/env bash
+# Venue-parity contract: "a venue may PROVISION a machine; only a CANONICAL leg
+# script may EXERCISE the product."
+#
+# Why this exists: smoke ran on THREE harnesses until 2026-07-26 — local CI and
+# PR CI shared the wrappers while _smoke.yml carried a hand-copied YAML
+# reimplementation (no env sandbox, no user-PATH guard, fixed port); the soak
+# sequence existed as six hand-synced YAML step pairs; the arm64 sanitizer
+# flags lived inline in _test.yml where the local venue could not see them.
+# Each drift was invisible until a release-only leg went red. This contract
+# makes the drift itself the failure: every `run:` step in every VENUE workflow
+# is walked line by line, and each line must classify as provisioning, artifact
+# plumbing, or a call to a canonical leg entry — an unclassifiable line is a
+# red build naming the file, line and remedy. It runs as Step 0j of
+# scripts/test.sh, i.e. inside every venue it polices.
+#
+# Layers:
+# 1. FORBIDDEN markers — hard failures in ANY workflow (inline fixture
+# serving, direct smoke-test.sh/soak-test.sh calls, inline ACL code).
+# 2. Whitelist walk — every run-step line in the VENUE workflows classified.
+# 3. REQUIRED markers — the unification itself must stay referenced.
+# 4. Local venues — docker-compose services and the VM scripts must route
+# through the same canonical entries.
+# 5. Interface probes — every entry must answer --help (exit 0, "Usage:")
+# and reject unknown flags with exit 2 + "Please consult --help." so an
+# agent can always discover exactly what a run will do.
+#
+# Usage: tests/test_venue_parity_contract.sh [repo-root] (root override so
+# the suite can prove the contract FAILS on a violation, not just passes;
+# layer 5 runs only against the real repo root).
+
+set -euo pipefail
+
+ROOT="${1:-$(cd "$(dirname "$0")/.." && pwd)}"
+
+python3 - "$ROOT" <<'PYEOF'
+from __future__ import annotations
+
+import pathlib
+import re
+import sys
+
+root = pathlib.Path(sys.argv[1])
+workflows = root / ".github" / "workflows"
+
+failures: list[str] = []
+
+# ── The canonical leg entries (the ONLY product-exercising calls allowed) ──
+CANONICAL = re.compile(
+ r"scripts/(test|build|lint|clean|smoke-local|soak-legs|smoke-invariants)\.sh"
+ r"|test-infrastructure/vm/vm-smoke\.sh"
+ r"|scripts/ci/[a-z0-9-]+\.(sh|ps1|py)"
+ r"|scripts/security-[a-z0-9-]+\.sh"
+ r"|scripts/gen-third-party-notices\.sh"
+ r"|scripts/check-no-test-skips\.sh"
+ r"|scripts/check-lsp-originality\.sh"
+ r"|scripts/test-windows\.ps1"
+ r"|pkg/glama/verify\.sh"
+)
+
+# ── Layer 1: forbidden in ANY workflow (the known drift signatures) ──
+FORBIDDEN = [
+ (re.compile(r"http\.server"),
+ "inline fixture server — smoke-local.sh / vm-smoke.sh own serving"),
+ (re.compile(r"SMOKE_DOWNLOAD_URL|SMOKE_UPDATE_FIXTURE_DIR"),
+ "fixture-server env is wrapper-owned; pass CBM_SMOKE_ARTIFACT_DIR instead"),
+ (re.compile(r"scripts/smoke-test\.sh"),
+ "smoke-test.sh must be reached through smoke-local.sh / vm-smoke.sh"),
+ (re.compile(r"scripts/soak-test\.sh"),
+ "soak-test.sh must be reached through scripts/soak-legs.sh"),
+ (re.compile(r"scripts/run-tests-parallel\.sh"),
+ "the parallel harness must be reached through scripts/test.sh"),
+ (re.compile(r"AddAccessRule|SetAccessRuleProtection"),
+ "inline ACL construction — call scripts/ci/new-protected-temp-root.ps1"),
+]
+
+# ── Layer 2: the whitelist walk over VENUE workflows ──
+VENUE_WORKFLOWS = [
+ "pr.yml", "dry-run.yml", "release.yml", "nightly-soak.yml",
+ "_test.yml", "_smoke.yml", "_soak.yml", "_build.yml", "_lint.yml",
+ "smoke.yml",
+]
+
+# Provisioning / plumbing commands a venue may run (first word of a line).
+ALLOWED_CMDS = {
+ # package + toolchain provisioning
+ "sudo", "apt-get", "brew", "wget", "curl", "git", "cmake", "freshclam",
+ "clamscan", "systemctl",
+ # shell + env plumbing
+ "echo", "printf", "export", "cd", "set", "source", "eval", "env",
+ "if", "then", "else", "elif", "fi", "for", "while", "until", "do", "done",
+ "case", "esac", "break", "continue", "return", "shift", "read", "local",
+ "trap", "exit", "true", "ccache",
+ # file/artifact plumbing
+ "chmod", "mkdir", "cp", "mv", "rm", "tar", "unzip", "zip", "test",
+ "[", "[[", "sha256sum", "shasum", "cygpath", "mktemp", "ls", "cat",
+ "grep", "sed", "tee", "jq", "tr", "find", "file", "basename", "dirname",
+ # CI plumbing
+ "gh", "python3", "node", "codesign", "xcrun", "command", "awk",
+}
+# Per-file additions: _build.yml packages artifacts (its make invocation builds
+# the launcher exe for the zip — packaging, not a test leg) and drives npm for
+# the embedded UI; release.yml pushes finished artifacts to registries after
+# every product-exercising gate already ran; the brew tap smoke installs the
+# released formula.
+ALLOWED_EXTRA = {
+ "_build.yml": {"make", "npm", "strip", "install_name_tool", "otool", "ldd"},
+ # The npm-wrapper failure-handling test is its own leg (package.json's test
+ # script is its entry). RECORDED gap: it has no local-ladder equivalent.
+ "_test.yml": {"npm"},
+ "release.yml": {"npm", "pip", "pip3", "twine", "python", "make",
+ "./mcp-publisher"},
+ "_smoke.yml": {"codebase-memory-mcp"}, # brew-installed CLI version check
+}
+# Steps that are scanners/data-generators with inherently inline bodies, keyed
+# "<file>:<step name>". Additions here are DELIBERATE holes — keep tiny.
+EXEMPT_STEPS = {
+ "_smoke.yml:Windows Defender scan", # AV cmdlet exit-code interpretation
+ "_smoke.yml:Compute matrices", # pure JSON matrix data + jq
+ "_test.yml:Compute matrices",
+ "_test.yml:Compute shard matrix",
+}
+
+def classify_line(line: str, allowed: set[str]) -> bool:
+ s = line.strip()
+ if not s or s.startswith("#"):
+ return True
+ # Continuation fragments, closers, pipes into plumbing, pure data.
+ if s in {"|", "&&", "||", "}", "{", ")", "fi", "done", "esac", "then", "else"}:
+ return True
+ if s.startswith(("| ", "|| ", "&& ", ")")):
+ return True
+ first = s.split()[0]
+ # Direct test-runner EXECUTION (first token) — building it as a make
+ # target is packaging; running it bypasses scripts/test.sh.
+ if re.match(r'^"?[\w./-]*test-runner(\.exe)?"?$', first):
+ return False
+ # VAR=... — a pure assignment, a command-substitution value (classify the
+ # substituted command), or an env-prefixed command (classify the command).
+ m = re.match(r"^[A-Za-z_][A-Za-z0-9_]*=(.*)$", s)
+ if m:
+ value = m.group(1).strip()
+ if value.startswith("$("):
+ s = value[2:].strip()
+ if not s:
+ return True
+ else:
+ tokens = value.split(None, 1)
+ if len(tokens) == 2 and re.match(r"^[\w./-]+$", tokens[0]):
+ s = tokens[1].strip() # env-prefix form: VAR=x cmd ...
+ else:
+ return True # plain assignment (any value shape)
+ first = s.split()[0]
+ if first in {"bash", "sh", "pwsh", "powershell", "powershell.exe", "&"}:
+ # interpreter prefix: the thing being run must itself be canonical
+ return bool(CANONICAL.search(s))
+ if CANONICAL.search(s):
+ return True
+ # data fragments: quoted strings, JSON, heredoc bodies, YAML-ish keys
+ if re.match(r"""^["'\[{$(-]""", s) or s.endswith(("\\", "'", '"')):
+ return True
+ return first in allowed
+
+def walk_runs(path: pathlib.Path):
+ """Yield (step_name, line_number, line) for every run:-block line.
+ Indentation state machine over our own consistently-styled workflows —
+ an unrecognized run: form is itself a contract failure. Heredoc bodies
+ are opaque data (the OPENER line still gets classified)."""
+ name = "?"
+ lines = path.read_text().splitlines()
+ i = 0
+ while i < len(lines):
+ raw = lines[i]
+ m = re.match(r"^(\s*)- name:\s*(.+?)\s*$", raw)
+ if m:
+ name = m.group(2)
+ m = re.match(r"^(\s*)run:\s*(.*)$", raw)
+ if m:
+ indent, rest = len(m.group(1)), m.group(2)
+ if rest and rest not in {"|", "|-", ">-", ">"}:
+ yield name, i + 1, rest # single-line run
+ elif rest in {">-", ">"}:
+ failures.append(f"{path.name}:{i+1}: folded run: style — use `run: |`")
+ else: # block scalar
+ i += 1
+ heredoc = None
+ while i < len(lines):
+ body = lines[i]
+ if heredoc is not None:
+ if body.strip() == heredoc:
+ heredoc = None
+ i += 1
+ continue
+ if body.strip() and (len(body) - len(body.lstrip())) <= indent:
+ i -= 1
+ break
+ hd = re.search(r"<<-?\s*['\"]?(\w+)['\"]?", body)
+ if hd:
+ heredoc = hd.group(1)
+ yield name, i + 1, body
+ i += 1
+ i += 1
+
+seen = 0
+for path in sorted(workflows.glob("*.yml")):
+ text = path.read_text()
+ seen += 1
+ for number, line in enumerate(text.splitlines(), 1):
+ stripped = line.strip()
+ if stripped.startswith("#"):
+ continue
+ for pattern, why in FORBIDDEN:
+ if pattern.search(stripped):
+ failures.append(
+ f"{path.name}:{number}: forbidden `{pattern.pattern}` — {why}\n"
+ f" {stripped}")
+
+for wf in VENUE_WORKFLOWS:
+ path = workflows / wf
+ if not path.exists():
+ failures.append(f"{wf}: venue workflow missing — update the contract "
+ f"if it was deliberately renamed/retired")
+ continue
+ allowed = ALLOWED_CMDS | ALLOWED_EXTRA.get(wf, set())
+ continued = False
+ for step, number, line in walk_runs(path):
+ # A line following a backslash-continued line is that command's
+ # argument tail, not a new command — plumbing by association.
+ was_continued, continued = continued, line.rstrip().endswith("\\")
+ if was_continued:
+ continue
+ if f"{wf}:{step}" in EXEMPT_STEPS:
+ continue
+ if not classify_line(line, allowed):
+ failures.append(
+ f"{wf}:{number}: unclassifiable in step '{step}' — a venue may "
+ f"provision, plumb artifacts, or call a canonical leg script; "
+ f"anything else belongs INSIDE a scripts/ entry\n"
+ f" {line.strip()}")
+
+# ── Layer 3: the unification must stay referenced ──
+REQUIRED = [
+ ("_smoke.yml", r"vm-smoke\.sh", "the Windows smoke legs run the shared wrapper"),
+ ("_smoke.yml", r"scripts/smoke-local\.sh", "the unix smoke legs run the shared wrapper"),
+ ("_soak.yml", r"scripts/soak-legs\.sh", "the soak sequence lives in the canonical entry"),
+ ("_soak.yml", r"scripts/ci/new-protected-temp-root\.ps1", "Windows soak uses the shared temp root"),
+ ("_test.yml", r"scripts/ci/new-protected-temp-root\.ps1", "Windows tests use the shared temp root"),
+ ("_test.yml", r"scripts/test\.sh", "the test legs run the canonical entry"),
+ ("pr.yml", r"vm-smoke\.sh", "PR CI smokes through the shared wrapper"),
+]
+for name, pattern, why in REQUIRED:
+ path = workflows / name
+ if path.exists() and not re.search(pattern, path.read_text()):
+ failures.append(f"{name}: missing required `{pattern}` — {why}")
+
+# ── Layer 4: the local venues route through the same entries ──
+compose = root / "test-infrastructure" / "docker-compose.yml"
+if compose.exists():
+ text = compose.read_text()
+ for number, line in enumerate(text.splitlines(), 1):
+ s = line.strip()
+ if s.startswith("#"):
+ continue
+ if re.search(r"scripts/(smoke-test|soak-test)\.sh", s):
+ failures.append(
+ f"docker-compose.yml:{number}: internal harness called directly — "
+ f"route through smoke-local.sh / soak-legs.sh\n {s}")
+
+for local in ["test-infrastructure/vm/win.sh",
+ "test-infrastructure/vm/vm-run-tests.sh"]:
+ path = root / local
+ if not path.exists():
+ continue
+ text = path.read_text()
+ for number, line in enumerate(text.splitlines(), 1):
+ s = line.strip()
+ if s.startswith("#"):
+ continue
+ if re.search(r"scripts/(smoke-test|soak-test)\.sh", s):
+ failures.append(
+ f"{local}:{number}: internal harness called directly — route "
+ f"through the canonical entries\n {s}")
+
+if failures:
+ print("VENUE PARITY CONTRACT VIOLATED — one harness, every venue:")
+ for failure in failures:
+ print(f" {failure}")
+ sys.exit(1)
+
+print(f"venue-parity contract OK ({seen} workflows marker-checked, "
+ f"{len(VENUE_WORKFLOWS)} venue workflows whitelist-walked, "
+ f"{len(EXEMPT_STEPS)} deliberate step exemptions)")
+PYEOF
+
+# ── Layer 5: interface probes (real repo root only — the fake-root RED-proof
+# trees carry no scripts). Every entry answers --help; the strict ones reject
+# an unknown flag with exit 2 and the uniform "Please consult --help." line.
+if [ -d "$ROOT/scripts" ] && [ -f "$ROOT/scripts/test.sh" ]; then
+ probe_failures=0
+
+ HELP_ENTRIES="
+scripts/test.sh
+scripts/build.sh
+scripts/lint.sh
+scripts/smoke-local.sh
+scripts/soak-legs.sh
+scripts/smoke-test.sh
+scripts/soak-test.sh
+scripts/smoke-invariants.sh
+scripts/ci/preflight-docker.sh
+scripts/ci/require-all-green.sh
+scripts/ci/verify-shard-union.sh
+scripts/ci/generate-sbom.py
+test-infrastructure/run.sh
+test-infrastructure/vm/vm-smoke.sh
+test-infrastructure/vm/vm-run-tests.sh
+test-infrastructure/vm/win.sh
+"
+ for entry in $HELP_ENTRIES; do
+ out=$(cd "$ROOT" && bash "$entry" --help 2>&1) && rc=0 || rc=$?
+ case "$entry" in
+ *.py) out=$(cd "$ROOT" && python3 "$entry" --help 2>&1) && rc=0 || rc=$? ;;
+ esac
+ if [ "$rc" -ne 0 ] || ! printf '%s' "$out" | grep -q "Usage:"; then
+ echo "INTERFACE CONTRACT: $entry --help must exit 0 and print a Usage: block (rc=$rc)" >&2
+ probe_failures=1
+ fi
+ done
+
+ # Strict-flag probe: hermetic entries only (no external deps before their
+ # argument validation). vm-run-tests takes free-form suite names and
+ # win.sh/run.sh need infra before dispatch — their --help is probed above.
+ STRICT_ENTRIES="
+scripts/test.sh
+scripts/build.sh
+scripts/lint.sh
+scripts/smoke-local.sh
+scripts/soak-legs.sh
+scripts/ci/preflight-docker.sh
+test-infrastructure/vm/vm-smoke.sh
+scripts/smoke-invariants.sh
+"
+ for entry in $STRICT_ENTRIES; do
+ out=$(cd "$ROOT" && bash "$entry" --definitely-not-a-flag 2>&1) && rc=0 || rc=$?
+ if [ "$rc" -ne 2 ] || ! printf '%s' "$out" | grep -q "Please consult --help."; then
+ echo "INTERFACE CONTRACT: $entry must reject unknown flags with exit 2 + 'Please consult --help.' (rc=$rc)" >&2
+ probe_failures=1
+ fi
+ done
+
+ if [ "$probe_failures" -ne 0 ]; then
+ echo "VENUE PARITY CONTRACT VIOLATED — interface probes failed (layer 5)" >&2
+ exit 1
+ fi
+ echo "interface probes OK ($(printf '%s' "$HELP_ENTRIES" | grep -c .) --help entries, $(printf '%s' "$STRICT_ENTRIES" | grep -c .) strict-flag entries)"
+fi