initreport

package
v0.0.37 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: Apache-2.0 Imports: 21 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 initreport gives the measures of an init run from init's record alone: files in a capability, shared and unclaimed; PRs and changes placed; PRs in one capability; capabilities with no PR or change; where the rules' reasons came from; consolidation's counts; and spend per phase. It reads the record with no session, no repo files, no forge and no environment. A measure whose inputs are not stored, are stale or cannot be read says why it can't be given and holds no number. It renders the measures as plain text, as a section of the PR body and as JSON, in counts and shares only: no file path, capability name or PR number reaches it.

Index

Constants

View Source
const SectionHeading = "## Measures"

SectionHeading is the PR body section's heading line.

Variables

This section is empty.

Functions

func Section

func Section(r Report) string

Section is the report as the PR body's section: its heading and a list, without spend, which the body's "Tokens spent" table holds.

func Text

func Text(r Report) string

Text is the report as plain text for the run's output: a first line, then one measure to a line, each detail indented under it, spend per phase last.

Types

type AnchorCount

type AnchorCount struct {
	Kind string `json:"kind"`
	Ratio
}

AnchorCount is the rules of one kind of anchor, a share of all rules.

type ConsolidationCounts

type ConsolidationCounts struct {
	CapabilityMerges       int `json:"capability_merges"`
	CapabilitiesMergedAway int `json:"capabilities_merged_away"`
	EntriesMergedExact     int `json:"entries_merged_exact"`
	EntriesMergedNear      int `json:"entries_merged_near"`
	Moved                  int `json:"rules_moved"`
	Dropped                int `json:"questions_dropped"`
	Lifted                 int `json:"rules_lifted"`
	Refused                int `json:"refused"`
	EntriesBefore          int `json:"entries_before"`
	EntriesAfter           int `json:"entries_after"`
	ProductRulesAfter      int `json:"product_rules_after"`
}

ConsolidationCounts is what the stored consolidation did.

type FileCounts

type FileCounts struct {
	SourceFiles  int   `json:"source_files"`
	InCapability Ratio `json:"in_a_capability"`
	Shared       Ratio `json:"shared"`
	Unclaimed    Ratio `json:"unclaimed"`
}

FileCounts is the areas' source files: owned by one walk capability, shared, or unclaimed, each a share of them all.

type Measure

type Measure[T any] struct {
	CantBeGiven string
	Value       *T
}

Measure is a measure's numbers in Value, or, when Value is nil, why it can't be given, marshalled as {"cant_be_given": why} and no number.

func (Measure[T]) MarshalJSON

func (m Measure[T]) MarshalJSON() ([]byte, error)

MarshalJSON writes the numbers, or only the reason they can't be given.

type Nowhere

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

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

type OneCounts

type OneCounts struct {
	Ratio
	LeftOut int `json:"left_out"`
}

OneCounts is the gathered PRs whose source files a capability owns all belong to one, of the PRs touching such a file, and the PRs left out.

type PhaseSpend

type PhaseSpend struct {
	Phase          string `json:"phase"`
	Input          int64  `json:"input"`
	CachedInput    int64  `json:"cached_input"`
	Output         int64  `json:"output"`
	WeightedTokens int64  `json:"weighted_tokens"`
	MicroUSD       *int64 `json:"micro_usd,omitempty"`
	Unpriced       bool   `json:"unpriced,omitempty"`
	Cost           string `json:"cost"`
}

PhaseSpend is one phase's raw tokens, weighted tokens and cost estimate. MicroUSD is left out when some of it has no price, and Cost says so.

type PlacedCounts

type PlacedCounts struct {
	PRs           Measure[PlacingCounts] `json:"prs"`
	Changes       Measure[PlacingCounts] `json:"changes_on_their_own"`
	FollowTheirPR int                    `json:"changes_following_their_pr"`
}

PlacedCounts is the gathered PRs placed, the changes no gathered PR holds placed on their own, and the changes that follow their PR.

type PlacingCounts

type PlacingCounts struct {
	Ratio
	Nowhere []Nowhere `json:"nowhere"`
}

PlacingCounts is items placed of those gathered, and those placed nowhere.

type Ratio

type Ratio struct {
	Count   int `json:"count"`
	Of      int `json:"of"`
	Percent int `json:"percent"`
}

Ratio is a count of a total that is not zero, and its whole percent.

type ReasonCounts

type ReasonCounts struct {
	Rules                  int            `json:"rules"`
	ByAnchor               []AnchorCount  `json:"by_anchor"`
	TestOnlyWithBecause    Measure[Ratio] `json:"test_only_with_because"`
	ProductRules           int            `json:"product_rules,omitempty"`
	ProductRulesNotCounted int            `json:"product_rules_not_counted,omitempty"`
	CapabilitiesNotCounted int            `json:"capabilities_not_counted,omitempty"`
}

ReasonCounts is the rules `--write` would write by the first kind of anchor that applies, every kind in order; ProductRules are among Rules.

type Report

type Report struct {
	Files         Measure[FileCounts]          `json:"files"`
	Placed        Measure[PlacedCounts]        `json:"placed"`
	OneCapability Measure[OneCounts]           `json:"prs_in_one_capability"`
	Unplaced      Measure[Ratio]               `json:"capabilities_with_no_pr_or_change"`
	Reasons       Measure[ReasonCounts]        `json:"rules_reasons"`
	Consolidation Measure[ConsolidationCounts] `json:"consolidation"`
	Spend         Measure[SpendCounts]         `json:"spend"`
}

Report is every measure of an init run.

func Load

func Load(ctx context.Context, st *initrecord.Store) Report

Load gives every measure of st's init record. It never fails as a whole: a measure whose inputs are missing, stale or unreadable says why instead.

func Part

func Part(ctx context.Context, st *initrecord.Store) (key, text string, v Report)

Part is st's report as one part of the run's output: the key it goes under in a --json document, its plain text and its JSON value.

type SpendCounts

type SpendCounts struct {
	Phases []PhaseSpend `json:"phases"`
	Total  PhaseSpend   `json:"total"`
}

SpendCounts is what each phase spent, in the store's order, and the total.

Jump to

Keyboard shortcuts

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