Fix MC nested-dataclass round-trip; add CI + vesting-curve test#16
Open
Pattermesh wants to merge 2 commits into
Open
Fix MC nested-dataclass round-trip; add CI + vesting-curve test#16Pattermesh wants to merge 2 commits into
Pattermesh wants to merge 2 commits into
Conversation
…g test The Monte Carlo config round-trip (_dict_to_config / _dict_to_dataclass) left revenue_streams and vest_buckets as dicts, so run() crashed with AttributeError: 'dict' object has no attribute 'volume_usd_m0'. Four existing monte_carlo tests failed on a clean clone. Root cause: _dict_to_config inferred list element types from a default SimConfig(), whose list fields are empty, so the reconstruction branch was dead. _dict_to_dataclass also called cls() with no args, which fails for dataclasses with required positional fields. Fix: declare the nested-list field -> dataclass mapping explicitly, and build dataclass instances directly from matching dict fields. Also add a GitHub Actions CI workflow (pytest on 3.10-3.12) and one vesting-curve test asserting the cliff holds supply flat then the bucket releases exactly fraction_of_supply * total_supply over the window. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Welcome to kcolbchain, @Pattermesh — glad you're here. 🌱 Here's what happens from this PR:
While you wait:
What happens after your first merge
Thanks for writing the code. We're building this to last. |
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.
What
tests/test_monte_carlo.pyfailed withAttributeError: 'dict' object has no attribute 'volume_usd_m0':_dict_to_config/_dict_to_dataclassleftrevenue_streamsandvest_bucketsas plain dicts, sorun()crashed._dict_to_configinferred the list element type from a defaultSimConfig(), whose list fields are empty (field(default_factory=list)), so the reconstruction branch was dead code._dict_to_dataclassdidcls()with no args, which raises for dataclasses with required positional fields (RevenueStream,VestBucket)..github/workflows/ci.yml): installs the package with dev extras and runspytest -qon Python 3.10, 3.11, 3.12, on push tomainand on PRs. No workflow existed before.test_vesting_curve_respects_cliff_and_unlocks_full_allocation): asserts supply stays flat through the cliff, then exactlyfraction_of_supply * total_supplyis released linearly over the unlock window with no overshoot. Mutation-checked: it fails if the cliff logic is removed.Verification
Clean clone +
pip install -e ".[dev]"+pytest -q:(18 pre-existing tests, previously 4 failing on a clean clone, plus the 1 new vesting-curve test.)
🤖 Generated with Claude Code