Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
fix(cli): allow login with stale daemon port env (#6801)
Multica Eve3ef345b65804
diff --git a/apps/docs/content/docs/cli.mdx b/apps/docs/content/docs/cli.mdxindex 5ab2f7c9bd..af71da799d 100644--- a/apps/docs/content/docs/cli.mdx+++ b/apps/docs/content/docs/cli.mdx@@ -212,6 +212,8 @@ multica config showmultica config show --profile staging```+Do not set `MULTICA_DAEMON_PORT` in the host shell, Compose service, or container entrypoint that starts a daemon. The host daemon derives its health port from `--profile` and injects this variable into agent tasks itself. Remove the variable from older startup environments entirely: versions 0.4.22 and 0.4.23 otherwise mistake that shell for a managed task and reject login. Newer versions let guarded human login and `daemon status` recover when the port is the only task signal, but ordinary API and profile-resolving commands intentionally remain fail-closed until the variable is removed.+When the CLI runs inside a daemon-managed agent task, it does not load or modify these human-owned profile files. Multica API commands authenticate with the task-scoped credential injected by the daemon. `config show` and `config set` use private task-local state; human/local commands such as `login`, `logout`, `setup`, `workspace switch`, local runtime profile path changes, `daemon start` / `stop` / `restart`, `daemon logs`, and `daemon probe-runtimes` are unavailable. `auth status` does not print token material in this context.`daemon status` and `daemon disk-usage` stay available so an agent can inspect the runtime hosting it, scoped to that runtime: `status` probes the health port the daemon injected, and `disk-usage` scans the workspaces root the daemon injected. Neither accepts `--profile`, `disk-usage` also rejects `--all-profiles` and `--workspaces-root`, and its STATUS column is blank because resolving it would require the human's stored token. Use `du` and `df` for anything outside that scope.diff --git a/server/cmd/multica/cmd_agent.go b/server/cmd/multica/cmd_agent.goindex f26f59e6be..f4bf45fcd4 100644--- a/server/cmd/multica/cmd_agent.go+++ b/server/cmd/multica/cmd_agent.go@@ -265,7 +265,7 @@ func newAPIClient(cmd *cobra.Command) (*cli.APIClient, error) {return nil, fmt.Errorf("agent execution context requires MULTICA_TOKEN to be a task-scoped mat_ token; detected a daemon task marker at %s — if you are not running inside an agent task this is likely a leftover, remove it and retry", markerPath)}}- return nil, fmt.Errorf("agent execution context requires MULTICA_TOKEN to be a task-scoped mat_ token")+ return nil, fmt.Errorf("agent execution context requires MULTICA_TOKEN to be a task-scoped mat_ token%s", daemonPortOnlyContextHint())}serverURL := resolveServerURL(cmd)@@ -291,13 +291,35 @@ const ()func tryResolveServerURL(cmd *cobra.Command) string {- val := cli.FlagOrEnv(cmd, "server-url", "MULTICA_SERVER_URL", "")- if val != "" {- return normalizeAPIBaseURL(val)+ if val := tryResolveExplicitServerURL(cmd); val != "" {+ return val}if inDaemonManagedExecutionContext() && strings.TrimSpace(os.Getenv(cli.TaskConfigRootEnv)) == "" {return ""}+ return tryResolveProfileServerURL(cmd)+}++// tryResolveHumanServerURL is reserved for a human/local command after it has+// passed requireHumanLocalCommand. Unlike the general resolver, a stale+// MULTICA_DAEMON_PORT in a host/container environment must not hide the human+// profile that login is explicitly meant to update.+func tryResolveHumanServerURL(cmd *cobra.Command) string {+ if val := tryResolveExplicitServerURL(cmd); val != "" {+ return val+ }+ return tryResolveProfileServerURL(cmd)+}++func tryResolveExplicitServerURL(cmd *cobra.Command) string {+ val := cli.FlagOrEnv(cmd, "server-url", "MULTICA_SERVER_URL", "")+ if val == "" {+ return ""+ }+ return normalizeAPIBaseURL(val)+}++func tryResolveProfileServerURL(cmd *cobra.Command) string {profile := resolveProfile(cmd)cfg, err := cli.LoadCLIConfigForProfile(profile)if err == nil && cfg.ServerURL != "" {@@ -310,13 +332,26 @@ func resolveServerURL(cmd *cobra.Command) string {if val := tryResolveServerURL(cmd); val != "" {return val}+ fmt.Fprintln(os.Stderr, missingServerConfigMessage())+ os.Exit(1)+ return "" // unreachable+}++func missingServerConfigMessage() string {+ return fmt.Sprintf("No server configured. Run 'multica setup' first%s.", daemonPortOnlyContextHint())+}++func resolveHumanServerURL(cmd *cobra.Command) string {+ if val := tryResolveHumanServerURL(cmd); val != "" {+ return val+ }fmt.Fprintln(os.Stderr, "No server configured. Run 'multica setup' first.")os.Exit(1)return "" // unreachable}func resolveLoginTokenServerURL(cmd *cobra.Command) string {- if val := tryResolveServerURL(cmd); val != "" {+ if val := tryResolveHumanServerURL(cmd); val != "" {return val}return defaultCloudServerURL@@ -346,6 +381,23 @@ func inDaemonManagedExecutionContext() bool {return inAgentExecutionContext() || os.Getenv("MULTICA_DAEMON_PORT") != "" || hasDaemonTaskContextMarker()}+// inDaemonTaskIdentityContext reports strong evidence that the current process+// belongs to a daemon-managed task. MULTICA_DAEMON_PORT is deliberately not+// sufficient: older host/container setups may export that otherwise inert+// task hint before login or daemon startup.+func inDaemonTaskIdentityContext() bool {+ return inAgentExecutionContext() ||+ strings.TrimSpace(os.Getenv(cli.TaskConfigRootEnv)) != "" ||+ hasDaemonTaskContextMarker()+}++func daemonPortOnlyContextHint() string {+ if strings.TrimSpace(os.Getenv("MULTICA_DAEMON_PORT")) == "" || inDaemonTaskIdentityContext() {+ return ""+ }+ return "; MULTICA_DAEMON_PORT is set without task identity — if this is a host or container startup shell, remove that variable and retry"+}+// requireTaskLocalConfigRoot prevents daemon-managed subprocesses that lost// part of their injected environment from silently resolving Multica state// below the daemon owner's HOME. Commands that intentionally support task-local@@ -355,7 +407,7 @@ func requireTaskLocalConfigRoot() error {return nil}if strings.TrimSpace(os.Getenv(cli.TaskConfigRootEnv)) == "" {- return fmt.Errorf("daemon-managed task requires a task-local Multica config root in %s", cli.TaskConfigRootEnv)+ return fmt.Errorf("daemon-managed task requires a task-local Multica config root in %s%s", cli.TaskConfigRootEnv, daemonPortOnlyContextHint())}return nil}@@ -364,7 +416,7 @@ func requireTaskLocalConfigRoot() error {// set up, or operate the human-owned local daemon/profile. Task API commands// remain available with the injected mat_ token; these local commands do not.func requireHumanLocalCommand(command string) error {- if inDaemonManagedExecutionContext() {+ if inDaemonTaskIdentityContext() {return fmt.Errorf("%s is not available inside a daemon-managed task", command)}return nildiff --git a/server/cmd/multica/cmd_agent_test.go b/server/cmd/multica/cmd_agent_test.goindex 836eaaecac..503679cda0 100644--- a/server/cmd/multica/cmd_agent_test.go+++ b/server/cmd/multica/cmd_agent_test.go@@ -63,6 +63,72 @@ func chdirWithDaemonTaskMarker(t *testing.T) {})}+func TestHumanLocalCommandDistinguishesPortHintFromTaskIdentity(t *testing.T) {+ t.Chdir(t.TempDir())+ t.Setenv("MULTICA_AGENT_ID", "")+ t.Setenv("MULTICA_TASK_ID", "")+ t.Setenv(cli.TaskConfigRootEnv, "")+ t.Setenv("MULTICA_DAEMON_PORT", "20032")++ if err := requireHumanLocalCommand("login"); err != nil {+ t.Fatalf("port-only host context rejected login: %v", err)+ }++ t.Setenv(cli.TaskConfigRootEnv, filepath.Join(t.TempDir(), "task-multica"))+ if err := requireHumanLocalCommand("login"); err == nil || !strings.Contains(err.Error(), "daemon-managed task") {+ t.Fatalf("task config root did not reject login: %v", err)+ }+}++func TestHumanLocalCommandRejectsWorkdirTaskMarker(t *testing.T) {+ chdirWithDaemonTaskMarker(t)+ t.Setenv("MULTICA_AGENT_ID", "")+ t.Setenv("MULTICA_TASK_ID", "")+ t.Setenv(cli.TaskConfigRootEnv, "")+ t.Setenv("MULTICA_DAEMON_PORT", "")++ if err := requireHumanLocalCommand("daemon stop"); err == nil || !strings.Contains(err.Error(), "daemon-managed task") {+ t.Fatalf("workdir task marker did not reject daemon stop: %v", err)+ }+}++func TestHumanLocalCommandRejectsExplicitTaskIdentity(t *testing.T) {+ for _, tc := range []struct {+ name string+ envName string+ command string+ }{+ {name: "agent ID blocks setup", envName: "MULTICA_AGENT_ID", command: "setup"},+ {name: "task ID blocks daemon stop", envName: "MULTICA_TASK_ID", command: "daemon stop"},+ } {+ t.Run(tc.name, func(t *testing.T) {+ t.Chdir(t.TempDir())+ t.Setenv("MULTICA_AGENT_ID", "")+ t.Setenv("MULTICA_TASK_ID", "")+ t.Setenv(cli.TaskConfigRootEnv, "")+ t.Setenv("MULTICA_DAEMON_PORT", "")+ t.Setenv(tc.envName, "task-identity")++ if err := requireHumanLocalCommand(tc.command); err == nil || !strings.Contains(err.Error(), "daemon-managed task") {+ t.Fatalf("%s with %s was not rejected: %v", tc.command, tc.envName, err)+ }+ })+ }+}++func TestMissingServerConfigMessageExplainsPortOnlyContext(t *testing.T) {+ t.Chdir(t.TempDir())+ t.Setenv("MULTICA_AGENT_ID", "")+ t.Setenv("MULTICA_TASK_ID", "")+ t.Setenv(cli.TaskConfigRootEnv, "")+ t.Setenv("MULTICA_DAEMON_PORT", "20032")++ message := missingServerConfigMessage()+ if !strings.Contains(message, "MULTICA_DAEMON_PORT") || !strings.Contains(message, "remove") {+ t.Fatalf("missing server message = %q, want stale port recovery guidance", message)+ }+}+// TestNewAPIClient_WorkdirParentEscapeFailsClosed reproduces the confirmed// impersonation escape: a sandbox fault strips every MULTICA_* env var from// an agent subprocess, which then runs `multica` from the *parent* directory@@ -467,6 +533,7 @@ func TestNewAPIClient_AgentContextRequiresTaskToken(t *testing.T) {}func TestNewAPIClient_DaemonPortRequiresTaskToken(t *testing.T) {+ t.Chdir(t.TempDir())t.Setenv("HOME", t.TempDir())t.Setenv("MULTICA_SERVER_URL", "http://127.0.0.1:8080")t.Setenv("MULTICA_WORKSPACE_ID", "workspace-123")@@ -486,6 +553,9 @@ func TestNewAPIClient_DaemonPortRequiresTaskToken(t *testing.T) {if !strings.Contains(err.Error(), "mat_ token") {t.Fatalf("newAPIClient() error = %q, want mat_ token guidance", err.Error())}+ if !strings.Contains(err.Error(), "MULTICA_DAEMON_PORT") || !strings.Contains(err.Error(), "remove") {+ t.Fatalf("newAPIClient() error = %q, want stale port recovery guidance", err.Error())+ }}func TestNewAPIClient_WorkdirMarkerRequiresTaskToken(t *testing.T) {diff --git a/server/cmd/multica/cmd_auth.go b/server/cmd/multica/cmd_auth.goindex a7c7ae488c..195dd19092 100644--- a/server/cmd/multica/cmd_auth.go+++ b/server/cmd/multica/cmd_auth.go@@ -236,7 +236,7 @@ func detectOutboundIP(serverURL string) net.IP {}func runAuthLoginBrowser(cmd *cobra.Command) error {- serverURL := resolveServerURL(cmd)+ serverURL := resolveHumanServerURL(cmd)appURL := resolveAppURL(cmd)flagHost := callbackHostFlagValue(cmd)diff --git a/server/cmd/multica/cmd_daemon.go b/server/cmd/multica/cmd_daemon.goindex a013f38caf..81d9ee4a45 100644--- a/server/cmd/multica/cmd_daemon.go+++ b/server/cmd/multica/cmd_daemon.go@@ -1376,7 +1376,7 @@ func runDaemonStatus(cmd *cobra.Command, _ []string) error {// named-profile host look like a conflict and break the standing contract// that `daemon status` in a task reports on the daemon hosting it.var conflict *daemonProfileMismatchError- if daemonAlive(health) && !inDaemonManagedExecutionContext() {+ if daemonAlive(health) && !inDaemonTaskIdentityContext() {errors.As(daemonIdentityMismatch(health, profile, healthPort), &conflict)}@@ -1413,15 +1413,16 @@ func runDaemonStatus(cmd *cobra.Command, _ []string) error {}// daemonStatusHealthPort resolves which daemon `status` should probe. Outside a-// task that is the --profile-derived port. Inside a managed task it is the-// daemon-injected MULTICA_DAEMON_PORT and nothing else: healthPortForProfile-// hashes whatever profile name the caller passes, so deriving the port there-// would let a task report on a daemon that is not the one hosting it — and for-// a task hosted by a named-profile daemon it would silently probe the default-// daemon instead. A missing port fails closed rather than guessing.+// task that is the --profile-derived port, even when a stale+// MULTICA_DAEMON_PORT remains in the host environment. Inside a managed task it+// is the daemon-injected port and nothing else: healthPortForProfile hashes+// whatever profile name the caller passes, so deriving the port there would let+// a task report on a daemon that is not the one hosting it — and for a task+// hosted by a named-profile daemon it would silently probe the default daemon+// instead. A missing port fails closed rather than guessing.func daemonStatusHealthPort(cmd *cobra.Command) (int, error) {profile := resolveProfile(cmd)- if !inDaemonManagedExecutionContext() {+ if !inDaemonTaskIdentityContext() {return healthPortForProfile(profile), nil}if profile != "" {diff --git a/server/cmd/multica/cmd_daemon_test.go b/server/cmd/multica/cmd_daemon_test.goindex 68e602e65f..3bc1ccd2ea 100644--- a/server/cmd/multica/cmd_daemon_test.go+++ b/server/cmd/multica/cmd_daemon_test.go@@ -868,6 +868,28 @@ func TestDaemonStatusHealthPortInTaskContext(t *testing.T) {}})+ t.Run("port-only host context derives the port from the profile", func(t *testing.T) {+ t.Chdir(t.TempDir())+ clearDaemonTaskEnv(t)+ t.Setenv("MULTICA_DAEMON_PORT", strconv.Itoa(injectedPort))++ cmd := &cobra.Command{}+ cmd.Flags().String("profile", "", "")+ if err := cmd.Flags().Set("profile", "staging"); err != nil {+ t.Fatalf("set profile flag: %v", err)+ }+ got, err := daemonStatusHealthPort(cmd)+ if err != nil {+ t.Fatalf("daemonStatusHealthPort: %v", err)+ }+ if want := healthPortForProfile("staging"); got != want {+ t.Fatalf("health port = %d, want profile-derived %d", got, want)+ }+ if got == injectedPort {+ t.Fatal("port-only host context used the stale injected port")+ }+ })+t.Run("inside a task uses the injected port", func(t *testing.T) {t.Chdir(t.TempDir())clearDaemonTaskEnv(t)diff --git a/server/cmd/multica/cmd_login.go b/server/cmd/multica/cmd_login.goindex 88662ba8a1..1e23102fa1 100644--- a/server/cmd/multica/cmd_login.go+++ b/server/cmd/multica/cmd_login.go@@ -84,13 +84,23 @@ func runLogin(cmd *cobra.Command, args []string) error {}func autoWatchWorkspaces(cmd *cobra.Command) error {- serverURL := resolveServerURL(cmd)- token := resolveToken(cmd)- if token == "" {+ // runLogin has already passed the human/local command guard and saved the+ // newly authenticated profile. Read that exact profile here rather than the+ // general task-safe resolvers, which intentionally fail closed on a lone+ // MULTICA_DAEMON_PORT signal.+ profile := resolveProfile(cmd)+ cfg, err := cli.LoadCLIConfigForProfile(profile)+ if err != nil {+ return err+ }+ if cfg.Token == "" {return fmt.Errorf("not authenticated")}+ if cfg.ServerURL == "" {+ return fmt.Errorf("server URL not configured")+ }- client := cli.NewAPIClient(serverURL, "", token)+ client := cli.NewAPIClient(normalizeAPIBaseURL(cfg.ServerURL), "", cfg.Token)ctx, cancel := cli.APIContext(context.Background())defer cancel()@@ -114,12 +124,6 @@ func autoWatchWorkspaces(cmd *cobra.Command) error {}}- profile := resolveProfile(cmd)- cfg, err := cli.LoadCLIConfigForProfile(profile)- if err != nil {- return err- }-// Set default workspace if not set.if cfg.WorkspaceID == "" {cfg.WorkspaceID = workspaces[0].IDdiff --git a/server/cmd/multica/cmd_login_test.go b/server/cmd/multica/cmd_login_test.goindex fe4bcb002a..59c3860b52 100644--- a/server/cmd/multica/cmd_login_test.go+++ b/server/cmd/multica/cmd_login_test.go@@ -29,21 +29,40 @@ func TestResolveLoginTokenServerURLDefaultsToCloud(t *testing.T) {}func TestResolveLoginTokenServerURLPrefersConfiguredServer(t *testing.T) {+ t.Chdir(t.TempDir())t.Setenv("HOME", t.TempDir())t.Setenv("MULTICA_SERVER_URL", "")- if err := cli.SaveCLIConfig(cli.CLIConfig{ServerURL: "https://api.example.test/"}); err != nil {+ // A stale host/container value is not proof that this process is running+ // inside a daemon task. Login still needs the selected human profile.+ t.Setenv("MULTICA_AGENT_ID", "")+ t.Setenv("MULTICA_TASK_ID", "")+ t.Setenv(cli.TaskConfigRootEnv, "")+ t.Setenv("MULTICA_DAEMON_PORT", "20032")+ cmd := newLoginTestCmd()+ if err := cmd.Flags().Set("profile", "jcode"); err != nil {+ t.Fatalf("set profile: %v", err)+ }+ if err := cli.SaveCLIConfigForProfile(cli.CLIConfig{ServerURL: "https://api.example.test/"}, "jcode"); err != nil {t.Fatalf("SaveCLIConfig: %v", err)}- if got := resolveLoginTokenServerURL(newLoginTestCmd()); got != "https://api.example.test" {+ if got := resolveLoginTokenServerURL(cmd); got != "https://api.example.test" {t.Fatalf("resolveLoginTokenServerURL() = %q, want configured server", got)}}func TestRunLoginTokenAutoWatchesDiscoveredWorkspaces(t *testing.T) {+ t.Chdir(t.TempDir())t.Setenv("HOME", t.TempDir())t.Setenv("MULTICA_TOKEN", "")t.Setenv("MULTICA_WORKSPACE_ID", "")+ // Regression for #6779: older container setups may leave this daemon-+ // injected task hint in the host environment. It must not block the+ // explicitly human login flow or hide the profile just written by it.+ t.Setenv("MULTICA_AGENT_ID", "")+ t.Setenv("MULTICA_TASK_ID", "")+ t.Setenv(cli.TaskConfigRootEnv, "")+ t.Setenv("MULTICA_DAEMON_PORT", "20032")srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {if r.Header.Get("Authorization") != "Bearer mul_test_token" {@@ -68,7 +87,12 @@ func TestRunLoginTokenAutoWatchesDiscoveredWorkspaces(t *testing.T) {t.Setenv("MULTICA_SERVER_URL", srv.URL)cmd := newLoginTestCmd()- _ = cmd.Flags().Set("token", "mul_test_token")+ if err := cmd.Flags().Set("token", "mul_test_token"); err != nil {+ t.Fatalf("set token: %v", err)+ }+ if err := cmd.Flags().Set("profile", "jcode"); err != nil {+ t.Fatalf("set profile: %v", err)+ }stderr := captureStderr(t)err := runLogin(cmd, nil)@@ -80,7 +104,7 @@ func TestRunLoginTokenAutoWatchesDiscoveredWorkspaces(t *testing.T) {t.Fatalf("stderr = %q, want workspace discovery and daemon hint", errOut)}- cfg, err := cli.LoadCLIConfig()+ cfg, err := cli.LoadCLIConfigForProfile("jcode")if err != nil {t.Fatalf("LoadCLIConfig: %v", err)}diff --git a/server/cmd/multica/cmd_workspace.go b/server/cmd/multica/cmd_workspace.goindex c47daf8138..eebde81f22 100644--- a/server/cmd/multica/cmd_workspace.go+++ b/server/cmd/multica/cmd_workspace.go@@ -148,7 +148,7 @@ func fetchWorkspaces(ctx context.Context, cmd *cobra.Command) ([]workspaceSummarserverURL := resolveServerURL(cmd)token := resolveToken(cmd)if token == "" {- return nil, fmt.Errorf("not authenticated: run 'multica login' first")+ return nil, fmt.Errorf("not authenticated: run 'multica login' first%s", daemonPortOnlyContextHint())}client := cli.NewAPIClient(serverURL, "", token)diff --git a/server/cmd/multica/cmd_workspace_test.go b/server/cmd/multica/cmd_workspace_test.goindex 3b7c436cce..7c37453267 100644--- a/server/cmd/multica/cmd_workspace_test.go+++ b/server/cmd/multica/cmd_workspace_test.go@@ -362,6 +362,25 @@ func TestRunWorkspaceSwitchFailsClosedInTaskContext(t *testing.T) {}}+func TestFetchWorkspacesExplainsPortOnlyFailClosedContext(t *testing.T) {+ t.Chdir(t.TempDir())+ t.Setenv("HOME", t.TempDir())+ t.Setenv("MULTICA_AGENT_ID", "")+ t.Setenv("MULTICA_TASK_ID", "")+ t.Setenv(cli.TaskConfigRootEnv, "")+ t.Setenv("MULTICA_DAEMON_PORT", "20032")+ t.Setenv("MULTICA_SERVER_URL", "https://api.example.test")+ t.Setenv("MULTICA_TOKEN", "")+ if err := cli.SaveCLIConfig(cli.CLIConfig{Token: "mul_owner_pat"}); err != nil {+ t.Fatalf("seed config: %v", err)+ }++ _, err := fetchWorkspaces(t.Context(), newWorkspaceSwitchTestCmd())+ if err == nil || !strings.Contains(err.Error(), "MULTICA_DAEMON_PORT") || !strings.Contains(err.Error(), "remove") {+ t.Fatalf("fetchWorkspaces error = %v, want stale port recovery guidance", err)+ }+}+func TestResolveWorkspaceByIDOrSlug(t *testing.T) {workspaces := []workspaceSummary{{ID: "11111111-1111-1111-1111-111111111111", Name: "Alpha", Slug: "alpha"},diff --git a/server/internal/service/builtin_skills/multica-runtimes-and-repos/SKILL.md b/server/internal/service/builtin_skills/multica-runtimes-and-repos/SKILL.mdindex 975f472728..9c0e4a9a2e 100644--- a/server/internal/service/builtin_skills/multica-runtimes-and-repos/SKILL.md+++ b/server/internal/service/builtin_skills/multica-runtimes-and-repos/SKILL.md@@ -59,6 +59,8 @@ The daemon injects a task-scoped `mat_` credential for Multica API commands and- `daemon status` and `daemon disk-usage` report on the runtime hosting this task: `status` probes the daemon-injected health port, and `disk-usage` scans the daemon-injected workspaces root. Both refuse `--profile`, `disk-usage` also refuses `--all-profiles` and `--workspaces-root`, and its STATUS column stays blank because filling it would spend the Owner's credential.- Human/local profile and daemon commands — including `login`, `logout`, `setup`, `workspace switch`, local runtime profile path mutation, `daemon start` / `stop` / `restart`, `daemon logs`, and `daemon probe-runtimes` — are unavailable. `daemon stop` in particular would terminate the daemon running this task and every sibling task on it.+`MULTICA_DAEMON_PORT` alone is a weak, defense-in-depth signal for task-safe API and profile resolution, not task identity for human/local command rejection. Genuine tasks also carry `MULTICA_AGENT_ID` / `MULTICA_TASK_ID`, `MULTICA_TASK_CONFIG_ROOT`, or a daemon-managed workdir marker. When the port is the only signal, `daemon status` uses the selected host profile's derived health port; ordinary API and profile-resolving commands still fail closed. Host operators should not export `MULTICA_DAEMON_PORT`; the daemon derives its host health port from the selected profile and injects the variable into tasks itself.+The daemon still preserves the real `HOME` and XDG variables for provider tools such as `gh`, `aws`, `kubectl`, and npm. This is CLI resolution hardening, not hard filesystem confidentiality: a process under the same OS user can still open an explicitly known Owner path. Dedicated Unix users, containers, VMs, or an equivalent OS boundary are required for that stronger isolation.## Debugging an agent that did not rundiff --git a/server/internal/service/builtin_skills/multica-runtimes-and-repos/references/runtimes-and-repos-source-map.md b/server/internal/service/builtin_skills/multica-runtimes-and-repos/references/runtimes-and-repos-source-map.mdindex efdbe0af4b..2acf9219bb 100644--- a/server/internal/service/builtin_skills/multica-runtimes-and-repos/references/runtimes-and-repos-source-map.md+++ b/server/internal/service/builtin_skills/multica-runtimes-and-repos/references/runtimes-and-repos-source-map.md@@ -13,6 +13,6 @@- `server/internal/daemon/daemon.go` claims tasks, prepares workdirs, launches provider CLIs, and reports completion. It validates the task-scoped `mat_` credential, exports `MULTICA_TASK_CONFIG_ROOT`, and keeps that daemon-owned variable ahead of custom environment assembly so agents cannot override it.- `server/internal/daemon/execenv/execenv.go` creates and restores the private per-task `multica-config` directory with mode `0700`; it does not copy the daemon Owner's Multica profile into the directory.- `server/internal/cli/config.go` resolves Multica CLI profiles below `MULTICA_TASK_CONFIG_ROOT` when present while leaving ordinary `HOME`-based resolution unchanged outside tasks.-- `server/cmd/multica/cmd_agent.go`, `cmd_config.go`, `cmd_auth.go`, `cmd_login.go`, `cmd_setup.go`, `cmd_workspace.go`, `cmd_runtime_profile.go`, and `cmd_daemon.go` enforce the task boundary: API calls require task authentication, task-local config commands fail closed without their root, auth status hides credential material, and human/local profile or daemon commands reject managed task context.-- `cmd_daemon.go` scopes the two read-only diagnostics instead of rejecting them: `daemonStatusHealthPort` takes the injected `MULTICA_DAEMON_PORT` (never the `--profile` hash, which would report an unrelated daemon), `resolveDiskUsageRoot` takes `daemon.TaskWorkspacesRootEnv` (never the `$HOME`-derived default), `checkTaskDiskUsageScope` rejects the flags that widen the scan past this daemon, and the STATUS column plus the other-roots hint are skipped because both reach for Owner profile state.+- `server/cmd/multica/cmd_agent.go`, `cmd_config.go`, `cmd_auth.go`, `cmd_login.go`, `cmd_setup.go`, `cmd_workspace.go`, `cmd_runtime_profile.go`, and `cmd_daemon.go` enforce the task boundary: API calls require task authentication, task-local config commands fail closed without their root, auth status hides credential material, and human/local profile or daemon commands reject strong managed-task identity (`MULTICA_AGENT_ID` / `MULTICA_TASK_ID`, `MULTICA_TASK_CONFIG_ROOT`, or the workdir marker). `MULTICA_DAEMON_PORT` remains a weak fail-closed signal for general API/profile resolution but is not sufficient by itself to reject human/local commands, because older host/container setups may leave it in the startup environment; guarded login paths explicitly resolve and update the human profile.+- `cmd_daemon.go` scopes the two read-only diagnostics instead of rejecting them: with strong task identity, `daemonStatusHealthPort` takes the injected `MULTICA_DAEMON_PORT` (never the `--profile` hash, which would report an unrelated daemon); when that port is the only signal in a host environment, it uses the selected profile's derived port. `resolveDiskUsageRoot` takes `daemon.TaskWorkspacesRootEnv` (never the `$HOME`-derived default), `checkTaskDiskUsageScope` rejects the flags that widen the scan past this daemon, and the STATUS column plus the other-roots hint are skipped because both reach for Owner profile state.- `server/internal/daemon/execenv/runtime_config.go` injects task/project/repo context into agent workdirs.