-
Notifications
You must be signed in to change notification settings - Fork 499
Refactor safe-output repo target accessors #53838
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+156
−150
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
ac17ab8
Initial plan
Copilot d21bb00
Refactor safe output repo target accessors
Copilot 773023e
Strengthen repo target registry coverage
Copilot 987cc12
Add draft ADR for registry-based repo target accessor pattern (PR #53…
github-actions[bot] 87fbefa
Merge branch 'main' into copilot/refactor-repo-target-extraction
github-actions[bot] ec1120a
Derive repo target accessors from handler metadata
Copilot a596fb6
Merge remote-tracking branch 'origin/main' into copilot/refactor-repo…
Copilot 94b6b00
Merge branch 'main' into copilot/refactor-repo-target-extraction
github-actions[bot] 4161388
Investigate reported CI failure
Copilot dc4b0d5
Fix governance formal test lint assertions
Copilot 903c288
Restore generated workflow skill source
Copilot 4c4f39a
chore: begin maintainer finish pass
Copilot 2502e9e
Merge remote-tracking branch 'origin/main' into copilot/refactor-repo…
Copilot aace5b5
Merge branch 'main' into copilot/refactor-repo-target-extraction
github-actions[bot] 67cd33d
Verify latest PR readiness
Copilot aa9257f
Revert unrelated skill-list change
Copilot 619c237
Merge branch 'main' into copilot/refactor-repo-target-extraction
pelikhan 699abbc
Guard reflected repo target assertion
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
docs/adr/53838-registry-based-repo-target-accessor-pattern.md
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| # ADR-53838: Registry-Based Repo Target Accessor Pattern | ||
|
|
||
| **Date**: 2026-08-19 | ||
| **Status**: Draft | ||
| **Deciders**: Unknown | ||
|
|
||
| --- | ||
|
|
||
| ### Context | ||
|
|
||
| `pkg/workflow/safe_outputs_tools_repo_params.go` contained a single function (`addRepoParameterIfNeeded`) with a 28-case `switch` statement that duplicated the same `AllowedRepos` / `TargetRepoSlug` extraction pattern for every safe-output tool. Adding a new tool required inserting identical boilerplate into multiple branches of that switch with no compile-time or test-time guard against omissions, making the code easy to implement inconsistently. | ||
|
|
||
| ### Decision | ||
|
|
||
| We will replace the monolithic switch with a `repoTargetAccessors` registry: a package-level `map[string]repoTargetAccessor` that maps each tool name to a one-liner function returning a `*repoTargetConfig`. `addRepoParameterIfNeeded` performs a single map lookup and delegates to the accessor, reducing the function from ~160 lines to ~10. A dedicated test (`TestRepoTargetAccessorsCoverRepoTargetTools`) asserts that the registry contains exactly the expected set of tool names, acting as a coverage guard for future additions. | ||
|
|
||
| ### Alternatives Considered | ||
|
|
||
| #### Alternative 1: Keep the switch with a coverage test | ||
|
|
||
| Add the `TestRepoTargetAccessorsCoverRepoTargetTools`-style test against the existing switch (e.g., by enumerating all `case` labels via reflection or a maintained list), leaving the implementation unchanged. This would surface omissions at test time but would not reduce the per-tool duplication or shorten `addRepoParameterIfNeeded`. | ||
|
|
||
| #### Alternative 2: Interface-based tool registry | ||
|
|
||
| Define a `RepoTargetProvider` interface and have each tool's config struct implement it, removing the accessor functions entirely. This would eliminate all per-tool boilerplate in the registry at the cost of touching every config struct and coupling the config layer to the repo-parameter generation logic. | ||
|
|
||
| ### Consequences | ||
|
|
||
| #### Positive | ||
| - Adding a new tool now requires a single, uniform registry entry instead of a switch case in an already-large function. | ||
| - The coverage test fails fast if a tool is added to the tool list but omitted from the registry. | ||
| - `addRepoParameterIfNeeded` is reduced from ~160 lines to ~10, making it easy to understand at a glance. | ||
|
|
||
| #### Negative | ||
| - Each of the 28 registry entries still contains near-identical boilerplate (`if output := config.X; output != nil { return &repoTargetConfig{...} }`), so per-entry verbosity is unchanged. | ||
| - The registry is a package-level `var`, which is initialized at program startup; errors in registry construction surface only at runtime, not at compile time. | ||
|
|
||
| #### Neutral | ||
| - The `repoTargetConfig` struct is now the canonical representation of per-tool repo-target state, which is a minor new abstraction other callers could reuse. | ||
| - The test coverage guard encodes the full list of repo-target tools in the test file; this list must be kept in sync when tools are added or removed. | ||
|
|
||
| --- | ||
|
|
||
| *ADR created by [adr-writer agent]. Review and finalize before changing status from Draft to Accepted.* |
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.