Recompute a ranking from a refresh message (Step 4 of #386) - #496
Open
zipdoki wants to merge 2 commits into
Open
Recompute a ranking from a refresh message (Step 4 of #386)#496zipdoki wants to merge 2 commits into
zipdoki wants to merge 2 commits into
Conversation
zipdoki
force-pushed
the
feat/topk-sweep
branch
from
August 19, 2026 08:18
efbd0b3 to
a4df80d
Compare
The sweep design moved from an _expire table scanned by expiredAt to a refresh queue, and these three payloads never got wired to anything. AggregationExpireItemRequest has no references at all, and AggregationExpireResult is only read by AggregationsExpireResponse.from, which nothing calls. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
zipdoki
force-pushed
the
feat/topk-sweep
branch
from
August 20, 2026 02:16
a4df80d to
376049b
Compare
This was referenced Aug 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The previous PR schedules a refresh for the instant a bucket leaves the sliding window, but nothing consumes it. A windowed ranking goes stale the moment its oldest bucket ages out, and stays stale. This consumes the refresh.
POST /aggregations/v1/sweeptakes refresh messages and recomputes the ranking row each one names:{ "items": [ { "type": "TOPK", "item": { "database": "graph", "table": "likes", "topk": "daily_likes", "source": "...", "target": "...", "direction": "OUT", "entity": "...", "topkDimensionValue": "...", "dimensionValues": "", "ranges": "", "properties": {}, "refreshAt": 1755500000000 } } ] }{ "items": [ { "database": "graph", "table": "likes", "topk": "daily_likes", "entity": "...", "status": "OK", "error": null } ] }SweepItemresolvesitempolymorphically offtypethrough Jackson'sEXTERNAL_PROPERTY, so a second aggregation kind adds aSweepItemPayloadsubtype and aJsonSubTypesentry rather than a second endpoint.AggregationHandlergainssweep, andAggregationServicedispatches byAggregationTypeinstead of fanning out toevery handler the way
aggregatedoes — a refresh message already knows which kind it belongs to.TopkSweepItemcarries exactly whatrefreshKeyencodes, plusrefreshAt, so the consumer can rebuild the ranking without reading the queue row back.Sweep is a write path and is rejected under read-only mode, alongside
POST /aggregations/v1/aggregate.Stacked on #494 — that needs to land first.
Part of #386.
Test plan
./gradlew :engine:test --tests '*TopkAggregationHandlerTest*'— recompute from a refresh message, including the rank row rewrite./gradlew :engine:test --tests '*AggregationServiceTest*'— dispatch to the handler named byAggregationType./gradlew :server:test --tests '*MetadataAggControllerE2ETest*'—POST /aggregations/v1/sweepover HTTP, per-item status and error./gradlew :server:test --tests '*ReadOnlyRequestFilterTest*'— sweep is blocked in read-only mode./gradlew spotlessKotlinCheck build— formatting and full buildAI Assistance