Skip to content

[Feature] CRDT-kind exhaustiveness check + ALL_CRDT_KINDS const #282

@pathosDev

Description

@pathosDev

Size / Priority

  • Size: Trivial (~30 lines)
  • Category: C.3 Type-Safety.
  • Risk: low.

Affected files

  • src/crdt/index.ts — exports list of CRDT kinds.
  • Tests that check CRDT kind coverage.

Background

CrdtJson is a discriminated union over kind. Currently 9 kinds: GCounter / PNCounter / GSet / ORSet / LWWRegister / GCounterMap / LWWMap / MVRegister / ORMap.

To verify all kinds are tested + handled, a static ALL_CRDT_KINDS constant:

// src/crdt/index.ts

export const ALL_CRDT_KINDS = [
  'GCounter',
  'PNCounter',
  'GSet',
  'ORSet',
  'LWWRegister',
  'GCounterMap',
  'LWWMap',
  'MVRegister',
  'ORMap',
] as const;

export type CrdtKind = typeof ALL_CRDT_KINDS[number];

Tests can iterate ALL_CRDT_KINDS to test each.

Compile-time check: if a new kind is added to CrdtJson but ALL_CRDT_KINDS isn't updated, the type system catches it via the exhaustiveness assertion in decodeCrdt (#231).

Integration / risk

  • No behavioural change.
  • Tests benefit.

Test plan

  1. Each kind in ALL_CRDT_KINDS is exercised by at least one test.
  2. Adding a new kind requires updating the constant + tests catch missing entries.

Acceptance criteria

  • ALL_CRDT_KINDS exported.
  • Tests iterate it for coverage.
  • No CHANGELOG entry needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestpriority: lowNice-to-have / niche / demand-driven

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions