Skip to content

Instantly share code, notes, and snippets.

@JarbasAl
Last active December 31, 2024 17:35
Show Gist options
  • Select an option

  • Save JarbasAl/99d7a4545ce0355e606c277b21abc729 to your computer and use it in GitHub Desktop.

Select an option

Save JarbasAl/99d7a4545ce0355e606c277b21abc729 to your computer and use it in GitHub Desktop.
hivemind security model

Main Concepts of the Pyramid Network

image

  1. Hierarchical Trust:

    • Each node only trusts the node directly above it (higher in the hierarchy).
    • Nodes do not have full knowledge of the entire network but operate under a limited scope, making the system more secure by design.
  2. Upward Flow of Information:

    • Any information can move upward in the hierarchy, but it is authorized, filtered and processed by every intermediary node.
    • The top (e.g., AGI or high-command node) only receives critical information that lower nodes cannot resolve.
  3. Downward Flow of Information:

    • Information moving downward (e.g., commands or private data) is scrutinized by the sender to prevent unauthorized or sensitive data from leaking.
    • Lower Nodes always trust incoming data, any received commands are executed
  4. Distributed Intelligence:

    • Each node acts as an independent agent, capable of handling tasks autonomously or escalating them to smarter nodes.
    • The system ensures redundancy and fallback mechanisms by escalating problems to progressively smarter or higher-tier nodes.
  5. Limited Knowledge:

    • A node knows about its direct superior and potentially its immediate peers but not the full network topology.
    • This isolation ensures that compromising one node does not expose the entire system.

Key Message Types in the Pyramid Model

The HiveMind message types are designed to facilitate this hierarchical communication:

  • PROPAGATE: Messages that try to reach as much of the network as possible. "send everywhere"
  • ESCALATE: Reserved for critical situations requiring immediate attention by higher-level nodes. "send up"
  • BROADCAST: When a higher-level node wants to send a message to all lower-level nodes. "send down"

How Nodes Handle Messages

  1. Incoming Requests (Upward Flow):

    • A node evaluates incoming messages and decides:
      • Can it handle the request independently?
      • Should it escalate the message upward to a smarter or higher node?
      • Should it discard or filter the message (e.g., if it's spam or irrelevant)?
      • Should it ban the sender?
  2. Outgoing Commands (Downward Flow):

    • Commands or data from higher nodes are inspected and stripped of sensitive information before being passed to lower nodes.
    • Each node enforces strict checks to ensure that only the necessary payload reaches subordinate nodes.
  3. Fallback Mechanism:

    • If a node lacks the capability to process a message, it escalates it to a higher node.
    • This ensures that the network can handle any request, even if the initial node is "dumb."

Example Workflow

  • Scenario: A user asks a voice assistant (node A) a question it cannot answer.
    1. Node A (Basic OVOS):
      • Receives the question and checks if it has the skills to answer.
      • If not, it formats the message as ESCALATE and sends it to its parent node (node B).
    2. Node B (Smarter OVOS):
      • Processes the message. If it can handle it, it responds directly.
      • If not, it escalates the message to node C.
    3. Node C (AGI):
      • Handles the question and returns a response.
    4. Response Flow:
      • The response is passed down through nodes B and A, with each node verifying that no sensitive information leaks.

Security and Scalability

  1. Security Model:

    • Each node acts as a security checkpoint.
    • The design ensures that sensitive data only flows downward with proper scrutiny, and no secrets are exposed unnecessarily.
  2. Scalability:

    • New nodes can be added to the network without requiring global reconfiguration.
    • The trust model ensures that only immediate relationships need to be defined (parent-child or peer-peer).

Design Considerations

  1. Message Routing:

    • Message types and routing logic are designed to enforce the hierarchical trust model.
  2. Node Isolation:

    • Limit a node's visibility of the network to its direct parent and peers, ensuring robustness against compromise.
  3. Payload Filtering:

    • Implement strict payload validation and redaction mechanisms to ensure that sensitive data does not flow downward unchecked.
  4. Fallback Mechanisms:

    • Use the ESCALATE type to ensure that unresolved requests are always addressed at higher levels.
  5. Auditing and Logs:

    • Maintain logs at each node for message flow, ensuring transparency and traceability in case of anomalies.
  6. Broadcast with Control (Propagate):

    • Wide-reaching messages, but with filtering by higher nodes to maintain efficiency and security.
  7. Group Orders (Broadcast):

    • Wide-reaching commands or announcemnts, that reach only lower nodes.
  8. Secure Escalation (Escalate):

    • Trusted routing ensures that sensitive or critical information only flows to competent and trusted nodes.
  9. Command Authority (Down):

    • Commands from trusted nodes are always followed, ensuring a structured and reliable chain of authority.
  10. Optional Handling (Up):

  • Nodes retain autonomy in deciding how to handle requests, preserving system flexibility.

This approach makes the system resilient, secure, and capable of handling diverse tasks in a distributed and hierarchical environment.


"Up" vs. "Down"

  1. "Up" (Requests):

    • Requests for assistance, data, or processing sent to a node higher in the hierarchy.
    • Behavior:
      • A node receiving an "up" request may choose to:
        • Ignore it entirely.
        • Handle it locally.
        • Forward it further upward.
    • This loose coupling ensures that higher-level nodes are not overwhelmed by unnecessary requests, as lower-level nodes should ideally filter them first.
  2. "Down" (Commands):

    • Directives from a higher node to a lower node.
    • Behavior:
      • Commands must always be obeyed, as they represent trusted authority in the hierarchy.
      • Scrutiny mechanisms ensure that "down" commands are sanitized, secure, and appropriate for the recipient.

Message Types in Context

1. Propagate

  • Purpose: Broadcasts a message to all nodes in the network or as far as possible.
  • Behavior:
    • Nodes higher in the hierarchy can decide to filter the propagation and may not route to certain nodes.
    • Typically used for:
      • Network discovery (e.g., "hello" or "ping").
      • Status updates or general announcements (e.g., "system online").
    • It is not guaranteed to reach every node but is designed to have wide coverage.
  • Example Use Case:
    • A new node joins the network and sends a "hello" message to introduce itself.

2. Escalate

  • Purpose: Sends a message directly to a more trusted node, bypassing untrusted intermediaries.
  • Behavior:
    • Ensures the message reaches a more competent or authoritative node (e.g., higher in the hierarchy).
    • Cannot be intercepted or redirected to untrusted nodes.
    • Typically used for:
      • Critical issues that require secure handling (e.g., "security breach" or "unknown entity detected").
      • Requests for help that lower nodes are incapable of addressing.
  • Example Use Case:
    • A low-level node detects a potential threat and escalates the message to its parent or an AGI for validation.


Example Scenarios

1. Propagation for Network Discovery

  • A new node joins the network and sends a "propagate: hello" message.
  • Behavior:
    • The message travels outward through the network.
    • Higher nodes can choose not to propagate it further if they see no need.
    • Lower nodes receive the message and may respond with a status or acknowledgment.

2. Escalation for Security Breach

  • A low-level node detects an unknown entity trying to access the network.
  • It sends an "escalate: security_alert" message to its parent node.
  • Behavior:
    • The message is securely routed to a higher, trusted node.
    • Untrusted nodes or peers cannot intercept it.
    • The trusted node can take appropriate action, such as blacklisting the entity.

3. Handling a User Query

  • A user asks a question the local node cannot answer:
    • Upward (Request): The local node sends the query as an "up" message.
    • Escalate: If no response is received, it escalates to a higher node for a definitive answer.
    • Downward (Command): The response comes back as a "down" command with the answer.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment