Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
test: shared-skills opt-out on both engines and the wedged 0.53.0 resume through the real orchestrator
garrytan2b2de510bf76
diff --git a/test/shared-skills-inventory-park.serial.test.ts b/test/shared-skills-inventory-park.serial.test.tsnew file mode 100644index 0000000000..026986f5a4--- /dev/null+++ b/test/shared-skills-inventory-park.serial.test.ts@@ -0,0 +1,117 @@+import { expect, test } from 'bun:test';+import { appendFileSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';+import { join } from 'node:path';+import { tmpdir } from 'node:os';+import { PGLiteEngine } from '../src/core/pglite-engine.ts';+import { withEnv } from './helpers/with-env.ts';+import { SHARED_CONTENT_MIGRATION_VERSION } from '../src/commands/migrations/shared-content.ts';++async function cli(home: string, args: string[], expectCode = 0) {+ const env: NodeJS.ProcessEnv = { ...process.env, GBRAIN_HOME: home, GBRAIN_SKIP_STARTUP_HOOKS: '1' };+ for (const key of ['DATABASE_URL', 'GBRAIN_DATABASE_URL', 'GBRAIN_SOURCE', 'GBRAIN_BRAIN_ID', 'GBRAIN_IN_AGENT_SETUP']) delete env[key];+ const child = Bun.spawn([process.execPath, join(import.meta.dir, '../src/cli.ts'), ...args], { cwd: home, env, stdout: 'pipe', stderr: 'pipe' });+ const [stdout, stderr, code] = await Promise.all([new Response(child.stdout).text(), new Response(child.stderr).text(), child.exited]);+ expect({ args, code, failure: code !== expectCode ? stdout + stderr : '' }).toEqual({ args, code: expectCode, failure: '' });+ return { stdout, stderr };+}++const ledger = (home: string) => readFileSync(join(home, '.gbrain', 'migrations', 'completed.jsonl'), 'utf8').trim().split('\n')+ .map(line => JSON.parse(line) as { version: string; status: string }).filter(entry => entry.version === SHARED_CONTENT_MIGRATION_VERSION);++test('a wedged 0.53.0 migration resumes through --force-retry, parks the oversized source once and completes', async () => {+ const home = mkdtempSync(join(tmpdir(), 'gbrain-shared-park-')), root = join(home, 'pack');+ await withEnv({ GBRAIN_HOME: home, DATABASE_URL: undefined, GBRAIN_DATABASE_URL: undefined }, async () => {+ const engine = new PGLiteEngine();+ const database = { engine: 'pglite' as const, database_path: join(home, '.gbrain', 'brain.pglite') };+ try {+ await cli(home, ['init', '--pglite', '--no-embedding', '--non-interactive', '--db-only']);+ mkdirSync(join(root, 'skills', 'big'), { recursive: true });+ writeFileSync(join(root, 'skillpack.json'), JSON.stringify({ skills: ['skills/big'] }));+ writeFileSync(join(root, 'skills', 'big', 'SKILL.md'), `# Big\n${'x'.repeat(300_000)}\n`);+ await engine.connect(database);+ await engine.executeRaw("UPDATE sources SET local_path=$1 WHERE id='default'", [root]);+ await engine.disconnect();+ mkdirSync(join(home, '.gbrain', 'migrations'), { recursive: true });+ for (let attempt = 0; attempt < 3; attempt++) appendFileSync(join(home, '.gbrain', 'migrations', 'completed.jsonl'), `${JSON.stringify({ version: SHARED_CONTENT_MIGRATION_VERSION, status: 'partial' })}\n`);+ const listed = JSON.parse((await cli(home, ['apply-migrations', '--list', '--json'])).stdout);+ expect(listed.plan.wedged).toContain(SHARED_CONTENT_MIGRATION_VERSION);++ await cli(home, ['apply-migrations', '--force-retry', SHARED_CONTENT_MIGRATION_VERSION]);+ const applied = await cli(home, ['apply-migrations', '--migration', SHARED_CONTENT_MIGRATION_VERSION, '--yes']);+ expect(ledger(home).at(-1)!.status).toBe('complete');+ expect(applied.stderr).toContain('payload_too_large');+ expect(applied.stderr).toContain('gbrain sources shared-skills default off');++ const status = JSON.parse((await cli(home, ['sources', 'shared-skills', 'default', 'status', '--json'])).stdout);+ expect(status).toMatchObject({ schema_version: 1, action: 'status', source_id: 'default', configured: null, mode: 'content',+ parked: { limit: 'shared_skills.inventory.max_file_bytes' } });+ const parkedAt = status.parked.parked_at;+ const doctor = JSON.parse((await cli(home, ['doctor', '--only', 'shared_skills_sources', '--json'])).stdout);+ expect(doctor.checks.find((check: { name: string }) => check.name === 'shared_skills_sources')).toMatchObject({ status: 'warn', details: { parked: [{ source_id: 'default' }] } });++ await cli(home, ['apply-migrations', '--migration', SHARED_CONTENT_MIGRATION_VERSION, '--yes']);+ expect(JSON.parse((await cli(home, ['sources', 'shared-skills', 'default', 'status', '--json'])).stdout).parked.parked_at).toBe(parkedAt);+ expect(ledger(home).map(entry => entry.status)).toEqual(['partial', 'partial', 'partial', 'retry', 'complete']);++ await cli(home, ['config', 'set', 'shared_skills.inventory.max_file_bytes', String(64 * 1024 * 1024)], 2);+ await cli(home, ['config', 'set', 'shared_skills.inventory.max_file_bytes', '524288']);+ await cli(home, ['apply-migrations', '--migration', SHARED_CONTENT_MIGRATION_VERSION, '--yes']);+ const resumed = JSON.parse((await cli(home, ['sources', 'status', 'default', '--json'])).stdout);+ expect(resumed.sources[0].shared_skills).toMatchObject({ source_id: 'default', configured: null, mode: 'content', parked: null });+ await engine.connect(database);+ const [source] = await engine.executeRaw<{ incarnation: string }>("SELECT incarnation FROM sources WHERE id='default'");+ const record = JSON.parse((await engine.getConfig(`shared_skills.migration.v1.default.${source!.incarnation}`))!);+ expect(record.stages.find((stage: { stage: string }) => stage.stage === 'inventory').status).toBe('complete');+ await engine.disconnect();+ } finally { await engine.disconnect(); rmSync(home, { recursive: true, force: true }); }+ });+}, 240_000);++test('sources shared-skills off/on through the CLI: help, opError refusals and the opt-out resume path', async () => {+ const home = mkdtempSync(join(tmpdir(), 'gbrain-shared-optout-cli-')), root = join(home, 'pack');+ await withEnv({ GBRAIN_HOME: home, DATABASE_URL: undefined, GBRAIN_DATABASE_URL: undefined }, async () => {+ const engine = new PGLiteEngine();+ const database = { engine: 'pglite' as const, database_path: join(home, '.gbrain', 'brain.pglite') };+ try {+ await cli(home, ['init', '--pglite', '--no-embedding', '--non-interactive', '--db-only']);+ mkdirSync(join(root, 'skills', 'big'), { recursive: true });+ writeFileSync(join(root, 'skillpack.json'), JSON.stringify({ skills: ['skills/big'] }));+ writeFileSync(join(root, 'skills', 'big', 'SKILL.md'), `# Big\n${'x'.repeat(300_000)}\n`);+ await engine.connect(database);+ await engine.executeRaw("UPDATE sources SET local_path=$1 WHERE id='default'", [root]);+ await engine.disconnect();++ expect((await cli(home, ['sources', 'shared-skills', '--help'])).stdout).toContain('Usage: gbrain sources shared-skills <id> on|off|status [--json]');+ const invalid = JSON.parse((await cli(home, ['sources', 'shared-skills', 'default', 'maybe', '--json'], 2)).stdout);+ expect({ code: invalid.code, argv: invalid.fix.argv.slice(0, 6) }).toEqual({ code: 'invalid_params', argv: ['gbrain', 'sources', 'shared-skills', 'default', 'status', '--json'] });+ const missing = JSON.parse((await cli(home, ['sources', 'shared-skills', 'absent-source', 'off', '--json'], 1)).stdout);+ expect(missing.code).toBe('not_found');++ await cli(home, ['apply-migrations', '--migration', SHARED_CONTENT_MIGRATION_VERSION, '--yes']);+ expect(ledger(home).at(-1)!.status).toBe('complete');+ const off = await cli(home, ['sources', 'shared-skills', 'default', 'off']);+ expect(off.stdout).toContain('config.shared_skills = false; effective policy preserve_files (source_shared_skills_disabled)');+ await cli(home, ['apply-migrations', '--migration', SHARED_CONTENT_MIGRATION_VERSION, '--yes']);+ const human = (await cli(home, ['sources', 'status', 'default'])).stdout;+ expect(human).toContain('default: config.shared_skills = false');+ const doctor = JSON.parse((await cli(home, ['doctor', '--only', 'shared_skills_sources', '--json'], 0)).stdout);+ expect(doctor.checks.find((check: { name: string }) => check.name === 'shared_skills_sources')).toMatchObject({ status: 'ok', details: { opted_out: ['default'], parked: [] } });+ const on = JSON.parse((await cli(home, ['sources', 'shared-skills', 'default', 'on', '--json'])).stdout);+ expect(on).toMatchObject({ action: 'on', changed: true, configured: null, mode: 'content' });+ } finally { await engine.disconnect(); rmSync(home, { recursive: true, force: true }); }+ });+}, 240_000);++test('a thin client is refused with trusted_local_only, the host command and a read-only verify', async () => {+ const home = mkdtempSync(join(tmpdir(), 'gbrain-shared-thin-'));+ try {+ mkdirSync(join(home, '.gbrain'), { recursive: true });+ writeFileSync(join(home, '.gbrain', 'config.json'), JSON.stringify({ engine: 'postgres',+ remote_mcp: { issuer_url: 'https://brain-host.example', mcp_url: 'https://brain-host.example/mcp', oauth_client_id: 'cid', oauth_client_secret: 'csecret' } }));+ const refusal = JSON.parse((await cli(home, ['sources', 'shared-skills', 'default', 'off', '--json'], 1)).stdout);+ expect(refusal).toMatchObject({ code: 'trusted_local_only', fix: { actor: 'host_admin', next: 'tell_user_to_run' } });+ expect(refusal.fix.argv.slice(0, 5)).toEqual(['gbrain', 'sources', 'shared-skills', 'default', 'off']);+ expect(refusal.fix.verify.argv.slice(0, 6)).toEqual(['gbrain', 'sources', 'shared-skills', 'default', 'status', '--json']);+ expect((await cli(home, ['sources', 'shared-skills', '--help'])).stdout).toContain('Runs only on the brain host.');+ } finally { rmSync(home, { recursive: true, force: true }); }+}, 60_000);diff --git a/test/shared-skills-source-opt-out.test.ts b/test/shared-skills-source-opt-out.test.tsnew file mode 100644index 0000000000..5d2af78e32--- /dev/null+++ b/test/shared-skills-source-opt-out.test.ts@@ -0,0 +1,190 @@+import { afterAll, beforeAll, expect, test } from 'bun:test';+import { mkdirSync, mkdtempSync, rmSync, symlinkSync, unlinkSync, writeFileSync } from 'node:fs';+import { join } from 'node:path';+import { tmpdir } from 'node:os';+import { PGLiteEngine } from '../src/core/pglite-engine.ts';+import type { BrainEngine } from '../src/core/engine.ts';+import type { OperationContext } from '../src/core/ops/contract.ts';+import { isolatedPersistencePostgres } from './helpers/persistence-postgres.ts';+import { withEnv } from './helpers/with-env.ts';+import { runSharedSkillsMigration } from '../src/core/shared-skills/migration.ts';+import { readSharedSkillsSourceView, setSourceSharedSkills } from '../src/core/shared-skills/source-opt-out.ts';+import { DEFAULT_INVENTORY_LIMITS, INVENTORY_LIMIT_CEILINGS, parseInventoryLimitValue, readInventoryLimits } from '../src/core/shared-skills/inventory-limits.ts';+import { inventorySkillpack } from '../src/core/shared-skills/setup-files.ts';+import { checkSharedSkillsSources } from '../src/commands/doctor/checks/shared-skills.ts';+import { runSourcesSharedSkills } from '../src/commands/sources-shared-skills.ts';++const home = mkdtempSync(join(tmpdir(), 'gbrain-shared-optout-'));+const engines: Array<{ name: string; engine: BrainEngine }> = [];+let closePg: (() => Promise<void>) | undefined;++beforeAll(async () => {+ const pglite = new PGLiteEngine();+ await pglite.connect({});+ await pglite.initSchema();+ engines.push({ name: 'pglite', engine: pglite });+ if (process.env.DATABASE_URL) {+ const pg = await isolatedPersistencePostgres(process.env.DATABASE_URL);+ engines.push({ name: 'postgres', engine: pg.engine });+ closePg = pg.close;+ }+}, 120_000);++afterAll(async () => {+ for (const { name, engine } of engines) if (name === 'pglite') await engine.disconnect();+ await closePg?.();+ rmSync(home, { recursive: true, force: true });+});++const ctxFor = (engine: BrainEngine): OperationContext => ({ engine, config: { engine: 'pglite' }, sourceId: 'default', remote: false, dryRun: false,+ logger: { info() {}, warn() {}, error() {} } });+const resetDefault = (engine: BrainEngine) => engine.executeRaw("UPDATE sources SET config='{}'::jsonb, local_path=NULL WHERE id='default'");+const sourceRow = async (engine: BrainEngine, id = 'default') => (await runSharedSkillsMigration(ctxFor(engine))).sources.find(row => row.source_id === id)!;++function oversizedPack(name: string): string {+ const root = join(home, name);+ mkdirSync(join(root, 'skills', 'big'), { recursive: true });+ writeFileSync(join(root, 'skillpack.json'), JSON.stringify({ skills: ['skills/big'] }));+ writeFileSync(join(root, 'skills', 'big', 'SKILL.md'), `# Big\n${'x'.repeat(300_000)}\n`);+ return root;+}++test('on/off/status write and clear config.shared_skills and the migration policy follows, on both engines', async () => withEnv({ GBRAIN_HOME: home }, async () => {+ for (const { name, engine } of engines) {+ await resetDefault(engine);+ const initial = await readSharedSkillsSourceView(engine, 'default');+ expect({ name, configured: initial.configured, mode: initial.mode, parked: initial.parked }).toEqual({ name, configured: null, mode: 'content', parked: null });++ const off = await setSourceSharedSkills({ engine, remote: false }, 'default', false);+ expect({ name, changed: off.changed, configured: off.configured, mode: off.mode, code: off.reason_code })+ .toEqual({ name, changed: true, configured: false, mode: 'preserve_files', code: 'source_shared_skills_disabled' });+ expect(off.reason).toContain('gbrain sources shared-skills default on');+ expect(off.reason).toContain('docs/guides/shared-brain-skills.md#choose-which-sources-adopt-shared-skills');+ const [stored] = await engine.executeRaw<{ kind: string; value: string }>("SELECT jsonb_typeof(config->'shared_skills') AS kind, config->>'shared_skills' AS value FROM sources WHERE id='default'");+ expect({ name, ...stored }).toEqual({ name, kind: 'boolean', value: 'false' });+ expect((await sourceRow(engine)).stages[0]!.reason).toContain('source_shared_skills_disabled');+ expect((await setSourceSharedSkills({ engine, remote: false }, 'default', false)).changed).toBe(false);++ const on = await setSourceSharedSkills({ engine, remote: false }, 'default', true);+ expect({ name, changed: on.changed, configured: on.configured, mode: on.mode }).toEqual({ name, changed: true, configured: null, mode: 'content' });+ const [cleared] = await engine.executeRaw<{ present: boolean }>("SELECT config ? 'shared_skills' AS present FROM sources WHERE id='default'");+ expect(cleared!.present).toBe(false);+ expect((await sourceRow(engine)).stages[0]!.reason ?? '').not.toContain('source_shared_skills_disabled');+ expect((await setSourceSharedSkills({ engine, remote: false }, 'default', true)).changed).toBe(false);+ }+}), 120_000);++test('a remote caller is refused with a host_admin fix and a read-only verify; a missing source is not_found', async () => {+ const { engine } = engines[0]!;+ const refusal = await setSourceSharedSkills({ engine, remote: true }, 'default', false).catch(error => error);+ expect(refusal.code).toBe('trusted_local_only');+ expect(refusal.fix).toMatchObject({ argv: ['gbrain', 'sources', 'shared-skills', 'default', 'off'], actor: 'host_admin',+ verify: { argv: ['gbrain', 'sources', 'shared-skills', 'default', 'status', '--json'] } });+ expect(await engine.executeRaw("SELECT 1 FROM sources WHERE id='default' AND config ? 'shared_skills'")).toEqual([]);+ await expect(readSharedSkillsSourceView(engine, 'absent-source')).rejects.toMatchObject({ code: 'not_found' });+ await expect(setSourceSharedSkills({ engine, remote: false }, 'absent-source', false)).rejects.toMatchObject({ code: 'not_found' });+});++test('a connector or external source with shared skills on explains why it keeps its effective mode', async () => withEnv({ GBRAIN_HOME: home }, async () => {+ for (const { name, engine } of engines) {+ for (const [config, mode] of [[{ kind: 'google', shared_skills: false }, 'preserve_files'], [{ remote_url: 'https://example.com/acme-example.git', managed_clone: true }, 'explicit_pack_required']] as const) {+ await engine.executeRaw("UPDATE sources SET config=$1::text::jsonb WHERE id='default'", [JSON.stringify(config)]);+ const view = await setSourceSharedSkills({ engine, remote: false }, 'default', true);+ expect({ name, mode: view.mode, code: view.reason_code, configured: view.configured }).toEqual({ name, mode, code: 'source_skill_adoption_required', configured: null });+ expect(view.explanation).toContain('turning shared skills on cannot change that');+ expect(view.reason).toContain('gbrain sources shared-skills default status');+ const [kept] = await engine.executeRaw<{ kind: string | null; remote: string | null }>("SELECT config->>'kind' AS kind, config->>'remote_url' AS remote FROM sources WHERE id='default'");+ expect({ name, ...kept }).toEqual({ name, kind: 'kind' in config ? config.kind : null, remote: 'remote_url' in config ? config.remote_url : null });+ }+ await resetDefault(engine);+ }+}), 120_000);++test('an oversized pack parks once, is not retried, and resumes after the bound is raised or the source opts out', async () => withEnv({ GBRAIN_HOME: home }, async () => {+ for (const { name, engine } of engines) {+ await resetDefault(engine);+ const root = oversizedPack(`pack-${name}`);+ await engine.executeRaw("UPDATE sources SET local_path=$1 WHERE id='default'", [root]);+ expect(await checkSharedSkillsSources(engine)).toBeNull();++ const report = await runSharedSkillsMigration(ctxFor(engine));+ expect(report.status).not.toBe('conflict');+ const parked = report.sources.find(row => row.source_id === 'default')!;+ expect({ name, status: parked.status, limit: parked.parked?.limit }).toEqual({ name, status: 'action_required', limit: 'shared_skills.inventory.max_file_bytes' });+ expect(parked.stages[0]!.reason).toContain('gbrain apply-migrations --migration 0.53.0 --yes');+ expect(parked.stages[0]!.reason).toContain('gbrain sources shared-skills default off');+ const view = await readSharedSkillsSourceView(engine, 'default');+ expect(view.parked?.parked_at).toBe(parked.parked!.parked_at);+ const doctor = await checkSharedSkillsSources(engine);+ expect({ name, status: doctor?.status, parked: (doctor?.details as { parked: Array<{ source_id: string }> }).parked.map(row => row.source_id) })+ .toEqual({ name, status: 'warn', parked: ['default'] });++ // Not retried: a pack that would now fail confinement stays parked instead of turning into a conflict.+ const skill = join(root, 'skills', 'big', 'SKILL.md');+ unlinkSync(skill);+ symlinkSync(join(root, 'skillpack.json'), skill);+ const again = await sourceRow(engine);+ expect({ name, status: again.status, parked_at: again.parked?.parked_at }).toEqual({ name, status: 'action_required', parked_at: parked.parked!.parked_at });+ unlinkSync(skill);+ writeFileSync(skill, `# Big\n${'x'.repeat(300_000)}\n`);++ await engine.setConfig('shared_skills.inventory.max_file_bytes', '524288');+ const resumed = await sourceRow(engine);+ expect({ name, parked: resumed.parked, inventory: resumed.stages.find(stage => stage.stage === 'inventory')?.status })+ .toEqual({ name, parked: undefined, inventory: 'complete' });+ expect(resumed.inventory?.hashes['skills/big/SKILL.md']).toMatch(/^[a-f0-9]{64}$/);++ await engine.executeRaw("DELETE FROM config WHERE key='shared_skills.inventory.max_file_bytes'");+ expect((await sourceRow(engine)).parked?.limit).toBe('shared_skills.inventory.max_file_bytes');+ await setSourceSharedSkills({ engine, remote: false }, 'default', false);+ expect((await readSharedSkillsSourceView(engine, 'default')).parked).toBeNull();+ const optedOut = await sourceRow(engine);+ expect({ name, parked: optedOut.parked, status: optedOut.status }).toEqual({ name, parked: undefined, status: 'action_required' });+ expect(optedOut.stages[0]!.reason).toContain('source_shared_skills_disabled');+ expect((await checkSharedSkillsSources(engine))).toMatchObject({ status: 'ok', details: { opted_out: ['default'], parked: [] } });++ expect((await setSourceSharedSkills({ engine, remote: false }, 'default', true)).released_parked).toBe(false);+ const reparked = await sourceRow(engine);+ expect(reparked.parked?.limit).toBe('shared_skills.inventory.max_file_bytes');+ const released = await setSourceSharedSkills({ engine, remote: false }, 'default', true);+ expect({ name, released: released.released_parked, parked: released.parked }).toEqual({ name, released: true, parked: null });+ await resetDefault(engine);+ await engine.executeRaw("DELETE FROM config WHERE key LIKE 'shared_skills.migration.v1%'");+ rmSync(root, { recursive: true, force: true });+ }+}), 180_000);++test('inventory bounds are config-backed with today\'s defaults, capped, and confinement stays immutable', async () => {+ const { engine } = engines[0]!;+ expect(await readInventoryLimits(engine)).toEqual({ ...DEFAULT_INVENTORY_LIMITS });+ expect(DEFAULT_INVENTORY_LIMITS).toEqual({ max_files: 256, max_total_bytes: 4 * 1024 * 1024, max_file_bytes: 262_144, max_entries: 1024 });+ for (const value of ['0', '-1', '1.5', 'many', String(INVENTORY_LIMIT_CEILINGS.max_file_bytes + 1)]) {+ expect(() => parseInventoryLimitValue('shared_skills.inventory.max_file_bytes', value)).toThrow(expect.objectContaining({ code: 'invalid_params' }));+ }+ expect(parseInventoryLimitValue('shared_skills.inventory.max_files', '4096')).toBe(4096);+ await engine.setConfig('shared_skills.inventory.max_files', '2');+ expect((await readInventoryLimits(engine)).max_files).toBe(2);+ await engine.executeRaw("DELETE FROM config WHERE key='shared_skills.inventory.max_files'");++ const root = join(home, 'limits');+ mkdirSync(join(root, 'skills', 'small'), { recursive: true });+ writeFileSync(join(root, 'skillpack.json'), JSON.stringify({ skills: ['skills/small'] }));+ writeFileSync(join(root, 'skills', 'small', 'SKILL.md'), '# Small\n');+ writeFileSync(join(root, 'skills', 'small', 'notes.md'), 'notes\n');+ expect(() => inventorySkillpack(root, { ...DEFAULT_INVENTORY_LIMITS, max_files: 2 })).toThrow(expect.objectContaining({ code: 'payload_too_large', detail: 'shared_skills.inventory.max_files' }));+ expect(() => inventorySkillpack(root, { ...DEFAULT_INVENTORY_LIMITS, max_total_bytes: 20 })).toThrow(expect.objectContaining({ code: 'payload_too_large', detail: 'shared_skills.inventory.max_total_bytes' }));+ expect(() => inventorySkillpack(root, { ...DEFAULT_INVENTORY_LIMITS, max_entries: 1 })).toThrow(expect.objectContaining({ code: 'payload_too_large', detail: 'shared_skills.inventory.max_entries' }));+ expect(Object.keys(inventorySkillpack(root)!.hashes).sort()).toEqual(['skillpack.json', 'skills/small/SKILL.md', 'skills/small/notes.md']);+ symlinkSync(join(root, 'skills', 'small', 'SKILL.md'), join(root, 'skills', 'small', 'link.md'));+ expect(() => inventorySkillpack(root, INVENTORY_LIMIT_CEILINGS)).toThrow(expect.objectContaining({ code: 'local_conflict' }));+ rmSync(root, { recursive: true, force: true });+});++test('sources shared-skills refuses invalid input with opError codes', async () => {+ const { engine } = engines[0]!;+ await expect(runSourcesSharedSkills(engine, ['default', 'maybe'])).rejects.toMatchObject({ code: 'invalid_params', fix: { argv: ['gbrain', 'sources', 'shared-skills', 'default', 'status', '--json'] } });+ await expect(runSourcesSharedSkills(engine, [])).rejects.toMatchObject({ code: 'invalid_params' });+ await expect(runSourcesSharedSkills(engine, ['default', 'off', 'extra'])).rejects.toMatchObject({ code: 'invalid_params' });+ await expect(runSourcesSharedSkills(engine, ['default', 'off', '--force'])).rejects.toMatchObject({ code: 'unknown_flag' });+ expect(await engine.executeRaw("SELECT 1 FROM sources WHERE id='default' AND config ? 'shared_skills'")).toEqual([]);+});