conformance

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2026 License: AGPL-3.0 Imports: 10 Imported by: ? 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 runs the official OpenJD conformance test suite (https://github.com/OpenJobDescription/openjd-specifications) against sqi's internal/openjd implementation.

The suite is supplied by a pinned git submodule under third_party/ rather than vendored, because it is licensed CC BY-ND 4.0: verbatim redistribution is permitted but modified copies are not, and this repo's mandatory SPDX header would make every vendored fixture a derivative work.

File layout

Everything except suite_test.go is untagged, so the harness's own unit tests run under `make test` and count toward coverage. Only suite_test.go — the file that walks the real fixture tree — carries the `conformance` build tag, because only it needs the submodule present.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DiffBaseline

func DiffBaseline(results []Result, baseline map[string]struct{}) (regressions, stale, orphaned []string)

DiffBaseline compares results against the baseline in three directions.

regressions are live tests that failed but are not in the baseline — a real break. stale are live tests that are in the baseline but passed — the baseline needs updating. orphaned are baseline entries that match no live result at all: either the fixture no longer exists in results (upstream deleted or renamed it), or it exists but is no longer StateLive (for example a fixture reclassified to StateNotApplicable, as base/env_templates was by Finding 1's kind-aware Classify). Without this check such an entry is invisible forever — the regression/stale loop below only ever looks at live results, so a line nothing live ever matches is never flagged by either of the other two directions.

Checking all three directions is what keeps the baseline from decaying into a permanent ignore-list: a fixed test forces its entry to be removed, and a dead entry is forced out too instead of rotting silently.

Not-applicable results are otherwise skipped entirely for regressions/stale; they are neither pass nor fail. All three slices are sorted for stable output.

func ExtensionFor

func ExtensionFor(path string) string

ExtensionFor returns the extension directory a fixture belongs to, given its path relative to the suite root: "base", "EXPR", "TASK_CHUNKING", and so on.

The layout is <extension>/<kind>/<file>.yaml, so the extension is the grandparent directory.

func FormatRollup

func FormatRollup(groups []Group) string

FormatRollup renders groups as an aligned human-readable table.

Not-applicable counts are reported in their own column and never as a pass ratio, so an unimplemented extension or unimplemented document kind (such as env_templates) can never look like a green one.

func IsFixtureFile

func IsFixtureFile(name string) bool

IsFixtureFile reports whether a directory entry's base name is a conformance fixture the walker should collect.

A ".yaml" suffix alone is not enough: AppleDouble companions keep the extension (see fsutil.IsAppleDouble), and no fixture in the suite begins with a dot, so leading-dot names are excluded outright — which also covers ".DS_Store" and any other OS metadata.

func KindFor

func KindFor(path string) string

KindFor returns the template kind a fixture belongs to, given its path relative to the suite root: "job_templates" or "env_templates".

The layout is <extension>/<kind>/<file>.yaml, so the kind is the parent directory.

func LoadBaseline

func LoadBaseline(path string) (map[string]struct{}, error)

LoadBaseline reads a baseline file: one known-failing test ID per line. Blank lines are ignored, and everything from a '#' to end of line is a comment. A missing file yields an empty baseline, not an error — that is the legitimate starting state before the first run.

Types

type Group

type Group struct {
	// Name is "<extension>/<kind>", e.g. "base/job_templates".
	Name string
	// Passed and Failed count live tests only.
	Passed, Failed int
	// NotApplicable counts tests for extensions sqi has not registered, or for
	// a document kind sqi does not implement at all (env_templates). These
	// are never folded into Passed — see StateNotApplicable.
	NotApplicable int
}

Group is the per-directory tally reported at the end of a run.

func Rollup

func Rollup(results []Result) []Group

Rollup tallies results per "<extension>/<kind>" directory, sorted by name.

type Result

type Result struct {
	// Case is the fixture that was run.
	Case TestCase
	// State is whether this result counts toward the score.
	State State
	// Accepted reports whether sqi accepted the template (parsed and validated
	// with no errors).
	Accepted bool
	// Passed reports whether the outcome matched the fixture's expectation.
	// Always false when State is StateNotApplicable.
	Passed bool
	// Reason describes the outcome, including the validation error when the
	// template was rejected. Empty when a live fixture passed.
	Reason string
}

Result is the outcome of running one conformance fixture.

func RunCase

func RunCase(tc TestCase, state State, data []byte) Result

RunCase parses and validates one template fixture and scores it against the expectation encoded in its filename.

A fixture whose name lacks ".invalid" must be ACCEPTED; one carrying it must be REJECTED. Malformed YAML counts as a rejection — the spec's contract is accept-versus-reject, and it does not distinguish a parse failure from a validation failure.

Limits are enforced: the suite tests spec-defined limits, so the enforcing path is the one under test.

When state is StateNotApplicable the fixture is not scored at all — Passed is false regardless of outcome. See the StateNotApplicable doc comment.

func (Result) ID

func (r Result) ID() string

ID returns the fixture's stable identifier — its path relative to the suite root. This is what the baseline file lists.

type State

type State int

State is whether a fixture's result counts toward the score.

const (
	// StateLive means sqi implements the fixture's extension (or it is a base
	// spec fixture) AND the document kind the fixture exercises, so pass/fail
	// is a meaningful signal.
	StateLive State = iota
	// StateNotApplicable means either the fixture's extension is not in sqi's
	// registry, or the fixture is a document kind sqi does not implement at
	// all (standalone "environment-2023-09" templates — env_templates). Its
	// result is reported separately and NEVER counted as a pass.
	//
	// This distinction is load-bearing, and it now guards against two
	// distinct false-green failure modes:
	//
	//  1. sqi rejects templates declaring an unregistered extension, which is
	//     correct behavior — but it means every ".invalid" fixture for such
	//     an extension is rejected for the wrong reason and would score as a
	//     pass under naive pass/fail classification. All 209 EXPR template
	//     fixtures would report green before a single line of EXPR existed.
	//  2. sqi does not implement standalone environment-2023-09 templates at
	//     all: every env_templates fixture is rejected on
	//     "/specificationVersion: unsupported version", regardless of the
	//     fixture's own defect. A ".invalid" env_templates fixture is
	//     therefore rejected for the wrong reason too, and would score as a
	//     pass the same way an unregistered-extension fixture does — this is
	//     the same bug class, just keyed on document kind instead of
	//     extension. base/env_templates alone had 24 fixtures scoring as
	//     false passes this way before Classify took kind into account.
	StateNotApplicable
)

func Classify

func Classify(extension, kind string) State

Classify reports whether fixtures for the given extension directory and template kind ("job_templates" or "env_templates") should be scored.

kind is checked first and unconditionally: sqi does not implement standalone environment-2023-09 templates at all, so every env_templates fixture — regardless of extension, including "base" and EXPR — is not applicable. Only once kind clears that gate does extension matter: "base" is always live, and any other extension is live only when it is registered in internal/openjd's extension registry AND marked openjd.StatusSupported. A registered-but-in-progress extension does not count as live: validateExtensions rejects every such template on the status gate alone, so scoring its fixtures through this path would report a false failure for every valid one and a false pass for every ".invalid" one, instead of the honest "not applicable". EXPR was exactly that case until sub-project H2 marked it supported; it is live now, and EXPR/job_templates is scored by TestConformance_Templates like every other live directory.

func (State) String

func (s State) String() string

type TestCase

type TestCase struct {
	// Path is the fixture's path relative to the 2023-09 suite root.
	Path string
	// Section is the spec section under test ("1.1", "expr2.2.4"), or "" when
	// the filename carries no section prefix.
	Section string
	// Description is the human-readable remainder of the filename.
	Description string
	// Invalid reports whether the implementation is expected to REJECT this
	// fixture (filename carries ".invalid").
	Invalid bool
	// IsJobTest reports whether this is a job-execution test (".test"), which
	// requires a live session runtime and is out of scope for template
	// validation.
	IsJobTest bool
}

TestCase is one conformance fixture, described by its filename.

The naming convention is <spec-section>--<description>[.invalid][.test].yaml. The section prefix is optional: some extension fixtures (for example TASK_CHUNKING/jobs/contiguous-even.test.yaml) carry no "--" separator.

func ParseTestCase

func ParseTestCase(path string) TestCase

ParseTestCase derives a TestCase from a fixture path relative to the suite root. It never fails: an unrecognized filename yields a TestCase with an empty Section and the whole stem as Description, which the caller reports like any other test rather than silently dropping.

Jump to

Keyboard shortcuts

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