Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

fix(daemon): preserve issue status catalog wire compatibility (#8378)

Jiayuan Zhangaac85ab263a6
diff --git a/server/internal/daemon/execenv/runtime_config_issue_status_legacy_test.go b/server/internal/daemon/execenv/runtime_config_issue_status_legacy_test.go
new file mode 100644
index 0000000000..d553da5d39
--- /dev/null
+++ b/server/internal/daemon/execenv/runtime_config_issue_status_legacy_test.go
@@ -0,0 +1,54 @@
+package execenv
+
+import (
+ "fmt"
+ "strings"
+)
+
+// Frozen status renderer from a9e82c797, before four lifecycle categories.
+// Only the function and category-order identifiers are renamed. Keep the old
+// bucketing logic independent of production ParseCategory and category order:
+// testing only the latest renderer would miss new-server/old-daemon failures.
+var legacyStatusCategoryOrder = []string{"backlog", "todo", "in_progress", "in_review", "done", "blocked", "cancelled"}
+
+func writeLegacyIssueStatusCommand(b *strings.Builder, ctx TaskContextForEnv) {
+ if len(ctx.IssueStatuses) == 0 {
+ b.WriteString("- `multica issue status <id> <status> [--no-start]` — flip status (todo / in_progress / in_review / done / blocked / backlog / cancelled).\n")
+ return
+ }
+ byCategory := make(map[string][]IssueStatusForEnv, len(legacyStatusCategoryOrder))
+ for _, s := range ctx.IssueStatuses {
+ if sanitizeBriefCodeToken(s.Key) == "" {
+ continue
+ }
+ byCategory[s.Category] = append(byCategory[s.Category], s)
+ }
+ b.WriteString("- `multica issue status <id> <status> [--no-start]` — flip status. This workspace's statuses by category — a custom status inherits its category's platform behavior in full:\n")
+ builtInOnly := make([]string, 0, len(legacyStatusCategoryOrder))
+ for _, category := range legacyStatusCategoryOrder {
+ customs := byCategory[category]
+ if len(customs) == 0 {
+ builtInOnly = append(builtInOnly, "`"+category+"`")
+ continue
+ }
+ fmt.Fprintf(b, " - `%s`: `%s` (built-in)", category, category)
+ for _, s := range customs {
+ name := sanitizeNameForBriefMarkdown(s.Name)
+ desc := sanitizeNameForBriefMarkdown(s.Description)
+ fmt.Fprintf(b, ", `%s`", sanitizeBriefCodeToken(s.Key))
+ switch {
+ case name != "" && desc != "":
+ fmt.Fprintf(b, " (%s — %s)", name, desc)
+ case name != "":
+ fmt.Fprintf(b, " (%s)", name)
+ }
+ }
+ b.WriteString("\n")
+ }
+ if len(builtInOnly) > 0 {
+ fmt.Fprintf(b, " - Built-in key only: %s.\n", strings.Join(builtInOnly, ", "))
+ }
+ if ctx.IssueStatusesOmitted > 0 {
+ fmt.Fprintf(b, " - …and %d more custom statuses not listed; an invalid status errors with the full valid list.\n", ctx.IssueStatusesOmitted)
+ }
+}
diff --git a/server/internal/daemon/execenv/runtime_config_issue_status_test.go b/server/internal/daemon/execenv/runtime_config_issue_status_test.go
index 10a8e46d47..907654e76a 100644
--- a/server/internal/daemon/execenv/runtime_config_issue_status_test.go
+++ b/server/internal/daemon/execenv/runtime_config_issue_status_test.go
@@ -3,6 +3,8 @@ package execenv
import (
"strings"
"testing"
+
+ "github.com/multica-ai/multica/server/internal/issuestatus"
)
// legacyStatusLine is the pre-MUL-6460 status bullet. Workspaces without
@@ -59,7 +61,7 @@ func TestBriefStatusCatalogRendered(t *testing.T) {
t.Errorf("catalog brief missing %q\n---\n%s", want, out)
}
}
- if strings.Contains(out, "more custom statuses not listed") {
+ if strings.Contains(out, "custom statuses not listed") {
t.Errorf("no truncation disclosure may appear when nothing was omitted")
}
}
@@ -92,3 +94,91 @@ func TestBriefStatusCatalogSanitizesAndDiscloses(t *testing.T) {
t.Errorf("entry with an invalid key must be dropped entirely\n---\n%s", out)
}
}
+
+func TestBriefStatusCatalogMixedVersions(t *testing.T) {
+ t.Parallel()
+ stored := []IssueStatusForEnv{
+ {Key: "later", Name: "Later", Category: "unstarted", Description: "Deferred on purpose"},
+ {Key: "awaiting_response", Name: "Awaiting response", Category: "started", Description: "Waiting for a reply"},
+ {Key: "accepted", Name: "Accepted", Category: "done", Description: "Review complete"},
+ {Key: "withdrawn", Name: "Withdrawn", Category: "closed", Description: "No longer needed"},
+ }
+ wire := append([]IssueStatusForEnv(nil), stored...)
+ for i := range wire {
+ wire[i].Category = issuestatus.WireCategory(wire[i].Key, wire[i].Category)
+ }
+ for _, tc := range []struct {
+ name string
+ entries []IssueStatusForEnv
+ render func(*strings.Builder, TaskContextForEnv)
+ legacyRaw bool
+ }{
+ {"stored categories with old daemon reproduce omission", stored, writeLegacyIssueStatusCommand, true},
+ {"stored categories with new daemon", stored, writeIssueStatusCommand, false},
+ {"wire categories with old daemon", wire, writeLegacyIssueStatusCommand, false},
+ {"wire categories with new daemon", wire, writeIssueStatusCommand, false},
+ } {
+ t.Run(tc.name, func(t *testing.T) {
+ var b strings.Builder
+ tc.render(&b, TaskContextForEnv{IssueStatuses: tc.entries})
+ for _, entry := range stored {
+ want := "`" + entry.Key + "` (" + entry.Name + " — " + entry.Description + ")"
+ count := 1
+ if tc.legacyRaw && entry.Category != "done" {
+ count = 0
+ }
+ if got := strings.Count(b.String(), want); got != count {
+ t.Errorf("%q occurs %d times, want %d in:\n%s", want, got, count, b.String())
+ }
+ }
+ })
+ }
+ var storedBrief, wireBrief strings.Builder
+ writeIssueStatusCommand(&storedBrief, TaskContextForEnv{IssueStatuses: stored})
+ writeIssueStatusCommand(&wireBrief, TaskContextForEnv{IssueStatuses: wire})
+ if storedBrief.String() != wireBrief.String() {
+ t.Errorf("wire mapping must preserve the new daemon's grouping and output")
+ }
+ // Previously emitted wire categories must all remain readable, including
+ // the three spellings not produced for customs by today's WireCategory.
+ for _, category := range legacyStatusCategoryOrder {
+ var b strings.Builder
+ writeIssueStatusCommand(&b, TaskContextForEnv{IssueStatuses: []IssueStatusForEnv{
+ {Key: "custom", Name: "Custom", Category: category, Description: "Legacy payload"},
+ }})
+ if strings.Count(b.String(), "`custom` (Custom — Legacy payload)") != 1 {
+ t.Errorf("legacy category %s not rendered exactly once: %s", category, b.String())
+ }
+ }
+}
+
+func TestBriefStatusCatalogUnknownCategoriesDisclosed(t *testing.T) {
+ t.Parallel()
+ for _, onlyUnknown := range []bool{false, true} {
+ entries := []IssueStatusForEnv{
+ {Key: "future_one", Name: "DO_NOT_RENDER_NAME", Category: "future\n# INJECT", Description: "DO_NOT_RENDER_DESCRIPTION"},
+ {Key: "future_two", Name: "Hidden", Category: ""},
+ {Key: "bad key!", Name: "INVALID_KEY_NAME", Category: "future"},
+ }
+ if !onlyUnknown {
+ entries = append(entries, IssueStatusForEnv{Key: "qa", Name: "QA *bold*\n# Heading", Category: "started", Description: "line1\nline2 [x]"})
+ }
+ out := buildMetaSkillContent("claude", TaskContextForEnv{IssueStatuses: entries, IssueStatusesOmitted: 4})
+ for _, want := range []string{
+ " - 2 custom statuses not listed because this daemon does not recognize their categories; upgrade the daemon to display them.\n",
+ " - …and 4 more custom statuses not listed; an invalid status errors with the full valid list.\n",
+ } {
+ if !strings.Contains(out, want) {
+ t.Errorf("missing %q in:\n%s", want, out)
+ }
+ }
+ for _, unwanted := range []string{"future_one", "future_two", "INJECT", "DO_NOT_RENDER", "INVALID_KEY_NAME"} {
+ if strings.Contains(out, unwanted) {
+ t.Errorf("unknown/invalid entry leaked %q", unwanted)
+ }
+ }
+ if !onlyUnknown && !strings.Contains(out, "`qa` (QA \\*bold\\* # Heading — line1 line2 \\[x\\])") {
+ t.Errorf("known status must retain sanitization: %s", out)
+ }
+ }
+}
diff --git a/server/internal/daemon/execenv/runtime_config_sections.go b/server/internal/daemon/execenv/runtime_config_sections.go
index 97e036dc42..6c17aba3fe 100644
--- a/server/internal/daemon/execenv/runtime_config_sections.go
+++ b/server/internal/daemon/execenv/runtime_config_sections.go
@@ -319,12 +319,14 @@ func writeIssueStatusCommand(b *strings.Builder, ctx TaskContextForEnv) {
return
}
byCategory := make(map[string][]IssueStatusForEnv, len(briefStatusCategoryOrder))
+ unknownCategories := 0
for _, s := range ctx.IssueStatuses {
if sanitizeBriefCodeToken(s.Key) == "" {
continue
}
category, ok := issuestatus.ParseCategory(s.Category)
if !ok {
+ unknownCategories++
continue
}
byCategory[category] = append(byCategory[category], s)
@@ -346,6 +348,11 @@ func writeIssueStatusCommand(b *strings.Builder, ctx TaskContextForEnv) {
}
b.WriteString("\n")
}
+ // Count only otherwise renderable entries, without echoing untrusted
+ // category values or conflating these omissions with the server's cap.
+ if unknownCategories > 0 {
+ fmt.Fprintf(b, " - %d custom statuses not listed because this daemon does not recognize their categories; upgrade the daemon to display them.\n", unknownCategories)
+ }
if ctx.IssueStatusesOmitted > 0 {
fmt.Fprintf(b, " - …and %d more custom statuses not listed; an invalid status errors with the full valid list.\n", ctx.IssueStatusesOmitted)
}
diff --git a/server/internal/handler/agent.go b/server/internal/handler/agent.go
index 78a971edb2..e666a753c0 100644
--- a/server/internal/handler/agent.go
+++ b/server/internal/handler/agent.go
@@ -334,7 +334,8 @@ const taskIssueStatusCap = 30
// TaskIssueStatusData is one active CUSTOM workspace status on the claim wire
// (MUL-6460). Only the fields an agent needs to choose and write the status
// travel: key is the CLI argument, name is what users call it in instructions,
-// category anchors the inherited platform behavior, and description is the
+// category uses the legacy wire enum for installed daemons (presentation only,
+// not inherited platform behavior), and description is the
// admin's "when to use me" guidance — the disambiguator when a category holds
// more than one status. Color/position/id stay off the wire: they carry no
// behavioral meaning for an agent, and the server already emits entries in
diff --git a/server/internal/handler/daemon.go b/server/internal/handler/daemon.go
index d2ec251b3c..9e5a0ceb83 100644
--- a/server/internal/handler/daemon.go
+++ b/server/internal/handler/daemon.go
@@ -3342,10 +3342,11 @@ func (h *Handler) buildClaimedTaskResponse(r *http.Request, task *db.AgentTaskQu
resp.IssueStatusesOmitted++
continue
}
+ // Older daemons only render the seven legacy category values.
resp.IssueStatuses = append(resp.IssueStatuses, TaskIssueStatusData{
Key: entry.Key,
Name: entry.Name,
- Category: entry.Category,
+ Category: issuestatus.WireCategory(entry.Key, entry.Category),
Description: entry.Description,
})
}
diff --git a/server/internal/handler/daemon_claim_issue_status_test.go b/server/internal/handler/daemon_claim_issue_status_test.go
index d3fc97866a..40ef93a8db 100644
--- a/server/internal/handler/daemon_claim_issue_status_test.go
+++ b/server/internal/handler/daemon_claim_issue_status_test.go
@@ -2,7 +2,9 @@ package handler
import (
"context"
+ "fmt"
"net/http"
+ "slices"
"testing"
"github.com/multica-ai/multica/server/internal/testutil"
@@ -22,7 +24,17 @@ func TestClaimTaskByRuntime_PopulatesIssueStatusCatalog(t *testing.T) {
ctx := context.Background()
createTestCustomStatus(t, "rework", "todo")
dbfx.Exec(t, `UPDATE issue_status SET name = 'Rework', description = 'Sent back by review' WHERE workspace_id = $1 AND key = 'rework'`, testWorkspaceID)
- createTestCustomStatus(t, "later", "backlog")
+ createTestCustomStatus(t, "later", "unstarted")
+ createTestCustomStatus(t, "awaiting_response", "started")
+ createTestCustomStatus(t, "accepted", "done")
+ createTestCustomStatus(t, "withdrawn", "closed")
+ dbfx.Exec(t, `UPDATE issue_status SET description = 'Custom guidance' WHERE workspace_id = $1 AND key IN ('awaiting_response', 'accepted', 'withdrawn')`, testWorkspaceID)
+ // A different workspace's catalog must never enter this claim.
+ otherWorkspace := dbfx.Workspace(t, "Other catalog", "other-claim-catalog")
+ dbfx.Insert(t, "issue_status", testutil.Cols{
+ "workspace_id": otherWorkspace, "key": "private_status", "name": "Private status",
+ "category": "started", "description": "Other workspace only", "color": "#123456",
+ })
archived := createTestCustomStatus(t, "old_qa", "in_review")
dbfx.Exec(t, `UPDATE issue_status SET archived_at = now() WHERE id = $1`, archived.ID)
@@ -54,16 +66,24 @@ func TestClaimTaskByRuntime_PopulatesIssueStatusCatalog(t *testing.T) {
if resp.Task.ID != taskID {
t.Fatalf("claimed task id = %s, want %s", resp.Task.ID, taskID)
}
- if got := len(resp.Task.IssueStatuses); got != 2 {
- t.Fatalf("issue_statuses count = %d, want 2 (active customs only): %+v", got, resp.Task.IssueStatuses)
+ if got := len(resp.Task.IssueStatuses); got != 5 {
+ t.Fatalf("issue_statuses count = %d, want 5 (active customs in this workspace only): %+v", got, resp.Task.IssueStatuses)
}
// Both statuses share unstarted; insertion position determines their order.
- if resp.Task.IssueStatuses[1].Key != "later" || resp.Task.IssueStatuses[1].Category != "unstarted" {
- t.Errorf("issue_statuses[1] = %+v, want key=later category=unstarted", resp.Task.IssueStatuses[1])
+ if resp.Task.IssueStatuses[1].Key != "later" || resp.Task.IssueStatuses[1].Category != "todo" {
+ t.Errorf("issue_statuses[1] = %+v, want key=later category=todo", resp.Task.IssueStatuses[1])
}
- second := resp.Task.IssueStatuses[0]
- if second.Key != "rework" || second.Category != "unstarted" || second.Name != "Rework" || second.Description != "Sent back by review" {
- t.Errorf("issue_statuses[1] = %+v, want the full rework entry (key/name/category/description)", second)
+ first := resp.Task.IssueStatuses[0]
+ if first.Key != "rework" || first.Category != "todo" || first.Name != "Rework" || first.Description != "Sent back by review" {
+ t.Errorf("issue_statuses[0] = %+v, want the full rework entry (key/name/category/description)", first)
+ }
+ for i, want := range []struct{ key, category string }{
+ {"awaiting_response", "in_progress"}, {"accepted", "done"}, {"withdrawn", "cancelled"},
+ } {
+ got := resp.Task.IssueStatuses[i+2]
+ if got.Key != want.key || got.Name != want.key || got.Category != want.category || got.Description != "Custom guidance" {
+ t.Errorf("issue_statuses[%d] = %+v, want key/name=%s category=%s", i+2, got, want.key, want.category)
+ }
}
if resp.Task.IssueStatusesOmitted != 0 {
t.Errorf("issue_statuses_omitted = %d, want 0 under the cap", resp.Task.IssueStatusesOmitted)
@@ -105,3 +125,50 @@ func TestClaimTaskByRuntime_IssueStatusCatalogAbsentWithoutCustoms(t *testing.T)
t.Errorf("issue_statuses_omitted must be absent when nothing was omitted")
}
}
+
+// The claim cap counts active customs only, preserves catalog order, and
+// discloses server truncation independently of daemon rendering omissions.
+func TestClaimTaskByRuntime_IssueStatusCatalogCap(t *testing.T) {
+ if testHandler == nil || testPool == nil {
+ t.Skip("database not available")
+ }
+ ctx := context.Background()
+ for i := 0; i < 34; i++ {
+ createTestCustomStatus(t, fmt.Sprintf("custom_%02d", i), "started")
+ }
+ archived := createTestCustomStatus(t, "archived_custom", "started")
+ dbfx.Exec(t, `UPDATE issue_status SET archived_at = now() WHERE id = $1`, archived.ID)
+ runtimeID := createClaimReclaimRuntime(t, ctx, "Capped catalog runtime")
+ agentID, issueID := createClaimReclaimAgentAndIssue(t, ctx, runtimeID, "Capped catalog agent")
+ taskID := createDispatchedClaimFixtureTask(t, ctx, agentID, runtimeID, issueID, "120 seconds", false)
+ req := newDaemonTokenRequest("POST", "/api/daemon/runtimes/"+runtimeID+"/tasks/claim", nil, testWorkspaceID, "capped-catalog-claim")
+ req = withURLParam(req, "runtimeId", runtimeID)
+ var resp struct {
+ Task *struct {
+ ID string `json:"id"`
+ IssueStatuses []TaskIssueStatusData `json:"issue_statuses"`
+ IssueStatusesOmitted int `json:"issue_statuses_omitted"`
+ } `json:"task"`
+ }
+ testutil.Call(t, testHandler.ClaimTaskByRuntime, req).Want(http.StatusOK).JSON(&resp)
+ if resp.Task == nil || resp.Task.ID != taskID {
+ t.Fatalf("expected task %s, got %+v", taskID, resp.Task)
+ }
+ if len(resp.Task.IssueStatuses) != 30 || resp.Task.IssueStatusesOmitted != 4 {
+ t.Fatalf("want 30 entries and 4 omitted, got %+v", resp.Task)
+ }
+ keys := make([]string, 0, 30)
+ for _, entry := range resp.Task.IssueStatuses {
+ if entry.Category != "in_progress" {
+ t.Errorf("category = %q, want in_progress", entry.Category)
+ }
+ keys = append(keys, entry.Key)
+ }
+ want := make([]string, 30)
+ for i := range want {
+ want[i] = fmt.Sprintf("custom_%02d", i)
+ }
+ if !slices.Equal(keys, want) {
+ t.Errorf("catalog keys = %v, want %v", keys, want)
+ }
+}
diff --git a/server/internal/service/builtin_skills/multica-platform/references/issues.md b/server/internal/service/builtin_skills/multica-platform/references/issues.md
index 058fec7bfd..2c5ca1cf22 100644
--- a/server/internal/service/builtin_skills/multica-platform/references/issues.md
+++ b/server/internal/service/builtin_skills/multica-platform/references/issues.md
@@ -237,6 +237,15 @@ Backlog parking, In Review completion, Blocked failure, or In Progress recovery.
Use the built-in key when its special behavior is needed. Built-in definitions
cannot be edited or archived.
+Task claims send custom status categories using the legacy wire enum so older
+daemons can display the catalog: unstarted → todo, started → in_progress,
+done → done, closed → cancelled. This presentation mapping does not restore
+built-in automation behavior. Older daemon instructions may still describe
+inheritance; upgrading the daemon is required for current behavior guidance.
+If the brief reports unrecognized categories, upgrade the daemon to display
+those entries. That omission count is separate from the server's 30-custom-status
+catalog limit.
+
Archive a custom status only after moving every issue off it, including
completed/canceled issues. An occupied status returns HTTP 409 with code
`issue_status_in_use` and `issue_count`; it remains active. Use Settings >