Runtime operations

Operate MARS while agents are running.

MARS has two runtime shapes: a scoped single-repo lifecycle with mars start, and a persistent multi-repo orchestrator with mars serve. This guide documents the visible runtime surfaces users operate day to day: dashboard pages, local control endpoints, terminal controls, state paths, queue recovery, logs, traces, and safe shutdown.

Start Vs Serve

Choose the runtime mode from the operating need. Both use the same queue, dashboard package, controls, tools, traces, and local inference routing; the difference is scope and default database behavior.

ModeUse whenDefault scopeDefault database
mars start --repo /path/to/repo --execution-profile host --acknowledge-host-executionYou want one target repo initialized, registered, reconciled, and run with target mutation enabled.Single target repo.~/.mars/db/{repo-name}/mars.db.
mars serve --execution-profile host --acknowledge-host-executionYou already registered repos and want a long-running mutating orchestrator that receives webhooks and cron triggers.All repos in the configured DB.Legacy shared DB ~/.mars-harness/db/mars.db unless --db is passed.
mars run <role> --repo /path/to/repoYou need one manual role execution rather than the full orchestrator loop.One role, one repo, one job.Uses the selected repo and command options; not the dashboard loop.

Scoped lifecycle

mars start --repo ~/my-project --execution-profile host --acknowledge-host-execution
mars start --repo ~/my-project --dashboard-addr 127.0.0.1:9090 --addr 127.0.0.1:9091 --execution-profile host --acknowledge-host-execution

Use explicit addresses when scripts or users depend on stable ports. With default addresses, scoped start can fall back to ephemeral local ports on conflict.

Persistent daemon

mars register --repo ~/my-project --remote owner/repo
mars serve --addr 127.0.0.1:9091 --concurrency 2 --db ~/.mars-harness/db/mars.db --execution-profile host --acknowledge-host-execution

Use this when webhooks, schedules, and multiple registered repos should share one orchestrator.

Execution profiles: agent entry points default to observer, which independently caps trust and blocks all target mutators. Host requires both acknowledgement flags, has the current OS user's full authority, and is not containment. Isolated is unavailable until MARS has an enforceable adapter.

Startup Lifecycle

Acknowledged-host mars start is intentionally more than a process launcher. It prepares the target harness, creates a clean initial scaffold commit when needed, registers the repo, reconciles stale or resumable lifecycle state, then either resumes work or seeds the bootstrap role.

  1. Resolve target repository

    If --repo is omitted, the current directory is used. MARS rejects runtime DB or log paths that would live inside the target repo.

  2. Ensure the deployed harness exists

    In this acknowledged-host path, a missing .harness/manifest.yaml runs the same scaffold as mars init. Generated first-run files are committed as chore(harness): initialize mars harness so agents start from a clean baseline; observer mode fails before target writes.

  3. Open the per-repo database

    The default path is ~/.mars/db/{repo-name}/mars.db. Use --db only when you deliberately want another database location outside the repo.

  4. Build runtime dependencies

    MARS resolves local configuration, code graph settings, dashboard/control addresses, model endpoint override, local model preflight, and inference tuning.

  5. Reconcile lifecycle state

    Existing active jobs, stale recoverable jobs, in-progress tickets, rework states, and deterministic dispositions are resumed before a fresh CEO bootstrap is seeded.

  6. Run until stopped

    The worker pool claims jobs, records telemetry and traces, updates the dashboard, and responds to terminal or HTTP controls.

Ambiguous startup: if MARS cannot safely decide whether to resume or start fresh, it refuses and asks you to inspect the repo or rerun with --new-lifecycle when you intentionally want to seed a new CEO lifecycle.

Dashboard

The current dashboard is embedded in the Go binary. It uses server-rendered HTML, embedded static assets, Chart.js, htmx-style interaction, and server-sent events. It is local by default and requires no frontend build step or outbound CDN. Page/login shells, embedded assets, and minimal status are bounded observer views; privileged reads, SSE, and mutations require environment-only MARS_DASHBOARD_CONTROL_SECRET, login, exact Host/Origin, and session CSRF. For endpoint-level request, response, error, and scripting details, use the Dashboard API Reference.

PathPageUser purpose
/RedirectRedirects to /pipeline.
/pipelinePipeline FlowShows live role routing and active pipeline mode.
/orchestrationOrchestrationSummarizes orchestrator state and runtime control context.
/rolesRole HealthSurfaces role health and execution status.
/throughputThroughputShows throughput-oriented runtime signals.
/debugDebugDebug-oriented operator view for runtime events.
/evolutionEvolution HistorySelf-improvement and intervention history surface.
/api/eventsSSE streamStreams recent dashboard events and live updates.
/api/telemetryTelemetry APIServe-attached read API for telemetry view data.
/api/evolutionEvolution APIServe-attached read API for evolution history.
/api/rolesRoles APIServe-attached read API for role health and score data.
/api/quality-scoreQuality score APIServe-attached read API for repo-visible quality score output.
/api/throughputThroughput APIServe-attached read API for job and runtime throughput data.
/api/orchestrationOrchestration APIServe-attached read API for routing and orchestration state.
/api/orchestration/decisionsDecision APIServe-attached read API for recent orchestration decisions.
Two local HTTP servers: the loopback dashboard address serves pages and dashboard APIs. An exact authenticated HTTPS reverse-proxy origin may be configured, but MARS itself remains on loopback. The webhook/control address serves webhook traffic and GET /healthz.

Open the dashboard

mars start --repo ~/my-project --dashboard-addr 127.0.0.1:9090
open http://localhost:9090

The dashboard URL is also printed in the runtime display when the terminal dashboard is active.

Stream events manually

curl -N http://localhost:9090/api/events

Late subscribers receive buffered recent events, then live event payloads.

Controls API

The dashboard exposes bounded local JSON endpoints for operators and companion UIs. Mutating endpoints require authenticated POST, exact same-origin Origin, and the current session CSRF token. Missing callbacks return a not-implemented response rather than pretending a control succeeded.

EndpointMethodRequestBehavior
/healthzGETControl address only.Returns orchestrator health on the webhook/control HTTP server.
/api/statusGETNone.Returns the live runtime status object supplied by the orchestrator.
/api/reposGETNone.Returns registered repos as id and path.
/api/repo-roles?repo_id=...GETrepo_id query parameter.Returns role names available for a repo.
/api/pausePOSTEmpty body.Stops claiming new jobs. Running jobs are allowed to finish.
/api/resumePOSTEmpty body.Allows workers to claim jobs again.
/api/restartPOSTEmpty body.Warm restart: reload manifests and triggers without dropping HTTP.
/api/stopPOSTEmpty body.Requests graceful orchestrator stop.
/api/scanPOST{"repo_id":"..."}Runs a scanner pass for the selected registered repo.
/api/run-rolePOST{"repo_id":"...","role":"engineer"}Queues or invokes a selected role for the selected repo.
/api/emergency-stopPOSTEmpty body.Runs the configured emergency-stop callback and reports any errors.

Serve-Attached Read APIs

When the dashboard is created by the orchestrator, serve attaches additional read APIs used by the dashboard pages: /api/telemetry, /api/evolution, /api/roles, /api/quality-score, /api/throughput, /api/orchestration, and /api/orchestration/decisions.

Pause and resume

Set the environment-only control secret before startup, log in through the embedded browser, then use Pause or Resume. Anonymous mutations fail closed.

Run a role from an external UI

Resolve the bounded repo/role lists, then implement the documented login-cookie, exact-Origin, and CSRF exchange before POST. Do not guess IDs from filesystem paths.

Terminal Controls

When start or serve is attached to an interactive terminal, MARS exposes keyboard controls and a status bar. The same operations are available through the dashboard API.

KeyActionOperational note
pPause or resumePaused workers finish current jobs but do not claim new ones.
rWarm restartReloads manifests, triggers, and workers while HTTP stays up.
sScan reposRuns scanner passes for registered repos.
qGraceful stopSame intent as Ctrl+C or POST /api/stop.
hHelpPrints the key binding help text.

State And Paths

MARS keeps durable runtime state outside target repos by default. Target repositories remain the system of record for plans, tickets, feature contracts, changelogs, and committed work; runtime queues, traces, local model artifacts, and process logs live under ~/.mars/. For a complete ownership and cleanup map, use the Files And State Reference.

PathOwned byPurpose
~/.mars/config.yamlUser machineLocal configuration such as ports, model directories, performance profile, and install paths.
~/.mars/models/User machineDownloaded GGUF model files and local model cache.
~/.mars/bin/User machineManaged runtime binaries such as llama-server artifacts.
~/.mars/db/{repo-name}/mars.dbScoped target runtimeDefault queue, telemetry, trust, scoring, and registry state for mars start.
~/.mars-harness/db/mars.dbShared runtimeLegacy shared DB used by mars serve unless --db is explicit.
~/.mars/traces/User machineTrace and log artifacts from role runs and runtime commands.
.harness/Target repoRepo-owned role, guardrail, skill, knowledge, manifest, and metadata files.
docs/, VERSION, CHANGELOG.mdTarget repoDurable operating model artifacts and release state.
Database isolation: prefer the per-repo default from mars start unless you intentionally need a multi-repo shared database. Passing --db should be deliberate and outside the target repo.

Queue And Recovery

The orchestrator is designed to resume useful work and avoid restarting broad jobs blindly. Startup reconciliation inspects jobs, tickets, deterministic dispositions, stale recoverable work, and ambiguous states before deciding what to seed next.

Resumable work

Active jobs, stale recoverable jobs, rework tickets, in-progress tickets, and recent deterministic dispositions can be resumed rather than discarded.

Ambiguous work

When the next safe role is unclear, MARS refuses startup and asks for inspection or explicit --new-lifecycle.

Pause semantics

Pause is not a kill switch. It prevents new claims while current jobs finish or reach their own timeout.

Warm restart

Restart reloads manifests and triggers, then restarts workers while keeping the local HTTP server available.

Logs And Traces

Use debug output when you are actively diagnosing a run, and log files when you need a durable artifact outside the repo. Role traces record the turn-level evidence needed for quality, scoring, and troubleshooting.

Inline debug output

mars start --repo ~/my-project --debug
mars serve --debug

Debug mode streams verbose trace and logs inline instead of relying on the TTY dashboard.

Write command logs

mars start --repo ~/my-project --log-file ~/.mars/traces/logs/my-project-start.log
mars serve --log-file ~/.mars/traces/logs/orchestrator.log

Keep logs outside source and target repos. MARS rejects lifecycle log paths that would live inside the target repo.

Run one role with a trace

mars run engineer --repo ~/my-project --trace --debug

Use this to inspect one role's prompt, tools, model tier, and turn evidence without the full queue loop.

Record a local check

mars checks run --repo ~/my-project --name go-test -- go test ./...

MARS stores whether the command passed or failed in the repo database. It does not write a check file into the target repo.

Open the local checks guide

Check runtime health

mars doctor --repo ~/my-project --json
mars trust --repo ~/my-project

Doctor checks setup, model, database, repo, and operating-model health; trust shows progressive autonomy levels.

Operator Recipes

Run a controlled first lifecycle

mars init --repo ~/my-project
mars doctor --repo ~/my-project --json
mars run engineer --repo ~/my-project --dry-run
mars start --repo ~/my-project --concurrency 1 --execution-profile host --acknowledge-host-execution

Initialize, inspect, then run sequentially. This is the safest first target path.

Use a real remote model endpoint

mars start --repo ~/my-project \
  --model-endpoint http://127.0.0.1:8088/v1

The endpoint must be a real OpenAI-compatible model endpoint. Fake, stub, mock, canned, or scripted endpoints are test fixtures, not live validation evidence.

Recover from occupied local ports

mars start --repo ~/my-project --dashboard-addr 127.0.0.1:9190 --addr 127.0.0.1:9191
mars start --repo ~/my-project --model-endpoint http://127.0.0.1:8088/v1

Use alternate dashboard/control ports, or bypass local llama-server startup with a real OpenAI-compatible endpoint.

Drain before maintenance

Use terminal p then q, or authenticated dashboard Pause then Stop. Pause first when current jobs should finish without new claims.

Troubleshooting

SymptomLikely causeUser action
Dashboard does not open on the expected port.Another process owns the address, or scoped start fell back to an ephemeral port.Pass --dashboard-addr 127.0.0.1:PORT explicitly and watch the runtime display for the final URL.
/api/scan or /api/run-role returns a bad request.Missing repo_id or role payload.Call GET /api/repos and GET /api/repo-roles?repo_id=... first.
Startup refuses ambiguous lifecycle state.MARS found state that could be resumed or restarted, but cannot choose safely.Inspect tickets, queue, and DB state; rerun with --new-lifecycle only when intentionally starting fresh.
Model preflight fails before agents run.Required local model file is missing or the active profile changed.Run mars setup, or provide a real endpoint on the command that starts agents: mars start --repo /path/to/repo --model-endpoint http://127.0.0.1:8080/v1 or mars run engineer --repo /path/to/repo --model-endpoint http://127.0.0.1:8080/v1. See Models Guide.
Serve appears to use the wrong repo history.serve defaults to the shared legacy DB.Use mars start --repo ... for per-repo state, or pass --db deliberately.
Trace/log files clutter the repo.A manual path was pointed inside the source or target checkout.Move runtime logs under ~/.mars/traces/; lifecycle commands validate these paths.