Skip to content

Enforce OCF adjustment state integrity#280

Open
HardlyDifficult wants to merge 2 commits into
codex/ocf-vesting-quantity-integrityfrom
codex/ocf-adjustment-state-integrity
Open

Enforce OCF adjustment state integrity#280
HardlyDifficult wants to merge 2 commits into
codex/ocf-vesting-quantity-integrityfrom
codex/ocf-adjustment-state-integrity

Conversation

@HardlyDifficult

@HardlyDifficult HardlyDifficult commented Jul 12, 2026

Copy link
Copy Markdown
Collaborator

Summary

Enforce one OCF adjustment-state integrity category across issuer authorization, stock-class authorization, stock-plan pools, and stock-class conversion ratios:

  • treat OCF transaction dates as calendar dates rather than allowing DAML transport timestamps to create an intra-day ordering
  • reject conflicting absolute adjustment states for the same target on the same OCF date while allowing repeated declarations of the identical state
  • apply an adjustment for the entire OCF date in all historical/as-of ceiling and conversion-ratio lookups
  • compare the complete ratio conversion mechanism, including conversion price, ratio, and rounding behavior
  • require a stock-class conversion-ratio adjustment to target a class that actually declares a ratio conversion right
  • validate the submitted final cap-table state so creates, edits, deletes, replacements, and upgraded contracts cannot leave ambiguous histories

This removes the previous implementation-specific same-timestamp tie breakers. OCF provides only a date and declares the new absolute state, so two different states for one target on one date cannot be ordered consistently.

OCF requirement references

Validated against Open Cap Format commit dd84bdb6bafb63681c77166f315cea5a2078a4c8:

The same-date conflict rule is the consistency invariant implied by those definitions: each transaction supplies an absolute state, but the OCF date type supplies no sub-day ordering with which to choose between conflicting values.

Coverage

Behavioral coverage includes:

  • conflicting and identical same-date issuer authorization adjustments
  • conflicting and identical same-date stock-class authorization adjustments
  • conflicting and identical same-date stock-plan pool adjustments
  • conflicting and identical same-date conversion-ratio adjustments
  • full conversion-mechanism comparison beyond the numeric ratio
  • same-date historical effectiveness for all four adjustment families
  • ratio-target eligibility and missing-target rejection
  • final-state validation across edit/delete replacement paths

Validation

Exact head: 6aec384921802ee526f07d411e083e74c6009716

  • npm test (770 DAML scripts)
  • npm run build
  • npm run format
  • npm run lint (0 errors; 2 pre-existing warnings)
  • npm run lint:daml (no hints)
  • npm run check:schema-gaps -- --ocf-schema-dir /tmp/ocf-audit.v3uqeD/schema (55/55 clean; 1 intentional helper skip)
  • npm run verify-package
  • npm run verify-dars (18 DARs)
  • npm run check-upgrade-compat (0.0.17 -> 0.0.18)
  • clean generated output and working tree

Package

Bumps OpenCapTable-v34 to 0.0.18.

DAR SHA-256: f73752ab485c0926f61bd0d4c5b1be9b4a7aff35902d170189238c2424650805 (3,449,292 bytes).

Stack

Targets codex/ocf-vesting-quantity-integrity so this PR contains only adjustment-state integrity. Retarget to main after the base PR lands.


Note

High Risk
Changes core cap-table authorization, pool, and conversion-ratio validation used on every UpdateCapTable; incorrect semantics could reject valid cap tables or accept ambiguous histories.

Overview
Bumps OpenCapTable-v34 to 0.0.18 and ships the updated DAR; Test depends on the new package.

Cap table logic now treats OCF transaction dates as calendar dates (ocfDate / ocfDateOnOrBefore), so intra-day DAML timestamps no longer pick winners among adjustments on the same day. Same-day precedence tie-breakers (e.g. lower authorized shares or “higher ratio”) are removed; only later OCF dates win.

recordAdjustmentState and validateAdjustmentStateIntegrity run on UpdateCapTable final state: conflicting absolute adjustment values for the same target on one OCF date fail; identical repeats are allowed. This covers issuer authorized shares, stock-class authorized shares, stock-plan pool adjustments, and conversion-ratio adjustments (full new_ratio_conversion_mechanism equality). Ratio adjustments must target a class with a ratio conversion right.

DAML scripts replace old “same date lower wins” scenarios with tests for conflicts, identical same-date success, whole-day effectiveness, final-state edit/delete paths, ratio-target eligibility, and full-mechanism same-date conflicts.

Reviewed by Cursor Bugbot for commit 6aec384. Bugbot is set up for automated code reviews on this repo. Configure here.

@coderabbitai

coderabbitai Bot commented Jul 12, 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: 58 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: 8ae8f938-080e-44c2-8182-318bb9d7c162

📥 Commits

Reviewing files that changed from the base of the PR and between b4e81c2 and 6aec384.

⛔ Files ignored due to path filters (1)
  • dars/dars.lock is excluded by !**/*.lock
📒 Files selected for processing (8)
  • OpenCapTable-v34/daml.yaml
  • Test/daml.yaml
  • Test/daml/OpenCapTable/TestIssuerAuthorizedShares.daml
  • Test/daml/OpenCapTable/TestStockClassAuthorizedShares.daml
  • Test/daml/OpenCapTable/TestStockClassConversionRatioAdjustment.daml
  • Test/daml/OpenCapTable/TestStockPlanReservedShares.daml
  • dars/OpenCapTable-v34/0.0.18/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-adjustment-state-integrity

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

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

This PR enforces OCF adjustment-state integrity by treating OCF transaction times as calendar dates (no intra-day ordering), rejecting conflicting same-date absolute states, and validating conversion-ratio adjustment eligibility and final-state consistency.

Changes:

  • Normalize adjustment precedence/effectiveness to OCF calendar dates (ignore intra-day timestamps) and apply adjustments for the entire OCF date in “as-of” lookups.
  • Add final-state integrity validation to reject conflicting same-date adjustment states (while allowing identical re-declarations) and validate conversion-ratio adjustment eligibility.
  • Expand DAML script coverage for conflicting/identical same-date adjustments and same-date effectiveness; bump OpenCapTable-v34 to 0.0.18 and update DAR artifacts/locks.

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
scripts/codegen/templates/CapTable.daml.template Implements OCF-date normalization, same-date conflict detection, and final-state validation hook.
Test/daml/OpenCapTable/TestIssuerAuthorizedShares.daml Updates tests for same-OCF-date conflict/identity rules and full-day effectiveness.
Test/daml/OpenCapTable/TestStockClassAuthorizedShares.daml Updates tests for stock-class auth + conversion-ratio adjustments under OCF-date semantics.
Test/daml/OpenCapTable/TestStockPlanReservedShares.daml Updates stock-plan pool adjustment tests for same-OCF-date conflict/identity and full-day effectiveness.
Test/daml/OpenCapTable/TestStockClassConversionRatioAdjustment.daml Adds tests for ratio-right requirement, final-state validation behavior, and full-mechanism comparisons.
Test/daml.yaml Bumps test package data-dependency DAR to 0.0.18.
OpenCapTable-v34/daml.yaml Bumps package version to 0.0.18.
dars/OpenCapTable-v34/0.0.18/OpenCapTable-v34.dar Adds the 0.0.18 DAR (Git LFS pointer).
dars/dars.lock Registers the new DAR hash/metadata for 0.0.18.

Comment thread scripts/codegen/templates/CapTable.daml.template
@HardlyDifficult HardlyDifficult marked this pull request as ready for review July 12, 2026 02:09

Copy link
Copy Markdown
Collaborator Author

@copilot review exact head 6aec384921802ee526f07d411e083e74c6009716. Please review the adjustment-state integrity category, including OCF calendar-date normalization, conflicting same-date absolute-state rejection, full ratio-mechanism comparison, ratio-target eligibility, and the final-state create/edit/delete paths. Exact-head CI and all 770 local DAML scripts are green; the earlier missing-target comment is covered by the shared final-state reference validator and a new explicit regression test.

Copy link
Copy Markdown
Collaborator Author

@codex review exact head 6aec384921802ee526f07d411e083e74c6009716. Focus on whether the final-state same-date conflict rule is complete across all four adjustment families and whether calendar-day normalization changes any historical ceiling behavior incorrectly. Copilot was requested first; CI and all 770 scripts are green.

@HardlyDifficult

Copy link
Copy Markdown
Collaborator Author

@cursor review exact head 6aec384921802ee526f07d411e083e74c6009716. Please inspect adjustment-state final-state integrity, OCF calendar-day handling, and ratio-target eligibility. Copilot was requested first; exact-head CI and all 770 DAML scripts are green.

@cursor cursor Bot 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.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 6aec384. Configure here.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: 6aec384921

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@HardlyDifficult

Copy link
Copy Markdown
Collaborator Author

@copilot review exact head 6aec384921802ee526f07d411e083e74c6009716. This is one follow-up because the only submitted Copilot review is still attached to stale commit 2cc6a4da18b1e9cd234007b5fa8f42073c1c9ad8, and the earlier exact-head request has had no response for over two hours. Please review adjustment-state calendar-date normalization, conflicting same-date absolute states, ratio-mechanism equality, ratio-target eligibility, and final-state create/edit/delete behavior. Exact-head CI and all 770 scripts remain green.

Copilot AI commented Jul 12, 2026

Copy link
Copy Markdown

@copilot review exact head 6aec384921802ee526f07d411e083e74c6009716. This is one follow-up because the only submitted Copilot review is still attached to stale commit `2cc6a4da18b1e9cd234007b5fa8f42...

Reviewed exact head 6aec384. The final-state same-date conflict rule is complete across all four adjustment families via validateAdjustmentStateIntegrity and recordAdjustmentState, with full new_ratio_conversion_mechanism equality for ratio adjustments and ratio-right eligibility checks in place. Calendar-day normalization is applied consistently through ocfDate/ocfDateOnOrBefore in all as-of ceiling/reserved-share/ratio lookups, and coverage includes conflicting vs identical same-date cases plus whole-day effectiveness and create/edit/delete final-state paths. I don’t see additional changes needed on top of this head.

@HardlyDifficult HardlyDifficult marked this pull request as draft July 13, 2026 19:06
@HardlyDifficult HardlyDifficult requested a review from Copilot July 13, 2026 19:39
@HardlyDifficult HardlyDifficult marked this pull request as ready for review July 13, 2026 19:39

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

Copilot reviewed 8 out of 9 changed files in this pull request and generated no new comments.

@HardlyDifficult HardlyDifficult marked this pull request as draft July 13, 2026 20:28
@HardlyDifficult HardlyDifficult marked this pull request as ready for review July 13, 2026 20:43
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.

3 participants