Documentation
¶
Overview ¶
Package githubprworkflow provides Graphable entity types for the GitHub issue-to-PR automation workflow.
These entities model GitHub artifacts (issues, pull requests, reviews) as first-class graph nodes, enabling the knowledge graph to reason about repository activity and code change history.
Package githubprworkflow demonstrates a reactive workflow that automates the path from a GitHub issue to a merged pull request. Three adversarial agents — qualifier, developer, and reviewer — iterate against each other until the PR is approved or the review cycle limit is reached.
Index ¶
- Constants
- func NewIssueToPRWorkflow() *reactive.Definition
- func PhaseIsActive(phase string) bool
- type GitHubIssueEntity
- func (e *GitHubIssueEntity) EntityID() string
- func (e *GitHubIssueEntity) MarshalJSON() ([]byte, error)
- func (e *GitHubIssueEntity) Schema() message.Type
- func (e *GitHubIssueEntity) Triples() []message.Triple
- func (e *GitHubIssueEntity) UnmarshalJSON(data []byte) error
- func (e *GitHubIssueEntity) Validate() error
- type GitHubIssueWebhookEvent
- type GitHubPREntity
- type GitHubReviewEntity
- func (e *GitHubReviewEntity) EntityID() string
- func (e *GitHubReviewEntity) MarshalJSON() ([]byte, error)
- func (e *GitHubReviewEntity) Schema() message.Type
- func (e *GitHubReviewEntity) Triples() []message.Triple
- func (e *GitHubReviewEntity) UnmarshalJSON(data []byte) error
- func (e *GitHubReviewEntity) Validate() error
- type IssueDetail
- type IssueToPRState
- type OwnerDetail
- type RepoDetail
- type WorkflowCompletionPayload
Constants ¶
const ( // StateBucket is the NATS KV bucket that stores workflow execution state. StateBucket = "GITHUB_ISSUE_PR_STATE" // MaxReviewCycles is the maximum number of reviewer rejection/retry loops // before the workflow escalates to human intervention. MaxReviewCycles = 3 // WorkflowTimeout is the maximum wall-clock duration for any single // execution before the engine marks it as timed out. WorkflowTimeout = 30 * time.Minute // DefaultTokenBudget is the maximum tokens (in+out) per workflow execution. // ~$5 at GPT-4o pricing — enough for qualify + develop + review. DefaultTokenBudget = 500_000 // DefaultMaxConcurrentWorkflows limits parallel active workflows. DefaultMaxConcurrentWorkflows = 3 // DefaultHourlyTokenCeiling is the global hourly token limit across all workflows. // ~$20/hour hard ceiling. DefaultHourlyTokenCeiling = 2_000_000 // DefaultIssueCooldown is the minimum time between processing new issues. DefaultIssueCooldown = 60 * time.Second )
const ( PhaseQualified = "qualified" PhaseRejected = "rejected" PhaseNotABug = "not_a_bug" PhaseWontFix = "wont_fix" PhaseNeedsInfo = "needs_info" PhaseAwaitingInfo = "awaiting_info" PhaseDevComplete = "dev_complete" PhaseDeveloping = "developing" PhaseApproved = "approved" PhaseChangesRequested = "changes_requested" PhaseEscalated = "escalated" )
Phase constants represent the distinct states an issue-to-PR execution can occupy. They are written into IssueToPRState.Phase and drive all KV-triggered rule conditions.
Variables ¶
This section is empty.
Functions ¶
func NewIssueToPRWorkflow ¶
func NewIssueToPRWorkflow() *reactive.Definition
NewIssueToPRWorkflow builds the reactive workflow definition for the adversarial issue qualification, development, and review pipeline.
func PhaseIsActive ¶
PhaseIsActive returns true if the phase indicates an active workflow.
Types ¶
type GitHubIssueEntity ¶
type GitHubIssueEntity struct {
// Org is the GitHub organization or user that owns the repository.
Org string `json:"org"`
// Repo is the repository name within the organization.
Repo string `json:"repo"`
// Number is the issue number within the repository.
Number int `json:"number"`
// Title is the issue title.
Title string `json:"title"`
// Body is the issue body text.
Body string `json:"body"`
// Labels contains any labels applied to the issue.
Labels []string `json:"labels,omitempty"`
// State is the current issue state (open, closed).
State string `json:"state"`
// Author is the GitHub username of the issue author.
Author string `json:"author"`
// Severity is an optional triage severity classification (e.g., critical, high, medium, low).
Severity string `json:"severity,omitempty"`
// Complexity is an optional effort estimation (e.g., small, medium, large).
Complexity string `json:"complexity,omitempty"`
}
GitHubIssueEntity represents a GitHub issue as a graph node. It implements the Graphable interface to expose issue facts as semantic triples.
func (*GitHubIssueEntity) EntityID ¶
func (e *GitHubIssueEntity) EntityID() string
EntityID returns the 6-part federated identifier for this issue. Format: {org}.github.repo.{repo}.issue.{number}
func (*GitHubIssueEntity) MarshalJSON ¶
func (e *GitHubIssueEntity) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler using the alias pattern to avoid recursion.
func (*GitHubIssueEntity) Schema ¶
func (e *GitHubIssueEntity) Schema() message.Type
Schema returns the message type for GitHubIssueEntity payloads.
func (*GitHubIssueEntity) Triples ¶
func (e *GitHubIssueEntity) Triples() []message.Triple
Triples returns semantic facts about this GitHub issue. Core facts (title, state, author) are always included; optional fields (severity, complexity, labels) are only included when set.
func (*GitHubIssueEntity) UnmarshalJSON ¶
func (e *GitHubIssueEntity) UnmarshalJSON(data []byte) error
UnmarshalJSON implements json.Unmarshaler using the alias pattern to avoid recursion.
func (*GitHubIssueEntity) Validate ¶
func (e *GitHubIssueEntity) Validate() error
Validate checks that the issue entity has all required fields.
type GitHubIssueWebhookEvent ¶
type GitHubIssueWebhookEvent struct {
Action string `json:"action"`
Issue IssueDetail `json:"issue"`
Repo RepoDetail `json:"repository"`
}
GitHubIssueWebhookEvent is a minimal representation of the GitHub webhook payload for issue events. Only the fields required by the workflow rules are modelled here; the full payload is not needed for routing.
type GitHubPREntity ¶
type GitHubPREntity struct {
// Org is the GitHub organization or user that owns the repository.
Org string `json:"org"`
// Repo is the repository name within the organization.
Repo string `json:"repo"`
// Number is the pull request number within the repository.
Number int `json:"number"`
// Title is the pull request title.
Title string `json:"title"`
// Body is the pull request description.
Body string `json:"body"`
// Head is the source branch name.
Head string `json:"head"`
// Base is the target branch name.
Base string `json:"base"`
// State is the current PR state (open, closed, merged).
State string `json:"state"`
// IssueNumber is the number of the issue this PR addresses.
IssueNumber int `json:"issue_number,omitempty"`
// FilesChanged lists the repository-relative paths of modified files.
FilesChanged []string `json:"files_changed,omitempty"`
}
GitHubPREntity represents a GitHub pull request as a graph node. It implements the Graphable interface and records the relationship to the issue it fixes as a triple linking the two entities by their IDs.
func (*GitHubPREntity) EntityID ¶
func (e *GitHubPREntity) EntityID() string
EntityID returns the 6-part federated identifier for this pull request. Format: {org}.github.repo.{repo}.pr.{number}
func (*GitHubPREntity) MarshalJSON ¶
func (e *GitHubPREntity) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler using the alias pattern to avoid recursion.
func (*GitHubPREntity) Schema ¶
func (e *GitHubPREntity) Schema() message.Type
Schema returns the message type for GitHubPREntity payloads.
func (*GitHubPREntity) Triples ¶
func (e *GitHubPREntity) Triples() []message.Triple
Triples returns semantic facts about this pull request. When IssueNumber is set, a "github.pr.fixes" triple is added that references the linked issue entity by its ID, enabling graph traversal from PR to issue.
func (*GitHubPREntity) UnmarshalJSON ¶
func (e *GitHubPREntity) UnmarshalJSON(data []byte) error
UnmarshalJSON implements json.Unmarshaler using the alias pattern to avoid recursion.
func (*GitHubPREntity) Validate ¶
func (e *GitHubPREntity) Validate() error
Validate checks that the pull request entity has all required fields.
type GitHubReviewEntity ¶
type GitHubReviewEntity struct {
// Org is the GitHub organization or user that owns the repository.
Org string `json:"org"`
// Repo is the repository name within the organization.
Repo string `json:"repo"`
// ID is a unique identifier for this review (e.g., UUID or sequential ID).
ID string `json:"id"`
// PRNumber is the pull request number that this review targets.
PRNumber int `json:"pr_number"`
// Verdict is the review outcome: approve, request_changes, or reject.
Verdict string `json:"verdict"`
// Issues is the count of issues found during review.
Issues int `json:"issues"`
// Agent is the role of the agent that performed this review (e.g., "reviewer").
Agent string `json:"agent"`
}
GitHubReviewEntity represents a code review conducted by an agent on a pull request. It implements the Graphable interface and records the relationship to the reviewed PR as a "github.review.targets" triple.
func (*GitHubReviewEntity) EntityID ¶
func (e *GitHubReviewEntity) EntityID() string
EntityID returns the 6-part federated identifier for this review. Format: {org}.github.repo.{repo}.review.{id}
func (*GitHubReviewEntity) MarshalJSON ¶
func (e *GitHubReviewEntity) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler using the alias pattern to avoid recursion.
func (*GitHubReviewEntity) Schema ¶
func (e *GitHubReviewEntity) Schema() message.Type
Schema returns the message type for GitHubReviewEntity payloads.
func (*GitHubReviewEntity) Triples ¶
func (e *GitHubReviewEntity) Triples() []message.Triple
Triples returns semantic facts about this review. A "github.review.targets" triple is always added when PRNumber is set, linking this review to its pull request entity by ID.
func (*GitHubReviewEntity) UnmarshalJSON ¶
func (e *GitHubReviewEntity) UnmarshalJSON(data []byte) error
UnmarshalJSON implements json.Unmarshaler using the alias pattern to avoid recursion.
func (*GitHubReviewEntity) Validate ¶
func (e *GitHubReviewEntity) Validate() error
Validate checks that the review entity has all required fields.
type IssueDetail ¶
type IssueDetail struct {
Number int `json:"number"`
Title string `json:"title"`
Body string `json:"body"`
}
IssueDetail carries the issue fields required to bootstrap an execution.
type IssueToPRState ¶
type IssueToPRState struct {
reactive.ExecutionState
// Issue context
IssueNumber int `json:"issue_number"`
IssueTitle string `json:"issue_title"`
IssueBody string `json:"issue_body"`
RepoOwner string `json:"repo_owner"`
RepoName string `json:"repo_name"`
// Qualifier output
QualifierVerdict string `json:"qualifier_verdict"`
QualifierConfidence float64 `json:"qualifier_confidence"`
Severity string `json:"severity"`
// Developer output
BranchName string `json:"branch_name"`
PRNumber int `json:"pr_number"`
PRUrl string `json:"pr_url"`
FilesChanged []string `json:"files_changed"`
// Reviewer output
ReviewVerdict string `json:"review_verdict"`
ReviewFeedback string `json:"review_feedback"`
// Adversarial tracking
ReviewRejections int `json:"review_rejections"`
DevelopmentAttempts int `json:"development_attempts"`
EscalatedToHuman bool `json:"escalated_to_human"`
// Cost tracking
TotalTokensIn int `json:"total_tokens_in"`
TotalTokensOut int `json:"total_tokens_out"`
}
IssueToPRState tracks the execution state of the issue-to-PR workflow. It embeds ExecutionState to participate in the reactive engine's KV watch and async callback mechanisms.
func (*IssueToPRState) GetExecutionState ¶
func (s *IssueToPRState) GetExecutionState() *reactive.ExecutionState
GetExecutionState implements reactive.StateAccessor to avoid reflection overhead.
type OwnerDetail ¶
type OwnerDetail struct {
Login string `json:"login"`
}
OwnerDetail carries the repository owner login.
type RepoDetail ¶
type RepoDetail struct {
Name string `json:"name"`
Owner OwnerDetail `json:"owner"`
}
RepoDetail carries the repository owner and name.
type WorkflowCompletionPayload ¶
type WorkflowCompletionPayload struct {
ExecutionID string `json:"execution_id"`
IssueNumber int `json:"issue_number"`
RepoOwner string `json:"repo_owner"`
RepoName string `json:"repo_name"`
PRNumber int `json:"pr_number"`
PRUrl string `json:"pr_url"`
FilesChanged []string `json:"files_changed"`
DevelopmentAttempts int `json:"development_attempts"`
ReviewRejections int `json:"review_rejections"`
TotalTokensIn int `json:"total_tokens_in"`
TotalTokensOut int `json:"total_tokens_out"`
}
WorkflowCompletionPayload summarises the outcome of a completed issue-to-PR execution for downstream consumers.
func (*WorkflowCompletionPayload) MarshalJSON ¶
func (p *WorkflowCompletionPayload) MarshalJSON() ([]byte, error)
MarshalJSON implements message.Payload.
func (*WorkflowCompletionPayload) Schema ¶
func (p *WorkflowCompletionPayload) Schema() message.Type
Schema implements message.Payload.
func (*WorkflowCompletionPayload) UnmarshalJSON ¶
func (p *WorkflowCompletionPayload) UnmarshalJSON(data []byte) error
UnmarshalJSON implements message.Payload.
func (*WorkflowCompletionPayload) Validate ¶
func (p *WorkflowCompletionPayload) Validate() error
Validate implements message.Payload.