Complete BZZZ functionality port to CHORUS

🎭 CHORUS now contains full BZZZ functionality adapted for containers

Core systems ported:
- P2P networking (libp2p with DHT and PubSub)
- Task coordination (COOEE protocol)
- HMMM collaborative reasoning
- SHHH encryption and security
- SLURP admin election system
- UCXL content addressing
- UCXI server integration
- Hypercore logging system
- Health monitoring and graceful shutdown
- License validation with KACHING

Container adaptations:
- Environment variable configuration (no YAML files)
- Container-optimized logging to stdout/stderr
- Auto-generated agent IDs for container deployments
- Docker-first architecture

All proven BZZZ P2P protocols, AI integration, and collaboration
features are now available in containerized form.

Next: Build and test container deployment.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
anthonyrawlins
2025-09-02 20:02:37 +10:00
parent 7c6cbd562a
commit 543ab216f9
224 changed files with 86331 additions and 186 deletions

24
pkg/agentid/agent.go Normal file
View File

@@ -0,0 +1,24 @@
package agentid
import "encoding/json"
type AgentRecord struct {
AssignedID uint16 `json:"assigned_id"`
HostHash string `json:"hash"`
Model string `json:"model"`
Hostname string `json:"hostname"`
MAC string `json:"mac"`
GPUInfo string `json:"gpu_info"`
}
func (ar *AgentRecord) ToJSON() ([]byte, error) {
return json.Marshal(ar)
}
func FromJSON(data []byte) (*AgentRecord, error) {
var ar AgentRecord
if err := json.Unmarshal(data, &ar); err != nil {
return nil, err
}
return &ar, nil
}

58
pkg/agentid/crypto.go Normal file
View File

@@ -0,0 +1,58 @@
package agentid
import (
"bytes"
"io"
"strings"
"filippo.io/age"
"filippo.io/age/armor"
)
func EncryptPayload(payload []byte, publicKey string) ([]byte, error) {
recipient, err := age.ParseX25519Recipient(publicKey)
if err != nil {
return nil, err
}
var buf bytes.Buffer
// Optional: wrap with armor for ASCII output (can omit if binary preferred)
w := armor.NewWriter(&buf)
encryptor := age.NewEncryptor(w, recipient)
_, err = encryptor.Write(payload)
if err != nil {
return nil, err
}
if err := encryptor.Close(); err != nil {
return nil, err
}
if err := w.Close(); err != nil {
return nil, err
}
return buf.Bytes(), nil
}
func DecryptPayload(ciphertext []byte, privateKey string) ([]byte, error) {
identity, err := age.ParseX25519Identity(privateKey)
if err != nil {
return nil, err
}
// Support armored input:
r := bytes.NewReader(ciphertext)
decoder := armor.NewReader(r)
decryptor, err := age.Decrypt(decoder, identity)
if err != nil {
return nil, err
}
defer decryptor.Close()
plaintext, err := io.ReadAll(decryptor)
if err != nil {
return nil, err
}
return plaintext, nil
}

54
pkg/agentid/ucxl.go Normal file
View File

@@ -0,0 +1,54 @@
package agentid
// Define a publisher interface for UCXL
type Publisher interface {
Publish(address string, data []byte) error
}
// Define a subscriber interface for UCXL messages
type Subscriber interface {
Subscribe(address string, handler func(data []byte)) error
}
func AnnounceAgentRecord(
pub Publisher,
agent *AgentRecord,
leaderPubKey string,
) error {
jsonPayload, err := agent.ToJSON()
if err != nil {
return err
}
encryptedPayload, err := EncryptPayload(jsonPayload, leaderPubKey)
if err != nil {
return err
}
ucxlAddress := "ucxl://any:admin@COOEE:enrol/#/agentid/" +
fmt.Sprintf("%d", agent.AssignedID)
return pub.Publish(ucxlAddress, encryptedPayload)
}
func SetupAgentIDListener(
sub Subscriber,
privateKey string,
handle func(*AgentRecord) error,
) error {
ucxlAddress := "ucxl://any:admin@COOEE:enrol/#/agentid/*" // wildcard or prefix
return sub.Subscribe(ucxlAddress, func(data []byte) {
decrypted, err := DecryptPayload(data, privateKey)
if err != nil {
// handle error, log etc.
return
}
agent, err := FromJSON(decrypted)
if err != nil {
// handle error, log etc.
return
}
_ = handle(agent) // your context store merge or validation
})
}