Skip to main content
QUICK REVIEW

[Paper Review] Behavioural Types for Local-First Software

Roland Kühn, Hernán Melgratti|arXiv (Cornell University)|Jan 1, 2023
Peer-to-Peer Network TechnologiesComputer Science4 citations
TL;DR

This paper introduces swarm protocols—a behavioural type system for local-first, peer-to-peer software that enables coordination-free interaction through a shared, eventually consistent event log. By projecting global protocols to local machines and using total ordering of events to resolve conflicts, the model ensures eventual consistency and convergence to correct global behaviour even under network partitions.

ABSTRACT

Peer-to-peer systems are the most resilient form of distributed computing, but the design of robust protocols for their coordination is difficult. This makes it hard to specify and reason about global behaviour of such systems. This paper presents swarm protocols to specify such systems from a global viewpoint. Swarm protocols are projected to machines, that is local specifications of peers. We take inspiration from behavioural types with a key difference: peers communicate through an event notification mechanism rather than through point-to-point message passing. Our goal is to adhere to the principles of local-first software where network devices collaborate on a common task while retaining full autonomy: every participating device can locally make progress at all times, not encumbered by unavailability of other devices or network connections. This coordination-free approach leads to inconsistencies that may emerge during computations. Our main result shows that under suitable well-formedness conditions for swarm protocols consistency is eventually recovered and the locally observable behaviour of conforming machines will eventually match the global specification. Our model elaborates on the Actyx industrial platform and provides the basis for tool support: we sketch an implemented prototype which proves this work a viable step towards reasoning about local-first and peer-to-peer software systems.

Motivation & Objective

  • To address the challenge of designing and reasoning about coordination-free, resilient peer-to-peer systems where network failures and asynchrony are common.
  • To enable robust global behaviour in systems where components operate autonomously and communicate via event publication and subscription.
  • To provide a formal foundation for local-first software by ensuring that locally observable behaviour eventually matches the global specification despite temporary inconsistencies.
  • To support dynamic, scalable systems with arbitrary numbers of role instances, avoiding assumptions about fixed topology or central coordination.

Proposed method

  • Proposes a behavioural type system based on multiparty session types, adapted for publish-subscribe communication instead of point-to-point messaging.
  • Models systems as swarms of machines that maintain local logs of events and react to incoming events based on local state.
  • Uses a total order on events (e.g., via Lamport timestamps) to resolve concurrent choices, ensuring that only one branch of a choice is ultimately accepted.
  • Projects global swarm protocols into local machine behaviours, ensuring that each machine’s actions are consistent with the global protocol.
  • Enforces well-formedness conditions to guarantee deadlock freedom and eventual consistency.
  • Employs speculative execution: multiple choices may proceed in parallel, but only the earliest event in the total order determines the outcome.

Experimental results

Research questions

  • RQ1How can global coordination be achieved in a peer-to-peer system without central coordination or consensus?
  • RQ2How can behavioural types be adapted to event-driven, publish-subscribe communication models in distributed systems?
  • RQ3What conditions ensure that local machines, acting autonomously, eventually converge to a globally consistent behaviour?
  • RQ4How can systems tolerate network partitions and transient failures while maintaining consistency and progress?
  • RQ5How can conflict resolution be formally captured and enforced using event ordering in a coordination-free setting?

Key findings

  • Under well-formedness conditions, swarm protocols guarantee that all conforming machines eventually observe the same global behaviour, even if they initially diverge.
  • The system achieves eventual consistency by using a total order on events to resolve concurrent choices, with the earliest event determining the outcome.
  • The model supports arbitrary numbers of role instances, making it suitable for dynamic, scalable systems such as taxi fleets or collaborative applications.
  • The behavioural type system ensures deadlock freedom and enables reasoning about correct local behaviour that aligns with the global protocol.
  • The approach supports conflict resolution without requiring coordination, by treating conflicting actions as speculative and discarding effects based on event ordering.
  • The framework is grounded in an industrial platform and supports tooling, as detailed in a companion artifact paper.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.