~/bend-docscommunity

src/rules/laws/trace.bend checks

raw source on the hub · import bolt@1.18.0.0/src/rules/laws/trace.bend as Trace

rule trace (project-wide, opt-in): SPEC.md and the laws agree. SPEC.md, read from the directory bolt runs in, lists requirements in tables whose header is exactly | ID | Requirement | Level | Status | Law |, and trust rows in tables headed | ID | Assumption | Why it is trusted |. An ID is uppercase letters and digits in two or more segments joined by - (BOLT-CFG-1); a law proves one when a line of its comment block is exactly that ID (# BOLT-CFG-1). A Proved row, proved or pending, is a claim: a proved row's Law cell names the laws that prove it, and a pending row's may name laws that prove part of it while the row stays pending. The findings: a row that is not a well-formed requirement or trust row, an ID that does not match the pattern included; an ID listed twice; a proved row whose Law cell names no law; a Trusted row that names a law; a Law entry of a Proved row, proved or pending, whose law is missing, has no for/exs binder, or lacks the row's tag; a Trusted row with no trust row; and a tag naming an ID SPEC.md does not list as Proved, proved or pending. A Law entry is <path> <law>, the path relative to SPEC.md, entries joined by ; . Only a bolt.bend that names the rule turns it on (src/config.bend). It runs only when bolt lints the whole tree, never over files named on the line.

6 imports
import Base
import ../../finding.bend as F
import ../digest.bend as Digest
import ../imports.bend as Imports
import ../../lazy/lazy.bend as Lazy
import ../../rchars.bend as Rchars

Types

type Row source · line 31 · raw

Data

one requirement row: its ID, level and status, the Law cell's entries, and its line (0-based)

type Mark source · line 35 · raw

Data

an ID, or a reason, at a line

type Mode source · line 40 · raw

Data

which table the lines are in; Head is the header row, whose | :-- | line comes next

type Spec source · line 49 · raw

Data

what SPEC.md says: the requirement rows, the trust rows, the rows that are not well formed (why, where), each list in reverse file order while read

type Cells source · line 66 · raw

Data

a table line read so far: the cell being read and the cells before it, each backwards

Definitions

def req_head source · line 53 · raw

String

the requirement table's header

def trust_head source · line 57 · raw

String

the trust table's header

def trim source · line 61 · raw

@+ss:String -> String

a cell's text, spaces trimmed

def cells.at source · line 70 · raw

@bar:Bool -> @cc:Char -> @st:Cells -> Cells

one char onto the cells read: a bar ends the cell, any other char extends it

def cells.go source · line 82 · raw

@cs:List<&2, Char> -> @esc:Bool -> @st:Cells -> List<&2, String>

the cells of a table line, split at every | that does not follow a \ (an escaped \|); esc says the char before was a \. It matches no char pattern, so the proofs can take a char apart by what Char.is_eq says of it

def cells source · line 91 · raw

@+line:String -> List<&2, String>

the cells between a line's outer bars

def cell source · line 96 · raw

@+cs:List<&2, String> -> @ii:Nat -> String

the i-th cell, or empty

def entries.go source · line 99 · raw

@ss:List<&2, String> -> List<&2, String>

def entries source · line 108 · raw

@ss:String -> List<&2, String>

a Law cell's entries

def add_req source · line 112 · raw

@+line:String -> @+nn:U32 -> @st:Spec -> Spec

a requirement row onto the spec, or a malformed one

def add_trust source · line 120 · raw

@+line:String -> @+nn:U32 -> @st:Spec -> Spec

a trust row onto the spec, or a malformed one

def moved source · line 128 · raw

@st:Spec -> @mm:Mode -> Spec

the spec in another mode

def in_table source · line 133 · raw

@mode:Mode -> @+line:String -> @+nn:U32 -> @st:Spec -> Spec

a line inside a table: the header's | :-- | line, a row, or the end

def mode_of source · line 147 · raw

@st:Spec -> Mode

the mode a spec is in

def step source · line 152 · raw

@+line:String -> @+nn:U32 -> @+st:Spec -> Spec

one line of SPEC.md onto what it says

def parse.go source · line 159 · raw

@ls:List<&2, String> -> @+nn:U32 -> @st:Spec -> Spec

def parse source · line 167 · raw

@text:String -> Spec

what SPEC.md's text says

def id_char source · line 174 · raw

@cc:Char -> Bool

is the char an uppercase letter or a digit?

def id_chars source · line 179 · raw

@cs:List<&2, Char> -> Bool

is every char an uppercase letter or a digit?

def segment source · line 187 · raw

@+ss:String -> Bool

is every char of the segment an uppercase letter or a digit, and is there one?

def segments source · line 191 · raw

@ss:List<&2, String> -> Bool

is every segment well formed?

def lettered source · line 199 · raw

@+ss:String -> Bool

does the ID start with a letter?

def is_id source · line 205 · raw

@+ss:String -> Bool

is the text an ID: [A-Z][A-Z0-9]*(-[A-Z0-9]+)+?

def at source · line 213 · raw

@+nn:U32 -> @msg:String -> 0x35f17b35555be5fc1e2ec2480b52b92a/src/finding.Finding

a finding in SPEC.md

def rows_with source · line 217 · raw

@rs:List<&2, Row> -> @+id:String -> Nat

how many rows have this ID (a Nat, so the count is the same in any order)

def marks_with source · line 226 · raw

@ms:List<&2, Mark> -> @+id:String -> Nat

how many trust rows have this ID

def laws_file source · line 235 · raw

@ds:List<&2, 0x35f17b35555be5fc1e2ec2480b52b92a/src/rules/digest.Digest> -> @+pp:String -> Maybe<&2, List<&2, 0x35f17b35555be5fc1e2ec2480b52b92a/src/rules/digest.Law>>

the digest of a LAWS.bend at a path, when it was read

def law_named source · line 244 · raw

@ls:List<&2, 0x35f17b35555be5fc1e2ec2480b52b92a/src/rules/digest.Law> -> @+name:String -> Maybe<&2, 0x35f17b35555be5fc1e2ec2480b52b92a/src/rules/digest.Law>

the law of that name

def tagged source · line 252 · raw

@doc:List<&2, String> -> @+id:String -> Bool

is the ID one of the doc lines?

def judge_law source · line 260 · raw

@mm:Maybe<&2, 0x35f17b35555be5fc1e2ec2480b52b92a/src/rules/digest.Law> -> @+id:String -> @+entry:String -> @+nn:U32 -> List<&2, 0x35f17b35555be5fc1e2ec2480b52b92a/src/finding.Finding>

what is wrong with the law a Proved row names, found or not

def judge_file source · line 271 · raw

@mm:Maybe<&2, List<&2, 0x35f17b35555be5fc1e2ec2480b52b92a/src/rules/digest.Law>> -> @+name:String -> @+id:String -> @+entry:String -> @+nn:U32 -> List<&2, 0x35f17b35555be5fc1e2ec2480b52b92a/src/finding.Finding>

the law file of an entry, then the law in it

def judge_entry source · line 285 · raw

@+ds:List<&2, 0x35f17b35555be5fc1e2ec2480b52b92a/src/rules/digest.Digest> -> @+id:String -> @+entry:String -> @+nn:U32 -> List<&2, 0x35f17b35555be5fc1e2ec2480b52b92a/src/finding.Finding>

one Law entry of a Proved row: <path> <law>

def judge_entries source · line 293 · raw

@es:List<&2, String> -> @+ds:List<&2, 0x35f17b35555be5fc1e2ec2480b52b92a/src/rules/digest.Digest> -> @+id:String -> @+nn:U32 -> List<&2, 0x35f17b35555be5fc1e2ec2480b52b92a/src/finding.Finding>

every Law entry of a Proved row

def claims source · line 301 · raw

@+lv:String -> @+st:String -> Bool

is the row a claim: Proved, and proved or pending?

def shape source · line 305 · raw

@+lv:String -> @+st:String -> @+ls:List<&2, String> -> String

what is wrong with a row's level, status and Law cell

def judge_row source · line 315 · raw

@rr:Row -> @+sp:Spec -> @+ds:List<&2, 0x35f17b35555be5fc1e2ec2480b52b92a/src/rules/digest.Digest> -> List<&2, 0x35f17b35555be5fc1e2ec2480b52b92a/src/finding.Finding>

every finding of one requirement row

def judge_rows source · line 328 · raw

@rs:List<&2, Row> -> @+sp:Spec -> @+ds:List<&2, 0x35f17b35555be5fc1e2ec2480b52b92a/src/rules/digest.Digest> -> List<&2, 0x35f17b35555be5fc1e2ec2480b52b92a/src/finding.Finding>

every finding of every requirement row

def claimed source · line 336 · raw

@rs:List<&2, Row> -> @+id:String -> Bool

is the ID a row that is a claim: Proved, and proved or pending?

def stray source · line 344 · raw

@doc:List<&2, String> -> @+rs:List<&2, Row> -> @+path:String -> @+name:String -> @+ll:U32 -> List<&2, 0x35f17b35555be5fc1e2ec2480b52b92a/src/finding.Finding>

the tags of a law SPEC.md does not list as Proved, proved or pending

def strays.laws source · line 361 · raw

@ls:List<&2, 0x35f17b35555be5fc1e2ec2480b52b92a/src/rules/digest.Law> -> @+rs:List<&2, Row> -> @+path:String -> List<&2, 0x35f17b35555be5fc1e2ec2480b52b92a/src/finding.Finding>

def strays source · line 369 · raw

@ds:List<&2, 0x35f17b35555be5fc1e2ec2480b52b92a/src/rules/digest.Digest> -> @+rs:List<&2, Row> -> List<&2, 0x35f17b35555be5fc1e2ec2480b52b92a/src/finding.Finding>

every stray tag of every law file

def malformed source · line 377 · raw

@ms:List<&2, Mark> -> List<&2, 0x35f17b35555be5fc1e2ec2480b52b92a/src/finding.Finding>

the rows that are not rows

def twins source · line 385 · raw

@ms:List<&2, Mark> -> @+all:List<&2, Mark> -> List<&2, 0x35f17b35555be5fc1e2ec2480b52b92a/src/finding.Finding>

every trust row whose ID is not an ID, or is listed twice

def check.spec source · line 396 · raw

@+sp:Spec -> @+ds:List<&2, 0x35f17b35555be5fc1e2ec2480b52b92a/src/rules/digest.Digest> -> List<&2, 0x35f17b35555be5fc1e2ec2480b52b92a/src/finding.Finding>

the rule over a SPEC.md that was read

def check.at source · line 402 · raw

@mm:Maybe<&2, String> -> @+ds:List<&2, 0x35f17b35555be5fc1e2ec2480b52b92a/src/rules/digest.Digest> -> List<&2, 0x35f17b35555be5fc1e2ec2480b52b92a/src/finding.Finding>

the rule over SPEC.md's text (None when there is none) and every file read

def check source · line 411 · raw

@whole:Bool -> @mm:Maybe<&2, String> -> @+ds:List<&2, 0x35f17b35555be5fc1e2ec2480b52b92a/src/rules/digest.Digest> -> List<&2, 0x35f17b35555be5fc1e2ec2480b52b92a/src/finding.Finding>

the rule, when bolt lints the whole tree; a run over the files named on the line holds only some of the laws, so it has nothing sound to check