Repository navigation
Closed
Description
Problem
A stranger downloads Cortex, runs cortex import ~/notes --extract, and their OpenRouter key is expired. What happens? Right now: a one-line notice and rule-only fallback. But that's one path out of dozens.
Every CLI command needs to be walked through with the question: "What does a first-time user see when this goes wrong?"
Scope
Error Path Inventory
Walk every command (import, search, extract, classify, conflicts, stale, stats, graph, connect, embed, reason, cleanup, summarize, reimport, mcp) and catalog:
- What happens with no DB file?
- What happens with a corrupt/locked DB?
- What happens with no API keys (OpenRouter, Ollama down, etc.)?
- What happens with empty input (no files, no facts, no matches)?
- What happens with permissions errors (read-only dir, no write to ~/.cortex)?
Standards
- No panics in any user-reachable path
- No silent failures — every skip/fallback gets a one-line notice to stderr
- Error messages include what went wrong + what to do (not just a Go stack trace)
- Exit codes are meaningful (0=success, 1=error, 2=partial success)
Graceful Degradation Matrix
Document and test these degradation paths:
| Missing | Behavior | Status |
|---|---|---|
| OpenRouter key | Skip enrichment/classify, rule-only extract | ✅ Done (v0.9.0) |
| Ollama | Skip semantic search, BM25 only | ⬜ Verify |
| No embeddings in DB | Hybrid falls back to BM25 | ⬜ Verify |
| Empty DB | Helpful "import something first" message | ⬜ Verify |
| Corrupt DB | Clear error, suggest backup/reimport | ⬜ Build |
| Read-only filesystem | Clear error before any writes | ⬜ Build |
Acceptance Criteria
- Every command tested with: missing DB, empty DB, no API keys, no Ollama
- No panics reachable from CLI
- Every error message includes remediation hint
- Exit codes documented in
--helpor man page - At least 10 new error-path tests added to test suite
Activity
feat: CLI hardening, doctor/agents commands, graph pagination (#228, #…
fix: error handling hardening — reinforce exit code, fact type valida…
hurttlocker commentedon Feb 26, 2026
Closed. Error handling audit complete across 3 commits:
ac5a54c — Core infrastructure:
exitWithError()centralized error handler withremediationHint()cortex help89a9064 — Edge cases:
reinforce: returns error when no facts were reinforcedlist --type: validates fact_type against 9 valid typessearch: validates modeVerified across all 30+ commands:
fix: graceful degradation for hybrid/RRF without embedder, new remedi…