Files
multica/server/internal
Eve 4600e725e3 feat(daemon): log runtime brief mode + path on every task start (MUL-3560)
Yushen asked how to confirm which prompt template a task is given —
slim or legacy — once staging starts opting into `runtime_brief_slim`.
Two verification paths now exist:

1. File inspection (works today): the rendered brief lives in
   {workDir}/CLAUDE.md (claude/codebuddy), AGENTS.md (codex /
   copilot / opencode / openclaw / hermes / pi / cursor / kimi /
   kiro / qoder / antigravity), or GEMINI.md (gemini). Operators
   can `cat` the file to see the exact bytes the agent will load.

2. Structured daemon log (this PR): the daemon now logs one
   `execenv: runtime brief written` line per task start, carrying
   provider, brief_path (so you don't have to guess the filename),
   brief_chars (rendered rune count), and brief_mode (`slim` or
   `legacy`). Dashboards / log queries can filter by brief_mode to
   confirm the staging rollout is actually hitting the slim path
   without grepping every workdir.

What's in this PR:

- `internal/daemon/execenv/observability.go` (new): public
  `RuntimeConfigPath(workDir, provider) string` (thin wrapper
  around the private mapping) and `BriefMode() string` ("slim" or
  "legacy", nil-safe via the feature flag service).
- `internal/daemon/daemon.go`: one `taskLog.Info(...)` after
  `InjectRuntimeConfig` returns successfully. Failure path
  unchanged (still warns).
- `internal/daemon/execenv/observability_test.go` (new):
  TestRuntimeConfigPath pins the full 15-provider mapping;
  TestBriefMode verifies the label flips with the flag and that
  a nil service returns "legacy" rather than panicking.

Sample log line (staging, flag on, codex provider):

    INFO execenv: runtime brief written task=abc12345
        provider=codex
        brief_path=/var/multica/workspaces/.../task-abc/workdir/AGENTS.md
        brief_chars=11868
        brief_mode=slim

Same line on prod (flag off):

    INFO execenv: runtime brief written task=abc12345
        provider=codex
        brief_path=/var/multica/workspaces/.../task-abc/workdir/AGENTS.md
        brief_chars=19567
        brief_mode=legacy

Verification:

- go vet ./internal/daemon/...                                   ok
- go test ./internal/daemon/...                                  ok
- TestRuntimeConfigPath pins all 15 providers (including the
  fall-through to "" for unknown).
- TestBriefMode verifies both flag states + nil-safety.

Risk: very low. Adds one INFO log per task start (already a low-
frequency event by daemon standards), no behaviour change anywhere
in the brief generation or task execution path.

Co-authored-by: multica-agent <github@multica.ai>
2026-06-24 14:29:04 +08:00
..