{"modulePath":"github.com/c360studio/semstreams","version":"v1.0.0-beta.146","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package githubprworkflow\n\nPackage githubprworkflow provides Graphable entity types for the GitHub issue-to-PR automation workflow.\n\nThese 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.\n\nNote: GitHubIssueEntity, GitHubPREntity, and GitHubReviewEntity are published by the github-webhook input component when it ingests events from GitHub. The pr-workflow-spawner component in this package does not instantiate these entities directly — it writes workflow-phase triples via the graph mutation API instead.\n\n## Constants\n\n```go\nconst (\n\t// MaxReviewCycles is the maximum number of reviewer rejection/retry loops\n\t// before the workflow escalates to human intervention.\n\tMaxReviewCycles = 3\n\n\t// WorkflowTimeout is the maximum wall-clock duration for any single\n\t// execution before the engine marks it as timed out.\n\tWorkflowTimeout = 30 * time.Minute\n\n\t// DefaultTokenBudget is the maximum tokens (in+out) per workflow execution.\n\tDefaultTokenBudget = 500_000\n\n\t// DefaultMaxConcurrentWorkflows limits parallel active workflows.\n\tDefaultMaxConcurrentWorkflows = 3\n\n\t// DefaultHourlyTokenCeiling is the global hourly token limit across all workflows.\n\tDefaultHourlyTokenCeiling = 2_000_000\n\n\t// DefaultIssueCooldown is the minimum time between processing new issues.\n\tDefaultIssueCooldown = 60 * time.Second\n)\n```\nWorkflow constants.\n\n```go\nconst (\n\tPhaseQualified        = \"qualified\"\n\tPhaseRejected         = \"rejected\"\n\tPhaseNotABug          = \"not_a_bug\"\n\tPhaseWontFix          = \"wont_fix\"\n\tPhaseNeedsInfo        = \"needs_info\"\n\tPhaseAwaitingInfo     = \"awaiting_info\"\n\tPhaseDevComplete      = \"dev_complete\"\n\tPhaseDeveloping       = \"developing\"\n\tPhaseApproved         = \"approved\"\n\tPhaseChangesRequested = \"changes_requested\"\n\tPhaseEscalated        = \"escalated\"\n)\n```\nPhase constants represent the distinct states an issue-to-PR execution can occupy. They are written as workflow.phase triples and drive all rule conditions.\n\n```go\nconst (\n\t// WorkflowSlug identifies this workflow for correlation in TaskMessage/LoopCompletedEvent.\n\tWorkflowSlug = \"github-issue-to-pr\"\n)\n```\n\n## Functions\n\n```go\nfunc BuildDeveloperPrompt(org, repo string, issueNumber int, issueTitle, issueBody, qualifierVerdict string, qualifierConfidence float64, severity, reviewFeedback string) string\n```\nBuildDeveloperPrompt builds the prompt for the developer agent. If reviewFeedback is non-empty, it is included as previous review feedback.\n\n```go\nfunc BuildQualifierPrompt(org, repo string, issueNumber int, title, body string) string\n```\nBuildQualifierPrompt builds the prompt for the qualifier agent.\n\n```go\nfunc BuildReviewerPrompt(org, repo string, issueNumber int, issueTitle string, prNumber int, prURL string, filesChanged []string) string\n```\nBuildReviewerPrompt builds the prompt for the reviewer agent.\n\n```go\nfunc NewComponent(rawConfig json.RawMessage, deps component.Dependencies) (component.Discoverable, error)\n```\nNewComponent creates a new PRWorkflowComponent from config.\n\n```go\nfunc PhaseIsActive(phase string) bool\n```\nPhaseIsActive returns true if the phase indicates an active workflow.\n\n```go\nfunc Register(registry *component.Registry) error\n```\nRegister registers the PR workflow spawner component with the given registry.\n\n```go\nfunc RegisterPayloads(reg *payloadregistry.Registry) error\n```\nRegisterPayloads registers all GitHub PR workflow payload types with the supplied registry. Called by binaries that load this example workflow.\n\n```go\nfunc WorkflowEntityID(org, repo string, issueNumber int) string\n```\nWorkflowEntityID builds the 6-part entity ID for a workflow execution.\n\n## Types\n\n```go\ntype Config struct {\n\t// Model is the model endpoint name for agent tasks (default: \"default\")\n\tModel string `json:\"model,omitempty\"`\n\n\t// TokenBudget is the maximum tokens per workflow execution (default: 500000)\n\tTokenBudget int `json:\"token_budget,omitempty\"`\n\n\t// MaxReviewCycles is the maximum review rejection/retry loops (default: 3)\n\tMaxReviewCycles int `json:\"max_review_cycles,omitempty\"`\n\n\t// Ports defines the component's input and output ports\n\tPorts PortConfig `json:\"ports,omitempty\"`\n}\n```\nConfig holds configuration for the PR workflow spawner component.\n\n```go\ntype DeveloperOutput struct {\n\tBranchName   string   `json:\"branch_name\"`\n\tPRNumber     int      `json:\"pr_number\"`\n\tPRUrl        string   `json:\"pr_url\"`\n\tFilesChanged []string `json:\"files_changed\"`\n}\n```\nDeveloperOutput represents the parsed developer agent result.\n\n```go\nfunc ParseDeveloperResult(result string) DeveloperOutput\n```\nParseDeveloperResult parses the developer agent's JSON result.\n\n```go\ntype GitHubIssueEntity struct {\n\t// Org is the GitHub organization or user that owns the repository.\n\tOrg string `json:\"org\"`\n\t// Repo is the repository name within the organization.\n\tRepo string `json:\"repo\"`\n\t// Number is the issue number within the repository.\n\tNumber int `json:\"number\"`\n\t// Title is the issue title.\n\tTitle string `json:\"title\"`\n\t// Body is the issue body text.\n\tBody string `json:\"body\"`\n\t// Labels contains any labels applied to the issue.\n\tLabels []string `json:\"labels,omitempty\"`\n\t// State is the current issue state (open, closed).\n\tState string `json:\"state\"`\n\t// Author is the GitHub username of the issue author.\n\tAuthor string `json:\"author\"`\n\t// Severity is an optional triage severity classification (e.g., critical, high, medium, low).\n\tSeverity string `json:\"severity,omitempty\"`\n\t// Complexity is an optional effort estimation (e.g., small, medium, large).\n\tComplexity string `json:\"complexity,omitempty\"`\n}\n```\nGitHubIssueEntity represents a GitHub issue as a graph node. It implements the Graphable interface to expose issue facts as semantic triples.\n\n```go\nfunc (e *GitHubIssueEntity) EntityID() string\n```\nEntityID returns the 6-part federated identifier for this issue. Format: {org}.github.repo.{repo}.issue.{number}\n\n```go\nfunc (e *GitHubIssueEntity) MarshalJSON() ([]byte, error)\n```\nMarshalJSON implements json.Marshaler using the alias pattern to avoid recursion.\n\n```go\nfunc (e *GitHubIssueEntity) Schema() message.Type\n```\nSchema returns the message type for GitHubIssueEntity payloads.\n\n```go\nfunc (e *GitHubIssueEntity) Triples() []message.Triple\n```\nTriples 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.\n\n```go\nfunc (e *GitHubIssueEntity) UnmarshalJSON(data []byte) error\n```\nUnmarshalJSON implements json.Unmarshaler using the alias pattern to avoid recursion.\n\n```go\nfunc (e *GitHubIssueEntity) Validate() error\n```\nValidate checks that the issue entity has all required fields.\n\n```go\ntype GitHubIssueWebhookEvent struct {\n\tAction string      `json:\"action\"`\n\tIssue  IssueDetail `json:\"issue\"`\n\tRepo   RepoDetail  `json:\"repository\"`\n}\n```\nGitHubIssueWebhookEvent is a minimal representation of the GitHub webhook payload for issue events.\n\n```go\ntype GitHubPREntity struct {\n\t// Org is the GitHub organization or user that owns the repository.\n\tOrg string `json:\"org\"`\n\t// Repo is the repository name within the organization.\n\tRepo string `json:\"repo\"`\n\t// Number is the pull request number within the repository.\n\tNumber int `json:\"number\"`\n\t// Title is the pull request title.\n\tTitle string `json:\"title\"`\n\t// Body is the pull request description.\n\tBody string `json:\"body\"`\n\t// Head is the source branch name.\n\tHead string `json:\"head\"`\n\t// Base is the target branch name.\n\tBase string `json:\"base\"`\n\t// State is the current PR state (open, closed, merged).\n\tState string `json:\"state\"`\n\t// IssueNumber is the number of the issue this PR addresses.\n\tIssueNumber int `json:\"issue_number,omitempty\"`\n\t// FilesChanged lists the repository-relative paths of modified files.\n\tFilesChanged []string `json:\"files_changed,omitempty\"`\n}\n```\nGitHubPREntity 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.\n\n```go\nfunc (e *GitHubPREntity) EntityID() string\n```\nEntityID returns the 6-part federated identifier for this pull request. Format: {org}.github.repo.{repo}.pr.{number}\n\n```go\nfunc (e *GitHubPREntity) MarshalJSON() ([]byte, error)\n```\nMarshalJSON implements json.Marshaler using the alias pattern to avoid recursion.\n\n```go\nfunc (e *GitHubPREntity) Schema() message.Type\n```\nSchema returns the message type for GitHubPREntity payloads.\n\n```go\nfunc (e *GitHubPREntity) Triples() []message.Triple\n```\nTriples 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.\n\n```go\nfunc (e *GitHubPREntity) UnmarshalJSON(data []byte) error\n```\nUnmarshalJSON implements json.Unmarshaler using the alias pattern to avoid recursion.\n\n```go\nfunc (e *GitHubPREntity) Validate() error\n```\nValidate checks that the pull request entity has all required fields.\n\n```go\ntype GitHubReviewEntity struct {\n\t// Org is the GitHub organization or user that owns the repository.\n\tOrg string `json:\"org\"`\n\t// Repo is the repository name within the organization.\n\tRepo string `json:\"repo\"`\n\t// ID is a unique identifier for this review (e.g., UUID or sequential ID).\n\tID string `json:\"id\"`\n\t// PRNumber is the pull request number that this review targets.\n\tPRNumber int `json:\"pr_number\"`\n\t// Verdict is the review outcome: approve, request_changes, or reject.\n\tVerdict string `json:\"verdict\"`\n\t// Issues is the count of issues found during review.\n\tIssues int `json:\"issues\"`\n\t// Agent is the role of the agent that performed this review (e.g., \"reviewer\").\n\tAgent string `json:\"agent\"`\n}\n```\nGitHubReviewEntity 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.\n\n```go\nfunc (e *GitHubReviewEntity) EntityID() string\n```\nEntityID returns the 6-part federated identifier for this review. Format: {org}.github.repo.{repo}.review.{id}\n\n```go\nfunc (e *GitHubReviewEntity) MarshalJSON() ([]byte, error)\n```\nMarshalJSON implements json.Marshaler using the alias pattern to avoid recursion.\n\n```go\nfunc (e *GitHubReviewEntity) Schema() message.Type\n```\nSchema returns the message type for GitHubReviewEntity payloads.\n\n```go\nfunc (e *GitHubReviewEntity) Triples() []message.Triple\n```\nTriples 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.\n\n```go\nfunc (e *GitHubReviewEntity) UnmarshalJSON(data []byte) error\n```\nUnmarshalJSON implements json.Unmarshaler using the alias pattern to avoid recursion.\n\n```go\nfunc (e *GitHubReviewEntity) Validate() error\n```\nValidate checks that the review entity has all required fields.\n\n```go\ntype IssueDetail struct {\n\tNumber int    `json:\"number\"`\n\tTitle  string `json:\"title\"`\n\tBody   string `json:\"body\"`\n}\n```\nIssueDetail carries the issue fields required to bootstrap an execution.\n\n```go\ntype OwnerDetail struct {\n\tLogin string `json:\"login\"`\n}\n```\nOwnerDetail carries the repository owner login.\n\n```go\ntype PRWorkflowComponent struct {\n\t// contains filtered or unexported fields\n}\n```\nPRWorkflowComponent spawns agent tasks for the GitHub issue-to-PR pipeline. It handles the Go-intensive parts of the workflow: prompt building, result parsing, and triple writing. The simpler reactive patterns (phase transitions, budget checks) are handled by JSON rules in configs/rules/github-pr-workflow/.\n\n```go\nfunc (c *PRWorkflowComponent) ConfigSchema() component.ConfigSchema\n```\nConfigSchema returns the JSON schema for this component's configuration. The canonical schema definition lives in register.go as prWorkflowSchema.\n\n```go\nfunc (c *PRWorkflowComponent) DataFlow() component.FlowMetrics\n```\nDataFlow returns current flow metrics for the component.\n\n```go\nfunc (c *PRWorkflowComponent) Health() component.HealthStatus\n```\nHealth returns the current health status of the component.\n\n```go\nfunc (c *PRWorkflowComponent) Initialize() error\n```\nInitialize prepares the component.\n\n```go\nfunc (c *PRWorkflowComponent) InputPorts() []component.Port\n```\nInputPorts returns the component's input port definitions.\n\n```go\nfunc (c *PRWorkflowComponent) Meta() component.Metadata\n```\nMeta returns component metadata.\n\n```go\nfunc (c *PRWorkflowComponent) OutputPorts() []component.Port\n```\nOutputPorts returns the component's output port definitions.\n\n```go\nfunc (c *PRWorkflowComponent) Start(ctx context.Context) error\n```\nStart begins consuming events and agent completions.\n\n```go\nfunc (c *PRWorkflowComponent) Stop(_ time.Duration) error\n```\nStop performs graceful shutdown.\n\n```go\ntype PortConfig struct {\n\tInputs  []PortDef `json:\"inputs,omitempty\"`\n\tOutputs []PortDef `json:\"outputs,omitempty\"`\n}\n```\nPortConfig defines port configuration.\n\n```go\ntype PortDef struct {\n\tName    string `json:\"name\"`\n\tSubject string `json:\"subject\"`\n\tType    string `json:\"type\"`\n\tStream  string `json:\"stream,omitempty\"`\n}\n```\nPortDef defines a single port.\n\n```go\ntype QualifierVerdict struct {\n\tVerdict    string  `json:\"verdict\"`\n\tConfidence float64 `json:\"confidence\"`\n\tSeverity   string  `json:\"severity\"`\n}\n```\nQualifierVerdict represents the parsed qualifier agent result.\n\n```go\nfunc ParseQualifierResult(result string) QualifierVerdict\n```\nParseQualifierResult parses the qualifier agent's JSON result. Returns a verdict with \"needs\\_info\" on parse failure.\n\n```go\ntype RepoDetail struct {\n\tName  string      `json:\"name\"`\n\tOwner OwnerDetail `json:\"owner\"`\n}\n```\nRepoDetail carries the repository owner and name.\n\n```go\ntype ReviewerOutput struct {\n\tVerdict  string `json:\"verdict\"`\n\tFeedback string `json:\"feedback\"`\n}\n```\nReviewerOutput represents the parsed reviewer agent result.\n\n```go\nfunc ParseReviewerResult(result string) ReviewerOutput\n```\nParseReviewerResult parses the reviewer agent's JSON result.\n\n```go\ntype WorkflowCompletionPayload struct {\n\tExecutionID         string   `json:\"execution_id\"`\n\tIssueNumber         int      `json:\"issue_number\"`\n\tRepoOwner           string   `json:\"repo_owner\"`\n\tRepoName            string   `json:\"repo_name\"`\n\tPRNumber            int      `json:\"pr_number\"`\n\tPRUrl               string   `json:\"pr_url\"`\n\tFilesChanged        []string `json:\"files_changed\"`\n\tDevelopmentAttempts int      `json:\"development_attempts\"`\n\tReviewRejections    int      `json:\"review_rejections\"`\n\tTotalTokensIn       int      `json:\"total_tokens_in\"`\n\tTotalTokensOut      int      `json:\"total_tokens_out\"`\n}\n```\nWorkflowCompletionPayload summarises the outcome of a completed issue-to-PR execution for downstream consumers.\n\n```go\nfunc (p *WorkflowCompletionPayload) MarshalJSON() ([]byte, error)\n```\nMarshalJSON implements message.Payload.\n\n```go\nfunc (p *WorkflowCompletionPayload) Schema() message.Type\n```\nSchema implements message.Payload.\n\n```go\nfunc (p *WorkflowCompletionPayload) UnmarshalJSON(data []byte) error\n```\nUnmarshalJSON implements message.Payload.\n\n```go\nfunc (p *WorkflowCompletionPayload) Validate() error\n```\nValidate implements message.Payload.\n\n","path":"github.com/c360studio/semstreams/examples/github-pr-workflow","name":"githubprworkflow","synopsis":"Package githubprworkflow provides Graphable entity types for the GitHub issue-to-PR automation workflow.","isRedistributable":true}
