Skip to content

feat: add remote coasts infrastructure (Phase 0)#168

Draft
VAIBHAVSING wants to merge 10 commits intocoast-guard:mainfrom
VAIBHAVSING:feat/remote-coasts-phase0
Draft

feat: add remote coasts infrastructure (Phase 0)#168
VAIBHAVSING wants to merge 10 commits intocoast-guard:mainfrom
VAIBHAVSING:feat/remote-coasts-phase0

Conversation

@VAIBHAVSING
Copy link
Copy Markdown
Contributor

@VAIBHAVSING VAIBHAVSING commented Mar 28, 2026

No description provided.

@VAIBHAVSING VAIBHAVSING marked this pull request as draft March 28, 2026 18:47
@VAIBHAVSING VAIBHAVSING reopened this Mar 28, 2026
@jamiesunderland
Copy link
Copy Markdown
Contributor

@VAIBHAVSING I'll play around with this tomorrow. I have an idea for a coast-client and coast-server module. That I want to write down and make sure this hooks into nicely.

Add complete Mutagen-based file synchronization for Remote Coasts:

Core Implementation:
- MutagenManager for sync session lifecycle (create, pause, resume, flush, terminate)
- One-way sync (local → remote) with 'one-way-safe' mode
- Session naming: coast-<project>-<branch>-<remote>
- Remote workspace path: ~/coast-workspaces/<project>/<branch>/
- Support for .coastignore patterns (node_modules, .git, *.log)
- State persistence in sync_sessions table

CLI Commands:
- coast sync create <project> <remote> --local-path <path> --branch <branch>
- coast sync status [project] - list active sync sessions
- coast sync pause/resume <project> - control sync
- coast sync flush <project> - force immediate sync
- coast sync terminate <project> - stop and remove session

Protocol:
- SyncCreateRequest/Response with local_path, branch, remote
- SyncStatusRequest/Response with session info
- SyncPauseRequest/Response, SyncResumeRequest/Response
- SyncFlushRequest/Response, SyncTerminateRequest/Response

Testing:
- Comprehensive test scripts (test_sync_simple.sh, test_sync_quick.sh)
- Setup automation (setup_test.sh, install_mutagen.sh)
- Detailed testing guides (QUICK_TEST.md, TEST_SYNC.md)
- Tests: initial sync, real-time updates, ignore patterns, pause/resume

Technical Details:
- Mutagen ~100MB on local, ~10MB agent on remote (auto-installed)
- Uses SSH for transport with optional key configuration
- Sync status tracking: Initial, Syncing, Paused, Error
- Handler integration in handlers/remote.rs
- Analytics support for all sync operations

Phase 2 complete - workspace sync fully functional.
Next: Phase 3 (remote build/run), Phase 4 (remote exec/logs)
- Installs Docker, Docker Compose, and Mutagen on remote VM
- Builds coastd-dev binary on remote (avoids glibc mismatch)
- Starts daemon and creates workspace directories
- Supports manual remote development environment setup
Add remote daemon client and request forwarding infrastructure:

- Create RemoteDaemonClient for communicating with remote daemons
  over SSH tunnels (coast-daemon/src/remote/client.rs)
- Add get_remote_route() to check project mode and tunnel status
- Add ensure_synced() to flush Mutagen before remote operations
- Add forward_streaming_to_remote() for proxying streaming responses
- Modify handle_build_streaming() to route to remote when configured
- Modify handle_run_streaming() to route to remote when configured

Flow: CLI -> Local Daemon -> Check Mode -> Sync Flush -> Forward via
SSH Tunnel -> Remote Daemon -> Proxy responses back

Also includes Phase 2 fixes:
- Fix get_sync_session method name in handlers
- Fix truncate_str test assertion
- Clean up unused imports
Add remote_name field to CoastInstance to track which remote an instance
is running on. This enables routing exec and logs requests to the correct
remote daemon based on instance location.

Key changes:
- Add remote_name: Option<String> to CoastInstance struct
- Add DB migration for remote_name column in instances table
- Add get_instance_remote_route() to look up instance's remote location
- Add forward_to_remote() for non-streaming requests (exec, logs)
- Add forward_logs_streaming_to_remote() for streaming logs
- Modify handle_connection to route exec/logs based on instance location
- Update forward_run_to_remote to create shadow instance records locally
  with remote_name set, enabling future exec/logs routing
- Fix all test files to include remote_name: None field

Phase 4 routes based on instance location (remote_name field), unlike
Phase 3 which routes based on project mode.
feat: implement workspace sync with Mutagen (Phase 2)
@VAIBHAVSING
Copy link
Copy Markdown
Contributor Author

for local testing

https://github.com/VAIBHAVSING/coasts/blob/feat/remote-coasts-phase0/REMOTE_COAST_TEST.md

but ubuntu vm is must as of now

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