Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

ci(C1, C3, C5, C6): backend-matrix files leave Selected E2E for their own 4-vCPU job; retire diff narrowing; up to 8 Selected E2E shards on 2 vCPUs

garrytan53b7f28d18c9
diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml
index db1edd7745..1ef53b5756 100644
--- a/.github/workflows/e2e.yml
+++ b/.github/workflows/e2e.yml
@@ -6,8 +6,8 @@ on:
pull_request:
branches: [master]
# Merge queue (inert until the queue is enabled on master): the PR profile.
- # select-e2e diffs the queued merge commit against origin/master, which is
- # exactly the queued change. docs/RELEASING.md#merge-queue.
+ # prepare-e2e classifies the queued change from the compare API (base_sha...
+ # head_sha). docs/RELEASING.md#merge-queue.
merge_group:
schedule:
- cron: '0 6 * * *' # Nightly at 6am UTC
@@ -121,15 +121,20 @@ jobs:
overwrite: true
# Freeze selection before setup; each worker owns a separate Postgres service.
+ # A doc-only pull request selects nothing; every other change selects the
+ # whole corpus minus E2E_EXCLUSIONS (diff narrowing is retired, C6). The
+ # changed files come from the GitHub API, so the checkout stays shallow; an
+ # incomplete list fails closed to the whole corpus.
prepare-e2e:
runs-on: ubicloud-standard-2-ubuntu-2404
timeout-minutes: 5
+ permissions:
+ contents: read
+ pull-requests: read
outputs:
matrix: ${{ steps.select.outputs.matrix }}
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- with:
- fetch-depth: 0
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
with:
bun-version: 1.4.2
@@ -138,13 +143,22 @@ jobs:
shell: bash
env:
FULL_CORPUS: ${{ github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && inputs.full_corpus) }}
+ GH_TOKEN: ${{ github.token }}
+ EVENT: ${{ github.event_name }}
+ REPO: ${{ github.repository }}
+ PR: ${{ github.event.pull_request.number }}
+ CHANGED_FILES: ${{ github.event.pull_request.changed_files }}
+ BASE_SHA: ${{ github.event.merge_group.base_sha }}
+ HEAD_SHA: ${{ github.event.merge_group.head_sha }}
run: |
if [ "$FULL_CORPUS" = "true" ]; then
# Full-profile coverage carries the complete E2E corpus separately.
: > "$RUNNER_TEMP/selected.txt"
+ elif bash scripts/ci-changed-files.sh > "$RUNNER_TEMP/changed-files.txt"; then
+ bun scripts/select-e2e.ts --changed-files "$RUNNER_TEMP/changed-files.txt" > "$RUNNER_TEMP/selected.txt"
else
- git fetch origin master --quiet
- bun scripts/select-e2e.ts > "$RUNNER_TEMP/selected.txt"
+ echo "Changed-file list incomplete; selecting the full E2E corpus (fail closed)."
+ bun scripts/select-e2e.ts --changed-files /dev/null > "$RUNNER_TEMP/selected.txt"
fi
matrix=$(bun scripts/e2e-matrix.ts prepare < "$RUNNER_TEMP/selected.txt")
echo "matrix=$matrix" >> "$GITHUB_OUTPUT"
@@ -163,7 +177,9 @@ jobs:
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.prepare-e2e.outputs.matrix) }}
- runs-on: ubicloud-standard-4-ubuntu-2404
+ # 2 vCPUs, up to 8 shards (C1): run-e2e.sh runs one bun process at a time,
+ # and a 25-file sample took 442s on 2 cores vs 455s on 4.
+ runs-on: ubicloud-standard-2-ubuntu-2404
timeout-minutes: 60
services:
postgres:
@@ -257,22 +273,6 @@ jobs:
--health-interval 10s
--health-timeout 5s
--health-retries 5
- # Transaction-mode pooler for the backend-matrix step (same settings as
- # docker-compose.ci.yml and persistence-validation.yml).
- pgbouncer:
- image: edoburu/pgbouncer:latest
- env:
- DB_HOST: postgres
- DB_PORT: '5432'
- DB_USER: postgres
- DB_PASSWORD: postgres
- POOL_MODE: transaction
- AUTH_TYPE: plain
- MAX_CLIENT_CONN: '200'
- DEFAULT_POOL_SIZE: '10'
- IGNORE_STARTUP_PARAMETERS: extra_float_digits,statement_timeout,idle_in_transaction_session_timeout,search_path
- ports:
- - 55433:5432
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
@@ -333,26 +333,6 @@ jobs:
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/gbrain_test
GBRAIN_TEST_ALLOW_DATABASE_URL: '1'
GBRAIN_TEST_RECEIPT_DIR: ${{ runner.temp }}/receipts
- - name: Run backend matrix (direct Postgres, then PgBouncer)
- # scripts/e2e-backend-matrix.txt: the E5 executor binding matrix and the
- # engine parity files, each run on direct Postgres and again through the
- # transaction-mode pooler with an explicit prepare mode (the 6543
- # auto-detect port is not used here). run-e2e.sh fails a file whose
- # executed-test counts differ between the two backends.
- shell: bash
- run: |
- export DATABASE_URL="postgresql://postgres:${PGPASSWORD}@localhost:5432/gbrain_test"
- export GBRAIN_PGBOUNCER_E2E_URL="postgresql://postgres:${PGPASSWORD}@localhost:55433/gbrain_test?prepare=false"
- export GBRAIN_PGBOUNCER_DIRECT_URL="$DATABASE_URL"
- mapfile -t files < <(grep -v -e '^#' -e '^!' -e '^$' scripts/e2e-backend-matrix.txt | cut -f1)
- bash scripts/run-e2e.sh "${files[@]}"
- env:
- PGPASSWORD: postgres
- GBRAIN_CI_REQUIRE_PGBOUNCER: '1'
- GBRAIN_TEST_DB: '1'
- GBRAIN_TEST_ALLOW_DATABASE_URL: '1'
- GBRAIN_TEST_RECEIPT_DIR: ${{ runner.temp }}/receipts
- GBRAIN_TEST_RECEIPT_LANE: backend-matrix
- name: Run multi-agent serve suite
# cathedral-6 (T7): multi-agent continuity + isolation over a real
# `gbrain serve --http`. Own invocation line (engine-parity
@@ -414,6 +394,96 @@ jobs:
if-no-files-found: warn
overwrite: true
+ # The backend matrix (scripts/e2e-backend-matrix.txt) runs each file on
+ # direct Postgres and again through transaction-mode PgBouncer, one file at
+ # a time, so it needs no more than 4 vCPUs (C5). Split from Tier 1, which
+ # keeps 16 vCPUs for its CLI-spawn timing. It is the PR owner of every
+ # listed test/e2e/ file: scripts/e2e-matrix.ts excludes them from Selected
+ # E2E (C3).
+ tier1-backend-matrix:
+ name: Tier 1 backend matrix (direct + PgBouncer)
+ runs-on: ubicloud-standard-4-ubuntu-2404
+ timeout-minutes: 30
+ services:
+ postgres:
+ image: pgvector/pgvector:pg16
+ env:
+ POSTGRES_USER: postgres
+ POSTGRES_PASSWORD: postgres
+ POSTGRES_DB: gbrain_test
+ ports:
+ - 5432:5432
+ options: >-
+ --health-cmd pg_isready
+ --health-interval 10s
+ --health-timeout 5s
+ --health-retries 5
+ # Transaction-mode pooler (same settings as docker-compose.ci.yml and
+ # persistence-validation.yml).
+ pgbouncer:
+ image: edoburu/pgbouncer:latest
+ env:
+ DB_HOST: postgres
+ DB_PORT: '5432'
+ DB_USER: postgres
+ DB_PASSWORD: postgres
+ POOL_MODE: transaction
+ AUTH_TYPE: plain
+ MAX_CLIENT_CONN: '200'
+ DEFAULT_POOL_SIZE: '10'
+ IGNORE_STARTUP_PARAMETERS: extra_float_digits,statement_timeout,idle_in_transaction_session_timeout,search_path
+ ports:
+ - 55433:5432
+ steps:
+ - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
+ - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
+ with:
+ bun-version: 1.4.2
+ - uses: actions/cache/restore@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
+ with:
+ path: ~/.bun/install/cache
+ key: bun-cache-${{ runner.os }}-${{ hashFiles('bun.lock') }}
+ restore-keys: bun-cache-${{ runner.os }}-
+ # PGLite snapshot (restore-only; test.yml's serial-tests job saves).
+ # run-e2e.sh builds it when absent/stale — this just avoids paying the
+ # build once per job. KEY: byte-identical with the homes in test.yml.
+ - uses: actions/cache/restore@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
+ with:
+ path: |
+ test/fixtures/pglite-snapshot.tar
+ test/fixtures/pglite-snapshot.version
+ key: pglite-snapshot-${{ runner.os }}-${{ hashFiles('src/core/*.ts', 'src/core/engine-sql/bootstrap.ts', 'src/core/schema-migrations/**', 'src/core/ai/defaults.ts', 'src/core/company-brain/receipt-schema.ts', 'src/core/entities/resolve.ts', 'src/core/facts/withdrawal-schema.ts', 'src/core/facts/relink-schema.ts', 'src/core/google/*.ts', 'src/core/grants/*.ts', 'src/core/minions/tools/brain-allowlist.ts', 'src/core/ops/contract.ts', 'src/core/page-state/*schema.ts', 'src/core/persistence/*.ts', 'src/core/schema-pack/link-inference.ts', 'src/core/schema-pack/redos-guard.ts', 'src/core/search/alias-normalize.ts', 'src/core/search/private-visibility.ts', 'src/core/search/projection-statistics.ts', 'src/core/shared-skills/*schema*.ts', 'src/core/ai/decide/schema.ts', 'test/helpers/legacy-embedding-config.ts', 'scripts/build-pglite-snapshot.ts') }}
+ - run: bun install --frozen-lockfile
+ - name: Run backend matrix (direct Postgres, then PgBouncer)
+ # scripts/e2e-backend-matrix.txt: the E5 executor binding matrix and the
+ # engine parity files, each run on direct Postgres and again through the
+ # transaction-mode pooler with an explicit prepare mode (the 6543
+ # auto-detect port is not used here). run-e2e.sh fails a file whose
+ # executed-test counts differ between the two backends.
+ shell: bash
+ run: |
+ export DATABASE_URL="postgresql://postgres:${PGPASSWORD}@localhost:5432/gbrain_test"
+ export GBRAIN_PGBOUNCER_E2E_URL="postgresql://postgres:${PGPASSWORD}@localhost:55433/gbrain_test?prepare=false"
+ export GBRAIN_PGBOUNCER_DIRECT_URL="$DATABASE_URL"
+ mapfile -t files < <(grep -v -e '^#' -e '^!' -e '^$' scripts/e2e-backend-matrix.txt | cut -f1)
+ bash scripts/run-e2e.sh "${files[@]}"
+ env:
+ PGPASSWORD: postgres
+ GBRAIN_CI_REQUIRE_PGBOUNCER: '1'
+ GBRAIN_TEST_DB: '1'
+ GBRAIN_TEST_ALLOW_DATABASE_URL: '1'
+ GBRAIN_TEST_RECEIPT_DIR: ${{ runner.temp }}/receipts
+ GBRAIN_TEST_RECEIPT_LANE: backend-matrix
+ - name: Upload receipts
+ if: always()
+ uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
+ with:
+ name: receipts-tier1-backend-matrix
+ path: ${{ runner.temp }}/receipts
+ retention-days: 14
+ if-no-files-found: warn
+ overwrite: true
+
tier2:
name: Tier 2 (LLM Skills)
# Runs on every push/PR (promoted from schedule-only in v0.19.0), in
@@ -623,7 +693,6 @@ jobs:
bun-version: 1.4.2
- run: bun install --frozen-lockfile
# Separate coverage dirs per bun process (a reused dir is overwritten).
- - run: bun test test/eval-longmemeval-e2e.slow.test.ts --timeout=60000 --coverage --coverage-reporter=lcov --coverage-dir=${{ runner.temp }}/coverage/slow-a
- run: bun test test/entity-resolve-perf.slow.test.ts --timeout=300000 --coverage --coverage-reporter=lcov --coverage-dir=${{ runner.temp }}/coverage/slow-b
- run: bun test test/entity-card-perf.slow.test.ts --timeout=300000 --coverage --coverage-reporter=lcov --coverage-dir=${{ runner.temp }}/coverage/slow-c
- run: bun test test/eval-brainbench-e2e.slow.test.ts --timeout=300000 --coverage --coverage-reporter=lcov --coverage-dir=${{ runner.temp }}/coverage/slow-d
@@ -805,7 +874,7 @@ jobs:
# in e2e-status; baseline comparisons run locally with
# bun scripts/ci-executed-counts.ts --base-run <id> --head-run <id>
executed-receipts:
- needs: [jsonb-parity, tier1, tier2, selected-e2e, coverage-full-unit, coverage-full-serial, coverage-full-e2e]
+ needs: [jsonb-parity, tier1, tier1-backend-matrix, tier2, selected-e2e, coverage-full-unit, coverage-full-serial, coverage-full-e2e]
if: always()
runs-on: ubicloud-standard-2-ubuntu-2404
timeout-minutes: 10
@@ -846,7 +915,7 @@ jobs:
# The stable aggregate includes full-profile execution lanes when requested.
# Coverage reporting itself remains advisory; failed tests never do.
e2e-status:
- needs: [jsonb-parity, tier1, tier2, prepare-e2e, selected-e2e, coverage-full-unit, coverage-full-serial, coverage-full-slow, coverage-full-e2e]
+ needs: [jsonb-parity, tier1, tier1-backend-matrix, tier2, prepare-e2e, selected-e2e, coverage-full-unit, coverage-full-serial, coverage-full-slow, coverage-full-e2e]
if: always()
runs-on: ubicloud-standard-2-ubuntu-2404
timeout-minutes: 5
@@ -857,13 +926,14 @@ jobs:
run: |
JSONB="${{ needs.jsonb-parity.result }}"
TIER1="${{ needs.tier1.result }}"
+ BACKEND_MATRIX="${{ needs.tier1-backend-matrix.result }}"
TIER2="${{ needs.tier2.result }}"
PREPARE="${{ needs.prepare-e2e.result }}"
SELECTED="${{ needs.selected-e2e.result }}"
EVENT="${{ github.event_name }}"
echo "event=$EVENT"
- echo "jsonb-parity=$JSONB tier1=$TIER1 tier2=$TIER2 prepare-e2e=$PREPARE selected-e2e=$SELECTED"
- for r in "$JSONB" "$TIER1" "$TIER2" "$PREPARE" "$SELECTED"; do
+ echo "jsonb-parity=$JSONB tier1=$TIER1 tier1-backend-matrix=$BACKEND_MATRIX tier2=$TIER2 prepare-e2e=$PREPARE selected-e2e=$SELECTED"
+ for r in "$JSONB" "$TIER1" "$BACKEND_MATRIX" "$TIER2" "$PREPARE" "$SELECTED"; do
if [ "$r" != "success" ]; then
echo "✗ gated e2e job did not succeed (got $r) — E2E fail"
exit 1
diff --git a/scripts/ci-changed-files.sh b/scripts/ci-changed-files.sh
new file mode 100755
index 0000000000..8382c7706e
--- /dev/null
+++ b/scripts/ci-changed-files.sh
@@ -0,0 +1,35 @@
+#!/usr/bin/env bash
+# scripts/ci-changed-files.sh — the changed files of the pull request or
+# merge-group entry that triggered this workflow run, one per line, from the
+# GitHub API (no git history needed, so the checkout stays shallow).
+#
+# Exits 1 with the reason on stderr whenever the list cannot be complete, so
+# callers fail closed (prepare-e2e then runs the full E2E corpus):
+# - no pull_request or merge_group context (push, schedule, dispatch);
+# - an unknown or capped size: the pull request files API returns at most
+# 3000 files and the compare API at most 300;
+# - an API error, or a paginated list shorter than the PR's changed_files.
+#
+# Env: EVENT, REPO, GH_TOKEN; PR + CHANGED_FILES (pull_request);
+# BASE_SHA + HEAD_SHA (merge_group).
+set -euo pipefail
+
+fail() { echo "ci-changed-files: $*" >&2; exit 1; }
+
+case "${EVENT:-}" in
+ pull_request)
+ [[ "${CHANGED_FILES:-}" =~ ^[0-9]{1,4}$ ]] || fail "changed-file count unknown (${CHANGED_FILES:-unset})"
+ [ "$CHANGED_FILES" -lt 3000 ] || fail "the pull request changes $CHANGED_FILES files; the files API lists at most 3000"
+ files=$(gh api --paginate "repos/${REPO:?}/pulls/${PR:?}/files?per_page=100" --jq '.[].filename') || fail "pull request files API failed"
+ listed=$(printf '%s\n' "$files" | awk 'NF { n++ } END { print n+0 }')
+ [ "$listed" -eq "$CHANGED_FILES" ] || fail "the files API listed $listed of $CHANGED_FILES changed files"
+ ;;
+ merge_group)
+ files=$(gh api "repos/${REPO:?}/compare/${BASE_SHA:?}...${HEAD_SHA:?}" --jq 'if (.files | length) >= 300 then error("capped") else .files[].filename end') \
+ || fail "compare API failed or capped at 300 files"
+ ;;
+ *)
+ fail "no pull request or merge-group context (event: ${EVENT:-unset})"
+ ;;
+esac
+[ -z "$files" ] || printf '%s\n' "$files"
diff --git a/scripts/ci-doc-checks.sh b/scripts/ci-doc-checks.sh
new file mode 100755
index 0000000000..63b378c449
--- /dev/null
+++ b/scripts/ci-doc-checks.sh
@@ -0,0 +1,36 @@
+#!/usr/bin/env bash
+# scripts/ci-doc-checks.sh — the checks a doc-only change can still break.
+#
+# `ci:local:diff` and `ci:ubicloud:diff` skip every test lane when the diff is
+# doc-only (scripts/select-e2e.ts classifies it DOC_ONLY); these checks still
+# run, because a doc edit can leave generated or guarded artifacts stale:
+# llms.txt freshness, KEY_FILES / TESTING.md byte caps and current-state
+# voice, documented repository paths, skill references and the privacy guards.
+# Every check runs; the exit code is 1 if any failed, and each failure prints
+# its repair command.
+set -uo pipefail
+
+cd "$(dirname "$0")/.."
+
+failed=0
+check() {
+ local name="$1" fix="$2"
+ shift 2
+ echo "[doc-checks] $name"
+ if ! "$@"; then
+ echo "[doc-checks] FAIL $name" >&2
+ echo "Why: a doc-only change still has to keep this artifact current." >&2
+ echo "Fix: $fix" >&2
+ echo "Docs: docs/TESTING.md#e2e-selection" >&2
+ failed=1
+ fi
+}
+
+check "llms.txt + llms-full.txt are fresh" "bun run build:llms" bun test --timeout 60000 test/build-llms.test.ts
+check "KEY_FILES and TESTING.md byte caps / current-state voice" "follow the check's message, then rerun bun run check:doc-history" bun run check:doc-history
+check "documented scripts/ and test/ paths exist" "fix or delete the reference the test names" bun test --timeout 60000 test/docs-repo-paths.test.ts
+check "skill references resolve" "follow the check's message, then rerun bun run check:skill-refs" bun run check:skill-refs
+check "privacy guard" "replace real names with placeholders (alice-example, acme-example), then rerun bun run check:privacy" bun run check:privacy
+check "fixture privacy guard" "replace real names with placeholders, then rerun bun run check:fixture-privacy" bun run check:fixture-privacy
+
+exit "$failed"
diff --git a/scripts/ci-local.sh b/scripts/ci-local.sh
index c07974978a..9d82329c8e 100755
--- a/scripts/ci-local.sh
+++ b/scripts/ci-local.sh
@@ -6,7 +6,7 @@
#
# Modes:
# bash scripts/ci-local.sh # full local gate: gitleaks + unit + ALL E2E (4-way sharded)
-# bash scripts/ci-local.sh --diff # full local gate: gitleaks + unit + selected E2E (4-way sharded)
+# bash scripts/ci-local.sh --diff # doc-only diff: gitleaks + doc checks; any other diff: the full gate
# bash scripts/ci-local.sh --no-pull # skip docker compose pull (offline / debug)
# bash scripts/ci-local.sh --clean # nuke named volumes for cold debug
# bash scripts/ci-local.sh --no-shard # debug: run E2E sequentially against postgres-1 only
@@ -54,37 +54,27 @@ if [ "$CLEAN" = "1" ]; then
docker compose -f "$COMPOSE_FILE" down -v --remove-orphans 2>&1 | tail -5 || true
fi
-# Tier 2: --diff fast-path. If the diff is doc-only (or empty), skip the
-# whole heavy gate (postgres + bun install + unit + E2E) and just verify
-# gitleaks on host. Doc-only diffs go from ~25 min to ~5 seconds.
+# --diff: a doc-only diff skips the heavy gate (postgres + bun install + unit
+# + E2E) and runs gitleaks plus the doc checks on the host (seconds instead of
+# ~25 min). Any other diff runs the full gate: E2E narrowing is retired (a
+# typical E2E file imports most of src/, so no diff map ever narrowed).
if [ "$DIFF" = "1" ]; then
CLASSIFICATION=$(bun run scripts/select-e2e.ts --classify-only 2>/dev/null || echo "ERR")
- case "$CLASSIFICATION" in
- DOC_ONLY)
- echo "[ci-local] --diff: diff is doc-only — skipping postgres + unit + E2E (Tier 2 fast-path)."
- echo "[ci-local] Running gitleaks on host as the only gate..."
- if ! command -v gitleaks >/dev/null 2>&1; then
- echo "[ci-local] ERROR: gitleaks not installed; the required secrets scan cannot run. Install gitleaks and retry." >&2
- exit 1
- else
- bash scripts/test-gitleaks-config.sh
- bash scripts/scan-worktree-secrets.sh
- gitleaks git . --redact --no-banner --log-opts="origin/master..HEAD"
- fi
- echo "[ci-local] Doc-only fast-path complete. No code paths exercised."
- trap - EXIT
- exit 0
- ;;
- EMPTY)
- echo "[ci-local] --diff: diff is empty (clean branch) — running full gate per fail-closed contract."
- ;;
- SRC)
- echo "[ci-local] --diff: diff touches src/ — running selected E2E + full unit phase."
- ;;
- *)
- echo "[ci-local] WARN: select-e2e.ts --classify-only returned '$CLASSIFICATION' — running full gate." >&2
- ;;
- esac
+ if [ "$CLASSIFICATION" = "DOC_ONLY" ]; then
+ echo "[ci-local] --diff: diff is doc-only — skipping postgres + unit + E2E; running gitleaks and the doc checks."
+ if ! command -v gitleaks >/dev/null 2>&1; then
+ echo "[ci-local] ERROR: gitleaks not installed; the required secrets scan cannot run. Install gitleaks and retry." >&2
+ exit 1
+ fi
+ bash scripts/test-gitleaks-config.sh
+ bash scripts/scan-worktree-secrets.sh
+ gitleaks git . --redact --no-banner --log-opts="origin/master..HEAD"
+ bash scripts/ci-doc-checks.sh
+ echo "[ci-local] Doc-only fast-path complete. No code paths exercised."
+ trap - EXIT
+ exit 0
+ fi
+ echo "[ci-local] --diff: E2E narrowing is retired; running the full E2E corpus (see docs/TESTING.md#e2e-selection). Classification: $CLASSIFICATION"
fi
# Pre-flight: postgres host ports for 4 shards. Defaults to 5434-5437 (avoid
@@ -166,32 +156,7 @@ bash scripts/ci-local-e2e-smoke.sh
# E2E files against postgres-N. Guards + typecheck run ONCE before fan-out.
# --no-shard runs the legacy unsharded flow (debug aid).
if [ "$NO_SHARD" = "1" ]; then
- if [ "$DIFF" = "1" ]; then
- RUN_PHASES_CMD='echo "[runner] guards + typecheck"
-bash scripts/check-bun-test-timeout.sh
-bun run verify
-echo "[runner] serial tests (DATABASE_URL unset)"
-env -u DATABASE_URL -u GBRAIN_DATABASE_URL bun run test:serial
-echo "[runner] slow tests (DATABASE_URL unset)"
-env -u DATABASE_URL -u GBRAIN_DATABASE_URL bun run test:slow
-echo "[runner] unit (unsharded, DATABASE_URL unset)"
-env -u DATABASE_URL bash scripts/run-unit-shard.sh
-echo "[runner] e2e (unsharded, --diff selected)"
-SELECTED=$(bun run scripts/select-e2e.ts)
-if [ -z "$SELECTED" ]; then
- echo "[runner] selector emitted nothing (doc-only diff); skipping E2E."
-else
- printf "%s\n" "$SELECTED" > /tmp/e2e-selected.txt
- DATABASE_URL=postgresql://postgres:postgres@postgres-1:5432/gbrain_test \
- GBRAIN_PGBOUNCER_URL=postgresql://postgres:postgres@pgbouncer:5432/gbrain_pgbouncer_test \
- GBRAIN_PGBOUNCER_DIRECT_URL=postgresql://postgres:postgres@postgres-1:5432/gbrain_test \
- GBRAIN_PGBOUNCER_E2E_DB=gbrain_test \
- GBRAIN_CI_REQUIRE_PGBOUNCER=1 \
- GBRAIN_TEST_DB=1 \
- xargs bash scripts/run-e2e.sh < /tmp/e2e-selected.txt
-fi'
- else
- RUN_PHASES_CMD='echo "[runner] guards + typecheck"
+ RUN_PHASES_CMD='echo "[runner] guards + typecheck"
bash scripts/check-bun-test-timeout.sh
bun run verify
echo "[runner] serial tests (DATABASE_URL unset)"
@@ -208,21 +173,9 @@ GBRAIN_PGBOUNCER_E2E_DB=gbrain_test \
GBRAIN_CI_REQUIRE_PGBOUNCER=1 \
GBRAIN_TEST_DB=1 \
bash scripts/run-e2e.sh'
- fi
else
# Tier 1 sharded path. Each shard runs unit+E2E sequentially against its
# own postgres-N. Shards run in parallel via xargs -P4.
- if [ "$DIFF" = "1" ]; then
- DIFF_E2E_PREP='SELECTED=$(bun run scripts/select-e2e.ts)
-if [ -z "$SELECTED" ]; then
- echo "" > /tmp/e2e-selected.txt
-else
- echo "$SELECTED" | tr " " "\n" | grep -v "^$" > /tmp/e2e-selected.txt
-fi'
- else
- # Empty file -> run-e2e.sh uses default glob (every test/e2e file).
- DIFF_E2E_PREP='> /tmp/e2e-selected.txt'
- fi
RUN_PHASES_CMD="echo \"[runner] guards + typecheck (run once before sharding)\"
bash scripts/check-bun-test-timeout.sh
bun run verify
@@ -241,8 +194,6 @@ export GBRAIN_PGLITE_SNAPSHOT=test/fixtures/pglite-snapshot.tar
# file in the container than natively — timeout-class failures that pass on
# the host. Scale the per-test ceiling for the container lane (overridable).
export GBRAIN_TEST_TIMEOUT_MULTIPLIER=\${GBRAIN_TEST_TIMEOUT_MULTIPLIER:-6}
-echo \"[runner] resolving E2E file selection (--diff aware)\"
-${DIFF_E2E_PREP}
mkdir -p /tmp/shard-logs
echo \"[runner] Tier 1: 4-shard parallel unit + E2E (xargs -P4)\"
set +e
@@ -260,25 +211,14 @@ printf '%s\\n' 1 2 3 4 | xargs -P4 -I{} sh -c '
echo \"[shard \${shard}] e2e phase (SHARD=\${shard}/4, DATABASE_URL=postgres-\${shard})\" >> \$log
# Backend-matrix PgBouncer pass: the one pooler fronts postgres-1, so each
# shard gets its own pooled database there (run-e2e.sh creates it).
- if [ -s /tmp/e2e-selected.txt ]; then
- SHARD=\${shard}/4 \\
- DATABASE_URL=postgresql://postgres:postgres@postgres-\${shard}:5432/gbrain_test \\
- GBRAIN_PGBOUNCER_URL=postgresql://postgres:postgres@pgbouncer:5432/gbrain_pgbouncer_test \\
- GBRAIN_PGBOUNCER_DIRECT_URL=postgresql://postgres:postgres@postgres-1:5432/gbrain_test \\
- GBRAIN_PGBOUNCER_E2E_DB=gbrain_pooled_\${shard}_test \\
- GBRAIN_CI_REQUIRE_PGBOUNCER=1 \\
- GBRAIN_TEST_DB=1 \\
- xargs bash scripts/run-e2e.sh < /tmp/e2e-selected.txt >> \$log 2>&1
- else
- SHARD=\${shard}/4 \\
- DATABASE_URL=postgresql://postgres:postgres@postgres-\${shard}:5432/gbrain_test \\
- GBRAIN_PGBOUNCER_URL=postgresql://postgres:postgres@pgbouncer:5432/gbrain_pgbouncer_test \\
- GBRAIN_PGBOUNCER_DIRECT_URL=postgresql://postgres:postgres@postgres-1:5432/gbrain_test \\
- GBRAIN_PGBOUNCER_E2E_DB=gbrain_pooled_\${shard}_test \\
- GBRAIN_CI_REQUIRE_PGBOUNCER=1 \\
- GBRAIN_TEST_DB=1 \\
- bash scripts/run-e2e.sh >> \$log 2>&1
- fi
+ SHARD=\${shard}/4 \\
+ DATABASE_URL=postgresql://postgres:postgres@postgres-\${shard}:5432/gbrain_test \\
+ GBRAIN_PGBOUNCER_URL=postgresql://postgres:postgres@pgbouncer:5432/gbrain_pgbouncer_test \\
+ GBRAIN_PGBOUNCER_DIRECT_URL=postgresql://postgres:postgres@postgres-1:5432/gbrain_test \\
+ GBRAIN_PGBOUNCER_E2E_DB=gbrain_pooled_\${shard}_test \\
+ GBRAIN_CI_REQUIRE_PGBOUNCER=1 \\
+ GBRAIN_TEST_DB=1 \\
+ bash scripts/run-e2e.sh >> \$log 2>&1
e2e_exit=\$?
if [ \$e2e_exit -ne 0 ]; then
echo \"[shard \${shard}] E2E FAILED (exit=\$e2e_exit)\" >> \$log
diff --git a/scripts/ci-ubicloud.ts b/scripts/ci-ubicloud.ts
index b5f8ab1679..fa1a2c070e 100755
--- a/scripts/ci-ubicloud.ts
+++ b/scripts/ci-ubicloud.ts
@@ -4,7 +4,7 @@
* Ubicloud VMs.
*
* bun run ci:ubicloud # gitleaks + verify + serial + slow + unit + ALL E2E
- * bun run ci:ubicloud:diff # same, E2E narrowed by select-e2e (doc-only: gitleaks only)
+ * bun run ci:ubicloud:diff # doc-only diff: doc checks + gitleaks; any other diff: the full gate
*
* Options:
* --vms N VMs to provision in parallel (default 4: 64 vCPUs of the
@@ -13,7 +13,7 @@
* --slots N concurrent work slots per VM (default: half of --size's vCPUs)
* --location LOC Ubicloud location (default eu-central-h1)
* --lanes a,b subset of gitleaks,verify,serial,slow,unit,e2e (default all)
- * --diff select E2E files from the branch diff (ci:local --diff)
+ * --diff doc-only diffs run only the doc checks and gitleaks (ci:local --diff)
* --record-weights write measured durations to scripts/ubicloud/weights.json
* --keep leave the VMs running (destroy with ubi-runner.sh down NAME)
*
@@ -186,16 +186,16 @@ async function main() {
mkdirSync(join(runDir, "failures"), { recursive: true });
// ── Inventory: the same discovery the ci:local wrappers use ───────────────
- let e2eFiles = lines(sh("bash", ["scripts/run-e2e.sh", "--dry-run-list"]));
+ const e2eFiles = lines(sh("bash", ["scripts/run-e2e.sh", "--dry-run-list"]));
if (opts.diff) {
const classification = spawnSync("bun", ["run", "scripts/select-e2e.ts", "--classify-only"], { cwd: ROOT, encoding: "utf8" }).stdout?.trim();
if (classification === "DOC_ONLY") {
- log("--diff: doc-only diff — running gitleaks only (ci:local Tier 2 fast-path)");
+ log("--diff: doc-only diff — running the doc checks locally, then gitleaks (ci:local doc-only fast-path)");
+ if (spawnSync("bash", ["scripts/ci-doc-checks.sh"], { cwd: ROOT, stdio: "inherit" }).status !== 0) process.exit(1);
opts.lanes = new Set(["gitleaks"]);
opts.vms = 1;
} else {
- log(`--diff: classification ${classification || "unknown"} — full unit lanes + selected E2E`);
- e2eFiles = lines(sh("bun", ["run", "scripts/select-e2e.ts"]));
+ log(`--diff: E2E narrowing is retired; running the full E2E corpus (see docs/TESTING.md#e2e-selection). Classification: ${classification || "unknown"}`);
}
}
const exclusive = lines(sh("bash", ["scripts/run-serial-tests.sh", "--dry-run-list-exclusive"]));
diff --git a/scripts/e2e-matrix.ts b/scripts/e2e-matrix.ts
index 4b47ff04a7..ddfa4303c1 100644
--- a/scripts/e2e-matrix.ts
+++ b/scripts/e2e-matrix.ts
@@ -1,7 +1,7 @@
#!/usr/bin/env bun
// Freeze selection before setup; workers execute exactly the supplied argv.
// selector -> exclusions -> weighted matrix -> isolated sequential workers
-import { realpathSync, statSync } from "node:fs";
+import { readFileSync, realpathSync, statSync } from "node:fs";
import { resolve, relative, isAbsolute } from "node:path";
import { loadWeights, partition, type WeightMap } from "./sharding.ts";
@@ -12,11 +12,21 @@ export const PERSISTENCE_VALIDATION_OWNED = new Set([
'test/e2e/reconcile-crash.test.ts',
'test/e2e/reconcile-crash-unactivated.test.ts',
]);
+// PR owner of every test/e2e/ row of scripts/e2e-backend-matrix.txt (`!` rows
+// stay out of the matrix) is e2e.yml's tier1-backend-matrix job: it runs each
+// file on direct Postgres and again through PgBouncer, so Selected E2E's
+// direct-only run of the same file was a duplicate (C3).
+export const BACKEND_MATRIX_OWNED = new Set(
+ readFileSync(resolve(import.meta.dir, "e2e-backend-matrix.txt"), "utf8").split("\n")
+ .filter(row => row.startsWith("test/e2e/"))
+ .map(row => row.split("\t")[0]),
+);
export function exclusionNotice(file: string): string {
- return PERSISTENCE_VALIDATION_OWNED.has(file)
- ? `excluded: ${file} (owned by persistence-validation.yml)`
- : `excluded (named-job / live-key lane): ${file}`;
+ if (PERSISTENCE_VALIDATION_OWNED.has(file)) return `excluded: ${file} (owned by persistence-validation.yml)`;
+ if (BACKEND_MATRIX_OWNED.has(file)) return `excluded: ${file} (owned by the Tier 1 backend matrix, scripts/e2e-backend-matrix.txt)`;
+ return `excluded (named-job / live-key lane): ${file}`;
}
+export const MAX_E2E_WORKERS = 8;
export const E2E_EXCLUSIONS = new Set([
'test/e2e/op-checkpoint-jsonb-parity.test.ts',
'test/e2e/jsonb-roundtrip.test.ts',
@@ -32,6 +42,7 @@ export const E2E_EXCLUSIONS = new Set([
'test/e2e/voyage-rerank-live.test.ts',
'test/e2e/voyage-multimodal.test.ts',
...PERSISTENCE_VALIDATION_OWNED,
+ ...BACKEND_MATRIX_OWNED,
]);
export interface E2ERow { shard: number; files: string[]; empty: boolean }
function validatePath(file: unknown): asserts file is string {
@@ -48,12 +59,12 @@ export function prepareMatrix(files: string[], weights: WeightMap): { include: E
return false;
});
if (!selected.length) return { include: [{ shard: 1, files: [], empty: true }] };
- return { include: partition(selected, weights, Math.min(4, selected.length)).map((files, i) => ({ shard: i + 1, files, empty: false })) };
+ return { include: partition(selected, weights, Math.min(MAX_E2E_WORKERS, selected.length)).map((files, i) => ({ shard: i + 1, files, empty: false })) };
}
export function validateRow(value: unknown, root: string): E2ERow {
if (!value || typeof value !== "object") throw new Error("missing E2E matrix row");
const row = value as E2ERow;
- if (!Number.isInteger(row.shard) || row.shard < 1 || row.shard > 4 || !Array.isArray(row.files) || typeof row.empty !== "boolean") throw new Error("malformed E2E matrix row");
+ if (!Number.isInteger(row.shard) || row.shard < 1 || row.shard > MAX_E2E_WORKERS || !Array.isArray(row.files) || typeof row.empty !== "boolean") throw new Error("malformed E2E matrix row");
if (row.empty !== (row.files.length === 0) || (row.empty && row.shard !== 1)) throw new Error("invalid empty E2E sentinel");
if (new Set(row.files).size !== row.files.length) throw new Error("duplicate E2E worker file");
const base = realpathSync(root);
diff --git a/scripts/e2e-test-map.ts b/scripts/e2e-test-map.ts
deleted file mode 100644
index 722f3dd6f3..0000000000
--- a/scripts/e2e-test-map.ts
+++ /dev/null
@@ -1,747 +0,0 @@
-// scripts/e2e-test-map.ts
-//
-// Path-glob -> E2E test files map. Used by scripts/select-e2e.ts.
-//
-// CONTRACT: This map can ONLY narrow from "all". When a changed src/ path
-// matches no glob here, the selector falls back to "run all E2E" (fail-closed).
-// You can safely add narrowing entries; you cannot break correctness by missing
-// one. Tune as misses surface (i.e., when ci:local:diff ran more than necessary
-// and you'd like to narrow that surface area).
-//
-// Glob syntax is the minimal subset implemented in select-e2e.ts:
-// - "**" matches any sequence of path segments (including zero)
-// - "*" matches any characters within a single path segment
-// - everything else is literal
-// No brace expansion, no ?, no [ ].
-
-const MIGRATION_WAVE_TESTS = [
- "test/e2e/migration-wave-budget-crash.test.ts",
- "test/e2e/migration-wave-healing-fence.test.ts",
- "test/e2e/migration-wave-intermediate-retrieval.test.ts",
- "test/e2e/migration-wave-phase-leases.test.ts",
- "test/e2e/migration-wave-prepared-withdrawal.test.ts",
- "test/e2e/migration-wave-provider-outcomes.test.ts",
-];
-
-export const E2E_TEST_MAP: Record<string, string[]> = {
- // #5984: the env-gated wire-level SQL trace for the managed-sync catch-up bench.
- "src/core/sql-trace.ts": ["test/e2e/sql-trace-postgres.test.ts"],
- // Fix wave 8, Lane G: reindex auto-concurrency sizing (#5181).
- "src/commands/reindex.ts": ["test/e2e/reindex-auto-workers-5181.test.ts"],
- // Fix wave 8, Lane G: deferred ANN build after the embedding re-embed (#5088).
- // Fix wave 8, Lane G: page revision rollout (#5216).
- "src/core/page-state/revision-backfill-schema.ts": ["test/e2e/page-revision-rollout-5216-postgres.test.ts"],
- "src/core/embedding-ann-build.ts": ["test/e2e/migrate-embeddings-ann-build-5088-postgres.test.ts", "test/e2e/migrate-embeddings-postgres.test.ts"],
- // FOUNDATIONS 1 F4a: get_health SQL aggregate, shared orphan policy, op memo.
- "src/core/engine-sql/health.ts": ["test/e2e/engine-sql-health-parity.test.ts", "test/e2e/health-parity-postgres.test.ts", "test/e2e/get-health-embedding-column-postgres.test.ts"],
- "src/core/orphan-policy.ts": ["test/e2e/engine-sql-health-parity.test.ts", "test/e2e/health-parity-postgres.test.ts"],
- "src/core/health-memo.ts": ["test/e2e/engine-sql-health-parity.test.ts", "test/e2e/get-health-embedding-column-postgres.test.ts"],
- // Fix wave 8 lane D2 (#5828): the brain_score timeline grading helper.
- "src/core/timeline-grading.ts": ["test/e2e/wave8-lane-d2-postgres.test.ts", "test/e2e/health-parity-postgres.test.ts"],
- // GBRA-35 E10: the managed connector-source job contract drives these writers on an unbound connector source.
- "test/helpers/managed-connector-job-contract.ts": ["test/e2e/managed-connector-job-contract.test.ts"],
- "src/core/persistence/atom-maintenance.ts": ["test/e2e/managed-connector-job-contract.test.ts"],
- "src/core/ops/loops.ts": ["test/e2e/managed-connector-job-contract.test.ts", "test/e2e/loops-close-fact-postgres.test.ts"],
- "src/core/persistence/loop-fact-retirement.ts": ["test/e2e/loops-close-fact-postgres.test.ts", "test/e2e/managed-connector-job-contract.test.ts"],
- "src/core/repair/loop-facts.ts": ["test/e2e/loops-close-fact-postgres.test.ts"],
- // Foundations 1 F1b: write attribution reads and the journal-proven backfill, direct and through PgBouncer.
- "src/core/ops/attribution.ts": ["test/e2e/write-attribution-read-parity.test.ts"],
- "src/core/repair/attribution-backfill.ts": ["test/e2e/write-attribution-read-parity.test.ts"],
- "src/core/engine-sql/pages.ts": ["test/e2e/write-attribution-read-parity.test.ts"],
- "src/core/google/loop-catchup.ts": ["test/e2e/google-loops-recovery-postgres.test.ts"],
- "src/core/google/loop-detect.ts": ["test/e2e/google-loops-recovery-postgres.test.ts"],
- "src/core/cycle/connector-extract.ts": ["test/e2e/connector-cycle-extract-postgres.test.ts", "test/e2e/managed-connector-job-contract.test.ts"],
- "src/core/minions/handlers/autopilot-cycle.ts": ["test/e2e/managed-connector-job-contract.test.ts"],
- // Fix wave 4, Lane D: the apply-migrations orchestration lease (#5693), source deletes and
- // orphan bindings (#5732), and deactivate racing admission (#5455).
- "src/core/migration-orchestration-lock.ts": ["test/e2e/apply-migrations-orchestration-lock.test.ts", "test/e2e/export-db-only-own-lease-postgres.test.ts"],
- "src/core/source-delete.ts": ["test/e2e/sources-remove-bindings.test.ts"],
- "src/core/persistence/orphan-bindings.ts": ["test/e2e/sources-remove-bindings.test.ts"],
- // Fix wave 5 shared commit: preview-bound approved sets in op_checkpoints.
- "src/core/persistence/preview-approval.ts": ["test/e2e/preview-approval-postgres.test.ts", "test/e2e/minions-legacy-journey-postgres.test.ts"],
- // #5157: the legacy recovery commands and doctor check.
- // Agent operator wave D2: the Postgres-only --json successes (db-repair healthy, supervisor --detach).
- "src/commands/db-repair.ts": ["test/e2e/cli-json-commands-postgres.test.ts"],
- "src/commands/jobs/supervisor.ts": ["test/e2e/cli-json-commands-postgres.test.ts"],
- "src/commands/jobs/authorize-legacy.ts": ["test/e2e/minions-legacy-journey-postgres.test.ts"],
- "src/commands/jobs/cancel.ts": ["test/e2e/minions-legacy-journey-postgres.test.ts"],
- "src/commands/doctor/checks/legacy-job-authority.ts": ["test/e2e/minions-legacy-journey-postgres.test.ts"],
- // #5824: the vector-plan doctor check EXPLAINs the real searchVector statement.
- "src/commands/doctor/checks/vector-plan.ts": ["test/e2e/vector-plan-real-column-postgres.test.ts", "test/e2e/doctor-json-golden.test.ts"],
- // Fix wave 5 #5401: projection drain CLI and the budgeted resident drain.
- "src/commands/projections.ts": ["test/e2e/projection-drain-postgres.test.ts", "test/e2e/fix-wave-5-integration.test.ts"],
- "src/core/persistence/consumer.ts": ["test/e2e/projection-drain-postgres.test.ts"],
- "src/core/persistence/journal.ts": ["test/e2e/projection-drain-postgres.test.ts", "test/e2e/withdrawal-followup-writes-postgres.test.ts", "test/e2e/worktree-refresh-postgres.test.ts"],
- // F0 `gbrain sources refresh`: the refresh state machine, its admission/claim fence and restart recovery.
- "src/core/persistence/worktree-refresh.ts": ["test/e2e/worktree-refresh-postgres.test.ts"],
- // Fix wave 5 (#5731): the extractor-facts restore and its doctor check.
- "src/core/repair/extractor-facts.ts": ["test/e2e/repair-extractor-facts-postgres.test.ts", "test/e2e/fix-wave-5-integration.test.ts"],
- "src/core/repair/captured-facts.ts": ["test/e2e/repair-captured-facts-postgres.test.ts"],
- "src/commands/doctor/checks/captured-facts.ts": ["test/e2e/repair-captured-facts-postgres.test.ts"],
- "src/commands/extract-timeline-db.ts": ["test/e2e/extract-timeline-db-postgres.test.ts", "test/e2e/managed-connector-job-contract.test.ts"],
- "src/commands/doctor/checks/extractor-facts.ts": ["test/e2e/repair-extractor-facts-postgres.test.ts"],
- // Fix wave 5: managed writeSingleFact keeps an absent entity's fallback slug (attribute_fallback).
- // #5888 capture-lane dedup + hot-memory collapse, managed coordinator arm on Postgres.
- "src/core/facts/capture-dedup.ts": ["test/e2e/capture-dedup-postgres.test.ts"],
- "src/core/facts/single-prepare.ts": ["test/e2e/capture-dedup-postgres.test.ts"],
- "src/core/facts/write-single.ts": ["test/e2e/managed-write-single-attribution-postgres.test.ts", "test/e2e/managed-facts-writers.test.ts", "test/e2e/fix-wave-5-integration.test.ts"],
- "src/core/facts/managed-fact-write.ts": ["test/e2e/managed-write-single-attribution-postgres.test.ts", "test/e2e/managed-facts-writers.test.ts"],
- // Fix wave 5 (#5409): read-only mirror sources.
- "src/core/persistence/mirror-read-only.ts": ["test/e2e/sources-mirror-read-only-postgres.test.ts", "test/e2e/fix-wave-5-integration.test.ts"],
- "src/commands/sources-mirror.ts": ["test/e2e/sources-mirror-read-only-postgres.test.ts"],
- "src/core/persistence/deactivation.ts": ["test/e2e/persistence-deactivate-race.test.ts", "test/e2e/fix-wave-4-integration.test.ts"],
- // SkillOpt orchestrator, outcome/resume, models plan + strict mode, spend ledger.
- "src/core/skillopt/**": [
- "test/e2e/skillopt-loop.serial.test.ts",
- "test/e2e/skillopt-pglite.serial.test.ts",
- "test/e2e/skillopt-outcome.serial.test.ts",
- "test/e2e/skillopt-models-strict.serial.test.ts",
- "test/e2e/skillopt-models-used.serial.test.ts",
- "test/e2e/dream-cycle-phase-order-pglite.test.ts",
- ],
- "src/commands/skillopt.ts": [
- "test/e2e/skillopt-loop.serial.test.ts",
- "test/e2e/skillopt-pglite.serial.test.ts",
- "test/e2e/skillopt-outcome.serial.test.ts",
- "test/e2e/skillopt-models-strict.serial.test.ts",
- "test/e2e/skillopt-models-used.serial.test.ts",
- ],
- "src/commands/export.ts": ["test/e2e/export-snapshot-postgres.test.ts", "test/e2e/memory-safety-wave-postgres.test.ts"],
- "src/core/export-*.ts": ["test/e2e/export-snapshot-postgres.test.ts", "test/e2e/memory-safety-wave-postgres.test.ts"],
- // System One decide storage, egress page query and decide_health on Postgres/PgBouncer.
- "src/core/ai/decide/**": ["test/e2e/decide-store-postgres.test.ts"],
- // #5836 facts relink: write-target routing (file, page body, unbound refusal, managed) on Postgres.
- "src/core/facts/relink*.ts": ["test/e2e/facts-relink-routing.test.ts"],
- "src/core/persistence/fact-write-target.ts": ["test/e2e/facts-relink-routing.test.ts"],
- "src/commands/doctor/checks/decide.ts": ["test/e2e/decide-store-postgres.test.ts"],
- "src/core/company-brain/receipts.ts": ["test/e2e/company-brain-receipts.test.ts"],
- "src/core/company-brain/receipt-schema.ts": ["test/e2e/company-brain-receipts.test.ts"],
- "src/core/minions/errors.ts": ["test/e2e/subagent-gateway-path.test.ts", "test/e2e/delegated-http-worker.test.ts", "test/e2e/subagent-crash-replay-multi-provider.test.ts"],
- "src/core/harness/**": ["test/e2e/harness-access.test.ts", "test/e2e/shared-skills-transports.test.ts"],
- "src/core/shared-skills/**": ["test/e2e/export-db-only-own-lease-postgres.test.ts", "test/e2e/shared-skills-transports.test.ts", "test/e2e/shared-skills-rls.test.ts", "test/e2e/persistence-skill-bundles-postgres.test.ts", "test/e2e/knowledge-source-uri-postgres.test.ts"],
- "src/mcp/skill-resources.ts": ["test/e2e/shared-skills-transports.test.ts"],
- "src/core/scope.ts": ["test/e2e/client-grants.test.ts", "test/e2e/shared-skills-transports.test.ts"],
- "src/core/grants/**": ["test/e2e/client-grants.test.ts", "test/e2e/harness-access.test.ts", "test/e2e/delegated-grants-withdrawal.test.ts", "test/e2e/delegated-http-worker.test.ts"],
- // #5231/#5893 (O-ENG-7): legacy-token rescope and the explicit no-source grant on Postgres.
- "src/core/grants/legacy-token.ts": ["test/e2e/auth-rescope-token.test.ts", "test/e2e/access-token-grants.test.ts"],
- "src/core/legacy-token-scope.ts": ["test/e2e/auth-rescope-token.test.ts", "test/e2e/auth-permissions.test.ts", "test/e2e/access-token-grants.test.ts"],
- // F3: unified token grant columns, lazy migration, drift and the born-unified mint on Postgres.
- "src/core/grants/model.ts": ["test/e2e/access-token-grants.test.ts"],
- "src/core/grants/access-token-schema.ts": ["test/e2e/access-token-grants.test.ts"],
- "src/core/token-mint.ts": ["test/e2e/access-token-grants.test.ts", "test/e2e/auth-rescope-token.test.ts"],
- "src/core/facts/withdrawal*.ts": ["test/e2e/delegated-grants-withdrawal.test.ts", "test/e2e/withdrawal-bounded-safety-postgres.test.ts", "test/e2e/withdrawal-crash-postgres.test.ts", "test/e2e/memory-safety-wave-postgres.test.ts", "test/e2e/fact-withdrawal-scope-postgres.test.ts"],
- "src/commands/mcp*.ts": ["test/e2e/harness-access.test.ts"],
- // OpenRouter subagent-loop families: the family allowlist + recipe feed the
- // key-gated live DeepSeek replay (self-skips without OPENROUTER_API_KEY).
- "src/core/ai/openrouter-families.ts": ["test/e2e/openrouter-deepseek-subagent-replay.live.test.ts"],
- "src/core/ai/recipes/openrouter.ts": ["test/e2e/openrouter-deepseek-subagent-replay.live.test.ts"],
- // Serve-delegated sync: wire types, job runner, CLI ladder, and the IPC
- // plumbing all feed the delegation-under-serve E2E.
- "src/core/context/sync-ipc.ts": ["test/e2e/sync-delegation-under-serve.serial.test.ts"],
- "src/core/serve-sync-runner.ts": ["test/e2e/sync-delegation-under-serve.serial.test.ts"],
- "src/commands/sync-delegate.ts": ["test/e2e/sync-delegation-under-serve.serial.test.ts"],
- "src/core/context/resolve-ipc.ts": [
- "test/e2e/sync-delegation-under-serve.serial.test.ts",
- ],
- // Codex session-end capture lane: the hooks writer + hook-lane parser +
- // dispatch seam all feed the real-codex door (heavy lane).
- "src/core/bootstrap/codex-hooks.ts": ["test/e2e/bootstrap-real-codex.serial.test.ts"],
- "src/core/transcripts/codex-hook-lane.ts": ["test/e2e/bootstrap-real-codex.serial.test.ts"],
- "src/core/transcripts/capture-spec.ts": [
- "test/e2e/bootstrap-real-codex.serial.test.ts",
- ],
- // Concrete content and derived-information read policy parity.
- "src/core/remote-body.ts": ["test/e2e/engine-content-privacy.test.ts", "test/e2e/legacy-chunk-privacy.test.ts", "test/e2e/chunk-canonical-text-privacy.test.ts"],
- "src/core/entity-identity.ts": ["test/e2e/engine-content-privacy.test.ts"],
- "src/core/ops/admin.ts": ["test/e2e/get-health-embedding-column-postgres.test.ts"],
- "src/core/ops/**": ["test/e2e/engine-content-privacy.test.ts", "test/e2e/read-enrichment-privacy.test.ts", "test/e2e/legacy-chunk-privacy.test.ts", "test/e2e/chunk-canonical-text-privacy.test.ts", "test/e2e/put-page-persistence-postgres.test.ts", "test/e2e/deep-research-source-id.test.ts", "test/e2e/deep-research-http.test.ts", "test/e2e/derived-page-visibility.test.ts"],
- "src/commands/whoknows.ts": ["test/e2e/read-enrichment-privacy.test.ts"],
- "src/commands/orphans.ts": ["test/e2e/engine-content-privacy.test.ts"],
- // Source-aware ranking, hybrid search, intent classification.
- "src/core/search/private-visibility.ts": ["test/e2e/derived-page-visibility.test.ts", "test/e2e/derived-visibility-repair.test.ts", "test/e2e/chronicle-event-privacy-postgres.test.ts"],
- "src/core/search/**": [
- "test/e2e/unsupported-embedding-identity-postgres.test.ts",
- "test/e2e/projection-statistics-postgres.test.ts",
- "test/e2e/search-query-contract-postgres.test.ts",
- "test/e2e/vector-candidate-safety-postgres.test.ts",
- "test/e2e/vector-plan-real-column-postgres.test.ts",
- "test/e2e/projection-readiness-currency.test.ts",
- "test/e2e/chunk-canonical-text-privacy.test.ts",
- "test/e2e/engine-content-privacy.test.ts",
- "test/e2e/read-enrichment-privacy.test.ts", "test/e2e/legacy-chunk-privacy.test.ts",
- "test/e2e/search-quality.test.ts",
- "test/e2e/search-exclude.test.ts",
- "test/e2e/search-swamp.test.ts",
- ],
- "src/core/page-state/**": ["test/e2e/projection-recovery-parity.test.ts", "test/e2e/projection-drain-postgres.test.ts", "test/e2e/projection-readiness-currency.test.ts", "test/e2e/projection-embedding-input-hash.test.ts", "test/e2e/safe-chunk-reseal.test.ts", ...MIGRATION_WAVE_TESTS],
- "src/core/embedding-input-hash.ts": ["test/e2e/projection-embedding-input-hash.test.ts"],
- // Evidence delivery (return_unit): the release-gate leak canaries and the
- // engine / product-path parity suite.
- "src/core/search/evidence-delivery.ts": ["test/e2e/evidence-delivery-leak.test.ts", "test/e2e/evidence-delivery-parity.test.ts"],
- "src/core/search/chunk-windows.ts": ["test/e2e/evidence-delivery-leak.test.ts", "test/e2e/evidence-delivery-parity.test.ts"],
- "src/core/search/safe-chunks.ts": ["test/e2e/safe-chunk-reseal.test.ts", "test/e2e/legacy-chunk-privacy.test.ts"],
- "src/core/code-chunks.ts": ["test/e2e/projection-recovery-parity.test.ts"],
- "src/core/markdown-chunks.ts": ["test/e2e/projection-recovery-parity.test.ts"],
- // Tree-sitter chunkers feed code-indexing E2E.
- "src/core/chunkers/**": ["test/e2e/code-indexing.test.ts", "test/e2e/legacy-chunk-privacy.test.ts", "test/e2e/chunk-canonical-text-privacy.test.ts"],
- // OpenClaw context-engine plugin: engine + entry feed the plugin-shape E2E
- // (mocked SDK) AND the real-loader Tier 2 E2E that spawns openclaw and
- // actually installs the plugin into an isolated --profile.
- "src/core/context-engine.ts": [
- "test/e2e/openclaw-context-engine-plugin.test.ts",
- "test/e2e/openclaw-plugin-load-real.test.ts",
- "test/e2e/context-engine-rung3-extraction.test.ts",
- ],
- "src/openclaw-context-engine.ts": [
- "test/e2e/openclaw-context-engine-plugin.test.ts",
- "test/e2e/openclaw-plugin-load-real.test.ts",
- ],
- // dream.ts is a thin alias over runCycle in cycle.ts.
- "src/core/cycle.ts": ["test/e2e/cycle.test.ts", "test/e2e/dream.test.ts", "test/e2e/managed-phase-matrix.test.ts", "test/e2e/managed-connector-job-contract.test.ts", "test/e2e/connector-cycle-extract-postgres.test.ts", "test/e2e/extract-timeline-db-postgres.test.ts"],
- "src/core/cycle/phase-*.ts": ["test/e2e/managed-phase-matrix.test.ts"],
- // Multi-source sync writes share the per-source bookmark anchor.
- "src/core/sync.ts": ["test/e2e/sync.test.ts", "test/e2e/multi-source.test.ts", "test/e2e/sync-reconcile-postgres.test.ts", "test/e2e/sync-lock-overlap-postgres.test.ts"],
- // F7: real SIGKILL mid-sync on live Postgres — checkpoint banking
- // (op_checkpoint_paths), the frozen last_commit bookmark, stranded-lock
- // reclaim via TTL + steal grace, and exactly-once convergence on resume.
- // The peeled sync-* core modules (anchor/lock/reconcile/delta/git/…) all
- // feed that kill/resume journey.
- // Refactor wave 1 (W4 sync): parallel-worker completion under abort over
- // the concurrency clamp and stall/abort composition (sync-concurrency,
- // sync-reconcile). src/commands/sync/** stays unmapped (runs all E2E).
- "src/core/sync-*.ts": ["test/e2e/sync-sigkill-resume-postgres.test.ts", "test/e2e/sync-lock-overlap-postgres.test.ts", "test/e2e/sync-run-workers-postgres.test.ts"],
- // v0.32.8 multi-source bug class regression suite — fires on any cycle
- // phase, extract, integrity, embed, or migrate-engine change.
- "src/core/cycle/extract-takes.ts": ["test/e2e/multi-source-bug-class.test.ts", "test/e2e/extract-takes-managed.test.ts", "test/e2e/write-attribution-postgres.test.ts"],
- // Takes write-op layer (fence-first write + page-lock journey on real PG).
- "src/core/ops/takes.ts": ["test/e2e/takes-write-ops-postgres.test.ts"],
- "src/core/takes-write.ts": ["test/e2e/takes-write-ops-postgres.test.ts"],
- // JSONB bind parity for the cycle writers (the #2339 class PGLite hides).
- "src/core/cycle/propose-takes.ts": ["test/e2e/propose-takes-jsonb-postgres.test.ts"],
- "src/core/cycle/calibration-profile.ts": ["test/e2e/calibration-profile-write.test.ts"],
- "src/core/cycle/patterns.ts": ["test/e2e/multi-source-bug-class.test.ts", "test/e2e/dream-breaker-postgres.test.ts"],
- // Dream paid-loop breaker: released-key JSONB shape + counter + migration 173 on Postgres.
- "src/core/cycle/dream-breaker.ts": ["test/e2e/dream-breaker-postgres.test.ts"],
- "src/core/cycle/synthesize.ts": [
- "test/e2e/multi-source-bug-class.test.ts",
- "test/e2e/synthesize-bigint-job-id-postgres.test.ts",
- "test/e2e/dream-synthesize-pglite.test.ts",
- ],
- // The inline drain claims from MinionQueue, so its entry must be a SUPERSET:
- // the drain suite plus the full minions e2e set — a narrower list would
- // reduce coverage vs the fail-closed run-everything default for unmapped paths.
- "src/core/cycle/inline-drain.ts": [
- "test/e2e/dream-synthesize-pglite.test.ts",
- "test/e2e/minions-authority-parity.test.ts",
- "test/e2e/minions-concurrency.test.ts",
- "test/e2e/minions-resilience.test.ts",
- "test/e2e/minions-shell.test.ts",
- "test/e2e/minions-shell-pglite.test.ts",
- "test/e2e/worker-abort-recovery.test.ts",
- ],
- "src/commands/embed.ts": [
- ...MIGRATION_WAVE_TESTS,
- "test/e2e/multi-source-bug-class.test.ts",
- // #3391: the NULL-signature stale predicates differ per engine.
- "test/e2e/migrate-embeddings-postgres.test.ts",
- ],
- // #3390: runSchemaTransition's DDL path + the stale predicates behave
- // differently on real pgvector than on PGLite.
- "src/core/embedding-migration*.ts": ["test/e2e/migrate-embeddings-postgres.test.ts", "test/e2e/embedding-recovery-parity.test.ts", "test/e2e/memory-safety-wave-postgres.test.ts", "test/e2e/embedding-migration-settle-postgres.test.ts", ...MIGRATION_WAVE_TESTS],
- // #5680: the per-request ceilings the migration reserves and settles under FOR UPDATE.
- "src/core/ai/embed-batch-plan.ts": ["test/e2e/embedding-migration-settle-postgres.test.ts"],
- "src/core/embedding-readiness.ts": ["test/e2e/embedding-recovery-parity.test.ts"],
- "src/core/facts/embedding-identity.ts": ["test/e2e/embedding-recovery-parity.test.ts", "test/e2e/fact-embedding-backfill-parity.test.ts"],
- "src/core/stored-embedding-identity.ts": ["test/e2e/unsupported-embedding-identity-postgres.test.ts"],
- "src/commands/extract.ts": ["test/e2e/multi-source-bug-class.test.ts", "test/e2e/attendance-retrieval-postgres.test.ts", "test/e2e/extract-timeline-attendance-postgres.test.ts", "test/e2e/w5-persistence-postgres.test.ts", "test/e2e/managed-phase-matrix.test.ts", "test/e2e/managed-connector-job-contract.test.ts"],
- "src/commands/lint.ts": ["test/e2e/managed-phase-matrix.test.ts"],
- "src/commands/extract-attendance-repair.ts": ["test/e2e/attendance-repair-postgres.test.ts"],
- "src/commands/migrate-engine.ts": [
- "test/e2e/multi-source-bug-class.test.ts",
- "test/e2e/migrate-engine-pglite-to-postgres.test.ts",
- ],
- // Any minions queue/worker/handler change exercises all minion E2E.
- "src/core/minions/**": [
- "test/e2e/minions-legacy-coalesce-postgres.test.ts",
- "test/e2e/minions-legacy-journey-postgres.test.ts",
- "test/e2e/worker-readiness-cli.test.ts",
- "test/e2e/worker-configuration-release.test.ts",
- "test/e2e/delegated-grants-withdrawal.test.ts",
- "test/e2e/delegated-http-worker.test.ts",
- "test/e2e/minions-concurrency.test.ts",
- "test/e2e/minions-resilience.test.ts",
- "test/e2e/minions-shell.test.ts",
- "test/e2e/minions-shell-pglite.test.ts",
- "test/e2e/worker-abort-recovery.test.ts",
- "test/e2e/connector-sync-handler-pglite.test.ts",
- ],
- // v0.46.31.0 chat-connectors wave (mapped at the test-gap-wave merge —
- // these arrived unclaimed): connector classify/sync core + doctor check.
- "src/core/connectors/**": [
- "test/e2e/connector-sync-handler-pglite.test.ts",
- "test/e2e/connectors-sync-checkpoints-pglite.test.ts",
- "test/e2e/connectors-ingest-failure-pglite.test.ts",
- "test/e2e/connectors-sync-pglite.test.ts",
- "test/e2e/doctor-connectors-pglite.test.ts",
- ],
- // C-19: timestamp-less sessions are reported skips, not watermark-freezing errors.
- "src/core/transcripts/ingest.ts": ["test/e2e/transcripts-no-timestamp-pglite.test.ts"],
- // Agent-job scope fences over real Postgres.
- "src/core/ops/jobs.ts": ["test/e2e/jobs-agent-scope-postgres.test.ts", "test/e2e/delegated-grants-withdrawal.test.ts", "test/e2e/delegated-http-worker.test.ts"],
- // postgres.js bind paths + JSONB shapes + parity vs PGLite.
- "src/core/db-lock.ts": ["test/e2e/db-lock-acquisition-token.test.ts", "test/e2e/sync-lock-overlap-postgres.test.ts", "test/e2e/managed-connector-fencing.test.ts", "test/e2e/managed-connector-recovery.test.ts"],
- "src/core/lease-schema.ts": ["test/e2e/db-lock-acquisition-token.test.ts"],
- // O-CEO-13 wave-8 write contract gate: receipts, replay, edit_page, publication reauthorization.
- "src/core/persistence/page-edit.ts": ["test/e2e/write-contract-conformance.test.ts"],
- "src/core/persistence/write-wait.ts": ["test/e2e/write-contract-conformance.test.ts", "test/e2e/agent-journey-postgres.test.ts"],
- "src/core/ops/page-edit.ts": ["test/e2e/write-contract-conformance.test.ts"],
- // Foundations 1 write attribution: actor settings and BEFORE ROW triggers, direct and through PgBouncer.
- "src/core/persistence/attribution.ts": ["test/e2e/write-attribution-postgres.test.ts"],
- "src/core/persistence/attribution-schema.ts": ["test/e2e/write-attribution-postgres.test.ts"],
- "src/core/persistence/context.ts": ["test/e2e/write-attribution-postgres.test.ts"],
- "src/core/persistence/**": [
- "test/e2e/fix-wave-3-integration.test.ts",
- "test/e2e/persistence-http-liveness.test.ts",
- "test/e2e/persistence-phase-liveness.test.ts",
- "test/e2e/persistence-idle-pool.test.ts",
- "test/e2e/persistence-publication-parity.test.ts",
- "test/e2e/persistence-sync-origin-parity.test.ts",
- "test/e2e/persistence-sync-options-parity.test.ts",
- "test/e2e/persistence-sync-company-parity.test.ts",
- "test/e2e/persistence-chaos.test.ts",
- "test/e2e/persistence-runtime-matrix.test.ts",
- "test/e2e/persistence-admin-intent.test.ts",
- "test/e2e/persistence-writer-admin-lock.test.ts",
- "test/e2e/persistence-writer-stamps.test.ts",
- "test/e2e/persistence-recovery.test.ts",
- "test/e2e/managed-sync-failures.test.ts",
- "test/e2e/managed-connector-routing.test.ts",
- "test/e2e/managed-connector-retry.test.ts",
- "test/e2e/managed-connector-fencing.test.ts",
- "test/e2e/managed-connector-recovery.test.ts",
- "test/e2e/managed-facts-backstop.test.ts",
- "test/e2e/managed-facts-embedding.test.ts",
- "test/e2e/managed-facts-compaction.test.ts",
- "test/e2e/facts-worker-config.test.ts",
- "test/e2e/managed-extract-atoms.test.ts",
- "test/e2e/managed-atom-regressions.test.ts",
- "test/e2e/managed-atom-compaction.test.ts",
- "test/e2e/repair-stale-atoms-postgres.test.ts",
- "test/e2e/journey-atoms-sync-race-postgres.test.ts",
- "test/e2e/managed-maintenance.test.ts",
- "test/e2e/managed-writers-w3.test.ts",
- "test/e2e/managed-facts-writers.test.ts",
- "test/e2e/unbound-source-postgres.test.ts",
- "test/e2e/managed-phase-matrix.test.ts",
- "test/e2e/managed-synthesis-postprocess.test.ts",
- "test/e2e/persistence-embedding-effects.test.ts",
- "test/e2e/withdrawal-bounded-safety-postgres.test.ts",
- "test/e2e/withdrawal-crash-postgres.test.ts",
- "test/e2e/memory-safety-wave-postgres.test.ts",
- "test/e2e/reconcile-crash.test.ts",
- "test/e2e/reconcile-crash-unactivated.test.ts",
- "test/e2e/reconcile-pgbouncer.test.ts",
- "test/e2e/reconcile-unbound-collision.test.ts",
- "test/e2e/persistence-skill-bundles-postgres.test.ts",
- "test/e2e/shared-skills-transports.test.ts",
- "test/e2e/canonical-projection-history.test.ts",
- "test/e2e/derived-page-visibility.test.ts",
- "test/e2e/timeline-materialize.test.ts",
- "test/e2e/derived-visibility-repair.test.ts",
- "test/e2e/repair-command.test.ts",
- "test/e2e/w5-persistence-postgres.test.ts",
- "test/e2e/persistence-large-manifest-postgres.test.ts",
- "test/e2e/persistence-large-manifest-50k.test.ts",
- ],
- "src/core/brain-score-recommendations.ts": ["test/e2e/w5-persistence-postgres.test.ts"],
- "src/core/repair/**": ["test/e2e/repair-command.test.ts", "test/e2e/derived-visibility-repair.test.ts", "test/e2e/safe-chunk-reseal.test.ts", "test/e2e/recovery-layer.test.ts", "test/e2e/repair-contextual-mode-5621-postgres.test.ts", "test/e2e/fix-wave-3-integration.test.ts"],
- "src/core/remediation/**": ["test/e2e/recovery-layer.test.ts"],
- "src/core/remediation-checkpoint.ts": ["test/e2e/recovery-layer.test.ts"],
- "src/commands/repair.ts": ["test/e2e/repair-command.test.ts", "test/e2e/repair-contextual-mode-5621-postgres.test.ts"],
- "src/core/import-contextual-mode.ts": ["test/e2e/repair-contextual-mode-5621-postgres.test.ts"],
- "src/core/ai/embedding-guard.ts": ["test/e2e/embedding-zero-norm-4616-postgres.test.ts"],
- "src/commands/reindex-vectors.ts": ["test/e2e/embedding-zero-norm-4616-postgres.test.ts"],
- "src/core/embedding-invalidation.ts": ["test/e2e/embed-stale-dry-run-restamp-5289-postgres.test.ts", "test/e2e/embedding-tombstones-postgres.test.ts"],
- "src/core/embed-concurrency.ts": ["test/e2e/embed-stale-pool-default-postgres.test.ts"],
- "src/core/embed-stale.ts": ["test/e2e/embed-stale-pool-default-postgres.test.ts"],
- "src/core/persistence/effect-git.ts": ["test/e2e/persistence-git-coalescing-5530-postgres.test.ts"],
- "src/core/persistence/effect-journal.ts": ["test/e2e/persistence-git-coalescing-5530-postgres.test.ts", "test/e2e/worktree-refresh-postgres.test.ts"],
- "src/core/persistence/grandfather.ts": ["test/e2e/persistence-git-coalescing-5530-postgres.test.ts", "test/e2e/grandfather-projection-postgres.test.ts"],
- "src/core/timeline-marker.ts": ["test/e2e/timeline-materialize.test.ts"],
- "src/commands/source-reconcile.ts": ["test/e2e/reconcile-crash.test.ts", "test/e2e/reconcile-crash-unactivated.test.ts", "test/e2e/reconcile-pgbouncer.test.ts"],
- // fix wave GBRA-35 lane C (#5809/#5832): drain hard stops, bounded counts and lease loss on Postgres.
- "src/core/cycle/extract-atoms-drain.ts": ["test/e2e/extract-atoms-drain-postgres.test.ts", "test/e2e/managed-connector-job-contract.test.ts"],
- "src/core/cycle/extract-atoms.ts": ["test/e2e/extract-atoms-page-state.test.ts", "test/e2e/cycle.test.ts", "test/e2e/dream.test.ts", "test/e2e/multi-source-bug-class.test.ts", "test/e2e/managed-extract-atoms.test.ts", "test/e2e/managed-atom-regressions.test.ts", "test/e2e/managed-atom-compaction.test.ts"],
- "src/core/cycle/synthesize*.ts": ["test/e2e/managed-maintenance.test.ts", "test/e2e/managed-synthesis-postprocess.test.ts", "test/e2e/managed-writers-w3.test.ts", "test/e2e/session-seat-synthesize.test.ts"],
- // #4618: seat sidecar discovery and the seat stamp on both synthesis write paths.
- "src/core/cycle/transcript-discovery.ts": ["test/e2e/session-seat-synthesize.test.ts"],
- "src/core/cycle/dream-provenance.ts": ["test/e2e/session-seat-synthesize.test.ts"],
- "src/core/cycle/concept-publication.ts": ["test/e2e/managed-writers-w3.test.ts"],
- "src/core/chronicle/extract-events.ts": ["test/e2e/managed-writers-w3.test.ts"],
- "src/commands/enrich.ts": ["test/e2e/managed-writers-w3.test.ts"],
- // #5827: link-op source scope (remote federated, local per-source merge).
- "src/core/ops/links.ts": ["test/e2e/managed-writers-w3.test.ts", "test/e2e/federated-link-reads-postgres.test.ts"],
- "src/core/cycle/extract-atoms-page-state.ts": ["test/e2e/extract-atoms-page-state.test.ts", "test/e2e/reconcile-crash.test.ts", "test/e2e/reconcile-crash-unactivated.test.ts", "test/e2e/reconcile-pgbouncer.test.ts"],
- "src/commands/migrations/v0_13_1.ts": ["test/e2e/grandfather-projection-postgres.test.ts", "test/e2e/persistence-git-coalescing-5530-postgres.test.ts"],
- "src/commands/migrations/v0_32_2.ts": ["test/e2e/migrations-v0_32_2-managed.test.ts"],
- "src/core/facts/withdrawal.ts": ["test/e2e/facts-withdrawal-fingerprint-once.test.ts"],
- "src/core/extract-takes-from-pages.ts": ["test/e2e/persistence-managed-takes-extract.test.ts", "test/e2e/extract-takes-from-pages-resolutions.test.ts"],
- "src/core/persistence/prepared-maintenance.ts": ["test/e2e/migrations-v0_32_2-managed.test.ts", "test/e2e/fix-wave-4-integration.test.ts", "test/e2e/managed-connector-job-contract.test.ts", "test/e2e/maintenance-write-wait.test.ts"],
- "src/core/persistence/maintenance-wait.ts": ["test/e2e/maintenance-write-wait.test.ts", "test/e2e/managed-synthesis-postprocess.test.ts", "test/e2e/managed-connector-job-contract.test.ts"],
- "src/core/pool-budget.ts": ["test/e2e/persistence-runtime-matrix.test.ts"],
- "src/core/connection-manager.ts": ["test/e2e/persistence-runtime-matrix.test.ts", "test/e2e/pgbouncer-teardown.test.ts"],
- "src/core/postgres-engine.ts": [
- "test/e2e/executor-binding-matrix.test.ts",
- ...MIGRATION_WAVE_TESTS,
- "test/e2e/legacy-vector-compatibility-postgres.test.ts",
- "test/e2e/postgres-driver-install.test.ts",
- "test/e2e/unsupported-embedding-identity-postgres.test.ts",
- "test/e2e/fixture-reset-postgres.test.ts",
- "test/e2e/persistence-chaos.test.ts",
- "test/e2e/postgres-poisoned-connection.test.ts",
- "test/e2e/postgres-checkout-observer.test.ts",
- "test/e2e/db-lock-acquisition-token.test.ts",
- "test/e2e/chunk-canonical-text-privacy.test.ts",
- "test/e2e/engine-content-privacy.test.ts",
- "test/e2e/read-enrichment-privacy.test.ts", "test/e2e/legacy-chunk-privacy.test.ts",
- "test/e2e/postgres-bootstrap.test.ts",
- "test/e2e/postgres-jsonb.test.ts",
- "test/e2e/jsonb-roundtrip.test.ts",
- "test/e2e/engine-parity.test.ts",
- "test/e2e/schema-drift.test.ts",
- "test/e2e/schema-catalog-golden.test.ts",
- // #3391: includeNullSignature stale predicates (engine parity).
- "test/e2e/migrate-embeddings-postgres.test.ts",
- // getHealth islanded-liveness + entity-coverage floor (#4153/#4147).
- "test/e2e/health-parity-postgres.test.ts",
- // #4109: FOR KEY SHARE deletion-race behavior of addLink/addTimelineEntry.
- "test/e2e/source-boundary-mutation-postgres.test.ts",
- // Shared-singleton ownership: disconnect idempotency, shared-pool
- // recovery and reconnect under a live singleton.
- "test/e2e/postgres-engine-disconnect-idempotency.test.ts",
- "test/e2e/db-singleton-shared-recovery.test.ts",
- "test/e2e/postgres-reconnect-singleton.test.ts",
- // #5824: searchVector + explainVectorSearch plan proof.
- "test/e2e/vector-candidate-safety-postgres.test.ts",
- "test/e2e/vector-plan-real-column-postgres.test.ts",
- ],
- // PGLite bootstrap path + parity guard.
- "src/core/pglite-engine.ts": [
- "test/e2e/executor-binding-matrix.test.ts",
- ...MIGRATION_WAVE_TESTS,
- "test/e2e/legacy-vector-compatibility-postgres.test.ts",
- "test/e2e/unsupported-embedding-identity-postgres.test.ts",
- "test/e2e/persistence-chaos.test.ts",
- "test/e2e/chunk-canonical-text-privacy.test.ts",
- "test/e2e/engine-content-privacy.test.ts",
- "test/e2e/read-enrichment-privacy.test.ts", "test/e2e/legacy-chunk-privacy.test.ts",
- "test/e2e/postgres-bootstrap.test.ts",
- "test/e2e/engine-parity.test.ts",
- "test/e2e/schema-drift.test.ts",
- "test/e2e/schema-catalog-golden.test.ts",
- "test/e2e/health-parity-postgres.test.ts",
- ],
- // Engine method modules peeled from the façades carry the same blast
- // radius as the façades themselves.
- "src/core/postgres-engine/**": [
- "test/e2e/executor-binding-matrix.test.ts",
- "test/e2e/unsupported-embedding-identity-postgres.test.ts",
- "test/e2e/chunk-canonical-text-privacy.test.ts",
- "test/e2e/engine-content-privacy.test.ts",
- "test/e2e/read-enrichment-privacy.test.ts", "test/e2e/legacy-chunk-privacy.test.ts",
- "test/e2e/postgres-bootstrap.test.ts",
- "test/e2e/postgres-jsonb.test.ts",
- "test/e2e/jsonb-roundtrip.test.ts",
- "test/e2e/engine-parity.test.ts",
- "test/e2e/schema-drift.test.ts",
- "test/e2e/schema-catalog-golden.test.ts",
- "test/e2e/migrate-embeddings-postgres.test.ts",
- "test/e2e/health-parity-postgres.test.ts",
- "test/e2e/source-boundary-mutation-postgres.test.ts",
- ],
- "src/core/pglite-engine/**": [
- "test/e2e/executor-binding-matrix.test.ts",
- "test/e2e/unsupported-embedding-identity-postgres.test.ts",
- "test/e2e/chunk-canonical-text-privacy.test.ts",
- "test/e2e/engine-content-privacy.test.ts",
- "test/e2e/read-enrichment-privacy.test.ts", "test/e2e/legacy-chunk-privacy.test.ts",
- "test/e2e/postgres-bootstrap.test.ts",
- "test/e2e/engine-parity.test.ts",
- "test/e2e/schema-drift.test.ts",
- "test/e2e/health-parity-postgres.test.ts",
- // master's own remote-privacy sweep suite for the scoped salience arms
- // (mapped at the test-gap-wave merge — arrived unclaimed).
- "test/e2e/salience-anomalies-source-isolation-pglite.test.ts",
- ],
- // Both engines route CJK queries through the shared branch since #3986
- // (src/core/search/cjk-keyword-sql.ts). The cross-engine parity is pinned — any change here must re-run the pin. (Matches
- // src/core/engine-sql/** too; selector unions the entries.)
- "src/core/engine-sql/cjk-search.ts": ["test/e2e/engine-parity-cjk.test.ts"],
- // #5889 / title FTS: the title arm (engine-sql/titles.ts + its statement in
- // search/title-statement.ts) — dual-backend ranking + remote plan proof.
- "src/core/engine-sql/titles.ts": ["test/e2e/title-arm-postgres.test.ts"],
- "src/core/search/title-statement.ts": ["test/e2e/title-arm-postgres.test.ts"],
- // D7 parity batch: the code-edge read paths (getCallersOf / getCalleesOf /
- // getEdgesByChunk) live in engine-sql/code-edges.ts (PGLite's getEdgesByChunk
- // stays in its engine module dir); both key the cross-engine read-parity
- // suite directly. (The ** globs match these files too; the selector unions
- // the entries.)
- "src/core/engine-sql/code-edges.ts": ["test/e2e/code-edges-read-parity.test.ts", "test/e2e/code-intel-n13-postgres.test.ts"],
- // Eval-category wave lane A (folded into fix wave 5): N13 code-intel walk and N8 private-page reflex filter.
- "src/core/code-intel/recursive-walk.ts": ["test/e2e/code-intel-n13-postgres.test.ts"],
- "src/core/context/retrieval-reflex.ts": ["test/e2e/reflex-private-visibility-postgres.test.ts"],
- "src/core/pglite-engine/code-edges.ts": ["test/e2e/code-edges-read-parity.test.ts"],
- // D7 parity batch: chronicle ontology merge (mergeOntologyFact helpers in
- // chronicle/ontology.ts) + event projection (only production caller:
- // chronicle/extract-events.ts) and their op surface run against BOTH
- // engines; a change to any of them re-runs the parity pins.
- "src/core/chronicle/**": [
- "test/e2e/ontology-merge-parity.test.ts",
- "test/e2e/chronicle-event-projection-parity.test.ts",
- "test/e2e/chronicle-auto-decision-postgres.test.ts",
- "test/e2e/chronicle-auto-phase-postgres.test.ts",
- "test/e2e/chronicle-event-privacy-postgres.test.ts",
- "test/e2e/chronicle-surfaces-postgres.test.ts",
- ],
- // #5876: doctor auto_chronicle + the chronicle advisor read the ledger rollups.
- "src/commands/doctor/checks/auto-chronicle.ts": ["test/e2e/chronicle-surfaces-postgres.test.ts"],
- "src/core/advisor/collect-chronicle.ts": ["test/e2e/chronicle-surfaces-postgres.test.ts"],
- "src/core/ops/chronicle.ts": [
- "test/e2e/ontology-merge-parity.test.ts",
- "test/e2e/chronicle-event-projection-parity.test.ts",
- "test/e2e/managed-ontology-propose-postgres.test.ts",
- ],
- // #5876: the Life Chronicle automatic path (phase, write decision, origin privacy) on Postgres.
- "src/core/cycle/chronicle.ts": ["test/e2e/chronicle-auto-phase-postgres.test.ts"],
- "src/core/persistence/derived-extraction-gate.ts": ["test/e2e/chronicle-auto-decision-postgres.test.ts"],
- // Eval-category wave lane C: coordinated database-only writes (manual links,
- // ontology observations) and the per-stint ontology dedup key.
- "src/core/persistence/database-write.ts": ["test/e2e/managed-ontology-propose-postgres.test.ts", "test/e2e/managed-writers-w3.test.ts"],
- "src/core/schema-migrations/v188-facts-ontology-stint-dedup.ts": ["test/e2e/ontology-merge-parity.test.ts", "test/e2e/schema-drift.test.ts"],
- "src/core/persistence/memory-mutations.ts": ["test/e2e/withdrawal-followup-writes-postgres.test.ts"],
- "src/core/persistence/coordinator.ts": ["test/e2e/withdrawal-followup-writes-postgres.test.ts"],
- "src/core/repair/failed-writes.ts": ["test/e2e/repair-failed-writes-5983-postgres.test.ts"],
- "src/core/persistence/writer-guard-schema.ts": ["test/e2e/managed-writer-guard-null-source-5983-postgres.test.ts", "test/e2e/schema-drift.test.ts", "test/e2e/schema-catalog-golden.test.ts"],
- "src/core/schema-migrations/v197-managed-guard-null-source-fallback.ts": ["test/e2e/managed-writer-guard-null-source-5983-postgres.test.ts", "test/e2e/schema-drift.test.ts", "test/e2e/schema-catalog-golden.test.ts"],
- "src/core/facts/meta-hook.ts": ["test/e2e/capture-dedup-postgres.test.ts", "test/e2e/hot-memory-invalidation-postgres.test.ts", "test/e2e/facts-context-injection-postgres.test.ts", "test/e2e/serve-http-meta.test.ts"],
- "src/mcp/dispatch.ts": ["test/e2e/hot-memory-invalidation-postgres.test.ts", "test/e2e/write-contract-conformance.test.ts", "test/e2e/agent-journey-postgres.test.ts"],
- // Foundations 1 F4b: PGLite-only planner-stats accounting; Postgres must gain no object, doctor/repair read pg_stat_user_tables.
- "src/core/planner-stats.ts": ["test/e2e/planner-stats-postgres.test.ts"],
- "src/core/planner-stats-schema.ts": ["test/e2e/planner-stats-postgres.test.ts", "test/e2e/schema-drift.test.ts", "test/e2e/schema-catalog-golden.test.ts"],
- "src/core/schema-migrations/v193-f4-planner-stats.ts": ["test/e2e/planner-stats-postgres.test.ts", "test/e2e/schema-drift.test.ts", "test/e2e/schema-catalog-golden.test.ts"],
- "src/commands/doctor/checks/planner-stats.ts": ["test/e2e/planner-stats-postgres.test.ts"],
- "src/core/repair/planner-stats.ts": ["test/e2e/planner-stats-postgres.test.ts"],
- // Agent operator wave H4: Postgres parity of the keyless agent journey (init --json, day-zero doctor,
- // doctor --remediate consent on a pending-migration brain, stdio MCP notices/errors/readiness, degraded serve).
- "src/core/agent-output.ts": ["test/e2e/agent-journey-postgres.test.ts"],
- "src/core/readiness.ts": ["test/e2e/agent-journey-postgres.test.ts"],
- "src/core/consent.ts": ["test/e2e/agent-journey-postgres.test.ts"],
- "src/core/consent-cli.ts": ["test/e2e/agent-journey-postgres.test.ts"],
- "src/core/interop-notices.ts": ["test/e2e/agent-journey-postgres.test.ts"],
- "src/core/degraded-engine.ts": ["test/e2e/agent-journey-postgres.test.ts"],
- "src/core/agent-contract-log.ts": ["test/e2e/agent-journey-postgres.test.ts"],
- "src/mcp/server.ts": ["test/e2e/agent-journey-postgres.test.ts"],
- "src/mcp/capabilities.ts": ["test/e2e/agent-journey-postgres.test.ts"],
- "src/mcp/validate-params.ts": ["test/e2e/agent-journey-postgres.test.ts"],
- "src/commands/init.ts": ["test/e2e/agent-journey-postgres.test.ts"],
- "src/commands/serve-status.ts": ["test/e2e/agent-journey-postgres.test.ts"],
- // Schema source of truth: any change must pass the cross-engine drift gate.
- "src/schema.sql": ["test/e2e/schema-drift.test.ts", "test/e2e/schema-catalog-golden.test.ts"],
- "src/core/pglite-schema.ts": ["test/e2e/schema-drift.test.ts", "test/e2e/schema-catalog-golden.test.ts"],
- "src/core/pglite-schema.generated.ts": ["test/e2e/schema-drift.test.ts", "test/e2e/schema-catalog-golden.test.ts"],
- "src/core/migrate.ts": [
- "test/e2e/migration-vector-replay-postgres.test.ts",
- "test/e2e/schema-drift.test.ts",
- // Refactor wave 1 E4: catalog-level goldens (both engines, both init paths).
- "test/e2e/schema-catalog-golden.test.ts",
- "test/e2e/migrate-chain.test.ts",
- "test/e2e/link-source-check-repair-postgres.test.ts",
- // Refactor wave 1 W3: replay the split registry from checkpoints.
- "test/e2e/schema-migrations-replay.test.ts",
- ],
- "src/core/schema-migrations/**": [
- "test/e2e/migration-vector-replay-postgres.test.ts",
- "test/e2e/schema-drift.test.ts",
- "test/e2e/schema-catalog-golden.test.ts",
- "test/e2e/migrate-chain.test.ts",
- "test/e2e/schema-migrations-replay.test.ts",
- ],
- // #4613: the links_link_source_check self-heal must use migration v114's
- // two-phase DDL (DROP + ADD NOT VALID, then VALIDATE outside the txn) on real
- // Postgres — lock semantics PGLite can't observe. Keyed on the repair module
- // and on migrate.ts (the definition it reproduces).
- "src/core/link-source-check-repair.ts": ["test/e2e/link-source-check-repair-postgres.test.ts"],
- "src/core/vector-index.ts": ["test/e2e/migration-vector-replay-postgres.test.ts"],
- // MCP stdio + HTTP transports share dispatch.
- "src/mcp/**": ["test/e2e/http-transport.test.ts", "test/e2e/mcp-search-transport-matrix.test.ts", "test/e2e/token-usage-skip-locked.test.ts"],
- // Integrity batch-load fast path.
- "src/commands/integrity.ts": ["test/e2e/integrity-batch.test.ts"],
- // Upgrade chains migration ledger; touches both runners. The bun-link arc
- // is pinned by test/upgrade-bun-link-arc.serial.test.ts (serial lane).
- "src/commands/upgrade.ts": [
- "test/e2e/upgrade.test.ts",
- "test/e2e/migrate-chain.test.ts",
- "test/e2e/migration-flow.test.ts",
- ],
- "src/commands/apply-migrations.ts": [
- "test/e2e/apply-migrations-orchestration-lock.test.ts",
- "test/e2e/export-db-only-own-lease-postgres.test.ts",
- "test/e2e/migration-preview-safety.test.ts",
- "test/e2e/migrate-chain.test.ts",
- "test/e2e/migration-flow.test.ts",
- "test/e2e/managed-migration-chain-postgres.test.ts",
- ],
- "src/commands/migrations/**": [
- "test/e2e/migration-preview-safety.test.ts",
- "test/e2e/migrate-chain.test.ts",
- "test/e2e/migration-flow.test.ts",
- "test/e2e/managed-migration-chain-postgres.test.ts",
- ],
- // Autopilot linux install/uninstall lifecycle (PATH-shimmed crontab +
- // systemctl; the ubuntu CI runner's only behavioral pin on those arms).
- "src/commands/autopilot.ts": ["test/e2e/autopilot-linux-lifecycle.serial.test.ts", "test/e2e/autopilot-multi-brain.serial.test.ts", "test/e2e/worker-readiness-cli.test.ts"],
- "src/commands/autopilot/jobs.ts": ["test/e2e/autopilot-linux-lifecycle.serial.test.ts", "test/e2e/autopilot-multi-brain.serial.test.ts"],
- "src/core/autopilot-paths.ts": ["test/e2e/autopilot-linux-lifecycle.serial.test.ts", "test/e2e/autopilot-multi-brain.serial.test.ts"],
- "src/commands/autopilot-daemon.ts": ["test/e2e/autopilot-linux-lifecycle.serial.test.ts", "test/e2e/worker-readiness-cli.test.ts"],
- "src/commands/autopilot-dispatch.ts": ["test/e2e/autopilot-linux-lifecycle.serial.test.ts", "test/e2e/worker-readiness-cli.test.ts", "test/e2e/managed-connector-job-contract.test.ts", "test/e2e/autopilot-auto-drain-dispatch.test.ts"],
- "src/commands/autopilot-probes.ts": ["test/e2e/autopilot-linux-lifecycle.serial.test.ts", "test/e2e/worker-readiness-cli.test.ts"],
- "src/commands/doctor.ts": ["test/e2e/doctor-progress.test.ts", "test/e2e/doctor-json-golden.test.ts"],
- // Doctor check modules peeled from doctor.ts feed the same e2e surface.
- "src/commands/doctor/**": ["test/e2e/doctor-progress.test.ts", "test/e2e/recovery-layer.test.ts", "test/e2e/fix-wave-3-integration.test.ts", "test/e2e/doctor-json-golden.test.ts", "test/e2e/agent-journey-postgres.test.ts"],
- // Knowledge graph layer feeds graph-quality.
- "src/core/link-extraction.ts": ["test/e2e/graph-quality.test.ts", "test/e2e/attendance-retrieval-postgres.test.ts"],
- "src/core/attendance-repair.ts": ["test/e2e/attendance-repair-postgres.test.ts"],
- "src/core/extract-timeline-from-meetings.ts": ["test/e2e/extract-timeline-attendance-postgres.test.ts"],
- "src/core/derived-links.ts": ["test/e2e/attendance-retrieval-postgres.test.ts", "test/e2e/attendance-repair-postgres.test.ts"],
- "src/core/link-reconciliation.ts": ["test/e2e/attendance-retrieval-postgres.test.ts"],
- "src/core/persistence/links-preparation.ts": ["test/e2e/attendance-retrieval-postgres.test.ts"],
- "src/core/sweep.ts": ["test/e2e/attendance-retrieval-postgres.test.ts", "test/e2e/fix-wave-5-integration.test.ts"],
- // v0.38 ingestion substrate. POST /ingest lives inside serve-http.ts
- // (per the plan-eng-review E1 decision); the daemon + built-in sources
- // + ingest_capture Minion handler all feed the in-process roundtrip
- // E2E AND the HTTP contract E2E for the webhook route.
- "src/core/oauth-provider.ts": ["test/e2e/oauth-grant-transactions.test.ts", "test/e2e/serve-http-oauth.test.ts", "test/e2e/token-usage-skip-locked.test.ts"],
- // #5730: non-idle pooled connections are discarded by the vendored driver.
- "vendor/postgres/**": ["test/e2e/postgres-poisoned-connection.test.ts", "test/e2e/persistence-chaos.test.ts"],
- "src/core/pool-gauge.ts": ["test/e2e/postgres-poisoned-connection.test.ts", "test/e2e/postgres-checkout-observer.test.ts"],
- "src/core/oauth-grants.ts": ["test/e2e/oauth-grant-transactions.test.ts", "test/e2e/serve-http-consent.test.ts"],
- "src/core/grants/lifecycle.ts": ["test/e2e/oauth-grant-transactions.test.ts", "test/e2e/serve-http-consent.test.ts"],
- "src/commands/serve-http-clients.ts": ["test/e2e/serve-http-consent.test.ts"],
- "src/commands/serve-http-grants.ts": ["test/e2e/serve-http-consent.test.ts", "test/e2e/serve-http-source-grant.test.ts"],
- "src/commands/serve-http-registration.ts": ["test/e2e/serve-http-consent.test.ts"],
- "src/commands/serve-http-admin-limits.ts": ["test/e2e/serve-http-consent.test.ts"],
- "src/core/harness/client-setup.ts": ["test/e2e/serve-http-consent.test.ts"],
- "src/commands/serve-http-oauth.ts": ["test/e2e/serve-http-consent.test.ts", "test/e2e/serve-http-oauth.test.ts"],
- // Refactor wave 1 split runServeHttp into these modules; each keeps the
- // façade's e2e claims for the code it took.
- "src/commands/serve-http-admin-api.ts": ["test/e2e/serve-http-consent.test.ts", "test/e2e/serve-http-oauth.test.ts"],
- "src/commands/serve-http-metrics.ts": ["test/e2e/serve-http-oauth.test.ts"],
- "src/commands/serve-http-spa.ts": ["test/e2e/serve-http-consent.test.ts"],
- "src/commands/serve-http-webhooks.ts": ["test/e2e/serve-http-ingest-webhook.test.ts", "test/e2e/minions-legacy-journey-postgres.test.ts"],
- "src/commands/serve-http-mcp.ts": [
- "test/e2e/serve-http-oauth.test.ts",
- "test/e2e/harness-access.test.ts",
- "test/e2e/serve-http-source-grant.test.ts",
- ],
- "src/commands/serve-http.ts": [
- "test/e2e/serve-http-consent.test.ts",
- "test/e2e/serve-http-ingest-webhook.test.ts",
- "test/e2e/serve-http-oauth.test.ts",
- "test/e2e/harness-access.test.ts",
- // #3242 wiring: legacy no-grant federated widening vs granted confinement
- // over the SDK /mcp transport (verifyAccessToken → noGrantFederatedScope
- // → OperationContext.localFederatedSourceIds).
- "test/e2e/serve-http-source-grant.test.ts",
- ],
- "src/core/ingestion/**": [
- "test/e2e/ingestion-roundtrip.test.ts",
- "test/e2e/serve-http-ingest-webhook.test.ts",
- ],
- "src/core/minions/handlers/ingest-capture.ts": [
- "test/e2e/ingestion-roundtrip.test.ts",
- "test/e2e/serve-http-ingest-webhook.test.ts",
- ],
- "src/core/embed-facts*.ts": ["test/e2e/fact-embedding-backfill-parity.test.ts"],
- "src/core/cycle/extract-facts.ts": ["test/e2e/fact-vector-repair-parity.test.ts", "test/e2e/facts-fence-reconcile-postgres.test.ts", "test/e2e/write-attribution-postgres.test.ts"],
- "src/core/cycle/phases/consolidate.ts": ["test/e2e/managed-maintenance.test.ts", "test/e2e/cycle.test.ts"],
- "src/core/ops/facts.ts": ["test/e2e/managed-facts-backstop.test.ts"],
- "src/core/facts/backstop.ts": ["test/e2e/capture-dedup-postgres.test.ts", "test/e2e/managed-facts-backstop.test.ts", "test/e2e/facts-worker-config.test.ts", "test/e2e/managed-facts-embedding.test.ts", "test/e2e/managed-facts-compaction.test.ts", "test/e2e/legacy-fact-extraction-dedup-postgres.test.ts"],
- "src/core/facts/extract.ts": ["test/e2e/managed-facts-embedding.test.ts"],
- "src/core/github-source.ts": ["test/e2e/managed-connector-routing.test.ts", "test/e2e/managed-connector-retry.test.ts", "test/e2e/managed-connector-fencing.test.ts", "test/e2e/managed-connector-recovery.test.ts", "test/e2e/connector-holds.test.ts"],
- "src/core/google/google-source.ts": ["test/e2e/managed-connector-routing.test.ts", "test/e2e/managed-connector-retry.test.ts", "test/e2e/managed-connector-fencing.test.ts", "test/e2e/managed-connector-recovery.test.ts", "test/e2e/google-attachments-postgres.test.ts", "test/e2e/connector-holds.test.ts", "test/e2e/managed-connector-job-contract.test.ts", "test/e2e/google-loops-recovery-postgres.test.ts"],
- "src/core/google/attachment-receipts.ts": ["test/e2e/google-attachments-postgres.test.ts"],
- "src/core/google/attachment-backfill.ts": ["test/e2e/google-attachments-postgres.test.ts"],
- "src/core/persistence/connector-google-receipts.ts": ["test/e2e/google-attachments-postgres.test.ts"],
- // Fix wave 4 lane B: connector item holds, #5581 Gmail cursors, the dispatch gate and the fence refusal.
- "src/core/connectors/item-holds.ts": ["test/e2e/connector-holds.test.ts"],
- "src/core/connectors/item-holds-store.ts": ["test/e2e/connector-holds.test.ts"],
- "src/core/connectors/connector-hold-session.ts": ["test/e2e/connector-holds.test.ts"],
- "src/core/connectors/connector-text.ts": ["test/e2e/connector-holds.test.ts"],
- "src/commands/sources-retry-held.ts": ["test/e2e/connector-holds.test.ts"],
- "src/core/repair/connector-fences.ts": ["test/e2e/connector-holds.test.ts"],
- // Fix wave 5 (#5770): stale-atoms repair and its #5777 cross-lane journey.
- "src/core/repair/stale-atoms.ts": ["test/e2e/repair-stale-atoms-postgres.test.ts", "test/e2e/journey-atoms-sync-race-postgres.test.ts", "test/e2e/managed-extract-atoms.test.ts", "test/e2e/fix-wave-5-integration.test.ts", "test/e2e/write-attribution-postgres.test.ts"],
- // Fix wave 3 lane A: connector identity, account pin, no-op kernel, pending set and migration 176.
- "src/core/take-proposals.ts": ["test/e2e/takes-propose-accept-managed.test.ts"],
- "src/core/persistence/connector-sync.ts": ["test/e2e/connector-wave3.test.ts", "test/e2e/connector-holds.test.ts"],
- "src/core/persistence/connector-identity.ts": ["test/e2e/connector-wave3.test.ts"],
- "src/core/persistence/connector-state.ts": ["test/e2e/connector-wave3.test.ts", "test/e2e/connector-holds.test.ts", "test/e2e/fix-wave-4-integration.test.ts"],
- "src/core/persistence/connector-account.ts": ["test/e2e/connector-wave3.test.ts"],
- "src/core/persistence/connector-errors.ts": ["test/e2e/connector-wave3.test.ts"],
- "src/core/persistence/connector-status.ts": ["test/e2e/connector-wave3.test.ts"],
- "src/core/persistence/connector-reset.ts": ["test/e2e/connector-wave3.test.ts"],
- "src/core/persistence/connector-checkpoint-migration.ts": ["test/e2e/connector-wave3.test.ts"],
- "src/core/persistence/noop-kernel.ts": ["test/e2e/connector-wave3.test.ts", "test/e2e/fix-wave-4-lane-a.test.ts"],
- "src/core/persistence/import-mutations.ts": ["test/e2e/connector-wave3.test.ts"],
- "src/core/persistence/sync-run.ts": ["test/e2e/connector-wave3.test.ts", "test/e2e/fix-wave-4-lane-a.test.ts"],
- "src/core/persistence/sync-prepare.ts": ["test/e2e/connector-wave3.test.ts", "test/e2e/fix-wave-4-lane-a.test.ts"],
- // Fix wave 4 lane A (#5762): request indexes, checkpoint validation, the repair kind and the doctor checks.
- "src/core/persistence/checkpoint-validation.ts": ["test/e2e/fix-wave-4-lane-a.test.ts", "test/e2e/persistence-request-indexes-postgres.test.ts"],
- "src/core/repair/request-indexes.ts": ["test/e2e/persistence-request-indexes-postgres.test.ts"],
- "src/commands/doctor/checks/persistence-requests.ts": ["test/e2e/persistence-request-indexes-postgres.test.ts"],
- "src/core/schema-migrations/v179-persistence-request-sync-run-indexes.ts": ["test/e2e/persistence-request-indexes-postgres.test.ts"],
- // Security wave ENG-1/ENG-2: credential-safe projection and the existing-brain re-chunk.
- "src/core/credential-projection.ts": ["test/e2e/credential-projection-repair.test.ts"],
- "src/core/page-state/credential-reseal.ts": ["test/e2e/credential-projection-repair.test.ts"],
- "src/core/schema-migrations/v189-pages-credential-projection-pending.ts": ["test/e2e/credential-projection-repair.test.ts"],
- "src/commands/migrations/v0_60_31.ts": ["test/e2e/credential-projection-repair.test.ts"],
- "src/commands/doctor/checks/credential-projection.ts": ["test/e2e/credential-projection-repair.test.ts"],
- "src/core/search/two-pass.ts": ["test/e2e/credential-projection-repair.test.ts"],
- "src/core/persistence/accepted-pending.ts": ["test/e2e/connector-wave3.test.ts"],
- "src/commands/google-attachments.ts": ["test/e2e/google-attachments-postgres.test.ts"],
- "src/core/backup/**": ["test/e2e/backup-coverage-parity.test.ts"],
- "src/commands/backup.ts": ["test/e2e/backup-coverage-parity.test.ts"],
- "src/commands/doctor/checks/backup-coverage.ts": ["test/e2e/backup-coverage-parity.test.ts"],
- "src/commands/doctor/checks/sync-failures.ts": ["test/e2e/managed-sync-failures.test.ts"],
- "src/commands/doctor/checks/writer-version.ts": ["test/e2e/persistence-writer-stamps.test.ts"],
- // E5 executor binding matrix: master's executor path is engine.executeRaw
- // over sql-query.ts's scalar contract (refactor wave 1, EO20).
- "src/core/sql-query.ts": ["test/e2e/executor-binding-matrix.test.ts"],
-};
-
-// Refactor wave 1: src/core/engine-sql/ holds SQL shared by BOTH engines, so a
-// change there re-runs every E2E file either engine's façade or module dir
-// selects (plus the E5 binding matrix, already in those rows).
-E2E_TEST_MAP["src/core/engine-sql/**"] = [
- ...new Set(
- [
- "src/core/postgres-engine.ts",
- "src/core/pglite-engine.ts",
- "src/core/postgres-engine/**",
- "src/core/pglite-engine/**",
- ].flatMap((key) => E2E_TEST_MAP[key] ?? []),
- ),
-];
-
-// Executor-contract E2E files (both backends) claimed by the module they pin.
-const ENGINE_SQL_EXECUTOR_E2E = [
- "test/e2e/engine-sql-prepare-parity.test.ts",
- "test/e2e/engine-sql-capabilities-parity.test.ts",
- "test/e2e/engine-sql-transaction-parity.test.ts",
-];
-E2E_TEST_MAP["src/core/engine-sql/executor.ts"] = ENGINE_SQL_EXECUTOR_E2E;
-E2E_TEST_MAP["src/core/engine-sql/dialect-*.ts"] = ENGINE_SQL_EXECUTOR_E2E;
-E2E_TEST_MAP["src/core/engine-sql/normalize.ts"] = ["test/e2e/engine-sql-normalize-parity.test.ts"];
-E2E_TEST_MAP["src/core/engine-sql/brands.ts"] = ["test/e2e/engine-sql-rls-scope.test.ts"];
-E2E_TEST_MAP["src/core/engine-sql/chunks.ts"] = ["test/e2e/evidence-delivery-leak.test.ts", "test/e2e/evidence-delivery-parity.test.ts", "test/e2e/embedding-tombstones-postgres.test.ts"];
-E2E_TEST_MAP["src/core/engine-sql/links.ts"] = ["test/e2e/links-read-order.test.ts", "test/e2e/attendance-retrieval-postgres.test.ts", "test/e2e/federated-link-reads-postgres.test.ts"];
diff --git a/scripts/select-e2e.ts b/scripts/select-e2e.ts
index 83e14e58d7..16ade5ff38 100644
--- a/scripts/select-e2e.ts
+++ b/scripts/select-e2e.ts
@@ -1,269 +1,99 @@
#!/usr/bin/env bun
// scripts/select-e2e.ts
//
-// Fail-closed diff-based E2E test selector. Reads the working-tree diff vs
-// origin/master plus untracked files, classifies the change set as
-// EMPTY / DOC_ONLY / SRC, and emits one relevant E2E test path per stdout line.
+// E2E selection: a doc-only change runs no E2E; every other change runs the
+// whole corpus. Diff narrowing is retired (GBRA-47 C6): a typical E2E file
+// imports most of src/, so a file-to-test map selected every file on 40 of 40
+// merged pull requests while half of them had to edit it.
//
-// CONTRACT (fail-closed):
-// - When in doubt, run all E2E. The map narrows from "all"; it never widens
-// from "none". An unmapped src/ change emits ALL test/e2e/*.test.ts.
-// - Doc-only diffs emit nothing (the only case where stdout is empty).
-// - Empty diff emits ALL (clean branch shouldn't run nothing).
+// Changed files come from git (the working-tree diff vs origin/master plus
+// untracked files) or, with --changed-files <path|->, from a newline-separated
+// list (CI passes the pull request's file list from the GitHub API).
//
-// Selection algorithm:
-// 1. Read changed files from three git sources, union them:
-// - git diff --name-only origin/master...HEAD (committed)
-// - git diff --name-only HEAD (unstaged + staged)
-// - git ls-files --others --exclude-standard (untracked, NOT .gitignore'd)
-// 2. EMPTY -> emit ALL test/e2e/*.test.ts
-// DOC_ONLY (every path matches doc allowlist) -> emit nothing
-// SRC (at least one path is outside doc allowlist):
-// a. Any escape-hatch path matched -> emit ALL
-// b. Else union map matches; include directly-modified test/e2e/*.test.ts
-// c. Any non-doc path without coverage -> FAIL-CLOSED -> emit ALL
+// EMPTY (no changed files) -> every test/e2e/*.test.ts
+// DOC_ONLY (every path is a doc) -> nothing (the only empty stdout)
+// SRC (anything else) -> every test/e2e/*.test.ts
//
-// On git command failure: print error to stderr and exit 2 so callers see the
-// failure (xargs -r will run nothing AND the human sees the error).
+// scripts/e2e-matrix.ts drops the files a named job owns (E2E_EXCLUSIONS)
+// before partitioning. On git failure the selector exits 2.
//
// Usage:
-// bun run scripts/select-e2e.ts
-// bun run scripts/select-e2e.ts | xargs -r bash scripts/run-e2e.sh
+// bun run scripts/select-e2e.ts [--changed-files <path|->] [--classify-only]
import { spawnSync } from "node:child_process";
-import { readdirSync, existsSync } from "node:fs";
+import { existsSync, readdirSync, readFileSync } from "node:fs";
import { join } from "node:path";
-import { E2E_TEST_MAP } from "./e2e-test-map.ts";
-import { PERSISTENCE_VALIDATION_OWNED, exclusionNotice } from "./e2e-matrix.ts";
+export const NARROWING_RETIRED = "E2E narrowing is retired; running the full E2E corpus (see docs/TESTING.md#e2e-selection)";
-// Doc allowlist (inclusive). A path counts as doc-only ONLY if it matches one
-// of these patterns. Unrecognized paths fall through to SRC, never silently
-// doc-only. skills/ is intentionally NOT here — skills are product input.
-const DOC_ROOT_FILES = new Set([
- "README.md",
- "CLAUDE.md",
- "AGENTS.md",
- "CHANGELOG.md",
- "TODOS.md",
- "LICENSE",
- "VERSION",
-]);
+// A path counts as doc-only ONLY if it matches one of these patterns.
+// Unrecognized paths fall through to SRC. skills/ is product input, not docs.
+const DOC_ROOT_FILES = new Set(["LICENSE", "VERSION"]);
function isDocPath(p: string): boolean {
if (DOC_ROOT_FILES.has(p)) return true;
- // Any *.md at repo root.
if (!p.includes("/") && p.endsWith(".md")) return true;
- // Anything under docs/.
- if (p.startsWith("docs/")) return true;
- return false;
-}
-
-// Escape-hatch triggers. Any match -> emit ALL.
-const ESCAPE_HATCH_FILES = new Set([
- "src/schema.sql",
- "src/core/migrate.ts",
- "src/core/db.ts",
- "src/core/engine-factory.ts",
- "src/core/operations.ts",
- "package.json",
- "bun.lock",
- "Dockerfile.ci",
- "docker-compose.ci.yml",
- "scripts/ci-local.sh",
- "scripts/run-e2e.sh",
- "scripts/select-e2e.ts",
- "scripts/e2e-test-map.ts",
- "test/e2e/helpers.ts",
-]);
-
-const ESCAPE_HATCH_PREFIXES = [
- "src/commands/migrations/",
- // Schema migrations split out of src/core/migrate.ts (refactor wave 1)
- // keep migrate.ts's escape-hatch blast radius: every E2E file boots them.
- "src/core/schema-migrations/",
- // Operation domain modules peeled out of operations.ts (an escape-hatch
- // file) carry the same blast radius as the contract itself.
- "src/core/ops/",
- "test/e2e/fixtures/",
- "skills/",
- ".github/workflows/",
-];
-
-function isEscapeHatch(p: string): boolean {
- if (ESCAPE_HATCH_FILES.has(p)) return true;
- for (const prefix of ESCAPE_HATCH_PREFIXES) {
- if (p.startsWith(prefix)) return true;
- }
- return false;
-}
-
-// Minimal glob matcher: supports ** (any segments) and * (one segment, no /).
-// Throws on unsupported syntax so map mistakes surface loudly.
-export function matchGlob(glob: string, path: string): boolean {
- if (glob.includes("?") || glob.includes("[") || glob.includes("{")) {
- throw new Error(
- `select-e2e: unsupported glob syntax in "${glob}" (only ** and * are supported)`
- );
- }
- // Build a regex: ** -> .*, * -> [^/]*, escape other regex meta-chars.
- let regex = "";
- let i = 0;
- while (i < glob.length) {
- const c = glob[i];
- if (c === "*" && glob[i + 1] === "*") {
- regex += ".*";
- i += 2;
- } else if (c === "*") {
- regex += "[^/]*";
- i += 1;
- } else if (/[.+^${}()|\\]/.test(c)) {
- regex += "\\" + c;
- i += 1;
- } else {
- regex += c;
- i += 1;
- }
- }
- return new RegExp("^" + regex + "$").test(path);
-}
-
-function listAllE2ETests(repoRoot: string): string[] {
- const dir = join(repoRoot, "test/e2e");
- if (!existsSync(dir)) return [];
- return readdirSync(dir)
- .filter((f) => f.endsWith(".test.ts"))
- .map((f) => `test/e2e/${f}`)
- .sort();
-}
-
-// Pure function — exposed for unit tests. Decides what to emit given the
-// inputs, without touching git or filesystem (callers pass arrays in).
-export interface SelectInputs {
- changedFiles: string[]; // union of three git sources
- allE2ETests: string[]; // glob result of test/e2e/*.test.ts
- map: Record<string, string[]>; // E2E_TEST_MAP
+ return p.startsWith("docs/");
}
export type Classification = "EMPTY" | "DOC_ONLY" | "SRC";
export function classify(changedFiles: string[]): Classification {
if (changedFiles.length === 0) return "EMPTY";
- for (const f of changedFiles) {
- if (!isDocPath(f)) return "SRC";
- }
- return "DOC_ONLY";
+ return changedFiles.every(isDocPath) ? "DOC_ONLY" : "SRC";
}
-export function selectTests(inputs: SelectInputs): string[] {
- const { changedFiles, allE2ETests, map } = inputs;
- const cls = classify(changedFiles);
- const allSorted = allE2ETests.slice().sort();
-
- if (cls === "EMPTY") return allSorted;
- if (cls === "DOC_ONLY") return [];
-
- // SRC case.
- // 3a. Any escape-hatch -> ALL.
- for (const f of changedFiles) {
- if (isEscapeHatch(f)) return allSorted;
- }
-
- // 3b. Union map matches; include directly-modified test files.
- const result = new Set<string>();
- for (const f of changedFiles) {
- if (isDocPath(f)) continue;
- // Direct test file modification: include it.
- if (f.startsWith("test/e2e/") && f.endsWith(".test.ts")) {
- result.add(f);
- continue;
- }
- let covered = false;
- for (const [glob, tests] of Object.entries(map)) {
- if (matchGlob(glob, f)) {
- if (tests.length > 0) covered = true;
- for (const t of tests) result.add(t);
- }
- }
- // A covered sibling must not hide an unknown change's blast radius.
- // Check coverage per changed path, not just whether the union is nonempty.
- if (!covered) return allSorted;
- }
-
- // Defensive fallback for an empty map/selection.
- if (result.size === 0) return allSorted;
-
- // Sort for determinism (helps tests + readability).
- return Array.from(result).sort();
+export function selectTests(changedFiles: string[], allE2ETests: string[]): string[] {
+ return classify(changedFiles) === "DOC_ONLY" ? [] : allE2ETests.slice().sort();
}
-export function persistenceOwnedNotices(changedFiles: string[], map: Record<string, string[]>): string[] {
- const owned = new Set<string>();
- for (const f of changedFiles) {
- if (PERSISTENCE_VALIDATION_OWNED.has(f)) owned.add(f);
- for (const [glob, tests] of Object.entries(map)) {
- if (!matchGlob(glob, f)) continue;
- for (const t of tests) if (PERSISTENCE_VALIDATION_OWNED.has(t)) owned.add(t);
- }
- }
- return Array.from(owned).sort().map(exclusionNotice);
+function listAllE2ETests(repoRoot: string): string[] {
+ const dir = join(repoRoot, "test/e2e");
+ if (!existsSync(dir)) return [];
+ return readdirSync(dir).filter((f) => f.endsWith(".test.ts")).map((f) => `test/e2e/${f}`).sort();
}
function runGit(args: string[], cwd: string): string {
const result = spawnSync("git", args, { cwd, encoding: "utf8" });
if (result.status !== 0) {
- const stderr = (result.stderr || "").trim();
- process.stderr.write(
- `select-e2e: git ${args.join(" ")} failed: ${stderr}\n`
- );
+ process.stderr.write(`select-e2e: git ${args.join(" ")} failed: ${(result.stderr || "").trim()}\n`);
process.exit(2);
}
return result.stdout || "";
}
-function readChangedFiles(repoRoot: string): string[] {
- const sources = [
- runGit(["diff", "--name-only", "origin/master...HEAD"], repoRoot),
- runGit(["diff", "--name-only", "HEAD"], repoRoot),
- runGit(["ls-files", "--others", "--exclude-standard"], repoRoot),
- ];
+function splitLines(text: string): string[] {
+ return text.split("\n").map((line) => line.trim()).filter(Boolean);
+}
+
+function readChangedFiles(repoRoot: string, listPath: string | undefined): string[] {
+ if (listPath !== undefined) return [...new Set(splitLines(readFileSync(listPath === "-" ? 0 : listPath, "utf8")))].sort();
const set = new Set<string>();
- for (const out of sources) {
- for (const line of out.split("\n")) {
- const trimmed = line.trim();
- if (trimmed.length > 0) set.add(trimmed);
- }
+ for (const args of [["diff", "--name-only", "origin/master...HEAD"], ["diff", "--name-only", "HEAD"], ["ls-files", "--others", "--exclude-standard"]]) {
+ for (const line of splitLines(runGit(args, repoRoot))) set.add(line);
}
- return Array.from(set).sort();
+ return [...set].sort();
}
-// Entrypoint. Skipped under test (Bun.main check).
if (import.meta.main) {
- const repoRoot = spawnSync("git", ["rev-parse", "--show-toplevel"], {
- encoding: "utf8",
- }).stdout?.trim();
+ const repoRoot = spawnSync("git", ["rev-parse", "--show-toplevel"], { encoding: "utf8" }).stdout?.trim();
if (!repoRoot) {
process.stderr.write("select-e2e: not a git repository\n");
process.exit(2);
}
-
- const changedFiles = readChangedFiles(repoRoot);
-
- // --classify-only: print EMPTY|DOC_ONLY|SRC + exit. Used by ci-local.sh's
- // Tier 2 fast-path so doc-only diffs skip the unit phase entirely.
+ const at = process.argv.indexOf("--changed-files");
+ if (at !== -1 && !process.argv[at + 1]) {
+ process.stderr.write("select-e2e: --changed-files needs a path or -\n");
+ process.exit(2);
+ }
+ const changedFiles = readChangedFiles(repoRoot, at === -1 ? undefined : process.argv[at + 1]);
+ const classification = classify(changedFiles);
if (process.argv.includes("--classify-only")) {
- process.stdout.write(classify(changedFiles) + "\n");
+ process.stdout.write(classification + "\n");
process.exit(0);
}
-
- const allE2ETests = listAllE2ETests(repoRoot);
- const tests = selectTests({
- changedFiles,
- allE2ETests,
- map: E2E_TEST_MAP,
- });
-
- for (const notice of persistenceOwnedNotices(changedFiles, E2E_TEST_MAP)) process.stderr.write(notice + "\n");
+ if (classification !== "DOC_ONLY") process.stderr.write(NARROWING_RETIRED + "\n");
+ const tests = selectTests(changedFiles, listAllE2ETests(repoRoot));
process.stdout.write(tests.join("\n"));
if (tests.length > 0) process.stdout.write("\n");
}
diff --git a/scripts/structural-suites.tsv b/scripts/structural-suites.tsv
index 974833d816..ff07822b78 100644
--- a/scripts/structural-suites.tsv
+++ b/scripts/structural-suites.tsv
@@ -257,21 +257,21 @@ test/scripts/ci-executed-counts.test.ts CLI 2 readFileSync
test/scripts/ci-gates.test.ts CI execution evidence 6 readFileSync
test/scripts/ci-gates.test.ts test:full exit status 0 readFileSync
test/scripts/ci-local-rendering.test.ts ci-local command rendering 1 readFileSync
-test/scripts/ci-local-rendering.test.ts ci-local execution coverage 3 readFileSync
+test/scripts/ci-local-rendering.test.ts ci-local execution coverage 5 readFileSync
test/scripts/ci-local-rendering.test.ts local test configuration through run-e2e 2 readFileSync
test/scripts/ci-local-rendering.test.ts required PgBouncer execution through run-e2e 1 readFileSync
test/scripts/ci-manifest-diff.test.ts test.yml dependency-audit scope 2 readFileSync
test/scripts/ci-pr-scope.test.ts pull-request CI scope 9 readFileSync
-test/scripts/ci-runner-routing.test.ts CI runner routing 6 readFileSync
+test/scripts/ci-runner-routing.test.ts CI runner routing 7 readFileSync
test/scripts/classify-tests.test.ts classify-tests detectors 23 bun-file,doctor-source-helper,exec-scan,readFileSync,source-surface-helper
test/scripts/coverage-diff-gate.test.ts exemptions 3 readFileSync
test/scripts/data-safety-native-workflow.test.ts data-safety native CI coverage 12 readFileSync
test/scripts/e2e-backend-matrix.test.ts scripts/e2e-backend-matrix.txt 3 readFileSync
test/scripts/e2e-live-key-only.test.ts shared live-key E2E exclusion list 4 readFileSync
+test/scripts/e2e-matrix.test.ts frozen E2E matrix 9 readFileSync
test/scripts/e2e-runner.test.ts second 5 readFileSync
test/scripts/e2e-runner.test.ts sequential E2E runner (GITHUB_ACTIONS=${githubActions}) 9 readFileSync
-test/scripts/e2e-wiring.test.ts e2e file claim ratchet 5 readFileSync
-test/scripts/e2e-wiring.test.ts selected-e2e job wiring 6 readFileSync
+test/scripts/e2e-wiring.test.ts (file-level) 12 readFileSync
test/scripts/heavy-door-workflow.test.ts heavy door supply chain and coverage gates 8 readFileSync
test/scripts/native-lock-prebuilds.test.ts native lock distribution integrity 2 readFileSync
test/scripts/nightly-e2e.test.ts nightly E2E scheduling 4 readFileSync
diff --git a/test/fixtures/e2e-unmapped-baseline.txt b/test/fixtures/e2e-unmapped-baseline.txt
deleted file mode 100644
index 5921d1ed1b..0000000000
--- a/test/fixtures/e2e-unmapped-baseline.txt
+++ /dev/null
@@ -1,129 +0,0 @@
-# e2e-unmapped-baseline.txt — shrink-only ratchet (test-gap plan G1).
-# Files listed here get PR-time e2e signal ONLY via select-e2e fail-closed
-# ALL-selections and the scheduled nightly full glob. A NEW e2e file must
-# either be mapped in scripts/e2e-test-map.ts (preferred) or consciously
-# added here in a reviewer-visible diff. Removing lines (by mapping the
-# file) is always safe. Enforced by test/scripts/e2e-wiring.test.ts.
-test/e2e/anomalies-pglite.test.ts
-test/e2e/auth-takes-holders-pglite.test.ts
-test/e2e/autopilot-cooldown-parity.test.ts
-test/e2e/autopilot-fanout-postgres.test.ts
-test/e2e/bootstrap-attach.serial.test.ts
-test/e2e/bootstrap-compiled-binary.serial.test.ts
-test/e2e/bootstrap-degraded-modes.serial.test.ts
-test/e2e/bootstrap-keyed-postgres.serial.test.ts
-test/e2e/bootstrap-lifecycle.serial.test.ts
-test/e2e/bootstrap-magic-moment.serial.test.ts
-test/e2e/bootstrap-persistence.serial.test.ts
-test/e2e/bootstrap-real-claude.serial.test.ts
-test/e2e/brainstorm-resume.test.ts
-test/e2e/cache-gate-pglite.test.ts
-test/e2e/capture-generation-regression.test.ts
-test/e2e/chronicle-last-seen-postgres.test.ts
-test/e2e/chunker-takes-strip.test.ts
-test/e2e/cjk-roundtrip.test.ts
-test/e2e/claude-plugin-install-real.serial.test.ts
-test/e2e/cli-source-scoping-pglite.test.ts
-test/e2e/code-edges-jsonb-postgres.test.ts
-test/e2e/code-intel-mcp-ops-pglite.test.ts
-test/e2e/codex-plugin-install-real.serial.test.ts
-test/e2e/compile-context-pglite.test.ts
-test/e2e/concurrent-embed-race.test.ts
-test/e2e/contextual-retrieval-pglite.test.ts
-test/e2e/conversation-parser-pglite.test.ts
-test/e2e/cross-modal-eval.test.ts
-test/e2e/cycle-consolidate-postgres.test.ts
-test/e2e/cycle-recompute-emotional-weight-pglite.test.ts
-test/e2e/db-guard.test.ts
-test/e2e/doctor-silent-death-parity.test.ts
-test/e2e/dream-allow-list-pglite.test.ts
-test/e2e/dream-patterns-pglite.test.ts
-test/e2e/dream-synthesize-concurrency-postgres.test.ts
-test/e2e/dream-triage-postgres.test.ts
-test/e2e/embed-stale-pagination.test.ts
-test/e2e/embedding-column-pglite.test.ts
-test/e2e/embedding-column-postgres.test.ts
-test/e2e/engine-parity-salience.test.ts
-test/e2e/enrich-pglite.test.ts
-test/e2e/eval-capture.test.ts
-test/e2e/eval-contradictions-postgres.test.ts
-test/e2e/eval-loop.test.ts
-test/e2e/eval-replay-column.test.ts
-test/e2e/eval-takes-quality.test.ts
-test/e2e/extract-atoms-discovery-sql.test.ts
-test/e2e/extraction-review-postgres.test.ts
-test/e2e/facts-cross-source-isolation.test.ts
-test/e2e/facts-forget.test.ts
-test/e2e/facts-notability-roundtrip.test.ts
-test/e2e/facts-recall-event-time-postgres.test.ts
-test/e2e/facts-recall-render.test.ts
-test/e2e/facts-separation-postgres.test.ts
-test/e2e/frontmatter-migration.test.ts
-test/e2e/global-basename-pglite.test.ts
-test/e2e/graph-signals-engine.test.ts
-test/e2e/graph-signals-eval.test.ts
-test/e2e/import-credential-preflight.test.ts
-test/e2e/install-real-grok.serial.test.ts
-test/e2e/install-real-hermes.serial.test.ts
-test/e2e/install-real-opencode.serial.test.ts
-test/e2e/jobs-watch-readsnapshot.test.ts
-test/e2e/jsonb-batch-poison-postgres.test.ts
-test/e2e/list-all-sources-postgres.test.ts
-test/e2e/list-pages-regression.test.ts
-test/e2e/mcp-budget-reservation-postgres.test.ts
-test/e2e/migrate-engine-sources-postgres.test.ts
-test/e2e/migration-drop-invalid-concurrent-index.test.ts
-test/e2e/migration-v35-auto-rls.test.ts
-test/e2e/migration-v35-event-trigger.test.ts
-test/e2e/migration-v47-notability.test.ts
-test/e2e/migration-v50-ingest-log-source-id.test.ts
-test/e2e/minions-prefix-strip-smoke.test.ts
-test/e2e/multi-source-emotional-weight-pglite.test.ts
-test/e2e/multimodal-postgres.test.ts
-test/e2e/non-tty-output.serial.test.ts
-test/e2e/onboard-full-flow.test.ts
-test/e2e/openclaw-reference-compat.test.ts
-test/e2e/openrouter-anthropic-subagent-replay.live.test.ts
-test/e2e/orphan-reduction.test.ts
-test/e2e/pglite-cli-exit.serial.test.ts
-test/e2e/phantom-redirect.test.ts
-test/e2e/purge-deleted-dryrun-postgres.test.ts
-test/e2e/quarantine-search-exclusion.test.ts
-test/e2e/restore-source-config-jsonb-postgres.test.ts
-test/e2e/salience-llm-routing.test.ts
-test/e2e/salience-pglite.test.ts
-test/e2e/schema-cathedral.test.ts
-test/e2e/self-upgrade-binary-swap.test.ts
-test/e2e/self-upgrade-marker.test.ts
-test/e2e/serve-http-takes-holders.test.ts
-test/e2e/skill-brain-first.test.ts
-test/e2e/skillpack-third-party.test.ts
-test/e2e/source-isolation-pglite.test.ts
-test/e2e/source-routing.test.ts
-test/e2e/sources-remote-mcp.test.ts
-test/e2e/status-pglite.test.ts
-test/e2e/storage-tiering.test.ts
-test/e2e/subagent-gateway-resume-reconciliation.test.ts
-test/e2e/symbol-resolver-pglite.test.ts
-test/e2e/sync-cjk-git.test.ts
-test/e2e/sync-credential-preflight.test.ts
-test/e2e/sync-lock-recovery.test.ts
-test/e2e/sync-parallel.test.ts
-test/e2e/sync-status-pglite.test.ts
-test/e2e/system-of-record-invariant.test.ts
-test/e2e/takes-postgres.test.ts
-test/e2e/takes-scorecard-parity.test.ts
-test/e2e/takes-weight-rounding-postgres.test.ts
-test/e2e/thin-client.test.ts
-test/e2e/think-source-isolation-pglite.test.ts
-test/e2e/think-trajectory-pglite.test.ts
-test/e2e/transcripts-writeback-fidelity.test.ts
-test/e2e/type-unification-full-flow.test.ts
-test/e2e/upsert-chunks-registry-column.test.ts
-test/e2e/v0_29-mcp-dispatch-pglite.test.ts
-test/e2e/vector-ef-search-postgres.test.ts
-test/e2e/volunteer-context-postgres.test.ts
-test/e2e/whoknows.test.ts
-test/e2e/worker-lock-renewal-starvation.test.ts
-test/e2e/workspace-generic-compat.test.ts
-test/e2e/zombie-reaping.test.ts
diff --git a/test/scripts/ci-gates.test.ts b/test/scripts/ci-gates.test.ts
index 349e1f9b9c..c8c4a7a86a 100644
--- a/test/scripts/ci-gates.test.ts
+++ b/test/scripts/ci-gates.test.ts
@@ -52,7 +52,7 @@ describe('CI execution evidence', () => {
test('unit aggregate rejects failed, cancelled or skipped required jobs', () => {
expect(unit.jobs['test-status'].if).toBe("${{ always() && (github.event_name != 'workflow_dispatch' || inputs.native_only != true) }}");
expect(unit.jobs['test-status'].needs).toEqual([
- 'gitleaks', 'security-regressions', 'dependency-audit', 'verify', 'serial-tests', 'slow-eval-longmemeval',
+ 'gitleaks', 'security-regressions', 'dependency-audit', 'verify', 'serial-tests',
'slow-entity-resolve-perf', 'slow-brainbench-e2e', 'brainbench', 'test', 'native-locks', 'persistence-validation',
'admin-browser', 'shared-skills-compatibility',
]);
@@ -68,7 +68,7 @@ describe('CI execution evidence', () => {
expect(e2e.jobs['e2e-status'].if).toBe('always()');
const needs = e2e.jobs['e2e-status'].needs as string[];
const nightly = ['coverage-full-unit', 'coverage-full-serial', 'coverage-full-slow', 'coverage-full-e2e'];
- expect(needs).toEqual(['jsonb-parity', 'tier1', 'tier2', 'prepare-e2e', 'selected-e2e', ...nightly]);
+ expect(needs).toEqual(['jsonb-parity', 'tier1', 'tier1-backend-matrix', 'tier2', 'prepare-e2e', 'selected-e2e', ...nightly]);
for (const event of ['pull_request', 'push', 'workflow_dispatch']) {
expect(aggregate(e2e, 'e2e-status', event, Object.fromEntries(nightly.map(job => [job, 'skipped'])))).toBe(0);
}
diff --git a/test/scripts/ci-local-rendering.test.ts b/test/scripts/ci-local-rendering.test.ts
index 64466ec65e..715bf05eb0 100644
--- a/test/scripts/ci-local-rendering.test.ts
+++ b/test/scripts/ci-local-rendering.test.ts
@@ -108,7 +108,6 @@ function runPhases(noShard: boolean, diff: boolean, failStage = '') {
for (const name of ['git', 'python3', 'ps', 'psql', 'apt-get']) put(`bin/${name}`, 'exit 0');
put('bin/bun', `
case "$*" in
- "run scripts/select-e2e.ts") printf '%s\\n' test/e2e/one.test.ts test/e2e/two.test.ts; exit 0 ;;
"run verify") stage=verify ;;
"run test:serial") stage=serial ;;
"run test:slow") stage=slow ;;
@@ -178,7 +177,8 @@ describe('ci-local execution coverage', () => {
const targets = result.trace.filter(line => line.startsWith('target:'));
expect(targets).toHaveLength(noShard ? 3 : 12);
for (const target of targets) expect(() => assertSafeE2eDatabaseUrl(target.slice(7), {})).not.toThrow();
- if (diff) expect(e2e.every(line => line.endsWith('test/e2e/one.test.ts test/e2e/two.test.ts'))).toBe(true);
+ // --diff no longer narrows: every shard runs run-e2e.sh's full discovery.
+ expect(e2e.every(line => line.endsWith(':'))).toBe(true);
if (!noShard) {
expect(result.stdout).toContain('Complete shard logs saved to .context/ci-local-shards/');
for (const log of result.archivedLogs) {
@@ -226,18 +226,56 @@ describe('ci-local execution coverage', () => {
// the real detector/configuration canary runs separately in CI.
writeFileSync(join(home, 'scripts/test-gitleaks-config.sh'), 'exit 0\n');
writeFileSync(join(home, 'scripts/scan-worktree-secrets.sh'), 'gitleaks dir . --redact --no-banner\n');
+ writeFileSync(join(home, 'scripts/ci-doc-checks.sh'), 'printf "%s\\n" docs >> "$SCAN_LOG"\n');
const result = spawnSync('bash', ['-c', script, join(home, 'scripts/ci-local.sh'), '--diff'], {
encoding: 'utf8', timeout: 5_000,
env: { ...process.env, PATH: `${bin}:${process.env.PATH}`, SCAN_MODE: gitleaks, SCAN_LOG: log },
});
expect(result.status, result.stderr).toBe(gitleaks === 'success' ? 0 : 1);
const scans = existsSync(log) ? readFileSync(log, 'utf8') : '';
- expect(scans).toBe(gitleaks === 'success' ? 'dir\ngit\n' : gitleaks === 'failure' ? 'dir\n' : '');
+ expect(scans).toBe(gitleaks === 'success' ? 'dir\ngit\ndocs\n' : gitleaks === 'failure' ? 'dir\n' : '');
} finally {
rmSync(home, { recursive: true, force: true });
}
});
}
+
+ function diffPreflight(classification: string, docChecks = 'exit 0') {
+ const home = mkdtempSync(join(tmpdir(), 'gbrain-ci-diff-'));
+ try {
+ const bin = join(home, 'bin');
+ mkdirSync(bin);
+ mkdirSync(join(home, 'scripts'));
+ writeFileSync(join(bin, 'bun'), `#!/bin/sh\necho ${classification}\n`, { mode: 0o755 });
+ writeFileSync(join(bin, 'docker'), '#!/bin/sh\nexit 0\n', { mode: 0o755 });
+ writeFileSync(join(bin, 'gitleaks'), '#!/bin/sh\nexit 0\n', { mode: 0o755 });
+ writeFileSync(join(home, 'scripts/test-gitleaks-config.sh'), 'exit 0\n');
+ writeFileSync(join(home, 'scripts/scan-worktree-secrets.sh'), 'exit 0\n');
+ writeFileSync(join(home, 'scripts/ci-doc-checks.sh'), `${docChecks}\n`);
+ const end = source.indexOf('# Pre-flight: postgres host ports');
+ return spawnSync('bash', ['-c', `${source.slice(0, end)}\necho FULL_GATE_CONTINUES`, join(home, 'scripts/ci-local.sh'), '--diff'], {
+ encoding: 'utf8', timeout: 5_000, env: { ...process.env, PATH: `${bin}:${process.env.PATH}` },
+ });
+ } finally {
+ rmSync(home, { recursive: true, force: true });
+ }
+ }
+
+ test('doc-only diff fails when a doc check fails (e.g. llms.txt not rebuilt)', () => {
+ const result = diffPreflight('DOC_ONLY', 'echo "Fix: bun run build:llms" >&2; exit 1');
+ expect(result.status).toBe(1);
+ expect(result.stderr).toContain('Fix: bun run build:llms');
+ expect(result.stdout).not.toContain('FULL_GATE_CONTINUES');
+ });
+
+ for (const classification of ['SRC', 'EMPTY', 'ERR']) {
+ test(`a ${classification} diff says narrowing is retired and runs the full gate`, () => {
+ const result = diffPreflight(classification);
+ expect(result.status, result.stderr).toBe(0);
+ expect(result.stdout).toContain('E2E narrowing is retired; running the full E2E corpus (see docs/TESTING.md#e2e-selection)');
+ expect(result.stdout).toContain('FULL_GATE_CONTINUES');
+ });
+ }
});
describe('required PgBouncer execution through run-e2e', () => {
diff --git a/test/scripts/ci-runner-routing.test.ts b/test/scripts/ci-runner-routing.test.ts
index b4460c341e..2fc65b1ec7 100644
--- a/test/scripts/ci-runner-routing.test.ts
+++ b/test/scripts/ci-runner-routing.test.ts
@@ -36,15 +36,14 @@ describe('CI runner routing', () => {
test('single-process lanes and soaks use 4 vCPUs, pooled lanes 8, and the label-gated heavy suite keeps 30', () => {
// Measured: a unit shard is one bun process (1.1-1.5 busy cores on average)
- // and took the same time on 4, 8 and 16 vCPUs; the serial pool and verify
- // match 16 vCPUs at 8.
- for (const name of ['test', 'slow-eval-longmemeval', 'slow-brainbench-e2e', 'brainbench', 'slow-entity-resolve-perf', 'admin-browser', 'shared-skills-compatibility']) {
+ // and took the same time on 4, 8 and 16 vCPUs; verify matches 16 vCPUs at 8.
+ for (const name of ['slow-brainbench-e2e', 'brainbench', 'slow-entity-resolve-perf', 'admin-browser', 'shared-skills-compatibility']) {
expect(load('test.yml').jobs[name]['runs-on'], name).toBe(single);
}
- for (const name of ['verify', 'serial-tests']) expect(load('test.yml').jobs[name]['runs-on'], name).toBe(pooled);
+ expect(load('test.yml').jobs.verify['runs-on']).toBe(pooled);
// E2E files run one bun process at a time against the job's Postgres:
// full-corpus shard 1 took 668s on 4 vCPUs, 704s on 8 and 741s on 16.
- for (const name of ['jsonb-parity', 'selected-e2e', 'tier2', 'coverage-full-unit', 'coverage-full-slow', 'coverage-full-e2e']) {
+ for (const name of ['jsonb-parity', 'tier2', 'tier1-backend-matrix', 'coverage-full-unit', 'coverage-full-slow', 'coverage-full-e2e']) {
expect(load('e2e.yml').jobs[name]['runs-on'], name).toBe(single);
}
expect(load('e2e.yml').jobs.tier1['runs-on']).toBe(normal);
@@ -56,6 +55,14 @@ describe('CI runner routing', () => {
expect(load('heavy-tests.yml').jobs.heavy['runs-on']).toBe(heavy);
});
+ test('PR-critical single-process shards run on 2 vCPUs and the serial pool on 4 (C1, C4, C8)', () => {
+ // A unit shard took 212s on 2 cores vs 204s on 4; a 25-file E2E sample 442s
+ // vs 455s. The serial shards finish far off the critical path on 4.
+ expect(load('test.yml').jobs.test['runs-on']).toBe(small);
+ expect(load('e2e.yml').jobs['selected-e2e']['runs-on']).toBe(small);
+ expect(load('test.yml').jobs['serial-tests']['runs-on']).toBe(single);
+ });
+
test('security matrix labels and native platform coverage retain their identities', () => {
const security = load('test.yml').jobs['security-regressions'];
expect(security.strategy!.matrix.os).toEqual(['ubuntu-latest', 'macos-26', 'windows-latest']);
diff --git a/test/scripts/e2e-backend-matrix.test.ts b/test/scripts/e2e-backend-matrix.test.ts
index a7dec4eff0..a8a1c6b075 100644
--- a/test/scripts/e2e-backend-matrix.test.ts
+++ b/test/scripts/e2e-backend-matrix.test.ts
@@ -53,9 +53,11 @@ describe('scripts/e2e-backend-matrix.txt', () => {
expect(text, file).toMatch(/GBRAIN_PGBOUNCER_E2E_URL=\S+\?prepare=false/);
expect(text, file).toContain('GBRAIN_CI_REQUIRE_PGBOUNCER');
}
- // ci:local names a database behind its single pooler; run-e2e.sh pins prepare=false.
+ // ci:local names a database behind its single pooler in both E2E
+ // invocations (sharded and --no-shard); run-e2e.sh pins prepare=false.
const local = readFileSync(join(REPO, 'scripts/ci-local.sh'), 'utf8');
- expect(local.match(/GBRAIN_PGBOUNCER_E2E_DB=\S+/g)?.length).toBe(4);
+ expect(local.match(/GBRAIN_PGBOUNCER_E2E_DB=\S+/g)?.length).toBe(2);
+ expect(local.match(/bash scripts\/run-e2e\.sh/g)?.length).toBe(2);
expect(local).toContain('GBRAIN_CI_REQUIRE_PGBOUNCER');
});
});
diff --git a/test/scripts/e2e-matrix.test.ts b/test/scripts/e2e-matrix.test.ts
index bbdd699f5a..783efc7077 100644
--- a/test/scripts/e2e-matrix.test.ts
+++ b/test/scripts/e2e-matrix.test.ts
@@ -3,10 +3,10 @@ import { existsSync, mkdtempSync, mkdirSync, readFileSync, writeFileSync, rmSync
import { tmpdir } from 'node:os';
import { join } from 'node:path';
import { spawnSync } from 'node:child_process';
-import { E2E_EXCLUSIONS, prepareMatrix, validateRow } from '../../scripts/e2e-matrix.ts';
+import { BACKEND_MATRIX_OWNED, E2E_EXCLUSIONS, MAX_E2E_WORKERS, prepareMatrix, validateRow } from '../../scripts/e2e-matrix.ts';
const repo = join(import.meta.dir, '../..');
-const paths = ['a', 'b', 'c', 'd', 'e'].map(n => `test/e2e/${n}.test.ts`);
+const paths = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i'].map(n => `test/e2e/${n}.test.ts`);
const weights = new Map(paths.map((f, i) => [f, 100 - i * 10]));
function fixture(fn: (root: string) => void) {
const root = mkdtempSync(join(tmpdir(), 'gbrain-e2e-matrix-'));
@@ -23,9 +23,10 @@ function worker(root: string, row: unknown) {
});
}
describe('frozen E2E matrix', () => {
- test('partitions the exact selection once, with deterministic weights and at most four workers', () => {
+ test('partitions the exact selection once, with deterministic weights and at most eight workers', () => {
const matrix = prepareMatrix(paths, weights);
- expect(matrix.include).toHaveLength(4);
+ expect(MAX_E2E_WORKERS).toBe(8);
+ expect(matrix.include).toHaveLength(8);
expect(matrix.include.flatMap(r => r.files).sort()).toEqual(paths);
expect(prepareMatrix(paths, weights)).toEqual(matrix);
expect(prepareMatrix(paths.slice(0, 2), weights).include).toHaveLength(2);
@@ -47,13 +48,27 @@ describe('frozen E2E matrix', () => {
'excluded: test/e2e/reconcile-crash-unactivated.test.ts (owned by persistence-validation.yml)',
]);
});
+ test('drops every backend-matrix file and names the Tier 1 backend matrix as its owner', () => {
+ const rows = readFileSync(join(repo, 'scripts/e2e-backend-matrix.txt'), 'utf8').split('\n')
+ .filter(row => row && !row.startsWith('#') && !row.startsWith('!')).map(row => row.split('\t')[0]);
+ const e2eRows = rows.filter(row => row.startsWith('test/e2e/'));
+ expect(e2eRows.length).toBeGreaterThan(30);
+ expect([...BACKEND_MATRIX_OWNED].sort()).toEqual([...e2eRows].sort());
+ const notices: string[] = [];
+ const spy = spyOn(console, 'error').mockImplementation((line: string) => { notices.push(line); });
+ try {
+ expect(prepareMatrix([...e2eRows, paths[0]], weights).include).toEqual([{ shard: 1, files: [paths[0]], empty: false }]);
+ } finally { spy.mockRestore(); }
+ expect(notices).toContain('excluded: test/e2e/executor-binding-matrix.test.ts (owned by the Tier 1 backend matrix, scripts/e2e-backend-matrix.txt)');
+ expect(notices).toHaveLength(e2eRows.length);
+ });
test('refuses invalid selections and duplicate paths', () => {
for (const files of [[paths[0], paths[0]], ['../outside.test.ts'], ['test/e2e/../escape.test.ts'], ['test/e2e/$(touch marker).test.ts']]) expect(() => prepareMatrix(files, weights)).toThrow();
});
test('empty sentinel launches no runner; missing/malformed input fails instead of selecting all', () => fixture(root => {
writeFileSync(join(root, 'scripts/run-e2e.sh'), 'exit 99\n');
expect(worker(root, { shard: 1, files: [], empty: true }).status).toBe(0);
- for (const row of [null, {}, { shard: 1, files: [], empty: false }, { shard: 2, files: [], empty: true }, { shard: 5, files: [paths[0]], empty: false }]) expect(worker(root, row).status).not.toBe(0);
+ for (const row of [null, {}, { shard: 1, files: [], empty: false }, { shard: 2, files: [], empty: true }, { shard: 9, files: [paths[0]], empty: false }]) expect(worker(root, row).status).not.toBe(0);
}));
test('worker executes the complete frozen argv and clears inherited SHARD', () => fixture(root => {
writeFileSync(join(root, 'scripts/run-e2e.sh'), 'test -z "${SHARD:-}" || exit 81\nprintf "FILE:%s\\n" "$@"\n');
diff --git a/test/scripts/e2e-wiring.test.ts b/test/scripts/e2e-wiring.test.ts
index 0f962f6dcb..8d9665ded3 100644
--- a/test/scripts/e2e-wiring.test.ts
+++ b/test/scripts/e2e-wiring.test.ts
@@ -1,34 +1,23 @@
/**
- * G1 (test-gap wave 1) — CI e2e lane wiring pins.
+ * CI E2E lane wiring pins (.github/workflows/e2e.yml).
*
- * Structural guards over .github/workflows/e2e.yml + scripts/e2e-test-map.ts:
- * 1. The selected-e2e job exists, consumes scripts/select-e2e.ts in its
- * default file-selection mode, and NOTHING masks the selector's exit
- * code (exit 2 = git failure must fail the job — fail-loud).
- * 2. The e2e-status aggregate carries the job in `needs` and requires
- * success — a red selected lane cannot report E2E green.
- * 3. The job passes NO live provider keys, so it is fork-runnable by
- * construction (service Postgres only) and can never spend tokens.
- * 4. The job's checkout fetches real history (select-e2e diffs
- * origin/master...HEAD).
- * 5. Every workflow-side EXCLUDE entry is honest: either a file a named
- * job in this same workflow already runs, or a live-key token spender.
- * 6. Unmapped-file ratchet: every test/e2e/*.test.ts is mapped in
- * E2E_TEST_MAP, named in the workflow, or grandfathered in
- * test/fixtures/e2e-unmapped-baseline.txt (shrink-only). A NEW e2e
- * file must be mapped (preferred) or consciously baselined. The
- * baseline itself is enforced both ways: a row naming a deleted file
- * is stale (remove the line), a row that E2E_TEST_MAP or the workflow
- * already claims is redundant (remove the line), and total length may
- * never grow past the seeded literal.
+ * 1. prepare-e2e feeds scripts/select-e2e.ts the pull request's changed
+ * files from the GitHub API (shallow checkout, no git history) and fails
+ * closed to the whole corpus when the list is incomplete; nothing masks
+ * the selector's exit code.
+ * 2. The e2e-status aggregate requires the selected lane, which never
+ * receives live provider keys (fork-runnable, never spends tokens).
+ * 3. Every test/e2e/*.test.ts runs in Selected E2E or is in E2E_EXCLUSIONS
+ * with a named owning job: a job in this workflow that names the file,
+ * the tier1-backend-matrix job (scripts/e2e-backend-matrix.txt),
+ * persistence-validation.yml, or the live-key lanes.
*/
import { describe, test, expect } from 'bun:test';
-import { existsSync, mkdtempSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
+import { mkdtempSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
import { join } from 'node:path';
import { tmpdir } from 'node:os';
import { spawnSync } from 'node:child_process';
-import { E2E_EXCLUSIONS, PERSISTENCE_VALIDATION_OWNED, prepareMatrix } from '../../scripts/e2e-matrix.ts';
-import { E2E_TEST_MAP } from '../../scripts/e2e-test-map.ts';
+import { BACKEND_MATRIX_OWNED, E2E_EXCLUSIONS, PERSISTENCE_VALIDATION_OWNED, prepareMatrix } from '../../scripts/e2e-matrix.ts';
const repoRoot = join(import.meta.dir, '..', '..');
const yml = readFileSync(join(repoRoot, '.github/workflows/e2e.yml'), 'utf8');
@@ -49,17 +38,28 @@ const LIVE_KEY_FILES = new Set([
'test/e2e/voyage-multimodal.test.ts',
]);
+/** The job that runs an excluded file instead of Selected E2E, or null when nothing owns it. */
+function owner(file: string, exclusions: Set<string>): string | null {
+ if (!exclusions.has(file)) return 'selected-e2e';
+ if (PERSISTENCE_VALIDATION_OWNED.has(file) && persistenceYml.includes(file)) return 'persistence-validation.yml';
+ if (BACKEND_MATRIX_OWNED.has(file) && jobBlock('tier1-backend-matrix').includes('scripts/e2e-backend-matrix.txt')) return 'tier1-backend-matrix';
+ if (LIVE_KEY_FILES.has(file)) return 'live-key lane';
+ const named = yml.replace(jobBlock('selected-e2e'), '');
+ return named.includes(file) ? 'named job in e2e.yml' : null;
+}
+
describe('selected-e2e job wiring', () => {
const job = jobBlock('selected-e2e');
const prep = jobBlock('prepare-e2e');
test('consumes select-e2e with nothing masking its exit code', () => {
- expect(prep).toContain('bun scripts/select-e2e.ts');
+ expect(prep).toContain('bun scripts/select-e2e.ts --changed-files');
expect(job).not.toContain('bun scripts/select-e2e.ts');
expect(job).toContain('bun scripts/e2e-matrix.ts run');
- const selectorLine = prep.split('\n').find(l => l.includes('bun scripts/select-e2e.ts'))!;
- expect(selectorLine).not.toContain('|| true');
- expect(selectorLine).not.toContain('|| echo');
+ for (const line of prep.split('\n').filter(l => l.includes('bun scripts/select-e2e.ts'))) {
+ expect(line).not.toContain('|| true');
+ expect(line).not.toContain('|| echo');
+ }
expect(job).not.toContain('continue-on-error');
});
@@ -77,8 +77,11 @@ describe('selected-e2e job wiring', () => {
}
});
- test('checkout fetches real history for the master diff', () => {
- expect(prep).toContain('fetch-depth: 0');
+ test('prepare-e2e classifies from the pull request files API on a shallow checkout', () => {
+ expect(prep).not.toContain('fetch-depth');
+ expect(prep).not.toContain('git fetch');
+ expect(prep).toContain('bash scripts/ci-changed-files.sh');
+ expect(prep).toContain('pull-requests: read');
});
test('selector emits separate lines so workflow exclusions retain other selected files', () => {
@@ -103,82 +106,88 @@ describe('selected-e2e job wiring', () => {
rmSync(dir, { recursive: true, force: true });
}
});
+});
- test('every EXCLUDE entry is named by another job here, by persistence-validation.yml, or is a live-key spender', () => {
- const excluded = [...E2E_EXCLUSIONS];
- expect(excluded.length).toBeGreaterThan(0);
- const restOfWorkflow = yml.replace(job, '');
- for (const f of excluded) {
- const honest = LIVE_KEY_FILES.has(f) || restOfWorkflow.includes(f) || (PERSISTENCE_VALIDATION_OWNED.has(f) && persistenceYml.includes(f));
- if (!honest) throw new Error(`EXCLUDE entry not carried by any named job and not a live-key file: ${f}`);
+describe('prepare-e2e changed-file classification', () => {
+ const step = jobBlock('prepare-e2e');
+ const script = (() => {
+ const lines = step.split('\n');
+ const start = lines.findIndex(l => l.trim() === 'run: |');
+ const body: string[] = [];
+ for (const line of lines.slice(start + 1)) {
+ if (line.trim() && !line.startsWith(' ')) break;
+ body.push(line.slice(10));
}
- });
-});
+ return body.join('\n');
+ })();
+ const all = readdirSync(join(repoRoot, 'test/e2e')).filter(f => f.endsWith('.test.ts')).map(f => `test/e2e/${f}`).sort();
-/**
- * The CURRENT number of baseline entries. NEVER raise this number; when the
- * baseline shrinks (a file gets mapped or deleted), lower this constant IN
- * THE SAME COMMIT (the module-size ratchet's no-stale-slack convention).
- */
-const BASELINE_SEEDED_LENGTH = 126;
-
-describe('e2e file claim ratchet', () => {
- const mapped = new Set(Object.values(E2E_TEST_MAP).flat());
- const baselineEntries = readFileSync(join(repoRoot, 'test/fixtures/e2e-unmapped-baseline.txt'), 'utf8')
- .split('\n').map(l => l.trim()).filter(l => l && !l.startsWith('#'));
- const baseline = new Set(baselineEntries);
-
- test('every e2e file is mapped, workflow-named, or grandfathered (shrink-only baseline)', () => {
- const files = readdirSync(join(repoRoot, 'test/e2e'))
- .filter(f => f.endsWith('.test.ts'))
- .map(f => `test/e2e/${f}`);
- expect(files.length).toBeGreaterThan(150);
- const orphans = files.filter(f => !mapped.has(f) && !yml.includes(f) && !E2E_EXCLUSIONS.has(f) && !baseline.has(f));
- if (orphans.length > 0) {
- throw new Error(
- `new e2e file(s) with no PR-time claim — map them in scripts/e2e-test-map.ts ` +
- `(preferred) or consciously add to test/fixtures/e2e-unmapped-baseline.txt:\n` +
- orphans.join('\n'),
- );
+ function select(env: Record<string, string>, ghFiles: string, ghExit = 0): string[] {
+ const dir = mkdtempSync(join(tmpdir(), 'gbrain-prepare-e2e-'));
+ try {
+ const bin = join(dir, 'bin');
+ mkdirSync(bin);
+ writeFileSync(join(dir, 'gh-files'), ghFiles);
+ writeFileSync(join(bin, 'gh'), `#!/bin/sh\ncat "${join(dir, 'gh-files')}"\nexit ${ghExit}\n`, { mode: 0o755 });
+ const result = spawnSync('bash', ['-eo', 'pipefail', '-c', script], {
+ cwd: repoRoot, encoding: 'utf8',
+ env: { ...process.env, PATH: `${bin}:${process.env.PATH}`, RUNNER_TEMP: dir, GITHUB_OUTPUT: join(dir, 'out'), FULL_CORPUS: 'false', REPO: 'o/r', PR: '1', ...env },
+ });
+ expect(result.status, result.stderr).toBe(0);
+ return readFileSync(join(dir, 'selected.txt'), 'utf8').split('\n').filter(Boolean);
+ } finally {
+ rmSync(dir, { recursive: true, force: true });
}
- // Map entries must point at real files (typo guard — a registry-walking
- // matrix seeded with wrong names silently matches nothing).
- const real = new Set(files);
- const dangling = [...mapped].filter(f => !real.has(f));
- expect(dangling).toEqual([]);
+ }
+
+ test('a complete doc-only pull request list selects nothing', () => {
+ expect(select({ EVENT: 'pull_request', CHANGED_FILES: '2' }, 'docs/a.md\nREADME.md\n')).toEqual([]);
});
- test('no stale baseline entries: every row names an existing e2e file', () => {
- const stale = baselineEntries.filter(f => !existsSync(join(repoRoot, f)));
- if (stale.length > 0) {
- throw new Error(
- `baseline row(s) name deleted e2e file(s) — remove the line from ` +
- `test/fixtures/e2e-unmapped-baseline.txt (the ratchet only shrinks):\n` +
- stale.join('\n'),
- );
- }
+ test('a code change selects the whole corpus', () => {
+ expect(select({ EVENT: 'pull_request', CHANGED_FILES: '2' }, 'docs/a.md\nsrc/cli.ts\n')).toEqual(all);
});
- test('no redundant baseline entries: a mapped or workflow-named file must leave the baseline', () => {
- const redundant = baselineEntries.filter(f => mapped.has(f) || yml.includes(f) || E2E_EXCLUSIONS.has(f));
- if (redundant.length > 0) {
- throw new Error(
- `baseline row(s) already claimed by E2E_TEST_MAP or the workflow — ` +
- `remove the line from test/fixtures/e2e-unmapped-baseline.txt ` +
- `(mapped ⇒ off the baseline):\n` +
- redundant.join('\n'),
- );
- }
+ test.each([
+ ['a truncated pull request list', { EVENT: 'pull_request', CHANGED_FILES: '3' }, 'docs/a.md\n', 0],
+ ['a capped pull request (3000 files)', { EVENT: 'pull_request', CHANGED_FILES: '3000' }, 'docs/a.md\n', 0],
+ ['an unknown changed-file count', { EVENT: 'pull_request', CHANGED_FILES: '' }, 'docs/a.md\n', 0],
+ ['an API error', { EVENT: 'pull_request', CHANGED_FILES: '1' }, 'docs/a.md\n', 1],
+ ['a capped merge-group compare', { EVENT: 'merge_group', BASE_SHA: 'a', HEAD_SHA: 'b' }, '', 1],
+ ['a push (no pull request context)', { EVENT: 'push' }, 'docs/a.md\n', 0],
+ ] as const)('%s fails closed to the whole corpus', (_label, env, files, exit) => {
+ expect(select(env, files, exit)).toEqual(all);
+ });
+
+ test('a complete doc-only merge-group compare selects nothing', () => {
+ expect(select({ EVENT: 'merge_group', BASE_SHA: 'a', HEAD_SHA: 'b' }, 'docs/a.md\n')).toEqual([]);
+ });
+});
+
+describe('e2e file ownership', () => {
+ const files = readdirSync(join(repoRoot, 'test/e2e')).filter(f => f.endsWith('.test.ts')).map(f => `test/e2e/${f}`);
+
+ test('every e2e file runs in Selected E2E or names the job that owns it', () => {
+ expect(files.length).toBeGreaterThan(150);
+ const unowned = files.filter(f => owner(f, E2E_EXCLUSIONS) === null);
+ if (unowned.length) throw new Error(`excluded from Selected E2E with no owning job (add the file to a named job, or drop it from E2E_EXCLUSIONS):\n${unowned.join('\n')}`);
+ });
+
+ test('every exclusion names an existing file', () => {
+ expect([...E2E_EXCLUSIONS].filter(f => !files.includes(f))).toEqual([]);
});
- test('baseline is shrink-only (seeded length ratchet)', () => {
- expect(baselineEntries.length).toBeLessThanOrEqual(BASELINE_SEEDED_LENGTH);
+ test('a file excluded without an owning job fails the ownership check', () => {
+ const fixture = 'test/e2e/fixture-unowned.test.ts';
+ expect(owner(fixture, new Set([...E2E_EXCLUSIONS, fixture]))).toBeNull();
+ expect(owner(fixture, E2E_EXCLUSIONS)).toBe('selected-e2e');
});
- test('select-e2e fail-closed behavior has its own behavioral suite', () => {
- // Cross-reference, not duplication: the ALL-on-uncertainty + exit-2
- // semantics are behaviorally pinned in test/select-e2e.test.ts.
- const behavioral = readFileSync(join(repoRoot, 'test/select-e2e.test.ts'), 'utf8');
- expect(behavioral).toContain('select-e2e');
+ test('backend-matrix files are owned by the tier1-backend-matrix job, which e2e-status requires', () => {
+ for (const file of BACKEND_MATRIX_OWNED) expect(owner(file, E2E_EXCLUSIONS), file).not.toBeNull();
+ const matrix = jobBlock('tier1-backend-matrix');
+ expect(matrix).toContain('GBRAIN_CI_REQUIRE_PGBOUNCER');
+ expect(matrix).toContain('pgbouncer:');
+ expect(jobBlock('e2e-status')).toContain('needs.tier1-backend-matrix.result');
});
});
diff --git a/test/scripts/nightly-e2e.test.ts b/test/scripts/nightly-e2e.test.ts
index 353626948d..ffdb852926 100644
--- a/test/scripts/nightly-e2e.test.ts
+++ b/test/scripts/nightly-e2e.test.ts
@@ -176,7 +176,7 @@ describe('nightly E2E scheduling', () => {
writeFileSync(join(bin, 'git'), '#!/bin/sh\nexit 0\n', { mode: 0o755 });
writeFileSync(join(bin, 'bun'), `#!/bin/sh
case "$*" in
- "scripts/select-e2e.ts") echo test/e2e/selected.test.ts ;;
+ "scripts/select-e2e.ts --changed-files "*) echo test/e2e/selected.test.ts ;;
"scripts/e2e-matrix.ts prepare") cat > "$RUNNER_TEMP/received-selection"; echo '{}' ;;
*) exit 2 ;;
esac
diff --git a/test/select-e2e.test.ts b/test/select-e2e.test.ts
index 20b4bcf7c0..fff488c984 100644
--- a/test/select-e2e.test.ts
+++ b/test/select-e2e.test.ts
@@ -1,8 +1,8 @@
// test/select-e2e.test.ts
//
-// Unit tests for the diff-based E2E selector. Pure-function tests — no git,
-// no filesystem. The 3 codex regression guards (skills/, untracked,
-// unmapped src/) are explicitly named.
+// The E2E selector after narrowing retired (GBRA-47 C6): doc-only changes
+// select nothing, every other change selects the whole corpus, and the CI
+// path reads the changed-file list instead of git history.
import { describe, expect, test } from "bun:test";
import { spawnSync } from "node:child_process";
@@ -10,84 +10,10 @@ import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
-import {
- E2E_TEST_MAP,
-} from "../scripts/e2e-test-map.ts";
-import {
- classify,
- matchGlob,
- persistenceOwnedNotices,
- selectTests,
-} from "../scripts/select-e2e.ts";
+import { classify, NARROWING_RETIRED, selectTests } from "../scripts/select-e2e.ts";
-const ALL_E2E = [
- "test/e2e/cycle.test.ts",
- "test/e2e/dream.test.ts",
- "test/e2e/code-indexing.test.ts",
- "test/e2e/engine-parity.test.ts",
- "test/e2e/chunk-canonical-text-privacy.test.ts",
- "test/e2e/engine-content-privacy.test.ts",
- "test/e2e/legacy-chunk-privacy.test.ts",
- "test/e2e/read-enrichment-privacy.test.ts",
- "test/e2e/graph-quality.test.ts",
- "test/e2e/http-transport.test.ts",
- "test/e2e/integrity-batch.test.ts",
- "test/e2e/jsonb-roundtrip.test.ts",
- "test/e2e/mechanical.test.ts",
- "test/e2e/migrate-chain.test.ts",
- "test/e2e/migration-flow.test.ts",
- "test/e2e/minions-concurrency.test.ts",
- "test/e2e/minions-resilience.test.ts",
- "test/e2e/minions-shell-pglite.test.ts",
- "test/e2e/minions-shell.test.ts",
- "test/e2e/multi-source.test.ts",
- "test/e2e/postgres-bootstrap.test.ts",
- "test/e2e/postgres-jsonb.test.ts",
- "test/e2e/search-exclude.test.ts",
- "test/e2e/search-quality.test.ts",
- "test/e2e/search-swamp.test.ts",
- "test/e2e/skills.test.ts",
- "test/e2e/sync.test.ts",
- "test/e2e/upgrade.test.ts",
- "test/e2e/worker-abort-recovery.test.ts",
- "test/e2e/doctor-progress.test.ts",
- "test/e2e/frontmatter-migration.test.ts",
- "test/e2e/openclaw-reference-compat.test.ts",
-];
-
-function select(changedFiles: string[]): string[] {
- return selectTests({
- changedFiles,
- allE2ETests: ALL_E2E,
- map: E2E_TEST_MAP,
- });
-}
-
-describe("matchGlob", () => {
- test("** matches any path segments", () => {
- expect(matchGlob("src/core/search/**", "src/core/search/intent.ts")).toBe(
- true
- );
- expect(
- matchGlob("src/core/search/**", "src/core/search/sub/dir/file.ts")
- ).toBe(true);
- });
-
- test("* matches one segment, no /", () => {
- expect(matchGlob("src/*.ts", "src/cli.ts")).toBe(true);
- expect(matchGlob("src/*.ts", "src/core/cli.ts")).toBe(false);
- });
-
- test("literal path matches itself", () => {
- expect(matchGlob("src/core/cycle.ts", "src/core/cycle.ts")).toBe(true);
- expect(matchGlob("src/core/cycle.ts", "src/core/cycle.test.ts")).toBe(false);
- });
-
- test("throws on unsupported glob syntax", () => {
- expect(() => matchGlob("src/[abc].ts", "src/a.ts")).toThrow();
- expect(() => matchGlob("src/{foo,bar}.ts", "src/foo.ts")).toThrow();
- });
-});
+const ALL_E2E = ["test/e2e/sync.test.ts", "test/e2e/cycle.test.ts", "test/e2e/mechanical.test.ts"];
+const SELECTOR = join(import.meta.dir, "../scripts/select-e2e.ts");
describe("classify", () => {
test("empty -> EMPTY", () => {
@@ -107,248 +33,63 @@ describe("classify", () => {
});
describe("selectTests", () => {
- test.each([
- "src/core/attendance-repair.ts",
- "src/commands/extract-attendance-repair.ts",
- ])("attendance repair changes select their PostgreSQL parity entry: %s", (path) => {
- expect(selectTests({
- changedFiles: [path],
- allE2ETests: [
- "test/e2e/attendance-repair-postgres.test.ts",
- "test/e2e/attendance-retrieval-postgres.test.ts",
- "test/e2e/graph-quality.test.ts",
- ],
- map: E2E_TEST_MAP,
- })).toEqual(["test/e2e/attendance-repair-postgres.test.ts"]);
- });
-
- test("shared derived-link changes retain attendance retrieval and repair parity", () => {
- expect(selectTests({
- changedFiles: ["src/core/derived-links.ts"],
- allE2ETests: [
- "test/e2e/attendance-repair-postgres.test.ts",
- "test/e2e/attendance-retrieval-postgres.test.ts",
- "test/e2e/graph-quality.test.ts",
- ],
- map: E2E_TEST_MAP,
- })).toEqual([
- "test/e2e/attendance-repair-postgres.test.ts",
- "test/e2e/attendance-retrieval-postgres.test.ts",
- ]);
- });
-
- test("postgres-engine.ts changes select its shared-singleton owners", () => {
- const singletonOwners = [
- "test/e2e/db-singleton-shared-recovery.test.ts",
- "test/e2e/postgres-engine-disconnect-idempotency.test.ts",
- "test/e2e/postgres-reconnect-singleton.test.ts",
- ];
- const selected = selectTests({
- changedFiles: ["src/core/postgres-engine.ts"],
- allE2ETests: [...singletonOwners, "test/e2e/graph-quality.test.ts"],
- map: E2E_TEST_MAP,
- });
- for (const owner of singletonOwners) expect(selected).toContain(owner);
- expect(selected).not.toContain("test/e2e/graph-quality.test.ts");
- });
-
- test("case 1: empty diff -> all E2E", () => {
- expect(select([])).toEqual(ALL_E2E.slice().sort());
+ test("a doc-only change selects nothing", () => {
+ expect(selectTests(["docs/guides/example.md", "README.md"], ALL_E2E)).toEqual([]);
});
-
- test("case 2: doc-only -> nothing", () => {
- expect(select(["README.md", "docs/guides/foo.md", "CHANGELOG.md"])).toEqual(
- []
- );
- });
-
- test("case 3: single mapped src -> only mapped tests", () => {
- expect(select(["src/core/search/intent.ts"])).toEqual([
- "test/e2e/chunk-canonical-text-privacy.test.ts",
- "test/e2e/engine-content-privacy.test.ts",
- "test/e2e/legacy-chunk-privacy.test.ts",
- "test/e2e/projection-readiness-currency.test.ts",
- "test/e2e/projection-statistics-postgres.test.ts",
- "test/e2e/read-enrichment-privacy.test.ts",
- "test/e2e/search-exclude.test.ts",
- "test/e2e/search-quality.test.ts",
- "test/e2e/search-query-contract-postgres.test.ts",
- "test/e2e/search-swamp.test.ts",
- "test/e2e/unsupported-embedding-identity-postgres.test.ts",
- "test/e2e/vector-candidate-safety-postgres.test.ts",
- "test/e2e/vector-plan-real-column-postgres.test.ts",
- ]);
- });
-
- test("case 4: multiple mapped srcs -> union, no duplicates", () => {
- const result = select([
- "src/core/search/intent.ts",
- "src/core/minions/queue.ts",
- ]);
- expect(result).toContain("test/e2e/search-quality.test.ts");
- expect(result).toContain("test/e2e/minions-concurrency.test.ts");
- // Determinism: dedup preserved
- const set = new Set(result);
- expect(set.size).toBe(result.length);
- });
-
- test("case 5: schema escape-hatch -> all", () => {
- expect(select(["src/schema.sql"])).toEqual(ALL_E2E.slice().sort());
- });
-
- test("case 6 (Codex F4 regression): skills/ -> all", () => {
- expect(select(["skills/RESOLVER.md"])).toEqual(ALL_E2E.slice().sort());
- expect(select(["skills/migrations/v0.22.4.md"])).toEqual(
- ALL_E2E.slice().sort()
- );
- });
-
- test("case 7 (Codex F5 regression): untracked file -> fail-closed -> all", () => {
- // The selector receives the union of (committed, unstaged, untracked).
- // We simulate "untracked" by passing the path in the changed list with
- // no map entry — should fail-closed to ALL.
- expect(select(["src/foo-new.ts"])).toEqual(ALL_E2E.slice().sort());
- });
-
- test("case 8 (Codex F1 headline): unmapped src/ -> fail-closed -> all", () => {
- // src/core/utils.ts is not in the map; must fail-closed.
- expect(select(["src/core/utils.ts"])).toEqual(ALL_E2E.slice().sort());
- // src/cli.ts is also not in the map.
- expect(select(["src/cli.ts"])).toEqual(ALL_E2E.slice().sort());
+ test.each([
+ ["an empty change", []],
+ ["a source change", ["src/core/search/intent.ts"]],
+ ["a direct test edit", ["test/e2e/sync.test.ts"]],
+ ["a workflow edit", [".github/workflows/e2e.yml"]],
+ ["mixed docs and source", ["docs/foo.md", "src/cli.ts"]],
+ ])("%s selects the whole corpus, sorted", (_label, changed) => {
+ expect(selectTests(changed, ALL_E2E)).toEqual([...ALL_E2E].sort());
});
+});
- test("an unmapped change forces all tests even beside a mapped change or direct test edit", () => {
- for (const changes of [
- ["src/core/search/intent.ts", "src/new-unmapped.ts"],
- ["src/new-unmapped.ts", "src/core/search/intent.ts"],
- ["test/e2e/sync.test.ts", "src/new-unmapped.ts"],
- ]) {
- expect(select(changes)).toEqual(ALL_E2E.slice().sort());
+describe("selector CLI", () => {
+ function run(args: string[], files: Record<string, string> = {}, input?: string) {
+ const dir = mkdtempSync(join(tmpdir(), "gbrain-select-e2e-"));
+ try {
+ const git = (...a: string[]) => expect(spawnSync("git", a, { cwd: dir, encoding: "utf8" }).status).toBe(0);
+ git("init", "-q");
+ git("-c", "user.name=fixture", "-c", "[email protected]", "commit", "-q", "--allow-empty", "-m", "base");
+ git("update-ref", "refs/remotes/origin/master", "HEAD");
+ mkdirSync(join(dir, "test/e2e"), { recursive: true });
+ for (const file of ["test/e2e/a.test.ts", "test/e2e/b.test.ts"]) writeFileSync(join(dir, file), "// fixture\n");
+ for (const [path, body] of Object.entries(files)) writeFileSync(join(dir, path), body);
+ return spawnSync(process.execPath, ["--no-env-file", SELECTOR, ...args], { cwd: dir, encoding: "utf8", input });
+ } finally {
+ rmSync(dir, { recursive: true, force: true });
}
- });
-
- test("an empty map entry cannot declare an unknown change covered", () => {
- expect(selectTests({
- changedFiles: ["src/covered.ts", "src/empty.ts"],
- allE2ETests: ALL_E2E,
- map: { "src/covered.ts": ["test/e2e/sync.test.ts"], "src/empty.ts": [] },
- })).toEqual(ALL_E2E.slice().sort());
- });
-
- test("case 9: directly-modified test file is included", () => {
- // Touching a test file directly with no other src changes:
- // - test/e2e/foo.test.ts is in changedFiles
- // - it gets added to result
- // - no other map entries match
- // - result has 1 entry, so NOT fail-closed
- expect(select(["test/e2e/sync.test.ts"])).toEqual([
- "test/e2e/sync.test.ts",
- ]);
- });
-
- test("case 10: mixed doc + mapped-src -> only src-relevant", () => {
- const result = select([
- "README.md",
- "docs/foo.md",
- "src/core/search/intent.ts",
- ]);
- expect(result).toEqual([
- "test/e2e/chunk-canonical-text-privacy.test.ts",
- "test/e2e/engine-content-privacy.test.ts",
- "test/e2e/legacy-chunk-privacy.test.ts",
- "test/e2e/projection-readiness-currency.test.ts",
- "test/e2e/projection-statistics-postgres.test.ts",
- "test/e2e/read-enrichment-privacy.test.ts",
- "test/e2e/search-exclude.test.ts",
- "test/e2e/search-quality.test.ts",
- "test/e2e/search-query-contract-postgres.test.ts",
- "test/e2e/search-swamp.test.ts",
- "test/e2e/unsupported-embedding-identity-postgres.test.ts",
- "test/e2e/vector-candidate-safety-postgres.test.ts",
- "test/e2e/vector-plan-real-column-postgres.test.ts",
- ]);
- });
-
- test("escape-hatch: package.json -> all", () => {
- expect(select(["package.json"])).toEqual(ALL_E2E.slice().sort());
- });
-
- test("escape-hatch: bun.lock -> all", () => {
- expect(select(["bun.lock"])).toEqual(ALL_E2E.slice().sort());
- });
-
- test("escape-hatch: .github/workflows/** -> all", () => {
- expect(select([".github/workflows/test.yml"])).toEqual(
- ALL_E2E.slice().sort()
- );
- });
+ }
- test("escape-hatch: src/commands/migrations/** -> all", () => {
- expect(select(["src/commands/migrations/v0_22_8.ts"])).toEqual(
- ALL_E2E.slice().sort()
- );
- });
-
- test("escape-hatch: src/core/schema-migrations/** -> all (refactor wave 1)", () => {
- expect(select(["src/core/schema-migrations/v176-add-widget.ts"])).toEqual(
- ALL_E2E.slice().sort()
- );
- });
-
- test("src/core/engine-sql/** selects both engines' E2E files and the E5 binding matrix, not all (refactor wave 1)", () => {
- const selected = select(["src/core/engine-sql/facts.ts"]);
- const engineRows = ["src/core/postgres-engine.ts", "src/core/pglite-engine.ts", "src/core/postgres-engine/**", "src/core/pglite-engine/**"];
- expect(selected).toEqual([...new Set(engineRows.flatMap((k) => E2E_TEST_MAP[k]))].sort());
- expect(selected).toContain("test/e2e/executor-binding-matrix.test.ts");
- expect(selected).toContain("test/e2e/engine-parity.test.ts");
- expect(selected).not.toContain("test/e2e/skills.test.ts");
- });
-
- test("escape-hatch: test/e2e/helpers.ts -> all", () => {
- expect(select(["test/e2e/helpers.ts"])).toEqual(ALL_E2E.slice().sort());
- });
-
- test("escape-hatch beats narrow map: schema + search both touched", () => {
- // schema.sql is escape-hatch; should win over search narrow match.
- expect(select(["src/schema.sql", "src/core/search/intent.ts"])).toEqual(
- ALL_E2E.slice().sort()
- );
+ test("a code change in the working tree lists every E2E file and says narrowing is retired", () => {
+ const r = run([]);
+ expect(r.status, r.stderr).toBe(0);
+ expect(r.stdout).toBe("test/e2e/a.test.ts\ntest/e2e/b.test.ts\n");
+ expect(r.stderr).toContain(NARROWING_RETIRED);
});
-});
-describe("persistenceOwnedNotices", () => {
- test("a mapped reconcile source names both crash suites and their owner", () => {
- expect(persistenceOwnedNotices(["src/commands/source-reconcile.ts"], E2E_TEST_MAP)).toEqual([
- "excluded: test/e2e/reconcile-crash-unactivated.test.ts (owned by persistence-validation.yml)",
- "excluded: test/e2e/reconcile-crash.test.ts (owned by persistence-validation.yml)",
- ]);
+ test("--changed-files reads the CI list: doc-only selects nothing", () => {
+ const r = run(["--changed-files", "changed.txt"], { "changed.txt": "docs/a.md\nREADME.md\n" });
+ expect(r.status, r.stderr).toBe(0);
+ expect(r.stdout).toBe("");
+ expect(r.stderr).not.toContain(NARROWING_RETIRED);
});
- test("editing a crash suite directly names it", () => {
- expect(persistenceOwnedNotices(["test/e2e/reconcile-crash.test.ts"], E2E_TEST_MAP)).toEqual([
- "excluded: test/e2e/reconcile-crash.test.ts (owned by persistence-validation.yml)",
- ]);
+ test("--changed-files - reads stdin; an empty list (fail-closed fallback) selects everything", () => {
+ const r = run(["--changed-files", "-"], {}, "");
+ expect(r.status, r.stderr).toBe(0);
+ expect(r.stdout).toBe("test/e2e/a.test.ts\ntest/e2e/b.test.ts\n");
});
- test("the CLI prints the notice on stderr and still lists the files on stdout", () => {
- const root = mkdtempSync(join(tmpdir(), "gbrain-select-e2e-"));
- try {
- const git = (...args: string[]) => spawnSync("git", args, { cwd: root, encoding: "utf8" });
- git("init", "-q");
- git("-c", "user.name=fixture", "-c", "[email protected]", "commit", "-q", "--allow-empty", "-m", "base");
- git("update-ref", "refs/remotes/origin/master", "HEAD");
- mkdirSync(join(root, "src/commands"), { recursive: true });
- writeFileSync(join(root, "src/commands/source-reconcile.ts"), "// changed\n");
- const r = spawnSync(process.execPath, [join(import.meta.dir, "../scripts/select-e2e.ts")], { cwd: root, encoding: "utf8" });
- expect(r.status, r.stderr).toBe(0);
- expect(r.stderr).toContain("excluded: test/e2e/reconcile-crash.test.ts (owned by persistence-validation.yml)");
- expect(r.stdout.split("\n")).toContain("test/e2e/reconcile-crash.test.ts");
- } finally {
- rmSync(root, { recursive: true, force: true });
- }
+ test("--classify-only prints the classification of the given list", () => {
+ const r = run(["--changed-files", "-", "--classify-only"], {}, "src/cli.ts\n");
+ expect(r.stdout).toBe("SRC\n");
});
- test("unrelated sources print nothing", () => {
- expect(persistenceOwnedNotices(["src/core/derived-links.ts", "README.md"], E2E_TEST_MAP)).toEqual([]);
+ test("--changed-files without a value exits 2", () => {
+ expect(run(["--changed-files"]).status).toBe(2);
});
});