graphgorm

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: 20 Imported by: 0

Documentation

Overview

@index GORM persistence adapter for git-diff change-risk analysis.

@index Namespace-agnostic graph reader that merges cross_refs into traversal edges for cross-repository analysis.

@index GORM adapter for materialized cross-namespace reference rows and ccg ref resolution.

@index GORM read adapter for documentation generation and lint facts.

@index GORM persistence adapter for atomic stored-flow rebuilds.

@index GORM persistence adapter for predefined analysis graph queries.

@index GORM read models for MCP graph, context, namespace, and change surfaces.

@index GORM graph statistics adapter for operator and protocol read surfaces.

@index GORM-based graph repository that manages CRUD operations and transactions for nodes, edges, and annotations.

@index GORM unit-of-work adapter for atomic graph and derived search updates.

@index GORM persistence for unresolved-edge reverse lookup and readiness state.

@index GORM read adapter for eager and lazy built-in Wiki tree construction.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CrossNamespaceReader

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

CrossNamespaceReader reads nodes and edges across every namespace and augments traversal with synthetic cross_ref edges derived from resolved cross-namespace references. @intent let impact and flow analysis walk across repository boundaries declared by annotations. @domainRule node ids are globally unique, so id-based reads are safe without a namespace filter.

func (*CrossNamespaceReader) GetEdgesFrom

func (r *CrossNamespaceReader) GetEdgesFrom(ctx context.Context, nodeID uint) ([]graph.Edge, error)

GetEdgesFrom returns outgoing edges of one node across namespaces, including cross refs. @intent satisfy the impact analyzer contract for cross-namespace traversal.

func (*CrossNamespaceReader) GetEdgesFromNodes

func (r *CrossNamespaceReader) GetEdgesFromNodes(ctx context.Context, nodeIDs []uint) ([]graph.Edge, error)

GetEdgesFromNodes returns outgoing edges of the node set across namespaces, including cross refs. @intent expand traversal frontiers across repository boundaries in one query pair.

func (*CrossNamespaceReader) GetEdgesTo

func (r *CrossNamespaceReader) GetEdgesTo(ctx context.Context, nodeID uint) ([]graph.Edge, error)

GetEdgesTo returns incoming edges of one node across namespaces, including cross refs. @intent satisfy the impact analyzer contract for reverse cross-namespace traversal.

func (*CrossNamespaceReader) GetEdgesToNodes

func (r *CrossNamespaceReader) GetEdgesToNodes(ctx context.Context, nodeIDs []uint) ([]graph.Edge, error)

GetEdgesToNodes returns incoming edges of the node set across namespaces, including cross refs. @intent let impact analysis find foreign namespaces that depend on the target nodes.

func (*CrossNamespaceReader) GetNodeByID

func (r *CrossNamespaceReader) GetNodeByID(ctx context.Context, id uint) (*graph.Node, error)

GetNodeByID retrieves one node by primary key regardless of namespace. @intent resolve traversal frontiers that crossed into another namespace.

func (*CrossNamespaceReader) GetNodesByIDs

func (r *CrossNamespaceReader) GetNodesByIDs(ctx context.Context, ids []uint) ([]graph.Node, error)

GetNodesByIDs retrieves nodes by primary key regardless of namespace. @intent load result nodes for cross-namespace traversals in one query.

type SearchWriterFactory

type SearchWriterFactory func(tx *gorm.DB) ingest.SearchWriter

SearchWriterFactory binds a search writer to the active GORM transaction. @intent construct derived-state persistence with the same transaction handle as graph persistence.

type Store

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

Store is the GORM-backed GraphStore implementation. @intent implement the graph repository contract through a GORM DB handle.

func New

func New(db *gorm.DB) *Store

New creates a repository wrapping a GORM DB. @intent initialize the GraphStore implementation with the injected DB handle.

func (*Store) AffectedFlowsPage

func (s *Store) AffectedFlowsPage(ctx context.Context, changedNodeIDs []uint, limit, offset int) ([]analyze.AffectedFlow, bool, error)

@intent map changed nodes to one deterministic page of namespace-scoped stored flows.

func (*Store) Annotations

func (s *Store) Annotations(ctx context.Context, ids []uint) (map[uint]*graph.Annotation, error)

@intent batch-load Wiki annotations with deterministic tag ordering.

func (*Store) AutoMigrate

func (s *Store) AutoMigrate() error

AutoMigrate creates or updates the graph repository schema. @intent prepare the GORM model tables required for graph persistence. @sideEffect may modify the database schema.

func (*Store) CCGRefExists

func (s *Store) CCGRefExists(ctx context.Context, ref reference.Ref) (bool, error)

@intent validate parsed cross-namespace ccg references against graph path and symbol semantics.

func (*Store) CallEdges

func (s *Store) CallEdges(ctx context.Context, anchorID uint, peerIDs []uint, direction analyze.EdgeDirection) (map[uint]graph.Edge, error)

@intent select the strongest call evidence edge for each requested peer node.

func (*Store) CreateFlow

func (s *Store) CreateFlow(ctx context.Context, flow *graph.Flow) error

CreateFlow persists one flow and its ordered memberships through the active transaction. @intent store traced flow aggregates while keeping generated IDs visible to application results. @sideEffect inserts a flow row and zero or more flow-membership rows. @mutates flow.ID and each flow.Members item FlowID.

func (*Store) CrossNamespaceReader

func (s *Store) CrossNamespaceReader() *CrossNamespaceReader

CrossNamespaceReader returns a namespace-agnostic reader over the same database. @intent derive the cross-repository read surface from an existing store without new wiring inputs.

func (*Store) DeleteEdgesByFile

func (s *Store) DeleteEdgesByFile(ctx context.Context, filePath string) error

DeleteEdgesByFile removes edges generated from a file. @intent selectively clean existing relationships during file-scoped updates. @sideEffect deletes matching file_path records from the edges table.

func (*Store) DeleteFlows

func (s *Store) DeleteFlows(ctx context.Context) error

DeleteFlows removes all stored flows and memberships in the active namespace. @intent clear stale flow state before a transaction-scoped rebuild. @sideEffect deletes namespace-owned flow and flow-membership rows.

func (*Store) DeleteGraph

func (s *Store) DeleteGraph(ctx context.Context) error

DeleteGraph removes the entire graph state for the current namespace. @intent replace namespace-scoped state before a full rebuild or include_paths rebuild. @sideEffect deletes all nodes, edges, annotations, and doc_tags in the namespace. @domainRule namespace-owned search documents are deleted directly before node-scoped dependent cleanup.

func (*Store) DeleteNodesByFile

func (s *Store) DeleteNodesByFile(ctx context.Context, filePath string) error

DeleteNodesByFile removes nodes in a file and their related data. @intent keep the single-file API compatible while delegating cleanup to the bounded batch path. @sideEffect deletes related records from the nodes, edges, annotations, and doc_tags tables. @domainRule connected edges and annotations must also be removed when deleting a file.

func (*Store) DeleteNodesByFiles

func (s *Store) DeleteNodesByFiles(ctx context.Context, filePaths []string) error

DeleteNodesByFiles removes nodes and dependent graph rows for bounded file-path batches. @intent replace per-file deletion round trips with one transaction and a fixed deletion sequence per path chunk. @sideEffect deletes unresolved candidates, edges, annotations/tags, memberships, search documents, and nodes. @domainRule only rows owned by the request namespace and rows connected to its deleted nodes may be removed.

func (*Store) DeletePackageSemanticEdges

func (s *Store) DeletePackageSemanticEdges(ctx context.Context, anchors []string) error

DeletePackageSemanticEdges removes synthesized package-level implementation edges for anchor files. @intent replace stale package semantic relationships without exposing persistence queries to the application layer. @sideEffect deletes namespace-scoped edge rows matching the supplied anchors. @domainRule only synthesized implements edges, identified by line zero, are eligible for deletion.

func (*Store) DeleteUnresolvedEdgesByFingerprints

func (s *Store) DeleteUnresolvedEdgesByFingerprints(ctx context.Context, fingerprints []string) error

DeleteUnresolvedEdgesByFingerprints removes every lookup-key row for resolved syntax edges. @intent keep the reverse index limited to relationships that still lack endpoints.

func (*Store) FileSymbols

func (s *Store) FileSymbols(ctx context.Context, filePath string, kinds []graph.NodeKind) ([]graph.Node, error)

@intent load stable symbol children for one lazy Wiki file node.

func (*Store) FindFlowEntrypoints

func (s *Store) FindFlowEntrypoints(ctx context.Context) ([]graph.Node, error)

FindFlowEntrypoints returns function/test nodes with no inbound call-kind edge. @intent provide deterministic namespace-scoped entrypoints for stored-flow rebuild policy. @domainRule inbound detection includes every kind returned by graph.CallEdgeKinds.

func (*Store) FindUnresolvedEdgesByFiles

func (s *Store) FindUnresolvedEdgesByFiles(ctx context.Context, filePaths []string) ([]graph.Edge, error)

FindUnresolvedEdgesByFiles loads every candidate edge owned by the selected affected files. @intent replay import warmup and related edges together after reverse-index selection narrows source files.

func (*Store) FindUnresolvedEdgesByLookupKeys

func (s *Store) FindUnresolvedEdgesByLookupKeys(ctx context.Context, keys []string) ([]graph.Edge, error)

FindUnresolvedEdgesByLookupKeys finds deduplicated syntax edges matching newly added symbol keys. @intent use the reverse index to identify affected unchanged source files.

func (*Store) FlowsPage

func (s *Store) FlowsPage(ctx context.Context, sortBy string, limit, offset int) ([]analyze.FlowSummary, bool, error)

@intent load one stable namespace-scoped stored-flow page with member counts.

func (*Store) GetAnnotation

func (s *Store) GetAnnotation(ctx context.Context, nodeID uint) (*graph.Annotation, error)

GetAnnotation retrieves the annotation attached to a node ID. @intent load a node's structured comment and tags together for search and display. @return returns nil when no annotation exists.

func (*Store) GetEdgesFrom

func (s *Store) GetEdgesFrom(ctx context.Context, nodeID uint) ([]graph.Edge, error)

GetEdgesFrom retrieves outgoing edges from a node. @intent load outbound relationships for a specific declaration.

func (*Store) GetEdgesFromNodes

func (s *Store) GetEdgesFromNodes(ctx context.Context, nodeIDs []uint) ([]graph.Edge, error)

GetEdgesFromNodes retrieves outgoing edges from multiple nodes. @intent load outbound relationships for multiple declarations in one call. @return returns a nil slice when nodeIDs is empty.

func (*Store) GetEdgesTo

func (s *Store) GetEdgesTo(ctx context.Context, nodeID uint) ([]graph.Edge, error)

GetEdgesTo retrieves incoming edges to a node. @intent load inbound relationships for a specific declaration.

func (*Store) GetEdgesToNodes

func (s *Store) GetEdgesToNodes(ctx context.Context, nodeIDs []uint) ([]graph.Edge, error)

GetEdgesToNodes retrieves incoming edges to multiple nodes. @intent load inbound relationships for multiple declarations in one call. @return returns a nil slice when nodeIDs is empty.

func (*Store) GetFileNodesByPathSuffix

func (s *Store) GetFileNodesByPathSuffix(ctx context.Context, suffix string) ([]graph.Node, error)

GetFileNodesByPathSuffix finds file nodes whose directory matches an import-path suffix. @intent let import edge resolution bind repo-local import paths back to stored file nodes.

func (*Store) GetNode

func (s *Store) GetNode(ctx context.Context, qualifiedName string) (*graph.Node, error)

GetNode retrieves a single node by qualified name. @intent find one node by the declaration's qualified name. @return returns nil when no node exists.

func (*Store) GetNodeByID

func (s *Store) GetNodeByID(ctx context.Context, id uint) (*graph.Node, error)

GetNodeByID retrieves a single node by primary key. @intent find one node by its internal identifier. @return returns nil when no node exists.

func (*Store) GetNodesByFile

func (s *Store) GetNodesByFile(ctx context.Context, filePath string) ([]graph.Node, error)

GetNodesByFile retrieves nodes belonging to a file path. @intent load declarations parsed from a specific source file.

func (*Store) GetNodesByFiles

func (s *Store) GetNodesByFiles(ctx context.Context, filePaths []string) (map[string][]graph.Node, error)

GetNodesByFiles retrieves nodes from multiple files grouped by file path. @intent return declarations for a file set grouped by path. @return returns a map whose keys are file paths and values are the nodes in each file.

func (*Store) GetNodesByIDs

func (s *Store) GetNodesByIDs(ctx context.Context, ids []uint) ([]graph.Node, error)

GetNodesByIDs retrieves nodes matching the provided ID list. @intent load multiple nodes at once by internal identifier. @return returns a nil slice when ids is empty.

func (*Store) GetNodesByQualifiedNames

func (s *Store) GetNodesByQualifiedNames(ctx context.Context, names []string) (map[string][]graph.Node, error)

GetNodesByQualifiedNames loads a set of names into a node map. @intent build a fast lookup map for qualified-name-based reference resolution. @return returns a map keyed by QualifiedName, with slices containing all nodes for each name.

func (*Store) GraphStatistics

func (s *Store) GraphStatistics(ctx context.Context) (analyze.GraphStatistics, error)

GraphStatistics loads totals and grouped distributions for the active namespace. @intent implement the application statistics port while preserving namespace filtering and aggregate semantics.

func (*Store) GraphView

func (s *Store) GraphView(ctx context.Context, limit int, edgeKinds []graph.EdgeKind) (wiki.GraphView, error)

GraphView loads a bounded stable node set and only edges contained within it. @intent implement the Wiki force-graph read port with deterministic ordering and limits.

func (*Store) HasSymbol

func (s *Store) HasSymbol(ctx context.Context, filePath string, kinds []graph.NodeKind) (bool, error)

@intent answer whether a lazy file node has expandable symbol children.

func (*Store) ListAnnotationCCGRefs

func (s *Store) ListAnnotationCCGRefs(ctx context.Context, namespace string) ([]crossrefapp.AnnotationRef, error)

ListAnnotationCCGRefs returns every @see ccg:// tag value declared by nodes of one namespace. @intent collect the source facts for rebuilding a namespace's outbound cross refs.

func (*Store) ListFileNodes

func (s *Store) ListFileNodes(ctx context.Context) ([]graph.Node, error)

ListFileNodes returns the minimal persisted state used to compare source files during an update. @intent expose namespace-scoped file identity and hash state without leaking the database handle.

func (*Store) ListImportFileNodes

func (s *Store) ListImportFileNodes(ctx context.Context) ([]graph.Node, error)

ListImportFileNodes returns actual file nodes for build-scoped import-path resolution. @intent let full builds create an in-memory import suffix index without reloading all file nodes per import.

func (*Store) ListInboundCrossRefs

func (s *Store) ListInboundCrossRefs(ctx context.Context, toNamespace string) ([]graph.CrossRef, error)

ListInboundCrossRefs returns refs from other namespaces that target the given namespace. @intent select the rows whose resolution may change after this namespace rebuilds. @domainRule self-namespace refs are excluded because the outbound rebuild already re-resolved them.

func (*Store) ListOutboundCrossRefs

func (s *Store) ListOutboundCrossRefs(ctx context.Context, fromNamespace string) ([]graph.CrossRef, error)

ListOutboundCrossRefs returns every cross ref originating from one namespace. @intent expose a namespace's declared external dependencies for listing and analysis.

func (*Store) LoadParseResult

func (s *Store) LoadParseResult(ctx context.Context, key ingest.ParseCacheKey) ([]byte, bool, error)

LoadParseResult returns a cached parser payload only when every identity field matches. @intent prevent stale parser output from being reused across content, path, parser, context, or namespace changes.

func (*Store) MarkUnresolvedIndexReady

func (s *Store) MarkUnresolvedIndexReady(ctx context.Context, version string) error

MarkUnresolvedIndexReady marks the current namespace and producer version after a successful full candidate pass. @intent distinguish a compatible legitimately empty reverse index from stale or uninitialized state. @sideEffect inserts or updates unresolved_index_states.

func (*Store) Namespaces

func (s *Store) Namespaces(ctx context.Context) ([]string, error)

Namespaces returns distinct stored namespaces in stable order. @intent implement Wiki namespace discovery without exposing persistence to HTTP.

func (*Store) NamespacesPage

func (s *Store) NamespacesPage(ctx context.Context, limit, offset int) ([]analyze.NamespaceSummary, bool, error)

@intent load one stable global namespace page with node counts.

func (*Store) NavigationNodes

func (s *Store) NavigationNodes(ctx context.Context, kinds []graph.NodeKind) ([]graph.Node, error)

@intent load the stable graph snapshot from which the eager Wiki hierarchy is derived.

func (*Store) NodesByExactName

func (s *Store) NodesByExactName(ctx context.Context, name string, limit int) ([]graph.Node, error)

NodesByExactName loads deterministic namespace-scoped short-name matches. @intent support exact-name fallback suggestions through the analysis repository.

func (*Store) NodesByFile

func (s *Store) NodesByFile(ctx context.Context, filePath string) ([]graph.Node, error)

NodesByFile loads all namespace-scoped nodes belonging to one file. @intent supply file-summary inputs without exposing database filtering to app policy.

func (*Store) NodesByFiles

func (s *Store) NodesByFiles(ctx context.Context, filePaths []string) ([]graph.Node, error)

NodesByFiles loads deterministic namespace-scoped graph nodes for changed files. @intent supply diff-overlap inputs without exposing database filters to change policy.

func (*Store) OutgoingDocEdges

func (s *Store) OutgoingDocEdges(ctx context.Context, namespace string, ids []uint) (map[uint][]graph.Edge, error)

@intent load call/import relationships rendered beneath symbol documentation.

func (*Store) OutgoingEdgeCounts

func (s *Store) OutgoingEdgeCounts(ctx context.Context, nodeIDs []uint) (map[uint]int64, error)

OutgoingEdgeCounts returns namespace-scoped outgoing edge counts keyed by source node ID. @intent provide risk-weight inputs through one grouped persistence query.

func (*Store) PathNodes

func (s *Store) PathNodes(ctx context.Context, folderPath string, kinds []graph.NodeKind) ([]graph.Node, error)

@intent load stable path-bearing candidates below one lazy Wiki folder or package.

func (*Store) QualifiedNameExists

func (s *Store) QualifiedNameExists(ctx context.Context, namespace, name string) (bool, error)

@intent validate local @see targets within the active docs namespace.

func (*Store) RelatedNodes

RelatedNodes loads one deterministic distinct relationship page and its total count. @intent implement namespace-scoped relationship joins behind the analysis query repository.

func (*Store) ReplaceCrossRefsFrom

func (s *Store) ReplaceCrossRefsFrom(ctx context.Context, fromNamespace string, refs []graph.CrossRef) error

ReplaceCrossRefsFrom atomically replaces every cross ref originating from one namespace. @intent make outbound cross-ref state a pure function of the namespace's current annotations. @sideEffect deletes and inserts cross_refs rows in one transaction.

func (*Store) ResolveCCGRef

func (s *Store) ResolveCCGRef(ctx context.Context, ref reference.Ref) (uint, bool, error)

ResolveCCGRef resolves a parsed ccg:// reference to a target node id. @intent give cross-ref materialization the concrete node identity behind a symbolic reference. @domainRule namespace-scope refs resolve with a zero node id when the namespace has any nodes. @domainRule path-scope refs prefer the file node of the path; remaining ties resolve to the lowest node id.

func (*Store) ResolveReference

func (s *Store) ResolveReference(ctx context.Context, ref *reference.Ref) (*graph.Node, error)

ResolveReference finds the first deterministic graph node matching a parsed CCG reference. @intent resolve Wiki reference navigation while keeping GORM filtering and preload behavior in the outbound adapter.

func (*Store) Snapshot

func (s *Store) Snapshot(ctx context.Context, namespace string, kinds []graph.NodeKind) (docsapp.Snapshot, error)

@intent load documentable nodes and their annotations from one namespace.

func (*Store) StoreParseResult

func (s *Store) StoreParseResult(ctx context.Context, key ingest.ParseCacheKey, payload []byte) error

StoreParseResult replaces the latest cached parser payload for one namespace/file path. @intent retain one bounded current cache entry per source path instead of accumulating every historical hash. @sideEffect inserts or updates a parse_cache_entries row.

func (*Store) StoredNode

func (s *Store) StoredNode(ctx context.Context, kind graph.NodeKind, filePath string) (*graph.Node, error)

@intent resolve one stored package or file used as a lazy Wiki root.

func (*Store) SymbolNode

func (s *Store) SymbolNode(ctx context.Context, qualifiedName string, kinds []graph.NodeKind) (*graph.Node, error)

@intent resolve the first deterministic symbol match used by direct lazy navigation.

func (*Store) TopCommunities

func (s *Store) TopCommunities(ctx context.Context, limit int) ([]analyze.NamedCount, error)

@intent rank namespace communities by stored membership count.

func (*Store) TopFlows

func (s *Store) TopFlows(ctx context.Context, limit int) ([]analyze.NamedCount, error)

@intent rank namespace flows by stored membership count.

func (*Store) UnresolvedIndexReady

func (s *Store) UnresolvedIndexReady(ctx context.Context, version string) (bool, error)

UnresolvedIndexReady reports whether a compatible full build populated the namespace's reverse index. @intent gate semi-naive update on complete historical unresolved-edge coverage produced by the expected algorithm and parsers.

func (*Store) UntestedCount

func (s *Store) UntestedCount(ctx context.Context, nodeIDs []uint) (int, error)

@intent count requested nodes without a namespace-scoped tested_by edge.

func (*Store) UpdateCrossRefResolution

func (s *Store) UpdateCrossRefResolution(ctx context.Context, id uint, resolvedNodeID *uint, status graph.CrossRefStatus) error

UpdateCrossRefResolution updates one row's derived resolution state. @intent remap or invalidate a reference after its target namespace rebuilt. @sideEffect updates resolved_node_id and status of one cross_refs row.

func (*Store) UpsertAnnotation

func (s *Store) UpsertAnnotation(ctx context.Context, ann *graph.Annotation) error

UpsertAnnotation stores a node's annotation and tags. @intent keep the single-annotation API compatible while delegating persistence to the batch path. @sideEffect performs inserts, updates, and deletes on the annotations and doc_tags tables. @mutates may overwrite ann.ID with the existing record ID. @domainRule only one annotation must be kept per node_id.

func (*Store) UpsertAnnotations

func (s *Store) UpsertAnnotations(ctx context.Context, annotations []*graph.Annotation) error

UpsertAnnotations replaces annotations and tags for a batch of namespace-owned nodes. @intent collapse per-annotation lookup and write round trips into bounded batch operations. @sideEffect inserts or updates annotations, deletes prior tags, and inserts replacement tags in one transaction. @mutates assigns persisted annotation and annotation-tag foreign IDs to input values. @domainRule every node must belong to the request namespace before any annotation in the batch is mutated.

func (*Store) UpsertEdges

func (s *Store) UpsertEdges(ctx context.Context, edges []graph.Edge) error

UpsertEdges stores a batch of edges keyed by fingerprint. @intent apply graph relationships in bulk without duplicates. @sideEffect performs batch inserts on the edges table. @domainRule edges with the same fingerprint must be stored only once.

func (*Store) UpsertNodes

func (s *Store) UpsertNodes(ctx context.Context, nodes []graph.Node) error

UpsertNodes stores a batch of nodes keyed by qualified_name. @intent apply parsed result nodes in bulk without creating duplicates. @sideEffect performs batch inserts and updates on the nodes table. @requires nodes must have a non-empty QualifiedName. @ensures existing nodes with the same qualified_name are updated with the latest metadata.

func (*Store) UpsertUnresolvedEdges

func (s *Store) UpsertUnresolvedEdges(ctx context.Context, candidates []graph.UnresolvedEdgeCandidate) error

UpsertUnresolvedEdges stores reverse-index rows without exposing them as traversable graph edges. @intent retain unresolved syntax candidates until a future symbol addition can resolve them. @sideEffect inserts unresolved_edge_candidates rows.

func (*Store) WithTx

func (s *Store) WithTx(ctx context.Context, fn func(store ingest.GraphStore) error) error

WithTx executes the given function inside the same transaction. @intent allow multiple repository operations to run atomically as one unit. @sideEffect starts a database transaction and commits or rolls it back. @ensures commits the transaction when fn returns a nil error.

func (*Store) WithTxDB

func (s *Store) WithTxDB(ctx context.Context, fn func(ingest.GraphStore, *gorm.DB) error) error

WithTxDB passes the transaction DB handle together with the repository. @intent let graph persistence and DB-backed derived-state updates share a single transaction. @sideEffect starts a database transaction and commits or rolls it back.

func (*Store) WithinFlowRebuild

func (s *Store) WithinFlowRebuild(ctx context.Context, fn func(analyzeapp.FlowRebuildStore) error) error

WithinFlowRebuild executes stored-flow replacement against one transaction-scoped store. @intent implement the analysis flow unit of work without exposing GORM to application policy. @sideEffect starts a transaction and commits or rolls back namespace-scoped flow changes.

type UnitOfWork

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

UnitOfWork implements the ingest atomicity boundary with GORM transactions. @intent coordinate graph and search writes without exposing GORM to application policy.

func NewUnitOfWork

func NewUnitOfWork(db *gorm.DB, newSearchWriter SearchWriterFactory) *UnitOfWork

NewUnitOfWork constructs a GORM-backed ingest unit of work. @intent inject the database transaction owner and transaction-scoped search writer factory.

func (*UnitOfWork) WithinTransaction

func (u *UnitOfWork) WithinTransaction(ctx context.Context, fn func(ingest.Transaction) error) error

WithinTransaction executes graph and search work against one GORM transaction. @intent commit graph and derived search state together or roll both back on any callback error. @sideEffect starts a database transaction and commits or rolls it back. @ensures the callback is not invoked unless both transaction capabilities are available.

Jump to

Keyboard shortcuts

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