🗺 TRI-27 Token System — Complete Integration Roadmap
Epic: $TRI Token Rewrite for TRI-27 VM
📋 Context
Анализ показал: TRI-27 — чистая VM без интеграции с токенами. НЕОБХОДИМО добавить $TRI функциональность.
Current TRI-27 Status
Component
File
LOC
Tokens?
Coptic Alphabet
src/tri27/coptic.zig
138
❌
Trit27 Type
src/tri27/emu/tri_cpu.zig
216
❌
Executor
src/tri27/emu/executor.zig
500+
❌
Decoder
src/tri27/emu/decoder.zig
~300
❌
CLI
src/tri27/tri27_cli.zig
~600
❌
🌳 Technology Tree
Layer 0: TRI-27 CORE ✅ (1,754 LOC)
├── coptic.zig, tri_cpu.zig, executor.zig, decoder.zig, tri27_cli.zig
↓
Layer 1: TOKEN INTEGRATION ❌ (~1,000 LOC)
├── token_types.zig NEW — Token structures
├── token_ffi.zig NEW — Web3 contract calls
├── staking.zig NEW — TRI-27 staking
└── rewards.zig NEW — Reward calculation
↓
Layer 2: CLI EXTENSIONS ❌ (~1,200 LOC)
├── wallet_commands.zig NEW — Token subcommands
├── stake_commands.zig NEW — Staking commands
└── claim_commands.zig NEW — Reward claiming
↓
Layer 3: DEPIN ❌ (~500 LOC)
├── depin_adapter.zig NEW — DePIN protocol adapter
└── node_commands.zig NEW — Node management
↓
Layer 4: BLOCKCHAIN ❌ (~600 LOC)
├── tri27_token.sol NEW — Token contract
└── bridge.zig NEW — Cross-chain support
↓
Layer 5: GOVERNANCE ❌ (~800 LOC)
└── governance.zig NEW — DAO for TRI-27
📅 4 Sprints / 4 Weeks
Sprint
Week
Priority
Files
LOC
S1
1-2
P1
Token Integration Core
~1,000
S2
3-4
P2
CLI Extensions
~1,200
S3
5-6
P3
DePIN Integration
~500
S4
7-8
P4
Blockchain + Governance
~1,400
Total : ~4,100 LOC
Sprint 1: Week 1-2 — Token Integration Core
#436 : feat(tri27): Token Types for TRI-27
Files : src/tri27/token_types.zig (NEW, ~300 LOC)
Tasks :
Create spec/token_types.tri
Generate token_types.zig via tri gen
Define TokenAccount: balance, nonce, allowance
Define TokenStake: staker, amount, lock_time, unlock_time
Functions: transfer(), approve(), stake(), unstake(), claimRewards()
Map to Coptic registers: t18=balance, t19=pending, t20=staked
#437 : feat(tri27): Token FFI for TRI-27
Files : src/tri27/token_ffi.zig (NEW, ~400 LOC)
Tasks :
#438 : feat(tri27): TRI-27 Staking Module
Files : src/tri27/staking.zig (NEW, ~400 LOC)
Tasks :
#439 : feat(tri27): Reward Distribution System
Files : src/tri27/rewards.zig (NEW, ~300 LOC)
Tasks :
Sprint 2: Week 3-4 — CLI Extensions
#440 : feat(tri27): Token CLI Commands
Files : src/tri27/wallet_commands.zig (NEW, ~400 LOC)
Commands :
tri27 token balance — Show balance
tri27 token stake <amount> <days> — Stake tokens
tri27 token unstake — Unstake
tri27 token claim — Claim rewards
tri27 token approve <spender> <amount> — Approve spending
tri27 token send <to> <amount> — Transfer tokens
#441 : feat(tri27): Staking Commands
Files : src/tri27/stake_commands.zig (NEW, ~300 LOC)
Commands :
tri27 stake list — All stakers
tri27 stake info <address> — Stake info
tri27 stake rewards — Calculate APY
tri27 stake harvest — Harvest rewards
#442 : feat(tri27): Claim Commands
Files : src/tri27/claim_commands.zig (NEW, ~300 LOC)
Commands :
tri27 rewards list — Payment history
tri27 rewards claim <address> — Claim available
tri27 rewards pending — Pending rewards
Sprint 3: Week 5-6 — DePIN & Blockchain
#443 : feat(tri27): DePIN Adapter
Files : src/tri27/depin_adapter.zig (NEW, ~500 LOC)
Tasks :
#444 : feat(tri27): TRI-27 Token Contract
Files : contracts/tri27_token.sol (NEW, ~250 LOC)
Tasks :
Sprint 4: Week 7-8 — Governance & Bridge
#445 : feat(tri27): Cross-Chain Bridge
Files : src/tri27/bridge.zig (NEW, ~400 LOC)
Tasks :
#446 : feat(tri27): Governance for TRI-27
Files : src/tri27/governance.zig (NEW, ~400 LOC)
Tasks :
Create spec/governance.tri
Proposal: proposer, description, execute_after, votes_for/against
GovernanceEngine: propose(), vote(), execute(), quorumReached()
Commands: propose, vote, list, execute
Parameters: threshold=10K, voting=3d, delay=1d, quorum=50%
📊 Performance Benchmarks
Metric
Target
Proof
tri27 token balance
<100ms
Unit test
tri27 token stake
<200ms
Unit test
tri27 token claim
<500ms
Unit test
Gas for stake()
<100K
Estimate
Gas for unstake()
<80K
Estimate
Batch rewards
1000/tx
Stress test
⚠️ Agent Rules
НЕ писать .zig напрямую — только .tri → tri gen
Один источник правды — spec и код не дублируют
Каждый шаг = tri issue comment "⚙️ [TRI27] Step X/10"
При провале = tri issue comment "❌ [TRI27] Failed" → MNL loop
После спринта = закрывать sub-issues, комментировать в epic
MNL rule : 3x failed → stop + escalate к feat(agent-loop): tri dev loop — full 10-step autonomous cycle with experience/ source of truth #420
🔗 Related Issues
📦 Summary
Total : ~4,100 LOC новых файлов
Critical Path : Token Integration → CLI → DePIN → Blockchain
Goal : Полностью функциональная TRI-27 с $TRI токенами
φ² + 1/φ² = 3 | TRINITY
🗺 TRI-27 Token System — Complete Integration Roadmap
Epic: $TRI Token Rewrite for TRI-27 VM
📋 Context
Анализ показал: TRI-27 — чистая VM без интеграции с токенами. НЕОБХОДИМО добавить $TRI функциональность.
Current TRI-27 Status
src/tri27/coptic.zigsrc/tri27/emu/tri_cpu.zigsrc/tri27/emu/executor.zigsrc/tri27/emu/decoder.zigsrc/tri27/tri27_cli.zig🌳 Technology Tree
📅 4 Sprints / 4 Weeks
Total: ~4,100 LOC
Sprint 1: Week 1-2 — Token Integration Core
#436:
feat(tri27): Token Types for TRI-27Files:
src/tri27/token_types.zig(NEW, ~300 LOC)Tasks:
spec/token_types.tritoken_types.zigviatri gen#437:
feat(tri27): Token FFI for TRI-27Files:
src/tri27/token_ffi.zig(NEW, ~400 LOC)Tasks:
spec/token_ffi.tritoken_ffi.zigviatri gen#438:
feat(tri27): TRI-27 Staking ModuleFiles:
src/tri27/staking.zig(NEW, ~400 LOC)Tasks:
spec/staking.tristaking.zigviatri gen#439:
feat(tri27): Reward Distribution SystemFiles:
src/tri27/rewards.zig(NEW, ~300 LOC)Tasks:
spec/rewards.trirewards.zigviatri genSprint 2: Week 3-4 — CLI Extensions
#440:
feat(tri27): Token CLI CommandsFiles:
src/tri27/wallet_commands.zig(NEW, ~400 LOC)Commands:
tri27 token balance— Show balancetri27 token stake <amount> <days>— Stake tokenstri27 token unstake— Unstaketri27 token claim— Claim rewardstri27 token approve <spender> <amount>— Approve spendingtri27 token send <to> <amount>— Transfer tokens#441:
feat(tri27): Staking CommandsFiles:
src/tri27/stake_commands.zig(NEW, ~300 LOC)Commands:
tri27 stake list— All stakerstri27 stake info <address>— Stake infotri27 stake rewards— Calculate APYtri27 stake harvest— Harvest rewards#442:
feat(tri27): Claim CommandsFiles:
src/tri27/claim_commands.zig(NEW, ~300 LOC)Commands:
tri27 rewards list— Payment historytri27 rewards claim <address>— Claim availabletri27 rewards pending— Pending rewardsSprint 3: Week 5-6 — DePIN & Blockchain
#443:
feat(tri27): DePIN AdapterFiles:
src/tri27/depin_adapter.zig(NEW, ~500 LOC)Tasks:
spec/depin_adapter.tri#444:
feat(tri27): TRI-27 Token ContractFiles:
contracts/tri27_token.sol(NEW, ~250 LOC)Tasks:
Sprint 4: Week 7-8 — Governance & Bridge
#445:
feat(tri27): Cross-Chain BridgeFiles:
src/tri27/bridge.zig(NEW, ~400 LOC)Tasks:
spec/bridge.tri#446:
feat(tri27): Governance for TRI-27Files:
src/tri27/governance.zig(NEW, ~400 LOC)Tasks:
spec/governance.tri📊 Performance Benchmarks
tri27 token balancetri27 token staketri27 token claim.tri → tri gentri issue comment "⚙️ [TRI27] Step X/10"tri issue comment "❌ [TRI27] Failed"→ MNL loop🔗 Related Issues
tri devloop (MNL pattern)📦 Summary
Total: ~4,100 LOC новых файлов
Critical Path: Token Integration → CLI → DePIN → Blockchain
Goal: Полностью функциональная TRI-27 с $TRI токенами
φ² + 1/φ² = 3 | TRINITY