Skip to content

fix(bus): clean CLI error for kb-delete --scope private with no agent; add exec timeout - #165

Open
asachs01 wants to merge 1 commit into
mainfrom
fix/kb-delete-cli-guard
Open

fix(bus): clean CLI error for kb-delete --scope private with no agent; add exec timeout#165
asachs01 wants to merge 1 commit into
mainfrom
fix/kb-delete-cli-guard

Conversation

@asachs01

@asachs01 asachs01 commented Aug 30, 2026

Copy link
Copy Markdown

Summary

Two optional follow-ups from dev's PR #157 review (task_1787750905384_03501051): (1) kb-delete --scope private with no agent resolved now exits cleanly with ERROR: --agent or CTX_AGENT_NAME required for --scope private instead of dumping a raw Node stack trace — mirrors the existing --org guard in the same CLI action handler. (2) deleteFromKnowledgeBase's execFileSync call now has a 30s timeout, matching queryKnowledgeBase's flat local-only timeout (delete is disk I/O only, no outbound network like ingest's Gemini calls, so it doesn't need ingest's minutes-scale floor/default/env-override machinery).

Test plan

  • Reproduced the original bug live against the fixed build: CTX_AGENT_NAME= node dist/cli.js bus kb-delete <path> --org wyre --scope private (run from a cwd whose basename is also empty, so agentName genuinely resolves empty) now prints the clean ERROR line and exits 1, no stack trace.
  • Added 3 new tests to tests/unit/bus/knowledge-base.test.ts covering deleteFromKnowledgeBase: missing-config graceful return, execFileSync called with timeout: 30000, and the private-scope-no-agent throw stays a plain catchable Error (the contract the new CLI guard depends on).
  • npx tsc --noEmit clean.
  • npm run build clean.
  • npm test: 2617/2623 passed, 4 skipped, 2 failures both in dashboard/.../watcher-ingests-real-events.test.ts (unrelated file, real-chokidar filesystem timing) — confirmed pre-existing/environment-flaky, passes 4/4 clean in isolation, same class already documented in root CLAUDE.md and hit again independently during tonight's fix(bus): thread CTX_ROOT through resolvePaths() #164 work.

Checklist

  • npm run build passes
  • npm test passes (see test plan — 1 pre-existing unrelated flake, verified isolated-pass)
  • No new secrets or credentials committed
  • Agent Awareness: N/A — no new command/endpoint/hook/behavior surface, just error-handling + a timeout on an existing command
  • Migration Parity: N/A — CLI code fix in dist/cli.js, not an agent-installed template/hook/settings file

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

…; add exec timeout

deleteFromKnowledgeBase already threw a plain Error when --scope private
resolved with no agent (--agent/CTX_AGENT_NAME), but the kb-delete CLI
action had no pre-check for it -- unlike the sibling --org guard in the
same handler -- so it bubbled up as a raw Node stack trace instead of a
clean ERROR/exit(1). Mirrors the --org guard's shape exactly.

Also added a 30s execFileSync timeout to deleteFromKnowledgeBase's mmrag.py
call, matching queryKnowledgeBase's flat local-only timeout (delete is disk
I/O only, no outbound network like ingest's Gemini calls, so it doesn't
need ingest's floor/default/env-override machinery -- the simpler sibling
pattern is the right fit).

Follow-ups from dev's PR #157 review (task_1787750905384_03501051).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant