Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
ci: wire master-push reuse, document full CI on pull requests (P1-P3)
garrytan60d841bbe47d
diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.ymlindex a56abd0950..77fe92aa5c 100644--- a/.github/workflows/e2e.yml+++ b/.github/workflows/e2e.yml@@ -49,6 +49,8 @@ jobs:# Postgres and HARD-FAILS if DATABASE_URL is missing, so the guard can never# silently skip.name: JSONB parity (#2339 regression guard)+ needs: [prepare-e2e]+ if: ${{ needs.prepare-e2e.outputs.reuse != 'true' }}runs-on: ubicloud-standard-4-ubuntu-2404timeout-minutes: 15services:@@ -144,13 +146,32 @@ jobs:permissions:contents: readpull-requests: read+ actions: readoutputs:matrix: ${{ steps.select.outputs.matrix }}+ reuse: ${{ steps.reuse.outputs.reuse }}+ reuse-source-run-id: ${{ steps.reuse.outputs.source_run_id }}steps:- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2with:bun-version: 1.4.3+ # Master-push reuse (P2, scripts/ci-reuse.ts): a push whose tree equals the+ # tree of a passed full-suite run skips every full lane and records the+ # reused run. Any doubt, a crash included, leaves reuse unset: a full run.+ - id: reuse+ if: github.event_name == 'push'+ continue-on-error: true+ env:+ GH_TOKEN: ${{ github.token }}+ run: bun scripts/ci-reuse.ts --workflow e2e --sha "$GITHUB_SHA" --repo "$GITHUB_REPOSITORY" --output "$GITHUB_OUTPUT" --summary "$GITHUB_STEP_SUMMARY" --record "$RUNNER_TEMP/reuse.json"+ - if: steps.reuse.outputs.reuse == 'true'+ uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4+ with:+ name: reused-full-suite+ path: ${{ runner.temp }}/reuse.json+ if-no-files-found: error+ retention-days: 90- name: Select and freeze E2E filesid: selectshell: bash@@ -190,12 +211,13 @@ jobs:selected-e2e:name: Selected E2E (diff-relevant) ${{ matrix.shard }}- needs: prepare-e2e+ needs: [prepare-e2e]strategy:fail-fast: falsematrix: ${{ fromJSON(needs.prepare-e2e.outputs.matrix) }}# 2 vCPUs, up to 8 shards (C1): run-e2e.sh runs one bun process at a time,# and a 25-file sample took 442s on 2 cores vs 455s on 4.+ if: ${{ needs.prepare-e2e.outputs.reuse != 'true' }}runs-on: ubicloud-standard-2-ubuntu-2404timeout-minutes: 60services:@@ -276,6 +298,8 @@ jobs:# Tier 1 stays on 16 vCPUs: on 4 its CLI `init --url` spawns in# mechanical.test.ts went from ~2s to past their 15-30s kill timeouts# (measured September 29, 2026), while every other E2E lane ran as fast.+ needs: [prepare-e2e]+ if: ${{ needs.prepare-e2e.outputs.reuse != 'true' }}runs-on: ubicloud-standard-16-ubuntu-2404timeout-minutes: 70services:@@ -454,6 +478,8 @@ jobs:# E2E (C3).tier1-backend-matrix:name: Tier 1 backend matrix (direct + PgBouncer) ${{ matrix.shard }}/2+ needs: [prepare-e2e]+ if: ${{ needs.prepare-e2e.outputs.reuse != 'true' }}runs-on: ubicloud-standard-4-ubuntu-2404# Two weighted shards: the whole matrix took 715s on one 4-vCPU runner# (the PR critical path); files run sequentially, so a split halves it.@@ -1041,8 +1067,8 @@ jobs:# in e2e-status; baseline comparisons run locally with# bun scripts/ci-executed-counts.ts --base-run <id> --head-run <id>executed-receipts:- needs: [jsonb-parity, tier1, tier1-backend-matrix, tier2, selected-e2e, coverage-full-unit, coverage-full-serial, coverage-full-e2e]- if: always()+ needs: [prepare-e2e, jsonb-parity, tier1, tier1-backend-matrix, tier2, selected-e2e, coverage-full-unit, coverage-full-serial, coverage-full-e2e]+ if: ${{ needs.prepare-e2e.outputs.reuse != 'true' && always() }}runs-on: ubicloud-standard-2-ubuntu-2404timeout-minutes: 10steps:@@ -1100,7 +1126,7 @@ jobs:# full-corpus lanes to the aggregate on the nightly schedule only.e2e-status:needs: [jsonb-parity, tier1, tier1-backend-matrix, tier2, prepare-e2e, selected-e2e, coverage-full-unit, coverage-full-serial, coverage-full-slow, coverage-full-e2e]- if: always()+ if: ${{ needs.prepare-e2e.outputs.reuse != 'true' && always() }}runs-on: ubicloud-standard-2-ubuntu-2404timeout-minutes: 5steps:@@ -1166,7 +1192,7 @@ jobs:if: github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && inputs.full_corpus)run: bun scripts/verify-nightly-e2e.ts "$RUNNER_TEMP/e2e-execution" 4 "$GITHUB_SHA"- # Full CI on pull requests (docs/TESTING.md#full-ci-on-pull-requests): the E2E+ # Full CI on pull requests (docs/ci-event-parity.md#full-ci-on-pull-requests): the E2E# check merge-train reads. E2E does not run on pull_request events; it runs# in the full-ci dispatch on a pull request's head, on every push to master,# in the merge queue and on the nightly schedule. It succeeds only when@@ -1175,8 +1201,8 @@ jobs:# Event parity (docs/TESTING.md#event-parity): the same job on every event;# EVENT only labels the recorded tree.e2e-full-suite:- needs: [e2e-status]- if: always()+ needs: [prepare-e2e, e2e-status]+ if: ${{ needs.prepare-e2e.outputs.reuse != 'true' && always() }}runs-on: ubicloud-standard-2-ubuntu-2404timeout-minutes: 5steps:@@ -1207,3 +1233,16 @@ jobs:path: ${{ runner.temp }}/full-suite/tree.jsonretention-days: 30overwrite: true++ # Master-push reuse marker (scripts/ci-reuse.ts, scripts/release-gate.ts): exists+ # only in a push run that reused a passed full-suite run of its exact tree; the+ # release gate reads its reuse.json.+ reused-full-suite:+ needs: [prepare-e2e]+ if: ${{ needs.prepare-e2e.outputs.reuse == 'true' }}+ runs-on: ubicloud-standard-2-ubuntu-2404+ timeout-minutes: 2+ steps:+ - env:+ SOURCE: ${{ needs.prepare-e2e.outputs.reuse-source-run-id }}+ run: echo "Reused full-suite run $SOURCE (identical tree)"diff --git a/.github/workflows/persistence-validation.yml b/.github/workflows/persistence-validation.ymlindex 61d81e3917..215d0de6a9 100644--- a/.github/workflows/persistence-validation.yml+++ b/.github/workflows/persistence-validation.yml@@ -14,7 +14,7 @@ permissions:contents: readjobs:- # Event parity (docs/TESTING.md#full-ci-on-pull-requests): full profile only; a+ # Event parity (docs/ci-event-parity.md#full-ci-on-pull-requests): full profile only; a# pull request (cheap tier) runs only the crash robot and convergence here. The# full-ci dispatch on its head, every push and the nightly run this lane.read-performance:@@ -61,7 +61,7 @@ jobs:path: .context/persistence-read-latency.jsonif-no-files-found: error- # Event parity (docs/TESTING.md#full-ci-on-pull-requests): full profile only; a+ # Event parity (docs/ci-event-parity.md#full-ci-on-pull-requests): full profile only; a# pull request (cheap tier) runs only the crash robot and convergence here. The# full-ci dispatch on its head, every push and the nightly run this lane.deployment-matrix:@@ -190,7 +190,7 @@ jobs:# balanced by measured runtime (scripts/postgres-arm-weights.json, mined from# this job's logs); each shard's measured sum, doubled for a slow runner, must# end a minute inside the step's 20 minutes (ARM_SHARD_BUDGET_MS).- # Event parity (docs/TESTING.md#full-ci-on-pull-requests): full profile only; a+ # Event parity (docs/ci-event-parity.md#full-ci-on-pull-requests): full profile only; a# pull request (cheap tier) runs only the crash robot and convergence here. The# full-ci dispatch on its head, every push and the nightly run this lane.unit-postgres-arms:@@ -278,7 +278,7 @@ jobs:if-no-files-found: warnoverwrite: true- # Event parity (docs/TESTING.md#full-ci-on-pull-requests): full profile only; a+ # Event parity (docs/ci-event-parity.md#full-ci-on-pull-requests): full profile only; a# pull request (cheap tier) runs only the crash robot and convergence here. The# full-ci dispatch on its head, every push and the nightly run this lane.invariants:@@ -418,7 +418,7 @@ jobs:# The reconciliation crash suites run beside the soak instead of after it, so# neither holds the other's runner: each is about four minutes on PGLite.- # Event parity (docs/TESTING.md#full-ci-on-pull-requests): full profile only; a+ # Event parity (docs/ci-event-parity.md#full-ci-on-pull-requests): full profile only; a# pull request (cheap tier) runs only the crash robot and convergence here. The# full-ci dispatch on its head, every push and the nightly run this lane.reconciliation:diff --git a/.github/workflows/release.yml b/.github/workflows/release.ymlindex 0ec4d592ba..2e9e4e76aa 100644--- a/.github/workflows/release.yml+++ b/.github/workflows/release.yml@@ -80,6 +80,8 @@ jobs:outputs:publish: ${{ steps.gate.outputs.publish }}sha: ${{ steps.gate.outputs.sha }}+ test_reused_run_id: ${{ steps.gate.outputs.test_reused_run_id }}+ e2e_reused_run_id: ${{ steps.gate.outputs.e2e_reused_run_id }}steps:- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4with:diff --git a/.github/workflows/test.yml b/.github/workflows/test.ymlindex 04af0c6910..61c988108d 100644--- a/.github/workflows/test.yml+++ b/.github/workflows/test.yml@@ -80,9 +80,12 @@ jobs:permissions:contents: readpull-requests: read+ actions: readoutputs:native-scope: ${{ steps.scope.outputs.native }}convergence: ${{ steps.convergence.outputs.convergence }}+ reuse: ${{ steps.reuse.outputs.reuse }}+ reuse-source-run-id: ${{ steps.reuse.outputs.source_run_id }}steps:- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4with:@@ -90,7 +93,29 @@ jobs:scripts/ci-native-scope.shscripts/ci-manifest-diff.shscripts/ci-convergence-scope.sh+ scripts/ci-reuse.ts+ scripts/lib/gh-issue.tssparse-checkout-cone-mode: false+ - if: github.event_name == 'push'+ uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2+ with:+ bun-version: 1.4.3+ # Master-push reuse (P2, scripts/ci-reuse.ts): a push whose tree equals the+ # tree of a passed full-suite run skips every full lane and records the+ # reused run. Any doubt, a crash included, leaves reuse unset: a full run.+ - id: reuse+ if: github.event_name == 'push'+ continue-on-error: true+ env:+ GH_TOKEN: ${{ github.token }}+ run: bun scripts/ci-reuse.ts --workflow test --sha "$GITHUB_SHA" --repo "$GITHUB_REPOSITORY" --output "$GITHUB_OUTPUT" --summary "$GITHUB_STEP_SUMMARY" --record "$RUNNER_TEMP/reuse.json"+ - if: steps.reuse.outputs.reuse == 'true'+ uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4+ with:+ name: reused-full-suite+ path: ${{ runner.temp }}/reuse.json+ if-no-files-found: error+ retention-days: 90- id: scopeenv:GH_TOKEN: ${{ github.token }}@@ -154,7 +179,7 @@ jobs:echo "convergence gate: $convergence"echo "convergence=$convergence" >> "$GITHUB_OUTPUT"- # Re-run checks for every event. Only dependencies and PGLite snapshots are cached.+ # Re-run checks for every event, except a master push reusing a passed full-suite run of its exact tree (scripts/ci-reuse.ts). Only dependencies and PGLite snapshots are cached.gitleaks:if: ${{ github.event_name != 'workflow_dispatch' || (inputs.native_only != true && inputs.race_hunt != true && !inputs.stress_files && !inputs.stress_base) }}runs-on: ubicloud-standard-2-ubuntu-2404@@ -468,12 +493,13 @@ jobs:path: node_modules/.cache/gbrain-typecheck.tsbuildinfokey: tsbuildinfo-${{ runner.os }}-${{ hashFiles('bun.lock', 'tsconfig.json') }}-${{ github.sha }}- # Event parity (docs/TESTING.md#full-ci-on-pull-requests): full profile only. A+ # Event parity (docs/ci-event-parity.md#full-ci-on-pull-requests): full profile only. A# pull request runs the cheap tier; this job runs in the full-ci dispatch on its# head before merge (merge-train requires full-suite), on every push to master# and on the nightly schedule.serial-tests:- if: ${{ github.event_name != 'pull_request' && (github.event_name != 'workflow_dispatch' || (inputs.native_only != true && inputs.race_hunt != true && !inputs.stress_files && !inputs.stress_base)) }}+ needs: [changes]+ if: ${{ needs.changes.outputs.reuse != 'true' && (github.event_name != 'pull_request' && (github.event_name != 'workflow_dispatch' || (inputs.native_only != true && inputs.race_hunt != true && !inputs.stress_files && !inputs.stress_base))) }}# *.serial.test.ts — one bun process per file (module-registry isolation),# POOLED across files by scripts/run-serial-tests.sh (was strictly# sequential: an 8.5-minute job whose serialization the quarantine@@ -564,12 +590,13 @@ jobs:retention-days: 14overwrite: true- # Event parity (docs/TESTING.md#full-ci-on-pull-requests): full profile only. A+ # Event parity (docs/ci-event-parity.md#full-ci-on-pull-requests): full profile only. A# pull request runs the cheap tier; this job runs in the full-ci dispatch on its# head before merge (merge-train requires full-suite), on every push to master# and on the nightly schedule.slow-brainbench-e2e:- if: ${{ github.event_name != 'pull_request' && (github.event_name != 'workflow_dispatch' || (inputs.native_only != true && inputs.race_hunt != true && !inputs.stress_files && !inputs.stress_base)) }}+ needs: [changes]+ if: ${{ needs.changes.outputs.reuse != 'true' && (github.event_name != 'pull_request' && (github.event_name != 'workflow_dispatch' || (inputs.native_only != true && inputs.race_hunt != true && !inputs.stress_files && !inputs.stress_base))) }}# Dedicated runner for the BrainBench CLI e2e file. At 98s mined it was# the matrix's single heaviest atom (10% of the whole corpus weight) and# the hard floor on shard-count scaling; a Phase-2 rewrite (spawn batching@@ -645,12 +672,13 @@ jobs:if-no-files-found: ignoreoverwrite: true- # Event parity (docs/TESTING.md#full-ci-on-pull-requests): full profile only. A+ # Event parity (docs/ci-event-parity.md#full-ci-on-pull-requests): full profile only. A# pull request runs the cheap tier; this job runs in the full-ci dispatch on its# head before merge (merge-train requires full-suite), on every push to master# and on the nightly schedule.brainbench:- if: ${{ github.event_name != 'pull_request' && (github.event_name != 'workflow_dispatch' || (inputs.native_only != true && inputs.race_hunt != true && !inputs.stress_files && !inputs.stress_base)) }}+ needs: [changes]+ if: ${{ needs.changes.outputs.reuse != 'true' && (github.event_name != 'pull_request' && (github.event_name != 'workflow_dispatch' || (inputs.native_only != true && inputs.race_hunt != true && !inputs.stress_files && !inputs.stress_base))) }}# BrainBench memory-conformance gate (Cathedral 2). Hermetic: in-memory# PGLite, zero API keys, ~15s for the full 141-fixture × 3-harness run.# Governance (decision 4): compares HEAD's run against MAIN's committed@@ -693,12 +721,13 @@ jobs:bun scripts/render-brainbench-delta.ts "${{ runner.temp }}/brainbench-result.json" >> "$GITHUB_STEP_SUMMARY"fi- # Event parity (docs/TESTING.md#full-ci-on-pull-requests): full profile only. A+ # Event parity (docs/ci-event-parity.md#full-ci-on-pull-requests): full profile only. A# pull request runs the cheap tier; this job runs in the full-ci dispatch on its# head before merge (merge-train requires full-suite), on every push to master# and on the nightly schedule.slow-entity-resolve-perf:- if: ${{ github.event_name != 'pull_request' && (github.event_name != 'workflow_dispatch' || (inputs.native_only != true && inputs.race_hunt != true && !inputs.stress_files && !inputs.stress_base)) }}+ needs: [changes]+ if: ${{ needs.changes.outputs.reuse != 'true' && (github.event_name != 'pull_request' && (github.event_name != 'workflow_dispatch' || (inputs.native_only != true && inputs.race_hunt != true && !inputs.stress_files && !inputs.stress_base))) }}# Dedicated runner for the entity-resolve perf test (~159s, single perf# describe with one test that builds 5000+ pages and asserts the NEW# tryPrefixExpansion shape is 5x faster than the OLD shape — not@@ -781,12 +810,13 @@ jobs:bun run src/cli.ts init --pglite --no-embedding --non-interactivebun run src/cli.ts protocol conformance --synthesize- # Event parity (docs/TESTING.md#full-ci-on-pull-requests): full profile only. A+ # Event parity (docs/ci-event-parity.md#full-ci-on-pull-requests): full profile only. A# pull request runs the cheap tier; this job runs in the full-ci dispatch on its# head before merge (merge-train requires full-suite), on every push to master# and on the nightly schedule.test:- if: ${{ github.event_name != 'pull_request' && (github.event_name != 'workflow_dispatch' || (inputs.native_only != true && inputs.race_hunt != true && !inputs.stress_files && !inputs.stress_base)) }}+ needs: [changes]+ if: ${{ needs.changes.outputs.reuse != 'true' && (github.event_name != 'pull_request' && (github.event_name != 'workflow_dispatch' || (inputs.native_only != true && inputs.race_hunt != true && !inputs.stress_files && !inputs.stress_base))) }}# Pure matrix shard — no verify, no serial. Each shard runs its slice# of the unit test set under one `bun test` invocation.#@@ -901,13 +931,13 @@ jobs:# `always()` is load-bearing: without it, a failed shard skips this job at# exactly the moment the (degraded) report matters most.# ──────────────────────────────────────────────────────────────────────- # Event parity (docs/TESTING.md#full-ci-on-pull-requests): full profile only. A+ # Event parity (docs/ci-event-parity.md#full-ci-on-pull-requests): full profile only. A# pull request runs the cheap tier; this job runs in the full-ci dispatch on its# head before merge (merge-train requires full-suite), on every push to master# and on the nightly schedule.coverage-report:- needs: [serial-tests, slow-entity-resolve-perf, slow-brainbench-e2e, test]- if: ${{ always() && github.event_name != 'pull_request' && (github.event_name != 'workflow_dispatch' || (inputs.native_only != true && inputs.race_hunt != true && !inputs.stress_files && !inputs.stress_base)) }}+ needs: [changes, serial-tests, slow-entity-resolve-perf, slow-brainbench-e2e, test]+ if: ${{ needs.changes.outputs.reuse != 'true' && always() && github.event_name != 'pull_request' && (github.event_name != 'workflow_dispatch' || (inputs.native_only != true && inputs.race_hunt != true && !inputs.stress_files && !inputs.stress_base)) }}runs-on: ubicloud-standard-4-ubuntu-2404timeout-minutes: 10steps:@@ -963,23 +993,23 @@ jobs:if-no-files-found: ignoreoverwrite: true- # Event parity (docs/TESTING.md#full-ci-on-pull-requests): a pull request (cheap+ # Event parity (docs/ci-event-parity.md#full-ci-on-pull-requests): a pull request (cheap# tier) runs the native cells only when its diff touches native code (scope other# than smoke); the full-ci dispatch, every push and the nightly run them all.native-locks:needs: [changes]- if: ${{ (github.event_name != 'pull_request' || needs.changes.outputs.native-scope != 'smoke') && (github.event_name != 'workflow_dispatch' || (inputs.race_hunt != true && !inputs.stress_files && !inputs.stress_base)) }}+ if: ${{ needs.changes.outputs.reuse != 'true' && ((github.event_name != 'pull_request' || needs.changes.outputs.native-scope != 'smoke') && (github.event_name != 'workflow_dispatch' || (inputs.race_hunt != true && !inputs.stress_files && !inputs.stress_base))) }}uses: ./.github/workflows/native-locks.ymlwith:scope: ${{ needs.changes.outputs.native-scope }}- # Event parity (docs/TESTING.md#full-ci-on-pull-requests): a pull request (cheap+ # Event parity (docs/ci-event-parity.md#full-ci-on-pull-requests): a pull request (cheap# tier) calls it only when its diff can change persistence or managed sync, and# then runs only the crash robot and convergence; the full-ci dispatch, every# push and the nightly run every lane.persistence-validation:needs: [changes]- if: ${{ (github.event_name != 'pull_request' || needs.changes.outputs.convergence != 'skip') && (github.event_name != 'workflow_dispatch' || (inputs.native_only != true && inputs.race_hunt != true && !inputs.stress_files && !inputs.stress_base)) }}+ if: ${{ needs.changes.outputs.reuse != 'true' && ((github.event_name != 'pull_request' || needs.changes.outputs.convergence != 'skip') && (github.event_name != 'workflow_dispatch' || (inputs.native_only != true && inputs.race_hunt != true && !inputs.stress_files && !inputs.stress_base))) }}uses: ./.github/workflows/persistence-validation.ymlwith:convergence: ${{ needs.changes.outputs.convergence || 'run' }}@@ -1018,12 +1048,13 @@ jobs:with:mode: race-hunt- # Event parity (docs/TESTING.md#full-ci-on-pull-requests): full profile only. A+ # Event parity (docs/ci-event-parity.md#full-ci-on-pull-requests): full profile only. A# pull request runs the cheap tier; this job runs in the full-ci dispatch on its# head before merge (merge-train requires full-suite), on every push to master# and on the nightly schedule.admin-browser:- if: ${{ github.event_name != 'pull_request' && (github.event_name != 'workflow_dispatch' || (inputs.native_only != true && inputs.race_hunt != true && !inputs.stress_files && !inputs.stress_base)) }}+ needs: [changes]+ if: ${{ needs.changes.outputs.reuse != 'true' && (github.event_name != 'pull_request' && (github.event_name != 'workflow_dispatch' || (inputs.native_only != true && inputs.race_hunt != true && !inputs.stress_files && !inputs.stress_base))) }}runs-on: ubicloud-standard-4-ubuntu-2404timeout-minutes: 12steps:@@ -1070,12 +1101,13 @@ jobs:include-hidden-files: trueretention-days: 7- # Event parity (docs/TESTING.md#full-ci-on-pull-requests): full profile only. A+ # Event parity (docs/ci-event-parity.md#full-ci-on-pull-requests): full profile only. A# pull request runs the cheap tier; this job runs in the full-ci dispatch on its# head before merge (merge-train requires full-suite), on every push to master# and on the nightly schedule.shared-skills-compatibility:- if: ${{ github.event_name != 'pull_request' && (github.event_name != 'workflow_dispatch' || (inputs.native_only != true && inputs.race_hunt != true && !inputs.stress_files && !inputs.stress_base)) }}+ needs: [changes]+ if: ${{ needs.changes.outputs.reuse != 'true' && (github.event_name != 'pull_request' && (github.event_name != 'workflow_dispatch' || (inputs.native_only != true && inputs.race_hunt != true && !inputs.stress_files && !inputs.stress_base))) }}runs-on: ubicloud-standard-4-ubuntu-2404timeout-minutes: 10steps:@@ -1108,8 +1140,8 @@ jobs:# comparison against a baseline run is the parent's local call:# bun scripts/ci-executed-counts.ts --base-run <id> --head-run <id>executed-receipts:- needs: [verify, serial-tests, slow-entity-resolve-perf, slow-brainbench-e2e, test, shared-skills-compatibility, persistence-validation]- if: ${{ always() && (github.event_name != 'workflow_dispatch' || (inputs.native_only != true && inputs.race_hunt != true && !inputs.stress_files && !inputs.stress_base)) }}+ needs: [changes, verify, serial-tests, slow-entity-resolve-perf, slow-brainbench-e2e, test, shared-skills-compatibility, persistence-validation]+ if: ${{ needs.changes.outputs.reuse != 'true' && always() && (github.event_name != 'workflow_dispatch' || (inputs.native_only != true && inputs.race_hunt != true && !inputs.stress_files && !inputs.stress_base)) }}runs-on: ubicloud-standard-2-ubuntu-2404timeout-minutes: 10steps:@@ -1162,19 +1194,20 @@ jobs:# The stable aggregate succeeds only when every required lane ran successfully.# Coverage percentages remain advisory until their separate graduation.- # Event parity (docs/TESTING.md#full-ci-on-pull-requests): full profile only. A+ # Event parity (docs/ci-event-parity.md#full-ci-on-pull-requests): full profile only. A# pull request runs the cheap tier; this job runs in the full-ci dispatch on its# head before merge (merge-train requires full-suite), on every push to master# and on the nightly schedule.test-status:name: ${{ (github.event_name == 'pull_request' || (github.event_name == 'workflow_dispatch' && (inputs.native_only == true || inputs.race_hunt == true || inputs.stress_files != '' || inputs.stress_base != ''))) && 'full-suite-not-run' || 'test-status' }}- needs: [gitleaks, security-regressions, dependency-audit, verify, typecheck, serial-tests, slow-entity-resolve-perf, slow-brainbench-e2e, brainbench, test, native-locks, persistence-validation, admin-browser, shared-skills-compatibility, stress-changed-tests]- if: ${{ always() && github.event_name != 'pull_request' && (github.event_name != 'workflow_dispatch' || (inputs.native_only != true && inputs.race_hunt != true && !inputs.stress_files && !inputs.stress_base)) }}+ needs: [changes, gitleaks, security-regressions, dependency-audit, verify, typecheck, serial-tests, slow-entity-resolve-perf, slow-brainbench-e2e, brainbench, test, native-locks, persistence-validation, admin-browser, shared-skills-compatibility, stress-changed-tests]+ if: ${{ needs.changes.outputs.reuse != 'true' && always() && github.event_name != 'pull_request' && (github.event_name != 'workflow_dispatch' || (inputs.native_only != true && inputs.race_hunt != true && !inputs.stress_files && !inputs.stress_base)) }}runs-on: ubicloud-standard-2-ubuntu-2404timeout-minutes: 5steps:- name: Aggregate resultrun: |+ CHANGES="${{ needs.changes.result }}"GITLEAKS="${{ needs.gitleaks.result }}"SECURITY="${{ needs.security-regressions.result }}"AUDIT="${{ needs.dependency-audit.result }}"@@ -1190,9 +1223,9 @@ jobs:ADMIN_BROWSER="${{ needs.admin-browser.result }}"SKILL_COMPATIBILITY="${{ needs.shared-skills-compatibility.result }}"STRESS="${{ needs.stress-changed-tests.result }}"- echo "gitleaks=$GITLEAKS security-regressions=$SECURITY dependency-audit=$AUDIT verify=$VERIFY typecheck=$TYPECHECK serial-tests=$SERIAL slow-entity-resolve-perf=$SLOW_PERF slow-brainbench-e2e=$SLOW_BRAINBENCH brainbench=$BRAINBENCH test=$TEST native-locks=$NATIVE_LOCKS persistence=$PERSISTENCE admin-browser=$ADMIN_BROWSER"+ echo "changes=$CHANGES gitleaks=$GITLEAKS security-regressions=$SECURITY dependency-audit=$AUDIT verify=$VERIFY typecheck=$TYPECHECK serial-tests=$SERIAL slow-entity-resolve-perf=$SLOW_PERF slow-brainbench-e2e=$SLOW_BRAINBENCH brainbench=$BRAINBENCH test=$TEST native-locks=$NATIVE_LOCKS persistence=$PERSISTENCE admin-browser=$ADMIN_BROWSER"echo "shared-skills-compatibility=$SKILL_COMPATIBILITY stress-changed-tests=$STRESS"- for r in "$GITLEAKS" "$SECURITY" "$AUDIT" "$VERIFY" "$TYPECHECK" "$SERIAL" "$SLOW_PERF" "$SLOW_BRAINBENCH" "$BRAINBENCH" "$TEST" "$NATIVE_LOCKS" "$PERSISTENCE" "$ADMIN_BROWSER" "$SKILL_COMPATIBILITY" "$STRESS"; do+ for r in "$CHANGES" "$GITLEAKS" "$SECURITY" "$AUDIT" "$VERIFY" "$TYPECHECK" "$SERIAL" "$SLOW_PERF" "$SLOW_BRAINBENCH" "$BRAINBENCH" "$TEST" "$NATIVE_LOCKS" "$PERSISTENCE" "$ADMIN_BROWSER" "$SKILL_COMPATIBILITY" "$STRESS"; doif [ "$r" != "success" ]; thenecho "✗ gated job did not succeed (got $r) — CI fail"exit 1@@ -1201,17 +1234,17 @@ jobs:echo "✓ all gated jobs succeeded — CI green"- # Full CI on pull requests (docs/TESTING.md#full-ci-on-pull-requests): the+ # Full CI on pull requests (docs/ci-event-parity.md#full-ci-on-pull-requests): the# check merge-train reads. It succeeds only when test-status did on the same# run, and a pull-request run (the cheap tier) names it full-suite-not-run, so# a cheap green can never produce it. Its artifact records the tree the run# tested, which scripts/ci-reuse.ts compares on a push to master.- # Event parity (docs/TESTING.md#full-ci-on-pull-requests): full profile only;+ # Event parity (docs/ci-event-parity.md#full-ci-on-pull-requests): full profile only;# a pull request gets it from the full-ci dispatch on its head.full-suite:name: ${{ (github.event_name == 'pull_request' || (github.event_name == 'workflow_dispatch' && (inputs.native_only == true || inputs.race_hunt == true || inputs.stress_files != '' || inputs.stress_base != ''))) && 'full-suite-not-run' || 'full-suite' }}- needs: [test-status]- if: ${{ always() && github.event_name != 'pull_request' && (github.event_name != 'workflow_dispatch' || (inputs.native_only != true && inputs.race_hunt != true && !inputs.stress_files && !inputs.stress_base)) }}+ needs: [changes, test-status]+ if: ${{ needs.changes.outputs.reuse != 'true' && always() && github.event_name != 'pull_request' && (github.event_name != 'workflow_dispatch' || (inputs.native_only != true && inputs.race_hunt != true && !inputs.stress_files && !inputs.stress_base)) }}runs-on: ubicloud-standard-2-ubuntu-2404timeout-minutes: 5steps:@@ -1243,11 +1276,11 @@ jobs:retention-days: 30overwrite: true- # The cheap tier's result (docs/TESTING.md#full-ci-on-pull-requests). It never+ # The cheap tier's result (docs/ci-event-parity.md#full-ci-on-pull-requests). It never# reports test-status or full-suite; its name and step summary say the full# suite did not run. The persistence and native lanes may be skipped only when# their own diff selectors left them out.- # Event parity (docs/TESTING.md#full-ci-on-pull-requests): pull requests only;+ # Event parity (docs/ci-event-parity.md#full-ci-on-pull-requests): pull requests only;# every other event runs the full profile and reports full-suite instead.cheap-tier:name: cheap-tier (full suite not run)@@ -1275,6 +1308,19 @@ jobs:CONVERGENCE: ${{ needs.changes.outputs.convergence }}run: bash scripts/ci-cheap-tier.sh+ # Master-push reuse marker (scripts/ci-reuse.ts, scripts/release-gate.ts): exists+ # only in a push run that reused a passed full-suite run of its exact tree; the+ # release gate reads its reuse.json.+ reused-full-suite:+ needs: [changes]+ if: ${{ needs.changes.outputs.reuse == 'true' }}+ runs-on: ubicloud-standard-2-ubuntu-2404+ timeout-minutes: 2+ steps:+ - env:+ SOURCE: ${{ needs.changes.outputs.reuse-source-run-id }}+ run: echo "Reused full-suite run $SOURCE (identical tree)"+# A native-only run emits its own scoped result, never the required full-suite check.native-only-status:name: Native-only result (full CI not run)diff --git a/docs/RELEASING.md b/docs/RELEASING.mdindex 4220476ad6..e8f1c76c71 100644--- a/docs/RELEASING.md+++ b/docs/RELEASING.md@@ -555,6 +555,12 @@ succeed on the release commit.- **Backfill:** `gh workflow run release.yml --ref master` gates and publishesmaster HEAD's VERSION. Other refs are refused.- The gate waits up to 110 minutes, then fails with the backfill command.+- **Reused push run:** a push run that reused a passed full-suite run of its+ exact tree ([master-push reuse](ci-event-parity.md#master-push-reuse))+ publishes only with a readable `reuse.json` naming the same workflow, the+ push head and a valid source run. The gate prints the reused run per+ workflow and writes `test_reused_run_id` / `e2e_reused_run_id` (empty when+ that workflow ran in full); the `ci-gate` job exposes both as outputs.### The `latest-stable` tagdiff --git a/docs/TESTING.md b/docs/TESTING.mdindex 09ec6054b0..ff015987ca 100644--- a/docs/TESTING.md+++ b/docs/TESTING.md@@ -80,13 +80,13 @@ the decision rule is critical path first, vCPU-minutes second.### Event parity-Every test file runs on every push to master, on the nightly schedule and on-manual dispatch, and pull requests and merge-queue runs (`merge_group`) run-every Bun-version cell too. Each narrower PR behavior is a named exception-whose comment names the scheduled run that covers it-(`test/scripts/ci-pr-scope.test.ts` fails on an unclassified one). Table,-dependency-audit rule and cost: [docs/ci-event-parity.md](ci-event-parity.md). Required checks stay keyed on-the `test-status` and `e2e-status` aggregators.+Every test file and Bun cell runs on each push to master, nightly, on manual+dispatch and in the merge queue. A pull request runs the cheap tier;+merge needs `full-suite` and `e2e-full-suite` from a full run on its head+([full CI for PRs](ci-event-parity.md#full-ci-on-pull-requests)).+Each narrower PR behavior is a named exception whose comment names the run+covering it (`test/scripts/ci-pr-scope.test.ts` fails on an unclassified one).+Table, audit rule and cost: [docs/ci-event-parity.md](ci-event-parity.md).The `changes` job classifies a pull request's changed files with`scripts/ci-native-scope.sh`: native lock sources, the native toolchain, IPC,diff --git a/docs/ci-event-parity.md b/docs/ci-event-parity.mdindex 273d61b887..f6a1ae1a4b 100644--- a/docs/ci-event-parity.md+++ b/docs/ci-event-parity.md@@ -10,8 +10,8 @@ covers it. A condition with no covering scheduled run defaults to parity;anything else needs a new scheduled run or a decision recorded beside thecondition. `test/scripts/ci-pr-scope.test.ts` fails on an event-conditionaljob or block in a test workflow without that comment, and on a Bun-version-cell excluded on any event. Required checks stay keyed on the `test-status`-and `e2e-status` aggregators, never on per-cell matrix names.+cell excluded on any event. Merge reads the `full-suite` and `e2e-full-suite`+checks ([below](#full-ci-on-pull-requests)), never per-cell matrix names.## Classification@@ -26,13 +26,16 @@ and `e2e-status` aggregators, never on per-cell matrix names.| `test.yml` | `race-hunt` | Named exception: schedule and dispatch only, outside `test-status` | Itself (nightly Test schedule) || `e2e.yml` | `order-hunt` | Named exception: schedule and `order_hunt` dispatch only, outside `e2e-status` | Itself (nightly E2E schedule) || `test.yml` | `native_only`, `race_hunt`, `stress_*` dispatch inputs; concurrency suffixes | Parity: manual modes and run grouping, never applied to PR, push or schedule events | — |-| `persistence-validation.yml` | Bun matrix of read latency, deployment matrix, unit-lane PostgreSQL arms, soak, crash robot, reconciliation, convergence | Parity: both Bun versions on every event | — |+| `persistence-validation.yml` | Bun matrix of read latency, deployment matrix, unit-lane PostgreSQL arms, soak, crash robot, reconciliation, convergence | Parity: both Bun versions on every event that runs the lane | — |+| `test.yml`, `persistence-validation.yml` | Cheap tier on pull requests: no unit shards, serial, slow, BrainBench, admin-browser, shared-skills, coverage or `test-status`; of the persistence lanes only the crash robot and convergence, and those and the native cells only when the diff selects them | Named exception ([below](#full-ci-on-pull-requests)) | The full-ci dispatch on the head before merge (merge-train requires `full-suite`), every push to master, the merge queue and the nightly Test schedule |+| `e2e.yml` | No `pull_request` trigger | Named exception ([below](#full-ci-on-pull-requests)) | The full-ci dispatch on the head before merge (merge-train requires `e2e-full-suite`), every push to master, the merge queue and the nightly E2E schedule |+| `test.yml`, `e2e.yml` | A push to master skips its full lanes when it reuses a passed full-suite run of its exact tree | Named exception ([below](#master-push-reuse)) | The reused run (same tree, full profile); schedules never reuse || `persistence-validation.yml` | `convergence` selected on pull requests by `scripts/ci-convergence-scope.sh` (test.yml `changes`; never by `package.json` alone) | Named exception | Every merge-queue run and every push to master; the nightly cell runs in `convergence-nightly.yml` || `convergence-nightly.yml` | The convergence gate's nightly cell (2,000 pages, 50 ms, 20 kills, run-id seed): schedule and dispatch only, outside `test-status`; the PR cell (200 pages, 10 ms, 6 kills, seed 6650) runs in `persistence-validation.yml` | Named exception | Itself (nightly Convergence schedule) || `persistence-validation.yml` | `SOAK_OPERATIONS` 2,500 vs 10,000 | Named exception | Every push to master and the nightly Test schedule || `persistence-validation.yml` | `ROBOT_SECONDS` 150 vs 600 | Named exception | Every push to master and the nightly Test schedule || `native-locks.yml` | `inputs.scope` (OpenClaw, musl, Windows probes, Bun 1.4.0 and cross-target cells) | Named exception | Every push to master and the nightly Test schedule (`full`) |-| `e2e.yml` | Doc-only pull request selects no E2E file | Named exception | Every push to master (whole corpus) and the nightly E2E schedule |+| `e2e.yml` | Doc-only merge-queue entry selects no E2E file | Named exception | Every push to master (whole corpus) and the nightly E2E schedule || `e2e.yml` | Full-corpus coverage lanes and their `e2e-status` checks | Named exception | Nightly E2E schedule (or a `full_corpus` dispatch) || `heavy-tests.yml` | Label-gated jobs on pull requests | Named exception | Nightly Heavy Tests schedule || `heavy-tests.yml` | `grok-door` (label or input only) | Recorded decision: no scheduled run until the `XAI_API_KEY` secret exists | None yet, by decision |@@ -43,6 +46,58 @@ and `e2e-status` aggregators, never on per-cell matrix names.| `osv-scanner.yml` | Pull requests scan only on a manifest change | Named exception | Weekly OSV schedule; `dependency-audit` on every PR || `nightly-watch.yml` | `workflow_run` event guard | Not a test scope: it files issues from qualifying scheduled and push-to-master runs | — || `fix-wave-gate.yml`, `fix-wave-closeout.yml` | Pull-request action and merge state | Not a test scope: merge-process automation | — |+| `full-ci.yml` | `full-ci` label, later pushes to a labeled pull request, same-repository head | Not a test scope: dispatches the full profile on the head | — |++## Full CI on pull requests++Every pull-request push runs the cheap tier in Test: `verify`, `typecheck`,+`gitleaks`, the security regressions, the dependency audit, the stress gate+on changed tests, and the GitHub-only lanes the diff selects. The crash robot+and convergence run when `scripts/ci-convergence-scope.sh` selects+persistence or sync paths. The native cells run when+`scripts/ci-native-scope.sh` selects more than `smoke`. The+`cheap-tier (full suite not run)` check aggregates them+(`scripts/ci-cheap-tier.sh`): a selected lane that skipped fails it, and its+summary says the full suite did not run. E2E does not run on pull requests.++The full suite runs on the exact head before merge, with the same shape as a+push to master: every unit shard, serial, slow, both PostgreSQL arms and the+whole E2E corpus. A maintainer adds the `full-ci` label (a label needs triage+access, so contributors cannot add one). `full-ci.yml` then dispatches Test+and E2E on the head branch, and again on every later push while the label+stays. A fork's branch is never dispatched. A thread that wants the full suite+earlier, for a risky change, dispatches it itself:+`gh workflow run test.yml --ref <branch> && gh workflow run e2e.yml --ref <branch>`.++merge-train requires the `full-suite` (Test) and `e2e-full-suite` (E2E)+checks to have succeeded on the exact head. Each one succeeds only when its+own run's aggregate did (`test-status`, `e2e-status`). A pull-request run+skips both and names them `full-suite-not-run`, so a cheap green can never+produce either one. Each uploads `full-suite-tree` / `e2e-full-suite-tree`,+a `tree.json` recording the tested tree (`scripts/ci-full-suite-tree.sh`).+Pushes to master, the merge queue and schedules always run the full profile.++## Master-push reuse++A push to master runs nothing again when its tree equals the tree of a passed,+complete full-suite run of the same workflow (`scripts/ci-reuse.ts`, in Test+`changes` and E2E `prepare-e2e`). The candidate must meet all of these:++- It is a `workflow_dispatch` or `push` run from this repository.+- Its latest attempt completed with success.+- Its single `full-suite` (or `e2e-full-suite`) job succeeded in that attempt.+- Its `tree.json` matches the run (id, attempt, commit, event, workflow,+ profile `full`).+- The recorded tree equals both the push tree and the tree of the run's head.++The push itself must be a merge commit. Anything else, an API error or a+partial, cancelled or diagnostic run included, leaves reuse unset, so the push+runs in full. A reusing push skips every full lane and both aggregates, records the+reused run in its summary, and runs the `reused-full-suite` job with the+`reuse.json` artifact. The release gate (`scripts/release-gate.ts`) accepts a+reusing push only with a readable `reuse.json` naming the same workflow, the+push head and a valid source run. It prints the reused run per workflow and+writes `test_reused_run_id` / `e2e_reused_run_id`. Schedules never reuse.## Dependency-audit rulediff --git a/scripts/ci-cheap-tier.sh b/scripts/ci-cheap-tier.shindex c8e7da69ee..8e6038616f 100755--- a/scripts/ci-cheap-tier.sh+++ b/scripts/ci-cheap-tier.sh@@ -1,5 +1,5 @@#!/usr/bin/env bash-# test.yml cheap-tier aggregator (docs/TESTING.md#full-ci-on-pull-requests).+# test.yml cheap-tier aggregator (docs/ci-event-parity.md#full-ci-on-pull-requests).# Inputs: job results in GITLEAKS SECURITY AUDIT VERIFY TYPECHECK STRESS NATIVE# PERSISTENCE, and the selectors NATIVE_SCOPE and CONVERGENCE.# Every cheap lane must succeed. The native and persistence lanes may bediff --git a/scripts/ci-full-suite-tree.sh b/scripts/ci-full-suite-tree.shindex 73d6c9087a..ab5112606b 100755--- a/scripts/ci-full-suite-tree.sh+++ b/scripts/ci-full-suite-tree.sh@@ -1,5 +1,5 @@#!/usr/bin/env bash-# Record the tree a full-profile run tested (docs/TESTING.md#full-ci-on-pull-requests).+# Record the tree a full-profile run tested (docs/ci-event-parity.md#full-ci-on-pull-requests).# Called by test.yml `full-suite` and e2e.yml `e2e-full-suite` after their# aggregate succeeded. scripts/ci-reuse.ts reads the artifact on a push to master.# Input (environment): ARTIFACT_DIR, RUN_ID, RUN_ATTEMPT, WORKFLOW, EVENT.diff --git a/scripts/structural-suites.tsv b/scripts/structural-suites.tsvindex 1bdadbbde7..16ce428c9d 100644--- a/scripts/structural-suites.tsv+++ b/scripts/structural-suites.tsv@@ -310,6 +310,8 @@ test/scripts/e2e-runner.test.ts second 5 readFileSynctest/scripts/e2e-runner.test.ts sequential E2E runner (GITHUB_ACTIONS=${githubActions}) 9 readFileSynctest/scripts/e2e-wiring.test.ts (file-level) 12 readFileSynctest/scripts/fix-wave-gate.test.ts fix-wave gate workflow 3 readFileSync+test/scripts/full-ci-workflow.test.ts full CI on pull requests 4 readFileSync+test/scripts/full-ci-workflow.test.ts master-push reuse of a passed full-suite run 2 readFileSynctest/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/native-setup-toolchain.test.ts scripts/native/setup-toolchain.ts download budget 4 readFileSyncdiff --git a/test/scripts/ci-gates.test.ts b/test/scripts/ci-gates.test.tsindex 8a624c9701..4b9b4f2142 100644--- a/test/scripts/ci-gates.test.ts+++ b/test/scripts/ci-gates.test.ts@@ -39,7 +39,7 @@ describe('CI execution evidence', () => {}expect(unit.on.pull_request.paths).toBeUndefined();// E2E never runs on pull_request events: the full-ci dispatch runs it on the- // head before merge (docs/TESTING.md#full-ci-on-pull-requests).+ // head before merge (docs/ci-event-parity.md#full-ci-on-pull-requests).expect(e2e.on.pull_request).toBeUndefined();for (const name of ['gitleaks', 'verify', 'typecheck']) {expect(unit.jobs[name].needs).toBeUndefined();@@ -77,9 +77,9 @@ describe('CI execution evidence', () => {});test('unit aggregate rejects failed, cancelled or skipped required jobs', () => {- expect(unit.jobs['test-status'].if).toBe("${{ always() && github.event_name != 'pull_request' && (github.event_name != 'workflow_dispatch' || (inputs.native_only != true && inputs.race_hunt != true && !inputs.stress_files && !inputs.stress_base)) }}");+ expect(unit.jobs['test-status'].if).toBe("${{ needs.changes.outputs.reuse != 'true' && always() && github.event_name != 'pull_request' && (github.event_name != 'workflow_dispatch' || (inputs.native_only != true && inputs.race_hunt != true && !inputs.stress_files && !inputs.stress_base)) }}");expect(unit.jobs['test-status'].needs).toEqual([- 'gitleaks', 'security-regressions', 'dependency-audit', 'verify', 'typecheck', 'serial-tests',+ 'changes', 'gitleaks', 'security-regressions', 'dependency-audit', 'verify', 'typecheck', 'serial-tests','slow-entity-resolve-perf', 'slow-brainbench-e2e', 'brainbench', 'test', 'native-locks', 'persistence-validation','admin-browser', 'shared-skills-compatibility', 'stress-changed-tests',]);@@ -92,7 +92,7 @@ describe('CI execution evidence', () => {});test('E2E aggregate gates nightly full-corpus execution and allows its skip on other events', () => {- expect(e2e.jobs['e2e-status'].if).toBe('always()');+ expect(e2e.jobs['e2e-status'].if).toBe("${{ needs.prepare-e2e.outputs.reuse != 'true' && always() }}");const needs = e2e.jobs['e2e-status'].needs as string[];const nightly = ['coverage-full-unit', 'coverage-full-serial', 'coverage-full-slow', 'coverage-full-e2e'];expect(needs).toEqual(['jsonb-parity', 'tier1', 'tier1-backend-matrix', 'tier2', 'prepare-e2e', 'selected-e2e', ...nightly]);diff --git a/test/scripts/ci-pr-scope.test.ts b/test/scripts/ci-pr-scope.test.tsindex 3088f67570..33b95bd76b 100644--- a/test/scripts/ci-pr-scope.test.ts+++ b/test/scripts/ci-pr-scope.test.ts@@ -150,7 +150,7 @@ esac} finally { rmSync(dir, { recursive: true, force: true }); }});- // Pull requests run the cheap tier (docs/TESTING.md#full-ci-on-pull-requests):+ // Pull requests run the cheap tier (docs/ci-event-parity.md#full-ci-on-pull-requests):// of the persistence lanes only the crash robot and convergence; the rest run// in the full-ci dispatch, on every push, in the merge queue and nightly.test('security and persistence matrices run both supported Bun versions on every event that runs them; pull requests run only the crash robot and convergence', () => {diff --git a/test/scripts/full-ci-workflow.test.ts b/test/scripts/full-ci-workflow.test.tsnew file mode 100644index 0000000000..b448a2008c--- /dev/null+++ b/test/scripts/full-ci-workflow.test.ts@@ -0,0 +1,199 @@+import { describe, expect, test } from 'bun:test';+import { mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';+import { tmpdir } from 'node:os';+import { join } from 'node:path';+import { spawnSync } from 'node:child_process';+import { runInNewContext } from 'node:vm';+import { load } from 'js-yaml';++// Full CI on pull requests (docs/ci-event-parity.md#full-ci-on-pull-requests):+// a pull request runs the cheap tier, the full-ci dispatch runs the full suite+// on its head, and a master push may reuse a passed full-suite run of its tree.+type Step = { name?: string; id?: string; if?: string; run?: string; uses?: string; 'continue-on-error'?: boolean; env?: Record<string, string>; with?: Record<string, string> };+type Job = { if?: string; name?: string; needs?: string[] | string; permissions?: Record<string, string>; steps?: Step[] };+type Workflow = { on: Record<string, { types?: string[]; branches?: string[] } | null>; permissions?: unknown; jobs: Record<string, Job> };+const root = join(import.meta.dir, '../..');+const workflow = (name: string) => load(readFileSync(join(root, '.github/workflows', name), 'utf8')) as Workflow;+const unit = workflow('test.yml');+const e2e = workflow('e2e.yml');+const dispatcher = workflow('full-ci.yml');++type Context = { event: string; inputs?: Record<string, unknown>; outputs?: Record<string, string>; action?: string; label?: string; pr?: Record<string, unknown> };+function evaluate(expression: string, context: Context): unknown {+ const js = expression.replace(/^\$\{\{\s*|\s*\}\}$/g, '')+ .replace(/needs\.prepare-e2e\./g, "needs['prepare-e2e'].")+ .replace(/outputs\.(\w+(?:-\w+)+)/g, (_, key) => `outputs['${key}']`)+ .replace(/labels\.\*\.name/g, 'labels.map(label => label.name)');+ const outputs = { 'native-scope': 'full', convergence: 'run', reuse: '', ...context.outputs };+ return runInNewContext(js, {+ always: () => true,+ contains: (list: unknown[], item: unknown) => list.includes(item),+ format: (f: string, ...a: unknown[]) => f.replace(/\{(\d+)\}/g, (_, i) => String(a[Number(i)])),+ vars: { GBRAIN_PAID_LANES: '' },+ github: { event_name: context.event, repository: 'acme-example/gbrain',+ event: { action: context.action, label: { name: context.label }, pull_request: context.pr ?? {} } },+ inputs: context.inputs ?? {},+ needs: { changes: { outputs }, 'prepare-e2e': { outputs } },+ }, { timeout: 100 });+}+const template = (value: string, context: Context) => value.replace(/\$\{\{(.*?)\}\}/g, (_, expression) => String(evaluate(expression.trim(), context)));+const runs = (w: Workflow, context: Context) =>+ Object.entries(w.jobs).filter(([, job]) => !job.if || Boolean(evaluate(job.if, context))).map(([name]) => name).sort();+const step = (job: Job, name: string) => job.steps!.find(s => s.name === name)!;+const bash = (script: string, env: Record<string, string>, cwd = root) =>+ spawnSync('bash', ['-c', script], { cwd, encoding: 'utf8', env: { PATH: process.env.PATH, ...env } });++const CHEAP = ['changes', 'cheap-tier', 'dependency-audit', 'executed-receipts', 'gitleaks', 'security-regressions', 'stress-changed-tests', 'typecheck', 'verify'];+const FULL_ONLY = ['serial-tests', 'slow-brainbench-e2e', 'brainbench', 'slow-entity-resolve-perf', 'test', 'admin-browser',+ 'shared-skills-compatibility', 'coverage-report', 'test-status', 'full-suite'];++describe('full CI on pull requests', () => {+ test('a pull request runs exactly the cheap tier, plus the persistence and native lanes its diff selects', () => {+ expect(runs(unit, { event: 'pull_request', outputs: { 'native-scope': 'smoke', convergence: 'skip' } })).toEqual(CHEAP);+ expect(runs(unit, { event: 'pull_request', outputs: { 'native-scope': 'primary', convergence: 'run' } }))+ .toEqual([...CHEAP, 'native-locks', 'persistence-validation'].sort());+ for (const event of ['push', 'merge_group', 'schedule', 'workflow_dispatch']) {+ const full = runs(unit, { event });+ for (const job of [...FULL_ONLY, 'native-locks', 'persistence-validation']) expect(full, `${event}: ${job}`).toContain(job);+ expect(full).not.toContain('cheap-tier');+ }+ });++ test('a pull-request run never reports test-status or full-suite under any name', () => {+ for (const job of ['test-status', 'full-suite']) {+ expect(template(unit.jobs[job]!.name!, { event: 'pull_request' })).toBe('full-suite-not-run');+ for (const event of ['push', 'merge_group', 'schedule', 'workflow_dispatch']) {+ expect(template(unit.jobs[job]!.name!, { event, inputs: event === 'workflow_dispatch' ? { native_only: false, race_hunt: false, stress_files: '', stress_base: '' } : {} })).toBe(job);+ }+ }+ expect(unit.jobs['cheap-tier']!.name).toBe('cheap-tier (full suite not run)');+ expect(unit.jobs['full-suite']!.needs).toContain('test-status');+ expect(e2e.jobs['e2e-full-suite']!.needs).toContain('e2e-status');+ });++ test.each([['test.yml', 'full-suite', 'TEST_STATUS', 'Require test-status'], ['e2e.yml', 'e2e-full-suite', 'E2E_STATUS', 'Require e2e-status']])(+ '%s %s succeeds only when its aggregate succeeded on the same run', (file, job, variable, name) => {+ const require = step(workflow(file).jobs[job]!, name);+ for (const result of ['success', 'failure', 'cancelled', 'skipped']) {+ expect(bash(require.run!, { [variable]: result }).status, result).toBe(result === 'success' ? 0 : 1);+ }+ });++ test('the full-suite artifact records the tree the run checked out', () => {+ const dir = mkdtempSync(join(tmpdir(), 'gbrain-full-suite-tree-'));+ try {+ const git = (...args: string[]) => spawnSync('git', ['-c', 'user.name=t', '-c', '[email protected]', ...args], { cwd: dir, encoding: 'utf8' });+ git('init', '-q');+ writeFileSync(join(dir, 'a.txt'), 'a\n');+ git('add', 'a.txt');+ git('commit', '-qm', 'a');+ const out = join(dir, 'out');+ const result = bash(`bash ${join(root, 'scripts/ci-full-suite-tree.sh')}`,+ { ARTIFACT_DIR: out, RUN_ID: '42', RUN_ATTEMPT: '2', WORKFLOW: 'Test', EVENT: 'workflow_dispatch', GITHUB_STEP_SUMMARY: join(dir, 'summary.md') }, dir);+ expect(result.status, result.stderr).toBe(0);+ expect(JSON.parse(readFileSync(join(out, 'tree.json'), 'utf8'))).toEqual({+ tree: git('rev-parse', 'HEAD^{tree}').stdout.trim(), sha: git('rev-parse', 'HEAD').stdout.trim(),+ workflow: 'Test', event: 'workflow_dispatch', run_id: 42, run_attempt: 2, profile: 'full',+ });+ } finally {+ rmSync(dir, { recursive: true, force: true });+ }+ for (const [w, job, artifact] of [[unit, 'full-suite', 'full-suite-tree'], [e2e, 'e2e-full-suite', 'e2e-full-suite-tree']] as const) {+ const upload = w.jobs[job]!.steps!.find(s => s.uses?.startsWith('actions/upload-artifact@'))!;+ expect(upload.with).toMatchObject({ name: artifact, overwrite: true });+ expect(step(w.jobs[job]!, 'Record the tested tree').run).toBe('bash scripts/ci-full-suite-tree.sh');+ }+ });++ test('E2E never runs on pull_request events; the full-ci label dispatches Test and E2E on a same-repository head', () => {+ expect(e2e.on.pull_request).toBeUndefined();+ expect(dispatcher.on.pull_request).toEqual({ branches: ['master'], types: ['labeled', 'synchronize', 'reopened'] });+ expect(dispatcher.permissions).toEqual({});+ const job = dispatcher.jobs.dispatch!;+ expect(job.permissions).toEqual({ actions: 'write', contents: 'read' });+ const own = { head: { repo: { full_name: 'acme-example/gbrain' } } };+ const fork = { head: { repo: { full_name: 'fork-a/gbrain' } } };+ const labels = (...names: string[]) => names.map(name => ({ name }));+ const cases: Array<[Context, boolean]> = [+ [{ event: 'pull_request', action: 'labeled', label: 'full-ci', pr: { ...own, labels: labels('full-ci') } }, true],+ [{ event: 'pull_request', action: 'labeled', label: 'docs', pr: { ...own, labels: labels('docs', 'full-ci') } }, false],+ [{ event: 'pull_request', action: 'synchronize', pr: { ...own, labels: labels('full-ci') } }, true],+ [{ event: 'pull_request', action: 'reopened', pr: { ...own, labels: labels('full-ci') } }, true],+ [{ event: 'pull_request', action: 'synchronize', pr: { ...own, labels: labels('docs') } }, false],+ [{ event: 'pull_request', action: 'labeled', label: 'full-ci', pr: { ...fork, labels: labels('full-ci') } }, false],+ [{ event: 'pull_request', action: 'synchronize', pr: { ...fork, labels: labels('full-ci') } }, false],+ ];+ for (const [context, expected] of cases) expect(Boolean(evaluate(job.if!, context)), JSON.stringify(context)).toBe(expected);+ const run = job.steps![0]!.run!;+ expect(run).toContain('gh workflow run test.yml -R "$REPO" --ref "$BRANCH"');+ expect(run).toContain('gh workflow run e2e.yml -R "$REPO" --ref "$BRANCH"');+ expect(run.indexOf('"$current" != "$HEAD_SHA"')).toBeLessThan(run.indexOf('gh workflow run'));+ });++ describe('cheap-tier aggregator', () => {+ const green = { GITLEAKS: 'success', SECURITY: 'success', AUDIT: 'success', VERIFY: 'success', TYPECHECK: 'success', STRESS: 'success',+ NATIVE: 'skipped', NATIVE_SCOPE: 'smoke', PERSISTENCE: 'skipped', CONVERGENCE: 'skip' };+ const aggregate = (env: Record<string, string>) => {+ const dir = mkdtempSync(join(tmpdir(), 'gbrain-cheap-tier-'));+ try {+ const summary = join(dir, 'summary.md');+ const result = bash(`bash ${join(root, 'scripts/ci-cheap-tier.sh')}`, { ...env, GITHUB_STEP_SUMMARY: summary });+ return { status: result.status, summary: readFileSync(summary, 'utf8') };+ } finally {+ rmSync(dir, { recursive: true, force: true });+ }+ };++ test('green when every cheap lane passed; the summary always says the full suite did not run', () => {+ const result = aggregate(green);+ expect(result.status).toBe(0);+ expect(result.summary).toContain('## Full suite not run');+ expect(result.summary).toContain('`full-suite` and `e2e-full-suite`');+ expect(aggregate({ ...green, NATIVE: 'success', NATIVE_SCOPE: 'primary', PERSISTENCE: 'success', CONVERGENCE: 'run' }).status).toBe(0);+ });++ test.each(['GITLEAKS', 'SECURITY', 'AUDIT', 'VERIFY', 'TYPECHECK', 'STRESS'])('%s not succeeding fails the tier', lane => {+ for (const result of ['failure', 'cancelled', 'skipped', '']) {+ expect(aggregate({ ...green, [lane]: result }).status, `${lane}=${result}`).toBe(1);+ }+ });++ test('a selected persistence or native lane must succeed; only an unselected one may skip', () => {+ for (const result of ['failure', 'cancelled', 'skipped']) {+ expect(aggregate({ ...green, NATIVE: result, NATIVE_SCOPE: 'primary' }).status).toBe(1);+ expect(aggregate({ ...green, PERSISTENCE: result, CONVERGENCE: 'run' }).status).toBe(1);+ }+ expect(aggregate({ ...green, NATIVE: 'failure' }).status).toBe(1);+ expect(aggregate({ ...green, PERSISTENCE: 'cancelled' }).status).toBe(1);+ });+ });+});++describe('master-push reuse of a passed full-suite run', () => {+ test('only a push computes reuse, and a crash leaves it unset (a full run)', () => {+ for (const [w, job] of [[unit, 'changes'], [e2e, 'prepare-e2e']] as const) {+ const reuse = w.jobs[job]!.steps!.find(s => s.id === 'reuse')!;+ expect(reuse.if).toBe("github.event_name == 'push'");+ expect(reuse['continue-on-error']).toBe(true);+ expect(reuse.run).toContain(`--workflow ${w === unit ? 'test' : 'e2e'}`);+ expect(w.jobs[job]!.permissions).toMatchObject({ actions: 'read', contents: 'read' });+ }+ });++ test('a reusing push skips every full lane and both aggregates, and runs the marker the release gate reads', () => {+ const reused = runs(unit, { event: 'push', outputs: { reuse: 'true' } });+ expect(reused).toContain('reused-full-suite');+ for (const job of [...FULL_ONLY, 'native-locks', 'persistence-validation', 'executed-receipts']) expect(reused, job).not.toContain(job);+ const full = runs(unit, { event: 'push' });+ expect(full).not.toContain('reused-full-suite');+ for (const job of [...FULL_ONLY, 'native-locks', 'persistence-validation']) expect(full, job).toContain(job);++ const e2eReused = runs(e2e, { event: 'push', outputs: { reuse: 'true' } });+ expect(e2eReused).toContain('reused-full-suite');+ for (const job of ['jsonb-parity', 'tier1', 'tier1-backend-matrix', 'selected-e2e', 'executed-receipts', 'e2e-status', 'e2e-full-suite']) {+ expect(e2eReused, job).not.toContain(job);+ expect(runs(e2e, { event: 'push' }), job).toContain(job);+ }+ expect(e2e.jobs.tier2!.needs).toBe('jsonb-parity');+ });+});diff --git a/test/scripts/native-only-workflow.test.ts b/test/scripts/native-only-workflow.test.tsindex 56313f51f5..feb3fe9957 100644--- a/test/scripts/native-only-workflow.test.ts+++ b/test/scripts/native-only-workflow.test.ts@@ -14,7 +14,7 @@ const workflow = load(readFileSync(join(import.meta.dir, '../../.github/workflowtype Diagnostic = { race_hunt?: boolean; stress_files?: string; stress_base?: string };// test.yml `changes` outputs a pull request's diff selectors; the default// selects every native target and the persistence lanes.-type Changes = { 'native-scope'?: string; convergence?: string };+type Changes = { 'native-scope'?: string; convergence?: string; reuse?: string };function context(event: string, flag?: boolean, diagnostic: Diagnostic = {}, changes: Changes = {}) {// Dispatch inputs carry their declared defaults; other events have no inputs.const inputs = event === 'workflow_dispatch' ? { native_only: flag, race_hunt: false, stress_files: '', stress_base: '', stress_head: '', ...diagnostic } : {};@@ -28,7 +28,7 @@ function evaluate(expression: string, event: string, flag?: boolean, diagnostic?function template(value: string, event: string, flag?: boolean, diagnostic?: Diagnostic): string {return value.replace(/\$\{\{(.*?)\}\}/g, (_, expression) => String(evaluate(expression.trim(), event, flag, diagnostic)));}-// Jobs a pull request (the cheap tier) never runs (docs/TESTING.md#full-ci-on-pull-requests).+// Jobs a pull request (the cheap tier) never runs (docs/ci-event-parity.md#full-ci-on-pull-requests).const FULL_ONLY = new Set(['serial-tests', 'slow-brainbench-e2e', 'brainbench', 'slow-entity-resolve-perf', 'test', 'admin-browser','shared-skills-compatibility', 'coverage-report', 'test-status', 'full-suite']);@@ -47,6 +47,7 @@ describe('native-only CI remains separate from full validation', () => {const nativeOnly = event === 'workflow_dispatch' && flag === true;const expected = name === 'native-only-status' ? nativeOnly: name === 'cheap-tier' ? event === 'pull_request'+ : name === 'reused-full-suite' ? false: !nativeOnly && !(event === 'pull_request' && FULL_ONLY.has(name));expect(Boolean(evaluate(job.if!, event, flag)), `${name}/${event}/${flag}`).toBe(expected);}