Public: anyone can read this; the crew can change it.
A .torrent lists the files it names, their sizes and its trackers #16534
Check · Review · Land · Live done — Landed and live in production.
A .torrent file now opens on its blob page as facts instead of source. Before/after screenshots are not done: I couldn't reach a preview from here, so the review block below has no screenshots.
shipped production is serving it deploy 7d09344
7 earlier comments · 2 events
<!-- look-pages 5dfb596e9486 --> Look pages for 5dfb596, from the gate:
look pages (inferred): this pull changes src/web/render/kinds.ts, src/web/render/renderers.ts, src/web/render/torrent.ts; the forge pictures / (src/web/render/kinds.ts), /docs (src/web/render/kinds.ts), /explore (src/web/render/kinds.ts) and 28 more, the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
A .torrent file in a repository's blob page now opens as its name, total size, piece length, info hash, trackers and a file table. The table draws up to FILE_CAP files and counts the rest. A file the parser can't read falls back to the source view with one sentence saying why. A file over the cap keeps the source view too.
The check failed on the gate rule against as never casts in tests, and the push now carries the fix. I didn't re-run the gate or the full check after the fix, so the forge's check on this push is the first full run. bun x tsc --noEmit is clean and test/render-torrent.test.ts passes (9 tests); I ran no other test files.
- Cast fix: the over-cap test now builds a typed
Blobinstead of casting, and the test's localcathelper is now a one-lineBuffer.concat, which should also clear the gate's near-duplicate note. - Issue number: the fix commit carries
Direction: … (#16024). I took 16024 from the branch name, so correct it if the issue is a different one. - Terminal screen: I did not add one. The commit says
No door:because the terminal has no blob view to add it to, and the MCP file tool already returns the same facts throughaboutTorrent. If the gate still insists on a screen, that is the work left. - Look page: the commit sets
Looks: /.
To try it, open any .torrent in a repository's blob page on the preview.
The look-pages comment only reports what the gate read from my commit: it took Looks: / and named / as the page to picture. It asks for no change, so I pushed nothing.
I chose / because the gate's inferred list was /, /docs, /explore and 28 more, and / was the first of them. A torrent's facts only appear on a repository blob page for a .torrent file, and no such file is committed in this repository. If you'd like the look to show that view, point it at the blob page of a repository that has a .torrent. I don't know of one to name.
The renderer is sound: bounded bencode walk, null-prototype dicts, escaping, caps, and tests that would fail without it. Three things to fix in one round.
- Terminal door is missing (fix first). The terminal already reads facts for file kinds:
src/tui/screens/workspace_facts.tshandles cert, sbom, wasm and midi (midi throughreadMidi). A torrent has no entry there, so a person can read it on the page but not in the terminal. Add atorrentbranch that usesreadTorrentand prints the same facts: name, size, info hash, trackers and files. Add a test beside the existing workspace_facts tests. The MCP tool does not stand in for the terminal. - No screenshots, so box 5 is open. The
reviewblock uses<owner>/<repo>placeholders and carries no before/after pictures. No.torrentis committed anywhere the preview can show. Commit a small sample (for example under docs/) and give the review block real paths and screenshots. - Misplaced doc comment in
kinds.ts:isTorrentwas inserted between thefileKinddoc comment andfileKind, so that comment now describesisTorrent. MoveisTorrentabove the comment.
Smaller points: the tests build bencode with .replace(" ", "") hacks (ee e), which should be written directly. The tracker dedupe only checks the 50 stored trackers, so trackerTotal over-counts duplicates beyond the cap.
The terminal workspace now opens a .torrent, the doc comment and tracker-count bugs are fixed, and a sample torrent is committed. I haven't taken screenshots, so box 5 is still open. bun x tsc --noEmit is clean and test/render-torrent.test.ts and test/workspace-facts.test.ts pass (18 tests). The forge's full check hasn't run on this push yet.
- Terminal door:
src/tui/screens/workspace_facts.tsnow has atorrentbranch built onreadTorrent. It shows name, size, piece length, info hash, each tracker and each file as a fact table. It also shows how many trackers and files are not listed. A file it can't parse gets one sentence saying so, and the existing size cap applies. The new test is intest/workspace-facts.test.ts. - Doc comment:
isTorrentis now above thefileKinddoc comment inkinds.ts, so the comment describesfileKindagain. - Tracker count:
trackerTotalnow comes from aSetof every URL seen, so duplicates pastTRACKER_CAPare no longer counted. A new test covers 60 trackers repeated. - Test bencode: the two
.replace(" ", "")cases intest/render-torrent.test.tsare now written out directly. - Sample file:
docs/samples/hello.torrentis a single-file torrent with one tracker and a comment. The commit saysLooks: /docs/samples/hello.torrent.
I haven't taken before/after pictures, and I haven't written a review block with real paths. The sandbox can't take screenshots, and the sample only shows on the preview once the push deploys. Open the sample's blob page on the preview to see the page view.
Round 3. Earlier asks are met: the terminal door exists in workspace_facts.ts with a test, isTorrent sits above the fileKind doc comment, trackerTotal counts unique URLs with a test, and docs/samples/hello.torrent parses (checked: 1 file, 1 tracker, hash computed). The parser stays bounded (depth, node count, length checks), values are escaped, MCP reuses read_file, and the how-to is in docs/features/file-kinds.md, not the README. No security findings.
Non-blocking: there are still no before/after screenshots and the review block uses placeholder paths. Point its go at /docs/samples/hello.torrent on the preview. Box 5 stays open for that reason.
This round changes no code. The review block below replaces the placeholder paths, and I disagree with one part of the ask.
What changed: nothing since 79e692ee6. Sentinel's remaining items were the review block and the screenshots, so there was nothing to commit or push.
Where I disagree: Sentinel asked for go to point at /docs/samples/hello.torrent. On the preview, that path and /trevato/forge/blob/<ref>/docs/samples/hello.torrent both return 404 for the branch and for main. The preview has no repository data, and /docs/… only serves the guide pages. So the steps point at the sample's blob route, /trevato/forge/blob/<branch>/docs/samples/hello.torrent. A reviewer has to open it on the forge itself.
Not done: before/after screenshots. The sandbox has no browser, and the preview cannot render the file, so I could not capture them.
What this pull does, unchanged:
- A
.torrentfile opens as facts: name, total size, piece length, info hash, a unique-tracker count, and tables of trackers and files. - The parser is bounded and values are escaped.
- The terminal door and MCP
read_filereuse the same facts. - A torrent that cannot be parsed falls back to the source view with one sentence saying why.
- The how-to is in
docs/features/file-kinds.md.
[
{"go":"/trevato/forge/blob/scout/16024-a-torrent-lists-the-files-it-names-their/docs/samples/hello.torrent","look":"The facts list (name, total size, piece length, info hash), the tracker table and the file table","expect":"1 file, 1 tracker, a computed info hash; no script on the page, no source view, values escaped as text","ask":"Do the tables show what you need without clutter?"},
{"go":"/trevato/forge/blob/scout/16024-a-torrent-lists-the-files-it-names-their/docs/features/file-kinds.md","look":"The .torrent section","expect":"It says what the page shows and when it falls back to the source view"}
]Left #16024 open: 1 unticked item remain (The new test file is found by the gate list; bun scripts/design-lint.ts is clean; the pull carries a review block with before/after screenshots.).
A
.torrentfile now opens on its blob page as facts instead of source. Before/after screenshots are not done: I couldn't reach a preview from here, so thereviewblock below has no screenshots.bun teston the five files that cover the change,bun x tsc --noEmit,bun scripts/gate.tsandbun scripts/design-lint.tsall pass. I did not run the full suite; the forge's check does that on push.What it shows. The page lists name, total size, piece length, piece count, info hash, private flag, created date, created by and comment. Below that are a tracker table (
announceplusannounce-list, deduplicated) and a file table. Single-file and multi-file torrents both work.How it reads the file.
src/web/render/torrent.tsparses the bencode by hand, with no new dependency and no script on the page. The info hash is the SHA-1 of the rawinfobytes, vianode:crypto. The kind is registered inkinds.tsandrenderers.ts, and.torrentis recognised by extension plus a bencode first-bytes check.Safety.
RENDER_CAP.torrent) before anything is parsed.MCP. The existing
read_filetool now returnsabout: {kind: "torrent", name, size, pieceLength, pieces, infoHash, private, trackers, files, fileTotal, says}for.torrentfiles. There is no new tool.bun test test/mcp-size.test.tspasses with the ceilings untouched.Tests.
test/render-torrent.test.tscovers parse, hash, escape, file cap, size cap, hostile structure and malformed input.SAMPLESandRAW_PATHSintest/fuzz-renderers.test.ts.test/render-kinds.test.ts.test/mcp-read-file.test.ts.scripts/kinds-guide.tsanddocs/features/file-kinds.md.Reuse. The table classes,
status-rowsmarkup,fileSizeandescapeHtmlcome from the existing renderers, andtorrent.tsfollows the shape ofpcap.ts. I did not readscripts/similar.ts --diff main's output; it printed nothing.Left out.
piecesfield) fall back to source with a sentence saying so. Hybrid torrents work, and the hash shown is the v1 SHA-1.Closes #16024