Skip to content

[improvement] Weighted indexer - #37

Merged
ajatix merged 2 commits into
mainfrom
weighted-indexer
Jul 19, 2026
Merged

ajatix merged 2 commits into
mainfrom
weighted-indexer

Conversation

@ajatix

@ajatix ajatix commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

No description provided.

ajatix and others added 2 commits July 19, 2026 06:52
Ranks search results by how often each resource is deliberately opened,
so frequently consulted resources surface above equally relevant ones.

UsageService counts views recorded by QueryService.describe -- opening a
resource, never a search impression, which would boost whatever already
ranked highly and is self-fulfilling. Counts live in cortex://usage, a
reserved named graph beside cortex://provenance, so nothing here writes
to the default graph and the review rule still holds.

Views buffer in memory and flush in batches: TDB2 admits a single writer,
so a write transaction per view would serialize the read path against
ingestion. The Spring bean flushes on shutdown via destroyMethod.

Only unflushed deltas are held in memory, never totals. Restore replaces
the whole assertions dataset during context refresh, so a total cached at
construction would be written back over the restored counts at the next
flush -- silently, and only on replicas that restore. The current value is
re-read inside the flush transaction, making the update a true increment.

The weight saturates and is bounded at 2x. Raw counts would let one hot
resource swamp textual relevance, and since boosted results are seen and
so viewed more often, an unbounded weight compounds into a rich-get-richer
loop that new resources cannot break into. Re-ranking runs over the whole
candidate set rather than a truncated head, so a popular resource low in
the candidates can still be promoted.

UsageService is wired into QueryService rather than added as a role, so
Cortex remains nine roles and JenaCortex eleven services. Both assembly
paths construct it.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Search ranking weights each resource by how often it is opened. Without
decay a resource popular a year ago outranks a newer one indefinitely, so
a view's contribution now halves every cortex.search.viewHalfLife
(default 30d; 0 disables decay and restores plain lifetime counting).

cortex:viewCount is therefore no longer a tally but a decayed score,
meaningless without the cortex:viewCountUpdated instant beside it. Storing
a timestamped event per view would grow without bound, so each resource
keeps one score plus when it was last recomputed, and the discount is
computed from that. Changing the half-life takes effect immediately, with
no stored history to migrate.

The discount is applied on read as well as on write. Applying it only on
write would leave a resource nobody has opened since holding a stale score
until the moment someone opened it again -- exactly backwards. A missing
timestamp means "current" rather than the epoch, so counts written before
decay existed are not silently wiped on first read.

CortexBuilder.DEFAULT_VIEW_HALF_LIFE and the property default must stay
equal; the two assembly paths are required to produce identical graphs.

Also replaces the note-pad search fixtures' previous naming, which had
leaked domain vocabulary into the test corpus and the published docs, and
documents the ranking model in README, CLAUDE.md, and the site. The site
states plainly that this is a query-independent ranking prior and not
Hebbian learning: each resource carries its own score, and nothing
strengthens a connection between two resources.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@ajatix
ajatix merged commit 74f58a4 into main Jul 19, 2026
3 checks passed
@ajatix
ajatix deleted the weighted-indexer branch July 19, 2026 00:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant