Skip to content

Enforce valuation stock class references#248

Closed
HardlyDifficult wants to merge 3 commits into
codex/ocf-warrant-conversion-right-referencesfrom
codex/ocf-valuation-stock-class-reference
Closed

Enforce valuation stock class references#248
HardlyDifficult wants to merge 3 commits into
codex/ocf-warrant-conversion-right-referencesfrom
codex/ocf-valuation-stock-class-reference

Conversation

@HardlyDifficult

@HardlyDifficult HardlyDifficult commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Validate each Valuation.stock_class_id against the final CapTable stock-class map.
  • Cover same-batch stock-class creation, missing targets on create/edit, and deleting a referenced stock class.

OCF documentation

  • Valuation.schema.json requires stock_class_id and 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 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
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
UpdateCapTable now rejects batches that would leave valuations pointing at stock classes that are not on the cap table.

A new validateValuationStockClassReferences step runs on the post-batch maps (alongside existing conversion/document checks) and requires every valuation’s stock_class_id to exist in stock_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.daml adds script coverage for those paths. The packaged OpenCapTable-v34 DAR and dars.lock are 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.

@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: 42 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: 7bf7f7de-1bab-47ad-9772-addf3f35600b

📥 Commits

Reviewing files that changed from the base of the PR and between f937857 and a260183.

⛔ Files ignored due to path filters (1)
  • dars/dars.lock is excluded by !**/*.lock
📒 Files selected for processing (3)
  • Test/daml/OpenCapTable/TestValuationReferences.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-valuation-stock-class-reference

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 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.

@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