Skip to content

Trust canonical stakeholder relationship schema#439

Merged
HardlyDifficult merged 7 commits into
codex/decoder-backed-stakeholder-event-readersfrom
codex/canonical-stakeholder-relationship-normalization
Jul 13, 2026
Merged

Trust canonical stakeholder relationship schema#439
HardlyDifficult merged 7 commits into
codex/decoder-backed-stakeholder-event-readersfrom
codex/canonical-stakeholder-relationship-normalization

Conversation

@HardlyDifficult

@HardlyDifficult HardlyDifficult commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • expose one frozen canonical 13-value stakeholder relationship tuple and derive the public union and exhaustive DAML mapping from it
  • preserve relationship order, duplicates, casing, and exact optional-field distinctions; reject trimming, coercion, legacy singular/new_relationships aliases, and unknown values
  • decode stakeholder DAML through the generated lossless boundary and return detached, recursively frozen snapshots from direct, dispatcher, batch, manifest, replication, and OcpClient read surfaces
  • retain the inherited immutable generated-DAML and stakeholder-event architecture from #438

Behavior

  • all 13 pinned canonical relationship values are accepted and typed without any
  • relationship_started and relationship_ended compare exactly; null, omission, numeric lookalikes, padding, and lowercase values are not silently equated
  • current_relationships preserves ordering and duplicates; reordering produces exactly one replication edit
  • legacy current_relationship and new_relationships inputs are rejected before normalization can discard information
  • hostile proxies, accessors, sparse arrays, oversized arrays, aliases, and post-read source mutation cannot poison stakeholder snapshots

Validation

  • npm run typecheck
  • focused stakeholder/event/replication/schema gate: 10 suites, 802 tests
  • npm run test:ci: 121 suites, 8,135 tests
  • npm run test:declarations, including build, exact-public config, built cardinality, and installed-package consumer
  • npm run lint
  • npm run format
  • npm pack --dry-run: 1,278 files, 597,589 bytes packed, 3,328,914 bytes unpacked
  • exact-head hosted build-and-test and QuickStart: success
  • clean diff, exact-parent ancestry, generated inventory, package, and fresh GitHub feedback audits

Stack

Status

Exact-head local and hosted gates are green, and GitHub reports CLEAN/MERGEABLE with no actionable feedback. This PR remains draft and unassigned for stack-level reviewer coordination. No reviewers were requested in this phase.


Note

Medium Risk
Changes stakeholder read types to deep readonly snapshots and alters replication/comparison rules for relationship arrays—high touch for sync and round-trip—but behavior is heavily gated by tests and bounded decode preflight.

Overview
Introduces STAKEHOLDER_RELATIONSHIP_TYPES as the single frozen canonical tuple (exported from the package root) and derives the public union and frozen STAKEHOLDER_RELATIONSHIP_TYPE_TO_DAML mapping from it.

Stakeholder reads now route through decodeDamlEntityData with assertSafeGeneratedDamlJson (stakeholder is dispatched before the generic JSON graph walk), and damlStakeholderDataToNative returns OcfStakeholderOutput as a detached, recursively Object.freeze’d snapshot with current_relationships order and duplicates preserved. stakeholder is listed among immutable read entity types.

Write and parse boundaries tighten canonical semantics: Zod refinements validate current_relationships and relationship-change relationship_started / relationship_ended, reject legacy current_relationship / new_relationships, and batch/client paths reject padded, lowercase, or unknown relationship values. ocfCompare / diffOcfObjects treat relationship fields strictly (no trim/coerce, ordered array semantics, omitted vs [] equivalence only where defined) and stop ignoring new_relationships in deprecated-field lists.

Built check-built-cardinality, declaration tests, and a large test expansion lock in the behavior across batch, replication, and integration surfaces.

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

@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown

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
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/canonical-stakeholder-relationship-normalization

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

Canonical stakeholder relationship hardening and exact #438 parent integration are pushed at audited head 3e469b8. The SDK now exposes one frozen pinned 13-value tuple/union; preserves relationship order and duplicates end-to-end; treats reordering as a meaningful comparison and one replication edit; and removes legacy discriminators, new_relationships/singular aliases, coercion, trimming, sorting, deduplication, and invented uniqueness. Lowercase, padded, unknown, proxy, accessor, and sparse inputs are rejected across public paths. Source, built, package, and built-runtime proofs are exact and any-resistant. Normal merge ancestry is original #439 plus audited #438 db093d7. Independent audit found no issue. Exact validation passes: full 118 suites / 7,732 tests, typecheck, lint, formatting, build, declarations, exact-public/cardinality, package-consumer, and built-runtime gates. Keeping this PR draft/unassigned while remote CI runs and until the finalized upstream #417-derived chain is propagated.

# Conflicts:
#	src/functions/OpenCapTable/capTable/batchTypes.ts
#	src/functions/OpenCapTable/capTable/damlEntityData.ts
#	src/functions/OpenCapTable/capTable/damlToOcf.ts
#	src/functions/OpenCapTable/capTable/entityTypes.ts
#	src/functions/OpenCapTable/stakeholder/getStakeholderAsOcf.ts
#	src/utils/ocfNormalization.ts
#	src/utils/ocfZodSchemas.ts
#	src/utils/replicationHelpers.ts
#	test/declarations/damlReadDispatch.types.ts
#	test/declarations/replicationHelpers.types.ts
#	test/functions/stakeholderEventReaders.test.ts
#	test/package-consumer/publicEntrypoint.types.ts
#	test/schemaAlignment/canonicalOcfObjectInventory.json
#	test/types/capTableBatch.types.ts
#	test/types/damlReadDispatch.types.ts
#	test/types/replicationHelpers.types.ts
#	test/utils/ocfNormalization.test.ts
#	test/utils/replicationHelpers.test.ts
@HardlyDifficult

Copy link
Copy Markdown
Collaborator Author

Restacked normally onto hosted-green #438 at exact merge head 6daceb36c5777a0b52d1d11205bd71a82ad810e0 with parents a3a1953314f889474e9eec4be60b9dac31b4e801 and 4373e834b070bf7b2c92f1475b91e2f3feec2576.

The resolution preserves the inherited lossless generated-DAML and immutable replication architecture plus #439 canonical relationship exactness and recursively frozen stakeholder outputs. Local validation is green: focused 10 suites / 802 tests; full 121 suites / 8,135 tests; declarations/build/exact-public/cardinality/package-consumer; typecheck; lint; formatting; generated inventories; package dry-run with 1,278 files; and clean ancestry/diff audits.

Exact-head hosted build-and-test and QuickStart are both successful. A fresh GitHub sweep found zero reviews, reviewer requests, review threads, or actionable comments; GitHub reports CLEAN/MERGEABLE. The PR remains draft and unassigned, with no reviewer requests made in this phase.

@HardlyDifficult HardlyDifficult marked this pull request as ready for review July 13, 2026 15:50
@HardlyDifficult HardlyDifficult merged commit 6cb2f58 into codex/decoder-backed-stakeholder-event-readers Jul 13, 2026
3 checks passed
@HardlyDifficult HardlyDifficult deleted the codex/canonical-stakeholder-relationship-normalization branch July 13, 2026 15:50
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.

1 participant