Skip to content

Torrent v2 7/8: Tracker lifecycle, editing and discovery privacy - #237

Merged
linroid merged 1 commit into
torrent-v2-stack-06-downloadsfrom
torrent-v2-stack-07-trackers
Sep 20, 2026
Merged

linroid merged 1 commit into
torrent-v2-stack-06-downloadsfrom
torrent-v2-stack-07-trackers

Conversation

@linroid

@linroid linroid commented Sep 20, 2026 •

Copy link
Copy Markdown
Owner

Adds typed tracker topics, bounded scrape/reannounce, status, private-peer cleanup and revisioned tracker edits with checkpoint recovery. Explicit tracker-only metadata discovery and persisted source privacy keep tracker-restricted tasks from falling back to public discovery.

Part 7/8 of the consolidated stack for #162. Review and merge bottom-up. This PR targets torrent-v2-stack-06-downloads; its diff contains only this capability group.

Preservation and validation

Consolidates #210–#226. The consolidation snapshot matches original boundary 584e0cca exactly. Fresh CI then exposed a listener shutdown race: canceled accept() could escape as a socket exception. Foundation commit 2fdddd39 fixes cancellation classification and adds a deterministic regression test. This inherited fix and its test are the only file differences from that original boundary; all other contents are preserved. Original branches and discussions are retained.

Fresh CI runs on this replacement PR; historical checks and approvals are not transferred. The remaining production roadmap and release gates are still open.

Original PRs and frozen heads

PR Original head
#210 — Add typed v2 tracker announces and lifecycle accounting c808a24d
#211 — Add bounded HTTP and UDP tracker scrape support 2000bd71
#212 — Throttle tracker reannounce and back off failed polls aeaf1849
#213 — Await private peer cleanup before tracker failover 1d108cbf
#214 — Revoke private incoming admission before peer reset d12db27f
#215 — Add credential-free per-tracker status snapshots e173c80d
#216 — Replace tracker configuration through lifecycle barriers 1ebda08e
#217 — Wire bounded tracker controls into live sessions 06303674
#218 — Admit retained tracker configuration with transferable ownership 8fd9fa98
#219 — Persist task tracker overrides in versioned checkpoints 8824f258
#220 — Commit tracker configuration through atomic checkpoints 937d18d1
#221 — Apply tracker edits through the session lifecycle 107811dd
#222 — Persist tracker revisions and reject stale session edits ee5a5780
#223 — Recover committed tracker edits ahead of TaskStore 34fce20d
#224 — Add explicit tracker-only engine discovery e2ca4ca1
#225 — Expose and persist source discovery privacy 66d004fd
#226 — Wire bounded scrape commands into active torrent sessions 584e0cca

Review carry-forward

These original discussions and their responses remain linked for review. Their unresolved status is preserved; consolidation does not imply reviewer approval.

Consolidated stack

  1. Torrent v2 1/8: Contracts, verification infrastructure and resource limits #231 — Contracts, verification infrastructure and resource limits
  2. Torrent v2 2/8: V2 identity, metainfo and Merkle integrity #232 — V2 identity, metainfo and Merkle integrity
  3. Torrent v2 3/8: V2 layout and verified storage #233 — V2 layout and verified storage
  4. Torrent v2 4/8: V2 catalog, checkpoints and crash recovery #234 — V2 catalog, checkpoints and crash recovery
  5. Torrent v2 5/8: V2 handshake, hash exchange and bounded transport #235 — V2 handshake, hash exchange and bounded transport
  6. Torrent v2 6/8: V2 scheduling and download execution #236 — V2 scheduling and download execution
  7. Torrent v2 7/8: Tracker lifecycle, editing and discovery privacy #237 — Tracker lifecycle, editing and discovery privacy
  8. Torrent v2 8/8: V2 engine lifecycle, rate controls and restart recovery #238 — V2 engine lifecycle, rate controls and restart recovery

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 20, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-20T07:44:49.604495Z 69ec55a PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 69ec55ab64

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

require(it.isNotEmpty()) { "Tracker-only magnets require supplied trackers" }
}
} else emptyList()
val metadata = cache.resolve(magnet.infoHash) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Isolate tracker-only metadata fetches from public cache work

When a PUBLIC resolution for this info hash is already pending, a concurrent TRACKER_ONLY call joins the same TorrentMetadataCache.resolve deferred because pending operations are keyed only by hash. The shared operation can already be using explicit peers or DHT, so the restricted caller's privacy choice does not prevent public discovery; it can also inherit the public operation's rejection of private metadata. Partition in-flight cache work by discovery privacy, or bypass public pending operations for tracker-only requests.

Useful? React with 👍 / 👎.

Consolidates #210–#226, preserving source 584e0cc.
Includes the foundation listener cancellation regression fix discovered by consolidation CI.
@github-actions

Copy link
Copy Markdown
Contributor

Test Results

  767 files  + 55    767 suites  +55   4m 52s ⏱️ +38s
3 182 tests +279  3 182 ✅ +279  0 💤 ±0  0 ❌ ±0 
4 382 runs  +465  4 382 ✅ +465  0 💤 ±0  0 ❌ ±0 

Results for commit c43e7ff. ± Comparison against base commit 2df2f77.

@linroid
linroid added this pull request to stack #239 September 20, 2026 08:46
@linroid
linroid merged commit e560a94 into main Sep 20, 2026
10 checks passed
@linroid
linroid deleted the torrent-v2-stack-07-trackers branch September 20, 2026 11:01
linroid added a commit that referenced this pull request Sep 20, 2026
)

Four automated review findings from PRs #232, #235, #236 and #237 were left
unresolved when those branches were consolidated and merged.

Metadata cache (#237, P1): pending fetches were keyed by info hash alone, so a
TRACKER_ONLY caller arriving while a PUBLIC fetch was in flight joined that
operation and inherited discovery it had opted out of, along with its rejection
of private metadata. The privacy branch lives inside the fetch lambda, which
only runs for the caller that creates the deferred, so the guard could never
fire for the joining caller. Pending work is now keyed by hash and privacy.
Completed entries stay shared because the hash authenticates them.

Piece scheduler (#236): every HAVE frame rebuilt the peer's full availability
as a BooleanArray and made the scheduler copy and rescan it, so a peer sending
duplicate announcements forced repeated allocation and a full rarity scan per
message. HAVE now applies incrementally; only the one-time bitfield rebuilds.

Hash wire (#235): BEP 52 permits a request length of any positive power of two
up to 512, but length 1 was rejected during decoding, closing otherwise valid
v2 connections. The existing hashCount calculation already covers that case:
a lone base hash covers no proof layer, so uncles is proofLayers + 1, which
matches the invariant peerHashProofHeight enforces.

Metainfo (#232): an unconditional requireNotNull rejected documents that omit
"piece layers", which BEP 52 allows when no file exceeds the piece length. An
absent key now parses as an empty dictionary; validatePieceLayers still rejects
omission whenever the parsed files require external layers.

The symlink race reported on #233 is not addressed here. Closing it needs a
no-follow open plus handle-identity verification, which okio's commonMain
FileSystem does not expose; validateOwned still rejects symlinks, checks file
identity and revalidates after writing. The oversized-file finding on the same
PR was already fixed before merge and only left unresolved on GitHub.

Each fix carries a regression test. The two behavioural ones were confirmed to
fail without their fix: reverting the pending key to ignore privacy fails
restrictedCallersNeverJoinPendingPublicDiscovery, and removing the duplicate
guard fails announce_buildsAvailabilityIncrementallyAndIgnoresRepeatedIndexes.
Full suites pass on a forced rerun: 639 torrent and 203 core JVM tests, plus
the iOS simulator target compiling clean.
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.

1 participant