Repository navigation
Conversation
GitHub keeps the reason of a thread at mention after the first mention, so every later notification of that thread says mention. The record of a mention thread now says whether the update itself mentions the account (metadata mention: new or old). The description and the comments are checked against GitHub's mention events of the thread, a pull request's reviews and inline review comments by their text, both since the thread's previous update. The record's comments are listed with since. The listing of one thread's comments takes no sort order, so the "recent" comments of a record were the ten oldest of the thread. The login is read from gh in every run that needs it and never kept between runs, in the events source too.
|
Nerve PR review · ✅ Ready to merge Updated for da64ff7: this commit fixes the earlier blocking point. Before, a Overall this is a useful, well-bounded change: Completeness: tests cover both the run/read interleaving and storage. One test drives two source runs between two inbox reads through Checked: full suite in an offline sandbox at |
Storage keeps one record per thread and replaces it when the thread moves, and the source runs more often than the inbox is read. A record that said new could be replaced by one that said old before any reader saw it, and the mention then never reached the reader as one. What is new is now counted from the last record of the thread that every live consumer of the source has read. The source gets that read state from storage once per run.
What
The record of a GitHub notification with reason
mentionnow says whether the update itself mentions the account.mention: newin the metadata: something posted since the readers of the inbox last read a record of the thread mentions the account. Withmention_at, and withmention_byandmention_urlwhen the source read the text. The text is quoted in the content under--- Mention ---.mention: old: nothing new mentions the account, and an earlier mention (mention_at) explains GitHub's reason. The summary line ends with(update, no new mention)instead of(mention).mentionkey: not known. The record is what it was before this change.reasonstaysmentionin all three cases, soallow_reasonsanddeny_reasonswork as before.Why
GitHub's
reasonbelongs to the thread, not to the update. Its REST documentation says: "The reason remains as mention, regardless of whether you're ever mentioned again." So one mention makes every later comment on that thread arrive asmention, for months.A reader of the inbox could not tell the difference. The summary line and the metadata said
mention, and the content is condensed for long records, so the comment behind the update was usually not in it.Measured on one account over two weeks: 19 threads arrived with reason
mention. In 18 of them the latest update did not mention the account; the mentions that set the reason were from hours to months old.How
For an issue or a pull request with reason
mention, the source reads what was posted since the readers of the inbox last read a record of the thread.@loginoutside Markdown codeThe two differ because GitHub writes no mention event for a mention in a review or in an inline review comment, though it notifies. Measured on live threads: 30 of 30 mentions in comments had a mention event, and 0 of 6 mentions in reviews and inline review comments had one. Where timed (29 mentions), the event came 1 to 3 seconds after the text. The events also date a mention that an edit added.
Evidence only. A record is marked
oldonly when every read succeeded and an earlier mention of the account was found. If the login cannot be read, a read fails, or no mention is found at all, the record keeps GitHub'smentionunchanged. A failed read cannot hide a mention.The login is the account
ghacts as. It is read in every run that has such a thread and never kept between runs, so another account, or a renamed one, is used from the next run on. The GitHub events source kept its looked-up login for the life of the process; it now reads it in every run too and falls back to the last answer when a read fails.New until read. Storage keeps one record per thread and replaces it when the thread moves, and the source runs more often than the inbox is read (by default every 15 minutes against every 30). A record that says
newcan therefore be replaced before any reader saw it. So "new" is counted from the last record of the thread that every live consumer of the source has read: the record that replaces an unreadnewstill saysnew, with the mention text, and a record saysoldonly after a reader has read the mention. A consumer that stopped reading counts until its cursor expires (2 days by default); until then a mention can benewagain in later records of the thread, with the samemention_at.The source gets the read state from storage (
unread_source_message_metadata, one query per run). Where each look at a thread ended is remembered in the process (the latest 2048 threads). A thread listed again with the sameupdated_atis checked from the same moment as the first time, so its record comes out identical and storage skips it. After a restart, a thread is checked for the time since the sync cursor, and no later than a mention that an unread record says isnew.Also fixed
The "recent comments" of a record were the ten oldest comments of the thread. The listing of one thread's comments takes no sort order:
sort=created&direction=descis ignored there and the oldest come first. The source now lists the comments withsince, from the last record that the readers have read, and shows the human ones newest first under--- New Comments ---.Not changed
team_mention, and subjects other than issues and pull requests, are not checked.mention.Tests
tests/test_github_source_mentions.py(71 cases): new, old and unknown answers; reviews and inline comments; failed reads; paging of the mention events and of the comments; the same update listed twice; a mention that stays new until a reader has read it, also through the source runner and storage (two source runs between two reads of the inbox); the read state in storage; the login read per run and a change of account; the events source.The existing GitHub source and source runner tests pass unchanged.
Also run read-only against a live account: of five threads listed with reason
mention, the one whose latest update mentioned the account came outnewwith its author and link, and the other four came outoldwith the date of their last mention. A second run from the same cursor produced identical records.