handoff 2026-08-06 — stale upstream_status after migration: fixed, sweep ready
for the operator, re: the coverage-gap investigation (zlay 98.7% vs 99.1%,
~70% of misses on migration-destination PDSes). your diagnosis was right:
migrated accounts stuck with upstream_status='deactivated' while active
on their PDS. root cause confirmed at code level, fix on branch, recovery
sweep script included.
root cause (one-shot event loss, no recovery path)
during a migration the old PDS's #account deactivation is recorded
(legitimately — the stored host still matches, so no authority check runs).
the new PDS then emits #account active=true exactly once. that event
carries a host change, which triggers the synchronous DID-doc host-authority
check — and if it rejects (PLC propagation lag, a transient resolver
failure, or the 60s negative rejection cache primed by an earlier racing
event), the event is dropped wholesale and nothing ever retries it.
subsequent commits from the new host do eventually pass authority and fix
the host pointer, but each is then dropped by the inactive-account check
(status AND upstream_status both required). permanent mute — the exact
db state you found: correct host, status='active',
upstream_status='deactivated'.
reviewed indigo's relay and hydrant before fixing. indigo has the same
event-loss window but never gets stuck: its EnsureAccountActive re-checks
getRepoStatus against the PDS whenever a commit arrives for an
upstream-inactive account. that lazy re-check is the mechanism zlay had
removed (the old TODO in frame_worker.zig). the key property that makes it
cheap: a PDS does not emit repo events for accounts inactive on it, so a
commit from the account's own confirmed host contradicting our record is
itself strong evidence the record is stale — the check almost only fires
when it should.
the fix
fix: recover accounts muted by stale upstream account status
- StatusChecker (
src/internal/status_checker.zig) — background worker (indigo's EnsureAccountActive, but queued off the frame workers). when a commit/sync from the account's own host is dropped withstatus='active'butupstream_status!='active', the account is queued; the worker asks the PDS viacom.atproto.sync.getRepoStatusand stores the answer. per-uid 60s rate limit, 4096-deep queue, SSRF-guarded, local takedowns never re-checked. #accountevents bypass the negative host-authority cache — they are rare and one-shot; a cached rejection from an event racing PLC propagation must not swallow a migration's activation. (indigo/hydrant instead purge their DID-doc caches and re-resolve on mismatch; zlay resolves fresh every time, so the negative cache was our only stale layer.)
regression tests: status mapping vs the real getRepoStatus response shape, queue dedup/rate-limit mechanics, and the local-vs-upstream activity split. full suite passes.
expected signals after deploy
status check worker startedat boot.stale upstream status corrected: uid=... did=... host=... -> activeat info level — that's the fix working. each such account resumes flowing from its next commit (~one event lost per recovery, same as indigo's behavior).- coverage on eurosky/blacksky/northsky should start climbing organically as stuck accounts post.
the recovery sweep (run once, after the fix is deployed)
the fix only heals accounts that commit; the long tail of quiet stuck
accounts needs the one-time sweep. scripts/sweep_stale_upstream.py:
DATABASE_URL=postgres://... uv run scripts/sweep_stale_upstream.py # dry run
DATABASE_URL=postgres://... uv run scripts/sweep_stale_upstream.py --apply # write
it resolves each candidate's current PDS from plc.directory (the db host pointer is itself stale for accounts that never committed since migrating — don't trust it), probes getRepoStatus there, and only writes what the PDS reports. genuinely deactivated accounts (your 12/12 mushroom control) are confirmed and left alone. dry-run first and eyeball the would-fix lines; safe to re-run. ~2.4k+ candidates × 2 small HTTP GETs, 50ms pacing — minutes, negligible bandwidth.
host pointers are deliberately left alone: once unmuted, an account's next commit migrates its pointer through the normal authority path.
deploy
normal flow: just zlay publish-remote ReleaseSafe <ref> zio with a ref
at or past the fix commit.
still open
- the collection index entries removed at deactivation repopulate lazily from new commits, not at recovery time. acceptable; noting it.
- consumer connect/disconnect logs still lack remote addr + cursor (carried over from the OOM handoff).