Archilyzer · Source

archilyzer

Archilyzer
git clone https://archilyzer.pages.dev/source/archilyzer.git
Log | Files | Refs | README | LICENSE

commit 93d8c161ff94870d4108cbf2c5dc20f0de034292
parent 5a55e58328ee113053867f149be276fe00e1297c
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Wed, 18 Nov 2026 01:12:22 -0500

plans: x-trending.md, the brief for the whole trending-library feature

The ask, the rulings (as rulings), slice 1 as built and slices 2 to 4 as scoped, so the brief outlives the job directory it was written in.

Co-Authored-By: Claude <noreply@anthropic.com>

Diffstat:
Aplans/x-trending.md | 151++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 151 insertions(+), 0 deletions(-)

diff --git a/plans/x-trending.md b/plans/x-trending.md @@ -0,0 +1,151 @@ +# X trending pages, in a private library + +Lanes `lane/x-trending` (slice 1, merged 2026-11-17) and `lane/x-trending-2` (slice 2). This is the brief +for the whole feature: what was asked, what is ruled, what slice 1 built, and what slices 2 to 4 are. + +## The ask + +An agent operating Archilyzer (through `pnpm ops` and the MCP, with nobody in the loop if desired) looks +through X's trending pages (`https://x.com/i/trending/<number>`), archives the interesting threads and +their media, stores each piece of media once however many posts or topics carry it, and organises what it +found by topic. The operator then browses and judges the library, and nothing is on any site until a +person publishes it. + +## Rulings + +These are rulings, not reasons. A later ruling overturns an earlier one only when it says so. + +**Privacy** + +- A trending library is PRIVATE: on no site, in no build, export, index shard, `corpus.json`, `llms.txt` + or remote MCP surface, until a deliberate publish step. Every publishing door refuses it by its marker. +- No real person's, channel's or the operator's name or handle, no hostname, home path or real trending + id, in code, fixtures, tests, docs or commit messages. Fixtures are invented. +- The raw capture of a read is never committed and never served. + +**X safety** + +- All X traffic goes through the editor's X queue (`platform:twitter`), its pace, its hold and backoff, + the X alert and the fresh-jar rule. One trending page read is ONE job. Never a burst. +- A 429 stops the job at once and leaves X alone for 15 minutes: reads, captures, watch ticks and media + fetches all honour that cooldown. Nothing retries by itself. +- Development and tests use fixtures and the fake profile browser only. No test opens a socket. +- The page reader MAY be the connected profile's Playwright browser. It reads the JSON the page itself + fetches, never builds a request of its own, scrolls gently under a cap, and saves the raw capture so + parsing never needs a second read. +- THE JAR RULE STANDS FOR THE WATCH. The editor never refreshes X's cookie jar by itself: a refresh is a + person's press on /cookies. A watch therefore runs only while the jar is under 60 minutes old. It + pauses when the jar goes stale and resumes at the first scan after a Refresh, so **a watch does not + cover the night unattended**. A tick that exports the profile's cookies itself is NOT built, not even + behind a switch. + +**The library** + +- A topic is an entity inside the library, not a channel. The operator's topics may merge several + trending pages and need not carry X's titles. +- A read archives nothing: it lists posts. Media, a screenshot and thread context are fetched for posts + marked keep, and for new posts of a watched topic (media at once; screenshots when the topic says so). +- Every step is an editor job or action with a `pnpm ops` twin, and an MCP read tool where an agent + needs to look. The UI works with no model. +- Curated and corpus files have one writer each. A media file is removed with `removeMediaFile`. + +**Judging** + +- States are `keep | drop | later`. No entry means undecided; clearing a judgement removes the entry. +- A judgement records who decided (`agent` or `operator`) and when, with an optional note. A thread can + be judged too: its key is its root post's id, and a post's effective judgement is its own, else its + thread's. +- An agent's judgement is a suggestion. An agent's write never overrides an operator's: it is skipped + for that id and reported. +- Drop deletes nothing and is reversible. Purging a dropped post's capture is the operator's press + (slice 3). + +**Media** + +- Stored once, deduplicated by content hash across posts and topics. Exact duplicates only: the same + video at another quality is another file. +- The media CDN addresses already in the saved capture are preferred over logged-in page loads. The + logged-in fallback runs only for posts marked keep. +- Deleting a post never deletes media another post still uses. +- Watch media includes videos up to a per-file cap (100 MB, `config.xTrending.maxVideoMb`); larger ones + are owed until the post is kept. One capture job fetches at most 40 files or 200 MB; the rest is owed. +- A library's media is not in the media tier (no posts channel's `posts-media/` is): it stays on the + corpus disk, beside the library's text. + +**Watch** + +- A per-topic switch with an interval and an end time. Defaults: 30 minutes, 48 hours, at most 4 watched + topics per library. Each tick is the same single read job. +- A post seen before and absent from a read that reached the page's end is recorded as "gone from the + page at <time>". It is never called deleted. A capped, cancelled or failed read asserts nothing. +- A trending page X has retired ends the watch with a sentence. +- The watch has its own scan timer, armed below the idle gate (`ARCHILYZER_IDLE_BOOT` arms nothing). + +**Later slices** + +- The judge view is a project-less Posts library page in umtool, built on the export's post display. +- Publishing a topic materialises its KEPT posts into an ordinary posts channel named for the topic. +- "Break out a user": the library lists its accounts like an X search channel's leads and reuses that + channel's archive action to create the account's own channel, on no site. + +## Slice 1, as built + +- **The library** is a channel made with platform `x-trending`; `config.xTrending` is its marker, and + the marker alone decides (`common/lib/xTrending/config.ts`, `marker.mjs`). It has no URL and no + timeline to fetch. +- **`read-x-trending`** (`common/controller/readXTrending.ts`, `common/social/xTrendingRead.ts`): one + page opened in the connected X profile's browser; every GraphQL JSON answer the page fetched is saved + raw to `channels/<lib>/trending/reads/<readId>/responses.jsonl` with `page.png` and `read.json` (the + record: operation names and sizes, never a body). Posts are parsed FROM THE SAVED FILE + (`common/social/xTrendingParse.ts`). `probe` saves and writes no post; `reparse` parses a saved read + again, offline, as `reparse-x-trending`. +- **Stops and deadlines.** A read stops at its scroll cap, its post cap, after two scrolls that brought + nothing new, and at once on a 429, a 403, a 401 or a login page. Deadlines: the load 75 s, any other + page call 20 s, closing 10 s, a whole read 6 minutes. +- **The store** (`common/lib/xTrending/store.ts`): the library's posts live under + `channels/<lib>/trending/posts/` (a posts channel's shard format, one directory down, so every reader + of an ordinary posts channel sees a channel with no posts), `topics.json`, `membership.json` (post → + topic, the reads that showed it, its media by kind). One writer, under the file's lock. +- **One browser on the profile at a time.** A Connect or a Refresh is refused while a read or a capture + runs, and those jobs are refused while a Connect or Refresh is in flight + (`editor/app/lib/cookieRefreshGuard.ts`). +- **The doors.** Sites, the index build, reports and articles, drafts and research, umtool's post + archive and the MCP's remote surface all refuse a library; pinned by + `common/publish/xTrendingReportDoor.test.ts`, `umtool/lib/report/xTrendingLibrary.test.mjs` and + `mcp/src/xTrendingPrivacy.test.ts`. +- **Looking.** `pnpm ops get trending <slug>` and the MCP tools `x_trending_topics` / + `x_trending_posts`. + +## Slice 2: keep posts, save media once, watch a topic + +- `judge-trending` writes `trending/judgements.json` through one writer; a keep enqueues the existing + `capture-posts` job for that post (media, screenshot, context, thread shot). +- `capture-posts` takes a posts root, so a library's captures land in `trending/posts-media/<id>/` and + its availability in `trending/posts-availability.json`. +- Media: fetched from the CDN addresses in the saved capture inside the capture job (on X's queue, files + 1 to 2 s apart, the cooldown checked between posts), hashed, and kept once in + `trending/media-store/<aa>/<sha256>.<ext>` with a hardlink at `posts-media/<id>/<name>`; + `trending/media-index.json` maps hash → bytes, source addresses and posts. `trending/.gitignore` + keeps both directories out of the corpus repo. +- `watch-trending` and the watch scan (`common/controller/xTrendingWatch.ts`); "gone from the page" + marks; the jar pause with X's jar-age alert and a "Paused watches" section on /review. +- A hung browser is killed by pid (the profile's `SingletonLock`, checked against the process's command + line; never a pid that does not name that exact profile directory). A reparse refuses inside the job + while the read is still running. + +## Slice 3: the judge view + +umtool's Posts library page: by topic, filters by state, media type and author, bulk actions, keyboard +friendly, judgements through the editor's `judge-trending`; the purge button and its `pnpm ops` twin. + +## Slice 4: topics and publishing + +Rename, merge, move a post between topics; publish a topic's kept posts into an ordinary posts channel; +break out a user. + +## Open + +- The real page's shape is confirmed only by the first probe. The parser is built so that a change is + local to `common/social/xTrendingParse.ts`. +- Whether a watch may keep the jar fresh by itself is the operator's to rule; until then the jar rule + above stands.