Skip to content

drop variadic on AddDataToContext#143

Merged
robbyt merged 2 commits into
mainfrom
claude/review-repo-improvements-NDaxm
May 23, 2026
Merged

drop variadic on AddDataToContext#143
robbyt merged 2 commits into
mainfrom
claude/review-repo-improvements-NDaxm

Conversation

@robbyt
Copy link
Copy Markdown
Owner

@robbyt robbyt commented May 23, 2026

Summary

Drops the variadic on data.Setter.AddDataToContext. Signature changes from

AddDataToContext(ctx context.Context, data ...map[string]any) (context.Context, error)

to

AddDataToContext(ctx context.Context, data map[string]any) (context.Context, error)

The variadic was used by exactly one call site in the entire repo (the examples/data-prep/starlark main, which now merges its two maps before calling). All other ~80 call sites pass a single map; the variadic added zero value for them and forced an inner loop in ContextProvider.AddDataToContext and a forwarding slice through CompositeProvider.

The (context.Context, error) return stays — ContextProvider still validates keys and propagates processValue errors, and StaticProvider's ErrStaticProviderNoRuntimeUpdates sentinel is unchanged.

Files touched

  • platform/data/provider.go — interface
  • platform/data/{contextProvider,staticProvider,compositeProvider,addDataToContext}.go — implementations + helper wrappers
  • engines/{extism,risor,starlark}/evaluator/evaluator.go — wrapper signatures
  • examples/data-prep/starlark/main.go — merge two-map call into one (adds maps import)
  • ~14 _test.go files including local mock impls of data.Setter
  • CHANGELOG.md[Unreleased] > Changed

Net diff: +85 / -91 across 23 files.

Closes #87.

Test plan

  • go build ./... clean
  • go vet ./... clean
  • go test -race -count=1 ./... full suite green
  • grep -rn 'AddDataToContext(.*\.\.\.\|AddDataToContext(ctx, [^,]*,[^,]*,' --include='*.go' finds no multi-arg callers
  • CI: SonarQube, dependency-review, Copilot review

https://claude.ai/code/session_01C61VEAmjxSnX5Xhbab8NvL


Generated by Claude Code

Signature changes from
  AddDataToContext(ctx, data ...map[string]any) (context.Context, error)
to
  AddDataToContext(ctx, data map[string]any) (context.Context, error)

The variadic was used by exactly one call in the repo (the starlark
example, which now merges its two maps before calling). All other ~80
call sites pass a single map; the variadic added nothing for them.

Touches the Setter interface, the three Provider implementations
(ContextProvider, StaticProvider, CompositeProvider), the two helper
wrappers (AddDataToContextHelper, AddDataToContextFromProvider), the
three engine Evaluator wrappers, the data-prep starlark example, and
~30 test sites including local mock implementations of data.Setter.

Closes #87.

https://claude.ai/code/session_01C61VEAmjxSnX5Xhbab8NvL
Copilot AI review requested due to automatic review settings May 23, 2026 15:34
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 23, 2026

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

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

Refactors the platform/data runtime-enrichment API by removing the rarely-used variadic parameter from data.Setter.AddDataToContext, simplifying call sites and avoiding unnecessary slice forwarding/looping in provider implementations.

Changes:

  • Updated data.Setter.AddDataToContext (and all implementers/wrappers) to accept a single map[string]any.
  • Updated call sites (including examples and integration tests) to pass one map, merging multiple sources ahead of time.
  • Updated mocks/tests and documented the breaking change in CHANGELOG.md.

Reviewed changes

Copilot reviewed 23 out of 23 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
polyscript_test.go Updates test mock AddDataToContext signature to non-variadic.
polyscript_mocks_test.go Updates evaluator mock AddDataToContext signature to non-variadic.
platform/mocks_test.go Updates evaluator mock AddDataToContext signature to non-variadic.
platform/evaluator_test.go Updates test mocks and a multi-map call to a single merged map.
platform/data/staticProvider.go Updates StaticProvider.AddDataToContext signature to accept a single map.
platform/data/staticProvider_test.go Updates tests to pass a single map; one subtest name should be renamed to match new API.
platform/data/provider.go Changes Setter interface signature and updates docs/example accordingly.
platform/data/provider_test.go Adjusts tests from multi-map inputs to a single map with multiple keys.
platform/data/data_helpers_test.go Updates MockProvider.AddDataToContext signature to non-variadic.
platform/data/contextProvider.go Simplifies merge logic to iterate over a single map (no outer variadic loop).
platform/data/contextProvider_test.go Updates tests to use a single merged map where applicable.
platform/data/compositeProvider.go Updates composite provider signature and removes variadic forwarding.
platform/data/addDataToContext.go Updates helper/wrapper signatures and removes variadic forwarding.
platform/data/addDataToContext_test.go Updates helper tests to pass a single merged map.
examples/data-prep/starlark/main.go Merges two maps before calling AddDataToContext (adds maps usage).
engines/starlark/evaluator/evaluator.go Updates evaluator wrapper signature and call into data helper.
engines/starlark/evaluator/evaluator_test.go Updates mock provider signature and test inputs to a single map.
engines/risor/evaluator/evaluator.go Updates evaluator wrapper signature and call into data helper.
engines/risor/evaluator/evaluator_test.go Updates mock provider signature and test inputs to a single map.
engines/integration_test.go Updates integration test calls from multi-map to single map literals.
engines/extism/evaluator/evaluator.go Updates evaluator wrapper signature and call into data helper.
engines/extism/evaluator/evaluator_test.go Updates mock providers/test inputs to a single map.
CHANGELOG.md Documents the breaking signature change under Unreleased.

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

Comment thread platform/data/staticProvider_test.go Outdated
Comment on lines 175 to 179
@@ -178,9 +178,7 @@ func TestStaticProvider_AddDataToContext(t *testing.T) {

newCtx, err := provider.AddDataToContext(
@robbyt robbyt changed the title refactor(data): drop variadic on AddDataToContext drop variadic on AddDataToContext May 23, 2026
Per Copilot review on #143 — after dropping the variadic in da45a53 the
subtest passes a single multi-key map; the old name was misleading.

https://claude.ai/code/session_01C61VEAmjxSnX5Xhbab8NvL
@sonarqubecloud
Copy link
Copy Markdown

@robbyt robbyt merged commit 7f2345c into main May 23, 2026
3 checks passed
@robbyt robbyt deleted the claude/review-repo-improvements-NDaxm branch May 23, 2026 18:03
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.

[v1][breaking] Rethink Setter.AddDataToContext signature

3 participants