Documentation
¶
Overview ¶
Package popularity ranks works by their event-time eligible-population participation over immutable access intervals, weighted by bounded quality (docs/popularity-policy.md):
rank = rate + we·engage + wf·finish + wa·approve + wr·revisit
where every term is the duration-weighted mean over a work's intervals of its smoothed participation rate times the interval's smoothed quality term.
Index ¶
Constants ¶
const DefaultPeriod = "30d"
DefaultPeriod is the window a listing gets when it names none.
Variables ¶
var Periods = []string{"7d", "30d", "90d", "365d", "all"}
Periods are the only public popularity windows: literal whole-UTC-day windows with equal weight inside, "all" unbounded.
var PolicyV2 = Policy{ Weights: Weights{Engagement: 0.35, Completion: 0.25, Approval: 0.40, Revisit: 0.10}, Priors: Priors{ Engagement: 0.40, EngagementWeight: 10, Completion: 0.30, CompletionWeight: 10, Approval: 0.75, ApprovalWeight: 5, RevisitWeight: 10, }, }
PolicyV2 normalizes each historical access interval by its active eligible population. Its twenty pseudo-eligible nonreaders are a modest reliability heuristic, not a statistical confidence interval.
Functions ¶
func Rank ¶ added in v0.128.6
func Rank(ctx context.Context, source Source, availability AvailabilityProvider, kind string, window signal.Window, scope signal.ActivityScope, limit int) ([]string, error)
Rank returns up to limit works of kind with qualified readers in window, best first. Without trusted audience history it returns none: missing lineage never becomes unnormalized reach.
Types ¶
type AvailabilityProvider ¶ added in v0.98.0
type AvailabilityProvider interface {
Availability(ctx context.Context, kind string, window signal.Window, scope signal.ActivityScope, contents []string) (signal.Availability, error)
}
AvailabilityProvider supplies immutable publication and access history for a common covered portion of a requested activity window, for the given contents of the kind.
type Priors ¶
type Priors struct {
Engagement float64
EngagementWeight float64
Completion float64
CompletionWeight float64
Approval float64
ApprovalWeight float64
RevisitWeight float64
}
Priors smooth each term with pseudo-observations: a prior mean in [0, 1] and its weight (>= 1) in pseudo-readers or pseudo-votes.
type Source ¶
type Source interface {
Popular(ctx context.Context, contentKind string, opts signal.PopularOptions) ([]signal.PopularHit, error)
// ReadContent lists the works of kind read in window.
ReadContent(ctx context.Context, kind string, window signal.Window) ([]string, error)
// PopulationCoverage is when trusted audience observations start for scope.
PopulationCoverage(ctx context.Context, kind string, scope signal.ActivityScope, window signal.Window) (time.Time, bool, error)
}
Source is one tenant's signal plane; the engine's hub satisfies it.