Skip to content

Swap out copyleft pgregory.net/rapid@v1.3.0 dependency, replace with gopter - #771

Open
liamfallon wants to merge 2 commits into
kptdev:mainfrom
Nordix:remove-rapid
Open

liamfallon wants to merge 2 commits into
kptdev:mainfrom
Nordix:remove-rapid

Conversation

@liamfallon

Copy link
Copy Markdown
Contributor

Replace pgregory.net/rapid (MPL-2.0) with github.com/leanovate/gopter (MIT)

Why

pgregory.net/rapid is licensed under MPL-2.0 (weak copyleft). This PR removes it in favour of github.com/leanovate/gopter (MIT), a permissively licensed property-based testing library, bringing the dependency set in line with the project's Apache-2.0 / BSD / MIT policy.

rapid was a test-only dependency, so no shipped code is affected.

What changed

Rewrote all 7 property-based tests in the go/fn module to use gopter. Assertions and coverage are unchanged — only the generator/runner API was swapped.

File Properties
go/fn/internal/docs/markers_test.go Property 1, 7
go/fn/internal/docs/metadata_test.go Property 2
go/fn/internal/docs/render_test.go Property 3, 4, 5
go/fn/run_filemode_property_test.go Property 6
go/fn/internal/docs/proptest_helpers_test.go new — shared bounded-slice helper

API mapping

rapid gopter
rapid.Check(t, fn) gopter.NewProperties(nil) + prop.ForAll(...) + properties.TestingRun(t)
rapid.StringMatching(re) gen.RegexMatch(re)
rapid.Custom(... struct ...) gen.Struct(reflect.TypeOf(...), map[string]gopter.Gen{...})
rapid.SliceOfN(gen, min, max) genBoundedSlice helper over gen.IntRange(min,max).FlatMap(gen.SliceOfN)
rapid.IntRange gen.IntRange
rapid.Bool() gen.Bool()
rapid.SampledFrom([]T{...}) gen.OneConstOf(...)

Note: gopter's prop.ForAll condition must return bool, string, or *PropResult (not a bare error). Each property body now returns a string — empty means pass, non-empty is the failure message.

Dependency cleanup

  • go/fn/go.mod / go.sum: pgregory.net/rapid removed, github.com/leanovate/gopter v0.2.11 added.
  • go/fn/internal/test/go.sum: rapid swapped for gopter (builds against local go/fn via replace).

Known follow-up

go/get-started and go/fn/examples still list pgregory.net/rapid in their go.sum. Their replace directives are commented out, so they build against the published go/fn v1.0.4 (which still declares rapid). These are checksum records only — rapid is not pulled into any binary. They will clear once a new rapid-free go/fn is released and those modules bump to it.

Verification

  • ✅ go vet ./... — all modules
  • ✅ go fmt ./... — no changes
  • ✅ go test ./... — all modules pass
  • ✅ Property tests stable across -count=5 runs
  • ✅ No pgregory.net/rapid references remain in go/fn source

golangci-lint was not run successfully locally due to a toolchain mismatch (pinned v2.12.2 can't parse Go 1.27.2 stdlib export data). CI pins Go to match the linter, so this does not affect CI.

AI Declaration

This PR was produced with AI assistance (Kiro).

How AI was used

  • Investigated how pgregory.net/rapid was used across the go/fn module and confirmed it was a test-only dependency.
  • Proposed replacement options and their licensing/trade-offs; the maintainer chose github.com/leanovate/gopter (MIT).
  • Rewrote the 7 property-based tests from the rapid API to the gopter API, added a shared bounded-slice test helper, and ran go mod tidy to update dependency files.

Human oversight

  • The maintainer directed the approach (chose gopter over the other options) and reviewed the changes.
  • All assertions and test coverage were preserved from the original rapid-based tests; only the generator/runner API was swapped.

Verification

  • go vet ./..., go fmt ./..., and go test ./... pass across all modules.
  • Property tests confirmed stable across repeated runs (-count=5).
  • No pgregory.net/rapid references remain in go/fn source.
  • golangci-lint was not run successfully locally due to a Go toolchain/linter version mismatch; CI pins Go to match the linter.

Accountability

  • The author takes full responsibility for the correctness and licensing suitability of these changes.

@liamfallon
liamfallon requested review from a team October 14, 2026 16:10
…gopter

Signed-off-by: liamfallon <liam.fallon@est.tech>
Signed-off-by: liamfallon <liam.fallon@est.tech>
@liamfallon
liamfallon requested review from a team October 15, 2026 09:41

This branch has not been deployed

No deployments
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.

2 participants