consolidate

package
v0.0.32 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: 32 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 consolidate is init's consolidation phase: over the capabilities recovered from the walk, sessions judge which capabilities from different areas are one promise, then which entries of one area repeat each other, are misplaced or are answered, then which rules repeated across areas are one rule the product keeps. Code applies each choice by id, refusing and reporting what fails a check, so a session's words never reach the map. What it did is stored in init's record, with the consolidated capabilities and the product's rules, only when a final guard finds every entry sourced and nothing lost; nothing reaches the repo or the map here.

Index

Constants

View Source
const (
	Concurrency = 3
	LiftBatch   = 40
	StepMerge   = consolidating.StepMerge
	StepArea    = consolidating.StepArea
	StepLift    = consolidating.StepLift
)

Concurrency is the most sessions running at once, LiftBatch the most candidate groups one lift session is given, and the steps are those a session runs for, as Result's sessions name them.

Variables

This section is empty.

Functions

func Current

func Current(st *initrecord.Store) (bool, error)

Current says whether a consolidation is stored and still matches what it was made from: the recovered rows of the walk eligible now, the walk and the product's promise. Any later recovery, of one more capability too, makes it stale.

func Text

func Text(w io.Writer, r Result) error

Text writes what consolidation did in plain lines: the counts before and after, the pre-pass's slug renames and term conflicts, the capabilities merged with their renamed slugs, the exact and session merges of entries, moves, dropped questions, lifts, every refusal with its reason, the capabilities left as recovered, the sessions and the model.

Types

type Capability

type Capability struct {
	Name       string               `json:"name"`
	Promise    string               `json:"promise"`
	Area       capabilitytext.Area  `json:"area"`
	MergedFrom []string             `json:"merged_from"`
	Footprint  recovering.Footprint `json:"footprint"`
	File       string               `json:"file"`
	Terms      string               `json:"terms"`
	SessionID  string               `json:"session_id"`
}

Capability is a consolidated capability: one whose text or terms consolidation changed, with the capabilities merged into it.

type Counts

type Counts struct {
	Capabilities int `json:"capabilities"`
	Entries      int `json:"entries"`
	ProductRules int `json:"product_rules"`
}

Counts is how many capabilities, entries and product rules there were.

type MergedAway

type MergedAway struct {
	Name      string               `json:"name"`
	Into      string               `json:"into"`
	SessionID string               `json:"session_id"`
	Dropped   []recovering.Dropped `json:"dropped"`
}

MergedAway is a capability merged into another: the session of its recovery and the entries that recovery dropped, so a write keeps both.

type Result

type Result struct {
	// Fingerprint is a hash of what it was made from: every recovered row
	// it read, the walk's time and the product's promise.
	Fingerprint    string    `json:"fingerprint"`
	WalkAt         time.Time `json:"walk_at"`
	ProductPromise string    `json:"product_promise"`
	// Capabilities are the consolidated ones in walk order, and Left the
	// names of those left as recovered.
	Capabilities []Capability         `json:"capabilities"`
	Left         []string             `json:"left_as_recovered"`
	MergedAway   []MergedAway         `json:"merged_away"`
	ProductRules []string             `json:"product_rules"`
	Record       consolidating.Record `json:"record"`
	Before       Counts               `json:"before"`
	After        Counts               `json:"after"`
	Sessions     []SessionRun         `json:"sessions"`
	Model        string               `json:"model"`
	Tokens       adapter.Tokens       `json:"tokens"`
}

Result is what consolidation did, as init's record stores it and the phase shows it. Its exit code (ExitCode) is 0 when every session answered and 1 when any session's step was left as it was; an error from Run, with nothing stored, is 2.

func Load

func Load(st *initrecord.Store) (Result, bool, error)

Load reads the stored consolidation, false when none is stored.

func Run

func Run(ctx context.Context, st *initrecord.Store, s Session) (Result, error)

Run is init's consolidation of the rows recovered from the stored walk, never of a stored consolidation: a session chooses which candidate groups of capabilities are one promise and code merges them; code merges exact duplicates; one session per area merges, moves and drops entries by id; sessions choose which rules repeated across areas the product's rules take. A session that fails or cannot be read leaves its step's items as they were, reported. One consolidation is stored only when the guard and the map check's form hold; otherwise, when ctx is cancelled or the cap stopped a session (s.Stopped), nothing is stored and the error says why. With no error, the exit code is the Result's ExitCode (0, or 1 when any step was left as it was); an error is exit code 2.

func (Result) ExitCode

func (r Result) ExitCode() int

ExitCode is 1 when any session's step was left as it was, else 0; refused items alone do not change it.

type Session

type Session struct {
	Agent    func() (adapter.Adapter, error)
	Stopped  func() bool
	Root     string
	Product  string
	Progress io.Writer
	Now      func() time.Time
}

Session is the agent, the root the map's `from` anchors resolve in, the product's name, progress, the clock, and whether the cap has stopped a session.

type SessionRun

type SessionRun struct {
	Step     string   `json:"step"`
	Item     string   `json:"item"`
	IDs      []string `json:"ids"`
	Answered bool     `json:"answered"`
	Error    string   `json:"error,omitempty"`
}

SessionRun is one session consolidation ran: its step, what it judged, the ids it ran under, and whether it answered or why not.

Jump to

Keyboard shortcuts

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