Skip to content

Curate strict public SDK declarations#412

Merged
HardlyDifficult merged 79 commits into
mainfrom
codex/curated-public-sdk
Jul 13, 2026
Merged

Curate strict public SDK declarations#412
HardlyDifficult merged 79 commits into
mainfrom
codex/curated-public-sdk

Conversation

@HardlyDifficult

@HardlyDifficult HardlyDifficult commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • replace wildcard root exports with a curated high-level SDK surface
  • expose canonical OCF-native entity, batch, result, and contract-id types while keeping generated DAML packages and low-level converters internal
  • add a root-only package export map plus runtime, declaration, and consumer tests that prevent accidental internal/generated leakage
  • keep generated codecs only at the wire/serialization boundary; do not duplicate DAML business or integrity validation in the public SDK
  • preserve current Financing and canonical stakeholder-event support from main v0.8.0

DAML / SDK boundary

DAML remains authoritative for domain correctness and integrity. This PR does not reintroduce #411 date, graph, pricing, quantity, cardinality, or cross-field semantic preflight. The SDK checks retained here are operation-capability, template identity, and generated-codec/JSON transport checks needed to construct or decode the wire value faithfully.

Validation on exact final tree

  • npm run build
  • npm run test:declarations with skipLibCheck: false and no generated DAML packages reachable from the root declaration graph
  • npm run typecheck
  • npm test -- --runInBand — 61 suites / 2,773 tests passed
  • npm run lint
  • npm run format
  • git diff --check

Revision note

The final tree was rebuilt from current main (v0.8.0) and attached to this existing branch with an additive merge commit. No history was rewritten or force-pushed. The PR remains draft until exact-head CI is green and fresh automated review completes.


Note

Medium Risk
Broad export and type-surface change can break downstream imports that relied on deep or generated symbols; runtime behavior is mostly refactored behind the same client/batch flows.

Overview
Replaces wildcard root exports with a curated high-level surface (OcpClient, batch helpers, issuer auth, environment/errors/types) and adds an explicit package.json exports map for the package root only.

Splits public types from generated DAML wiring: new entityTypes holds canonical OCF-native batch/entity/result types (including OcfContractId and a frozen OCF_OBJECT_TYPE_TO_ENTITY_TYPE map); DAML decode/build logic moves to generatedBatchOperations and stays off the root graph. Issuer and issuer-authorization params/results live in thin api/types modules that route ledger response types through types/common.

Tightens declaration checks: check-declarations validates a strict consumer fixture, fails if dist references @fairmint/open-captable-protocol-daml-js, and enforces transaction-tree types via common. Tests lock the runtime export list and compile-time contracts so converters/registry helpers are not root exports.

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

@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

The package now exposes a curated root API with explicit Node entrypoints, introduces canonical cap-table entity and batch types, separates generated operation builders, adds issuer API types, decouples conversion declarations from generated DAML types, and strengthens declaration validation.

Changes

SDK boundary and type-safe APIs

Layer / File(s) Summary
Curated package boundary and declaration validation
package.json, src/index.ts, src/types/*, scripts/check-declarations.ts, src/functions/OpenCapTable/issuer/*, src/functions/OpenCapTable/issuerAuthorization/*, test/publicApi/*, test/declarations/publicApi.types.ts
The package root uses explicit exports and Node resolution targets; issuer and authorization types are centralized; generated declarations are checked for diagnostics, disallowed package references, and transaction-tree import paths.
Canonical entity types and batch builders
src/functions/OpenCapTable/capTable/{entityTypes,batchTypes,generatedBatchOperations,CapTableBatch,index}.ts, test/batch/*, test/types/capTableBatch.types.ts, test/types/generatedOperationConstruction.types.ts
Cap-table entity mappings, operation correlations, contract-ID results, runtime guards, and create/edit/delete DAML builders are centralized and validated through updated type tests.
Command APIs and module wiring
src/OcpClient.ts, src/functions/OpenCapTable/capTable/{archiveCapTable,archiveFullCapTable,buildCapTableCommand,getCapTableState}.ts, src/functions/OpenCapTable/issuer/createIssuer.ts, src/functions/OpenCapTable/stockIssuance/createStockIssuance.ts, test/client/*, test/integration/utils/setupTestData.ts
Client and command modules use specific type imports, shared command result types, and CapTableBatchParams for cap-table updates.
DAML conversion type boundaries
src/utils/{enumConversions,typeConversions,cantonOcfExtractor,ocfZodSchemas,replicationHelpers}.ts, test/converters/*, test/declarations/normalization.types.ts, test/types/normalization.types.ts
Conversion declarations use local DAML literals and structural types, while entity mapping and normalization imports reference dedicated modules.

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

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 43.24% 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 The title clearly summarizes the main change: curating and tightening the SDK's public declarations.
✨ 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/curated-public-sdk

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 — I'll review the latest 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.

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 replaces the previous “wildcard” SDK surface with a curated, root-only public API, while moving generated DAML wiring (codecs, unions, low-level converters/readers) behind internal modules and enforcing the boundary via package.json exports and stricter declaration validation.

Changes:

  • Curate src/index.ts to export only high-level runtime APIs plus canonical OCF DTOs (and block package deep imports via package.json#exports).
  • Split public OCF-native batch/entity types into entityTypes.ts, and move generated DAML operation builders into generatedBatchOperations.ts.
  • Tighten declaration validation (check-declarations.ts) and add tests that lock down the root runtime export list and root declaration surface.

Reviewed changes

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

Show a summary per file
File Description
test/types/normalization.types.ts Updates compile-time source contracts to import canonicalization helpers from their new internal module.
test/types/generatedOperationConstruction.types.ts Repoints source type contracts to generated batch operation builders and internal batch types.
test/types/damlReadDispatch.types.ts Adjusts source type contracts to import read-dispatch types from the cap-table facade + native types.
test/types/capTableBatch.types.ts Updates source type contracts for batch API surface and new OcfContractId / execute result typing.
test/publicApi/rootExports.test.ts Adds a runtime test that locks the curated root export key list.
test/integration/utils/setupTestData.ts Minor type tightening (ReadonlyArray) for created CID extraction helper.
test/declarations/publicApi.types.ts Updates built-SDK declaration smoke tests to match the curated root surface and removed exports.
test/declarations/normalization.types.ts Updates built declaration contracts for canonicalization helpers to new module path.
test/declarations/generatedOperationConstruction.types.ts Repoints built declaration contracts to generated batch operation builders and internal batch types.
test/declarations/damlReadDispatch.types.ts Repoints built declaration contracts to internal read-dispatch modules/types.
test/converters/coreObjectReadValidation.test.ts Updates imports to avoid relying on root re-exports for internal converter helpers.
test/client/OcpClient.test.ts Updates spying/import paths for cap-table state helpers after refactor.
test/batch/generatedOperationConstruction.test.ts Repoints batch tests to new generated operation builders + internal registry/tag map modules.
test/batch/batchTypes.test.ts Repoints registry import to new internal batchTypes module.
src/types/index.ts Removes DAML barrel export and moves CommandWithDisclosedContracts out of this index barrel.
src/types/common.ts Adds CommandWithDisclosedContracts to the common type module used by high-level APIs.
src/OcpClient.ts Refactors imports to new cap-table/issuer/authorization modules and aliases CapTableUpdateParams.
src/index.ts Implements curated root public API exports (no more wildcard re-export of functions/types/utils).
src/functions/OpenCapTable/stockIssuance/createStockIssuance.ts Splits native vs DAML type imports to keep public/native surface clean.
src/functions/OpenCapTable/issuerAuthorization/withdrawAuthorization.ts Moves public param/result types to a dedicated types module and re-exports them.
src/functions/OpenCapTable/issuerAuthorization/types.ts Introduces shared public issuer-authorization params/results module.
src/functions/OpenCapTable/issuerAuthorization/index.ts Re-exports new issuer-authorization types.
src/functions/OpenCapTable/issuerAuthorization/authorizeIssuer.ts Moves public param/result types to the new types module and re-exports them.
src/functions/OpenCapTable/issuer/types.ts Introduces issuer CreateCapTable input/params types behind a dedicated module.
src/functions/OpenCapTable/issuer/index.ts Switches issuer public export surface to the new API facade while keeping internal helpers.
src/functions/OpenCapTable/issuer/createIssuer.ts Moves public types out to types.ts and updates imports to common/native types.
src/functions/OpenCapTable/issuer/api.ts Adds a public wrapper for CreateIssuer command builder isolated from generated converter declarations.
src/functions/OpenCapTable/capTable/index.ts Re-exports generated operation builders from the new module and adjusts cap-table exports.
src/functions/OpenCapTable/capTable/getCapTableState.ts Adjusts imports to avoid leaking entity type definitions from the generated batchTypes module.
src/functions/OpenCapTable/capTable/generatedBatchOperations.ts New module that builds/validates generated DAML create/edit/delete variants via decoders.
src/functions/OpenCapTable/capTable/entityTypes.ts New module defining public OCF-native entity unions, guards, and batch result/contract-id typing.
src/functions/OpenCapTable/capTable/CapTableBatch.ts Refactors batch builder to delegate generated wire construction to generatedBatchOperations.
src/functions/OpenCapTable/capTable/buildCapTableCommand.ts Updates CommandWithDisclosedContracts import to the new common type module.
src/functions/OpenCapTable/capTable/batchTypes.ts Refactors to re-export public OCF types from entityTypes and keep generated DAML types local.
src/functions/OpenCapTable/capTable/archiveFullCapTable.ts Updates entity type import to the new entityTypes module.
src/functions/OpenCapTable/capTable/archiveCapTable.ts Updates CommandWithDisclosedContracts import to the new common type module.
scripts/check-declarations.ts Tightens declaration validation by typechecking a strict consumer and checking for generated DAML package leaks in the root declaration graph.
package.json Adds a root-only exports map to block unsupported deep imports and enforce the curated public surface.

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

Comment thread src/functions/OpenCapTable/issuerAuthorization/types.ts Outdated
@HardlyDifficult

Copy link
Copy Markdown
Collaborator Author

Final parent-fix propagation complete at exact head f625fbba64d1c02641d338024082ce718886c016, incorporating #411 at 9d459b27f3894265e49bb90f9ddc945d8e18bcc3. Validation passed on canton-node-sdk 0.0.227: source typecheck plus the convertible-issuance and shared-vesting suites (2 suites / 80 tests), including the new nested write-record guards and structured diagnostics. The PR remains draft and unassigned while CI runs.

@HardlyDifficult
HardlyDifficult marked this pull request as ready for review July 11, 2026 21:10
@HardlyDifficult

Copy link
Copy Markdown
Collaborator Author

@copilot review

Please review exact head f625fbb. Pre-review gate verified: expected stacked base, build-and-test SUCCESS, full QuickStart SUCCESS, CLEAN/MERGEABLE, unassigned, and zero unresolved review threads.

Copilot AI commented Jul 11, 2026

Copy link
Copy Markdown

@copilot review

Please review exact head f625fbb. Pre-review gate verified: expected stacked base, build-and-test SUCCESS, full QuickStart SUCCESS, CLEAN/MERGEABLE, u...

Reviewed the exact current head (f625fbba64d1c02641d338024082ce718886c016) for the propagated parent fixes and current curated public SDK surface. I don’t see additional actionable issues to flag on this pass.

@HardlyDifficult

Copy link
Copy Markdown
Collaborator Author

@cursor review

Please review exact head f625fbb. Copilot completed an explicit exact-head no-findings review: #412 (comment). Current gate remains green: both required checks SUCCESS, CLEAN/MERGEABLE, unassigned, and zero unresolved review threads.

@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 f625fbb. Configure here.

@HardlyDifficult

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

Please perform a substantive incremental review of exact current head f625fbb, including the final propagated parent-fix delta since the prior substantive CodeRabbit review. Copilot completed an exact-head no-findings review: #412 (comment). Cursor completed an exact-head no-findings formal review: #412 (review). Please run the real analysis phases and submit a formal exact-head review; an instant status check is not sufficient.

@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown

@HardlyDifficult Understood — I'll perform a substantive review of the exact current head f625fbba64d1c02641d338024082ce718886c016 now, including the final propagated parent-fix delta since the prior substantive review.

✅ 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

Please perform a substantive incremental review of exact current head f625fbba64d1c02641d338024082ce718886c016, including the final propagated parent-fix delta since the prior substantive review. The prior 2026-07-11 21:16Z invocation returned an instant “Review finished” while the live CodeRabbit status simultaneously showed the run was rate-limited until this reset window, so that false-success must not count. Please execute the real analysis, feedback, and publish phases and submit a substantive exact-head review. Copilot and Cursor have both completed explicit exact-head no-findings reviews; both required CI checks are green, the PR is CLEAN/MERGEABLE, unassigned, and has zero unresolved review threads.

@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown

@HardlyDifficult Understood — I'll trigger a fresh review pass on exact head f625fbba64d1c02641d338024082ce718886c016 now, covering the full delta since the prior review, including the propagated parent-fix changes. If the system is still within a rate-limit window, the review will be queued and run once that window clears; I don't have a way to force an instant analysis pass ahead of the limiter, but this request is registered as a real (non-rate-limited) review trigger.

✅ 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

Readiness temporarily retracted: upstream #411 does not yet contain the current exact head of its own base #409. This PR is back in draft and unassigned until #411 is repaired, its corrected exact head is merged normally into this branch, validation is green, and Copilot plus the other enabled review agents complete fresh exact-head passes.

@HardlyDifficult

Copy link
Copy Markdown
Collaborator Author

Pivot cleanup is now on exact head a28dfb83313c6f6fdb708cb58fb8ee6c820a853a. The final tree is identical to the clean v0.8.0-based extraction: runtime domain validation from #411 is absent; curated public types, generated-codec isolation, and transport/declaration gates remain. Local build, strict declarations, typecheck, 61/61 suites (2,773 tests), lint, format, and diff checks are green. Keeping the PR draft while exact-head CI runs; Copilot will be requested first only after Stage 1 is green.

@HardlyDifficult

Copy link
Copy Markdown
Collaborator Author

@copilot review

Please review exact head a28dfb83313c6f6fdb708cb58fb8ee6c820a853a, focusing on the curated public API/declaration boundary and confirming that the cleaned scope does not reintroduce DAML-domain semantic validation. Exact-head build, CodeQL, and full OCP QuickStart checks are green; unresolved review threads: 0.

Copilot AI commented Jul 13, 2026

Copy link
Copy Markdown

@copilot review

Please review exact head a28dfb83313c6f6fdb708cb58fb8ee6c820a853a, focusing on the curated public API/declaration boundary and confirming that the cleaned scope does not reintroduce...

Reviewed the exact head (a28dfb83313c6f6fdb708cb58fb8ee6c820a853a) with focus on the curated public API/declaration boundary and ensuring the cleaned scope does not reintroduce DAML-domain semantic validation. I don’t see additional actionable issues to flag on this pass.

@HardlyDifficult

Copy link
Copy Markdown
Collaborator Author

@cursor review

Please review exact head a28dfb83313c6f6fdb708cb58fb8ee6c820a853a. Copilot completed an exact-head no-findings review: #412 (comment). All hosted checks are green and unresolved threads are zero.

@HardlyDifficult

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

Please perform a substantive review of exact head a28dfb83313c6f6fdb708cb58fb8ee6c820a853a, focusing on the clean v0.8.0-based diff rather than historical stacked commits. Copilot completed an exact-head no-findings review: #412 (comment). All hosted checks are green and unresolved threads are zero.

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown

@HardlyDifficult Understood — I'll perform a substantive review of exact head a28dfb83313c6f6fdb708cb58fb8ee6c820a853a now, focusing on the clean diff against v0.8.0 rather than the historical stacked commits.

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

@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 a28dfb8. Configure here.

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

Copilot reviewed 41 out of 41 changed files in this pull request and generated 2 comments.

Comment on lines +17 to 19
import type { CommandWithDisclosedContracts } from '../../../types/common';
import { type OcfCreateData, type OcfDeleteData, type OcfEditData, type UpdateCapTableResult } from './batchTypes';
import {
TX_WARRANT_TRANSFER: 'warrantTransfer',
VALUATION: 'valuation',
VESTING_TERMS: 'vestingTerms',
} as const satisfies Record<string, OcfEntityType>);
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