Documentation
¶
Overview ¶
Package conformance reports frontend behavior against pinned formula corpora.
The package is test infrastructure, not part of the rendering pipeline. It evaluates each case under default and explicit resource limits, validates the resulting IR, and records a stable disposition for every input. The reporting model is dialect-neutral so TeX and Typst share evaluation, process isolation, policy, and reporting without sharing parser or layout code.
Index ¶
- Variables
- func CheckCorpusSet(report *Report) error
- func CheckTypstCorpusSet(report *Report) error
- func CompareReports(want, got *Report) string
- func ExplicitTeXLimits() source.Limits
- func ExplicitTypstLimits() source.Limits
- func RunWorker(frontend FrontendFunc, input io.Reader, output io.Writer) error
- func TeXCaseIDs(report *Report) []string
- func TypstCaseIDs(report *Report) []string
- type CaseReport
- type CorpusSummary
- type DiagnosticRef
- type Dialect
- type Evaluator
- type ExpectationKind
- type FamilySummary
- type FrontendFunc
- type FrontendResult
- type IRSummary
- type Input
- type LimitProfiles
- type LimitValues
- type Policy
- type PolicyRule
- type ProcessConfig
- type Report
- type Request
- type ReviewKind
- type Status
- type SuiteOptions
- type Summary
Constants ¶
This section is empty.
Variables ¶
var ErrFrontendTimeout = errors.New("frontend evaluation timed out")
ErrFrontendTimeout identifies a frontend call that exceeded its per-run budget. Frontends should honor ctx themselves; this guard also contains older APIs that cannot yet be canceled cooperatively.
Functions ¶
func CheckCorpusSet ¶
CheckCorpusSet verifies that a report contains exactly the expected TeX corpora. It avoids treating a partial report as a successful suite.
func CheckTypstCorpusSet ¶
CheckTypstCorpusSet rejects partial or unexpectedly expanded Typst suites.
func CompareReports ¶
CompareReports returns the first stable difference between two reports.
func ExplicitTeXLimits ¶
ExplicitTeXLimits is deliberately distinct from DefaultLimits. It is large enough for every tracked formula while still bounding the parser much more tightly than an unbounded configuration.
func ExplicitTypstLimits ¶
ExplicitTypstLimits is distinct from DefaultLimits and large enough for every imported selected Typst case, including the parser-depth stress records. MaxNesting intentionally matches the default because those records cross the default boundary; the other tighter budgets still prove parity is not accidental.
func RunWorker ¶
RunWorker executes one frontend request using a process-safe protocol. The report commands and conformance tests use this entry point for isolation.
func TeXCaseIDs ¶
TeXCaseIDs returns a stable copy of all evaluated case keys.
func TypstCaseIDs ¶
TypstCaseIDs returns the stable sorted case keys in a Typst report.
Types ¶
type CaseReport ¶
type CaseReport struct {
ID string `json:"id"`
Corpus string `json:"corpus"`
Index int `json:"index"`
Status Status `json:"status"`
Review ReviewKind `json:"review,omitempty"`
Reason string `json:"reason,omitempty"`
Families []string `json:"families"`
Commands []string `json:"commands,omitempty"`
Environments []string `json:"environments,omitempty"`
Codes []source.Code `json:"codes,omitempty"`
Diagnostics []DiagnosticRef `json:"diagnostics,omitempty"`
Detail string `json:"detail,omitempty"`
// contains filtered or unexported fields
}
CaseReport is the stable, source-independent record for one corpus case.
func (CaseReport) Key ¶
func (r CaseReport) Key() string
Key uniquely identifies a report case across corpora.
type CorpusSummary ¶
CorpusSummary identifies one corpus and its expected case count.
type DiagnosticRef ¶
type DiagnosticRef struct {
Code source.Code `json:"code"`
Severity source.Severity `json:"severity"`
Start int `json:"start"`
End int `json:"end"`
Message string `json:"message"`
}
DiagnosticRef is a compact diagnostic representation. It intentionally excludes free-form hints, which are not part of the conformance contract.
type Evaluator ¶
type Evaluator struct {
Frontend FrontendFunc
ExplicitLimits source.Limits
Timeout time.Duration
}
Evaluator repeats one frontend, checks both limit profiles, and verifies the IR, diagnostics, source ranges, and canonical-output contracts.
type ExpectationKind ¶
type ExpectationKind string
ExpectationKind describes only whether the upstream case is supposed to parse or to produce a recoverable diagnostic. Exact diagnostic codes are frozen by the reviewed baseline, not by the frontend under test.
const ( ExpectParse ExpectationKind = "parse" ExpectDiagnostic ExpectationKind = "diagnostic" )
type FamilySummary ¶
FamilySummary counts cases containing one explicit command, environment, or lexical feature family.
type FrontendFunc ¶
type FrontendFunc func(context.Context, Request) (FrontendResult, error)
FrontendFunc evaluates one request under the supplied limits. Frontends share this boundary without sharing parser or layout code.
func ProcessFrontend ¶
func ProcessFrontend(config ProcessConfig) FrontendFunc
ProcessFrontend returns a frontend that communicates with one worker process per evaluation over stdin/stdout.
type FrontendResult ¶
type FrontendResult struct {
Root ir.Node
Tags []ir.EquationTag
Diagnostics []source.Diagnostic
Observation *IRSummary
}
FrontendResult is the observation returned by a parser adapter.
func ParseTeX ¶
func ParseTeX(_ context.Context, request Request) (FrontendResult, error)
ParseTeX adapts the TeX frontend to the dialect-neutral executor. TeX preambles are not part of the imported corpus and are intentionally ignored.
func ParseTypst ¶
func ParseTypst(ctx context.Context, request Request) (FrontendResult, error)
ParseTypst adapts the Typst frontend to the dialect-neutral executor.
type IRSummary ¶
IRSummary is the serializable part of an IR observation used by isolated workers. When present, it replaces Root for validation and parity checks.
type Input ¶
type Input struct {
Corpus string
ID string
Index int
Source string
Preamble string
Mode ir.Mode
Expect ExpectationKind
ExpectCode []source.Code
ExpectSpan *source.Range
Dialect Dialect
Families []string
}
Input is one dialect-neutral conformance case.
type LimitProfiles ¶
type LimitProfiles struct {
Default LimitValues `json:"default"`
Explicit LimitValues `json:"explicit"`
}
LimitProfiles records both limit configurations exercised for every case.
type LimitValues ¶
type LimitValues struct {
MaxSourceBytes int `json:"maxSourceBytes"`
MaxTokens int `json:"maxTokens"`
MaxNesting int `json:"maxNesting"`
MaxNodes int `json:"maxNodes"`
MaxMacroExpansions int `json:"maxMacroExpansions"`
MaxExpandedTokens int `json:"maxExpandedTokens"`
MaxCallDepth int `json:"maxCallDepth"`
MaxTableCells int `json:"maxTableCells"`
MaxAssemblyRepeats int `json:"maxAssemblyRepeats"`
MaxTextBytes int `json:"maxTextBytes"`
MaxOutputItems int `json:"maxOutputItems"`
MaxPathSegments int `json:"maxPathSegments"`
MaxDimension int64 `json:"maxDimension"`
}
LimitValues is the stable JSON representation of source.Limits.
type Policy ¶
type Policy struct {
SchemaVersion int `json:"schemaVersion"`
DiagnosticExpectations []PolicyRule `json:"diagnosticExpectations,omitempty"`
Exclusions []PolicyRule `json:"exclusions,omitempty"`
KnownGaps []PolicyRule `json:"knownGaps,omitempty"`
// contains filtered or unexported fields
}
Policy is the reviewed, data-driven set of scope exclusions and known gaps. Rules must identify cases by explicit IDs or source families; broad status heuristics are intentionally unavailable.
func LoadPolicy ¶
LoadPolicy loads and validates reviewed disposition data.
type PolicyRule ¶
type PolicyRule struct {
IDs []string `json:"ids,omitempty"`
Families []string `json:"families,omitempty"`
Codes []source.Code `json:"codes,omitempty"`
Reason string `json:"reason"`
Corpus string `json:"corpus"`
}
PolicyRule matches within one corpus. Fields are ANDed across dimensions and ORed within each list.
type ProcessConfig ¶
ProcessConfig describes an isolated frontend worker. Every case receives a fresh process, so a non-cooperative parser hang or fatal failure cannot poison the rest of the conformance run.
type Report ¶
type Report struct {
SchemaVersion int `json:"schemaVersion"`
Dialect Dialect `json:"dialect"`
Corpora []CorpusSummary `json:"corpora"`
Limits LimitProfiles `json:"limits"`
Summary Summary `json:"summary"`
Families []FamilySummary `json:"families"`
Cases []CaseReport `json:"cases"`
}
Report is the deterministic result for one dialect and its corpora.
func BuildTeXReport ¶
func BuildTeXReport(ctx context.Context, options SuiteOptions) (*Report, error)
BuildTeXReport evaluates the tracked RaTeX and selected KaTeX corpora.
func BuildTypstReport ¶
func BuildTypstReport(ctx context.Context, options SuiteOptions) (*Report, error)
BuildTypstReport evaluates every imported selected Typlet Typst corpus.
func LoadReport ¶
LoadReport loads a strict reviewed baseline.
func (*Report) CanonicalJSON ¶
CanonicalJSON returns deterministic reviewed-baseline JSON.
type ReviewKind ¶
type ReviewKind string
ReviewKind records why a non-passing case is accepted in a reviewed baseline. An empty review on a non-passing case is an unexplained failure.
const ( ReviewUpstream ReviewKind = "upstream-diagnostic" ReviewScope ReviewKind = "scope-exclusion" ReviewGap ReviewKind = "known-gap" )
type SuiteOptions ¶
type SuiteOptions struct {
FixtureRoot string
PolicyPath string
Frontend FrontendFunc
ExplicitLimits source.Limits
CaseTimeout time.Duration
}
SuiteOptions selects tracked inputs and reviewed disposition data.