Skip to content

shim: inspection getters — file table + piece availability (ABI v5)#19

Merged
SethMorrowSoftware merged 1 commit into
mainfrom
claude/relaxed-cerf-816pyn
Jun 27, 2026
Merged

shim: inspection getters — file table + piece availability (ABI v5)#19
SethMorrowSoftware merged 1 commit into
mainfrom
claude/relaxed-cerf-816pyn

Conversation

@SethMorrowSoftware

Copy link
Copy Markdown
Owner

Batch 2 of surfacing more of libtorrent — let script see inside a torrent. Until now there was no way to enumerate a torrent's files at all; this batch fixes the biggest inspection gap.

New ABI (v4 → v5, append-only)

btx_* bt* returns what
file_list btFileList List of Arrays one record per file: path, size, progress (bytes downloaded), priority (0..7)
piece_availability btPieceAvailability Data one byte per piece — peers advertising it (clamped 255)

56 → 58 public handlers.

btFileList returns the whole file table in one FFI round-trip (per the single-thread perf playbook), pulling per-file progress + priorities in two bulk engine calls and reusing the exact peer-list framing. It's empty until metadata arrives, so it doubles as a "do we have metadata yet?" probe. btPieceAvailability pairs with btPieceBitfield (which pieces you have) for a full piece/rarity map.

Schema

Four append-only file-entry fields — F_FILE_PATH/SIZE/PROGRESS/PRIORITY (120–123) — mirrored as kField* and as keys path/size/progress/priority in _fieldKey. Registry stays in lock-step: 95 constants in sync (was 91).

Verification

  • C++: built + run under gcc ASan/UBSan against real libtorrent — 430 checks, 0 failures, clean -Wall -Wextra. New getters assert empty/0 on a bogus handle.
  • Static gates green: check-livecodescript 7/7; check-record-registry 95 in sync; golden vectors OK; BTX_ABI_VERSIONkABIVersion both 5.
  • README + api-reference (entries + a file-entry key table) updated. CI rebuilds the committed binaries on merge.

Remaining roadmap

  1. Tracker + webseed editing (and tracker listing) · 4. Session ops (pause/resume, listen port, find-by-hash, classic DHT announce/get_peers) · 5. IP filter + extended add.

🤖 Generated with Claude Code

https://claude.ai/code/session_01371AXB4CUUke7enHHS8okc


Generated by Claude Code

Batch 2 of surfacing more of libtorrent: let script see INSIDE a torrent.
Until now there was no way to enumerate a torrent's files at all.

New btx_* ABI (v4 -> v5, append-only):
- btx_file_list - the torrent's files as a count-prefixed list of KV records,
  one per file: path (relative), size, bytes downloaded, and download priority.
  One FFI round-trip returns the whole file table (perf playbook). Empty until
  metadata arrives, so it doubles as a "do we have metadata yet" probe. Pulls
  per-file progress + priorities in two bulk engine calls, mirrors the
  peer-list framing exactly.
- btx_piece_availability - one byte per piece (peers advertising it, clamped to
  255) as a raw view, like btx_piece_bitfield; pair the two for a full piece map.

Record schema: four append-only file-entry fields (F_FILE_PATH/SIZE/PROGRESS/
PRIORITY = 120..123), mirrored as kField* + keys path/size/progress/priority in
_fieldKey. LCB: kABIVersion -> 5; two foreign decls + btFileList (List of
Arrays) / btPieceAvailability (Data) wrappers. 56 -> 58 public handlers.

Built + run under gcc ASan/UBSan against real libtorrent: 430 checks, 0
failures, clean -Wall -Wextra. Static gates green (check-livecodescript 7/7;
record-registry 95 in sync; golden OK; ABI 5<->5). README + api-reference
(entries + file-entry key table) updated. CI rebuilds the binaries on merge.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01371AXB4CUUke7enHHS8okc
@SethMorrowSoftware SethMorrowSoftware marked this pull request as ready for review June 27, 2026 03:41
@SethMorrowSoftware SethMorrowSoftware merged commit 0cfe245 into main Jun 27, 2026
5 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants