Skip to content

Conversation

@sirtimid
Copy link
Contributor

@sirtimid sirtimid commented Jan 14, 2026

Summary

Refactors the remotes/ folder to improve code organization and separation of concerns:

  • Split into platform/ and kernel/ subfolders:

    • platform/ - Low-level transport infrastructure (connection management, message queuing, reconnection)
    • kernel/ - Kernel-level modules that interact with KernelStore, KernelQueue, and krefs
  • Refactored transport.ts into smaller focused modules:

    • peer-registry.ts - Manages per-peer state (channels, queues, location hints)
    • channel-reader.ts - Handles reading messages from peer channels
    • reconnection-orchestrator.ts - Manages reconnection loop logic
    • channel-utils.ts - Shared utilities for channel management

New folder structure

remotes/
├── kernel/
│   ├── OcapURLManager.ts
│   ├── RemoteHandle.ts
│   ├── RemoteManager.ts
│   └── remote-comms.ts
├── platform/
│   ├── channel-reader.ts
│   ├── channel-utils.ts
│   ├── connection-factory.ts
│   ├── message-queue.ts
│   ├── peer-registry.ts
│   ├── reconnection-orchestrator.ts
│   ├── reconnection.ts
│   ├── transport.test.ts
│   └── transport.ts
└── types.ts

Test plan

  • Add unit tests for new modules (peer-registry, channel-reader, reconnection-orchestrator, channel-utils)
  • Verify all existing tests pass
  • Manual testing of remote communication functionality

🤖 Generated with Claude Code


Note

Refactors remote comms into clearer layers and renames the transport initializer.

  • Split remotes/ into kernel/ and platform/, moving RemoteManager, RemoteHandle, OcapURLManager, and related imports under remotes/kernel/*
  • Introduce modular transport under remotes/platform/* (peer-registry, channel-reader, reconnection-orchestrator, channel-utils, connection-factory, etc.) and remove legacy remotes/network.ts
  • Rename and re-export initNetwork to initTransport; update all usages in browser and node platform services and tests
  • Update Kernel.ts and tests to new paths; adjust index.ts/index.test.ts to export initTransport
  • Add comprehensive unit tests for new platform modules; update existing tests to new APIs and paths

Written by Cursor Bugbot for commit cc6edbb. This will update automatically on new commits. Configure here.

sirtimid and others added 8 commits January 14, 2026 17:07
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Move RemoteManager, RemoteHandle, OcapURLManager, and remote-comms
to the kernel/ subdirectory. These modules interact with kernel
concepts like KernelStore, KernelQueue, and krefs.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Extract logical components from transport.ts (~1030 lines) into:
- peer-registry.ts: Manages per-peer state (channels, queues, hints)
- channel-reader.ts: Handles channel reading and message dispatch
- reconnection-orchestrator.ts: Manages reconnection loop logic

transport.ts now acts as a thin coordinator (~590 lines).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Deduplicate the reuseOrReturnChannel function that existed in both
transport.ts and reconnection-orchestrator.ts by extracting it to a
new channel-utils.ts module.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add comprehensive unit tests for the extracted platform modules:
- peer-registry.test.ts: Tests for PeerRegistry class
- channel-utils.test.ts: Tests for reuseOrReturnChannel utility
- channel-reader.test.ts: Tests for makeChannelReader function
- reconnection-orchestrator.test.ts: Tests for makeReconnectionOrchestrator function

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@sirtimid sirtimid force-pushed the sirtimid/refactor-remotes-folder-structure branch from e89d9b5 to 6642221 Compare January 14, 2026 16:08
sirtimid and others added 2 commits January 14, 2026 17:23
Align the function name with the file name (transport.ts).
Also clean up circular dependency pattern by reordering creation,
reducing from 2 eslint-disable comments to 1.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@sirtimid sirtimid marked this pull request as ready for review January 14, 2026 16:46
@sirtimid sirtimid requested a review from a team as a code owner January 14, 2026 16:46
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