Documentation
¶
Overview ¶
Package contentkit is the deterministic content library: tenant-scoped keyword search over host content, the ClickHouse signal plane, and the discovery reads over both. The DocumentSink port publishes document changes to optional external consumers.
Index ¶
- Constants
- Variables
- func Migrate(ctx context.Context, cfg MigrateConfig) error
- func NewEvalRunner(client *Client, base SearchOptions) eval.CaseRunner
- type CandidateTrace
- type CatalogQuery
- type Client
- func (c *Client) Search(ctx context.Context, userText string, opts SearchOptions) (SearchResult, error)
- func (c *Client) SearchWithTrace(ctx context.Context, userText string, opts SearchOptions) (SearchResult, SearchTrace, error)
- func (c *Client) Tenant() string
- func (c *Client) Typeahead(ctx context.Context, userText string, opts TypeaheadOptions) ([]TypeaheadHit, error)
- type ClientConfig
- type ContentCatalog
- type ContentCatalogFunc
- type ContentKey
- type ContentRef
- type ContributionTrace
- type DocumentKey
- type DocumentSink
- type Eligibility
- type EmbeddedConfig
- type EmbeddedHub
- func (h *EmbeddedHub) Attribution(ctx context.Context, opts signal.AttributionOptions) (signal.AttributionPage, error)
- func (h *EmbeddedHub) Client() *Client
- func (h *EmbeddedHub) Content(contentKind, contentID string) ContentRef
- func (h *EmbeddedHub) EnforceErasures(ctx context.Context) (signal.ErasureReport, error)
- func (h *EmbeddedHub) EraseSubjects(ctx context.Context, subjects []signal.Subject) (signal.ErasureReport, error)
- func (h *EmbeddedHub) Forget(ctx context.Context, subject signal.Subject, contentKind, contentID string) error
- func (h *EmbeddedHub) ForgetExposures(ctx context.Context, subject signal.Subject) error
- func (h *EmbeddedHub) ForgetExposuresBefore(ctx context.Context, subject signal.Subject, before time.Time) error
- func (h *EmbeddedHub) History(ctx context.Context, subject signal.Subject, opts signal.HistoryOptions) ([]signal.StateRow, error)
- func (h *EmbeddedHub) HistoryCount(ctx context.Context, subject signal.Subject, opts signal.HistoryOptions) (int64, error)
- func (h *EmbeddedHub) Inventory(ctx context.Context) ([]signal.InventoryRow, error)
- func (h *EmbeddedHub) Metrics(ctx context.Context, refs []ContentRef, window signal.Window) (map[ContentKey]signal.ContentMetrics, error)
- func (h *EmbeddedHub) Popular(ctx context.Context, contentKind string, opts signal.PopularOptions) ([]signal.PopularHit, error)
- func (h *EmbeddedHub) PopularityFor(ctx context.Context, contentKind string, ids []string, window signal.Window) (map[string]float64, error)
- func (h *EmbeddedHub) PurgeContentKinds(ctx context.Context, contentKinds []string) error
- func (h *EmbeddedHub) Recommend(ctx context.Context, subject signal.Subject, opts RecommendOptions) ([]RecHit, error)
- func (h *EmbeddedHub) RecordExposures(ctx context.Context, exposures []signal.Exposure) error
- func (h *EmbeddedHub) RecordSignals(ctx context.Context, signals []signal.Signal) error
- func (h *EmbeddedHub) RefreshCoEngagement(ctx context.Context, opts signal.RefreshCoEngagementOptions) error
- func (h *EmbeddedHub) RepairProjections(ctx context.Context, opts signal.RepairOptions) (signal.RepairResult, error)
- func (h *EmbeddedHub) Search(ctx context.Context, userText string, opts HubSearchOptions) (SearchResult, error)
- func (h *EmbeddedHub) SeenIDs(ctx context.Context, subject signal.Subject, contentKind string) (map[string]struct{}, error)
- func (h *EmbeddedHub) SimilarTo(ctx context.Context, ref ContentRef, opts SimilarOptions) ([]RecHit, error)
- func (h *EmbeddedHub) States(ctx context.Context, subject signal.Subject, refs []ContentRef) (map[ContentKey]signal.State, error)
- func (h *EmbeddedHub) Tenant() string
- func (h *EmbeddedHub) Typeahead(ctx context.Context, userText string, opts TypeaheadOptions) ([]TypeaheadHit, error)
- func (h *EmbeddedHub) Unseen(ctx context.Context, subject signal.Subject, opts UnseenOptions) ([]string, error)
- type EmptyReason
- type Hub
- type HubSearchOptions
- type KeywordDocument
- type LanguageMode
- type MigrateConfig
- type Personalization
- type PublishedDocument
- type RecHit
- type RecommendOptions
- type ResultTrace
- type RetrievalBackend
- type Runtime
- func (r *Runtime) EraseSubjects(ctx context.Context, subjects []signal.Subject) (signal.ErasureReport, error)
- func (r *Runtime) Handler() http.Handler
- func (r *Runtime) ResyncPreferences(ctx context.Context) (content.PreferenceSyncReport, error)
- func (r *Runtime) SyncPreferences(ctx context.Context) (content.PreferenceSyncReport, error)
- func (r *Runtime) WorkerOptions(host worker.Options) worker.Options
- type RuntimeConfig
- type ScoreKind
- type SearchHit
- type SearchOptions
- type SearchResult
- type SearchTrace
- type SimilarOptions
- type SourceStatus
- type SourceTrace
- type TaxonomyID
- type TraceKey
- type TypeaheadHit
- type TypeaheadOptions
- type UnseenOptions
Constants ¶
const PreferenceEventID = "current"
PreferenceEventID is the stable signal identity of a subject's current preference on one axis: (tenant, canonical reference, subject, axis, "current"). A newer revision supersedes the previous one; a re-send carries the same revision and converges.
Variables ¶
var ErrSignalPlaneDisabled = errors.New("contentkit: signal plane disabled (no ClickHouse configured)")
ErrSignalPlaneDisabled is returned by signal/discovery methods when the hub was constructed without a ClickHouse connection.
Functions ¶
func Migrate ¶
func Migrate(ctx context.Context, cfg MigrateConfig) error
Migrate installs all PostgreSQL features in one host-selected schema and the optional ClickHouse signal plane. This baseline initializes fresh stores.
func NewEvalRunner ¶
func NewEvalRunner(client *Client, base SearchOptions) eval.CaseRunner
NewEvalRunner adapts a Client to eval.CaseRunner so a golden suite can be executed against real search. The base options carry cross-case settings (LanguageMode and filters); each case overrides Language, ContentKinds, and Limit from its own definition.
This adapter is the single seam where the client meets the dependency-free eval package.
Types ¶
type CandidateTrace ¶
type CandidateTrace struct {
Key TraceKey `json:"key"`
Rank int `json:"rank"`
Score float32 `json:"score"`
}
CandidateTrace records one source candidate at its raw source rank.
type CatalogQuery ¶
type CatalogQuery struct {
Limit int
}
CatalogQuery bounds a Universe read. Limit 0 = host-defined default.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client answers keyword search and typeahead for one tenant.
func NewClient ¶
func NewClient(cfg ClientConfig) (*Client, error)
func (*Client) Search ¶
func (c *Client) Search(ctx context.Context, userText string, opts SearchOptions) (SearchResult, error)
Search returns one page of content items. Documents from every searched language are grouped per work before Offset and Limit apply; each hit carries the matched document's reference and language.
func (*Client) SearchWithTrace ¶
func (c *Client) SearchWithTrace(ctx context.Context, userText string, opts SearchOptions) (SearchResult, SearchTrace, error)
SearchWithTrace executes Search and returns opt-in retrieval provenance. On failure, the returned trace contains all work completed before the error.
func (*Client) Typeahead ¶
func (c *Client) Typeahead(ctx context.Context, userText string, opts TypeaheadOptions) ([]TypeaheadHit, error)
Typeahead returns suggestions while a user is typing (typos/substring matching), one per content item, grouped before Limit.
type ClientConfig ¶
type ClientConfig struct {
Pool *pgxpool.Pool
Schema string
// Tenant scopes every document, query and result. Required.
Tenant string
// Defaults.
DefaultLanguage string
DefaultLimit int
}
ClientConfig configures the keyword search client of one tenant.
type ContentCatalog ¶
type ContentCatalog interface {
Universe(ctx context.Context, tenant string, contentKind string, q CatalogQuery) ([]string, error)
}
ContentCatalog supplies the content "universe" for Unseen: live, non-deleted content ids of a kind, read from the host's own tables. The host owns visibility and gating (premium, region, ...) — ContentKit never interprets them. Order defines Unseen order (recommended: newest first).
type ContentCatalogFunc ¶
type ContentCatalogFunc func(ctx context.Context, tenant string, contentKind string, q CatalogQuery) ([]string, error)
ContentCatalogFunc adapts a function to the ContentCatalog interface.
func (ContentCatalogFunc) Universe ¶
func (f ContentCatalogFunc) Universe(ctx context.Context, tenant string, contentKind string, q CatalogQuery) ([]string, error)
type ContentKey ¶
type ContentKey = contentref.ContentKey
ContentKey is the comparable form of a ContentRef.
type ContentRef ¶
type ContentRef = contentref.ContentRef
ContentRef is the tenant-scoped reference to host-owned content (the work or one of its versions). See contentref.
type ContributionTrace ¶
type ContributionTrace struct {
SourceIndex int `json:"source_index"`
SourceRank int `json:"source_rank"`
Weight float32 `json:"weight"`
Contribution float32 `json:"contribution"`
}
ContributionTrace records one exact source contribution to a result score.
type DocumentKey ¶
type DocumentKey = search.DocumentKey
DocumentKey identifies one keyword document: a ContentRef in one language.
type DocumentSink ¶
type DocumentSink = search.DocumentSink
DocumentSink is the optional document port (see search.DocumentSink): the worker delivers every published keyword document to it at least once.
type Eligibility ¶
type Eligibility = search.Eligibility
Eligibility is the host's per-document eligibility join; see search.Eligibility.
type EmbeddedConfig ¶
type EmbeddedConfig struct {
// Content plane (Postgres). PG + PGSchema are required. PGSchema is the
// host-selected schema containing all ContentKit tables; it may also hold
// application tables.
PG *pgxpool.Pool
PGSchema string
// Content-plane defaults (as in ClientConfig).
DefaultLanguage string
DefaultLimit int
// DefaultRRFK controls deterministic popularity/discovery fusion (default 60).
DefaultRRFK int
// Signal plane (ClickHouse). Optional: omit CH to run content-only
// (signal/discovery methods return ErrSignalPlaneDisabled). CHDatabase
// is the hub's dedicated ClickHouse database; apply
// migrations.ClickHouse and gate startup on signal.CheckSchema.
CH signal.Conn
CHDatabase string
// Tenant is the single tenant of this embedded hub. Required: every
// document, signal, cursor and result carries it.
Tenant string
// Scorers maps content kind → host Scorer. When a signal arrives for a
// registered kind, the scorer's result overwrites Score / Progress /
// ProgressMax / Completed before recording.
Scorers map[string]signal.Scorer
// Catalogs maps content kind → host ContentCatalog (the Unseen universe).
Catalogs map[string]ContentCatalog
// Candidates sources SimilarTo and Recommend (requires CH). Nil =
// discovery.Engagement (co-engagement) over this hub's signal store.
Candidates discovery.Candidates
}
EmbeddedConfig configures an in-process hub against the shared DB.
type EmbeddedHub ¶
type EmbeddedHub struct {
// contains filtered or unexported fields
}
EmbeddedHub implements Hub in-process. Construct with NewEmbedded.
func NewEmbedded ¶
func NewEmbedded(cfg EmbeddedConfig) (*EmbeddedHub, error)
NewEmbedded builds the embedded hub: in-process, shared DB, one tenant.
func (*EmbeddedHub) Attribution ¶
func (h *EmbeddedHub) Attribution(ctx context.Context, opts signal.AttributionOptions) (signal.AttributionPage, error)
Attribution exports renders at one stage with their clicks joined (see signal.Store.Attribution); the evaluation dataset source.
func (*EmbeddedHub) Client ¶
func (h *EmbeddedHub) Client() *Client
Client returns the underlying content-plane client (advanced use).
func (*EmbeddedHub) Content ¶
func (h *EmbeddedHub) Content(contentKind, contentID string) ContentRef
Content returns a reference to a work of this hub's tenant.
func (*EmbeddedHub) EnforceErasures ¶
func (h *EmbeddedHub) EnforceErasures(ctx context.Context) (signal.ErasureReport, error)
EnforceErasures physically removes residue of every recorded erasure of this tenant (see signal.Store.EnforceErasures): schedule it and run it after every restore.
func (*EmbeddedHub) EraseSubjects ¶
func (h *EmbeddedHub) EraseSubjects(ctx context.Context, subjects []signal.Subject) (signal.ErasureReport, error)
EraseSubjects permanently erases subjects from this tenant's signal plane: see signal.Store.EraseSubjects for the completion contract. Shared accounts exist in several tenants: each host erases its own tenant.
func (*EmbeddedHub) Forget ¶
func (h *EmbeddedHub) Forget(ctx context.Context, subject signal.Subject, contentKind, contentID string) error
Forget erases the subject's signals for one work and its versions (contentID set) or a whole content kind (contentID empty) — host "clear my history" support.
func (*EmbeddedHub) ForgetExposures ¶
ForgetExposures clears a subject's result-list exposures (search history).
func (*EmbeddedHub) ForgetExposuresBefore ¶ added in v0.15.0
func (h *EmbeddedHub) ForgetExposuresBefore(ctx context.Context, subject signal.Subject, before time.Time) error
ForgetExposuresBefore clears only exposures from before the host's clear request.
func (*EmbeddedHub) History ¶
func (h *EmbeddedHub) History(ctx context.Context, subject signal.Subject, opts signal.HistoryOptions) ([]signal.StateRow, error)
func (*EmbeddedHub) HistoryCount ¶
func (h *EmbeddedHub) HistoryCount(ctx context.Context, subject signal.Subject, opts signal.HistoryOptions) (int64, error)
HistoryCount returns the total row count History would paginate over.
func (*EmbeddedHub) Inventory ¶
func (h *EmbeddedHub) Inventory(ctx context.Context) ([]signal.InventoryRow, error)
Inventory reports canonical event volume per content kind and signal type.
func (*EmbeddedHub) Metrics ¶
func (h *EmbeddedHub) Metrics(ctx context.Context, refs []ContentRef, window signal.Window) (map[ContentKey]signal.ContentMetrics, error)
Metrics returns named window metrics (viewers, views, completions, feedback, ...) for the references (works or versions).
func (*EmbeddedHub) Popular ¶
func (h *EmbeddedHub) Popular(ctx context.Context, contentKind string, opts signal.PopularOptions) ([]signal.PopularHit, error)
func (*EmbeddedHub) PopularityFor ¶
func (h *EmbeddedHub) PopularityFor(ctx context.Context, contentKind string, ids []string, window signal.Window) (map[string]float64, error)
PopularityFor scores a fixed candidate set (work ids of one kind) by the popularity ranking, returning content_id -> score. Use to rank a host- filtered universe (e.g. "galleries of artist X by popularity").
func (*EmbeddedHub) PurgeContentKinds ¶
func (h *EmbeddedHub) PurgeContentKinds(ctx context.Context, contentKinds []string) error
PurgeContentKinds irreversibly deletes whole content kinds from this tenant's signal plane (see signal.Store.PurgeContentKinds).
func (*EmbeddedHub) Recommend ¶
func (h *EmbeddedHub) Recommend(ctx context.Context, subject signal.Subject, opts RecommendOptions) ([]RecHit, error)
Recommend returns "for you" works for a subject from the configured Candidates source, excluding seen (unless IncludeSeen) and disliked works, with a popularity fill for cold start. The host hydrates the references.
func (*EmbeddedHub) RecordExposures ¶
RecordExposures logs one row per result list and stage (served, rendered, visible) so clicks can be attributed to what was actually exposed. Hosts call it once per list per stage, never per item.
func (*EmbeddedHub) RecordSignals ¶
RecordSignals applies each content kind's registered Scorer, then records the batch (see signal.Store.RecordSignals). A scorer error records nothing.
func (*EmbeddedHub) RefreshCoEngagement ¶
func (h *EmbeddedHub) RefreshCoEngagement(ctx context.Context, opts signal.RefreshCoEngagementOptions) error
RefreshCoEngagement (re)materializes the content_pairs co-engagement rollup for this tenant (see signal.Store.RefreshCoEngagement). Run periodically.
func (*EmbeddedHub) RepairProjections ¶
func (h *EmbeddedHub) RepairProjections(ctx context.Context, opts signal.RepairOptions) (signal.RepairResult, error)
RepairProjections is the bounded, host-scheduled projection repair (see signal.Store.RepairProjections): run it periodically with IngestedSince for crash repair, and with Rebuild over a window after projection changes.
func (*EmbeddedHub) Search ¶
func (h *EmbeddedHub) Search(ctx context.Context, userText string, opts HubSearchOptions) (SearchResult, error)
func (*EmbeddedHub) SeenIDs ¶
func (h *EmbeddedHub) SeenIDs(ctx context.Context, subject signal.Subject, contentKind string) (map[string]struct{}, error)
SeenIDs returns the subject's seen-set for one content kind (the signal-plane half of the unseen anti-join). Use when the host wants to run its own diff against a custom-filtered universe instead of Unseen's registered catalog.
func (*EmbeddedHub) SimilarTo ¶
func (h *EmbeddedHub) SimilarTo(ctx context.Context, ref ContentRef, opts SimilarOptions) ([]RecHit, error)
SimilarTo returns works like the anchor ("more like this") from the configured Candidates source (default: co-engagement).
func (*EmbeddedHub) States ¶
func (h *EmbeddedHub) States(ctx context.Context, subject signal.Subject, refs []ContentRef) (map[ContentKey]signal.State, error)
func (*EmbeddedHub) Tenant ¶
func (h *EmbeddedHub) Tenant() string
Tenant returns the pinned tenant value.
func (*EmbeddedHub) Typeahead ¶
func (h *EmbeddedHub) Typeahead(ctx context.Context, userText string, opts TypeaheadOptions) ([]TypeaheadHit, error)
func (*EmbeddedHub) Unseen ¶
func (h *EmbeddedHub) Unseen(ctx context.Context, subject signal.Subject, opts UnseenOptions) ([]string, error)
Unseen returns catalog ids the subject has not seen (max_progress > 0 defines "seen"): host universe MINUS the subject's seen-set. The host catalog applies its own visibility/premium gating against its own tables.
type EmptyReason ¶
type EmptyReason string
EmptyReason explains a successful empty response.
const ( EmptyReasonNormalizedQuery EmptyReason = "normalized_query_empty" EmptyReasonNoCandidates EmptyReason = "no_candidates" )
type Hub ¶
type Hub interface {
// Tenant returns the tenant this hub instance is scoped to.
Tenant() string
// Content plane.
Search(ctx context.Context, userText string, opts HubSearchOptions) (SearchResult, error)
Typeahead(ctx context.Context, userText string, opts TypeaheadOptions) ([]TypeaheadHit, error)
SimilarTo(ctx context.Context, ref ContentRef, opts SimilarOptions) ([]RecHit, error)
// Signal plane.
RecordSignals(ctx context.Context, signals []signal.Signal) error
RecordExposures(ctx context.Context, exposures []signal.Exposure) error
ForgetExposures(ctx context.Context, subject signal.Subject) error
ForgetExposuresBefore(ctx context.Context, subject signal.Subject, before time.Time) error
Attribution(ctx context.Context, opts signal.AttributionOptions) (signal.AttributionPage, error)
Forget(ctx context.Context, subject signal.Subject, contentKind, contentID string) error
EraseSubjects(ctx context.Context, subjects []signal.Subject) (signal.ErasureReport, error)
EnforceErasures(ctx context.Context) (signal.ErasureReport, error)
// Discovery plane.
History(ctx context.Context, subject signal.Subject, opts signal.HistoryOptions) ([]signal.StateRow, error)
HistoryCount(ctx context.Context, subject signal.Subject, opts signal.HistoryOptions) (int64, error)
SeenIDs(ctx context.Context, subject signal.Subject, contentKind string) (map[string]struct{}, error)
Unseen(ctx context.Context, subject signal.Subject, opts UnseenOptions) ([]string, error)
States(ctx context.Context, subject signal.Subject, refs []ContentRef) (map[ContentKey]signal.State, error)
Metrics(ctx context.Context, refs []ContentRef, window signal.Window) (map[ContentKey]signal.ContentMetrics, error)
Popular(ctx context.Context, contentKind string, opts signal.PopularOptions) ([]signal.PopularHit, error)
PopularityFor(ctx context.Context, contentKind string, ids []string, window signal.Window) (map[string]float64, error)
Recommend(ctx context.Context, subject signal.Subject, opts RecommendOptions) ([]RecHit, error)
// Maintenance.
RefreshCoEngagement(ctx context.Context, opts signal.RefreshCoEngagementOptions) error
RepairProjections(ctx context.Context, opts signal.RepairOptions) (signal.RepairResult, error)
Inventory(ctx context.Context) ([]signal.InventoryRow, error)
PurgeContentKinds(ctx context.Context, contentKinds []string) error
}
Hub is the single surface host apps program against: content-plane queries (search/typeahead), the signal plane (RecordSignals), and the discovery plane (reads over content × signals). All methods return ranked content references (+ per-subject State); the host hydrates them into cards from its own DB. Every method is scoped to the tenant pinned at construction; a reference of another tenant is an error.
type HubSearchOptions ¶
type HubSearchOptions struct {
SearchOptions
Personalize *Personalization
}
HubSearchOptions extends content SearchOptions with optional signal-aware personalization.
type KeywordDocument ¶
type KeywordDocument = search.KeywordDocument
KeywordDocument is the host's canonical search input for one document.
type LanguageMode ¶
type LanguageMode string
const ( // LanguageModeExact uses only the requested language. LanguageModeExact LanguageMode = "exact" // LanguageModeFallbackEnglish uses requested language first, then English. LanguageModeFallbackEnglish LanguageMode = "fallback_en" )
type MigrateConfig ¶
type MigrateConfig struct {
// DB holds PostgreSQL DDL credentials. Required.
DB *sql.DB
// Schema receives every PostgreSQL table; it may be the application's schema.
// Required. Identifiers contain letters, numbers or underscores.
Schema string
// ClickHouse applies the signal baseline when set; PostgresDB defaults to DB.
ClickHouse *chmigrate.Config
}
MigrateConfig selects the host-owned stores for the two ContentKit baselines.
type Personalization ¶
type Personalization struct {
Subject signal.Subject
// PopularityWeight is the RRF weight of the candidate-set popularity
// list blended with the content ranking. Defaults to 0.25.
PopularityWeight float32
// PopularityWindow bounds candidate popularity (zero = all time).
PopularityWindow signal.Window
// AffinityWeight boosts works the subject already engaged with by
// (1 + AffinityWeight·last_score/100). 0 = off.
AffinityWeight float32
// DemoteSeen demotes already-seen / completed works.
DemoteSeen bool
// SeenPenalty multiplies seen-but-not-completed scores (default 0.85).
SeenPenalty float32
// CompletedPenalty multiplies completed scores (default 0.6).
CompletedPenalty float32
// DislikePenalty multiplies works the subject has net-negative explicit
// feedback for (default 0.3). Always applied when view context is loaded
// (i.e. AffinityWeight > 0 or DemoteSeen).
DislikePenalty float32
}
Personalization fuses signal aggregates into search ranking. Recall is unchanged — this is a ranking-only layer over the candidate set. A per-request toggle the host flips (e.g. only for logged-in users).
type PublishedDocument ¶
type PublishedDocument = search.PublishedDocument
PublishedDocument is one keyword document as delivered to a DocumentSink.
type RecommendOptions ¶
type RecommendOptions = discovery.RecommendOptions
RecommendOptions controls Recommend (see discovery.RecommendOptions).
type ResultTrace ¶
type ResultTrace struct {
Key TraceKey `json:"key"`
Rank int `json:"rank"`
Score float32 `json:"score"`
ScoreKind ScoreKind `json:"score_kind"`
Contributions []ContributionTrace `json:"contributions"`
}
ResultTrace records one returned item and its best document's contributions.
type RetrievalBackend ¶
type RetrievalBackend string
RetrievalBackend identifies one candidate source.
const (
BackendKeyword RetrievalBackend = "keyword"
)
type Runtime ¶
type Runtime struct {
*EmbeddedHub
Content *content.Runtime
}
Runtime is the one surface a host wires: the Hub (search, typeahead, signals, discovery) plus the content module and its HTTP routes.
func NewRuntime ¶
func NewRuntime(ctx context.Context, cfg RuntimeConfig) (*Runtime, error)
NewRuntime builds the hub and the content module over the host pool.
func (*Runtime) EraseSubjects ¶
func (r *Runtime) EraseSubjects(ctx context.Context, subjects []signal.Subject) (signal.ErasureReport, error)
EraseSubjects erases every configured runtime plane: signals, interaction data and data retained by moderation/classifier providers. Current approved authored content remains under host retention policy (content.EraseSubjects). ContentKit-owned reactions, favorites, poll votes and unpublished submissions are removed atomically behind the source fence. EmbeddedHub.EraseSubjects is the explicit analytics-only lower-level API.
AuthKit ACK means durable acceptance by the host's deletion ledger, not this downstream completion. Retry while error != nil or !report.Complete(). A disabled signal plane is intentionally absent. Remaining may include pending plane markers content_plane or signal_plane when a plane could not complete; these are not estimates of retained provider rows.
func (*Runtime) Handler ¶
Handler returns the content routes (comments, reactions, favorites, polls, posts). Mount it under a prefix after the host's auth middleware.
func (*Runtime) ResyncPreferences ¶ added in v0.15.0
ResyncPreferences re-sends every exportable preference: the periodic repair for sink loss. Newer revisions still win.
func (*Runtime) SyncPreferences ¶ added in v0.15.0
SyncPreferences sends reactions and favorites changed since the last sync into the signal plane (see content.Runtime.SyncPreferences). Schedule it from the host's worker; with the signal plane disabled it returns ErrSignalPlaneDisabled.
func (*Runtime) WorkerOptions ¶
WorkerOptions returns the host's keyword worker options extended with ContentKit's own documents: posts (content.KindPost) are listed and built by the content module, every other kind by the host callbacks.
type RuntimeConfig ¶
type RuntimeConfig struct {
EmbeddedConfig
Content content.Options
}
RuntimeConfig configures one tenant's full ContentKit: the search and signal planes (EmbeddedConfig) and the interaction module (Content). Pool, tenant and schema are shared: Content.Pool, Content.Tenant and Content.Schema are filled from the hub configuration when empty. Posts join the keyword queue.
type ScoreKind ¶
type ScoreKind string
ScoreKind identifies the numeric domain of a candidate or result score.
const (
ScoreKeywordMatch ScoreKind = "keyword_match"
)
type SearchHit ¶
type SearchHit struct {
// ContentRef names the matched document's content: the work, or the
// version when the document was indexed per version.
ContentRef
// Language is the matched document's language.
Language string
// Score ranks the item by its best matching document in any searched
// language, using the keyword match tier.
Score float32
}
SearchHit is one content item, represented by its matched document.
type SearchOptions ¶
type SearchOptions struct {
Language string
// Defaults to LanguageModeExact when omitted.
LanguageMode LanguageMode
// ContentKinds selects the kinds searched. Required.
ContentKinds []string
// Limit is the page size in content items; Offset skips items. Documents
// are grouped per item before either applies.
Limit int
Offset int
// CandidateLimit is the document window requested from each retrieval
// source (per language) before grouping. It defaults to twice Offset+Limit
// (at least 100) and is clamped to at least Offset+Limit. Pass the same
// value on every page when a truncated window must stay identical.
CandidateLimit int
// Eligibility maps each document to the host's access, publication and
// version-trait rules on that one document. Without it every document of
// a work is eligible.
Eligibility *Eligibility
FilterSQL string
FilterArgs map[string]any
}
type SearchResult ¶
type SearchResult struct {
Hits []SearchHit
// HasMore is true when items follow this page in the grouped retrieval, or
// when Truncated: documents beyond the window were never ranked, so the
// next page may still be non-empty.
HasMore bool
// Truncated reports that a candidate window filled. Raise CandidateLimit
// for complete deep pagination.
Truncated bool
}
SearchResult is one page of items.
type SearchTrace ¶
type SearchTrace struct {
NormalizedQuery string `json:"normalized_query"`
RequestedLanguage string `json:"requested_language,omitempty"`
RequestedLanguageMode LanguageMode `json:"requested_language_mode,omitempty"`
Languages []string `json:"languages,omitempty"`
RequestedResultLimit int `json:"requested_result_limit"`
ResultLimit int `json:"result_limit"`
RequestedCandidateLimit int `json:"requested_candidate_limit"`
CandidateLimit int `json:"candidate_limit"`
Sources []SourceTrace `json:"sources,omitempty"`
Results []ResultTrace `json:"results,omitempty"`
EmptyReason EmptyReason `json:"empty_reason,omitempty"`
ErrorCategory string `json:"error_category,omitempty"`
}
SearchTrace contains opt-in effective configuration and retrieval provenance.
type SimilarOptions ¶
type SimilarOptions = discovery.SimilarOptions
SimilarOptions controls SimilarTo (see discovery.SimilarOptions).
type SourceStatus ¶
type SourceStatus string
SourceStatus records whether an attempted retrieval source succeeded.
const ( SourceStatusSucceeded SourceStatus = "succeeded" SourceStatusFailed SourceStatus = "failed" )
type SourceTrace ¶
type SourceTrace struct {
Backend RetrievalBackend `json:"backend"`
Language string `json:"language"`
ScoreKind ScoreKind `json:"score_kind"`
Limit int `json:"limit"`
Status SourceStatus `json:"status"`
ErrorCategory string `json:"error_category,omitempty"`
Candidates []CandidateTrace `json:"candidates,omitempty"`
}
SourceTrace records one language-specific keyword retrieval and its candidates.
type TaxonomyID ¶
type TaxonomyID = contentref.TaxonomyID
TaxonomyID identifies a generic ContentKit catalog record (tag, artist, series, creator, character, voice actor).
type TraceKey ¶
type TraceKey struct {
ContentRef
Language string `json:"language"`
}
TraceKey identifies a document in retrieval provenance.
type TypeaheadHit ¶
type TypeaheadHit struct {
ContentRef
Language string
Score float32
}
TypeaheadHit is one suggested content item and its matched document.
type TypeaheadOptions ¶
type TypeaheadOptions struct {
Language string
// Defaults to LanguageModeExact when omitted.
LanguageMode LanguageMode
ContentKinds []string
Limit int
MinSimilarity float32
FilterSQL string
FilterArgs map[string]any
// Eligibility groups suggestions per content item; see SearchOptions.
Eligibility *Eligibility
}
type UnseenOptions ¶
type UnseenOptions struct {
// ContentKind selects which catalog universe to diff against. Required.
ContentKind string
// Limit caps the returned ids (default 50). Order follows the host
// catalog's Universe order.
Limit int
// CatalogLimit is passed through to the host catalog's Universe call
// (0 = host default).
CatalogLimit int
}
UnseenOptions controls Unseen reads.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package access is the host's gating vocabulary shared by content interactions and media: the authenticated Actor, the ContentResolver port and its Resolution.
|
Package access is the host's gating vocabulary shared by content interactions and media: the authenticated Actor, the ContentResolver port and its Resolution. |
|
cmd
|
|
|
media-access
command
Command media-access is the media access worker.
|
Command media-access is the media access worker. |
|
media-worker
command
Command media-worker runs media/video encode jobs from River schema media_worker in the host database.
|
Command media-worker runs media/video encode jobs from River schema media_worker in the host database. |
|
Package content is ContentKit's interaction module: posts, comments, reactions, favorites and polls over tenant-scoped content references, stored in the host schema's content_* interaction tables.
|
Package content is ContentKit's interaction module: posts, comments, reactions, favorites and polls over tenant-scoped content references, stored in the host schema's content_* interaction tables. |
|
Package contentref defines the reference vocabulary every ContentKit package and port shares: a tenant-scoped reference to host-owned content and the identity of a generic taxonomy record.
|
Package contentref defines the reference vocabulary every ContentKit package and port shares: a tenant-scoped reference to host-owned content and the identity of a generic taxonomy record. |
|
Package discovery produces "similar to this work" and "for you" lists.
|
Package discovery produces "similar to this work" and "for you" lists. |
|
Package eval provides dependency-free golden-query evaluation, aggregate search-quality metrics, versioned reports, baseline comparison, and score-domain-safe threshold sweeps.
|
Package eval provides dependency-free golden-query evaluation, aggregate search-quality metrics, versioned reports, baseline comparison, and score-domain-safe threshold sweeps. |
|
internal
|
|
|
boundaries
Package boundaries holds a test enforcing ContentKit's package layering from the module's dependency graph (go list; no compilation or services).
|
Package boundaries holds a test enforcing ContentKit's package layering from the module's dependency graph (go list; no compilation or services). |
|
normalize
Package normalize cleans user query text before retrieval.
|
Package normalize cleans user query text before retrieval. |
|
pgtest
Package pgtest provisions disposable keyword-profile schemas on the CONTENTKIT_TEST_URL Postgres for integration tests.
|
Package pgtest provisions disposable keyword-profile schemas on the CONTENTKIT_TEST_URL Postgres for integration tests. |
|
signaltest
Package signaltest provisions disposable signal-plane ClickHouse databases for integration tests by applying the real migration lineage.
|
Package signaltest provisions disposable signal-plane ClickHouse databases for integration tests by applying the real migration lineage. |
|
Package media stores host content files in per-item folders of one private bucket: library-built keys, the generic manifest with conditional-write edits, and the Store port.
|
Package media stores host content files in per-item folders of one private bucket: library-built keys, the generic manifest with conditional-write edits, and the Store port. |
|
accessworker
Package accessworker is the media access worker's HTTP handler, run by cmd/media-access: it checks the token for a blob path (URL `?t=` or cookie `mt`), serves public/ paths without one (immutable at a current ?v= version), refuses manifests and originals/, and streams the object from the private bucket with its own read-only key.
|
Package accessworker is the media access worker's HTTP handler, run by cmd/media-access: it checks the token for a blob path (URL `?t=` or cookie `mt`), serves public/ paths without one (immutable at a current ?v= version), refuses manifests and originals/, and streams the object from the private bucket with its own read-only key. |
|
image
Package image derives WebP variants, public slots and zip downloads with libvips (CGO).
|
Package image derives WebP variants, public slots and zip downloads with libvips (CGO). |
|
internal/s3test
Package s3test opens the test bucket from the environment:
|
Package s3test opens the test bucket from the environment: |
|
internal/uploadtestserver
command
Command uploadtestserver serves media.UploadHandler over a fresh MinIO/RGW bucket for the browser SDK's integration tests (sdk/upload/test).
|
Command uploadtestserver serves media.UploadHandler over a fresh MinIO/RGW bucket for the browser SDK's integration tests (sdk/upload/test). |
|
internal/wirets
Package wirets renders the upload API wire types as TypeScript for the browser SDK (sdk/upload/src/wire.gen.ts).
|
Package wirets renders the upload API wire types as TypeScript for the browser SDK (sdk/upload/src/wire.gen.ts). |
|
layout
Package layout defines media object keys, dependency-free so the access worker can classify paths without importing the media runtime:
|
Package layout defines media object keys, dependency-free so the access worker can classify paths without importing the media runtime: |
|
s3
Package s3 implements media.Store over aws-sdk-go-v2 for Ceph RGW (production) and MinIO (tests).
|
Package s3 implements media.Store over aws-sdk-go-v2 for Ceph RGW (production) and MinIO (tests). |
|
tiered
Package tiered is an optional visibility policy: it maps an item's level to entitlement keys and asks a Checker which ones the actor holds.
|
Package tiered is an optional visibility policy: it maps an item's level to entitlement keys and asks a Checker which ones the actor holds. |
|
token
Package token signs and verifies media access tokens, shared by the host signer and the access worker so the format cannot drift:
|
Package token signs and verifies media access tokens, shared by the host signer and the access worker so the format cannot drift: |
|
video
Package video encodes an item's video files with ffmpeg into a byte-range HLS ladder (one single-file fMP4 blob per rendition and audio track), WebVTT subtitles, a thumbnail sprite and one muxed MP4 download per quality, and records them in the manifest's hls and downloads.
|
Package video encodes an item's video files with ffmpeg into a byte-range HLS ladder (one single-file fMP4 blob per rendition and audio track), WebVTT subtitles, a thumbnail sprite and one muxed MP4 download per quality, and records them in the manifest's hls and downloads. |
|
Package migrations owns ContentKit's PostgreSQL and ClickHouse baselines.
|
Package migrations owns ContentKit's PostgreSQL and ClickHouse baselines. |
|
Package popularity ranks host content by a named, bounded policy over the signal plane's canonical window metrics (docs/popularity-policy.md).
|
Package popularity ranks host content by a named, bounded policy over the signal plane's canonical window metrics (docs/popularity-policy.md). |
|
Package search is ContentKit's keyword retrieval over content_search_documents: exact names and aliases, native-script prefixes and bounded typos for every language, with the host's eligibility join applied inside every route.
|
Package search is ContentKit's keyword retrieval over content_search_documents: exact names and aliases, native-script prefixes and bounded typos for every language, with the host's eligibility join applied inside every route. |
|
Package signal implements ContentKit's signal plane: an append-only stream of host-defined interaction signals plus a durable per-(subject, content) current-state projection, both stored in ClickHouse.
|
Package signal implements ContentKit's signal plane: an append-only stream of host-defined interaction signals plus a durable per-(subject, content) current-state projection, both stored in ClickHouse. |
|
Package taxonomy is ContentKit's generic catalog: tenant-scoped nodes (tags, artists, creators, characters, series, seasons, voice actors, ...) with localized names and aliases, typed node relationships and typed assignments of host content (a work or one of its versions) to nodes.
|
Package taxonomy is ContentKit's generic catalog: tenant-scoped nodes (tags, artists, creators, characters, series, seasons, voice actors, ...) with localized names and aliases, typed node relationships and typed assignments of host content (a work or one of its versions) to nodes. |
|
Package worker maintains one tenant's keyword documents: it drains the dirty queue, runs a bounded cursor backfill and delivers every published document to the optional DocumentSink.
|
Package worker maintains one tenant's keyword documents: it drains the dirty queue, runs a bounded cursor backfill and delivers every published document to the optional DocumentSink. |