Feature: Workspace Mirroring Phase 1 - Ghost Mirror Foundations #10 #12

Closed yangyangxie opened this issue 18 hours ago - 2 comments

@yangyangxie yangyangxie commented 18 hours ago

Goal

Establish the foundations for real-time file synchronization between the Orchestrator and Agent Nodes using the Ghost Mirror pattern.

Tasks

  • Protobuf Expansion: Define FileSyncRequest, FileChunk, and DirectoryManifest in agent.proto.
  • Ghost Mirror Service: Implement a basic storage manager on the Orchestrator to maintain local copies of node workspaces.
  • Server-to-Node Initial Sync: Implement a unidirectional push from the server to newly attached nodes.

References

✅ Implementation Complete

All 5 phases of the Ghost Mirror Workspace Synchronization system have been implemented, tested, and merged into master (commit 785b387).


Phase Summary

Phase 1 & 2 – Foundations & Real-time Sync

  • Implemented FSMirror service (Ghost Mirror) on the Orchestrator.
  • Bidirectional gRPC FileSync messages in agent.proto.
  • Local directory watchers on Agent Nodes (watchdog).
  • Node-to-server delta streaming and multi-node broadcast propagation.

Phase 3 – Conflict Handling & Optimization

  • .cortexignore and .gitignore filtering (shared_core/ignore.py).
  • Workspace LOCK/UNLOCK control to prevent AI/User race conditions.
  • Dynamic reloading of ignore rules on file change.

Phase 4 – Browser & Shell Skill Integration

  • ShellSkill is now CWD-aware: automatically executes commands inside the session's mirrored workspace.
  • BrowserSkill supports Download-to-Sync: browser downloads are saved directly into the mirrored workspace and propagated across the mesh.
  • session_id is now passed through TaskRequest and BrowserAction for context-aware execution.

Phase 5 – Resiliency & Automatic Recovery

  • SHA-256 hash-based drift detection on manifest reconciliation.
  • When a node reconnects after a disconnect, the server automatically detects which files are stale/missing and re-pushes them.
  • Validated with test_recovery.py: node disconnected, server updated, node reconnected → file automatically recovered ✅

Test Suite

  • poc-grpc-agent/test_mesh.py – Multi-node broadcast, ignore filtering, locking.
  • poc-grpc-agent/test_recovery.py – Auto-recovery on reconnection.

Conflict Handling Strategy (Documented)

  • Prevention: Workspace Locking during AI write operations.
  • Detection: SHA-256 manifest comparison on every (re)connect.
  • Recovery: Targeted file re-push for only the drifted files.
  • Future: Optimistic Concurrency (reject edits with stale parent hash) proposed for Phase 6.

✅ Implementation Complete - All 5 Phases Merged

All phases of the Ghost Mirror Workspace Synchronization system have been implemented, tested, and merged into master (commit 785b387).

Phase Summary

Phase 1 & 2 – Ghost Mirror foundations, bidirectional gRPC FileSync, watchdog-based delta streaming, multi-node broadcast.
Phase 3.cortexignore/.gitignore filtering, workspace LOCK/UNLOCK to prevent AI-user race conditions.
Phase 4 – ShellSkill CWD-aware execution in mirrored workspace; BrowserSkill Download-to-Sync; session_id passed through TaskRequest.
Phase 5 – SHA-256 hash drift detection; automatic file recovery on node reconnect; validated with test_recovery.py.

Conflict Strategy

  • Prevention: Workspace Locking during AI write phases.
  • Detection: SHA-256 manifest comparison on every (re)connect.
  • Recovery: Targeted re-push of only drifted files.

Test Suite

  • test_mesh.py – Multi-node sync, ignores, locking.
  • test_recovery.py – Auto-recovery on reconnection (PASSED ✅).
@yangyangxie yangyangxie closed this issue 16 hours ago
Labels

Priority
No priority
Milestone
No milestone
Assignee
No one assigned
1 participant
@yangyangxie