Skip to content

fix: Smart server fallback for unsupported commands #104

Closed

Description

@ajianaz

Summary

When server.enabled = true in config and uteke-serve is reachable, CLI routes all commands via HTTP. But 13/20 commands have no server endpoint — they return error "This command requires local store. Disable server mode to use it."

This is bad UX. Commands that can't go through server should auto-fallback to local store instead of erroring.

Current Behavior (Broken)

# server.enabled = true, uteke-serve running
uteke doctor        # ERROR: "This command requires local store"
uteke verify        # ERROR
uteke repair        # ERROR
uteke tags list     # ERROR
uteke export        # ERROR

Expected Behavior

# server.enabled = true, uteke-serve running
uteke remember "hi"   # → HTTP to server (fast, warm) ✓
uteke recall "hi"     # → HTTP to server (fast, warm) ✓
uteke doctor          # → auto-fallback to local store ✓
uteke tags list       # → auto-fallback to local store ✓
uteke export          # → auto-fallback to local store ✓

Acceptance Criteria

  • Commands supported via server route through HTTP (no change)
  • Commands NOT supported via server auto-fallback to local store (open DB locally)
  • Log message when falling back: "Command not supported via server, using local store"
  • No user-facing error for unsupported commands
  • Same data directory used by both CLI local and server (~/.uteke/ or UTEKE_HOME)
  • Existing server.enabled = false behavior unchanged

Affected Commands (13 → auto-fallback)

Command Why local-only
get <id> No /memory?id= endpoint
forget --cold/--all Server only supports ?id= and ?tag=
doctor Diagnostic, needs filesystem access
verify Index consistency check
repair Rebuild index from SQLite
export / import File I/O operations
consolidate O(n²) pairwise comparison
prune Temporal cleanup
tags Tag management
aging Tier management
hook Shell script generation
init File generation
namespace Config management

Implementation Notes

In crates/uteke-cli/src/main.rs:

  • Current: run_via_server() returns Err() for unsupported commands → CLI prints error
  • Fix: run_via_server() returns a signal (e.g., Err("unsupported")) → main falls through to local store path
  • Or: move the server check inside each command branch instead of globally

Verification

# Setup: start server
uteke-serve &

# Config
echo "[server]
enabled = true" > ~/.uteke/uteke.toml

# Test: server-supported (routed via HTTP)
uteke remember "test fallback" --tags test    # ✓ via HTTP
uteke recall "test"                           # ✓ via HTTP

# Test: local-only (auto-fallback, no error)
uteke doctor                                  # ✓ local, no error
uteke tags list                               # ✓ local, no error
uteke verify                                  # ✓ local, no error

# Test: server down → all fallback to local
kill %1
uteke remember "offline test" --tags test     # ✓ local fallback
uteke doctor                                  # ✓ local

Metadata

Metadata

Assignees

No one assigned

    Labels

    scope:clitype:feature

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions