Skip to content

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

Go

fix(daemon): tell agents not to use the shared git stash list (MUL-8989) (#10326)

Jiayuan Zhang1a9ddcf8f0a7
diff --git a/server/internal/daemon/execenv/runtime_config_commands_test.go b/server/internal/daemon/execenv/runtime_config_commands_test.go
index b71a297865..79c3423b99 100644
--- a/server/internal/daemon/execenv/runtime_config_commands_test.go
+++ b/server/internal/daemon/execenv/runtime_config_commands_test.go
@@ -86,6 +86,12 @@ func TestAvailableCommandsKeepsCompressedContracts(t *testing.T) {
"`git config --worktree user.name` / `user.email`",
"plain or `--local` config can leak into a shared cache",
"never change the global identity",
+ // Stash: the list is shared across checkouts (MUL-8989), so
+ // the prohibition and both safe alternatives stay here.
+ "share a single `git stash` list",
+ "never use `git stash` / `git stash pop` there",
+ "make a temporary commit",
+ "keep the SHA from `git stash create` and restore it with `git stash apply <sha>`",
} {
if !strings.Contains(ac, want) {
t.Errorf("Available Commands lost %q\n---\n%s", want, ac)
diff --git a/server/internal/daemon/execenv/runtime_config_sections.go b/server/internal/daemon/execenv/runtime_config_sections.go
index 5929040fd8..389e005048 100644
--- a/server/internal/daemon/execenv/runtime_config_sections.go
+++ b/server/internal/daemon/execenv/runtime_config_sections.go
@@ -280,6 +280,10 @@ func writeAvailableCommands(b *strings.Builder, ctx TaskContextForEnv) {
b.WriteString("- `multica issue comment add <issue-id> [--content \"...\" | --content-file <path> | --content-stdin] [--parent <comment-id>] [--attachment <path>]` — post a comment. Agent-authored bodies MUST use `--content-file` with a file inside your working directory; full flags: `multica issue comment add --help`.\n")
b.WriteString("- `multica repo checkout <url> [--ref <branch-or-sha>] [--fresh]` — repository checkout on a dedicated branch; re-running it keeps a checkout that has uncommitted or unpushed work, or is already on this task's branch, and only fetches; a clean, fully pushed checkout on another branch starts over on a new branch. `--fresh` discards uncommitted and untracked files for a new branch; commits stay on the old branch, so push any you still need first.\n\n")
b.WriteString("Commits use the user's configured Git identity; keep it unless asked. For a requested override in a managed checkout use `git config --worktree user.name` / `user.email` — plain or `--local` config can leak into a shared cache; never change the global identity.\n\n")
+ // refs/stash belongs to the shared repository cache, not to a worktree, so
+ // every agent checkout of one repo pushes and pops the same list (MUL-8989:
+ // a `git stash pop` applied another agent's edits).
+ b.WriteString(sharedStashRule)
// Squad maintenance is squad-leader surface: an agent that leads no squad
// has no squad to change roles in, so this shipped to every run as dead
// weight (MUL-5442). IsSquadLeader is a PER-TASK role (the daemon derives
@@ -293,6 +297,10 @@ func writeAvailableCommands(b *strings.Builder, ctx TaskContextForEnv) {
}
}
+// sharedStashRule keeps agents off the stash list in managed checkouts and
+// names the two ways to set changes aside that stay inside one checkout.
+const sharedStashRule = "Managed checkouts of one repo share a single `git stash` list, so `git stash pop` can apply another agent's changes: never use `git stash` / `git stash pop` there. To set changes aside, make a temporary commit, or keep the SHA from `git stash create` and restore it with `git stash apply <sha>`.\n\n"
+
// duplicateOfCommandLine teaches the duplicate mark (MUL-7821). Without it
// agents cancel duplicates with a plain status change plus a comment, which
// leaves the original's duplicates list empty.