Move AutoRespond CLI name selection to CodeBackend (#412)#423
Merged
Conversation
`AutoRespondCoordinator` selected the CLI binary name with six inline `provider == .gitlab ? "glab" : "gh"` (and equivalent `if provider == .gitlab` prose) checks. With the `TaskBackend` / `CodeBackend` split from #410 / ADR 0005 in place, this responsibility belongs on the backend. - Add `cliName: String` to the `CodeBackend` protocol; implement `"gh"` on `GitHubCodeBackend` and `"glab"` on `GitLabCodeBackend`. - Inject `ProviderManager` into `AutoRespondCoordinator` and resolve a `CodeBackend` per session using `session.codeProvider ?? session.provider` (the resolver convention from `Session.swift` / #420). Corveil-or-unknown sessions fall back to GitHub tooling — matches the prior `?? .github` default. - Change `AutoRespondPrompts.build` and `QuickActionPrompts.build` to take a `CodeBackend` instead of a `Provider`. Prose branches still read `codeBackend.provider`; CLI tokens read `codeBackend.cliName`. Prompt text is byte-identical for every existing branch (`cliName` returns the same string that was previously hardcoded), so no behavior change. Closes #412
dhilgaertner
approved these changes
Jun 4, 2026
Contributor
dhilgaertner
left a comment
There was a problem hiding this comment.
Code & Security Review
Critical Issues
None.
Security Review
Strengths:
- Pure internal refactor — no new external input, network, auth, or filesystem surface. CLI tokens (
gh/glab) are compile-time constants on each backend, not user-controlled, so no command-injection vector is introduced. - PR URLs interpolated into prompt hints were already interpolated identically before this change; no new injection path.
Concerns:
- None.
Code Quality
- Behavior parity confirmed.
cliNamereturns the exact strings (gh/glab) previously hardcoded, and the prose branches still key offcodeBackend.provider, so prompt text is byte-identical for every existing branch. Verified the GitLabfixChecks/mergePR/fixConflictsand GitHubchangesRequestedbranches all reduce to the prior literals. - Force-unwrap is safe.
providerManager.codeBackend(for: .github)!inresolveCodeBackendcan never trap —ProviderManager.codeBackend(for:)returns nil only for.corveil;.githubalways yields aGitHubCodeBackend. The fallback is documented inline. - Provider resolution matches convention.
session.codeProvider ?? session.provider ?? .githubmirrors the established pattern atSessionService.swift:1210and theSession.swiftdoc contract (#420 / ADR 0005). - Concurrency correct.
codeBackend(for:)isnonisolated, so the@MainActorcoordinator calls it synchronously withoutawait— appropriate. - All call sites updated (
AppDelegateinjects the existingproviderManager; both test suites migrated toCodeBackend);rgconfirms zero remaining inlineprovider == .gitlab ? "glab" : "gh"checks. - Test stub
FakeCodeBackendis appropriately minimal — onlyprovider/cliNameare read by the builders.
Note: the resolved CodeBackend is built with host: nil, so a self-hosted GitLab session's host isn't threaded through. This is harmless here because prompt rendering only reads cliName and provider (never linkedPR/ensureMergeLabel), but worth keeping in mind if these backends ever get used for live calls in this path.
Summary Table
| Color | Meaning | Verdict effect |
|---|---|---|
| Red | Must fix | Request changes |
| Yellow | Should fix | Request changes |
| Green | Consider | Approve allowed |
Recommendation: Approve — driven by [0 Red, 0 Yellow, 1 Green] findings. Behavior-preserving refactor that correctly moves CLI-name selection onto CodeBackend, consistent with ADR 0005 and #420.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
AutoRespondCoordinatorselected the CLI binary name (ghvsglab) with six inlineprovider == .gitlab ? "glab" : "gh"/if provider == .gitlabchecks. With theTaskBackend/CodeBackendsplit from Extract TicketBackend protocol — decouple gh/glab shell-outs from call sites #410 / ADR 0005 in place, this belongs on the backend.cliName: StringtoCodeBackend; implement"gh"onGitHubCodeBackendand"glab"onGitLabCodeBackend.ProviderManagerintoAutoRespondCoordinator; resolve aCodeBackendper session viasession.codeProvider ?? session.provider(the convention fromSession.swift/ Add Session.codeProvider for cross-backend pairing #420). Corveil-or-unknown sessions fall back to GitHub tooling — matches the prior?? .githubdefault.AutoRespondPrompts.buildandQuickActionPrompts.buildto take aCodeBackendinstead of aProvider. Prose branches still readcodeBackend.provider; CLI tokens readcodeBackend.cliName.Prompt text is byte-identical for every existing branch (
cliNamereturns the same string previously hardcoded), so no behavior change.Test plan
swift build --arch arm64— cleanswift build --arch arm64 --build-tests— clean (QuickActionPromptsTests,AutoRespondCoordinatorReviewSessionTestsupdated to constructCodeBackend/ProviderManager)rg 'provider == \.gitlab \? "glab" : "gh"' Sources/ Packages/ Tests/returns zero matchesswiftpm-xctest-helperbeing x86_64-only on this Xcode install (build is arm64); CI runs the suite.Closes #412