Documentation
¶
Overview ¶
Package sync provides git-friendly memory synchronization via compressed chunks.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetUsername ¶
func GetUsername() string
GetUsername returns the current username for chunk metadata.
Types ¶
type ChunkData ¶
type ChunkData struct {
Sessions []*domain.Session `json:"sessions"`
Observations []*domain.Observation `json:"observations"`
Prompts []*domain.Prompt `json:"prompts"`
}
ChunkData is the content of a single sync chunk.
type ChunkEntry ¶
type ChunkEntry struct {
ID string `json:"id"`
CreatedBy string `json:"created_by,omitempty"`
CreatedAt string `json:"created_at,omitempty"`
Sessions int `json:"sessions,omitempty"`
Memories int `json:"memories,omitempty"`
Prompts int `json:"prompts,omitempty"`
}
ChunkEntry describes a single sync chunk in the manifest.
type FileTransport ¶
type FileTransport struct {
// contains filtered or unexported fields
}
FileTransport implements Transport using the local filesystem. Chunks are stored as gzipped JSONL files in a chunks/ subdirectory.
func NewFileTransport ¶
func NewFileTransport(syncDir string) *FileTransport
NewFileTransport creates a FileTransport rooted at the given sync directory.
func (*FileTransport) ReadChunk ¶
func (ft *FileTransport) ReadChunk(chunkID string) ([]byte, error)
ReadChunk reads and decompresses a gzipped chunk file.
func (*FileTransport) ReadManifest ¶
func (ft *FileTransport) ReadManifest() (*Manifest, error)
ReadManifest reads manifest.json from the sync directory. Returns an empty manifest (Version=1) if the file doesn't exist.
func (*FileTransport) WriteChunk ¶
func (ft *FileTransport) WriteChunk(chunkID string, data []byte, _ ChunkEntry) error
WriteChunk gzips data and writes to chunks/{chunkID}.jsonl.gz.
func (*FileTransport) WriteManifest ¶
func (ft *FileTransport) WriteManifest(m *Manifest) error
WriteManifest writes the manifest to manifest.json with pretty-printing.
type ImportResult ¶
type ImportResult struct {
ChunksImported int `json:"chunks_imported"`
ChunksSkipped int `json:"chunks_skipped"`
SessionsImported int `json:"sessions_imported"`
ObservationsImported int `json:"observations_imported"`
PromptsImported int `json:"prompts_imported"`
}
ImportResult is returned after an import operation.
type Manifest ¶
type Manifest struct {
Version int `json:"version"`
Chunks []ChunkEntry `json:"chunks,omitempty"`
}
Manifest tracks all sync chunks and their metadata.
type SyncResult ¶
type SyncResult struct {
ChunkID string `json:"chunk_id,omitempty"`
SessionsExported int `json:"sessions_exported"`
ObservationsExported int `json:"observations_exported"`
PromptsExported int `json:"prompts_exported"`
IsEmpty bool `json:"is_empty"`
}
SyncResult is returned after an export operation.
type SyncStore ¶
type SyncStore interface {
ExportAll(ctx context.Context) (*sqlitestore.ExportData, error)
ImportData(ctx context.Context, data *sqlitestore.ExportData) (*sqlitestore.SyncImportResult, error)
GetSyncedChunks(ctx context.Context) (map[string]bool, error)
RecordSyncedChunk(ctx context.Context, chunkID string) error
}
SyncStore defines the store methods needed by the Syncer.
type Syncer ¶
type Syncer struct {
// contains filtered or unexported fields
}
Syncer handles chunk-based memory synchronization.