variant

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package variant resolves a problem's parameters for one interview, deterministically. The same problem and interview id always produce the same values, so a session can be reproduced exactly for regrading, and each parameter draws from its own derived seed, so adding a parameter to a problem never changes the values existing parameters resolve to.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HashParts added in v0.8.0

func HashParts(parts ...string) []byte

HashParts digests parts with each one length-prefixed, so no two part lists share a digest.

func IsTemplated

func IsTemplated(name string) bool

IsTemplated reports whether a candidate file is rendered as a Go template when it ships: known text extensions plus extensionless files. The content linter and the bundle renderer share this one predicate, so no file can be rendered without also being lint-checked.

func Render

func Render(text string, r *Resolved) (string, error)

Render substitutes resolved parameters into candidate-facing text. A reference to a parameter the variant does not define is an error, never a silent blank: a bundle with a hole in it must not reach a candidate.

Types

type Resolved

type Resolved struct {
	Problem     string            `json:"problem"`
	InterviewID string            `json:"interview_id"`
	Params      map[string]any    `json:"params"`
	Overrides   map[string]string `json:"overrides,omitempty"`
}

Resolved is one interview's fully resolved variant, with the provenance needed to reproduce it. It serializes into evidence bundles.

func Resolve

func Resolve(problemID string, specs map[string]content.ParamSpec, interviewID string, overrides map[string]string) (*Resolved, error)

Resolve computes the variant for one interview. Overrides win over everything and are validated against the spec; a parameter with a default is pinned to it; anything else draws from the interview seed.

type TemplateIssue

type TemplateIssue struct {
	Path string
	Msg  string
}

TemplateIssue is one problem found in candidate-facing template text.

func CheckTemplates

func CheckTemplates(fsys fs.FS, candidateFiles []string, declared map[string]bool) []TemplateIssue

CheckTemplates parses every candidate-visible text file and reports unparseable templates and references to parameters the problem does not declare. Without this, a typo like {{.scal}} only surfaces when a bundle is rendered for a real candidate.

Jump to

Keyboard shortcuts

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