Pre-release review — 2026-08-20 #
Audit of the codebase before the soft release (tangled push + mini-PC deploy). Three sections: security, effectivity, user workflow. Ordered by severity within each section. Items marked (verified) were reproduced against the actual venv, not just read.
Release-blocking: security 1 and 4; effectivity 1 and 3 (the deployed product looks broken without them); effectivity 2 silently shrinks every topic region. The rest survives a soft launch with friends.
Status 2026-08-20 (post-soft-release prep): all release-blocking items are fixed and the processes restarted on the new code. Marked ✅ done below. The rest remain open.
Security #
-
The proxy publicly exposes the sidecar's admin routes.
auth/proxy.py:49forwards all of/oauth/*to the sidecar, which serves unauthenticated (auth/oauth/server.mjs:181-189):GET /oauth/sessions— enumerates every logged-in user's DIDGET /oauth/logout?did=X— anyone on the internet can revoke anyone's atproto OAuth session (it callssession.signOut())
Login and callback already go through the proxy's own
ask_sidecar, so this forwarding serves no purpose. Deleting"/oauth": SIDECARfromUPSTREAMcloses both holes and breaks nothing.✅ done —
"/oauth": SIDECARremoved fromUPSTREAM(auth/proxy.py:49). The sidecar is now only reached viaask_sidecar(login, callback, client metadata, jwks);/oauth/sessionsand/oauth/logoutare off the tunnel. -
Unbounded cost/abuse surface on
/api/request. Any logged-in user can create unlimited topics (app/server.py:437). Each topic costs GreenPT calls forever (exemplars + harvest + ~60 fit judgments per pass, re-run every housekeeping round). No per-user cap, no rate limit, no server-side length cap (maxlength=300on the input is client-only). Add a per-DID topic cap and a server-side text cap.Follow-up — roles, topic verification, and rate limits (design, not yet built). Add a global rate limit for new users (one topic). When a new user requests a topic it should not appear in the main feed until it is verified by a member (currently just the admin). Once a topic is verified the per-user rate limit lifts. Keep a global rate limit as a safety net. From a technical standpoint we need:
- role assignment on users — admin, member, verified user, new user;
- a verification flag/step on topics;
- rate limits set per role. A verified user's topics flow into the feed immediately; a new user's topic is queued behind member verification.
-
SQL-style injection in LanceDB
whereclauses.feed/store.pybuilds filters with f-strings (_getL237,fitted_urisL711,vote_countsL783,delete_topicL550-552) over user-controlledrkey/uri(/api/topic/<rkey>is URL-decoded). Today's impact is low — the data is public, and the destructivedelete_topicis accidentally gated byrecords.deletefailing on a malformed rkey first — but that is luck, not design. One helper that doubles single quotes fixes the whole class. -
systemd units run everything as root (
deploy/*.service— noUser=). The proxy is internet-facing via the tunnel. Add a dedicated user plusProtectSystem=strict,ProtectHome=true,ReadWritePaths=/opt/aligned.click/private. Also:install.shneedssystemctl daemon-reloadafter copying units;.envis mode 664 (containsGREENPT_API_KEYand the app password —chmod 600);save_sessions(proxy.py:146) writes non-atomically with default perms — the sidecar's ownstore.mjsshows the pattern (0600 + tmp+rename), copy it.✅ done — all five
deploy/*.serviceunits now runUser=aligned/Group=alignedwithProtectSystem=strict,ProtectHome=true,ReadWritePaths=/opt/aligned.click/private.install.shcreates thealigneduser,chmod 600+chowns.env, ownsprivate/, and runssystemctl daemon-reload.save_sessionsnow writes atomically with 0600 (tmp + rename), matchingstore.mjs. Note: the currently-running dev processes are still manual (no systemd units active) — these only take effect wheninstall.shruns on the mini-PC. Fix on re-review: the sidecar's store dir defaulted toauth/private/oauth— outsideReadWritePaths, so every login write would have failed under the new unit.aligned-oauth.servicenow setsOAUTH_STORE_DIR=/opt/aligned.click/private/oauth(the sidecar creates the dir itself asalignedon first boot). -
Smaller items.
- Proxy sessions never expire server-side; the 30-day TTL is only a cookie hint.
app/server.py:111body()reads unbounded/negativeContent-Length; a negative value makesrfile.read()block until close (thread-exhaustion DoS).feedgen/server.py:95-96—int()onlimit/cursorraises on garbage input, killing the handler thread.- A topic whose criteria text is itself a prompt injection ("score
everything 10") pollutes the union feed for everyone. The feedgen has
MIN_GRADE=6as a backstop, but the app's main feed has no default grade floor.
Effectivity #
-
The worker's event loop is blocked by synchronous I/O, and housekeeping starves.
_handle_frame(ingest/worker.py:269) isasyncbut calls blockingembed(),store.add_posts,touch_keyword, andtopics.pass_post(LLM calls with 120s timeouts) directly on the event loop — while one post is judged, nothing is received, and Jetstream disconnects slow consumers. Worse:run_once(worker.py:305) only returns after 5 seconds of total silence, which never happens on the full post firehose — so themain_loopnever iterates, and housekeeping (topic processing, backfill, sweeps) and the 2-minute keyword-filter refresh only run when the connection happens to drop. A new topic's keywords may never reach the firehose filter while connected. Fix: wrap blocking work inasyncio.to_thread, and boundrun_onceby wall-clock (e.g. return after 60s) instead of by silence.✅ done — the blocking per-frame work (embed, store writes, LLM judge) now runs off the event loop via
asyncio.to_thread(_process_frame_sync), andrun_onceis bounded by wall-clock (RUN_DURATION60s,ONCE_DURATION15s for--once) instead of 5s of silence, so housekeeping and the keyword-filter refresh run on schedule. -
LanceDB vector searches silently cap at 10 results (verified on lancedb 0.33.0).
posts_within,posts_within_exemplars(store.py:626) andtopics_near_exemplars(store.py:645) call.search(vec)without.limit()— the default is 10. Consequences:pass_topiconly ever sees the 10 nearest pool posts per exemplar (~60 max); once those are judged,assignment_existsfilters them and the pass returns 0 forever — the rest of a region is never judged from the pool side.pass_postonly considers the 10 nearest exemplars globally; as topics multiply, posts silently stop being checked against regions they fall in.
Fix: explicit generous
.limit()(e.g. 1000) before the distance filter.✅ done —
posts_within,posts_within_exemplars,topics_near_exemplarsandtopics_nearnow pullVECTOR_SEARCH_LIMIT(1000, env-tunable) before the distance filter.pass_topicalso pulls a generous pool (max(limit*10, 1000)) and filters already-judged, so a region is exhausted from the pool side instead of returning 0 once the first batch is judged. -
Stale table handles (verified). A cached
_tableshandle does not see another process's writes;checkout_latest()fixes it. The app and feedgen will serve frozen data in production until restarted — the worker writes constantly. Cheap fix: clear_tables(orcheckout_latest()each table) on a short timer, or per request.✅ done —
_table()clears its cache on a shortSTORE_TABLE_TTL(15s, env-tunable) timer, so the nextopen_tablere-reads the latest version instead of serving frozen data until restart. -
/api/topicsis N full-table scans, polled every 3s per open tab.app/server.py:211callsstore.fitted_uris(topic=rkey)per topic — each scans the entire assignments table. One scan grouped by topic replaces all of it. -
main_feedrecomputes the world per request (two full assignment scans + a gianturi IN (...)+ votes scan), andfeedgen/skeletoncalls it on every appview poll. A 30–60s TTL cache makes the feedgen nearly free and the app snappy. -
One bad post kills a whole judge batch — contradicting the repo's own convention ("a flaky provider must not kill a whole pass").
fit.quality_check(feed/fit.py:80) callsfuture.result()bare; oneClassifyErroraborts the batch and discards the 39 completed verdicts — nothing is assigned. Same inquality.py. Catch per future and skip failures. Notecompletion_tolerantdoes not retry — it only records a hint. -
Hot-path store writes are heavy.
touch_keyword(per keyword hit per firehose post) reads the row and merge-rewrites it including the 2560-dim vector;add_postsdoes a per-row existence query before merging. Debouncelast_seenupdates (dirty-set flushed once a minute) and batch the existence check into oneuri IN (...)query. -
Serial LLM chains in backfill.
backfill_oncecallspass_postper post, which judges one post against up to 5 topics sequentially — hundreds of serial round-trips per run. Collect candidates per topic and batch them throughquality_check(which is already parallel). -
The app runs the topic sweep unconditionally (
app/server.py:517). AGENTS.md says production leaves it to the worker, but the code always runssweep_unprocessed— the per-topic locks infeed/topics.pydon't cross processes, so app and worker can double-process a topic (double LLM cost, LanceDB commit races). Gate it behind an env flag. -
_annotate_engagementdoes two serial sidecar→PDS round-trips per feed request per logged-in user, and only sees the first 100 likes/reposts (older likes render dark). Parallelize the two calls.
User workflow #
-
The ask box eats pastes.
guardPrefix(app/index.html:231) assumes the value started with the prefix; on select-all + paste it rebuilds asBASE + pasted.slice(30), deleting typical pasted input entirely. People will paste a wish. Fix: if the prefix is gone, append the whole current value instead of slicing it. -
"add topic" is enabled with only the prefix typed (
updateAuth, L259 —Q.value.trim()is never empty since the prefix is always present), so a click yields a server 400. Enable only whenQ.value.slice(PRE).trim()is non-empty. Relatedly, for logged-out users the button is just dead with no hint why; the Enter-key path does show the "log in" error, so mouse users are the ones left guessing. -
There is no way to un-+1 anything — including a topic. The +1 buttons (posts, and the topic itself in topic view) only ever create vote records; clicking ✓ again writes a duplicate record to the user's repo. For a topic this is worse than a wasted record: the
likedflag is what groups it under "feeds you like" in the pane, so a +1'd topic is pinned there forever with no way to remove it. Meanwhile the ♥/↻ buttons right next to it toggle on/off, teaching the user the wrong lesson. The retract machinery already exists —_my_record(app/server.py:391) does the listRecords lookup for engage; reuse it for votes, and letDELETE-ish toggling remove the vote record and thevotesrow. -
Topic deletion has no confirmation, and it is doubly destructive (store rows + the atproto record). One misclick in the ⋯ menu and it is gone.
-
The pane re-renders every 3 seconds (
setInterval(loadPane, 3000)), which (a) closes an open ⋯ menu before you can reach "delete", and (b) leaks onedocument-level click listener per render (L528 is insiderenderPane) — thousands per hour. Bind the document listener once; skip re-render when nothing changed or when a menu is open. -
Stale login state.
mecomes fromlocalStorageand is trusted over the server (init only calls/api/mewhen localStorage is empty). After a server-side session loss the UI shows you logged in and every write 401s. Clearaligned_meon any 401 and re-check/api/me. -
Minor.
- Pane polling continues in hidden tabs (
document.visibilitychange). hasMoreshows "…" once too often when the remainder is exactly one page.- A failed
start_topicafter the record write returns a 400 even though the topic will appear later via the sweep — say "queued" instead of failing, or the user retries and creates a duplicate. - The handle cache in
identity.pynever refreshes — a renamed handle shows the old one until restart.
- Pane polling continues in hidden tabs (
Also shipped 2026-08-20 #
- Mobile mode (
app/index.html). On screens ≤720px the left pane becomes an off-canvas slide-in overlay, hidden by default; a floating chevron button (❯) opens it and (❮) closes it. Selecting a topic or the brand auto-closes it; resizing back to desktop resets the overlay. The toggle is hidden on wide screens.
Planned: a dev/admin site (not yet built) #
A small admin product, separate from the customer-facing feed, for running and
inspecting the pool by hand. This is the natural consumer of private/progress.json
(AGENTS.md already notes a future admin site can poll it). Draft scope:
- Add keywords by hand —
POSTa term (or a few) → runsfeed.keywords.index_keywords([term], provenance="admin"), which embeds the term, searches its recent posts, and pools them. Retrieval-only: keywords never decide membership, so this is safe for an admin surface. - See keyword statistics — per keyword: status (candidate/indexed/
disqualified/pruned),
post_count,last_seen,last_indexed,provenance. Spot a gap (e.g. a topic concept that never got a keyword) and fix it by hand. - See exemplars — every topic's exemplar posts (the region anchors) with their embeddings/score context, so an operator can judge whether a region landed where real posts live.
- See topic processing state — poll
store.progress_for(rkey)so a processing pass is watchable live. - Own identity, no allowlist — a real atproto login through the auth
sidecar like everything else; gate writes (add-keyword) to
ADMIN_DID, keep reads open to the operator.
Deliberately not in scope: mutating grades, assignments, or votes — those stay owned by their writer activities (judge, worker). The admin site reads the store and adds retrieval keywords only.
Open question (unresolved): whether it is a new admin/ module that binds
loopback and is routed by the existing proxy, or a separate process on its own
port. The repo's current stance — "the proxy is the only exposed surface" —
argues for routing it through the proxy under an /admin path.