PLT-455: Distribution config primitive + discriminator#43
Conversation
Add a tagged Distribution config type mirroring GasPicker: an UnmarshalJSON switch on a "Name" discriminator selecting "uniform" or "zipfian" delegates, with a loud default error on unknown kinds. The zipfian "theta" parameter is range-checked at parse time. Wire optional KeyDistribution and SizeDistribution onto Scenario as additive, omitempty *Distribution fields so existing profiles round-trip unchanged. Sampling math (YCSB precomputed-zeta zipfian + seeded uniform draw) is deferred to PLT-460; SampleIndex methods are placeholders. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
PR SummaryLow Risk Overview The new Tests cover unmarshaling/validation and prove existing profiles without these fields still parse and remarshal without adding distribution keys (golden check on Reviewed by Cursor Bugbot for commit efc85ec. Bugbot is set up for automated code reviews on this repo. Configure here. |
Implements PLT-455 — the reusable keyspace-distribution config primitive for the sei-load workload modeler. Locks the JSON wire format (a one-way door); sampling math is deliberately deferred to PLT-460.
What
config/distribution.go— aDistributiontagged type mirroringconfig/gas.go'sGasPickerdiscriminator exactly:Name-tagged two-passUnmarshalJSON, unexportedindexSamplerinterface + compile-time assertions, louddefault:error on unknown kinds. Kinds:"uniform","zipfian"(paramtheta, range-validated at parse time).KeyDistribution/SizeDistribution(*Distribution,omitempty) onconfig.Scenario, nil-guarded like the existing gas-picker field.Locked wire format (one-way door)
Discriminator
Name; kindsuniform/zipfian; zipfian paramtheta. Frozen — documented in code.Deferred to PLT-460
SampleIndexis a clearly-marked placeholder (return 0, nil) — the YCSB precomputed-zeta zipfian + uniform draw (using the PLT-456 seeded RNG) lands there. Confirmed no existing caller can reach it.Additive
A config with no distribution fields round-trips byte-identically (golden test against
profiles/conflict.json); no existing profile changes meaning.Tests / review
go build+go test -race ./config/...green. Idiom cross-review: clean (faithfulgas.gomirror).Decision brief:
designs/sei-load-workload-modeler/PLT-455-distribution-discriminator.md(sei-protocol/bdchatham-designs).🤖 Generated with Claude Code