Skip to content

feat: add target/targets aliases for service/services - #277

Merged
jmeridth merged 3 commits into
mainfrom
feat/target-alias
Aug 20, 2026
Merged

jmeridth merged 3 commits into
mainfrom
feat/target-alias

Conversation

@jmeridth

@jmeridth jmeridth commented Aug 20, 2026 •

Copy link
Copy Markdown
Member

Closes #276

What/Why

Adds a --target flag and a targets: config key as aliases for --service and services:, giving consumers a migration path toward the eventual deprecation of the service naming. pvtr benchmark also accepts --target alongside its existing -s.

Resolution rules: an explicitly passed flag (either alias) outranks PVTR_TARGET/PVTR_SERVICE env vars and config-file values, so plugin subprocesses launched with --service=<name> are immune to an inherited PVTR_TARGET. Within the same source, target wins over service. A non-empty targets: map replaces services: entirely (no merging); an empty or absent targets: falls back to services:.

Proof it works

Full go test ./... suite passes. Regression tests exercise real flag/env/config tiers (not viper's override layer): a changed --service beats PVTR_TARGET and a config-file target:, a changed --target beats --service, a stray PVTR_TARGETS or targets: {} does not mask a populated services: map, the invalid-policy error hints when a name exists only under an ignored legacy services: 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.BindTargetFlags called from SetRunFlags) that lets TargetName rank explicit flags above env/config, and whether that tiered precedence matches the intent in #276. Also: --target has no shorthand because -t belongs to --test-suites.

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 jmeridth self-assigned this Aug 20, 2026
@jmeridth
jmeridth marked this pull request as ready for review August 20, 2026 21:12
@jmeridth
jmeridth requested a review from a team August 20, 2026 21:12
@jmeridth
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
jmeridth marked this pull request as ready for review August 20, 2026 21:34
eddie-knight
eddie-knight previously approved these changes Aug 20, 2026

@eddie-knight eddie-knight left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread command/harness/benchmark.go Resolved
Comment thread command/base.go Resolved
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>
@jmeridth jmeridth added release and removed release labels Aug 20, 2026
@jmeridth
jmeridth merged commit 3e4bcf5 into main Aug 20, 2026
8 checks passed
@jmeridth
jmeridth deleted the feat/target-alias branch August 20, 2026 22:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add target/targets aliases for service/services in config and flags

2 participants