Skip to content

Bound v2 block requests by file tails and response deadlines - #194

Closed
linroid wants to merge 2 commits into
torrent-v2-08-outboundfrom
torrent-v2-08-block-exchange
Closed

linroid wants to merge 2 commits into
torrent-v2-08-outboundfrom
torrent-v2-08-block-exchange

Conversation

@linroid

@linroid linroid commented Sep 12, 2026

Copy link
Copy Markdown
Owner

V2 block requests now connect explicit response ownership to admitted transport writes and file-aligned layout bounds. Requests cannot cross a real file tail; choke/cancel retain their slots and buffer credit until a matching response. All writes are bounded by the earliest outstanding response deadline, and expired or invalid responses close the connection rather than recycling ambiguous slots.

Stacked on #193, under #162. Delivered blocks retain credit after frame dispatch and connection shutdown and remain explicitly unverified until the consumer validates them. Full event-loop/timer wiring, piece assembly/commit, upload/hash serving and scheduler/runtime integration remain required.

Validation at 8704c37ab543219564fde088c04fe6218addedb6:

  • 436 JVM tests and 415 actually executed iOS simulator tests; zero failures, errors or skips.
  • Both pinned v1 conformance scenarios and the native-runtime dependency guard pass.
  • Tests cover file-tail bounds, admission before sending, canceled pipeline saturation, stale tickets, retained delivered buffers, malformed/late responses, clock rollback, blocked writes bounded by older requests, and partial cancel-write cleanup.

@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-12T17:43:50.680366Z 8704c37 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: 8704c37ab5

ℹ️ 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 +77 to +80
} catch (error: Throwable) {
lease.close()
close()
throw error

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 Preserve the stream when outbound admission fails

When the transport's frame budget is temporarily exhausted, PeerHashTransport.send() throws before encoding or writing anything and intentionally leaves the stream reusable. This catch nevertheless calls close(), discarding every pending request and disconnecting a healthy peer; it also contradicts this method's contract that exhausted credit returns null. Outbound frame credit needs to be admitted before registering ownership, or pre-write admission failures need to roll back the new request without closing the transport.

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 45e5b9e. The transport now exposes a pre-write admission callback: new block ownership is registered only after frame credit is acquired. Frame pressure returns null for a new request without emitting bytes or changing existing ownership. Unsent cancellation returns false and leaves the request uncanceled for retry. Partial writes and deadline expiry still tear down the stream.

The regression saturates the frame budget while a request is live, verifies a second request and cancel leave the stream/bytes/credit unchanged, then verifies the original response remains deliverable and later requests/cancels work after credit returns. Focused tests and iOS compilation pass; the descendant assembly head 908aa34 additionally passes 442 JVM and 421 executed iOS tests, both conformance scenarios and the runtime guard with this fix included.

@github-actions

Copy link
Copy Markdown
Contributor

Test Results

  647 files  + 5    647 suites  +5   4m 11s ⏱️ +12s
2 690 tests +21  2 690 ✅ +21  0 💤 ±0  0 ❌ ±0 
3 562 runs  +35  3 562 ✅ +35  0 💤 ±0  0 ❌ ±0 

Results for commit 45e5b9e. ± Comparison against base commit 7e7c32e.

@linroid

linroid commented Sep 20, 2026

Copy link
Copy Markdown
Owner Author

Superseded by #235 (V2 handshake, hash exchange and bounded transport) 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 added a commit that referenced this pull request Sep 20, 2026
Consolidates #186–#194, preserving source 45e5b9e.
Includes the foundation listener cancellation regression fix discovered by consolidation CI.
@linroid
linroid deleted the torrent-v2-08-block-exchange 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