service

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Overview

@index Graph building service that orchestrates parsing, persistence, and search indexing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckParseFileSize

func CheckParseFileSize(relPath string, size int64, maxFileBytes int64) error

@intent reject individual files that exceed the configured per-file parse budget before loading them into memory.

func CheckTotalParsedBytes

func CheckTotalParsedBytes(relPath string, current int64, next int64, maxTotalBytes int64) error

@intent stop one build or update pass once cumulative parsed bytes would exceed the configured safety limit.

func ExistingGraphFiles

func ExistingGraphFiles(ctx context.Context, db *gorm.DB) ([]string, error)

ExistingGraphFiles returns namespace-scoped graph file paths currently stored. @intent share deletion-scope discovery across CLI and MCP incremental updates

func RefreshSearchDocuments

func RefreshSearchDocuments(ctx context.Context, db *gorm.DB) (int, error)

RefreshSearchDocuments rebuilds namespace-scoped search_documents from current graph nodes. @intent keep derived search documents consistent with graph state before FTS rebuilds

func RefreshSearchDocumentsFor

func RefreshSearchDocumentsFor(ctx context.Context, db *gorm.DB, nodeIDs []uint) (int, error)

RefreshSearchDocumentsFor rebuilds search_documents for the specified node IDs only. @intent incremental update 경로에서 영향받은 문서만 갱신한다.

Types

type BuildOptions

type BuildOptions struct {
	Dir                 string
	NoRecursive         bool
	ExcludePatterns     []string
	IncludePaths        []string
	MaxFileBytes        int64
	MaxTotalParsedBytes int64
	SkipSearchRebuild   bool
	FallbackCalls       bool
}

BuildOptions configures one graph build run. @intent 빌드 대상 경로와 탐색 범위를 호출자에서 제어하게 한다.

type BuildStats

type BuildStats struct {
	TotalFiles int
	TotalNodes int
	TotalEdges int
	Unresolved edgeresolve.FilterResolvedDiagnostics
}

BuildStats reports how much content a build processed. @intent CLI와 호출자가 빌드 결과 규모를 사용자에게 보여줄 수 있게 한다.

type GraphService

type GraphService struct {
	Store         store.GraphStore
	DB            *gorm.DB
	SearchBackend search.Backend
	Walkers       map[string]*treesitter.Walker
	Parsers       map[string]Parser
	Logger        *slog.Logger
}

GraphService orchestrates graph building and search document refresh. @intent 파싱 결과 저장과 검색 인덱스 재구성을 하나의 서비스로 묶는다.

func (*GraphService) Build

func (s *GraphService) Build(ctx context.Context, opts BuildOptions) (BuildStats, error)

Build walks source files, stores parsed graph data, and rebuilds search docs. @intent perform a full graph build from the specified directory. @sideEffect 파일 시스템을 읽고 그래프 저장소·DB·검색 인덱스를 갱신한다.

func (*GraphService) Update

Update incrementally syncs changed files into the graph and optionally rebuilds search. @intent centralize file collection, include path, parse limit, and search policy for update callers

type IncrementalSyncer

type IncrementalSyncer interface {
	SyncWithExisting(ctx context.Context, files map[string]incremental.FileInfo, existingFiles []string) (*incremental.SyncStats, error)
}

IncrementalSyncer defines the sync operation GraphService.Update delegates to. @intent keep filesystem/build policy in service while preserving the existing incremental engine

type NamespacePurger

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

NamespacePurger는 단일 namespace의 모든 영속 상태를 일관되게 제거하는 단일 진입점이다. @intent gormstore.DeleteGraph(노드/엣지/어노테이션/멤버십/검색문서)와 그동안 MCP handler 안에 흩어져 있던 Community/Flow/orphan-membership/검색 백엔드 정리를 한 곳으로 모아 namespace-scoped 테이블 추가 시의 drift 위험을 줄인다. @sideEffect graph store와 service 레벨 테이블, 검색 백엔드를 하나의 DB 트랜잭션으로 정리한다.

func NewNamespacePurger

func NewNamespacePurger(graphStore store.NodeWriter, db *gorm.DB, backend storesearch.Backend) *NamespacePurger

NewNamespacePurger는 NamespacePurger를 생성한다. @param graphStore namespace 단위 graph 정리를 수행할 저장소. @param db Community/Flow 등 service-level 테이블을 정리할 DB. nil이면 해당 단계는 skip 한다. @param backend FTS 등 검색 백엔드. nil이면 해당 단계는 skip 한다. @intent assemble one namespace purge entry point that can remove graph, service, and search state together.

func (*NamespacePurger) Purge

func (p *NamespacePurger) Purge(ctx context.Context) error

Purge는 ctx의 namespace에 속한 모든 그래프/서비스/검색 상태를 제거한다. @intent workspace 삭제와 같은 namespace 단위 purge 경로의 단일 진입점을 제공한다. @requires ctx에 ctxns.WithNamespace로 namespace가 설정되어 있어야 한다. @sideEffect 노드, 엣지, 어노테이션, 멤버십, 검색 문서, 커뮤니티, 플로우, 검색 인덱스를 삭제한다.

type Parser

type Parser interface {
	Parse(filePath string, content []byte) ([]model.Node, []model.Edge, error)
	ParseWithContext(ctx context.Context, filePath string, content []byte) ([]model.Node, []model.Edge, error)
}

Parser defines the minimum parser behavior required by graph builds. @intent let CLI, MCP, and tests share the same build policy with their parser implementations

type UnreadableFilesError

type UnreadableFilesError struct {
	Files []string
}

UnreadableFilesError signals that the update path encountered files it could not stat or read while FailOnUnreadable was enabled. @intent give webhook/server callers a structured failure they can surface instead of silent partial sync

func (*UnreadableFilesError) Error

func (e *UnreadableFilesError) Error() string

Error formats the unreadable file failure with a count and a representative sample path. @intent give operators a stable, single-line summary they can grep instead of dumping every path.

type UpdateOptions

type UpdateOptions struct {
	BuildOptions
	Syncer           IncrementalSyncer
	Replace          bool
	FailOnUnreadable bool
}

UpdateOptions configures one incremental graph sync run. @intent reuse GraphService traversal and parse limit policy for CLI and MCP updates

Jump to

Keyboard shortcuts

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