@ibgib/core-gib 0.1.42 → 0.1.43
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.
- package/dist/sync/sync-conflict-text-merge.respec.mjs +26 -26
- package/dist/sync/sync-conflict-text-merge.respec.mjs.map +1 -1
- package/dist/sync/sync-innerspace-dest-ahead-withid.respec.d.mts +7 -0
- package/dist/sync/sync-innerspace-dest-ahead-withid.respec.d.mts.map +1 -0
- package/dist/sync/sync-innerspace-dest-ahead-withid.respec.mjs +252 -0
- package/dist/sync/sync-innerspace-dest-ahead-withid.respec.mjs.map +1 -0
- package/dist/sync/sync-saga-coordinator.mjs +3 -3
- package/dist/sync/sync-saga-coordinator.mjs.map +1 -1
- package/dist/test/mock-space.d.mts +1 -38
- package/dist/test/mock-space.d.mts.map +1 -1
- package/dist/test/mock-space.mjs +73 -78
- package/dist/test/mock-space.mjs.map +1 -1
- package/package.json +1 -1
- package/src/keystone/README.md +118 -0
- package/src/keystone/docs/architecture.md +30 -1
- package/src/sync/README.md +122 -5
- package/src/sync/docs/architecture.md +2 -2
- package/src/sync/{SYNC_TESTING.md → docs/testing.md} +113 -28
- package/src/sync/sync-conflict-text-merge.respec.mts +25 -25
- package/src/sync/sync-innerspace-dest-ahead-withid.respec.mts +316 -0
- package/src/sync/sync-saga-coordinator.mts +4 -4
- package/src/test/mock-space.mts +72 -72
- package/src/sync/docs/verification.md +0 -43
package/src/test/mock-space.mts
CHANGED
|
@@ -1,85 +1,85 @@
|
|
|
1
|
-
import { IbGib_V1 } from '@ibgib/ts-gib/dist/V1/types.mjs';
|
|
2
|
-
import { getIbGibAddr } from '@ibgib/ts-gib/dist/helper.mjs';
|
|
1
|
+
// import { IbGib_V1 } from '@ibgib/ts-gib/dist/V1/types.mjs';
|
|
2
|
+
// import { getIbGibAddr } from '@ibgib/ts-gib/dist/helper.mjs';
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export class MockIbGibSpace {
|
|
11
|
-
|
|
4
|
+
// /**
|
|
5
|
+
// * A simple in-memory map acting as a Space.
|
|
6
|
+
// * Pure Storage. No Indexing logic.
|
|
7
|
+
// *
|
|
8
|
+
// * Copied/Adapted from Keystone Respecs.
|
|
9
|
+
// */
|
|
10
|
+
// export class MockIbGibSpace {
|
|
11
|
+
// store = new Map<string, IbGib_V1>();
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
// constructor(public name: string = "mock_space") { }
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
// async put({ ibGib }: { ibGib: IbGib_V1 }): Promise<void> {
|
|
16
|
+
// const addr = getIbGibAddr({ ibGib });
|
|
17
|
+
// this.store.set(addr, JSON.parse(JSON.stringify(ibGib))); // Deep copy
|
|
18
|
+
// }
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
// async get({ addr }: { addr: string }): Promise<IbGib_V1 | null> {
|
|
21
|
+
// const data = this.store.get(addr);
|
|
22
|
+
// return data ? JSON.parse(JSON.stringify(data)) : null;
|
|
23
|
+
// }
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
25
|
+
// async witness(arg: any): Promise<any> {
|
|
26
|
+
// const cmd = arg.data?.cmd;
|
|
27
|
+
// if (cmd === 'get') {
|
|
28
|
+
// const addrs = arg.data.ibGibAddrs || [];
|
|
29
|
+
// const ibGibs: IbGib_V1[] = [];
|
|
30
|
+
// for (const addr of addrs) {
|
|
31
|
+
// const ig = await this.get({ addr });
|
|
32
|
+
// if (ig) ibGibs.push(ig);
|
|
33
|
+
// }
|
|
34
|
+
// return { ibGibs };
|
|
35
|
+
// }
|
|
36
|
+
// if (cmd === 'put') {
|
|
37
|
+
// const ibGibs = arg.ibGibs || [];
|
|
38
|
+
// for (const ibGib of ibGibs) {
|
|
39
|
+
// await this.put({ ibGib });
|
|
40
|
+
// }
|
|
41
|
+
// return { ibGibs: [] }; // Return empty result or whatever witness expects
|
|
42
|
+
// }
|
|
43
|
+
// return undefined;
|
|
44
|
+
// }
|
|
45
|
+
// }
|
|
46
46
|
|
|
47
|
-
/**
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
export class MockMetaspaceService {
|
|
47
|
+
// /**
|
|
48
|
+
// * A partial mock of Metaspace.
|
|
49
|
+
// */
|
|
50
|
+
// export class MockMetaspaceService {
|
|
51
51
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
// /**
|
|
53
|
+
// * Map of TJP Gib (Timeline ID) -> Latest IbGib Addr (Head)
|
|
54
|
+
// */
|
|
55
|
+
// timelineHeads = new Map<string, string>();
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
// constructor(public space: MockIbGibSpace) { }
|
|
58
58
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
// async getLocalUserSpace({ lock }: { lock: boolean }): Promise<MockIbGibSpace> {
|
|
60
|
+
// return this.space;
|
|
61
|
+
// }
|
|
62
62
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
63
|
+
// async put(args: any): Promise<void> {
|
|
64
|
+
// const target = args.space || this.space;
|
|
65
|
+
// return target.put(args);
|
|
66
|
+
// }
|
|
67
67
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
// async registerNewIbGib(args: { ibGib: IbGib_V1, space?: any }): Promise<void> {
|
|
69
|
+
// const { ibGib } = args;
|
|
70
|
+
// const targetSpace = args.space || this.space;
|
|
71
71
|
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
// // 1. Ensure it is stored
|
|
73
|
+
// await targetSpace.put({ ibGib });
|
|
74
74
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
75
|
+
// // 2. Extract TJP
|
|
76
|
+
// const gib = ibGib.gib || '';
|
|
77
|
+
// let tjpGib = gib;
|
|
78
|
+
// if (gib.includes('.')) {
|
|
79
|
+
// const parts = gib.split('.');
|
|
80
|
+
// tjpGib = parts.slice(1).join('.');
|
|
81
|
+
// }
|
|
82
|
+
// const addr = getIbGibAddr({ ibGib });
|
|
83
|
+
// this.timelineHeads.set(tjpGib, addr);
|
|
84
|
+
// }
|
|
85
|
+
// }
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
# Sync Protocol Verification
|
|
2
|
-
|
|
3
|
-
This document outlines the testing strategy and verification results for the Symmetric Sync Protocol.
|
|
4
|
-
|
|
5
|
-
## Testing Strategy
|
|
6
|
-
We use `respec-gib` (a BDD-style framework) with **In-Memory Simulation (`InnerSpace`)** to verify logic. This allows us to test complex graph scenarios without network or disk I/O overhead.
|
|
7
|
-
|
|
8
|
-
### Key Test Files
|
|
9
|
-
* `sync-innerspace.respec.mts`: Basic Push/Pull scenarios.
|
|
10
|
-
* `sync-innerspace-multiple-timelines.respec.mts`: Handling multiple independent timelines in one Saga.
|
|
11
|
-
* `sync-innerspace-deep-updates.respec.mts`: Syncing timelines with extensive history (ensuring `past` links are traversed).
|
|
12
|
-
* `sync-innerspace-partial-update.respec.mts`: **Smart Diff** verification (Sender uses Receiver's context to send only deltas).
|
|
13
|
-
* `sync-innerspace-dest-ahead.respec.mts`: Verifying "Fast-Backward" or "Push Offer" logic (Sender offers update, Receiver accepts).
|
|
14
|
-
* `sync-innerspace-constants.respec.mts`: Verifying synchronization of **Stones** (Constants/Non-TJPs).
|
|
15
|
-
|
|
16
|
-
## Verification Matrix
|
|
17
|
-
|
|
18
|
-
### 1. Basic Scenarios
|
|
19
|
-
| Feature | Description | Status | Test File |
|
|
20
|
-
| :--- | :--- | :--- | :--- |
|
|
21
|
-
| **Push** | Source syncs a new timeline to an empty Dest. | ✅ Verified | `sync-innerspace.respec.mts` |
|
|
22
|
-
| **Pull** | Dest requests data from Source (Reverse Sync). | ⏳ Pending | `sync-innerspace.respec.mts` |
|
|
23
|
-
| **Dest Ahead** | Dest has newer data; Source offers Push. | ✅ Verified | `sync-innerspace-dest-ahead.respec.mts` |
|
|
24
|
-
|
|
25
|
-
### 2. Complex Graph Scenarios
|
|
26
|
-
| Feature | Description | Status | Test File |
|
|
27
|
-
| :--- | :--- | :--- | :--- |
|
|
28
|
-
| **Multi-Timeline** | Syncing multiple separate timelines. | ✅ Verified | `sync-innerspace-multiple-timelines.respec.mts` |
|
|
29
|
-
| **Deep Updates** | Syncing deep dependency chains (Ancestors). | ✅ Verified | `sync-innerspace-deep-updates.respec.mts` |
|
|
30
|
-
| **Smart Diff** | Sender skips data Receiver already has. | ✅ Verified | `sync-innerspace-partial-update.respec.mts` |
|
|
31
|
-
| **Constants** | Syncing immutable stones (no TJP). | ✅ Verified | `sync-innerspace-constants.respec.mts` |
|
|
32
|
-
|
|
33
|
-
### 3. Failure & Edge Cases
|
|
34
|
-
| Feature | Description | Status | Test File |
|
|
35
|
-
| :--- | :--- | :--- | :--- |
|
|
36
|
-
| **Validation** | Verifying Integrity Checks (ib/gib). | ⏳ Pending | - |
|
|
37
|
-
| **Conflicts** | Divergent branches (Merge Strategy). | ⏳ Pending | - |
|
|
38
|
-
|
|
39
|
-
## Recent Verifications
|
|
40
|
-
### Sync Constants (2026-01-08)
|
|
41
|
-
* **Goal**: Ensure constants (ibGibs without `tjp` or `past`) are synced.
|
|
42
|
-
* **Result**: Passed.
|
|
43
|
-
* **Fixes**: Updated `handleInitFrame` to request missing stones; updated `handleAckFrame` to include "tip" stones in payload even without dependencies.
|