Files
multica/server
Eve 38aa864e70 MUL-3560: refactor buildMetaSkillContent into kind-driven dispatcher
This is the structural prep PR for the runtime-brief diet roadmap on
MUL-3560 — split out from the per-section compression work so the
refactor risk and the content-gating risk land separately.

Output is byte-for-byte identical to the pre-refactor monolithic
builder for every existing test fixture. All existing tests pass
unchanged. The follow-up PR (0.6) will start gating sections per the
Section × Kind matrix from Eve's design comment on MUL-3560 (drop
Mentions / Comment Formatting / Issue Metadata / Sub-issue out of
quick-create, drop Comment Formatting / Mentions / Attachments out of
autopilot and chat, etc.), with negative assertions added alongside
each removal so each kind's brief contract becomes machine-checked.

What changed:

- runtime_config_kind.go (new): taskKind enum + classifyTask helper.
  Five kinds, mutually exclusive in practice; the documented
  precedence rule keeps the tiebreak deterministic even if a future
  caller breaks the mutex by accident. hasIssueContext is the
  predicate Issue Metadata and Sub-issue Creation gate on.
- runtime_config_sections.go (new): every section of the brief is
  extracted into its own writeXxx helper, preserving byte sequences
  exactly. Helpers with internal conditions keep those conditions;
  helpers the dispatcher always wants to call are unconditional.
- runtime_config.go: buildMetaSkillContent collapses from a
  ~450-line monolith to a ~70-line dispatcher — prelude, conditional
  context sections, a 5-way kind switch over Workflow bodies, and
  trailing sections. The matrix of "which kind gets which section"
  is now readable in one screen.
- runtime_config_kind_test.go (new): TestClassifyTask covers all 5
  kinds plus tiebreak cases; TestTaskKindHasIssueContext pins the
  predicate semantics; TestBuildMetaSkillContentKindMatrix is the
  structural canary that locks today's per-kind section set so any
  later PR that drops a section from a kind must update its
  expectations in lockstep.

Verification:

- go build ./...                                                      ok
- go vet ./internal/daemon/...                                        ok
- go test ./internal/daemon/... ./internal/handler/...                ok
- go test ./internal/daemon/execenv -run TestClassifyTask -v         pass
- go test ./internal/daemon/execenv -run TestTaskKindHasIssueContext pass
- go test ./internal/daemon/execenv -run TestBuildMetaSkillContent   pass

No production behaviour change in this PR. No new logging, no new
char-bucket fields — those are in PR #4439 and compose cleanly with
this refactor.

Co-authored-by: multica-agent <github@multica.ai>
2026-06-23 14:33:42 +08:00
..