Skip to content

Enforce stock class conversion right references#245

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

Enforce stock class conversion right references#245
HardlyDifficult wants to merge 3 commits into
codex/ocf-document-related-object-referencesfrom
codex/ocf-stock-class-conversion-right-references

Conversation

@HardlyDifficult

@HardlyDifficult HardlyDifficult commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add a final-state CapTable validation pass that checks every StockClass.conversion_rights[].converts_to_stock_class_id resolves to an existing stock class.
  • Cover same-batch target creation, missing targets on create/edit, and deleting a target that would leave a dangling conversion right.
  • Update existing conversion-right fixtures so positive tests create the SC_COMMON target they reference.

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
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_id must 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 and dars.lock were 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.

@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 41 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 46e1b520-ab26-44f5-98fa-616419806cfe

📥 Commits

Reviewing files that changed from the base of the PR and between 802c70f and 04aa001.

⛔ Files ignored due to path filters (1)
  • dars/dars.lock is excluded by !**/*.lock
📒 Files selected for processing (5)
  • Test/daml/OpenCapTable/TestConversionMechanisms.daml
  • Test/daml/OpenCapTable/TestStockClass.daml
  • Test/daml/OpenCapTable/TestStockClassConversionRightReferences.daml
  • dars/OpenCapTable-v34/0.0.2/OpenCapTable-v34.dar
  • scripts/codegen/templates/CapTable.daml.template
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/ocf-stock-class-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 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_id cannot 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_COMMON stock 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)
@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