Skip to content

Add lossless typed vesting readers#433

Draft
HardlyDifficult wants to merge 14 commits into
codex/decoder-backed-transfer-readersfrom
codex/decoder-backed-vesting-readers
Draft

Add lossless typed vesting readers#433
HardlyDifficult wants to merge 14 commits into
codex/decoder-backed-transfer-readersfrom
codex/decoder-backed-vesting-readers

Conversation

@HardlyDifficult

@HardlyDifficult HardlyDifficult commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • decode vesting terms, starts, events, and accelerations through exact pinned generated DAML codecs with detached source/decoder/encoder ownership and lossless round-trip enforcement
  • validate exact template identity, non-empty text, Time/Numeric semantics, cardinality, graph reachability and cycles, context shape, and bounded hostile inputs before conversion
  • expose recursively readonly generated reader inputs and runtime-frozen OCF results while retaining exact writable DAML output contracts
  • preserve stable field-specific diagnostics, canonical wrapper precedence, and non-recursive graph validation for deeply nested schedules
  • add source and built declaration contracts plus reader, writer, aliasing, text, cardinality, graph-depth, malformed-ledger, and hostile-boundary coverage

Validation

  • npm run test:ci — 106 suites, 6,024 tests
  • npm run test:declarations
  • npm run lint
  • npm run format
  • npm pack --dry-run — 1,234 files, 567.8 kB packed / 3.2 MB unpacked
  • git diff --check

Stack

@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Vesting entities now use dedicated generated-wrapper decoding, shared validation and numeric converters, typed reader results, stricter template identity checks, iterative graph validation, and expanded tests for boundary safety, deep graphs, round trips, and type contracts.

Changes

Vesting decoding and conversion

Layer / File(s) Summary
Vesting wrapper decoding and dispatch
src/functions/OpenCapTable/capTable/damlEntityData.ts, src/functions/OpenCapTable/capTable/vestingContractData.ts, src/functions/OpenCapTable/capTable/damlToOcf.ts, src/functions/OpenCapTable/capTable/ocfToDaml.ts, test/functions/vestingBoundarySafety.test.ts, test/validation/generatedDamlBoundary.test.ts
Vesting entities are routed through generated codecs with plain-data validation, lossless round-trip checks, and structured parse diagnostics.
Shared text and entity conversion
src/functions/OpenCapTable/shared/*, src/functions/OpenCapTable/vestingStart/*, src/functions/OpenCapTable/vestingEvent/*, src/functions/OpenCapTable/vestingAcceleration/*, test/converters/valuationVestingConverters.test.ts
Required text, comments, dates, and positive quantities use shared typed conversion pipelines while empty strings remain valid schema values.
Vesting terms numeric and graph validation
src/functions/OpenCapTable/vestingTerms/*, test/functions/vestingGraphDepth.test.ts, test/converters/valuationVestingConverters.test.ts
Vesting terms use shared numeric parsing and iterative graph traversal for deep references, cycle detection, and ancestor classification.
Typed vesting readers and template checks
src/functions/OpenCapTable/vesting*/get*AsOcf.ts, src/utils/templateIdentity.ts, test/functions/vestingReaders.test.ts, test/functions/vestingTextRoundtrip.test.ts, test/types/vestingReaders.types.ts, test/declarations/vestingReaders.types.ts, test/validation/damlToOcfValidation.test.ts, test/utils/templateIdentity.test.ts
Reader functions enforce expected templates, decode canonical wrapper data, return { event, contractId }, and expose corresponding compile-time type contracts.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant VestingReader
  participant LedgerJsonApiClient
  participant VestingCodec
  participant NativeConverter
  Client->>VestingReader: request vesting entity
  VestingReader->>LedgerJsonApiClient: read contract with expected template
  LedgerJsonApiClient-->>VestingReader: contractId and createArgument
  VestingReader->>VestingCodec: decode generated wrapper
  VestingCodec-->>VestingReader: canonical vesting data
  VestingReader->>NativeConverter: convert decoded data
  NativeConverter-->>Client: event and contractId
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 31.71% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed Title clearly reflects the main change: adding typed vesting readers and related lossless reader/result contract updates.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/decoder-backed-vesting-readers

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

@HardlyDifficult

Copy link
Copy Markdown
Collaborator Author

@coderabbitai pause

@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown
✅ Action performed

Reviews paused.

@HardlyDifficult

Copy link
Copy Markdown
Collaborator Author

Implementation validation update for head 9bac6bb:

  • Normal merge commit parents: 7bbb222 and corrected transfer-reader head 2991df8; ancestry check passed.
  • All merge conflicts resolved; no conflict markers, unstaged changes, or diff-check errors remain.
  • Full test/coverage: 103 suites and 5,846 tests passed; coverage is 89.88% statements, 81.79% branches, 89.76% functions, and 90.52% lines.
  • Focused vesting validation: deep 5k graph read/write/dispatcher/ledger boundaries, 20k reachability stress, trap-safe writer/reader inputs, generated-wrapper losslessness, empty text/comments, zero-length periods, numeric/Int lexical boundaries, and exact diagnostics all pass.
  • Build, source typecheck, built declarations, exact public config, built cardinality, package-consumer typecheck, lint with zero warnings, and Prettier check all pass.
  • Canonical schema inventory was regenerated twice with identical hash 2869ff5b6efccec4da103ee5a6aeda5d25747866 and fingerprint e1ac1de3030914e4d1c25872bb43f2dd4af2d0794a1d78180ad446cb2b941a56.
  • The four named vesting getters now expose the exact common result shape { event, contractId }, asserted against both source and built declarations.

GitHub currently reports the branch mergeable. CodeRabbit is successful; build-and-test and quickstart integration are in progress. The PR remains draft and unassigned, with no review requests added.

@HardlyDifficult

HardlyDifficult commented Jul 12, 2026

Copy link
Copy Markdown
Collaborator Author

Vesting hardening and final transfer-review propagation are pushed at exact head 5fdf56b on exact base 6f87de5.

This revision fixes the independent audit findings:

  • all four vesting writers require their exact canonical object_type on direct and dispatcher paths
  • dispatcher writers retain descriptor-only trap safety
  • allocation-type failures precede simultaneous graph failures consistently across writer, dispatcher, direct reader, dispatcher reader, and ledger surfaces
  • distinct-target relative-ancestor traversals stop once every queried descendant is reached, eliminating the reproduced quadratic grandparent-chain behavior
  • the four transfer CodeRabbit fixes are propagated unchanged from the final base

Exact combined validation:

  • focused transfer plus vesting boundary matrix: 8 suites / 458 tests passed
  • full test:ci: 103 suites / 5,860 tests passed; 89.95% statements, 81.84% branches, 89.77% functions, 90.61% lines
  • declarations, clean build, exact public config, built cardinality, package consumer: passed
  • typecheck, ESLint with zero warnings, Prettier, diff and ancestry checks: passed
  • schema inventory stable across two regenerations: 55 variants, 0 aliases, reachable fingerprint e1ac1de3030914e4d1c25872bb43f2dd4af2d0794a1d78180ad446cb2b941a56; inventory file hash cf7a6f3176f9cb9f05a4a28fa7b3bbbbb2049a6755d75795fbae4ec56270f687

The PR remains draft and unassigned while fresh build and QuickStart checks run. No reviewers have been requested.

@HardlyDifficult HardlyDifficult marked this pull request as ready for review July 12, 2026 05:41
@HardlyDifficult

Copy link
Copy Markdown
Collaborator Author

@copilot review

Please perform the required formal review of exact current head 5fdf56b on exact stacked base 6f87de5. Both build-and-test and full QuickStart are green, GitHub is CLEAN/MERGEABLE, the PR is unassigned, and there are zero unresolved threads. Focus on exact vesting object_type enforcement, direct and dispatcher trap safety, allocation-versus-graph diagnostic precedence, iterative graph correctness and performance, lossless generated-codec boundaries, and exact public result types. Report every current-head actionable issue before Cursor or CodeRabbit review.

@HardlyDifficult

Copy link
Copy Markdown
Collaborator Author

@copilot review

Please run the required formal review now for unchanged exact head 5fdf56b. The earlier request overlapped another active Copilot review and produced no response. All checks, including automatic Cursor Bugbot, are now successful; GitHub remains CLEAN/MERGEABLE with zero threads. Review the vesting object_type, trap-safety, diagnostic-precedence, graph correctness/performance, generated-codec, and exact-type changes and report every actionable issue.

Copilot AI commented Jul 12, 2026

Copy link
Copy Markdown

@copilot review

Please perform the required formal review of exact current head 5fdf56b on exact stacked base 6f87de5. Both build-and...

Completed the formal review on head 5fdf56b against base 6f87de5 with focus on the requested vesting and transfer propagation areas. I did not find any current-head actionable issues in scope.

@HardlyDifficult

Copy link
Copy Markdown
Collaborator Author

@cursor review

Please perform an explicit review of exact current head 5fdf56b on base 6f87de5. Copilot completed the required formal exact-head review with no actionable findings: #433 (comment). All checks are green, GitHub is CLEAN/MERGEABLE, and there are zero threads. Focus on vesting discriminator enforcement, trap safety, error precedence, iterative graph correctness/performance, and exact types.

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

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 5fdf56b. Configure here.

Copilot AI commented Jul 12, 2026

Copy link
Copy Markdown

@copilot review

Please run the required formal review now for unchanged exact head 5fdf56b. The earlier request overlapped another active Copilot review and produced ...

Completed the formal review on exact head 5fdf56b against base 6f87de5 with the requested focus areas (vesting object_type enforcement, trap safety in direct/dispatcher paths, diagnostic precedence, graph correctness/performance, generated-codec boundaries, and exact public types). I found no current-head actionable issues.

@HardlyDifficult

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

The observed global included-review interval after the completed #432 substantive run has fully elapsed, and no later repository-wide CodeRabbit run has consumed the slot. Please now run and publish the complete substantive review pipeline for exact PR head 5fdf56bcbd80faa4841f1846af898523a4f8f227 against exact stacked base 6f87de5d9d0a467c5fcb701b6b0c52158cfd748e, covering every file in this PR. Copilot is exact-head clean (#433 (comment)), Cursor is exact-head clean (#433 (review)), all checks pass, GitHub is CLEAN/MERGEABLE, and all threads are resolved. Focus on exact vesting object_type enforcement, direct and dispatcher trap safety, allocation-before-graph diagnostic precedence, iterative graph correctness and deep-input performance, lossless generated-codec boundaries, Numeric(10)/integer exactness, and exact public result types. Publish every actionable finding.

@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown

@HardlyDifficult I'll run a full review of the current head now.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@HardlyDifficult

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

The full 11-minute availability window on Run ID c6b6f7b5-c56b-4785-a18c-3bbd7b932a50 has elapsed. Please now execute and publish the substantive review for exact PR head 5fdf56bcbd80faa4841f1846af898523a4f8f227 against exact stacked base 6f87de5d9d0a467c5fcb701b6b0c52158cfd748e, covering all 32 selected PR files. The preceding command was rate-limited before analysis; its acknowledgement and zero-second check were not a review. Copilot and Cursor are exact-head clean, both required checks pass, GitHub is CLEAN/MERGEABLE, and all threads are resolved. Review exact vesting object_type enforcement, direct and dispatcher trap safety, allocation-before-graph diagnostic precedence, iterative graph correctness and deep-input performance, lossless generated-codec boundaries, Numeric(10)/integer exactness, and exact public result types. Publish every actionable finding.

@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown

@HardlyDifficult I'll trigger another review pass now. Note that CodeRabbit reviews incrementally per commit — if head 5fdf56bcbd80faa4841f1846af898523a4f8f227 was already fully processed in the prior run, there won't be new findings to publish for that same commit; a fresh push (even a trivial one) would guarantee a new full pass. If you're only seeing an acknowledgement without a review body, that typically means there were no new commits since the last completed review rather than a rate limit.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/functions/OpenCapTable/vestingTerms/getVestingTermsAsOcf.ts`:
- Around line 423-428: Update the description spread in the common object within
getVestingTermsAsOcf to check c.description with a nullish guard, so both null
and undefined omit the optional description field while defined values remain
included.

In `@test/declarations/vestingReaders.types.ts`:
- Around line 18-20: Update the IsExactly helper in
test/declarations/vestingReaders.types.ts and test/types/vestingReaders.types.ts
to return false whenever either type operand is any, using IsAny before the
bidirectional exactness check. Preserve true results for genuinely identical
non-any types and ensure all existing exactness assertions use the strengthened
helper.
- Around line 88-89: Update the negative type assertion for
wrongPublicVestingTerms to assign a PublicVestingStartData value instead of
null, preserving the `@ts-expect-error` so the test verifies that public
vesting-start data is incompatible with OcfVestingTerms.

In `@test/functions/vestingGraphDepth.test.ts`:
- Around line 104-108: Remove the wall-clock assertion from the distinct-target
traversal test, while retaining the findVestingGraphIssue(...).toBeUndefined()
correctness check. Use the test’s existing Jest timeout configuration to detect
regressions without relying on performance.now() or a fixed 1,500 ms threshold.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: dad458b8-2314-4473-99bd-430a3cf3a960

📥 Commits

Reviewing files that changed from the base of the PR and between 6f87de5 and 5fdf56b.

📒 Files selected for processing (32)
  • src/functions/OpenCapTable/capTable/damlEntityData.ts
  • src/functions/OpenCapTable/capTable/damlToOcf.ts
  • src/functions/OpenCapTable/capTable/ocfToDaml.ts
  • src/functions/OpenCapTable/capTable/vestingContractData.ts
  • src/functions/OpenCapTable/shared/damlText.ts
  • src/functions/OpenCapTable/shared/transferWriterValidation.ts
  • src/functions/OpenCapTable/vestingAcceleration/damlToOcf.ts
  • src/functions/OpenCapTable/vestingAcceleration/getVestingAccelerationAsOcf.ts
  • src/functions/OpenCapTable/vestingAcceleration/vestingAccelerationDataToDaml.ts
  • src/functions/OpenCapTable/vestingEvent/damlToOcf.ts
  • src/functions/OpenCapTable/vestingEvent/getVestingEventAsOcf.ts
  • src/functions/OpenCapTable/vestingEvent/vestingEventDataToDaml.ts
  • src/functions/OpenCapTable/vestingStart/damlToOcf.ts
  • src/functions/OpenCapTable/vestingStart/getVestingStartAsOcf.ts
  • src/functions/OpenCapTable/vestingStart/vestingStartDataToDaml.ts
  • src/functions/OpenCapTable/vestingTerms/createVestingTerms.ts
  • src/functions/OpenCapTable/vestingTerms/getVestingTermsAsOcf.ts
  • src/functions/OpenCapTable/vestingTerms/vestingGraphValidation.ts
  • src/functions/OpenCapTable/vestingTerms/vestingPeriodInteger.ts
  • src/functions/OpenCapTable/vestingTerms/vestingQuantity.ts
  • src/utils/templateIdentity.ts
  • test/converters/valuationVestingConverters.test.ts
  • test/declarations/vestingReaders.types.ts
  • test/functions/generatedDamlReaderValidation.test.ts
  • test/functions/vestingBoundarySafety.test.ts
  • test/functions/vestingGraphDepth.test.ts
  • test/functions/vestingReaders.test.ts
  • test/functions/vestingTextRoundtrip.test.ts
  • test/types/vestingReaders.types.ts
  • test/utils/templateIdentity.test.ts
  • test/validation/damlToOcfValidation.test.ts
  • test/validation/generatedDamlBoundary.test.ts

Comment thread src/functions/OpenCapTable/vestingTerms/getVestingTermsAsOcf.ts
Comment thread test/declarations/vestingReaders.types.ts Outdated
Comment thread test/declarations/vestingReaders.types.ts Outdated
Comment thread test/functions/vestingGraphDepth.test.ts Outdated
@HardlyDifficult HardlyDifficult marked this pull request as draft July 12, 2026 07:28
@HardlyDifficult

Copy link
Copy Markdown
Collaborator Author

CodeRabbit completed its exact-head substantive pass and identified four actionable improvements. Returning this PR to draft while I fix and validate all four; reviewer gates will be rerun on the resulting exact head.

@HardlyDifficult

Copy link
Copy Markdown
Collaborator Author

@copilot review

Please perform the required formal review of exact current head f57e17a on exact stacked base 6f87de5. This revision addresses all four CodeRabbit findings with resolved threads: nullish omission of optional vesting-condition descriptions plus regression coverage, any-safe exact-type assertions, a real PublicVestingStartData incompatibility assertion, and removal of a flaky wall-clock bound while preserving the 20k correctness test and 30s Jest timeout. Both exact-head checks are green, GitHub is CLEAN/MERGEABLE, the PR is unassigned, and there are zero unresolved threads. Report every current-head actionable issue before Cursor or a final CodeRabbit pass.

Copilot AI commented Jul 12, 2026

Copy link
Copy Markdown

@copilot review

Please perform the required formal review of exact current head f57e17a on exact stacked base 6f87de5. This revision ...

Completed the formal review on exact head f57e17a against base 6f87de5 with the requested focus areas. I found no current-head actionable issues.

@HardlyDifficult

Copy link
Copy Markdown
Collaborator Author

@cursor review

Please perform an explicit review of exact current head f57e17a on exact stacked base 6f87de5. Copilot completed the required exact-head review with no actionable findings: #433 (comment). Both required checks are green, GitHub is CLEAN/MERGEABLE, the PR is unassigned, and there are zero unresolved threads. Focus on the four review-fix areas: nullish optional-field omission and its regression, any-safe exact-type assertions, the public vesting-start incompatibility assertion, and stable deep-graph correctness testing without a wall-clock threshold. Report every current-head actionable issue.

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

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 f57e17a. Configure here.

@HardlyDifficult HardlyDifficult marked this pull request as draft July 12, 2026 08:39
@HardlyDifficult

Copy link
Copy Markdown
Collaborator Author

Returned to draft because the ordered upstream stack (#431#432) is advancing materially. This vesting slice remains held until the exact updated #432 parent is propagated, after which CI and Copilot-first reviewer gates will restart.

…aders' into codex/decoder-backed-vesting-readers

# Conflicts:
#	src/functions/OpenCapTable/capTable/damlCodecLosslessness.ts
#	src/functions/OpenCapTable/capTable/damlEntityData.ts
#	src/functions/OpenCapTable/capTable/damlToOcf.ts
#	src/functions/OpenCapTable/shared/plainDataValidation.ts
#	src/functions/OpenCapTable/shared/transferWriterValidation.ts
@HardlyDifficult HardlyDifficult changed the title Validate vesting reader payloads Add lossless typed vesting readers Jul 12, 2026
@HardlyDifficult

Copy link
Copy Markdown
Collaborator Author

Restacked onto exact #432 head 1002142caa9baa73a193982cce9f9badd3687cc5 and pushed material vesting hardening in exact head 5df1c78aaff8c753fbd64dbac1955a298e6fa626.

The combined boundary now retains transfer and vesting invariants, detaches generated decoder ownership, preserves structured decoder paths, exposes readonly vesting decoder inputs, and bounds data plus prototype traversal. The restack also caught and fixed transfer non-empty-text and depth-limit regressions before push.

Local exact-head validation is green: 106 suites / 6,024 tests, declarations/build/package-consumer checks, lint, formatting, package dry-run, and diff checks. This PR remains draft and unassigned while hosted CI runs and the stack is propagated.

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