diffcheck

package
v1.2.11 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package diffcheck is the lander's mechanical checks of one card's diff, the two the calibration of the decide read found a model read does not make (docs/SPEC-SPRINT.md section 7, the lander's checks): every file the diff changes is one the card's PATHS names (E12), and no changed line leaves a stranded sentence fragment or an unmatched backquote beside it (E4). Both read the unified diff alone, as git prints it; no model, no repository, no network.

Index

Constants

View Source
const (
	UpdateEnv    = "NOVA_CI_UPDATE"
	UpdatedRerun = "updated, rerun"
)

UpdateEnv is the variable that turns the class tests' ledger checks into a rewrite (internal/ci/allowlist): only the value "1" does. UpdatedRerun is the sentence the one failure of a run that rewrote carries. The lander runs that update to regenerate the ledgers at a merge, and reads its result by these.

View Source
const CatalogFile = "internal/docs/catalog.go"

CatalogFile is the hand-written catalog a card that adds a directory may add a row to (internal/docs/catalog.go; docs/SPEC-SPRINT.md section 7, land-e12-catalog-rows).

View Source
const LedgerDir = "internal/ci/testdata/"

The class ledgers a card may update beyond its PATHS (the cards' own words: "Those ledger files are the only files beyond PATHS you may change"): under LedgerDir, a list file named as internal/ci spells its lists (allowlist_update_test.go, listFilePatterns, and the deleted-tests ledger) or a .txt shard of one of its counted-ledger directories (countedShardDirectories). The class tests' fixtures beside them are not ledgers.

Variables

View Source
var AgentsMapRoots = []string{
	"AGENTS.md",
	"cmd/AGENTS.md",
	"docs/AGENTS.md",
	"internal/AGENTS.md",
	"internal/ghevent/AGENTS.md",
	"tools/AGENTS.md",
}

AgentsMapRoots are the maps tools/agentsmap writes from the catalog's pages. The lander regenerates them at a merge (docs/SPEC-SPRINT.md section 7, land-e12-catalog-rows).

View Source
var GeneralityRoots = []string{LedgerDir + "generality", LedgerDir + "generality-text", LedgerDir + "generality_text_fixtures_allowlist.txt"}

GeneralityRoots are where the generality ledgers live: the shard directories of the Go scan and the text scan, and the text scan's fixtures allowlist. Their update run (TestGeneralityGuardrail and TestGeneralityText) rewrites all three.

Functions

func AgentsMap

func AgentsMap(p string) bool

AgentsMap says p is an AGENTS.md map tools/agentsmap writes: the root page, or a directory's page. docs/STANDARD.md is not one.

func GeneralityLedger

func GeneralityLedger(p string) bool

GeneralityLedger says p is a generality ledger: a class ledger (Ledger: a .txt shard or a list file, never a directory, a Go file or a class test's fixture) under one of the GeneralityRoots. The lander regenerates these at a merge (docs/SPEC-SPRINT.md section 7).

func Ledger

func Ledger(p string) bool

Ledger says p is a class ledger (LedgerDir).

func Outside

func Outside(paths []string, diff string, trackedBefore []string) []string

Outside is every file the diff changes that the card may not (E12); nil when paths is empty (a card that names no PATHS is held to none). A file is the card's when its PATHS globs name it or it is a ledger (Ledger). A rename holds both sides: the file it moves from is the card's, and the file it moves to is the card's too or stays in the directory it was in (a name card renames a file in place). A rename out of a PATHS file to anywhere else, and a file moved into the ledgers' directory, are outside.

trackedBefore is the tree the merge lands on: the paths git tracks before it. nil is an unknown tree, and then nothing is exempt. A directory that holds no tracked file before, under which the diff adds a file the card's PATHS name (the file, or that directory), is a new directory the card adds: CatalogFile is then the card's when its change is added lines only, each a row naming one of those directories, and every AGENTS.md map is the card's. Any other change to the catalog, or a map change from a card that adds no directory, stays outside (docs/SPEC-SPRINT.md section 7, land-e12-catalog-rows).

Types

type File

type File struct {
	Old, New string
	Hunks    []Hunk
}

File is one file of a diff: its path before and after (equal unless renamed; a created or deleted file names the side it has on both) and its hunks.

func Parse

func Parse(diff string) []File

Parse reads a unified git diff (git diff, with or without -M).

type Finding

type Finding struct {
	File string
	Line int // the new side's line
	Why  string
}

Finding is one place a changed line breaks the text beside it.

func Fragments

func Fragments(diff string) []Finding

Fragments is every stranded fragment and unmatched backquote the diff leaves in prose (E4): a Go comment, or a line of a Markdown or text file. A block is a run of changed lines in a hunk, and it is read against the line before it:

  • the block takes away a number of backquotes of one parity and puts back the other, so a code span beside it is left open;
  • the line before it ends mid-sentence (on a letter, a digit or a comma, and not on a word that opens a sentence, as "The" does), the old text went on with a word that does not open a sentence, and the new text goes on with one that does (a capital and lower case after it: The, An, A): the sentence before the block is left without its end.

func (Finding) String

func (f Finding) String() string

type Hunk

type Hunk struct {
	NewStart int
	Lines    []string
}

Hunk is one @@ section: the new side's first line number and its lines, each with its marker (' ', '-' or '+').

Jump to

Keyboard shortcuts

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