MemtraceDOCS

memtrace start

The default command: boots the workspace runtime, indexes your repos, arms the file watcher, and serves the dashboard at localhost:3030.

Usage#

memtrace start [--headless|--no-ui|--no-browser] [--clear|--fresh] [--force|--replace] [--workspace <PATH|NAME>] [--no-workspace] [--bless-workspace] [--debug]

memtrace start is the default command. It connects to (or spawns) the local MemDB storage engine, discovers and indexes git repositories under the current directory, arms a file watcher for incremental re-indexing, and serves a REST/WebSocket API plus the dashboard UI on http://localhost:3030. It runs in the foreground until Ctrl-C/SIGTERM, at which point it flushes indexes and exits.

Bare memtrace (no arguments) and memtrace --headless/--no-ui/--no-browser all fall through to this same command — there is no separate code path for them.

TIP

First time here? Getting started walks through install, first run, and connecting an agent end to end.

Flags#

FlagDescription
--headlessSuppress the automatic browser tab open on startup. The HTTP API and dashboard UI server still bind and serve on :3030 exactly as in the default path — only the browser auto-open is skipped.
--no-uiDeprecated alias for --headless (prints a one-time deprecation note). Same behavior.
--no-browserDeprecated alias for --headless. Same behavior.
--clear / --freshWipes the local MemDB data directory before connecting, then reconnects fresh. In external MemDB mode this only removes the local lock/cache dir, never the remote database. Equivalent aliases.
--force / --replaceWhen a live, compatible daemon already owns this workspace's MemDB data dir, skip the normal "already running" short-circuit and forcibly reclaim/replace that owner instead of exiting early. Equivalent aliases.
--workspace <PATH>Hard override: anchors the MemDB/.memtrace data-dir resolution directly at PATH (creating it if needed) and writes a .memtrace-workspace marker there, so sibling memtrace mcp processes in child repos converge on the same MemDB.
--workspace <NAME>Boots a registry-backed Named Workspace: an explicit set of repos, scattered anywhere on disk, resolved from ~/.memtrace/workspaces/ — replacing cwd-based repo auto-discovery entirely for this run.
--no-workspaceSuppresses the Folder-Group workspace-shape auto-detection/auto-bless prompt entirely for this run (cwd is treated as N independent repos, never merged into one shared index).
--bless-workspacePre-answers "yes" to the interactive confirmation that would otherwise be asked before writing a .memtrace-workspace marker for a newly detected Folder Group (2+ sibling git repos, no .git of cwd's own). Equivalent to MEMTRACE_BLESS_WORKSPACE=1.
--debugRaises the tracing/log verbosity for this run. Equivalent to MEMTRACE_DEBUG=1.

Environment variables#

VariableDefaultDescription
MEMTRACE_UI_PORT3030HTTP port for the REST API + dashboard UI. If busy and not explicitly set, memtrace scans up to 49 ports above the requested one and uses the first free one (with a warning); if explicitly set and busy, start fails instead of falling back.
MEMTRACE_UI_HOST127.0.0.1Bind host for the UI/API server. Defaults to loopback-only for security; set e.g. 0.0.0.0 to expose on the LAN/container network intentionally. Blank/whitespace values also fall back to loopback.
MEMTRACE_MEMDB_DATA_DIR<git-root-or-cwd>/.memdbOverrides where the local MemDB data directory (and workspace state) lives. Otherwise resolved from an ancestor .memtrace-workspace marker or the git root of cwd.
MEMTRACE_MEMDB_MODElocalHow this process reaches MemDB: local (default — spawns/adopts a loopback memcore-server sidecar over gRPC to 127.0.0.1:50051), embedded (in-process RealEngine), or external (operator-supplied gRPC endpoint). Aliases: sidecar=local, remote/hosted=external.
MEMTRACE_HEADLESSunset (false)Canonical env equivalent of --headless: suppresses browser auto-open only.
MEMTRACE_NO_UI / MEMTRACE_NO_BROWSERunset (false)Deprecated env aliases for MEMTRACE_HEADLESS (one-time deprecation note printed).
MEMTRACE_START_FORCEunset (false)Env equivalent of --force/--replace.
MEMTRACE_BLESS_WORKSPACEunset (false)Env equivalent of --bless-workspace.
MEMTRACE_DEBUGunset (false)Env equivalent of --debug (raises log verbosity).
MEMTRACE_LICENSE_KEYunsetSupplying a license key also bypasses the interactive first-run device flow.
MEMTRACE_SKIP_EMBEDunset (false)Skips the ONNX Runtime dlopen pre-flight and the embedding pipeline; structural (non-semantic) indexing still works. Without it, a missing/broken libonnxruntime causes memtrace start to trip the embed breaker and exit(75).
MEMTRACE_NO_REPLAYunset (false)Also skips git-history replay — a workaround alongside MEMTRACE_SKIP_EMBED.
MEMTRACE_START_AUTOINDEXunset (auto)0/false/off/no disables the startup structural re-index entirely; 1/true/on/yes forces it; unset falls back to a large-store size heuristic.
MEMTRACE_START_AUTOINDEX_LARGE_STORE_MB512Size threshold (MB) above which startup auto-index is skipped (the engine repairs embeddings in the background instead); 0 disables the size gate.
MEMTRACE_OVERLAY_TTL_HOURS168TTL for the startup GC sweep that reaps stale worktree overlays for each discovered repo.
REDIS_URLunsetWhen set, start subscribes to the memtrace:indexed Redis channel and forwards messages into the local WebSocket broadcast (used for cloud deployments where an indexer worker is a separate process).
MEMTRACE_SHUTDOWN_FLUSH_TIMEOUT_SECS10Bounds how long shutdown waits for index-manifest flush before falling through to the sync_all safety net.

Boot order#

This is the exact sequence memtrace start runs through on every invocation:

  1. 1
    Banner + runtime gates

    Prints the brand banner and a runtime-gates summary (RSS ceiling, pressure threshold, batch sizes, breaker state).

  2. 2
    ONNX Runtime pre-flight

    Probes whether libonnxruntime can be dlopen'd. If it can't and MEMTRACE_SKIP_EMBED isn't set, start exits with code 75 (EX_TEMPFAIL) rather than degrading silently. Workaround: MEMTRACE_SKIP_EMBED=1 memtrace start keeps the structural graph working without embeddings (semantic search off, everything else on).

  3. 3
    First-run sign-in gate

    If there's no saved session and no MEMTRACE_LICENSE_KEY, the device-flow browser sign-in runs inline before anything else.

  4. 4
    Already-running short-circuit

    If a live, mode-compatible daemon already owns this workspace's MemDB dir (confirmed via heartbeat, not just a stale lock), start prints the existing UI URL and MemDB owner endpoint and exits Ok(()) without opening a browser tab — unless --force/--replace reclaims the owner first.

  5. 5
    MemDB sidecar

    Resolves and binds the UI port (auto-bumped up to +49 if busy, unless MEMTRACE_UI_PORT was set explicitly), then connects to MemDB — default mode local spawns or adopts a loopback memcore-server sidecar over gRPC on 127.0.0.1:50051.

  6. 6
    UI bind + browser auto-open

    Spawns the Axum REST/WebSocket API + dashboard server as a background task, bound to 127.0.0.1 by default (MEMTRACE_UI_HOST to change). Auto-opens the default browser to http://localhost:<port> on a fresh boot only — suppressed by --headless/--no-ui/--no-browser or their env equivalents. The server itself always starts regardless of these flags.

  7. 7
    Cortex sidecars

    Also spawns, as background tasks alongside the UI server: a Cortex decision-memory sidecar bootstrap (universal/default-on for every plan since v0.8.3 — opt out via MEMTRACE_CORTEX=off; fail-safe, so a spawn failure just degrades quietly without blocking startup), Rail search-cache warming, graph/insights cache pre-warming, cross-repo HTTP link backfill/repair, and branch-attribution self-heal.

  8. 8
    Workspace detection

    Discovers repos to index: the single cwd git repo first, then a Named Workspace's registered members (if --workspace <NAME> was used), then falls back to scanning up to 2 directory levels below cwd for sibling git repos. If 2+ sibling repos are found under a cwd with no .git of its own (a "Folder Group"), memtrace interactively asks (TTY-gated) before writing a .memtrace-workspace marker that shares one index across all of them.

  9. 9
    Two-phase auto-index

    Arms a debounced (200ms) file watcher per discovered repo, then runs a two-phase background bootstrap: Phase 1 indexes HEAD for every repo sequentially (skipped if MEMTRACE_START_AUTOINDEX=0 or the store exceeds the large-store size threshold — 512MB by default — and isn't empty); Phase 2 runs embedding + git-history replay per repo, gated by a pressure/RSS pre-flight that backs off exponentially rather than tripping the embed breaker on transient pressure.

  10. 10
    Model download

    The first embed triggers a one-time download of the default embedding model — jina-code (jina-embeddings-v2-base-code, 768-dim) — cached at ~/.memtrace/fastembed_cache. The terminal prints an explicit "First run — downloading embedding model" notice so the silent stretch isn't mistaken for a hang.

memtrace start boot orderFLOW
oknoyes
ONNX preflight
Sign-in gate
Already running?
MemDB sidecar:50051
UI + browser:3030
Cortex sidecars
Two-phase index
Model downloadjina-code
DECISIONSUPPORTINGINFRASTRUCTURESERVICEEXTERNAL

Gotchas#

HEADLESS ONLY SUPPRESSES BROWSER OPEN

--headless/--no-ui/--no-browser suppress the automatic browser-tab open only. The HTTP API and dashboard UI server still start and bind a port.

NON-INTERACTIVE SHELLS CAN HANG ON FIRST RUN

A first run with no ~/.config/memtrace/credentials.json and no MEMTRACE_LICENSE_KEY blocks memtrace start on an interactive device-flow browser auth before anything else happens. Set MEMTRACE_LICENSE_KEY in CI/non-interactive invocations.

EXIT CODE 75 IS A HOST-CONFIG PROBLEM, NOT A CRASH

If ONNX Runtime's libonnxruntime can't be dlopen'd and MEMTRACE_SKIP_EMBED is not set, start exits with code 75 (EX_TEMPFAIL) rather than degrading silently. Install the dylib, or run MEMTRACE_SKIP_EMBED=1 memtrace start for a structural-only graph.

MEMTRACE_UI_HOST=0.0.0.0 IS AN EXPLICIT OPT-IN

The UI/API server binds loopback (127.0.0.1) by default for security. Setting MEMTRACE_UI_HOST=0.0.0.0 exposes the unauthenticated REST/WebSocket API (graph/episode/search JSON) to the LAN — treat it as a deliberate choice, not a convenience default.

--CLEAR IN EXTERNAL MEMDB MODE IS SCOPED LOCALLY

--clear/--fresh in external MemDB mode only wipes the local lock/cache directory, never the remote database.

A 'STUCK' DASHBOARD AFTER RESTART IS BY DESIGN

On a large existing store (over 512MB by default, tunable via MEMTRACE_START_AUTOINDEX_LARGE_STORE_MB), the startup structural re-index is skipped automatically and the engine instead repairs embeddings incrementally in the background. This avoids re-embedding from scratch on every restart — it explains why a big repo's dashboard can look incomplete right after a restart, but it isn't a bug.

FOLDER GROUP PROMPTS NEED A TTY

Detecting a Folder Group (2+ sibling repos, no .git of cwd's own) triggers an interactive yes/no prompt on a TTY; in CI or non-TTY contexts it silently declines to share an index unless --bless-workspace/MEMTRACE_BLESS_WORKSPACE=1 is set.

SHUTDOWN IS A HARD EXIT

Shutdown publishes a 'stopping' status, removes the PID file, flushes index manifests (bounded, default 10s), flushes/syncs the MemDB backend (bounded 5s), shuts down the memcore-server sidecar if present, then calls std::process::exit(0) — background tasks are not gracefully joined by design. A second Ctrl-C during a stuck shutdown is caught by a raw libc SIGINT handler that force-exits with code 130, independent of the tokio runtime.

Examples#

terminal
$ memtrace start
# Default: index the current repo (or discovered sibling repos),
# watch for changes, and open the dashboard at http://localhost:3030.

$ memtrace
# Identical to `memtrace start` — bare invocation falls through to the same dispatch arm.

$ memtrace start --headless
# Run without auto-opening a browser tab; the API/UI still bind on :3030
# (useful for CI, containers, or remote/background daemons).

$ memtrace start --clear
# Wipe the local .memdb data directory first, then start fresh
# (re-indexes everything from scratch).

$ memtrace start --force
# Replace an already-running owner daemon for this workspace
# instead of just reporting it and exiting.

$ memtrace start --workspace ./monorepo-root
# Hard-anchor the shared MemDB/.memtrace data dir at a specific path
# (writes a .memtrace-workspace marker there).

$ memtrace start --workspace my-team-ws
# Boot a registry-backed Named Workspace whose member repos
# can be scattered anywhere on disk.

$ MEMTRACE_SKIP_EMBED=1 memtrace start
# Start with structural indexing only, skipping the ONNX embedding pipeline
# (useful if libonnxruntime isn't installed).

See also memtrace stop, memtrace status, memtrace index, memtrace mcp, memtrace reset, memtrace workspace, memtrace connect, and memtrace doctor.