PM 31023 - Creating density models for Seeder#7157
Draft
theMickster wants to merge 12 commits intomainfrom
Draft
PM 31023 - Creating density models for Seeder#7157theMickster wants to merge 12 commits intomainfrom
theMickster wants to merge 12 commits intomainfrom
Conversation
Contributor
|
Great job! No new security vulnerabilities introduced in this pull request |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7157 +/- ##
==========================================
+ Coverage 56.68% 56.77% +0.08%
==========================================
Files 2026 2026
Lines 88681 88685 +4
Branches 7905 7906 +1
==========================================
+ Hits 50272 50348 +76
+ Misses 36585 36507 -78
- Partials 1824 1830 +6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.




🎟️ Tracking
PM-31023 - Relational Density Modeling
PM-32777 - Baked-In Density Preset Profiles
📔 Objective
Complete the density modeling additions to the Seeder in our presets. The work represents a sizable shift in the way the Seeder was first allocating entities as it created them. By leveraging the new JSON density property, we can now make precise adjustments to allocate entity distribution without changing the Seeder.
Key changes
Note on the Hamilton apportionment bug
The Distribution.Select() method divides items into percentage-based buckets using integer truncation, which leaves unclaimed remainder items. The old code silently dumped all remainder onto the last bucket — so a zero-weight HidePasswords bucket would still receive items. The fix uses Hamilton apportionment (largest-remainder method): remainder items go one-at-a-time to whichever buckets lost the most from truncation, and zero-weight buckets are guaranteed to receive exactly zero.
Alexander Hamilton — the first U.S. Secretary of the Treasury. He proposed this method in 1792 to apportion congressional seats among states. The math problem is the same: distribute a fixed number of indivisible items (seats, or in our case collection permissions) proportionally across groups when the proportional shares aren't whole numbers.
Where did our distribution statistics come from?
The scale preset archetypes are modeled after three real production organizations analyzed in DBOPS-91: Company A (hierarchical, 2,795 users/74 groups), Company B (flat, 11,491 users/5 groups/13,906 collections), and Company C (balanced, 954 users/99 groups). These profiles revealed that production relationship patterns follow power-law and mega-group distributions — not the uniform round-robin the seeder previously generated. Each scale preset's density parameters (membership skew, collection fan-out, permission weights, orphan rates) were calibrated to reproduce these observed production shapes at five tiers from family (6 users) to mega-corp (10,000 users).
Why the re-organization or presets?
The seeder is still early-adoption — breaking preset names now costs nearly nothing, but doing it after teams build scripts around them has cost. Purpose-based folders (features/qa/scale/validation) make preset discovery self-documenting so engineers don't need to read a README to find the right one. Consolidating docs into Seeds/docs/ eliminates duplication across scattered READMEs and separates everyday usage from developer-only verification content.
🧪 Testing
Expand for detailed instructions
Step 1: Verify preset resolution (all 4 folders)
From util/SeederUtility/, run one preset from each folder:
All four should seed successfully with no errors.
Step 2: Verify density distributions on a scale preset
Seed a mid-tier and large-tier preset:
After each, run the verification queries from util/Seeder/Seeds/docs/verification.md against your local MSSQL database. Compare results to the expected-value tables in the same doc.
Key things to verify
Step 3: Verify backward compatibility
Seed the no-density validation preset:
Key things to verify
This confirms the null-density path is unchanged.
Claude Code prompt for verification
Note: Mick has a
reading-bw-mssqlskill that automates the pwsh/SqlClient connection pattern. If you'd like it for your Claude Code setup, ask him to share it.If you'd like Claude Code to run the verification queries for you, use this prompt after seeding: