Files
gbrain/test/doctor-drift-advice.test.ts
78bc2fef09 fix(cli,config,doctor): CLI/config UX wave — config-get file plane, idempotent archive, honest help + doctor text (#2120 #2792 #1175 #1123 #2451) (#2918)
* fix(cli,config,doctor): CLI/config UX wave — config-get file plane, idempotent archive, honest help + doctor text, prefixed model defaults (#2120 #2792 #1175 #1123 #2451)

- config get resolves the file/env plane before the DB plane (runtime
  precedence) and reports provenance on stderr; stdout stays a bare value.
- sources archive distinguishes already-archived (friendly no-op, exit 0)
  from not-found (clear exit-4 error).
- gbrain --help SOURCES block now lists archive/restore/archived/purge/status
  plus a pointer at `sources --help` for the long tail.
- multi_source_drift doctor advice references only real CLI surfaces
  (drops the never-built 'sources rehome'; pins delete to GBRAIN_SOURCE=default).
- #2451 (bare model ids in calibration defaults) verified already fixed +
  tested on master by #2892 — no change needed.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* test: satisfy test-isolation gate for wave-B tests

check-test-isolation R1 forbids direct process.env mutation in non-serial
unit tests (env leaks across files sharing a shard process). Route the
GBRAIN_HOME / GBRAIN_CHAT_MODEL / GBRAIN_PGLITE_SNAPSHOT overrides through
the canonical withEnv() helper instead.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Sinabina <sinabina@Sinabinas-MacBook-Pro-4.local>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-07-17 11:27:34 -07:00

34 lines
1.3 KiB
TypeScript

/**
* #1123 — the multi_source_drift doctor recommendation must only reference
* CLI surfaces that actually exist. Pre-fix it pointed at
* 'gbrain sources rehome' (never built) and at 'gbrain delete <slug>'
* without saying that delete targets the ACTIVE source — following it
* literally on a multi-source brain deletes the correctly-routed row.
*/
import { describe, test, expect } from 'bun:test';
import { multiSourceDriftAdvice } from '../src/commands/doctor.ts';
describe('#1123 — multiSourceDriftAdvice references only real surfaces', () => {
const advice = multiSourceDriftAdvice(45, 'foo (intended=wiki)');
test('carries the count and sample', () => {
expect(advice).toContain('45 page slug(s)');
expect(advice).toContain('foo (intended=wiki)');
});
test('points at the re-sync path that reconciles drift', () => {
expect(advice).toContain("gbrain sources status");
expect(advice).toContain("gbrain sync --source <id> --full");
});
test('does not reference the never-built rehome command', () => {
expect(advice).not.toContain('rehome');
});
test('delete advice pins the source explicitly instead of implying delete targets default', () => {
expect(advice).toContain('GBRAIN_SOURCE=default gbrain delete <slug>');
expect(advice).not.toContain('delete --source');
});
});