Skip to content

PLT-455: Distribution config primitive + discriminator#43

Merged
bdchatham merged 1 commit into
mainfrom
brandon2/plt-455-distribution-discriminator
Jun 11, 2026
Merged

PLT-455: Distribution config primitive + discriminator#43
bdchatham merged 1 commit into
mainfrom
brandon2/plt-455-distribution-discriminator

Conversation

@bdchatham

Copy link
Copy Markdown
Contributor

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 — a Distribution tagged type mirroring config/gas.go's GasPicker discriminator exactly: Name-tagged two-pass UnmarshalJSON, unexported indexSampler interface + compile-time assertions, loud default: error on unknown kinds. Kinds: "uniform", "zipfian" (param theta, range-validated at parse time).
  • Optional KeyDistribution / SizeDistribution (*Distribution, omitempty) on config.Scenario, nil-guarded like the existing gas-picker field.

Locked wire format (one-way door)

Discriminator Name; kinds uniform/zipfian; zipfian param theta. Frozen — documented in code.

Deferred to PLT-460

SampleIndex is 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 (faithful gas.go mirror).

Decision brief: designs/sei-load-workload-modeler/PLT-455-distribution-discriminator.md (sei-protocol/bdchatham-designs).

🤖 Generated with Claude Code

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>
@cursor

cursor Bot commented Jun 11, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Additive config and parsing only; no sampling logic or callers yet, with backward-compatible round-trip behavior covered by tests.

Overview
Adds a keyspace distribution config primitive (patterned after GasPicker) and wires it into load scenarios as optional keyDistribution / sizeDistribution fields.

The new Distribution type uses a frozen JSON discriminator (Name: uniform or zipfian), validates zipfian theta at parse time, and rejects unknown kinds. SampleIndex is intentionally stubbed (0, nil) until PLT-460 implements actual uniform/zipfian draws.

Tests cover unmarshaling/validation and prove existing profiles without these fields still parse and remarshal without adding distribution keys (golden check on profiles/conflict.json).

Reviewed by Cursor Bugbot for commit efc85ec. Bugbot is set up for automated code reviews on this repo. Configure here.

@bdchatham bdchatham merged commit ac7ef08 into main Jun 11, 2026
4 checks passed
@bdchatham bdchatham deleted the brandon2/plt-455-distribution-discriminator branch June 11, 2026 23:23
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