Enforce convertible conversion right references#246
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
…-right-references' into codex/ocf-convertible-conversion-right-references
There was a problem hiding this comment.
Pull request overview
Adds CapTable-level validation to ensure ConvertibleIssuance.conversion_triggers[].conversion_right.converts_to_stock_class_id (when set) references a stock class that exists in the final post-batch CapTable maps, and introduces regression tests covering create/edit/delete scenarios (including same-batch target creation). This aligns convertible conversion-right reference behavior with the existing stock-class conversion-right reference validation.
Changes:
- Add shared stock-class reference validators and apply them to both stock-class conversion rights and convertible conversion triggers.
- Validate convertible conversion trigger
converts_to_stock_class_idonly when present (keepingNonevalid for future/undetermined rounds). - Add DAML Script tests covering same-batch target creation, missing targets on create/edit, and preventing deletion of a referenced target; update packaged DAR + lock metadata.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| Test/daml/OpenCapTable/TestConvertibleConversionRightReferences.daml | New tests for convertible conversion-right stock-class reference validation across create/edit/delete workflows. |
| scripts/codegen/templates/CapTable.daml.template | Adds reusable stock-class reference validators and enforces convertible conversion trigger references during UpdateCapTable. |
| dars/OpenCapTable-v34/0.0.2/OpenCapTable-v34.dar | Updated packaged DAR reflecting the new validation logic. |
| dars/dars.lock | Updates DAR checksum/size metadata for the rebuilt 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
ConvertibleIssuance.conversion_triggers[].conversion_right.converts_to_stock_class_idvalues against the final CapTable stock-class map.OCF documentation
ConvertibleIssuance.schema.jsondefines convertible issuanceconversion_triggers.ConvertibleConversionRight.schema.jsonspecializes conversion rights for convertibles.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
Changes cap-table batch acceptance rules for convertible conversion targets; behavior is scoped to post-batch validation with script coverage, but incorrect logic could block valid updates or allow invalid references.
Overview
UpdateCapTablenow rejects batches where a convertible issuance’sconversion_triggerspoint at a stock class ID that isn’t in the final cap table map. Whenconverts_to_stock_class_idis unset (None), validation still passes so future-round convertibles stay valid.The CapTable codegen template adds shared
validateStockClassReference/validateOptionalStockClassReferencehelpers, refactors existing stock-class conversion-right checks to use them, and runsvalidateConvertibleConversionRightReferencesafter creates/edits/deletes (same timing as other reference validations).New DAML script tests cover same-batch target creation, missing targets on create/edit, and blocking stock-class deletes that would leave a dangling reference. The OpenCapTable-v34 DAR and
dars.lockare updated for the rebuilt package.Reviewed by Cursor Bugbot for commit 6841797. Bugbot is set up for automated code reviews on this repo. Configure here.