place

package
v0.0.26 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: 15 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 place puts each gathered PR and change on the capabilities that own most of its files. Placement is a fact of the footprints the walk stored and never a judgment: code weighs the files, with no agent call and no session, and the placements stay in init's record, never the map.

Index

Constants

View Source
const (
	NoFiles = "no files known from the gather"
	NoOwner = "none of its files belongs to a capability"
)

The reasons a PR or change is placed nowhere.

View Source
const Broad = 40

Broad is the most files a footprint's test, doc or other entry may name and still place: an entry naming more, such as a whole test folder, says nothing about one capability.

Variables

This section is empty.

Functions

func Text

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

Text writes what placement did in plain words, one count to a line, each reason named. It names no file but the broad entries it did not use.

Types

type BroadEntry

type BroadEntry struct {
	Capability string `json:"capability"`
	Kind       string `json:"kind"`
	Entry      string `json:"entry"`
	Files      int    `json:"files"`
}

BroadEntry is a footprint entry naming more than Broad files: kept in the footprint, not used to place.

type CapabilityPlaced

type CapabilityPlaced struct {
	Capability string   `json:"capability"`
	Area       string   `json:"area"`
	Parent     string   `json:"parent"`
	PRs        []int    `json:"prs"`
	Changes    []string `json:"changes"`
}

CapabilityPlaced is a capability, with its area and, when that area is a part, the area it was split from, and what is placed on it.

type ChangeNowhere

type ChangeNowhere struct {
	ID     string `json:"id"`
	PR     int    `json:"pr,omitempty"`
	Reason string `json:"reason"`
}

ChangeNowhere is a gathered change placed nowhere. PR is the gathered PR whose reason it carries, 0 when the reason is its own.

type ChangePlaced

type ChangePlaced struct {
	ID         string      `json:"id"`
	PR         int         `json:"pr,omitempty"`
	Placements []Placement `json:"placements"`
}

ChangePlaced is a gathered change with the capabilities it is placed on. PR is the gathered PR it follows, 0 when it is placed on its own.

type Loader

type Loader interface {
	Place() (initrecord.Place, bool, error)
}

Loader is the store as Load reads it.

type Nowhere

type Nowhere struct {
	PRs     []PRNowhere     `json:"prs"`
	Changes []ChangeNowhere `json:"changes"`
}

Nowhere is the PRs and changes placed on no capability, with the reason.

type PRNowhere

type PRNowhere struct {
	Number int    `json:"number"`
	Reason string `json:"reason"`
}

PRNowhere is a gathered PR placed nowhere.

type PRPlaced

type PRPlaced struct {
	Number     int         `json:"number"`
	Placements []Placement `json:"placements"`
}

PRPlaced is a gathered PR with the capabilities it is placed on.

type Placement

type Placement struct {
	Capability string  `json:"capability"`
	Weight     float64 `json:"weight"`
	Share      float64 `json:"share"`
}

Placement is one capability an item is placed on: the weight of the item's files there, and that weight's share of the item's whole weight.

type ReasonCount

type ReasonCount struct {
	Reason string `json:"reason"`
	Count  int    `json:"count"`
}

ReasonCount is how many items are placed nowhere for one reason.

type Record

type Record struct {
	// PRs and Changes are the placed ones, in gather order.
	PRs     []PRPlaced     `json:"prs"`
	Changes []ChangePlaced `json:"changes"`
	Nowhere Nowhere        `json:"nowhere"`
	// ByCapability is every capability of the walk, in walk order, with the
	// PRs placed on it and the changes placed there on their own.
	ByCapability []CapabilityPlaced `json:"by_capability"`
	Broad        []BroadEntry       `json:"broad_entries"`
	// WalkEntries is false when the walk was stored without its footprints'
	// entries, so each stored file placed as itself and none could be broad.
	WalkEntries  bool `json:"walk_entries"`
	FilesWeighed int  `json:"files_weighed"`
}

Record is the body init's record keeps for the placement, read back with Load. Its file paths are init's own and never reach the map.

func Load

func Load(st Loader) (Record, bool, error)

Load reads the stored placement and decodes its body, false when none exists.

type Result

type Result struct {
	Capabilities int `json:"capabilities"`
	PRsPlaced    int `json:"prs_placed"`
	// PRsNowhere and ChangesNowhere count each reason, both always listed.
	PRsNowhere []ReasonCount `json:"prs_nowhere"`
	// ChangesPlaced are the changes no gathered PR holds, placed on their
	// own; ChangesWithPR are those placed where their PR is.
	ChangesPlaced  int           `json:"changes_placed"`
	ChangesWithPR  int           `json:"changes_placed_with_pr"`
	ChangesNowhere []ReasonCount `json:"changes_nowhere"`
	// Without are the capabilities no PR or change is placed on.
	Without      Without      `json:"capabilities_without"`
	Broad        []BroadEntry `json:"broad_entries"`
	WalkEntries  bool         `json:"walk_entries"`
	FilesWeighed int          `json:"files_weighed"`
}

Result is what placement did, in counts.

func Run

func Run(st Store) (Result, error)

Run places every gathered PR and change by the stored footprints and stores the placement in init's record. It needs the walk and the gather, and says which phase to run when one is missing, before anything else.

type Store

type Store interface {
	Gathered() (store.Gather, bool, error)
	Areas() (initrecord.Areas, bool, error)
	Walk() (initrecord.Walk, bool, error)
	PutPlace(initrecord.Place) error
}

Store is init's record as Run reads and writes it.

type Without

type Without struct {
	Count int      `json:"count"`
	Names []string `json:"names"`
}

Without is the capabilities with no PR or change, in walk order.

Jump to

Keyboard shortcuts

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