Repository navigation
feat: add target/targets aliases for service/services - #277
Merged
Merged
Conversation
Relates to #276 What/Why Add a --target flag and a targets: config key as aliases for --service and services:, so consumers can migrate ahead of an eventual deprecation of the service naming. When both are set, target/targets win; targets: replaces services: outright rather than merging. Proof it works go build, go vet, gofmt -s, golangci-lint (0 issues), and the full go test ./... suite pass. New tests cover flag registration/binding, TargetName precedence (flag, env, both, neither), getter resolution through targets:, and NewConfig resolving policy/vars/loglevel from a targets: map. Risk + AI role Low. Additive alias with unchanged legacy behavior when target keys are absent. Implementation and tests AI-generated (Claude Fable 5), reviewed against existing package conventions. Review focus Precedence semantics: targets: replacing services: entirely (no merge), and --target intentionally lacking a shorthand because -t belongs to --test-suites. Signed-off-by: jmeridth <jmeridth@gmail.com>
jmeridth
marked this pull request as ready for review
August 20, 2026 21:12
jmeridth
marked this pull request as draft
August 20, 2026 21:19
What/Why
Multi-model review of the alias change surfaced two regressions and three
gaps. An inherited PVTR_TARGET env var could override the --service flag the
harness passes to every plugin subprocess, making all plugins in a
multi-target run resolve the same target and overwrite each other's results;
and a stray PVTR_TARGETS env var or emptied targets: block silently masked a
populated services: map. TargetName now ranks explicitly passed flags above
env and config regardless of alias (via a flag set registered by
SetRunFlags, since viper cannot arbitrate across two distinct keys), and
targetsKey gates on a non-empty targets map instead of key presence. Also:
the invalid-policy error now hints when the name exists only under the
ignored legacy services: key, pvtr benchmark gains --target as an alias for
its --service flag, and docs describe the tiered precedence.
Proof it works
Full go test ./... suite, vet, gofmt -s, and golangci-lint (0 issues) pass.
A standalone reproduction that demonstrated both regressions (flag --service
losing to PVTR_TARGET; PVTR_TARGETS emptying GetServices) now shows the
correct values. New regression tests exercise real flag/env/config tiers
rather than viper's override layer, covering: changed --service beats
PVTR_TARGET and a config-file target:, changed --target beats --service,
PVTR_TARGETS and targets: {} not masking services:, the legacy-services
error hint, and benchmark's --target/-s acceptance.
Risk + AI role
Low. Precedence fixes restore pre-alias behavior for explicit flags; alias
semantics are otherwise unchanged. Found by AI review agents and fixed by AI
(Claude Fable 5), independently verified via scratch reproductions.
Review focus
The flag-registration seam (config.BindTargetFlags called from SetRunFlags)
and whether flag-beats-env-beats-config is the precedence you and Eddie want
for the alias pair.
Signed-off-by: jmeridth <jmeridth@gmail.com>
jmeridth
marked this pull request as ready for review
August 20, 2026 21:34
eddie-knight
previously approved these changes
Aug 20, 2026
eddie-knight
left a comment
Contributor
There was a problem hiding this comment.
This all looks grea, thanks for pulling it together.
I'm wondering, though, whether it would be prudent to isolate the relationship messaging to the old field so that it doesn't distract new users.
What/Why Apply review suggestions from #277: drop the precedence notes from both --target help strings so the relationship messaging lives only on the legacy --service flag and does not distract new users. Help text only, no behavior change; precedence stays documented in docs/configuration.md. Proof it works go vet, go test ./command/... ./config/..., and golangci-lint pass. Risk + AI role Low. Help-text only. Suggested by reviewer, applied by AI (Claude Fable 5). Review focus None needed beyond confirming the wording matches the suggestions. Signed-off-by: jmeridth <jmeridth@gmail.com>
eddie-knight
approved these changes
Aug 20, 2026
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.
Closes #276
What/Why
Adds a
--targetflag and atargets:config key as aliases for--serviceandservices:, giving consumers a migration path toward the eventual deprecation of the service naming.pvtr benchmarkalso accepts--targetalongside its existing-s.Resolution rules: an explicitly passed flag (either alias) outranks
PVTR_TARGET/PVTR_SERVICEenv vars and config-file values, so plugin subprocesses launched with--service=<name>are immune to an inheritedPVTR_TARGET. Within the same source,targetwins overservice. A non-emptytargets:map replacesservices:entirely (no merging); an empty or absenttargets:falls back toservices:.Proof it works
Full
go test ./...suite passes. Regression tests exercise real flag/env/config tiers (not viper's override layer): a changed--servicebeatsPVTR_TARGETand a config-filetarget:, a changed--targetbeats--service, a strayPVTR_TARGETSortargets: {}does not mask a populatedservices:map, the invalid-policy error hints when a name exists only under an ignored legacyservices:key, and benchmark accepts--target/-s. Standalone reproductions of the two env-precedence bugs found in review now show correct values.Risk + AI role
Low. Purely additive; legacy
service/services:behavior is unchanged when the target keys are absent. Implementation and tests AI-generated, then AI-reviewed with two independent review passes whose findings were fixed and human-verified.Review focus
The flag-registration seam (
config.BindTargetFlagscalled fromSetRunFlags) that letsTargetNamerank explicit flags above env/config, and whether that tiered precedence matches the intent in #276. Also:--targethas no shorthand because-tbelongs to--test-suites.