Skip to main content

Federated, secure, and AI-optimized distributed computing platform

Project description

๐Ÿฆ Flock ย โ€ขย  A Distributed Computing Framework for Python


PyPI

Python

Downloads

License

CI

Tests

Get Started ย โ€ขย  Quick Start ย โ€ขย  Architecture ย โ€ขย  API Reference ย โ€ขย  Configuration


Overview

Flock is a fully-typed Python framework for building systems that run across multiple machines. It bundles the components a distributed system normally needs โ€” Raft consensus, leader election, cluster membership, a message bus, scheduling, and security โ€” into one importable package, so you wire up services with dependency injection instead of standing up separate infrastructure.

It's built around 42 focused subsystems (flock.consensus, flock.scheduler, flock.security, flock.workflow, and others), each independently testable and typed under mypy --strict.

Language Python 3.11+
Core dependency footprint pydantic, structlog, msgpack
Consensus model Raft (leader election, log replication, snapshots)
Transport Pluggable โ€” TCP built in
Install pip install flock-p2p

Table of Contents

๐Ÿš€ Getting Started

๐Ÿ—๏ธ Reference

๐Ÿ“ฆ Project


The Story Behind Flock

๐Ÿ’ก A single computer is no longer enough.

Whether it's traffic outgrowing one server, data too big for one machine, or uptime that can't depend on a single point of failure โ€” the fix is always the same: run your software across multiple computers working together as one.

That's distributed computing. It quietly powers Netflix, Google, WhatsApp, and Uber. But here's what most tutorials leave out:

"Building a distributed system from scratch is one of the hardest things in software engineering."


๐Ÿฉน Fault Tolerance

What happens when a server crashes mid-op?

๐Ÿ‘‘ Leader Election

Who's in charge, with no single source of truth?

๐Ÿ”„ Consistency

How do 5 machines agree on the same data?

๐Ÿ”’ Security

How do you stop traffic interception?

๐Ÿ“Š Observability

How do you catch failures before users do?


These problems have occupied computer scientists for decades. Google and Amazon threw years of engineering effort at solving them internally โ€” most teams don't have that runway.

That's why Flock exists โ€” one pip install for infrastructure that used to take enterprise teams years to build.

๐Ÿ“– Read the full story

Flock was born from a simple frustration: developers shouldn't have to spend months building infrastructure before they can start building their actual product โ€” especially when the Python ecosystem had no single, cohesive package that solved this.

The tools that solve consensus, replication, security, and observability have always existed โ€” but scattered across research papers, expensive enterprise platforms, or locked inside the infrastructure teams of large tech companies. Nothing brought them together for the average Python developer.

Flock closes that gap: open-source, fully typed, and built to give any developer the same caliber of distributed-systems infrastructure that used to be exclusive to the biggest engineering teams in the world.


What Problem Does Flock Solve?

Flock provides a complete distributed systems stack in Python โ€” mapping familiar real-world problems to concrete solutions:

Real-World Problem Computer Science Term Flock Solution
Who is in charge? Leader Election ConsensusService (Raft algorithm)
Stay online when a server dies Fault Tolerance Automatic failover + replication
All servers agree on the same data Consensus Raft log replication + state machine
Prevent data loss on crashes Durability Write-Ahead Log (WAL) + snapshots
Find other servers automatically Service Discovery DiscoveryService
Secure communication mTLS / Zero-Trust SecurityService
Know when things go wrong Observability Metrics, tracing, alerts, dashboards
Scale up when traffic spikes Autoscaling AI-powered OrchestratorService
Run jobs across many servers Distributed Scheduling SchedulerService + PlacementEngine
Recover from disasters Disaster Recovery RecoveryService with backups + PITR
๐Ÿณ Prefer an analogy? The Restaurant Kitchen Problem

Imagine running a restaurant. On a quiet Tuesday, one chef handles everything. On a Friday night with 200 customers, that one chef becomes a bottleneck โ€” you need multiple chefs working together, which raises new problems:

  • Who's the head chef, and who takes over if they go home sick? โ†’ leader election
  • A chef drops a dish mid-prep โ€” who picks it up where it was left off? โ†’ fault tolerance
  • How do two chefs avoid cooking the same order twice? โ†’ consensus
  • How do you stop the dishwasher from accessing the safe? โ†’ security & RBAC
  • How do you know which chef is overloaded, in real time? โ†’ observability

Flock solves all of these โ€” not for kitchens, but for any system that needs to run across multiple servers.


Who Is Flock For?

Flock scales from a student reading source code for the first time to an enterprise team running hundreds of clusters.

๐ŸŽ“ Students & Learners ๐Ÿ‘จโ€๐Ÿ’ป Developers & Side Projects ๐Ÿข Startups & Small Teams ๐Ÿญ Enterprise ๐Ÿ”ฌ Researchers & Data Scientists

๐ŸŽ“ Students & Learners

See a real, working implementation of Raft consensus, leader election, distributed state machines, and service meshes โ€” not just theory. Every subsystem is documented, strictly typed, and built to textbook standards, so the source code doubles as a reference implementation.

pip install flock-p2p
python -c "from flock.consensus import ConsensusService; help(ConsensusService)"
๐Ÿ‘จโ€๐Ÿ’ป Individual Developers & Side Projects

Skip weeks of reading consensus papers and debugging race conditions โ€” install Flock and have a working distributed foundation in an afternoon.

Use cases: personal projects outgrowing a single VPS ยท home lab clusters (Raspberry Pi farms) ยท distributed data pipelines ยท multiplayer game server backends ยท distributed web scrapers

๐Ÿข Startups & Small Engineering Teams

A team of 2โ€“5 engineers doesn't need to become distributed-systems experts to run production infrastructure. Consensus, replication, security, and observability are already solved.

Use cases: multi-region SaaS deployment ยท distributed task queues with guaranteed execution ยท real-time multi-node data processing ยท highly available APIs with automatic failover

๐Ÿญ Enterprise & Large Organizations

Built-in support for multi-cloud federation, policy-as-code governance, compliance auditing, fleet management, RBAC, secrets vaulting, and intrusion detection โ€” capabilities most companies otherwise build in-house over years.

Use cases: multi-cloud infrastructure across AWS/GCP/Azure ยท compliance auditing (HIPAA, SOC2) ยท fleet management across hundreds of nodes ยท disaster recovery with point-in-time restore ยท policy-enforced workload governance

๐Ÿ”ฌ Researchers & Data Scientists

Distribute an ML training job across multiple GPUs or machines, or build a data pipeline that processes terabytes of data โ€” Flock provides the distributed execution substrate so you can focus on the algorithm, not the infrastructure.


How Does Flock Help You?

The Traditional Approach (Without Flock)

Building the same distributed foundation from scratch typically looks like this:

Timeline What You're Building The Hard Part
Month 1โ€“2 A consensus algorithm (Raft or Paxos) Debugging election edge cases, split-brain scenarios
Month 3 A membership registry Heartbeats, node join/leave, network partitions
Month 4 A message bus Protocol design, serialization, versioning, backward compatibility
Month 5โ€“6 Security TLS, authentication, authorization, secrets management
Month 7โ€“8 Observability Metrics collection, distributed tracing, alerting
Month 9+ Finally โ€” your actual product โ€”

โฑ๏ธ ~9 months before writing a single line of business logic โ€” for a skilled team.


The Flock Approach

pip install flock-p2p   # 30 seconds
# A few minutes to a working distributed system
from flock.consensus import ConsensusService
from flock.events.bus import EventBus
from flock.messaging.bus import MessageBus

consensus = ConsensusService("node-1", membership, message_bus, event_bus)
await consensus.start()

# You now have Raft consensus, leader election, log replication,
# fault tolerance, and event publishing. Start building your product.

โฑ๏ธ Time to a working distributed foundation: under an hour.


The Difference, By the Numbers

Metric Build Yourself With Flock
Time to first working cluster Months Minutes
Infrastructure code you maintain Thousands of lines Already written
Test coverage for edge cases You write it all 629 tests included
Consensus algorithm correctness Your responsibility Implemented Raft, unit-tested
Security posture Your responsibility Built-in mTLS, RBAC, secrets vault
Ongoing maintenance On you Shared with the OSS community

โœจ Features

CORE PLATFORM


โšก Full Raft Consensus

Leader election, log replication, state machine, term management, log compaction

๐ŸŒ Cluster Membership

Node discovery, heartbeat health monitoring, live membership registry

๐Ÿ”„ Distributed State Machine

Consistent replicated state with snapshotting and WAL

๐Ÿ“ก Transport-Independent Messaging

Pluggable transport (TCP built-in); typed message routing

๐Ÿ—‚๏ธ DataGrid

In-memory distributed KV store โ€” replication, partitioning, failover


EXECUTION & SCHEDULING


๐Ÿง  AI-Powered Orchestration

ML-based placement, predictive autoscaling, anomaly detection

๐Ÿ“‹ Workflow Engine

DAG workflows with checkpointing, parallelism, failure recovery

โฐ Advanced Scheduler

Cron, event-driven, deadline-aware scheduling

๐ŸŽฏ Constraint-Aware Placement

CPU/memory/affinity/anti-affinity placement engine


ENTERPRISE INFRASTRUCTURE


๐Ÿ”’ Zero-Trust Security

mTLS, RBAC, certificate management, credential rotation, intrusion detection

๐Ÿ›ก๏ธ Secrets Vault

Encrypted storage, key rotation, compliance auditing

๐Ÿ“Š Full Observability

Tracing, structured logging, metrics, alerts, profiling, dashboards

๐ŸŒ Multi-Cloud Federation

Cross-region federation, latency-aware routing, trust handshakes

๐Ÿ›๏ธ Control Plane

Fleet management, cluster enrollment, org governance

๐Ÿ“œ Policy-as-Code

Declarative policy compiler, rule engine, compliance enforcement

๐Ÿ’พ Disaster Recovery

Automated snapshots, incremental backups, PITR restore

๐Ÿ›’ Plugin Marketplace

Package registry, dependency resolution, sandboxed execution

๐Ÿš€ Deployment Automation

Docker/K8s manifests, rolling updates, rollback


DEVELOPER EXPERIENCE

โœ… 635 Tests

Full regression coverage, 42 subsystems

๐Ÿ”ค Fully Typed

mypy --strict clean, 390 source files

๐Ÿ“ฆ Single Install

pip install flock-p2p

๐Ÿ–ฅ๏ธ TUI Dashboard

Keyboard-driven CLI dashboard (flock)

๐Ÿ Python 3.11+

Modern Python, no legacy baggage


๐Ÿ“ฆ Installation

pip install flock-p2p

๐Ÿ–ฅ๏ธ Interactive CLI Dashboard

Once installed, you can immediately launch the interactive TUI onboarding dashboard by running:

flock

This starts a keyboard-driven, in-place terminal dashboard that lets you run diagnostics, launch local cluster simulations, view examples, check version details, and access documentation.

Requirements

Dependency Version Purpose
Python โ‰ฅ 3.11 Runtime
pydantic โ‰ฅ 2.0.0 Data validation and models
structlog โ‰ฅ 23.1.0 Structured logging
msgpack โ‰ฅ 1.0.0 Binary serialization

Development Installation

For contributing or running the test suite locally:

1. Clone the repository

git clone https://github.com/Ashish6298/Flock.git

2. Enter the project directory

cd Flock

3. Install in editable mode with dev dependencies

pip install -e .[dev]

Dev extras include: pytest ยท pytest-asyncio ยท mypy ยท black ยท ruff


๐Ÿš€ Quick Start ย โ€ขย  Three examples. Each one runnable in under a minute.

๐Ÿงฑ Start a Cluster

Raft consensus, leader election

๐Ÿ›๏ธ Join the Control Plane

Fleet enrollment & governance

๐Ÿ“‹ Submit a Workflow

DAG-based task execution


1๏ธโƒฃ Start a Single-Node Cluster

Spin up Raft consensus, elect a leader, and commit your first log entry.

Show code
import asyncio
from unittest.mock import MagicMock
from flock.events.bus import EventBus
from flock.messaging.bus import MessageBus
from flock.consensus import ConsensusService
from flock.cluster.registry import MembershipRegistry
from flock.cluster.models import NodeMember, ClusterMemberStatus

async def main() -> None:
    # Wire up core infrastructure
    event_bus = EventBus()
    transport = MagicMock()       # Replace with TCPTransport in production
    serializer = MagicMock()      # Replace with JsonSerializer in production
    message_bus = MessageBus(transport, serializer)

    # Build membership registry
    registry = MembershipRegistry()
    registry.register(NodeMember(
        node_id="node-1",
        host="127.0.0.1",
        port=9000,
        status=ClusterMemberStatus.ACTIVE,
    ))

    # Start Raft consensus
    consensus = ConsensusService(
        node_id="node-1",
        membership=registry,
        message_bus=message_bus,
        event_bus=event_bus,
    )
    await consensus.start()

    # Submit a command (only succeeds if this node is the leader)
    if consensus.is_leader():
        entry = await consensus.submit_command(b"hello-world")
        print(f"Committed log entry: {entry}")

    await consensus.stop()

asyncio.run(main())

2๏ธโƒฃ Register a Cluster with the Control Plane

Enroll a cluster into a fleet with labels, versioning, and active feature tracking.

Show code
import asyncio
from flock.events.bus import EventBus
from flock.messaging.bus import MessageBus
from flock.controlplane.service import ControlPlaneService
from flock.controlplane.models import EnrolledCluster
from unittest.mock import MagicMock

async def main() -> None:
    event_bus = EventBus()
    message_bus = MessageBus(MagicMock(), MagicMock())

    cp = ControlPlaneService(
        node_id="coordinator",
        message_bus=message_bus,
        event_bus=event_bus,
    )
    await cp.start()

    cluster = EnrolledCluster(
        cluster_id="cluster-east",
        fleet_id="fleet-prod",
        name="US East Compute",
        version="1.0.0",
        labels={"region": "us-east-1", "tier": "prod"},
        features_active=["Consensus", "Security", "Observability"],
        last_seen=0.0,
    )
    cp.coordinator.clusters.enroll_cluster(cluster)
    print(f"Cluster enrolled: {cluster.name}")

    await cp.stop()

asyncio.run(main())

3๏ธโƒฃ Submit a Distributed Workflow

Define a DAG with dependencies and submit it for checkpointed execution.

Show code
import asyncio
from flock.workflow.service import WorkflowService
from flock.workflow.models import WorkflowDefinition, WorkflowStep
from flock.events.bus import EventBus
from flock.messaging.bus import MessageBus
from flock.storage.backend import StorageBackend
from unittest.mock import MagicMock

async def main() -> None:
    storage = StorageBackend()
    event_bus = EventBus()
    message_bus = MessageBus(MagicMock(), MagicMock())

    workflow_svc = WorkflowService(
        node_id="node-1",
        storage_backend=storage,
        message_bus=message_bus,
        event_bus=event_bus,
    )
    await workflow_svc.start()

    # Define a two-step DAG workflow
    wf = WorkflowDefinition(
        workflow_id="wf-001",
        name="data-pipeline",
        steps=[
            WorkflowStep(step_id="ingest", name="Ingest Data", dependencies=[]),
            WorkflowStep(step_id="transform", name="Transform", dependencies=["ingest"]),
        ],
    )
    await workflow_svc.submit(wf)
    await workflow_svc.stop()

asyncio.run(main())

๐Ÿ—๏ธ Architecture

Flock is a distributed, event-driven platform built around a strong consistency core. The architecture connects application interfaces, coordination services, cluster nodes, and persistence layers through a unified event graph.

Flock Architecture


โœจ Design Principles

A great architecture isn't defined by frameworksโ€”it's defined by the principles that guide every design decision.

These core principles ensure the system remains modular, scalable, maintainable, and easy to evolve as new requirements emerge.


Transport Independence

Build once. Change the transport anytime.

Business logic communicates exclusively through the MessageBus, never with TCP, UDP, gRPC, WebSockets, or any other transport directly.

The transport layer becomes an implementation detailโ€”not a dependency.

โœ… Why it matters

  • Switch communication protocols without touching business logic
  • Use an in-memory transport for lightning-fast tests
  • Keep networking concerns isolated from the domain
  • Add new transports with minimal effort

๐Ÿ’ก Guiding Principle Infrastructure should be replaceable without affecting domain logic.


Event-Driven Architecture

Components react to eventsโ€”not to each other.

Every meaningful state transition publishes a strongly typed event through the EventBus.

Any number of subscribers can respond independently, allowing the system to grow without creating tight coupling.

๐Ÿ”„ How it works

Service A
    โ”‚
    โ–ผ
Publishes Event
    โ”‚
    โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Subscriber A โ”‚ Subscriber B โ”‚ Subscriber C โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

โœ… Why it matters

  • Loose coupling between components
  • Add new features without modifying existing services
  • Natural support for asynchronous workflows
  • Independent testing of event handlers

๐Ÿ’ก Guiding Principle Publish events instead of invoking services directly.


Immutable Domain Models

State is createdโ€”not modified.

Every domain object is implemented using:

@dataclass(frozen=True)

Instead of changing existing objects, each state transition creates a new immutable instance representing the updated state.

๐Ÿ”„ Example

Order(status="Pending")
          โ”‚
          โ–ผ
Order(status="Shipped")

The original object remains unchanged.

โœ… Why it matters

  • Predictable behavior
  • Safer concurrent execution
  • Easier debugging
  • Fewer unintended side effects

๐Ÿ’ก Guiding Principle Domain objects represent valuesโ€”not mutable state.


Thread Safety

Concurrency is a design requirementโ€”not an afterthought.

Whenever shared mutable state exists, access is synchronized using:

threading.RLock()

This guarantees correctness even under concurrent workloads.

โœ… Why it matters

  • Prevent race conditions
  • Preserve consistent application state
  • Safe multi-threaded execution
  • Reliable behavior under load

๐Ÿ’ก Guiding Principle Shared mutable state must always be synchronized.


SOLID & Dependency Inversion

Depend on abstractionsโ€”not implementations.

Services receive all dependencies through constructor injection, rather than creating infrastructure internally.

This clean separation keeps business logic independent from implementation details.

๐Ÿ”„ Dependency Flow

Business Service
       โ”‚
       โ–ผ
Interface (Abstraction)
       โ”‚
       โ–ผ
Concrete Implementation

โœ… Why it matters

  • Highly testable services
  • Easily replace implementations
  • Clear separation of concerns
  • Long-term maintainability

๐Ÿ’ก Guiding Principle Services should never construct their own infrastructure.


Principles at a Glance

Principle Purpose
Transport Independence Decouple communication from transport protocols.
Event-Driven Architecture Enable collaboration through published events instead of direct calls.
Immutable Domain Models Create predictable, side-effect-free state transitions.
Thread Safety Ensure correctness under concurrent execution.
SOLID & Dependency Inversion Keep services modular, testable, and infrastructure-agnostic.

How They Work Together

                +--------------------+
                |   Business Logic   |
                +---------+----------+
                          โ”‚
          depends only on abstractions
                          โ”‚
                          โ–ผ
                 +----------------+
                 |  Message Bus   |
                 +-------+--------+
                         โ”‚
        publishes events โ”‚
                         โ–ผ
                 +----------------+
                 |   Event Bus    |
                 +-------+--------+
                         โ”‚
          โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
          โ–ผ              โ–ผ              โ–ผ
     Service A      Service B      Service C
          โ”‚              โ”‚              โ”‚
          โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                         โ–ผ
                Immutable Domain Models
                         โ”‚
                Thread-safe execution

The Bigger Picture

Each principle reinforces the others:

  • Transport Independence keeps infrastructure replaceable.
  • Events keep services loosely coupled.
  • Immutability makes state predictable.
  • Thread Safety ensures correctness under concurrency.
  • Dependency Inversion keeps the architecture clean and testable.

Together, they create a system that is:

Modular โ€ข Scalable โ€ข Resilient โ€ข Testable โ€ข Extensible โ€ข Future-Proof

๐Ÿ’™ Good architecture isn't about making today's code workโ€”it's about making tomorrow's changes effortless.


๐Ÿงฉ Flock Subsystems


Flock is composed of 42 focused subsystems.

Each subsystem has a single responsibility and can evolve independently while collaborating through shared interfaces and the event-driven architecture.


๐Ÿ—๏ธ Core Distributed Systems


The foundation of the cluster.
Subsystem Module Responsibility
๐Ÿ—ณ๏ธ Consensus flock.consensus Raft consensus, leader election, log replication, replicated state machine
๐Ÿ›๏ธ Cluster flock.cluster Node membership, registry, health management
โค๏ธ Heartbeat flock.heartbeat Failure detection and peer liveness monitoring
๐Ÿ” Discovery flock.discovery Service registration and peer discovery
๐ŸŒ Transport flock.transport Pluggable network transport (TCP and future transports)
๐Ÿ“ฆ Protocol flock.protocol Typed protocol messages and MessageType definitions

๐Ÿ’ฌ Communication Layer


Everything related to messaging and event distribution.
Subsystem Module Responsibility
๐Ÿ“จ Messaging flock.messaging MessageBus, routing, middleware, handlers
โšก Events flock.events EventBus for publish/subscribe communication
๐ŸŒŠ Streaming flock.streaming Distributed event streaming with backpressure

๐Ÿ’พ Data & Storage


Persistent and distributed data management.
Subsystem Module Responsibility
๐Ÿ—„๏ธ DataGrid flock.datagrid Distributed key-value storage with partitioning
๐Ÿ’ฝ Storage flock.storage WAL, persistence, recovery
๐Ÿ“ธ Snapshot flock.snapshot Snapshotting, compaction, replication
๐Ÿ”„ State Machine flock.statemachine Generic replicated state machine
๐Ÿ“‘ Serialization flock.serialization JSON and MessagePack serialization

โš™๏ธ Runtime & Scheduling


Task execution and workload management.
Subsystem Module Responsibility
๐Ÿš€ Runtime flock.runtime Execution context and runtime environment
โฑ๏ธ Scheduler flock.scheduler Priority-based task scheduling
๐Ÿ“… Scheduling flock.scheduling Cron, triggers, deadlines, recurring jobs
๐Ÿ“‹ Results flock.results Result collection, serialization, registry

โ˜๏ธ Distributed Compute


Cluster-wide execution and orchestration.
Subsystem Module Responsibility
๐Ÿค– Orchestrator flock.orchestrator AI-assisted workload orchestration and autoscaling
๐Ÿ“ Placement flock.placement Constraint-aware workload placement
๐Ÿง  Resources flock.resources CPU, memory, balancing, capacity planning
๐Ÿ”€ Workflow flock.workflow DAG workflow engine with checkpointing
โšก Functions flock.functions Serverless function execution

๐ŸŒ Networking & Services


Application networking capabilities.
Subsystem Module Responsibility
๐Ÿ•ธ๏ธ Mesh flock.mesh Service mesh, routing, circuit breaking, load balancing
๐Ÿ” Query flock.query Distributed query parser, planner, optimizer

๐Ÿ“Š Operations & Monitoring


Visibility into the running cluster.
Subsystem Module Responsibility
๐Ÿ“ˆ Observability flock.observability Metrics, tracing, profiling, alerts, logging
๐Ÿ“บ Dashboard flock.dashboard Real-time operational dashboard

๐Ÿ” Security & Governance


Securing and governing the platform.
Subsystem Module Responsibility
๐Ÿ›ก๏ธ Security flock.security Zero-Trust security, RBAC, vault, cryptography
๐Ÿ“œ Policy flock.policy Policy-as-Code, compliance, rule engine
๐ŸŽ›๏ธ Control Plane flock.controlplane Fleet management and cluster governance

๐Ÿค– Intelligence


Machine learning and predictive capabilities.
Subsystem Module Responsibility
๐Ÿง  AI flock.ai Prediction, anomaly detection, adaptive learning

๐ŸŒ Enterprise & Cloud


Large-scale deployment capabilities.
Subsystem Module Responsibility
๐ŸŒ Federation flock.federation Multi-region and multi-cloud federation
๐Ÿš‘ Recovery flock.recovery Disaster recovery, backup, point-in-time restore
๐Ÿš€ Deployment flock.deployment Kubernetes and Docker deployment automation
๐Ÿ“ฆ Release flock.release Release lifecycle and production readiness

๐Ÿ”Œ Extensibility


Customize and extend Flock.
Subsystem Module Responsibility
๐Ÿ›’ Marketplace flock.marketplace Plugin registry, dependency resolution, sandboxing
๐Ÿงฉ Plugins flock.plugins Plugin loading, lifecycle, isolation
๐Ÿ”— Interfaces flock.interfaces Shared interfaces, abstract base classes, protocols

๐Ÿ› ๏ธ Developer Experience


Developer-facing tools.
Subsystem Module Responsibility
โš™๏ธ Config flock.config Configuration management
๐ŸŒ API flock.api HTTP gateway and REST API
๐Ÿ’ป CLI flock.cli Command-line interface

๐Ÿ“ฆ Architecture Map


                              FLOCK
                                โ”‚
 โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
 โ”‚                  Core Distributed Systems                   โ”‚
 โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
            โ”‚
            โ”œโ”€โ”€ ๐Ÿ’ฌ Communication
            โ”œโ”€โ”€ ๐Ÿ’พ Data & Storage
            โ”œโ”€โ”€ โš™๏ธ Runtime & Scheduling
            โ”œโ”€โ”€ โ˜๏ธ Distributed Compute
            โ”œโ”€โ”€ ๐ŸŒ Networking
            โ”œโ”€โ”€ ๐Ÿ“Š Observability
            โ”œโ”€โ”€ ๐Ÿ” Security & Governance
            โ”œโ”€โ”€ ๐Ÿค– AI
            โ”œโ”€โ”€ ๐ŸŒ Enterprise
            โ”œโ”€โ”€ ๐Ÿ”Œ Extensibility
            โ””โ”€โ”€ ๐Ÿ› ๏ธ Developer Experience

๐Ÿ“ˆ At a Glance


Category Modules
๐Ÿ—๏ธ Core Distributed Systems 6
๐Ÿ’ฌ Communication 3
๐Ÿ’พ Data & Storage 5
โš™๏ธ Runtime & Scheduling 4
โ˜๏ธ Distributed Compute 5
๐ŸŒ Networking 2
๐Ÿ“Š Operations 2
๐Ÿ” Security & Governance 3
๐Ÿค– Intelligence 1
๐ŸŒ Enterprise 4
๐Ÿ”Œ Extensibility 3
๐Ÿ› ๏ธ Developer Experience 3

42 focused subsystems working together to provide a modular, scalable, distributed application platform.


๐Ÿ“š API Reference


The Flock API is asynchronous, strongly typed, and modular. Expand any section below to explore its API, methods, and examples.


Core Types โ€” Immutable domain models that represent nodes, tasks, and shared entities used throughout the Flock ecosystem.

NodeInfo

from flock import NodeInfo

node = NodeInfo(
    node_id="node-1",
    host="10.0.0.1",
    port=9000,
    metadata={"zone": "us-east-1a"},
)

TaskSpec

from flock import TaskSpec

task = TaskSpec.create(
    "process_batch",
    dataset="sales_q4",
    limit=1000,
)

TaskStatus

class TaskStatus(str, Enum):
    PENDING = "PENDING"
    RUNNING = "RUNNING"
    COMPLETED = "COMPLETED"
    FAILED = "FAILED"
    CANCELLED = "CANCELLED"

ConsensusService โ€” Implements the Raft consensus algorithm for leader election, replicated logs, and distributed state consistency.

Create a service

from flock.consensus import ConsensusService

service = ConsensusService(...)

Start

await service.start()
await service.stop()

Cluster State

service.is_leader()
service.current_term
service.leader_id

Submit Command

entry = await service.submit_command(
    b"payload"
)

Published Events

Event Description
consensus.leader.elected Leader elected
consensus.term.changed Current term changed
consensus.log.committed Log committed
consensus.replication.failed Replication failure

SecurityService โ€” Provides authentication, authorization, cryptographic operations, identity management, and secure secret storage.

Initialize

from flock.security.service import SecurityService

service = SecurityService(...)

Authenticate

service.authentication_engine.authenticate(
    token,
    peer_id,
)

Authorize

service.authorization_engine.authorize(
    identity,
    "write",
    "resource",
)

Secrets

service.secrets_manager.store(
    "db_password",
    b"secret",
)

secret = service.secrets_manager.retrieve(
    "db_password",
)

WorkflowService โ€” Executes distributed DAG workflows with dependency management, checkpointing, and fault recovery.

Create Service

from flock.workflow.service import WorkflowService

service = WorkflowService(...)

Submit Workflow

await service.submit(workflow)

EventBus โ€” Enables loosely coupled publish/subscribe communication between independent services and subsystems.

Subscribe

from flock.events.bus import EventBus

bus = EventBus()

bus.subscribe(
    "consensus.leader.elected",
    callback,
)

Publish

bus.publish(
    "consensus.leader.elected",
    payload,
)

MessageBus โ€” Provides transport-independent, strongly typed messaging with routing, middleware, and asynchronous delivery.

Register Handler

from flock.messaging.bus import MessageBus
from flock.protocol.packet import MessageType

@bus.handler(MessageType.VOTE_REQUEST)
async def handle_vote(message):
    ...

Send Message

await bus.send(
    peer_id="node-2",
    message_type=MessageType.HEARTBEAT,
    payload=b"...",
)

API Design Principles


Every public API in Flock follows the same architectural philosophy:

  • Immutable Models โ€” Domain objects are value types that never mutate.
  • Async First โ€” Network and I/O operations use async / await.
  • Event Driven โ€” Components collaborate through published events.
  • Strongly Typed โ€” APIs expose explicit types, enums, and contracts.
  • Transport Independent โ€” Business logic is isolated from networking protocols.
  • Dependency Injection โ€” Infrastructure is supplied externally for flexibility and testability.

The API is intentionally consistent across every subsystem, making it easy to learn, extend, and scale distributed applications with Flock.


โš™๏ธ Configuration


Flock follows an explicit configuration model. Services are configured entirely through constructor arguments and dependency injectionโ€”there are no global configuration files, hidden state, or singleton objects.

This approach keeps every subsystem modular, testable, and easy to replace while making dependencies explicit.


โœจ Configuration Philosophy

  • ๐Ÿงฉ Dependency Injection โ€” Services receive their dependencies through constructors.
  • ๐Ÿšซ No Global State โ€” No global configuration objects or singletons.
  • ๐Ÿ”’ Explicit Dependencies โ€” Every required component is visible in the constructor.
  • ๐Ÿงช Test Friendly โ€” Infrastructure can easily be replaced with mocks or in-memory implementations.
  • ๐Ÿ”„ Composable โ€” Mix and match implementations without changing business logic.

๐Ÿ—๏ธ Typical Service Wiring โ€” Initialize infrastructure, construct services, start them, and gracefully shut them down.

Create Infrastructure

event_bus = EventBus()
message_bus = MessageBus(
    transport,
    serializer,
)

Create Services

membership = MembershipRegistry()

consensus = ConsensusService(
    "node-1",
    membership,
    message_bus,
    event_bus,
)

security = SecurityService(
    "node-1",
    secret_key,
    identity,
    message_bus,
    event_bus,
)

workflow = WorkflowService(
    "node-1",
    storage,
    message_bus,
    event_bus,
)

Start Services

await consensus.start()
await security.start()
await workflow.start()

Application Runs

# Your application logic...

Graceful Shutdown

await workflow.stop()
await security.stop()
await consensus.stop()

โš™๏ธ Configuration Parameters โ€” Common constructor options available across core Flock services.
Service Parameter Default Description
ConsensusService heartbeat_interval 0.15s Frequency of leader heartbeats sent to followers.
ConsensusService election_timeout_min 0.30s Minimum randomized election timeout before starting a new election.
ConsensusService election_timeout_max 0.60s Maximum randomized election timeout.
SecurityService secret_key Required 32-byte encryption key used for cryptographic operations.
FederationService region Required Geographic region identifier for multi-region deployments.

๐Ÿ’ก Best Practices โ€” Recommended patterns for configuring production applications.

Recommended Guidelines

  • โœ… Create shared infrastructure (EventBus, MessageBus) once and reuse it.
  • โœ… Inject dependencies instead of creating them inside services.
  • โœ… Start services in dependency order.
  • โœ… Shut down services gracefully in reverse order.
  • โœ… Keep configuration close to application startup.
  • โœ… Use immutable configuration values whenever possible.

๐Ÿ“Œ Design Principles


Every Flock application follows the same startup lifecycle:

Create Infrastructure
        โ”‚
        โ–ผ
Construct Services
        โ”‚
        โ–ผ
Inject Dependencies
        โ”‚
        โ–ผ
Start Services
        โ”‚
        โ–ผ
Application Running
        โ”‚
        โ–ผ
Graceful Shutdown

By making dependencies explicit rather than hidden, Flock applications remain predictable, maintainable, and straightforward to test at any scale.


๐Ÿš€ Examples


Learn Flock by example. These practical snippets demonstrate common workflowsโ€”from creating your first cluster to federation, policy enforcement, and disaster recovery.

Whether you're just getting started or exploring advanced capabilities, the examples below provide a solid foundation for building distributed applications with Flock.


๐Ÿ“š Available Examples

Example Description
๐Ÿš€ Getting Started Create your first Flock cluster and verify your installation.
๐ŸŒ Multi-Node Federation Connect multiple clusters across regions into a unified federation.
๐Ÿ“œ Policy-as-Code Define and enforce runtime policies using the policy engine.
๐Ÿ’พ Disaster Recovery Create snapshots and restore cluster state after failures.

๐Ÿš€ Getting Started โ€” Build and run your first Flock application in just a few commands.

Clone the repository

git clone https://github.com/Ashish6298/Flock.git
cd Flock
pip install -e .

Run the example

python examples/getting_started.py

Expected Output

Successfully initialized Flock Cluster: US East compute under organization registries.

๐Ÿ’ก Tip: This example verifies that your installation is working correctly and demonstrates the basic application startup lifecycle.


๐ŸŒ Multi-Node Federation โ€” Connect multiple clusters into a single federated deployment spanning regions or cloud providers.
from flock.federation.service import FederationService
from flock.federation.models import FederatedCluster

federation = FederationService(
    node_id="gateway-node",
    message_bus=message_bus,
    event_bus=event_bus,
)

await federation.start()

remote = FederatedCluster(
    cluster_id="cluster-west",
    region="us-west-2",
    endpoint="https://west.internal:9443",
    trust_level="verified",
)

federation.registry.register(remote)

Federation enables geographically distributed clusters to communicate securely while maintaining independent operation.


๐Ÿ“œ Policy-as-Code โ€” Define security and operational policies that are evaluated automatically at runtime.
from flock.policy.service import PolicyService
from flock.policy.models import PolicyDefinition, PolicyRule

policy_svc = PolicyService(
    node_id="node-1",
    event_bus=event_bus,
)

policy = PolicyDefinition(
    policy_id="deny-root",
    name="Deny Root Privilege Tasks",
    rules=[
        PolicyRule(
            rule_id="r1",
            condition="task.user == 'root'",
            action="DENY",
            severity="CRITICAL",
        )
    ],
)

policy_svc.engine.load_policy(policy)

Policies can enforce security, compliance, scheduling constraints, or custom business rules without changing application code.


๐Ÿ’พ Disaster Recovery โ€” Protect your cluster by creating snapshots and restoring state after failures.
from flock.recovery.service import RecoveryService

recovery = RecoveryService(
    node_id="node-1",
    storage=storage,
    event_bus=event_bus,
)

await recovery.start()

# Create a snapshot
snapshot_id = await recovery.create_snapshot(
    label="pre-migration-backup"
)

# Restore a snapshot
await recovery.restore_snapshot(snapshot_id)

Snapshots capture a consistent view of cluster state, enabling reliable backup, migration, and disaster recovery workflows.


๐Ÿ’ก Explore More


The examples/ directory contains additional sample applications covering different Flock subsystems and integration patterns. Each example is designed to be self-contained, making it easy to experiment with specific features or use them as a starting point for your own projects.


The fastest way to learn Flock is to run the examples, modify them, and build from there.


๐Ÿงช Testing


Flock is built with testability as a first-class design goal. The complete test suite validates all 42 subsystems, ensuring reliability across distributed components, communication layers, storage systems, and core services.


๐Ÿ“Š Test Coverage Overview


Metric Result
๐Ÿงฉ Subsystems Tested 42
โœ… Total Tests 629
โšก Execution Time ~10 seconds
๐Ÿ” Type Checking mypy --strict
๐Ÿ“ Source Files Checked 390

โ–ถ๏ธ Running Tests โ€” Execute the complete Flock validation suite and verify system correctness.

Run Full Test Suite

python -m pytest tests/ -v

This runs all tests across every subsystem.


Run a Specific Subsystem

python -m pytest tests/test_consensus_service.py -v

Useful when developing or debugging a particular component.


Generate Coverage Report

Install coverage support:

pip install pytest-cov

Run tests with coverage:

python -m pytest tests/ \
    --cov=src/flock \
    --cov-report=html

The generated HTML report provides a detailed view of:

  • Covered modules
  • Missing lines
  • Coverage percentage
  • Test distribution

Run Strict Type Checking

mypy --strict src/

Flock uses strict static typing to catch interface errors before runtime.


๐Ÿ“ˆ Test Results โ€” Latest validation results from the complete test and type-checking pipeline.

Pytest Results

629 passed in ~10s

Type Checking Results

Success: no issues found in 390 source files

๐Ÿงฉ Testing Philosophy โ€” How Flock maintains reliability across a distributed architecture.

Flock testing focuses on:

Area Purpose
๐Ÿ—๏ธ Subsystem Isolation Each component can be tested independently.
๐Ÿ”„ Integration Testing Ensures services communicate correctly.
โšก Async Testing Validates concurrent workflows and event handling.
๐Ÿ“จ Messaging Tests Verifies transport and routing behavior.
๐Ÿ—ณ๏ธ Consensus Testing Validates leader election and replication logic.
๐Ÿ’พ Recovery Testing Ensures snapshots and restoration work correctly.
๐Ÿ”’ Security Testing Validates authentication and authorization flows.

๐Ÿšฆ Development Workflow


A typical development cycle:

        Write Code
            โ”‚
            โ–ผ
      Run Unit Tests
            โ”‚
            โ–ผ
    Run Type Checking
            โ”‚
            โ–ผ
   Validate Integration
            โ”‚
            โ–ผ
       Submit Change

Every subsystem in Flock is continuously validated to keep the platform stable as new capabilities are added.


๐Ÿ—‚๏ธ Project Structure


Flock is organized as a modular distributed platform with 42 focused subsystems under the flock package. Each subsystem owns a specific responsibility while communicating through shared interfaces, events, and dependency injection.


๐ŸŒณ Repository Overview


Flock/
โ”‚
โ”œโ”€โ”€ ๐Ÿ“ฆ src/
โ”‚   โ””โ”€โ”€ ๐Ÿฆ flock/                         # Main package (42 subsystems)
โ”‚       โ”‚
โ”‚       โ”œโ”€โ”€ __init__.py                   # Public API exports
โ”‚       โ”‚                                  # FlockError, NodeInfo, TaskSpec, TaskStatus
โ”‚       โ”‚
โ”‚       โ”œโ”€โ”€ ๐Ÿ—ณ๏ธ consensus/                 # Raft consensus engine
โ”‚       โ”‚                                  # Leader election, log replication,
โ”‚       โ”‚                                  # state machine management
โ”‚       โ”‚
โ”‚       โ”œโ”€โ”€ ๐Ÿข cluster/                   # Cluster membership
โ”‚       โ”‚                                  # Node registry and cluster models
โ”‚       โ”‚
โ”‚       โ”œโ”€โ”€ ๐Ÿ” security/                  # Zero-Trust security framework
โ”‚       โ”‚                                  # Authentication, RBAC, cryptography
โ”‚       โ”‚
โ”‚       โ”œโ”€โ”€ ๐Ÿ”„ workflow/                  # Distributed DAG workflow engine
โ”‚       โ”‚
โ”‚       โ”œโ”€โ”€ ๐Ÿ“Š observability/             # Monitoring infrastructure
โ”‚       โ”‚                                  # Metrics, tracing, profiling, alerts
โ”‚       โ”‚
โ”‚       โ”œโ”€โ”€ ๐ŸŒ federation/                # Multi-cloud federation layer
โ”‚       โ”‚                                  # Cross-region cluster communication
โ”‚       โ”‚
โ”‚       โ”œโ”€โ”€ ๐ŸŽ›๏ธ controlplane/              # Fleet management and governance
โ”‚       โ”‚
โ”‚       โ”œโ”€โ”€ ๐Ÿ“œ policy/                    # Policy-as-Code engine
โ”‚       โ”‚
โ”‚       โ”œโ”€โ”€ ๐Ÿ’พ recovery/                  # Disaster recovery subsystem
โ”‚       โ”‚                                  # Snapshots and restoration
โ”‚       โ”‚
โ”‚       โ”œโ”€โ”€ ๐Ÿงฉ marketplace/               # Plugin registry and extensions
โ”‚       โ”‚
โ”‚       โ””โ”€โ”€ ...                           # 32 additional subsystems
โ”‚
โ”œโ”€โ”€ ๐Ÿงช tests/                             # Automated test suite
โ”‚                                         # 211 test files, 629 tests
โ”‚
โ”œโ”€โ”€ ๐Ÿš€ examples/                          # Runnable examples and demos
โ”‚
โ”œโ”€โ”€ ๐Ÿ“š docs/                              # Documentation and audit reports
โ”‚
โ”œโ”€โ”€ โš™๏ธ .github/
โ”‚   โ””โ”€โ”€ workflows/
โ”‚       โ””โ”€โ”€ ci.yml                        # GitHub Actions CI pipeline
โ”‚
โ””โ”€โ”€ ๐Ÿ“„ pyproject.toml                     # Package metadata,
                                          # dependencies, and tooling

๐Ÿงฉ Source Package Layout


๐Ÿฆ src/flock โ€” Core package containing all distributed system capabilities.

The flock package contains every subsystem required to run and extend the platform.

Public API

from flock import (
    FlockError,
    NodeInfo,
    TaskSpec,
    TaskStatus,
)

Core Subsystems

Module Purpose
consensus Raft consensus, leader election, replication
cluster Membership and node management
security Identity, authentication, authorization
workflow DAG-based workflow execution
observability Metrics, tracing, profiling
federation Multi-region cluster federation
controlplane Fleet management
policy Policy evaluation and enforcement
recovery Backup and restoration
marketplace Plugin discovery and management

๐Ÿงช tests โ€” Comprehensive validation suite covering every major subsystem.

The test suite validates:

  • โœ… Core domain models
  • โœ… Distributed communication
  • โœ… Consensus behavior
  • โœ… Event handling
  • โœ… Storage and recovery
  • โœ… Security workflows
  • โœ… Service integrations

Current size:

211 test files
629 automated tests

๐Ÿš€ examples โ€” Runnable applications demonstrating Flock capabilities.

Examples provide practical entry points for:

  • Cluster initialization
  • Federation
  • Policy management
  • Workflow execution
  • Recovery operations

Each example is designed to be executed independently.


๐Ÿ“š docs โ€” Documentation, architecture guides, and audit material.

Contains:

  • Architecture documentation
  • API references
  • Design principles
  • Operational guides
  • Audit reports

โš™๏ธ CI/CD โ€” Automated quality checks using GitHub Actions.

The CI pipeline validates:

  • ๐Ÿงช Test execution
  • ๐Ÿ” Type checking
  • ๐Ÿ“ฆ Package integrity
  • ๐Ÿšฆ Build verification

Configuration:

.github/workflows/ci.yml

๐Ÿ—๏ธ Architecture Flow


                 Flock Platform
                       โ”‚
                       โ–ผ
              โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
              โ”‚   src/flock     โ”‚
              โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                       โ”‚
        โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
        โ–ผ              โ–ผ              โ–ผ
   Core Services   Infrastructure   Extensions
        โ”‚              โ”‚              โ”‚
        โ–ผ              โ–ผ              โ–ผ
 Consensus       Messaging       Plugins
 Workflow        Storage         Marketplace
 Security        Transport       Federation

The repository structure mirrors the architecture itself: small, focused subsystems connected through clear interfaces, making Flock easy to understand, test, and extend.


๐Ÿšฆ CI/CD Pipeline


Flock uses an automated GitHub Actions CI pipeline to maintain code quality, reliability, and consistency across all changes.


Every push and pull request targeting main automatically triggers the validation workflow.


๐Ÿ”„ Pipeline Overview


Developer Push / Pull Request
              โ”‚
              โ–ผ
      GitHub Actions Runner
              โ”‚
              โ–ผ
      Install Environment
              โ”‚
              โ–ผ
       Type Validation
              โ”‚
              โ–ผ
       Test Execution
              โ”‚
              โ–ผ
        Merge Approved โœ…

โš™๏ธ CI Workflow Steps โ€” Automated checks executed for every code change.

1๏ธโƒฃ Setup Python Environment

- Set up Python 3.11

The pipeline runs against the supported Python runtime to ensure consistent behavior.


2๏ธโƒฃ Install Dependencies

pip install -r requirements

Installs all required dependencies, including:

  • ๐Ÿ“ฆ msgpack โ€” binary serialization support
  • ๐Ÿงช pytest โ€” testing framework
  • โšก pytest-asyncio โ€” async test support

3๏ธโƒฃ Install Flock Package

pip install -e .

Installs Flock in editable mode so the CI environment tests the actual source package.


4๏ธโƒฃ Strict Type Checking

mypy --strict src/

Flock uses zero-tolerance type checking to detect:

  • Missing type annotations
  • Invalid interfaces
  • Unsafe type usage
  • Contract violations

5๏ธโƒฃ Full Regression Test Suite

python -m pytest tests/ -v

Runs the complete automated test suite:

629 tests
42 subsystems


โœ… Quality Gates โ€” Conditions required before changes can be merged.

Every pull request must successfully complete:

Check Requirement
๐Ÿ Python Environment Python 3.11 setup
๐Ÿ“ฆ Dependencies All packages installed successfully
๐Ÿ” Type Safety mypy --strict passes
๐Ÿงช Tests All 629 tests pass
๐Ÿšฆ Pipeline Status No CI failures

๐Ÿ›ก๏ธ Why CI Matters


The CI pipeline protects Flock by ensuring:

  • ๐Ÿ”’ New changes do not break existing behavior
  • ๐Ÿงฉ Subsystems remain compatible
  • ๐Ÿงช Distributed components stay validated
  • ๐Ÿ“ˆ Code quality remains consistent
  • ๐Ÿš€ Releases are safer and predictable

Every change entering the main branch is automatically verified against Flock's type safety and regression standards.


๐Ÿค Contributing


Contributions help Flock grow. Whether you're fixing bugs, improving documentation, adding features, or expanding subsystems, every contribution is welcome.


Before submitting changes, please review the full contribution guidelines in CONTRIBUTING.md.


๐Ÿš€ Quick Start


Follow these steps to set up your development environment and submit your first contribution.


๐Ÿ› ๏ธ Development Workflow โ€” Fork, develop, validate, and submit your changes.

1๏ธโƒฃ Fork & Clone

Create your fork and clone it locally:

git clone https://github.com/YOUR_USERNAME/Flock.git
cd Flock

2๏ธโƒฃ Install Development Dependencies

Install Flock with all development tools:

pip install -e .[dev]

This installs:

  • ๐Ÿงช Testing tools
  • ๐Ÿ” Type checking tools
  • ๐Ÿ› ๏ธ Development utilities

3๏ธโƒฃ Make Your Changes

When developing:

  • Follow existing architecture patterns
  • Keep changes focused
  • Add tests for new functionality
  • Maintain backward compatibility

4๏ธโƒฃ Run Validation

Before opening a pull request, run the complete validation pipeline:

mypy --strict src/

python -m pytest tests/ -v

Your changes must pass:

  • โœ… Strict type checking
  • โœ… Full regression suite
  • โœ… Existing subsystem tests

5๏ธโƒฃ Submit Pull Request

Submit your pull request against:

main

Ensure the PR description explains:

  • What changed
  • Why the change is needed
  • How it was tested

๐Ÿ“ Code Standards โ€” Development rules that keep Flock consistent, reliable, and maintainable.

All contributions must follow these standards:


๐Ÿ” Type Safety

All code must pass:

mypy --strict src/

Requirements:

  • โœ… Complete type annotations
  • โœ… No unchecked typing shortcuts
  • ๐Ÿšซ No # type: ignore exceptions

๐Ÿงช Testing Requirements

Every new feature must include tests.

Change Requirement
New feature Add corresponding tests
Bug fix Add regression test
API change Update API tests
Subsystem change Validate affected components

๐Ÿงฉ Architecture Patterns

Follow Flock's core design principles:

  • ๐Ÿ”’ Use immutable dataclasses
  • ๐Ÿ›๏ธ Use dependency injection
  • โšก Prefer event-driven communication
  • ๐Ÿšš Keep infrastructure replaceable
  • ๐Ÿงฉ Avoid unnecessary coupling

Example:

@dataclass(frozen=True)
class DomainModel:
    value: str

๐Ÿ“ Logging

Use structlog for all library logging.

โœ… Recommended:

logger.info(
    "task_started",
    task_id=task_id,
)

โŒ Avoid:

print("Task started")

Library code should never use print() for logging.



๐Ÿงญ Contribution Checklist


Before submitting a pull request:

Check
๐Ÿ“ฆ Dependencies installed
๐Ÿงช Tests added/updated
๐Ÿ” mypy --strict passes
๐Ÿšซ No type: ignore added
๐Ÿ”’ Immutable models followed
๐Ÿ›๏ธ Dependency injection maintained
๐Ÿ“ Logging uses structlog

Great contributions are not only about adding codeโ€”they preserve the architecture, quality, and principles that make Flock scalable.


๐Ÿ” Security


Security is a core part of Flock's architecture. Vulnerability reports are handled through a responsible disclosure process to ensure issues can be investigated and resolved safely before public discussion.


๐Ÿ›ก๏ธ Reporting Security Issues


If you discover a potential security vulnerability, please do not open a public issue.

Instead, report it privately by following the process described in:

๐Ÿ“„ SECURITY.md


๐Ÿšจ Responsible Disclosure โ€” How security reports are handled safely and efficiently.

When reporting a vulnerability, please include:

  • ๐Ÿ” Description โ€” Clear explanation of the issue
  • ๐Ÿงฉ Affected Component โ€” Subsystem, module, or service involved
  • ๐Ÿ“ Reproduction Steps โ€” Minimal steps to reproduce the behavior
  • ๐Ÿ’ฅ Impact Assessment โ€” Potential security impact
  • ๐Ÿ› ๏ธ Suggested Fix โ€” If you have recommendations

Providing detailed information helps the maintainers investigate and resolve the issue quickly.


๐Ÿ”’ Security Areas โ€” Components covered by Flock's security model.

Security considerations include:

Area Description
๐Ÿ”‘ Authentication Identity verification between nodes and services
๐Ÿ›ก๏ธ Authorization Access control and permission enforcement
๐Ÿ” Cryptography Secure communication and secret handling
๐ŸŒ Federation Security Trust management between clusters
๐Ÿ“œ Policy Enforcement Runtime security and compliance rules
๐Ÿ’พ Data Protection Secure storage and recovery mechanisms

โš ๏ธ Please Avoid


To protect users and maintainers:

  • โŒ Do not publicly disclose unpatched vulnerabilities
  • โŒ Do not include sensitive data in reports
  • โŒ Do not test against systems without authorization
  • โŒ Do not publish exploit details before a fix is available

Responsible disclosure helps keep the Flock ecosystem secure while giving maintainers the opportunity to protect all users.


๐Ÿ“„ License


Flock is released under the MIT License, allowing developers to freely use, modify, distribute, and build upon the project while preserving the original license terms.


โš–๏ธ MIT License


Flock is open source software licensed under the MIT License.

The full license text is available here:

๐Ÿ“„ LICENSE


โœจ What This Means โ€” The permissions and responsibilities provided by the MIT License.

The MIT License allows you to:

Permission Description
โœ… Use Use Flock for personal, commercial, or internal projects
โœ… Modify Change and adapt the source code
โœ… Distribute Share original or modified versions
โœ… Integrate Include Flock in larger applications

๐Ÿ“Œ License Requirements โ€” Conditions that apply when using Flock.

When redistributing Flock or derivative works:

  • Include the original copyright notice
  • Include the MIT License text
  • Preserve license attribution

๐ŸŒฑ Open Source Commitment


Flock is built with the goal of being:

  • ๐Ÿงฉ Accessible to developers and organizations
  • ๐Ÿ”„ Easy to extend and integrate
  • ๐ŸŒ Community-driven and transparent
  • ๐Ÿš€ Free to use across different environments

The MIT License keeps Flock flexible while ensuring proper attribution to the project and its contributors.


๐Ÿ“š Citation


If you use Flock in research, academic work, technical publications, or production systems, please cite the project to acknowledge the work and help others discover the platform.


๐Ÿ“ BibTeX Citation


Use the following BibTeX entry:

@software{flock2026,
  title   = {Flock: Enterprise-Grade Federated Distributed Computing Platform},
  author  = {Ashish6298},
  year    = {2026},
  url     = {https://github.com/Ashish6298/Flock},
  version = {1.0.0}
}

๐Ÿ“– Citation Guidelines โ€” When and why to cite Flock.

Please cite Flock when you:

  • ๐Ÿ”ฌ Use Flock as part of research or experiments
  • ๐Ÿ“„ Reference Flock in technical papers or articles
  • ๐Ÿข Deploy Flock in production systems
  • ๐Ÿงฉ Build extensions or integrations based on Flock
  • ๐Ÿ“š Include Flock in educational material

๐ŸŒ Repository


Source code and project information:

https://github.com/Ashish6298/Flock

Citing Flock helps recognize the project and supports continued development of the platform.


๐Ÿฆ Flock

Enterprise-Grade Federated Distributed Computing Platform

Built with โค๏ธ for the distributed systems community

Flock provides a modular foundation for building resilient distributed systems with consensus, federation, workflows, security, observability, and scalable execution.


๐ŸŒŸ Explore Flock


๐Ÿš€ Get Started ๐Ÿ—๏ธ Architecture ๐Ÿค Contribute
Install & run examples Explore 42 subsystems Join development
Learn the API Understand design principles Submit improvements

๐Ÿงฉ Built Around


๐Ÿ—ณ๏ธ Consensus     โšก Event Driven     ๐Ÿ” Security
๐ŸŒ Federation    ๐Ÿ“Š Observability    ๐Ÿ”„ Workflows
๐Ÿ’พ Recovery      ๐Ÿ“จ Messaging        ๐Ÿง  Intelligence

๐ŸŒ Community


Have ideas, improvements, or questions?

๐Ÿ’ฌ Join discussions ยท ๐Ÿ› Report issues ยท ๐Ÿš€ Share your projects built with Flock



๐Ÿ“š Resources


๐Ÿ“ฆ PyPI ย ย โ€ขย ย  ๐Ÿ’ป Source Code ย ย โ€ขย ย  ๐Ÿ› Bug Reports ย ย โ€ขย ย  ๐Ÿ’ฌ Community Discussions



Built with โค๏ธ by the Flock community

Open source ยท Distributed by design ยท MIT Licensed

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flock_p2p-1.1.0.tar.gz (534.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

flock_p2p-1.1.0-py3-none-any.whl (416.3 kB view details)

Uploaded Python 3

File details

Details for the file flock_p2p-1.1.0.tar.gz.

File metadata

  • Download URL: flock_p2p-1.1.0.tar.gz
  • Upload date:
  • Size: 534.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.4

File hashes

Hashes for flock_p2p-1.1.0.tar.gz
Algorithm Hash digest
SHA256 6fe0fadf3701c017a84567f12f3bc228f538d23ad7a7b4ef29430a6b97ac519e
MD5 00f86c48440c312c44d8ffbad612cdfd
BLAKE2b-256 608750b87d71b90818445620eae78b58a15a5ed96ea12211e14385c95750cac9

See more details on using hashes here.

File details

Details for the file flock_p2p-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: flock_p2p-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 416.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.4

File hashes

Hashes for flock_p2p-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 db5dd51f2bfb935463a0dd6db092cefd4e4583c8b992e81b184f1c4f0892b66d
MD5 fff8ac32ff61dc38e46552d4fcaabac0
BLAKE2b-256 541f3fa1ec86f17dae90954f90cf4073e70ac7e87b3194c1dfc55ce4961ffe1c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page