Documentation
¶
Overview ¶
Package typedrec is the one typed parser: the home of every typed line a nova tool reads, the RESULT v2 record and DISPOSITION line first, and the Lua replies (the PATHS gate's refusal) and any other typed line with them. No other package compares a line's token to a bare word, builds a table of the tokens, or cuts a token's prefix: the class test TestOneTypedParser walks the tree for those shapes and skips this package because of that, not by accident.
Index ¶
- Constants
- Variables
- func CardPaths(read func(string) (string, bool)) []string
- func IsFullSha(s string) bool
- func IsKind(k string) bool
- func IsSha(s string) bool
- func JudgementFields(kind string) (fields, sections []string)
- func NamesADefect(finding string) bool
- func RequiredSections(kind string) []string
- func ResultFormat(kind string) string
- type CardResult
- type ContractDef
- type FieldEntry
- type TableCheck
- type TableMember
- type TableRefusal
Constants ¶
const ( ReqRequired = "R" // Required always ReqDone = "D" // Required when status is DONE ReqPass = "P" // Required when DONE and CHECK=pass, optional otherwise ReqUnknown = "-" // Unknown for this kind, refused )
Requirement codes in the contract.
const ( KindFix = "fix" KindRecut = "recut" KindPort = "port" KindDocsGuard = "docs-guard" KindReport = "report" KindRead = "read" )
Card kinds supported by v2 typedrec.
const ( DefectMissing = "missing" DefectMalformed = "malformed" )
Defects named in the specification.
const FindingPattern = `` /* 145-byte string literal not displayed */
FindingPattern is what a line of a broken read's finding must hold for the finding to name its defect (docs/SPEC-CARD-CONTRACT.md section 3): a file (a name with an extension, `a.go` too, so a path, or any name at file:line), a line (`line <n>`), or the rule the work breaks (the card's `STEP <n>`, or its RULES). An extension ends the name: a dot right after it (`e.g.`, `i.e.`) is an abbreviation, not a file. It is one POSIX extended expression, read the same by Go's regexp and by `grep -E` in the card's gh shim, so the shim refuses at the review what the member would hand back after it, and the sprint's read verb refuses what neither caught.
Variables ¶
var CardResultKeys = []string{"head", "branch", "verdict", "gate", "output", "report"}
CardResultKeys are the six keys a shaped card result carries.
var CardVerdicts = []string{"ok", "not-done", "nothing", "broken"}
CardVerdicts are the verdicts a card result may give.
var Contract = ContractDef{ Entries: []FieldEntry{ {Field: "line 1", Type: "card line 1 verbatim (else contradictory)", Fix: "R", Recut: "R", Port: "R", DocsGuard: "R", Report: "R", Read: "R"}, {Field: "line 2", Type: "`DONE` | `ABSTAIN <why>` | `BLOCKED <why>`; why is 1-512 B", Fix: "R", Recut: "R", Port: "R", DocsGuard: "R", Report: "R", Read: "R"}, {Field: "SCHEMA", Type: "literal `v2`", Fix: "R", Recut: "R", Port: "R", DocsGuard: "R", Report: "R", Read: "R"}, {Field: "KIND", Type: "enum of the 6; must equal the card's KIND", Fix: "R", Recut: "R", Port: "R", DocsGuard: "R", Report: "R", Read: "R"}, {Field: "ATTEMPT", Type: "int 1-99; must equal the card's attempt", Fix: "R", Recut: "R", Port: "R", DocsGuard: "R", Report: "R", Read: "R"}, {Field: "CHECK", Type: "`pass` | `fail` | `not-run`", Fix: "R", Recut: "R", Port: "R", DocsGuard: "R", Report: "R", Read: "R"}, {Field: "REPO", Type: "`owner/name`, `^[a-z0-9-]+/[a-z0-9._-]+$`; must equal the card's repo", Fix: "R", Recut: "R", Port: "R", DocsGuard: "R", Report: "R", Read: "R"}, {Field: "BRANCH", Type: "git ref (check-ref-format), ≤200 B; must equal the card's branch when it has one", Fix: "D", Recut: "D", Port: "D", DocsGuard: "D", Report: "O", Read: "-"}, {Field: "PATHS", Type: "1-256 whitespace-separated repo-relative paths; no `..`, no leading `/`, no duplicates", Fix: "D", Recut: "D", Port: "D", DocsGuard: "D", Report: "O", Read: "-"}, {Field: "RED", Type: "text 1-4096 B", Fix: "D", Recut: "D", Port: "D", DocsGuard: "-", Report: "-", Read: "-"}, {Field: "GREEN", Type: "text 1-4096 B", Fix: "P", Recut: "P", Port: "P", DocsGuard: "-", Report: "-", Read: "-"}, {Field: "PRIOR", Type: "`#<int> @<hex12>`", Fix: "-", Recut: "D", Port: "-", DocsGuard: "-", Report: "-", Read: "-"}, {Field: "PR", Type: "int", Fix: "-", Recut: "-", Port: "-", DocsGuard: "-", Report: "-", Read: "D"}, {Field: "HEAD", Type: "hex40; must equal the card's `pr_head`", Fix: "-", Recut: "-", Port: "-", DocsGuard: "-", Report: "-", Read: "D"}, {Field: "FINDINGS", Type: "int 0-999; must equal the number of `## Findings` rows", Fix: "-", Recut: "-", Port: "-", DocsGuard: "-", Report: "-", Read: "D"}, {Field: "FLOOR", Type: "`HIGH` | `MEDIUM` | `LOW` | `NONE`; `NONE` iff FINDINGS=0", Fix: "-", Recut: "-", Port: "-", DocsGuard: "-", Report: "-", Read: "D"}, {Field: "SUGGEST", Type: "`APPROVE` | `HOLD`: a suggestion, never a disposition", Fix: "-", Recut: "-", Port: "-", DocsGuard: "-", Report: "-", Read: "D"}, {Field: "PROBES", Type: "int ≥1; must equal the number of `## Probes` rows", Fix: "-", Recut: "-", Port: "-", DocsGuard: "-", Report: "D", Read: "-"}, {Field: "sections", Type: "required `## ` headings, each with at least one row", Fix: "Gates, Left owed", Recut: "Gates, Left owed", Port: "Gates, Left owed", DocsGuard: "Verification, Gates", Report: "Probes, Summary", Read: "Findings (rows = FINDINGS, the one zero-row case)"}, }, }
Contract is the canonical Go table defining RESULT v2.
var Kinds = []string{KindFix, KindRecut, KindPort, KindDocsGuard, KindReport, KindRead}
Kinds is the list of all 6 valid card kinds in canonical order.
var WrapperOwned = []string{"SCHEMA", "KIND", "ATTEMPT", "CHECK", "REPO", "BRANCH", "PATHS", "RED", "GREEN"}
WrapperOwned are the typed fields the wrapper writes. A model-written line for one of them is dropped: the wrapper's value is the record.
Functions ¶
func CardPaths ¶
CardPaths is the scope named by a card's PATHS and NEW fields, in that order. The reader supplies values from the card's strict typed header; an absent field, an empty comma-separated entry or none contributes no path.
func IsKind ¶
IsKind reports whether k is one of the declared Kinds. Every reader of a card or RESULT KIND checks it here before using it as a key.
func JudgementFields ¶
JudgementFields are what a DONE record of kind needs that the wrapper cannot know: the Contract fields the kind requires that are not WrapperOwned, and its required sections other than Gates and Left owed.
func NamesADefect ¶
NamesADefect says a broken read's finding names what is wrong: some line of it names a file, a line or the rule the work breaks. "Request changes." alone, or an approval's words under a broken verdict, names none.
func RequiredSections ¶
RequiredSections returns the required section names for kind.
func ResultFormat ¶
ResultFormat is the RESULT-FORMAT paragraph a worker's brief carries for a typed card of kind. It describes the two-line contract: the model writes line 1 (this card's line 1, verbatim) and line 2 (`DONE`, `ABSTAIN <why>` or `BLOCKED <why>`) and an optional note; the card wrapper writes every field it knows or computes (WrapperOwned, the Gates rows) into the record it validates (Synthesize). A kind whose DONE record needs something only the model can know (JudgementFields) names those too. It is "" for a kind outside Kinds.
Types ¶
type CardResult ¶
type CardResult struct {
Shaped bool // the six keys are present and head, verdict and report read
Head string
Branch string
Verdict string // a work card's ok, not-done or nothing; a read's ok or broken
Gate string
Output string
Report string
Title string
Body string
}
CardResult is a sprint card's RESULT.md in the card contract's shape (docs/SPEC-CARD-CONTRACT.md section 3): six `key: value` lines, an optional pull request title, and the text under `## Body`. It lives here with the other typed records, giving each record shape one parser.
func ParseCardResult ¶
func ParseCardResult(b []byte) CardResult
ParseCardResult reads a card result: the first `key: value` of each key, and the text under a `## Body` line as the body. A head of `-` is none.
type ContractDef ¶
type ContractDef struct {
Entries []FieldEntry
}
ContractDef represents the single source of truth for typedrec RESULT v2.
func (*ContractDef) FieldKeys ¶
func (c *ContractDef) FieldKeys() []string
FieldKeys returns the 16 typed field keys defined by the Contract.
func (*ContractDef) RequirementFor ¶
func (c *ContractDef) RequirementFor(field, kind string) string
RequirementFor returns the requirement code for a given field key and kind.
type FieldEntry ¶
type FieldEntry struct {
Field string
Type string
Fix string
Recut string
Port string
DocsGuard string
Report string
Read string
}
FieldEntry specifies one row of the contract table.
type TableCheck ¶
type TableCheck struct{ Epoch, Revision, Members, Cells uint64 }
TableCheck is the table maintenance function's RESP report. Counts are canonical decimal strings so uint64 values survive Lua and RESP exactly.
func ParseTableCheck ¶
func ParseTableCheck(reply []any) (TableCheck, error)
ParseTableCheck decodes the complete ns_table_check reply.
type TableMember ¶
TableMember is the atomic placement lookup reply; State distinguishes a missing identity from a real, unplaced member. Row and Column name an owned cell only when State is placed.
func ParseTableMember ¶
func ParseTableMember(reply []any) (TableMember, error)
type TableRefusal ¶
type TableRefusal int
TableRefusal identifies the classified refusal tag of a table Lua reply.
const ( TableRefusalUnknown TableRefusal = iota TableRefusalStale TableRefusalMemberEpoch TableRefusalMemberExists TableRefusalPlaced TableRefusalDrift TableRefusalNoTable TableRefusalExists TableRefusalNoRow TableRefusalNoCol TableRefusalText TableRefusalNotMember TableRefusalOccupiedValue TableRefusalOccupied TableRefusalOccupiedCells TableRefusalOwnedAlias TableRefusalNoMember TableRefusalNoView TableRefusalViewTable TableRefusalSummary TableRefusalSelf TableRefusalWhere TableRefusalColExists TableRefusalDepends TableRefusalLastCol TableRefusalSorted TableRefusalSortKey TableRefusalSortKeep TableRefusalNotText TableRefusalBound TableRefusalEpoch TableRefusalCondition TableRefusalArgs TableRefusalRevision TableRefusalMemberRevision TableRefusalFieldGuard TableRefusalOpConflict TableRefusalLimit TableRefusalReservedField TableRefusalTwice TableRefusalScore TableRefusalOverflow TableRefusalMutation TableRefusalManifest TableRefusalStreamFull TableRefusalSchema TableRefusalOperation TableRefusalMember TableRefusalWrongType TableRefusalStreamType TableRefusalEpochAhead TableRefusalPlaceGuard TableRefusalFormula TableRefusalPropGuard TableRefusalOrphan TableRefusalResidue )
func ParseTableRefusal ¶
func ParseTableRefusal(reason string) TableRefusal
ParseTableRefusal parses a raw table Lua reply reason token into a typed TableRefusal.