Relocate the ~6k-file docs tree from the repo root into plugins/document-navigator/docs/ so the plugin is self-contained and portable. docs/superpowers/ (specs and plans) stays at the repo root. Moved via cp+rm rather than git mv because directory rename() fails with EPERM on this WSL /mnt DrvFs mount; git rename-detection pairs the identical-content files at commit time. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
8.5 KiB
8.5 KiB
@suaveplan/drive-mesh-protocol - Wire protocol for chunk discovery, request, and delivery across the mesh. Three request forms (whole/specific/bitset), bitpacker-compressed presence bitsets, response presence piggyback, probabilistic trust model. Types + codecs + validators only — no runtime side effects.
Summary
Wire protocol for chunk discovery, request, and delivery across the mesh. Three envelope shapes (cd:request, cd:advertise, cd:response) with three request forms (whole / specific / bitset), bitpacker-compressed presence bitsets, response presence piggyback, and a probabilistic trust model. Types + codecs + selectors only — zero runtime side effects.
Documentation tree
- advertise — Encodes and decodes
cd:advertiseenvelope payloads — the gossip messages a peer emits to announce which chunks it cur… - bitset — Implements the wire-format bitset codec for the mesh protocol. Bitsets carry chunk presence (
cd:advertise) and chunk-… - common — Internal helpers shared by the four envelope codec modules (
request.ts,advertise.ts,response.ts,error.ts). C… - error — Encodes and decodes
cd:errorenvelopes — the responder-to-requester error channel that carries a structured `ChunkErr… - request — Encodes and decodes
cd:requestenvelope payloads for the chunk-request side of the mesh protocol. Owns the wire forma… - response — Encodes and decodes
cd:responseenvelope payloads — the responder-side messages that carry chunk bytes back to a requ… - monotonic — Implements
GenerationTracker, the receiver-side state machine that keeps the highest seengenerationper `(peerId,… - throttle — Implements
AdvertiseThrottle, the issuer-side rate limiter that caps outgoingcd:advertiseenvelopes at one per `(n… - schemas — (no submodules)
- envelope.schema — (no submodules)
- select — (no submodules)
- form — (no submodules)
- decay — Implements the probabilistic-skip decay logic (DMP-15) the request scheduler uses to decide whether to include a peer i…
- sample — Implements the adaptive sample-verification rate (DMP-17). On every incoming
cd:advertise, the protocol MAY request a… - score — Implements
TrustMap, the per-(peerId, fileId)trust state container the request scheduler indrive-meshuses to d… - error-codes — Frozen registry of error codes plus the error class for the
@suaveplan/drive-mesh-protocolpackage. Every rejection p…
- sample — Implements the adaptive sample-verification rate (DMP-17). On every incoming
cd:advertise, the protocol MAY request a… - score — Implements
TrustMap, the per-(peerId, fileId)trust state container the request scheduler indrive-meshuses to d… - error-codes — Frozen registry of error codes plus the error class for the
@suaveplan/drive-mesh-protocolpackage. Every rejection p… - envelope.schema — (no submodules)- select — (no submodules)- form — (no submodules)- decay — Implements the probabilistic-skip decay logic (DMP-15) the request scheduler uses to decide whether to include a peer i…
- sample — Implements the adaptive sample-verification rate (DMP-17). On every incoming
cd:advertise, the protocol MAY request a… - score — Implements
TrustMap, the per-(peerId, fileId)trust state container the request scheduler indrive-meshuses to d… - error-codes — Frozen registry of error codes plus the error class for the
@suaveplan/drive-mesh-protocolpackage. Every rejection p… - envelope.schema — (no submodules)- select — (no submodules)- form — (no submodules)- decay — Implements the probabilistic-skip decay logic (DMP-15) the request scheduler uses to decide whether to include a peer i…
- sample — Implements the adaptive sample-verification rate (DMP-17). On every incoming
cd:advertise, the protocol MAY request a… - score — Implements
TrustMap, the per-(peerId, fileId)trust state container the request scheduler indrive-meshuses to d… - error-codes — Frozen registry of error codes plus the error class for the
@suaveplan/drive-mesh-protocolpackage. Every rejection p… - envelope.schema — (no submodules)- select — (no submodules) - form — (no submodules)- decay — Implements the probabilistic-skip decay logic (DMP-15) the request scheduler uses to decide whether to include a peer i…
- sample — Implements the adaptive sample-verification rate (DMP-17). On every incoming
cd:advertise, the protocol MAY request a… - score — Implements
TrustMap, the per-(peerId, fileId)trust state container the request scheduler indrive-meshuses to d… - error-codes — Frozen registry of error codes plus the error class for the
@suaveplan/drive-mesh-protocolpackage. Every rejection p…
Install
bun add @suaveplan/drive-mesh-protocol
Quick start
import {
DMP_CODES,
DmpError,
selectForm,
selectWhole,
type ChunkRequestEnvelope,
} from "@suaveplan/drive-mesh-protocol";
// Pick the most compact request form for a list of missing chunks.
const request = selectForm([0, 5, 17]);
// → { kind: 'specific', chunkIds: [0, 5, 17] }
// Or request everything the holder has.
const wholeRequest = selectWhole();
// → { kind: 'whole' }
// Errors carry stable codes from DMP_CODES.
try {
selectForm([]);
} catch (err) {
if (err instanceof DmpError && err.code === DMP_CODES.EMPTY_REQUEST) {
console.error("use selectWhole() for empty-needed lists");
}
}
Modules
src/error-codes.md—DMP_CODESregistry andDmpErrorclass.src/select/form.md—selectForm,selectWhole,encodeBitset,decodeBitset, plus theSELECT_FORM_BITSET_THRESHOLDconstant.src/types/protocol.types.ts— wire envelope and payload shapes (ChunkRequest,ChunkRequestEnvelope,ChunkAdvertisePayload,ChunkResponsePayload,ChunkErrorPayload,TrustScore).
Subpath exports
@suaveplan/drive-mesh-protocol— full barrel.@suaveplan/drive-mesh-protocol/types— wire types only (no runtime).@suaveplan/drive-mesh-protocol/select— form-selection helpers and bitset codec.@suaveplan/drive-mesh-protocol/errors—DMP_CODES,DmpError.
Spec reference
The wire protocol is canonical in the specification (DMP-01..DMP-22). The architectural reference is docs/drive/mesh-protocol.md.
Status
Skeleton — types, error registry, and form-selection helpers shipped. The full codec layer (bitpacker-network framing, schema validation, trust scoring) lands in subsequent commits.