chadtmiller.com/group-host
atmosphere group host
A handle being typed is looked for by the host, in its own directory on a network of its own
MergedThis adds fyi.opensocial.searchActors. The host answers it either from a typeahead service or, on a network with its own directory, from that directory's /export. The console now asks the host, and its CSP is tightened to self. I read every changed file. The tests cover both modes and the docs are updated.
Two weaknesses in the plc path are worth fixing, but neither blocks the merge:
- Failed reads are cached.
directory_handlesstores whatever it read, including nothing after a failed or partial read. The directory being briefly down therefore means no suggestions for a full minute after it recovers. Consider caching only a read that got at least one page, or giving a failed read a much shorter life. - No single flight. The endpoint is open to anyone, and the browser asks on every keystroke. When the cache is stale, every concurrent request starts its own sequential read of up to 50 pages. Holding an async lock across the refresh, or sharing one in-flight read, would make this one fetch per minute.
crates/group-host/src/actor_search.rsline 83Outdated
.filter_map(|(d, h)| Some((d, h?))) | |
.collect(); | |
let handles = Arc::new(handles); | |
*self.handles.0.lock().expect("not poisoned") = Some((Instant::now(), handles.clone())); |
This stores the result even when no page could be read, so an outage is remembered for KEPT_FOR. It also lets concurrent callers each repeat the whole export read. Consider not caching an empty failed read, and sharing one refresh among callers.
Both done in 9597a3c. The cache is a tokio Mutex held across the refresh, so callers at once wait for one read (test: eight searches at once make exactly one read of the export, and a search after makes none). A read that never reached the directory is not kept, so the next search tries again.
Both points from my last review are fixed in 9597a3c. I read only actor_search.rs this round. I did not re-read the tests, though the author reports one for the single read.
- Single flight:
Handlesis now atokio::sync::Mutexheld across the refresh indirectory_handles. Concurrent callers wait on the lock, then find the fresh cache and return it. - Failed reads: the cache is only written when
reachedis true, so a request that never reached the directory is retried on the next search.
One small gap remains, and it does not block the merge. A directory that answers with an error body or garbage still counts as reached, so that empty result is cached for a minute. Setting reached only when at least one line parsed would close this.
What changes
The host finds a handle being typed (
GET fyi.opensocial.searchActors?q=&limit=, anyone may ask). Where it looks is a new setting,ACTOR_SEARCH:tech.waow.typeahead.searchActors: typeahead.waow.tech by default whenPLC_URLishttps://plc.directory, asked by the host with what was typed, its answer passed on (DID, handle, name, picture; ahandle.invalidor an account with no DID left out);plc, the default for any other directory: the handles its/exportnames, read a page at a time (at most 50) and kept a minute, the last operation of each DID deciding, a tombstone or a nullified operation naming none. A handle beginning with what was typed comes first, then one holding it, shortest first.Under two letters, or when the host cannot look, it answers none.
The console's handle fields ask the host (
web/src/lib/typeahead.ts), and its content security policy lets its scripts reach no server but the host. What is typed no longer goes from each browser to typeahead.waow.tech.So the next network (its own directory at plc.next.opensocial.fyi) suggests its own accounts when signing in, inviting or labelling, by handle alone, as a directory has no names or pictures.
Why
On next.opensocial.fyi, whose accounts are in a directory of its own, the typeahead suggested no one: typeahead.waow.tech only knows the real network.
How it was checked
crates/group-host/tests/actor_search.rs: the test directory now serves/exporttwo operations a page, so the host reads on to an empty page; groups found by the start and then the middle of their handle, an ended group (tombstoned) left out,@and capitals let go,limit, under two letters, the minute's cache, an unreachable directory; and a fake typeahead service, its answer filtered and passed on,qandlimitforwarded, and one unreachable.tests/config.rs:ACTOR_SEARCH's defaults and refusal. The e2e stub for the typeahead now stands in for the host's method.Shortcomings
/exportis read whole (up to 50 pages) each minute someone types; fine for a network of its own, not meant for plc.directory, which keeps the service.🤖 Generated with Claude Code