Skip to content

Run v2 downloads under shared engine ownership and admission - #228

Open
linroid wants to merge 2 commits into
torrent-v2-08-session-lifecyclefrom
torrent-v2-08-engine-owner
Open

Run v2 downloads under shared engine ownership and admission#228
linroid wants to merge 2 commits into
torrent-v2-08-session-lifecyclefrom
torrent-v2-08-engine-owner

Conversation

@linroid

@linroid linroid commented Sep 13, 2026

Copy link
Copy Markdown
Owner

The Kotlin engine can now own a scoped full-metainfo v2 download using its shared connection, transfer-memory, session-memory, and payload-file limits. Caller cancellation and engine shutdown join the v2 lifetime before releasing its metadata admission and output claim. Files remain intact when ownership ends.

V1 and v2 registrations share the active-task ceiling and output-overlap checks. Full v2 identities prevent duplicate registrations, hybrid v1 aliases cannot acquire independent legacy owners, and legacy removal cannot release a live v2 output claim. File/piece/info bounds and retained metadata/index admission run before storage construction.

Stacked on #227 for #162. Real TCP coverage downloads a pure v2 file and a selected hybrid file after padding. Other tests cover shared registration limits, duplicate identities/output paths, pre-I/O admission failures, and joined engine shutdown. Both TCP peers are Ketch fixtures.

Validation: full JVM and executed iOS simulator suites, native-runtime dependency guard, and both existing Transmission v1 conformance scenarios. Public v2 source resolution, incoming routing, integrated discovery, checkpoint/TaskStore recovery, rate controls, and seeding remain roadmap work; this internal scoped path is not advertised as public v2 capability.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 13, 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-13T00:47:22.867476Z ab29c5c 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: ab29c5c426

ℹ️ 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".

discover: suspend (SendChannel<PeerEndpoint>) -> Unit,
body: suspend (TorrentV2DownloadSession) -> T,
): T {
val pending = scope.async {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Prevent shutdown from joining its own v2 child

When the supplied body or discover callback calls engine.stop(), it is executing inside this engine-scope child. stop() cancels scope and then joins the scope's root job, which cannot complete until this same child returns, while the child cannot return until stop() does; the call therefore deadlocks. Run caller callbacks outside the owned child or make shutdown avoid joining the calling child.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Fixed in 8b6b1c1. Shutdown now has a single cleanup operation outside the engine job tree. An engine-owned callback requests that operation without joining its own ancestor; external stop calls await the same full cleanup barrier. Regressions call stop from both the v2 body and discovery callback, then await external stop and assert that admission returned. The combined local capability branch passes 618 JVM tests, 597 executed iOS simulator tests, the runtime guard, and both existing v1 conformance scenarios.

@github-actions

github-actions Bot commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

Test Results

  772 files  + 5    772 suites  +5   4m 40s ⏱️ +20s
3 221 tests +24  3 221 ✅ +24  0 💤 ±0  0 ❌ ±0 
4 447 runs  +40  4 447 ✅ +40  0 💤 ±0  0 ❌ ±0 

Results for commit 8b6b1c1. ± Comparison against base commit d72fce5.

♻️ This comment has been updated with latest results.

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