style: apply gofumpt formatting
This commit is contained in:
1 parent
58524f24d8
commit
16ec8393fe
22 files changed
+82
-36
No files matched your search
@@ -770,7 +770,8 @@ func (b *boot) setupGuardrails() {
|
||||
log := b.log
|
||||
gc := tools.DefaultGuardrailConfig()
|
||||
b.guardrails = tools.NewGuardrailEngine(gc)
|
||||
log.Info("guardrail engine enabled",
|
||||
log.Info(
|
||||
"guardrail engine enabled",
|
||||
"exact_failure_warn", gc.ExactFailureWarnAfter,
|
||||
"same_tool_failure_warn", gc.SameToolFailureWarnAfter,
|
||||
"no_progress_warn", gc.NoProgressWarnAfter,
|
||||
|
||||
@@ -773,7 +773,9 @@ func (stubForge) CreatePR(context.Context, string, string, string, string, strin
|
||||
}
|
||||
func (stubForge) SetStateLabel(context.Context, string, string, int, string, []string) {}
|
||||
func (stubForge) LinkBranch(context.Context, string, string, int, string) error { return nil }
|
||||
func (stubForge) AcceptInvitations(context.Context) error { panic("unexpected call") }
|
||||
|
||||
func (stubForge) AcceptInvitations(context.Context) error { panic("unexpected call") }
|
||||
|
||||
func (stubForge) AssignedIssues(context.Context, string, string, string) ([]forge.Issue, error) {
|
||||
panic("unexpected call")
|
||||
}
|
||||
@@ -793,8 +795,11 @@ func (stubForge) PRState(context.Context, string, string, int) (string, error) {
|
||||
func (stubForge) CreateIssue(context.Context, string, string, string, string, []string) (int, error) {
|
||||
panic("unexpected call")
|
||||
}
|
||||
|
||||
func (stubForge) React(context.Context, string, string, int, string) error { panic("unexpected call") }
|
||||
func (stubForge) VerifyPush(context.Context, string, string) error { panic("unexpected call") }
|
||||
|
||||
func (stubForge) VerifyPush(context.Context, string, string) error { panic("unexpected call") }
|
||||
|
||||
func startEmbeddedNATS(t *testing.T) *server.Server {
|
||||
t.Helper()
|
||||
srv := natssrv.RunRandClientPortServer()
|
||||
@@ -875,7 +880,9 @@ func (*identityForge) CreatePR(context.Context, string, string, string, string,
|
||||
}
|
||||
func (*identityForge) SetStateLabel(context.Context, string, string, int, string, []string) {}
|
||||
func (*identityForge) LinkBranch(context.Context, string, string, int, string) error { return nil }
|
||||
func (*identityForge) AcceptInvitations(context.Context) error { panic("unexpected") }
|
||||
|
||||
func (*identityForge) AcceptInvitations(context.Context) error { panic("unexpected") }
|
||||
|
||||
func (*identityForge) AssignedIssues(context.Context, string, string, string) ([]forge.Issue, error) {
|
||||
panic("unexpected")
|
||||
}
|
||||
@@ -895,8 +902,10 @@ func (*identityForge) PRState(context.Context, string, string, int) (string, err
|
||||
func (*identityForge) CreateIssue(context.Context, string, string, string, string, []string) (int, error) {
|
||||
panic("unexpected")
|
||||
}
|
||||
|
||||
func (*identityForge) React(context.Context, string, string, int, string) error { panic("unexpected") }
|
||||
func (*identityForge) VerifyPush(context.Context, string, string) error { panic("unexpected") }
|
||||
|
||||
func (*identityForge) VerifyPush(context.Context, string, string) error { panic("unexpected") }
|
||||
|
||||
// A container-mode task owned by a non-root identity must have its RPC
|
||||
// calls served by that identity's own forge client, never the root's.
|
||||
|
||||
@@ -85,7 +85,8 @@ func handleSingleStageRequest(
|
||||
return err
|
||||
}
|
||||
|
||||
log.Info("stage complete",
|
||||
log.Info(
|
||||
"stage complete",
|
||||
"task", request.TaskID,
|
||||
"stage", request.Stage,
|
||||
"status", response.Result.Status,
|
||||
|
||||
@@ -42,13 +42,16 @@ type prCapturingForge struct {
|
||||
func (f *prCapturingForge) Comment(context.Context, string, string, int, string) (int64, error) {
|
||||
return 1, nil
|
||||
}
|
||||
|
||||
func (f *prCapturingForge) CloseIssue(context.Context, string, string, int, string) error { return nil }
|
||||
|
||||
func (f *prCapturingForge) CreatePR(_ context.Context, owner, repo, title, head, base, body string) (int, error) {
|
||||
f.prs = append(f.prs, struct{ owner, repo, title, head, base, body string }{owner, repo, title, head, base, body})
|
||||
return 5, nil
|
||||
}
|
||||
func (f *prCapturingForge) SetStateLabel(context.Context, string, string, int, string, []string) {}
|
||||
func (f *prCapturingForge) AcceptInvitations(context.Context) error { panic("unexpected call") }
|
||||
|
||||
func (f *prCapturingForge) AssignedIssues(context.Context, string, string, string) ([]forge.Issue, error) {
|
||||
panic("unexpected call")
|
||||
}
|
||||
@@ -76,6 +79,7 @@ func (f *prCapturingForge) React(context.Context, string, string, int, string) e
|
||||
func (f *prCapturingForge) VerifyPush(context.Context, string, string) error {
|
||||
panic("unexpected call")
|
||||
}
|
||||
|
||||
func (f *prCapturingForge) LinkBranch(context.Context, string, string, int, string) error { return nil }
|
||||
|
||||
type remoteManager struct {
|
||||
|
||||
@@ -247,7 +247,8 @@ func (g *Gateway) handleApprovalCallback(ctx context.Context, b *bot.Bot, update
|
||||
return
|
||||
}
|
||||
|
||||
g.log.Info("tool approval decision",
|
||||
g.log.Info(
|
||||
"tool approval decision",
|
||||
"action", pa.action, "decision", decision,
|
||||
"recipient", query.From.ID, "username", query.From.Username,
|
||||
)
|
||||
|
||||
@@ -158,7 +158,8 @@ func (g *Gateway) handleDangerousCallback(ctx context.Context, b *bot.Bot, updat
|
||||
}
|
||||
|
||||
decision, _ := parseDangerousCallback(query.Data)
|
||||
g.log.Info("dangerous command decision",
|
||||
g.log.Info(
|
||||
"dangerous command decision",
|
||||
"command", action.command, "decision", decision,
|
||||
"recipient", query.From.ID, "username", query.From.Username,
|
||||
)
|
||||
|
||||
@@ -305,7 +305,8 @@ func (g *Gateway) launch(ctx context.Context, router *gateway.Router) (*bot.Bot,
|
||||
if err != nil {
|
||||
g.log.Warn("failed to get webhook info", "error", err)
|
||||
} else {
|
||||
g.log.Info("webhook info",
|
||||
g.log.Info(
|
||||
"webhook info",
|
||||
"url", info.URL,
|
||||
"pending_update_count", info.PendingUpdateCount,
|
||||
"last_error_message", info.LastErrorMessage,
|
||||
@@ -635,7 +636,8 @@ func (g *Gateway) authorizedMessage(ctx context.Context, b *bot.Bot, update *mod
|
||||
if g.isSenderAllowed(update.Message.From.ID) {
|
||||
return update.Message, true
|
||||
}
|
||||
g.log.Warn("message from unauthorized sender",
|
||||
g.log.Warn(
|
||||
"message from unauthorized sender",
|
||||
"user_id", update.Message.From.ID,
|
||||
"username", update.Message.From.Username,
|
||||
"chat_id", update.Message.Chat.ID,
|
||||
|
||||
@@ -206,7 +206,8 @@ func TestRepoJSONRoundTrip(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
assertJSONKeys(t, data,
|
||||
assertJSONKeys(
|
||||
t, data,
|
||||
"owner",
|
||||
"name",
|
||||
"base",
|
||||
|
||||
@@ -771,7 +771,8 @@ func (d *Daemon) reconcilePRs(ctx context.Context) {
|
||||
// row that is a second implementation and a second PR for work
|
||||
// already merged.
|
||||
d.closeResolvedIssue(ctx, fg, &t, fmt.Sprintf(
|
||||
"Closed by #%d, merged by archie.", t.PRNumber))
|
||||
"Closed by #%d, merged by archie.", t.PRNumber,
|
||||
))
|
||||
d.Log.Info("PR merged", "repo", t.Owner+"/"+t.Repo, "pr", t.PRNumber)
|
||||
d.emit(events.Event{
|
||||
Kind: events.KindPRMerged, TaskID: t.ID,
|
||||
|
||||
@@ -1084,6 +1084,7 @@ func (f *recordingForge) React(context.Context, string, string, int, string) err
|
||||
}
|
||||
|
||||
func (f *recordingForge) VerifyPush(context.Context, string, string) error { panic("unexpected call") }
|
||||
|
||||
func (f *recordingForge) LinkBranch(context.Context, string, string, int, string) error {
|
||||
panic("unexpected call")
|
||||
}
|
||||
|
||||
@@ -115,7 +115,8 @@ func mergeSkillWorkflows(worktree string, reg workflow.Registry, origins map[str
|
||||
sw := SkillWorkflow{Workflow: entry.Workflow, Dir: entry.Dir}
|
||||
wf, err := BuildWorkflow(worktree, sw)
|
||||
if err != nil {
|
||||
slog.Default().Warn("skipping broken skill workflow",
|
||||
slog.Default().Warn(
|
||||
"skipping broken skill workflow",
|
||||
"workflow", entry.Workflow,
|
||||
"skill", entry.Dir,
|
||||
"err", err,
|
||||
@@ -126,7 +127,8 @@ func mergeSkillWorkflows(worktree string, reg workflow.Registry, origins map[str
|
||||
// Only warn when TWO SKILLS declare the same workflow name.
|
||||
// Overriding a built-in name is routine -- don't log.
|
||||
if prevSkill, dup := seenFromSkill[entry.Workflow]; dup {
|
||||
slog.Default().Warn("duplicate workflow name across skills -- overriding",
|
||||
slog.Default().Warn(
|
||||
"duplicate workflow name across skills -- overriding",
|
||||
"workflow", entry.Workflow,
|
||||
"skill", entry.Dir,
|
||||
"previous_skill", prevSkill,
|
||||
|
||||
@@ -47,7 +47,8 @@ func (r *Router) handleDelete(ctx context.Context, msg Message, rest string) (st
|
||||
return fmt.Sprintf(
|
||||
"Refusing to delete on %d characters — this cannot be undone. "+
|
||||
"Give at least %d characters of the session id, or its full id.",
|
||||
len([]rune(ref)), minDeleteRefLen), nil
|
||||
len([]rune(ref)), minDeleteRefLen,
|
||||
), nil
|
||||
}
|
||||
|
||||
// Read the active session before the delete, so the reply can say
|
||||
|
||||
@@ -214,7 +214,8 @@ func (s *sqliteSessionStore) ClaimTurn(ctx context.Context, initial TurnRecord)
|
||||
FROM turns WHERE turn_id = ?`, initial.TurnID).Scan(
|
||||
&turn.TurnID, &turn.SessionID, &turn.SourceID, &turn.Status, &turn.Attempt, &turn.OwnerID,
|
||||
&turn.InputMessageID, &turn.AssistantMessageID, &turn.PartialText,
|
||||
&turn.ResponseText, &turn.Error, &createdMS, &updatedMS)
|
||||
&turn.ResponseText, &turn.Error, &createdMS, &updatedMS,
|
||||
)
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
now := time.Now().UTC()
|
||||
initial.Status = TurnStatusRunning
|
||||
@@ -253,7 +254,8 @@ func (s *sqliteSessionStore) ClaimTurn(ctx context.Context, initial TurnRecord)
|
||||
FROM turns WHERE turn_id = ?`, initial.TurnID).Scan(
|
||||
&turn.TurnID, &turn.SessionID, &turn.SourceID, &turn.Status, &turn.Attempt, &turn.OwnerID,
|
||||
&turn.InputMessageID, &turn.AssistantMessageID, &turn.PartialText,
|
||||
&turn.ResponseText, &turn.Error, &createdMS, &updatedMS)
|
||||
&turn.ResponseText, &turn.Error, &createdMS, &updatedMS,
|
||||
)
|
||||
}
|
||||
if err != nil {
|
||||
return TurnRecord{}, "", fmt.Errorf("sessionstore: read turn: %w", err)
|
||||
@@ -343,7 +345,8 @@ func (s *sqliteSessionStore) GetTurn(ctx context.Context, turnID string) (TurnRe
|
||||
FROM turns WHERE turn_id = ?`, turnID).Scan(
|
||||
&turn.TurnID, &turn.SessionID, &turn.SourceID, &turn.Status, &turn.Attempt, &turn.OwnerID,
|
||||
&turn.InputMessageID, &turn.AssistantMessageID, &turn.PartialText,
|
||||
&turn.ResponseText, &turn.Error, &createdMS, &updatedMS)
|
||||
&turn.ResponseText, &turn.Error, &createdMS, &updatedMS,
|
||||
)
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return TurnRecord{}, false, nil
|
||||
}
|
||||
@@ -417,7 +420,8 @@ func (s *sqliteSessionStore) ListRecoverableTurns(ctx context.Context) ([]TurnRe
|
||||
if err := rows.Scan(
|
||||
&turn.TurnID, &turn.SessionID, &turn.SourceID, &turn.Status, &turn.Attempt, &turn.OwnerID,
|
||||
&turn.InputMessageID, &turn.AssistantMessageID, &turn.PartialText,
|
||||
&turn.ResponseText, &turn.Error, &createdMS, &updatedMS); err != nil {
|
||||
&turn.ResponseText, &turn.Error, &createdMS, &updatedMS,
|
||||
); err != nil {
|
||||
return nil, fmt.Errorf("sessionstore: scan recoverable turn: %w", err)
|
||||
}
|
||||
turn.CreatedAt = time.UnixMilli(createdMS).UTC()
|
||||
|
||||
@@ -148,7 +148,8 @@ func taskListTool(lister ChatTaskLister, identity string) tools.ToolEntry {
|
||||
"type": "integer",
|
||||
"description": fmt.Sprintf(
|
||||
"Maximum tasks to return. Defaults to %d, capped at %d.",
|
||||
defaultTaskListLimit, maxTaskListLimit),
|
||||
defaultTaskListLimit, maxTaskListLimit,
|
||||
),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -259,7 +260,8 @@ func taskLogsTool(reader ChatTaskLogReader, identity string) tools.ToolEntry {
|
||||
"type": "integer",
|
||||
"description": fmt.Sprintf(
|
||||
"Maximum entries to return. Defaults to %d, capped at %d.",
|
||||
defaultTaskLogLimit, maxTaskLogLimit),
|
||||
defaultTaskLogLimit, maxTaskLogLimit,
|
||||
),
|
||||
},
|
||||
},
|
||||
"required": []any{"task_id"},
|
||||
|
||||
@@ -53,7 +53,8 @@ func markSafe(ctx context.Context, mountDir string, run gitRunner, log *slog.Log
|
||||
|
||||
out, err := run(ctx, "config", "--global", "--add", "safe.directory", mountDir)
|
||||
if err != nil {
|
||||
log.Warn("git safe.directory config failed -- gates that shell out to git may fail",
|
||||
log.Warn(
|
||||
"git safe.directory config failed -- gates that shell out to git may fail",
|
||||
"dir", mountDir,
|
||||
"err", err,
|
||||
"output", strings.TrimSpace(string(out)),
|
||||
|
||||
@@ -46,7 +46,8 @@ func New(in *os.File, out io.Writer) (*Terminal, error) {
|
||||
return nil, fmt.Errorf(
|
||||
"terminalprompt: %s is not a terminal; archied setup requires an "+
|
||||
"interactive session (input cannot be piped, redirected, or "+
|
||||
"scripted)", in.Name())
|
||||
"scripted)", in.Name(),
|
||||
)
|
||||
}
|
||||
return &Terminal{
|
||||
in: in,
|
||||
|
||||
@@ -27,7 +27,8 @@ func line(level, msg string, extra ...string) string {
|
||||
}
|
||||
|
||||
func TestTailFilters(t *testing.T) {
|
||||
path := writeLog(t,
|
||||
path := writeLog(
|
||||
t,
|
||||
line("INFO", "started", `"component":"daemon"`),
|
||||
line("WARN", "telegram rate limited", `"component":"gateway-telegram"`),
|
||||
line("ERROR", "pull failed", `"component":"container"`),
|
||||
@@ -175,7 +176,8 @@ func TestDecodeKeepsStructuredFields(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestComponents(t *testing.T) {
|
||||
path := writeLog(t,
|
||||
path := writeLog(
|
||||
t,
|
||||
line("INFO", "a", `"component":"daemon"`),
|
||||
line("INFO", "b", `"component":"gateway-telegram"`),
|
||||
line("INFO", "c", `"component":"daemon"`),
|
||||
|
||||
@@ -277,7 +277,8 @@ func TestEdit_NotFoundReportsNearestMatch(t *testing.T) {
|
||||
|
||||
// Same code, wrong indentation on the body line.
|
||||
res, err := tool.Execute(context.Background(), json.RawMessage(
|
||||
`{"path":"f.go","edits":[{"old_text":"func handleCancel() {\n\tdoWork()\n}","new_text":"func handleCancel() { return }"}]}`), nil)
|
||||
`{"path":"f.go","edits":[{"old_text":"func handleCancel() {\n\tdoWork()\n}","new_text":"func handleCancel() { return }"}]}`,
|
||||
), nil)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
@@ -313,7 +314,8 @@ func TestEdit_NotFoundWithNoPlausibleMatchStaysGeneric(t *testing.T) {
|
||||
tool := NewEditTool(tmp, NewMutationQueue(), rt)
|
||||
|
||||
res, err := tool.Execute(context.Background(), json.RawMessage(
|
||||
`{"path":"f.go","edits":[{"old_text":"nothing like this exists","new_text":"x"}]}`), nil)
|
||||
`{"path":"f.go","edits":[{"old_text":"nothing like this exists","new_text":"x"}]}`,
|
||||
), nil)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
|
||||
@@ -336,7 +336,8 @@ func TestGrepClampsContextLines(t *testing.T) {
|
||||
|
||||
tool := NewGrepTool(tmp, nil)
|
||||
res, err := tool.Execute(context.Background(), json.RawMessage(
|
||||
`{"pattern":"needle","context_before":40,"context_after":40}`), nil)
|
||||
`{"pattern":"needle","context_before":40,"context_after":40}`,
|
||||
), nil)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
@@ -363,7 +364,8 @@ func TestGrepLeavesModestContextAlone(t *testing.T) {
|
||||
|
||||
tool := NewGrepTool(tmp, nil)
|
||||
res, err := tool.Execute(context.Background(), json.RawMessage(
|
||||
`{"pattern":"needle","context_before":2,"context_after":2}`), nil)
|
||||
`{"pattern":"needle","context_before":2,"context_after":2}`,
|
||||
), nil)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
@@ -392,7 +394,8 @@ func TestGrepUsesIndexForSubdirectorySearch(t *testing.T) {
|
||||
|
||||
tool := NewGrepTool(tmp, index)
|
||||
res, err := tool.Execute(context.Background(), json.RawMessage(
|
||||
`{"pattern":"needle","path":"sub"}`), nil)
|
||||
`{"pattern":"needle","path":"sub"}`,
|
||||
), nil)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
@@ -420,7 +423,8 @@ func TestGrepFallsBackToDirectWhenNoCandidatesInSubtree(t *testing.T) {
|
||||
|
||||
tool := NewGrepTool(tmp, index)
|
||||
res, err := tool.Execute(context.Background(), json.RawMessage(
|
||||
`{"pattern":"needle","path":"sub"}`), nil)
|
||||
`{"pattern":"needle","path":"sub"}`,
|
||||
), nil)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
|
||||
@@ -110,7 +110,8 @@ func TestGrepAllowsGoModCache(t *testing.T) {
|
||||
|
||||
tool := NewGrepTool(cwd, nil)
|
||||
res, err := tool.Execute(context.Background(), json.RawMessage(
|
||||
`{"pattern":"Needle","path":`+quote(cache)+`}`), nil)
|
||||
`{"pattern":"Needle","path":`+quote(cache)+`}`,
|
||||
), nil)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
@@ -131,7 +132,8 @@ func TestWriteRejectsGoModCache(t *testing.T) {
|
||||
|
||||
tool := NewWriteTool(cwd, nil, NewReadTracker())
|
||||
res, err := tool.Execute(context.Background(), json.RawMessage(
|
||||
`{"path":`+quote(filepath.Join(cache, "evil.go"))+`,"content":"package evil\n"}`), nil)
|
||||
`{"path":`+quote(filepath.Join(cache, "evil.go"))+`,"content":"package evil\n"}`,
|
||||
), nil)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
@@ -154,7 +156,8 @@ func TestEditRejectsGoModCache(t *testing.T) {
|
||||
rt.MarkRead(cwd, target)
|
||||
tool := NewEditTool(cwd, nil, rt)
|
||||
res, err := tool.Execute(context.Background(), json.RawMessage(
|
||||
`{"path":`+quote(target)+`,"edits":[{"old_text":"package dep","new_text":"package hacked"}]}`), nil)
|
||||
`{"path":`+quote(target)+`,"edits":[{"old_text":"package dep","new_text":"package hacked"}]}`,
|
||||
), nil)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
|
||||
@@ -246,7 +246,8 @@ func (c *Client) dialContext(ctx context.Context, network, addr string) (net.Con
|
||||
if len(refused) > 0 {
|
||||
return nil, fmt.Errorf(
|
||||
"refusing to connect to %s: it resolves to the private or loopback address %s, which is where this host's own services live; set tools.web_fetch.allow_private_networks to permit it",
|
||||
host, strings.Join(refused, ", "))
|
||||
host, strings.Join(refused, ", "),
|
||||
)
|
||||
}
|
||||
return nil, fmt.Errorf("could not connect to %s", host)
|
||||
}
|
||||
|
||||
@@ -127,7 +127,8 @@ func (s *Server) handleChatSessions(w http.ResponseWriter, r *http.Request) {
|
||||
func chatCommandSpecs(chat *ChatService) []gateway.CommandSpec {
|
||||
specs := gateway.LocalCommandSpecs()
|
||||
if chat.Dangerous != nil {
|
||||
specs = append(specs,
|
||||
specs = append(
|
||||
specs,
|
||||
gateway.CommandSpec{Command: "/rollback", Description: "Request approval to restore a filesystem checkpoint", Usage: "/rollback [number]"},
|
||||
gateway.CommandSpec{Command: "/stop", Description: "Request approval to terminate a background process", Usage: "/stop <process-name>"},
|
||||
gateway.CommandSpec{Command: "/deny", Description: "Deny a pending dangerous action", Usage: "/deny <action-id>"},
|
||||
|
||||
Reference in new issue
Block a user