@rljson/rljson 0.0.77 → 0.0.78

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -678,6 +678,32 @@ ephemeral Connector `origin` (which changes on every instantiation), a
678
678
 
679
679
  Format: `"client_"` + 12-character nanoid (e.g. `"client_V1StGXR8_Z5j"`).
680
680
 
681
+ ### Conflict Detection Types
682
+
683
+ The sync protocol includes types for detecting DAG branch conflicts in the
684
+ InsertHistory. A **DAG branch** occurs when two or more InsertHistory rows
685
+ share the same predecessor, creating divergent branches from concurrent
686
+ writes by different clients.
687
+
688
+ | Type | Description |
689
+ | ------------------ | --------------------------------------------------------------------- |
690
+ | `ConflictType` | String literal union — currently `'dagBranch'` |
691
+ | `Conflict` | Interface describing a detected conflict: table, type, time, branches |
692
+ | `ConflictCallback` | `(conflict: Conflict) => void` — callback type for observers |
693
+
694
+ **Conflict interface fields:**
695
+
696
+ | Field | Type | Description |
697
+ | ------------ | ----------------------- | ----------------------------------------------------- |
698
+ | `table` | `string` | Table where the conflict was detected (no suffix) |
699
+ | `type` | `ConflictType` | `'dagBranch'` |
700
+ | `detectedAt` | `number` | Timestamp (ms since epoch) of detection |
701
+ | `branches` | `InsertHistoryTimeId[]` | Tip timeIds forming the DAG fork (always ≥ 2 entries) |
702
+
703
+ Detection is protocol-level only — no resolution logic. Upper layers
704
+ (application code or `@rljson/db`) use these types to signal and react
705
+ to conflicts.
706
+
681
707
  ## Package Structure
682
708
 
683
709
  ```
package/README.public.md CHANGED
@@ -360,6 +360,32 @@ isClientId(id); // true
360
360
  isClientId('not-a-client-id'); // false
361
361
  ```
362
362
 
363
+ ### Conflict Detection Types
364
+
365
+ Protocol-level types for DAG branch conflict detection. A conflict occurs when the InsertHistory for a table has diverged into multiple branches (multiple "tips" that are not ancestors of each other), indicating concurrent writes from different clients.
366
+
367
+ Detection only — no resolution: these types signal that a conflict exists. Resolution logic is left to upper layers (application code).
368
+
369
+ ```typescript
370
+ import type { Conflict, ConflictCallback, ConflictType } from '@rljson/rljson';
371
+
372
+ // ConflictType — currently only 'dagBranch'
373
+ const type: ConflictType = 'dagBranch';
374
+
375
+ // Conflict — describes a detected fork in InsertHistory
376
+ const conflict: Conflict = {
377
+ table: 'cars', // Table where the conflict was detected
378
+ type: 'dagBranch', // Type of conflict
379
+ detectedAt: Date.now(), // Detection timestamp (ms since epoch)
380
+ branches: ['17000…:AbCd', '17000…:EfGh'] // InsertHistory tip timeIds forming the fork
381
+ };
382
+
383
+ // ConflictCallback — fires when a conflict is detected
384
+ const onConflict: ConflictCallback = (conflict: Conflict) => {
385
+ console.log(`Conflict in ${conflict.table}:`, conflict.branches);
386
+ };
387
+ ```
388
+
363
389
  ## Utilities
364
390
 
365
391
  ### TimeId
@@ -678,6 +678,32 @@ ephemeral Connector `origin` (which changes on every instantiation), a
678
678
 
679
679
  Format: `"client_"` + 12-character nanoid (e.g. `"client_V1StGXR8_Z5j"`).
680
680
 
681
+ ### Conflict Detection Types
682
+
683
+ The sync protocol includes types for detecting DAG branch conflicts in the
684
+ InsertHistory. A **DAG branch** occurs when two or more InsertHistory rows
685
+ share the same predecessor, creating divergent branches from concurrent
686
+ writes by different clients.
687
+
688
+ | Type | Description |
689
+ | ------------------ | --------------------------------------------------------------------- |
690
+ | `ConflictType` | String literal union — currently `'dagBranch'` |
691
+ | `Conflict` | Interface describing a detected conflict: table, type, time, branches |
692
+ | `ConflictCallback` | `(conflict: Conflict) => void` — callback type for observers |
693
+
694
+ **Conflict interface fields:**
695
+
696
+ | Field | Type | Description |
697
+ | ------------ | ----------------------- | ----------------------------------------------------- |
698
+ | `table` | `string` | Table where the conflict was detected (no suffix) |
699
+ | `type` | `ConflictType` | `'dagBranch'` |
700
+ | `detectedAt` | `number` | Timestamp (ms since epoch) of detection |
701
+ | `branches` | `InsertHistoryTimeId[]` | Tip timeIds forming the DAG fork (always ≥ 2 entries) |
702
+
703
+ Detection is protocol-level only — no resolution logic. Upper layers
704
+ (application code or `@rljson/db`) use these types to signal and react
705
+ to conflicts.
706
+
681
707
  ## Package Structure
682
708
 
683
709
  ```
@@ -360,6 +360,32 @@ isClientId(id); // true
360
360
  isClientId('not-a-client-id'); // false
361
361
  ```
362
362
 
363
+ ### Conflict Detection Types
364
+
365
+ Protocol-level types for DAG branch conflict detection. A conflict occurs when the InsertHistory for a table has diverged into multiple branches (multiple "tips" that are not ancestors of each other), indicating concurrent writes from different clients.
366
+
367
+ Detection only — no resolution: these types signal that a conflict exists. Resolution logic is left to upper layers (application code).
368
+
369
+ ```typescript
370
+ import type { Conflict, ConflictCallback, ConflictType } from '@rljson/rljson';
371
+
372
+ // ConflictType — currently only 'dagBranch'
373
+ const type: ConflictType = 'dagBranch';
374
+
375
+ // Conflict — describes a detected fork in InsertHistory
376
+ const conflict: Conflict = {
377
+ table: 'cars', // Table where the conflict was detected
378
+ type: 'dagBranch', // Type of conflict
379
+ detectedAt: Date.now(), // Detection timestamp (ms since epoch)
380
+ branches: ['17000…:AbCd', '17000…:EfGh'] // InsertHistory tip timeIds forming the fork
381
+ };
382
+
383
+ // ConflictCallback — fires when a conflict is detected
384
+ const onConflict: ConflictCallback = (conflict: Conflict) => {
385
+ console.log(`Conflict in ${conflict.table}:`, conflict.branches);
386
+ };
387
+ ```
388
+
363
389
  ## Utilities
364
390
 
365
391
  ### TimeId
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rljson/rljson",
3
- "version": "0.0.77",
3
+ "version": "0.0.78",
4
4
  "description": "The RLJSON data format specification",
5
5
  "homepage": "https://github.com/rljson/rljson",
6
6
  "bugs": "https://github.com/rljson/rljson/issues",