Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

fix(#6712 PR 4b): name the source in file-drift --side/--state suggestions; admission test engine in beforeAll

garrytan7585cea7b263
diff --git a/src/core/repair/file-drift.ts b/src/core/repair/file-drift.ts
index 0307d034d4..365170a122 100644
--- a/src/core/repair/file-drift.ts
+++ b/src/core/repair/file-drift.ts
@@ -322,9 +322,9 @@ function validateOptions(scope: RepairScope, opts: RepairPlanOptions | undefined
if (modes !== 1) throw opError('invalid_params', 'Select pages one way: --slug, --request, --all-drifted or --held.', `Pick one selection: ${usage}`);
if ((opts.side || opts.state) && !opts.held) throw opError('invalid_params', '--side and --state only narrow --held.', `Drop them, or select the held pages with --held: ${usage}`);
if (opts.side && !(FILE_DRIFT_SIDES as readonly string[]).includes(opts.side)) throw opError('invalid_params', `Unknown file-drift side '${opts.side}'.`,
- `Pass --side ${FILE_DRIFT_SIDES.join(', --side ')}; gbrain sources status <source> --json lists each held file's side.`);
+ `Pass --side ${FILE_DRIFT_SIDES.join(', --side ')}; gbrain sources status ${scope.source_ids[0]} --json lists each held file's side.`);
if (opts.state && !(FILE_DRIFT_DELETED_STATES as readonly string[]).includes(opts.state)) throw opError('invalid_params', `Unknown deleted-side state '${opts.state}'.`,
- `Pass --state ${FILE_DRIFT_DELETED_STATES.join(', --state ')} with --side deleted; gbrain sources status <source> --json lists each held file's state.`);
+ `Pass --state ${FILE_DRIFT_DELETED_STATES.join(', --state ')} with --side deleted; gbrain sources status ${scope.source_ids[0]} --json lists each held file's state.`);
if (opts.state && opts.side !== 'deleted') throw opError('invalid_params', '--state only narrows --side deleted.', `Drop --state, or pass --side deleted with it: ${usage}`);
if (opts.side === 'deleted' && !opts.state) throw stateRequired(scope.source_ids[0]!, opts, FILE_DRIFT_DELETED_STATES);
if (opts.driftClass && !opts.allDrifted) throw opError('invalid_params', '--class only narrows --all-drifted.', `Drop --class, or use it with --all-drifted: ${usage}`);
diff --git a/test/sync-admission-6712.test.ts b/test/sync-admission-6712.test.ts
index 633b1a54cc..9873aa010f 100644
--- a/test/sync-admission-6712.test.ts
+++ b/test/sync-admission-6712.test.ts
@@ -32,12 +32,6 @@ let engine: BrainEngine;
let incarnation: string;
const SOURCE = 'default';
-async function connect(backend: 'pglite' | 'postgres'): Promise<void> {
- if (backend === 'postgres') { const pg = new PostgresEngine(); await pg.connect({ database_url: requirePostgresTestDatabase() } as never); engine = pg; }
- else { const lite = new PGLiteEngine(); await lite.connect({}); engine = lite; }
- await engine.initSchema();
- incarnation = (await engine.executeRaw<{ incarnation: string }>('SELECT incarnation::text AS incarnation FROM sources WHERE id=$1', [SOURCE]))[0]!.incarnation;
-}
async function reset(): Promise<void> {
await engine.unsetConfig(SYNC_ADMISSION_KEY);
await engine.executeRaw('DELETE FROM op_checkpoints WHERE op=ANY($1::text[])', [[SYNC_ADMISSION_SET_OP, 'managed-sync-pass']]);
@@ -90,7 +84,12 @@ async function setManaged(enabled: boolean) {
}
for (const backend of testBackends()) describe(backend, () => {
- beforeAll(() => connect(backend), 120_000);
+ beforeAll(async () => {
+ if (backend === 'postgres') { const pg = new PostgresEngine(); await pg.connect({ database_url: requirePostgresTestDatabase() } as never); engine = pg; }
+ else { const lite = new PGLiteEngine(); await lite.connect({}); engine = lite; }
+ await engine.initSchema();
+ incarnation = (await engine.executeRaw<{ incarnation: string }>('SELECT incarnation::text AS incarnation FROM sources WHERE id=$1', [SOURCE]))[0]!.incarnation;
+ }, 120_000);
afterAll(async () => { await engine.disconnect(); });
beforeEach(reset);