102 lines
4.2 KiB
Org Mode
102 lines
4.2 KiB
Org Mode
:PROPERTIES:
|
|
:ID: 89954f1a-7923-441e-a3c6-c35b9c3273d9
|
|
:CREATED: [2026-03-31 Tue 20:28]
|
|
:EDITED: [2026-04-07 Tue 13:42]
|
|
:END:
|
|
#+TITLE: SKILL: Social Consensus Protocol (Universal Literate Note)
|
|
#+STARTUP: content
|
|
#+FILETAGS: :distributed:swarms:consensus:autonomy:
|
|
#+DEPENDS_ON: skill-sub-agent-manager
|
|
|
|
* Overview
|
|
The *Social Consensus Protocol* enables multi-agent negotiation. It provides a Lisp-native implementation of decentralized agreement, allowing federated `org-agent` instances to coordinate on shared resources and conflicting goals.
|
|
|
|
* Phase A: Demand (PRD)
|
|
:PROPERTIES:
|
|
:STATUS: FROZEN
|
|
:END:
|
|
|
|
** 1. Purpose
|
|
Enable reliable, cross-instance coordination without a central master.
|
|
|
|
** 2. User Needs
|
|
- *Resource Negotiation:* Agree on which instance should handle a high-compute task.
|
|
- *Conflict Resolution:* Settle divergent world-states during swarm execution.
|
|
- *Byzantine Fault Tolerance:* Handle disconnected or misbehaving instances gracefully.
|
|
|
|
* Phase D: Build (Implementation)
|
|
|
|
** Consensus Algorithm (Simplified Raft)
|
|
#+begin_src lisp
|
|
(defun consensus-propose-vote (proposal)
|
|
"Broadcasts a proposal to the peer swarm and collects votes.
|
|
Implements org-agent Social Consensus Protocol."
|
|
(let* ((peers (get-swarm-peer-list))
|
|
(votes (loop for peer in peers
|
|
collect (org-agent:send-swarm-packet peer `(:type :REQUEST :action :vote :proposal ,proposal)))))
|
|
(if (> (count :YES votes) (/ (length peers) 2))
|
|
t ; Consensus reached
|
|
nil)))
|
|
#+end_src
|
|
|
|
* Registration
|
|
#+begin_src lisp
|
|
(defskill :skill-consensus
|
|
:priority 85
|
|
:trigger (lambda (context) (eq (getf (getf context :payload) :sensor) :conflict-detected))
|
|
:probabilistic (lambda (context) "Formulate a consensus proposal for the peer swarm.")
|
|
:deterministic (lambda (action context) action))
|
|
#+end_src
|
|
|
|
|
|
* Phase B: Blueprint (PROTOCOL)
|
|
:PROPERTIES:
|
|
:STATUS: SIGNED
|
|
:END:
|
|
|
|
* Phase B: Blueprint (PROTOCOL)
|
|
:PROPERTIES:
|
|
:STATUS: IN-PROGRESS
|
|
:END:
|
|
|
|
** 1. Architectural Intent
|
|
The consensus protocol should be implemented as a swarm behavior modeled after Raft, but simplified for the constraints of the `org-agent` ecosystem (i.e. eventual consistency, potentially unreliable messaging). The architecture should allow for future extensions, such as dynamically adjusting the voting threshold based on swarm size or node reputation. We use gossip protocols for state sharing.
|
|
|
|
** 2. Semantic Interfaces
|
|
|
|
*** a. Proposal Submission
|
|
|
|
- *Function Signature:* `(consensus-propose-value value &key (timeout 10))`
|
|
- *Purpose:* Initiate a consensus-building process for a given `value`. The `value` can represent a resource assignment, conflict resolution strategy, or any other agreed-upon data structure.
|
|
- *Arguments:*
|
|
- `value`: The Lisp object (e.g., symbol, list, string) representing the proposal.
|
|
- `timeout`: (Optional) The maximum time (in seconds) to wait for consensus.
|
|
- *Return Value:* `T` if consensus is reached on the `value` within the timeout; otherwise `NIL`.
|
|
- *Side Effects:* Broadcasts proposal messages to the swarm, updates local consensus state.
|
|
|
|
*** b. Vote Request Handling
|
|
|
|
- *Function Signature:* `(consensus-handle-vote-request proposal)`
|
|
- *Purpose:* Handles incoming vote requests from other swarm members.
|
|
- *Arguments:*
|
|
- `proposal`: The proposal being voted on (Lisp object).
|
|
- *Return Value:* `:YES` if the local agent agrees with the proposal; `:NO` otherwise. Decision is based on local state and policies.
|
|
- *Side Effects:* None (ideally, decision logic should be idempotent).
|
|
|
|
*** c. State Synchronization
|
|
|
|
- *Function Signature:* `(consensus-gossip-state)`
|
|
- *Purpose:* Periodically gossips its summarized consensus state to a random subset of peers. This should include current term, leader information, and recent proposal hashes.
|
|
- *Arguments:* None.
|
|
- *Return Value:* None.
|
|
- *Side Effects:* Sends state packets to other peers.
|
|
|
|
*** d. Peer Discovery
|
|
|
|
- *Function Signature:* `(get-swarm-peer-list)`
|
|
- *Purpose:* Returns a list of known peer agents in the swarm.
|
|
- *Arguments:* None
|
|
- *Return Value:* List of agent IDs/addresses. Relies on underlying SWIM or similar infrastructure.
|
|
- *Side Effects:* Potentially triggers peer discovery if stale.
|
|
|