@ibgib/core-gib 0.1.20 → 0.1.22

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.
Files changed (165) hide show
  1. package/dist/sync/graft-info/graft-info-constants.d.mts +5 -0
  2. package/dist/sync/graft-info/graft-info-constants.d.mts.map +1 -0
  3. package/dist/sync/graft-info/graft-info-constants.mjs +5 -0
  4. package/dist/sync/graft-info/graft-info-constants.mjs.map +1 -0
  5. package/dist/sync/graft-info/graft-info-helpers.d.mts +49 -0
  6. package/dist/sync/graft-info/graft-info-helpers.d.mts.map +1 -0
  7. package/dist/sync/graft-info/graft-info-helpers.mjs +236 -0
  8. package/dist/sync/graft-info/graft-info-helpers.mjs.map +1 -0
  9. package/dist/sync/graft-info/graft-info-helpers.respec.d.mts +2 -0
  10. package/dist/sync/graft-info/graft-info-helpers.respec.d.mts.map +1 -0
  11. package/dist/sync/graft-info/graft-info-helpers.respec.mjs +70 -0
  12. package/dist/sync/graft-info/graft-info-helpers.respec.mjs.map +1 -0
  13. package/dist/sync/graft-info/graft-info-types.d.mts +31 -0
  14. package/dist/sync/{merge-info/merge-info-types.d.mts.map → graft-info/graft-info-types.d.mts.map} +1 -1
  15. package/dist/sync/graft-info/graft-info-types.mjs +2 -0
  16. package/dist/sync/graft-info/graft-info-types.mjs.map +1 -0
  17. package/dist/sync/strategies/conflict-optimistic.d.mts +1 -1
  18. package/dist/sync/strategies/conflict-optimistic.d.mts.map +1 -1
  19. package/dist/sync/strategies/conflict-optimistic.mjs +10 -60
  20. package/dist/sync/strategies/conflict-optimistic.mjs.map +1 -1
  21. package/dist/sync/sync-conflict.respec.mjs +155 -34
  22. package/dist/sync/sync-conflict.respec.mjs.map +1 -1
  23. package/dist/sync/sync-constants.d.mts +9 -11
  24. package/dist/sync/sync-constants.d.mts.map +1 -1
  25. package/dist/sync/sync-constants.mjs +3 -5
  26. package/dist/sync/sync-constants.mjs.map +1 -1
  27. package/dist/sync/sync-helpers.d.mts +2 -0
  28. package/dist/sync/sync-helpers.d.mts.map +1 -1
  29. package/dist/sync/sync-helpers.mjs +11 -9
  30. package/dist/sync/sync-helpers.mjs.map +1 -1
  31. package/dist/sync/sync-innerspace-constants.respec.mjs +5 -1
  32. package/dist/sync/sync-innerspace-constants.respec.mjs.map +1 -1
  33. package/dist/sync/sync-innerspace-deep-updates.respec.mjs +5 -1
  34. package/dist/sync/sync-innerspace-deep-updates.respec.mjs.map +1 -1
  35. package/dist/sync/sync-innerspace-dest-ahead.respec.mjs +8 -4
  36. package/dist/sync/sync-innerspace-dest-ahead.respec.mjs.map +1 -1
  37. package/dist/sync/sync-innerspace-multiple-timelines.respec.mjs +5 -1
  38. package/dist/sync/sync-innerspace-multiple-timelines.respec.mjs.map +1 -1
  39. package/dist/sync/sync-innerspace-partial-update.respec.mjs +5 -1
  40. package/dist/sync/sync-innerspace-partial-update.respec.mjs.map +1 -1
  41. package/dist/sync/sync-innerspace.respec.mjs +5 -1
  42. package/dist/sync/sync-innerspace.respec.mjs.map +1 -1
  43. package/dist/sync/sync-peer/sync-peer-constants.d.mts +2 -0
  44. package/dist/sync/sync-peer/sync-peer-constants.d.mts.map +1 -0
  45. package/dist/sync/sync-peer/sync-peer-constants.mjs +2 -0
  46. package/dist/sync/sync-peer/sync-peer-constants.mjs.map +1 -0
  47. package/dist/sync/sync-peer/sync-peer-helpers.d.mts +2 -0
  48. package/dist/sync/sync-peer/sync-peer-helpers.d.mts.map +1 -0
  49. package/dist/sync/sync-peer/sync-peer-helpers.mjs +2 -0
  50. package/dist/sync/sync-peer/sync-peer-helpers.mjs.map +1 -0
  51. package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-constants.d.mts +8 -0
  52. package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-constants.d.mts.map +1 -0
  53. package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-constants.mjs +8 -0
  54. package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-constants.mjs.map +1 -0
  55. package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-helpers.d.mts +18 -0
  56. package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-helpers.d.mts.map +1 -0
  57. package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-helpers.mjs +54 -0
  58. package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-helpers.mjs.map +1 -0
  59. package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-types.d.mts +80 -0
  60. package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-types.d.mts.map +1 -0
  61. package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-types.mjs +5 -0
  62. package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-types.mjs.map +1 -0
  63. package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.d.mts +43 -0
  64. package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.d.mts.map +1 -0
  65. package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.mjs +229 -0
  66. package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.mjs.map +1 -0
  67. package/dist/sync/sync-peer/sync-peer-types.d.mts +12 -0
  68. package/dist/sync/sync-peer/sync-peer-types.d.mts.map +1 -1
  69. package/dist/sync/sync-peer/sync-peer-v1.d.mts +15 -7
  70. package/dist/sync/sync-peer/sync-peer-v1.d.mts.map +1 -1
  71. package/dist/sync/sync-peer/sync-peer-v1.mjs +105 -24
  72. package/dist/sync/sync-peer/sync-peer-v1.mjs.map +1 -1
  73. package/dist/sync/sync-saga-context/sync-saga-context-helpers.d.mts +5 -8
  74. package/dist/sync/sync-saga-context/sync-saga-context-helpers.d.mts.map +1 -1
  75. package/dist/sync/sync-saga-context/sync-saga-context-helpers.mjs +34 -18
  76. package/dist/sync/sync-saga-context/sync-saga-context-helpers.mjs.map +1 -1
  77. package/dist/sync/sync-saga-context/sync-saga-context-types.d.mts +26 -22
  78. package/dist/sync/sync-saga-context/sync-saga-context-types.d.mts.map +1 -1
  79. package/dist/sync/sync-saga-context/sync-saga-context-types.mjs +1 -9
  80. package/dist/sync/sync-saga-context/sync-saga-context-types.mjs.map +1 -1
  81. package/dist/sync/sync-saga-coordinator.d.mts +48 -51
  82. package/dist/sync/sync-saga-coordinator.d.mts.map +1 -1
  83. package/dist/sync/sync-saga-coordinator.mjs +720 -420
  84. package/dist/sync/sync-saga-coordinator.mjs.map +1 -1
  85. package/dist/sync/sync-saga-message/sync-saga-message-helpers.d.mts.map +1 -1
  86. package/dist/sync/sync-saga-message/sync-saga-message-helpers.mjs +1 -0
  87. package/dist/sync/sync-saga-message/sync-saga-message-helpers.mjs.map +1 -1
  88. package/dist/sync/sync-saga-message/sync-saga-message-types.d.mts +1 -12
  89. package/dist/sync/sync-saga-message/sync-saga-message-types.d.mts.map +1 -1
  90. package/dist/sync/sync-types.d.mts +15 -3
  91. package/dist/sync/sync-types.d.mts.map +1 -1
  92. package/dist/witness/light-witness-base-v1.d.mts.map +1 -1
  93. package/dist/witness/light-witness-base-v1.mjs +2 -0
  94. package/dist/witness/light-witness-base-v1.mjs.map +1 -1
  95. package/dist/witness/space/inner-space/inner-space-v1.mjs +1 -1
  96. package/dist/witness/space/inner-space/inner-space-v1.mjs.map +1 -1
  97. package/ibgib-foundations.md +20 -2
  98. package/package.json +1 -1
  99. package/src/sync/README.md +31 -22
  100. package/src/sync/graft-info/graft-info-constants.mts +4 -0
  101. package/src/sync/graft-info/graft-info-helpers.mts +308 -0
  102. package/src/sync/graft-info/graft-info-helpers.respec.mts +83 -0
  103. package/src/sync/graft-info/graft-info-types.mts +33 -0
  104. package/src/sync/strategies/conflict-optimistic.mts +11 -70
  105. package/src/sync/sync-conflict.respec.mts +177 -37
  106. package/src/sync/sync-constants.mts +5 -9
  107. package/src/sync/sync-helpers.mts +11 -7
  108. package/src/sync/sync-innerspace-constants.respec.mts +5 -1
  109. package/src/sync/sync-innerspace-deep-updates.respec.mts +5 -1
  110. package/src/sync/sync-innerspace-dest-ahead.respec.mts +7 -3
  111. package/src/sync/sync-innerspace-multiple-timelines.respec.mts +5 -1
  112. package/src/sync/sync-innerspace-partial-update.respec.mts +8 -2
  113. package/src/sync/sync-innerspace.respec.mts +5 -1
  114. package/src/sync/sync-peer/sync-peer-constants.mts +0 -0
  115. package/src/sync/sync-peer/sync-peer-helpers.mts +0 -0
  116. package/src/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-constants.mts +8 -0
  117. package/src/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-helpers.mts +72 -0
  118. package/src/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-types.mts +87 -0
  119. package/src/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.mts +242 -0
  120. package/src/sync/sync-peer/sync-peer-types.mts +13 -1
  121. package/src/sync/sync-peer/sync-peer-v1.mts +93 -27
  122. package/src/sync/sync-saga-context/sync-saga-context-helpers.mts +47 -29
  123. package/src/sync/sync-saga-context/sync-saga-context-types.mts +29 -30
  124. package/src/sync/sync-saga-coordinator.mts +782 -441
  125. package/src/sync/sync-saga-message/sync-saga-message-helpers.mts +2 -0
  126. package/src/sync/sync-saga-message/sync-saga-message-types.mts +0 -11
  127. package/src/sync/sync-types.mts +17 -3
  128. package/src/witness/light-witness-base-v1.mts +2 -1
  129. package/src/witness/space/inner-space/inner-space-v1.mts +1 -1
  130. package/test_output.log +489 -0
  131. package/tmp.md +61 -2
  132. package/dist/sync/merge-info/merge-info-constants.d.mts +0 -2
  133. package/dist/sync/merge-info/merge-info-constants.d.mts.map +0 -1
  134. package/dist/sync/merge-info/merge-info-constants.mjs +0 -2
  135. package/dist/sync/merge-info/merge-info-constants.mjs.map +0 -1
  136. package/dist/sync/merge-info/merge-info-helpers.d.mts +0 -51
  137. package/dist/sync/merge-info/merge-info-helpers.d.mts.map +0 -1
  138. package/dist/sync/merge-info/merge-info-helpers.mjs +0 -92
  139. package/dist/sync/merge-info/merge-info-helpers.mjs.map +0 -1
  140. package/dist/sync/merge-info/merge-info-helpers.respec.d.mts +0 -2
  141. package/dist/sync/merge-info/merge-info-helpers.respec.d.mts.map +0 -1
  142. package/dist/sync/merge-info/merge-info-helpers.respec.mjs +0 -32
  143. package/dist/sync/merge-info/merge-info-helpers.respec.mjs.map +0 -1
  144. package/dist/sync/merge-info/merge-info-types.d.mts +0 -26
  145. package/dist/sync/merge-info/merge-info-types.mjs +0 -2
  146. package/dist/sync/merge-info/merge-info-types.mjs.map +0 -1
  147. package/dist/sync/sync-local-spaces.respec.d.mts +0 -2
  148. package/dist/sync/sync-local-spaces.respec.d.mts.map +0 -1
  149. package/dist/sync/sync-local-spaces.respec.mjs +0 -159
  150. package/dist/sync/sync-local-spaces.respec.mjs.map +0 -1
  151. package/dist/sync/sync-peer/sync-peer-innerspace-v1.d.mts +0 -39
  152. package/dist/sync/sync-peer/sync-peer-innerspace-v1.d.mts.map +0 -1
  153. package/dist/sync/sync-peer/sync-peer-innerspace-v1.mjs +0 -131
  154. package/dist/sync/sync-peer/sync-peer-innerspace-v1.mjs.map +0 -1
  155. package/dist/sync/sync-saga-coordinator.respec.d.mts +0 -2
  156. package/dist/sync/sync-saga-coordinator.respec.d.mts.map +0 -1
  157. package/dist/sync/sync-saga-coordinator.respec.mjs +0 -40
  158. package/dist/sync/sync-saga-coordinator.respec.mjs.map +0 -1
  159. package/src/sync/merge-info/merge-info-constants.mts +0 -1
  160. package/src/sync/merge-info/merge-info-helpers.mts +0 -134
  161. package/src/sync/merge-info/merge-info-helpers.respec.mts +0 -41
  162. package/src/sync/merge-info/merge-info-types.mts +0 -28
  163. package/src/sync/sync-local-spaces.respec.mts +0 -200
  164. package/src/sync/sync-peer/sync-peer-innerspace-v1.mts +0 -167
  165. package/src/sync/sync-saga-coordinator.respec.mts +0 -52
@@ -1,131 +0,0 @@
1
- /**
2
- * @module SyncPeerInnerspace_V1
3
- */
4
- import { extractErrorMsg } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
5
- import { getIbGibAddr } from '@ibgib/ts-gib/dist/helper.mjs';
6
- import { GLOBAL_LOG_A_LOT } from '../../core-constants.mjs';
7
- import { SYNC_ATOM } from '../sync-constants.mjs';
8
- import { SyncPeer_V1 } from './sync-peer-v1.mjs';
9
- import { createSyncSagaContext } from '../sync-saga-context/sync-saga-context-helpers.mjs';
10
- import { getFromSpace, putInSpace } from '../../witness/space/space-helper.mjs';
11
- const logalot = GLOBAL_LOG_A_LOT || true;
12
- /**
13
- * Concrete implementation of SyncPeer for local in-memory simulation (Innerspace to Innerspace).
14
- *
15
- * Acts as the "Network" layer, transferring data between two local spaces and
16
- * executing the receiver's coordinator logic.
17
- */
18
- export class SyncPeerInnerspace_V1 extends SyncPeer_V1 {
19
- opts;
20
- lc = `[${SyncPeerInnerspace_V1.name}]`;
21
- constructor(opts) {
22
- super(opts.receiverSpace.data); // Use receiver space data as initial phantom data? Or empty.
23
- this.opts = opts;
24
- }
25
- async getLocalIbGib(addr) {
26
- const res = await getFromSpace({ space: this.opts.senderSpace, addr });
27
- return res.ibGibs?.[0];
28
- }
29
- async push(addr) {
30
- await this.transfer({ addr, from: this.opts.senderSpace, to: this.opts.receiverSpace });
31
- }
32
- async pull(addr) {
33
- await this.transfer({ addr, from: this.opts.receiverSpace, to: this.opts.senderSpace });
34
- }
35
- async sendRequest(context) {
36
- const lc = `${this.lc}[${this.sendRequest.name}]`;
37
- const { receiverSpace, receiverCoordinator, receiverMetaspace } = this.opts;
38
- try {
39
- if (logalot) {
40
- console.log(`${lc} starting...Context: ${getIbGibAddr({ ibGib: context })}`);
41
- }
42
- // 1. Resolve Frame from Receiver Space (It was PUSHED there independently)
43
- const sagaFrameAddr = context.rel8ns?.sagaFrame?.[0];
44
- if (!sagaFrameAddr) {
45
- throw new Error(`${lc} Missing sagaFrame in context (E: bf486874f5db0cb0883b79e81b344a26)`);
46
- }
47
- const resFrame = await getFromSpace({ space: receiverSpace, addr: sagaFrameAddr });
48
- const sagaFrame = resFrame.ibGibs?.[0];
49
- if (!sagaFrame) {
50
- throw new Error(`${lc} sagaFrame not found in receiver space: ${sagaFrameAddr} (E: 2c0190bd04ea408c909618193850029b)`);
51
- }
52
- // 2. Execute Receiver Logic
53
- // The Peer "Network" triggers the Receiver Coordinator.
54
- if (logalot) {
55
- console.log(`${lc} Invoking Receiver Coordinator...`);
56
- }
57
- // We pass an empty srcGraph because "Network" doesn't know about graph state.
58
- // Receiver Coordinator must rely on Space or fetch what it needs.
59
- const result = await receiverCoordinator.handleSagaFrame({
60
- sagaIbGib: sagaFrame,
61
- srcGraph: {},
62
- space: receiverSpace,
63
- metaspace: receiverMetaspace,
64
- });
65
- if (!result) {
66
- if (logalot) {
67
- console.log(`${lc} Receiver returned no result (Saga End?).`);
68
- }
69
- return undefined;
70
- }
71
- const { frame: responseFrame, payloadIbGibs } = result;
72
- if (logalot) {
73
- console.log(`${lc} responseFrame addr: ${getIbGibAddr({ ibGib: responseFrame })}`);
74
- }
75
- // 3. Persist Response Data to Receiver Space (Output Buffer)
76
- // The Receiver created new data (Frame, Payload). It must be saved in Receiver Space
77
- // so the "Network" can PULL it back to Sender.
78
- const ibGibsToPersist = [responseFrame, ...(payloadIbGibs || [])];
79
- // Note: payloadIbGibs might have deep dependencies.
80
- // Since they were generated/fetched by the Receiver Coordinator,
81
- // we assume they are already in the Receiver Space or explicitly returned here.
82
- // But if they are NEW (e.g. Ack Stone), they need putting.
83
- // For safety, we persist the full graph of any NEW payload?
84
- // Actually, `handleSagaFrame` usually creates stones in `tempSpace` or `space`.
85
- // If `space` passed was `receiverSpace`, they should be there.
86
- // But let's explicit put to be sure.
87
- await putInSpace({ space: receiverSpace, ibGibs: ibGibsToPersist });
88
- // 4. Create Response Context
89
- const responsePayloadAddrs = payloadIbGibs?.map(p => getIbGibAddr({ ibGib: p }));
90
- const responseCtx = await createSyncSagaContext({
91
- sagaFrame: responseFrame,
92
- payloadAddrs: responsePayloadAddrs,
93
- // TODO: identity/claims from Receiver?
94
- });
95
- // Persist Context to Receiver Space (so we can PULL it)
96
- await putInSpace({ space: receiverSpace, ibGib: responseCtx });
97
- return responseCtx;
98
- }
99
- catch (error) {
100
- console.error(`${lc} ${extractErrorMsg(error)}`);
101
- throw error;
102
- }
103
- }
104
- /**
105
- * Helper to copy single ibgib from A to B.
106
- */
107
- async transfer({ addr, from, to }) {
108
- const lc = `${this.lc}[${this.transfer.name}]`;
109
- // if (logalot) { console.log(`${lc} transferring ${addr}...`); } // Verbose
110
- // 1. Get from Source
111
- const res = await getFromSpace({ space: from, addr });
112
- if (!res.success || !res.ibGibs?.length) {
113
- throw new Error(`${lc} Failed to get ${addr} from source space ${from.data?.name} (E: 8a9b2c3d4e5f6g7h)`);
114
- }
115
- const ibGib = res.ibGibs[0];
116
- // 2. Put in Dest
117
- // Note: putInSpace handles existence check usually, or we can check.
118
- await putInSpace({ space: to, ibGib });
119
- // Force timeline indexing for Sync Frames
120
- if (ibGib.ib && ibGib.ib.startsWith(SYNC_ATOM)) {
121
- // Check if we are transferring TO the receiver space
122
- if (to === this.opts.receiverSpace) {
123
- // We must ensure the receiver metaspace knows this is a timeline TJP
124
- await this.opts.receiverMetaspace.registerNewIbGib({ ibGib, space: to });
125
- }
126
- }
127
- // Note: We do NOT recurse here. The base class 'witness' template drives the graph walk.
128
- // This is a "dumb" primitive transfer.
129
- }
130
- }
131
- //# sourceMappingURL=sync-peer-innerspace-v1.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sync-peer-innerspace-v1.mjs","sourceRoot":"","sources":["../../../src/sync/sync-peer/sync-peer-innerspace-v1.mts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,iDAAiD,CAAC;AAElF,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAE7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CA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@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=sync-saga-coordinator.respec.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sync-saga-coordinator.respec.d.mts","sourceRoot":"","sources":["../../src/sync/sync-saga-coordinator.respec.mts"],"names":[],"mappings":""}
@@ -1,40 +0,0 @@
1
- /**
2
- * @fileoverview Tests for SyncSagaCoordinator
3
- */
4
- import { respecfully, iReckon, ifWe } from '@ibgib/helper-gib/dist/respec-gib/respec-gib.mjs';
5
- const maam = `[${import.meta.url}]`, sir = maam;
6
- import { MockIbGibSpace } from '../test/mock-space.mjs';
7
- import { SyncSagaCoordinator } from './sync-saga-coordinator.mjs';
8
- import { KeystoneService_V1 } from '../keystone/keystone-service-v1.mjs';
9
- const lc = `[sync-saga.respec]`;
10
- await respecfully(sir, 'SyncSagaCoordinator', async () => {
11
- await ifWe(sir, 'runs a basic push sync', async () => {
12
- // Setup
13
- const sourceSpace = new MockIbGibSpace();
14
- const destSpace = new MockIbGibSpace(); // Acts as server
15
- const keystone = new KeystoneService_V1();
16
- const coordinator = new SyncSagaCoordinator(keystone);
17
- // Dummy Identity (In real test we'd gen one)
18
- const identity = {
19
- ib: 'keystone genesis',
20
- data: { uuid: 'alice' },
21
- rel8ns: {}
22
- };
23
- const identitySecret = 'secret';
24
- // Execute Sync
25
- // await coordinator.deprecated_sync({
26
- // source: sourceSpace,
27
- // dest: destSpace,
28
- // identity,
29
- // domainIbGibs: [], // Empty for test
30
- // identitySecret
31
- // });
32
- // Verify Dest has received frames
33
- // We look for any ibgibs in the destSpace witness output
34
- // Since FakeSpaceLocal stores in memory, we can peer into it if we had access,
35
- // but via public API, we might need to getLatestAddrs or similar.
36
- // For now, let's just assume no error means success, and iReckon true to pass.
37
- iReckon(sir, true).isGonnaBeTrue();
38
- });
39
- });
40
- //# sourceMappingURL=sync-saga-coordinator.respec.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sync-saga-coordinator.respec.mjs","sourceRoot":"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,aAAa,EAAE,CAAC;IACvC,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
@@ -1 +0,0 @@
1
- export const MERGE_INFO_ATOM = 'merge_info';
@@ -1,134 +0,0 @@
1
- import { Factory_V1 } from "@ibgib/ts-gib/dist/V1/factory.mjs";
2
- import { IbGib_V1 } from "@ibgib/ts-gib/dist/V1/types.mjs";
3
- import { getIbGibAddr } from "@ibgib/ts-gib/dist/helper.mjs";
4
- import { extractErrorMsg } from "@ibgib/helper-gib/dist/helpers/utils-helper.mjs";
5
-
6
- import { MetaspaceService } from "../../witness/space/metaspace/metaspace-types.mjs";
7
- import { MERGE_INFO_ATOM } from "./merge-info-constants.mjs";
8
- import { MergeInfoData_V1, MergeInfoIbGib_V1, MergeInfoIb_V1 } from "./merge-info-types.mjs";
9
- import { IbGibSpaceAny } from "../../witness/space/space-base-v1.mjs";
10
-
11
- const lc = `[merge-info-helpers]`;
12
-
13
- /**
14
- * Validates and constructs the `ib` object for a Merge Info ibGib.
15
- */
16
- export async function getMergeInfoIb({
17
- data
18
- }: {
19
- data: MergeInfoData_V1
20
- }): Promise<string> {
21
- if (!data.algo) { throw new Error(`(UNEXPECTED) data.algo required for MergeInfoIb (E: 8a9b0c1d2e3f4g5h)`); }
22
-
23
- // merge_info algo
24
- return [MERGE_INFO_ATOM, data.algo].join(' ');
25
- }
26
-
27
- /**
28
- * Parses a standard Merge Info 'ib' string.
29
- */
30
- export async function parseMergeInfoIb({
31
- ib
32
- }: {
33
- ib: string
34
- }): Promise<MergeInfoIb_V1> {
35
- try {
36
- const parts = ib.split(' ');
37
- if (parts[0] !== MERGE_INFO_ATOM) { throw new Error(`Atom mismatch. Expected ${MERGE_INFO_ATOM} (E: 8f03c92a95144b618821915632599266)`); }
38
- if (parts.length < 2) { throw new Error(`Invalid merge info ib. Expected at least 2 parts. (E: 9c2b4c8a6d34469f8263544710183355)`); }
39
-
40
- const algo = parts.slice(1).join(' '); // allow spaces in algo? usually single word but safe to join.
41
-
42
- return {
43
- atom: MERGE_INFO_ATOM,
44
- algo,
45
- };
46
- } catch (error) {
47
- console.error(`${lc} ${extractErrorMsg(error)}`);
48
- throw error;
49
- }
50
- }
51
-
52
- /**
53
- * Creates a new MergeInfo ibGib.
54
- */
55
- export async function createMergeInfo({
56
- algo,
57
- ancestors,
58
- details,
59
- }: {
60
- algo: string,
61
- ancestors: IbGib_V1[],
62
- details?: string,
63
- }): Promise<MergeInfoIbGib_V1> {
64
- const data: MergeInfoData_V1 = {
65
- algo,
66
- details,
67
- };
68
-
69
- const ib = await getMergeInfoIb({ data });
70
-
71
- const rel8ns: any = {};
72
- if (ancestors && ancestors.length > 0) {
73
- rel8ns.ancestors = ancestors.map(a => getIbGibAddr({ ibGib: a }));
74
- }
75
-
76
- const res = await Factory_V1.stone({
77
- ib,
78
- data,
79
- rel8ns,
80
- parentPrimitiveIb: MERGE_INFO_ATOM,
81
- uuid: true, // Should be unique per merge event? Yes.
82
- });
83
-
84
- // Unwrapping if necessary, though recent checking suggests Factory returns ibGib directly.
85
- // Wait, recent check in SyncSagaCoordinator showed Factory_V1.stone returns the ibGib directly.
86
- // But check the implementation plan/previous learnings.
87
- // Confirmed: Factory_V1.stone returns the ibGib directly.
88
- return res as MergeInfoIbGib_V1;
89
- }
90
-
91
- /**
92
- * Naive text merge.
93
- * Strategies:
94
- * 1. Concat (A + B)
95
- * 2. structured diff (not impl)
96
- */
97
- export async function mergeText({
98
- textA,
99
- textB,
100
- }: {
101
- textA: string,
102
- textB: string,
103
- }): Promise<string> {
104
- // Very naive: Just concat with a marker for now.
105
- // User wants "best effort at being non-destructive".
106
- if (textA === textB) { return textA; }
107
- return `${textA}\n\n>>> MERGE SEPARATOR <<<\n\n${textB}`;
108
- }
109
-
110
- /**
111
- * Combines two divergent timelines by applying missing DNA from one branch to another.
112
- *
113
- * Logic:
114
- * 1. Identify missing DNA (transforms) in `targetTip` that exist in `sourceTip` (relative to LCA).
115
- * 2. Replay those transforms onto `targetTip`.
116
- * 3. Create a MergeInfo stone describing this operation.
117
- * 4. Relate the new tip to the MergeInfo.
118
- */
119
- export async function combineDivergentTimelines({
120
- targetTip,
121
- sourceTip,
122
- lca,
123
- space,
124
- metaspace,
125
- }: {
126
- targetTip: IbGib_V1,
127
- sourceTip: IbGib_V1,
128
- lca: IbGib_V1,
129
- space: IbGibSpaceAny,
130
- metaspace: MetaspaceService,
131
- }): Promise<IbGib_V1> {
132
- // stub implementation
133
- return targetTip;
134
- }
@@ -1,41 +0,0 @@
1
- /**
2
- * @module merge-info-helpers.respec
3
- */
4
- import { iReckon, respecfully, ifWe, ifWeMight } from '@ibgib/helper-gib/dist/respec-gib/respec-gib.mjs';
5
- import { mergeText } from './merge-info-helpers.mjs';
6
-
7
- const maam = `[${import.meta.url}]`;
8
- const sir = maam;
9
-
10
- await respecfully(sir, 'Merge Info Helpers', async () => {
11
-
12
- await respecfully(sir, 'mergeText', async () => {
13
-
14
- await ifWeMight(sir, 'mergeText should concat different strings', async () => {
15
- const textA = "Hello";
16
- const textB = "World";
17
- const res = await mergeText({ textA, textB });
18
- iReckon(sir, res).asTo('result').isGonnaBeTruthy();
19
- iReckon(sir, res.includes(textA)).asTo('includes A').isGonnaBeTruthy();
20
- iReckon(sir, res.includes(textB)).asTo('includes B').isGonnaBeTruthy();
21
- iReckon(sir, res.includes('MERGE SEPARATOR')).asTo('includes separator').isGonnaBeTruthy();
22
- });
23
-
24
- await ifWeMight(sir, 'mergeText should return same string if identical', async () => {
25
- const textA = "Hello";
26
- const res = await mergeText({ textA, textB: textA });
27
- iReckon(sir, res).asTo('result').isGonnaBe(textA);
28
- });
29
-
30
- });
31
-
32
- await respecfully(sir, 'combineDivergentTimelines', async () => {
33
-
34
- await ifWeMight(sir, 'combineDivergentTimelines should work (Stub)', async () => {
35
- // Validation of stub for now, just to ensure scaffolding works.
36
- iReckon(sir, true).asTo('stub executed').isGonnaBeTruthy();
37
- });
38
-
39
- });
40
-
41
- });
@@ -1,28 +0,0 @@
1
- import { IbGib_V1, IbGibData_V1, IbGibRel8ns_V1 } from "@ibgib/ts-gib/dist/V1/types.mjs";
2
- import { MERGE_INFO_ATOM } from "./merge-info-constants.mjs";
3
-
4
- export interface MergeInfoIb_V1 {
5
- atom: typeof MERGE_INFO_ATOM;
6
- algo: string; // e.g. "optimistic", "text", "manual"
7
- }
8
-
9
- export interface MergeInfoData_V1 extends IbGibData_V1 {
10
- /**
11
- * The algorithm or strategy used to perform the merge.
12
- */
13
- algo: string;
14
- /**
15
- * Optional details about the merge, e.g. validation results or specifics about conflicts resolved.
16
- */
17
- details?: string;
18
- }
19
-
20
- export interface MergeInfoRel8ns_V1 extends IbGibRel8ns_V1 {
21
- /**
22
- * The ibGibs that were merged together.
23
- * For a timeline merge, these are the tips of the divergent branches.
24
- */
25
- ancestors?: string[];
26
- }
27
-
28
- export interface MergeInfoIbGib_V1 extends IbGib_V1<MergeInfoData_V1, MergeInfoRel8ns_V1> { }
@@ -1,200 +0,0 @@
1
- import { rm } from 'node:fs/promises';
2
- import { default as pathUtils } from 'path';
3
-
4
- import {
5
- respecfully, lastOfAll
6
- } from '@ibgib/helper-gib/dist/respec-gib/respec-gib.mjs';
7
- const maam = `[${import.meta.url}]`, sir = maam;
8
-
9
- import { Factory_V1 } from '@ibgib/ts-gib/dist/V1/factory.mjs';
10
- import { rel8 } from '@ibgib/ts-gib/dist/V1/transforms/rel8.mjs';
11
- import { getIbGibAddr, } from '@ibgib/ts-gib/dist/helper.mjs';
12
- import { IBGIB_ENCODING } from '../witness/space/filesystem-space/filesystem-constants.mjs';
13
- import { NodeFilesystemSpace_V1 } from '../witness/space/filesystem-space/node-filesystem-space/node-filesystem-space-v1.mjs';
14
- import { NodeFilesystemSpaceData_V1 } from '../witness/space/filesystem-space/node-filesystem-space/node-filesystem-space-types.mjs';
15
- import { SyncSagaCoordinator } from './sync-saga-coordinator.mjs';
16
- import { SyncStage } from './sync-constants.mjs';
17
- import { getTimestampInTicks, getUUID } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
18
- import { GIB, IBGIB_DELIMITER } from '@ibgib/ts-gib/dist/V1/constants.mjs';
19
- import { putInSpace, getFromSpace } from '../witness/space/space-helper.mjs';
20
- import { KeystoneService_V1 } from '../keystone/keystone-service-v1.mjs';
21
- import { KeystoneIbGib_V1 } from '../keystone/keystone-types.mjs';
22
- import { mut8 } from '@ibgib/ts-gib/dist/V1/transforms/mut8.mjs';
23
-
24
- const logalot = true;
25
- const lc = `[sync-local-spaces.respec]`;
26
-
27
- // Helper to create a temp space
28
- const createTempSpace = async ({
29
- baseDir,
30
- name
31
- }: {
32
- baseDir: string,
33
- name: string
34
- }): Promise<NodeFilesystemSpace_V1> => {
35
- const uuid = await getUUID();
36
- const initialData: NodeFilesystemSpaceData_V1 = {
37
- version: '1',
38
- classname: NodeFilesystemSpace_V1.name,
39
- uuid,
40
- name,
41
- description: `Temp space for ${name}`,
42
- baseDir,
43
- baseSubPath: 'ibgib', // keep short to avoid long path issues
44
- spaceSubPath: name,
45
- ibgibsSubPath: 'ibgibs',
46
- metaSubPath: 'meta',
47
- binSubPath: 'bin',
48
- dnaSubPath: 'dna',
49
- encoding: IBGIB_ENCODING,
50
- mitigateLongPaths: true,
51
- // other defaults
52
- catchAllErrors: false,
53
- trace: false,
54
- };
55
-
56
- // mimic constructor logic if needed, or just new it up
57
- const space = new NodeFilesystemSpace_V1(initialData);
58
- // Explicitly initialize if needed (based on findings, constructor calls super which calls initialize?
59
- // Actually source had it commented out in ctor. Let's call it via a witness "put" which should verify initialization)
60
- return space;
61
- };
62
-
63
- // class MockKeystoneService implements KeystoneService_V1 {
64
- // async getIdentity(): Promise<KeystoneIbGib_V1> {
65
- // // Return a dummy identity
66
- // const res = await Factory_V1.firstGen({
67
- // ib: 'identity',
68
- // data: { uuid: await getUUID() },
69
- // dna: true,
70
- // });
71
- // return res.newIbGib as KeystoneIbGib_V1;
72
- // }
73
- // // Implement other methods as no-ops or simple mocks
74
- // async sign(ibGib: any): Promise<any> { return ibGib; }
75
- // async verify(ibGib: any): Promise<boolean> { return true; }
76
- // // Add other required properties/methods of KeystoneService_V1 if any (checking interface might be needed)
77
- // // Assuming for now these are the core ones used by Coordinator.
78
- // // If strict interface, might need more.
79
- // }
80
-
81
- await respecfully(sir, `Sync Local Spaces`, async () => {
82
-
83
- const TEST_ROOT = pathUtils.join(process.cwd(), 'tmp_sync_test_' + await getUUID());
84
-
85
- lastOfAll(sir, async () => {
86
- if (!logalot) {
87
- await rm(TEST_ROOT, { recursive: true, force: true });
88
- } else {
89
- console.log(`${lc} Leaving TEST_ROOT for inspection: ${TEST_ROOT}`);
90
- }
91
- });
92
-
93
- await respecfully(sir, `Basic Push Sync (Source -> Dest)`, async () => {
94
- // // 1. Setup Spaces
95
- // const srcDir = pathUtils.join(TEST_ROOT, 'source');
96
- // const destDir = pathUtils.join(TEST_ROOT, 'dest');
97
-
98
- // const sourceSpace = await createTempSpace({ baseDir: srcDir, name: 'source' });
99
- // const destSpace = await createTempSpace({ baseDir: destDir, name: 'dest' });
100
-
101
- // // 2. Seed Source Data
102
- // // 2.1 Create a "Stone" (Primitive-like or just immutable data)
103
- // const stoneRes = await Factory_V1.firstGen({
104
- // ib: 'stone_data',
105
- // data: { some: 'data', timestamp: getTimestampInTicks() },
106
- // dna: false,
107
- // });
108
- // const stone = stoneRes.newIbGib;
109
- // const stoneAddr = getIbGibAddr({ ibGib: stone });
110
-
111
- // // 2.2 Create a "Living" Timeline (Root -> Child)
112
- // const rootRes = await Factory_V1.firstGen({
113
- // ib: 'timeline_root',
114
- // data: { type: 'root' },
115
- // dna: true,
116
- // });
117
- // const root = rootRes.newIbGib;
118
- // const rootAddr = getIbGibAddr({ ibGib: root });
119
-
120
- // const childRes = await mut8({
121
- // type: 'fork',
122
- // src: root,
123
- // dna: true,
124
- // data: { type: 'child', n: 1 }
125
- // });
126
- // const child = childRes.newIbGib;
127
- // const childAddr = getIbGibAddr({ ibGib: child });
128
-
129
- // // Put into Source
130
- // await putInSpace({
131
- // space: sourceSpace,
132
- // ibGibs: [stone, root, child]
133
- // });
134
-
135
- // // 3. Setup Sync Coordinator
136
- // const mockKeystone = new MockKeystoneService() as unknown as KeystoneService_V1;
137
- // const identity = await mockKeystone.getIdentity();
138
- // const coordinator = new SyncSagaCoordinator(mockKeystone);
139
-
140
- // // Define domain (roots to sync)
141
- // const domainIbGibs = [root]; // We only explicitly track the "Living" root. Stone is standalone?
142
- // // Actually for the test let's explicitly include both or rely on dependency graph.
143
- // // If 'stone' is not related to 'root', it won't be picked up unless we add it to domain.
144
- // // Let's Rel8 the stone to the child to test dependency traversal.
145
-
146
- // const childWithRelRes = await rel8({
147
- // src: child,
148
- // rel8nsToAddByAddr: { 'linked_stone': [stoneAddr] },
149
- // dna: true,
150
- // });
151
- // const childWithRel = childWithRelRes.newIbGib;
152
- // const childWithRelAddr = getIbGibAddr({ ibGib: childWithRel });
153
-
154
- // // Update Source with linked child
155
- // await putInSpace({
156
- // space: sourceSpace,
157
- // ibGibs: [childWithRel]
158
- // });
159
-
160
- // // 4. Run Sync
161
- // const syncRes = await coordinator.sync({
162
- // source: sourceSpace,
163
- // dest: destSpace,
164
- // domainIbGibs: [childWithRel], // Sync starting from the tip
165
- // identity
166
- // });
167
-
168
- // // 5. Verify Dest
169
- // // Check Stone
170
- // const getStone = await getFromSpace({
171
- // space: destSpace,
172
- // addr: stoneAddr
173
- // });
174
- // if (!getStone.success || !getStone.ibGibs?.[0]) {
175
- // throw new Error(`Dest failed to get Stone: ${stoneAddr}`);
176
- // }
177
- // console.log(`${lc} Verified Stone synced.`);
178
-
179
- // // Check ChildWithRel (Tip)
180
- // const getChild = await getFromSpace({
181
- // space: destSpace,
182
- // addr: childWithRelAddr
183
- // });
184
- // if (!getChild.success || !getChild.ibGibs?.[0]) {
185
- // throw new Error(`Dest failed to get ChildWithRel: ${childWithRelAddr}`);
186
- // }
187
- // console.log(`${lc} Verified Timeline Tip synced.`);
188
-
189
- // // Check Root (Dependency)
190
- // const getRoot = await getFromSpace({
191
- // space: destSpace,
192
- // addr: rootAddr
193
- // });
194
- // if (!getRoot.success || !getRoot.ibGibs?.[0]) {
195
- // throw new Error(`Dest failed to get Root: ${rootAddr}`);
196
- // }
197
- // console.log(`${lc} Verified Root synced.`);
198
-
199
- });
200
- });