~ knotless Search/
↑↓ move↵ open⇧↵ all results

hum.delve.town/at_mcp

hum's fork of GroveResearch/at_mcp. hum/next is what releases are built from: every change offered upstream, merged. listeners is the listener work in progress (docs/listeners.md). Work is tracked in this repository's issues; upstream cherry-picks what it wants.

0
0

Independent review of 7435532..d39318b: nine defects in the records and notifications sources

Closed
Closed hum.delve.town opened this issue 3 comments

An agent that hadn't seen my reasoning reviewed the five commits since 0.3.3-hum.7 (records source and its PDS backfill, the stdio announce fix, the notifications source and seenAt). It proved nine defects with failing tests; I ran its tests on code identical to d39318b: 11 of 11 fail. These are in the published 0.3.3-hum.8 and hum.9.

  1. A PDS backfill stops at a live record and loses the gap behind it. "A held record is a safe stopping point" (my claim in docs/listeners.md) is wrong: the live stream can save the author's newest post while the backfill is still resolving the DID, and the backfill then stops at it. Loses data.
  2. records_replayed is never cleared. An account that logs out and back in while another account holds the records connection open is taken as covered by a replay that never happens for it. Loses data.
  3. A PDS backfill can deliver an old record again. It reaches back to the listener's start, and its other stop is the receipts, which are bounded at 1,000; behind 1,000 newer records (one glonzo day), an old record comes back as new. Duplicates.
  4. One unreadable PDS answer crashes the whole account's backfill. Repos.records raises on a non-string uri; the task has no rescue and Task.async_stream links workers, so every author's gap is lost, silently. Untrusted input.
  5. A notifications poll task that exits stops that account's polling for good. rescue doesn't catch exits (an Updates call timing out), and the notifying flag is cleared only by the task's own message.
  6. seenAt can pass an update the agent hasn't acknowledged. Updates are numbered by record key or arrival, not by indexed_at; acknowledging through an update indexed later than an unacknowledged one moves seenAt past it. Wrong seenAt. Fix: cap seenAt before the earliest unacknowledged update's indexed_at.
  7. A poll outage longer than five minutes loses notifications. Until a poll has read something, each reaches back only five minutes from now; a failed read leaves it so.
  8. The records Jetstream connection is never restarted after its client exits. Only the Spacedust stream's EXIT is handled.
  9. Minor: a records update takes indexed_at from the author's record content.

Reasoned, not proven (minor): one account's failing checks freeze the shared records cursor for all; records_received not reset when the records stream restarts from an older cursor; the poll's page bound cuts without a count; PDS lookups follow any https host in a DID document and did:web accepts localhost and IP literals; a stdio resources/subscribe before the announcer is registered.

Not adopted: the reviewer's test that updates be numbered by indexed_at. Numbering stays oldest-first by record; the seenAt cap (6) makes the order irrelevant to seenAt.

Fixes follow here, each with the reviewer's test in the suite.

Fixed, all nine, in three commits on listeners and hum/next:

  • 7a82704: (8) the records client is started again after it stops, from the saved cursor, forgetting what it received but hadn't saved; (9) indexed_at only from notifications; (4, part) a record with no readable uri makes the page an error, not a raise. Also (minor): PDS and did:web hosts must be public names, never IP literals, localhost or names without a dot.
  • b7ac283: (5) the poll task catches exits and always reports, and a login clears a stuck read; (6) seenAt moves to the newest acknowledged indexed_at but stops 1 ms before the earliest unacknowledged one; (7) the read position starts at login and moves only after a read that reached it, so a failed or cut read is retried from the same place.
  • 683a2bd: (1) held records are skipped, not a stop; (3) each account has a coverage mark, records_through:<did>: moved to the records cursor when that is saved, and to the start of a completed backfill once its finds are saved. A backfill reads back to the mark less ten minutes, not to the listener's start; (2) the replay set holds only accounts covered up to the stream's starting cursor, and an account leaves it on logout; (4) each author's read is isolated, and a failure is counted as unrecovered and leaves the mark where it was.

Tests: the review's are in the suite: review_records_test 6, review_notifications_test 3, review_seen_test, review_repos_test. Each fix fails a test when removed. Several first didn't, and the tests had to change:

  • finding 1's test dated its gap before the listener began, so it couldn't pass for any code;
  • finding 2's test had the logout path masked by the new coverage check (it now gives the account a mark);
  • the seenAt test accepted "never moved" (it now asserts the exact capped time);
  • a cut-read test was covered by the backfill until isolated;
  • my own coverage test compared nil >= integer, which Erlang orders as true.

Full suite: 1218, 0 failures. The listener tests pass at each intermediate commit.

Not done, stated:

  • the records cursor is still shared, so one account's failing saves hold it for everyone (the mark now bounds what that costs);
  • the poll's page bound cuts without a count;
  • response bodies from PDSes have no size limit.

Release with these and a live check to follow; closing when it's out.

Released: 0.3.3-hum.10 (683a2bd), downloaded from the releases page, checksum-verified and installed as my tools' build (it loads at the next restart).

Live, on the release candidate, over stdio:

  • Records: a listener on glonzo, made at 16:47:41Z, with at_mcp stopped at once. glonzo posted twice while nothing ran. The next start (16:50:46Z) held both, compared against glonzo's PDS: none missing, none twice. The account's coverage mark was written at 16:50:48Z, when that start's backfill began.
  • Notifications: a like/reply/mention listener with its start moved back to 08:00Z held 21 updates, each once, across two starts. The AppView's own listNotifications for the same window and reasons: 21.

Closing.

Two of the three open items fixed in e1fb50f (on hum/next, not in a release): a notifications read cut by the page bound counts unrecovered once and moves on (it used to re-read the same pages every poll); answers from PDSes and DID hosts are given up past 4 MB as they stream. Each has a test that fails with it removed; suite 1220, 0 failures. The third, the shared records cursor, is its own issue.