Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
fix(execenv): fold redundant metadata-list read into the issue-get step (#7016) (#7042)
Bohan Jiang8b1acfd19ea3
diff --git a/server/internal/daemon/execenv/execenv_test.go b/server/internal/daemon/execenv/execenv_test.goindex 2f1432de45..a8221de4a8 100644--- a/server/internal/daemon/execenv/execenv_test.go+++ b/server/internal/daemon/execenv/execenv_test.go@@ -5662,9 +5662,9 @@ func TestInjectRuntimeConfigCatchUpScansRootsFirst(t *testing.T) {// TestInjectRuntimeConfigIssueMetadataSectionScope locks in MUL-2017:// the `## Issue Metadata` section (semantic guide + recommended keys +-// pin/clear rules) and the `metadata list` workflow step are emitted only-// when the task carries a real issue id (comment-triggered or-// assignment-triggered). Chat / quick-create / run-only autopilot don't+// pin/clear rules) and the metadata-read guidance on the issue-get step+// are emitted only when the task carries a real issue id (comment-triggered+// or assignment-triggered). Chat / quick-create / run-only autopilot don't// have an issue, so injecting the section there would just guarantee a// failed CLI call on every entry. The discovery line in Available// Commands → Core is global and must appear everywhere so that the agent@@ -5737,9 +5737,10 @@ func TestInjectRuntimeConfigIssueMetadataSectionScope(t *testing.T) {// each entry must appear in the workflow numbered list to prove// the metadata read step is wired in.workflowStepPresent []string- // workflowAbsent is matched in non-issue contexts to guarantee- // no metadata-list step leaked into a workflow that has no- // issue id.+ // workflowAbsent lists workflow substrings that must NOT appear:+ // in non-issue contexts, any metadata-list step that leaked into+ // a workflow with no issue id; in issue contexts, the standalone+ // metadata-list read step retired by #7016.workflowAbsent []stringwant wantSection}{@@ -5752,11 +5753,13 @@ func TestInjectRuntimeConfigIssueMetadataSectionScope(t *testing.T) {provider: "claude",filename: "CLAUDE.md",workflowStepPresent: []string{- "Read the metadata bag (`multica issue metadata list`)",- // Platform failure semantics, not tool mechanics: a failed- // metadata read must never block the main task (MUL-5442- // stage-1 review).- "CLI failures are normal",+ // #7016: the standalone `metadata list` read was folded+ // into the issue-get step — `issue get` already returns+ // the metadata bag, so the entry read costs zero extra+ // calls. The old step's "CLI failures are normal"+ // best-effort clause retired with it: when `issue get`+ // itself fails, there is no bootstrap to unblock.+ "its JSON already carries the issue's `metadata` bag",// Both steps point at the section instead of restating its// rules (MUL-5442); the entry step names what to look for,// the exit step names the write bar.@@ -5769,6 +5772,10 @@ func TestInjectRuntimeConfigIssueMetadataSectionScope(t *testing.T) {"multica issue metadata delete","Before exiting",},+ workflowAbsent: []string{+ // The redundant standalone read must not come back (#7016).+ "Read the metadata bag (`multica issue metadata list`)",+ },want: withSection,},{@@ -5777,13 +5784,16 @@ func TestInjectRuntimeConfigIssueMetadataSectionScope(t *testing.T) {provider: "claude",filename: "CLAUDE.md",workflowStepPresent: []string{- "Read the metadata bag (`multica issue metadata list`)",+ "its JSON already carries the issue's `metadata` bag","What to look for: `## Issue Metadata`","the bar in `## Issue Metadata`","multica issue metadata set","multica issue metadata delete","Before exiting",},+ workflowAbsent: []string{+ "Read the metadata bag (`multica issue metadata list`)",+ },want: withSection,},{@@ -5897,8 +5907,12 @@ func TestInjectRuntimeConfigIssueMetadataCodexFormattingUnchanged(t *testing.T)if !strings.Contains(s, "## Issue Metadata") {t.Fatalf("Issue Metadata section missing\n---\n%s", s)}- if !strings.Contains(s, "Read the metadata bag (`multica issue metadata list`)") {- t.Fatalf("metadata list step missing\n---\n%s", s)+ if !strings.Contains(s, "its JSON already carries the issue's `metadata` bag") {+ t.Fatalf("metadata-in-issue-get guidance missing\n---\n%s", s)+ }+ // The standalone read step retired by #7016 must not reappear.+ if strings.Contains(s, "Read the metadata bag (`multica issue metadata list`)") {+ t.Fatalf("redundant metadata list step present\n---\n%s", s)}// ...AND the post-#4182 file-first rule is still emitted on Linux.if !strings.Contains(s, "always write the comment body to a UTF-8 file with your file-write tool first, then post it with `--content-file <path>`") {diff --git a/server/internal/daemon/execenv/reply_instructions_test.go b/server/internal/daemon/execenv/reply_instructions_test.goindex 8c9ee47b93..3d60eff4b5 100644--- a/server/internal/daemon/execenv/reply_instructions_test.go+++ b/server/internal/daemon/execenv/reply_instructions_test.go@@ -209,7 +209,7 @@ func TestInjectRuntimeConfigKeepsTriggerCommentOutOfBrief(t *testing.T) {// a further compression that drops the one-block rule or the// no-mode-line fallback must fail here (stage-1 review)."**Turn mode.**",- "Steps 1–6 are shared",+ "Steps 1–5 are shared","apply exactly one mode block","differ on issue status",// The full fallback MAPPING, not its halves: "No mode line" and@@ -268,7 +268,7 @@ func TestWindowsCommentReplyInstructionsHaveNoStdin(t *testing.T) {// "post your final results" step literally would pipe its final comment through// PowerShell and drop non-ASCII bytes (#2198 / #2236 / #2376). The OS-aware// ## Comment Formatting section (file-only on Windows) is the single source of-// truth; the Available Commands entry and step 6 must defer to it, not re-offer+// truth; the Available Commands entry and step 5 must defer to it, not re-offer// stdin. The flag synopsis may still *list* `--content-stdin` as available.//// Not parallel: mutates the package-level runtimeGOOS.diff --git a/server/internal/daemon/execenv/runtime_config_sections.go b/server/internal/daemon/execenv/runtime_config_sections.goindex 10bc78100d..4b1d009b64 100644--- a/server/internal/daemon/execenv/runtime_config_sections.go+++ b/server/internal/daemon/execenv/runtime_config_sections.go@@ -384,7 +384,7 @@ func writeIssueMetadata(b *strings.Builder) {// workflow below" guardrail. Caller gates on kind == kindIssue.//// This section owns the single enumeration of the actions Agent Identity can-// forbid. It and workflow step 4 were added together in #3802 and each carried+// forbid. It and workflow step 3 were added together in #3802 and each carried// its own list; the lists then disagreed — this one named status changes, the// step named issue create/update and delegation, and neither contained the// other. MUL-5442 merges them here so adding an action type is a one-place@@ -565,22 +565,21 @@ func writeWorkflowAutopilot(b *strings.Builder, ctx TaskContextForEnv) {// it here does move brief bytes when the same agent runs leader one turn and// worker the next. Owner-accepted tradeoff; decision recorded in MUL-5811.func writeWorkflowIssue(b *strings.Builder, ctx TaskContextForEnv) {- b.WriteString("**Turn mode.** The per-turn user message names this run's mode on a line of its own: `Turn mode: Reply.` (respond to the comment that message carries — it brings the triggering comment's id and your `--parent` value) or `Turn mode: Ownership.` (an assignment or status change started this run). Steps 1–6 are shared; then **apply exactly one mode block, the one the user message named** — they differ on issue status. No mode line → Reply mode, do not change the issue status.\n\n")+ b.WriteString("**Turn mode.** The per-turn user message names this run's mode on a line of its own: `Turn mode: Reply.` (respond to the comment that message carries — it brings the triggering comment's id and your `--parent` value) or `Turn mode: Ownership.` (an assignment or status change started this run). Steps 1–5 are shared; then **apply exactly one mode block, the one the user message named** — they differ on issue status. No mode line → Reply mode, do not change the issue status.\n\n")- b.WriteString("**Steps 1–6 — both modes** (the per-turn user message carries this issue's real id and ready-to-run context-read commands; assemble other calls from `## Available Commands`)\n\n")- b.WriteString("1. Read the issue (`multica issue get`) to understand the context.\n")- b.WriteString("2. Read the metadata bag (`multica issue metadata list`) — best-effort, empty `{}` and CLI failures are normal. What to look for: `## Issue Metadata`.\n")- b.WriteString("3. Catch up on the comment history — this is mandatory, not optional — in two bounded reads, never one bulk pull: scan every thread cheaply (`--roots-only --summary --compact`), then expand only the threads that matter (`--thread <id> --tail 30 --compact`). Earlier comments often carry context the issue body lacks. Skipping this step is the most common cause of agents acting on stale or incomplete instructions — so always run the scan, even when the trigger looks self-contained. In Reply mode the per-turn user message names the thread to expand first; the scan is how you decide whether any OTHER thread is also relevant.\n")- b.WriteString("4. Complete the task within your Agent Identity boundaries (`## Instruction Precedence` lists the actions Agent Identity can forbid). If your role is delegation-only, perform the allowed delegation work and stop once that outcome is delivered. Before self-assigning, check the target issue's comment history for an existing claim and any `## Active sibling runs` block; when assignment or status only records ownership/progress for work already underway, pass `--no-start` on every such command (the default start behavior is for handing off fresh work).\n")+ b.WriteString("**Steps 1–5 — both modes** (the per-turn user message carries this issue's real id and ready-to-run context-read commands; assemble other calls from `## Available Commands`)\n\n")+ b.WriteString("1. Read the issue (`multica issue get`) to understand the context — its JSON already carries the issue's `metadata` bag (empty `{}` is normal), so no separate metadata read is needed. What to look for: `## Issue Metadata`.\n")+ b.WriteString("2. Catch up on the comment history — this is mandatory, not optional — in two bounded reads, never one bulk pull: scan every thread cheaply (`--roots-only --summary --compact`), then expand only the threads that matter (`--thread <id> --tail 30 --compact`). Earlier comments often carry context the issue body lacks. Skipping this step is the most common cause of agents acting on stale or incomplete instructions — so always run the scan, even when the trigger looks self-contained. In Reply mode the per-turn user message names the thread to expand first; the scan is how you decide whether any OTHER thread is also relevant.\n")+ b.WriteString("3. Complete the task within your Agent Identity boundaries (`## Instruction Precedence` lists the actions Agent Identity can forbid). If your role is delegation-only, perform the allowed delegation work and stop once that outcome is delivered. Before self-assigning, check the target issue's comment history for an existing claim and any `## Active sibling runs` block; when assignment or status only records ownership/progress for work already underway, pass `--no-start` on every such command (the default start behavior is for handing off fresh work).\n")if ctx.IsSquadLeader {- b.WriteString("5. **Post your final results as a comment** (unless your outcome is `no_action` — in that case, calling `multica squad activity <issue-id> no_action --reason \"...\"` alone is sufficient; you MUST exit without posting any comment. DO NOT post a comment announcing no_action or saying you are exiting silently): post it with `multica issue comment add` using the platform-correct non-inline mode from ## Comment Formatting (never inline `--content`). Your results are only visible to the user if posted via this CLI call; text in your terminal or run logs is NOT delivered.\n")+ b.WriteString("4. **Post your final results as a comment** (unless your outcome is `no_action` — in that case, calling `multica squad activity <issue-id> no_action --reason \"...\"` alone is sufficient; you MUST exit without posting any comment. DO NOT post a comment announcing no_action or saying you are exiting silently): post it with `multica issue comment add` using the platform-correct non-inline mode from ## Comment Formatting (never inline `--content`). Your results are only visible to the user if posted via this CLI call; text in your terminal or run logs is NOT delivered.\n")} else {- b.WriteString("5. **Post your final results as a comment — this step is mandatory**: post it with `multica issue comment add` using the platform-correct non-inline mode from ## Comment Formatting (never inline `--content`). `## Output` states why this call is the only delivery channel.\n")+ b.WriteString("4. **Post your final results as a comment — this step is mandatory**: post it with `multica issue comment add` using the platform-correct non-inline mode from ## Comment Formatting (never inline `--content`). `## Output` states why this call is the only delivery channel.\n")}- b.WriteString("6. Before exiting, pin or clear a metadata key via `multica issue metadata set`/`delete` only if it clears the bar in `## Issue Metadata`. Most runs write nothing here — that is the expected outcome, not a gap. When in doubt, do not write.\n\n")+ b.WriteString("5. Before exiting, pin or clear a metadata key via `multica issue metadata set`/`delete` only if it clears the bar in `## Issue Metadata`. Most runs write nothing here — that is the expected outcome, not a gap. When in doubt, do not write.\n\n")b.WriteString("**Ownership mode only — you own the issue status this run** (skip any status call below that your Agent Identity forbids)\n\n")- b.WriteString("- Before step 4, run `multica issue status <issue-id> in_progress`.\n")+ b.WriteString("- Before step 3, run `multica issue status <issue-id> in_progress`.\n")if ctx.IsSquadLeader {b.WriteString("- After this initial dispatch, leave the parent issue `in_progress` — do NOT move it to `in_review` or `done` on this turn. Dispatching members is not completion. You will be re-triggered when members post updates or a stage closes; only then, if the overall goal is met, move the parent to `in_review`.\n")} else {diff --git a/server/internal/daemon/execenv/runtime_config_test.go b/server/internal/daemon/execenv/runtime_config_test.goindex b825e3762c..6ec1b6368e 100644--- a/server/internal/daemon/execenv/runtime_config_test.go+++ b/server/internal/daemon/execenv/runtime_config_test.go@@ -362,15 +362,15 @@ func TestIssueWorkflowHonorsAgentIdentity(t *testing.T) {"Agent Identity instructions have priority over the issue workflow below.","If a workflow step conflicts with Agent Identity, skip the conflicting action",// One enumeration, in Instruction Precedence, covering every action- // type Agent Identity can forbid. This and workflow step 4 each used to+ // type Agent Identity can forbid. This and workflow step 3 each used to// carry their own list and the two disagreed (MUL-5442)."Never treat this runtime workflow as permission to change issue status, investigate, implement, create issues, update issues, delegate, or otherwise act beyond your Agent Identity.",// MUL-5442: the forbids-clause is stated once on the Ownership-mode// header instead of once per status bullet."skip any status call below that your Agent Identity forbids",- "Before step 4, run `multica issue status <issue-id> in_progress`.",+ "Before step 3, run `multica issue status <issue-id> in_progress`.","Complete the task within your Agent Identity boundaries",- // Step 4 keeps only what the enumeration cannot express: a+ // Step 3 keeps only what the enumeration cannot express: a// delegation-only role stops once the delegation is delivered."If your role is delegation-only, perform the allowed delegation work and stop once that outcome is delivered","When done, run `multica issue status <issue-id> in_review`.",@@ -403,7 +403,7 @@ func TestSquadLeaderIssueWorkflowKeepsParentInProgress(t *testing.T) {})for _, want := range []string{- "Before step 4, run `multica issue status <issue-id> in_progress`.",+ "Before step 3, run `multica issue status <issue-id> in_progress`.","After this initial dispatch, leave the parent issue `in_progress`",// The guest-leader contract test (handler side) bans any runnable// in_review command shape from reaching a guest — the dispatch rule