pack

package
v0.1.21 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: Apache-2.0 Imports: 16 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 pack reads published packages of modules as the bench needs them: the server part, server.json, by the types of spec's canonical view and without module-kit, checked through the chain of digests from a pinned module index (docs/architecture.md, sections 1, 3.3 and 3.9; R62, R72, R77 spec; the text of the format, sections 25 and 26). It translates the canonical view into what learner-model and engine take, as api would (R14 in docs/decisions.md).

Index

Constants

This section is empty.

Variables

View Source
var ErrDigest = errors.New("pack: a digest does not match")

ErrDigest is a file whose SHA-256 is not the one the chain of digests names.

View Source
var ErrFormat = errors.New("pack: a version of the module format outside the window")

ErrFormat is a package of a version of the format the bench does not read.

View Source
var ErrIdentity = errors.New("pack: the package is not the version its entry names")

ErrIdentity is a package that is not the module and version its entry names.

View Source
var ErrNoTask = errors.New("pack: no such task in the module")

ErrNoTask is a task the module has not.

View Source
var ErrTranslate = errors.New("pack: the canonical view cannot be translated")

ErrTranslate is a canonical view the bench cannot translate.

View Source
var ErrWithdrawn = errors.New("pack: the version is withdrawn from publication")

ErrWithdrawn is a version the index marks withdrawn from publication: api begins no attempt on it (R63 spec), and the bench reads none.

Functions

func Digest

func Digest(data []byte) formatv0.Digest

Digest gives the SHA-256 of a file as the format writes a digest: the package digest, when the file is a package's inventory.json.

func Entry

Entry gives the entry of a version of a module in an index, if the bench may read it: one the index names, of a version of the format in the window, and not withdrawn.

func ReadFiles

func ReadFiles(inventory, server []byte, e *formatv0.Entry) (*formatv0.CanonicalView, *formatv0.Inventory, error)

ReadFiles reads a package from its inventory.json and server.json, as a folder holds them: the digest and size of server.json must be the inventory's, whatever the version of the format, since the inventory keeps server_part in every version (the text of the format, section 2); that version must be one the bench reads, and the manifest must name the module, the version and the version of the format the inventory names; server.json is read by the types of the canonical view. With an entry of an index, the SHA-256 of inventory.json must be the entry's package digest and its version of the format the entry's: the chain of digests from the index. With none, the package is one a build wrote, which no index names yet. The inventory comes back whenever it could be read, so that a caller can tell a package of a version of the format outside the window.

func ReadIndex

func ReadIndex(data []byte, digest string) (*formatv0.ModuleIndex, error)

ReadIndex reads a module index whose SHA-256, in hex, must be digest: the digest the gate file pins, as the configuration of api pins it (R63 spec; docs/architecture.md, section 3.9). It reads the index's members by their places alone, whatever version of the format the index is of: a reader skips an entry whose format version it does not read, rather than refuse the index (the text of the format, section 2), and Entry does that.

func ReadPackage

func ReadPackage(archive []byte, id formatv0.ModuleID, version formatv0.ModuleVersion, e formatv0.Entry) (*formatv0.CanonicalView, error)

ReadPackage reads the server part of the archive of a version of a module whose entry in the index is e: the SHA-256 of its inventory.json must be the entry's package digest, and the digest and size of server.json the inventory's; the inventory and the manifest must name the module, the version and the version of the format the entry names; server.json is read by the types of the canonical view (the text of the format, sections 25 and 26).

func Readable

func Readable(v formatv0.ModuleFormatVersion) bool

Readable tells whether the bench reads a version of the module format.

func Untar

func Untar(archive []byte) (map[string][]byte, error)

Untar gives the regular files of a package's archive, by name. The archive is a gzip of a tar of 512-byte blocks: a header — the name in its first 100 bytes, the size in octal at 124, the type at 156 — then the file's blocks; the packages name their files short, with no ustar prefix. It is read here, as engine's test reads it, since archive/tar would pull os/user, whose cgo the rules of code cannot type-check for every target.

Types

type Lesson

type Lesson struct {
	Lesson engine.Lesson
	Links  int // its segments: explanations, worked examples and tasks, in the author's order
	// Order gives each link in the author's order: the index of its task in Lesson.Tasks, or -1 for
	// an explanation or a worked example.
	Order []int
	Ages  []string // its own age categories; none, the module's
}

Lesson is a lesson of the module: what engine takes of it, and its links beside.

type Module

type Module struct {
	ID    string
	Graph learnermodel.Graph // by learnermodel.NewGraph, for both libraries (R28 spec)
	Ages  []string           // the module's age categories, its audience
	Tasks []Task             // ordered by full ID
	// Lessons are the module's lessons, ordered by full ID.
	Lessons []Lesson
}

Module is a module as the bench reads it: the graph and the inputs of engine, translated once from the canonical view, and what the virtual learners need beside them.

func Translate

func Translate(cv *formatv0.CanonicalView) (*Module, error)

Translate reads a canonical view into the bench's module: full IDs — the module, the kind and the local ID joined by / (the text of the format, section 10) —, anchor skills as they are; bands by place from the manifest; tiers from skill_tiers; a slot's kind of check and a choice's number of options, whether they stand beside the check or in it; a check by a rubric gives no slot with a verdict; of a leading question, only that the task has one. The graph is learner-model's own NewGraph, so that sim and api build one graph of one module alike (R28 spec).

func (*Module) ForAge

func (m *Module) ForAge(age string) ([]engine.Candidate, []engine.Lesson)

ForAge gives the pool and the lessons as api gives them to a learner of an age category: the tasks that suit them, and the lessons that suit them whose every task does too (R107 spec; architecture 3.7 api). The age category is api's filter, not an input of engine.

func (*Module) Instance

func (m *Module) Instance(id string, attemptSeed uint64) (int, formatv0.Numbers, error)

Instance gives the instance of a template an attempt with seed attemptSeed takes: its number, chosen as the platform chooses it — the place names the task's ID in the module, as the format's task has it (the text of the format, section 23; R60 spec) —, and its numbers, read from the canonical view, whose instances are in that order. A task that is no template has no instance.

func (*Module) Task

func (m *Module) Task(id string) (*Task, error)

Task gives a task of the module by its full ID.

func (*Module) Text

func (m *Module) Text() ([]byte, error)

Text gives the canonical text of what the bench reads of the module: the module translated — its graph with the bands and the tiers, its audience, its tasks with their items, slots, traps, canvases and ages, whether each has a leading question and the numbers of each template's instances, its lessons —, as JSON, whose fields keep their order and whose maps are written by their keys. What Translate does not read — the texts for the learner, the leading question's own words among them, the version — is not in it, so two packages give the same text when the bench reads the same of them, and Translate is the one list of what the bench reads (docs/architecture.md, section 3.9; R27 in docs/decisions.md).

type Task

type Task struct {
	Candidate engine.Candidate // the task as engine takes it, with the traps of its items
	Local     string           // its ID in the module
	Canvas    formatv0.CanvasKind
	Rubric    bool     // a task with a rubric: no verdict and no evidence (architecture 3.8 spec)
	Ages      []string // its own age categories; none, the module's
	Instances int      // the number of instances of a template; 0 for a task
	// Leading tells that the task has a leading question, which a hint asked for gives before the
	// first wrong answer (the text of the format, sections 14 and 19). The bench reads that it has
	// one, not its text.
	Leading bool
	// contains filtered or unexported fields
}

Task is a task of the module: what engine takes of it, and what the bench reads beside.

func (*Task) ItemPrimary

func (t *Task) ItemPrimary(i int) []string

ItemPrimary gives the primary skills of the item at index i of the task: the item's own, when it has skills of its own, and the task's otherwise (the text of the format, section 12). The truth, the engine's results and the measures read an item's skills by this one rule.

Jump to

Keyboard shortcuts

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