Documentation
¶
Overview ¶
Package consolidating is the code side of init's consolidation: over the capabilities recovered from the walk, it merges capabilities a session names as one promise, merges exact duplicate entries, applies an area's merges, moves and drops by id, and lifts rules repeated across areas to the product's rules. It never writes, rewords or invents an entry, a heading, a reason, a name or a promise: it only chooses among what recovery wrote and adds anchors, refuses with its reason whatever fails a check or a size limit, and records everything it did.
Index ¶
- Constants
- func ID(capability, slug string) string
- func ProductRules(product string, rules []capabilitytext.Entry) string
- type AreaChoices
- type CapabilityMerge
- type DropChoice
- type DroppedOverview
- type DroppedQuestion
- type EntryMerge
- type Lift
- type LiftChoice
- type MergeChoice
- type Move
- type MoveChoice
- type Normal
- type Output
- type Record
- type Refusal
- type Rename
- type Repeat
- type State
- func (s *State) ApplyArea(area capabilitytext.Area, ch AreaChoices)
- func (s *State) Areas() []capabilitytext.Area
- func (s *State) Capabilities() []capabilitytext.Capability
- func (s *State) ExactDuplicates(normal Normal) []Repeat
- func (s *State) Lift(l LiftChoice, shown []string, groups [][]string) bool
- func (s *State) Merge(group []string, name, promiseOf string, normal Normal) bool
- func (s *State) Output() Output
- func (s *State) Record() Record
- func (s *State) Refuse(r Refusal)
- type TermConflict
Constants ¶
const ( StepMerge = "merge" StepArea = "area" StepLift = "lift" StepGuard = "guard" )
The steps a Refusal names.
Variables ¶
This section is empty.
Functions ¶
func ProductRules ¶
func ProductRules(product string, rules []capabilitytext.Entry) string
ProductRules is the product's rules file as the map writes it for the product named product: its title, its contents and the rules.
Types ¶
type AreaChoices ¶
type AreaChoices struct {
Merges []MergeChoice `json:"merges"`
Moves []MoveChoice `json:"moves"`
Drops []DropChoice `json:"drops"`
}
AreaChoices is what an area's session chose, by id: entries to merge, rules to move and questions to drop as answered.
type CapabilityMerge ¶
type CapabilityMerge struct {
Group []string `json:"group"`
Name string `json:"name"`
PromiseOf string `json:"promise_of"`
Renamed []Rename `json:"renamed_slugs"`
DroppedOverviews []DroppedOverview `json:"dropped_overviews"`
TermConflicts []TermConflict `json:"term_conflicts"`
}
CapabilityMerge is capabilities merged into one: the group, the name and whose promise it keeps, and what the merge renamed, dropped and listed.
type DropChoice ¶
DropChoice drops a question another live entry of its area answers.
type DroppedOverview ¶
DroppedOverview is the overview of a merged capability whose name was not kept.
type DroppedQuestion ¶
DroppedQuestion is a question dropped as answered, and the entry that answers it.
type EntryMerge ¶
type EntryMerge struct {
Kept string `json:"kept"`
Merged []string `json:"merged"`
AnchorsAdded []string `json:"anchors_added"`
}
EntryMerge is entries merged into a kept one, by id, and the anchors the kept one took from them.
type Lift ¶
type Lift struct {
Kept string `json:"kept"`
With []string `json:"with"`
Areas []capabilitytext.Area `json:"areas"`
AnchorsAdded []string `json:"anchors_added"`
}
Lift is a rule lifted to the product's rules: the one kept, the ones it repeats, the areas they came from and the anchors it took from them.
type LiftChoice ¶
LiftChoice is a lift a session chose, by id: the rule kept and the rules it repeats.
type MergeChoice ¶
MergeChoice keeps one entry and drops others of its kind into it.
type MoveChoice ¶
MoveChoice moves a rule to another capability of its area.
type Normal ¶
Normal is the form two entries share when they are exact duplicates: of a heading and a body without its Because: line, case, spacing and punctuation set aside.
type Output ¶
type Output struct {
Product string
Capabilities []capabilitytext.Capability
Rules []capabilitytext.Entry
}
Output is consolidation's result: the capabilities in walk order and the product's rules, under the product's name.
type Record ¶
type Record struct {
// SlugRenames and TermConflicts are the pre-pass's: slugs and terms that
// separate recoveries already shared before anything was merged.
SlugRenames []Rename `json:"slug_renames"`
TermConflicts []TermConflict `json:"term_conflicts"`
Merged []CapabilityMerge `json:"merged"`
ExactMerges []EntryMerge `json:"exact_merges"`
EntryMerges []EntryMerge `json:"entry_merges"`
Moves []Move `json:"moves"`
Dropped []DroppedQuestion `json:"dropped"`
Lifts []Lift `json:"lifts"`
Refused []Refusal `json:"refused"`
// Consolidated are the capabilities whose text or terms changed, in walk
// order; every other one is left as recovered.
Consolidated []string `json:"consolidated"`
}
Record is what consolidation did, as init's record stores and shows it.
type Refusal ¶
type Refusal struct {
Step string `json:"step"`
Item string `json:"item"`
Reason string `json:"reason"`
}
Refusal is an item consolidation refused: the step, the item and why.
type Repeat ¶
type Repeat struct {
IDs []string `json:"ids"`
Areas []capabilitytext.Area `json:"areas"`
}
Repeat is a rule repeated, as an exact duplicate, in different areas: a candidate to lift. IDs are in walk order, Areas each once.
type State ¶
type State struct {
// contains filtered or unexported fields
}
State is a consolidation under way over the capabilities recovered from the walk.
func New ¶
func New(product string, caps []capabilitytext.Capability, rules []capabilitytext.Entry) *State
New starts a consolidation of caps, in walk order, for the product named product, whose rules are rules. Nothing given is changed. Before anything else it renames, in later capabilities in walk order, slugs an earlier one holds, and keeps once a term an earlier one defines the same way or lists it as a term conflict when it is defined differently: slugs and term names are unique in the whole map.
func (*State) ApplyArea ¶
func (s *State) ApplyArea(area capabilitytext.Area, ch AreaChoices)
ApplyArea applies an area's choices, by id, in order: merges, then moves, then drops. Each item that fails a check is refused with its reason and the rest still apply.
func (*State) Areas ¶
func (s *State) Areas() []capabilitytext.Area
Areas is the areas of the capabilities, in walk order, each once.
func (*State) Capabilities ¶
func (s *State) Capabilities() []capabilitytext.Capability
Capabilities is the capabilities as they stand, in walk order, as copies.
func (*State) ExactDuplicates ¶
ExactDuplicates merges, inside each area, the exact duplicates (by normal) among entries of the same kind, the first in walk order kept with every anchor of the rest. Rules that are exact duplicates in different areas are not merged: it returns them as repeats, candidates to lift.
func (*State) Lift ¶
func (s *State) Lift(l LiftChoice, shown []string, groups [][]string) bool
Lift applies one lift: the kept rule, with every anchor of the rules it repeats, goes to the product's rules, and all of them leave their capabilities. shown are the ids the session was shown and groups the candidate groups it was given. It is refused, with its reason and nothing changed, when an id is unknown, removed, not a rule, not shown, or not in keep's candidate group, when its rules are in fewer than two areas, when the kept rule's heading anchor is one the product's rules already have, or when the product's rules would pass their size limit. It says whether it lifted.
func (*State) Merge ¶
Merge merges the capabilities named in group into one named name, with the promise of promiseOf, both from the group (architecture 12 §3). Every rule, decision, question and term is kept, each in its kind; the group's exact duplicates (by normal) are merged first, keeping every anchor; a slug any other entry of the map holds is renamed; the footprint is the union, and the area is name's. It is refused, with its reason, and the capabilities stay apart, when the group has fewer than two capabilities or all are in one area, when two entries of a kind would share a heading's anchor, or when the merged folder would pass a size limit. It says whether it merged.
type TermConflict ¶
type TermConflict struct {
Capability string `json:"capability"`
Name string `json:"name"`
KeptIn string `json:"kept_in"`
Text string `json:"text"`
}
TermConflict is a term whose name an earlier capability already defines differently: the first definition is kept, and this one is listed whole.