Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

test isolation and a strict missing-table predicate for dangling_aliases (#7145)

garrytande3fa7cf61be
diff --git a/src/core/onboard/checks.ts b/src/core/onboard/checks.ts
index b0508e4ccc..e4ddf8db6d 100644
--- a/src/core/onboard/checks.ts
+++ b/src/core/onboard/checks.ts
@@ -30,7 +30,7 @@ import { loadConfig } from '../config.ts';
import { MIN_ENTITY_PAGES_FOR_COVERAGE } from '../types.ts';
import { ORPHANED_ALIAS_COUNTS_SQL, SOFT_DELETED_ALIAS_COUNT_SQL } from '../repair/aliases.ts';
import { repairPreviewCommand } from '../repair/registry.ts';
-import { isUndefinedTableError } from '../utils.ts';
+import { isMissingSchemaObject } from '../utils.ts';
/** Shared shape returned by all four checks. */
export interface OnboardCheckResult {
@@ -757,7 +757,7 @@ export async function checkDanglingAliases(
if (row) soft = row;
} catch (error) {
// #7145: only a pre-v105 brain (no alias tables) has nothing to report; any other failure is unknown, not clear.
- if (!isUndefinedTableError(error)) {
+ if (!isMissingSchemaObject(error, 'table', ['slug_aliases', 'page_aliases'])) {
return { check: { name: 'dangling_aliases', status: 'warn', details: { health: 'unknown' },
message: `Dangling aliases unknown: the alias read failed (${redactConnectionInfo(error instanceof Error ? error.message : String(error))}); rerun doctor.` }, remediations: [] };
}
diff --git a/test/doctor-bound-unknown-7145.test.ts b/test/doctor-bound-unknown-7145.test.ts
index 6c3141f289..de08c44f80 100644
--- a/test/doctor-bound-unknown-7145.test.ts
+++ b/test/doctor-bound-unknown-7145.test.ts
@@ -143,18 +143,14 @@ describe('connectors drift is read from the newest connector receipt, not a 20-r
});
describe('link_resolution_opportunity names its sample on every verdict', () => {
+ let engine: PGLiteEngine;
+ beforeAll(async () => { engine = new PGLiteEngine(); await engine.connect({}); await engine.initSchema(); }, 60_000);
+ afterAll(async () => { await engine.disconnect(); });
test('a brain larger than the sample: the clean verdict says it read a sample and carries exact: false', async () => {
- const engine = new PGLiteEngine();
- await engine.connect({});
- await engine.initSchema();
- try {
- await engine.executeRaw("INSERT INTO pages(source_id, slug, type, title, compiled_truth, timeline, frontmatter) SELECT 'default', 'notes/n-' || g, 'note', 'n', 'plain text', '', '{}'::jsonb FROM generate_series(1, 1001) g");
- const check = await checkLinkResolutionOpportunity(engine);
- expect(check.status).toBe('ok');
- expect(check.message).toBe('No bare wikilinks found (scanned the 1000 most-recent of 1001 pages)');
- expect(check.details).toMatchObject({ exact: false, bound: 'sample', limit: 1000, total_pages: 1001 });
- } finally {
- await engine.disconnect();
- }
+ await engine.executeRaw("INSERT INTO pages(source_id, slug, type, title, compiled_truth, timeline, frontmatter) SELECT 'default', 'notes/n-' || g, 'note', 'n', 'plain text', '', '{}'::jsonb FROM generate_series(1, 1001) g");
+ const check = await checkLinkResolutionOpportunity(engine);
+ expect(check.status).toBe('ok');
+ expect(check.message).toBe('No bare wikilinks found (scanned the 1000 most-recent of 1001 pages)');
+ expect(check.details).toMatchObject({ exact: false, bound: 'sample', limit: 1000, total_pages: 1001 });
}, 120_000);
});
diff --git a/test/doctor-git-convergence-5063.test.ts b/test/doctor-git-convergence-5063.test.ts
index 67ecf55a8c..7ee9d9e231 100644
--- a/test/doctor-git-convergence-5063.test.ts
+++ b/test/doctor-git-convergence-5063.test.ts
@@ -12,6 +12,7 @@ import { PGLiteEngine } from '../src/core/pglite-engine.ts';
import { gitConvergenceCheck, trackedOwnershipMarkerCheck } from '../src/commands/doctor/checks/git-convergence.ts';
import { DOCTOR_CHECK_REGISTRY } from '../src/commands/doctor/registry.ts';
import { categorizeCheck } from '../src/core/doctor-categories.ts';
+import { withEnv } from './helpers/with-env.ts';
let engine: PGLiteEngine;
const dir = mkdtempSync(join(tmpdir(), 'gbrain-git-convergence-'));
@@ -38,12 +39,18 @@ function commitAt(work: string, file: string, ageMs: number) {
git(work, ['commit', '-q', '-m', file], { GIT_AUTHOR_DATE: date, GIT_COMMITTER_DATE: date });
}
+/** #7145: a brain with only the slow checkout, so no other root waits on the slow git. */
+let solo: PGLiteEngine;
beforeAll(async () => {
engine = new PGLiteEngine();
await engine.connect({});
await engine.initSchema();
+ solo = new PGLiteEngine();
+ await solo.connect({});
+ await solo.initSchema();
});
afterAll(async () => {
+ await solo.disconnect();
await engine.disconnect();
rmSync(dir, { recursive: true, force: true });
});
@@ -89,19 +96,12 @@ test('#7145: a git call past its timeout is health unknown, not a converged chec
const realGit = execFileSync('sh', ['-c', 'command -v git']).toString().trim();
const bin = join(dir, 'slow-bin'); mkdirSync(bin);
writeFileSync(join(bin, 'git'), `#!/bin/sh\ncase " $* " in *" status "*|*" ls-files "*) sleep 8 ;; esac\nexec ${realGit} "$@"\n`); chmodSync(join(bin, 'git'), 0o755);
- const solo = new PGLiteEngine();
- await solo.connect({}); await solo.initSchema();
- const path = process.env.PATH;
- try {
- await solo.executeRaw("INSERT INTO sources(id,name,local_path) VALUES('slow','slow',$1)", [slow]);
- process.env.PATH = `${bin}:${path}`;
+ await solo.executeRaw("INSERT INTO sources(id,name,local_path) VALUES('slow','slow',$1)", [slow]);
+ await withEnv({ PATH: `${bin}:${process.env.PATH}` }, async () => {
const check = await gitConvergenceCheck(solo);
expect(check).toMatchObject({ name: 'git_convergence', status: 'warn', details: { health: 'unknown', reason: 'bound', bound: 'time', exact: false, limit: 5000 } });
expect(check!.message).toContain('Git convergence unknown');
const marker = await trackedOwnershipMarkerCheck(solo);
expect(marker).toMatchObject({ name: 'tracked_ownership_marker', status: 'warn', details: { health: 'unknown', bound: 'time' } });
- } finally {
- process.env.PATH = path;
- await solo.disconnect();
- }
+ });
}, 60_000);