import threading

class GlobalWorkPool:
    """Thread-safe pool of unassigned tasks that can be claimed by any node."""
    def __init__(self):
        self.lock = threading.Lock()
        self.available = {"shared-001": "uname -a", "shared-002": "uptime"}
    
    def claim(self, task_id, node_id):
        """Allows a node to pull a specific task from the pool."""
        with self.lock:
            if task_id in self.available:
                print(f"    [📦] Task {task_id} Claimed by {node_id}")
                return True, self.available.pop(task_id)
            return False, None
    
    def list_available(self):
        """Returns IDs of all currently available unclaimed tasks."""
        with self.lock:
            return list(self.available.keys())
