-
Notifications
You must be signed in to change notification settings - Fork 0
Implement KNU token distribution system with v6.0 nomenclature compliance #82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
AmedeoPelliccia
merged 10 commits into
main
from
copilot/implement-knu-token-distribution
Feb 25, 2026
+1,441
−0
Merged
Changes from 3 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
a5e5364
Initial plan
Copilot fcb351e
Implement KNU token distribution system with config, schema, template…
Copilot eaba2a1
Add comprehensive documentation for KNU token distribution system
Copilot 5194321
Rename schema file to comply with v6.0 nomenclature standard
Copilot 110d4d1
Actualizar knu_token_distribution.py
AmedeoPelliccia f126796
Actualizar 00_AMPEL360_SPACET_Q10_GEN_PLUS_BB_GEN_SB90_K06_DATA__knu-…
AmedeoPelliccia fb647b7
Actualizar 00_AMPEL360_SPACET_Q10_GEN_PLUS_BB_GEN_SB90_K06_DATA__knu-…
AmedeoPelliccia ba8a93c
Actualizar knu_token_distribution.py
AmedeoPelliccia 88582cc
Actualizar knu-reward-ledger.csv
AmedeoPelliccia 413c839
Actualizar knu_token_distribution.py
AmedeoPelliccia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,265 @@ | ||
| # KNU Token Distribution System | ||
|
|
||
| ## Overview | ||
|
|
||
| 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). | ||
|
|
||
| This system implements the distribution formula: | ||
|
|
||
| ``` | ||
| w_i = α·Ê_i + (1-α)·Î_i | ||
| T_i = P_k · w_i | ||
| ``` | ||
|
|
||
| Where: | ||
| - `P_k` = Prize pool (total KNU tokens for the KNOT) | ||
| - `E_i` = Predicted effort (normalized) | ||
| - `Ê_i` = Normalized effort: `E_i / Σ E_i` | ||
| - `I_i` = Effective impact: `ΔR_k,i + λ·S_i` | ||
| - `Î_i` = Normalized impact: `I_i / Σ I_i` | ||
| - `S_i` = Spillover: `Σ(a_k→j · ΔR_j,i)` for adjacent KNOTs | ||
| - `ΔR_k,i` = Direct residue reduction attributed to KNU | ||
| - `a_k→j` = Adjacency weight between KNOTs | ||
|
|
||
| **Default Parameters:** | ||
| - `α = 0.30` (30% effort, 70% impact) | ||
| - `λ = 0.50` (spillover worth 50% of direct impact) | ||
|
|
||
| ## Files | ||
|
|
||
| ### Configuration | ||
| - **`config/tokenomics/knu_distribution.yaml`** - Central configuration for distribution parameters, eligibility criteria, KNOT pools, and adjacency graph | ||
|
|
||
| ### Schema | ||
| - **`schemas/knu_reward_record.schema.json`** - JSON Schema for reward record validation | ||
|
|
||
| ### Templates | ||
| - **`templates/knu-reward-ledger.csv`** - CSV template for tracking KNU rewards | ||
|
|
||
| ### Scripts | ||
| - **`scripts/knu_token_distribution.py`** - Main distribution calculator with CLI commands | ||
|
|
||
| ## Usage | ||
|
|
||
| ### 1. Prepare KNU Entries | ||
|
|
||
| Create a CSV file with your KNU entries following the template in `templates/knu-reward-ledger.csv`: | ||
|
|
||
| ```csv | ||
| knot_id,knu_id,owner,E_pred,dR_primary,dR_adj_sum,status,artifacts,validated_by,validated_at,weight,tokens_awarded | ||
| 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,, | ||
| 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,, | ||
| ``` | ||
|
|
||
| **Field Descriptions:** | ||
| - `knot_id` - KNOT identifier (K01-K14) | ||
| - `knu_id` - Unique KNU identifier (format: `KNU-{KNOT}-{PARTITION}-{SEQUENCE}`) | ||
| - `owner` - Person or team responsible for resolution | ||
| - `E_pred` - Predicted effort score (arbitrary units, normalized during calculation) | ||
| - `dR_primary` - Direct residue reduction in primary KNOT (0-100%) | ||
| - `dR_adj_sum` - Sum of residue reductions in adjacent KNOTs (0-100%) | ||
| - `status` - Current status (`draft`, `submitted`, `in_review`, `accepted`, `merged`, `rejected`) | ||
| - `artifacts` - Semicolon-separated list of artifact references | ||
| - `validated_by` - Name of validator who confirmed impact | ||
| - `validated_at` - Validation timestamp (ISO 8601 format) | ||
| - `weight` - Calculated distribution weight (filled by script) | ||
| - `tokens_awarded` - Number of tokens awarded (filled by script) | ||
|
|
||
| ### 2. Distribute Tokens | ||
|
|
||
| Run the distribution command: | ||
|
|
||
| ```bash | ||
| python scripts/knu_token_distribution.py distribute \ | ||
| --knot K06 \ | ||
| --pool 1000 \ | ||
| --input knu_entries.csv \ | ||
| --output knu_rewards.csv | ||
| ``` | ||
|
|
||
| **Options:** | ||
| - `--knot` (required) - KNOT ID (e.g., K06) | ||
| - `--pool` (optional) - Pool amount (overrides config default) | ||
| - `--input` (required) - Input CSV file with KNU entries | ||
| - `--output` (optional) - Output CSV file (defaults to overwriting input) | ||
| - `--alpha` (optional) - Effort weight (0.0-1.0, default: 0.30) | ||
| - `--lambda` (optional) - Spillover multiplier (0.0-1.0, default: 0.50) | ||
|
|
||
| **Example with custom parameters:** | ||
| ```bash | ||
| python scripts/knu_token_distribution.py distribute \ | ||
| --knot K06 \ | ||
| --pool 1000 \ | ||
| --input knu_entries.csv \ | ||
| --alpha 0.25 \ | ||
| --lambda 0.60 | ||
| ``` | ||
|
|
||
| ### 3. Generate Distribution Report | ||
|
|
||
| Generate a JSON report with detailed distribution information: | ||
|
|
||
| ```bash | ||
| python scripts/knu_token_distribution.py report \ | ||
| --knot K06 \ | ||
| --input knu_rewards.csv \ | ||
| --output distribution_report.json | ||
| ``` | ||
|
|
||
| **Report Contents:** | ||
| - Distribution timestamp | ||
| - KNOT ID and pool configuration | ||
| - Distribution parameters (α, λ) | ||
| - All KNU entries with calculated weights and token awards | ||
| - Total tokens distributed | ||
| - Number of eligible entries | ||
|
|
||
| ### 4. Validate KNU Eligibility | ||
|
|
||
| Check if a specific KNU entry qualifies for rewards: | ||
|
|
||
| ```bash | ||
| python scripts/knu_token_distribution.py validate \ | ||
| --knot K06 \ | ||
| --knu KNU-K06-00-001 \ | ||
| --input knu_entries.csv | ||
| ``` | ||
|
|
||
| **Eligibility Criteria (default):** | ||
| - Status must be `accepted` or `merged` | ||
| - Must have at least one artifact | ||
| - Must be validated by an authorized reviewer | ||
|
|
||
| ## Example Calculation | ||
|
|
||
| Given the reference example from the requirements: | ||
|
|
||
| **Input:** | ||
| - Pool: 1000 tokens | ||
| - α = 0.30, λ = 0.50 | ||
| - KNU1: E=5, ΔR_k=30, S=10 | ||
| - KNU2: E=3, ΔR_k=15, S=5 | ||
| - KNU3: E=2, ΔR_k=5, S=0 | ||
|
|
||
| **Calculation:** | ||
|
|
||
| 1. **Effective Impact:** `I_i = ΔR_k,i + λ·S_i` | ||
| - KNU1: 30 + 0.50×10 = 35 | ||
| - KNU2: 15 + 0.50×5 = 17.5 | ||
| - KNU3: 5 + 0.50×0 = 5 | ||
|
|
||
| 2. **Normalized Effort:** `Ê_i = E_i / ΣE_i` | ||
| - E_total = 10 | ||
| - KNU1: 5/10 = 0.50 | ||
| - KNU2: 3/10 = 0.30 | ||
| - KNU3: 2/10 = 0.20 | ||
|
|
||
| 3. **Normalized Impact:** `Î_i = I_i / ΣI_i` | ||
| - I_total = 57.5 | ||
| - KNU1: 35/57.5 = 0.6087 | ||
| - KNU2: 17.5/57.5 = 0.3043 | ||
| - KNU3: 5/57.5 = 0.0870 | ||
|
|
||
| 4. **Weights:** `w_i = α·Ê_i + (1-α)·Î_i` | ||
| - KNU1: 0.30×0.50 + 0.70×0.6087 = 0.5761 | ||
| - KNU2: 0.30×0.30 + 0.70×0.3043 = 0.3030 | ||
| - KNU3: 0.30×0.20 + 0.70×0.0870 = 0.1209 | ||
|
|
||
| 5. **Token Awards:** `T_i = P_k · w_i` | ||
| - KNU1: 1000 × 0.5761 = **576 tokens** | ||
| - KNU2: 1000 × 0.3030 = **303 tokens** | ||
| - KNU3: 1000 × 0.1209 = **121 tokens** | ||
|
|
||
| ## Configuration | ||
|
|
||
| ### Adjusting Distribution Parameters | ||
|
|
||
| Edit `config/tokenomics/knu_distribution.yaml`: | ||
|
|
||
| ```yaml | ||
| parameters: | ||
| alpha: 0.30 # Effort weight (0.0-1.0) | ||
| lambda_spillover: 0.50 # Spillover multiplier (0.0-1.0) | ||
| ``` | ||
|
|
||
| ### Modifying Eligibility Criteria | ||
|
|
||
| ```yaml | ||
| eligibility: | ||
| required_status: | ||
| - "accepted" | ||
| - "merged" | ||
| require_artifacts: true | ||
| require_validation: true | ||
| ``` | ||
|
|
||
| ### Updating KNOT Pools | ||
|
|
||
| ```yaml | ||
| knot_pools: | ||
| K06: | ||
| base_pool: 1000 | ||
| description: "Data governance SSOT schemas identifiers" | ||
| ``` | ||
|
|
||
| ### Defining Adjacency Relationships | ||
|
|
||
| The adjacency graph defines how impact in one KNOT spills over to adjacent KNOTs: | ||
|
|
||
| ```yaml | ||
| adjacency_graph: | ||
| K06: | ||
| K01: 0.3 # Data governance → Certification | ||
| K05: 0.3 # Data governance → Model fidelity | ||
| K07: 0.4 # Data governance → AI/ML | ||
| K08: 0.5 # Data governance → DPP | ||
| ``` | ||
|
|
||
| ## Integration with Existing Code | ||
|
|
||
| The token distribution system integrates with existing AMPEL360 Space-T components: | ||
|
|
||
| ### KNOT-AoR Mapping | ||
| - Imports `KNOT_AOR_MAPPING` from `scripts/knot_aor_mapping.py` | ||
| - Uses KNOT definitions to derive adjacency relationships | ||
|
|
||
| ### NKU Scoring Patterns | ||
| - Follows CSV handling patterns from `scripts/nku_scoring.py` | ||
| - Implements CSV injection prevention | ||
| - Uses similar dataclass patterns and CLI structure | ||
|
|
||
| ## Security Considerations | ||
|
|
||
| ### CSV Injection Prevention | ||
| All CSV fields are sanitized to prevent injection attacks: | ||
| - Dangerous characters (`=`, `+`, `-`, `@`, tabs, newlines) are prefixed with a single quote | ||
| - Embedded newlines are replaced with spaces | ||
|
|
||
| ### Input Validation | ||
| - KNOT IDs validated against pattern `^K(0[1-9]|1[0-4])$` | ||
| - KNU IDs validated against pattern `^KNU-K(0[1-9]|1[0-4])-[A-Z0-9]{2,6}-\d{3}$` | ||
| - Numeric values constrained (effort ≥ 0, residue 0-100%) | ||
| - Required fields enforced by JSON Schema | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| ### Error: "No eligible KNU entries" | ||
| - Check that KNU entries have status `accepted` or `merged` | ||
| - Verify artifacts are provided | ||
| - Ensure entries are validated by an authorized reviewer | ||
|
|
||
| ### Error: "No pool configuration found" | ||
| - Check that the KNOT ID exists in `config/tokenomics/knu_distribution.yaml` | ||
| - Verify KNOT ID format (K01-K14) | ||
|
|
||
| ### Calculation discrepancies | ||
| - Verify input data is correct (E_pred, dR_primary, dR_adj_sum) | ||
| - Check that spillover values (dR_adj_sum) are pre-calculated correctly | ||
| - Ensure normalization is working (weights should sum to 1.0) | ||
|
|
||
| ## References | ||
|
|
||
| - **Problem Statement**: See issue requirements for full specification | ||
| - **KNOT Governance**: K01-K14 definitions with uncertainty focus | ||
| - **NKU Scoring**: `scripts/nku_scoring.py` for related uncertainty tracking | ||
| - **KNOT-AoR Mapping**: `scripts/knot_aor_mapping.py` for KNOT relationships | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation incorrectly states that the system "Imports
KNOT_AOR_MAPPINGfromscripts/knot_aor_mapping.py" and "Uses KNOT definitions to derive adjacency relationships". In reality, the adjacency graph is defined directly inconfig/tokenomics/knu_distribution.yamland the code does not import from knot_aor_mapping.py.Update the documentation to reflect that the adjacency graph is defined in the configuration file rather than derived from KNOT_AOR_MAPPING.