Skip to content

Authenticate v2 stored reads and rebuild availability with bounded rechecks - #179

Closed
linroid wants to merge 3 commits into
torrent-v2-06-piece-storefrom
torrent-v2-06-recheck
Closed

linroid wants to merge 3 commits into
torrent-v2-06-piece-storefrom
torrent-v2-06-recheck

Conversation

@linroid

@linroid linroid commented Sep 12, 2026

Copy link
Copy Markdown
Owner

Add authenticated reads and bounded rechecks to the v2/hybrid store. Reads require committed availability, validate the owned file and payload snapshot again, and transfer a buffer reservation to the consumer until it closes the result. Changed, truncated or replaced files revoke the affected availability without exposing their bytes.

Rechecks discard prior progress, verify selected owned files with at most 64 KiB of payload scratch, flush matching bytes and publish progress only after the I/O cancellation boundary. Cancellation retains active I/O reservations until the provider returns; a later scan can recover valid data.

Stack: based on #178, advancing #162 step 06. This still operates on the live fresh-directory store; restart/import ownership, checkpoint v2, session integration and wire proof serving remain pending.

Validation: all 366 local torrent tests, both existing pinned-client v1 conformance scenarios and the native-runtime guard pass. New tests cover consumer-held read budgets, uncommitted reads, corruption, truncation, foreign replacement preservation, scratch-space limits and canceled blocked rechecks.

@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-12T15:03:08.848147Z 6810f3d 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: 6810f3d4ec

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

}
val matches = verification.verify()
// A previous canceled/failed write may have left bytes without a completed flush.
if (matches) handle.flush()

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 Flush each file once rather than after every valid piece

For a valid multi-piece file, this invokes a durable filesystem flush for every piece; the platform implementations map this to FileChannel.force(true)/fsync. With the accepted 16 KiB minimum piece size and up to 1,000,000 pieces, a normal recheck can therefore perform hundreds of thousands of expensive flushes even though it writes no data, making restart verification impractically slow. Track which files contain matching data and flush each file once after scanning it instead.

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 e69f761. Recheck now scans each selected file through one handle and flushes once for its matching pieces. Bitmap changes stay tentative under the mutex until that flush and the cancellation boundary succeed; failure clears the file’s tentative bits before unlocking. The new four-piece regression asserts exactly one flush and verifies that an injected flush failure publishes no pieces or progress. All five focused recheck tests pass, including the blocked-provider cancellation test.

@github-actions

github-actions Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Test Results

  569 files  +13    569 suites  +13   4m 3s ⏱️ +5s
2 488 tests +13  2 488 ✅ +13  0 💤 ±0  0 ❌ ±0 
3 220 runs  +23  3 220 ✅ +23  0 💤 ±0  0 ❌ ±0 

Results for commit cbc0856. ± Comparison against base commit 4f7301d.

♻️ This comment has been updated with latest results.

@linroid

linroid commented Sep 20, 2026

Copy link
Copy Markdown
Owner Author

Superseded by #233 (V2 layout and verified storage) 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 #174–#179, preserving source cbc0856.
Includes the foundation listener cancellation regression fix discovered by consolidation CI.
@linroid
linroid deleted the torrent-v2-06-recheck branch September 20, 2026 11:12
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