# Sync Protocol Verification

This document outlines the testing strategy and verification results for the Symmetric Sync Protocol.

## Testing Strategy
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.

### Key Test Files
*   `sync-innerspace.respec.mts`: Basic Push/Pull scenarios.
*   `sync-innerspace-multiple-timelines.respec.mts`: Handling multiple independent timelines in one Saga.
*   `sync-innerspace-deep-updates.respec.mts`: Syncing timelines with extensive history (ensuring `past` links are traversed).
*   `sync-innerspace-partial-update.respec.mts`: **Smart Diff** verification (Sender uses Receiver's context to send only deltas).
*   `sync-innerspace-dest-ahead.respec.mts`: Verifying "Fast-Backward" or "Push Offer" logic (Sender offers update, Receiver accepts).
*   `sync-innerspace-constants.respec.mts`: Verifying synchronization of **Stones** (Constants/Non-TJPs).

## Verification Matrix

### 1. Basic Scenarios
| Feature | Description | Status | Test File |
| :--- | :--- | :--- | :--- |
| **Push** | Source syncs a new timeline to an empty Dest. | ✅ Verified | `sync-innerspace.respec.mts` |
| **Pull** | Dest requests data from Source (Reverse Sync). | ⏳ Pending | `sync-innerspace.respec.mts` |
| **Dest Ahead** | Dest has newer data; Source offers Push. | ✅ Verified | `sync-innerspace-dest-ahead.respec.mts` |

### 2. Complex Graph Scenarios
| Feature | Description | Status | Test File |
| :--- | :--- | :--- | :--- |
| **Multi-Timeline** | Syncing multiple separate timelines. | ✅ Verified | `sync-innerspace-multiple-timelines.respec.mts` |
| **Deep Updates** | Syncing deep dependency chains (Ancestors). | ✅ Verified | `sync-innerspace-deep-updates.respec.mts` |
| **Smart Diff** | Sender skips data Receiver already has. | ✅ Verified | `sync-innerspace-partial-update.respec.mts` |
| **Constants** | Syncing immutable stones (no TJP). | ✅ Verified | `sync-innerspace-constants.respec.mts` |

### 3. Failure & Edge Cases
| Feature | Description | Status | Test File |
| :--- | :--- | :--- | :--- |
| **Validation** | Verifying Integrity Checks (ib/gib). | ⏳ Pending | - |
| **Conflicts** | Divergent branches (Merge Strategy). | ⏳ Pending | - |

## Recent Verifications
### Sync Constants (2026-01-08)
*   **Goal**: Ensure constants (ibGibs without `tjp` or `past`) are synced.
*   **Result**: Passed.
*   **Fixes**: Updated `handleInitFrame` to request missing stones; updated `handleAckFrame` to include "tip" stones in payload even without dependencies.
