Repository navigation
feat: serve Vote and Subscription - #26
Open
mattdjenkinson wants to merge 1 commit into
Open
mattdjenkinson wants to merge 1 commit into
mattdjenkinson wants to merge 1 commit into
Conversation
Votes and subscriptions belong to a user and are named after the post, so there is one of each per user per post. Staff list everyone's in the platform context, with the owner in a read-only annotation the store sets. - Voting needs a verified email (Milo's emailVerified claim, matched case-insensitively because aggregated APIs get extras through headers) and a visible, unmerged post. - A vote subscribes the voter and recomputes the post's votes in the same transaction. Votes record the voter's organizations and linked GitHub username from Milo, best effort. - votes.total subtracts voters whose linked GitHub username is among the thumbs-up reactions sync reports; trendingScore is the 7-day half-life sum over votes and timed reactions. Both are recomputed on every vote and post write, and trending hourly. - When sync sets status.mergedInto, votes and subscriptions move to the target post. - New fields: PostVotes.linked and githubReactions, PostStatus.mergedInto, VoteStatus.githubLogin. - --milo-kubeconfig replaces --search-kubeconfig and is also used for the voter lookups. Part of datum-cloud/enhancements#943. Closes #7.
This was referenced Nov 12, 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.
Serves
VoteandSubscription. Closes #7.Stacked on #25 (PostQuery), which is on #23, #22 and #16. GitHub retargets it as those merge.
What it does
feedback.miloapis.com/ownerannotation on user-owned objects so staff can see whose is whose;kubectl get votes -o wideshows it. It is never stored and clients can't set it.iam.miloapis.com/emailVerifiedclaim Milo puts on human identities. As in Milo's admission plugin, identities without the claim pass.reason: voted) unless they already follow the post;votesand bumps its resourceVersion;reason: manual; the other reasons are set by the server.OrganizationMembershipbyspec.userRef.name) and the linked GitHub username (UserIdentitybystatus.userUID) come from Milo through--milo-kubeconfig. They're best effort with a 3s timeout: if Milo can't answer, the vote is still recorded. Neither is public.votes.linkedcounts voters whose linked GitHub username is among the 👍 reactions sync reports in the newvotes.githubReactions, andtotal = datum + github - linked. This follows the product decision that matching is by login only.linkednever exceeds the reaction count, in case the list lags the count.Σ 0.5^(age_days / 7)over votes and 👍 reactions that have a time, counting linked people once. It's recomputed on every vote and post write and refreshed hourly as votes age, rounded so the hourly refresh doesn't rewrite posts for float noise.status.mergedInto, the post's votes and subscriptions move to the target. A user with both keeps the target's, and both posts are re-tallied, all in the same transaction.API changes
status.votes.linked(server-owned);status.votes.githubReactions(sync-owned,loginandat);status.mergedInto(sync-owned, validated as a post name other than itself).status.githubLogin.--milo-kubeconfigreplaces--search-kubeconfigfrom feat: serve PostQuery #25, since search and the voter lookups both talk to Milo.Bug found while testing
Aggregated APIs receive user extras as request headers, and the apiserver lowercases their keys (
headerrequest/requestheader.go). So the claim arrives asiam.miloapis.com/emailverified, and an exact-match lookup let unverified users vote. The kind run caught this, and a test now covers the lowercase key. Theparent-typeandparent-namekeys are already lowercase, so they're unaffected.Not in this PR
mergedInto: sync isn't built yet. It needs to send 👍 reactors with times when the count changes, and setmergedIntowhen an issue is closed as a duplicate of a tracked one.showPublicVotes): not part of Vote and Subscription #7.Testing
votedsubscription;-o wideshows owners;