Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

fix: small-fixes wave (#8723 #8717 #8700 #8702 #8713)

garrytan2dad947360eb
diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml
index acbc81f134..d89ca45116 100644
--- a/.github/workflows/e2e.yml
+++ b/.github/workflows/e2e.yml
@@ -86,7 +86,7 @@ jobs:
path: |
test/fixtures/pglite-snapshot.tar
test/fixtures/pglite-snapshot.version
- key: pglite-snapshot-${{ runner.os }}-${{ hashFiles('src/core/*.ts', 'src/core/audit/redact-connection-info.ts', 'src/core/engine-sql/bootstrap.ts', 'src/core/schema-migrations/**', 'src/core/ai/defaults.ts', 'src/core/company-brain/receipt-schema.ts', 'src/core/entities/resolve.ts', 'src/core/facts/withdrawal-schema.ts', 'src/core/facts/relink-schema.ts', 'src/core/google/*.ts', 'src/core/meetings/source-config.ts', 'src/core/meetings/types.ts', 'src/core/slack/source-config.ts', 'src/core/slack/types.ts', 'src/core/grants/*.ts', 'src/core/minions/tools/brain-allowlist.ts', 'src/core/ops/contract.ts', 'src/core/ops/execution-prerequisites.ts', 'src/core/page-body/page-shape.ts', 'src/core/page-body/schema.ts', 'src/core/page-state/*schema.ts', 'src/core/persistence/*.ts', 'src/core/schema-pack/link-inference.ts', 'src/core/schema-pack/redos-guard.ts', 'src/core/search/alias-normalize.ts', 'src/core/search/private-visibility.ts', 'src/core/access/principals.ts', 'src/core/access/folder-rules.ts', 'src/core/search/projection-statistics.ts', 'src/core/search/relational-intent.ts', 'src/core/shared-skills/*schema*.ts', 'src/core/ai/decide/schema.ts', 'test/helpers/legacy-embedding-config.ts', 'scripts/build-pglite-snapshot.ts', 'src/core/facts/purge-schema.ts', 'src/core/facts/insert-guard-schema.ts', 'src/core/facts/fts-index.ts', 'src/core/eligibility/generation-schema.ts', 'src/core/trust/schema.ts', 'src/core/trust/tier.ts', 'src/core/trust/allow-rules.ts', 'src/core/write-gate-schema.ts', 'src/core/questions/schema.ts', 'src/core/questions/identity.ts', 'src/core/questions/auto-think-migration.ts', 'src/core/loops/loops-schema.ts', 'src/core/postgres-engine/schema-lock-timeout.ts', 'src/core/postgres-engine/read-write-transactions.ts', 'src/core/belief/schema.ts', 'src/core/fence-repair/reasons.ts', 'src/core/fence-repair/measured.ts', 'src/core/ai/errors.ts') }}
+ key: pglite-snapshot-${{ runner.os }}-${{ hashFiles('src/core/**/*.ts', 'test/helpers/legacy-embedding-config.ts', 'scripts/build-pglite-snapshot.ts') }}
- name: Install dependencies (bounded, retried once)
timeout-minutes: 8
run: bun scripts/ci-bun-install.ts --frozen-lockfile
@@ -254,7 +254,7 @@ jobs:
path: |
test/fixtures/pglite-snapshot.tar
test/fixtures/pglite-snapshot.version
- key: pglite-snapshot-${{ runner.os }}-${{ hashFiles('src/core/*.ts', 'src/core/audit/redact-connection-info.ts', 'src/core/engine-sql/bootstrap.ts', 'src/core/schema-migrations/**', 'src/core/ai/defaults.ts', 'src/core/company-brain/receipt-schema.ts', 'src/core/entities/resolve.ts', 'src/core/facts/withdrawal-schema.ts', 'src/core/facts/relink-schema.ts', 'src/core/google/*.ts', 'src/core/meetings/source-config.ts', 'src/core/meetings/types.ts', 'src/core/slack/source-config.ts', 'src/core/slack/types.ts', 'src/core/grants/*.ts', 'src/core/minions/tools/brain-allowlist.ts', 'src/core/ops/contract.ts', 'src/core/ops/execution-prerequisites.ts', 'src/core/page-body/page-shape.ts', 'src/core/page-body/schema.ts', 'src/core/page-state/*schema.ts', 'src/core/persistence/*.ts', 'src/core/schema-pack/link-inference.ts', 'src/core/schema-pack/redos-guard.ts', 'src/core/search/alias-normalize.ts', 'src/core/search/private-visibility.ts', 'src/core/access/principals.ts', 'src/core/access/folder-rules.ts', 'src/core/search/projection-statistics.ts', 'src/core/search/relational-intent.ts', 'src/core/shared-skills/*schema*.ts', 'src/core/ai/decide/schema.ts', 'test/helpers/legacy-embedding-config.ts', 'scripts/build-pglite-snapshot.ts', 'src/core/facts/purge-schema.ts', 'src/core/facts/insert-guard-schema.ts', 'src/core/facts/fts-index.ts', 'src/core/eligibility/generation-schema.ts', 'src/core/trust/schema.ts', 'src/core/trust/tier.ts', 'src/core/trust/allow-rules.ts', 'src/core/write-gate-schema.ts', 'src/core/questions/schema.ts', 'src/core/questions/identity.ts', 'src/core/questions/auto-think-migration.ts', 'src/core/loops/loops-schema.ts', 'src/core/postgres-engine/schema-lock-timeout.ts', 'src/core/postgres-engine/read-write-transactions.ts', 'src/core/belief/schema.ts', 'src/core/fence-repair/reasons.ts', 'src/core/fence-repair/measured.ts', 'src/core/ai/errors.ts') }}
+ key: pglite-snapshot-${{ runner.os }}-${{ hashFiles('src/core/**/*.ts', 'test/helpers/legacy-embedding-config.ts', 'scripts/build-pglite-snapshot.ts') }}
- name: Install dependencies (bounded, retried once)
timeout-minutes: 8
run: bun scripts/ci-bun-install.ts --frozen-lockfile
@@ -351,7 +351,7 @@ jobs:
path: |
test/fixtures/pglite-snapshot.tar
test/fixtures/pglite-snapshot.version
- key: pglite-snapshot-${{ runner.os }}-${{ hashFiles('src/core/*.ts', 'src/core/audit/redact-connection-info.ts', 'src/core/engine-sql/bootstrap.ts', 'src/core/schema-migrations/**', 'src/core/ai/defaults.ts', 'src/core/company-brain/receipt-schema.ts', 'src/core/entities/resolve.ts', 'src/core/facts/withdrawal-schema.ts', 'src/core/facts/relink-schema.ts', 'src/core/google/*.ts', 'src/core/meetings/source-config.ts', 'src/core/meetings/types.ts', 'src/core/slack/source-config.ts', 'src/core/slack/types.ts', 'src/core/grants/*.ts', 'src/core/minions/tools/brain-allowlist.ts', 'src/core/ops/contract.ts', 'src/core/ops/execution-prerequisites.ts', 'src/core/page-body/page-shape.ts', 'src/core/page-body/schema.ts', 'src/core/page-state/*schema.ts', 'src/core/persistence/*.ts', 'src/core/schema-pack/link-inference.ts', 'src/core/schema-pack/redos-guard.ts', 'src/core/search/alias-normalize.ts', 'src/core/search/private-visibility.ts', 'src/core/access/principals.ts', 'src/core/access/folder-rules.ts', 'src/core/search/projection-statistics.ts', 'src/core/search/relational-intent.ts', 'src/core/shared-skills/*schema*.ts', 'src/core/ai/decide/schema.ts', 'test/helpers/legacy-embedding-config.ts', 'scripts/build-pglite-snapshot.ts', 'src/core/facts/purge-schema.ts', 'src/core/facts/insert-guard-schema.ts', 'src/core/facts/fts-index.ts', 'src/core/eligibility/generation-schema.ts', 'src/core/trust/schema.ts', 'src/core/trust/tier.ts', 'src/core/trust/allow-rules.ts', 'src/core/write-gate-schema.ts', 'src/core/questions/schema.ts', 'src/core/questions/identity.ts', 'src/core/questions/auto-think-migration.ts', 'src/core/loops/loops-schema.ts', 'src/core/postgres-engine/schema-lock-timeout.ts', 'src/core/postgres-engine/read-write-transactions.ts', 'src/core/belief/schema.ts', 'src/core/fence-repair/reasons.ts', 'src/core/fence-repair/measured.ts', 'src/core/ai/errors.ts') }}
+ key: pglite-snapshot-${{ runner.os }}-${{ hashFiles('src/core/**/*.ts', 'test/helpers/legacy-embedding-config.ts', 'scripts/build-pglite-snapshot.ts') }}
- name: Install dependencies (bounded, retried once)
timeout-minutes: 8
run: bun scripts/ci-bun-install.ts --frozen-lockfile
@@ -611,7 +611,7 @@ jobs:
path: |
test/fixtures/pglite-snapshot.tar
test/fixtures/pglite-snapshot.version
- key: pglite-snapshot-${{ runner.os }}-${{ hashFiles('src/core/*.ts', 'src/core/audit/redact-connection-info.ts', 'src/core/engine-sql/bootstrap.ts', 'src/core/schema-migrations/**', 'src/core/ai/defaults.ts', 'src/core/company-brain/receipt-schema.ts', 'src/core/entities/resolve.ts', 'src/core/facts/withdrawal-schema.ts', 'src/core/facts/relink-schema.ts', 'src/core/google/*.ts', 'src/core/meetings/source-config.ts', 'src/core/meetings/types.ts', 'src/core/slack/source-config.ts', 'src/core/slack/types.ts', 'src/core/grants/*.ts', 'src/core/minions/tools/brain-allowlist.ts', 'src/core/ops/contract.ts', 'src/core/ops/execution-prerequisites.ts', 'src/core/page-body/page-shape.ts', 'src/core/page-body/schema.ts', 'src/core/page-state/*schema.ts', 'src/core/persistence/*.ts', 'src/core/schema-pack/link-inference.ts', 'src/core/schema-pack/redos-guard.ts', 'src/core/search/alias-normalize.ts', 'src/core/search/private-visibility.ts', 'src/core/access/principals.ts', 'src/core/access/folder-rules.ts', 'src/core/search/projection-statistics.ts', 'src/core/search/relational-intent.ts', 'src/core/shared-skills/*schema*.ts', 'src/core/ai/decide/schema.ts', 'test/helpers/legacy-embedding-config.ts', 'scripts/build-pglite-snapshot.ts', 'src/core/facts/purge-schema.ts', 'src/core/facts/insert-guard-schema.ts', 'src/core/facts/fts-index.ts', 'src/core/eligibility/generation-schema.ts', 'src/core/trust/schema.ts', 'src/core/trust/tier.ts', 'src/core/trust/allow-rules.ts', 'src/core/write-gate-schema.ts', 'src/core/questions/schema.ts', 'src/core/questions/identity.ts', 'src/core/questions/auto-think-migration.ts', 'src/core/loops/loops-schema.ts', 'src/core/postgres-engine/schema-lock-timeout.ts', 'src/core/postgres-engine/read-write-transactions.ts', 'src/core/belief/schema.ts', 'src/core/fence-repair/reasons.ts', 'src/core/fence-repair/measured.ts', 'src/core/ai/errors.ts') }}
+ key: pglite-snapshot-${{ runner.os }}-${{ hashFiles('src/core/**/*.ts', 'test/helpers/legacy-embedding-config.ts', 'scripts/build-pglite-snapshot.ts') }}
- name: Install dependencies (bounded, retried once)
timeout-minutes: 8
run: bun scripts/ci-bun-install.ts --frozen-lockfile
@@ -689,7 +689,7 @@ jobs:
path: |
test/fixtures/pglite-snapshot.tar
test/fixtures/pglite-snapshot.version
- key: pglite-snapshot-${{ runner.os }}-${{ hashFiles('src/core/*.ts', 'src/core/audit/redact-connection-info.ts', 'src/core/engine-sql/bootstrap.ts', 'src/core/schema-migrations/**', 'src/core/ai/defaults.ts', 'src/core/company-brain/receipt-schema.ts', 'src/core/entities/resolve.ts', 'src/core/facts/withdrawal-schema.ts', 'src/core/facts/relink-schema.ts', 'src/core/google/*.ts', 'src/core/meetings/source-config.ts', 'src/core/meetings/types.ts', 'src/core/slack/source-config.ts', 'src/core/slack/types.ts', 'src/core/grants/*.ts', 'src/core/minions/tools/brain-allowlist.ts', 'src/core/ops/contract.ts', 'src/core/ops/execution-prerequisites.ts', 'src/core/page-body/page-shape.ts', 'src/core/page-body/schema.ts', 'src/core/page-state/*schema.ts', 'src/core/persistence/*.ts', 'src/core/schema-pack/link-inference.ts', 'src/core/schema-pack/redos-guard.ts', 'src/core/search/alias-normalize.ts', 'src/core/search/private-visibility.ts', 'src/core/access/principals.ts', 'src/core/access/folder-rules.ts', 'src/core/search/projection-statistics.ts', 'src/core/search/relational-intent.ts', 'src/core/shared-skills/*schema*.ts', 'src/core/ai/decide/schema.ts', 'test/helpers/legacy-embedding-config.ts', 'scripts/build-pglite-snapshot.ts', 'src/core/facts/purge-schema.ts', 'src/core/facts/insert-guard-schema.ts', 'src/core/facts/fts-index.ts', 'src/core/eligibility/generation-schema.ts', 'src/core/trust/schema.ts', 'src/core/trust/tier.ts', 'src/core/trust/allow-rules.ts', 'src/core/write-gate-schema.ts', 'src/core/questions/schema.ts', 'src/core/questions/identity.ts', 'src/core/questions/auto-think-migration.ts', 'src/core/loops/loops-schema.ts', 'src/core/postgres-engine/schema-lock-timeout.ts', 'src/core/postgres-engine/read-write-transactions.ts', 'src/core/belief/schema.ts', 'src/core/fence-repair/reasons.ts', 'src/core/fence-repair/measured.ts', 'src/core/ai/errors.ts') }}
+ key: pglite-snapshot-${{ runner.os }}-${{ hashFiles('src/core/**/*.ts', 'test/helpers/legacy-embedding-config.ts', 'scripts/build-pglite-snapshot.ts') }}
- name: Install dependencies (bounded, retried once)
timeout-minutes: 8
run: bun scripts/ci-bun-install.ts --frozen-lockfile
@@ -776,7 +776,7 @@ jobs:
path: |
test/fixtures/pglite-snapshot.tar
test/fixtures/pglite-snapshot.version
- key: pglite-snapshot-${{ runner.os }}-${{ hashFiles('src/core/*.ts', 'src/core/audit/redact-connection-info.ts', 'src/core/engine-sql/bootstrap.ts', 'src/core/schema-migrations/**', 'src/core/ai/defaults.ts', 'src/core/company-brain/receipt-schema.ts', 'src/core/entities/resolve.ts', 'src/core/facts/withdrawal-schema.ts', 'src/core/facts/relink-schema.ts', 'src/core/google/*.ts', 'src/core/meetings/source-config.ts', 'src/core/meetings/types.ts', 'src/core/slack/source-config.ts', 'src/core/slack/types.ts', 'src/core/grants/*.ts', 'src/core/minions/tools/brain-allowlist.ts', 'src/core/ops/contract.ts', 'src/core/ops/execution-prerequisites.ts', 'src/core/page-body/page-shape.ts', 'src/core/page-body/schema.ts', 'src/core/page-state/*schema.ts', 'src/core/persistence/*.ts', 'src/core/schema-pack/link-inference.ts', 'src/core/schema-pack/redos-guard.ts', 'src/core/search/alias-normalize.ts', 'src/core/search/private-visibility.ts', 'src/core/access/principals.ts', 'src/core/access/folder-rules.ts', 'src/core/search/projection-statistics.ts', 'src/core/search/relational-intent.ts', 'src/core/shared-skills/*schema*.ts', 'src/core/ai/decide/schema.ts', 'test/helpers/legacy-embedding-config.ts', 'scripts/build-pglite-snapshot.ts', 'src/core/facts/purge-schema.ts', 'src/core/facts/insert-guard-schema.ts', 'src/core/facts/fts-index.ts', 'src/core/eligibility/generation-schema.ts', 'src/core/trust/schema.ts', 'src/core/trust/tier.ts', 'src/core/trust/allow-rules.ts', 'src/core/write-gate-schema.ts', 'src/core/questions/schema.ts', 'src/core/questions/identity.ts', 'src/core/questions/auto-think-migration.ts', 'src/core/loops/loops-schema.ts', 'src/core/postgres-engine/schema-lock-timeout.ts', 'src/core/postgres-engine/read-write-transactions.ts', 'src/core/belief/schema.ts', 'src/core/fence-repair/reasons.ts', 'src/core/fence-repair/measured.ts', 'src/core/ai/errors.ts') }}
+ key: pglite-snapshot-${{ runner.os }}-${{ hashFiles('src/core/**/*.ts', 'test/helpers/legacy-embedding-config.ts', 'scripts/build-pglite-snapshot.ts') }}
- name: Install dependencies (bounded, retried once)
timeout-minutes: 8
run: bun scripts/ci-bun-install.ts --frozen-lockfile
@@ -1080,7 +1080,7 @@ jobs:
path: |
test/fixtures/pglite-snapshot.tar
test/fixtures/pglite-snapshot.version
- key: pglite-snapshot-${{ runner.os }}-${{ hashFiles('src/core/*.ts', 'src/core/audit/redact-connection-info.ts', 'src/core/engine-sql/bootstrap.ts', 'src/core/schema-migrations/**', 'src/core/ai/defaults.ts', 'src/core/company-brain/receipt-schema.ts', 'src/core/entities/resolve.ts', 'src/core/facts/withdrawal-schema.ts', 'src/core/facts/relink-schema.ts', 'src/core/google/*.ts', 'src/core/meetings/source-config.ts', 'src/core/meetings/types.ts', 'src/core/slack/source-config.ts', 'src/core/slack/types.ts', 'src/core/grants/*.ts', 'src/core/minions/tools/brain-allowlist.ts', 'src/core/ops/contract.ts', 'src/core/ops/execution-prerequisites.ts', 'src/core/page-body/page-shape.ts', 'src/core/page-body/schema.ts', 'src/core/page-state/*schema.ts', 'src/core/persistence/*.ts', 'src/core/schema-pack/link-inference.ts', 'src/core/schema-pack/redos-guard.ts', 'src/core/search/alias-normalize.ts', 'src/core/search/private-visibility.ts', 'src/core/access/principals.ts', 'src/core/access/folder-rules.ts', 'src/core/search/projection-statistics.ts', 'src/core/search/relational-intent.ts', 'src/core/shared-skills/*schema*.ts', 'src/core/ai/decide/schema.ts', 'test/helpers/legacy-embedding-config.ts', 'scripts/build-pglite-snapshot.ts', 'src/core/facts/purge-schema.ts', 'src/core/facts/insert-guard-schema.ts', 'src/core/facts/fts-index.ts', 'src/core/eligibility/generation-schema.ts', 'src/core/trust/schema.ts', 'src/core/trust/tier.ts', 'src/core/trust/allow-rules.ts', 'src/core/write-gate-schema.ts', 'src/core/questions/schema.ts', 'src/core/questions/identity.ts', 'src/core/questions/auto-think-migration.ts', 'src/core/loops/loops-schema.ts', 'src/core/postgres-engine/schema-lock-timeout.ts', 'src/core/postgres-engine/read-write-transactions.ts', 'src/core/belief/schema.ts', 'src/core/fence-repair/reasons.ts', 'src/core/fence-repair/measured.ts', 'src/core/ai/errors.ts') }}
+ key: pglite-snapshot-${{ runner.os }}-${{ hashFiles('src/core/**/*.ts', 'test/helpers/legacy-embedding-config.ts', 'scripts/build-pglite-snapshot.ts') }}
- name: Install dependencies (bounded, retried once)
timeout-minutes: 8
run: bun scripts/ci-bun-install.ts --frozen-lockfile
diff --git a/.github/workflows/stress.yml b/.github/workflows/stress.yml
index e590b6a4a3..d0e32d36a0 100644
--- a/.github/workflows/stress.yml
+++ b/.github/workflows/stress.yml
@@ -119,7 +119,7 @@ jobs:
path: |
test/fixtures/pglite-snapshot.tar
test/fixtures/pglite-snapshot.version
- key: pglite-snapshot-${{ runner.os }}-${{ hashFiles('src/core/*.ts', 'src/core/audit/redact-connection-info.ts', 'src/core/engine-sql/bootstrap.ts', 'src/core/schema-migrations/**', 'src/core/ai/defaults.ts', 'src/core/company-brain/receipt-schema.ts', 'src/core/entities/resolve.ts', 'src/core/facts/withdrawal-schema.ts', 'src/core/facts/relink-schema.ts', 'src/core/google/*.ts', 'src/core/meetings/source-config.ts', 'src/core/meetings/types.ts', 'src/core/slack/source-config.ts', 'src/core/slack/types.ts', 'src/core/grants/*.ts', 'src/core/minions/tools/brain-allowlist.ts', 'src/core/ops/contract.ts', 'src/core/ops/execution-prerequisites.ts', 'src/core/page-body/page-shape.ts', 'src/core/page-body/schema.ts', 'src/core/page-state/*schema.ts', 'src/core/persistence/*.ts', 'src/core/schema-pack/link-inference.ts', 'src/core/schema-pack/redos-guard.ts', 'src/core/search/alias-normalize.ts', 'src/core/search/private-visibility.ts', 'src/core/access/principals.ts', 'src/core/access/folder-rules.ts', 'src/core/search/projection-statistics.ts', 'src/core/search/relational-intent.ts', 'src/core/shared-skills/*schema*.ts', 'src/core/ai/decide/schema.ts', 'test/helpers/legacy-embedding-config.ts', 'scripts/build-pglite-snapshot.ts', 'src/core/facts/purge-schema.ts', 'src/core/facts/insert-guard-schema.ts', 'src/core/facts/fts-index.ts', 'src/core/eligibility/generation-schema.ts', 'src/core/trust/schema.ts', 'src/core/trust/tier.ts', 'src/core/trust/allow-rules.ts', 'src/core/write-gate-schema.ts', 'src/core/questions/schema.ts', 'src/core/questions/identity.ts', 'src/core/questions/auto-think-migration.ts', 'src/core/loops/loops-schema.ts', 'src/core/postgres-engine/schema-lock-timeout.ts', 'src/core/postgres-engine/read-write-transactions.ts', 'src/core/belief/schema.ts', 'src/core/fence-repair/reasons.ts', 'src/core/fence-repair/measured.ts', 'src/core/ai/errors.ts') }}
+ key: pglite-snapshot-${{ runner.os }}-${{ hashFiles('src/core/**/*.ts', 'test/helpers/legacy-embedding-config.ts', 'scripts/build-pglite-snapshot.ts') }}
- name: Install dependencies (bounded, retried once)
timeout-minutes: 8
run: bun scripts/ci-bun-install.ts --frozen-lockfile
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index b0d3456643..904e1c13e1 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -430,7 +430,7 @@ jobs:
path: |
test/fixtures/pglite-snapshot.tar
test/fixtures/pglite-snapshot.version
- key: pglite-snapshot-${{ runner.os }}-${{ hashFiles('src/core/*.ts', 'src/core/audit/redact-connection-info.ts', 'src/core/engine-sql/bootstrap.ts', 'src/core/schema-migrations/**', 'src/core/ai/defaults.ts', 'src/core/company-brain/receipt-schema.ts', 'src/core/entities/resolve.ts', 'src/core/facts/withdrawal-schema.ts', 'src/core/facts/relink-schema.ts', 'src/core/google/*.ts', 'src/core/meetings/source-config.ts', 'src/core/meetings/types.ts', 'src/core/slack/source-config.ts', 'src/core/slack/types.ts', 'src/core/grants/*.ts', 'src/core/minions/tools/brain-allowlist.ts', 'src/core/ops/contract.ts', 'src/core/ops/execution-prerequisites.ts', 'src/core/page-body/page-shape.ts', 'src/core/page-body/schema.ts', 'src/core/page-state/*schema.ts', 'src/core/persistence/*.ts', 'src/core/schema-pack/link-inference.ts', 'src/core/schema-pack/redos-guard.ts', 'src/core/search/alias-normalize.ts', 'src/core/search/private-visibility.ts', 'src/core/access/principals.ts', 'src/core/access/folder-rules.ts', 'src/core/search/projection-statistics.ts', 'src/core/search/relational-intent.ts', 'src/core/shared-skills/*schema*.ts', 'src/core/ai/decide/schema.ts', 'test/helpers/legacy-embedding-config.ts', 'scripts/build-pglite-snapshot.ts', 'src/core/facts/purge-schema.ts', 'src/core/facts/insert-guard-schema.ts', 'src/core/facts/fts-index.ts', 'src/core/eligibility/generation-schema.ts', 'src/core/trust/schema.ts', 'src/core/trust/tier.ts', 'src/core/trust/allow-rules.ts', 'src/core/write-gate-schema.ts', 'src/core/questions/schema.ts', 'src/core/questions/identity.ts', 'src/core/questions/auto-think-migration.ts', 'src/core/loops/loops-schema.ts', 'src/core/postgres-engine/schema-lock-timeout.ts', 'src/core/postgres-engine/read-write-transactions.ts', 'src/core/belief/schema.ts', 'src/core/fence-repair/reasons.ts', 'src/core/fence-repair/measured.ts', 'src/core/ai/errors.ts') }}
+ key: pglite-snapshot-${{ runner.os }}-${{ hashFiles('src/core/**/*.ts', 'test/helpers/legacy-embedding-config.ts', 'scripts/build-pglite-snapshot.ts') }}
- name: Install dependencies (bounded, retried once)
timeout-minutes: 8
run: bun scripts/ci-bun-install.ts --frozen-lockfile
@@ -591,7 +591,7 @@ jobs:
path: |
test/fixtures/pglite-snapshot.tar
test/fixtures/pglite-snapshot.version
- key: pglite-snapshot-${{ runner.os }}-${{ hashFiles('src/core/*.ts', 'src/core/audit/redact-connection-info.ts', 'src/core/engine-sql/bootstrap.ts', 'src/core/schema-migrations/**', 'src/core/ai/defaults.ts', 'src/core/company-brain/receipt-schema.ts', 'src/core/entities/resolve.ts', 'src/core/facts/withdrawal-schema.ts', 'src/core/facts/relink-schema.ts', 'src/core/google/*.ts', 'src/core/meetings/source-config.ts', 'src/core/meetings/types.ts', 'src/core/slack/source-config.ts', 'src/core/slack/types.ts', 'src/core/grants/*.ts', 'src/core/minions/tools/brain-allowlist.ts', 'src/core/ops/contract.ts', 'src/core/ops/execution-prerequisites.ts', 'src/core/page-body/page-shape.ts', 'src/core/page-body/schema.ts', 'src/core/page-state/*schema.ts', 'src/core/persistence/*.ts', 'src/core/schema-pack/link-inference.ts', 'src/core/schema-pack/redos-guard.ts', 'src/core/search/alias-normalize.ts', 'src/core/search/private-visibility.ts', 'src/core/access/principals.ts', 'src/core/access/folder-rules.ts', 'src/core/search/projection-statistics.ts', 'src/core/search/relational-intent.ts', 'src/core/shared-skills/*schema*.ts', 'src/core/ai/decide/schema.ts', 'test/helpers/legacy-embedding-config.ts', 'scripts/build-pglite-snapshot.ts', 'src/core/facts/purge-schema.ts', 'src/core/facts/insert-guard-schema.ts', 'src/core/facts/fts-index.ts', 'src/core/eligibility/generation-schema.ts', 'src/core/trust/schema.ts', 'src/core/trust/tier.ts', 'src/core/trust/allow-rules.ts', 'src/core/write-gate-schema.ts', 'src/core/questions/schema.ts', 'src/core/questions/identity.ts', 'src/core/questions/auto-think-migration.ts', 'src/core/loops/loops-schema.ts', 'src/core/postgres-engine/schema-lock-timeout.ts', 'src/core/postgres-engine/read-write-transactions.ts', 'src/core/belief/schema.ts', 'src/core/fence-repair/reasons.ts', 'src/core/fence-repair/measured.ts', 'src/core/ai/errors.ts') }}
+ key: pglite-snapshot-${{ runner.os }}-${{ hashFiles('src/core/**/*.ts', 'test/helpers/legacy-embedding-config.ts', 'scripts/build-pglite-snapshot.ts') }}
- name: Install dependencies (bounded, retried once)
timeout-minutes: 8
run: bun scripts/ci-bun-install.ts --frozen-lockfile
@@ -667,13 +667,13 @@ jobs:
path: |
test/fixtures/pglite-snapshot.tar
test/fixtures/pglite-snapshot.version
- key: pglite-snapshot-${{ runner.os }}-${{ hashFiles('src/core/*.ts', 'src/core/audit/redact-connection-info.ts', 'src/core/engine-sql/bootstrap.ts', 'src/core/schema-migrations/**', 'src/core/ai/defaults.ts', 'src/core/company-brain/receipt-schema.ts', 'src/core/entities/resolve.ts', 'src/core/facts/withdrawal-schema.ts', 'src/core/facts/relink-schema.ts', 'src/core/google/*.ts', 'src/core/meetings/source-config.ts', 'src/core/meetings/types.ts', 'src/core/slack/source-config.ts', 'src/core/slack/types.ts', 'src/core/grants/*.ts', 'src/core/minions/tools/brain-allowlist.ts', 'src/core/ops/contract.ts', 'src/core/ops/execution-prerequisites.ts', 'src/core/page-body/page-shape.ts', 'src/core/page-body/schema.ts', 'src/core/page-state/*schema.ts', 'src/core/persistence/*.ts', 'src/core/schema-pack/link-inference.ts', 'src/core/schema-pack/redos-guard.ts', 'src/core/search/alias-normalize.ts', 'src/core/search/private-visibility.ts', 'src/core/access/principals.ts', 'src/core/access/folder-rules.ts', 'src/core/search/projection-statistics.ts', 'src/core/search/relational-intent.ts', 'src/core/shared-skills/*schema*.ts', 'src/core/ai/decide/schema.ts', 'test/helpers/legacy-embedding-config.ts', 'scripts/build-pglite-snapshot.ts', 'src/core/facts/purge-schema.ts', 'src/core/facts/insert-guard-schema.ts', 'src/core/facts/fts-index.ts', 'src/core/eligibility/generation-schema.ts', 'src/core/trust/schema.ts', 'src/core/trust/tier.ts', 'src/core/trust/allow-rules.ts', 'src/core/write-gate-schema.ts', 'src/core/questions/schema.ts', 'src/core/questions/identity.ts', 'src/core/questions/auto-think-migration.ts', 'src/core/loops/loops-schema.ts', 'src/core/postgres-engine/schema-lock-timeout.ts', 'src/core/postgres-engine/read-write-transactions.ts', 'src/core/belief/schema.ts', 'src/core/fence-repair/reasons.ts', 'src/core/fence-repair/measured.ts', 'src/core/ai/errors.ts') }}
+ key: pglite-snapshot-${{ runner.os }}-${{ hashFiles('src/core/**/*.ts', 'test/helpers/legacy-embedding-config.ts', 'scripts/build-pglite-snapshot.ts') }}
- uses: actions/cache/restore@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
with:
path: |
test/fixtures/pglite-snapshot-default.tar
test/fixtures/pglite-snapshot-default.version
- key: pglite-snapshot-default-${{ runner.os }}-${{ hashFiles('src/core/*.ts', 'src/core/audit/redact-connection-info.ts', 'src/core/engine-sql/bootstrap.ts', 'src/core/schema-migrations/**', 'src/core/ai/defaults.ts', 'src/core/company-brain/receipt-schema.ts', 'src/core/entities/resolve.ts', 'src/core/facts/withdrawal-schema.ts', 'src/core/facts/relink-schema.ts', 'src/core/google/*.ts', 'src/core/meetings/source-config.ts', 'src/core/meetings/types.ts', 'src/core/slack/source-config.ts', 'src/core/slack/types.ts', 'src/core/grants/*.ts', 'src/core/minions/tools/brain-allowlist.ts', 'src/core/ops/contract.ts', 'src/core/ops/execution-prerequisites.ts', 'src/core/page-body/page-shape.ts', 'src/core/page-body/schema.ts', 'src/core/page-state/*schema.ts', 'src/core/persistence/*.ts', 'src/core/schema-pack/link-inference.ts', 'src/core/schema-pack/redos-guard.ts', 'src/core/search/alias-normalize.ts', 'src/core/search/private-visibility.ts', 'src/core/access/principals.ts', 'src/core/access/folder-rules.ts', 'src/core/search/projection-statistics.ts', 'src/core/search/relational-intent.ts', 'src/core/shared-skills/*schema*.ts', 'src/core/ai/decide/schema.ts', 'test/helpers/legacy-embedding-config.ts', 'scripts/build-pglite-snapshot.ts', 'src/core/facts/purge-schema.ts', 'src/core/facts/insert-guard-schema.ts', 'src/core/facts/fts-index.ts', 'src/core/eligibility/generation-schema.ts', 'src/core/trust/schema.ts', 'src/core/trust/tier.ts', 'src/core/trust/allow-rules.ts', 'src/core/write-gate-schema.ts', 'src/core/questions/schema.ts', 'src/core/questions/identity.ts', 'src/core/questions/auto-think-migration.ts', 'src/core/loops/loops-schema.ts', 'src/core/postgres-engine/schema-lock-timeout.ts', 'src/core/postgres-engine/read-write-transactions.ts', 'src/core/belief/schema.ts', 'src/core/fence-repair/reasons.ts', 'src/core/fence-repair/measured.ts', 'src/core/ai/errors.ts') }}
+ key: pglite-snapshot-default-${{ runner.os }}-${{ hashFiles('src/core/**/*.ts', 'test/helpers/legacy-embedding-config.ts', 'scripts/build-pglite-snapshot.ts') }}
- name: Install dependencies (bounded, retried once)
timeout-minutes: 8
run: bun scripts/ci-bun-install.ts --frozen-lockfile
@@ -755,7 +755,7 @@ jobs:
path: |
test/fixtures/pglite-snapshot-default.tar
test/fixtures/pglite-snapshot-default.version
- key: pglite-snapshot-default-${{ runner.os }}-${{ hashFiles('src/core/*.ts', 'src/core/audit/redact-connection-info.ts', 'src/core/engine-sql/bootstrap.ts', 'src/core/schema-migrations/**', 'src/core/ai/defaults.ts', 'src/core/company-brain/receipt-schema.ts', 'src/core/entities/resolve.ts', 'src/core/facts/withdrawal-schema.ts', 'src/core/facts/relink-schema.ts', 'src/core/google/*.ts', 'src/core/meetings/source-config.ts', 'src/core/meetings/types.ts', 'src/core/slack/source-config.ts', 'src/core/slack/types.ts', 'src/core/grants/*.ts', 'src/core/minions/tools/brain-allowlist.ts', 'src/core/ops/contract.ts', 'src/core/ops/execution-prerequisites.ts', 'src/core/page-body/page-shape.ts', 'src/core/page-body/schema.ts', 'src/core/page-state/*schema.ts', 'src/core/persistence/*.ts', 'src/core/schema-pack/link-inference.ts', 'src/core/schema-pack/redos-guard.ts', 'src/core/search/alias-normalize.ts', 'src/core/search/private-visibility.ts', 'src/core/access/principals.ts', 'src/core/access/folder-rules.ts', 'src/core/search/projection-statistics.ts', 'src/core/search/relational-intent.ts', 'src/core/shared-skills/*schema*.ts', 'src/core/ai/decide/schema.ts', 'test/helpers/legacy-embedding-config.ts', 'scripts/build-pglite-snapshot.ts', 'src/core/facts/purge-schema.ts', 'src/core/facts/insert-guard-schema.ts', 'src/core/facts/fts-index.ts', 'src/core/eligibility/generation-schema.ts', 'src/core/trust/schema.ts', 'src/core/trust/tier.ts', 'src/core/trust/allow-rules.ts', 'src/core/write-gate-schema.ts', 'src/core/questions/schema.ts', 'src/core/questions/identity.ts', 'src/core/questions/auto-think-migration.ts', 'src/core/loops/loops-schema.ts', 'src/core/postgres-engine/schema-lock-timeout.ts', 'src/core/postgres-engine/read-write-transactions.ts', 'src/core/belief/schema.ts', 'src/core/fence-repair/reasons.ts', 'src/core/fence-repair/measured.ts', 'src/core/ai/errors.ts') }}
+ key: pglite-snapshot-default-${{ runner.os }}-${{ hashFiles('src/core/**/*.ts', 'test/helpers/legacy-embedding-config.ts', 'scripts/build-pglite-snapshot.ts') }}
- name: Install dependencies (bounded, retried once)
timeout-minutes: 8
run: bun scripts/ci-bun-install.ts --frozen-lockfile
@@ -799,7 +799,7 @@ jobs:
path: |
test/fixtures/pglite-snapshot.tar
test/fixtures/pglite-snapshot.version
- key: pglite-snapshot-${{ runner.os }}-${{ hashFiles('src/core/*.ts', 'src/core/audit/redact-connection-info.ts', 'src/core/engine-sql/bootstrap.ts', 'src/core/schema-migrations/**', 'src/core/ai/defaults.ts', 'src/core/company-brain/receipt-schema.ts', 'src/core/entities/resolve.ts', 'src/core/facts/withdrawal-schema.ts', 'src/core/facts/relink-schema.ts', 'src/core/google/*.ts', 'src/core/meetings/source-config.ts', 'src/core/meetings/types.ts', 'src/core/slack/source-config.ts', 'src/core/slack/types.ts', 'src/core/grants/*.ts', 'src/core/minions/tools/brain-allowlist.ts', 'src/core/ops/contract.ts', 'src/core/ops/execution-prerequisites.ts', 'src/core/page-body/page-shape.ts', 'src/core/page-body/schema.ts', 'src/core/page-state/*schema.ts', 'src/core/persistence/*.ts', 'src/core/schema-pack/link-inference.ts', 'src/core/schema-pack/redos-guard.ts', 'src/core/search/alias-normalize.ts', 'src/core/search/private-visibility.ts', 'src/core/access/principals.ts', 'src/core/access/folder-rules.ts', 'src/core/search/projection-statistics.ts', 'src/core/search/relational-intent.ts', 'src/core/shared-skills/*schema*.ts', 'src/core/ai/decide/schema.ts', 'test/helpers/legacy-embedding-config.ts', 'scripts/build-pglite-snapshot.ts', 'src/core/facts/purge-schema.ts', 'src/core/facts/insert-guard-schema.ts', 'src/core/facts/fts-index.ts', 'src/core/eligibility/generation-schema.ts', 'src/core/trust/schema.ts', 'src/core/trust/tier.ts', 'src/core/trust/allow-rules.ts', 'src/core/write-gate-schema.ts', 'src/core/questions/schema.ts', 'src/core/questions/identity.ts', 'src/core/questions/auto-think-migration.ts', 'src/core/loops/loops-schema.ts', 'src/core/postgres-engine/schema-lock-timeout.ts', 'src/core/postgres-engine/read-write-transactions.ts', 'src/core/belief/schema.ts', 'src/core/fence-repair/reasons.ts', 'src/core/fence-repair/measured.ts', 'src/core/ai/errors.ts') }}
+ key: pglite-snapshot-${{ runner.os }}-${{ hashFiles('src/core/**/*.ts', 'test/helpers/legacy-embedding-config.ts', 'scripts/build-pglite-snapshot.ts') }}
- name: Install dependencies (bounded, retried once)
timeout-minutes: 8
run: bun scripts/ci-bun-install.ts --frozen-lockfile
@@ -920,7 +920,7 @@ jobs:
path: |
test/fixtures/pglite-snapshot.tar
test/fixtures/pglite-snapshot.version
- key: pglite-snapshot-${{ runner.os }}-${{ hashFiles('src/core/*.ts', 'src/core/audit/redact-connection-info.ts', 'src/core/engine-sql/bootstrap.ts', 'src/core/schema-migrations/**', 'src/core/ai/defaults.ts', 'src/core/company-brain/receipt-schema.ts', 'src/core/entities/resolve.ts', 'src/core/facts/withdrawal-schema.ts', 'src/core/facts/relink-schema.ts', 'src/core/google/*.ts', 'src/core/meetings/source-config.ts', 'src/core/meetings/types.ts', 'src/core/slack/source-config.ts', 'src/core/slack/types.ts', 'src/core/grants/*.ts', 'src/core/minions/tools/brain-allowlist.ts', 'src/core/ops/contract.ts', 'src/core/ops/execution-prerequisites.ts', 'src/core/page-body/page-shape.ts', 'src/core/page-body/schema.ts', 'src/core/page-state/*schema.ts', 'src/core/persistence/*.ts', 'src/core/schema-pack/link-inference.ts', 'src/core/schema-pack/redos-guard.ts', 'src/core/search/alias-normalize.ts', 'src/core/search/private-visibility.ts', 'src/core/access/principals.ts', 'src/core/access/folder-rules.ts', 'src/core/search/projection-statistics.ts', 'src/core/search/relational-intent.ts', 'src/core/shared-skills/*schema*.ts', 'src/core/ai/decide/schema.ts', 'test/helpers/legacy-embedding-config.ts', 'scripts/build-pglite-snapshot.ts', 'src/core/facts/purge-schema.ts', 'src/core/facts/insert-guard-schema.ts', 'src/core/facts/fts-index.ts', 'src/core/eligibility/generation-schema.ts', 'src/core/trust/schema.ts', 'src/core/trust/tier.ts', 'src/core/trust/allow-rules.ts', 'src/core/write-gate-schema.ts', 'src/core/questions/schema.ts', 'src/core/questions/identity.ts', 'src/core/questions/auto-think-migration.ts', 'src/core/loops/loops-schema.ts', 'src/core/postgres-engine/schema-lock-timeout.ts', 'src/core/postgres-engine/read-write-transactions.ts', 'src/core/belief/schema.ts', 'src/core/fence-repair/reasons.ts', 'src/core/fence-repair/measured.ts', 'src/core/ai/errors.ts') }}
+ key: pglite-snapshot-${{ runner.os }}-${{ hashFiles('src/core/**/*.ts', 'test/helpers/legacy-embedding-config.ts', 'scripts/build-pglite-snapshot.ts') }}
- name: Install dependencies (bounded, retried once)
timeout-minutes: 8
run: bun scripts/ci-bun-install.ts --frozen-lockfile
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8b7f30365a..4cc41663a2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -10,6 +10,18 @@ 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 upgrade` now restarts a jobs supervisor started from a source checkout as `bun run src/cli.ts jobs supervisor` instead of refusing the upgrade with `restart_refused`.** The restart planner recognised a gbrain process only when its command line held a path containing "gbrain", so a supervisor launched with a relative `src/cli.ts` was invisible, its worker looked unsupervised, and the upgrade stopped. Four smaller fixes ride along: a flaky spend-guard SIGTERM test, the PGLite snapshot cache keys, the stress gate's pooled-owner match, and the ownership stamp on a checkout that became a Git repository after it was stamped.
+
+### Itemized changes
+
+- `src/core/upgrade-restart.ts`: `gbrainEntry` resolves a relative entry point against the process's working directory (`/proc/<pid>/cwd` on Linux) and treats `src/cli.ts` as gbrain when the package two levels up is named gbrain; an unreadable package falls back to the old path match. `bun run <file>` runs the file in its own process and is classified; `bunx`, `bun x` and `bun run <bin>` are wrappers whose child is the gbrain process, so they are no longer counted twice. A worker whose parent is not recognised as gbrain is refused with that parent's pid and command line. On macOS, where the working directory is not read, a relative launch is named in the refusal.
+- `scripts/eval-spend-guard.sh` (#8717): the lease's start time is read before the signal traps are armed, so no command substitution is parsed between arming them and `wait`. A TERM that landed there ran its trap while bash 5.2 still expected the lease line's `)`, the trap failed with "unexpected EOF while looking for matching `)'", the signal was lost and the guard waited out its command and exited 0. Under CPU load the original guard did that in 3 of 3000 forced TERMs and the fixed guard in 0 of 3000, interleaved. `test/eval-spend-guard.test.ts` pins that no command substitution sits in that window; the exit-143 assertion is unchanged.
+- `.github/workflows/test.yml`, `e2e.yml`, `stress.yml` (#8700): the 15 `pglite-snapshot` cache keys hash `src/core/**/*.ts` (plus the snapshot builder and its test helper) instead of `src/core/*.ts` and a hand list of subdirectory files, so a schema input in a new `src/core` folder needs no workflow edit. A change anywhere under `src/core` now rebuilds the snapshot cache.
+- `scripts/stress/run.ts` (#8702): a pooler-gated test is exempt from the stress gate only when the workflow job that names it, or the script lines beside it, set `GBRAIN_CI_REQUIRE_PGBOUNCER`; a flag elsewhere in the same file no longer counts. `test/e2e/graduation-cli-topologies.test.ts` is no longer exempt, and a script owner is reported as an "owning pooled runner".
+- `src/core/persistence/physical-root-record.ts` (#8713): verifying a physical root inside a Git checkout writes the ownership-marker exclude once per process, so a repo-less brain that later ran `git init` stops offering its `.gbrain-owner.json` to `git add -A`. The conversion refusal for a root with no Git history now says to add the exclude before the first `git add -A`. Doctor's existing `tracked_ownership_marker` check (#5186) still names a stamp already in the index with the `git rm --cached` fix, which keeps the file and history.
+
## [0.60.593.0] - 2026-11-06
**`gbrain repair failed-writes` now previews a brain with a large write journal in about a second instead of timing out.** On Postgres, the preview of refused writes read the request table once per refused write, and one of those reads walked the table from that write to its end. With hundreds of refused writes and a journal of over a million requests, the preview ran for minutes and the server's statement timeout ended it with a bare `internal_error`, so the operator had no way to see or recover the lost writes. The preview now classes refused writes together in set reads, each sized so it stays short even on a page with hundreds of refused writes and a long history. On a synthetic journal of 1.5 million requests with over 800 refused writes it took about a second (it took 265 seconds before), with the same classes and the same preview hash. When a preview read does still run past the timeout, it refuses `repair_preview_timeout` with a fix instead of `internal_error`, and nothing is saved.
diff --git a/scripts/eval-spend-guard.sh b/scripts/eval-spend-guard.sh
index e2e51bf904..346838602d 100755
--- a/scripts/eval-spend-guard.sh
+++ b/scripts/eval-spend-guard.sh
@@ -359,6 +359,12 @@ on_exit() { # <exit status>
stop_child
reconcile "$EST" "$1" || exit 3
}
+# The lease's start time is read before the traps are armed (#8717): no
+# command substitution may be parsed between here and `wait`. Bash 5.2 can run
+# a trap that lands while it parses a top-level `$(...)` inside that parse,
+# where the trap command fails ("unexpected EOF while looking for matching
+# `)'") and the signal is lost, so the guard waited out its command and exited 0.
+STARTED="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
# Traps BEFORE the reservation: a signal in the append→launch window must
# still reconcile (RESERVED gates whether there is anything to reconcile).
trap 'on_signal 2' INT
@@ -397,7 +403,7 @@ set -m
CHILD=$!
set +m
if mkdir -p "$LEASES" 2>/dev/null && printf 'run_id=%s\nguard_pid=%s\npgid=%s\nhost=%s\nboot_id=%s\nstarted=%s\n' \
- "$RUN_ID" "$$" "$CHILD" "$GUARD_HOST" "$BOOT_ID" "$(date -u +%Y-%m-%dT%H:%M:%SZ)" > "$LEASES/$RUN_ID.lease" 2>/dev/null; then
+ "$RUN_ID" "$$" "$CHILD" "$GUARD_HOST" "$BOOT_ID" "$STARTED" > "$LEASES/$RUN_ID.lease" 2>/dev/null; then
LEASE="$LEASES/$RUN_ID.lease"
else
echo "eval-spend-guard: could not write the run lease under $LEASES; a later guard cannot report this run if the guard is SIGKILLed" >&2
diff --git a/scripts/stress/run.ts b/scripts/stress/run.ts
index 1daf4e99fe..5418c879c9 100644
--- a/scripts/stress/run.ts
+++ b/scripts/stress/run.ts
@@ -362,13 +362,25 @@ export function skipReason(file: string): string | null {
const owner = OWNING_WORKFLOWS.find(w => { const p = join(ROOT, '.github/workflows', w); return existsSync(p) && readFileSync(p, 'utf8').includes(file); });
if (owner) return `every test skipped here: its prerequisite (agent binary or native target) comes from its owning job in .github/workflows/${owner}; not stressed`;
if (/process\.env\.GBRAIN_PGBOUNCER_URL/.test(text) && !process.env.GBRAIN_PGBOUNCER_URL) {
+ const workflow = readdirSync(join(ROOT, '.github/workflows')).map(w => `.github/workflows/${w}`).find(p => requiresPooler(file, p, workflowJobs));
+ if (workflow) return `every test skipped without the PgBouncer fixture (GBRAIN_PGBOUNCER_URL); its owning pooled job in ${workflow} requires it; not stressed`;
const scripts = existsSync(join(ROOT, 'scripts')) ? readdirSync(join(ROOT, 'scripts')).filter(s => s.endsWith('.sh')).map(s => `scripts/${s}`) : [];
- const pooled = [...readdirSync(join(ROOT, '.github/workflows')).map(w => `.github/workflows/${w}`), ...scripts].find(p => { const body = readFileSync(join(ROOT, p), 'utf8'); return body.includes(file) && body.includes('GBRAIN_CI_REQUIRE_PGBOUNCER'); });
- if (pooled) return `every test skipped without the PgBouncer fixture (GBRAIN_PGBOUNCER_URL); its owning pooled job in ${pooled} requires it; not stressed`;
+ const script = scripts.find(p => requiresPooler(file, p, scriptStatements));
+ if (script) return `every test skipped without the PgBouncer fixture (GBRAIN_PGBOUNCER_URL); its owning pooled runner ${script} requires it; not stressed`;
}
return null;
}
+/** A workflow's jobs (each top-level key under `jobs:`, env included), so the pooler requirement must be on the job that runs the file. */
+const workflowJobs = (lines: string[]) => lines.reduce<string[][]>((jobs, line) => { if (/^ {2}[\w-]+:/.test(line)) jobs.push([]); jobs.at(-1)?.push(line); return jobs; }, [[]]).map(job => job.join('\n'));
+/** Every two-line neighbourhood of a script, so the pooler requirement must sit beside the file's own test (as at scripts/run-e2e.sh:536-537). */
+const scriptStatements = (lines: string[]) => lines.map((_, i) => lines.slice(Math.max(0, i - 2), i + 3).join('\n'));
+
+function requiresPooler(file: string, path: string, blocks: (lines: string[]) => string[]): boolean {
+ const body = readFileSync(join(ROOT, path), 'utf8');
+ return body.includes(file) && blocks(body.split('\n')).some(block => block.includes(file) && block.includes('GBRAIN_CI_REQUIRE_PGBOUNCER'));
+}
+
async function stressFile(ctx: RunContext, file: string, profile: Profile, first: number, count: number): Promise<FileResult> {
const { args } = ctx;
const seedBase = args.seed ?? defaultSeed(ctx.sha, file);
diff --git a/src/commands/upgrade-restart.ts b/src/commands/upgrade-restart.ts
index 30f8734111..2504d0b156 100644
--- a/src/commands/upgrade-restart.ts
+++ b/src/commands/upgrade-restart.ts
@@ -8,7 +8,7 @@
* onto the build already installed (doctor's `runtime_build_skew` fix);
* `--dry-run` prints the plan and changes nothing.
*/
-import { existsSync, readFileSync, realpathSync, statSync } from 'node:fs';
+import { existsSync, readFileSync, readlinkSync, realpathSync, statSync } from 'node:fs';
import { homedir } from 'node:os';
import { delimiter, dirname, join } from 'node:path';
import { spawnSync } from '../core/spawn.ts';
@@ -51,6 +51,21 @@ function processHome(pid: number): string | null | undefined {
}
}
+/** A process's working directory, which a relative entry point resolves against; null when it cannot be read (only Linux exposes it). */
+function processCwd(pid: number): string | null {
+ try { return readlinkSync(`/proc/${pid}/cwd`); } catch { return null; }
+}
+
+/** The package name at a directory; undefined when it holds no readable package.json. */
+function packageNameAt(root: string): string | null | undefined {
+ try {
+ const name = (JSON.parse(readFileSync(join(root, 'package.json'), 'utf8')) as { name?: unknown }).name;
+ return typeof name === 'string' ? name : null;
+ } catch {
+ return undefined;
+ }
+}
+
/** This user's processes from `ps` (Linux and macOS), or the given pids; null when ps cannot run. */
function readProcessTable(uid: number | undefined, pids?: number[]): ProcessTableRow[] | null {
const select = pids ? ['-p', pids.join(',')] : uid === undefined ? ['-x'] : ['-U', String(uid)];
@@ -62,13 +77,13 @@ function readProcessTable(uid: number | undefined, pids?: number[]): ProcessTabl
if (!m) return [];
const elapsed = parseEtimeToMs(m[3]!);
const pid = Number(m[1]);
- return [{ pid, ppid: Number(m[2]), command: m[4]!, started_ms: elapsed === null ? null : now - elapsed, gbrain_home: processHome(pid) }];
+ return [{ pid, ppid: Number(m[2]), command: m[4]!, started_ms: elapsed === null ? null : now - elapsed, gbrain_home: processHome(pid), cwd: processCwd(pid) }];
});
}
/** The gbrain install a command line starts from: the package directory above its entry point and the version it holds now (null for a compiled binary). */
-function installOf(command: string): { root: string | null; version: string | null } {
- const entry = gbrainEntry(command)?.entry;
+function installOf(command: string, cwd?: string | null): { root: string | null; version: string | null } {
+ const entry = gbrainEntry(command, { cwd, packageName: packageNameAt })?.entry;
if (!entry) return { root: null, version: null };
try {
const found = entry.includes('/') ? entry : (process.env.PATH ?? '').split(delimiter).map(dir => join(dir, entry)).find(path => existsSync(path));
@@ -136,6 +151,7 @@ async function hostSources(): Promise<{ sources: ProcessSources; notes: string[]
workers: () => { try { return readWorkers(() => null).map(w => ({ pid: w.pid, version: w.version ?? null })); } catch { return []; } },
processTable: () => readProcessTable(uid),
install: installOf,
+ packageName: packageNameAt,
home: brainHome(),
exclude: [process.pid, process.ppid],
};
@@ -159,7 +175,7 @@ function hostExecutor(pidFile: string): RestartExecutor {
function terminateIfUnchanged(pid: number, startedMs: number | null): 'stopped' | 'gone' | 'changed' {
const row = readProcessTable(undefined, [pid])?.find(r => r.pid === pid);
if (!row) return 'gone';
- if (classifyGbrainCommand(row.command) !== 'mcp' || startedMs === null || row.started_ms === null || Math.abs(row.started_ms - startedMs) > 2_000) return 'changed';
+ if (classifyGbrainCommand(row.command, { cwd: row.cwd, packageName: packageNameAt }) !== 'mcp' || startedMs === null || row.started_ms === null || Math.abs(row.started_ms - startedMs) > 2_000) return 'changed';
try { process.kill(pid, 'SIGTERM'); return 'stopped'; } catch { return 'gone'; }
}
diff --git a/src/core/persistence/git-conversion.ts b/src/core/persistence/git-conversion.ts
index 4f3cbc54d8..e113b1abc1 100644
--- a/src/core/persistence/git-conversion.ts
+++ b/src/core/persistence/git-conversion.ts
@@ -329,7 +329,7 @@ async function assertConversionCheckout(sourceId: string, root: string): Promise
const state = code === 'git_checkout_required' ? 'is not inside a Git checkout' : 'is a Git checkout with no commit yet';
const why = 'A git-canonical source commits every page to Git on top of the checkout\'s branch, so its root needs a Git checkout with a first commit.';
throw opError(code, `Source ${sourceId}'s root ${root} ${state}, so it has nothing to convert into; nothing was read or written. The source stays usable as it is, with the database as its record.`,
- 'Keep the source as it is, or make its root a Git repository with a first commit on the brain host (git init, git add -A, git commit), then preview again.',
+ 'Keep the source as it is, or make its root a Git repository with a first commit on the brain host (git init, then echo \'.gbrain-owner*\' >> .git/info/exclude so the ownership marker stays out of Git, git add -A, git commit), then preview again.',
{ why, docs: DOCS, fix: { argv: ['gbrain', 'sources', 'canonical', sourceId, '--to', 'git', '--dry-run', '--json'], consent: [], actor: 'user', requires_exclusive: false,
why: 'Previews the conversion again once the root has a first commit; read-only.',
user_message: `Source ${sourceId} has no Git history to convert into. It keeps working as it is. Should its folder become a Git repository with a first commit so it can be converted?` } });
diff --git a/src/core/persistence/physical-root-record.ts b/src/core/persistence/physical-root-record.ts
index f2af349edf..2fa65a99d7 100644
--- a/src/core/persistence/physical-root-record.ts
+++ b/src/core/persistence/physical-root-record.ts
@@ -403,5 +403,21 @@ export function assertPhysicalRoot(path: string, identity: { worktreeId: string;
const reservation = readPhysicalRootReservation(root);
if (!reservation || reservation.worktreeId !== identity.worktreeId || identity.coordinationPath && reservation.coordinationPath !== identity.coordinationPath) throw physicalRootError();
assertPhysicalRootStamp(root, reservation);
+ excludeMarkersInLaterCheckout(root);
} catch (error) { if (error instanceof OperationError) throw error; throw physicalRootError(); }
}
+/**
+ * #8713: a root stamped before it was a Git checkout (`git init` on a repo-less brain) got no exclude, so an add-all
+ * writer commits its stamp. A verified root inside a checkout whose exclude file lacks a marker glob gets them written.
+ * A root in no checkout costs a few stats and an existing exclude one read; git runs only when one is missing (or the
+ * checkout is a linked worktree, whose exclude git resolves).
+ */
+function excludeMarkersInLaterCheckout(root: string): void {
+ let top = root;
+ while (!existsSync(join(top, '.git'))) { if (dirname(top) === top) return; top = dirname(top); }
+ try {
+ const present = new Set(readFileSync(join(top, '.git', 'info', 'exclude'), 'utf8').split('\n').map(line => line.trim()));
+ if (OWNERSHIP_MARKER_GLOBS.every(glob => present.has(glob))) return;
+ } catch { /* no exclude file yet, or .git is a linked worktree's pointer file */ }
+ excludeOwnershipMarkers([root, dirname(root)]);
+}
diff --git a/src/core/upgrade-restart.ts b/src/core/upgrade-restart.ts
index 8194d8e5bf..a8b7028ebf 100644
--- a/src/core/upgrade-restart.ts
+++ b/src/core/upgrade-restart.ts
@@ -31,7 +31,7 @@
* holds it), each restarted role and supervised worker came back, and the
* warm CLI socket, when serve had one, accepts this build.
*/
-import { basename, resolve } from 'node:path';
+import { basename, dirname, isAbsolute, resolve } from 'node:path';
import { parseGlobalFlags } from './cli-options.ts';
export type ProcessRole = 'serve' | 'autopilot' | 'supervisor' | 'worker' | 'mcp' | 'sync';
@@ -53,9 +53,11 @@ export interface HostProcess {
install_version?: string | null;
/** The package directory of the gbrain install it was started from (realpath); null when unknown (a compiled binary). */
install_root?: string | null;
+ /** A worker with no gbrain process above it: the process that started it, which was not recognised as gbrain. */
+ unclassified_parent?: { pid: number; command: string };
}
-export interface ProcessTableRow { pid: number; ppid: number; command: string; started_ms: number | null; gbrain_home: string | null | undefined }
+export interface ProcessTableRow { pid: number; ppid: number; command: string; started_ms: number | null; gbrain_home: string | null | undefined; cwd?: string | null }
export interface ProcessSources {
/** Live consumer heartbeat rows on this host (Postgres only; PGLite keeps none). */
@@ -64,8 +66,10 @@ export interface ProcessSources {
workers: () => Array<{ pid: number; version: string | null }>;
/** This user's processes, null when ps cannot run; `gbrain_home` is the GBRAIN_HOME (else HOME) from the process's environment, undefined when unreadable. */
processTable: () => ProcessTableRow[] | null;
- /** The gbrain install a command line starts from: its package directory and the version it holds now (null when unknown). */
- install?: (command: string) => { root: string | null; version: string | null };
+ /** The gbrain install a command line started in `cwd` runs from: its package directory and the version it holds now (null when unknown). */
+ install?: (command: string, cwd?: string | null) => { root: string | null; version: string | null };
+ /** The package name at a directory, undefined when unreadable: which `src/cli.ts` entry points are gbrain. */
+ packageName?: (root: string) => string | null | undefined;
/** This brain's GBRAIN_HOME (else HOME), resolved. */
home: string;
/** Pids never listed: this process and its parents (the upgrade that spawned it). */
@@ -77,20 +81,49 @@ const SERVE_SUBCOMMANDS_TRANSIENT = new Set(['status', 'install', 'uninstall', '
const AUTOPILOT_TRANSIENT = new Set(['status', 'install', 'uninstall', 'pause', 'resume', 'help']);
const INTERPRETERS = new Set(['bun', 'node']);
+/**
+ * What decides whether a script entry point is gbrain: the process's working directory, which a relative entry
+ * resolves against (null when unreadable), and the package name at a directory (undefined when unreadable).
+ */
+export interface EntryLookup { cwd?: string | null; packageName?: (root: string) => string | null | undefined }
+
+/** A `src/cli.ts` entry is gbrain when the package two levels up is named gbrain; an unreadable package falls back to a gbrain path. */
+function isGbrainCli(path: string, packageName: EntryLookup['packageName']): boolean {
+ if (!/(^|\/)src\/cli\.ts$/.test(path)) return false;
+ const name = packageName?.(dirname(dirname(path)));
+ return name === undefined ? /gbrain[^\s]*\/src\/cli\.ts$/.test(path) : name === 'gbrain';
+}
+
/**
* The gbrain entry point of a command line and the arguments after it, or null when the command is not gbrain
- * itself: a wrapper that starts gbrain as its child (tini, a shell, `timeout`) is not the gbrain process.
+ * itself: a wrapper that starts gbrain as its child (tini, a shell, `timeout`, `bunx`, `bun x`, `bun run <bin>`)
+ * is not the gbrain process, while `bun run <file>` runs the file in its own process. A relative entry is
+ * returned resolved against the process's working directory, and is null when that directory is unknown.
*/
-export function gbrainEntry(command: string): { entry: string; args: string[] } | null {
+export function gbrainEntry(command: string, lookup: EntryLookup = {}): { entry: string; args: string[] } | null {
const tokens = command.trim().split(/\s+/);
- const at = tokens.findIndex(token => /(^|\/)gbrain$/.test(token) || /gbrain[^\s]*\/src\/cli\.ts$/.test(token));
- if (at === -1 || (at > 0 && !INTERPRETERS.has(basename(tokens[0]!)))) return null;
- return { entry: tokens[at]!, args: tokens.slice(at + 1) };
+ const isPath = (token: string) => token.includes('/') || /\.[cm]?[jt]s$/.test(token);
+ let at = 0;
+ if (INTERPRETERS.has(basename(tokens[0]!))) {
+ for (at = 1; tokens[at]?.startsWith('-'); at++);
+ if (basename(tokens[0]!) === 'bun') {
+ if (tokens[at] === 'x') return null;
+ if (tokens[at] === 'run') for (at++; tokens[at]?.startsWith('-'); at++);
+ if (tokens[at] !== undefined && !isPath(tokens[at]!)) return null;
+ }
+ }
+ const token = tokens[at];
+ if (token === undefined) return null;
+ const relative = isPath(token) && !isAbsolute(token);
+ if (relative && !lookup.cwd) return null;
+ const entry = relative ? resolve(lookup.cwd!, token) : token;
+ if (basename(entry) !== 'gbrain' && !isGbrainCli(entry, lookup.packageName)) return null;
+ return { entry, args: tokens.slice(at + 1) };
}
/** The role of a gbrain command line, or null when it is not a long-running gbrain process. */
-export function classifyGbrainCommand(command: string): ProcessRole | null {
- const args = gbrainEntry(command)?.args;
+export function classifyGbrainCommand(command: string, lookup: EntryLookup = {}): ProcessRole | null {
+ const args = gbrainEntry(command, lookup)?.args;
if (!args) return null;
const [sub, second] = args.filter(arg => !arg.startsWith('-'));
if (sub === 'serve') {
@@ -122,10 +155,11 @@ export async function collectHostProcesses(sources: ProcessSources): Promise<Hos
for (const row of table ?? []) {
if (excluded.has(row.pid)) continue;
if (row.gbrain_home !== undefined && row.gbrain_home !== null && resolve(row.gbrain_home) !== resolve(sources.home)) continue;
- const role = classifyGbrainCommand(row.command);
+ const lookup = { cwd: row.cwd, packageName: sources.packageName };
+ const role = classifyGbrainCommand(row.command, lookup);
if (!role) continue;
byPid.set(row.pid, { pid: row.pid, ppid: null, role, version: null, started_ms: row.started_ms, ancestors: ancestry(row.ppid),
- args: gbrainEntry(row.command)!.args, ...installFields(sources.install?.(row.command)) });
+ args: gbrainEntry(row.command, lookup)!.args, ...installFields(sources.install?.(row.command, row.cwd)) });
}
const merge = (pid: number, role: ProcessRole | null, version: string | null) => {
if (excluded.has(pid)) return;
@@ -141,7 +175,11 @@ export async function collectHostProcesses(sources: ProcessSources): Promise<Hos
for (const worker of sources.workers()) merge(worker.pid, 'worker', worker.version);
const supervisor = sources.supervisor();
if (supervisor) merge(supervisor.pid, 'supervisor', supervisor.version);
- for (const p of byPid.values()) p.ppid = p.ancestors?.find(pid => byPid.has(pid)) ?? null;
+ for (const p of byPid.values()) {
+ p.ppid = p.ancestors?.find(pid => byPid.has(pid)) ?? null;
+ const launcher = p.role === 'worker' && p.ppid === null && p.ancestors?.[0] !== undefined ? rows.get(p.ancestors[0]) : undefined;
+ if (launcher) p.unclassified_parent = { pid: launcher.pid, command: launcher.command };
+ }
return [...byPid.values()].sort((a, b) => a.pid - b.pid);
}
@@ -264,7 +302,7 @@ export function planRestart(processes: readonly HostProcess[], ctx: RestartConte
case 'worker':
if (parent?.role === 'supervisor' && parent.args) supervisors.set(parent.pid, [...(supervisors.get(parent.pid) ?? []), p.pid]);
else if (parent?.role === 'autopilot' && runsUnder(parent, ctx.autopilotService)) addService('autopilot', parent.pid);
- else kill(p, `${label(p)} is not run by a jobs supervisor this restart can relaunch${parent?.role === 'autopilot' ? ' (its autopilot runs under no installed service)' : ''}: stop it (\`kill ${p.pid}\`, SIGTERM drains its jobs) and start \`gbrain jobs work\` again the way it was launched, or run workers under \`gbrain jobs supervisor start --detach\`.`);
+ else kill(p, `${label(p)} is not run by a jobs supervisor this restart can relaunch${parent?.role === 'autopilot' ? ' (its autopilot runs under no installed service)' : ''}${p.unclassified_parent ? ` (its parent, pid ${p.unclassified_parent.pid} (\`${p.unclassified_parent.command}\`), is not a process this restart recognises as gbrain)` : ''}: stop it (\`kill ${p.pid}\`, SIGTERM drains its jobs) and start \`gbrain jobs work\` again the way it was launched, or run workers under \`gbrain jobs supervisor start --detach\`.`);
break;
case 'mcp':
if (ctx.stopMcp && p.args) stops.push({ kind: 'stop', role: 'mcp', pid: p.pid, started_ms: p.started_ms });
diff --git a/test/eval-spend-guard.test.ts b/test/eval-spend-guard.test.ts
index a37d5d6324..1a6f969f6b 100644
--- a/test/eval-spend-guard.test.ts
+++ b/test/eval-spend-guard.test.ts
@@ -273,6 +273,17 @@ describe('eval-spend-guard.sh', () => {
expect(n.stderr).not.toContain('in-flight');
});
+ test('no command substitution is parsed between arming the signal traps and waiting on the command (#8717)', () => {
+ // A TERM that lands while bash 5.2 parses a top-level $(...) runs the trap inside that parse, where it fails and the
+ // signal is lost: the guard then waits out its command and exits 0 instead of 143.
+ const text = readFileSync(SCRIPT, 'utf-8');
+ const start = text.indexOf("\ntrap 'on_signal 2' INT\n");
+ const armed = text.slice(start, text.indexOf('\nwait "$CHILD"\n', start));
+ expect(armed.length).toBeGreaterThan(0);
+ const code = armed.split('\n').filter((line) => !line.trimStart().startsWith('#')).join('\n');
+ expect(code.match(/\$\((?!\()|`/g) ?? []).toEqual([]);
+ });
+
test('a SIGTERMed guard stops the command and reconciles at the estimate (exit 143)', async () => {
const g = start(['10', '4', '--', 'sleep', '30']);
// Deterministic: the `reserved $` line is printed AFTER the reservation
diff --git a/test/ownership-marker-exclude.test.ts b/test/ownership-marker-exclude.test.ts
index 3bee886d62..9cd547a583 100644
--- a/test/ownership-marker-exclude.test.ts
+++ b/test/ownership-marker-exclude.test.ts
@@ -13,7 +13,7 @@ import { existsSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync,
import { tmpdir } from 'node:os';
import { join, resolve } from 'node:path';
import {
- OWNERSHIP_MARKER_GLOBS, adoptTransferredRootStamp, physicalRootReservationPath, reservePhysicalRootRecord, writePhysicalRootStamp,
+ OWNERSHIP_MARKER_GLOBS, adoptTransferredRootStamp, assertPhysicalRoot, physicalRootReservationPath, reservePhysicalRootRecord, writePhysicalRootStamp,
} from '../src/core/persistence/physical-root-record.ts';
let dir: string;
@@ -107,3 +107,18 @@ test('a root outside any checkout stamps as before and writes no exclude file',
expect(existsSync(join(root, '.git'))).toBe(false);
expect(existsSync(join(dir, '.git'))).toBe(false);
});
+
+test('a repo-less root that becomes a Git checkout after its stamp gets the exclude at its next verification, so git add -A leaves the stamp out (#8713)', () => {
+ const root = join(dir, 'converted');
+ mkdirSync(root);
+ const reservation = reservePhysicalRootRecord(root, identity());
+ writePhysicalRootStamp(root, reservation);
+ git(root, 'init', '-q', '-b', 'main');
+ writeFileSync(join(root, 'page.md'), 'a page\n');
+ assertPhysicalRoot(root, { worktreeId: reservation.worktreeId, coordinationPath: reservation.coordinationPath });
+
+ const body = readFileSync(excludeFile(root), 'utf-8');
+ for (const glob of OWNERSHIP_MARKER_GLOBS) expect(countLines(body, glob)).toBe(1);
+ git(root, 'add', '-A');
+ expect(git(root, 'ls-files').split('\n')).toEqual(['page.md']);
+});
diff --git a/test/scripts/test-stress.test.ts b/test/scripts/test-stress.test.ts
index 126a7c6560..0094bea1ad 100644
--- a/test/scripts/test-stress.test.ts
+++ b/test/scripts/test-stress.test.ts
@@ -111,7 +111,27 @@ describe('test:stress runner', () => {
});
const r = stress(root, 'test/script-pooled.test.ts', '--iterations', '2');
expect(r.code, r.out).toBe(0);
- expect(r.manifest.files[0]).toMatchObject({ status: 'not-stressed', reason: expect.stringContaining('owning pooled job in scripts/run-e2e.sh') });
+ expect(r.manifest.files[0]).toMatchObject({ status: 'not-stressed', reason: expect.stringContaining('owning pooled runner scripts/run-e2e.sh') });
+ });
+
+ test('the pooled owner must name the file in the step or statement that requires the pooler, not anywhere in the same file (#8702)', () => {
+ const body = "import { test } from 'bun:test';\nconst pooled = process.env.GBRAIN_PGBOUNCER_URL;\ntest.skipIf(!pooled)('pooled', () => {});\n";
+ const root = tree({
+ 'test/other-step.test.ts': body,
+ 'test/far-script.test.ts': body,
+ '.github/workflows/e2e.yml': "jobs:\n matrix:\n steps:\n - name: pooled matrix\n env:\n GBRAIN_CI_REQUIRE_PGBOUNCER: '1'\n run: bash scripts/run-e2e.sh\n graduation:\n steps:\n - name: graduation\n run: bun test test/other-step.test.ts\n",
+ 'scripts/run-e2e.sh': 'if [ "${GBRAIN_CI_REQUIRE_PGBOUNCER:-0}" = "1" ]; then echo pooled; fi\n' + '#\n'.repeat(10) + 'for f in test/far-script.test.ts; do bun test "$f"; done\n',
+ });
+ const r = stress(root, 'test/other-step.test.ts', 'test/far-script.test.ts', '--iterations', '2');
+ const byFile = Object.fromEntries(r.manifest.files.map((f: { file: string }) => [f.file, f]));
+ expect(byFile['test/other-step.test.ts']).toMatchObject({ status: 'fail' });
+ expect(byFile['test/far-script.test.ts']).toMatchObject({ status: 'fail' });
+ expect(r.code, r.out).toBe(1);
+ });
+
+ test('test/e2e/graduation-cli-topologies.test.ts is not pooler-owned: the job that runs it does not require the pooler (#8702)', async () => {
+ const reason = await withEnv({ GBRAIN_PGBOUNCER_URL: undefined }, () => skipReason('test/e2e/graduation-cli-topologies.test.ts'));
+ expect(reason).toBeNull();
});
test('test/e2e/pgbouncer-teardown.test.ts is pooler-owned in this repository', async () => {
diff --git a/test/snapshot-inputs-closure.test.ts b/test/snapshot-inputs-closure.test.ts
index 7ba16fa505..91cf59bb63 100644
--- a/test/snapshot-inputs-closure.test.ts
+++ b/test/snapshot-inputs-closure.test.ts
@@ -186,4 +186,11 @@ describe('pglite-snapshot CI cache keys (DX O7)', () => {
expect(keys[0]!.patterns).toContain(extra);
}
});
+
+ test('the keys cover any src/core subdirectory, so a new folder in the closure needs no workflow edit (#8700)', () => {
+ const globs = keys[0]!.patterns.map((p) => new Bun.Glob(p));
+ for (const probe of ['src/core/feature-example/x.ts', 'src/core/feature-example/nested/y.ts', 'src/core/z.ts']) {
+ expect({ probe, covered: globs.some((g) => g.match(probe)) }).toEqual({ probe, covered: true });
+ }
+ });
});
diff --git a/test/upgrade-restart.test.ts b/test/upgrade-restart.test.ts
index b989c5cab4..ca89b7b24f 100644
--- a/test/upgrade-restart.test.ts
+++ b/test/upgrade-restart.test.ts
@@ -9,7 +9,7 @@ import { describe, expect, test } from 'bun:test';
import { EQUALS_READERS } from '../src/cli/flag-equals.ts';
import { parseGlobalFlags } from '../src/core/cli-options.ts';
import {
- bunGlobalCopyOf, classifyGbrainCommand, collectHostProcesses, mismatchedBuilds, planRestart, restartProblems, runRestartSteps, supervisorRestartArgv, unverifiedBuilds, verifyRestart,
+ bunGlobalCopyOf, classifyGbrainCommand, collectHostProcesses, gbrainEntry, mismatchedBuilds, planRestart, restartProblems, runRestartSteps, supervisorRestartArgv, unverifiedBuilds, verifyRestart,
type HostProcess, type ProcessSources, type RestartContext, type RestartExecutor, type WarmSocketState,
} from '../src/core/upgrade-restart.ts';
import { handleRestartOnly, mismatchFix, restartRefusal } from '../src/commands/upgrade-restart.ts';
@@ -57,6 +57,61 @@ describe('classifyGbrainCommand', () => {
});
});
+describe('gbrainEntry (#8723)', () => {
+ const CHECKOUT = '/srv/checkout-example';
+ const packageName = (root: string) => root === CHECKOUT ? 'gbrain' : root === '/srv/gbrain-notes' ? 'notes-example' : undefined;
+
+ test('bun run with a relative entry resolves against the process working directory and checks the package there', () => {
+ expect(gbrainEntry('bun run src/cli.ts jobs supervisor', { cwd: CHECKOUT, packageName })).toEqual({ entry: `${CHECKOUT}/src/cli.ts`, args: ['jobs', 'supervisor'] });
+ expect(classifyGbrainCommand('/usr/local/bin/bun run src/cli.ts jobs supervisor --queue ingest', { cwd: CHECKOUT, packageName })).toBe('supervisor');
+ expect(classifyGbrainCommand('bun --smol run ./src/cli.ts serve --http', { cwd: CHECKOUT, packageName })).toBe('serve');
+ expect(classifyGbrainCommand('bun run src/cli.ts jobs supervisor', { cwd: null, packageName })).toBeNull();
+ expect(classifyGbrainCommand('bun run src/cli.ts jobs supervisor', { cwd: '/srv/other-tool', packageName: () => 'other-tool' })).toBeNull();
+ });
+
+ test('an absolute entry is gbrain by its package root, not by a path substring', () => {
+ expect(classifyGbrainCommand(`/usr/local/bin/bun ${CHECKOUT}/src/cli.ts jobs work --queue default`, { packageName })).toBe('worker');
+ expect(classifyGbrainCommand('bun /srv/gbrain-notes/src/cli.ts serve', { packageName })).toBeNull();
+ expect(classifyGbrainCommand('bun /srv/gbrain/src/cli.ts serve', { packageName })).toBe('mcp');
+ });
+
+ test('bunx and bun run <bin> are wrappers; the child they start is the gbrain process', () => {
+ expect(gbrainEntry('/usr/local/bin/bun x gbrain jobs supervisor --queue q')).toBeNull();
+ expect(gbrainEntry('bunx gbrain jobs supervisor')).toBeNull();
+ expect(gbrainEntry('/usr/local/bin/bun run gbrain jobs work')).toBeNull();
+ expect(classifyGbrainCommand('/usr/local/bin/bun /home/alice-example/proj/node_modules/.bin/gbrain jobs supervisor --queue q')).toBe('supervisor');
+ expect(classifyGbrainCommand('/home/alice-example/.bun/bin/gbrain jobs supervisor start --detach')).toBe('supervisor');
+ });
+
+ test('a supervisor started as bun run src/cli.ts restarts with its worker instead of refusing the upgrade', async () => {
+ const processes = await collectHostProcesses({
+ heartbeats: async () => [], workers: () => [{ pid: 21, version: OLD }], supervisor: () => ({ pid: 20, version: OLD }), home: HOME, exclude: [], packageName,
+ processTable: () => [
+ { pid: 20, ppid: 1, command: '/usr/local/bin/bun run src/cli.ts jobs supervisor --queue default', started_ms: 600, gbrain_home: HOME, cwd: CHECKOUT },
+ { pid: 21, ppid: 20, command: `/usr/local/bin/bun ${CHECKOUT}/src/cli.ts jobs work --concurrency 1 --queue default`, started_ms: 700, gbrain_home: HOME, cwd: CHECKOUT },
+ ],
+ install: (command, cwd) => gbrainEntry(command, { cwd, packageName })?.entry === `${CHECKOUT}/src/cli.ts` ? { root: CHECKOUT, version: OLD } : { root: null, version: null },
+ });
+ expect(processes.map(p => [p.pid, p.role, p.ppid, p.install_root])).toEqual([[20, 'supervisor', null, CHECKOUT], [21, 'worker', 20, CHECKOUT]]);
+ const plan = planRestart(processes, ctx({ ownInstallRoot: CHECKOUT }));
+ expect(plan.manual).toEqual([]);
+ expect(plan.steps).toEqual([{ kind: 'supervisor', pid: 20, workers: [21], ...supervisorRestartArgv(['jobs', 'supervisor', '--queue', 'default']) }]);
+ });
+
+ test('a worker whose parent cannot be classified is refused with that parent\'s pid and command line', async () => {
+ const processes = await collectHostProcesses({
+ heartbeats: async () => [], workers: () => [], supervisor: () => null, home: HOME, exclude: [], packageName,
+ processTable: () => [
+ { pid: 20, ppid: 1, command: 'bun run src/cli.ts jobs supervisor', started_ms: 600, gbrain_home: HOME, cwd: null },
+ { pid: 21, ppid: 20, command: `bun ${CHECKOUT}/src/cli.ts jobs work`, started_ms: 700, gbrain_home: HOME, cwd: null },
+ ],
+ });
+ expect(processes.map(p => [p.pid, p.role])).toEqual([[21, 'worker']]);
+ const [manual] = planRestart(processes, ctx()).manual;
+ expect(manual!.instruction).toContain('its parent, pid 20 (`bun run src/cli.ts jobs supervisor`), is not a process this restart recognises as gbrain');
+ });
+});
+
describe('supervisorRestartArgv', () => {
test('keeps the queue, concurrency and PID file the supervisor was launched with', () => {
expect(supervisorRestartArgv(['jobs', 'supervisor', 'start', '--queue', 'ingest', '--concurrency', '4', '--pid-file', '/tmp/sup-example.pid'])).toEqual({