status

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package status computes the ladders of a node (spec 04.8): H for the human proof, L for Lean, I for each language, V for the visualization and W for the writing.

Nobody writes a level by hand. Each level comes with the reasons that it is not higher, so that a page can say what it needs next.

Index

Constants

View Source
const MinScore = 0.85

MinScore is the mutation score of rule I04.

Variables

This section is empty.

Functions

func Hash

func Hash(path string) (string, error)

Hash is the hash that a review binds to: sha256 of the file, in hex.

func Lead

func Lead(body string) string

Lead returns the text before the first heading.

func LoadDecls

func LoadDecls(path string) (formal.Decls, error)

LoadDecls reads decls.jsonl. A missing file gives nil, which means that the Lean build did not run.

func LoadResults

func LoadResults(dir string) (map[string]map[string]Test, error)

LoadResults reads every build/results/*.json under dir. A missing dir gives no results.

func Reviewed

func Reviewed(root, tag, part, file string) (bool, string)

Reviewed tells if reviews/<tag>/<part>.yaml exists, approves, and binds to the current hash of file.

func Section

func Section(body, h string) string

Section returns the text of the level 2 section with the heading h, without the heading.

func Sections

func Sections(body string) []string

Sections returns the level 2 headings of the body, in order.

Types

type CaseFailure

type CaseFailure struct {
	Case   string `json:"case"`
	Reason string `json:"reason"`
	Got    string `json:"got,omitempty"`
	Want   string `json:"want,omitempty"`
}

CaseFailure is one shared case that failed, with the reason.

type Diff

type Diff struct {
	Problem string `json:"problem"`
	Cases   int    `json:"cases"`
	Passed  int    `json:"passed"`
	Skipped int    `json:"skipped,omitempty"`
	// Failures holds the shrunk failures, at most lang.MaxDiffFailures.
	Failures []CaseFailure `json:"failures,omitempty"`
	// Error is set when the run could not start, for example when the adapter does not build.
	Error string `json:"error,omitempty"`
}

Diff is the result of the differential run of one problem on one implementation.

type Env

type Env struct {
	Corpus  *node.Corpus
	Results map[string]map[string]Test // slug, then lang
	// VizChecked holds the scenes that passed `prog viz check` in this build, by slug, with the failures of the others.
	VizChecked map[string][]string
	// Decls holds the declarations that `prog lean build` extracted, or nil when it did not run.
	Decls formal.Decls
}

Env is what the ladders read besides the node.

type Mutation

type Mutation struct {
	// Mutants is the number of mutants of the sample, Ignored the number of them in mutants.ignore, and Killed the number of the others that the tests kill.
	Mutants int `json:"mutants"`
	Killed  int `json:"killed"`
	Ignored int `json:"ignored,omitempty"`
	// Survivors are the ids of the mutants that no test kills, as mutants.ignore writes them.
	Survivors []string `json:"survivors,omitempty"`
	// Error is set when the run could not start, or when the code fails its tests with no mutant.
	Error string `json:"error,omitempty"`
}

Mutation is the result of the mutation run of one implementation.

func (Mutation) Score

func (m Mutation) Score() float64

Score is the killed mutants divided by the mutants that are not ignored. A run with no mutant to count has the score 1.

type Results

type Results struct {
	Lang    string `json:"lang"`
	Version string `json:"version,omitempty"`
	// Kind is "diff" for the file <lang>.diff.json of the differential run, "mutate" for the file <lang>.mutate.json of the mutation run, and empty for the native tests and the shared cases.
	Kind  string `json:"kind,omitempty"`
	Tests []Test `json:"tests"`
}

Results is the content of one file build/results/<lang>.json.

type Review

type Review struct {
	Part     string `yaml:"part"`
	Hash     string `yaml:"hash"`
	Reviewer string `yaml:"reviewer"`
	Date     string `yaml:"date"`
	Verdict  string `yaml:"verdict"`
}

Review is a review record, reviews/<tag>/<part>.yaml (spec 13.2).

type Rung

type Rung struct {
	Level int      `json:"level"`
	Max   int      `json:"max"`
	Label string   `json:"label"` // for example "H2"
	Name  string   `json:"name"`  // for example "full proof"
	Next  []string `json:"next,omitempty"`
}

Rung is the level of one ladder, with the reasons that it is not higher.

func Writing

func Writing(n *node.Node, env Env) (r Rung)

Writing computes the W ladder from the sections, their content and the links (spec 06.8).

type Shared

type Shared struct {
	Problem    string `json:"problem"`
	Cases      int    `json:"cases"`
	Passed     int    `json:"passed"`
	Skipped    int    `json:"skipped,omitempty"`
	SkipReason string `json:"skip_reason,omitempty"`
	// SkipExpected is true when the language cannot run the skipped cases by design, as C cannot run T = string. Such a skip does not hold back I1.
	SkipExpected bool          `json:"skip_expected,omitempty"`
	Failures     []CaseFailure `json:"failures,omitempty"`
	// Error is set when the cases could not run, for example when the adapter does not build.
	Error string `json:"error,omitempty"`
}

Shared is the result of the shared cases of one problem on one implementation.

func (Shared) OK

func (s Shared) OK() bool

OK tells if every case that ran passed.

type Status

type Status struct {
	Slug  string          `json:"slug"`
	H     Rung            `json:"h"`
	L     Rung            `json:"l"`
	I     map[string]Rung `json:"i"`
	V     Rung            `json:"v"`
	W     Rung            `json:"w"`
	Tests map[string]Test `json:"tests,omitempty"`
}

Status is the set of ladders of one node.

func Of

func Of(n *node.Node, env Env) Status

Of computes the ladders of n.

type Test

type Test struct {
	Slug string `json:"slug"`
	Lang string `json:"lang"`
	// Pass tells if the native tests pass.
	Pass   bool   `json:"pass"`
	Output string `json:"output,omitempty"`
	Ms     int64  `json:"ms"`
	// Shared holds the results of the shared cases of each problem that the node solves (spec 09.2).
	Shared []Shared `json:"shared,omitempty"`
	// Diff holds the results of the differential run of each problem that the node solves (spec 09.5). It comes from the file <lang>.diff.json.
	Diff []Diff `json:"diff,omitempty"`
	// Mutation is the result of the mutation run (spec 09.6). It comes from the file <lang>.mutate.json.
	Mutation *Mutation `json:"mutation,omitempty"`
}

Test is the result of the native tests of one implementation, as `prog test` writes it.

func (Test) OK

func (t Test) OK() bool

OK tells if the native tests and the shared cases pass.

Jump to

Keyboard shortcuts

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