incremental

package
v0.12.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 19, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

@index Session-local parsed-edge spool for staged incremental reconciliation.

@index Transaction-local import lookup decorator for staged incremental edge replay.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnnotatingParser

type AnnotatingParser interface {
	Parser
	ParseWithComments(ctx context.Context, filePath string, content []byte) ([]graph.Node, []graph.Edge, []ingest.CommentBlock, error)
	Language() string
}

AnnotatingParser exposes richer parse output needed to restore annotations. @intent allow incremental sync to reuse comment-aware parsing when available

type FileInfo

type FileInfo = ingest.FileInfo

FileInfo holds change-tracking data for one file. @intent carry file content and hash so sync can detect modifications cheaply

type Parser

type Parser interface {
	Parse(filePath string, content []byte) ([]graph.Node, []graph.Edge, error)
}

Parser parses one file into graph nodes and edges. @intent decouple incremental sync from language-specific parsing logic

type Store

type Store interface {
	GetNodesByIDs(ctx context.Context, ids []uint) ([]graph.Node, error)
	GetNodesByFiles(ctx context.Context, filePaths []string) (map[string][]graph.Node, error)
	GetNodesByQualifiedNames(ctx context.Context, names []string) (map[string][]graph.Node, error)
	UpsertNodes(ctx context.Context, nodes []graph.Node) error
	UpsertEdges(ctx context.Context, edges []graph.Edge) error
	UpsertAnnotations(ctx context.Context, annotations []*graph.Annotation) error
	DeleteNodesByFiles(ctx context.Context, filePaths []string) error
}

Store defines persistence operations needed for incremental sync. @intent abstract graph storage so changed files can be reparsed and upserted

type SyncStats

type SyncStats = ingest.SyncStats

SyncStats summarizes one incremental sync run. @intent report how many files were added, modified, skipped, or deleted

type Syncer

type Syncer struct {
	// contains filtered or unexported fields
}

Syncer incrementally updates graph data for changed files. @intent avoid full rebuilds by reparsing only files whose content hash changed

func New

func New(store Store, parser Parser, opts ...SyncerOption) *Syncer

New creates an incremental syncer. @intent wire storage, parser, and optional configuration into a sync coordinator @ensures returned syncer always has a non-nil logger

func NewWithRegistry

func NewWithRegistry(store Store, parsers map[string]Parser, opts ...SyncerOption) *Syncer

NewWithRegistry creates an incremental syncer with extension-based parser dispatch. @intent support multi-language incremental parsing without breaking the legacy single-parser constructor

func (*Syncer) SetResolveOptions

func (s *Syncer) SetResolveOptions(opts resolve.ResolveOptions)

SetResolveOptions updates edge resolution policy for an existing syncer instance. @intent avoid rebuilding the syncer for every Build/Update invocation.

func (*Syncer) Sync

func (s *Syncer) Sync(ctx context.Context, files map[string]FileInfo) (*SyncStats, error)

Sync updates graph data using only the provided file snapshot. @intent run incremental parsing when only current files are known @param files current file snapshot keyed by repository-relative path @see incremental.Syncer.SyncWithExisting

func (*Syncer) SyncBatchesWithExisting

func (s *Syncer) SyncBatchesWithExisting(ctx context.Context, source ingest.FileBatchSource, deletedFiles []string) (*SyncStats, error)

SyncBatchesWithExisting stages every source batch before resolving any parsed edges. @intent prevent spool-record ordering from removing edges whose endpoints are both replaced in one bulk update. @param source bounded current-source batch replay owned by the workflow layer @param deletedFiles persisted paths absent from source that must be removed before edge replay @ensures edge resolution observes all current nodes after source staging completes

func (*Syncer) SyncBatchesWithExistingStore

func (s *Syncer) SyncBatchesWithExistingStore(ctx context.Context, syncStore ingest.GraphStore, source ingest.FileBatchSource, deletedFiles []string) (*SyncStats, error)

SyncBatchesWithExistingStore stages reconciliation using the active transaction-scoped graph store. @intent keep bulk update node, edge, package, and search writes within one transaction.

func (*Syncer) SyncWithExisting

func (s *Syncer) SyncWithExisting(ctx context.Context, files map[string]FileInfo, existingFiles []string) (*SyncStats, error)

SyncWithExisting updates graph data and removes files no longer present. @intent reconcile parsed graph state with the latest changed-file snapshot @param files current file snapshot keyed by repository-relative path @param existingFiles previously known file paths used to detect deletions @return counts of added, modified, skipped, and deleted files @sideEffect writes structured logs during sync execution @domainRule unchanged files are skipped when the stored hash matches the incoming hash @mutates graph storage by deleting stale nodes and upserting parsed nodes and edges @ensures deleted files are removed from storage when absent from files

func (*Syncer) SyncWithExistingStore

func (s *Syncer) SyncWithExistingStore(ctx context.Context, syncStore ingest.GraphStore, files map[string]FileInfo, existingFiles []string) (*SyncStats, error)

SyncWithExistingStore runs sync with the provided store without mutating the receiver. @intent let callers bind incremental sync to an existing transaction-scoped store

type SyncerOption

type SyncerOption func(*Syncer)

SyncerOption configures a Syncer instance. @intent customize incremental sync behavior without expanding the constructor signature

func WithLogger

func WithLogger(l *slog.Logger) SyncerOption

WithLogger sets the logger used during sync. @intent allow callers to observe incremental sync progress through structured logs @mutates Syncer.logger

func WithParsers

func WithParsers(parsers map[string]Parser) SyncerOption

WithParsers sets extension-based parsers used during sync. @intent let incremental sync dispatch parsing per file extension for multi-language projects

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL