Skip to content

Commit f771ab8

Browse files
committed
feat(vibee-v10): Cycle 46 — TRI Economy System specs (4 .vibee)
- tri_economy_core.vibee: Wallet, Reward, Transaction, EconomyState - reward_distribution.vibee: Contribution, DistributionConfig, DistributionRound - peer_ranking.vibee: PeerStats, RankTier, Leaderboard - economy_dashboard.vibee: EconomyMetrics, DashboardUpdate integration VIBEE-first workflow: specs → generated code (24 tests, 4 modules)
1 parent 7e3f8fa commit f771ab8

4 files changed

Lines changed: 266 additions & 0 deletions

File tree

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# TRI Economy Dashboard (MGEN-010)
2+
# Swarm Watch integration for economy metrics and rewards
3+
4+
name: economy_dashboard
5+
version: "1.0.0"
6+
language: zig
7+
module: economy_dashboard
8+
9+
types:
10+
EconomyMetrics:
11+
fields:
12+
my_wallet_balance: Int
13+
pending_rewards: Int
14+
current_rank: Int
15+
total_peers: Int
16+
reward_rate_per_hour: Float
17+
next_payout_time: Int
18+
19+
PeerEconomyInfo:
20+
fields:
21+
peer_id: String
22+
tier: String
23+
score: Float
24+
triples_stored: Int
25+
rewards_earned: Int
26+
27+
DashboardUpdate:
28+
fields:
29+
metrics: EconomyMetrics
30+
leaderboard: List<PeerEconomyInfo>
31+
recent_transactions: List<String>
32+
timestamp: Int
33+
34+
AlertThreshold:
35+
fields:
36+
min_balance: Int
37+
max_unclaimed_hours: Int
38+
min_rank: Int
39+
40+
behaviors:
41+
- name: get_metrics
42+
given: wallet address
43+
when: requesting dashboard data
44+
then: returns EconomyMetrics with current state
45+
46+
- name: format_dashboard_update
47+
given: metrics and leaderboard
48+
when: preparing for Swarm Watch display
49+
then: returns formatted DashboardUpdate
50+
51+
- name: check_alerts
52+
given: metrics and thresholds
53+
when: checking if alert needed
54+
then: returns alert list if thresholds exceeded
55+
56+
- name: get_earnings_projection
57+
given: current stats
58+
when: projecting future earnings
59+
then: returns estimated rewards for 24h/7d/30d
60+
61+
- name: notify_balance_change
62+
given: wallet and amount
63+
when: balance changes significantly
64+
then: triggers Telegram notification if enabled
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# TRI Peer Ranking (MGEN-009)
2+
# Rank peers by reputation, contribution, and reliability
3+
4+
name: peer_ranking
5+
version: "1.0.0"
6+
language: zig
7+
module: peer_ranking
8+
9+
types:
10+
PeerStats:
11+
fields:
12+
peer_id: String
13+
reputation_score: Float
14+
total_contribution: Int
15+
success_rate: Float
16+
avg_response_time_ms: Int
17+
last_seen: Int
18+
uptime_ratio: Float
19+
20+
RankTier:
21+
fields:
22+
tier_name: String
23+
min_score: Float
24+
max_score: Float
25+
reward_multiplier: Float
26+
27+
Ranking:
28+
fields:
29+
peer_id: String
30+
rank: Int
31+
tier: String
32+
score: Float
33+
change: Int
34+
35+
Leaderboard:
36+
fields:
37+
rankings: List<Ranking>
38+
last_updated: Int
39+
total_peers: Int
40+
41+
behaviors:
42+
- name: calculate_score
43+
given: peer stats
44+
when: calculating reputation score
45+
then: returns weighted score based on all factors
46+
47+
- name: update_ranking
48+
given: peer_id and new stats
49+
when: peer contributes to network
50+
then: recalculates rank and tier
51+
52+
- name: get_tier
53+
given: reputation score
54+
when: determining reward tier
55+
then: returns tier with multiplier
56+
57+
- name: get_leaderboard
58+
given: top N limit
59+
when: requesting leaderboard
60+
then: returns sorted rankings
61+
62+
- name: is_peer_reliable
63+
given: peer_id
64+
when: checking if peer meets reliability threshold
65+
then: returns true if success_rate > 95% and uptime_ratio > 0.9
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# TRI Reward Distribution (MGEN-008)
2+
# Distribute rewards to peers based on contribution
3+
4+
name: reward_distribution
5+
version: "1.0.0"
6+
language: zig
7+
module: reward_distribution
8+
9+
types:
10+
Contribution:
11+
fields:
12+
peer_id: String
13+
triples_stored: Int
14+
triples_retrieved: Int
15+
uptime_seconds: Int
16+
storage_bytes: Int
17+
network_bytes: Int
18+
19+
DistributionConfig:
20+
fields:
21+
reward_per_triple: Int
22+
reward_per_retrieval: Int
23+
reward_per_uptime_hour: Int
24+
reward_per_storage_mb: Int
25+
reward_pool: Int
26+
27+
DistributionResult:
28+
fields:
29+
peer_id: String
30+
reward_amount: Int
31+
contribution_score: Float
32+
rank: Int
33+
34+
DistributionRound:
35+
fields:
36+
round_id: Int
37+
start_time: Int
38+
end_time: Int
39+
total_rewards: Int
40+
num_peers: Int
41+
results: List<DistributionResult>
42+
43+
behaviors:
44+
- name: calculate_reward
45+
given: peer contribution and config
46+
when: calculating reward for round
47+
then: returns reward amount based on contribution
48+
49+
- name: distribute_round
50+
given: list of contributions and reward pool
51+
when: running distribution round
52+
then: returns DistributionRound with results
53+
54+
- name: get_leaderboard
55+
given: distribution round
56+
when: getting top peers
57+
then: returns sorted list by reward amount
58+
59+
- name: verify_contribution
60+
given: peer contribution claim
61+
when: verifying triple storage
62+
then: returns true if contribution is valid
63+
64+
- name: claim_reward
65+
given: peer_id and round_id
66+
when: peer claims reward
67+
then: transfers reward to wallet or returns error
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# TRI Economy Core (MGEN-007)
2+
# Core economy types: balances, rewards, transactions
3+
4+
name: tri_economy_core
5+
version: "1.0.0"
6+
language: zig
7+
module: tri_economy
8+
9+
types:
10+
Wallet:
11+
fields:
12+
address: String
13+
balance_wei: Int
14+
pending_rewards: Int
15+
total_earned: Int
16+
stake_amount: Int
17+
18+
Reward:
19+
fields:
20+
amount: Int
21+
reason: String
22+
timestamp: Int
23+
from_peer: Option<String>
24+
block_height: Int
25+
26+
Transaction:
27+
fields:
28+
tx_id: String
29+
from: String
30+
to: String
31+
amount: Int
32+
fee: Int
33+
timestamp: Int
34+
status: String
35+
block_height: Option<Int>
36+
37+
EconomyState:
38+
fields:
39+
total_supply: Int
40+
circulating_supply: Int
41+
staked_amount: Int
42+
active_peers: Int
43+
block_height: Int
44+
avg_triples_per_block: Float
45+
46+
behaviors:
47+
- name: create_wallet
48+
given: valid address
49+
when: creating new wallet
50+
then: returns Wallet with zero balance
51+
52+
- name: add_reward
53+
given: wallet and reward amount
54+
when: adding reward for work
55+
then: updates pending_rewards
56+
57+
- name: claim_rewards
58+
given: wallet with pending rewards
59+
when: claiming rewards
60+
then: transfers pending to balance
61+
62+
- name: get_balance
63+
given: wallet address
64+
when: querying balance
65+
then: returns current balance in wei
66+
67+
- name: transfer
68+
given: sender, recipient, amount
69+
when: transferring TRI
70+
then: creates transaction or error if insufficient funds

0 commit comments

Comments
 (0)