MemtraceDOCS

memtrace start

The default command: cold-starts the invoked repository or folder, indexes its repos, and serves the dashboard at localhost:3030.

Usage#

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

memtrace start is the default command. With no workspace flag, it cold-starts exactly the invoked git repository or folder. A folder containing multiple repos owns all of those repos in one folder-local store. Bare start does not inherit an ancestor .memtrace-workspace marker or an IDE workspace root, does not prompt for consent, and does not write a marker.

After resolving that scope, start connects to (or spawns) the local MemDB storage engine, indexes every git repository in scope, arms file watchers for incremental re-indexing, and serves a REST/WebSocket API plus the dashboard UI on http://localhost:3030. Bare memtrace and the browser-suppression aliases use the same command path.

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>Explicit legacy Folder Group: anchors MemDB/.memtrace at PATH (creating it if needed) and writes a .memtrace-workspace marker there, so sibling memtrace mcp processes converge on the same store.
--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.
--workspace-file <FILE> / --workspace <FILE>Loads a portable version-1 TOML workspace manifest. Member paths may be relative to the manifest or absolute, and each must be a git repository. The manifest's directory is the data anchor; no registry entry or .memtrace-workspace marker is written.
--no-workspaceHard per-repo mode. From inside a child repo, ignores parent workspace markers and IDE workspace roots, selects that repo's own MemDB/.memtrace directories, and discovers only that repo. A broad parent containing multiple repos is refused because one daemon cannot own several independent stores.
--bless-workspaceExplicitly turns the invoked multi-repo folder into a legacy Folder Group and writes its .memtrace-workspace marker. Bare start never does this implicitly. 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>/.memdbExplicitly overrides the local MemDB data directory. Without it, bare start uses the invoked git root or folder; an explicit Folder Group, Named Workspace, or manifest supplies its own anchor.
MEMTRACE_MEMDB_MODElocalHow this process reaches MemDB: local (default — starts a store-owned memcore-server sidecar on an isolated loopback gRPC port, preferring the configured/default port 50051 when it is free), 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
    Repository scope selection

    Resolves the complete repository scope before constructing config, wiping/opening MemDB, or arming a watcher. Bare start owns the invoked repo or folder as a cold scope, including every repository discovered beneath a multi-repo folder. Explicit Folder Groups, Named Workspaces, and workspace manifests replace that default. --no-workspace selects only the containing repo and refuses a broad multi-repo folder.

  4. 4
    First-run sign-in gate

    If there's no saved session and no MEMTRACE_LICENSE_KEY, the device-flow browser sign-in runs inline after repository-scope validation and before configuration/storage startup.

  5. 5
    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.

  6. 6
    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 starts a store-owned memcore-server sidecar on an isolated loopback gRPC port. It prefers the configured/default port 50051 when available, leases another local port when necessary, and never adopts an unrelated listener.

  7. 7
    Watcher readiness

    Publishes the pre-resolved repositories to startup repair and arms every repository watcher. Any watcher failure aborts startup before the HTTP/MCP runtime is advertised as ready.

  8. 8
    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.

  9. 9
    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.

  10. 10
    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.

  11. 11
    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
okresolvednoyes
ONNX preflight
Select repository scope
Sign-in gate
Already running?
MemDB sidecarisolated loopback port
Watchers ready
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.

BARE START IS A COLD SCOPE

Starting without a workspace flag never inherits an ancestor marker or IDE workspace root. The invoked repo or folder gets its own local store, and every repo discovered under a multi-repo folder belongs to that one cold scope. Use --workspace, --workspace-file, or --bless-workspace only when you want an explicitly reusable workspace identity.

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
# Cold-start the current repo or folder, ignoring ancestor markers and IDE roots.
# A multi-repo folder uses its own local store without prompting or writing a marker.

$ 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 start --workspace-file ./memtrace-workspace.toml
# Load a portable version-1 manifest. Relative member paths and the data
# directory are anchored beside the manifest. --workspace FILE is equivalent.

$ memtrace start --bless-workspace
# Explicitly turn a sibling-repo parent into a legacy Folder Group
# and persist its .memtrace-workspace marker.

$ memtrace start --no-workspace
# From inside a marked child repo, ignore the parent marker and use this repo's
# own .memdb. From a broad parent containing multiple repos, this is refused.

$ 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.