Documentation
¶
Overview ¶
Package knowledge provides a knowledge capture toolkit for the MCP data platform.
Index ¶
- Constants
- Variables
- func NormalizeConfidence(c string) string
- func NormalizeSource(s string) string
- func ValidateAction(action string) error
- func ValidateApplyChanges(changes []ApplyChange) error
- func ValidateCategory(c string) error
- func ValidateConfidence(c string) error
- func ValidateEntityURNs(urns []string) error
- func ValidateInsightText(text string) error
- func ValidateRelatedColumns(cols []RelatedColumn) error
- func ValidateSource(s string) error
- func ValidateStatusTransition(from, to string) error
- func ValidateSuggestedActions(actions []SuggestedAction) error
- type ApplyChange
- type ApplyConfig
- type Changeset
- type ChangesetFilter
- type ChangesetStore
- type DataHubClientWriter
- func (w *DataHubClientWriter) AddDocumentationLink(ctx context.Context, urn, linkURL, description string) error
- func (w *DataHubClientWriter) AddGlossaryTerm(ctx context.Context, urn, termURN string) error
- func (w *DataHubClientWriter) AddTag(ctx context.Context, urn, tag string) error
- func (w *DataHubClientWriter) CreateCuratedQuery(ctx context.Context, entityURN, name, sqlText, description string) (string, error)
- func (w *DataHubClientWriter) DeleteContextDocument(ctx context.Context, documentID string) error
- func (w *DataHubClientWriter) GetCurrentMetadata(ctx context.Context, urn string) (*EntityMetadata, error)
- func (w *DataHubClientWriter) RaiseIncident(ctx context.Context, entityURN, title, description string) (string, error)
- func (w *DataHubClientWriter) RemoveDocumentationLink(ctx context.Context, urn, linkURL string) error
- func (w *DataHubClientWriter) RemoveGlossaryTerm(ctx context.Context, urn, termURN string) error
- func (w *DataHubClientWriter) RemoveStructuredProperty(ctx context.Context, urn, propertyURN string) error
- func (w *DataHubClientWriter) RemoveTag(ctx context.Context, urn, tag string) error
- func (w *DataHubClientWriter) ResolveIncident(ctx context.Context, incidentURN, message string) error
- func (w *DataHubClientWriter) UpdateColumnDescription(ctx context.Context, urn, fieldPath, description string) error
- func (w *DataHubClientWriter) UpdateColumnDescriptionBatch(ctx context.Context, urn string, columns map[string]string) error
- func (w *DataHubClientWriter) UpdateDescription(ctx context.Context, urn, description string) error
- func (w *DataHubClientWriter) UpsertContextDocument(ctx context.Context, entityURN string, doc types.ContextDocumentInput) (*types.ContextDocument, error)
- func (w *DataHubClientWriter) UpsertStructuredProperties(ctx context.Context, urn, propertyURN string, values []any) error
- type DataHubWriter
- type EntityInsightSummary
- type EntityMetadata
- type Insight
- type InsightFilter
- type InsightStats
- type InsightStore
- type InsightUpdate
- type NoopDataHubWriter
- func (*NoopDataHubWriter) AddDocumentationLink(_ context.Context, _, _, _ string) error
- func (*NoopDataHubWriter) AddGlossaryTerm(_ context.Context, _, _ string) error
- func (*NoopDataHubWriter) AddTag(_ context.Context, _, _ string) error
- func (*NoopDataHubWriter) CreateCuratedQuery(_ context.Context, _, _, _, _ string) (string, error)
- func (*NoopDataHubWriter) DeleteContextDocument(_ context.Context, _ string) error
- func (*NoopDataHubWriter) GetCurrentMetadata(_ context.Context, _ string) (*EntityMetadata, error)
- func (*NoopDataHubWriter) RaiseIncident(_ context.Context, _, _, _ string) (string, error)
- func (*NoopDataHubWriter) RemoveDocumentationLink(_ context.Context, _, _ string) error
- func (*NoopDataHubWriter) RemoveGlossaryTerm(_ context.Context, _, _ string) error
- func (*NoopDataHubWriter) RemoveStructuredProperty(_ context.Context, _, _ string) error
- func (*NoopDataHubWriter) RemoveTag(_ context.Context, _, _ string) error
- func (*NoopDataHubWriter) ResolveIncident(_ context.Context, _, _ string) error
- func (*NoopDataHubWriter) UpdateColumnDescription(_ context.Context, _, _, _ string) error
- func (*NoopDataHubWriter) UpdateColumnDescriptionBatch(_ context.Context, _ string, _ map[string]string) error
- func (*NoopDataHubWriter) UpdateDescription(_ context.Context, _, _ string) error
- func (*NoopDataHubWriter) UpsertContextDocument(_ context.Context, _ string, _ types.ContextDocumentInput) (*types.ContextDocument, error)
- func (*NoopDataHubWriter) UpsertStructuredProperties(_ context.Context, _, _ string, _ []any) error
- type PromptCreator
- type ProposedChange
- type RelatedColumn
- type RequiredFieldError
- type RollbackConflictError
- type RollbackDeps
- type RollbackResult
- type SuggestedAction
- type Toolkit
- func (*Toolkit) Close() error
- func (*Toolkit) Connection() string
- func (*Toolkit) Kind() string
- func (t *Toolkit) Name() string
- func (*Toolkit) PromptInfos() []registry.PromptInfo
- func (t *Toolkit) RegisterTools(s *mcp.Server)
- func (t *Toolkit) SetApplyConfig(cfg ApplyConfig, csStore ChangesetStore, writer DataHubWriter)
- func (t *Toolkit) SetMemoryStore(ms memory.Store, emb embedding.Provider)
- func (t *Toolkit) SetPromptCreator(pc PromptCreator)
- func (t *Toolkit) SetQueryProvider(provider query.Provider)
- func (t *Toolkit) SetSemanticProvider(provider semantic.Provider)
- func (t *Toolkit) Tools() []string
- type UnrevertibleError
Constants ¶
const ( MinInsightTextLen = 10 MaxInsightTextLen = 4000 MaxEntityURNs = 10 MaxRelatedColumns = 20 MaxSuggestedActions = 5 MaxApplyChanges = 20 MaxInsightIDs = 50 )
Insight validation constraints.
const ( StatusPending = "pending" StatusApproved = "approved" StatusRejected = "rejected" StatusApplied = "applied" StatusSuperseded = "superseded" StatusRolledBack = "rolled_back" )
Insight status constants.
const DefaultLimit = 20
DefaultLimit is the default page size for list queries.
const MaxLimit = 100
MaxLimit is the maximum page size for list queries.
Variables ¶
var ErrChangesetAlreadyRolledBack = errors.New("changeset already rolled back")
ErrChangesetAlreadyRolledBack is returned when a rollback targets a changeset that has already been rolled back.
Functions ¶
func NormalizeConfidence ¶
NormalizeConfidence returns the confidence value, defaulting to "medium" if empty.
func NormalizeSource ¶ added in v0.21.1
NormalizeSource returns the source value, defaulting to "user" if empty.
func ValidateAction ¶
ValidateAction checks whether an action value is valid.
func ValidateApplyChanges ¶
func ValidateApplyChanges(changes []ApplyChange) error
ValidateApplyChanges validates the changes slice for the apply action.
func ValidateCategory ¶
ValidateCategory checks whether a category value is valid.
func ValidateConfidence ¶
ValidateConfidence checks whether a confidence value is valid. An empty string is valid and defaults to "medium".
func ValidateEntityURNs ¶
ValidateEntityURNs validates the entity URN slice.
func ValidateInsightText ¶
ValidateInsightText checks whether the insight text meets length requirements.
func ValidateRelatedColumns ¶
func ValidateRelatedColumns(cols []RelatedColumn) error
ValidateRelatedColumns validates the related columns slice.
func ValidateSource ¶ added in v0.21.1
ValidateSource checks whether a source value is valid. An empty string is valid and defaults to "user".
func ValidateStatusTransition ¶
ValidateStatusTransition checks whether a status transition is allowed.
func ValidateSuggestedActions ¶
func ValidateSuggestedActions(actions []SuggestedAction) error
ValidateSuggestedActions validates a slice of suggested actions.
Types ¶
type ApplyChange ¶
type ApplyChange struct {
ChangeType string `json:"change_type"`
Target string `json:"target"`
Detail string `json:"detail"`
QuerySQL string `json:"query_sql,omitempty"`
QueryDescription string `json:"query_description,omitempty"`
}
ApplyChange represents a single change to apply to DataHub.
type ApplyConfig ¶
type ApplyConfig struct {
Enabled bool `yaml:"enabled"`
DataHubConnection string `yaml:"datahub_connection"`
RequireConfirmation bool `yaml:"require_confirmation"`
}
ApplyConfig configures the apply_knowledge tool.
type Changeset ¶
type Changeset struct {
ID string `json:"id" example:"cs_x1y2z3a4b5c6d7e8"`
CreatedAt time.Time `json:"created_at" example:"2026-01-15T16:00:00Z"`
TargetURN string `json:"target_urn" example:"urn:li:dataset:(urn:li:dataPlatform:trino,hive.sales.orders,PROD)"`
ChangeType string `json:"change_type" example:"update_description"`
PreviousValue map[string]any `json:"previous_value"`
NewValue map[string]any `json:"new_value"`
SourceInsightIDs []string `json:"source_insight_ids"`
ApprovedBy string `json:"approved_by" example:"admin@example.com"`
AppliedBy string `json:"applied_by" example:"admin@example.com"`
RolledBack bool `json:"rolled_back" example:"false"`
RolledBackBy string `json:"rolled_back_by,omitempty"`
RolledBackAt *time.Time `json:"rolled_back_at,omitempty"`
}
Changeset records a set of changes applied to DataHub from insights.
type ChangesetFilter ¶
type ChangesetFilter struct {
EntityURN string
AppliedBy string
Since *time.Time
Until *time.Time
RolledBack *bool
Limit int
Offset int
}
ChangesetFilter defines filtering criteria for listing changesets.
func (*ChangesetFilter) EffectiveLimit ¶
func (f *ChangesetFilter) EffectiveLimit() int
EffectiveLimit returns the limit to use, applying defaults and caps.
type ChangesetStore ¶
type ChangesetStore interface {
InsertChangeset(ctx context.Context, cs Changeset) error
GetChangeset(ctx context.Context, id string) (*Changeset, error)
ListChangesets(ctx context.Context, filter ChangesetFilter) ([]Changeset, int, error)
RollbackChangeset(ctx context.Context, id, rolledBackBy string) error
}
ChangesetStore persists and queries knowledge changesets.
func NewNoopChangesetStore ¶
func NewNoopChangesetStore() ChangesetStore
NewNoopChangesetStore creates a no-op ChangesetStore.
func NewPostgresChangesetStore ¶
func NewPostgresChangesetStore(db *sql.DB) ChangesetStore
NewPostgresChangesetStore creates a new PostgreSQL changeset store.
type DataHubClientWriter ¶
type DataHubClientWriter struct {
// contains filtered or unexported fields
}
DataHubClientWriter is a real DataHubWriter implementation that delegates to the mcp-datahub client for read and write operations against DataHub.
func NewDataHubClientWriter ¶
func NewDataHubClientWriter(c *dhclient.Client) *DataHubClientWriter
NewDataHubClientWriter creates a DataHubClientWriter from an existing client.
func (*DataHubClientWriter) AddDocumentationLink ¶
func (w *DataHubClientWriter) AddDocumentationLink(ctx context.Context, urn, linkURL, description string) error
AddDocumentationLink adds a documentation link to an entity.
func (*DataHubClientWriter) AddGlossaryTerm ¶
func (w *DataHubClientWriter) AddGlossaryTerm(ctx context.Context, urn, termURN string) error
AddGlossaryTerm adds a glossary term to an entity.
func (*DataHubClientWriter) AddTag ¶
func (w *DataHubClientWriter) AddTag(ctx context.Context, urn, tag string) error
AddTag adds a tag to an entity.
func (*DataHubClientWriter) CreateCuratedQuery ¶ added in v0.25.0
func (w *DataHubClientWriter) CreateCuratedQuery(ctx context.Context, entityURN, name, sqlText, description string) (string, error)
CreateCuratedQuery creates a Query entity in DataHub associated with the given dataset.
func (*DataHubClientWriter) DeleteContextDocument ¶ added in v1.46.0
func (w *DataHubClientWriter) DeleteContextDocument(ctx context.Context, documentID string) error
DeleteContextDocument removes a context document by its ID.
func (*DataHubClientWriter) GetCurrentMetadata ¶
func (w *DataHubClientWriter) GetCurrentMetadata(ctx context.Context, urn string) (*EntityMetadata, error)
GetCurrentMetadata retrieves current metadata for an entity from DataHub.
func (*DataHubClientWriter) RaiseIncident ¶ added in v1.44.0
func (w *DataHubClientWriter) RaiseIncident(ctx context.Context, entityURN, title, description string) (string, error)
RaiseIncident creates a new incident on an entity.
func (*DataHubClientWriter) RemoveDocumentationLink ¶ added in v1.70.0
func (w *DataHubClientWriter) RemoveDocumentationLink(ctx context.Context, urn, linkURL string) error
RemoveDocumentationLink removes a documentation link from an entity by URL.
func (*DataHubClientWriter) RemoveGlossaryTerm ¶ added in v1.70.0
func (w *DataHubClientWriter) RemoveGlossaryTerm(ctx context.Context, urn, termURN string) error
RemoveGlossaryTerm removes a glossary term association from an entity.
func (*DataHubClientWriter) RemoveStructuredProperty ¶ added in v1.44.0
func (w *DataHubClientWriter) RemoveStructuredProperty(ctx context.Context, urn, propertyURN string) error
RemoveStructuredProperty removes a structured property from an entity.
func (*DataHubClientWriter) RemoveTag ¶
func (w *DataHubClientWriter) RemoveTag(ctx context.Context, urn, tag string) error
RemoveTag removes a tag from an entity.
func (*DataHubClientWriter) ResolveIncident ¶ added in v1.44.0
func (w *DataHubClientWriter) ResolveIncident(ctx context.Context, incidentURN, message string) error
ResolveIncident marks an incident as resolved.
func (*DataHubClientWriter) UpdateColumnDescription ¶ added in v0.22.1
func (w *DataHubClientWriter) UpdateColumnDescription(ctx context.Context, urn, fieldPath, description string) error
UpdateColumnDescription sets the editable description for a specific column.
func (*DataHubClientWriter) UpdateColumnDescriptionBatch ¶ added in v1.53.0
func (w *DataHubClientWriter) UpdateColumnDescriptionBatch(ctx context.Context, urn string, columns map[string]string) error
UpdateColumnDescriptionBatch sets descriptions for multiple columns in a single read-modify-write cycle. This avoids the stale-read bug where back-to-back single UpdateColumnDescription calls lose all but the last column due to DataHub's eventual consistency.
func (*DataHubClientWriter) UpdateDescription ¶
func (w *DataHubClientWriter) UpdateDescription(ctx context.Context, urn, description string) error
UpdateDescription sets the editable description for an entity.
func (*DataHubClientWriter) UpsertContextDocument ¶ added in v1.46.0
func (w *DataHubClientWriter) UpsertContextDocument(ctx context.Context, entityURN string, doc types.ContextDocumentInput) (*types.ContextDocument, error)
UpsertContextDocument creates or updates a context document on an entity.
func (*DataHubClientWriter) UpsertStructuredProperties ¶ added in v1.44.0
func (w *DataHubClientWriter) UpsertStructuredProperties(ctx context.Context, urn, propertyURN string, values []any) error
UpsertStructuredProperties sets a structured property on an entity.
type DataHubWriter ¶
type DataHubWriter interface {
GetCurrentMetadata(ctx context.Context, urn string) (*EntityMetadata, error)
UpdateDescription(ctx context.Context, urn string, description string) error
UpdateColumnDescription(ctx context.Context, urn string, fieldPath string, description string) error
// UpdateColumnDescriptionBatch sets descriptions for multiple columns in a single
// read-modify-write cycle, avoiding the stale-read bug where back-to-back single
// calls lose all but the last column.
UpdateColumnDescriptionBatch(ctx context.Context, urn string, columns map[string]string) error
AddTag(ctx context.Context, urn string, tag string) error
RemoveTag(ctx context.Context, urn string, tag string) error
AddGlossaryTerm(ctx context.Context, urn string, termURN string) error
// RemoveGlossaryTerm removes a glossary term association. Used to revert add_glossary_term.
RemoveGlossaryTerm(ctx context.Context, urn string, termURN string) error
AddDocumentationLink(ctx context.Context, urn string, url string, description string) error
// RemoveDocumentationLink removes a documentation link by URL. Used to revert add_documentation.
RemoveDocumentationLink(ctx context.Context, urn string, url string) error
CreateCuratedQuery(ctx context.Context, entityURN, name, sql, description string) (string, error)
// Structured properties (DataHub 1.4.x)
UpsertStructuredProperties(ctx context.Context, urn string, propertyURN string, values []any) error
RemoveStructuredProperty(ctx context.Context, urn string, propertyURN string) error
// Incidents (DataHub 1.4.x)
RaiseIncident(ctx context.Context, entityURN, title, description string) (string, error)
ResolveIncident(ctx context.Context, incidentURN, message string) error
// Context documents (DataHub 1.4.x with document support)
UpsertContextDocument(ctx context.Context, entityURN string, doc types.ContextDocumentInput) (*types.ContextDocument, error)
DeleteContextDocument(ctx context.Context, documentID string) error
}
DataHubWriter provides write-back operations to DataHub.
type EntityInsightSummary ¶
type EntityInsightSummary struct {
EntityURN string `json:"entity_urn"`
Count int `json:"count"`
Categories []string `json:"categories"`
LatestAt string `json:"latest_at"`
}
EntityInsightSummary summarizes insights for a single entity.
type EntityMetadata ¶
type EntityMetadata struct {
Description string `json:"description"`
Tags []string `json:"tags"`
GlossaryTerms []string `json:"glossary_terms"`
Owners []string `json:"owners"`
}
EntityMetadata holds current metadata for an entity from DataHub.
type Insight ¶
type Insight struct {
ID string `json:"id" example:"a1b2c3d4e5f67890a1b2c3d4e5f67890"`
CreatedAt time.Time `json:"created_at" example:"2026-01-15T14:30:00Z"`
SessionID string `json:"session_id" example:"sess_abc123"`
CapturedBy string `json:"captured_by" example:"analyst@example.com"`
Persona string `json:"persona" example:"analyst"`
Source string `json:"source" example:"user"`
Category string `json:"category" example:"correction"`
InsightText string `json:"insight_text" example:"The amount column represents gross margin before returns, not revenue."`
Confidence string `json:"confidence" example:"high"`
EntityURNs []string `json:"entity_urns"`
RelatedColumns []RelatedColumn `json:"related_columns"`
SuggestedActions []SuggestedAction `json:"suggested_actions"`
Status string `json:"status" example:"pending"`
// Lifecycle fields (populated by migrations 000007 and 000008)
ReviewedBy string `json:"reviewed_by,omitempty" example:"admin@example.com"`
ReviewedAt *time.Time `json:"reviewed_at,omitempty"`
ReviewNotes string `json:"review_notes,omitempty" example:"Verified with data engineering team"`
AppliedBy string `json:"applied_by,omitempty"`
AppliedAt *time.Time `json:"applied_at,omitempty"`
ChangesetRef string `json:"changeset_ref,omitempty"`
}
Insight represents a captured domain knowledge insight.
type InsightFilter ¶
type InsightFilter struct {
Status string
Category string
EntityURN string
CapturedBy string
Confidence string
Source string
Since *time.Time
Until *time.Time
Limit int
Offset int
}
InsightFilter defines filtering criteria for listing insights.
func (*InsightFilter) EffectiveLimit ¶
func (f *InsightFilter) EffectiveLimit() int
EffectiveLimit returns the limit to use, applying defaults and caps.
type InsightStats ¶
type InsightStats struct {
TotalPending int `json:"total_pending"`
ByEntity []EntityInsightSummary `json:"by_entity"`
ByCategory map[string]int `json:"by_category"`
ByConfidence map[string]int `json:"by_confidence"`
ByStatus map[string]int `json:"by_status"`
}
InsightStats holds aggregated insight statistics.
type InsightStore ¶
type InsightStore interface {
Insert(ctx context.Context, insight Insight) error
Get(ctx context.Context, id string) (*Insight, error)
List(ctx context.Context, filter InsightFilter) ([]Insight, int, error)
UpdateStatus(ctx context.Context, id, status, reviewedBy, reviewNotes string) error
Update(ctx context.Context, id string, updates InsightUpdate) error
Stats(ctx context.Context, filter InsightFilter) (*InsightStats, error)
MarkApplied(ctx context.Context, id, appliedBy, changesetRef string) error
// MarkRolledBack transitions an applied insight to rolled_back. It is a no-op
// for insights not currently in the applied state, so re-running a rollback
// does not error or double-transition.
MarkRolledBack(ctx context.Context, id, rolledBackBy string) error
Supersede(ctx context.Context, entityURN string, excludeID string) (int, error)
}
InsightStore persists and queries captured insights.
func NewMemoryInsightAdapter ¶ added in v1.52.0
func NewMemoryInsightAdapter(store memory.Store) InsightStore
NewMemoryInsightAdapter creates an InsightStore backed by a memory.Store.
func NewNoopStore ¶
func NewNoopStore() InsightStore
NewNoopStore creates a no-op InsightStore for use when no database is available.
func NewPostgresStore ¶
func NewPostgresStore(db *sql.DB) InsightStore
NewPostgresStore creates a new PostgreSQL insight store.
func ParseConfig ¶
func ParseConfig(cfg map[string]any) InsightStore
ParseConfig extracts an InsightStore from a configuration map. The store must be provided programmatically (not from YAML).
type InsightUpdate ¶
type InsightUpdate struct {
InsightText string `json:"insight_text,omitempty"`
Category string `json:"category,omitempty"`
Confidence string `json:"confidence,omitempty"`
}
InsightUpdate holds fields that can be edited on a non-applied insight.
type NoopDataHubWriter ¶
type NoopDataHubWriter struct{}
NoopDataHubWriter is a no-op implementation for when DataHub write-back is not configured.
func (*NoopDataHubWriter) AddDocumentationLink ¶
func (*NoopDataHubWriter) AddDocumentationLink(_ context.Context, _, _, _ string) error
AddDocumentationLink is a no-op.
func (*NoopDataHubWriter) AddGlossaryTerm ¶
func (*NoopDataHubWriter) AddGlossaryTerm(_ context.Context, _, _ string) error
AddGlossaryTerm is a no-op.
func (*NoopDataHubWriter) AddTag ¶
func (*NoopDataHubWriter) AddTag(_ context.Context, _, _ string) error
AddTag is a no-op.
func (*NoopDataHubWriter) CreateCuratedQuery ¶ added in v0.25.0
CreateCuratedQuery is a no-op.
func (*NoopDataHubWriter) DeleteContextDocument ¶ added in v1.46.0
func (*NoopDataHubWriter) DeleteContextDocument(_ context.Context, _ string) error
DeleteContextDocument is a no-op.
func (*NoopDataHubWriter) GetCurrentMetadata ¶
func (*NoopDataHubWriter) GetCurrentMetadata(_ context.Context, _ string) (*EntityMetadata, error)
GetCurrentMetadata returns empty metadata.
func (*NoopDataHubWriter) RaiseIncident ¶ added in v1.44.0
RaiseIncident is a no-op.
func (*NoopDataHubWriter) RemoveDocumentationLink ¶ added in v1.70.0
func (*NoopDataHubWriter) RemoveDocumentationLink(_ context.Context, _, _ string) error
RemoveDocumentationLink is a no-op.
func (*NoopDataHubWriter) RemoveGlossaryTerm ¶ added in v1.70.0
func (*NoopDataHubWriter) RemoveGlossaryTerm(_ context.Context, _, _ string) error
RemoveGlossaryTerm is a no-op.
func (*NoopDataHubWriter) RemoveStructuredProperty ¶ added in v1.44.0
func (*NoopDataHubWriter) RemoveStructuredProperty(_ context.Context, _, _ string) error
RemoveStructuredProperty is a no-op.
func (*NoopDataHubWriter) RemoveTag ¶
func (*NoopDataHubWriter) RemoveTag(_ context.Context, _, _ string) error
RemoveTag is a no-op.
func (*NoopDataHubWriter) ResolveIncident ¶ added in v1.44.0
func (*NoopDataHubWriter) ResolveIncident(_ context.Context, _, _ string) error
ResolveIncident is a no-op.
func (*NoopDataHubWriter) UpdateColumnDescription ¶ added in v0.22.1
func (*NoopDataHubWriter) UpdateColumnDescription(_ context.Context, _, _, _ string) error
UpdateColumnDescription is a no-op.
func (*NoopDataHubWriter) UpdateColumnDescriptionBatch ¶ added in v1.53.0
func (*NoopDataHubWriter) UpdateColumnDescriptionBatch(_ context.Context, _ string, _ map[string]string) error
UpdateColumnDescriptionBatch is a no-op.
func (*NoopDataHubWriter) UpdateDescription ¶
func (*NoopDataHubWriter) UpdateDescription(_ context.Context, _, _ string) error
UpdateDescription is a no-op.
func (*NoopDataHubWriter) UpsertContextDocument ¶ added in v1.46.0
func (*NoopDataHubWriter) UpsertContextDocument(_ context.Context, _ string, _ types.ContextDocumentInput) (*types.ContextDocument, error)
UpsertContextDocument is a no-op.
func (*NoopDataHubWriter) UpsertStructuredProperties ¶ added in v1.44.0
UpsertStructuredProperties is a no-op.
type PromptCreator ¶ added in v1.51.0
type PromptCreator interface {
Create(ctx context.Context, p *prompt.Prompt) error
RegisterRuntimePrompt(p *prompt.Prompt)
}
PromptCreator creates and registers prompts at runtime.
type ProposedChange ¶
type ProposedChange struct {
ChangeType string `json:"change_type"`
Target string `json:"target"`
CurrentValue string `json:"current_value"`
SuggestedValue string `json:"suggested_value"`
SourceInsightIDs []string `json:"source_insight_ids"`
}
ProposedChange represents a deterministic change proposal from synthesis.
type RelatedColumn ¶
type RelatedColumn struct {
URN string `json:"urn" example:"urn:li:dataset:(urn:li:dataPlatform:trino,hive.sales.orders,PROD)"`
Column string `json:"column" example:"amount"`
Relevance string `json:"relevance" example:"direct"`
}
RelatedColumn represents a column related to an insight.
type RequiredFieldError ¶ added in v1.51.0
type RequiredFieldError string
RequiredFieldError is a sentinel-like error for missing required fields.
func (RequiredFieldError) Error ¶ added in v1.51.0
func (e RequiredFieldError) Error() string
Error implements the error interface.
type RollbackConflictError ¶ added in v1.70.0
RollbackConflictError is returned when a newer, not-yet-rolled-back changeset has since mutated the same metadata aspect. Reverting would silently clobber that newer change, so the rollback is refused.
func (*RollbackConflictError) Error ¶ added in v1.70.0
func (e *RollbackConflictError) Error() string
Error implements the error interface.
type RollbackDeps ¶ added in v1.70.0
type RollbackDeps struct {
Writer DataHubWriter
Changesets ChangesetStore
Insights InsightStore
}
RollbackDeps bundles the stores and writer a rollback operates on. It is the shared dependency set for both the apply_knowledge MCP tool and the admin REST endpoint.
type RollbackResult ¶ added in v1.70.0
type RollbackResult struct {
ChangesetID string `json:"changeset_id"`
TargetURN string `json:"target_urn"`
RevertedChanges []string `json:"reverted_changes"`
SkippedChanges []string `json:"skipped_changes,omitempty"`
InsightsRolledBack []string `json:"insights_rolled_back"`
RolledBackBy string `json:"rolled_back_by,omitempty"`
}
RollbackResult summarizes the outcome of a successful changeset rollback.
func RevertChangeset ¶ added in v1.70.0
func RevertChangeset(ctx context.Context, deps RollbackDeps, cs *Changeset, rolledBackBy string) (*RollbackResult, error)
RevertChangeset reverts the DataHub aspects mutated by a changeset back to their pre-change state, transitions the source insights to rolled_back, and marks the changeset as rolled back. It is the single rollback implementation shared by the apply_knowledge MCP tool and the admin REST endpoint.
It refuses (rather than silently no-ops) when the changeset is already rolled back, when it contains change types whose prior state was not captured, or when a newer changeset has since touched the same aspect.
type SuggestedAction ¶
type SuggestedAction struct {
ActionType string `json:"action_type" example:"update_description"`
Target string `json:"target" example:"amount"`
Detail string `json:"detail" example:"Gross margin before returns"`
QuerySQL string `json:"query_sql,omitempty"`
QueryDescription string `json:"query_description,omitempty"`
}
SuggestedAction represents a proposed catalog change.
type Toolkit ¶
type Toolkit struct {
// contains filtered or unexported fields
}
Toolkit implements the knowledge capture toolkit.
func New ¶
func New(name string, store InsightStore) (*Toolkit, error)
New creates a new knowledge toolkit. If store is nil, a no-op store is used.
func (*Toolkit) Connection ¶
Connection returns the connection name for audit logging.
func (*Toolkit) PromptInfos ¶ added in v1.38.0
func (*Toolkit) PromptInfos() []registry.PromptInfo
PromptInfos returns metadata for prompts registered by the knowledge toolkit.
func (*Toolkit) RegisterTools ¶
RegisterTools registers the capture_insight tool with the MCP server.
func (*Toolkit) SetApplyConfig ¶
func (t *Toolkit) SetApplyConfig(cfg ApplyConfig, csStore ChangesetStore, writer DataHubWriter)
SetApplyConfig enables the apply_knowledge tool with its dependencies.
func (*Toolkit) SetMemoryStore ¶ added in v1.52.0
SetMemoryStore configures the memory store for unified memory writes. When set, capture_insight writes directly to the memory store with embeddings.
func (*Toolkit) SetPromptCreator ¶ added in v1.51.0
func (t *Toolkit) SetPromptCreator(pc PromptCreator)
SetPromptCreator sets the prompt creator for add_prompt change type support.
func (*Toolkit) SetQueryProvider ¶
SetQueryProvider sets the query execution provider.
func (*Toolkit) SetSemanticProvider ¶
SetSemanticProvider sets the semantic metadata provider.
type UnrevertibleError ¶ added in v1.70.0
type UnrevertibleError struct {
ChangeTypes []string
}
UnrevertibleError is returned when a changeset contains change types whose pre-change state is not captured in the changeset's before-image, so they cannot be reverted automatically. The recovery path for these is a manual re-apply of the desired state.
func (*UnrevertibleError) Error ¶ added in v1.70.0
func (e *UnrevertibleError) Error() string
Error implements the error interface.