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 platform catalog 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 config values and the catalog — 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 ¶
- type Config
- type Handle
- func (h *Handle) Catalog() catalog.Store
- func (h *Handle) ChangesetStore() knowledgekit.ChangesetStore
- func (h *Handle) InsightStore() knowledgekit.InsightStore
- func (h *Handle) PageIndexProducer() *indexjobs.Producer
- func (h *Handle) PendingReviewSummary(ctx context.Context) *ReviewQueueInfo
- func (h *Handle) Toolkit() *knowledgekit.Toolkit
- type ReviewQueueInfo
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 catalog, the knowledge-page writer, and the page guards.
ApplyEnabled bool
// 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
// Catalog is the platform catalog apply writes curation to (#1920); nil
// leaves catalog changes refused while the knowledge-page and
// agent-instruction sinks still apply. Used only when ApplyEnabled.
Catalog catalog.Store
// PortalBaseURL is the deployment's public portal address. A promotion that
// writes a knowledge page hands back where that page is read (#1696); empty
// leaves the address off, since a deployment that declared no public
// address cannot know it.
PortalBaseURL string
}
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 Handle ¶
type Handle struct {
// contains filtered or unexported fields
}
Handle owns the assembled knowledge-capture layer: the insight store, the changeset store and catalog for apply_knowledge, and the knowledge toolkit. The read accessors expose the pieces Platform surfaces through its KnowledgeInsightStore() / KnowledgeChangesetStore() / KnowledgeCatalog() 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 knowledge toolkit, and — when cfg.ApplyEnabled — the changeset store, catalog, 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 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 wrapping the memory 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) Catalog ¶ added in v1.146.0
Catalog returns the catalog apply_knowledge writes to, or nil on a nil Handle, when apply is disabled, or when there is no catalog.
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) 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) PageIndexProducer ¶ added in v1.121.0
PageIndexProducer returns the write-path index-job producer behind the apply path's knowledge-page writer, for the index-jobs queue to bind. Nil on a nil Handle or when apply is disabled.
func (*Handle) PendingReviewSummary ¶ added in v1.129.0
func (h *Handle) PendingReviewSummary(ctx context.Context) *ReviewQueueInfo
PendingReviewSummary summarizes the pending review queue for platform_info so an agent can nudge a reviewer about aging review debt (#764). It returns nil on a nil Handle, when knowledge is disabled (no insight store), when the stats lookup fails, or when the queue is empty; a failed lookup must not fail orientation, so the error is logged and swallowed rather than propagated.
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.
type ReviewQueueInfo ¶ added in v1.129.0
type ReviewQueueInfo struct {
Pending int `json:"pending"`
OldestPendingAgeDays int `json:"oldest_pending_age_days,omitempty"`
PendingOver30d int `json:"pending_over_30d,omitempty"`
}
ReviewQueueInfo summarizes the pending apply_knowledge review queue so an agent can nudge a reviewer about aging review debt, e.g. "6 insights pending review, oldest 94 days" (#764). platform_info reports it only for a caller who can reach apply_knowledge and only when the queue is non-empty.