Skip to content

Wire bounded tracker controls into live sessions - #217

Closed
linroid wants to merge 2 commits into
torrent-v2-11-tracker-editfrom
torrent-v2-11-live-tracker-control
Closed

linroid wants to merge 2 commits into
torrent-v2-11-tracker-editfrom
torrent-v2-11-live-tracker-control

Conversation

@linroid

@linroid linroid commented Sep 12, 2026

Copy link
Copy Markdown
Owner

Connects internal manual reannounce and tracker status flows to running Kotlin torrent sessions. Periodic and manual discovery share a lock; only one manual operation may be outstanding. Discovery owns manual jobs, and cancellation/shutdown joins cleanup before releasing reserved session-state credit. Automatic and manual responses share peer authorization/publication.

Pause detaches the control and clears status; resume installs a fresh control. A real engine test verifies HTTP tracker events, throttling, pause/resume, and final admission release. Deterministic tests cover bounded requests, serialization, caller cancellation, owner shutdown, and insufficient budget.

Stacked on #216; advances #162. SDK/daemon/UI exposure, tracker-edit persistence across pause/resume, and public v2 session registration remain separate work.

Validation at 44287443dfecd2dfcabe43ed605d6a2df1226545: 553 JVM and 532 executed iOS simulator tests, zero failures/errors/skips; native-runtime guard and both pinned v1 conformance scenarios passed.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 12, 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-12T21:47:51.595990Z 4428744 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: 44287443df

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

peers.forEach { output.send(it) }
}
delay(1000)
TrackerControl.run(exchangeBudgets.sessions, operation = { manual ->

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 Reserve tracker-control memory during session admission

When maxSessionStateBytes is exactly the accepted sessionStateWeight(spec)—a configuration explicitly exercised by the admission tests—the session lease consumes the entire budget, so this additional reservation fails whenever the torrent has trackers. Because the failure occurs in the supervised tracker-discovery child after addTask succeeds, a private or DHT-disabled torrent remains running without ever contacting its only peer source. Include this control charge in admission or reserve it atomically with the session lease.

AGENTS.md reference: AGENTS.md:L162-L165

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 0630367. sessionStateWeight now includes the tracker-control allowance, and each session uses a bounded control pool backed by that existing lease rather than reserving twice from the shared partition. The live engine regression runs at exactly sessionStateWeight(spec), contacts its tracker, exercises manual reannounce and pause/resume, and releases admission on stop. It failed before the fix and passes afterward; the combined stack passed 559 JVM and 538 executed iOS tests.

Comment on lines +44 to +45
} finally {
checkNotNull(publishStatus).invoke(checkNotNull(readStatus).invoke())

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 Publish tracker status while an announce is in flight

For a slow or stalled tracker request, TrackerTiers.announce changes the record to ANNOUNCING before suspending, but this callback runs only in finally, after the request has succeeded, failed, or been canceled and the status has already changed again. Consequently the newly exposed session trackerStatus flow can never emit ANNOUNCING and remains empty or stale throughout an in-flight request; publish the snapshot when the attempt enters that state as well.

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 0630367. TrackerTiers now publishes status transitions through an observer, including ANNOUNCING before network suspension, and the live engine attaches/detaches that observer with discovery. The integration regression holds the HTTP reply until ANNOUNCING is observed; a separate test covers transition snapshots and configuration revision changes. Combined validation passed 559 JVM and 538 executed iOS tests.

@github-actions

github-actions Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Test Results

  727 files  + 5    727 suites  +5   4m 10s ⏱️ -2s
3 041 tests +18  3 041 ✅ +18  0 💤 ±0  0 ❌ ±0 
4 147 runs  +30  4 147 ✅ +30  0 💤 ±0  0 ❌ ±0 

Results for commit 0630367. ± Comparison against base commit 1ebda08.

♻️ This comment has been updated with latest results.

@linroid

linroid commented Sep 20, 2026

Copy link
Copy Markdown
Owner Author

Superseded by #237 (Tracker lifecycle, editing and discovery privacy) in the consolidated eight-PR stack for #162.

The replacement preserves this PR's code and subsequent fixes; its description links the original head and review discussions. The only additional consolidation fix is the CI-discovered listener cancellation regression, documented on the replacement. All eight replacements have passed their required CI checks.

Closing without merging. This branch and its discussions remain available for reference. Review index: #162 (comment)

@linroid linroid closed this Sep 20, 2026
@linroid
linroid deleted the torrent-v2-11-live-tracker-control branch September 20, 2026 11:13
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