chore(security): enhance environment configuration, CI workflows, and wallet daemon with security improvements

- Restructure .env.example with security-focused documentation, service-specific environment file references, and AWS Secrets Manager integration
- Update CLI tests workflow to single Python 3.13 version, add pytest-mock dependency, and consolidate test execution with coverage
- Add comprehensive security validation to package publishing workflow with manual approval gates, secret scanning, and release
This commit is contained in:
oib
2026-03-03 10:33:46 +01:00
parent 00d00cb964
commit f353e00172
220 changed files with 42506 additions and 921 deletions

View File

@@ -0,0 +1,222 @@
"""
E2E Test Fixtures
This package contains fixtures and test data for end-to-end testing,
including mock home directories for agents and users.
"""
import os
from pathlib import Path
from typing import Dict, List
import pytest
@pytest.fixture
def mock_home_dir():
"""Create a temporary mock home directory for testing"""
import tempfile
with tempfile.TemporaryDirectory() as temp_dir:
home_path = Path(temp_dir)
# Create standard AITBC home directory structure
(home_path / ".aitbc").mkdir(exist_ok=True)
(home_path / ".aitbc" / "wallets").mkdir(exist_ok=True)
(home_path / ".aitbc" / "config").mkdir(exist_ok=True)
(home_path / ".aitbc" / "cache").mkdir(exist_ok=True)
yield home_path
@pytest.fixture
def agent_home_dirs():
"""Create mock agent home directories for testing"""
import tempfile
with tempfile.TemporaryDirectory() as temp_dir:
base_path = Path(temp_dir)
# Create agent home directories
agents = {}
for agent_name in ["client1", "miner1", "agent1", "agent2"]:
agent_path = base_path / agent_name
agent_path.mkdir(exist_ok=True)
# Create AITBC structure
(agent_path / ".aitbc").mkdir(exist_ok=True)
(agent_path / ".aitbc" / "wallets").mkdir(exist_ok=True)
(agent_path / ".aitbc" / "config").mkdir(exist_ok=True)
# Create default config
config_file = agent_path / ".aitbc" / "config.yaml"
config_file.write_text(f"""
agent:
name: {agent_name}
type: {"client" if "client" in agent_name else "miner" if "miner" in agent_name else "agent"}
wallet_path: ~/.aitbc/wallets/{agent_name}_wallet.json
node:
endpoint: http://localhost:8082
timeout: 30
coordinator:
url: http://localhost:8000
api_key: null
""")
agents[agent_name] = agent_path
yield agents
@pytest.fixture
def fixture_home_dirs():
"""Access to the actual fixture home directories"""
fixture_path = Path(__file__).parent / "home"
if not fixture_path.exists():
pytest.skip("Fixture home directories not found")
return fixture_path
class HomeDirManager:
"""Manager for test home directories"""
def __init__(self, base_path: Path):
self.base_path = base_path
self.created_dirs: List[Path] = []
def create_agent_home(self, agent_name: str, agent_type: str = "agent") -> Path:
"""Create a new agent home directory"""
agent_path = self.base_path / agent_name
agent_path.mkdir(exist_ok=True)
# Create AITBC structure
(agent_path / ".aitbc").mkdir(exist_ok=True)
(agent_path / ".aitbc" / "wallets").mkdir(exist_ok=True)
(agent_path / ".aitbc" / "config").mkdir(exist_ok=True)
# Create default config
config_file = agent_path / ".aitbc" / "config.yaml"
config_file.write_text(f"""
agent:
name: {agent_name}
type: {agent_type}
wallet_path: ~/.aitbc/wallets/{agent_name}_wallet.json
node:
endpoint: http://localhost:8082
timeout: 30
coordinator:
url: http://localhost:8000
api_key: null
""")
self.created_dirs.append(agent_path)
return agent_path
def create_wallet(self, agent_name: str, address: str, balance: int = 0) -> Path:
"""Create a wallet file for an agent"""
agent_path = self.base_path / agent_name
wallet_path = agent_path / ".aitbc" / "wallets" / f"{agent_name}_wallet.json"
wallet_data = {
"address": address,
"balance": balance,
"transactions": [],
"created_at": "2026-03-03T00:00:00Z"
}
import json
wallet_path.write_text(json.dumps(wallet_data, indent=2))
return wallet_path
def cleanup(self):
"""Clean up created directories"""
for dir_path in self.created_dirs:
if dir_path.exists():
import shutil
shutil.rmtree(dir_path)
self.created_dirs.clear()
@pytest.fixture
def home_dir_manager(tmp_path):
"""Create a home directory manager for tests"""
manager = HomeDirManager(tmp_path)
yield manager
manager.cleanup()
# Constants for fixture paths
FIXTURE_HOME_PATH = Path(__file__).parent / "home"
CLIENT1_HOME_PATH = FIXTURE_HOME_PATH / "client1"
MINER1_HOME_PATH = FIXTURE_HOME_PATH / "miner1"
def get_fixture_home_path(agent_name: str) -> Path:
"""Get the path to a fixture home directory"""
return FIXTURE_HOME_PATH / agent_name
def fixture_home_exists(agent_name: str) -> bool:
"""Check if a fixture home directory exists"""
return get_fixture_home_path(agent_name).exists()
def create_test_wallet(agent_name: str, address: str, balance: int = 0) -> Dict:
"""Create test wallet data"""
return {
"address": address,
"balance": balance,
"transactions": [],
"created_at": "2026-03-03T00:00:00Z",
"agent_name": agent_name
}
def setup_fixture_homes():
"""Set up the fixture home directories if they don't exist"""
fixture_path = FIXTURE_HOME_PATH
if not fixture_path.exists():
fixture_path.mkdir(parents=True, exist_ok=True)
# Create standard agent homes
for agent_name, agent_type in [("client1", "client"), ("miner1", "miner")]:
agent_path = fixture_path / agent_name
agent_path.mkdir(exist_ok=True)
# Create AITBC structure
(agent_path / ".aitbc").mkdir(exist_ok=True)
(agent_path / ".aitbc" / "wallets").mkdir(exist_ok=True)
(agent_path / ".aitbc" / "config").mkdir(exist_ok=True)
# Create default config
config_file = agent_path / ".aitbc" / "config.yaml"
config_file.write_text(f"""
agent:
name: {agent_name}
type: {agent_type}
wallet_path: ~/.aitbc/wallets/{agent_name}_wallet.json
node:
endpoint: http://localhost:8082
timeout: 30
coordinator:
url: http://localhost:8000
api_key: null
""")
# Create empty wallet
wallet_file = agent_path / ".aitbc" / "wallets" / f"{agent_name}_wallet.json"
wallet_data = create_test_wallet(agent_name, f"aitbc1{agent_name}", 1000)
import json
wallet_file.write_text(json.dumps(wallet_data, indent=2))
# Ensure fixture homes exist when this module is imported
setup_fixture_homes()

View File

@@ -0,0 +1,13 @@
agent:
name: client1
type: client
wallet_path: ~/.aitbc/wallets/client1_wallet.json
node:
endpoint: http://localhost:8082
timeout: 30
coordinator:
url: http://localhost:8000
api_key: null

View File

@@ -0,0 +1,49 @@
Okay, this is a hugely exciting and rapidly evolving area! The future of AI in decentralized systems is looking remarkably bright, and blockchain technology is a pivotal enabler. Heres a breakdown of what we can expect, broken down into key areas:
**1. The Future Landscape of AI in Decentralized Systems**
* **Increased Automation & Scalability:** Current decentralized systems (like DAOs, DeFi, and gaming) often struggle with complex decision-making and scalability. AI will be crucial to automate these processes, making them more efficient and less reliant on human intervention. Think of AI-powered automated market makers, smart contracts executing complex scenarios, and personalized asset management.
* **Enhanced Data Analysis & Insights:** Decentralized data is invaluable. AI will be used to analyze this data identifying patterns, anomalies, and opportunities far more effectively than traditional methods. This will lead to smarter governance, optimized resource allocation, and better risk assessment.
* **Personalized & Adaptive Experiences:** AI will personalize user experiences within decentralized platforms. Instead of relying on rigid rules, AI will understand individual behavior and preferences to tailor everything from content recommendations to loan terms.
* **Novel AI Models & Architectures:** Well see the development of AI models specifically designed for decentralized environments. This includes models that are:
* **Federated Learning:** Allows models to be trained across multiple decentralized nodes without sharing raw data, improving privacy and model robustness.
* **Differential Privacy:** Protects individual data points while still allowing for analysis, which is critical for privacy-preserving AI.
* **Secure Multi-Party Computation (SMPC):** Enables multiple parties to jointly compute a result without revealing their individual inputs.
* **AI-Driven Governance & Decentralized Autonomous Organizations (DAOs):** AI will be integrated into DAOs to:
* **Automate Governance:** AI can analyze proposals, vote flows, and community sentiment to suggest optimal governance strategies.
* **Identify & Mitigate Risks:** AI can detect potential risks like collusion or malicious activity within a DAO.
* **Optimize Resource Allocation:** AI can allocate funds and resources to projects based on community demand and potential impact.
**2. How Blockchain Technology Enhances AI Model Sharing & Governance**
Blockchain is *absolutely* the key technology here. Here's how its transforming AI governance:
* **Immutable Record of AI Models:** Blockchain creates an immutable record of every step in the AI model lifecycle training data, model versions, validation results, and even the models performance metrics. This ensures transparency and auditability.
* **Decentralized Model Sharing:** Instead of relying on centralized platforms like Hugging Face, models can be shared and distributed directly across the blockchain network. This creates a trustless ecosystem, reducing the risk of model manipulation or censorship.
* **Smart Contracts for Model Licensing & Royalty Payments:** Smart contracts can automate licensing agreements, distribute royalties to data providers, and manage intellectual property rights related to AI models. This is crucial for incentivizing collaboration and ensuring fair compensation.
* **Tokenization of AI Models:** Models can be tokenized (represented as unique digital assets) which can be used as collateral for loans, voting rights, or other incentives within the decentralized ecosystem. This unlocks new uses for AI assets.
* **Reputation Systems:** Blockchain-based reputation systems can reward contributors and penalize malicious behavior, fostering a more trustworthy and collaborative environment for AI model development.
* **Decentralized Verification & Validation:** The blockchain can be used to verify the accuracy and reliability of AI model outputs. Different parties can validate the results, building confidence in the model's output.
* **DAO Governance & Trust:** Blockchain-based DAOs allow for decentralized decision-making on AI model deployment, updates, and governance shifting control away from a single entity.
**3. Challenges & Considerations**
* **Scalability:** Blockchain can be slow and expensive, hindering the scalability needed for large-scale AI deployments. Layer-2 solutions and alternative blockchains are being explored.
* **Regulation:** The legal and regulatory landscape surrounding AI is still evolving. Decentralized AI systems need to navigate these complexities.
* **Data Privacy:** While blockchain can enhance transparency, its crucial to implement privacy-preserving techniques to protect sensitive data within AI models.
* **Computational Costs:** Running AI models on blockchain can be resource-intensive. Optimization and efficient model design are essential.
**Resources for Further Learning:**
* **Blockchain and AI:** [https://www.blockchainandai.com/](https://www.blockchainandai.com/)
* **Decentralized AI:** [https://www.decentralizedai.com/](https://www.decentralizedai.com/)
* **Ethereum Foundation - AI:** [https://ethereumfoundation.org/news/ethereum-foundation-ai](https://ethereumfoundation.org/news/ethereum-foundation-ai)
To help me tailor my response further, could you tell me:
* What specific area of AI are you most interested in (e.g., Generative AI, Machine Learning, Blockchain integration)?
* What kind of decentralized system are you thinking of (e.g., DeFi, DAOs, Gaming, Supply Chain)?

View File

@@ -0,0 +1,13 @@
agent:
name: miner1
type: miner
wallet_path: ~/.aitbc/wallets/miner1_wallet.json
node:
endpoint: http://localhost:8082
timeout: 30
coordinator:
url: http://localhost:8000
api_key: null

View File

@@ -0,0 +1 @@
What is the future of artificial intelligence in decentralized systems, and how will blockchain technology enhance AI model sharing and governance?