Skip to content

Commit eaba2a1

Browse files
Add comprehensive documentation for KNU token distribution system
Co-authored-by: AmedeoPelliccia <164860269+AmedeoPelliccia@users.noreply.github.com>
1 parent fcb351e commit eaba2a1

File tree

1 file changed

+265
-0
lines changed

1 file changed

+265
-0
lines changed

config/tokenomics/README.md

Lines changed: 265 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,265 @@
1+
# KNU Token Distribution System
2+
3+
## Overview
4+
5+
The **KNU Token Distribution System** distributes token rewards to contributors based on a weighted combination of **predicted effort** and **measured impact** (including spillover effects to adjacent KNOTs).
6+
7+
This system implements the distribution formula:
8+
9+
```
10+
w_i = α·Ê_i + (1-α)·Î_i
11+
T_i = P_k · w_i
12+
```
13+
14+
Where:
15+
- `P_k` = Prize pool (total KNU tokens for the KNOT)
16+
- `E_i` = Predicted effort (normalized)
17+
- `Ê_i` = Normalized effort: `E_i / Σ E_i`
18+
- `I_i` = Effective impact: `ΔR_k,i + λ·S_i`
19+
- `Î_i` = Normalized impact: `I_i / Σ I_i`
20+
- `S_i` = Spillover: `Σ(a_k→j · ΔR_j,i)` for adjacent KNOTs
21+
- `ΔR_k,i` = Direct residue reduction attributed to KNU
22+
- `a_k→j` = Adjacency weight between KNOTs
23+
24+
**Default Parameters:**
25+
- `α = 0.30` (30% effort, 70% impact)
26+
- `λ = 0.50` (spillover worth 50% of direct impact)
27+
28+
## Files
29+
30+
### Configuration
31+
- **`config/tokenomics/knu_distribution.yaml`** - Central configuration for distribution parameters, eligibility criteria, KNOT pools, and adjacency graph
32+
33+
### Schema
34+
- **`schemas/knu_reward_record.schema.json`** - JSON Schema for reward record validation
35+
36+
### Templates
37+
- **`templates/knu-reward-ledger.csv`** - CSV template for tracking KNU rewards
38+
39+
### Scripts
40+
- **`scripts/knu_token_distribution.py`** - Main distribution calculator with CLI commands
41+
42+
## Usage
43+
44+
### 1. Prepare KNU Entries
45+
46+
Create a CSV file with your KNU entries following the template in `templates/knu-reward-ledger.csv`:
47+
48+
```csv
49+
knot_id,knu_id,owner,E_pred,dR_primary,dR_adj_sum,status,artifacts,validated_by,validated_at,weight,tokens_awarded
50+
K06,KNU-K06-00-001,CM WG,5.0,30.0,10.0,merged,schema_v2.json;migration_guide.md,Lead Architect,2026-01-10T12:00:00Z,,
51+
K06,KNU-K06-00-002,AI/ML Engineering,3.0,15.0,5.0,accepted,trace_validator.py,QA Team,2026-01-10T14:00:00Z,,
52+
```
53+
54+
**Field Descriptions:**
55+
- `knot_id` - KNOT identifier (K01-K14)
56+
- `knu_id` - Unique KNU identifier (format: `KNU-{KNOT}-{PARTITION}-{SEQUENCE}`)
57+
- `owner` - Person or team responsible for resolution
58+
- `E_pred` - Predicted effort score (arbitrary units, normalized during calculation)
59+
- `dR_primary` - Direct residue reduction in primary KNOT (0-100%)
60+
- `dR_adj_sum` - Sum of residue reductions in adjacent KNOTs (0-100%)
61+
- `status` - Current status (`draft`, `submitted`, `in_review`, `accepted`, `merged`, `rejected`)
62+
- `artifacts` - Semicolon-separated list of artifact references
63+
- `validated_by` - Name of validator who confirmed impact
64+
- `validated_at` - Validation timestamp (ISO 8601 format)
65+
- `weight` - Calculated distribution weight (filled by script)
66+
- `tokens_awarded` - Number of tokens awarded (filled by script)
67+
68+
### 2. Distribute Tokens
69+
70+
Run the distribution command:
71+
72+
```bash
73+
python scripts/knu_token_distribution.py distribute \
74+
--knot K06 \
75+
--pool 1000 \
76+
--input knu_entries.csv \
77+
--output knu_rewards.csv
78+
```
79+
80+
**Options:**
81+
- `--knot` (required) - KNOT ID (e.g., K06)
82+
- `--pool` (optional) - Pool amount (overrides config default)
83+
- `--input` (required) - Input CSV file with KNU entries
84+
- `--output` (optional) - Output CSV file (defaults to overwriting input)
85+
- `--alpha` (optional) - Effort weight (0.0-1.0, default: 0.30)
86+
- `--lambda` (optional) - Spillover multiplier (0.0-1.0, default: 0.50)
87+
88+
**Example with custom parameters:**
89+
```bash
90+
python scripts/knu_token_distribution.py distribute \
91+
--knot K06 \
92+
--pool 1000 \
93+
--input knu_entries.csv \
94+
--alpha 0.25 \
95+
--lambda 0.60
96+
```
97+
98+
### 3. Generate Distribution Report
99+
100+
Generate a JSON report with detailed distribution information:
101+
102+
```bash
103+
python scripts/knu_token_distribution.py report \
104+
--knot K06 \
105+
--input knu_rewards.csv \
106+
--output distribution_report.json
107+
```
108+
109+
**Report Contents:**
110+
- Distribution timestamp
111+
- KNOT ID and pool configuration
112+
- Distribution parameters (α, λ)
113+
- All KNU entries with calculated weights and token awards
114+
- Total tokens distributed
115+
- Number of eligible entries
116+
117+
### 4. Validate KNU Eligibility
118+
119+
Check if a specific KNU entry qualifies for rewards:
120+
121+
```bash
122+
python scripts/knu_token_distribution.py validate \
123+
--knot K06 \
124+
--knu KNU-K06-00-001 \
125+
--input knu_entries.csv
126+
```
127+
128+
**Eligibility Criteria (default):**
129+
- Status must be `accepted` or `merged`
130+
- Must have at least one artifact
131+
- Must be validated by an authorized reviewer
132+
133+
## Example Calculation
134+
135+
Given the reference example from the requirements:
136+
137+
**Input:**
138+
- Pool: 1000 tokens
139+
- α = 0.30, λ = 0.50
140+
- KNU1: E=5, ΔR_k=30, S=10
141+
- KNU2: E=3, ΔR_k=15, S=5
142+
- KNU3: E=2, ΔR_k=5, S=0
143+
144+
**Calculation:**
145+
146+
1. **Effective Impact:** `I_i = ΔR_k,i + λ·S_i`
147+
- KNU1: 30 + 0.50×10 = 35
148+
- KNU2: 15 + 0.50×5 = 17.5
149+
- KNU3: 5 + 0.50×0 = 5
150+
151+
2. **Normalized Effort:** `Ê_i = E_i / ΣE_i`
152+
- E_total = 10
153+
- KNU1: 5/10 = 0.50
154+
- KNU2: 3/10 = 0.30
155+
- KNU3: 2/10 = 0.20
156+
157+
3. **Normalized Impact:** `Î_i = I_i / ΣI_i`
158+
- I_total = 57.5
159+
- KNU1: 35/57.5 = 0.6087
160+
- KNU2: 17.5/57.5 = 0.3043
161+
- KNU3: 5/57.5 = 0.0870
162+
163+
4. **Weights:** `w_i = α·Ê_i + (1-α)·Î_i`
164+
- KNU1: 0.30×0.50 + 0.70×0.6087 = 0.5761
165+
- KNU2: 0.30×0.30 + 0.70×0.3043 = 0.3030
166+
- KNU3: 0.30×0.20 + 0.70×0.0870 = 0.1209
167+
168+
5. **Token Awards:** `T_i = P_k · w_i`
169+
- KNU1: 1000 × 0.5761 = **576 tokens**
170+
- KNU2: 1000 × 0.3030 = **303 tokens**
171+
- KNU3: 1000 × 0.1209 = **121 tokens**
172+
173+
## Configuration
174+
175+
### Adjusting Distribution Parameters
176+
177+
Edit `config/tokenomics/knu_distribution.yaml`:
178+
179+
```yaml
180+
parameters:
181+
alpha: 0.30 # Effort weight (0.0-1.0)
182+
lambda_spillover: 0.50 # Spillover multiplier (0.0-1.0)
183+
```
184+
185+
### Modifying Eligibility Criteria
186+
187+
```yaml
188+
eligibility:
189+
required_status:
190+
- "accepted"
191+
- "merged"
192+
require_artifacts: true
193+
require_validation: true
194+
```
195+
196+
### Updating KNOT Pools
197+
198+
```yaml
199+
knot_pools:
200+
K06:
201+
base_pool: 1000
202+
description: "Data governance SSOT schemas identifiers"
203+
```
204+
205+
### Defining Adjacency Relationships
206+
207+
The adjacency graph defines how impact in one KNOT spills over to adjacent KNOTs:
208+
209+
```yaml
210+
adjacency_graph:
211+
K06:
212+
K01: 0.3 # Data governance → Certification
213+
K05: 0.3 # Data governance → Model fidelity
214+
K07: 0.4 # Data governance → AI/ML
215+
K08: 0.5 # Data governance → DPP
216+
```
217+
218+
## Integration with Existing Code
219+
220+
The token distribution system integrates with existing AMPEL360 Space-T components:
221+
222+
### KNOT-AoR Mapping
223+
- Imports `KNOT_AOR_MAPPING` from `scripts/knot_aor_mapping.py`
224+
- Uses KNOT definitions to derive adjacency relationships
225+
226+
### NKU Scoring Patterns
227+
- Follows CSV handling patterns from `scripts/nku_scoring.py`
228+
- Implements CSV injection prevention
229+
- Uses similar dataclass patterns and CLI structure
230+
231+
## Security Considerations
232+
233+
### CSV Injection Prevention
234+
All CSV fields are sanitized to prevent injection attacks:
235+
- Dangerous characters (`=`, `+`, `-`, `@`, tabs, newlines) are prefixed with a single quote
236+
- Embedded newlines are replaced with spaces
237+
238+
### Input Validation
239+
- KNOT IDs validated against pattern `^K(0[1-9]|1[0-4])$`
240+
- KNU IDs validated against pattern `^KNU-K(0[1-9]|1[0-4])-[A-Z0-9]{2,6}-\d{3}$`
241+
- Numeric values constrained (effort ≥ 0, residue 0-100%)
242+
- Required fields enforced by JSON Schema
243+
244+
## Troubleshooting
245+
246+
### Error: "No eligible KNU entries"
247+
- Check that KNU entries have status `accepted` or `merged`
248+
- Verify artifacts are provided
249+
- Ensure entries are validated by an authorized reviewer
250+
251+
### Error: "No pool configuration found"
252+
- Check that the KNOT ID exists in `config/tokenomics/knu_distribution.yaml`
253+
- Verify KNOT ID format (K01-K14)
254+
255+
### Calculation discrepancies
256+
- Verify input data is correct (E_pred, dR_primary, dR_adj_sum)
257+
- Check that spillover values (dR_adj_sum) are pre-calculated correctly
258+
- Ensure normalization is working (weights should sum to 1.0)
259+
260+
## References
261+
262+
- **Problem Statement**: See issue requirements for full specification
263+
- **KNOT Governance**: K01-K14 definitions with uncertainty focus
264+
- **NKU Scoring**: `scripts/nku_scoring.py` for related uncertainty tracking
265+
- **KNOT-AoR Mapping**: `scripts/knot_aor_mapping.py` for KNOT relationships

0 commit comments

Comments
 (0)