shares

package
v0.0.18 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package shares reads init's sources in shares when they are more than one session holds: propose's (design 02 §2.3.1), and one capability's in recovery (§2.4). It lays the sources, in the order reading gives them, into shares that each read their sources whole, and merges what propose's shares proposed. It never splits, cuts or skips a source (init-no-cut): a source larger than one share stops init, named, before anything is spent on propose. When the whole prompt fits one session, propose runs as before, unchanged.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckLinks(r mapping.Reply, ps []mapping.Proposal) (mapping.Reply, mapping.Dropped)

CheckLinks drops from the merge's reply every link no share's proposal gave: each PR or change in a capability's shown_by or a question's suggested_by, and each doc path in a capability's docs, whether on a capability or product-wide. Each drop is a mapping.WhatRef with the reason "no share gave it". Order and everything else are kept. The caller then checks the reply against the gather with mapping.Check.

func Estimate

func Estimate(g store.Gather, window int) (prompt, reply, shares int, err error)

Estimate is what init's estimate counts for propose of g with an agent whose window is window: the prompts' estimated tokens together, the reply reserves, and the number of shares. When the prompt fits one session (or window is 0) that is mapping.Estimate, one reply reserve and 0 shares. Otherwise it is every share's prompt and the merge's (MergeTokens), a reply reserve for each share and the merge, and the shares Propose would run. A source too large for one share gives the *TooLarge.

func Fits

func Fits(in reading.Input, window int) bool

Fits reports whether propose's whole prompt for in, with its reply reserve, fits one session of an agent whose window is window estimated tokens. A window of 0 is unknown, and then everything fits: propose runs one session, as before.

func JoinCapability added in v0.0.6

func JoinCapability(parts []reading.Input, whole reading.Input) reading.Input

JoinCapability is the sources of parts, laid by LayCapability, together again in order, the docs every capability reads once, under whole's Report; with no parts it is whole.

func Lay

func Lay(in reading.Input, room int) ([]reading.Input, error)

Lay lays in's sources into shares whose whole prompts are each at most room estimated tokens: the window less mapping.ReplyReserve, or less after a halving. Sources keep reading.Of's order (docs, PRs each with all its review comments, changes, clusters), and a share ends when the next source does not fit beside it. When the docs take at most half of room, every share reads all of them and only the other sources are divided; the docs are divided too when they take more, or when a source fits an empty share but not beside them. Every source reaches exactly one share whole, the docs every share when they are not divided. A source that does not fit even an empty share is a *TooLarge, and Lay returns no shares. Each share's Report counts only what it reads. The same input and room always give the same shares.

func LayCapability added in v0.0.6

func LayCapability(in reading.Input, room int, message func(reading.Input) string) ([]reading.Input, error)

LayCapability lays one capability's sources in for recovery (design 02 §2.4): as LayFor does, into shares whose messages, as message writes them, each take at most room estimated tokens, except the docs every capability reads (reading.Always), which recovery's sessions read in their system prompt: they are not laid, and every share keeps them. A source too large for one share is an error naming it.

func LayFor added in v0.0.6

func LayFor(in reading.Input, room int, prompt func(reading.Input) string) ([]reading.Input, error)

LayFor is Lay for a session whose prompt for an input is prompt's: room is then the most estimated tokens prompt's text for each share may take. Recovery lays a capability's own sources with it (design 02 §2.4).

func MergePrompt

func MergePrompt(ps []mapping.Proposal) string

MergePrompt returns everything the merge session reads: the merging skill, then each share's checked proposal under its own label. What the sessions wrote sits in fenced blocks nothing inside can close. It holds no source. The same proposals always give the same text.

func MergeTokens

func MergeTokens(n int) int

MergeTokens estimates the merge session before the shares have run, for init's estimate: the skill and labels for n shares, and a reply reserve for each share's proposal, which is what the merge will read.

func Propose

Propose is init's propose phase end to end, in one session or in shares. It reads the stored gather and resolves the agent once. When the whole prompt with its reply reserve fits the window the agent states, or the agent states none, it is mapping.Propose, unchanged. Otherwise, and when that one session is refused as too long, it lays the sources into shares (Lay), runs one session per share, one at a time, each reading its sources whole, then a merge session that reads only the shares' checked proposals and may add no link (CheckLinks), and stores the merged proposal with every session it ran.

A share's session refused as too long halves the room: its sources and those of every share not yet run are laid again, in order, and the shares already run are kept. A source too large for one share is a *TooLarge, returned before any share's session starts when the window is right. No session has an appetite or a circuit breaker: init is never bounded.

With no gather it returns mapping.ErrNoGather and resolves no agent. An agent that fails, or a reply that cannot be read (the error starts "the session's output: "), stores nothing; the Result then still says what the sessions used.

Types

type TooLarge

type TooLarge struct {
	// Source names the source as a person reads it: "doc <path>", "PR #N",
	// "change <short id>" or "cluster N".
	Source string
	// Tokens is the source's estimated tokens, as propose writes it.
	Tokens int
	// Room is the most estimated tokens one share's prompt may take.
	Room int
	// Leave says how to leave the source out of the gather.
	Leave string
}

TooLarge is returned by Lay when one source, with the skill and headings alone, is more than one share holds. Nothing is cut, so init stops before spending on propose.

func (*TooLarge) Error

func (e *TooLarge) Error() string

Jump to

Keyboard shortcuts

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