openapi: 3.1.0
info:
  title: GC-16 Capsule Bridge API
  version: 1.0.0
  description: |
    Bridges Google Workspace sync events from GC-16 to the Genesis Conductor 
    Soul Capsule event log. Implements A2A JSON-RPC 2.0 protocol.
  contact:
    name: Kovach Enterprises
    email: igor@kovachenterprises.com
  x-logo:
    url: https://genesisconductor.io/logo.png
servers:
  - url: https://gc-16-capsule-bridge.iholt.workers.dev
    description: Production
paths:
  /sync:
    post:
      operationId: syncBatch
      summary: Ingest sync batch from GC-16
      description: Idempotent batch ingestion keyed on (source, cursor)
      security:
        - bearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SyncRequest'
      responses:
        '200':
          description: Sync processed or skipped
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SyncResponse'
  /auth-status:
    post:
      operationId: updateAuthStatus
      summary: Update GC-16 authentication status
      security:
        - bearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                status:
                  type: string
                  enum: [ok, no_auth]
      responses:
        '200':
          description: Status updated
  /health:
    get:
      operationId: healthCheck
      summary: Health check endpoint
      responses:
        '200':
          description: Service healthy
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
  schemas:
    SyncRequest:
      type: object
      required: [source, items, cursor]
      properties:
        source:
          type: string
          description: GC-16 source (keep, tasks, gmail, drive)
        items:
          type: array
          items:
            type: object
        cursor:
          type: string
          description: Pagination cursor for idempotency
    SyncResponse:
      type: object
      properties:
        status:
          type: string
          enum: [ok, skipped, refused]
        processed:
          type: integer
        cursor:
          type: string
        reason:
          type: string
