Skip to content

Enforce exact optional properties across the SDK#422

Merged
HardlyDifficult merged 3 commits into
codex/exact-conversion-triggersfrom
codex/exact-optional-tests
Jul 10, 2026
Merged

Enforce exact optional properties across the SDK#422
HardlyDifficult merged 3 commits into
codex/exact-conversion-triggersfrom
codex/exact-optional-tests

Conversation

@HardlyDifficult

@HardlyDifficult HardlyDifficult commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • enable exactOptionalPropertyTypes in the main TypeScript configuration for production and tests
  • eliminate all 69 remaining exact-optional diagnostics by omitting absent values instead of assigning undefined
  • remove the now-redundant source-only exactness configuration while preserving the public-config compile probe
  • keep mocks mutable without unsafe assertions or type weakening

Validation

  • npm run typecheck — zero exact-optional diagnostics
  • npm run build
  • npm run test:declarations
  • npm run lint
  • npm run format
  • npm run test:ci — 65 suites / 2,560 tests; 76.82% statements, 69.56% branches, 77.81% functions, 76.96% lines

Stack


Note

Medium Risk
Broad TypeScript strictness affects optional-property shapes across the public SDK and many call sites; the warrant PPS discount DAML mapping behavior changes slightly for edge cases around zero/empty discount amounts.

Overview
Turns on exactOptionalPropertyTypes in the main tsconfig so production and test code share one stricter compile, and drops the separate test:exact-source / tsconfig.exact-source.json path now that typecheck no longer needs a second pass.

Call sites stop materializing undefined on optional fields: integration/setup helpers add withCapTableContractDetails (and similar conditional spreads) so absent disclosed-contract details and OCF fields are omitted rather than set to undefined. warrantMechanismToDaml for PPS discounts now keys off !== undefined for discount_percentage / discount_amount instead of in / truthiness checks.

Tests and mocks are aligned with the new rules—Parameters<> for ledger mocks, observability tests that omit per-call overrides, and requireCreatedEventBlob where blobs must be present.

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

@coderabbitai

coderabbitai Bot commented Jul 10, 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: 55 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: ff2062a7-d069-4c48-ace2-650d8553529a

📥 Commits

Reviewing files that changed from the base of the PR and between a81de37 and 2cbb203.

📒 Files selected for processing (16)
  • package.json
  • src/functions/OpenCapTable/shared/conversionMechanisms.ts
  • test/capTable/archiveFullCapTable.test.ts
  • test/capTable/getCapTableState.test.ts
  • test/client/OcpClient.test.ts
  • test/client/OcpContextManager.test.ts
  • test/integration/entities/acceptanceTypes.integration.test.ts
  • test/integration/entities/stockClassAdjustments.integration.test.ts
  • test/integration/entities/transferTypes.integration.test.ts
  • test/integration/entities/valuationVesting.integration.test.ts
  • test/integration/production/productionDataRoundtrip.integration.test.ts
  • test/integration/utils/setupTestData.ts
  • test/mocks/fairmint-canton-node-sdk.ts
  • test/validation/boundaries.test.ts
  • tsconfig.exact-source.json
  • tsconfig.json
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/exact-optional-tests

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

@HardlyDifficult
HardlyDifficult marked this pull request as ready for review July 10, 2026 04:53
@HardlyDifficult

Copy link
Copy Markdown
Collaborator Author

CI is green on the latest head, including the full OCP QuickStart integration suite.

@copilot review
@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown

@HardlyDifficult Thanks for the update — glad to hear CI is green including the full OCP QuickStart integration suite. I'll kick off a review of the latest changes 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.

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

Pull request overview

This PR enables TypeScript’s exactOptionalPropertyTypes across the SDK build/test toolchain and updates SDK code + tests to avoid materializing absent optional fields as undefined (favoring omission), including a small but intentional behavior adjustment in the PPS-based warrant discount mapping.

Changes:

  • Enable exactOptionalPropertyTypes in the primary tsconfig.json and remove the now-redundant source-only exactness config + npm script.
  • Update integration/unit tests and helpers to omit optional fields (via conditional spreads / withCapTableContractDetails) rather than assigning undefined.
  • Adjust warrantMechanismToDaml PPS discount emission to key off !== undefined for optional discount fields.

Reviewed changes

Copilot reviewed 15 out of 16 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tsconfig.json Enables exactOptionalPropertyTypes for the primary compile.
tsconfig.exact-source.json Removes the redundant source-only exactness config.
package.json Drops the test:exact-source script and simplifies typecheck.
src/functions/OpenCapTable/shared/conversionMechanisms.ts Updates PPS-based warrant discount mapping to rely on !== undefined checks.
test/validation/boundaries.test.ts Updates boundary test to omit optional OCF fields rather than setting undefined.
test/mocks/fairmint-canton-node-sdk.ts Adjusts mock fields to be T | undefined (instead of ?:) to comply with exact optional semantics.
test/integration/utils/setupTestData.ts Adds withCapTableContractDetails helper and replaces undefined assignments with conditional spreads.
test/integration/production/productionDataRoundtrip.integration.test.ts Uses withCapTableContractDetails and requireCreatedEventBlob for stricter optional handling.
test/integration/entities/valuationVesting.integration.test.ts Uses withCapTableContractDetails to omit absent contract details.
test/integration/entities/transferTypes.integration.test.ts Uses withCapTableContractDetails to omit absent contract details.
test/integration/entities/stockClassAdjustments.integration.test.ts Uses withCapTableContractDetails to omit absent contract details.
test/integration/entities/acceptanceTypes.integration.test.ts Uses withCapTableContractDetails to omit absent contract details.
test/client/OcpContextManager.test.ts Updates test to pass omitted fields ({}) instead of explicit undefined.
test/client/OcpClient.test.ts Updates test to omit per-call observability overrides instead of setting them to undefined.
test/capTable/getCapTableState.test.ts Aligns getActiveContracts mock param typing using Parameters<...>[0].
test/capTable/archiveFullCapTable.test.ts Aligns getActiveContracts mock param typing using Parameters<...>[0].

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@HardlyDifficult HardlyDifficult self-assigned this Jul 10, 2026
@HardlyDifficult
HardlyDifficult merged commit bbce567 into codex/exact-conversion-triggers Jul 10, 2026
6 checks passed
@HardlyDifficult
HardlyDifficult deleted the codex/exact-optional-tests branch July 10, 2026 16:15
@HardlyDifficult HardlyDifficult removed their assignment Jul 10, 2026
@HardlyDifficult

HardlyDifficult commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator Author

Correction: this PR was already merged into its #421 base at commit bbce567. The prior readiness-retraction wording was based on stale status; no action is required, and the updated #421 branch already contains this merged work.

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