newRepoVisibilityIFCLabeler returns a closure that attaches a repo-visibility IFC label to a tool result, for handlers that have several return paths and want to label each one. The returned function owns the feature-flag gate (so callers invoke it unconditionally) and caches the repository visibili
( ctx context.Context, deps ToolDependencies, client *github.Client, owner, repo string, labelFn func(isPrivate bool) ifc.SecurityLabel, )
| 143 | // a later return path can retry; on persistent failure the label is omitted |
| 144 | // rather than risking a misclassification. |
| 145 | func newRepoVisibilityIFCLabeler( |
| 146 | ctx context.Context, |
| 147 | deps ToolDependencies, |
| 148 | client *github.Client, |
| 149 | owner, repo string, |
| 150 | labelFn func(isPrivate bool) ifc.SecurityLabel, |
| 151 | ) func(*mcp.CallToolResult) *mcp.CallToolResult { |
| 152 | var ( |
| 153 | known bool |
| 154 | isPrivate bool |
| 155 | ) |
| 156 | return func(r *mcp.CallToolResult) *mcp.CallToolResult { |
| 157 | if r == nil || r.IsError || !deps.IsFeatureEnabled(ctx, FeatureFlagIFCLabels) { |
| 158 | return r |
| 159 | } |
| 160 | if !known { |
| 161 | p, err := FetchRepoIsPrivate(ctx, client, owner, repo) |
| 162 | if err != nil { |
| 163 | return r |
| 164 | } |
| 165 | isPrivate = p |
| 166 | known = true |
| 167 | } |
| 168 | setIFCLabel(r, labelFn(isPrivate)) |
| 169 | return r |
| 170 | } |
| 171 | } |
no test coverage detected