# ibGib Roadmap: Authentication, Sync, & Persistence

This document outlines the strategic technical goals for the next major phases of development.

## Phase 1: Symmetric Sync Completion (Current)
*   **Goal**: Robust, verifiable synchronization between two spaces.
*   **Status**: In Progress.
*   **Remaining Tasks**:
    *   [ ] **Conflict Resolution**: Implementing `handleConflictFrame`, divergent branch detection, and optimistic merge strategies.
    *   [ ] **Ephemeral Identity**: Integrating "Session Keystones" into the Sync Saga to sign frames and authorize exchanges.
    *   [ ] **Verification**: Extensive testing of "Happy Path", "Fast-Forward", "Fast-Backward", and "Divergence" scenarios.

## Phase 2: Authentication & SSO Integration
*   **Goal**: Secure, user-friendly login and session management for the ibGib ecosystem.
*   **Key Components**:
    *   **NO AWS Cognito**: We are building a custom integration.
    *   **OAuth2 / OIDC**: Implementing "Login with..." providers (Google, GitHub, etc.).
    *   **Keystone Binding**: Binding an SSO identity (e.g., Google `sub`) to an ibGib Keystone Identity.
    *   **Authorization**: Using Keystones to manage access control lists (ACLs) on spaces.

## Phase 3: Persistence (Postgres Space)
*   **Goal**: High-performance, scalable storage backend for "Server" nodes.
*   **Key Components**:
    *   **PostgresSpace**: Implementing the `Space` witness interface backed by PostgreSQL.
    *   **Graph Mapping**: Efficiently mapping the ibGib DAG structure to Relational tables.
    *   **Compression**: Implementing "Smart Storage" to deduplicate accretive relationship arrays.

## Detailed Task Backlog
Derived from `gemini_conversations/2026-01-08_Authentication-Sync-Part-One/task.md`.

### Phase 1: Symmetric Sync (Remaining)
- [ ] **Robustness Refactor**
    - [ ] Analyze and Plan Architecture Changes
- [ ] **Testing & Verification**
    - [ ] Verify `getDependencyGraph` integration test (in `space-respec-helper.mts`)
    - [ ] Create Test Suite for Sync Logic (`sync-saga-coordinator.respec.mts`)
    - [ ] Verify Local Sync Scenarios (InnerSpace)
        - [ ] Divergent (Conflict Detection & Merge)
- [ ] **Protocol Completion**
    - [ ] Implement `startSaga` (Initiator)
    - [ ] Implement `handleSagaFrame` (Reactor) -- *Verify completeness*
    - [ ] Implement Ephemeral Identity (Sync Keystone) & Trust Chain
- [ ] **Optimization**
    - [ ] Add Test `testSpace_getDependencyGraph` in `space-respec-helper.mts`
    - [ ] Verify `addrsNotFound` behavior in `space-respec-helper.mts`
    - [ ] Investigate Transactional Sync / `ReconciliationSpaceBase` cleanup

### Phase 2: Server Substrate (@ibgib/node-gib)
- [ ] Implement `PostgresSpace_V1`.
- [ ] Implement `StagingSpace` wrapper.

### Phase 3: Super Node Service (apps/sync-node)
- [ ] Fastify/Express Server setup.
- [ ] Remote Coordinator logic.
- [ ] SSO Integration (Google/GitHub -> Keystone Claim).

### Phase 4: Client Adapter (@ibgib/web-gib)
- [ ] Implement `HttpSyncSpace_V1`.
- [ ] Integration Testing.
