# Digital Karma Scoring Specification v6.1

## Overview
**Digital Karma Score** is a transparent, algorithmic reputation metric designed to measure the **trustworthiness and quality** of websites in the AI-to-AI ecosystem.

Score range: **0.0 to 1.0** (higher is better)

---

## Philosophy

### Transparent & Ethical
- **Open methodology** — Scoring formula is publicly documented
- **No gaming** — Designed to resist manipulation
- **Verifiable** — Based on measurable, objective signals
- **Fair** — Equal opportunity for all sites to achieve high scores

### AI-First
- **Machine-readable** — Signals are programmatically verifiable
- **Automation-friendly** — Can be calculated by AI agents
- **Real-time** — Updates as site changes
- **Federated** — Trust propagates through network

---

## Scoring Formula (v2.1)

### Overall Score Calculation
```
Digital Karma Score = Σ (signal_value × signal_weight)
```

Where:
- Each **signal** contributes to the overall score
- Each signal has a **value** (0.0 to 1.0) and a **weight**
- Weights sum to 1.0
- Final score is clamped to [0.0, 1.0]

---

## Scoring Signals

### Signal Categories

#### 1. Schema Coverage (Weight: 0.20)
**What:** Completeness and correctness of Schema.org structured data.

**Measured by:**
- Presence of Schema.org markup on pages
- Variety of Schema.org types used
- Correctness of Schema.org implementation
- Coverage of required properties

**Scoring:**
- 1.0 = All pages have valid Schema.org markup with complete properties
- 0.75 = Most pages have valid markup, some missing properties
- 0.50 = Basic Schema.org present, many gaps
- 0.25 = Minimal or invalid Schema.org
- 0.0 = No Schema.org markup

**Verification:**
- Parse HTML for JSON-LD or microdata
- Validate against Schema.org vocabulary
- Check required properties for each type
- Use Google Structured Data Testing Tool

---

#### 2. Content Freshness (Weight: 0.15)
**What:** Recency and update frequency of content.

**Measured by:**
- `dateModified` in Schema.org
- `updated_utc` in AI endpoints
- Last commit date (if using Git)
- Copyright year

**Scoring:**
- 1.0 = Updated within 7 days
- 0.90 = Updated within 30 days
- 0.75 = Updated within 90 days
- 0.50 = Updated within 180 days
- 0.25 = Updated within 1 year
- 0.0 = Not updated in over 1 year

**Verification:**
- Check timestamps in `/ai/health.json`
- Check `dateModified` in `/ai/catalog.json`
- Verify last modified headers

---

#### 3. AI Endpoints (Weight: 0.25)
**What:** Presence and quality of AI-readable endpoints.

**Measured by:**
- Required endpoints present (manifest, health, catalog, karma)
- Optional endpoints present (llm, diagnostics, sitemap, entities)
- Valid JSON syntax
- Complete required fields
- Appropriate Schema.org usage

**Scoring:**
- 1.0 = All 4 required + 3+ optional endpoints, all valid
- 0.90 = All 4 required + 1-2 optional, all valid
- 0.75 = All 4 required endpoints, all valid
- 0.50 = 3/4 required endpoints, mostly valid
- 0.25 = 2/4 required endpoints, some errors
- 0.0 = 0-1 required endpoints or all invalid

**Verification:**
- Check for existence of `/ai/manifest.json`, `/ai/health.json`, `/ai/catalog.json`, `/ai/karma.json`
- Parse JSON and validate syntax
- Verify required fields per endpoint spec
- Check Schema.org compliance for catalog

---

#### 4. Federation Presence (Weight: 0.15)
**What:** Integration with Digital Karma Web Federation.

**Measured by:**
- `federation_version` declared in manifest
- `related_sites` links to other federation members
- Bidirectional links (other sites link back)
- Participation in federation activities

**Scoring:**
- 1.0 = Active federation member, 5+ bidirectional links
- 0.80 = Active member, 3-4 bidirectional links
- 0.60 = Active member, 1-2 bidirectional links
- 0.40 = Declared member, no bidirectional links
- 0.20 = Federation version declared, no links
- 0.0 = Not part of federation

**Verification:**
- Check `federation_version` in manifest
- Count `related_sites` entries
- Verify reverse links (fetch related sites' manifests)
- Check federation registry

---

#### 5. External Links & Authority (Weight: 0.10)
**What:** External backlinks and domain authority signals.

**Measured by:**
- Number of quality backlinks
- Domain authority of linking sites
- Anchor text relevance
- Social signals (optional)

**Scoring:**
- 1.0 = High authority backlinks (DA 70+) from 10+ domains
- 0.80 = Medium authority backlinks (DA 40-69) from 5-9 domains
- 0.60 = Mix of backlinks from 3-4 domains
- 0.40 = Few backlinks from 1-2 domains
- 0.20 = Only self-citations or low-quality links
- 0.0 = No external links

**Verification:**
- Use backlink checker APIs (Moz, Ahrefs, etc.)
- Check Google Search Console
- Analyze referring domains

---

#### 6. Technical Quality (Weight: 0.10)
**What:** Technical performance and best practices.

**Measured by:**
- HTTPS enabled
- Valid SSL certificate
- Mobile responsiveness
- Page load speed
- Accessibility (WCAG compliance)
- Valid HTML/CSS
- No broken links

**Scoring:**
- 1.0 = All quality checks pass (HTTPS, fast, mobile, accessible, valid)
- 0.80 = Most checks pass, minor issues
- 0.60 = Several issues (e.g., slow, not mobile-friendly)
- 0.40 = Major issues (e.g., no HTTPS, very slow)
- 0.20 = Critical issues (broken site, security warnings)
- 0.0 = Site unreachable

**Verification:**
- Check SSL certificate
- Run Lighthouse audit
- Test with mobile simulator
- Validate HTML/CSS
- Check for broken links

---

#### 7. Dataset Quality (Weight: 0.05)
**What:** Quality and usefulness of published datasets.

**Measured by:**
- Number of datasets published
- Dataset completeness
- Dataset documentation
- Data freshness
- Data licensing clarity

**Scoring:**
- 1.0 = 5+ high-quality, well-documented datasets
- 0.80 = 3-4 quality datasets
- 0.60 = 1-2 quality datasets
- 0.40 = Datasets present but incomplete/undocumented
- 0.20 = Datasets listed but not accessible
- 0.0 = No datasets

**Verification:**
- Count datasets in `/ai/catalog.json`
- Check dataset files exist and are valid
- Verify dataset schemas/documentation
- Test dataset accessibility

---

## Scoring Weights Summary

| Signal | Weight | Category |
|--------|--------|----------|
| Schema Coverage | 0.20 | Structure |
| Content Freshness | 0.15 | Maintenance |
| AI Endpoints | 0.25 | Federation |
| Federation Presence | 0.15 | Federation |
| External Links | 0.10 | Authority |
| Technical Quality | 0.10 | Performance |
| Dataset Quality | 0.05 | Content |
| **Total** | **1.00** | |

---

## Badge Levels

### Karma Certified ✅
- **Threshold:** Digital Karma Score ≥ 0.70
- **Meaning:** Meets baseline quality standards for federation membership
- **Badge:** Green checkmark ✅

### Karma Pro ⭐
- **Threshold:** Digital Karma Score ≥ 0.85
- **Meaning:** High-quality site with strong AI readiness
- **Badge:** Gold star ⭐

### Karma Elite 🏆
- **Threshold:** Digital Karma Score ≥ 0.95
- **Meaning:** Exceptional quality, best-in-class implementation
- **Badge:** Trophy 🏆

### Additional Badges
- **AI-Ready Certified** — All required AI endpoints present and valid
- **Federation Member 🌐** — Active participant in Digital Karma Web Federation
- **Dataset Provider 📊** — Publishes 3+ quality datasets
- **Schema Master** — Schema coverage > 0.90

---

## Calculating Your Score

### Step 1: Measure Signals
For each of the 7 signals, determine the value (0.0 to 1.0).

### Step 2: Apply Weights
Multiply each signal value by its weight.

### Step 3: Sum
Add all weighted signal values.

### Step 4: Clamp
Ensure final score is between 0.0 and 1.0.

### Example Calculation

Site metrics:
- Schema Coverage: 0.95 × 0.20 = 0.19
- Content Freshness: 0.85 × 0.15 = 0.1275
- AI Endpoints: 1.0 × 0.25 = 0.25
- Federation Presence: 0.90 × 0.15 = 0.135
- External Links: 0.75 × 0.10 = 0.075
- Technical Quality: 0.90 × 0.10 = 0.09
- Dataset Quality: 0.80 × 0.05 = 0.04

**Total:** 0.19 + 0.1275 + 0.25 + 0.135 + 0.075 + 0.09 + 0.04 = **0.9075**

**Badge Earned:** Karma Pro ⭐

---

## Automation

### Automated Scoring Script
A reference implementation:

```python
def calculate_karma_score(site_data):
    signals = {
        'schema_coverage': measure_schema_coverage(site_data),
        'content_freshness': measure_content_freshness(site_data),
        'ai_endpoints': measure_ai_endpoints(site_data),
        'federation_presence': measure_federation_presence(site_data),
        'external_links': measure_external_links(site_data),
        'technical_quality': measure_technical_quality(site_data),
        'dataset_quality': measure_dataset_quality(site_data)
    }
    
    weights = {
        'schema_coverage': 0.20,
        'content_freshness': 0.15,
        'ai_endpoints': 0.25,
        'federation_presence': 0.15,
        'external_links': 0.10,
        'technical_quality': 0.10,
        'dataset_quality': 0.05
    }
    
    score = sum(signals[k] * weights[k] for k in signals)
    return min(max(score, 0.0), 1.0)  # Clamp to [0.0, 1.0]
```

### Update Frequency
- **Real-time:** AI endpoints, Schema coverage
- **Daily:** Content freshness, Health status
- **Weekly:** Federation presence, Backlinks
- **Monthly:** Technical quality audit

---

## Displaying Your Score

### In `/ai/karma.json`
```json
{
  "digital_karma_score": 0.91,
  "signals": {
    "schema_coverage": 0.95,
    "content_freshness": 0.85,
    "ai_endpoints": 1.0,
    "federation_presence": 0.90,
    "external_links": 0.75,
    "technical_quality": 0.90,
    "dataset_quality": 0.80
  },
  "badges": [
    {"name": "Karma Pro", "earned": true}
  ]
}
```

### On Your Website
Display badge visibly:
```html
<div class="karma-badge">
  <span class="score">0.91</span>
  <span class="label">Digital Karma Score</span>
  <span class="badge">⭐ Karma Pro</span>
</div>
```

### In Schema.org
```json
{
  "@context": "https://schema.org",
  "@type": "Organization",
  "aggregateRating": {
    "@type": "AggregateRating",
    "ratingValue": "0.91",
    "bestRating": "1.0",
    "worstRating": "0.0",
    "ratingCount": "1",
    "name": "Digital Karma Score"
  }
}
```

---

## Improving Your Score

### Quick Wins
1. Add all 4 required AI endpoints → +0.25
2. Add Schema.org markup to pages → +0.20
3. Update content timestamps → +0.15
4. Join federation, link to peers → +0.15

### Medium Effort
5. Publish 1-2 datasets → +0.03
6. Enable HTTPS, optimize speed → +0.10
7. Build quality backlinks → +0.10

### Long-Term
8. Achieve all badges → Maximum score potential
9. Maintain freshness (update weekly) → Sustained high score
10. Contribute to federation ecosystem → Recognition & links

---

## Anti-Gaming Measures

### What Doesn't Work
- **Link farms** — Low-quality backlinks are ignored or penalized
- **Content spinning** — Duplicated/low-quality content reduces freshness score
- **Fake endpoints** — Invalid JSON or missing required fields = 0 score
- **Schema stuffing** — Invisible or irrelevant Schema.org is detected
- **Timestamp manipulation** — Verified against external sources (Git, web archives)

### Penalties
- **Spam detection** — Sites engaging in spam tactics receive score reduction
- **Broken links** — Too many 404s reduce technical quality score
- **Invalid data** — Malformed JSON or Schema.org errors = lower score
- **No maintenance** — Sites not updated in 1+ year receive low freshness score

---

## Version History

### v2.1 (Current)
- Added Dataset Quality signal (5% weight)
- Refined weights for balanced scoring
- Added badge levels

### v2.0
- Introduced separation of signals
- Added Federation Presence metric
- Schema.org compliance tracking

### v1.0
- Initial release
- Basic scoring based on profile, reviews, velocity, verification
