Documentation
¶
Overview ¶
Package tutor is the AI side of NovaTrail's tutor, a library that api calls in its own process. It reads the learner's work into an observation, reviews the working and words the tutor's replies, through the AI routes and models it admits, and reports each call's usage. It decides no verdict and stores nothing, and its requests carry no identifier of the learner or the account.
The AI providers are reached only through the port in package provider. The eval runner, cmd/tutor-eval, runs on the same code.
Example ¶
api makes the library once, when it starts: spec's admission table, the facts of its deployment, the least stage of its learners and the platform's keys, which it reads from Secret Manager. Before an attempt it asks which models would read the learner's work, and whether any would.
package main
import (
"fmt"
"log"
"github.com/altnovatrail/spec/types/admissionv0"
"github.com/altnovatrail/tutor"
"github.com/altnovatrail/tutor/admission"
)
func main() {
table, err := admission.Platform()
if err != nil {
log.Fatal(err)
}
facts, err := admission.ReadFacts(table, []byte("anthropic:\n data_processing_agreement: [adult]\n minimal_retention: [adult]\n"))
if err != nil {
log.Fatal(err)
}
lib, err := tutor.New(tutor.Config{Table: table, Facts: facts, Least: admission.StageAuthor, Keys: map[admissionv0.Provider]string{"anthropic": "the platform's key"}})
if err != nil {
log.Fatal(err)
}
route := tutor.Route{AI: admissionv0.AiRoutePlatformAi, Category: admissionv0.AgeCategoryAdult}
entry, answer, err := lib.Choose(admissionv0.CapabilityHandwritingReading, route)
if err != nil {
log.Fatal(err)
}
fmt.Println(answer.Admitted, entry.Stage, entry.Models[0].Name(), "+", entry.Models[1].Name())
child := tutor.Route{AI: admissionv0.AiRoutePlatformAi, Category: admissionv0.AgeCategoryUnder13}
_, answer, _ = lib.Choose(admissionv0.CapabilityHandwritingReading, child)
fmt.Println(answer.Admitted, *answer.Reason, *answer.Fact)
}
Output: true author claude-opus-5-5 high + claude-haiku-5-5 medium false fact_missing data_processing_agreement
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Table *admission.Table
Facts admission.Facts
Least admission.Stage
Keys map[admissionv0.Provider]string
}
Config is what api gives tutor when it starts (architecture 3.10): spec's admission table, the deployment's facts, the least stage of admission its learners take — admission.StageAuthor only where the author alone learns, as in the first app (R76 spec; R80) — and the platform's keys at the AI providers, which api reads from Secret Manager (architecture 1). A provider with no key here is no route of platform AI: Choose takes none of its models.
type Kind ¶
type Kind int
Kind is how a call of the library ended (architecture 3.10): the models answered; AI failed; a provider refused for a limit, a balance or billing, whose reason Outcome.Limit names (architecture 3.7); the admission refused the call, before any model was asked (architecture 3.9); or the provider refused the own key, wrong or revoked (R84 spec). None but the first is the learner's mistake (R04 spec).
type LimitReason ¶
type LimitReason string
LimitReason is why a provider refused for a limit: one only the owner of the key can lift, each in its own way (architecture 3.7).
const ( LimitOwner LimitReason = "owner_limit" LimitTier LimitReason = "tier" LimitBalance LimitReason = "balance" LimitBilling LimitReason = "billing" )
The reasons of a limit reached.
type Outcome ¶
type Outcome struct {
Kind Kind
Limit LimitReason
Admission admission.Answer
Usage []Usage
Err error
}
Outcome is how a call of the library ended: its kind; the reason of a limit; the admission's answer, which on NotAdmitted refuses; and a record of usage for each call of a model that came back, in the order of the models, none on NotAdmitted. Err says what failed, for the logs: it carries no content and no key.
type OwnKey ¶
type OwnKey struct {
// contains filtered or unexported fields
}
OwnKey is the key of an account owner who learns, with its provider (R84 spec). It lives only in the memory of the request (privacy 5.2 spec): its fields are unexported, it prints as its provider alone with any verb, and as JSON it is nothing. The key itself stands behind a pointer, so that even an OwnKey printed field by field, as fmt prints an unexported field of another struct, shows an address rather than the key.
func NewOwnKey ¶
func NewOwnKey(p admissionv0.Provider, key string) *OwnKey
NewOwnKey is the own key of a provider.
func (*OwnKey) Provider ¶
func (k *OwnKey) Provider() admissionv0.Provider
Provider is the key's provider.
type Route ¶
type Route struct {
AI admissionv0.AiRoute
Category admissionv0.AgeCategory
Own *OwnKey
}
Route is what every call of the library carries besides its work (architecture 3.10): the AI route, the learner's age category, and on the own key the key with its provider. It names no learner, no account and no adult (R15 spec; privacy 5.1 spec).
type SheetRead ¶ added in v0.1.16
type SheetRead struct {
Observations []*observationv1.Observation
Outcome Outcome
}
SheetRead is what a reading of a sheet gives: the observation of each reader, in the order of the pair, the strong reader first (R68 spec), when Outcome is Answered — module-kit joins them and gives the verdict (R86 spec) —, and otherwise none: tutor gives both or the outcome, never one.
type SheetReading ¶ added in v0.1.16
SheetReading is a handwriting sheet to read (architecture 3.10, «чтение листа»): the PNG of the crop of its visible strokes, as app sends it (the contract between app and api, SheetWork), the open view of its task, and the route. The model sees the crop and the statement, never the key (R67 spec).
type Trap ¶ added in v0.1.18
type Trap struct {
ID, Description string
}
Trap is a trap of a task that a model may name, by its ID, with its description from the catalogue of traps, which api takes through module-kit (R57 spec).
type Tutor ¶
type Tutor struct {
// contains filtered or unexported fields
}
Tutor is the library as api holds it: made once, at the start, and called by many requests at once. It keeps nothing of a call (R09 spec).
func New ¶
New makes the library of a config. It refuses a config with no table, and a least stage that is neither of the two: an empty one is the stage full, the strict one.
func (*Tutor) Choose ¶
func (t *Tutor) Choose(c admissionv0.Capability, r Route) (admission.Entry, admission.Answer, error)
Choose chooses the models of a capability for a route (admission.Table.Select): api calls it before an attempt, and each call of the library before it calls a model, with the same answer while the config is the same. On the own key it takes only the models of the key's provider, and on platform AI only those of the providers it holds a key of. It refuses a route whose key does not fit it.
func (*Tutor) ReadSheet ¶ added in v0.1.16
func (t *Tutor) ReadSheet(ctx context.Context, r SheetReading) SheetRead
ReadSheet reads a handwriting sheet by the models admitted for reading handwriting, in parallel, each into the observation of the task's one answer slot bound anywhere (R86 spec; § 10 of spec's contracts text). The first version reads that slot alone: the sheets of the first modules have no other that AI reads (T115). A slot bound choice is no reading of AI: api gives the option tapped to module-kit. An answer that is no observation fails the reading, as a failure of AI does: there is no observation of a pair then (R86 spec).
func (*Tutor) Words ¶ added in v0.1.18
func (t *Tutor) Words(ctx context.Context, w WordsRequest) WordsAnswer
Words asks the admitted model of the words for the analysis and the hint of a rung. With the work it serves the analysis of the steps and the hint, so both must be admitted, and the model is the analysis's; without it, the hint alone. A task without words, a crop that is no PNG of a sheet, a rung the ladder has not, a language with no tag and no style of presentation fail before any call; an answer off the schema, or naming a trap the request does not hold, fails the call.
type Usage ¶
type Usage struct {
Provider admissionv0.Provider
Model string
InputTokens int64
OutputTokens int64
ThinkingTokens int64
Billed bool
}
Usage is a record of what one call of a model took (architecture 3.7): the provider and the model the provider says answered, the input, output and thinking tokens, and whether those tokens are the call's whole bill (provider.Billed). The cache and the price in dollars come with T120. It holds no content and no identifier, and may be written to logs (R09 spec).
type WordsAnswer ¶ added in v0.1.18
type WordsAnswer struct {
Box *observationv1.CropBox
Trap string
Question string
Outcome Outcome
}
WordsAnswer is what the call of words gives, when Outcome is Answered: the box round the first mistake, in thousandths of the crop, the same message as an observation's (R86 spec), or nil when the model found none or saw no work; the trap of the request's that the mistake falls into, or empty; and the tutor's question.
type WordsRequest ¶ added in v0.1.18
type WordsRequest struct {
Route Route
Task *open.Task
Crop []byte
Key string
Solution []string
Traps []Trap
Found string
Techniques []string
Rung int
Language string
Style string
Asked []string
}
WordsRequest is a call of the tutor's words (architecture 3.10, «разбор и подсказка»): the analysis of the steps and the hint of a rung, in one call, as architecture 4.1 of spec draws it.
- Crop is the PNG of the crop of the work, sent again, as the server keeps none (R09 spec); nil when the learner asks to have the rung put another way, which sends no work (R82 spec);
- Key and Solution are the task's, which the model sees here alone (R67 spec);
- Traps are the task's traps that AI may name, with their descriptions, and Found the trap of the cell of the rung, which the program found by its value, or empty (R82 spec);
- Techniques are the task's ways to solve it;
- Rung is the rung api picked, 1 to 3; Language the module's language of explanations, by its tag; Style only what of the presentation style changes the words (Д74 RUN.md spec);
- Asked are the questions the tutor has already asked on the task, in order (privacy 4 spec).
The words are checked by api for leaks and by words.Hint for their form, before they reach the learner; api gives the fallback text in their place when they fail (R70 spec).
Directories
¶
| Path | Synopsis |
|---|---|
|
Package admission is tutor's admission function (R57; architecture 3.9): one pure function that says whether the work of a learner of an age category may go to an AI provider on an AI route, for a capability of AI, by spec's admission table and the deployment facts an operator declares.
|
Package admission is tutor's admission function (R57; architecture 3.9): one pure function that says whether the work of a learner of an age category may go to an AI provider on an AI route, for a capability of AI, by spec's admission table and the deployment facts an operator declares. |
|
cmd
|
|
|
tutor-eval
command
Command tutor-eval is tutor's eval runner: it runs the AI capabilities on eval samples, on the same code that api calls, and reports how they did.
|
Command tutor-eval is tutor's eval runner: it runs the AI capabilities on eval samples, on the same code that api calls, and reports how they did. |
|
internal
|
|
|
board
Package board is the check board: a local page where a person solves fixed tasks by hand, the models read the work and judge it, and the person marks whether each model was right.
|
Package board is the check board: a local page where a person solves fixed tasks by hand, the models read the work and judge it, and the person marks whether each model was right. |
|
convert
Package convert writes the sheets of tutor-sample v0, the files the record mode of the board saved until T105, as samples of spec's eval protocol, the message Sample of novatrail.eval.v1 (R75): the author's sheets as a person's, at random by ID and by the author's writer's code, and the sheets code drew as the samples tutor-eval draw draws, to the byte, once the same code is found to draw them from the seed.
|
Package convert writes the sheets of tutor-sample v0, the files the record mode of the board saved until T105, as samples of spec's eval protocol, the message Sample of novatrail.eval.v1 (R75): the author's sheets as a person's, at random by ID and by the author's writer's code, and the sheets code drew as the samples tutor-eval draw draws, to the byte, once the same code is found to draw them from the seed. |
|
essay
Package essay is the assessment of an essay by the module author's rubric in the measurement of epic E4 (T82; docs/architecture.md, 3.4, «Сочинения»): what a model sees of a synthetic essay.
|
Package essay is the assessment of an essay by the module author's rubric in the measurement of epic E4 (T82; docs/architecture.md, 3.4, «Сочинения»): what a model sees of a synthetic essay. |
|
evalsample
Package evalsample is a sheet of the measurement as a sample file of spec's eval protocol, the message Sample of novatrail.eval.v1 (contracts/README.md of spec, sections 11 to 13; R93, R95 spec): Of writes a sheet that internal/synth drew as one, and Read reads one back into the sample that tutor's runner takes, internal/sample's, with what its plan sheet says and the protocol does not — the scenario, the planned erasure and the trap.
|
Package evalsample is a sheet of the measurement as a sample file of spec's eval protocol, the message Sample of novatrail.eval.v1 (contracts/README.md of spec, sections 11 to 13; R93, R95 spec): Of writes a sheet that internal/synth drew as one, and Read reads one back into the sample that tutor's runner takes, internal/sample's, with what its plan sheet says and the protocol does not — the scenario, the planned erasure and the trap. |
|
gen
Package gen builds the synthetic sets of the extended measurement (T94; R50 in docs/decisions.md): pages of the workbook in the format tutor-workbook and essays in the format tutor-essays, as many as a run needs, each with its truth by construction.
|
Package gen builds the synthetic sets of the extended measurement (T94; R50 in docs/decisions.md): pages of the workbook in the format tutor-workbook and essays in the format tutor-essays, as many as a run needs, each with its truth by construction. |
|
hint
Package hint is the call of the review and the hint (T74; docs/architecture.md, 3.4, «Подсказка»): once the program has found the final answer not yet right, a model finds the first mistake in the work and words the tutor's question for the rung of the hint ladder that the program chose, in one call, as architecture 4.1 spec draws it (R28).
|
Package hint is the call of the review and the hint (T74; docs/architecture.md, 3.4, «Подсказка»): once the program has found the final answer not yet right, a model finds the first mistake in the work and words the tutor's question for the rung of the hint ladder that the program chose, in one call, as architecture 4.1 spec draws it (R28). |
|
journal
Package journal tells how a sheet was written, for the forms of the measurement that show the model the writing process (R11, R24): a journal of numbered steps in English, and up to two frames of the sheet just before erasures.
|
Package journal tells how a sheet was written, for the forms of the measurement that show the model the writing process (R11, R24): a journal of numbered steps in English, and up to two frames of the sheet just before erasures. |
|
judge
Package judge holds what the measurement asks of a model and how it reads the answer (R24): the judge's instructions, the request of each form, and the schema of the answer.
|
Package judge holds what the measurement asks of a model and how it reads the answer (R24): the judge's instructions, the request of each form, and the schema of the answer. |
|
leak
Package leak is the leak check of the module format (R57 spec; the format text of spec, section 20, «The leak check»): the program's search for the answer in a text the learner will see, the tutor's words before they reach the learner.
|
Package leak is the leak check of the module format (R57 spec; the format text of spec, section 20, «The leak check»): the program's search for the answer in a text the learner will see, the tutor's words before they reach the learner. |
|
lines
Package lines finds the lines of a sheet: the strokes that stand at one height, told apart by the gaps between them down the sheet.
|
Package lines finds the lines of a sheet: the strokes that stand at one height, told apart by the gaps between them down the sheet. |
|
measure
Package measure is the judge's kind of call on the runner (T67): the measurement of the writing process (R24).
|
Package measure is the judge's kind of call on the runner (T67): the measurement of the writing process (R24). |
|
newfile
Package newfile writes the files tutor's tools keep: each a new file, never one written over.
|
Package newfile writes the files tutor's tools keep: each a new file, never one written over. |
|
openview
Package openview builds the open views of the measurement's tasks: the file that tutor's release carries for canvas's sample page, until modules has content (T37; R64 in docs/decisions.md; the 2026-10-21 amendment to R25 spec).
|
Package openview builds the open views of the measurement's tasks: the file that tutor's release carries for canvas's sample page, until modules has content (T37; R64 in docs/decisions.md; the 2026-10-21 amendment to R25 spec). |
|
protocol
Package protocol is spec's eval protocol in tutor's code: the package novatrail.eval.v1, whose messages Sample and Report are the sample file and the runner's report (contracts/README.md of spec, sections 11 and 14; R93, R95 spec).
|
Package protocol is spec's eval protocol in tutor's code: the package novatrail.eval.v1, whose messages Sample and Report are the sample file and the runner's report (contracts/README.md of spec, sections 11 and 14; R93, R95 spec). |
|
protocol/protocoltest
Package protocoltest gives tests spec's examples of the eval protocol: the synthetic sample files and reports of contracts/examples/eval/v1/ (contracts/README.md of spec, sections 11 and 14).
|
Package protocoltest gives tests spec's examples of the eval protocol: the synthetic sample files and reports of contracts/examples/eval/v1/ (contracts/README.md of spec, sections 11 and 14). |
|
reading
Package reading is the reading of a sheet into an observation (T68; docs/architecture.md, 3.4, «Чтение в наблюдение»): a model reads the work as it is written, part by part, and its final answer, without deciding whether it is right (concepts 9.1 spec).
|
Package reading is the reading of a sheet into an observation (T68; docs/architecture.md, 3.4, «Чтение в наблюдение»): a model reads the work as it is written, part by part, and its final answer, without deciding whether it is right (concepts 9.1 spec). |
|
render
Package render draws a sheet of handwriting from its strokes, as the board shows it: ink of the board's pen, #111, 3 px wide with round ends and joins, on white, one pixel to a unit of the sheet.
|
Package render draws a sheet of handwriting from its strokes, as the board shows it: ink of the board's pen, #111, 3 px wide with round ends and joins, on white, one pixel to a unit of the sheet. |
|
report
Package report turns the log of a run into the measurement's numbers and its criterion (R24; docs/architecture.md, 3.1, «Замер хода решения»), asking no model, and writes them as Markdown and CSV.
|
Package report turns the log of a run into the measurement's numbers and its criterion (R24; docs/architecture.md, 3.1, «Замер хода решения»), asking no model, and writes them as Markdown and CSV. |
|
runner
Package runner runs the calls of a measurement, whatever their kind (T67): the judge of the writing process, and in epic E4 also reading, the hint, the cells of the workbook and the rubric (docs/architecture.md, 3.4).
|
Package runner runs the calls of a measurement, whatever their kind (T67): the judge of the writing process, and in epic E4 also reading, the hint, the cells of the workbook and the rubric (docs/architecture.md, 3.4). |
|
sample
Package sample is the format of the reading measurement's samples, of its bank of tasks, of its sheet plan and of the split of its sheets: their types, how they are read from JSON and how they are checked.
|
Package sample is the format of the reading measurement's samples, of its bank of tasks, of its sheet plan and of the split of its sheets: their types, how they are read from JSON and how they are checked. |
|
samplecheck
Package samplecheck holds sample files of the eval protocol to the rules of sections 11 and 12 of spec's text of the contracts by spec's own code, its recipe sample-check, as section 13 has the runner refuse a sample "which the runner holds by the same code as sample-check": a repository other than spec MUST NOT write a check of its own (R93 spec; R69).
|
Package samplecheck holds sample files of the eval protocol to the rules of sections 11 and 12 of spec's text of the contracts by spec's own code, its recipe sample-check, as section 13 has the runner refuse a sample "which the runner holds by the same code as sample-check": a repository other than spec MUST NOT write a check of its own (R93 spec; R69). |
|
sheets
Package sheets reads the directory where the record mode of the board saves the measurement's sheets (R25), and tutor-eval draw the sheets it draws (R26), against the sheet plan: for each plan sheet its last file, read and checked as a sample.
|
Package sheets reads the directory where the record mode of the board saves the measurement's sheets (R25), and tutor-eval draw the sheets it draws (R26), against the sheet plan: for each plan sheet its last file, read and checked as a sample. |
|
states
Package states chooses the states of a sheet for the reading of unfinished work (О-8, О-21; T69): the moments of the writing at which a device that read on its own, without the learner asking, would read, and what the sheet shows at each.
|
Package states chooses the states of a sheet for the reading of unfinished work (О-8, О-21; T69): the moments of the writing at which a device that read on its own, without the learner asking, would read, and what the sheet shows at each. |
|
synth
Package synth draws synthetic samples and a synthetic bank of tasks for tests, and for the recording page until the measurement's own bank exists.
|
Package synth draws synthetic samples and a synthetic bank of tasks for tests, and for the recording page until the measurement's own bank exists. |
|
task
Package task gives each task of tutor's measurements — a task of a bank, solved on a sheet; a page of the workbook; an essay — the task of spec's module format 0.3 it is, with its checks: formatv0.Task (T103; R68 in docs/decisions.md).
|
Package task gives each task of tutor's measurements — a task of a bank, solved on a sheet; a page of the workbook; an essay — the task of spec's module format 0.3 it is, with its checks: formatv0.Task (T103; R68 in docs/decisions.md). |
|
value
Package value is how tutor reads a value as the module format's checks read it (R56 spec; the format text of spec, section 15, «Checks»): the normalization of steps 1 to 4, a number's value read in steps 1 to 5 and 7, and a text in a notation of number as a rational number, exactly.
|
Package value is how tutor reads a value as the module format's checks read it (R56 spec; the format text of spec, section 15, «Checks»): the normalization of steps 1 to 4, a number's value read in steps 1 to 5 and 7, and a text in a notation of number as a rational number, exactly. |
|
wordsjudge
Package wordsjudge is the judge of the tutor's words (T118; docs/architecture.md, 3.4, «Набор слов»): a model that reads a hint of the set of the words and says whether it tells the learner's sex, keeps to the task, suits a child and takes up the note at the side of the work, if there is one.
|
Package wordsjudge is the judge of the tutor's words (T118; docs/architecture.md, 3.4, «Набор слов»): a model that reads a hint of the set of the words and says whether it tells the learner's sex, keeps to the task, suits a child and takes up the note at the side of the work, if there is one. |
|
workbook
Package workbook is the measurement of the workbook in epic E4 (T78–T80; docs/architecture.md, 3.4, «Рабочая тетрадь»): its pages, which code draws in memory from eval/workbook.json, and the crop of each filled box, which is all a reading of the page sees (R53 spec, amendment of 2026-10-27): the ink of the box's strokes alone, cut by the rule of the eval protocol, without the box's frame and the print of its line.
|
Package workbook is the measurement of the workbook in epic E4 (T78–T80; docs/architecture.md, 3.4, «Рабочая тетрадь»): its pages, which code draws in memory from eval/workbook.json, and the crop of each filled box, which is all a reading of the page sees (R53 spec, amendment of 2026-10-27): the ink of the box's strokes alone, cut by the rule of the eval protocol, without the box's frame and the print of its line. |
|
Package provider is the port through which tutor reaches the AI providers.
|
Package provider is the port through which tutor reaches the AI providers. |
|
claude
Package claude is the adapter of Anthropic's Claude models, through the official Go SDK.
|
Package claude is the adapter of Anthropic's Claude models, through the official Go SDK. |
|
gpt
Package gpt is the adapter of OpenAI's GPT models, through the official Go SDK and the Responses API.
|
Package gpt is the adapter of OpenAI's GPT models, through the official Go SDK and the Responses API. |
|
Package words holds the checks of the tutor's words that api makes before they reach the learner, beside the leak check (R70 spec; architecture 1 and 3.5): the form of a hint and the rule of feedback by a rubric.
|
Package words holds the checks of the tutor's words that api makes before they reach the learner, beside the leak check (R70 spec; architecture 1 and 3.5): the form of a hint and the rule of feedback by a rubric. |