Documentation
¶
Overview ¶
Package cost calculates the real-world cost of GitHub pull requests. Costs are broken down into detailed components with itemized inputs.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthorCostDetail ¶
type AuthorCostDetail struct {
CodeCost float64 // COCOMO-based cost for writing code
CodeContextCost float64 // Cost of context switching while writing code (Microsoft research)
GitHubCost float64 // Cost of GitHub interactions (commits, comments, etc.)
GitHubContextCost float64 // Cost of context switching for GitHub sessions
// Supporting details
LinesAdded int // Number of lines of code added
Events int // Number of author events
Sessions int // Number of GitHub work sessions
CodeHours float64 // Hours spent writing code (COCOMO)
CodeContextHours float64 // Hours spent context switching during coding
GitHubHours float64 // Hours spent on GitHub interactions
GitHubContextHours float64 // Hours spent context switching for GitHub
TotalHours float64 // Total hours (sum of above)
TotalCost float64 // Total author cost
}
AuthorCostDetail breaks down the author's costs.
type Breakdown ¶
type Breakdown struct {
// Participant costs (everyone except the author)
Participants []ParticipantCostDetail
// Author costs (person who opened the PR)
Author AuthorCostDetail
// Delay cost with itemized breakdown
DelayCostDetail DelayCostDetail
// Delay cost with itemized breakdown
DelayCost float64
// Supporting details for delay cost
DelayHours float64
HourlyRate float64
AnnualSalary float64
BenefitsMultiplier float64
// Total cost (sum of all components)
TotalCost float64
// True if project delay was capped (either by 2 weeks after last event or 90 days total)
DelayCapped bool
}
Breakdown shows fully itemized costs for a pull request.
type Config ¶
type Config struct {
// Annual salary used for calculating hourly rate (default: $250,000)
AnnualSalary float64
// Benefits multiplier applied to salary (default: 1.3 = 30% benefits)
BenefitsMultiplier float64
// Hours per year for calculating hourly rate (default: 2080)
HoursPerYear float64
// Time per GitHub event (default: 20 minutes)
EventDuration time.Duration
// Time for context switching in/out (default: 20 minutes)
ContextSwitchDuration time.Duration
// Session gap threshold (default: 60 minutes)
// Events within this gap are considered part of the same session
SessionGapThreshold time.Duration
// Delay cost factor as percentage of hourly rate (default: 0.20 = 20%)
// This represents the opportunity cost of having a PR open
DelayCostFactor float64
// Maximum time after last event to count for project delay (default: 14 days / 2 weeks)
// Only counts delay costs up to this many days after the last event on the PR
MaxDelayAfterLastEvent time.Duration
// Maximum total project delay duration (default: 90 days / 3 months)
// Absolute cap on project delay costs regardless of PR age
MaxProjectDelay time.Duration
// Maximum duration for code drift calculation (default: 90 days / 3 months)
// Code drift is capped at this duration (affects rework percentage)
MaxCodeDrift time.Duration
// COCOMO configuration for estimating code writing effort
COCOMO cocomo.Config
}
Config holds all tunable parameters for cost calculation.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns reasonable defaults for cost calculation.
type DelayCostDetail ¶
type DelayCostDetail struct {
ProjectDelayCost float64 // Opportunity cost of engineer time (20% factor)
CodeUpdatesCost float64 // COCOMO cost for rework/merge conflicts
FutureGitHubCost float64 // Cost for future GitHub activity (3 events with context)
// Supporting details
ProjectDelayHours float64 // Hours of project delay
CodeUpdatesHours float64 // Hours for code updates
FutureGitHubHours float64 // Hours for future GitHub activity
ReworkPercentage float64 // Percentage of code requiring rework (1%-30%)
TotalDelayCost float64 // Total delay cost (sum of above)
TotalDelayHours float64 // Total delay hours
}
DelayCostDetail holds itemized delay costs.
type PRData ¶
type PRData struct {
// When the PR was opened
CreatedAt time.Time
// When the PR was last updated
UpdatedAt time.Time
// PR author's username
Author string
// All human events (reviews, comments, commits, etc.) with timestamps
// Excludes bot events
Events []ParticipantEvent
// Lines of code added by the author
LinesAdded int
// Whether the author has write access (false means external contributor)
AuthorHasWriteAccess bool
}
PRData contains all information needed to calculate PR costs.
type ParticipantCostDetail ¶
type ParticipantCostDetail struct {
Actor string // Participant username
GitHubCost float64 // Cost of GitHub interactions
GitHubContextCost float64 // Cost of context switching for GitHub sessions
// Supporting details
Events int // Number of participant events
Sessions int // Number of GitHub work sessions
GitHubHours float64 // Hours spent on GitHub interactions
GitHubContextHours float64 // Hours spent context switching for GitHub
TotalHours float64 // Total hours (sum of above)
TotalCost float64 // Total participant cost
}
ParticipantCostDetail breaks down a participant's costs.
type ParticipantEvent ¶
ParticipantEvent represents a single event by a participant.
Click to show internal directories.
Click to hide internal directories.