Documentation
¶
Overview ¶
Package mapping proposes a product's promise and capabilities from the gathered sources, read whole, in one prompt-only session with no appetite, and checks the reply against the gather. Every capability it proposes is a promise the product makes to its users, with the PRs or changes that best show it and the docs that hold it, and what the sources leave uncertain comes back as a question, never a guess. It writes nothing to the repo: the proposal goes to the store for init's next phase.
Index ¶
- Constants
- Variables
- func Check(r Reply, g store.Gather) (Proposal, Dropped)
- func Estimate(g store.Gather) int
- func Parse(text string) (Reply, []Malformed, error)
- func Prompt(in reading.Input) string
- func Read(g store.Gather) reading.Input
- func WriteJSON(w io.Writer, r Result) error
- func WriteText(w io.Writer, r Result) error
- type Capability
- type Drop
- type Dropped
- type Malformed
- type Product
- type Proposal
- type Question
- type ReadSource
- type Reading
- type Reply
- type Result
- type Session
- type Share
- type Store
- type Stored
Constants ¶
const ( WhatPromise = "product promise" WhatCapability = "capability" WhatRef = "ref" WhatQuestion = "question" )
The values of Drop.What.
const ReplyReserve = 16_000
ReplyReserve is what init's estimate counts for propose's reply. It is a first guess, to be tuned from real runs (measure-before-budget).
const ResultVersion = 3
ResultVersion is the version of a Result's JSON form. It changes only when a field changes meaning or goes away.
Variables ¶
var ErrNoGather = errors.New("nothing gathered yet; run physa init --gather first")
ErrNoGather is returned by Propose when the store holds no gather.
Functions ¶
func Check ¶
Check holds r against the gather g and returns what stands, with everything it took out and why. A capability is dropped when its name is not a slug (mapfile.ValidSlug), when an earlier capability has its name, or when its promise is not a single non-empty line. A PR or change that was not gathered, or a short id that matches more than one gathered change, is removed from where it was named; a capability left with nothing that shows it is kept, with Unshown set. A question that does not end with a question mark is dropped. The product's promise must be a single non-empty line too: when it is not, the Proposal's is empty and the drop says so.
func Parse ¶
Parse reads the session's reply: the last fenced json block in text, holding one object with a product, a capabilities list and a questions list. The error, worded to follow "the session's output: ", is for a reply with no such block, one that does not decode, or one with no product or no capabilities. Each capability and each product-wide question is decoded on its own, refusing unknown keys, so one that is not what it should be becomes a Malformed and the others are kept, in order. Parse checks shape only; Check holds the reply against the gather.
func Prompt ¶
Prompt returns everything the session reads: the mapping skill, then the sources, whole, under their own headings. All that others wrote (docs, PR titles, bodies and review comments, change subjects, paths) sits in fenced blocks nothing inside can close; the labels outside the fences are Physa's own. The same input always gives the same text.
Types ¶
type Capability ¶
type Capability struct {
// Name is the capability's name, a slug as mapfile.ValidSlug reads one.
Name string `json:"name"`
// Promise is what the product promises its users, on one line.
Promise string `json:"promise"`
// ShownBy names the PRs ("#12") and changes (short ids) that best show
// the promise.
ShownBy []string `json:"shown_by"`
// Docs are the paths of the gathered docs that hold its entries.
Docs []string `json:"docs"`
// Questions are the questions about this capability.
Questions []Question `json:"questions"`
// Unshown says nothing gathered shows the capability: the session named
// no evidence, or none of what it named was gathered. Check sets it.
Unshown bool `json:"unshown"`
}
Capability is one proposed capability.
type Drop ¶
type Drop struct {
// What is one of the What constants.
What string `json:"what"`
// Capability is the capability the thing belonged to; empty for the
// product's promise, a product-wide question, or a capability itself.
Capability string `json:"capability"`
// Value is the thing as the session wrote it: a name, a ref, a
// question, a promise.
Value string `json:"value"`
// Reason says why it was dropped.
Reason string `json:"reason"`
}
Drop is one thing Check took out of the reply, with its reason.
type Malformed ¶
type Malformed struct {
// Raw is the item as the session wrote it.
Raw string `json:"raw"`
// Reason says what is wrong with it.
Reason string `json:"reason"`
}
Malformed is one item of the session's reply that is not a capability or a question, kept so that it is reported and never dropped silently.
type Product ¶
type Product struct {
// Promise is one sentence on one line; empty when the session's was
// dropped.
Promise string `json:"promise"`
}
Product is the product's own promise, as the product's folder will hold it.
type Proposal ¶
type Proposal struct {
Product Product `json:"product"`
Capabilities []Capability `json:"capabilities"`
Questions []Question `json:"questions"`
}
Proposal is the checked proposal: the product's promise, the capabilities and the product-wide questions, every name a slug and every PR or change one that was gathered.
type Question ¶
type Question struct {
// Question is the matter, one line ending with a question mark.
Question string `json:"question"`
// SuggestedBy names the PRs ("#12") and changes (short ids) that
// suggested it.
SuggestedBy []string `json:"suggested_by"`
}
Question is an undecided matter the sources suggest but do not settle.
type ReadSource ¶
ReadSource is reading.SourceReport in its JSON form.
type Reading ¶
type Reading struct {
PromptTokens int `json:"prompt_tokens"`
SourceTokens int `json:"source_tokens"`
Sources []ReadSource `json:"sources"`
// Lines says per source what was read, as reading.Report.Lines does.
Lines []string `json:"lines"`
// Shares and Merge are set only for a proposal made in shares.
Merge *shareview.JSON `json:"merge,omitempty"`
}
Reading is what the session read, in its JSON form: the prompt's estimated tokens, the sources' together, and each source.
type Reply ¶
type Reply struct {
Product Product
Capabilities []Capability
Questions []Question
}
Reply is what the session wrote, in shape only: Parse has decoded it and Check has not yet held it against the gather.
type Result ¶
type Result struct {
// Proposal is the checked proposal.
Proposal Proposal
// Dropped is what Check took out of the reply, and why.
Dropped Dropped
// Malformed are the items of the reply that were not what they should be.
Malformed []Malformed
// Read says what the session read of the gather, all of it whole.
Read reading.Report
// PromptTokens is the prompt's estimated tokens.
PromptTokens int
// SessionID is the id the session ran under, as the agent reported it.
SessionID string
// Model is the name the agent reported for what it ran on.
Model string
// Tokens is what the session used.
Tokens adapter.Tokens
// Shares and Merge are set only for a proposal made in shares: what each
// share's session and the merge's read and used. Then Read is the whole
// gather's, PromptTokens is every prompt's together, and Tokens is every
// session's together. Both are empty for one session.
Merge *Share
}
Result is how one run of Propose ended.
func Propose ¶
Propose is init's second phase end to end. It reads the stored gather, all of it whole, runs one prompt-only session with the mapping skill, checks the reply against the gather and stores the proposal, replacing any earlier one. It writes nothing to the repo. The session has no appetite and no circuit breaker: init is never bounded (design 10 Q6).
With no gather it returns 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 either; the Result then still says what the session used.
type Session ¶
type Session struct {
// Agent resolves the agent to propose with. Propose calls it only when
// there is a gather.
Agent func() (adapter.Adapter, error)
// Progress receives one line before the session starts; nil drops it.
Progress io.Writer
// Now is the clock the stored proposal is dated by; nil means time.Now.
Now func() time.Time
}
Session says how Propose runs its session.
type Store ¶
type Store interface {
Gathered() (store.Gather, bool, error)
PutProposal(initrecord.Proposal) error
}
Store is what Propose needs of the store: the gather to read and a place for the proposal.
type Stored ¶
type Stored struct {
Proposal Proposal `json:"proposal"`
Dropped Dropped `json:"dropped"`
Malformed []Malformed `json:"malformed"`
Read Reading `json:"read"`
// Sessions are every session the proposal ran, the shares' in order and
// then the merge's; empty for one session, whose id the store holds.
Sessions []string `json:"sessions,omitempty"`
}
Stored is the JSON form of initrecord.Proposal's Body: the checked proposal with what was dropped, what was malformed and what the session read.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package shareview shows what a proposal made in shares read and used: each share's sources and session and the merge's, in the text and JSON forms of the proposal's Read and Session sections.
|
Package shareview shows what a proposal made in shares read and used: each share's sources and session and the merge's, in the text and JSON forms of the proposal's Read and Session sections. |