Documentation
¶
Overview ¶
Package knowledgelayer assembles the knowledge-capture layer behind one Handle: the insight store (the memory-backed adapter over memory_records when a memory store is present, else the legacy Postgres store), the changeset store and DataHub writer that back apply_knowledge, and the capture_insight / apply_knowledge toolkit itself.
Construction takes explicit inputs — a *sql.DB, the memory.Store for the insight adapter (nil selects the Postgres store), the shared embedding.Provider that powers the knowledge-page write-guard dedup probe, and the resolved knowledge / apply / page-guard / DataHub-connection config values — so the subsystem is constructible and testable without a Platform. It imports pkg/toolkits/knowledge, pkg/memory, pkg/embedding, and pkg/portal/knowledgepage, never pkg/platform. The *sql.DB, the memory store, and the embedding provider back many other subsystems, so they stay owned by Platform and are passed in.
The layer owns no background goroutine, so it needs no Stop/Close (unlike the memory layer's staleness watcher). Toolkit registration and the prompt-creator wiring stay Platform/registry concerns: New builds the toolkit and exposes it via Toolkit() for Platform to register into the shared toolkit registry and to wire the prompt creator onto (that wiring reaches back into Platform, so it cannot move here).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// ToolkitName is the knowledge toolkit instance name (the platform passes its
// default).
ToolkitName string
// ApplyEnabled gates the apply_knowledge dependencies: the changeset store,
// the DataHub writer, the knowledge-page writer, and the page guards.
ApplyEnabled bool
// ApplyDataHubConnection is the connection name apply writes to; reported in
// the enabled log and the noop-writer WARN.
ApplyDataHubConnection string
// ApplyRequireConfirmation is passed through to the toolkit's ApplyConfig.
ApplyRequireConfirmation bool
// PageGuards are the resolved knowledge-page write-guard thresholds (#705),
// applied only when apply is enabled.
PageGuards knowledgepage.PageGuards
// DataHub is the resolved DataHub connection for the apply writer; nil selects
// the noop writer with a startup WARN. Used only when ApplyEnabled.
DataHub *DataHubConfig
}
Config carries the resolved knowledge / apply / page-guard values the owner needs to assemble the layer. Platform translates its own config into this shape so this package stays free of the platform's config types.
type DataHubConfig ¶
DataHubConfig carries the resolved DataHub connection values the owner needs to build the real client-backed apply writer. Platform resolves its own toolkit config (keeping its toolkitcfg coupling out of this package) and passes a non-nil value when the apply datahub_connection is configured, or nil to select the noop writer (with the startup WARN).
type Handle ¶
type Handle struct {
// contains filtered or unexported fields
}
Handle owns the assembled knowledge-capture layer: the insight store, the changeset store and DataHub writer for apply_knowledge, and the knowledge toolkit. The read accessors expose the pieces Platform surfaces through its KnowledgeInsightStore() / KnowledgeChangesetStore() / KnowledgeDataHubWriter() admin accessors, reads for platform_info's pending-review count and the search router's insights provider, registers into the shared toolkit registry, and wires the prompt creator + guarded backfill onto. The layer owns no background goroutine, so there is no Stop/Close.
func New ¶
func New(db *sql.DB, memStore memory.Store, embeddingProv embedding.Provider, cfg Config) (*Handle, error)
New assembles the insight store (the memory-backed adapter when memStore is non-nil, else the legacy Postgres store), the knowledge toolkit, and — when cfg.ApplyEnabled — the changeset store, DataHub writer, knowledge-page writer, and page guards for apply_knowledge. It returns (nil, nil) when db is nil: the knowledge layer is a no-op without a database, matching the platform precondition. It returns an error only when the toolkit or the DataHub client fails to build.
func NewFromInsightStore ¶
func NewFromInsightStore(db *sql.DB, store knowledgekit.InsightStore, embeddingProv embedding.Provider, cfg Config) (*Handle, error)
NewFromInsightStore assembles the Handle and its toolkit from an already-built insight store. New delegates here after selecting the adapter-vs-postgres store; it is also the seam that lets callers (and tests) inject their own insight store implementation. When cfg.ApplyEnabled it configures the apply_knowledge dependencies from db / embeddingProv / cfg — which requires a non-nil db (the changeset and page stores are Postgres-backed), so enabling apply with a nil db is a construction error rather than a query-time failure.
func (*Handle) ChangesetStore ¶
func (h *Handle) ChangesetStore() knowledgekit.ChangesetStore
ChangesetStore returns the apply_knowledge changeset store, or nil on a nil Handle or when apply is disabled.
func (*Handle) DataHubWriter ¶
func (h *Handle) DataHubWriter() knowledgekit.DataHubWriter
DataHubWriter returns the apply_knowledge DataHub writer, or nil on a nil Handle or when apply is disabled.
func (*Handle) InsightStore ¶
func (h *Handle) InsightStore() knowledgekit.InsightStore
InsightStore returns the insight store, or nil on a nil Handle (knowledge disabled or no database).
func (*Handle) Toolkit ¶
func (h *Handle) Toolkit() *knowledgekit.Toolkit
Toolkit returns the knowledge toolkit for Platform to register into the shared toolkit registry, wire the prompt creator onto, and run the guarded backfill against, or nil on a nil Handle.