Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
ci: merge_group triggers (PR profile), version-only manifest diffs stay smoke, dependency-audit blocks only where dependencies change
garrytan42ef179db634
diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.ymlindex 99a6d16656..46bbec11d0 100644--- a/.github/workflows/e2e.yml+++ b/.github/workflows/e2e.yml@@ -5,6 +5,10 @@ on:branches: [master]pull_request:branches: [master]+ # Merge queue (inert until the queue is enabled on master): the PR profile.+ # select-e2e diffs the queued merge commit against origin/master, which is+ # exactly the queued change. docs/RELEASING.md#merge-queue.+ merge_group:schedule:- cron: '0 6 * * *' # Nightly at 6am UTCworkflow_dispatch:diff --git a/.github/workflows/persistence-validation.yml b/.github/workflows/persistence-validation.ymlindex 4623f21cc2..c330bcd5c6 100644--- a/.github/workflows/persistence-validation.yml+++ b/.github/workflows/persistence-validation.yml@@ -19,7 +19,7 @@ jobs:bun: ['1.4.0', '1.4.2']# Pull requests run the primary Bun version; pushes, schedules and# manual runs keep every supported version.- exclude: ${{ fromJSON(github.event_name == 'pull_request' && '[{"bun":"1.4.0"}]' || '[]') }}+ exclude: ${{ fromJSON((github.event_name == 'pull_request' || github.event_name == 'merge_group') && '[{"bun":"1.4.0"}]' || '[]') }}services:postgres:image: pgvector/pgvector:pg16@@ -60,7 +60,7 @@ jobs:bun: ['1.4.0', '1.4.2']# Pull requests run the primary Bun version; pushes, schedules and# manual runs keep every supported version.- exclude: ${{ fromJSON(github.event_name == 'pull_request' && '[{"bun":"1.4.0"}]' || '[]') }}+ exclude: ${{ fromJSON((github.event_name == 'pull_request' || github.event_name == 'merge_group') && '[{"bun":"1.4.0"}]' || '[]') }}services:postgres:image: pgvector/pgvector:pg16@@ -173,7 +173,7 @@ jobs:bun: ['1.4.0', '1.4.2']# Pull requests run the primary Bun version; pushes, schedules and# manual runs keep every supported version.- exclude: ${{ fromJSON(github.event_name == 'pull_request' && '[{"bun":"1.4.0"}]' || '[]') }}+ exclude: ${{ fromJSON((github.event_name == 'pull_request' || github.event_name == 'merge_group') && '[{"bun":"1.4.0"}]' || '[]') }}services:postgres:image: pgvector/pgvector:pg16@@ -196,7 +196,7 @@ jobs:- name: Execute 1000 schedules, eight SIGKILL boundaries and the process-separated write soakenv:DATABASE_URL: postgres://gbrain_test:[email protected]:5432/gbrain_test- SOAK_OPERATIONS: ${{ github.event_name == 'pull_request' && '2500' || '10000' }}+ SOAK_OPERATIONS: ${{ (github.event_name == 'pull_request' || github.event_name == 'merge_group') && '2500' || '10000' }}run: >-bun --no-env-file scripts/persistence/validate.ts --engine=${{ matrix.engine }}--operations="$SOAK_OPERATIONS"@@ -222,7 +222,7 @@ jobs:bun: ['1.4.0', '1.4.2']# Pull requests run the primary Bun version; pushes, schedules and# manual runs keep every supported version.- exclude: ${{ fromJSON(github.event_name == 'pull_request' && '[{"bun":"1.4.0"}]' || '[]') }}+ exclude: ${{ fromJSON((github.event_name == 'pull_request' || github.event_name == 'merge_group') && '[{"bun":"1.4.0"}]' || '[]') }}services:postgres:image: pgvector/pgvector:pg16diff --git a/.github/workflows/test.yml b/.github/workflows/test.ymlindex f9e8848f79..8cd2b0be4c 100644--- a/.github/workflows/test.yml+++ b/.github/workflows/test.yml@@ -5,6 +5,9 @@ on:branches: [master]pull_request:branches: [master]+ # Merge queue (inert until the queue is enabled on master): the PR profile,+ # run against the queued merge commit. docs/RELEASING.md#merge-queue.+ merge_group:# Nightly full matrix: every Bun version and native target, like a push to master.schedule:- cron: '23 7 * * *'@@ -49,7 +52,9 @@ jobs:steps:- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4with:- sparse-checkout: scripts/ci-native-scope.sh+ sparse-checkout: |+ scripts/ci-native-scope.sh+ scripts/ci-manifest-diff.shsparse-checkout-cone-mode: false- id: scopeenv:@@ -58,9 +63,14 @@ jobs:PR: ${{ github.event.pull_request.number }}REPO: ${{ github.repository }}CHANGED_FILES: ${{ github.event.pull_request.changed_files }}+ BASE_SHA: ${{ github.event.pull_request.base.sha }}+ HEAD_SHA: ${{ github.event.pull_request.head.sha }}run: |set -euo pipefail- if [ "$EVENT" != pull_request ]; then+ if [ "$EVENT" = merge_group ]; then+ # PR profile for the queue: every native target on the primary Bun.+ scope=primary+ elif [ "$EVENT" != pull_request ]; thenscope=fullelif ! [[ "$CHANGED_FILES" =~ ^[0-9]{1,4}$ ]] || [ "$CHANGED_FILES" -ge 3000 ]; then# The PR files API returns at most 3000 files. An unknown or@@ -71,7 +81,14 @@ jobs:if [ "$listed" -ne "$CHANGED_FILES" ]; thenscope=primaryelse- scope=$(printf '%s' "$files" | bash scripts/ci-native-scope.sh) || scope=primary+ # A version-only package.json / openclaw.plugin.json diff (every+ # release PR) cannot change native behavior (C11).+ kept=$(printf '%s\n' "$files" | bash scripts/ci-manifest-diff.sh drop-version-only) || kept=$files+ if [ -z "$kept" ]; then+ scope=smoke+ else+ scope=$(printf '%s' "$kept" | bash scripts/ci-native-scope.sh) || scope=primary+ fifielsescope=primary@@ -119,6 +136,8 @@ jobs:set -euo pipefailif [ "${{ github.event_name }}" = "pull_request" ]; thenRANGE="${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}"+ elif [ "${{ github.event_name }}" = "merge_group" ]; then+ RANGE="${{ github.event.merge_group.base_sha }}..${{ github.event.merge_group.head_sha }}"elseBEFORE="${{ github.event.before }}"case "$BEFORE" in@@ -140,7 +159,7 @@ jobs:bun: ['1.4.0', '1.4.2']# Pull requests run the primary Bun version on every OS; pushes,# schedules and manual runs add the oldest supported version.- exclude: ${{ fromJSON(github.event_name == 'pull_request' && '[{"bun":"1.4.0"}]' || '[]') }}+ exclude: ${{ fromJSON((github.event_name == 'pull_request' || github.event_name == 'merge_group') && '[{"bun":"1.4.0"}]' || '[]') }}steps:- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2@@ -156,21 +175,62 @@ jobs:- name: Windows durability, skill bundles and local-writer flags (#5595, #5475)run: bun test --timeout 60000 test/fs-durable.test.ts test/persistence-windows-flush-5595.test.ts test/bundle-files-windows-5475.test.ts test/init-packaged-skills-native.test.ts test/auth-local-writer-dry-run.test.ts test/scripts/durable-flush-guard.test.ts test/binary-self-update-durable-download.test.ts+ # bun audit blocks on pushes, schedules, manual runs, and pull requests or+ # merge-queue entries that change bun.lock, admin/bun.lock, patches/ or a+ # package.json dependency field (or carry the `dependency-audit` label).+ # Elsewhere a new upstream advisory is a warning, so it cannot turn every+ # open PR red at once; the push and nightly runs still fail on it (B11).dependency-audit:if: ${{ github.event_name != 'workflow_dispatch' || inputs.native_only != true }}runs-on: ubicloud-standard-2-ubuntu-2404timeout-minutes: 10+ permissions:+ contents: read+ pull-requests: readsteps:- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4+ - id: scope+ env:+ GH_TOKEN: ${{ github.token }}+ EVENT: ${{ github.event_name }}+ PR: ${{ github.event.pull_request.number }}+ REPO: ${{ github.repository }}+ CHANGED_FILES: ${{ github.event.pull_request.changed_files }}+ LABELS: ${{ toJSON(github.event.pull_request.labels.*.name) }}+ BASE_SHA: ${{ github.event.pull_request.base.sha || github.event.merge_group.base_sha }}+ HEAD_SHA: ${{ github.event.pull_request.head.sha || github.event.merge_group.head_sha }}+ run: |+ set -euo pipefail+ if [ "$EVENT" != pull_request ] && [ "$EVENT" != merge_group ]; then+ printf 'blocking=true\nreason=%s runs always block\n' "$EVENT" >> "$GITHUB_OUTPUT"+ elif printf '%s' "$LABELS" | grep -q '"dependency-audit"'; then+ printf 'blocking=true\nreason=the dependency-audit label is set\n' >> "$GITHUB_OUTPUT"+ else+ files=''+ if [ "$EVENT" = pull_request ]; then+ if [[ "$CHANGED_FILES" =~ ^[0-9]{1,4}$ ]] && [ "$CHANGED_FILES" -lt 3000 ] \+ && listed=$(gh api --paginate "repos/$REPO/pulls/$PR/files?per_page=100" --jq '.[].filename') \+ && [ "$(printf '%s\n' "$listed" | awk 'NF { n++ } END { print n+0 }')" -eq "$CHANGED_FILES" ]; then+ files=$listed+ fi+ elif listed=$(gh api "repos/$REPO/compare/$BASE_SHA...$HEAD_SHA" --jq 'if (.files | length) >= 300 then error("capped") else .files[].filename end'); then+ files=$listed+ fi+ # An unknown or capped diff stays empty, which classifies as blocking.+ printf '%s' "$files" | bash scripts/ci-manifest-diff.sh dependency-scope >> "$GITHUB_OUTPUT"+ fi+ cat "$GITHUB_OUTPUT"- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2with:bun-version: 1.4.2- run: bun install --frozen-lockfile --ignore-scripts- - run: bun audit- run: bun install --frozen-lockfile --ignore-scriptsworking-directory: admin- - run: bun audit- working-directory: admin+ - name: bun audit (root + admin)+ env:+ BLOCKING: ${{ steps.scope.outputs.blocking }}+ REASON: ${{ steps.scope.outputs.reason }}+ run: bash scripts/ci-dependency-audit.shverify:if: ${{ github.event_name != 'workflow_dispatch' || inputs.native_only != true }}@@ -500,7 +560,7 @@ jobs:# manual runs keep the 100,001-page scale (~4-10 minutes, one core).- run: bun test test/export-scale.slow.test.ts --timeout=900000 --coverage --coverage-reporter=lcov --coverage-dir=${{ runner.temp }}/coverage/perf-cenv:- GBRAIN_TEST_EXPORT_SCALE_PAGES: ${{ github.event_name == 'pull_request' && '10001' || '100001' }}+ GBRAIN_TEST_EXPORT_SCALE_PAGES: ${{ (github.event_name == 'pull_request' || github.event_name == 'merge_group') && '10001' || '100001' }}- name: Write coverage lane manifestrun: |printf '{"lane":"slowperf","sha":"%s","lcovCount":%s,"complete":true}\n' \diff --git a/scripts/ci-dependency-audit.sh b/scripts/ci-dependency-audit.shnew file mode 100755index 0000000000..23ffe02b64--- /dev/null+++ b/scripts/ci-dependency-audit.sh@@ -0,0 +1,20 @@+#!/usr/bin/env bash+# scripts/ci-dependency-audit.sh — run `bun audit` for the root and admin/+# lockfiles; fail only when the run is blocking (test.yml dependency-audit+# scope step; env BLOCKING=true|false, REASON). Otherwise a found advisory is+# a ::warning:: naming why this run does not block (GBRA-47 B11).+set -uo pipefail++found=0+bun audit || found=1+(cd admin && bun audit) || found=1+if [ "$found" -eq 0 ]; then+ echo "bun audit: no advisories."+ exit 0+fi+if [ "${BLOCKING:-true}" != false ]; then+ echo "::error::bun audit found advisories (blocking: ${REASON:-unknown scope}). Why: this run changes dependencies or protects master, so a known-vulnerable package must not land. Fix: bump the package (bun update <pkg>) or add an overrides entry, then push."+ exit 1+fi+echo "::warning::bun audit found advisories; advisory-only on this pull request (${REASON:-}). Why: an upstream advisory must not turn every open PR red; pushes and the nightly run block on it. Fix: none needed here; to block on it, add the dependency-audit label and push."+exit 0diff --git a/scripts/ci-manifest-diff.sh b/scripts/ci-manifest-diff.shnew file mode 100644index 0000000000..b0f6611a66--- /dev/null+++ b/scripts/ci-manifest-diff.sh@@ -0,0 +1,97 @@+#!/usr/bin/env bash+# scripts/ci-manifest-diff.sh — parsed-JSON classification of manifest diffs+# for CI path scoping (GBRA-47 B11, C11; ENG-17).+#+# bash scripts/ci-manifest-diff.sh version-only <base.json> <head.json>+# prints `true` when the two files differ only in their top-level+# "version" (every other key equal after parsing), else `false`.+# bash scripts/ci-manifest-diff.sh dependency-change <base.json> <head.json>+# prints `true` when any dependency field differs (dependencies,+# devDependencies, optionalDependencies, peerDependencies, overrides,+# resolutions, trustedDependencies, patchedDependencies), else `false`.+# bash scripts/ci-manifest-diff.sh drop-version-only < changed-files+# filters a changed-file list (one path per line): package.json and+# openclaw.plugin.json entries whose change is version-only are dropped.+# Reads both revisions with `gh api` (env REPO, BASE_SHA, HEAD_SHA).+# bash scripts/ci-manifest-diff.sh dependency-scope < changed-files+# prints `blocking=true|false` and `reason=...` for the dependency-audit+# job: true when bun.lock, admin/bun.lock or patches/ changed, or when a+# package.json's dependency fields changed (env as above).+#+# Fails closed: a file that cannot be read or parsed is never version-only+# and always counts as a dependency change, so an unknown diff never narrows+# validation.+set -euo pipefail++DEP_FIELDS='{dependencies, devDependencies, optionalDependencies, peerDependencies, overrides, resolutions, trustedDependencies, patchedDependencies}'++same_after() {+ local filter="$1" base="$2" head="$3" a b+ a=$(jq -S "$filter" "$base" 2>/dev/null) || return 2+ b=$(jq -S "$filter" "$head" 2>/dev/null) || return 2+ [ "$a" = "$b" ]+}++version_only() {+ if same_after 'del(.version)' "$1" "$2" && ! same_after '.' "$1" "$2"; then echo true; else echo false; fi+}++dependency_change() {+ if same_after "$DEP_FIELDS" "$1" "$2"; then echo false; else echo true; fi+}++fetch_pair() {+ local path="$1" dir="$2"+ [ -n "${REPO:-}" ] && [ -n "${BASE_SHA:-}" ] && [ -n "${HEAD_SHA:-}" ] || return 1+ gh api -H 'Accept: application/vnd.github.raw' "repos/$REPO/contents/$path?ref=$BASE_SHA" > "$dir/base.json" 2>/dev/null || return 1+ gh api -H 'Accept: application/vnd.github.raw' "repos/$REPO/contents/$path?ref=$HEAD_SHA" > "$dir/head.json" 2>/dev/null || return 1+}++mode="${1:-}"+case "$mode" in+ version-only) version_only "$2" "$3" ;;+ dependency-change) dependency_change "$2" "$3" ;;+ drop-version-only)+ tmp=$(mktemp -d)+ trap 'rm -rf "$tmp"' EXIT+ while IFS= read -r path || [ -n "$path" ]; do+ case "$path" in+ package.json|*openclaw.plugin.json)+ if fetch_pair "$path" "$tmp" && [ "$(version_only "$tmp/base.json" "$tmp/head.json")" = true ]; then+ continue+ fi+ ;;+ esac+ printf '%s\n' "$path"+ done+ ;;+ dependency-scope)+ tmp=$(mktemp -d)+ trap 'rm -rf "$tmp"' EXIT+ files=$(cat)+ if [ -z "$files" ]; then+ printf 'blocking=true\nreason=the changed-file list is empty or unreadable\n'+ exit 0+ fi+ if hit=$(grep -E -m1 '^(bun\.lock|admin/bun\.lock|patches/)' <<< "$files"); then+ printf 'blocking=true\nreason=%s changed\n' "$hit"+ exit 0+ fi+ while IFS= read -r path; do+ case "$path" in+ package.json|admin/package.json)+ if ! fetch_pair "$path" "$tmp" || [ "$(dependency_change "$tmp/base.json" "$tmp/head.json")" = true ]; then+ printf 'blocking=true\nreason=%s dependency fields changed (or could not be read)\n' "$path"+ exit 0+ fi+ ;;+ esac+ done <<< "$files"+ printf 'blocking=false\nreason=no lockfile, patches/ or dependency-field change\n'+ ;;+ *)+ echo "Usage: bash scripts/ci-manifest-diff.sh version-only|dependency-change <base.json> <head.json>" >&2+ echo " bash scripts/ci-manifest-diff.sh drop-version-only|dependency-scope < changed-files" >&2+ exit 2+ ;;+esacdiff --git a/scripts/structural-suites.tsv b/scripts/structural-suites.tsvindex 91af9af8a5..7cae9abb04 100644--- a/scripts/structural-suites.tsv+++ b/scripts/structural-suites.tsv@@ -246,6 +246,7 @@ test/redos-hardening.test.ts #1569 --no-schema-pack + heartbeat wiring (structurtest/redos-hardening.test.ts megawave vm-watchdog removal (bootstrap-verify freeze) 5 readFileSynctest/register-client-source-normalize.test.ts register-client route wiring (structural) 1 readFileSynctest/reindex-code-recovery.test.ts CLI help line (#3970 surface 1) 1 source-surface-helper+test/release-workflow.test.ts release.yml publish-template skip is visible (D-10) 1 readFileSynctest/release-workflow.test.ts release.yml ↔ binary-self-update asset contract 11 readFileSynctest/remediation-command-resolution.test.ts #3697 — remediation text resolves against the live CLI surface 3 readFileSynctest/reranker-default-seam.test.ts DEFAULT_RERANKER_MODEL seam (#3657, flipped v0.48.2) 3 readFileSync@@ -265,6 +266,7 @@ test/scripts/ci-local-rendering.test.ts ci-local command rendering 1 readFileSyntest/scripts/ci-local-rendering.test.ts ci-local execution coverage 3 readFileSynctest/scripts/ci-local-rendering.test.ts local test configuration through run-e2e 2 readFileSynctest/scripts/ci-local-rendering.test.ts required PgBouncer execution through run-e2e 1 readFileSync+test/scripts/ci-manifest-diff.test.ts test.yml dependency-audit scope 2 readFileSynctest/scripts/ci-pr-scope.test.ts pull-request CI scope 8 readFileSynctest/scripts/ci-runner-routing.test.ts CI runner routing 6 readFileSynctest/scripts/classify-tests.test.ts classify-tests detectors 23 bun-file,doctor-source-helper,exec-scan,readFileSync,source-surface-helper@@ -276,9 +278,11 @@ test/scripts/e2e-runner.test.ts second 5 readFileSynctest/scripts/e2e-runner.test.ts sequential E2E runner (GITHUB_ACTIONS=${githubActions}) 7 readFileSynctest/scripts/e2e-wiring.test.ts e2e file claim ratchet 5 readFileSynctest/scripts/e2e-wiring.test.ts selected-e2e job wiring 6 readFileSync-test/scripts/heavy-door-workflow.test.ts heavy door supply chain and coverage gates 4 readFileSync+test/scripts/heavy-door-workflow.test.ts heavy door supply chain and coverage gates 8 readFileSynctest/scripts/native-lock-prebuilds.test.ts native lock distribution integrity 2 readFileSynctest/scripts/nightly-e2e.test.ts nightly E2E scheduling 4 readFileSync+test/scripts/nightly-issue.test.ts .github/nightly-known-red.tsv 2 readFileSync+test/scripts/nightly-issue.test.ts nightly-watch incidents 9 readFileSynctest/scripts/run-verify-parallel.test.ts guard registration ⇒ execution coverage 1 readFileSynctest/scripts/test-shard.slow.test.ts test-shard.sh — LPT balance contract 5 readFileSynctest/scripts/test-shard.slow.test.ts test-shard.sh — exclusion contract 7 readFileSyncdiff --git a/test/scripts/ci-manifest-diff.test.ts b/test/scripts/ci-manifest-diff.test.tsnew file mode 100644index 0000000000..b3a8f8e785--- /dev/null+++ b/test/scripts/ci-manifest-diff.test.ts@@ -0,0 +1,137 @@+/**+ * scripts/ci-manifest-diff.sh, scripts/ci-dependency-audit.sh and the+ * test.yml dependency-audit scope step (GBRA-47 B11, C11; ENG-17): manifest+ * diffs compare parsed JSON, unknown diffs fail closed, and bun audit blocks+ * only where the scope says so.+ */+import { describe, expect, test } from 'bun:test';+import { spawnSync } from 'node:child_process';+import { chmodSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';+import { tmpdir } from 'node:os';+import { join } from 'node:path';+import { safeLoad } from 'js-yaml';++const root = join(import.meta.dir, '../..');+const SCRIPT = join(root, 'scripts/ci-manifest-diff.sh');+const base = { name: 'gbrain', version: '0.60.48.0', scripts: { test: 'bun test' }, dependencies: { a: '1.0.0' } };++function withDir<T>(fn: (dir: string) => T): T {+ const dir = mkdtempSync(join(tmpdir(), 'gbrain-manifest-diff-'));+ try { return fn(dir); } finally { rmSync(dir, { recursive: true, force: true }); }+}++function compare(mode: string, head: unknown, baseJson: unknown = base): string {+ return withDir(dir => {+ writeFileSync(join(dir, 'base.json'), typeof baseJson === 'string' ? baseJson : JSON.stringify(baseJson));+ writeFileSync(join(dir, 'head.json'), typeof head === 'string' ? head : JSON.stringify(head, null, 4));+ const r = spawnSync('bash', [SCRIPT, mode, join(dir, 'base.json'), join(dir, 'head.json')], { encoding: 'utf8' });+ expect(r.status, r.stderr).toBe(0);+ return r.stdout.trim();+ });+}++/** A fake `gh` that serves PR files and per-ref file contents from a JSON map keyed by `<path>@<ref>`. */+function fakeGh(dir: string, files: string[] | 'error', contents: Record<string, unknown> = {}): string {+ writeFileSync(join(dir, 'contents.json'), JSON.stringify(contents));+ writeFileSync(join(dir, 'files.txt'), files === 'error' ? '' : files.join('\n') + '\n');+ writeFileSync(join(dir, 'gh'), `#!/usr/bin/env bash+args="$*"+if [[ "$args" == *"/pulls/"*"/files"* ]]; then+ ${files === 'error' ? 'exit 1' : `cat '${join(dir, 'files.txt')}'; exit 0`}+fi+if [[ "$args" =~ contents/([^?]+)\\?ref=([a-z]+) ]]; then+ key="\${BASH_REMATCH[1]}@\${BASH_REMATCH[2]}"+ jq -e --arg k "$key" '.[$k] // error("missing")' '${join(dir, 'contents.json')}' || exit 1+ exit 0+fi+exit 1+`);+ chmodSync(join(dir, 'gh'), 0o755);+ return dir;+}++describe('ci-manifest-diff.sh', () => {+ test('version-only is true only when nothing but the top-level version changed (parsed, so formatting is ignored)', () => {+ expect(compare('version-only', { ...base, version: '0.60.49.0' })).toBe('true');+ expect(compare('version-only', { ...base, version: '0.60.49.0', scripts: { test: 'bun test --x' } })).toBe('false');+ expect(compare('version-only', base)).toBe('false');+ expect(compare('version-only', '{not json')).toBe('false');+ });++ test('dependency-change looks at dependency fields only and fails closed on unreadable JSON', () => {+ expect(compare('dependency-change', { ...base, version: '9', scripts: {} })).toBe('false');+ expect(compare('dependency-change', { ...base, dependencies: { a: '1.0.1' } })).toBe('true');+ expect(compare('dependency-change', { ...base, overrides: { b: '2' } })).toBe('true');+ expect(compare('dependency-change', '{not json')).toBe('true');+ });++ test('drop-version-only removes a version-bump manifest and keeps every other path; unreadable revisions are kept', () => withDir(dir => {+ fakeGh(dir, [], {+ 'package.json@base': base, 'package.json@head': { ...base, version: '0.60.49.0' },+ 'openclaw.plugin.json@base': { version: '1' }, 'openclaw.plugin.json@head': { version: '1', id: 'changed' },+ });+ const r = spawnSync('bash', [SCRIPT, 'drop-version-only'], {+ input: 'package.json\nopenclaw.plugin.json\nsrc/x.ts\n', encoding: 'utf8',+ env: { PATH: `${dir}:${process.env.PATH}`, REPO: 'o/r', BASE_SHA: 'base', HEAD_SHA: 'head' },+ });+ expect(r.stdout).toBe('openclaw.plugin.json\nsrc/x.ts\n');+ const noRefs = spawnSync('bash', [SCRIPT, 'drop-version-only'], { input: 'package.json\n', encoding: 'utf8', env: { PATH: `${dir}:${process.env.PATH}` } });+ expect(noRefs.stdout).toBe('package.json\n');+ }));+});++describe('test.yml dependency-audit scope', () => {+ const step = (safeLoad(readFileSync(join(root, '.github/workflows/test.yml'), 'utf8')) as {+ jobs: Record<string, { steps: Array<{ id?: string; run?: string }> }>;+ }).jobs['dependency-audit'].steps.find(s => s.id === 'scope')!;++ const scope = (env: Record<string, string>, files: string[] | 'error', contents: Record<string, unknown> = {}) => withDir(dir => {+ fakeGh(dir, files, contents);+ const output = join(dir, 'out');+ writeFileSync(output, '');+ const r = spawnSync('bash', ['-c', step.run!], {+ cwd: root, encoding: 'utf8',+ env: { PATH: `${dir}:${process.env.PATH}`, PR: '7', REPO: 'o/r', LABELS: '[]', BASE_SHA: 'base', HEAD_SHA: 'head',+ CHANGED_FILES: files === 'error' ? '1' : String(files.length), GITHUB_OUTPUT: output, ...env },+ });+ expect(r.status, r.stderr).toBe(0);+ return Object.fromEntries(readFileSync(output, 'utf8').trim().split('\n').map(l => l.split('=', 2) as [string, string]));+ });++ test('pushes and schedules always block; a labelled PR blocks', () => {+ expect(scope({ EVENT: 'push' }, 'error').blocking).toBe('true');+ expect(scope({ EVENT: 'schedule' }, 'error').blocking).toBe('true');+ expect(scope({ EVENT: 'pull_request', LABELS: '["dependency-audit"]' }, ['docs/a.md']).blocking).toBe('true');+ });++ test('a PR blocks only on lockfile, patches/ or dependency-field changes, and on an unreadable diff', () => {+ expect(scope({ EVENT: 'pull_request' }, ['docs/a.md', 'src/x.ts'])).toEqual({ blocking: 'false', reason: 'no lockfile, patches/ or dependency-field change' });+ expect(scope({ EVENT: 'pull_request' }, ['src/x.ts', 'bun.lock']).blocking).toBe('true');+ expect(scope({ EVENT: 'pull_request' }, ['patches/[email protected]']).blocking).toBe('true');+ expect(scope({ EVENT: 'pull_request' }, ['package.json'], { 'package.json@base': base, 'package.json@head': { ...base, version: '2' } }).blocking).toBe('false');+ expect(scope({ EVENT: 'pull_request' }, ['package.json'], { 'package.json@base': base, 'package.json@head': { ...base, dependencies: { a: '2' } } }).blocking).toBe('true');+ expect(scope({ EVENT: 'pull_request' }, 'error').blocking).toBe('true');+ });+});++describe('ci-dependency-audit.sh', () => {+ const audit = (blocking: string, auditExit: number) => withDir(dir => {+ writeFileSync(join(dir, 'bun'), `#!/usr/bin/env bash\nexit ${auditExit}\n`);+ chmodSync(join(dir, 'bun'), 0o755);+ return spawnSync('bash', [join(root, 'scripts/ci-dependency-audit.sh')], {+ cwd: root, encoding: 'utf8', env: { PATH: `${dir}:${process.env.PATH}`, BLOCKING: blocking, REASON: 'r' },+ });+ });++ test('advisories fail a blocking run with the fix and warn on an advisory-only PR', () => {+ const blocked = audit('true', 1);+ expect(blocked.status).toBe(1);+ expect(blocked.stdout).toContain('::error::bun audit found advisories (blocking: r)');+ expect(blocked.stdout).toContain('Fix: bump the package');+ const advisory = audit('false', 1);+ expect(advisory.status).toBe(0);+ expect(advisory.stdout).toContain('::warning::bun audit found advisories; advisory-only');+ expect(advisory.stdout).toContain('add the dependency-audit label');+ expect(audit('false', 0).status).toBe(0);+ });+});diff --git a/test/scripts/ci-pr-scope.test.ts b/test/scripts/ci-pr-scope.test.tsindex 517736df07..35f102efa1 100644--- a/test/scripts/ci-pr-scope.test.ts+++ b/test/scripts/ci-pr-scope.test.ts@@ -99,6 +99,7 @@ describe('pull-request CI scope', () => {expect(run('schedule', 'exit 1')).toBe('native=full');expect(run('workflow_dispatch', 'exit 1')).toBe('native=full');expect(run('pull_request', 'exit 1')).toBe('native=primary');+ expect(run('merge_group', 'exit 1')).toBe('native=primary');expect(run('pull_request', "printf 'docs/a.md\\n'")).toBe('native=smoke');expect(run('pull_request', "printf 'src/core/pglite-lock.ts\\n'")).toBe('native=primary');for (const count of ['', 'invalid', '3000', '4230', '99999']) {@@ -118,18 +119,52 @@ describe('pull-request CI scope', () => {} finally { rmSync(dir, { recursive: true, force: true }); }});- test('security and persistence matrices drop only the oldest Bun version on pull requests', () => {+ test('a release-style version-only package.json diff does not widen the native scope (C11)', () => {+ const step = load('test.yml').jobs.changes.steps!.find(entry => entry.id === 'scope')!;+ const dir = mkdtempSync(join(tmpdir(), 'gbrain-ci-scope-c11-'));+ try {+ const run = (files: string[], headPkg: Record<string, unknown>) => {+ writeFileSync(join(dir, 'files'), files.join('\n') + '\n');+ writeFileSync(join(dir, 'base.json'), JSON.stringify({ name: 'gbrain', version: '1', scripts: { a: 'x' } }));+ writeFileSync(join(dir, 'head.json'), JSON.stringify(headPkg));+ writeFileSync(join(dir, 'gh'), `#!/usr/bin/env bash+case "$*" in+ *pulls/*/files*) cat '${join(dir, 'files')}' ;;+ *ref=base*) cat '${join(dir, 'base.json')}' ;;+ *ref=head*) cat '${join(dir, 'head.json')}' ;;+ *) exit 1 ;;+esac+`);+ chmodSync(join(dir, 'gh'), 0o755);+ const output = join(dir, 'out');+ writeFileSync(output, '');+ const result = spawnSync('bash', ['-c', step.run!], { cwd: root, encoding: 'utf8',+ env: { PATH: `${dir}:${process.env.PATH}`, EVENT: 'pull_request', PR: '7', REPO: 'example/repo', CHANGED_FILES: String(files.length),+ BASE_SHA: 'base', HEAD_SHA: 'head', GITHUB_OUTPUT: output } });+ expect(result.status, result.stderr).toBe(0);+ return readFileSync(output, 'utf8').trim();+ };+ expect(run(['CHANGELOG.md', 'package.json'], { name: 'gbrain', version: '2', scripts: { a: 'x' } })).toBe('native=smoke');+ expect(run(['package.json'], { name: 'gbrain', version: '2', scripts: { a: 'x' } })).toBe('native=smoke');+ expect(run(['CHANGELOG.md', 'package.json'], { name: 'gbrain', version: '2', scripts: { a: 'y' } })).toBe('native=primary');+ } finally { rmSync(dir, { recursive: true, force: true }); }+ });++ test('security and persistence matrices drop only the oldest Bun version on pull requests and merge-queue runs', () => {+ const queue = { github: { event_name: 'merge_group' } };const pr = { github: { event_name: 'pull_request' } };const push = { github: { event_name: 'push' } };const security = load('test.yml').jobs['security-regressions'];expect(cells(security, push)).toHaveLength(6);expect(cells(security, pr)).toEqual(['ubuntu-latest/1.4.2', 'macos-26/1.4.2', 'windows-latest/1.4.2']);+ expect(cells(security, queue)).toEqual(cells(security, pr));const persistence = load('persistence-validation.yml').jobs;for (const name of ['read-performance', 'deployment-matrix', 'invariants', 'reconciliation']) {const full = cells(persistence[name], push);const primary = cells(persistence[name], pr);expect(full.filter(cell => cell.endsWith(MINIMUM_BUN_VERSION)).length, name).toBe(full.length / 2);expect(primary, name).toEqual(full.filter(cell => cell.endsWith('1.4.2')));+ expect(cells(persistence[name], queue), name).toEqual(primary);}});@@ -137,6 +172,7 @@ describe('pull-request CI scope', () => {const step = load('test.yml').jobs['slow-entity-resolve-perf'].steps!.find(entry => entry.run?.includes('test/export-scale.slow.test.ts'))!;const expression = step.env!.GBRAIN_TEST_EXPORT_SCALE_PAGES!;expect(evaluate(expression, { github: { event_name: 'pull_request' } })).toBe('10001');+ expect(evaluate(expression, { github: { event_name: 'merge_group' } })).toBe('10001');for (const event_name of ['push', 'schedule', 'workflow_dispatch']) expect(evaluate(expression, { github: { event_name } })).toBe('100001');});diff --git a/test/scripts/data-safety-native-workflow.test.ts b/test/scripts/data-safety-native-workflow.test.tsindex 0ec5e7e335..29a0a7e497 100644--- a/test/scripts/data-safety-native-workflow.test.ts+++ b/test/scripts/data-safety-native-workflow.test.ts@@ -211,13 +211,13 @@ describe('data-safety native CI coverage', () => {]);});- test('pull requests run a 2,500-write persistence soak while master keeps the full 10,000-write gate', () => {+ test('pull requests and merge-queue runs run a 2,500-write persistence soak while master keeps the full 10,000-write gate', () => {const persistence = safeLoad(readFileSync(join(import.meta.dir, '../../.github/workflows/persistence-validation.yml'), 'utf8')) as {jobs: { invariants: { steps: Step[] } };};const step = persistence.jobs.invariants.steps.find(entry => entry.run?.includes('scripts/persistence/validate.ts'));expect(step).toBeDefined();- expect(step!.env?.SOAK_OPERATIONS).toBe("${{ github.event_name == 'pull_request' && '2500' || '10000' }}");+ expect(step!.env?.SOAK_OPERATIONS).toBe("${{ (github.event_name == 'pull_request' || github.event_name == 'merge_group') && '2500' || '10000' }}");for (const operations of ['2500', '10000']) {const result = Bun.spawnSync(['bash', '-e', '-o', 'pipefail', '-c', `bun() { printf '%s\\n' "$@"; }