Documentation
¶
Overview ¶
Package templates renders every piece of markdown patchy writes — issue bodies, comments, pull-request bodies, and the agent-facing handoff files — from embedded text/templates, so the artifacts stay consistent across the estate.
The issue body carries a machine-readable manifest block (an HTML comment holding JSON) that is the authoritative record of the alerts accumulated into the issue; the human-readable body is re-rendered from the manifest on every accumulation, never string-edited. The accumulator (source-controller) owns the body; everyone else appends comments.
Index ¶
- Constants
- func AccumulationComment(alert Alert) (string, error)
- func ApproveComment(reason string) (string, error)
- func EnhancementComment(enhancerID, markdown string) (string, error)
- func IssueTitle(m Manifest) string
- func PRBody(issue int, report string) (string, error)
- func RenderClassifyPrompt(p ClassifyPrompt) (string, error)
- func RenderEnrichmentComment(e Enrichment, markdown string) (string, error)
- func RenderIssueBody(m Manifest) (string, error)
- func RenderRemediatePrompt(p RemediatePrompt) (string, error)
- func RenderWorkspaceIssue(w WorkspaceIssue) (string, error)
- func ReportComment(stage, report string) (string, error)
- type Alert
- type ClassifyPrompt
- type Enrichment
- type Manifest
- type RemediatePrompt
- type WorkspaceIssue
Constants ¶
const ( ClassificationReportHeading = "Classification" RemediationReportHeading = "Remediation" )
The stage headings on report comments. They are load-bearing: the /approve path recovers the classification report from its comment by looking for this heading, so GitHub stays the only state store.
Variables ¶
This section is empty.
Functions ¶
func AccumulationComment ¶
AccumulationComment announces an alert being folded into an existing issue.
func ApproveComment ¶
ApproveComment renders the human instructions for forcing a remediation attempt on an issue the pipeline held back.
func EnhancementComment ¶
EnhancementComment wraps an enhancer's contribution with attribution.
func IssueTitle ¶
IssueTitle is the canonical security-finding issue title.
func PRBody ¶
PRBody renders the pull-request body for a remediation branch; issue is the tracked issue number ("Fixes #issue" auto-links and auto-closes).
func RenderClassifyPrompt ¶
func RenderClassifyPrompt(p ClassifyPrompt) (string, error)
RenderClassifyPrompt renders the classification prompt.
func RenderEnrichmentComment ¶
func RenderEnrichmentComment(e Enrichment, markdown string) (string, error)
RenderEnrichmentComment renders an enhancement comment: attributed human-readable markdown plus the embedded machine block.
func RenderIssueBody ¶
RenderIssueBody renders the full issue body — human summary plus the machine manifest block — from the manifest.
func RenderRemediatePrompt ¶
func RenderRemediatePrompt(p RemediatePrompt) (string, error)
RenderRemediatePrompt renders the remediation prompt.
func RenderWorkspaceIssue ¶
func RenderWorkspaceIssue(w WorkspaceIssue) (string, error)
RenderWorkspaceIssue renders the workspace issue.md handoff file.
func ReportComment ¶
ReportComment wraps an agent stage report for posting to the issue.
Types ¶
type Alert ¶
type Alert struct {
Number int `json:"number"`
HTMLURL string `json:"url,omitempty"`
Locations []source.Location `json:"locations,omitempty"`
}
Alert is one accumulated finding instance.
type ClassifyPrompt ¶
type ClassifyPrompt struct {
IssuePath string
ReportPath string
AllowedModels []string
MaxTurnsCeiling int
TokenBudgetCeiling int
}
ClassifyPrompt is the data for the stage-1 (classification) prompt.
type Enrichment ¶
type Enrichment struct {
Enhancer string `json:"enhancer"`
Owners []string `json:"owners,omitempty"`
Attributes map[string]string `json:"attributes,omitempty"`
}
Enrichment is the machine-readable part of an enhancement comment: the facts downstream automation consumes (owners for assignment, attributes for future mapping). The human-readable markdown travels alongside it in the same comment.
func ParseEnrichment ¶
func ParseEnrichment(comment string) (Enrichment, bool)
ParseEnrichment recovers the machine block from one comment; ok reports whether the comment carries one.
type Manifest ¶
type Manifest struct {
Source string `json:"source"`
// Advisories are the categorization IDs, most authoritative first;
// Advisories[0] is the accumulation key.
Advisories []string `json:"advisories"`
RuleID string `json:"rule_id,omitempty"`
Title string `json:"title"`
// Description is the rule's markdown help text, shared by every alert of
// the family.
Description string `json:"description,omitempty"`
Severity string `json:"severity,omitempty"`
Alerts []Alert `json:"alerts"`
}
Manifest is the machine-readable state embedded in the issue body: the finding family the issue tracks and every alert accumulated into it. The body is derived from the manifest, so mutating the manifest and re-rendering is the only way the body changes.
func NewManifest ¶
NewManifest starts a manifest from the finding that opens an issue.
func ParseManifest ¶
ParseManifest recovers the manifest from an issue body written by RenderIssueBody.
func (*Manifest) Add ¶
Add accumulates a finding's alert into the manifest, reporting whether it was new (false means the alert number was already recorded — a redelivery).
func (Manifest) AlertNumbers ¶
AlertNumbers lists the accumulated alert numbers in insertion order.