1_general_forum/currency-ledger/scripts/generate-public-pages.py

300 lines
11 KiB
Python

#!/usr/bin/env python3
"""
Generate MkDocs pages for public transparency
Converts CSV ledger data into beautiful web pages - WORKING VERSION
"""
import csv
import os
from datetime import datetime
def parse_financial_data():
"""Parse actual financial data from CSV files"""
base_path = os.path.join(os.path.dirname(__file__), '..')
# Parse live SC from transactions
live_sc = 0
sc_file = os.path.join(base_path, 'ledger', 'smartup-credits', 'transactions.csv')
try:
with open(sc_file, 'r') as f:
reader = csv.DictReader(f)
for row in reader:
if not row['timestamp'].startswith('#') and row['timestamp']:
if row['type'] == 'SC':
live_sc += int(row['amount'])
elif row['type'] in ['REDEEM', 'DESTROY']:
live_sc -= int(row['amount'])
except FileNotFoundError:
live_sc = 0
# Parse treasury balance
treasury_eur = 0
treasury_file = os.path.join(base_path, 'ledger', 'treasury', 'balance.csv')
try:
with open(treasury_file, 'r') as f:
reader = csv.DictReader(f)
for row in reader:
if not row['timestamp'].startswith('#') and row['timestamp']:
treasury_eur = float(row['total_eur_balance'])
except FileNotFoundError:
treasury_eur = 0
# Parse pending SC
pending_sc = 0
pending_file = os.path.join(base_path, 'ledger', 'pending-sc', 'transactions.csv')
try:
with open(pending_file, 'r') as f:
reader = csv.DictReader(f)
for row in reader:
if not row['timestamp'].startswith('#') and row['timestamp']:
if row['status'] == 'PENDING_VALIDATION':
pending_sc += int(row['amount'])
except FileNotFoundError:
pending_sc = 0
return live_sc, treasury_eur, pending_sc
def generate_book_of_owners_page():
"""Generate public Book of Owners page"""
book_file = os.path.join(os.path.dirname(__file__), '..', 'ownership', 'book-of-owners.csv')
output_file = os.path.join(os.path.dirname(__file__), '..', '..', 'docs', 'smartup-zero', 'book-of-owners.md')
with open(book_file, 'r') as f:
reader = csv.DictReader(f)
owners = [row for row in reader if row['owner_id'] and not row['owner_id'].startswith('#')]
content = f'''# 📖 Book of Owners
**Live transparency into Smartup Zero ownership and organizational structure**
*Last updated: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}*
---
## Current Owners
| Owner ID | Display Name | License | Teams | Roles | SK | Status |
|----------|--------------|---------|-------|-------|----|---------| '''
for owner in owners:
content += f'''
| {owner['owner_id']} | **{owner['display_name']}** | `{owner['license_type']}` | {owner['team_memberships']} | {owner['role_assignments']} | {owner['current_sk']} | {owner['status']} |'''
content += f'''
## Organizational Statistics
- **Total Owners**: {len(owners)}
- **Active Contributors**: {len([o for o in owners if o['status'] == 'active'])}
- **Teams Formed**: {len(set([t.strip() for o in owners for t in o['team_memberships'].split(',') if t.strip()]))}
- **Roles Assigned**: {len(set([r.strip() for o in owners for r in o['role_assignments'].split(',') if r.strip()]))}
## License Distribution
'''
license_counts = {}
for owner in owners:
license_type = owner['license_type']
license_counts[license_type] = license_counts.get(license_type, 0) + 1
for license_type, count in license_counts.items():
content += f"- **{license_type.title()}**: {count} owners\n"
content += '''
## Democratic Principles
Every person listed above is an **equal co-owner** of Smartup Zero, regardless of license price paid. The license determines capabilities (what you can do), but every owner gets exactly **one vote** in governance decisions.
!!! info "Transparency Note"
This Book of Owners uses public aliases chosen by each owner. Real identities are kept private unless owners choose full public disclosure.
---
*This page automatically reflects the current state of `currency-ledger/ownership/book-of-owners.csv`*
'''
with open(output_file, 'w') as f:
f.write(content)
print(f"✅ Generated: docs/smartup-zero/book-of-owners.md")
def generate_financial_transparency_page():
"""Generate financial transparency page with REAL DATA"""
output_file = os.path.join(os.path.dirname(__file__), '..', '..', 'docs', 'smartup-zero', 'financial-transparency.md')
# Parse actual financial data
live_sc, treasury_eur, pending_sc = parse_financial_data()
# Calculate 3x rule status
if treasury_eur > 0:
ratio = live_sc / (treasury_eur * 3)
if ratio <= 1:
rule_status = f"✅ COMPLIANT ({ratio:.1%} of limit)"
else:
rule_status = f"❌ VIOLATION ({ratio:.1%} of limit)"
else:
if live_sc > 0:
rule_status = "⚠️ PENDING (SC outstanding but no treasury funding yet)"
else:
rule_status = "✅ COMPLIANT (no SC outstanding)"
content = f'''# 💰 Financial Transparency
**Complete transparency into Smartup Zero's financial health and currency system**
*Last updated: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}*
---
## Current Financial Status
- 💶 **EUR Treasury**: €{treasury_eur:,.2f}
- 🪙 **Live Smartup Credits**: {live_sc:,} SC
- ⏳ **Pending Validation**: {pending_sc:,} SC
- 📊 **3x Rule Status**: {rule_status}
## Live SC Activity
Current outstanding SC represents **earned value through completed work**:<br>
- Task-based collaborative work following effort-based assessment<br>
- Democratic validation through Team Captain approval<br>
- Complete audit trail in session logs and transaction records<br>
## Founding Work Audit
The largest pending SC amount represents the **founding entrepreneur's 10-year work audit**:
| Vesting Tranche | Amount | Validation Required | Status |
|-----------------|--------|-------------------|---------|
| **Design Phase** | 24,660 SC | Team Captains + Leadership vote | ⏳ Pending |
| **Production Phase** | 32,880 SC | Community binding vote | ⏳ Pending |
| **Organization Phase** | 24,660 SC | Automatic at market launch | ⏳ Pending |
| **TOTAL** | **82,200 SC** | Democratic validation | **Awaiting community growth** |
!!! warning "Democratic Safeguard"
The founding entrepreneur **cannot validate their own work**. All 82,200 SC requires approval from future Team Captains and community votes, proving that Smartup Zero's "no special founders" principle is real and enforceable.
## Treasury Health
**Financial Health**: {'EXCELLENT' if live_sc <= 1000 else 'GOOD' if live_sc <= 10000 else 'NEEDS_FUNDING'}
- SC holders earning value through effort-based work
- {'Treasury funding available for SC redemption' if treasury_eur > 0 else 'Treasury funding needed for SC redemption capability'}
- All transactions public and auditable in git history
---
*All financial data automatically updates from live CSV ledger files*
'''
with open(output_file, 'w') as f:
f.write(content)
print(f"✅ Generated: docs/smartup-zero/financial-transparency.md")
def generate_currency_system_page():
"""Generate currency system explanation page"""
output_file = os.path.join(os.path.dirname(__file__), '..', '..', 'docs', 'smartup-zero', 'currency-system.md')
content = '''# 💱 Currency System
**How Smartup Zero's dual-currency economy works**
---
## The Dual Currency Model
- 🪙 **Smartup Credits (SC)**: 1 SC = €1 treasury claim, earned through work
- ❤️ **Social Karma (SK)**: Non-transferable reputation, earned through community building
## How to Earn Smartup Credits
### Task-Based Earning (Effort Assessment Model)
- Small Task (1-2h): 25 SC base budget
- Medium Task (3-4h): 50 SC base budget
- Large Task (5-8h): 100 SC base budget
- Complex Task (1-2 days): 200 SC base budget
**Actual SC earned based on effort quality assessment (60-100% of budget)**
### ADM Triangle Collaboration
- **Attacker (Senior)**: 90% of SC award, mentors junior
- **Defender (Junior)**: 10% of SC award, learns through participation
- **Midfielder (Bot)**: Handles coordination and documentation
### Democratic Validation Process
1. Complete collaborative work session
2. Mission Leader assesses effort quality
3. Pending SC created for Team Captain review
4. Community lazy consensus (48h)
5. Official SC award through existing validation system
## How to Earn Social Karma
| Activity | SK Award | Purpose |
|----------|----------|---------|
| Code Review | 5 SK | Quality assurance |
| Mentoring | 10 SK | Knowledge transfer |
| Documentation | 15 SK | Community resource |
| Governance | 20 SK | Democratic participation |
| Conflict Resolution | 25 SK | Community harmony |
### SK Privilege Thresholds
- **50 SK**: Can propose in General Forum
- **100 SK**: Eligible for Team Captain roles
- **200 SK**: Can lead mission objectives
- **500 SK**: Join Leadership Team + enhanced voting weight (max 1.5x)
## Treasury Management
### The 3x Rule
**Outstanding SC ≤ 3x EUR Treasury Balance**
This mathematical rule prevents SC inflation and ensures redemption capacity.
**Example**: €10,000 treasury → Maximum 30,000 SC outstanding
### License Integration
| License | SC Earning | SK Earning | Max Daily |
|---------|------------|------------|-----------|
| Campaign | ❌ | ✅ | 25 SK |
| Watch | ❌ | ✅ | 50 SK |
| Work | ✅ | ✅ | 500 SC + 100 SK |
| Organizational | ✅ | ✅ | 500 SC + 100 SK |
---
**The result**: A currency system that rewards both individual contribution and collective success, with full democratic accountability and mathematical integrity.
'''
with open(output_file, 'w') as f:
f.write(content)
print(f"✅ Generated: docs/smartup-zero/currency-system.md")
def main():
"""Generate all public transparency pages"""
print("🌐 GENERATING PUBLIC TRANSPARENCY PAGES")
print("=" * 45)
# Create docs/smartup-zero directory if it doesn't exist
smartup_zero_dir = os.path.join(os.path.dirname(__file__), '..', '..', 'docs', 'smartup-zero')
os.makedirs(smartup_zero_dir, exist_ok=True)
generate_book_of_owners_page()
generate_financial_transparency_page()
generate_currency_system_page()
print("\n✅ All transparency pages generated!")
print("📝 Files created in docs/smartup-zero/ directory")
print("🌐 Will be visible on timeline0.org when committed")
if __name__ == "__main__":
main()