From 5b9a87f1a38d8f1fda3cf853aaaee78a265f8beb Mon Sep 17 00:00:00 2001 From: Time Attakc <89218912+time-attack@users.noreply.github.com> Date: Tue, 28 Jul 2026 14:34:28 -0700 Subject: [PATCH] =?UTF-8?q?fix(cli):=20make=20backfill=20command=20reachab?= =?UTF-8?q?le=20=E2=80=94=20add=20to=20CLI=5FONLY=20(#3224)=20(#3529)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 'backfill' had a fully implemented handler (case 'backfill' dispatching to commands/backfill.ts) but was missing from the CLI_ONLY set, so dispatch rejected every invocation with 'Unknown command: backfill'. Same drift class as #2900 (reconcile-links) and #2035 (calibration). Also lists backfill in the main --help TOOLS section. Co-authored-by: Garry Tan Co-authored-by: Claude Opus 5 --- src/cli.ts | 3 ++- test/reconcile-links-cli-reachability.test.ts | 20 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/cli.ts b/src/cli.ts index 779f0c2c8..55d54a3d9 100755 --- a/src/cli.ts +++ b/src/cli.ts @@ -55,7 +55,7 @@ export function bigintToStringReplacer(_key: string, value: unknown): unknown { } // CLI-only commands that bypass the operation layer -export const CLI_ONLY = new Set(['init', 'reinit-pglite', 'upgrade', 'post-upgrade', 'check-update', 'integrations', 'publish', 'check-backlinks', 'lint', 'report', 'import', 'export', 'files', 'embed', 'serve', 'call', 'config', 'doctor', 'migrate', 'eval', 'sync', 'extract', 'extract-conversation-facts', 'enrich', 'features', 'autopilot', 'graph-query', 'jobs', 'agent', 'apply-migrations', 'skillpack-check', 'skillpack', 'resolvers', 'integrity', 'repair-jsonb', 'orphans', 'maintain', 'sources', 'mounts', 'dream', 'check-resolvable', 'routing-eval', 'skillify', 'smoke-test', 'providers', 'storage', 'repos', 'code-def', 'code-refs', 'reindex', 'reindex-code', 'reindex-frontmatter', 'code-callers', 'code-callees', 'reconcile-links', 'frontmatter', 'auth', 'friction', 'claw-test', 'book-mirror', 'takes', 'think', 'salience', 'anomalies', 'calibration', 'transcripts', 'models', 'remote', 'recall', 'forget', 'edges-backfill', 'cache', 'ze-switch', 'retrieval-upgrade', 'founder', 'brainstorm', 'lsd', 'schema', 'capture', 'onboard', 'conversation-parser', 'status', 'connect', 'skillopt', 'quarantine', 'self-upgrade', 'advisor', 'watch', 'reindex-search-vector']); +export const CLI_ONLY = new Set(['init', 'reinit-pglite', 'upgrade', 'post-upgrade', 'check-update', 'integrations', 'publish', 'check-backlinks', 'lint', 'report', 'import', 'export', 'files', 'embed', 'serve', 'call', 'config', 'doctor', 'migrate', 'eval', 'sync', 'extract', 'extract-conversation-facts', 'enrich', 'features', 'autopilot', 'graph-query', 'jobs', 'agent', 'apply-migrations', 'skillpack-check', 'skillpack', 'resolvers', 'integrity', 'repair-jsonb', 'orphans', 'maintain', 'sources', 'mounts', 'dream', 'check-resolvable', 'routing-eval', 'skillify', 'smoke-test', 'providers', 'storage', 'repos', 'code-def', 'code-refs', 'reindex', 'reindex-code', 'reindex-frontmatter', 'code-callers', 'code-callees', 'reconcile-links', 'frontmatter', 'auth', 'friction', 'claw-test', 'book-mirror', 'takes', 'think', 'salience', 'anomalies', 'calibration', 'transcripts', 'models', 'remote', 'recall', 'forget', 'edges-backfill', 'cache', 'ze-switch', 'retrieval-upgrade', 'founder', 'brainstorm', 'lsd', 'schema', 'capture', 'onboard', 'conversation-parser', 'status', 'connect', 'skillopt', 'quarantine', 'self-upgrade', 'advisor', 'watch', 'reindex-search-vector', 'backfill']); // CLI-only commands whose handlers print their own --help text. These are // excluded from the generic short-circuit so detailed per-command and // per-subcommand usage stays reachable. @@ -2448,6 +2448,7 @@ TOOLS publish [--password] Shareable HTML (strips private data, optional AES-256) check-backlinks [dir] Find/fix missing back-links across brain lint [--fix] Catch LLM artifacts, placeholder dates, bad frontmatter + backfill v0.30.1: run a registered backfill (effective-date, ...) orphans [--json] [--count] Find pages with no inbound wikilinks salience [--days N] [--kind P] v0.29: pages ranked by emotional + activity salience anomalies [--since D] [--sigma N] v0.29: cohort-based statistical anomalies (tag, type) diff --git a/test/reconcile-links-cli-reachability.test.ts b/test/reconcile-links-cli-reachability.test.ts index 7357d86c7..08d614006 100644 --- a/test/reconcile-links-cli-reachability.test.ts +++ b/test/reconcile-links-cli-reachability.test.ts @@ -19,3 +19,23 @@ describe('CLI_ONLY command reachability (#2900)', () => { expect(CLI_ONLY.has('reconcile-links')).toBe(true); }); }); + +// #3224 — same drift class: `backfill` has a full `case 'backfill'` handler +// (cli.ts, dispatching to commands/backfill.ts) but was missing from CLI_ONLY, +// so every invocation hit the generic "Unknown command" branch. +describe('CLI_ONLY command reachability (#3224)', () => { + test('`backfill` is in CLI_ONLY so dispatch reaches its handler', () => { + expect(CLI_ONLY.has('backfill')).toBe(true); + }); + + test('`gbrain backfill --help` is dispatched, not rejected as unknown', () => { + const { spawnSync } = require('node:child_process') as typeof import('node:child_process'); + const result = spawnSync('bun', ['run', 'src/cli.ts', 'backfill', '--help'], { + cwd: process.cwd(), + encoding: 'utf8', + env: { ...process.env, GBRAIN_HOME: '/tmp/gbrain-test-backfill-nonexistent' }, + }); + expect(result.stderr ?? '').not.toContain('Unknown command'); + expect(result.status).toBe(0); + }); +});