Interface IMigrationTarget

Adapter for writing data to a migration target backend. Implementations exist for SQLite, Postgres, and Qdrant.

interface IMigrationTarget {
    ensureTable(table, sampleRow): Promise<void>;
    writeBatch(table, rows): Promise<number>;
    scopeIdForms?(brainIds?): Promise<Map<string, BrainScopeIdForm>>;
    clearScopeIdForm?(brainId): Promise<void>;
    close(): Promise<void>;
}

Methods

  • Ensure the target schema/collection exists for a table. Creates it if it doesn't exist, using a sample row to infer column types.

    Parameters

    • table: string

      Table name to create.

    • sampleRow: Record<string, unknown>

      A sample row to derive schema from.

    Returns Promise<void>

  • Write a batch of rows to the target. Uses INSERT OR REPLACE / upsert semantics to handle duplicates.

    Parameters

    • table: string

      Table name to write to.

    • rows: Record<string, unknown>[]

      Array of row objects.

    Returns Promise<number>

    Number of rows successfully written.

  • These brains as the target holds them, with their scope-id forms, for the handshake the engine runs before it copies any table; a brain the target does not hold reads as holding nothing. With no ids, every brain the target holds. A Qdrant target reads its sidecar, and counts a brain the sidecar holds as holding traces whose scope ids the two forms read apart, since its traces are in Qdrant; one with no sidecar leaves it out.

    Parameters

    • Optional brainIds: readonly string[]

    Returns Promise<Map<string, BrainScopeIdForm>>

  • Removes one brain's scope-id form record, when the handshake gives the copy the source's plain form.

    Parameters

    • brainId: string

    Returns Promise<void>