Skip to content

Replace tracker configuration through lifecycle barriers - #216

Closed
linroid wants to merge 2 commits into
torrent-v2-11-tracker-statusfrom
torrent-v2-11-tracker-edit
Closed

linroid wants to merge 2 commits into
torrent-v2-11-tracker-statusfrom
torrent-v2-11-tracker-edit

Conversation

@linroid

@linroid linroid commented Sep 12, 2026

Copy link
Copy Markdown
Owner

Adds serialized tracker replacement: validate and snapshot the new tiers before suspension, attempt a bounded stop on the old configuration, await private peer cleanup, then install the replacement. Caller cancellation or cleanup failure prevents installation. Successful edits discard cached tracker IDs, reset lifecycle/backoff timing, and increment a diagnostic configuration revision while retaining the full torrent topic binding.

Replacement is bounded to 256 entries/tiers and 8192 characters per absolute HTTP(S)/UDP URL. Empty configurations are supported; unsupported schemes and UDP user-info are rejected before old tracker contact. Endpoint policy authorization remains the caller's responsibility.

Stacked on #215; advances #162. Tests cover stop/cleanup/start order, credential state, mutable input, stop timeout versus caller cancellation, invalid edits, cleanup failure, empty configuration, and topic isolation. SDK/daemon/UI commands and persistence remain separate roadmap work.

Validation: 547 JVM and 526 executed iOS simulator tests, zero failures/errors/skips; native-runtime guard and both pinned v1 conformance scenarios passed. Only test API opt-in annotations changed afterward; JVM and iOS test compilation passed again.

@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:34:45.097351Z f567568 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: f567568fa6

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

Comment on lines +293 to +294
if (preferCurrent && current != null && !oldPeersClosed) beforeSwitch()
val replacement = configuration.tiers.map { it.shuffled().toMutableList() }

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 Recheck cancellation after the peer-cleanup barrier

When parent cancellation arrives while beforeSwitch() is completing, the callback can return into an already-cancelled context and the replacement is still installed because the remaining mutations contain no cancellation check. This violates replaceTrackers()'s cancellation guarantee: the caller can observe cancellation while tiers, cached IDs, statuses, and the revision have nevertheless changed. Check currentCoroutineContext().ensureActive() immediately after the cleanup callback and before mutating configuration.

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 1ebda08 with ensureActive immediately after private cleanup and before installing replacement state. The new regression cancels exactly as cleanup returns: it fails before the fix and now preserves the old revision and attempt state. The combined child stack passed 553 JVM and 532 executed iOS tests with zero failures.

@github-actions

github-actions Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Test Results

  722 files  + 5    722 suites  +5   4m 12s ⏱️ -1s
3 023 tests +24  3 023 ✅ +24  0 💤 ±0  0 ❌ ±0 
4 117 runs  +40  4 117 ✅ +40  0 💤 ±0  0 ❌ ±0 

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

♻️ 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-tracker-edit 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