# Share-Class Relationship Mapping

> Same Issuer Does Not Mean Same Security

`D02-F03-A03` · Corporate Actions and Security Master Data → Identity Continuity · archetype `record-transform` · difficulty 3/5 · verification **verified**

Full page: https://docs.thefintechbuilder.com/corporate-actions-and-security-master-data/identity-continuity/share-class-relationship-mapping/
Agent skill: `npx skills add IslamBaraka90/Fintech-Algorithms-Library` — https://docs.thefintechbuilder.com/guides/agent-skill/

## Install and import

```bash
npm install fintech-algorithms
```

```ts
import { calculate } from "fintech-algorithms/corporate-actions-and-security-master-data/identity-continuity/share-class-relationship-mapping";
```

## Signature

```ts
calculate(data)
```

Relates share classes of one issuer — GOOG and GOOGL, voting and non-voting lines. Index membership, float and liquidity screens all need to know these are one company, and naive de-duplication by name gets it wrong.

## Parameters

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `data` | `{ query: object; entities: Entity[]; relationships: Relationship[] }` | yes | `relationships` carries the declared links between classes rather than inferring them from name similarity, which fails on exactly the cases that matter. |

## Returns

`{ query, root, state, sameIssuerShareClassIds, comparison, resolvedRelationships, diagnostics }`

Every class of the same issuer, with the comparison basis used and diagnostics for links that could not be resolved.

## Errors

- When the query entity is unknown — reported as a state rather than thrown

## Complexity

Time `O(relationships)`, space `O(classes)`.

## Worked example

This is the worked example published in the article, replayed by the test suite on every run. The output cannot drift.

### Input

`data`:

```json
{
  "query": {
    "rootEntityId": "SYN-CLASS-FOUNDER",
    "validAt": "2026-03-01T12:00:00Z",
    "knownAt": "2026-03-05T12:00:00Z",
    "compareShareClassIds": ["SYN-CLASS-FOUNDER", "SYN-CLASS-PUBLIC"]
  },
  "entities": [
    {
      "entityId": "SYN-ISSUER-ALPHA",
      "entityType": "ISSUER",
      "label": "Synthetic Alpha Holdings"
    },
    {
      "entityId": "SYN-INSTRUMENT-COMMON",
      "entityType": "LEGAL_INSTRUMENT",
      "label": "Synthetic Alpha Common Equity"
    },
    {
      "entityId": "SYN-INSTRUMENT-PREFERRED",
      "entityType": "LEGAL_INSTRUMENT",
      "label": "Synthetic Alpha Preferred Equity"
    }
  ],
  "relationships": [
    {
      "assertionId": "R-ISSUE-COMMON",
      "revisionNumber": 1,
      "status": "ACTIVE",
      "relationshipType": "ISSUED_BY",
      "sourceEntityId": "SYN-INSTRUMENT-COMMON",
      "targetEntityId": "SYN-ISSUER-ALPHA",
      "effectiveFrom": "2026-01-01T00:00:00Z",
      "effectiveTo": null,
      "observedAt": "2025-12-15T09:00:00Z",
      "availableAt": "2025-12-15T10:00:00Z",
      "source": {
        "sourceId": "SYN-CHARTER-1",
        "sourceType": "synthetic_charter",
        "documentDate": "2025-12-15",
        "locator": "Article IV"
      },
      "terms": {
        "basis": "legal-issuer"
      },
      "unsupportedTerms": []
    },
    {
      "assertionId": "R-ISSUE-PREF",
      "revisionNumber": 1,
      "status": "ACTIVE",
      "relationshipType": "ISSUED_BY",
      "sourceEntityId": "SYN-INSTRUMENT-PREFERRED",
      "targetEntityId": "SYN-ISSUER-ALPHA",
      "effectiveFrom": "2026-01-01T00:00:00Z",
      "effectiveTo": null,
      "observedAt": "2025-12-15T09:00:00Z",
      "availableAt": "2025-12-15T10:00:00Z",
      "source": {
        "sourceId": "SYN-CHARTER-1",
        "sourceType": "synthetic_charter",
        "documentDate": "2025-12-15",
        "locator": "Article IV"
      },
      "terms": {
        "basis": "legal-issuer"
      },
      "unsupportedTerms": []
    },
    {
      "assertionId": "R-CLASS-FOUNDER",
      "revisionNumber": 1,
      "status": "ACTIVE",
      "relationshipType": "CLASS_OF",
      "sourceEntityId": "SYN-CLASS-FOUNDER",
      "targetEntityId": "SYN-INSTRUMENT-COMMON",
      "effectiveFrom": "2026-01-01T00:00:00Z",
      "effectiveTo": null,
      "observedAt": "2025-12-15T09:00:00Z",
      "availableAt": "2025-12-15T10:00:00Z",
      "source": {
        "sourceId": "SYN-CHARTER-1",
        "sourceType": "synthetic_charter",
        "documentDate": "2025-12-15",
        "locator": "Article IV.1"
      },
      "terms": {
        "classCode": "F"
      },
      "unsupportedTerms": []
    }
  ]
}
```

### Call

```ts
calculate(data)
```

### Returns

object with 4 fields: state, sameIssuerShareClassIds, comparison, diagnostics

```json
{
  "state": "RESOLVED",
  "sameIssuerShareClassIds": ["SYN-CLASS-FOUNDER", "SYN-CLASS-PREFERRED", "SYN-CLASS-PUBLIC"],
  "comparison": {
    "votingRightsRatioLeftToRight": {
      "status": "ESTABLISHED",
      "numerator": 10,
      "denominator": 1,
      "unit": "votes_per_share"
    },
    "economicRightsRatioLeftToRight": {
      "status": "ESTABLISHED",
      "numerator": 1,
      "denominator": 1,
      "unit": "distribution_units_per_share"
    },
    "equalEconomics": true,
    "conversion": {
      "status": "ESTABLISHED",
      "direction": "SYN-CLASS-FOUNDER->SYN-CLASS-PUBLIC",
      "relationshipType": "CONVERTS_TO",
      "ratio": {
        "numerator": 1,
        "denominator": 1
      },
      "unit": "target_shares_per_source_share",
      "conditions": ["qualifying_transfer"]
    },
    "fungibility": {
      "status": "NOT_ESTABLISHED"
    },
    "priceConvertibility": "NOT_ESTABLISHED"
  },
  "diagnostics": {
    "excludedFutureRevisionCount": 1,
    "cancelledAssertionIds": ["R-LIST-OLD"]
  }
}
```

## Verification and provenance

Tier: **verified** (via input-expected).

The worked example below is the figure published in this algorithm's article, replayed and asserted by the test suite on every build. The arithmetic cannot drift without the build failing.

Both tiers guarantee the signature. Full explanation: https://docs.thefintechbuilder.com/guides/verification/

Generated from the docs.json payload shipped inside fintech-algorithms@0.13.1.
The signature and parameter list are checked against the compiled implementation at build time,
so a description that contradicts the code fails the build rather than reaching this file.

## Links

- Article (how it works, step by step): https://thefintechbuilder.com/corporate-actions-and-security-master-data/identity-continuity/share-class-relationship-mapping/
- Implementation source: https://github.com/IslamBaraka90/Fintech-Algorithms-Library/blob/main/src/corporate-actions-and-security-master-data/identity-continuity/share-class-relationship-mapping/impl.ts
- Standalone repository: https://github.com/IslamBaraka90/Fintech-Share-Class-Relationship-Mapping-Corporate-Actions-algorithm
- Package on npm: https://www.npmjs.com/package/fintech-algorithms
- Domain index for agents: https://docs.thefintechbuilder.com/corporate-actions-and-security-master-data/llms.txt
