Documentation
¶
Overview ¶
Package walk holds the skill for init's walk: one session reads an area's code, tests and docs and names its capabilities, each a promise with a footprint, and marks every other source file of the area shared with a reason. Footprints are init's own scaffolding, kept in init's record and never in the map.
Index ¶
- Constants
- Variables
- func Check(a Area, ans Answer, split sourceset.Division) (Footprints, Problems)
- func CheckSplit(a Area, ans Answer) ([]Area, Problems)
- func FixPrompt(p Problems) string
- func Message(a Area, split sourceset.Division, sizes map[string]int) string
- func Text(w io.Writer, r Result) error
- type Answer
- type Area
- type AreaResult
- type Capability
- type CapabilityRecord
- type Entries
- type Fix
- type Footprint
- type Footprints
- type Part
- type Problems
- type Record
- type Rename
- type Result
- type Session
- type Shared
- type SharedRecord
- type SplitRecord
- type Store
Constants ¶
const ( // Concurrency is the most sessions running at once. Concurrency = 3 // MaxFixRounds is how often a session is sent back its answer's faults. MaxFixRounds = 2 )
const CapabilityDefinition = "" /* 322-byte string literal not displayed */
CapabilityDefinition is the definition of a capability the walk skill carries, word for word as architecture 15 section 4 quotes it.
Variables ¶
var Split string
Split is the section a top-level area's session gets after Walk: it may split its area once, by promise, into parts that are walked on their own.
var Walk string
Walk is the walk session's system text: what the map is, what a capability is, how to walk an area, what each capability carries and the shape of the answer.
Functions ¶
func Check ¶
Check judges a capabilities answer for area a against the split of the repo's files, and returns the footprints it resolves to and what is wrong. A source or shared path is a file or a folder ending with a slash; the most specific claim wins and a tie claims the file twice.
func CheckSplit ¶
CheckSplit judges a split answer for area a: two or more parts with unique names, every source file in exactly one. It returns the parts as areas, each with a as its Parent.
func FixPrompt ¶
FixPrompt is the message that sends back everything a check found wrong, grouped, and asks for an answer holding only the changes.
func Message ¶
Message is the walk session's message for area a: its name and promise (and the area it was split from), its source files one per line with line counts where sizes knows them, and the folders of the repo's test and doc files with counts (and its other files), so the session can Glob them. Everything of the repo's sits in a fence, as data.
Types ¶
type Answer ¶
type Answer struct {
Capabilities []Capability `json:"capabilities"`
Split []Part `json:"split"`
}
Answer is a walk session's answer: the capabilities and shared files of its area, or the parts it splits into.
type Area ¶
Area is what one walk session is given: an area's name and promise, the area it was split from when it is a part, and its source files.
type AreaResult ¶
type AreaResult struct {
Name string `json:"name"`
Parent string `json:"parent,omitempty"`
Capabilities []string `json:"capabilities"`
Owned int `json:"owned"`
Parts []string `json:"parts"`
}
AreaResult is one area of a Result, or a part of the split area Parent.
type Capability ¶
type Capability struct {
Name string `json:"name"`
Promise string `json:"promise"`
Sources []string `json:"sources"`
Tests []string `json:"tests"`
Docs []string `json:"docs"`
Other []string `json:"other,omitempty"`
}
Capability is one capability as the session names it: the source files it owns and the tests, docs and other files that bear on it.
type CapabilityRecord ¶
type CapabilityRecord struct {
Capability
Area string `json:"area"`
Parent string `json:"parent"`
// Entries are the test, doc and other paths as the session wrote them,
// folders keeping their trailing slash; empty in an older stored walk.
Entries Entries `json:"entries,omitempty"`
}
CapabilityRecord is a capability with its footprint, its area and, when that area is a part, the area it was split from.
type Entries ¶
type Entries struct {
Tests []string `json:"tests,omitempty"`
Docs []string `json:"docs,omitempty"`
Other []string `json:"other,omitempty"`
}
Entries are the paths a footprint names for one kind of file, as written.
type Fix ¶
type Fix struct {
Add map[string][]string `json:"add"`
New []Capability `json:"new"`
Drop []string `json:"drop"`
Remove []string `json:"remove"`
}
Fix is the answer to FixPrompt: only the changes. Add moves paths to a capability (or a part) from every other claim, Shared marks files shared, New adds capabilities, Drop takes paths back from every claim, and Remove takes capabilities out by name.
type Footprint ¶
Footprint is a capability with the source files it owns and the tests, docs and other files that bear on it, every folder expanded to files and sorted. Entries are the test, doc and other paths as the session gave them.
type Footprints ¶
type Footprints struct {
Capabilities []Footprint
}
Footprints are an area's capabilities, and its shared files with reasons.
type Part ¶
type Part struct {
Name string `json:"name"`
Promise string `json:"promise"`
Sources []string `json:"sources"`
}
Part is one part of a split area.
type Problems ¶
type Problems struct {
// Split is set when the answer checked was a split.
Split bool
// Unclaimed are source files owned by none and not shared.
Unclaimed []string
// Twice maps a source file to the owners that both claim it.
Twice map[string][]string
// Outside are "owner: path" for source or shared paths matching no file
// of the area.
Outside []string
// NotTest, NotDoc and NotOther are "capability: path" for tests, docs and
// other paths matching no file the split named a test, a doc or other.
NotTest, NotDoc, NotOther []string
// NoSource are the capabilities (or parts) owning no source file.
NoSource []string
// Names are the other faults: a repeated, malformed or empty name, an
// empty promise, too few parts.
Names []string
}
Problems are what a check found wrong with an answer. Each list is empty when it found nothing of that kind.
type Record ¶
type Record struct {
Capabilities []CapabilityRecord `json:"capabilities"`
Splits []SplitRecord `json:"splits"`
Renamed []Rename `json:"renamed"`
Sessions []string `json:"sessions"`
}
Record is the body init's record keeps for the walk, read back with Load. Its file paths are init's own and never reach the map.
type Result ¶
type Result struct {
Areas []AreaResult `json:"areas"`
Capabilities int `json:"capabilities"`
Owned int `json:"owned"`
Unclaimed int `json:"unclaimed"`
FixRounds int `json:"fix_rounds"`
Renamed []Rename `json:"renamed"`
Model string `json:"model"`
Tokens adapter.Tokens `json:"tokens"`
}
Result is what the walk ended with: each area in stored order, its parts after it, and the totals. Unclaimed is 0 when the walk was stored.
func Run ¶
Run is init's walk: one read-only session per stored area, at most Concurrency at once, names the area's capabilities with their footprints and its shared files, or splits it once into parts walked the same way. The walk is stored in init's record only when every area ended whole; otherwise the error names each that failed. Nothing reaches the repo or map.
type Session ¶
type Session struct {
Agent func() (adapter.Adapter, error)
Root string
Progress io.Writer
Now func() time.Time
}
Session is the agent, the root its sessions read, progress and the clock.
type Shared ¶
type Shared struct {
}
Shared is a source file, or a folder ending with a slash, kept by many capabilities or by none, with the reason.
type SharedRecord ¶
type SharedRecord struct {
}
SharedRecord is a source file no capability owns, with its area.
type SplitRecord ¶
type SplitRecord struct {
Area string `json:"area"`
Parts []areas.AreaRecord `json:"parts"`
}
SplitRecord is an area a session split, with the parts walked in its place.