mirror of
https://gh-proxy.org/https://github.com/klinsmaya/multica.git
synced 2026-11-11 02:46:45 +08:00
* fix(daemon): isolate task identity and workdir reuse Co-authored-by: multica-agent <[email protected]> * test(llm): use validated retry override in contract Co-authored-by: multica-agent <[email protected]> * fix(daemon): address task isolation review Co-authored-by: multica-agent <[email protected]> --------- Co-authored-by: Sol-Boy <[email protected]> Co-authored-by: multica-agent <[email protected]>
46 lines
1.3 KiB
Go
46 lines
1.3 KiB
Go
package daemon
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"log/slog"
|
|
"testing"
|
|
|
|
"github.com/multica-ai/multica/server/pkg/taskfailure"
|
|
)
|
|
|
|
func TestRunTaskRejectsMismatchedAgentIdentityBeforePreparation(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
d := &Daemon{}
|
|
_, err := d.runTask(context.Background(), Task{
|
|
ID: "task-identity-mismatch",
|
|
WorkspaceID: "workspace-a",
|
|
AgentID: "agent-a",
|
|
Agent: &AgentData{ID: "agent-b", Name: "Agent B"},
|
|
}, "claude", 0, slog.Default())
|
|
if !errors.Is(err, errInvalidTaskIdentity) {
|
|
t.Fatalf("runTask error = %v, want invalid task identity", err)
|
|
}
|
|
if got := taskRunFailureReason(err); got != taskfailure.ReasonInvalidTaskIdentity.String() {
|
|
t.Fatalf("failure reason = %q, want %q", got, taskfailure.ReasonInvalidTaskIdentity)
|
|
}
|
|
}
|
|
|
|
func TestValidateTaskIdentityRequiresExpandedAgent(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
err := validateTaskIdentity(Task{ID: "task-agent-missing", AgentID: "agent-a"})
|
|
if !errors.Is(err, errInvalidTaskIdentity) {
|
|
t.Fatalf("validateTaskIdentity error = %v, want invalid task identity", err)
|
|
}
|
|
}
|
|
|
|
func TestValidateTaskIdentityAcceptsMatchingAgent(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
if err := validateTaskIdentity(Task{ID: "task-agent-match", AgentID: "agent-a", Agent: &AgentData{ID: "agent-a"}}); err != nil {
|
|
t.Fatalf("validateTaskIdentity: %v", err)
|
|
}
|
|
}
|