This repository was archived by the owner on May 25, 2026. It is now read-only.
Commit 6ea1953
authored
feat(schemas): schema-driven slim fields on users (Phase 3b, DOT-560) (#111)
Sibling of DOT-558 (Phase 3a). Extends the schema-driven slim-fields
pattern (canonical: PR #109, PR #110) to the users domain — the one
piece Phase 3a deferred because the slim shape needed a privacy-aware
design pass.
Slim shape: identity-only — id, username, name, state, avatar_url,
web_url, bot. Seven fields. Always safe to expose for any user.
Privacy-sensitive fields (email, last_sign_in_at, is_admin,
two_factor_enabled, confirmed_at, current_sign_in_at, private_profile,
last_activity_on, theme_id, color_scheme_id, projects_limit, external)
are excluded by default; opt back in via fields:'all' or explicit pick.
A dedicated test pins the privacy guardrail so future expansions of
UserSlimShape can't accidentally leak those fields.
Phase-1 gaps closed along the way:
- src/schemas/users.ts: GitLabUserListSchema didn't exist; add it.
- src/tools/users.ts: get_users and search_users were never wrapped
with parseGitLabResponse; wrap them now (a prerequisite for typed
slim defaults to project from).
Wires four user-returning tools with fields + projection:
- get_current_user (already parse-wrapped, just adds fields+project)
- get_user (already parse-wrapped, just adds fields+project)
- get_users (newly parse-wrapped, per-username map slimmed element-wise)
- search_users (newly parse-wrapped, list slimmed)
Out of scope: list_events, get_project_events, upload_markdown,
download_attachment, health_check — they live in users.ts for
organizational convenience but don't return user-shaped data.
Tests:
- tests/schemas/users.test.ts: slim-schema parse, USER_SLIM_FIELDS
allow-list invariant, projectField allow-list at runtime,
**privacy guardrail** (USER_SLIM_FIELDS does NOT contain email /
is_admin / two_factor_enabled / etc.), separate test that
projectField actually drops those fields on a populated current-user
fixture, GitLabUserListSchema parse, token-budget regression.
- tests/users.test.ts: default / fields:'all' / custom-pick handler
tests for each of the four tools (12+ cases). get_current_user and
get_user tests specifically verify privacy fields absent by default
and present under fields:'all'. search_users test confirms `fields`
is not forwarded to GitLab as a query string.
README "Field Projection" section extended to list the four user
endpoints.1 parent 0f5aea4 commit 6ea1953
5 files changed
Lines changed: 492 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
189 | 189 | | |
190 | 190 | | |
191 | 191 | | |
| 192 | + | |
192 | 193 | | |
193 | 194 | | |
194 | 195 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
7 | 9 | | |
8 | 10 | | |
9 | 11 | | |
| 12 | + | |
10 | 13 | | |
11 | 14 | | |
12 | 15 | | |
13 | 16 | | |
| 17 | + | |
14 | 18 | | |
15 | 19 | | |
16 | 20 | | |
17 | 21 | | |
18 | 22 | | |
19 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
20 | 29 | | |
21 | 30 | | |
22 | 31 | | |
| |||
101 | 110 | | |
102 | 111 | | |
103 | 112 | | |
104 | | - | |
| 113 | + | |
| 114 | + | |
105 | 115 | | |
106 | 116 | | |
| 117 | + | |
107 | 118 | | |
108 | 119 | | |
109 | 120 | | |
| |||
116 | 127 | | |
117 | 128 | | |
118 | 129 | | |
119 | | - | |
| 130 | + | |
| 131 | + | |
120 | 132 | | |
121 | 133 | | |
122 | 134 | | |
123 | | - | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
124 | 144 | | |
125 | 145 | | |
126 | 146 | | |
| |||
133 | 153 | | |
134 | 154 | | |
135 | 155 | | |
136 | | - | |
| 156 | + | |
| 157 | + | |
137 | 158 | | |
138 | 159 | | |
| 160 | + | |
139 | 161 | | |
140 | 162 | | |
141 | 163 | | |
| |||
146 | 168 | | |
147 | 169 | | |
148 | 170 | | |
149 | | - | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
150 | 177 | | |
151 | 178 | | |
152 | 179 | | |
| |||
156 | 183 | | |
157 | 184 | | |
158 | 185 | | |
159 | | - | |
| 186 | + | |
| 187 | + | |
160 | 188 | | |
161 | 189 | | |
162 | 190 | | |
163 | 191 | | |
| 192 | + | |
164 | 193 | | |
165 | 194 | | |
166 | 195 | | |
| |||
169 | 198 | | |
170 | 199 | | |
171 | 200 | | |
172 | | - | |
| 201 | + | |
| 202 | + | |
173 | 203 | | |
174 | | - | |
175 | | - | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
176 | 213 | | |
177 | 214 | | |
178 | 215 | | |
| |||
366 | 403 | | |
367 | 404 | | |
368 | 405 | | |
369 | | - | |
370 | | - | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
371 | 410 | | |
372 | 411 | | |
373 | 412 | | |
374 | 413 | | |
375 | 414 | | |
376 | | - | |
| 415 | + | |
| 416 | + | |
377 | 417 | | |
378 | 418 | | |
379 | | - | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
380 | 425 | | |
381 | 426 | | |
382 | 427 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
3 | 10 | | |
4 | 11 | | |
5 | 12 | | |
| |||
28 | 35 | | |
29 | 36 | | |
30 | 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 | + | |
0 commit comments