conformance

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: Apache-2.0, MIT Imports: 20 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

Constants

This section is empty.

Variables

View Source
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

func CheckCorpusSet(report *Report) error

CheckCorpusSet verifies that a report contains exactly the expected TeX corpora. It avoids treating a partial report as a successful suite.

func CheckTypstCorpusSet

func CheckTypstCorpusSet(report *Report) error

CheckTypstCorpusSet rejects partial or unexpectedly expanded Typst suites.

func CompareReports

func CompareReports(want, got *Report) string

CompareReports returns the first stable difference between two reports.

func ExplicitTeXLimits

func ExplicitTeXLimits() source.Limits

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

func ExplicitTypstLimits() source.Limits

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

func RunWorker(frontend FrontendFunc, input io.Reader, output io.Writer) error

RunWorker executes one frontend request using a process-safe protocol. The report commands and conformance tests use this entry point for isolation.

func TeXCaseIDs

func TeXCaseIDs(report *Report) []string

TeXCaseIDs returns a stable copy of all evaluated case keys.

func TypstCaseIDs

func TypstCaseIDs(report *Report) []string

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

type CorpusSummary struct {
	Name  string `json:"name"`
	Count int    `json:"count"`
}

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 Dialect

type Dialect string

Dialect identifies the source language evaluated by a report.

const (
	DialectTeX   Dialect = "tex"
	DialectTypst Dialect = "typst"
)

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.

func (Evaluator) Evaluate

func (e Evaluator) Evaluate(ctx context.Context, input Input) (CaseReport, error)

Evaluate checks parse recovery, determinism, both limit profiles, and the IR contract.

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

type FamilySummary struct {
	Family string `json:"family"`
	Total  int    `json:"total"`
}

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

type IRSummary struct {
	Valid           bool
	ValidationError string
	CanonicalJSON   []byte
}

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

func LoadPolicy(path string) (*Policy, error)

LoadPolicy loads and validates reviewed disposition data.

func (*Policy) Validate

func (p *Policy) Validate() error

Validate checks rule structure before a suite is evaluated.

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

type ProcessConfig struct {
	Path string
	Args []string
	Env  []string
}

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

func LoadReport(path string) (*Report, error)

LoadReport loads a strict reviewed baseline.

func (*Report) CanonicalJSON

func (r *Report) CanonicalJSON() ([]byte, error)

CanonicalJSON returns deterministic reviewed-baseline JSON.

func (*Report) Validate

func (r *Report) Validate() error

Validate checks report conservation and review discipline.

type Request

type Request struct {
	Source string
	Mode   ir.Mode
	Limits source.Limits
}

Request is the complete formula source observation passed to a frontend.

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 Status

type Status string

Status is the required disposition of a conformance case.

const (
	StatusPass        Status = "pass"
	StatusDiagnostic  Status = "diagnostic"
	StatusUnsupported Status = "unsupported"
	StatusBug         Status = "bug"
)

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.

type Summary

type Summary struct {
	Total       int `json:"total"`
	Pass        int `json:"pass"`
	Diagnostic  int `json:"diagnostic"`
	Unsupported int `json:"unsupported"`
	Bug         int `json:"bug"`
	Unexplained int `json:"unexplained"`
}

Summary conserves all case dispositions.

Jump to

Keyboard shortcuts

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