Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Attribution ¶
type Attribution struct {
Component string `json:"component"` // Package name (e.g., "@hanzo/ui")
Repo string `json:"repo"` // GitHub repo (e.g., "hanzoai/ui")
Lines int64 `json:"lines"` // Lines of code authored
TotalLines int64 `json:"totalLines"` // Total lines in component
Percent float64 `json:"percent"` // Percentage of component authored
}
Attribution represents a contributor's share in a specific software component.
type Contributor ¶
type Contributor struct {
mixin.Model[Contributor]
// Identity
UserId string `json:"userId,omitempty"` // Hanzo user ID (if registered)
GitLogin string `json:"gitLogin"` // GitHub/GitLab login
GitEmail string `json:"gitEmail"` // Git commit email
Name string `json:"name"` // Display name
AvatarURL string `json:"avatarUrl,omitempty"` // Avatar URL
// Organization (optional: attribute to org instead of individual)
OrgId string `json:"orgId,omitempty"`
OrgName string `json:"orgName,omitempty"`
// Payout config
PayoutMethod string `json:"payoutMethod"` // "stripe", "crypto", "credits"
PayoutTarget string `json:"payoutTarget"` // Stripe account ID, wallet address, or user ID
Currency currency.Type `json:"currency" orm:"default:usd"`
// Stats (computed periodically by cron)
TotalLinesAuthored int64 `json:"totalLinesAuthored"`
TotalEarned currency.Cents `json:"totalEarned"`
TotalPending currency.Cents `json:"totalPending"`
// Status
Verified bool `json:"verified"` // Email/identity verified
Active bool `json:"active"` // Actively receiving payouts
JoinedAt time.Time `json:"joinedAt"`
LastPaid time.Time `json:"lastPaid,omitempty"`
// SBOM attribution: JSON array of component attributions
// [{"component":"@hanzo/ui","repo":"hanzoai/ui","lines":1234,"percent":5.2}]
Attributions []Attribution `json:"attributions,omitempty" datastore:"-"`
Attributions_ string `json:"-" datastore:",noindex"`
Metadata Map `json:"metadata,omitempty" datastore:"-"`
Metadata_ string `json:"-" datastore:",noindex"`
}
Contributor tracks an OSS contributor eligible for revenue share payouts. Contributors are identified by their git identity (email/login) and matched to SBOM line attribution for each software component used by bots, agents, and platform services.
func New ¶
func New(db *datastore.Datastore) *Contributor
func (*Contributor) Validator ¶
func (c *Contributor) Validator() *val.Validator
type PayoutAllocation ¶
type PayoutAllocation struct {
ContributorId string `json:"contributorId"`
GitLogin string `json:"gitLogin"`
Component string `json:"component"`
Lines int64 `json:"lines"`
Percent float64 `json:"percent"`
AmountCents int64 `json:"amountCents"`
}
PayoutAllocation represents a single contributor's share of a revenue pool.
type PayoutConfig ¶
type PayoutConfig struct {
// PlatformPercent is the platform's share before contributor distribution.
// Default: 80% platform, 20% to contributors.
PlatformPercent float64
// MinPayoutCents is the minimum payout threshold per contributor.
// Below this, credits accumulate until threshold is reached.
MinPayoutCents int64
// ComponentWeights allows weighting certain components higher.
// Key is component name, value is multiplier (1.0 = normal).
// Core infrastructure might be weighted 2x, UI components 1x, etc.
ComponentWeights map[string]float64
}
PayoutConfig controls the revenue sharing algorithm.
func DefaultConfig ¶
func DefaultConfig() PayoutConfig
DefaultConfig returns the default payout configuration. 80/20 split: 80% to platform, 20% to OSS contributors.
type PayoutSummary ¶
type PayoutSummary struct {
TotalRevenue int64 `json:"totalRevenue"` // Total revenue to distribute (cents)
ContributorPool int64 `json:"contributorPool"` // Pool for contributors (cents)
Allocations []PayoutAllocation `json:"allocations"`
}
PayoutSummary is the result of running the payout algorithm.
func CalculatePayouts ¶
func CalculatePayouts( totalRevenueCents int64, contributors []Contributor, componentRevenue map[string]int64, config PayoutConfig, ) PayoutSummary
CalculatePayouts runs the OSS contributor revenue sharing algorithm.
Algorithm:
- Take total revenue for the period
- Deduct platform share (default 80%)
- Remaining 20% is the contributor pool
- For each software component used in the billing period: a. Weight the component's revenue contribution b. For each contributor to that component: - Calculate their line attribution percentage - Multiply by component's weighted revenue share
- Aggregate per-contributor across all components
- Apply minimum payout threshold
- Return sorted allocations (highest first)
type SBOMAuthor ¶
type SBOMAuthor struct {
Login string `json:"login"`
Email string `json:"email"`
Name string `json:"name,omitempty"`
Lines int64 `json:"lines"`
Percent float64 `json:"percent"` // Percentage of component authored
}
SBOMAuthor is a contributor entry from git blame analysis.
type SBOMEntry ¶
type SBOMEntry struct {
mixin.Model[SBOMEntry]
// Component identity
Component string `json:"component"` // Package name (e.g., "@hanzo/bot")
Repo string `json:"repo"` // GitHub repo (e.g., "hanzoai/bot")
Version string `json:"version"` // Current version
License string `json:"license"` // License type (MIT, Apache-2.0, etc.)
TotalLines int64 `json:"totalLines"` // Total lines of code
// Contributor breakdown from git blame
// [{"login":"user","email":"u@e.com","lines":500,"percent":12.5}]
Authors []SBOMAuthor `json:"authors,omitempty" datastore:"-"`
Authors_ string `json:"-" datastore:",noindex"`
// Revenue attribution
UsageCount int64 `json:"usageCount"` // Times used in billing period
RevenuePercent float64 `json:"revenuePercent"` // % of total platform revenue attributed
// Scan metadata
LastScanned time.Time `json:"lastScanned"`
ScanCommit string `json:"scanCommit"` // Git commit hash of last scan
Metadata Map `json:"metadata,omitempty" datastore:"-"`
Metadata_ string `json:"-" datastore:",noindex"`
}
SBOMEntry represents a software component in the platform's bill of materials. Each entry tracks the component's identity, its contributors, and the revenue attributed to it based on bot/agent usage.