Skip to content

Enforce convertible conversion right references#246

Closed
HardlyDifficult wants to merge 3 commits into
codex/ocf-stock-class-conversion-right-referencesfrom
codex/ocf-convertible-conversion-right-references
Closed

Enforce convertible conversion right references#246
HardlyDifficult wants to merge 3 commits into
codex/ocf-stock-class-conversion-right-referencesfrom
codex/ocf-convertible-conversion-right-references

Conversation

@HardlyDifficult

@HardlyDifficult HardlyDifficult commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Validate declared ConvertibleIssuance.conversion_triggers[].conversion_right.converts_to_stock_class_id values against the final CapTable stock-class map.
  • Keep unset convertible conversion targets valid so future/undetermined conversion rounds can still be represented.
  • Cover same-batch stock-class target creation, missing targets on create/edit, and deleting a referenced target.

OCF documentation

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 build
  • JAVA_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
UpdateCapTable now rejects batches where a convertible issuance’s conversion_triggers point at a stock class ID that isn’t in the final cap table map. When converts_to_stock_class_id is unset (None), validation still passes so future-round convertibles stay valid.

The CapTable codegen template adds shared validateStockClassReference / validateOptionalStockClassReference helpers, refactors existing stock-class conversion-right checks to use them, and runs validateConvertibleConversionRightReferences after 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.lock are 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.

@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: a83ad014-2641-4251-b23a-4bd85d3de299

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/ocf-convertible-conversion-right-references

Comment @coderabbitai help to get the list of available commands.

@HardlyDifficult
HardlyDifficult marked this pull request as ready for review July 8, 2026 23:48
@HardlyDifficult
HardlyDifficult requested a review from Copilot July 8, 2026 23:48

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_id only when present (keeping None valid 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.

@HardlyDifficult

Copy link
Copy Markdown
Collaborator Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants