summaryrefslogtreecommitdiffstats
path: root/packages/meshbay-node
diff options
context:
space:
mode:
authorChristophe Besson <cbesson@gmail.com>2026-09-10 17:30:40 +0200
committerChristophe Besson <cbesson@gmail.com>2026-09-10 17:30:40 +0200
commitd5442e3a335327b445d27d0f7e8798726ba20973 (patch)
treef83e276a210fe36e1371bcc6a15bf5023c758056 /packages/meshbay-node
parent803e654086ac63e2d01fa4eb9cca50a4ebebcb73 (diff)
downloadmeshbay-d5442e3a335327b445d27d0f7e8798726ba20973.tar.gz
docs(code): drop the references to a plan file that no longer exists
Seven comments pointed at sections of `~/next/improve-downloads.md`, which is not in the tree and not anywhere a reader of this repository can follow. Each now states the thing it was citing: why a paused transfer holds nothing, why the lease is taken after the save target and not before, why a chunk request marks a lease alive, where the leaseless bound's number comes from. The leaseless comment also said "two files at a time" three paragraphs under `MAX_LEASELESS_IN_FLIGHT = 12`, left behind when the bound was raised. A comment that contradicts the constant beside it is worse than no comment: one of them is wrong and the reader cannot tell which. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AsoWC3GmhNdwVFomW3QjH3
Diffstat (limited to 'packages/meshbay-node')
-rw-r--r--packages/meshbay-node/src/meshbay_node/transfers.py45
-rw-r--r--packages/meshbay-node/src/meshbay_node/transport/webrtc_server.py6
-rw-r--r--packages/meshbay-node/tests/test_leaseless_reads.py6
3 files changed, 26 insertions, 31 deletions
diff --git a/packages/meshbay-node/src/meshbay_node/transfers.py b/packages/meshbay-node/src/meshbay_node/transfers.py
index dd382b4..cef817a 100644
--- a/packages/meshbay-node/src/meshbay_node/transfers.py
+++ b/packages/meshbay-node/src/meshbay_node/transfers.py
@@ -28,9 +28,8 @@ properties are load-bearing, and each one is a decision:
This module is deliberately free of asyncio and of the transport: it decides,
and the caller does the I/O. `sweep()` is called on a clock the caller owns, and
every method returns what changed so the caller can push it. That is what makes
-the failure modes in §5 of ~/next/improve-downloads.md testable at all — a
-queue that only reveals itself through a DataChannel is a queue nobody can
-prove things about.
+the failure modes testable at all — a queue that only reveals itself through a
+DataChannel is a queue nobody can prove things about.
"""
from __future__ import annotations
@@ -412,28 +411,24 @@ class TransferSlots:
# Browsing a group is never subject to a transfer slot — not the poster grid,
# not the covers, not opening a photo or a PDF to look at it. A member must be
# able to browse a group that is at capacity exactly as they browse an idle one.
-# That is a requirement, and §3.4 of ~/next/improve-downloads.md satisfies it
-# structurally: a transfer is what the transfers widget shows, and nothing else
-# takes a slot.
+# That requirement is met structurally rather than by judgement: a transfer is
+# what the transfers widget shows, and nothing else takes a slot.
#
# But "not leased" cannot mean "unbounded", or a client that simply omits `tr`
# transfers outside every cap and the caps are decoration.
#
-# **The number comes from what the shipped client legitimately does, and it was
-# wrong once already.** §3.4.1 of ~/next/improve-downloads.md argued for two,
-# reasoning about *viewers*: a photo viewer shows one photo, a preview modal one
-# document, and the second is for prefetching the next photo. That reasoning
-# forgot the music player, which warms a read-ahead window — `prefetchDepth()`
-# in music-player.js returns 5 on Wi-Fi, 3 otherwise — so playing an album has
-# six files in flight and the fourth was refused with `transfer_required`.
-# Reported the day MNP 3.0 shipped, as "I try to play a track and it tells me to
-# download it instead".
+# **The number comes from what the client legitimately does**, and reasoning
+# about *viewers* alone gets it wrong: a photo viewer shows one photo and a
+# preview modal one document, but the music player warms a read-ahead window —
+# `prefetchDepth()` in music-player.js returns 5 on Wi-Fi, 3 otherwise — so
+# playing an album has six files in flight before anyone has done anything
+# unusual, and a bound of two refuses a member trying to play a track.
#
-# Twelve: six for the music read-ahead at its widest, two for a photo viewer
-# and its own prefetch running at the same time in the same session, and the
-# rest as headroom for the next app that reads ahead. `test_leaseless_reads.py`
-# derives the floor from music-player.js itself, so raising the client's
-# prefetch without raising this fails rather than reaching a person.
+# Twelve: six for that read-ahead at its widest, two for a photo viewer and its
+# own prefetch running at the same time in the same session, and the rest as
+# headroom for the next app that reads ahead. `test_leaseless_reads.py` derives
+# the floor from music-player.js itself, so raising the client's prefetch
+# without raising this fails rather than reaching a person.
#
# Generosity is cheap here and refusal is not. This is a fairness control among
# cooperating clients, not a security boundary — a client that lies gets twelve
@@ -445,11 +440,11 @@ class TransferSlots:
# size threshold separates them. What separates them is which function asked.
#
# What it costs, stated plainly: a client that lies — labelling a bulk download
-# as a view — gets two files at a time instead of its member cap. That is the
-# residual, it is bounded, it is audited, and it is the same kind of statement
-# as the cap itself. **This is a fairness control among cooperating clients**,
-# not a defence against a member determined to saturate a node's disk. The
-# answer to that member is `member revoke`.
+# as a view — gets this many files at a time instead of its member cap. That is
+# the residual, it is bounded, it is audited, and it is the same kind of
+# statement as the cap itself. **This is a fairness control among cooperating
+# clients**, not a defence against a member determined to saturate a node's
+# disk. The answer to that member is `member revoke`.
MAX_LEASELESS_IN_FLIGHT = 12
# A leaseless read has no "close" message, so it ends when the last chunk goes
diff --git a/packages/meshbay-node/src/meshbay_node/transport/webrtc_server.py b/packages/meshbay-node/src/meshbay_node/transport/webrtc_server.py
index 46fbba3..b3618b5 100644
--- a/packages/meshbay-node/src/meshbay_node/transport/webrtc_server.py
+++ b/packages/meshbay-node/src/meshbay_node/transport/webrtc_server.py
@@ -4822,9 +4822,9 @@ class WebRTCPeerSession:
# 11:54:19 reclaimed 919ebf54 (abandoned)
# 11:55:48 Upload complete: ... (3 522 297 517 bytes)
#
- # The download twin of this was fixed on 2026-09-08 (§12.1 of
- # ~/next/improve-downloads.md); the same omission was still here,
- # invisible until uploads started taking a real lease.
+ # `_do_file_request` marks a lease alive for exactly the same reason;
+ # both sides of a transfer have to say they are still moving, or the
+ # sweeper reclaims whichever one forgot.
tr = msg.get("tr")
if tr:
slots = self._ctx.get("_transfer_slots")
diff --git a/packages/meshbay-node/tests/test_leaseless_reads.py b/packages/meshbay-node/tests/test_leaseless_reads.py
index 64aed3d..6bd7f1f 100644
--- a/packages/meshbay-node/tests/test_leaseless_reads.py
+++ b/packages/meshbay-node/tests/test_leaseless_reads.py
@@ -3,9 +3,9 @@ Browsing is never subject to a transfer slot — and is not unbounded either.
**Operator decision, 2026-09-08:** a member must be able to browse a group that
is at capacity exactly as they browse an idle one. Not the poster grid, not the
-covers, not opening a photo or a PDF to look at it. §3.4 of
-~/next/improve-downloads.md satisfies that structurally: a transfer is what the
-transfers widget shows, and nothing else takes a slot.
+covers, not opening a photo or a PDF to look at it. That is met structurally
+rather than by judgement: a transfer is what the transfers widget shows, and
+nothing else takes a slot.
But "not leased" cannot mean "unbounded". With MNP 3.0 making leases
compulsory, a client that simply omits `tr` would otherwise transfer outside