# fix(control-plane): close resolver findings + drop redundant ireturn nolints

`d8a4aab`·

toothbrush·3w ago·4 files·+256 added/-20 removed

Address trail #641 review findings on resolveref.go:
\- case-insensitive name matching (EqualFold) in pickOrg, pickProject, and
filterProjectsByName, matching the server's lower(name) uniqueness, so a
case-only typo resolves instead of erroring
\- guard empty resolved AccountId in resolveAccountRef with a clear local
error instead of forwarding "" as the owner ULID
\- add resolver tests asserting ULID refs make 0 HTTP calls and name/handle
refs make exactly 1, plus case-insensitive and empty-account cases

Also drop three //nolint:ireturn directives: main's ireturn allowlist now
covers checkpoint.CommittedStore/TemporaryStore, so they are redundant and
CI's nolintlint fails on them as unused.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

## Sessions

93dc23440f69View transcript

[?\
Resolve Names Server-Side in Control PlaneClaude Code·Opus 4.8[1m]·1 step](/content/gh/entireio/cli/session/ae5aa6a1-3cb0-4726-830b-04f79e7f24ce#timeline-93dc23440f69/index.html)

## Changes

4

- cmd/entire/cli

- checkpoint

- Mopen.go+1/-1

- Mresolveref.go+23/-10

- Mresolveref_test.go+230/-7

- strategy

- Mmanual_commit.go+2/-2

```
54 unmodified lines

55
56
57
58
58
59
60
61

54 unmodified lines

}

// Temporary returns the git-backed temporary shadow-branch store.
func (s *Stores) Temporary() TemporaryStore { return s.temporary } //nolint:ireturn // temporary store capability is the abstraction boundary
func (s *Stores) Temporary() TemporaryStore { return s.temporary }

// Refs returns the resolved committed-ref topology.
func (s *Stores) Refs() CommittedRefs { return s.refs }
```

Mcmd/entire/cli/checkpoint/open.go+1/-1

```
64 unmodified lines

65
66
67
68
69
70
71
72
73
74
75
76
10 unmodified lines

87
88
89
84
85
90
91
92
93
94
95
96
8 unmodified lines

105
106
107
100
108
109
110
111
112
104
113
114
115
116
16 unmodified lines

133
134
135
127
136
137
138
139
140
141
131
142
143
144
145
11 unmodified lines

157
158
159
149
150
151
160
161
162
163
164
165
166
167
168
169
170
158
171
172
173
174

64 unmodified lines

if err != nil {
		return "", err
	}
	// ResolvedIdentity.AccountId is a plain string, so a handle that resolves to
	// an identity with no backing account would silently forward "" as the owner
	// ULID and fail later with an opaque server-side create error. Catch it here.
	if id.AccountId == "" {
		return "", fmt.Errorf("handle %q resolved to no account", ref)
	}
	return id.AccountId, nil
}

10 unmodified lines

// resolveProjectRef turns a project reference (ULID or name) into its ULID. A
// ULID is returned unchanged; a name is looked up via the server's exact-name
// filter (the same call `entire project list --name` uses).
// ULID is returned unchanged; a name is looked up via the server's name filter
// (the same call `entire project list --name` uses). Name matching is
// case-insensitive end to end: the server enforces lower(name) uniqueness and
// pickProject re-checks with EqualFold, so case-only differences resolve.
func resolveProjectRef(ctx context.Context, c *coreapi.Client, ref string) (string, error) {
	if looksLikeULID(ref) {
		return ref, nil
	}
8 unmodified lines

// pickOrg selects the single org named name. Org names are unique, so a name
// matches at most one org; zero matches is an error pointing at `org list`, and
// (defensively) multiple matches list the colliding ids so the user can fall
// back to a ULID.
// back to a ULID. Matching is case-insensitive (EqualFold): pickOrg filters the
// full ListOrgs result client-side, so a case-only typo should still resolve.
func pickOrg(orgs []coreapi.Org, name string) (string, error) {
	var matches []coreapi.Org
	for _, o := range orgs {
		if o.Name == name {
			if strings.EqualFold(o.Name, name) {
				matches = append(matches, o)
			}
		}
	}
16 unmodified lines

// different orgs/accounts; on ambiguity the candidates (id + owner) are listed
// so the user can pass the intended ULID. (We can't suggest re-scoping the
// failing command: resolveProjectRef's callers — repo create/list, grant
// project … — have no --org flag; only `entire project list` does.)
// project … — have no --org flag; only `entire project list` does.) Matching is
// case-insensitive (EqualFold) so the client-side re-check never drops a row the
// server returned, regardless of whether the server's name filter folds case.
func pickProject(projects []coreapi.Project, name string) (string, error) {
	var matches []coreapi.Project
	for _, p := range projects {
		if p.Name == name {
			if strings.EqualFold(p.Name, name) {
				matches = append(matches, p)
			}
		}
	}
11 unmodified lines

}
}

// filterProjectsByName narrows projects to exact name matches, returning all of
// them when name is empty. Used by `project list --org` to apply --name
// client-side, since the org-scoped list endpoint has no name parameter.
// filterProjectsByName narrows projects to name matches, returning all of them
// when name is empty. Used by `project list --org` to apply --name client-side,
// since the org-scoped list endpoint has no name parameter. Matching is
// case-insensitive (EqualFold), consistent with pickProject and the server's
// lower(name) uniqueness guarantee.
func filterProjectsByName(projects []coreapi.Project, name string) []coreapi.Project {
	if name == "" {
		return projects
	}
	var out []coreapi.Project
	for _, p := range projects {
		if p.Name == name {
			if strings.EqualFold(p.Name, name) {
				out = append(out, p)
			}
		}
	}
```

Mcmd/entire/cli/resolveref.go+23/-10

```
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
60 unmodified lines

295
296
297
75
76
298
299
300
301
302
2 unmodified lines

305
306
307
85
308
309
310
311
20 unmodified lines

332
333
334
112
113
335
336
337
338
339
17 unmodified lines

357
358
359
137
138
360
361
362
363
364

package cli

import (
\t"context"
\t"net/http"
\t"net/http/httptest"
\t"sync/atomic"
\t"testing"

"github.com/entireio/cli/internal/coreapi"
)

// Valid ULID-shaped fixtures (26 Crockford base32 chars, no I/L/O/U) so the
// resolver tests exercise the ULID short-circuit instead of a name lookup.
const (
	ulidOrgAcme        = "0123456789ABCDEFGHJKMNPQR1"
	ulidOrgGlobex      = "0123456789ABCDEFGHJKMNPQR2"
	ulidProjectWidgets = "0123456789ABCDEFGHJKMNPQR3"
	ulidAccount        = "0123456789ABCDEFGHJKMNPQR4"
	ulidResolvedAcct   = "0123456789ABCDEFGHJKMNPQR9"
)

// resolveTestClient builds a coreapi client pointed at a test server whose
// handler is h, and returns the client plus a counter of HTTP requests seen.
// It lets the resolver tests assert the load-bearing invariant from
// resolveref.go's doc comment: a ULID ref makes zero network calls, a name ref
// makes exactly one.
func resolveTestClient(t *testing.T, h http.HandlerFunc) (*coreapi.Client, *atomic.Int64) {
\t\t// ... code ... 
}

func TestResolveOrgRef(t *testing.T) {
\t// ... test code ... 
}

func TestResolveProjectRef(t *testing.T) {
\t// ... test code ... 
}

func TestResolveAccountRef(t *testing.T) {
\t// ... test code ... 
}

func TestLooksLikeULID(t *testing.T) {
\t// ... test code ... 
}

func TestPickOrg(t *testing.T) {
\t// ... test code ... 
}

func TestPickProject(t *testing.T) {
\t// ... test code ... 
}`
