From 0c75c432b4b14b7816a07df4b7e8631d11b0377f Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Wed, 21 Oct 2026 07:06:22 +0000 Subject: [PATCH] refactor(frontend): drop test temporaries, explain the reused-run release and stop shadowing real Co-Authored-By: jason.han --- .../grpc/convert_check_diagnostics_test.go | 2 +- internal/frontend/grpc/run_options.go | 2 +- .../grpc/run_options_performer_test.go | 2 +- internal/frontend/mcp/toolkit/root.go | 22 +++++++++---------- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/internal/frontend/grpc/convert_check_diagnostics_test.go b/internal/frontend/grpc/convert_check_diagnostics_test.go index f3e406d4ed..535ee98563 100644 --- a/internal/frontend/grpc/convert_check_diagnostics_test.go +++ b/internal/frontend/grpc/convert_check_diagnostics_test.go @@ -178,7 +178,7 @@ func TestConvertCheckDiagnosticsWithRefusedConversion(t *testing.T) { if err != nil || resp.Error == "" || resp.Content != "" { t.Fatalf("check %v: two declarations of P converted: %v, error %q", check, err, resp.GetError()) } - if warned := severitiesByCode(resp.Diagnostics)["name-conflict"] == "warning"; warned != check { + if (severitiesByCode(resp.Diagnostics)["name-conflict"] == "warning") != check { t.Fatalf("check %v: diagnostics %v", check, resp.Diagnostics) } } diff --git a/internal/frontend/grpc/run_options.go b/internal/frontend/grpc/run_options.go index aa2474d004..a49d425a51 100644 --- a/internal/frontend/grpc/run_options.go +++ b/internal/frontend/grpc/run_options.go @@ -111,7 +111,7 @@ func (o runOptions) startAction(rt *runtime.Context, name string, action *symbol } release := exec.Release if reused { - release = func() {} + release = func() { /* a reused performance is the run's own; nothing was started for the call */ } } if _, err := rt.Advance(*o.advance); err != nil { release() diff --git a/internal/frontend/grpc/run_options_performer_test.go b/internal/frontend/grpc/run_options_performer_test.go index 86c9e3442b..4b7b39c83a 100644 --- a/internal/frontend/grpc/run_options_performer_test.go +++ b/internal/frontend/grpc/run_options_performer_test.go @@ -74,7 +74,7 @@ func TestExecuteActionAdvanceRunsThePerformersPerformance(t *testing.T) { if got := resp.PerformerAttributes["this.steps"].GetIntValue(); got != 1 { t.Errorf("%s %s: this.steps = %d, want 1: the robot's own performance ran, once", action, label, got) } - if got := resp.Outputs["run.n"].GetIntValue(); got != 1 { + if resp.Outputs["run.n"].GetIntValue() != 1 { t.Errorf("%s %s: outputs = %v, want the performed usage's run.n = 1", action, label, resp.Outputs) } } diff --git a/internal/frontend/mcp/toolkit/root.go b/internal/frontend/mcp/toolkit/root.go index c8b49e3a8c..67d7946fea 100644 --- a/internal/frontend/mcp/toolkit/root.go +++ b/internal/frontend/mcp/toolkit/root.go @@ -31,11 +31,11 @@ func NewRoot(dir string) (Root, error) { if err != nil { return Root{}, fmt.Errorf("resolving the workspace root %s: %w", dir, err) } - real, err := filepath.EvalSymlinks(abs) + resolved, err := filepath.EvalSymlinks(abs) if err != nil { return Root{}, fmt.Errorf("resolving the workspace root %s: %w", dir, err) } - return Root{Dir: abs, Real: real}, nil + return Root{Dir: abs, Real: resolved}, nil } // Resolved is a path Root.Resolve accepted. @@ -103,24 +103,24 @@ func (r Root) Resolve(path string, opts ...Option) (Resolved, error) { path = filepath.Join(r.Dir, path) } path = filepath.Clean(path) - real, err := realPath(path) + resolved, err := realPath(path) if err != nil { return Resolved{}, fmt.Errorf("resolving %s: %w", path, err) } - if o.role != NameIgnored && !sameFormat(path, real, o.role) { - return Resolved{}, fmt.Errorf("%s is a link to %s, whose extension names another format; name the file itself or a link with its extension", path, real) + if o.role != NameIgnored && !sameFormat(path, resolved, o.role) { + return Resolved{}, fmt.Errorf("%s is a link to %s, whose extension names another format; name the file itself or a link with its extension", path, resolved) } - res := Resolved{Path: path, Real: real} + res := Resolved{Path: path, Real: resolved} for _, dir := range o.exempt { - if realDir, err := filepath.EvalSymlinks(dir); err == nil && Under(realDir, real) { + if realDir, err := filepath.EvalSymlinks(dir); err == nil && Under(realDir, resolved) { return res, nil } } if !Under(r.Dir, path) { return Resolved{}, fmt.Errorf("%s is outside the workspace root %s", path, r.Dir) } - if !Under(r.Real, real) { - return Resolved{}, fmt.Errorf("%s leads through a symlink to %s, outside the workspace root %s", path, real, r.Dir) + if !Under(r.Real, resolved) { + return Resolved{}, fmt.Errorf("%s leads through a symlink to %s, outside the workspace root %s", path, resolved, r.Dir) } return res, nil } @@ -147,9 +147,9 @@ func realPath(path string) (string, error) { func realPathHops(path string, hops int) (string, error) { rest := "" for p := path; ; { - real, err := filepath.EvalSymlinks(p) + resolved, err := filepath.EvalSymlinks(p) if err == nil { - return filepath.Join(real, rest), nil + return filepath.Join(resolved, rest), nil } parent := filepath.Dir(p) if !(errors.Is(err, fs.ErrNotExist) || errors.Is(err, syscall.ENOTDIR)) || parent == p {