Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

ci(convergence): PR cell in persistence-validation, separate nightly workflow

garrytan954a28fd0d2f
diff --git a/.github/workflows/convergence-nightly.yml b/.github/workflows/convergence-nightly.yml
new file mode 100644
index 0000000000..ea4b4b0a9e
--- /dev/null
+++ b/.github/workflows/convergence-nightly.yml
@@ -0,0 +1,117 @@
+name: Convergence nightly
+
+# The managed-sync convergence gate at nightly size (#6712 PR 0,
+# test/sync-convergence.serial.test.ts, scripts/persistence/README.md#managed-sync-convergence-gate):
+# 2,000 notes at 50 ms round trip, 20 seeded kills, the run id as a rotating
+# seed (a dispatch may pass one to replay). The PR cell (200 notes, 10 ms,
+# 6 kills, seed 6650) runs in persistence-validation.yml under test-status;
+# this cell runs only here, outside test.yml and its test-status, on its own
+# concurrency group, and a red lands in the nightly-red issue (nightly-watch.yml).
+# Every job name carries its seed, and a failure writes the seed, the modes, the
+# fault plan, the fired faults and the one-line repro to the step summary.
+
+on:
+ schedule:
+ - cron: '17 9 * * *'
+ workflow_dispatch:
+ inputs:
+ seed:
+ description: Seed to replay (default the run id)
+ type: string
+ default: ''
+
+permissions:
+ contents: read
+
+concurrency:
+ group: ${{ github.workflow }}-${{ github.ref }}
+ cancel-in-progress: false
+
+jobs:
+ convergence:
+ name: Convergence nightly / Bun ${{ matrix.bun }} / seed ${{ inputs.seed || github.run_id }}
+ runs-on: ubicloud-standard-4-ubuntu-2404
+ timeout-minutes: 330
+ strategy:
+ fail-fast: false
+ matrix:
+ bun: ['1.4.0', '1.4.3']
+ services:
+ postgres:
+ image: pgvector/pgvector:pg16
+ env:
+ POSTGRES_USER: gbrain_test
+ POSTGRES_PASSWORD: gbrain_test
+ POSTGRES_DB: gbrain_test
+ ports: ['5432:5432']
+ options: >-
+ --health-cmd "pg_isready -U gbrain_test -d gbrain_test"
+ --health-interval 5s --health-timeout 5s --health-retries 20
+ pgbouncer:
+ image: edoburu/pgbouncer:latest
+ env:
+ DB_HOST: postgres
+ DB_PORT: '5432'
+ DB_USER: gbrain_test
+ DB_PASSWORD: gbrain_test
+ POOL_MODE: transaction
+ AUTH_TYPE: plain
+ MAX_CLIENT_CONN: '200'
+ DEFAULT_POOL_SIZE: '10'
+ IGNORE_STARTUP_PARAMETERS: extra_float_digits,statement_timeout,idle_in_transaction_session_timeout,search_path
+ ports: ['55433:5432']
+ env:
+ GBRAIN_TEST_CONVERGENCE_LOG_DIR: ${{ github.workspace }}/.context/convergence
+ steps:
+ - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262
+ - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6
+ with:
+ bun-version: ${{ matrix.bun }}
+ - name: Install dependencies (bounded, retried once)
+ timeout-minutes: 8
+ run: bun scripts/ci-bun-install.ts --frozen-lockfile --ignore-scripts
+ # The step timeout sits inside the job's, so the summary, cleanup and evidence steps below still run after it.
+ - name: Converge a managed sync after 20 seeded kills under concurrent writers (2,000 notes, 50 ms)
+ timeout-minutes: 300
+ env:
+ GBRAIN_TEST_CONVERGENCE: '1'
+ GBRAIN_PGBOUNCER_URL: postgres://gbrain_test:[email protected]:55433/gbrain_test
+ GBRAIN_PGBOUNCER_DIRECT_URL: postgres://gbrain_test:[email protected]:5432/gbrain_test
+ GBRAIN_TEST_CONVERGENCE_NOTES: '2000'
+ GBRAIN_TEST_CONVERGENCE_LATENCY_MS: '50'
+ GBRAIN_TEST_CONVERGENCE_KILLS: '20'
+ GBRAIN_TEST_CONVERGENCE_SEED: ${{ inputs.seed || github.run_id }}
+ GBRAIN_TEST_CONVERGENCE_SYNC_TIMEOUT_MS: '3600000'
+ GBRAIN_TEST_CONVERGENCE_SCENARIO_TIMEOUT_MS: '17400000'
+ run: |
+ set -o pipefail
+ mkdir -p "$GBRAIN_TEST_CONVERGENCE_LOG_DIR"
+ bun --no-env-file test --timeout="$GBRAIN_TEST_CONVERGENCE_SCENARIO_TIMEOUT_MS" test/sync-convergence.serial.test.ts 2>&1 | tee "$GBRAIN_TEST_CONVERGENCE_LOG_DIR/bun-test.log"
+ - name: Write the seed-carrying failure summary
+ if: failure() || cancelled()
+ env:
+ SEED: ${{ inputs.seed || github.run_id }}
+ BUN_CELL: ${{ matrix.bun }}
+ run: |
+ log="$GBRAIN_TEST_CONVERGENCE_LOG_DIR/bun-test.log"
+ {
+ echo "### Convergence nightly red: Bun $BUN_CELL, seed $SEED"
+ echo
+ echo '```'
+ grep -E '^\(fail\)|^seed [0-9]|^fault plan:|^fired:|^repro ' "$log" 2>/dev/null | head -60 || true
+ [ -s "$log" ] || echo "no test output: the step timed out or never started"
+ echo '```'
+ echo
+ echo "Replay: gh workflow run convergence-nightly.yml -f seed=$SEED (or the repro line above, locally)."
+ } >> "$GITHUB_STEP_SUMMARY"
+ - name: Stop harness processes a timed-out run left behind
+ if: always()
+ run: pkill -9 -f 'src/cli\.ts (serve|sync|put|call|extract)' || true
+ - name: Upload the convergence fault evidence (plan, fired faults, every client, serve and writer log)
+ if: always()
+ uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
+ with:
+ name: convergence-nightly-bun-${{ matrix.bun }}
+ path: .context/convergence
+ include-hidden-files: true
+ if-no-files-found: warn
diff --git a/.github/workflows/nightly-watch.yml b/.github/workflows/nightly-watch.yml
index e16039db6a..296e2fa0b0 100644
--- a/.github/workflows/nightly-watch.yml
+++ b/.github/workflows/nightly-watch.yml
@@ -49,6 +49,7 @@ on:
- E2E Tests
- Heavy Tests
- Scale tier
+ - Convergence nightly
- macOS 26 validation
- Semgrep
- OSV-Scanner
diff --git a/.github/workflows/persistence-validation.yml b/.github/workflows/persistence-validation.yml
index 85eee560a0..c1bda7d1c7 100644
--- a/.github/workflows/persistence-validation.yml
+++ b/.github/workflows/persistence-validation.yml
@@ -2,6 +2,12 @@ name: Durable persistence validation
on:
workflow_call:
+ inputs:
+ # test.yml `changes` (scripts/ci-convergence-scope.sh): `skip` only for a
+ # pull request whose diff cannot change managed-sync convergence.
+ convergence:
+ type: string
+ default: run
workflow_dispatch:
permissions:
@@ -443,3 +449,84 @@ jobs:
name: reconciliation-${{ matrix.engine }}-bun-${{ matrix.bun }}
path: .context/reconcile-crashes/*.json
if-no-files-found: error
+
+ # Managed-sync convergence gate, PR cell (#6712 PR 0, test/sync-convergence.serial.test.ts,
+ # scripts/persistence/README.md#managed-sync-convergence-gate): real serve and
+ # sync processes against Postgres behind transaction-mode PgBouncer, through
+ # the harness's latency proxy, a seeded kill -9 loop at sync fault points under
+ # concurrent writers, then at most two plain syncs and the convergence oracle.
+ # 200 notes at 10 ms, 6 kills, fixed seed 6650 on every event. The nightly
+ # cell (2,000 notes, 50 ms, 20 kills, rotating seed) is convergence-nightly.yml,
+ # outside test-status.
+ # Named exception (docs/TESTING.md#event-parity): a pull request runs it only
+ # when scripts/ci-convergence-scope.sh selects its diff (test.yml `changes`);
+ # every merge-queue run, every push to master and the nightly Test schedule
+ # run it.
+ convergence:
+ name: Managed-sync convergence / Bun ${{ matrix.bun }}
+ if: ${{ inputs.convergence != 'skip' }}
+ runs-on: ubicloud-standard-4-ubuntu-2404
+ timeout-minutes: 45
+ strategy:
+ fail-fast: false
+ matrix:
+ bun: ['1.4.0', '1.4.3']
+ # Event parity: every event, pull requests and merge-queue runs
+ # included, runs both supported Bun versions (docs/TESTING.md#event-parity).
+ services:
+ postgres:
+ image: pgvector/pgvector:pg16
+ env:
+ POSTGRES_USER: gbrain_test
+ POSTGRES_PASSWORD: gbrain_test
+ POSTGRES_DB: gbrain_test
+ ports: ['5432:5432']
+ options: >-
+ --health-cmd "pg_isready -U gbrain_test -d gbrain_test"
+ --health-interval 5s --health-timeout 5s --health-retries 20
+ pgbouncer:
+ image: edoburu/pgbouncer:latest
+ env:
+ DB_HOST: postgres
+ DB_PORT: '5432'
+ DB_USER: gbrain_test
+ DB_PASSWORD: gbrain_test
+ POOL_MODE: transaction
+ AUTH_TYPE: plain
+ MAX_CLIENT_CONN: '200'
+ DEFAULT_POOL_SIZE: '10'
+ IGNORE_STARTUP_PARAMETERS: extra_float_digits,statement_timeout,idle_in_transaction_session_timeout,search_path
+ ports: ['55433:5432']
+ steps:
+ - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262
+ - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6
+ with:
+ bun-version: ${{ matrix.bun }}
+ - name: Install dependencies (bounded, retried once)
+ timeout-minutes: 8
+ run: bun scripts/ci-bun-install.ts --frozen-lockfile --ignore-scripts
+ # The step timeout sits inside the job's, so the evidence and cleanup steps below still run after it.
+ - name: Converge a managed sync after the seeded kill loop under concurrent writers
+ timeout-minutes: 30
+ env:
+ GBRAIN_TEST_CONVERGENCE: '1'
+ GBRAIN_PGBOUNCER_URL: postgres://gbrain_test:[email protected]:55433/gbrain_test
+ GBRAIN_PGBOUNCER_DIRECT_URL: postgres://gbrain_test:[email protected]:5432/gbrain_test
+ GBRAIN_TEST_CONVERGENCE_NOTES: '200'
+ GBRAIN_TEST_CONVERGENCE_LATENCY_MS: '10'
+ GBRAIN_TEST_CONVERGENCE_KILLS: '6'
+ GBRAIN_TEST_CONVERGENCE_SEED: '6650'
+ GBRAIN_TEST_CONVERGENCE_SYNC_TIMEOUT_MS: '900000'
+ GBRAIN_TEST_CONVERGENCE_SCENARIO_TIMEOUT_MS: '1620000'
+ GBRAIN_TEST_CONVERGENCE_LOG_DIR: ${{ runner.temp }}/convergence
+ run: bun --no-env-file test --timeout="$GBRAIN_TEST_CONVERGENCE_SCENARIO_TIMEOUT_MS" test/sync-convergence.serial.test.ts
+ - name: Stop harness processes a timed-out run left behind
+ if: always()
+ run: pkill -9 -f 'src/cli\.ts (serve|sync|put|call|extract)' || true
+ - name: Upload the convergence fault evidence (plan, fired faults, every client, serve and writer log)
+ if: always()
+ uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
+ with:
+ name: convergence-bun-${{ matrix.bun }}
+ path: ${{ runner.temp }}/convergence
+ if-no-files-found: warn
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 2c6a966d5e..4fa82f6b68 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -82,12 +82,14 @@ jobs:
pull-requests: read
outputs:
native-scope: ${{ steps.scope.outputs.native }}
+ convergence: ${{ steps.convergence.outputs.convergence }}
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
sparse-checkout: |
scripts/ci-native-scope.sh
scripts/ci-manifest-diff.sh
+ scripts/ci-convergence-scope.sh
sparse-checkout-cone-mode: false
- id: scope
env:
@@ -128,6 +130,29 @@ jobs:
fi
echo "native scope: $scope"
echo "native=$scope" >> "$GITHUB_OUTPUT"
+ # Named exception (docs/TESTING.md#event-parity): a pull request runs the
+ # managed-sync convergence gate only when scripts/ci-convergence-scope.sh
+ # selects its diff (persistence, sync, projections, storage, the harness
+ # and its workflow; never package.json alone). Merge-queue runs, every push
+ # to master and the nightly Test schedule always run it; an unknown or
+ # unreadable diff runs it too.
+ - id: convergence
+ 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 }}
+ run: |
+ set -euo pipefail
+ convergence=run
+ if [ "$EVENT" = pull_request ] && [[ "$CHANGED_FILES" =~ ^[0-9]{1,4}$ ]] && [ "$CHANGED_FILES" -lt 3000 ] \
+ && files=$(gh api --paginate "repos/$REPO/pulls/$PR/files?per_page=100" --jq '.[].filename') \
+ && [ "$(printf '%s\n' "$files" | awk 'NF { count++ } END { print count+0 }')" -eq "$CHANGED_FILES" ]; then
+ convergence=$(printf '%s' "$files" | bash scripts/ci-convergence-scope.sh) || convergence=run
+ fi
+ echo "convergence gate: $convergence"
+ echo "convergence=$convergence" >> "$GITHUB_OUTPUT"
# Re-run checks for every event. Only dependencies and PGLite snapshots are cached.
gitleaks:
@@ -871,8 +896,11 @@ jobs:
scope: ${{ needs.changes.outputs.native-scope }}
persistence-validation:
+ needs: [changes]
if: ${{ github.event_name != 'workflow_dispatch' || (inputs.native_only != true && inputs.race_hunt != true && !inputs.stress_files && !inputs.stress_base) }}
uses: ./.github/workflows/persistence-validation.yml
+ with:
+ convergence: ${{ needs.changes.outputs.convergence || 'run' }}
# PR stress gate (docs/TESTING.md#stress-gate): every added or modified test
# file, plus direct importers of changed test/helpers/ files by the fan-in
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b8cc11cc1b..62b37b298a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -10,6 +10,25 @@ credits are retained; no result has been reassigned to another provider. Origina
identifiers and attribution are available in the pre-removal Git revision
`6040075c6cb95be5881cc2e1b76ef7d71f4e5d29` (retained on 2026-09-23).
+## [Unreleased]
+
+**`gbrain sync status --json` now always includes `checkpoint_blockers`, and managed sync has a convergence gate in CI (#6712).** `checkpoint_blockers` used to appear only while a run waited at its checkpoint, so an agent reading the status of a finished run, a run still mid-manifest or a source with no run could not tell "nothing blocks" from "not reported". It is now an array on every status, empty when no checkpoint is pending. Behind the scenes, every change to persistence, sync, projections or storage now has to pass a gate that kills sync clients and the serve at seeded points while other writers keep writing, then checks that one or two plain `gbrain sync --no-pull` runs bring every file and page back into agreement without losing an acknowledged write.
+
+### What you'd see
+
+| Situation | Before | Now |
+|---|---|---|
+| `gbrain sync status --source <id> --json` after a run finished, mid-run before the checkpoint, or with no run | no `checkpoint_blockers` field | `"checkpoint_blockers": []` |
+| the same while a run waits at its checkpoint behind a receipt | the blocking receipts | unchanged |
+
+### Itemized changes
+
+- `src/core/persistence/sync-status.ts`: `checkpoint_blockers` is always present (empty unless a checkpoint is pending); no other field changes. Test: `test/sync-status-checkpoint-blockers-shape.test.ts` (no cursor, unfinished, finished, recovery-record blocker).
+- `src/core/persistence/fault-points.ts`, `src/core/persistence/sync-run.ts`: a test-only `sync:after_freeze` seam after an import entry is frozen and before it is admitted (a no-op unless a test installs a hook).
+- Convergence gate (`test/sync-convergence.serial.test.ts`, `test/fixtures/convergence-fault-kill.ts`): a seeded kill loop (client and serve `kill -9` at six sync fault points), concurrent `put`, `remember` and maintenance writers, a DB-only competitor, out-of-band `git mv`/`git rm` with uncommitted deletions reported as ghosts, and two drainers, each on its own brain, with an acknowledged-write ledger and a field-present `sync status` oracle. Four modes that master fails are written and skipped until PR 1 of #6712: a mid-run uncommitted edit (no `worktree_dirty` hold is named), a pooler drop (publication stalls 356 s), one page refused inside a bulk group (the run's other 74 requests are cancelled and plain syncs stay blocked until `--retry-failed`) and a systemic trigger refusal (P0001 and 55000; plain syncs stay blocked after it is lifted). The fault preload has one action registry: kill, stall, edit, and throw with a given SQLSTATE. Every failure prints its seed, modes, fault plan and a repro command.
+- CI: a `convergence` job in `persistence-validation.yml` on both supported Bun versions (200 pages at 10 ms, 6 kills, fixed seed on pull requests, merge-queue runs and pushes), selected on pull requests by `scripts/ci-convergence-scope.sh`, which `bun.lock` and `vendor/postgres/` trigger and `package.json` alone does not. A separate `convergence-nightly.yml` workflow runs 2,000 pages at 50 ms with 20 kills and a rotating seed, outside `test-status`, and writes a failure summary carrying the seed.
+- Docs: `scripts/persistence/README.md` (managed-sync convergence gate), `docs/ci-event-parity.md`.
+
## [0.60.243.0] - 2026-10-15
**Entity rows now point at the records behind an account.** Every found `entity names` row (and each identity sibling) carries `referenced_by_count` and a `next` to its full card, so an agent that resolved a batch of names knows which ones have pages to read and how to open them. With `entity.record_types` set (off by default), the rows, the full card and `context_pack` also list the referring contracts, amendments or other record types you enroll: newest page date first, each with its page date labeled as a page date, its `status`, the record it amends (with the terms-start date when the link records one) and what it replaces, bounded per page and per call, with continuations that return exactly the rest. The order never claims which record governs. A late or failed read is marked `references_unavailable` with a degraded notice, never shown as an empty list.
diff --git a/docs/architecture/key-files/ci-health-and-test-guards.md b/docs/architecture/key-files/ci-health-and-test-guards.md
index 40f01c3653..6f2321f5ef 100644
--- a/docs/architecture/key-files/ci-health-and-test-guards.md
+++ b/docs/architecture/key-files/ci-health-and-test-guards.md
@@ -12,6 +12,7 @@ Current behavior and load-bearing invariants; history belongs in Git and CHANGEL
- `scripts/release-gate.ts` — release.yml's `ci-gate` job. Polls the push-to-master runs of Test and E2E Tests on the release commit and writes `publish`/`sha`: both green publishes; a failed run publishes nothing and fails with the next step; a run cancelled by a newer push is followed to the next master commit with the same VERSION (published there) or marks the version superseded; non-master refs are refused; it fails with the backfill command after 110 minutes. Build, release, `latest-stable` and the publish jobs use the gated commit. Tests: `test/scripts/release-gate.test.ts`. Docs: `docs/RELEASING.md#release-ci-gate`.
- `scripts/regen-all.ts` — one entry point for every generated artifact (`ARTIFACTS`: regen and check command per artifact). `bun run regen:all` regenerates offline and keyless (provider keys and database URLs removed) and lists what changed; a second run changes nothing. `--check` is read-only and runs in `verify` as `check:regen-all`; `--goldens` also regenerates the offline contract goldens. Postgres goldens are named with their own commands, and `llms.txt` regenerates last because it inlines other generated docs. Every `bun test` it spawns (two checks and the goldens) carries `--timeout=60000` through one `BUN_TEST` prefix, because Bun does not apply bunfig.toml's `[test] timeout`. Tests: `test/scripts/regen-all.test.ts`.
- `scripts/release-restamp.ts` + `scripts/lib/restamp.ts` — `bun run release:restamp`, run when a PR is next to merge. The CLI refuses a dirty tree, fetches `origin/master`, captures the branch CHANGELOG entry and migration inventory, merges master with a merge commit (version-only stamp hunks, `CHANGELOG.md` and the `GENERATED_PATHS` files resolve mechanically; anything else stops), sets VERSION to master's PATCH + 1, renumbers branch-only migrations from master's latest + 1 (filename, export name and `version:` literal only; `migrationPayloadKey` proves the rest is token-identical and refuses a copy of a published migration or an edited published one), rewrites `STAMPS` (the CLAUDE.md "Version locations" Required rows) plus CHANGELOG and TODOS, runs `DEFAULT_STEPS`, lists branch-added lines that still name an old number (`findLeftoverRefs`, never rewritten), runs `DEFAULT_CHECKS` and commits once. Stops save `.git/gbrain-restamp.json` for `--continue` / `--abort`; `--dry-run` prints the plan, `--no-commit` stages. Generators run through `offlineEnv` (no database URLs, no provider keys). Tests: `test/scripts/release-restamp.test.ts` (fixture repos with the real migration generator; also pins CLAUDE.md table coverage and docs anchors).
+- `scripts/ci-convergence-scope.sh` — #6712 PR 0: classifies a pull request's changed files (stdin) for the managed-sync convergence gate (`persistence-validation.yml` `convergence`): `run` for persistence, sync commands and sync core, page projections and storage, `bun.lock` and `vendor/postgres/`, the harness (`test/sync-convergence.serial.test.ts`, `test/fixtures/convergence-fault-kill.ts`), this script and its workflows (`persistence-validation.yml`, `convergence-nightly.yml`); `skip` otherwise, and never selected by `package.json` alone, so a release-stamp PR does not run it; an empty list runs. test.yml `changes` calls it for pull requests only (step `convergence`, passed as the `convergence` input). Tests: `test/scripts/ci-pr-scope.test.ts`.
- `scripts/ci-manifest-diff.sh` — parsed-JSON classification of manifest diffs for CI scoping: `version-only` (only the top-level `version` differs), `dependency-change` (any dependency field differs), `dependency-scope` (whether a changed-file list touches lockfiles, `patches/` or dependency fields) and `drop-version-only` (filters version-only `package.json` and `openclaw.plugin.json` entries out of a changed-file list, so a release bump does not widen the native scope). Used by test.yml's `changes` job (before `scripts/ci-native-scope.sh`) and its dependency-audit scope step. Tests: `test/scripts/ci-manifest-diff.test.ts`.
- `scripts/ci-dependency-audit.sh` — runs `bun audit` for the root and `admin/` lockfiles. It blocks (`BLOCKING=true`) on pushes, schedules and dispatches, on lockfile, `patches/` or dependency-field changes, with the `dependency-audit` label, or when the diff cannot be read; elsewhere an advisory is a `::warning::` naming why the run does not block.
- `scripts/ci-install-openclaw.sh` — e2e.yml's Tier 2 `Install OpenClaw` step. Each `npm install -g openclaw@<pin>` attempt is bounded (`timeout 120`); a failure whose npm log carries `code ETARGET` or `E404` is a registry race (a dependency version published but not yet visible for every package of its release, the 2026-10-12 master Tier 2 red on `@aws-sdk/credential-provider-node@^3.972.86`) and is retried up to 4 attempts 20/40/80 s apart; any other failure keeps the 3 attempts 10 s apart. Nothing else is retried, and the last attempt fails the step with npm's own log. Knobs (`OPENCLAW_SPEC`, `OPENCLAW_INSTALL_ATTEMPT_S`, `OPENCLAW_INSTALL_RETRY_SLEEP_S`, `OPENCLAW_INSTALL_RACE_SLEEPS_S`) exist for the test: `test/scripts/ci-install-openclaw.test.ts` installs a one-file package from a loopback registry (`test/helpers/npm-stub-registry.ts`) that answers ETARGET or E404 to the first three packument requests, forever, or publishes for an impossible `os` (`EBADPLATFORM`, the generic path). The lockfile route (a committed `package-lock.json` per pin) was weighed and not taken: two pins live in the workflows (`e2e.yml` 2026.4.9, `native-locks.yml` 2026.9.4), every bump would regenerate a multi-hundred-kilobyte lockfile, and the race the retry waits out is a propagation delay of minutes.
diff --git a/docs/ci-event-parity.md b/docs/ci-event-parity.md
index a85d7b1a2f..273d61b887 100644
--- a/docs/ci-event-parity.md
+++ b/docs/ci-event-parity.md
@@ -26,7 +26,9 @@ 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 | 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 | — |
+| `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`) |
diff --git a/scripts/ci-convergence-scope.sh b/scripts/ci-convergence-scope.sh
new file mode 100755
index 0000000000..64a9650efc
--- /dev/null
+++ b/scripts/ci-convergence-scope.sh
@@ -0,0 +1,24 @@
+#!/usr/bin/env bash
+# Classify a pull request's changed files (one path per line on stdin) for the
+# managed-sync convergence gate (persistence-validation.yml `convergence`,
+# test/sync-convergence.serial.test.ts). Prints `run` when any path can change
+# how a managed sync converges: persistence, the sync commands and sync core,
+# page projections and storage, the Postgres driver (bun.lock and the vendored
+# vendor/postgres), the harness and its workflows. Otherwise prints
+# `skip`. An empty or unreadable list prints `run`: an unknown diff never
+# narrows validation. package.json is deliberately not a selector, so a
+# release-stamp-only PR does not run the gate. Pushes, schedules and manual
+# runs never call this; they always run the gate.
+set -euo pipefail
+
+CONVERGENCE_PATHS='^(bun\.lock$|vendor/postgres/|src/core/persistence/|src/commands/sync/|src/core/page-state/|src/core/engine-sql/|src/core/storage/|test/fixtures/convergence-fault-kill\.ts$|test/sync-convergence\.serial\.test\.ts$|scripts/ci-convergence-scope\.sh$|\.github/workflows/(persistence-validation|convergence-nightly)\.yml$)|^src/commands/sync[^/]*\.ts$|^src/core/(sync[^/]*|import-file|markdown|write-through|timeline-write-through|storage|storage-config|page-lock|ghost-pages|postgres-engine)\.ts$'
+
+files=$(cat) || { echo run; exit 0; }
+# Consume the full input: grep -q closes an early match's pipe and printf
+# then fails with SIGPIPE under pipefail, incorrectly selecting skip.
+if [ -z "$files" ] || grep -E "$CONVERGENCE_PATHS" >/dev/null <<< "$files"; then
+ echo run
+else
+ status=$?
+ if [ "$status" -eq 1 ]; then echo skip; else echo run; fi
+fi
diff --git a/test/scripts/ci-pr-scope.test.ts b/test/scripts/ci-pr-scope.test.ts
index e7c8ee7ef6..42ee241084 100644
--- a/test/scripts/ci-pr-scope.test.ts
+++ b/test/scripts/ci-pr-scope.test.ts
@@ -153,7 +153,7 @@ esac
test('security and persistence matrices run both supported Bun versions on pull requests and merge-queue runs (event parity)', () => {
const security = load('test.yml').jobs['security-regressions'];
const persistence = load('persistence-validation.yml').jobs;
- const jobs = [security, ...['read-performance', 'deployment-matrix', 'unit-postgres-arms', 'invariants', 'crash-robot', 'reconciliation'].map(name => persistence[name]!)];
+ const jobs = [security, ...['read-performance', 'deployment-matrix', 'unit-postgres-arms', 'invariants', 'crash-robot', 'reconciliation', 'convergence'].map(name => persistence[name]!)];
for (const job of jobs) {
expect(job.strategy!.matrix.exclude).toBeUndefined();
const push = cells(job, { github: { event_name: 'push' }, inputs: {} });
@@ -173,7 +173,7 @@ esac
const conditional = /github\.event_name|github\.event\.(?:pull_request|merge_group|action)|inputs\.scope|"\$EVENT"|\$EVENT\b/;
const dispatchMode = /github\.event_name\s*(?:!=|==)\s*'workflow_dispatch'/g;
const unclassified: string[] = [];
- for (const name of ['test', 'stress', 'persistence-validation', 'native-locks', 'e2e', 'heavy-tests', 'macos-validation', 'scale-tier', 'semgrep']) {
+ for (const name of ['test', 'stress', 'persistence-validation', 'convergence-nightly', 'native-locks', 'e2e', 'heavy-tests', 'macos-validation', 'scale-tier', 'semgrep']) {
const lines = readFileSync(join(root, '.github/workflows', `${name}.yml`), 'utf8').split('\n');
// Blocks: each job (from the comments directly above its key to the next job) and the top-level preamble.
const starts = lines.flatMap((line, i) => (/^ [\w-]+:\s*$/.test(line) && lines.slice(0, i).some(l => l === 'jobs:') ? [i] : []));
@@ -196,12 +196,83 @@ esac
expect(readFileSync(join(root, 'docs/TESTING.md'), 'utf8')).toContain('### Event parity');
const docs = readFileSync(join(root, 'docs/ci-event-parity.md'), 'utf8');
const section = docs.slice(docs.indexOf('## Classification'), docs.indexOf('## Dependency-audit rule'));
- for (const name of ['test', 'stress', 'persistence-validation', 'native-locks', 'e2e', 'heavy-tests', 'macos-validation', 'scale-tier', 'semgrep', 'osv-scanner', 'nightly-watch']) {
+ for (const name of ['test', 'stress', 'persistence-validation', 'convergence-nightly', 'native-locks', 'e2e', 'heavy-tests', 'macos-validation', 'scale-tier', 'semgrep', 'osv-scanner', 'nightly-watch']) {
expect(section, name).toContain(`${name}.yml`);
}
expect(docs).toContain('## Dependency-audit rule');
});
+ function convergenceScope(files: string): string {
+ const result = spawnSync('bash', [join(root, 'scripts/ci-convergence-scope.sh')], { input: files, encoding: 'utf8' });
+ expect(result.status, result.stderr).toBe(0);
+ return result.stdout.trim();
+ }
+
+ // #6712 PR 0: the convergence gate's own selector, not the native one: package.json is not a selector, so a
+ // release-stamp PR does not run the gate.
+ test('the convergence gate selects persistence, sync, projection, storage, driver and harness paths, never package.json alone', () => {
+ for (const path of ['src/core/persistence/sync-run.ts', 'src/core/persistence/fault-points.ts', 'src/commands/sync/run.ts', 'src/commands/sync.ts',
+ 'src/core/sync-holds.ts', 'src/core/page-state/projections.ts', 'src/core/engine-sql/links.ts', 'src/core/storage/local.ts', 'src/core/storage-config.ts',
+ 'src/core/import-file.ts', 'src/core/markdown.ts', 'src/core/write-through.ts', 'src/core/postgres-engine.ts',
+ 'test/sync-convergence.serial.test.ts', 'test/fixtures/convergence-fault-kill.ts', 'scripts/ci-convergence-scope.sh', '.github/workflows/persistence-validation.yml',
+ '.github/workflows/convergence-nightly.yml', 'bun.lock', 'vendor/postgres/src/connection.js']) {
+ expect(convergenceScope(`README.md\n${path}\n`), path).toBe('run');
+ }
+ for (const path of ['package.json', 'VERSION', 'CHANGELOG.md', 'vendor/README.md', 'docs/guides/example.md', 'src/commands/doctor.ts', 'test/scripts/ci-pr-scope.test.ts', '.github/workflows/test.yml']) {
+ expect(convergenceScope(`README.md\n${path}\n`), path).toBe('skip');
+ }
+ expect(convergenceScope('')).toBe('run');
+ const large = Array.from({ length: 8000 }, (_, i) => `docs/guides/fixture-${i}-${'x'.repeat(72)}.md`);
+ expect(convergenceScope(large.join('\n'))).toBe('skip');
+ large.splice(large.length >> 1, 0, 'src/core/persistence/journal.ts');
+ expect(convergenceScope(large.join('\n'))).toBe('run');
+ });
+
+ test('the planning job runs the convergence gate off pull requests and on any unreadable pull-request diff', () => {
+ const step = load('test.yml').jobs.changes.steps!.find(entry => entry.id === 'convergence')!;
+ const dir = mkdtempSync(join(tmpdir(), 'gbrain-ci-convergence-'));
+ try {
+ const run = (event: string, gh: string, changedFiles = '1') => {
+ writeFileSync(join(dir, 'gh'), `#!/usr/bin/env bash\n${gh}\n`);
+ 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: event, PR: '7', REPO: 'example/repo', CHANGED_FILES: changedFiles, GITHUB_OUTPUT: output } });
+ expect(result.status, result.stderr).toBe(0);
+ return readFileSync(output, 'utf8').trim();
+ };
+ for (const event of ['push', 'schedule', 'workflow_dispatch', 'merge_group']) expect(run(event, "printf 'docs/a.md\\n'"), event).toBe('convergence=run');
+ expect(run('pull_request', "printf 'docs/a.md\\n'")).toBe('convergence=skip');
+ expect(run('pull_request', "printf 'package.json\\n'")).toBe('convergence=skip');
+ expect(run('pull_request', "printf 'src/core/persistence/journal.ts\\n'")).toBe('convergence=run');
+ expect(run('pull_request', 'exit 1')).toBe('convergence=run');
+ for (const count of ['', 'invalid', '3000', '99999']) expect(run('pull_request', "printf 'docs/a.md\\n'", count), count).toBe('convergence=run');
+ expect(run('pull_request', "printf 'docs/a.md\\n'", '2')).toBe('convergence=run');
+ } finally { rmSync(dir, { recursive: true, force: true }); }
+ });
+
+ test('the convergence job runs the PR cell on every event and skips only on the selector; the nightly cell runs only in its own workflow', () => {
+ const job = load('persistence-validation.yml').jobs.convergence!;
+ expect(evaluate(job.if!, { inputs: { convergence: 'skip' } })).toBe(false);
+ for (const convergence of ['run', undefined]) expect(evaluate(job.if!, { inputs: { convergence } })).toBe(true);
+ const cell = (workflow: Job) => {
+ const step = workflow.steps!.find(entry => entry.env?.GBRAIN_TEST_CONVERGENCE === '1')!;
+ return Object.fromEntries(['NOTES', 'LATENCY_MS', 'KILLS', 'SEED'].map(key => [key, step.env![`GBRAIN_TEST_CONVERGENCE_${key}`]]));
+ };
+ expect(cell(job)).toEqual({ NOTES: '200', LATENCY_MS: '10', KILLS: '6', SEED: '6650' });
+ const raw = loadYaml(readFileSync(join(root, '.github/workflows/convergence-nightly.yml'), 'utf8')) as {
+ on: Record<string, unknown>; concurrency: { group: string; 'cancel-in-progress': boolean }; jobs: Record<string, Job & { name?: string }> };
+ expect(Object.keys(raw.on).sort()).toEqual(['schedule', 'workflow_dispatch']);
+ expect(raw.concurrency).toEqual({ group: '${{ github.workflow }}-${{ github.ref }}', 'cancel-in-progress': false });
+ const nightly = raw.jobs.convergence!;
+ expect(nightly.strategy!.matrix.bun).toEqual([MINIMUM_BUN_VERSION, '1.4.3']);
+ expect(nightly.name).toContain('seed ${{ inputs.seed || github.run_id }}');
+ expect(cell(nightly)).toEqual({ NOTES: '2000', LATENCY_MS: '50', KILLS: '20', SEED: '${{ inputs.seed || github.run_id }}' });
+ // Outside test-status: no workflow calls it, and test.yml's aggregator never names it.
+ expect(readFileSync(join(root, '.github/workflows/test.yml'), 'utf8')).not.toContain('convergence-nightly');
+ });
+
test('export scale runs 10,001 pages on pull requests and 100,001 everywhere else', () => {
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!;
@@ -228,7 +299,7 @@ esac
expect(/GBRAIN_E2E_BUN_IMAGE:-oven\/bun:([^}]+)\}/.exec(read('tests/docker/bootstrap-e2e.sh'))?.[1]).toBe(primary);
const matrices = [load('test.yml').jobs['security-regressions'], ...Object.values(load('persistence-validation.yml').jobs)]
.map(job => job.strategy?.matrix.bun).filter(Boolean);
- expect(matrices).toHaveLength(7);
+ expect(matrices).toHaveLength(8);
for (const bun of matrices) expect(bun).toEqual([MINIMUM_BUN_VERSION, primary]);
for (const job of ['native', 'musl', 'windows-backup-console', 'windows-backup-dotnet']) {
expect(native[job].strategy!.matrix.bun).toEqual([MINIMUM_BUN_VERSION, primary]);
diff --git a/test/scripts/ci-runner-routing.test.ts b/test/scripts/ci-runner-routing.test.ts
index a2ce9b0959..4efe157aa8 100644
--- a/test/scripts/ci-runner-routing.test.ts
+++ b/test/scripts/ci-runner-routing.test.ts
@@ -22,7 +22,7 @@ const targetRunners = (job: Job) =>
describe('CI runner routing', () => {
test('owned Linux validation jobs use Ubicloud without moving release publishing', () => {
- for (const file of ['test.yml', 'e2e.yml', 'heavy-tests.yml', 'persistence-validation.yml', 'native-locks.yml', 'actionlint.yml', 'semgrep.yml']) {
+ for (const file of ['test.yml', 'e2e.yml', 'heavy-tests.yml', 'persistence-validation.yml', 'convergence-nightly.yml', 'native-locks.yml', 'actionlint.yml', 'semgrep.yml']) {
for (const job of Object.values(load(file).jobs)) {
const runner = job['runs-on'];
if (!runner || runner.startsWith('${{')) continue;
@@ -51,6 +51,8 @@ describe('CI runner routing', () => {
expect(load('persistence-validation.yml').jobs['read-performance']['runs-on']).toBe(single);
expect(load('persistence-validation.yml').jobs.invariants['runs-on']).toBe(single);
expect(load('persistence-validation.yml').jobs.reconciliation['runs-on']).toBe(single);
+ expect(load('persistence-validation.yml').jobs.convergence['runs-on']).toBe(single);
+ expect(load('convergence-nightly.yml').jobs.convergence['runs-on']).toBe(single);
expect(load('persistence-validation.yml').jobs['deployment-matrix']['runs-on']).toBe(pooled);
expect(load('heavy-tests.yml').jobs.heavy['runs-on']).toBe(heavy);
});