consolidating

package
v0.0.33 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: Apache-2.0 Imports: 7 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 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

View Source
const (
	StepMerge = "merge"
	StepArea  = "area"
	StepLift  = "lift"
	StepGuard = "guard"
)

The steps a Refusal names.

Variables

This section is empty.

Functions

func ID

func ID(capability, slug string) string

ID is an entry's id: its capability's name and its slug.

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

type DropChoice struct {
	ID         string `json:"id"`
	AnsweredBy string `json:"answered_by"`
}

DropChoice drops a question another live entry of its area answers.

type DroppedOverview

type DroppedOverview struct {
	Capability string `json:"capability"`
	Text       string `json:"text"`
}

DroppedOverview is the overview of a merged capability whose name was not kept.

type DroppedQuestion

type DroppedQuestion struct {
	ID         string `json:"id"`
	AnsweredBy string `json:"answered_by"`
}

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

type LiftChoice struct {
	Keep string   `json:"keep"`
	With []string `json:"with"`
}

LiftChoice is a lift a session chose, by id: the rule kept and the rules it repeats.

type MergeChoice

type MergeChoice struct {
	Keep string   `json:"keep"`
	Drop []string `json:"drop"`
}

MergeChoice keeps one entry and drops others of its kind into it.

type Move

type Move struct {
	From string `json:"from"`
	To   string `json:"to"`
}

Move is a rule moved to another capability of its area, by id before and after.

type MoveChoice

type MoveChoice struct {
	ID string `json:"id"`
	To string `json:"to"`
}

MoveChoice moves a rule to another capability of its area.

type Normal

type Normal func(heading, body string) string

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 Rename

type Rename struct {
	From string `json:"from"`
	To   string `json:"to"`
}

Rename is an entry whose slug was taken, by id before and after.

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

func (s *State) ExactDuplicates(normal Normal) []Repeat

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

func (s *State) Merge(group []string, name, promiseOf string, normal Normal) bool

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.

func (*State) Output

func (s *State) Output() Output

Output is the capabilities and the product's rules as they stand, as copies.

func (*State) Record

func (s *State) Record() Record

Record is what consolidation did so far, with the capabilities whose text or terms changed.

func (*State) Refuse

func (s *State) Refuse(r Refusal)

Refuse records an item refused at step with its reason, for a caller whose own check refused it, such as the guard.

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.

Jump to

Keyboard shortcuts

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