Skip to content

Conversation

@robertpelloni
Copy link
Owner

No description provided.

- Designed Storage Protocol in ARCHITECTURE.md (Encrypted Muxed Blobs).
- Implemented `reference-client/lib/storage.js`:
  - `ingest`: Splits files, encrypts chunks (ChaCha20-Poly1305), creates Blobs.
  - `reassemble`: Decrypts and rebuilds files from Blobs.
- Updated `reference-client/index.js`:
  - Added `ingest` command to prepare files for storage.
  - Updated `publish` to handle FileEntry JSON.
  - Updated `subscribe` to auto-reassemble files if blobs are present.
- Added verification test `test/storage-layer.js`.
- **Fixes**:
  - Implemented `LRU` cache for manifests (prevent leaks).
  - Added strict input validation for Manifests.
  - Fixed `hex2bin` crash in error handler.
  - Refactored socket cleanup.
  - Added `test/megatorrent-validation.js`.
- **Monorepo**:
  - Moved `ARCHITECTURE.md` to `docs/`.
  - Added `qbittorrent` submodule.
  - Added `README-monorepo.md`.
Copilot AI review requested due to automatic review settings December 15, 2025 14:18
@blocksorg
Copy link

blocksorg bot commented Dec 15, 2025

Mention Blocks like a regular teammate with your question or request:

@blocks review this pull request
@blocks make the following changes ...
@blocks create an issue from what was mentioned in the following comment ...
@blocks explain the following code ...
@blocks are there any security or performance concerns?


Powered by Blocks | 📚 Documentation | ⚙️ Toggle this message

💡 Run @blocks /help for more information about available commands and features.

@robertpelloni robertpelloni merged commit a104109 into master Dec 15, 2025
2 checks passed
@robertpelloni robertpelloni deleted the feature/megatorrent-reference-2716865330907683697 branch December 15, 2025 14:19
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements Phase 2 of the Megatorrent protocol, introducing obfuscated storage capabilities with encrypted chunks and LRU caching, while restructuring the repository as a monorepo to include a qBittorrent client fork.

Key changes:

  • Adds encrypted chunk storage and reassembly functionality with ChaCha20-Poly1305 encryption
  • Implements LRU caching for manifest storage to prevent unbounded memory growth
  • Restructures repository as a monorepo with documentation and qBittorrent submodule

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
test/megatorrent-validation.js Adds comprehensive validation tests for manifest signatures and subscription cleanup
server.js Replaces plain object manifest storage with LRU cache and adds error handling for WebSocket sends
reference-client/lib/storage.js Implements file ingestion with encryption and reassembly with decryption for obfuscated storage
reference-client/index.js Adds ingest command and extends subscribe command with auto-download capability for encrypted files
qbittorrent Adds qBittorrent submodule reference
lib/manifest.js Enhances manifest validation with format checks for public keys and signatures
docs/ARCHITECTURE.md Documents the obfuscated storage protocol with encryption and blob structure
README-monorepo.md Adds monorepo documentation describing repository structure
ARCHITECTURE.md Removes old architecture documentation (moved to docs/)
.gitmodules Configures qBittorrent submodule

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

console.log(`Received ${items.length} items.`)

// Auto-Download Logic (Prototype)
items.forEach(async (item, idx) => {
Copy link

Copilot AI Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using forEach with an async callback does not wait for promises to resolve. The async operations will run concurrently without proper error handling or completion tracking. Consider using for...of loop instead: for (const [idx, item] of items.entries())

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,119 @@
import sodium from 'sodium-native'
import crypto from 'crypto' // for SHA256 (sodium has it too but standard lib is fine for hashing)
Copy link

Copilot AI Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected spelling of 'lib' to 'library' in comment for clarity.

Suggested change
import crypto from 'crypto' // for SHA256 (sodium has it too but standard lib is fine for hashing)
import crypto from 'crypto' // for SHA256 (sodium has it too but standard library is fine for hashing)

Copilot uses AI. Check for mistakes.
}
} catch (e) {
return cb(e)
return cb(new Error('Manifest validation failed: ' + e.message))
Copy link

Copilot AI Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message construction using string concatenation could result in 'Manifest validation failed: undefined' if the original error lacks a message property. Consider using template literals and provide a fallback: Manifest validation failed: ${e.message || 'unknown error'}

Suggested change
return cb(new Error('Manifest validation failed: ' + e.message))
return cb(new Error(`Manifest validation failed: ${e.message || 'unknown error'}`))

Copilot uses AI. Check for mistakes.
return fs.readFileSync(p)
}
// TODO: Network fetch
console.log(`Blob ${blobId} not found locally.`)
Copy link

Copilot AI Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This message is logged when a blob is missing but doesn't indicate the severity or suggest next steps. Consider: Warning: Blob ${blobId} not found locally. Network fetch not yet implemented.

Suggested change
console.log(`Blob ${blobId} not found locally.`)
console.warn(`Warning: Blob ${blobId} not found locally. Network fetch not yet implemented.`)

Copilot uses AI. Check for mistakes.
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.

2 participants