Files
multica/server
Lambda e583c149ef fix(dev): make the local dev flow survive its own tooling
Three defects in the documented local flow, plus the bootstrap collapse
that keeps them from coming back.

1. `make daemon` produced a daemon that could not run any task. The chain
   ended in `go run`, and the daemon records its own executable path at
   startup to re-exec as the execution-environment helper for every task.
   `go run` deletes that temp binary when the launcher exits, so the
   daemon started, registered, heartbeat — then failed every task with
   "fork/exec .../go-build.../exe/multica: no such file or directory".
   `make daemon` now builds `server/bin/multica` and runs that (`ARGS`
   forwards any daemon subcommand), and `daemon start` refuses an
   ephemeral binary up front instead of deferring the failure.

2. `make stop` killed the daemon. `lsof -ti:PORT` matches every process
   holding a socket on the port, including CLIENTS — and the daemon holds
   a long-lived connection to the backend. Stop now goes through
   scripts/port-guard.sh, which filters to `-sTCP:LISTEN` and sends TERM
   before KILL. scripts/port-guard.test.sh pins both halves against a real
   listener and a real connected client.

3. Restarting over a running instance failed invisibly: the new process
   died on the bind, the old one kept serving, and /health answered 200
   throughout. `make dev` now preflights both ports and names the process
   that owns them, and /health reports `pid`, `started_at`, and `commit`
   so a caller can prove which process answered.

4. `make dev-bootstrap` collapses the ~12-step manual sequence into one
   command: env file, fixed verification code before first launch, DB via
   DATABASE_URL (not docker exec), port preflight, detached services,
   health verified against process identity, single-shot login, PAT,
   workspace, CLI profile, built daemon binary. It pins a durable TMPDIR
   so an agent-created environment outlives the run that created it.
   `make dev-bootstrap-stop` tears it down.

Measured on a clean checkout: 11.7s to a logged-in, daemon-attached
environment.

Co-authored-by: multica-agent <github@multica.ai>
2026-08-07 16:37:26 +08:00
..