perf(ci): narrow PR test selection fallbacks, unify stray lanes, and cache Windows builds (#11797)

* fix(ci): narrow false full-suite fallbacks in PR test selection

* ci: unify Go and Android lanes under CI and scope CodeQL and cache retention

* perf(ci): trim classification checkout, cache MinGW/Windows builds, and rebalance full shards

* fix(ci): calibrate PR CI health window and CI timings schedule

* perf(ci): fix script-basename substring fallbacks and trim macOS/Windows lane overhead

* fix(ci): address PR review findings across CodeQL, Windows cache key, PR health, and docs

* perf(tests): share canonical MCP catalog setup and avoid Ajv $ref expansion

* fix(ci): align selected test shard limits (50 files, max 8 shards) with 400-file cap
This commit is contained in:
morluto authored and GitHub committed 2026-11-16 21:27:46 -05:00
1 parent 575c0f1443
commit 30d5ad2a48
27 files changed
+1236 -481

No files matched your search

+6 -4
View File
@@ -4,6 +4,7 @@ on:
workflow_run:
workflows: ["CI"]
types: [completed]
branches: [main]
# Qualification calls ci.yml with actions: read. A nested workflow cannot raise
# that token, so cache deletion stays in this workflow.
@@ -21,13 +22,13 @@ jobs:
# Restrict the triggering-source checkout to same-repository default-branch
# CI events. The helper runs from this trusted workflow revision; triggering
# source is used only for cache identity and is never executed. Static and
# build save snapshots before later lanes finish, so failed, timed-out, or
# cancelled runs still retain those snapshots.
# build save snapshots before later lanes finish, so failed or timed-out
# runs still retain those snapshots, while queue-superseded cancelled runs
# never published caches.
if: >-
(github.event.workflow_run.conclusion == 'success' ||
github.event.workflow_run.conclusion == 'failure' ||
github.event.workflow_run.conclusion == 'timed_out' ||
github.event.workflow_run.conclusion == 'cancelled') &&
github.event.workflow_run.conclusion == 'timed_out') &&
github.event.workflow_run.head_repository.full_name == github.repository &&
github.event.workflow_run.head_branch == github.event.repository.default_branch &&
(github.event.workflow_run.event == 'push' ||
@@ -60,5 +61,6 @@ jobs:
CACHE_KNIP_PREFIX: knip-meta-v1-${{ runner.os }}-
CACHE_KNIP_KEEP_KEY: knip-meta-v1-${{ runner.os }}-${{ hashFiles('triggering-source/knip.json', 'triggering-source/tsconfig.json', 'triggering-source/package.json', 'triggering-source/package-lock.json') }}-${{ github.event.workflow_run.head_sha }}
CACHE_PORTABLE_PREFIX: rea-portable-build-v2-${{ runner.os }}-${{ runner.arch }}-
CACHE_WINDOWS_BUILD_PREFIX: rea-windows-build-v1-Windows-X64-
DEDUPE_NPM_DOWNLOADS: "true"
run: node trusted-retention/scripts/ci/cache-retention.mjs
+1 -1
View File
@@ -2,7 +2,7 @@ name: CI timings
on:
schedule:
- cron: "17 * * * *"
- cron: "17 */6 * * *"
workflow_dispatch:
concurrency:
+101 -22
View File
@@ -84,6 +84,8 @@ jobs:
agentenv: ${{ steps.plan.outputs.agentenv }}
nativeaot: ${{ steps.plan.outputs.nativeaot }}
ghidra_bridge: ${{ steps.plan.outputs.ghidra_bridge }}
go_binary: ${{ steps.plan.outputs.go_binary }}
android_metadata: ${{ steps.plan.outputs.android_metadata }}
website: ${{ steps.plan.outputs.website }}
matrix: ${{ steps.plan.outputs.matrix }}
test_selection: ${{ steps.plan.outputs.test_selection }}
@@ -94,6 +96,7 @@ jobs:
with:
ref: ${{ inputs.source_sha || github.sha }}
fetch-depth: 0
filter: blob:none
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version-file: .nvmrc
@@ -334,7 +337,7 @@ jobs:
fail-fast: ${{ github.event_name == 'pull_request' && needs.changes.outputs.tier == 'fast' }}
matrix:
# scripts/ci/test-selection.mjs owns the shard counts: twelve fast
# built shards, six full-qualification shards with coverage, or one
# built shards, twelve full-qualification shards with coverage, or one
# job per group of a selected PR subset.
shard: ${{ fromJSON(needs.changes.outputs.test_shards) }}
steps:
@@ -429,7 +432,8 @@ jobs:
needs.changes.outputs.web_source_map == 'true' ||
needs.changes.outputs.agentenv == 'true' ||
needs.changes.outputs.packet_capture == 'true' ||
needs.changes.outputs.signal_recording == 'true'
needs.changes.outputs.signal_recording == 'true' ||
needs.changes.outputs.go_binary == 'true'
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
@@ -688,7 +692,28 @@ jobs:
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version-file: .nvmrc
# Include runner ImageOS/ImageVersion and a UTC date bucket so runner image
# rollouts invalidate immediately and cached MinGW outputs refresh daily.
- name: Compute Windows native cache key
id: windows-native-key
env:
SOURCE_HASH: ${{ hashFiles('native/windows/**', 'src/domain/windowsNativeArtifact*.ts', 'src/domain/dosMz*.ts', 'src/domain/peCoffHeader*.ts', 'scripts/build-windows-native.mjs', 'scripts/verify-windows-native-artifact.mjs', 'scripts/lib/verifier-source-loader.mjs', 'tests/fixtures/windows-native-inspection-failure.cc', 'tests/fixtures/windows/processBoundary.cc', 'package.json') }}
run: |
utc_date="$(date -u +%Y-%m-%d)"
printf 'key=rea-windows-native-v2-%s-%s-%s-%s-%s-%s\n' \
"${RUNNER_OS}" "${RUNNER_ARCH}" "${ImageOS:-ubuntu}" "${ImageVersion:-rolling}" "${utc_date}" "${SOURCE_HASH}" \
>> "${GITHUB_OUTPUT}"
- name: Restore Windows native build outputs
id: windows-native-cache
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: |
native/windows/build/
.cache/windows-native-inspection-fixture/
.cache/windows-process-boundary/
key: ${{ steps.windows-native-key.outputs.key }}
- name: Prepare cross compiler
if: steps.windows-native-cache.outputs.cache-hit != 'true'
run: |
# Slow Azure archive transfers can exhaust the job before compilation.
# Keep the same signed packages and avoid slow HTTP mirror fallback.
@@ -699,9 +724,11 @@ jobs:
done
sudo apt-get update
sudo apt-get install --no-install-recommends -y g++-mingw-w64-x86-64
- run: npm run build:windows-native
- if: steps.windows-native-cache.outputs.cache-hit != 'true'
run: npm run build:windows-native
- run: npm run verify:windows-native:artifact
- run: node scripts/build-windows-native.mjs --inspection-fixture
- if: steps.windows-native-cache.outputs.cache-hit != 'true'
run: node scripts/build-windows-native.mjs --inspection-fixture
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: windows-native-inspection-fixture
@@ -712,11 +739,30 @@ jobs:
# results from a separate executable. Cross-build it in the lane that
# already has MinGW so the Windows job can observe them too.
- name: Build Windows process boundary fixture
if: steps.windows-native-cache.outputs.cache-hit != 'true'
run: |
mkdir -p .cache/windows-process-boundary
x86_64-w64-mingw32-g++ -municode -std=c++17 -O2 -static -Wall -Wextra \
-o .cache/windows-process-boundary/process-boundary.exe \
tests/fixtures/windows/processBoundary.cc -ladvapi32
- name: Verify cross-built Windows test fixtures
run: >-
node -e "const fs = require('node:fs');
for (const p of ['.cache/windows-native-inspection-fixture/manifest.json', '.cache/windows-process-boundary/process-boundary.exe']) {
if (fs.statSync(p).size <= 0) throw new Error('empty Windows fixture: ' + p); }"
- name: Save validated Windows native build outputs
if: >-
success() &&
steps.windows-native-cache.outputs.cache-hit != 'true' &&
github.ref == format('refs/heads/{0}', github.event.repository.default_branch) &&
(github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch')
uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: |
native/windows/build/
.cache/windows-native-inspection-fixture/
.cache/windows-process-boundary/
key: ${{ steps.windows-native-cache.outputs.cache-primary-key }}
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: windows-process-boundary-fixture
@@ -766,9 +812,17 @@ jobs:
console.log(JSON.stringify({ platform: process.platform, architecture: process.arch, node: process.version }));"
- run: npm ci
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
if: matrix.os != 'windows-latest'
with:
name: rea-build-cache
path: .turbo/cache/
- name: Restore Windows Turbo build cache
if: matrix.os == 'windows-latest'
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: .turbo/cache/
key: rea-windows-build-v1-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('.nvmrc', '.npmrc', 'package-lock.json') }}-${{ github.sha }}
restore-keys: rea-windows-build-v1-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('.nvmrc', '.npmrc', 'package-lock.json') }}-
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: windows-native-controls
@@ -819,21 +873,19 @@ jobs:
env:
REA_ARTIFACT_NODE_COMPILE_CACHE: ${{ runner.temp }}/rea-artifact-node-cache
run: |
npm run verify:keyed-archive
npm run verify:asset-catalog
npm run verify:macos-bundle
npm run verify:legacy-simulator
npm run verify:apple-dispatch
npm run verify:interface-builder
- name: Verify portable iNES CLI, MCP and source boundaries
npm run build:cached
node scripts/verify/apple/keyed-archive.mjs
node scripts/verify/apple/asset-catalog.mjs
node scripts/verify/apple/macos-bundle.mjs
node scripts/verify/apple/legacy-simulator.mjs
node scripts/verify/apple/dispatch.mjs
node scripts/verify/apple/interface-builder.mjs
- name: Run native Apple, iNES, and process boundary regressions
run: >-
npm run test:focused --
tests/acceptance/inesContainer.test.ts
tests/boundary/filesystem/inesArtifact.test.ts
tests/boundary/filesystem/inesCancellation.test.ts
- name: Run native Apple and process boundary regressions
run: >-
npm run test:focused --
tests/boundary/providers/hopper/hopperMacLaunchArguments.test.ts
tests/acceptance/providers/hopperStartupRecovery.test.ts
tests/boundary/providers/hopper/hopperClient.helperFailure.test.ts
@@ -922,16 +974,27 @@ jobs:
GOMAXPROCS: "2"
GOMEMLIMIT: "3GiB"
run: npm run typecheck -- --checkers 2
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
- name: Restore Windows Turbo build cache
id: windows-build-cache
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
name: rea-build-cache
path: .turbo/cache/
key: rea-windows-build-v1-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('.nvmrc', '.npmrc', 'package-lock.json') }}-${{ github.sha }}
restore-keys: rea-windows-build-v1-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('.nvmrc', '.npmrc', 'package-lock.json') }}-
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: windows-native-controls
path: native/windows/build/
- run: npm run verify:windows-native:artifact
- run: npm run build:cached
- name: Save validated Windows Turbo build cache
if: >-
success() && steps.npm-cache.outputs.can-save == 'true' &&
steps.windows-build-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: .turbo/cache/
key: ${{ steps.windows-build-cache.outputs.cache-primary-key }}
- name: Record named Windows host capabilities
run: node scripts/windows-capabilities.mjs | Out-File -Encoding utf8NoBOM windows-capabilities.json
- name: Validate Windows host capability report
@@ -1022,6 +1085,9 @@ jobs:
tests/process-global/runnerCancellation.test.ts
tests/process-global/windowsOwnedCommand.test.ts
tests/conformance/providers/ghidra/realGhidraWindowsWorkflow.test.ts
tests/boundary/filesystem/directoryArtifactReaderOpen.test.ts
tests/boundary/filesystem/javascriptPackagePrecedence.test.ts
tests/boundary/filesystem/javascriptArtifactContentIdentity.test.ts
- name: Verify real Node Inspector discovery and observation
timeout-minutes: 10
env:
@@ -1029,12 +1095,6 @@ jobs:
UV_THREADPOOL_SIZE: "2"
run: npm run verify:inspector
- run: npm run verify:package:windows
- name: Verify native directory identity on Node 24
run: >-
npx vitest run --coverage.enabled=false
tests/boundary/filesystem/directoryArtifactReaderOpen.test.ts
tests/boundary/filesystem/javascriptPackagePrecedence.test.ts
tests/boundary/filesystem/javascriptArtifactContentIdentity.test.ts
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: 22.23.4
@@ -1067,6 +1127,8 @@ jobs:
id: npm-cache
uses: ./.github/actions/npm-cache
- run: npm ci
- name: Reuse portable build outputs across runs
uses: ./.github/actions/portable-build-cache
- run: npm run docs:check
- name: Verify published routes, source links and local anchors
run: npm run verify:docs:routes
@@ -1202,6 +1264,16 @@ jobs:
build_cache_artifact: rea-build-cache
remote_cache_write: ${{ inputs.remote_cache_write == true || (github.ref == format('refs/heads/{0}', github.event.repository.default_branch) && (github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch')) }}
go_binary:
needs: [changes, static, build]
if: needs.changes.outputs.go_binary == 'true'
secrets:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
uses: ./.github/workflows/real-go-binary.yml
with:
build_cache_artifact: rea-build-cache
remote_cache_write: ${{ inputs.remote_cache_write == true || (github.ref == format('refs/heads/{0}', github.event.repository.default_branch) && (github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch')) }}
nativeaot:
needs: [changes, static]
if: needs.changes.outputs.nativeaot == 'true'
@@ -1212,6 +1284,11 @@ jobs:
if: needs.changes.outputs.ghidra_bridge == 'true'
uses: ./.github/workflows/ghidra-bridge-sources.yml
android_metadata:
needs: [changes, static]
if: needs.changes.outputs.android_metadata == 'true'
uses: ./.github/workflows/real-android-metadata.yml
website:
needs: [changes, static]
if: needs.changes.outputs.website == 'true'
@@ -1252,8 +1329,10 @@ jobs:
web_runtime,
web_source_map,
agentenv,
go_binary,
nativeaot,
ghidra_bridge,
android_metadata,
website,
]
runs-on: ubuntu-24.04
+51 -2
View File
@@ -3,8 +3,32 @@ name: CodeQL production
on:
push:
branches: [main]
paths-ignore:
- "tests/**"
- "scripts/fixtures/**"
- "**/*.test.*"
- "**/*.fixture.*"
- "**/test_*.py"
- "**/*_test.py"
- "**/*.md"
- "**/*.mermaid"
- "**/*.csv"
- "licenses/**"
- ".git-blame-ignore-revs"
pull_request:
branches: [main]
paths-ignore:
- "tests/**"
- "scripts/fixtures/**"
- "**/*.test.*"
- "**/*.fixture.*"
- "**/test_*.py"
- "**/*_test.py"
- "**/*.md"
- "**/*.mermaid"
- "**/*.csv"
- "licenses/**"
- ".git-blame-ignore-revs"
schedule:
- cron: "37 5 * * 1"
workflow_dispatch:
@@ -18,10 +42,35 @@ concurrency:
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
analyze:
scope:
# A repository administrator must disable default setup before enabling
# this workflow; default setup rejects advanced CodeQL result uploads.
if: vars.REA_CODEQL_ADVANCED == 'true'
name: Select production languages
runs-on: ubuntu-24.04
timeout-minutes: 5
outputs:
run: ${{ steps.scope.outputs.run }}
languages: ${{ steps.scope.outputs.languages }}
steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
with:
fetch-depth: ${{ github.event_name == 'pull_request' && 0 || 1 }}
filter: blob:none
persist-credentials: false
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version-file: .nvmrc
- name: Select CodeQL languages
id: scope
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
run: node scripts/ci/codeql-scope.mjs >> "$GITHUB_OUTPUT"
analyze:
needs: scope
if: vars.REA_CODEQL_ADVANCED == 'true' && needs.scope.outputs.run == 'true'
name: Analyze production (${{ matrix.language }})
runs-on: ubuntu-latest
timeout-minutes: 45
@@ -32,7 +81,7 @@ jobs:
fail-fast: false
max-parallel: 1
matrix:
language: [javascript-typescript, python, actions]
language: ${{ fromJSON(needs.scope.outputs.languages) }}
steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
with:
@@ -1,28 +1,12 @@
name: Real Android metadata bridge
on:
push:
branches: ["**"]
paths:
- .github/workflows/real-android-metadata.yml
- bridge/android/**
- src/android/JadxRelease.ts
- scripts/fixtures/android/**
- tests/conformance/android/**
- tests/fixtures/android/static-initializers/**
- tests/fixtures/android/direct-invokes/**
- tests/fixtures/android/external-invokes/**
- .nvmrc
workflow_dispatch:
workflow_call:
permissions:
contents: read
concurrency:
group: android-metadata-${{ github.ref }}
cancel-in-progress: true
jobs:
android-metadata:
runs-on: ubuntu-24.04
+25 -23
View File
@@ -1,38 +1,37 @@
name: Real Go binary metadata
on:
workflow_call:
inputs:
build_cache_artifact:
description: Portable build cache artifact from the calling CI run.
required: false
type: string
default: ""
remote_cache_write:
description: Trusted release qualification may publish the remote cache.
required: false
type: boolean
default: false
secrets:
TURBO_TOKEN:
description: Remote cache token. Only trusted callers pass it.
required: false
workflow_dispatch:
pull_request:
paths:
- ".github/workflows/real-go-binary.yml"
- "src/go/**"
- "src/domain/go/**"
- "src/domain/dosMz.ts"
- "src/application/go/**"
- "src/contracts/go/**"
- "src/composition/go.ts"
- "src/cli/goCommands.ts"
- "src/server/contractToolBindings.ts"
- "src/server/serviceToolBindings.ts"
- "src/server/createServer.ts"
- "scripts/verify-go-binary.mjs"
- "scripts/lib/mcp-verifier-results.mjs"
permissions:
contents: read
concurrency:
group: real-go-binary-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
NODE_OPTIONS: --max-old-space-size=768
HUSKY: "0"
# Writes only on the default branch for push, schedule, manual dispatch,
# and workflow_call. Pull requests get an empty token and remote read-only mode.
TURBO_TOKEN: "${{ (github.ref == format('refs/heads/{0}', github.event.repository.default_branch) && (github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || github.event_name == 'workflow_call')) && secrets.TURBO_TOKEN || '' }}"
# A called workflow sees the caller event, so workflow_call is not an event
# name here. Writes when remote_cache_write is set, or on the default branch
# for push, schedule, and manual dispatch. Open pull requests stay empty-token
# and use the local cache only.
TURBO_TOKEN: "${{ (inputs.remote_cache_write == true || (github.ref == format('refs/heads/{0}', github.event.repository.default_branch) && (github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'))) && secrets.TURBO_TOKEN || '' }}"
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
TURBO_CACHE: "${{ (github.ref == format('refs/heads/{0}', github.event.repository.default_branch) && (github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || github.event_name == 'workflow_call')) && 'local:rw,remote:rw' || 'local:rw,remote:r' }}"
TURBO_CACHE: "${{ (inputs.remote_cache_write == true || (github.ref == format('refs/heads/{0}', github.event.repository.default_branch) && (github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'))) && 'local:rw,remote:rw' || 'local:rw' }}"
jobs:
real-go-binary:
@@ -51,5 +50,8 @@ jobs:
go-version: "1.26.1"
cache: false
- run: npm ci
- uses: ./.github/actions/portable-build-cache
with:
build_cache_artifact: ${{ inputs.build_cache_artifact }}
- name: Verify compiler-produced ELF, PE and Mach-O through public CLI and MCP
run: npm run verify:go:binary
+44 -20
View File
@@ -544,9 +544,14 @@ relying on the new scope. While the variable is unset, the existing default
setup continues scanning. Adding the configuration file alone does not change
default setup in this user-owned repository.
Pull-request scans are cancelled when superseded. Active scans on `main` finish
so frequent pushes cannot prevent a complete baseline from being uploaded.
Cancelled runs skip the SARIF artifact upload when no report was produced.
Pull-request scans are cancelled when superseded, skip pure test/prose diffs via
`paths-ignore`, and select only the CodeQL languages (`javascript-typescript`,
`python`, `actions`) whose production inputs changed (failing closed to all
three languages on shared CodeQL configuration or unclassified paths). Active
scans on `main`, weekly schedules, and manual dispatches always analyze all
three languages so frequent pushes cannot prevent a complete baseline from being
uploaded. Cancelled runs skip the SARIF artifact upload when no report was
produced.
Each analysis uses two threads and a 4096 MiB CodeQL memory budget; language
jobs run one at a time. Complete SARIF reports are retained for seven days.
@@ -1168,7 +1173,7 @@ or qualify the release revision for mutation coverage.
Fast CI starts the source-only projects after classification, independently of
build and static checks, and runs twelve built-dependent shards after the build.
Those thirteen test jobs still select every portable test. Full qualification keeps six
Those thirteen test jobs still select every portable test. Full qualification keeps twelve
complete Vitest shards with coverage. Neither tier retries tests. Canonical
project ownership lives in `scripts/lib/test-projects.mjs`, shared by Vitest,
CI group execution, and development-test preparation. A test importing compiled
@@ -1249,11 +1254,13 @@ separate and grows when more shard jobs compete for runners. The npm download
cache stays the setup cache rather than a shared `node_modules` artifact.
`process-boundary` stays serial because process-tree sampling shares the host.
Hosted CI jobs use four workers; other hosts stay at two
because they are shared with other checks. Full qualification keeps six covered
because they are shared with other checks. Full qualification keeps twelve covered
shards; its longer instrumentation is outside this fast budget.
The separate `CI timings` workflow batches recent completed CI and Release runs
hourly or on manual dispatch. It uploads `ci-job-timings-batch` with raw API pages and
every six hours or on manual dispatch, and snapshots pull-request CI health across
the preceding twelve hours using full ISO 8601 timestamps within a ten-page
(1,000-run) API budget. It uploads `ci-job-timings-batch` with raw API pages and
a normalized point-in-time report for each collected workflow attempt, plus a
batch manifest describing examined coverage, failures, and limits. Overlapping
lookback windows may collect an attempt again; identify records by run ID and
@@ -1283,9 +1290,18 @@ rebuilds misses. A restore prefix with the same platform and toolchain permits
partial task reuse when one generator's inputs change; Turbo still invalidates
that generator's entry. Native outputs are not stored in this cache.
Native package jobs, the Windows curated lane, and the Apple artifact lane reuse
the same workflow's Turbo cache for portable compiled JavaScript, skills, and
catalogs. The key parser retains the validated `test:prepare` task identities in
POSIX native package jobs, documentation checks, Go binary verification, and the
Apple artifact lane reuse the same workflow's portable Turbo cache
(`rea-build-cache`) for compiled JavaScript, skills, and catalogs. Windows jobs
(`windows-curated` and Windows `package-e2e`) compile with `typescript` rather
than Linux's accelerated `tsrs` checker, so they restore and publish a separate
Windows `.turbo/cache/` family (`rea-windows-build-v1-Windows-X64-*`, pruned to
two generations by `cache-retention.mjs`). `windows-native-build` caches
cross-compiled MinGW outputs keyed by source/fixture hashes, runner
`ImageOS`/`ImageVersion`, and UTC date (bounding lifetime to 24 hours so
upstream toolchain updates refresh daily) while running
`npm run verify:windows-native:artifact` unconditionally on every cache hit. The
key parser retains the validated `test:prepare` task identities in
`.cache/ci-build-plan.json`; staging reads this plan without starting another
Turbo run that could evict cache entries. The producer stages matching archives,
metadata, and available manifests into `.cache/ci-build-cache/`.
@@ -1355,24 +1371,32 @@ revision and selects:
fake provider process;
- tests whose text names a changed path.
Verifier scripts (`scripts/verify-*.mjs`, `scripts/verify/**/*.mjs`) are traced
like source modules. Changed Markdown outside `src/` and `tests/` selects only
the tests that name it. Declarations, guard baselines
(`scripts/verify/baselines/*.json`) and advertised-schema summaries select no
tests, because the static and build jobs check them.
Verifier scripts (`scripts/verify-*.mjs`, `scripts/verify/**/*.mjs`) and shared
script libraries (`scripts/lib/*`, when no untraced consumer imports or names
them) are traced like source modules. Changed Markdown, non-code `docs/` assets,
issue templates, `LICENSE`, and `licenses/` inventories outside `src/` and
`tests/` select only the tests that name them. Declarations, guard and layer
baselines (`scripts/verify/baselines/*.json`,
`scripts/lib/module-layers.baseline.json`), `.git-blame-ignore-revs`, Python
analysis-efficiency test scripts, and advertised-schema summaries select no
portable Vitest tests unless named by path, because static, Python, and build
jobs check them. Non-module CLI parity fixtures with a single known test suite
are bound in `EXPLICIT_FIXTURE_OWNERS` and fail closed if their owner is missing.
The PR falls back to the complete fast suite when it cannot decide:
- a shared boundary (`src/process/`, `src/filesystem/`, `src/contracts/tool*`,
`src/server/createServer*`, `src/cli.ts`, `scripts/ci/`) changed;
- a shared production boundary (`src/process/`, `src/filesystem/`,
`src/contracts/tool*`, `src/server/createServer*`, `src/cli.ts`,
`scripts/ci/`) changed;
- any other changed input is not traced, such as workflows, package metadata,
build and test-runner scripts, `scripts/lib/`, fixtures or data;
build and test-runner scripts, untraced `scripts/lib/` consumers, or unmapped
fixtures and data;
- no test is selected;
- more than 150 test files are selected;
- more than 400 test files are selected;
- a selected file has no single owning test project.
A selection runs as one `Test shard (k/n)` job per group of up to 40 files, at
most four jobs, using exact file identity (`scripts/ci/test-group.mjs selected`).
A selection runs as one `Test shard (k/n)` job per group of up to 50 files, at
most eight jobs, using exact file identity (`scripts/ci/test-group.mjs selected`).
The separate `Source tests` job does not run, because the groups include the
selected source tests. The `Classify changes` summary gives the mode and its
reason.
+5
View File
@@ -18,6 +18,7 @@ const PREFIX_PATTERNS = [
/^rea-static-v1-[A-Za-z0-9]+-[A-Za-z0-9]+-$/u,
/^rea-static-deep-v1-[A-Za-z0-9]+-[A-Za-z0-9]+-$/u,
/^rea-portable-build-v2-[A-Za-z0-9]+-[A-Za-z0-9]+-$/u,
/^rea-windows-build-v1-[A-Za-z0-9]+-[A-Za-z0-9]+-$/u,
/^knip-meta-v1-[A-Za-z0-9]+-$/u,
];
@@ -272,6 +273,10 @@ function familiesFromEnv(env) {
env.CACHE_PORTABLE_PREFIX.length > 0
? { prefix: env.CACHE_PORTABLE_PREFIX }
: undefined,
typeof env.CACHE_WINDOWS_BUILD_PREFIX === "string" &&
env.CACHE_WINDOWS_BUILD_PREFIX.length > 0
? { prefix: env.CACHE_WINDOWS_BUILD_PREFIX }
: undefined,
].filter((family) => family !== undefined);
if (families.length === 0 && env.DEDUPE_NPM_DOWNLOADS !== "true")
throw new Error(
+12
View File
@@ -22,6 +22,7 @@ const GUARDED_WORKFLOWS = new Set([
".github/workflows/real-ghidra-windows.yml",
".github/workflows/sqlite-runtime.yml",
".github/workflows/ci-timings.yml",
".github/workflows/cache-retention.yml",
".github/workflows/mutation.yml",
]);
// Sources compiled by build-conformance-fixtures.mjs. The readiness journey
@@ -189,6 +190,17 @@ export function planChanges(request, repository) {
selected[owner] = true;
// The documentation check scans living prose outside docs/ too.
if (isLivingProsePath(file)) selected.docs = true;
if (file === ".git-blame-ignore-revs") return;
if (
file.startsWith("licenses/") ||
file === "THIRD_PARTY_NOTICES.md" ||
file === "DISCLAIMER.md" ||
file === "LICENSE"
) {
selected.docs = true;
selected.code = true;
return;
}
if (
/^(README(?:_[^/]+)?\.md|AGENTS\.md|CONTRIBUTING\.md|CHANGELOG\.md|SECURITY\.md|native\/windows\/README\.md|\.github\/pull_request_template\.md)$/.test(
file,
+25
View File
@@ -0,0 +1,25 @@
export type CodeqlLanguage = "javascript-typescript" | "python" | "actions";
export interface CodeqlScopeRequest {
readonly event: string | undefined;
readonly base: string | undefined;
readonly head: string | undefined;
}
export interface CodeqlScopeRepository {
readonly mergeBase: (base: string, head: string) => string;
readonly changedFiles: (base: string, head: string) => readonly string[];
}
export interface CodeqlScopePlan {
readonly run: boolean;
readonly languages: readonly CodeqlLanguage[];
readonly reason: string;
}
export const CODEQL_LANGUAGES: readonly CodeqlLanguage[];
export function planCodeqlLanguages(
request: CodeqlScopeRequest,
repository: CodeqlScopeRepository,
): CodeqlScopePlan;
+169
View File
@@ -0,0 +1,169 @@
import { execFileSync } from "node:child_process";
import { matchesGlob } from "node:path";
import { pathToFileURL } from "node:url";
/** @type {readonly import("./codeql-scope.d.mts").CodeqlLanguage[]} */
export const CODEQL_LANGUAGES = ["javascript-typescript", "python", "actions"];
// Inputs excluded by .github/codeql/production.yml plus pure prose, assets, and
// source languages outside CodeQL's javascript-typescript/python/actions extractors.
const EXCLUDED_PATTERNS = [
"tests/**",
"scripts/fixtures/**",
"**/*.test.*",
"**/*.fixture.*",
"**/test_*.py",
"**/*_test.py",
"**/*.md",
"**/*.mermaid",
"**/*.csv",
"licenses/**",
"LICENSE",
".git-blame-ignore-revs",
"website/locales/**/*.po",
"website/locales/**/*.pot",
"**/*.{png,jpg,jpeg,gif,svg,ico,webp}",
"bridge/**/*.{java,swift}",
"native/windows/**/*.{cc,cpp,c,h,hpp}",
"**/*.{go,sol,rs}",
];
const isExcludedFromCodeql = (file) =>
!file.startsWith("docs/.vitepress/") &&
EXCLUDED_PATTERNS.some((pattern) => matchesGlob(file, pattern));
const isActionsInput = (file) =>
/^\.github\/workflows\/[^/]+\.ya?ml$/u.test(file) ||
/^\.github\/actions\/.+\/action\.ya?ml$/u.test(file);
const isPythonInput = (file) => file.endsWith(".py");
const isJavaScriptTypeScriptInput = (file) =>
file.startsWith("docs/.vitepress/") ||
file === ".npmrc" ||
file === ".nvmrc" ||
/\.(?:[cm]?[jt]s|[jt]sx|html?|xhtml|vue|jsonc?)$/u.test(file);
/**
* Select the CodeQL languages required for one event. Non-PR baselines and any
* unrecognized or scan-configuration inputs select all configured languages.
*
* @param {import("./codeql-scope.d.mts").CodeqlScopeRequest} request
* @param {import("./codeql-scope.d.mts").CodeqlScopeRepository} repository
* @returns {import("./codeql-scope.d.mts").CodeqlScopePlan}
*/
export function planCodeqlLanguages(request, repository) {
if (request.event !== "pull_request") {
return {
run: true,
languages: [...CODEQL_LANGUAGES],
reason: `Complete CodeQL baseline for ${request.event ?? "unknown"} event`,
};
}
const { base, head } = request;
if (
!base ||
!head ||
!/^[0-9a-f]{40}$/iu.test(base) ||
!/^[0-9a-f]{40}$/iu.test(head)
) {
return {
run: true,
languages: [...CODEQL_LANGUAGES],
reason: "Missing or invalid pull-request revision; running all languages",
};
}
let files;
try {
const mergeBase = repository.mergeBase(base, head);
files = repository.changedFiles(mergeBase, head);
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
return {
run: true,
languages: [...CODEQL_LANGUAGES],
reason: `Git diff failed (${message}); running all languages`,
};
}
/** @type {Set<import("./codeql-scope.d.mts").CodeqlLanguage>} */
const selected = new Set();
for (const file of files) {
if (
file.startsWith(".github/codeql/") ||
file === ".github/workflows/codeql.yml"
) {
return {
run: true,
languages: [...CODEQL_LANGUAGES],
reason: `CodeQL configuration changed: ${file}`,
};
}
if (isExcludedFromCodeql(file)) continue;
let matched = false;
if (isActionsInput(file)) {
selected.add("actions");
matched = true;
}
if (isPythonInput(file)) {
selected.add("python");
matched = true;
}
if (isJavaScriptTypeScriptInput(file)) {
selected.add("javascript-typescript");
matched = true;
}
if (!matched) {
return {
run: true,
languages: [...CODEQL_LANGUAGES],
reason: `Unclassified input selects all CodeQL languages: ${file}`,
};
}
}
const languages = CODEQL_LANGUAGES.filter((language) =>
selected.has(language),
);
return {
run: languages.length > 0,
languages,
reason:
languages.length > 0
? `Selected CodeQL languages: ${languages.join(", ")}`
: "No CodeQL-extracted production files changed",
};
}
function gitCodeqlRepository(cwd = process.cwd()) {
const git = (args) =>
execFileSync("git", args, {
cwd,
encoding: "utf8",
maxBuffer: 16 * 1024 * 1024,
});
return {
mergeBase: (base, head) => git(["merge-base", base, head]).trim(),
changedFiles: (base, head) =>
git(["diff", "--name-only", "-z", "--no-renames", `${base}..${head}`])
.split("\0")
.filter(Boolean),
};
}
if (
process.argv[1] &&
import.meta.url === pathToFileURL(process.argv[1]).href
) {
const plan = planCodeqlLanguages(
{
event: process.env.GITHUB_EVENT_NAME,
base: process.env.BASE_SHA,
head: process.env.HEAD_SHA,
},
gitCodeqlRepository(),
);
process.stderr.write(`CodeQL language selection: ${plan.reason}\n`);
process.stdout.write(
`run=${String(plan.run)}\nlanguages=${JSON.stringify(plan.languages)}\n`,
);
}
+1 -1
View File
@@ -39,7 +39,7 @@ export async function collectJobTimingsBatch({
status: "completed",
createdAfter: cutoff,
lookbackHours: 24,
overlap: "Each hourly run re-reads the preceding 24 hours.",
overlap: "Each scheduled run re-reads the preceding 24 hours.",
pagination:
"Run listings use the first 100; jobs are paginated within the remaining time and 16 MiB response limits.",
maxRunsPerWorkflow: MAX_RUNS_PER_WORKFLOW,
+2
View File
@@ -45,6 +45,7 @@ export interface PrCiHealthReport {
repositoryId: number | null;
defaultBranch: string;
lookbackDays: number;
lookbackHours?: number;
scan: {
status: "complete" | "partial";
cutoff: string;
@@ -67,6 +68,7 @@ export function collectPrCiHealth(options: {
repositoryId?: number | string | null;
defaultBranch: string;
lookbackDays?: number;
lookbackHours?: number;
now?: number;
apiRequest?: GitHubApiRequest;
}): Promise<PrCiHealthReport>;
+30 -11
View File
@@ -7,12 +7,13 @@ import { createGhApiRequest } from "./github-api.mjs";
const OUTPUT_DIRECTORY = join(".cache", "ci-pr-health");
const PAGE_SIZE = 100;
const MAX_PULL_REQUEST_PAGES = 3;
const MAX_WORKFLOW_RUN_PAGES = 5;
const MAX_WORKFLOW_RUN_PAGES = 10;
const MAX_PULL_REQUEST_DETAILS = 40;
const MAX_API_REQUESTS =
MAX_PULL_REQUEST_PAGES + MAX_WORKFLOW_RUN_PAGES + MAX_PULL_REQUEST_DETAILS;
const LOOKBACK_DAYS = 14;
const LOOKBACK_HOURS = 12;
const MAX_LOOKBACK_DAYS = 30;
const MAX_LOOKBACK_HOURS = MAX_LOOKBACK_DAYS * 24;
const MAX_TOTAL_TIME_MS = 60_000;
const SHA_PATTERN = /^[0-9a-f]{40}$/iu;
const COMPLETED_CATEGORIES = new Map([
@@ -27,7 +28,8 @@ export async function collectPrCiHealth({
repository,
repositoryId,
defaultBranch,
lookbackDays = LOOKBACK_DAYS,
lookbackDays,
lookbackHours,
now = Date.now(),
apiRequest = createGhApiRequest(),
}) {
@@ -36,10 +38,11 @@ export async function collectPrCiHealth({
repositoryId,
defaultBranch,
lookbackDays,
lookbackHours,
now,
});
const observedAt = new Date(now).toISOString();
const cutoff = now - identity.lookbackDays * 24 * 60 * 60 * 1_000;
const cutoff = now - identity.lookbackHours * 60 * 60 * 1_000;
const snapshot = await collectApiSnapshot({ apiRequest, identity, cutoff });
const classified = classifyPullRequests(snapshot);
const { pulls, runs, budget } = snapshot;
@@ -53,6 +56,7 @@ export async function collectPrCiHealth({
repositoryId: identity.repositoryId,
defaultBranch: identity.defaultBranch,
lookbackDays: identity.lookbackDays,
lookbackHours: identity.lookbackHours,
scan: {
status:
errors.length === 0 && pulls.complete && runs.complete
@@ -518,8 +522,8 @@ async function listRecentWorkflowRuns({ requestGet, identity, cutoff }) {
let error = null;
for (let page = 1; page <= MAX_WORKFLOW_RUN_PAGES; page += 1) {
try {
const cutoffDate = new Date(cutoff).toISOString().slice(0, 10);
const endpoint = `repos/${identity.repository}/actions/workflows/ci.yml/runs?event=pull_request&created=%3E%3D${cutoffDate}&per_page=${PAGE_SIZE}&page=${page}`;
const cutoffIso = new Date(cutoff).toISOString();
const endpoint = `repos/${identity.repository}/actions/workflows/ci.yml/runs?event=pull_request&created=%3E%3D${encodeURIComponent(cutoffIso)}&per_page=${PAGE_SIZE}&page=${page}`;
const response = await requestGet(endpoint);
if (!isRecord(response) || !Array.isArray(response.workflow_runs))
throw new Error("workflow_run_page_malformed");
@@ -576,6 +580,7 @@ function validateInputs({
repositoryId,
defaultBranch,
lookbackDays,
lookbackHours,
now,
}) {
if (
@@ -603,19 +608,33 @@ function validateInputs({
)
throw new Error("CI_REPOSITORY_ID must be a positive safe integer");
if (
!Number.isInteger(lookbackDays) ||
lookbackDays < 1 ||
lookbackDays > MAX_LOOKBACK_DAYS
lookbackDays !== undefined &&
(!Number.isInteger(lookbackDays) ||
lookbackDays < 1 ||
lookbackDays > MAX_LOOKBACK_DAYS)
)
throw new Error(
`lookbackDays must be an integer from 1 to ${String(MAX_LOOKBACK_DAYS)}`,
);
if (
lookbackHours !== undefined &&
(!Number.isInteger(lookbackHours) ||
lookbackHours < 1 ||
lookbackHours > MAX_LOOKBACK_HOURS)
)
throw new Error(
`lookbackHours must be an integer from 1 to ${String(MAX_LOOKBACK_HOURS)}`,
);
const resolvedHours =
lookbackHours ??
(lookbackDays !== undefined ? lookbackDays * 24 : LOOKBACK_HOURS);
if (!Number.isFinite(now)) throw new Error("now must be a finite timestamp");
return {
repository,
repositoryId: parsedRepositoryId,
defaultBranch,
lookbackDays,
lookbackDays: resolvedHours / 24,
lookbackHours: resolvedHours,
};
}
@@ -664,7 +683,7 @@ function renderMarkdownSummary(report) {
return [
"# Pull request CI health snapshot",
"",
`Observed ${report.observedAt} for \`${report.repository}\`, target branch \`${escapeCell(report.defaultBranch)}\`; recent window ${String(report.lookbackDays)} days. Scan: **${report.scan.status}**.`,
`Observed ${report.observedAt} for \`${report.repository}\`, target branch \`${escapeCell(report.defaultBranch)}\`; recent window ${String(report.lookbackHours ?? report.lookbackDays * 24)} hours. Scan: **${report.scan.status}**.`,
"",
"This is read-only point-in-time telemetry. Missing is reported only when PR and workflow-run inventories are complete and the current immutable PR head identity is unambiguous. Incomplete lookups remain deferred or unknown.",
"",
+31
View File
@@ -682,6 +682,31 @@ const PATH_SCOPES = {
"tests/conformance/ghidra/loader-relocation*.c",
".github/workflows/ghidra-bridge-sources.yml",
],
go_binary: [
".github/workflows/real-go-binary.yml",
"src/go/**",
"src/domain/go/**",
"src/domain/dosMz.ts",
"src/application/go/**",
"src/contracts/go/**",
"src/composition/go.ts",
"src/cli/goCommands.ts",
"src/server/contractToolBindings.ts",
"src/server/serviceToolBindings.ts",
"src/server/createServer.ts",
"scripts/verify-go-binary.mjs",
"scripts/lib/mcp-verifier-results.mjs",
],
android_metadata: [
".github/workflows/real-android-metadata.yml",
"bridge/android/**",
"src/android/JadxRelease.ts",
"scripts/fixtures/android/**",
"tests/conformance/android/**",
"tests/fixtures/android/static-initializers/**",
"tests/fixtures/android/direct-invokes/**",
"tests/fixtures/android/external-invokes/**",
],
website: [
"website/**",
"scripts/*website*.py",
@@ -754,6 +779,12 @@ export const CI_LANES = {
agentenv: sameJobs(PATH_SCOPES.agentenv, ["agentenv"]),
nativeaot: sameJobs(PATH_SCOPES.nativeaot, ["nativeaot"]),
ghidra_bridge: sameJobs(PATH_SCOPES.ghidra_bridge, ["ghidra_bridge"]),
go_binary: sameJobs(PATH_SCOPES.go_binary, ["go_binary"]),
android_metadata: sameJobs(
PATH_SCOPES.android_metadata,
["android_metadata"],
{ testInputs: true },
),
website: sameJobs(PATH_SCOPES.website, ["website"], {
earlyInputs: [".agents/skills/reverse-engineer-anything/**"],
}),
+76 -23
View File
@@ -9,12 +9,12 @@ import { SHARED_BOUNDARY } from "./scopes.mjs";
// Selection falls back to the complete suite whenever it cannot decide.
/** More selected files than this run the complete suite instead. */
const SELECTION_CAP = 150;
const SELECTION_CAP = 400;
// Selected files per test job, and the most jobs one selection uses. Each job
// runs one `--shard` of the selection; the CI sequencer balances the shards by
// main's recorded per-file durations when that history is available.
const FILES_PER_SHARD = 40;
const MAX_SHARDS = 4;
const FILES_PER_SHARD = 50;
const MAX_SHARDS = 8;
// Leaf adapters whose tests also reach their sources through the built CLI,
// MCP server or a fake provider process rather than an import. An adapter
@@ -51,13 +51,33 @@ const isPresentationOwner = (path) =>
// paths (package subpaths such as `ajv/dist/2020.js`, fixture apps) are not.
const LAUNCHES_BUILT_RUNTIME =
/scripts\/rea\.mjs|\bdist\/(?:main|cli)\.js|["'`]dist["'`]\s*,\s*["'`](?:main|cli)\.js/u;
// Inputs that only a non-test check reads: declarations (typecheck), guard
// baselines (architecture guards, static job) and the advertised-schema
// summaries (build job). They select no tests.
// Inputs that only a non-test check reads: declarations (typecheck), guard and
// layer baselines (architecture/boundary guards, static job), git-blame ignore
// revisions, and the advertised-schema summaries (build job). Any test that
// directly names one by path still runs via `names`.
const isCheckerInput = (path) =>
/\.d\.m?ts$/u.test(path) ||
path === "scripts/lib/module-layers.baseline.json" ||
path === ".git-blame-ignore-revs" ||
path === "scripts/run-python-tests.py" ||
/^tests\/support\/analysis-efficiency\/.+\.py$/u.test(path) ||
/^scripts\/verify\/baselines\/[^/]+\.json$/u.test(path) ||
/^scripts\/verify\/advertised-schemas\/tools\/[^/]+\.json$/u.test(path);
// Non-module fixtures with a single known owning test suite.
const EXPLICIT_FIXTURE_OWNERS = [
[
"tests/fixtures/cli-parity/*.txt",
"tests/boundary/cli/cliParityGoldens.test.ts",
],
[
"tests/boundary/cli/cliContractSchemaParity.uncomparable.json",
"tests/boundary/cli/cliContractSchemaParity.test.ts",
],
];
const explicitFixtureOwners = (path) =>
EXPLICIT_FIXTURE_OWNERS.filter(([pattern]) => matchesGlob(path, pattern)).map(
([, owner]) => owner,
);
// Verifier scripts are imported by their tests like source modules.
const isVerifier = (path) =>
/^scripts\/(verify-[^/]+|verify\/.+)\.mjs$/u.test(path);
@@ -80,24 +100,40 @@ const isHelper = (path) =>
/^src\/.+\.fixture[^/]*\.ts$/u.test(path) ||
isVerifier(path) ||
isScriptLibrary(path));
const STATIC_CHECKER_CONFIG =
/^(?:tsconfig(?:\..+)?\.json|\.oxlintrc\.json|\.oxfmtrc\.json|\.jscpd\.json|knip\.json|stryker(?:\..+)?\.config\.mjs)$/u;
// Files outside src/ and tests/ that can run or load a shared script module:
// other scripts, root configuration, package metadata, hooks and workflows.
// other scripts, runtime/test configuration, package metadata, hooks and workflows.
const isScriptConsumer = (path) =>
!isHelper(path) &&
!isCheckerInput(path) &&
!STATIC_CHECKER_CONFIG.test(path) &&
!path.startsWith(".github/ISSUE_TEMPLATE/") &&
(/^scripts\/.+\.(?:m?[jt]s|cjs)$/u.test(path) ||
(/^[^/]+\.(?:m?[jt]s|cjs|json)$/u.test(path) &&
path !== "package-lock.json") ||
/^\.github\/.+\.ya?ml$/u.test(path) ||
/^\.husky\/[^/]+$/u.test(path));
// Prose that tests may read by path. Other non-module inputs (fixtures, data,
// scripts, workflows, package metadata) are not traced, so they run everything.
const isProse = (path) => path.endsWith(".md") && !/^(src|tests)\//u.test(path);
const DOCS_CODE = /\.(?:[cm]?[jt]s|[jt]sx)$/u;
// Prose and documentation/license metadata that tests may read by path. Other
// non-module inputs (unmapped fixtures, data, scripts, workflows, package
// metadata) are not traced, so they run everything.
const isProse = (path) =>
path === "LICENSE" ||
path.startsWith(".github/ISSUE_TEMPLATE/") ||
(path.endsWith(".md") && !/^(src|tests)\//u.test(path)) ||
(path.startsWith("docs/") &&
!DOCS_CODE.test(path) &&
!path.endsWith("/package.json")) ||
path.startsWith("licenses/");
/** Why a changed path cannot be traced to tests, if it cannot. */
const untracedInput = (path) =>
SHARED_BOUNDARY.test(path)
!isTest(path) && SHARED_BOUNDARY.test(path)
? `Shared boundary: ${path}`
: !isModule(path) && !isProse(path) && !isCheckerInput(path)
: !isModule(path) &&
!isProse(path) &&
!isCheckerInput(path) &&
explicitFixtureOwners(path).length === 0
? `Input is not traced to tests: ${path}`
: undefined;
@@ -145,7 +181,14 @@ export function traceAffectedTests({ files, snapshot }) {
const changedModules = files.filter(
(path) => isModule(path) && !isTest(path),
);
for (const path of files) if (isTest(path)) select(path, "changed");
for (const path of files) {
if (isTest(path)) select(path, "changed");
for (const owner of explicitFixtureOwners(path)) {
if (!trackedSet.has(owner))
untraced.push(`Missing test owner ${owner} for ${path}`);
else select(owner, "owner");
}
}
// A seed and every helper that imports it, directly or through another.
const throughHelpers = (seed) => {
@@ -196,7 +239,15 @@ export function traceAffectedTests({ files, snapshot }) {
}
// A shared script module that another script, configuration file, hook or
// workflow imports or names by file name can shape every run.
// workflow imports or names as a standalone file name can shape every run.
// Require a token boundary before the basename so `verify-module-boundaries.mjs`
// in package.json does not falsely match `scripts/lib/module-boundaries.mjs`.
const namesScriptBasename = (source, libraryPath) => {
const escaped = posix
.basename(libraryPath)
.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
return new RegExp(`(?<![\\w-])${escaped}(?![\\w.-])`, "u").test(source);
};
const libraries = [...affected].filter(isScriptLibrary);
if (libraries.length) {
const consumers = tracked.filter(isScriptConsumer);
@@ -205,7 +256,10 @@ export function traceAffectedTests({ files, snapshot }) {
const source = consumerSources.get(consumer) ?? "";
const targets = new Set(importsOf(consumer, source));
const library = libraries.find(
(path) => targets.has(path) || source.includes(posix.basename(path)),
(path) =>
targets.has(path) ||
(consumer !== "scripts/ci/scopes.mjs" &&
namesScriptBasename(source, path)),
);
if (library !== undefined)
untraced.push(
@@ -336,15 +390,14 @@ export function parseTestSelection(value) {
return plan;
}
// Fast feedback uses one source group and twelve built groups. Shards are
// balanced by recorded duration, but hosted runner speed varies, so the
// slowest shard sets the critical path: at eight shards it ran 24% above the
// mean shard. Smaller shards bound that excess at a few percent more runner
// time. Full qualification retains six complete shards with coverage. A
// selection runs its own shard count.
// Fast feedback uses one source group and twelve built groups; full
// qualification uses twelve complete shards with coverage. Shards are balanced
// by recorded duration, and twelve shards halve the full-qualification critical
// path (~14.5m -> ~7.5m) while bounding runner-speed variance at negligible
// extra setup (~22s/shard). A selection runs its own shard count.
const shardsOf = (count) =>
Array.from({ length: count }, (_, index) => `${index + 1}/${count}`);
/** The `test-shard` matrix labels for a tier and its test selection. */
export const testShards = (tier, plan) =>
shardsOf(plan.mode === "selected" ? plan.shards : tier === "full" ? 6 : 12);
export const testShards = (_tier, plan) =>
shardsOf(plan.mode === "selected" ? plan.shards : 12);
@@ -64,9 +64,7 @@ const assertRetentionPolicy = (expression: string): void => {
repositoryName === currentRepository &&
branch === defaultBranch &&
["push", "schedule", "workflow_dispatch"].includes(event) &&
["success", "failure", "timed_out", "cancelled"].includes(
conclusion,
);
["success", "failure", "timed_out"].includes(conclusion);
expect(
evaluatePolicy(expression, {
github: {
@@ -556,6 +554,7 @@ it("deletes superseded caches only from the trusted follow-up workflow", async (
workflow_run: z.object({
workflows: z.array(z.literal("CI")),
types: z.array(z.literal("completed")),
branches: z.array(z.literal("main")),
}),
workflow_call: z.unknown().optional(),
pull_request: z.unknown().optional(),
@@ -605,7 +604,6 @@ it("deletes superseded caches only from the trusted follow-up workflow", async (
"persist-credentials": false,
});
expect(checkouts).toHaveLength(2);
expect(steps.some((step) => step.run === "npm ci")).toBe(false);
const setupNode = steps.find(
(step) =>
step.uses ===
@@ -635,6 +633,9 @@ it("deletes superseded caches only from the trusted follow-up workflow", async (
expect(retentionEnv.CACHE_PORTABLE_PREFIX).toBe(
"rea-portable-build-v2-${{ runner.os }}-${{ runner.arch }}-",
);
expect(retentionEnv.CACHE_WINDOWS_BUILD_PREFIX).toBe(
"rea-windows-build-v1-Windows-X64-",
);
expect(retentionEnv.DEDUPE_NPM_DOWNLOADS).toBe("true");
expect(retentionEnv.GH_TOKEN).toBe("${{ github.token }}");
@@ -667,6 +668,14 @@ it("deletes superseded caches only from the trusted follow-up workflow", async (
expect(retentionEnv.CACHE_KNIP_PREFIX).toBe(knipPrefix);
expect(retentionEnv.CACHE_KNIP_KEEP_KEY).toBe(targetSourceKey("knip-cache"));
expect(publishedKey("knip-cache").startsWith(knipPrefix)).toBe(true);
const windowsNativeSteps =
ci?.workflow.jobs?.["windows-native-build"]?.steps ?? [];
const windowsNativeKey = windowsNativeSteps.find(
(step) => step.id === "windows-native-key",
);
expect(String(windowsNativeKey?.run)).toContain("ImageOS");
expect(String(windowsNativeKey?.run)).toContain("ImageVersion");
expect(String(windowsNativeKey?.run)).toContain("date -u +%Y-%m-%d");
});
it("publishes each hosted npm download cache from one writer", async () => {
@@ -89,8 +89,9 @@ describe("Turbo snapshot retention", () => {
).toEqual([4]);
});
it("retains the newest portable snapshots without a caller keep key", () => {
it("retains the newest portable and Windows build snapshots without a caller keep key", () => {
const portable = "rea-portable-build-v2-Linux-X64-";
const windowsBuild = "rea-windows-build-v1-Windows-X64-";
const deletions = selectPrefixDeletions(
[
cache(7, `${portable}one`, "2026-10-20T01:00:00Z"),
@@ -100,6 +101,16 @@ describe("Turbo snapshot retention", () => {
{ prefix: portable },
);
expect(deletions.map((entry) => entry.id)).toEqual([7]);
expect(
selectPrefixDeletions(
[
cache(10, `${windowsBuild}one`, "2026-10-20T01:00:00Z"),
cache(11, `${windowsBuild}two`, "2026-10-20T02:00:00Z"),
cache(12, `${windowsBuild}three`, "2026-10-20T03:00:00Z"),
],
{ prefix: windowsBuild },
).map((entry) => entry.id),
).toEqual([10]);
});
it("refuses prefixes and lists that can reach download caches", () => {
@@ -258,6 +258,14 @@ it.each([
["src/ports/apkSignature/ApkSignaturePort.ts", "apk_signature"],
["src/ports/javascript/JavaScriptRecoveryPort.ts", "javascript_recovery"],
["src/ports/WebRuntimePort.ts", "web_runtime"],
["src/go/GoBinaryProvider.ts", "go_binary"],
["scripts/verify-go-binary.mjs", "go_binary"],
["bridge/android/ReaJadxBridge.java", "android_metadata"],
["src/android/JadxRelease.ts", "android_metadata"],
[
"tests/conformance/android/ReaJadxMetadataRegression.java",
"android_metadata",
],
["src/ports/WebSourceLocationPorts.ts", "web_source_map"],
["src/ports/captures/PacketCapturePort.ts", "packet_capture"],
["src/ports/signals/SignalRecordingPort.ts", "signal_recording"],
@@ -470,7 +478,7 @@ it("selects the tests a pull request affects and runs everything when it cannot
await runPlanScript(directory, base, head, "pull_request", true),
).toMatchObject({
testSelection: { version: 3, mode: "full" },
testShards: ["1/6", "2/6", "3/6", "4/6", "5/6", "6/6"],
testShards: expect.arrayContaining(["12/12"]),
});
expect(await classify(directory, base, head, "push")).toMatchObject({
testSelection: { mode: "full" },
@@ -506,14 +514,14 @@ it("selects the tests a pull request affects and runs everything when it cannot
});
// Above the cap, selection gives way to the complete suite.
const many = Array.from(
{ length: 151 },
{ length: 401 },
(_, index) => `tests/composition/many${String(index)}.test.ts`,
);
const wide = await change(directory, many);
expect(await classify(directory, isolated, wide)).toMatchObject({
testSelection: {
mode: "full",
reason: "151 affected test files exceed the 150-file selection cap",
reason: "401 affected test files exceed the 400-file selection cap",
},
});
const capped = await change(directory, many.slice(0, 81), "// edited\n");
@@ -523,6 +531,33 @@ it("selects the tests a pull request affects and runs everything when it cannot
});
});
it("routes license inventories to docs checks and keeps blame-ignore edits formatting-only", async () => {
expect(await classifyPaths([".git-blame-ignore-revs"])).toMatchObject({
code: false,
docs: false,
runtime: false,
package: false,
});
expect(await classifyPaths(["licenses/npm-dependencies.txt"])).toMatchObject({
code: true,
docs: true,
runtime: false,
package: false,
});
expect(await classifyPaths(["THIRD_PARTY_NOTICES.md"])).toMatchObject({
code: true,
docs: true,
runtime: false,
package: false,
});
expect(await classifyPaths(["LICENSE"])).toMatchObject({
code: true,
docs: true,
runtime: false,
package: false,
});
});
it("passes the workflow environment through the entrypoint unchanged", async () => {
const { directory, base } = await fixture();
const head = await change(directory, ["src/evm/Example.ts"]);
+160 -40
View File
@@ -3,6 +3,10 @@ import { matchesGlob } from "node:path";
import { expect, it } from "vitest";
import { parse } from "yaml";
import { z } from "zod";
import {
CODEQL_LANGUAGES,
planCodeqlLanguages,
} from "../../../scripts/ci/codeql-scope.mjs";
const github = new URL("../../../.github/", import.meta.url);
const configuration = z
@@ -16,14 +20,77 @@ const configuration = z
parse(await readFile(new URL("codeql/production.yml", github), "utf8")),
);
const excluded = (path: string): boolean =>
configuration["paths-ignore"].some(
const triggerPathsSchema = z.object({
branches: z.array(z.string()),
"paths-ignore": z.array(z.string()),
});
const workflowDocument = z
.object({
on: z.object({
push: triggerPathsSchema,
pull_request: triggerPathsSchema,
schedule: z.array(z.object({ cron: z.string() })),
workflow_dispatch: z.unknown(),
}),
permissions: z.object({ contents: z.literal("read") }),
concurrency: z.object({
"cancel-in-progress": z.string(),
}),
jobs: z.object({
scope: z.object({
if: z.string(),
outputs: z.object({
run: z.string(),
languages: z.string(),
}),
steps: z.array(
z.object({
id: z.string().optional(),
uses: z.string().optional(),
run: z.string().optional(),
with: z.record(z.string(), z.unknown()).optional(),
}),
),
}),
analyze: z.object({
needs: z.literal("scope"),
if: z.string(),
permissions: z.object({
contents: z.literal("read"),
"security-events": z.literal("write"),
}),
strategy: z.object({
"max-parallel": z.literal(1),
matrix: z.object({ language: z.string() }),
}),
steps: z.array(
z.object({
uses: z.string(),
with: z.record(z.string(), z.unknown()).optional(),
}),
),
}),
}),
})
.parse(
parse(await readFile(new URL("workflows/codeql.yml", github), "utf8")),
);
const matchesPatterns = (path: string, patterns: readonly string[]): boolean =>
patterns.some(
(pattern) =>
path === pattern ||
path.startsWith(`${pattern}/`) ||
matchesGlob(path, pattern),
);
const excluded = (path: string): boolean =>
matchesPatterns(path, configuration["paths-ignore"]);
const triggerIgnored = (path: string): boolean =>
matchesPatterns(path, workflowDocument.on.push["paths-ignore"]) ||
matchesPatterns(path, workflowDocument.on.pull_request["paths-ignore"]);
it.each([
"tests/fixtures/fakeHopper.mjs",
"tests/conformance/ghidra/riscv-checks.mjs",
@@ -37,6 +104,7 @@ it.each([
"bridge/example_test.py",
])("excludes test-only input %s", (path) => {
expect(excluded(path)).toBe(true);
expect(triggerIgnored(path)).toBe(true);
});
it.each([
@@ -60,6 +128,7 @@ it.each([
".github/actions/publish-mcp/action.yml",
])("retains production or release input %s", (path) => {
expect(excluded(path)).toBe(false);
expect(triggerIgnored(path)).toBe(false);
});
it("retains all packaged entrypoints and the existing local-input threat model", async () => {
@@ -74,6 +143,12 @@ it("retains all packaged entrypoints and the existing local-input threat model",
),
);
expect(manifest.files.filter(excluded)).toEqual([]);
// Non-prose packaged files remain active triggers on main and pull requests.
expect(
manifest.files
.filter((path) => !path.endsWith(".md"))
.filter(triggerIgnored),
).toEqual([]);
expect(configuration["threat-models"]).toEqual(["local"]);
// A narrow allowlist would silently drop new production roots. Explicitly
// traverse the hidden configuration directory without excluding the root.
@@ -81,46 +156,23 @@ it("retains all packaged entrypoints and the existing local-input threat model",
expect(configuration.paths).toContain("docs/.vitepress");
});
it("uses the scope in a bounded workflow gated on administrator activation", async () => {
const workflow = z
.object({
permissions: z.object({ contents: z.literal("read") }),
concurrency: z.object({
"cancel-in-progress": z.string(),
}),
jobs: z.object({
analyze: z.object({
if: z.string(),
permissions: z.object({
contents: z.literal("read"),
"security-events": z.literal("write"),
}),
strategy: z.object({
"max-parallel": z.literal(1),
matrix: z.object({ language: z.array(z.string()) }),
}),
steps: z.array(
z.object({
uses: z.string(),
with: z.record(z.string(), z.unknown()).optional(),
}),
),
}),
}),
})
.parse(
parse(await readFile(new URL("workflows/codeql.yml", github), "utf8")),
);
expect(workflow.concurrency["cancel-in-progress"]).toBe(
it("uses the scope in a bounded workflow gated on administrator activation", () => {
expect(workflowDocument.concurrency["cancel-in-progress"]).toBe(
"${{ github.event_name == 'pull_request' }}",
);
const job = workflow.jobs.analyze;
expect(job.if).toBe("vars.REA_CODEQL_ADVANCED == 'true'");
expect(job.strategy.matrix.language).toEqual([
"javascript-typescript",
"python",
"actions",
]);
expect(workflowDocument.on.push["paths-ignore"]).toEqual(
workflowDocument.on.pull_request["paths-ignore"],
);
expect(workflowDocument.jobs.scope.if).toBe(
"vars.REA_CODEQL_ADVANCED == 'true'",
);
const job = workflowDocument.jobs.analyze;
expect(job.if).toBe(
"vars.REA_CODEQL_ADVANCED == 'true' && needs.scope.outputs.run == 'true'",
);
expect(job.strategy.matrix.language).toBe(
"${{ fromJSON(needs.scope.outputs.languages) }}",
);
const init = job.steps.find((step) =>
step.uses.startsWith("github/codeql-action/init@"),
);
@@ -140,3 +192,71 @@ it("uses the scope in a bounded workflow gated on administrator activation", asy
});
expect(analyze?.with).not.toHaveProperty("upload");
});
const SHA_BASE = "a".repeat(40);
const SHA_HEAD = "b".repeat(40);
const selectPr = (files: readonly string[]) =>
planCodeqlLanguages(
{ event: "pull_request", base: SHA_BASE, head: SHA_HEAD },
{ mergeBase: (base) => base, changedFiles: () => files },
);
it("selects affected CodeQL languages on pull requests and fails closed on shared or unknown inputs", () => {
for (const event of ["push", "schedule", "workflow_dispatch"]) {
expect(
planCodeqlLanguages(
{ event, base: undefined, head: SHA_HEAD },
{
mergeBase: () => {
throw new Error("Non-PR events must not diff");
},
changedFiles: () => [],
},
),
).toMatchObject({ run: true, languages: CODEQL_LANGUAGES });
}
expect(
selectPr([
"tests/boundary/filesystem/ciCodeqlScope.test.ts",
"src/process/ExecFileOutput.test.ts",
"docs/development/testing.md",
"bridge/ghidra/ReaGhidraBridge.java",
]),
).toMatchObject({ run: false, languages: [] });
expect(
selectPr(["src/process/ExecFileOutput.ts", "docs/.vitepress/config.ts"]),
).toMatchObject({
run: true,
languages: ["javascript-typescript"],
});
expect(selectPr(["bridge/pwndbg/launch.py"])).toMatchObject({
run: true,
languages: ["python"],
});
expect(
selectPr([
".github/workflows/release.yml",
".github/actions/publish-mcp/action.yml",
]),
).toMatchObject({
run: true,
languages: ["actions"],
});
for (const broad of [
".github/codeql/production.yml",
".github/workflows/codeql.yml",
"install.sh",
"scripts/unknown-entrypoint",
]) {
expect(selectPr([broad]), broad).toMatchObject({
run: true,
languages: CODEQL_LANGUAGES,
});
}
expect(
planCodeqlLanguages(
{ event: "pull_request", base: "not-a-sha", head: SHA_HEAD },
{ mergeBase: (base) => base, changedFiles: () => [] },
),
).toMatchObject({ run: true, languages: CODEQL_LANGUAGES });
});
+29 -2
View File
@@ -354,8 +354,9 @@ it.each([false, true])(
now: observedAt,
apiRequest,
});
expect(report.scan.workflowRunPages).toBe(5);
expect(report.scan.workflowRunPages).toBe(10);
expect(report.scan.workflowRunInventoryComplete).toBe(false);
expect(report.lookbackHours).toBe(12);
const firstPull = report.pullRequests[0];
if (firstPull === undefined) throw new Error("fixture PR was not scanned");
expect(firstPull.ci).toMatchObject({
@@ -598,6 +599,32 @@ it("keeps a proven newest run even when two older matched runs have equal timest
expect(result.runs).toHaveLength(3);
});
it("queries workflow runs with full ISO timestamp precision across the configured hour window", async () => {
const endpoints: string[] = [];
const midDay = Date.parse("2026-10-14T18:17:00Z");
const report = await collectPrCiHealth({
repository: "owner/rea",
repositoryId: 11,
defaultBranch: "main",
now: midDay,
apiRequest: async (_method, endpoint) => {
endpoints.push(endpoint);
if (endpoint.includes("/pulls?"))
return [
rawPull(91, { mergeable: true, created_at: "2026-10-14T12:00:00Z" }),
rawPull(92, { mergeable: true, created_at: "2026-10-14T05:00:00Z" }),
];
return { workflow_runs: [] };
},
});
expect(report.lookbackHours).toBe(12);
expect(report.scan.cutoff).toBe("2026-10-14T06:17:00.000Z");
expect(report.pullRequests.map((pull) => pull.number)).toEqual([91]);
expect(endpoints).toContain(
"repos/owner/rea/actions/workflows/ci.yml/runs?event=pull_request&created=%3E%3D2026-10-14T06%3A17%3A00.000Z&per_page=100&page=1",
);
});
function run(overrides: Partial<PrCiWorkflowRun> = {}): PrCiWorkflowRun {
return {
id: 77,
@@ -617,7 +644,7 @@ function rawPull(number: number, overrides: Record<string, unknown> = {}) {
return {
number,
draft: false,
created_at: "2026-10-13T00:00:00Z",
created_at: "2026-10-13T18:00:00Z",
html_url: `https://github.com/owner/rea/pull/${String(number)}`,
base: { ref: "main", repo: { id: 11 } },
head: {
@@ -375,6 +375,7 @@ async function assertProviderCacheCallers(
"sqlite-runtime",
"nativeaot",
"ghidra_bridge",
"android_metadata",
"website",
])
expect(jobs[name]?.secrets, name).toBeUndefined();
@@ -430,6 +431,7 @@ it("binds provider build reuse to the current run while keeping standalone dispa
"agentenv",
"packet_capture",
"signal_recording",
"go_binary",
];
const buildTerms = z
.string()
@@ -928,8 +930,10 @@ it("binds each canonical lane to its explicit fast and full workflow jobs", asyn
"web_runtime",
"web_source_map",
"agentenv",
"go_binary",
"nativeaot",
"ghidra_bridge",
"android_metadata",
"website",
].map((name) => [name, { fast: [name], full: [name] }]),
),
+257 -303
View File
@@ -41,7 +41,7 @@ interface ToolSchemas {
function expectStrictInputSchemaParity(
tools: readonly ToolSchemas[],
ajv: Ajv2020,
validators: ReadonlyMap<string, ReturnType<Ajv2020["compile"]>>,
): void {
const advertised = new Map(tools.map((tool) => [tool.name, tool]));
const names = [
@@ -62,15 +62,51 @@ function expectStrictInputSchemaParity(
({ name: toolName }) => toolName === name,
);
const tool = advertised.get(name);
const validate = validators.get(name);
const example = contract?.examples[0];
if (contract === undefined || tool === undefined || example === undefined)
if (
contract === undefined ||
tool === undefined ||
validate === undefined ||
example === undefined
)
throw new Error(`${name} did not have an advertised example`);
const malformed = { ...example.input, __unexpected_root_key__: true };
expect(contract.inputSchema.safeParse(malformed).success, name).toBe(false);
expect(ajv.compile(tool.inputSchema)(malformed), name).toBe(false);
expect(validate(malformed), name).toBe(false);
}
}
let cachedCanonicalTools:
| Promise<Awaited<ReturnType<Client["listTools"]>>["tools"]>
| undefined;
function listCanonicalAdvertisedTools() {
cachedCanonicalTools ??= (async () => {
const server = new McpServer({ name: "schema-validation", version: "0" });
const client = new Client(
{ name: "schema-validation", version: "0" },
{ jsonSchemaValidator: createMcpSchemaValidation() },
);
const [clientTransport, serverTransport] =
InMemoryTransport.createLinkedPair();
for (const contract of TOOL_CONTRACTS)
server.registerTool(
contract.name,
toolRegistrationOptions(contract),
async () => ({ content: [] }),
);
try {
await server.connect(serverTransport);
await client.connect(clientTransport);
return (await client.listTools()).tools;
} finally {
await Promise.allSettled([client.close(), server.close()]);
}
})();
return cachedCanonicalTools;
}
function expectKnownAuthorityHints(tools: readonly ToolSchemas[]): void {
const advertised = new Map(tools.map((tool) => [tool.name, tool]));
const expected = {
@@ -467,188 +503,159 @@ describe("MCP JSON Schema validity", () => {
});
it("advertises valid input and output schemas for every canonical tool", async () => {
const server = new McpServer({ name: "schema-validation", version: "0" });
const client = new Client(
{ name: "schema-validation", version: "0" },
{ jsonSchemaValidator: createMcpSchemaValidation() },
const tools = await listCanonicalAdvertisedTools();
expect(tools.map(({ name }) => name).sort()).toEqual(
TOOL_CONTRACTS.map(({ name }) => name).sort(),
);
const [clientTransport, serverTransport] =
InMemoryTransport.createLinkedPair();
for (const contract of TOOL_CONTRACTS)
server.registerTool(
contract.name,
toolRegistrationOptions(contract),
async () => ({
content: [],
}),
expect(advertisedSchemaErrors(tools)).toEqual([]);
expect(localInputReferences(tools)).toEqual([]);
expect(recursiveReferences(tools)).toEqual([]);
expectKnownAuthorityHints(tools);
const byName = new Map(tools.map((tool) => [tool.name, tool]));
expectManagedLocalSignatureSchema(byName.get("inspect_managed_members"));
const comparison = byName.get("compare_web_captures")?.inputSchema;
for (const side of ["before", "after"])
expect(comparison).toHaveProperty(
["properties", side, "properties", "inspection"],
{
type: "object",
description: expect.stringContaining(
"complete canonical observation",
),
},
);
try {
await server.connect(serverTransport);
await client.connect(clientTransport);
const { tools } = await client.listTools();
expect(tools.map(({ name }) => name).sort()).toEqual(
TOOL_CONTRACTS.map(({ name }) => name).sort(),
for (const contract of TOOL_CONTRACTS) {
const tool = byName.get(contract.name);
expect(tool?.title?.trim(), contract.name).toBeTruthy();
expect(tool?.description?.trim(), contract.name).toBeTruthy();
const examples = advertisedInputExamples(contract);
expect(tool?.inputSchema.examples, contract.name).toEqual(
examples.length === 0 ? undefined : examples,
);
expect(advertisedSchemaErrors(tools)).toEqual([]);
expect(localInputReferences(tools)).toEqual([]);
expect(recursiveReferences(tools)).toEqual([]);
expectKnownAuthorityHints(tools);
const byName = new Map(tools.map((tool) => [tool.name, tool]));
expectManagedLocalSignatureSchema(byName.get("inspect_managed_members"));
const comparison = byName.get("compare_web_captures")?.inputSchema;
for (const side of ["before", "after"])
expect(comparison).toHaveProperty(
["properties", side, "properties", "inspection"],
{
type: "object",
description: expect.stringContaining(
"complete canonical observation",
),
},
);
for (const contract of TOOL_CONTRACTS) {
const tool = byName.get(contract.name);
expect(tool?.title?.trim(), contract.name).toBeTruthy();
expect(tool?.description?.trim(), contract.name).toBeTruthy();
const examples = advertisedInputExamples(contract);
expect(tool?.inputSchema.examples, contract.name).toEqual(
examples.length === 0 ? undefined : examples,
);
for (const example of contract.examples)
expect(
contract.inputSchema.safeParse(example.input).success,
`${contract.name}: ${example.title}`,
).toBe(true);
expectMeaningfulPropertyDescriptions(tool?.inputSchema, contract.name);
}
} finally {
await Promise.allSettled([client.close(), server.close()]);
for (const example of contract.examples)
expect(
contract.inputSchema.safeParse(example.input).success,
`${contract.name}: ${example.title}`,
).toBe(true);
expectMeaningfulPropertyDescriptions(tool?.inputSchema, contract.name);
}
});
});
describe("MCP root input schemas", () => {
it("advertises object roots while enforcing union requirements at runtime", async () => {
const server = new McpServer({ name: "schema-constraints", version: "0" });
const client = new Client(
{ name: "schema-constraints", version: "0" },
{ jsonSchemaValidator: createMcpSchemaValidation() },
const tools = await listCanonicalAdvertisedTools();
const advertised = new Map(tools.map((tool) => [tool.name, tool]));
const ajv = new Ajv2020({
strict: false,
validateFormats: false,
inlineRefs: false,
code: { optimize: false },
});
const compiledValidators = new Map<
string,
ReturnType<Ajv2020["compile"]>
>();
const graphContract = TOOL_CONTRACTS.find(
({ name }) => name === "project_managed_application_graph",
);
const [clientTransport, serverTransport] =
InMemoryTransport.createLinkedPair();
for (const contract of TOOL_CONTRACTS)
server.registerTool(
contract.name,
toolRegistrationOptions(contract),
async () => ({ content: [] }),
);
try {
await server.connect(serverTransport);
await client.connect(clientTransport);
const { tools } = await client.listTools();
const advertised = new Map(tools.map((tool) => [tool.name, tool]));
const ajv = new Ajv2020({ strict: false, validateFormats: false });
const graphContract = TOOL_CONTRACTS.find(
({ name }) => name === "project_managed_application_graph",
);
const graphTool = advertised.get("project_managed_application_graph");
if (graphContract === undefined || graphTool === undefined)
throw new Error("Managed application graph tool was not advertised");
expect(graphContract.inputSchema.safeParse({}).success).toBe(false);
expect(graphTool.inputSchema).toMatchObject({ type: "object" });
expect(ajv.compile(graphTool.inputSchema)({})).toBe(false);
expect(ajv.compile(graphTool.inputSchema)({ unrelated: true })).toBe(
false,
);
expect(graphTool.inputSchema.description).toContain(
"Provide a complete input group",
);
expect(graphTool.inputSchema.description).not.toContain("exactly one");
const graphTool = advertised.get("project_managed_application_graph");
if (graphContract === undefined || graphTool === undefined)
throw new Error("Managed application graph tool was not advertised");
expect(graphContract.inputSchema.safeParse({}).success).toBe(false);
expect(graphTool.inputSchema).toMatchObject({ type: "object" });
const validateGraph = ajv.compile(graphTool.inputSchema);
compiledValidators.set("project_managed_application_graph", validateGraph);
expect(validateGraph({})).toBe(false);
expect(validateGraph({ unrelated: true })).toBe(false);
expect(graphTool.inputSchema.description).toContain(
"Provide a complete input group",
);
expect(graphTool.inputSchema.description).not.toContain("exactly one");
for (const contract of TOOL_CONTRACTS) {
const inputSchema = advertised.get(contract.name)!.inputSchema;
expect(inputSchema.type, contract.name).toBe("object");
expect(inputSchema.properties, contract.name).toBeDefined();
// Anthropic tool input schemas reject root combinators.
for (const combinator of ["anyOf", "oneOf", "allOf"])
expect(inputSchema, contract.name).not.toHaveProperty(combinator);
const validate = ajv.compile(inputSchema);
for (const example of contract.examples)
expect(
validate(example.input),
`${contract.name}: ${example.title}`,
).toBe(true);
}
expectStrictInputSchemaParity(tools, ajv);
for (const name of ["inspect_web_page", "analyze_web_bundle"]) {
const contract = TOOL_CONTRACTS.find((tool) => tool.name === name);
const tool = advertised.get(name);
if (contract === undefined || tool === undefined)
throw new Error(`${name} was not advertised`);
const validate = ajv.compile(
advertiseTool(
{ inputSchema: tool.inputSchema },
advertisedToolPresentation("off"),
).inputSchema ?? {},
);
const base = {
cdp_endpoint: "http://127.0.0.1:9222",
target_id: "target",
};
for (const flag of [undefined, false, true, "false", null]) {
const input =
flag === undefined
? base
: { ...base, include_script_sources: flag };
const accepted =
flag === undefined ||
flag === true ||
(name === "inspect_web_page" && flag === false);
const parsed = contract.inputSchema.safeParse(input);
expect(parsed.success, `${name}: ${String(flag)}`).toBe(accepted);
// The advertised dialect relaxes Boolean literals; the canonical parser
// still rejects false when this operation requires script sources.
expect(validate(input), `${name}: ${String(flag)}`).toBe(
flag === undefined || typeof flag === "boolean",
);
if (parsed.success && flag === undefined)
expect(parsed.data).toMatchObject({
include_script_sources: name === "analyze_web_bundle",
});
}
}
const nativeObservation = TOOL_CONTRACTS.find(
({ name }) => name === "observe_native_ui",
);
const nativeScenario = TOOL_CONTRACTS.find(
({ name }) => name === "capture_native_ui_scenario",
);
const nativeObservationTool = advertised.get("observe_native_ui");
const nativeScenarioTool = advertised.get("capture_native_ui_scenario");
if (
nativeObservation === undefined ||
nativeScenario === undefined ||
nativeObservationTool === undefined ||
nativeScenarioTool === undefined
)
throw new Error("Native UI tools were not registered");
const target = { pid: 123, window_id: 456 };
const scenario = {
...target,
steps: [{ kind: "wait", milliseconds: 100 }],
};
const observationResult = nativeObservation.inputSchema.safeParse(target);
const scenarioResult = nativeScenario.inputSchema.safeParse(scenario);
expect(observationResult.success).toBe(true);
expect(scenarioResult.success).toBe(true);
expect(ajv.compile(nativeObservationTool.inputSchema)(target)).toBe(true);
expect(ajv.compile(nativeScenarioTool.inputSchema)(scenario)).toBe(true);
} finally {
await Promise.allSettled([client.close(), server.close()]);
for (const contract of TOOL_CONTRACTS) {
const inputSchema = advertised.get(contract.name)!.inputSchema;
expect(inputSchema.type, contract.name).toBe("object");
expect(inputSchema.properties, contract.name).toBeDefined();
// Anthropic tool input schemas reject root combinators.
for (const combinator of ["anyOf", "oneOf", "allOf"])
expect(inputSchema, contract.name).not.toHaveProperty(combinator);
const validate =
compiledValidators.get(contract.name) ?? ajv.compile(inputSchema);
compiledValidators.set(contract.name, validate);
for (const example of contract.examples)
expect(
validate(example.input),
`${contract.name}: ${example.title}`,
).toBe(true);
}
expectStrictInputSchemaParity(tools, compiledValidators);
for (const name of ["inspect_web_page", "analyze_web_bundle"]) {
const contract = TOOL_CONTRACTS.find((tool) => tool.name === name);
const tool = advertised.get(name);
if (contract === undefined || tool === undefined)
throw new Error(`${name} was not advertised`);
const validate = ajv.compile(
advertiseTool(
{ inputSchema: tool.inputSchema },
advertisedToolPresentation("off"),
).inputSchema ?? {},
);
const base = {
cdp_endpoint: "http://127.0.0.1:9222",
target_id: "target",
};
for (const flag of [undefined, false, true, "false", null]) {
const input =
flag === undefined ? base : { ...base, include_script_sources: flag };
const accepted =
flag === undefined ||
flag === true ||
(name === "inspect_web_page" && flag === false);
const parsed = contract.inputSchema.safeParse(input);
expect(parsed.success, `${name}: ${String(flag)}`).toBe(accepted);
// The advertised dialect relaxes Boolean literals; the canonical parser
// still rejects false when this operation requires script sources.
expect(validate(input), `${name}: ${String(flag)}`).toBe(
flag === undefined || typeof flag === "boolean",
);
if (parsed.success && flag === undefined)
expect(parsed.data).toMatchObject({
include_script_sources: name === "analyze_web_bundle",
});
}
}
const nativeObservation = TOOL_CONTRACTS.find(
({ name }) => name === "observe_native_ui",
);
const nativeScenario = TOOL_CONTRACTS.find(
({ name }) => name === "capture_native_ui_scenario",
);
const nativeObservationTool = advertised.get("observe_native_ui");
const nativeScenarioTool = advertised.get("capture_native_ui_scenario");
if (
nativeObservation === undefined ||
nativeScenario === undefined ||
nativeObservationTool === undefined ||
nativeScenarioTool === undefined
)
throw new Error("Native UI tools were not registered");
const target = { pid: 123, window_id: 456 };
const scenario = {
...target,
steps: [{ kind: "wait", milliseconds: 100 }],
};
const observationResult = nativeObservation.inputSchema.safeParse(target);
const scenarioResult = nativeScenario.inputSchema.safeParse(scenario);
expect(observationResult.success).toBe(true);
expect(scenarioResult.success).toBe(true);
expect(compiledValidators.get("observe_native_ui")!(target)).toBe(true);
expect(
compiledValidators.get("capture_native_ui_scenario")!(scenario),
).toBe(true);
});
});
@@ -665,82 +672,55 @@ const advertiseAndEnforceItemSelectorCollectionConstraints =
if (contract === undefined)
throw new Error("inspect_analysis_view contract was not registered");
const server = new McpServer({
name: "item-selector-schema",
version: "0",
});
server.registerTool(
contract.name,
toolRegistrationOptions(contract),
async () => ({
content: [],
}),
const advertised = (await listCanonicalAdvertisedTools()).find(
({ name }) => name === contract.name,
);
const client = new Client(
{ name: "item-selector-schema", version: "0" },
{ jsonSchemaValidator: createMcpSchemaValidation() },
);
const [clientTransport, serverTransport] =
InMemoryTransport.createLinkedPair();
try {
await server.connect(serverTransport);
await client.connect(clientTransport);
const advertised = (await client.listTools()).tools.find(
({ name }) => name === contract.name,
);
if (advertised === undefined)
throw new Error("inspect_analysis_view tool was not advertised");
if (advertised === undefined)
throw new Error("inspect_analysis_view tool was not advertised");
const validate = new Ajv2020({
strict: false,
validateFormats: false,
}).compile(advertised.inputSchema);
const source = {
kind: "retained-evidence",
evidence_id: `ev_${"a".repeat(64)}`,
};
const itemInput = (collection: string, selector: unknown) => ({
source,
view: { kind: "item", collection, selector },
});
const nodeId = `jag_node_${"b".repeat(64)}`;
// Collection-specific selector constraints must survive JSON Schema
// conversion: the advertised schema rejects exactly what runtime
// input validation rejects.
const invalid: ReadonlyArray<readonly [string, unknown]> = [
["modules", { index: 0 }],
["modules", { name: "entry" }],
["sections", { path: "/src/entry.js" }],
["symbols", { node_id: nodeId }],
];
const valid: ReadonlyArray<readonly [string, unknown]> = [
["modules", { path: "/src/entry.js" }],
["modules", { node_id: nodeId }],
["sections", { index: 0 }],
["sections", { name: ".text" }],
["symbols", { index: 0 }],
["symbols", { name: "main" }],
];
for (const [collection, selector] of invalid) {
const input = itemInput(collection, selector);
const label = `${collection}/${Object.keys(selector as object)[0]}`;
expect(contract.inputSchema.safeParse(input).success, label).toBe(
false,
);
expect(validate(input), `advertised schema rejects ${label}`).toBe(
false,
);
}
for (const [collection, selector] of valid) {
const input = itemInput(collection, selector);
const label = `${collection}/${Object.keys(selector as object)[0]}`;
expect(contract.inputSchema.safeParse(input).success, label).toBe(true);
expect(validate(input), `advertised schema accepts ${label}`).toBe(
true,
);
}
} finally {
await Promise.allSettled([client.close(), server.close()]);
const validate = new Ajv2020({
strict: false,
validateFormats: false,
inlineRefs: false,
code: { optimize: false },
}).compile(advertised.inputSchema);
const source = {
kind: "retained-evidence",
evidence_id: `ev_${"a".repeat(64)}`,
};
const itemInput = (collection: string, selector: unknown) => ({
source,
view: { kind: "item", collection, selector },
});
const nodeId = `jag_node_${"b".repeat(64)}`;
// Collection-specific selector constraints must survive JSON Schema
// conversion: the advertised schema rejects exactly what runtime
// input validation rejects.
const invalid: ReadonlyArray<readonly [string, unknown]> = [
["modules", { index: 0 }],
["modules", { name: "entry" }],
["sections", { path: "/src/entry.js" }],
["symbols", { node_id: nodeId }],
];
const valid: ReadonlyArray<readonly [string, unknown]> = [
["modules", { path: "/src/entry.js" }],
["modules", { node_id: nodeId }],
["sections", { index: 0 }],
["sections", { name: ".text" }],
["symbols", { index: 0 }],
["symbols", { name: "main" }],
];
for (const [collection, selector] of invalid) {
const input = itemInput(collection, selector);
const label = `${collection}/${Object.keys(selector as object)[0]}`;
expect(contract.inputSchema.safeParse(input).success, label).toBe(false);
expect(validate(input), `advertised schema rejects ${label}`).toBe(false);
}
for (const [collection, selector] of valid) {
const input = itemInput(collection, selector);
const label = `${collection}/${Object.keys(selector as object)[0]}`;
expect(contract.inputSchema.safeParse(input).success, label).toBe(true);
expect(validate(input), `advertised schema accepts ${label}`).toBe(true);
}
};
@@ -751,64 +731,38 @@ it(
describe("MCP process input JSON Schema", () => {
it("advertises process strings without weakening terminal input", async () => {
const server = new McpServer({
name: "process-schema-validation",
version: "0",
});
const client = new Client(
{
name: "process-schema-validation",
version: "0",
},
{ jsonSchemaValidator: createMcpSchemaValidation() },
const tools = await listCanonicalAdvertisedTools();
const processContract = TOOL_CONTRACTS.find(
({ name }) => name === "capture_process_scenario",
);
const [clientTransport, serverTransport] =
InMemoryTransport.createLinkedPair();
for (const contract of TOOL_CONTRACTS)
server.registerTool(
contract.name,
toolRegistrationOptions(contract),
async () => ({ content: [] }),
);
try {
await server.connect(serverTransport);
await client.connect(clientTransport);
const processContract = TOOL_CONTRACTS.find(
({ name }) => name === "capture_process_scenario",
);
const processTool = (await client.listTools()).tools.find(
({ name }) => name === "capture_process_scenario",
);
if (processContract === undefined || processTool === undefined)
throw new Error("Process scenario tool was not advertised");
const validate = new Ajv2020({
strict: false,
validateFormats: false,
}).compile(processTool.inputSchema);
const base = { executable: "/usr/bin/true" };
for (const input of [
{ ...base, executable: "/usr/bin/true\0" },
{ ...base, arguments: ["\0"] },
{ ...base, working_directory: "/tmp\0" },
{ ...base, environment: { KEY: "value\0" } },
{ ...base, filesystem_observation_paths: ["/tmp\0"] },
]) {
expect(processContract.inputSchema.safeParse(input).success).toBe(
false,
);
expect(validate(input)).toBe(false);
}
const terminalInput = {
...base,
events: [{ type: "input", at_ms: 0, data: "\0" }],
};
expect(processContract.inputSchema.safeParse(terminalInput).success).toBe(
true,
);
expect(validate(terminalInput)).toBe(true);
} finally {
await Promise.allSettled([client.close(), server.close()]);
const processTool = tools.find(
({ name }) => name === "capture_process_scenario",
);
if (processContract === undefined || processTool === undefined)
throw new Error("Process scenario tool was not advertised");
const validate = new Ajv2020({
strict: false,
validateFormats: false,
}).compile(processTool.inputSchema);
const base = { executable: "/usr/bin/true" };
for (const input of [
{ ...base, executable: "/usr/bin/true\0" },
{ ...base, arguments: ["\0"] },
{ ...base, working_directory: "/tmp\0" },
{ ...base, environment: { KEY: "value\0" } },
{ ...base, filesystem_observation_paths: ["/tmp\0"] },
]) {
expect(processContract.inputSchema.safeParse(input).success).toBe(false);
expect(validate(input)).toBe(false);
}
const terminalInput = {
...base,
events: [{ type: "input", at_ms: 0, data: "\0" }],
};
expect(processContract.inputSchema.safeParse(terminalInput).success).toBe(
true,
);
expect(validate(terminalInput)).toBe(true);
});
});
+121 -5
View File
@@ -102,14 +102,22 @@ it("lets checker-only inputs and prose select nothing by themselves", () => {
const sources = {
"src/domain/Value.test.ts": "",
"tests/boundary/filesystem/docs.test.ts": 'read("docs/guide.md");',
"tests/boundary/filesystem/mermaid.test.ts":
'read("docs/architecture/architecture.mermaid");',
"tests/boundary/filesystem/licenses.test.ts":
'read("licenses/npm-dependencies.txt"); read("LICENSE");',
"tests/boundary/filesystem/issueTemplate.test.ts":
'read(".github/ISSUE_TEMPLATE/bug_report.yml");',
};
// A declaration, guard baseline or schema summary adds no tests…
// A declaration, guard/layer baseline, blame-ignore list or schema summary adds no tests…
expect(
selectedFiles(
plan(
[
"src/domain/Value.test.ts",
"scripts/lib/helper.d.mts",
"scripts/lib/module-layers.baseline.json",
".git-blame-ignore-revs",
"scripts/verify/baselines/some-guard.json",
"scripts/verify/advertised-schemas/tools/tool.json",
],
@@ -117,15 +125,70 @@ it("lets checker-only inputs and prose select nothing by themselves", () => {
),
),
).toEqual(["src/domain/Value.test.ts"]);
// …and prose selects the tests that read it by path.
// …and prose, non-code docs assets, and license inventories select the tests that read them by path.
expect(selectedFiles(plan(["docs/guide.md"], sources))).toEqual([
"tests/boundary/filesystem/docs.test.ts",
]);
expect(
selectedFiles(plan(["docs/architecture/architecture.mermaid"], sources)),
).toEqual(["tests/boundary/filesystem/mermaid.test.ts"]);
expect(
selectedFiles(plan(["licenses/npm-dependencies.txt"], sources)),
).toEqual(["tests/boundary/filesystem/licenses.test.ts"]);
expect(selectedFiles(plan(["LICENSE"], sources))).toEqual([
"tests/boundary/filesystem/licenses.test.ts",
]);
expect(
selectedFiles(plan([".github/ISSUE_TEMPLATE/bug_report.yml"], sources)),
).toEqual(["tests/boundary/filesystem/issueTemplate.test.ts"]);
// Authored code under docs/ stays untraced so it falls back to the full suite.
expect(plan(["docs/.vitepress/config.ts"], sources)).toMatchObject({
mode: "full",
reason: "Input is not traced to tests: docs/.vitepress/config.ts",
});
expect(plan(["scripts/verify/baselines/x.json"], sources)).toMatchObject({
mode: "full",
});
});
it("selects tests under shared-boundary directories and declared fixture owners, failing closed on missing owners", () => {
const sources = {
"src/process/OwnedCommand.test.ts": "",
"tests/boundary/cli/cliParityGoldens.test.ts": "",
"tests/boundary/cli/cliContractSchemaParity.test.ts": "",
};
expect(
selectedFiles(plan(["src/process/OwnedCommand.test.ts"], sources)),
).toEqual(["src/process/OwnedCommand.test.ts"]);
expect(plan(["src/process/OwnedCommand.ts"], sources)).toMatchObject({
mode: "full",
reason: "Shared boundary: src/process/OwnedCommand.ts",
});
expect(
selectedFiles(
plan(["tests/fixtures/cli-parity/error-unknown-command.txt"], sources),
),
).toEqual(["tests/boundary/cli/cliParityGoldens.test.ts"]);
expect(
selectedFiles(
plan(
["tests/boundary/cli/cliContractSchemaParity.uncomparable.json"],
sources,
),
),
).toEqual(["tests/boundary/cli/cliContractSchemaParity.test.ts"]);
// If an explicit fixture owner is missing or renamed, selection fails closed.
expect(
plan(["tests/fixtures/cli-parity/error-unknown-command.txt"], {
"src/process/OwnedCommand.test.ts": "",
}),
).toMatchObject({
mode: "full",
reason:
"Missing test owner tests/boundary/cli/cliParityGoldens.test.ts for tests/fixtures/cli-parity/error-unknown-command.txt",
});
});
it("traces shared script modules to their tests and falls back for other consumers", () => {
const sources = {
"scripts/lib/shared.mjs": "",
@@ -194,6 +257,41 @@ it("traces shared script modules to their tests and falls back for other consume
"tests/boundary/filesystem/runtimeVerifier.test.ts",
"tests/boundary/filesystem/startup.test.ts",
]);
// Static checker JSON/Stryker configs, hyphen-prefixed script names in
// package.json (such as verify-shared.mjs vs scripts/lib/shared.mjs), and
// path-string tables in scopes.mjs do not force a full-suite fallback.
expect(
selectedFiles(
plan(
[
"scripts/lib/shared.mjs",
"tests/support/analysis-efficiency/test_eval.py",
],
{
...sources,
"package.json":
'{"scripts":{"verify:shared":"node scripts/verify-shared.mjs"}}',
"tsconfig.scripts.json": '{"include":["scripts/lib/shared.mjs"]}',
"stryker.config.mjs": 'import "./scripts/lib/shared.mjs";',
"scripts/ci/scopes.mjs":
'export const S = ["scripts/lib/shared.mjs"];',
},
),
),
).toEqual([
"tests/boundary/filesystem/shared.test.ts",
"tests/boundary/filesystem/verifier.test.ts",
]);
expect(
plan(["scripts/lib/shared.mjs"], {
...sources,
"scripts/ci/scopes.mjs": 'import "../lib/shared.mjs";',
}),
).toMatchObject({
mode: "full",
reason:
"Script consumer is not traced: scripts/ci/scopes.mjs uses scripts/lib/shared.mjs",
});
// Other scripts remain untraced inputs.
expect(plan(["scripts/build.mjs"], sources)).toMatchObject({
mode: "full",
@@ -212,9 +310,27 @@ it("parses only well-formed plans and derives the selected shard count", () => {
expect(
testShards("fast", parseTestSelection(JSON.stringify(selected))),
).toEqual(["1/2", "2/2"]);
const maxSelectedFiles = Object.fromEntries(
Array.from({ length: 400 }, (_, i) => [
`src/feature-${String(i)}.test.ts`,
"",
]),
);
expect(plan(Object.keys(maxSelectedFiles), maxSelectedFiles)).toMatchObject({
mode: "selected",
shards: 8,
});
const overCapFiles = {
...maxSelectedFiles,
"src/feature-400.test.ts": "",
};
expect(plan(Object.keys(overCapFiles), overCapFiles)).toMatchObject({
mode: "full",
reason: "401 affected test files exceed the 400-file selection cap",
});
const full = { version: 3, mode: "full", reason: "Shared" };
expect(testShards("fast", parseTestSelection(full))).toHaveLength(12);
expect(testShards("full", parseTestSelection(full))).toHaveLength(6);
expect(testShards("full", parseTestSelection(full))).toHaveLength(12);
for (const value of [
"",
"null",
@@ -229,8 +345,8 @@ it("parses only well-formed plans and derives the selected shard count", () => {
{ ...selected, shards: 0 },
{
...selected,
files: Array.from({ length: 5 }, (_, i) => `src/${i}.test.ts`),
shards: 5,
files: Array.from({ length: 9 }, (_, i) => `src/${i}.test.ts`),
shards: 9,
},
{ ...full, shards: 1 },
])
+3
View File
@@ -31,6 +31,9 @@ export function advertisedSchemaErrors(
strict: false,
validateFormats: false,
addUsedSchema: false,
// Keep shared definitions as compiled functions instead of expanding them
// at every reference, while still compiling every $ref target.
inlineRefs: false,
// This check compiles schemas to detect invalid references but never runs
// their validators. Generated-code optimization adds substantial work here
// without checking another contract; actual SDK validators keep defaults.
+3
View File
@@ -27,6 +27,9 @@ const ajv = new Ajv2020({
strict: false,
allErrors: false,
validateFormats: false,
addUsedSchema: false,
inlineRefs: false,
code: { optimize: false },
});
type Root = Readonly<Record<string, unknown>>;
@@ -213,4 +213,21 @@ it("checks the complete source with the fallback compiler before Windows build r
const built = steps.findIndex((step) => step.run === "npm run build:cached");
expect(checked).toBeGreaterThan(-1);
expect(built).toBeGreaterThan(checked);
const vitestRuns = steps
.map((step) => step.run)
.filter((value) => value?.includes("npx vitest run"));
// One Node 24 curated run and one Node 22 path-boundary run; both cover the
// three native directory-identity suites without booting a second Node 24 Vitest process.
expect(vitestRuns).toHaveLength(2);
for (const run of vitestRuns) {
expect(run).toContain(
"tests/boundary/filesystem/directoryArtifactReaderOpen.test.ts",
);
expect(run).toContain(
"tests/boundary/filesystem/javascriptPackagePrecedence.test.ts",
);
expect(run).toContain(
"tests/boundary/filesystem/javascriptArtifactContentIdentity.test.ts",
);
}
});