Skip to content

Remove generics from service factory.#1022

Merged
winder merged 1 commit intomainfrom
will/use-bootstrap-jobspec
Apr 14, 2026
Merged

Remove generics from service factory.#1022
winder merged 1 commit intomainfrom
will/use-bootstrap-jobspec

Conversation

@winder
Copy link
Copy Markdown
Collaborator

@winder winder commented Apr 14, 2026

With #1007 the service factories now use bootstrap.JobSpec unconditionally, so generics are no longer needed.

@github-actions
Copy link
Copy Markdown

Code coverage report:

Package main will/use-bootstrap-jobspec diff
github.com/smartcontractkit/chainlink-ccv/aggregator 48.46% 48.46% +0.00%
github.com/smartcontractkit/chainlink-ccv/bootstrap 42.62% 39.56% -3.06%
github.com/smartcontractkit/chainlink-ccv/cli 65.13% 65.13% +0.00%
github.com/smartcontractkit/chainlink-ccv/cmd 0.00% 0.00% +0.00%
github.com/smartcontractkit/chainlink-ccv/common 50.74% 50.74% +0.00%
github.com/smartcontractkit/chainlink-ccv/executor 45.74% 45.74% +0.00%
github.com/smartcontractkit/chainlink-ccv/indexer 37.50% 37.51% +0.01%
github.com/smartcontractkit/chainlink-ccv/integration 48.07% 47.97% -0.10%
github.com/smartcontractkit/chainlink-ccv/pkg 38.00% 38.00% +0.00%
github.com/smartcontractkit/chainlink-ccv/pricer 0.00% 0.00% +0.00%
github.com/smartcontractkit/chainlink-ccv/protocol 65.19% 65.19% +0.00%
github.com/smartcontractkit/chainlink-ccv/verifier 32.44% 32.43% -0.01%

@winder winder marked this pull request as ready for review April 14, 2026 14:18
@winder winder requested review from a team and skudasov as code owners April 14, 2026 14:18
Copilot AI review requested due to automatic review settings April 14, 2026 14:18
Comment thread bootstrap/bootstrap.go
Comment on lines +145 to +151
js := JobSpec{
Name: "no-jd",
ExternalJobID: "",
SchemaVersion: 0,
Type: "",
AppConfig: *b.appCfg,
}
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Wrap hard coded app config in a job spec since it's no longer a template.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR removes the generic AppConfig type parameter from the bootstrap/service-factory API, standardizing job startup around bootstrap.JobSpec and moving app-config TOML decoding into each service’s Start implementation.

Changes:

  • Make bootstrap.ServiceFactory, bootstrap.Bootstrapper, and bootstrap.Option non-generic, and update bootstrap.Run/NewBootstrapper signatures accordingly.
  • Update runners and call sites to pass/receive bootstrap.JobSpec instead of a typed AppConfig.
  • Update token verifier startup to decode spec.AppConfig internally; adjust bootstrap tests to match the new spec flow.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
bootstrap/bootstrap.go Removes generics from bootstrapper and runner; runner now TOML-decodes into JobSpec; options updated.
bootstrap/bootstrap_test.go Updates test factories/runner tests to use JobSpec and TOML marshal/decode path.
verifier/cmd/token/main.go Updates token verifier factory to implement new ServiceFactory signature and decode spec.AppConfig.
verifier/cmd/servicefactory.go Updates verifier service-factory constructors to return non-generic bootstrap.ServiceFactory.
verifier/cmd/committee/main.go Updates bootstrap option usage to new non-generic WithLogLevel.
cmd/executor/servicefactory.go Updates executor service-factory constructor return type to non-generic bootstrap.ServiceFactory.
Comments suppressed due to low confidence (1)

bootstrap/bootstrap_test.go:172

  • These test comments still describe the old behavior (“runner parses spec as TOML into AppConfig” / parseTomlStrict) but runner.StartJob now decodes TOML into JobSpec and passes the JobSpec through to ServiceFactory.Start. Please update the comments to match the new flow to avoid misleading future readers.
		// runner parses spec as TOML into AppConfig, then calls fac.Start(ctx, appConfig, deps)
		// use empty TOML so parseTomlStrict[any] succeeds (no undecoded fields)
		require.NoError(t, r.StartJob(ctx, ""))

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread bootstrap/bootstrap.go
Comment on lines +61 to +67
func (r *runner) StartJob(ctx context.Context, config string) error {
var spec JobSpec
_, err := toml.Decode(config, &spec)
if err != nil {
return fmt.Errorf("failed to parse app config toml: %w", err)
return fmt.Errorf("bootstrap: failed to parse config: %w", err)
}

return r.fac.Start(ctx, appConfig, r.deps)
return r.fac.Start(ctx, spec, r.deps)
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

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

runner.StartJob now uses toml.Decode without strict undecoded-field checking, so typos/unknown keys in the JD job spec will be silently ignored. Consider decoding in strict mode (e.g., reuse parseTOMLStrict or check md.Undecoded() and return an error) to match the strict parsing used elsewhere in bootstrap config loading.

Copilot uses AI. Check for mistakes.
Comment on lines +63 to 64
bootstrap.ServiceFactory

Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

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

tokenVerifierFactory embeds bootstrap.ServiceFactory as an anonymous field, but the struct already defines Start/Stop and the embedded interface value is never set. This adds confusing promoted methods (and could become a nil-forwarding footgun if the interface grows); remove the embedded bootstrap.ServiceFactory field unless it’s intentionally delegated to.

Suggested change
bootstrap.ServiceFactory

Copilot uses AI. Check for mistakes.
Comment on lines +102 to +105
_, err := toml.Decode(spec.AppConfig, &appConfig)
if err != nil {
return fmt.Errorf("unable to decode app config: %w", err)
}
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

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

Start decodes spec.AppConfig with toml.Decode but never checks md.Undecoded(), so unknown/typo keys in token verifier config will be silently ignored. For consistency with other services’ strict config loaders (e.g., executor/committee), decode into appConfig and fail if there are any undecoded fields, ideally including them in the error message.

Suggested change
_, err := toml.Decode(spec.AppConfig, &appConfig)
if err != nil {
return fmt.Errorf("unable to decode app config: %w", err)
}
md, err := toml.Decode(spec.AppConfig, &appConfig)
if err != nil {
return fmt.Errorf("unable to decode app config: %w", err)
}
if undecoded := md.Undecoded(); len(undecoded) > 0 {
return fmt.Errorf("unknown app config fields: %v", undecoded)
}

Copilot uses AI. Check for mistakes.
Comment thread bootstrap/bootstrap.go
return func(b *Bootstrapper[AppConfig]) error {
func WithTOMLAppConfig(configFilePath string) Option {
return func(b *Bootstrapper) error {
configFilePath = filepath.Clean(configFilePath)
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

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

WithTOMLAppConfig reads from a variable path using os.ReadFile without a //nolint:gosec justification, while other bootstrap config loads explicitly suppress G304. This is likely to fail gosec (G304) in CI; add an explicit //nolint:gosec with rationale (or otherwise constrain/validate the path) to keep linting consistent.

Suggested change
configFilePath = filepath.Clean(configFilePath)
configFilePath = filepath.Clean(configFilePath)
//nolint:gosec // G304: configFilePath is an explicit operator-provided bootstrap config path.

Copilot uses AI. Check for mistakes.
@winder winder added this pull request to the merge queue Apr 14, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Apr 14, 2026
@winder winder added this pull request to the merge queue Apr 14, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Apr 14, 2026
@winder winder added this pull request to the merge queue Apr 14, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Apr 14, 2026
@winder winder added this pull request to the merge queue Apr 14, 2026
Merged via the queue into main with commit 27a7db5 Apr 14, 2026
33 of 34 checks passed
@winder winder deleted the will/use-bootstrap-jobspec branch April 14, 2026 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants