Help us shape the future of Go! Take the 2026 Go Developer Survey

contribution

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 8, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound           = errors.New("contribution: not found")
	ErrMissingOpportunity = errors.New("contribution: opportunity is required")
	ErrEmptyGuidance      = errors.New("contribution: guidance is required")
	ErrMissingApproach    = errors.New("contribution: approach is required")
)

Functions

func EnsureDraftIdentity added in v0.14.0

func EnsureDraftIdentity(identity *DraftIdentity, repo, kind, title, body string)

EnsureDraftIdentity binds exact bytes for callers that construct drafts directly rather than through Renderer.

Types

type DraftArtifact added in v0.14.0

type DraftArtifact struct {
	DraftIdentity
	OpportunityID string
	Title         string
	Body          string
	RenderedAt    time.Time
	ManifestID    string
}

DraftArtifact is the common exact-byte view of an issue or pull-request draft revision.

type DraftDiagnostic added in v0.14.0

type DraftDiagnostic struct {
	Code       string
	Severity   string
	Message    string
	ByteOffset int
}

DraftDiagnostic reports an exact-byte validation finding without rewriting the draft.

func ValidateDraftBytes added in v0.14.0

func ValidateDraftBytes(title, body []byte) []DraftDiagnostic

ValidateDraftBytes inspects the final bytes and never normalizes or rewrites them. Markdown prose is identified through Goldmark's source segments.

func ValidateRequiredTemplateSections added in v0.14.0

func ValidateRequiredTemplateSections(body, guidance []byte) []DraftDiagnostic

ValidateRequiredTemplateSections reports headings declared by repository guidance but absent from the rendered contribution before its guidance appendix.

type DraftIdentity added in v0.14.0

type DraftIdentity struct {
	ID          string
	Revision    int
	Repository  string
	Kind        string
	TitleBytes  int
	BodyBytes   int
	TitleSHA256 string
	BodySHA256  string
	EvidenceIDs []string
	Warnings    []DraftDiagnostic
}

DraftIdentity binds one stored revision to the exact rendered UTF-8 bytes.

type IssueDraft

type IssueDraft struct {
	OpportunityID string
	DraftIdentity
	Title      string
	Body       string
	RenderedAt time.Time
	ManifestID string
}

IssueDraft is a rendered issue body ready for review.

type IssueInput

type IssueInput struct {
	Opportunity *investigation.Opportunity
	Evidence    []*evidence.Evidence
	Guidance    string
	Repo        domain.RepoRef
	Success     string
	ManifestID  string
}

IssueInput supplies the verified facts and repository guidance used to render an issue.

type PullRequestDraft

type PullRequestDraft struct {
	OpportunityID string
	DraftIdentity
	Title      string
	Body       string
	RenderedAt time.Time
	ManifestID string
}

PullRequestDraft is a rendered PR body ready for review.

type PullRequestInput

type PullRequestInput struct {
	Opportunity   *investigation.Opportunity
	Evidence      []*evidence.Evidence
	Guidance      string
	Repo          domain.RepoRef
	Approach      string
	Changes       string
	Compatibility string
	Limitations   string
	LinkedIssue   string
	ManifestID    string
}

PullRequestInput supplies the verified facts and repository guidance used to render a PR.

type Renderer

type Renderer struct{}

Renderer builds deterministic Markdown drafts from verified facts only.

func NewRenderer

func NewRenderer() *Renderer

NewRenderer returns a deterministic contribution renderer.

func (*Renderer) RenderIssue

func (r *Renderer) RenderIssue(in IssueInput) (*IssueDraft, error)

RenderIssue builds an issue draft from the supplied opportunity, evidence, and repository guidance. It does not invent claims beyond the input.

func (*Renderer) RenderPullRequest

func (r *Renderer) RenderPullRequest(in PullRequestInput) (*PullRequestDraft, error)

RenderPullRequest builds a PR draft from the supplied opportunity, evidence, repository guidance, and explicit approach details.

type Repository

type Repository interface {
	SaveIssueDraft(ctx context.Context, d *IssueDraft) error
	GetIssueDraft(ctx context.Context, opportunityID string) (*IssueDraft, error)
	SavePullRequestDraft(ctx context.Context, d *PullRequestDraft) error
	GetPullRequestDraft(ctx context.Context, opportunityID string) (*PullRequestDraft, error)
}

Repository is a narrow persistence boundary for contribution drafts. Concrete stores live outside this package; production code never uses an in-memory store.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service prepares contribution drafts and persists them through a narrow Repository.

func NewService

func NewService(repo Repository) *Service

NewService returns a ContributionService backed by repo and renderer.

func (*Service) PrepareIssue

func (s *Service) PrepareIssue(ctx context.Context, in IssueInput) (*IssueDraft, error)

PrepareIssue renders an issue draft and stores it.

func (*Service) PreparePullRequest

func (s *Service) PreparePullRequest(ctx context.Context, in PullRequestInput) (*PullRequestDraft, error)

PreparePullRequest renders a pull request draft and stores it.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL