@ibgib/core-gib 0.1.59 → 0.1.60

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 (42) hide show
  1. package/CHANGELOG.md +9 -1
  2. package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.mjs +1 -1
  3. package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.mjs.map +1 -1
  4. package/dist/sync/sync-peer/sync-peer-types.d.mts +12 -1
  5. package/dist/sync/sync-peer/sync-peer-types.d.mts.map +1 -1
  6. package/dist/sync/sync-peer/sync-peer-v1.d.mts +7 -0
  7. package/dist/sync/sync-peer/sync-peer-v1.d.mts.map +1 -1
  8. package/dist/sync/sync-peer/sync-peer-v1.mjs +43 -1
  9. package/dist/sync/sync-peer/sync-peer-v1.mjs.map +1 -1
  10. package/dist/sync/sync-peer/sync-peer-websocket/sync-peer-websocket-receiver/sync-peer-websocket-receiver-v1.d.mts +1 -0
  11. package/dist/sync/sync-peer/sync-peer-websocket/sync-peer-websocket-receiver/sync-peer-websocket-receiver-v1.d.mts.map +1 -1
  12. package/dist/sync/sync-peer/sync-peer-websocket/sync-peer-websocket-receiver/sync-peer-websocket-receiver-v1.mjs +15 -5
  13. package/dist/sync/sync-peer/sync-peer-websocket/sync-peer-websocket-receiver/sync-peer-websocket-receiver-v1.mjs.map +1 -1
  14. package/dist/sync/sync-peer/sync-peer-websocket/sync-peer-websocket-sender/sync-peer-websocket-sender-v1.d.mts +16 -0
  15. package/dist/sync/sync-peer/sync-peer-websocket/sync-peer-websocket-sender/sync-peer-websocket-sender-v1.d.mts.map +1 -1
  16. package/dist/sync/sync-peer/sync-peer-websocket/sync-peer-websocket-sender/sync-peer-websocket-sender-v1.mjs +223 -79
  17. package/dist/sync/sync-peer/sync-peer-websocket/sync-peer-websocket-sender/sync-peer-websocket-sender-v1.mjs.map +1 -1
  18. package/dist/sync/sync-saga-context/sync-saga-context-helpers.d.mts.map +1 -1
  19. package/dist/sync/sync-saga-context/sync-saga-context-helpers.mjs +41 -2
  20. package/dist/sync/sync-saga-context/sync-saga-context-helpers.mjs.map +1 -1
  21. package/dist/sync/sync-saga-context/sync-saga-context-types.d.mts +4 -0
  22. package/dist/sync/sync-saga-context/sync-saga-context-types.d.mts.map +1 -1
  23. package/dist/sync/sync-saga-coordinator.d.mts +6 -0
  24. package/dist/sync/sync-saga-coordinator.d.mts.map +1 -1
  25. package/dist/sync/sync-saga-coordinator.mjs +57 -1
  26. package/dist/sync/sync-saga-coordinator.mjs.map +1 -1
  27. package/dist/sync/sync-withid.pingpong.respec.mjs +68 -0
  28. package/dist/sync/sync-withid.pingpong.respec.mjs.map +1 -1
  29. package/package.json +1 -1
  30. package/src/sync/docs/security-3b.md +92 -0
  31. package/src/sync/docs/security.md +107 -39
  32. package/src/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.mts +1 -1
  33. package/src/sync/sync-peer/sync-peer-types.mts +11 -1
  34. package/src/sync/sync-peer/sync-peer-v1.mts +47 -1
  35. package/src/sync/sync-peer/sync-peer-websocket/README.md +42 -0
  36. package/src/sync/sync-peer/sync-peer-websocket/sync-peer-websocket-receiver/sync-peer-websocket-receiver-v1.mts +14 -5
  37. package/src/sync/sync-peer/sync-peer-websocket/sync-peer-websocket-sender/sync-peer-websocket-sender-v1.mts +242 -78
  38. package/src/sync/sync-saga-context/sync-saga-context-helpers.mts +46 -4
  39. package/src/sync/sync-saga-context/sync-saga-context-types.mts +5 -0
  40. package/src/sync/sync-saga-coordinator.mts +69 -1
  41. package/src/sync/sync-withid.pingpong.respec.mts +74 -1
  42. package/src/sync/docs/ping_pong_plan.md +0 -147
@@ -1,147 +0,0 @@
1
- # Phase 3: Ping Pong Sync with Identity Plan
2
-
3
- This document details the step-by-step execution flow, space-routing rules, and verification requirements for implementing Phase 3 (Basic Single-Timeline Sync with Identity).
4
-
5
- ## Core Concepts & Terms
6
- * **Durable Space**: Persistent local database/filesystem storage (`localSpace`).
7
- * **Temporary Space**: In-memory or transient storage (`tempSpace`) used during the sync saga to accumulate uncommitted domain data.
8
- * **Control/Saga IbGibs**: The sync saga timeline, saga message stones, context envelopes, and session identity evolutions. These represent the protocol communication and auditing trail.
9
- * **Domain IbGibs**: The actual user timelines, files, or payload data being synchronized.
10
- * **Sender (Alice / Initiator)**: The node that generates and signs all request turns using the ephemeral Session Keystone ($S$).
11
- * **Receiver (Bob / Sovereign Broker / Reactor)**: The node that validates the sender's cryptographic turns and replies with unsigned contexts echoing the same session identity.
12
-
13
- ### Note on "Domain" Overloaded Term
14
-
15
- The term "domain" is overloaded at this point WRT sync and identity contexts. In this sync context, "domain" refers to ibgibs in the business logic domain, i.e., the actual data we're working with. This is in contrast to the identity context, in which "domain" means the identity boundary created with a main identity keystone. Neither usage is easily refactorable in code, hence the term overloading.
16
-
17
- **TL;DR - Sync: "domain" vs "control". Identity: "domain" keystone vs. "session" keystone**
18
-
19
- ---
20
-
21
- ## Storage & Routing Rules (Security Boundary)
22
-
23
- | IbGib Category | Target Space (Validation Phase) | Target Space (Commit Phase) | Rationale |
24
- | :--- | :--- | :--- | :--- |
25
- | **Control / Saga** | Durable Space (`localSpace`) | Durable Space (`localSpace`) | Must be persisted ASAP after authentication/validation per exchange between endpoints to maintain a tamper-evident audit trail, even if the sync fails midway. |
26
- | **Domain Payloads** | Temporary Space (`tempSpace`) | Durable Space (`localSpace`) | Avoids polluting the durable space with unverified or partial data before a transaction successfully commits. |
27
-
28
- ---
29
-
30
- ## Detailed Leg-by-Leg Execution Flow
31
-
32
- ```mermaid
33
- sequenceDiagram
34
- autonumber
35
- actor Alice as Sender (Alice)
36
- actor Bob as Receiver (Bob)
37
-
38
- Note over Alice: Leg 1: Init (Sign & Post)
39
- Alice->>Alice: Sign/Evolve S -> S_init
40
- Alice->>Alice: Bind context.rel8ns.sessionIdentity = S_genesis
41
- Alice->>Alice: Bind context.signedSessionIdentity = S_init
42
- Alice->>Bob: Send Context (with S_init frame)
43
- Note over Bob: Authenticate S_init independently
44
- Bob->>Bob: Save Context & S_init to Durable Space
45
-
46
- Note over Bob: Leg 2: Ack (Passive Validation)
47
- Bob->>Bob: Prepare Ack context
48
- Bob->>Bob: Bind context.rel8ns.sessionIdentity = S_init
49
- Note over Bob: (No new evolution / signedSessionIdentity = undefined)
50
- Bob->>Alice: Return Ack Context
51
-
52
- Note over Alice: Leg 3: Delta (Sign & Payload)
53
- Alice->>Alice: Process Ack requests
54
- Alice->>Alice: Sign/Evolve S_init -> S_delta
55
- Alice->>Alice: Bind context.rel8ns.sessionIdentity = S_init
56
- Alice->>Alice: Bind context.signedSessionIdentity = S_delta
57
- Alice->>Bob: Send Delta Context + Domain Payloads
58
- Note over Bob: Authenticate S_delta independently
59
- Bob->>Bob: Save Context & S_delta to Durable Space
60
- Bob->>Bob: Save Domain Payloads to Temp Space
61
-
62
- Note over Bob: Leg 4: Commit (Passive Verification)
63
- Bob->>Bob: Prepare Commit context
64
- Bob->>Bob: Bind context.rel8ns.sessionIdentity = S_delta
65
- Bob->>Alice: Return Commit Context
66
- Bob->>Bob: Move Domain Payloads (Temp -> Durable)
67
- Alice->>Alice: Move Domain Payloads (Temp -> Durable)
68
- ```
69
-
70
- ### Leg 1: Init (Sender $\to$ Receiver)
71
- 1. **Sender (Alice)**:
72
- * [ ] Generates the `Init` message frame.
73
- * [ ] Signs and evolves the session identity from $S_{genesis}$ to $S_{init}$ using the `sync` pool, targeting the `Init` context ibgib.
74
- * [ ] Wraps the saga in a context:
75
- * `context.rel8ns.sessionIdentity = [S_genesis_addr]`
76
- * `context.signedSessionIdentity = S_init`
77
- * [ ] Transmits the context to the peer. Note: We only transmit the single evolved `S_init` frame inside `signedSessionIdentity`.
78
- 2. **Receiver (Bob)**:
79
- * [ ] Receives the context.
80
- * [ ] **Authentication**: Run `authenticateContext`.
81
- * [ ] Retrieve the previous keystone frame ($S_{genesis}$) independently from Bob's own local registry (using the session identity address obtained via $I_1$'s claim), rather than trusting any path/history Alice sends.
82
- * [ ] Validate the cryptographic evolution from $S_{genesis}$ to the incoming $S_{init}$ (sequential counters, signature verification).
83
- * [ ] Verify the signature in $S_{init}$ targets the exact context address.
84
- * [ ] **Persistence**: Ensure $S_{init}$ is saved to the durable space alongside the context/saga control ibgibs (already handled by the coordinator's sync state saving mechanism, but needs to include the new session identity frame).
85
-
86
- ### Leg 2: Ack (Receiver $\to$ Sender)
87
- 1. **Receiver (Bob)**:
88
- * [ ] Creates the `Ack` message frame.
89
- * [ ] Wraps it in an `Ack` context:
90
- * `context.rel8ns.sessionIdentity = [S_init_addr]`
91
- * `context.signedSessionIdentity = undefined` (Bob does *not* sign or evolve $S$).
92
- * [ ] Transmits the `Ack` context to Alice.
93
- 2. **Sender (Alice)**:
94
- * [ ] Receives the `Ack` context.
95
- * [ ] Processes the gap requests and prepares domain payloads.
96
-
97
- ### Leg 3: Delta (Sender $\to$ Receiver)
98
- 1. **Sender (Alice)**:
99
- * [ ] Creates the `Delta` message frame.
100
- * [ ] Signs and evolves the session identity from $S_{init}$ to $S_{delta}$, targeting the `Delta` context ibgib.
101
- * [ ] Wraps it in a `Delta` context:
102
- * `context.rel8ns.sessionIdentity = [S_init_addr]`
103
- * `context.signedSessionIdentity = S_delta`
104
- * [ ] Transmits the `Delta` context and the domain payloads.
105
- 2. **Receiver (Bob)**:
106
- * [ ] Receives the context and domain payloads.
107
- * [ ] **Authentication**: Run `authenticateContext`.
108
- * [ ] Retrieve $S_{init}$ independently from Bob's own local registry.
109
- * [ ] Validate transition from $S_{init}$ to $S_{delta}$.
110
- * [ ] Verify signature targets the `Delta` context address.
111
- * [ ] **Persistence**:
112
- * [ ] Ensure $S_{delta}$ is saved to the durable space alongside the control ibgibs.
113
- * [ ] Save incoming domain payloads to **Temporary Space** (`tempSpace`).
114
-
115
- ### Leg 4: Commit (Receiver $\to$ Sender)
116
- 1. **Receiver (Bob)**:
117
- * [ ] Creates the `Commit` message frame and context.
118
- * [ ] Returns the `Commit` context to Alice.
119
- * [ ] Commits the sync session: transfers all domain payloads from `tempSpace` to `localSpace` (Durable).
120
- 2. **Sender (Alice)**:
121
- * [ ] Receives the `Commit` context.
122
- * [ ] Commits the sync session: transfers accumulated domain payloads from `tempSpace` to `localSpace` (Durable).
123
-
124
- ---
125
-
126
- ## Phase 3A: Step-by-Step Testing Plan
127
-
128
- To prevent complexity explosion, we will implement this incrementally using a new test file: `libs/core-gib/src/sync/sync-withid.pingpong.respec.mts`.
129
-
130
- ### Step 1: Scaffold & Establish
131
- * [ ] Initialize a basic sync saga setup (two spaces, two coordinators, custom in-memory peer).
132
- * [ ] Perform Phase 1 establish to load the sender identity $I$ and session identity $S_{genesis}$ into the spaces.
133
- * [ ] Trigger `sync(...)`. Assert that the saga fails on Leg 1 due to unimplemented identity checks on the receiver.
134
-
135
- ### Step 2: Implement Leg 1 Validation
136
- * [ ] Implement `authenticateContext` on the sync peer receiver (or as a helper).
137
- * [ ] Wire `authenticateContext` into the coordinator/peer incoming frame handler.
138
- * [ ] Verify that Leg 1 completes without error and that the receiver successfully writes the saga/session frames to durable space.
139
-
140
- ### Step 3: Implement Leg 2 & Leg 3 Validation
141
- * [ ] Verify Alice processes the Ack and produces a Delta.
142
- * [ ] Implement Alice's second evolution to $S_{delta}$ and verification of it by Bob.
143
- * [ ] Verify domain payloads are successfully written to `tempSpace` during the Delta stage.
144
-
145
- ### Step 4: Transactional Commit
146
- * [ ] Implement the commit phase logic that transfers domain payloads from `tempSpace` to `localSpace` upon receipt/emission of the `Commit` frame.
147
- * [ ] Assert that the final domain graphs on both sides are completely equivalent.