Three-layer breakdown of the reference network.
This document explains how Tenseuron is structured, what can be swapped, and what's core.
┌─────────────────────────────────────────────────────────────┐
│ Layer 3: Marketplace │
│ (Creator Economics, Payments) │
├─────────────────────────────────────────────────────────────┤
│ Layer 2: Network Policy │
│ (Reputation, Risk, Collusion, Graduation) │
├─────────────────────────────────────────────────────────────┤
│ Layer 1: TDCP Protocol │
│ (Tasks, Agents, Evaluation) │
└─────────────────────────────────────────────────────────────┘
What it is: The minimum required for coordination
Components:
- Task schema and lifecycle
- Agent identity (Miners, Validators, Creators)
- Claim/execute/submit flow
- Evaluation result format
- Reward signal structure
Files:
/specs/Task.md
/specs/Agent.md
/specs/Evaluation.md
/interfaces/ITaskRepository.ts
/interfaces/INetworkRepository.ts
/interfaces/IValidatorRepository.ts
/types.ts
Can be swapped: No - this is the protocol Can be extended: Yes - add new task types, agent roles
What it is: How the reference network behaves under adversarial conditions
Purpose: Track agent performance over time
Files:
interfaces/ICreatorReputationService.ts- Implementations in launchpad or custom adapters
Policy choices:
- Reputation decay: Exponential
- Minimum reputation for privileges: Configurable
- Reputation recovery: Possible through good behavior
Can be swapped: Yes - implement different reputation logic Can be removed: Yes - for trusted environments
Purpose: Evaluate network and agent risk
Files:
RiskScoringService.ts
Policy choices:
- Risk factors: Creator history, network parameters, task complexity
- Risk thresholds: Configurable
- Risk decay: Exponential over successful tasks
Can be swapped: Yes - implement custom risk models Can be removed: Yes - if risk is managed externally
Purpose: Identify coordinated gaming attempts
Files:
CollusionTrackingService.tsCollusionPreventionService.ts
Policy choices:
- Detection signals: Timing patterns, validator relationships
- Strike system: 3 strikes default
- Penalties: Reputation loss, temporary bans
Can be swapped: Yes - different detection algorithms Can be removed: Yes - for trusted networks
Purpose: Prevent identity manipulation
Files:
SybilResistanceService.ts
Policy choices:
- Requirements: Stake + reputation
- Verification: Multi-factor
- Penalties: Stake slashing
Can be swapped: Yes - different verification methods Can be removed: Yes - if identities are verified externally
Purpose: Manage network lifecycle and privileges
Files:
GraduationService.tsBootstrapModeService.ts
Policy choices:
- Bootstrap mode: First 100 tasks
- Graduation threshold: 1000 successful tasks
- Privileges: Increased task limits, lower fees
Can be swapped: Yes - different lifecycle rules Can be removed: Yes - all networks can have full privileges
What it is: Full economic and operational layer
Purpose: Manage creator revenue and incentives
Files:
MoneyFlowService.tsCreatorRevenueService.ts
Policy choices:
- Revenue split: 70/30 (creator/protocol)
- Bond requirements: Risk-adjusted
- Refund policy: After graduation
Can be swapped: Yes - different economic models Can be removed: No - economics are core to coordination
Purpose: Execute payments and rewards
Files:
SettlementService.ts
Policy choices:
- Validator rewards: Performance-based
- Payment timing: After evaluation consensus
- Currency: Native blockchain tokens
Can be swapped: Yes - different payment logic Can be removed: No - payments are required
Purpose: Protect participants from fraudulent networks
Files:
ScamDefenseService.ts
Policy choices:
- Detection signals: Multiple factors
- Response: Automatic flagging, manual review
- Recovery: Refunds for scam victims
Can be swapped: Yes - different detection methods Can be removed: Yes - if scams are managed externally
Purpose: Work with any database
Interfaces:
INetworkRepositoryITaskRepositoryIValidatorRepository
Implementations:
PrismaNetworkRepository(PostgreSQL, MySQL, SQLite)D1NetworkRepository(Cloudflare D1)- Custom implementations
How to swap:
// Use Prisma
const networkRepo = new PrismaNetworkRepository(prisma, logger);
// Use D1
const networkRepo = new D1NetworkRepository(d1Database);
// Use custom
const networkRepo = new CustomDatabaseRepository(yourDb);Purpose: Work with any blockchain
Interface:
IBlockchainProvider
Implementations:
EthereumProvider(Ethereum, Polygon)SolanaHTTPProvider(Solana)- Custom implementations
How to swap:
// Use Ethereum
const blockchain = new EthereumProvider(rpcUrl, privateKey);
// Use Solana
const blockchain = new SolanaHTTPProvider(rpcUrl, privateKey);
// Use custom
const blockchain = new CustomBlockchainProvider(config);Purpose: Work with any storage backend
Interface:
IStorageProvider
Implementations:
IPFSStorageProviderCloudflareR2StorageProviderS3StorageProvider- Custom implementations
How to swap:
// Use IPFS
const storage = new IPFSStorageProvider();
// Use R2
const storage = new CloudflareR2StorageProvider(r2Bucket);
// Use custom
const storage = new CustomStorageProvider(config);graph TD
A[ProtocolServiceRefactored] --> B[Layer 1: TDCP]
A --> C[Layer 2: Policy]
A --> D[Layer 3: Economics]
B --> E[ITaskRepository]
B --> F[INetworkRepository]
B --> G[IValidatorRepository]
C --> H[RiskScoringService]
C --> I[CollusionTracking]
C --> J[SybilResistance]
C --> K[GraduationService]
D --> L[MoneyFlowService]
D --> M[SettlementService]
D --> N[CreatorRevenueService]
E --> O[Database Adapter]
F --> O
G --> O
A --> P[IBlockchainProvider]
A --> Q[IStorageProvider]
P --> R[Blockchain Adapter]
Q --> S[Storage Adapter]
✅ Database (Prisma → D1 → MongoDB) ✅ Blockchain (Ethereum → Solana → Custom) ✅ Storage (IPFS → R2 → S3)
❌ TDCP protocol structure ❌ Task lifecycle ❌ Agent roles ❌ Evaluation format
Separation of concerns:
- Layer 1: What coordination requires (minimal)
- Layer 2: How to behave safely (opinionated)
- Layer 3: How to sustain economically (complete)
Enables:
- Minimal forks (Layer 1 only)
- Policy forks (Layer 1 + custom Layer 2)
- Full forks (all three layers customized)
Flexibility:
- Run anywhere (Node.js, Workers, Deno)
- Use any database
- Support any blockchain
Testability:
- Mock adapters for testing
- Swap implementations easily
Future-proofing:
- New databases: just add adapter
- New blockchains: just add adapter
Modularity:
- Services don't know about concrete implementations
- Easy to swap components
Testability:
- Inject mocks for testing
- Test services in isolation
Flexibility:
- Different configurations for different environments
- Runtime-specific optimizations
const protocol = ProtocolServiceFactory.createForNode(logger, prisma);Uses:
- Prisma for database
- IPFS for storage
- Ethereum/Polygon for blockchain
const protocol = ProtocolServiceFactory.createForWorkers(logger, env);Uses:
- D1 for database
- R2 for storage
- HTTP providers for blockchain
const protocol = ProtocolServiceFactory.create(logger, {
database: { type: 'custom', instance: yourDb },
storage: { type: 'custom', config: yourStorage },
blockchain: { type: 'custom', config: yourBlockchain }
});Choice: Completeness Rationale: Better to have and not need than need and not have Cost: Higher learning curve Benefit: Production-ready from day one
Choice: Opinions Rationale: Defaults shape behavior; be explicit Cost: Not one-size-fits-all Benefit: Clear design intent, easier to fork
Choice: Adapters Rationale: Flexibility and testability Cost: Extra abstraction layer Benefit: Works anywhere, easy to swap
- Implement the interface:
export class MyDatabaseAdapter implements INetworkRepository {
// Implement all methods
}- Register with factory (optional):
// In ProtocolFactory.ts
if (config.database.type === 'mydb') {
return new MyDatabaseAdapter(config.database.instance);
}- Test:
const adapter = new MyDatabaseAdapter(db);
const network = await adapter.create(params);
expect(network.id).toBeDefined();- Create the service:
export class MyPolicyService {
constructor(private logger: ILogger) {}
async evaluatePolicy(params: any): Promise<boolean> {
// Your logic
}
}- Add to dependencies:
export interface ProtocolServiceDependencies {
// ... existing
myPolicyService: MyPolicyService;
}- Use in ProtocolService:
const allowed = await this.myPolicyService.evaluatePolicy(params);Keep: TDCP core, adapters Remove: All Layer 2 and 3 services Result: ~30% of codebase
Keep: TDCP core, adapters, Layer 3 Replace: Risk, collusion, reputation logic Result: ~70% of codebase + your policies
Keep: Adapter architecture Replace: Everything else Result: Framework only, all logic custom
This architecture is designed for forkability, not rigidity.
Swap what you need. Keep what works.
See FORK_GUIDE.md for how.