Enforce stock class conversion right references#245
Conversation
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 41 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 (5)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
…t-references' into codex/ocf-stock-class-conversion-right-references
There was a problem hiding this comment.
Pull request overview
Adds a final-state CapTable validation step to ensure every stock-class conversion right (StockClass.conversion_rights[].converts_to_stock_class_id) points to an existing stock class, preventing dangling references after batch creates/edits/deletes and aligning behavior with the OCF schema expectations.
Changes:
- Add post-batch validation to reject any stock class conversion right whose
converts_to_stock_class_idcannot be resolved in the final CapTable maps. - Introduce a focused Daml Script test module covering same-batch target creation, missing targets on create/edit, and target deletion that would leave a dangling reference.
- Update existing conversion-right test fixtures to create the referenced
SC_COMMONstock class where needed.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| Test/daml/OpenCapTable/TestStockClassConversionRightReferences.daml | New tests specifically exercising conversion-right target resolution across create/edit/delete scenarios. |
| Test/daml/OpenCapTable/TestStockClass.daml | Refactors/commonizes the “SC_COMMON” fixture and ensures tests that reference SC_COMMON create it. |
| Test/daml/OpenCapTable/TestConversionMechanisms.daml | Ensures stock-class conversion-right tests create SC_COMMON so referenced conversion targets exist. |
| scripts/codegen/templates/CapTable.daml.template | Implements final-state validation over StockClass.conversion_rights to enforce target existence. |
| dars/OpenCapTable-v34/0.0.2/OpenCapTable-v34.dar | Updates the packaged DAR artifact to reflect the new validation logic. |
| dars/dars.lock | Updates DAR hash/size metadata to match the new artifact. |
| mapA_ | ||
| (\conversionRight -> | ||
| assertMsg | ||
| ("Stock class conversion target not found: " <> conversionRight.converts_to_stock_class_id) |
|
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
StockClass.conversion_rights[].converts_to_stock_class_idresolves to an existing stock class.SC_COMMONtarget they reference.OCF documentation
StockClass.schema.jsondefinesconversion_rightsas the stock-class conversion-right array.StockClassConversionRight.schema.jsondescribes conversion from one stock class into another stock class.ConversionRight.schema.jsondescribesconverts_to_stock_class_idas the identifier of an existing, known stock class.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
Adds referential integrity on cap table mutations; invalid batches fail where they might have succeeded before, but scope is limited to stock-class conversion targets.
Overview
CapTable batch updates now run a final-state check: every
conversion_rights[].converts_to_stock_class_idmust point at a stock class present in the cap table maps after creates/edits/deletes (same pattern as document related-object validation).New Daml script tests cover same-batch target creation, missing targets on create/edit, and blocking delete of a class still referenced by another class’s conversion right.
Existing conversion-mechanism and stock-class tests were adjusted so positive paths create the common target (
SC_COMMON/defaultStockClass) that fixtures already reference. The packaged OpenCapTable-v34 DAR anddars.lockwere refreshed for the template change.Reviewed by Cursor Bugbot for commit 04aa001. Bugbot is set up for automated code reviews on this repo. Configure here.