Enforce document related object references#244
Conversation
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 42 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 (4)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
…-ceiling' into codex/ocf-document-related-object-references
…-ceiling' into codex/ocf-document-related-object-references
There was a problem hiding this comment.
Pull request overview
Adds final-state CapTable validation to ensure Document.related_objects references resolve to the current issuer or to an object/transaction present in the cap table maps, and expands DAML Script tests to cover valid/invalid document reference scenarios (including unsupported OCF object types).
Changes:
- Add
Document.related_objectsreference validation in the generatedCapTableupdate flow (runs after deletes/edits/issuer edit/creates). - Extend CapTable codegen to emit object-type constructor matches (including change-event overrides) and handle
Documentimports cleanly. - Update/add document tests for issuer/object existence checks, same-batch references, and unsupported object types.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| Test/daml/OpenCapTable/TestDocument.daml | Adds helper + new tests around Document.related_objects validation semantics. |
| scripts/codegen/templates/CapTable.daml.template | Implements final-state validation for document related-object references and wires it into UpdateCapTable. |
| scripts/codegen/generate-captable.ts | Extends type discovery metadata to generate correct OcfObjectType constructor matches (incl. overrides) and document handling. |
| dars/OpenCapTable-v34/0.0.2/OpenCapTable-v34.dar | Updates compiled DAR artifact to include the new validation behavior. |
| dars/dars.lock | Updates DAR lock metadata (sha/size/timestamp) for the new artifact. |
| OcfObjIssuer -> do | ||
| issuerContract <- fetch issuerCid | ||
| assertMsg ("Issuer not found: " <> ref.object_id) (ref.object_id == issuerContract.issuer_data.id) |
| {{object_type_constructor}} -> | ||
| assertMsg ("{{name}} not found: " <> ref.object_id) (isSome (Map.lookup ref.object_id maps.{{map_field}})) | ||
| {{/each}} | ||
| _ -> assertMsg ("Unsupported related object type: " <> ref.object_id) False |
|
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
Stacked on #243.
This adds final-state validation for
Document.related_objects:FINANCINGand plan-security transaction aliases, are rejected instead of being accepted as dangling IDs.OCF documentation
Document.related_objectsis a list of related OCF object references: https://github.com/Open-Cap-Table-Coalition/Open-Cap-Format-OCF/blob/main/schema/objects/Document.schema.json#L20-L27ObjectReference.object_typeandobject_id: https://github.com/Open-Cap-Table-Coalition/Open-Cap-Format-OCF/blob/main/schema/types/ObjectReference.schema.json#L8-L18ObjectTypeenum values: https://github.com/Open-Cap-Table-Coalition/Open-Cap-Format-OCF/blob/main/schema/enums/ObjectType.schema.json#L7-L64Tests
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 buildTest/: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
Batch commits can now fail when documents carry invalid or unsupported related-object refs, which may break previously accepted updates; logic is localized to document validation at the end of UpdateCapTable.
Overview
UpdateCapTablenow runs final-state validation on every document’srelated_objectsafter deletes, edits, issuer updates, and creates complete, so references must point at the cap table’s issuer or an ID present in the corresponding object/transaction map (including objects created in the same batch).Codegen adds
validateObjectReference/validateDocumentRelatedObjects, maps each modeledOcfObjectTypeto the right cap-table map (with transaction and change-event constructor naming), and fails on unsupported enum values (e.g.FINANCING) instead of accepting dangling IDs. The packaged OpenCapTable-v34 DAR anddars.lockare refreshed.Document tests gain a
documentDatahelper plus scenarios for missing issuer refs, same-batch stock-class refs, edit-time missing refs, and unsupported related types; the optional-fields test now uses the real issuer idISSUER_1.Reviewed by Cursor Bugbot for commit 802c70f. Bugbot is set up for automated code reviews on this repo. Configure here.