Enforce valuation stock class references#248
Conversation
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 42 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (3)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
…ht-references' into codex/ocf-valuation-stock-class-reference
There was a problem hiding this comment.
Pull request overview
Adds referential-integrity validation to ensure every Valuation.stock_class_id points to a stock class present in the final CapTable state after a batch update, aligning CapTable behavior with the OCF requirement that stock_class_id is required and meaningful.
Changes:
- Add CapTable-level validation that all valuations reference an existing stock class in the final maps.
- Add Daml Script tests covering same-batch creation, missing references on create/edit, and prevention of deleting a referenced stock class.
- Update the built DAR and lockfile to reflect the generated/compiled changes.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| Test/daml/OpenCapTable/TestValuationReferences.daml | Adds script tests for valuation → stock class reference enforcement across create/edit/delete scenarios. |
| scripts/codegen/templates/CapTable.daml.template | Introduces validateValuationStockClassReferences and wires it into UpdateCapTable validation on finalMaps. |
| dars/OpenCapTable-v34/0.0.2/OpenCapTable-v34.dar | Updates the compiled DAR artifact containing the new validation logic. |
| dars/dars.lock | Updates DAR sha/size metadata for the new build artifact. |
|
Superseded by #251, which consolidates the reference-integrity work into one PR. Before closing this stack PR, I rechecked the live review comments and folded the actionable improvements into #251: StockPlan create-tier ordering, document related-object error messages, stock-class conversion source IDs, warrant conversion validation across all OcfAnyConversionRight variants, WarrantIssuance same-batch vesting-term edits, and immutable DAR backup versioning. |
Summary
Valuation.stock_class_idagainst the final CapTable stock-class map.OCF documentation
Valuation.schema.jsonrequiresstock_class_idand describes it as the identifier of the stock class for the valuation.Validation
NODE_PATH=/Users/fairnick/Documents/code/fairmint/open-captable-protocol-daml/node_modules PATH="/Users/fairnick/Documents/code/fairmint/open-captable-protocol-daml/node_modules/.bin:$HOME/.dpm/bin:$PATH" npm run buildJAVA_HOME=/opt/homebrew/opt/openjdk@17 PATH="/opt/homebrew/opt/openjdk@17/bin:$HOME/.dpm/bin:$PATH" dpm test --show-coverage --color --coverage-ignore-choice 'splice-amulet:.*'Note
Medium Risk
Tightens cap-table batch validation for a required OCF field; valid updates are unchanged, but operations that previously might succeed with dangling valuation references will now fail.
Overview
UpdateCapTablenow rejects batches that would leave valuations pointing at stock classes that are not on the cap table.A new
validateValuationStockClassReferencesstep runs on the post-batch maps (alongside existing conversion/document checks) and requires every valuation’sstock_class_idto exist instock_classes. That blocks creating or editing a valuation with a missing class and blocks deleting a stock class while a valuation still references it; same-batch create of class + valuation still succeeds when ordering/tiers allow both to land in the final maps.TestValuationReferences.damladds script coverage for those paths. The packagedOpenCapTable-v34DAR anddars.lockare updated to the rebuilt artifact.Reviewed by Cursor Bugbot for commit a260183. Bugbot is set up for automated code reviews on this repo. Configure here.