engine

package module
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: Apache-2.0 Imports: 7 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.

README

engine

CI CodeQL Go version Coverage OpenSSF Scorecard License

Code Smells Reliability Rating Security Rating Maintainability Rating Vulnerabilities

The NovaTrail engine: it picks what a learner does next — a lesson or a task, on a new skill or on one due for practice again — and gives each choice a reason code that the adult sees. It is a Go library of pure computation that works by a rule, with no AI model: it is handed the skill graphs, the lessons and the task pool and the learner model's estimates, time comes from outside, it takes no seed because the rule needs no randomness, and the same input always gives the same choice, on any build. From stage 2 it runs inside the platform's service, api; at stage 1 the learner simulator, sim, runs it.

A component of NovaTrail, a universal open platform for adaptive learning, interactive lessons and AI tutoring. It belongs to stage 1, Format and core, with spec, modules, module-kit, learner-model and sim; it comes together with learner-model and sim, since the simulator needs both the learner model and the rule.

Status

Detailing is done: the first epic, archived in docs/plan/E1.md, decided everything the component's card left open, and spec has recorded it. The second epic, E2, archived in docs/plan/E2.md, built the first version of the rule, which starts from the one by which MathTrail's standalone chose the next task: lessons and tasks with their reason codes over several modules, with golden vectors of the choice on the graphs of the first slice, and the same bits on every build. It came out as v0.1.0, the baseline before sim's first tag, and its gate now holds every change after it. The current epic of RUN.md, E3, works on the first candidates of the rule, which sim judges: why the base gives tasks outside the corridor of success, and variants that close the gap.

The gate

Every change after the baseline passes the gate of sim, the learner simulator: the job "Gate" of CI runs sim, by the tag and the SHA of its commit that .github/workflows/ci.yml names, on the commit's code in place of engine, and a pull request whose numbers leave their bands, or whose choices break an invariant, does not merge (R17). just gate runs the same gate on the working tree, with sim fetched once into the user's cache.

Releases

Releases come out by themselves: each commit of main whose CI has passed and which changes the code, go.mod, go.sum or what builds the release's file gets the next patch of the line 0.1 — the first, v0.1.0, came out on 2026-11-08 — with its tag, by .github's shared release workflow (R15). Nobody tags by hand, and a release is immutable.

  • Go code takes the library as a Go module, by the tag: go get github.com/altnovatrail/engine@v0.1.0. go.sum and the Go checksum database hold the version from then on.
  • The release's one file is the code a consumer builds: engine-<tag>.tar.gz, with LICENSE, go.mod, go.sum and the Go files of the module but its tests and testdata/, signed without a key. Verify it where it enters NovaTrail with spec's recipe, just -f spec/justfile release-verify engine <tag> engine-<tag>.tar.gz, with its bundle <file>.sigstore.json beside it. just release-files <tag>, in the toolchain stage of the tag's .devcontainer/Dockerfile, builds the same bytes from the tag's tree.

Documents

The documents are in Russian.

  • docs/architecture.md — the component: what it does and does not do, its data and links, what the card left to decide — all of it decided — and how it is built.
  • docs/decisions.md — the decision log: what was decided, why, and what was rejected.
  • RUN.md — the work plan, in epics.

The working rules, for people and coding agents alike, are in CLAUDE.md and AGENTS.md. The platform's shared vocabulary, formats, contracts and decisions are in spec, checked out here as a git submodule at v0.14.0: clone this repository with git clone --recurse-submodules.

License

Apache-2.0.

Documentation

Overview

Package engine is NovaTrail's engine: it picks a learner's next lesson or task by a rule, and gives the choice a reason code, which the adult sees and the learner is not told.

It is a library with no input or output of its own. The api service — at stage 1, the learner simulator, sim — hands it the learner model's estimates, the skill graphs of the learner's modules, the lessons and the pool of tasks, the learner's lesson runs, and a summary of what has been handed out before, and passes the time in as a number; api keeps every choice the library makes. The library estimates no mastery — that is the learner model's — gives no verdict, calls no AI model, reads no module package or database, and keeps nothing between calls. The rule takes no randomness, so it takes no seed.

The same input gives the same choice and the same reason code, bit for bit, on any build by Go's gc compiler of one version of this module and of the learner model — on any architecture it knows, WebAssembly included, with any Go no older than go.mod names. The code imports nothing but Go's standard library and the learner model, and only the packages its rules allow.

What the library picks and why is in docs/architecture.md, section 3, and in docs/decisions.md of this repository.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalid = errors.New("engine: invalid input")

ErrInvalid is an input that breaks a rule the engine relies on (docs/architecture.md, section 3.6): a choice is never made of it. It comes as a value and never by panicking; errors.Is tells it apart, and the message says what and where. An error of learner-model the input brought, from Readout.Task, is wrapped, so that errors.Is finds learner-model's kind too.

Functions

This section is empty.

Types

type Candidate

type Candidate struct {
	Task  learnermodel.Task
	Traps []ItemTraps
}

Candidate is a task of the pool: its description, and the traps of its items.

type Choice

type Choice struct {
	Kind   ChoiceKind
	ID     string
	Reason ReasonCode
}

Choice is the engine's choice: a lesson or a task by its full ID — of a template, the template's — or nothing to give, with no ID; and the reason code of the branch that made it, ReasonUnspecified beside nothing to give.

func Choose

func Choose(in Input) (Choice, error)

Choose picks what the learner is given next, and the reason code of the choice (docs/architecture.md, section 3). It refuses, with ErrInvalid, an input whose rules it relies on are broken: a module, a task of the pool or a lesson twice by ID; a skill of a graph, a task of the pool or a lesson that is not its module's by ID; a skill of a lesson that is not in the graph of its module; the traps of an item twice, or at a place where its task has no item; a run's end outside its list, an open run with a time of its end, and two open runs of one lesson; a skill, a module or a task twice in the summary, and a reason code of the summary outside its list; a skill twice in the results of the last attempt, and a result with first right verdicts fewer than none or more than its first verdicts; a module of the engine with no reading of the learner model, and an anchor skill a graph names with none or with a status off its list; and a candidate task the reading refuses, or one with the P of an item outside [0, 1], NaN and the infinities included. The checks run in one order and each names the least ID that breaks it, so that the order of the input's lists does not change the error either.

Choose runs the rule: the lesson of an open run; then on the skill chosen on the map, or in "My subjects" — consolidation in the module of the last closed attempt, then the modules in turn, with the repetition, the lessons on the new and the author's order —; then a second pass with the tasks on pause, and gives a lesson or a task with the code of its branch, or nothing to give.

type ChoiceKind

type ChoiceKind int32

ChoiceKind is what a choice gives: ChoiceKind of cause.proto, names and numbers.

const (
	ChoiceUnspecified ChoiceKind = 0 // never given
	ChoiceLesson      ChoiceKind = 1
	ChoiceTask        ChoiceKind = 2 // a task outside a lesson
	ChoiceNothing     ChoiceKind = 3
)

type Input

type Input struct {
	Time int64 // the time of the choice
	// The learner model's reading at Time, by learnermodel.Read: the modules of the engine and
	// the modules of the evidence log.
	Readout learnermodel.Readout
	Modules []Module // the modules of the engine: connected, and suited to the learner
	// The full ID of the skill the learner chose on the skill map; empty in "My subjects".
	MapSkill   string
	Runs       []Run        // the lesson runs of the profile in the modules of the engine
	RubricDone []RubricDone // the attempts of tasks with a rubric closed by "Done"
	Last       Last         // the last closed attempt of the profile, when HasLast
	HasLast    bool
	Summary    Summary // what was handed out before
}

Input is all that one choice reads. The order of its lists does not change the choice: the rule orders by itself, by the order of the graph, of the lessons and of the IDs.

type ItemTraps

type ItemTraps struct {
	Place int32
	Traps []string
}

ItemTraps is the traps of an item, by its place: the trap_values of its checks, by full ID.

type Last

type Last struct {
	Task     string        // the full ID of its task, whose beginning is its module
	Left     bool          // whether it was closed as left: its outcome is "left"
	Lesson   string        // the full ID of the lesson, when InLesson
	InLesson bool          // whether the attempt is a segment of a run of that lesson
	Results  []SkillResult // the result on each of its primary skills
}

Last is the last closed attempt of the profile.

type Lesson

type Lesson struct {
	ID     string
	Skills []string
	Tasks  []learnermodel.Task
}

Lesson is a lesson of a module: its full ID, its skills, and the descriptions of the tasks of its segments, in the order of the segments.

type Module

type Module struct {
	Graph   learnermodel.Graph
	Pool    []Candidate
	Lessons []Lesson // the lessons that suit the learner whole
}

Module is a module of the engine: the graph of its current version, and the pool and the lessons api gives the learner of it.

type ModuleChoices

type ModuleChoices struct {
	Module  string
	Choices int64
}

ModuleChoices is the number of choices of a module, a lesson counted once.

type ReasonCode

type ReasonCode int32

ReasonCode is why the engine gave what it chose: one value of the closed list ReasonCode of cause.proto in spec's contracts, with its number, which api translates the code by. The adult sees it; the learner is not told it. A test holds the names and numbers to the file.

const (
	ReasonUnspecified   ReasonCode = 0 // a choice of nothing
	ReasonConsolidation ReasonCode = 1 // after a wrong answer, another task on the skill
	ReasonNewSkill      ReasonCode = 2 // a skill not given before, whose prerequisites are met
	ReasonQueue         ReasonCode = 3 // the skill within reach not given for longest in its module
	ReasonRepetition    ReasonCode = 4 // the review date of a mastered skill has come
	ReasonProbe         ReasonCode = 5 // a skill put aside comes back as a check
	ReasonSkillChosen   ReasonCode = 6 // the skill chosen on the skill map
	ReasonAuthorOrder   ReasonCode = 7 // a skill with a rubric or without assessment, by the graph
	ReasonOpenRun       ReasonCode = 8 // the lesson of a run that is open
	ReasonRotation      ReasonCode = 9 // a skill given before comes round again, outside the queue
)

type RubricDone

type RubricDone struct {
	Task string
	At   int64
}

RubricDone is an attempt of a task with a rubric that "Done" closed, and when. The attempts of one task repeat by right: a task with a rubric is given again by a new attempt.

type Run

type Run struct {
	Lesson  string
	Skills  []string
	End     RunEnd // RunOpen while it is open
	EndedAt int64  // zero while it is open
}

Run is a lesson run of the profile: its lesson and the lesson's skills — translated, on a package before — how it ended, and when. The runs of one lesson repeat by right: a lesson is given again by a new run.

type RunEnd

type RunEnd int32

RunEnd is how a lesson run ended: RunEndReason of cause.proto, names and numbers. Its zero is a run that is open.

const (
	RunOpen        RunEnd = 0
	RunPassed      RunEnd = 1
	RunUnchecked   RunEnd = 2
	RunNotSuitable RunEnd = 3
	RunAbandoned   RunEnd = 4
)

type SkillIssue

type SkillIssue struct {
	Skill      string
	LastIssued int64
	Issued     bool
	LastCode   ReasonCode
	LastResult SkillResult
	HasLast    bool
}

SkillIssue is when a skill was last handed out, by a task on it or by a lesson that teaches it, when Issued; and, when HasLast, the reason code of the choice of its last closed attempt and the attempt's result on it.

type SkillResult

type SkillResult struct {
	Skill         string
	Answered      int32
	FirstRight    int32
	SolutionShown bool
}

SkillResult is the result of an attempt on a skill, in facts: of the items of the attempt the skill is primary in, how many got a first verdict, how many of those are right, and whether the solution was shown. The engine tells a failure from them, by the same rule as the learner model.

type Summary

type Summary struct {
	Skills  []SkillIssue
	Modules []ModuleChoices
	Tasks   []TaskSolution
}

Summary is what api gives of what was handed out before, from the records of choices and attempts it keeps.

type TaskSolution

type TaskSolution struct {
	Task           string
	SolutionSentAt int64
}

TaskSolution is when the solution of a task last went to the learner's device.

Jump to

Keyboard shortcuts

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