Documentation
¶
Overview ¶
Package consolidate holds the feature consolidation's model calls (features/README.md, "Consolidation"): the input rendered for a repository's merge call and for one feature's split call, the reply schemas, and the validation of a reply. The host supplies its prompt versions (Prompts); Public are the published ones. It makes no call and reads no database.
Index ¶
- Constants
- Variables
- func Schema(kind Kind) map[string]any
- type Feature
- type Group
- type Kind
- type Part
- type Partition
- type Prompts
- func (p Prompts) KnownPromptVersion(version string) bool
- func (p Prompts) PromptVersions() []string
- func (p Prompts) Request(version string, kind Kind, input string, maxOutputTokens int64) (decisions.ModelRequest, error)
- func (p Prompts) UsesFeatureContext(version string) bool
- func (p Prompts) VersionOf(req decisions.ModelRequest) (string, Kind, bool)
- type PullRequest
- type PullRequestTitle
- type RenderedMerge
- type RenderedSplit
- type SplitCut
- type SplitInput
- type Version
Constants ¶
const ( MaxOutputTokens = 8192 MaxHostOutputTokens = 32768 )
MaxOutputTokens caps a reply, reasoning included, unless the host asks for more, up to MaxHostOutputTokens: a host whose model reasons within the reply's bound and cannot be told not to may need the room.
const ( DefaultMaxInputBytes = 200_000 MinInputBytes = 16 << 10 MaxInputBytes = 1 << 20 )
Bounds of one call's rendered input in bytes, a host's setting.
const ( MaxTitleRunes = 120 MaxDescriptionRunes = 1000 )
Bounds of a part's text in a split reply; a longer one is invalid.
const ( // MaxSplitPullRequests is the most pull requests a split call is // offered; a larger feature is not split. MaxSplitPullRequests = 200 )
Bounds of each rendered field, so no one field crowds the rest out.
const PublicVersion = "feature-consolidate-public-v1"
PublicVersion is the published prompt version.
Variables ¶
var ErrInvalidReply = errors.New("invalid feature consolidation reply")
ErrInvalidReply is a reply that does not match its schema, names an id outside its input, or does not place every member exactly once.
var ErrTooLarge = errors.New("the consolidation input does not fit its bound")
ErrTooLarge is an input that cannot be cut down to its bound.
var Public = Prompts{ PublicVersion: {Merge: publicMergePrompt, Split: publicSplitPrompt, Contextual: true}, }
Public are the published prompt versions: one whose merge call sees each feature's digest and its pull requests' summaries.
Functions ¶
Types ¶
type Feature ¶
type Feature struct {
Title, Description string
Digest string
// Withheld marks a feature whose text the repository may not read now:
// it is rendered without its title and description.
Withheld bool
Paths []string
PullRequests []PullRequestTitle
// Sessions counts the connected sessions in it on their own that follow
// no feature pull request.
Sessions int
// SplitFrom is the index among the features given to RenderMerge of the
// feature a recent split created this one from, nil for none; set only
// for a version that UsesFeatureContext.
SplitFrom *int
}
Feature is one of a repository's features as the merge call sees it: its generated text, paths and pull request titles, never a session's prompts or decisions. Digest and the pull requests' summaries are set only for a version that UsesFeatureContext, and only as far as the repository may read them.
type Group ¶
Group is a set of duplicate features of a validated merge reply, as indexes into the features given to RenderMerge: the survivor, and the duplicates that join it.
func ParseMergeReply ¶
func ParseMergeReply(data []byte, rendered RenderedMerge) ([]Group, int, error)
ParseMergeReply decodes and validates a merge reply against the rendered input, keeping what is valid: an id outside the input is dropped (a group whose survivor is one with it), every group naming a feature the reply names more than once is dropped, and so is a group left without a duplicate. It returns the groups kept and how many of the reply's groups it dropped or cut. A reply that does not decode, or misses a field, is invalid.
type Part ¶
Part is one deliverable of a validated split reply: its provisional text and its pull requests, as sorted indexes into SplitInput.PullRequests.
type Partition ¶
Partition is a validated split reply. Keeper is the part that keeps the feature's id: the largest, ties to the one with the earliest pull request.
func ParseSplitReply ¶
func ParseSplitReply(data []byte, rendered RenderedSplit) (Partition, error)
ParseSplitReply decodes and validates a split reply against the rendered input: every pull request of the input is in exactly one part, no part names an id outside it or is empty, and each has a title and a description within their bounds. Any violation invalidates the whole reply.
type Prompts ¶
Prompts are a host's released prompt versions, by name.
func (Prompts) KnownPromptVersion ¶
KnownPromptVersion reports whether version is a released prompt version.
func (Prompts) PromptVersions ¶
PromptVersions lists the released prompt versions, sorted.
func (Prompts) Request ¶
func (p Prompts) Request(version string, kind Kind, input string, maxOutputTokens int64) (decisions.ModelRequest, error)
Request is the call of the kind for a rendered input under prompt version version, its reply bounded by maxOutputTokens (MaxOutputTokens for 0, at most MaxHostOutputTokens).
func (Prompts) UsesFeatureContext ¶
UsesFeatureContext reports whether version's merge call reads each feature's digest and pull request summaries (Feature.Digest, PullRequestTitle.Summary).
type PullRequest ¶
type PullRequest struct {
Number int32
Title, Body string
// Summary is what it changed, as far as the repository may read it;
// set only for a version that UsesFeatureContext.
Summary string
State string
OpenedAt time.Time
Paths []string
}
PullRequest is one of a feature's pull requests as the split call sees it.
type PullRequestTitle ¶
PullRequestTitle is a pull request of a feature in the merge call.
type RenderedMerge ¶
type RenderedMerge struct {
Input string
// Features lists the indexes of the rendered features: ref Fi is
// Features[i-1].
Features []int
// Cut counts the features left out to keep the input within its bound.
Cut int
// CutSummaries and CutDigests count the pull request summaries and
// digests left out first, before any feature is.
CutSummaries, CutDigests int
}
RenderedMerge is the user message of a merge call.
func RenderMerge ¶
func RenderMerge(features []Feature, maxBytes int) (RenderedMerge, error)
RenderMerge is the user message of a merge call: the features in the order given (most recently active first), every field truncated to its bound, at most maxFeatures of them and at most maxBytes long. When it is longer, pull request summaries are left out first, each feature's earliest first, in turns over the features; then digests, of the least recently active feature first; then features at the end. A feature's digest, summaries and split_from (the ref of the feature it was recently split from, when that one is rendered too) are rendered only when set, so a version that does not UsesFeatureContext renders as before.
type RenderedSplit ¶
type RenderedSplit struct {
Input string
// PullRequests is how many pull requests it lists: ref Pi is the
// (i-1)-th of SplitInput.PullRequests.
PullRequests int
Cut SplitCut
}
RenderedSplit is the user message of a split call.
func RenderSplit ¶
func RenderSplit(input SplitInput, maxBytes int) (RenderedSplit, error)
RenderSplit is the user message of a split call: the feature and every one of its pull requests, each field truncated to its bound, at most maxBytes long. When it is longer, pull request descriptions are left out first, earliest first, then their paths, then their summaries, so a large feature is still split on what its pull requests changed. A summary is rendered only when set and the feature is not withheld, so a version that does not UsesFeatureContext renders as before. A feature with more than MaxSplitPullRequests pull requests, or one that does not fit with neither, is ErrTooLarge: every pull request must be placed, so none is left out.
type SplitCut ¶
type SplitCut struct {
Descriptions, Paths, Summaries int
}
SplitCut counts what was left out of a split call's input.
type SplitInput ¶
type SplitInput struct {
Title, Description string
Withheld bool
PullRequests []PullRequest
}
SplitInput is one oversized feature: its text and its pull requests, earliest opened first. Withheld renders it without its text.
type Version ¶
type Version struct {
Merge, Split string
// Contextual marks a version whose merge call also sees each feature's
// digest and its pull requests' summaries.
Contextual bool
}
Version is a released prompt version: its merge and split prompt. A released prompt is never edited; a change is a new version.