@altnovatrail/spec 0.7.9 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @altnovatrail/spec
2
2
 
3
- The types of [NovaTrail](https://github.com/altnovatrail)'s module format for TypeScript. The package covers:
3
+ The types of [NovaTrail](https://github.com/altnovatrail)'s module format for TypeScript, and from 0.8.0 on those of its admission table. The package covers:
4
4
  - the parts of a module and their open views;
5
5
  - the canonical view and the inventory of a package;
6
6
  - the module index;
@@ -10,6 +10,8 @@ They are generated from the format's schemas, [`format/schemas`](https://github.
10
10
 
11
11
  From 0.5.0 on, the package also holds the types of the element `<novatrail-canvas>`: the contract between the canvas and the learner's app. These are written by hand rather than generated, and only TypeScript has them.
12
12
 
13
+ From 0.8.0 on, it holds the types of the admission table too: which AI provider, on which route to AI, may receive the work of a learner of which age category ([the table's text](https://github.com/altnovatrail/spec/blob/main/admission/README.md)). They are generated from its schemas, `admission/schemas`, as the format's are.
14
+
13
15
  The package holds declarations alone, with no code to run, so import them with `import type`:
14
16
 
15
17
  ```ts
@@ -28,15 +30,17 @@ function show(task: open.Task, manifest: open.Manifest) {
28
30
 
29
31
  A field the object always holds is required, and any other is optional. That includes each field that only some branches of a schema give.
30
32
  - **`@altnovatrail/spec/formatv0/open`** holds the open view of each part, which is what the learner's app gets ([the format's text](https://github.com/altnovatrail/spec/blob/main/format/README.md#6-open-fields), section 6). Each type keeps its name from `formatv0` and only the fields marked `x-open`, so an open view has no check, no template and no solver.
33
+ - **`@altnovatrail/spec/admissionv0`** holds the types of the admission table's major version 0: the table, with its providers, deployment facts, rules of capabilities and cells, and the test vectors of the admission function's answers.
31
34
  - **`@altnovatrail/spec/canvas`** holds the types of `<novatrail-canvas>`:
32
- - `CanvasElement`, which describes the element's properties `tool`, `task`, `workedExample`, `demoState`, `manifest`, `media`, `history` and `filled` and its method `exportWork()`;
35
+ - `CanvasElement`, which describes the element's properties `tool`, `task`, `workedExample`, `demoState`, `manifest`, `media`, `history`, `marks` and `filled` and its method `exportWork()`;
33
36
  - `Media`, the function by which the consumer gives the files of the pictures: the canvas goes to no network;
34
37
  - the events `toolchange`, `historychange` and `demochange`, with `CanvasEventMap` naming them;
35
38
  - the state of a worked example's demo, `DemoState`;
36
39
  - the history of writing;
37
- - the work for checking, with the context of its submission.
40
+ - the work for checking, with the context of its submission;
41
+ - the tutor's marks of a submission, `Marks`, `Mark` and `Anchor`: their kind and place come from the contract between the app and the platform's API, the message `Mark` of `novatrail.api.v1` in the npm package `@altnovatrail/contracts`, and their name from the app.
38
42
 
39
- Its unions are exact: an event of the history is told by its `kind`, and the work of a sheet or of a workbook by its key, `png` or `cells`. The declarations need the DOM's types, so the consumer's `lib` must include `dom`. The tutor's marks are not in it yet: their types come with the contract between the app and the platform's API. The package registers nothing. The canvas's own package puts the element in `HTMLElementTagNameMap` and its events in `GlobalEventHandlersEventMap`.
43
+ Its unions are exact: an event of the history is told by its `kind`, and the work of a sheet or of a workbook by its key, `png` or `cells`. The declarations need the DOM's types, so the consumer's `lib` must include `dom`. The package registers nothing. The canvas's own package puts the element in `HTMLElementTagNameMap` and its events in `GlobalEventHandlersEventMap`.
40
44
 
41
45
  A type gives the shape of a value and nothing more: the schemas decide what is valid. Code that reads a value from elsewhere checks it against its schema first.
42
46
 
@@ -0,0 +1,377 @@
1
+ // Code generated by tools/types from admission/schemas; DO NOT EDIT.
2
+
3
+ /**
4
+ * The types of the admission table, major version 0, generated from the schemas of version 0.1 in
5
+ * admission/schemas by tools/types (R72, R73 and R96 in spec's docs/decisions.md): the same types
6
+ * as the Go package admissionv0, by the same names — the table, and the vectors of answers of the
7
+ * admission function. The schemas decide what is valid: a type gives the shape of a value alone,
8
+ * and code that reads a value from elsewhere checks it against its schema first. A field the object
9
+ * always holds is required; any other is optional.
10
+ *
11
+ * @packageDocumentation
12
+ */
13
+
14
+ // The types of admission-table.schema.json.
15
+
16
+ /**
17
+ * AdmissionTable is the type of admission-table.schema.json.
18
+ *
19
+ * The rules of admission to AI by age category (section 4 of the admission text): the AI providers,
20
+ * the dictionary of deployment facts, the rule of each capability of AI for each age category, and
21
+ * the cell of each provider, AI route and age category. What the table does not name is closed.
22
+ */
23
+ export interface AdmissionTable {
24
+ /**
25
+ * The AI providers the table knows, by code: the code that tutor's adapters and the admission
26
+ * function name a provider by. A provider that is not here is closed (R65).
27
+ */
28
+ readonly providers: Readonly<Record<Provider, AiProvider>>;
29
+ /**
30
+ * The dictionary of deployment facts, by code: what an operator declares about its agreements
31
+ * with each provider, for some age categories (section 5 of the admission text).
32
+ */
33
+ readonly facts: Readonly<Record<Fact, DeploymentFact>>;
34
+ /**
35
+ * The rule of each capability of AI for each age category: the first part of the table, which the
36
+ * admission function checks first. A capability and age category with no rule are closed.
37
+ */
38
+ readonly capabilities: readonly CapabilityRule[];
39
+ /**
40
+ * The cell of each AI provider, AI route and age category: the second part of the table. A
41
+ * provider, AI route and age category with no cell are closed.
42
+ */
43
+ readonly cells: readonly Cell[];
44
+ }
45
+
46
+ /**
47
+ * Provider is the type of admission-table.schema.json#/$defs/provider.
48
+ *
49
+ * The code of an AI provider, in snake_case: openai, anthropic.
50
+ */
51
+ export type Provider = string;
52
+
53
+ /**
54
+ * AiProvider is the type of admission-table.schema.json#/$defs/ai_provider.
55
+ *
56
+ * An AI provider of the table: what privacy 5.3 names it.
57
+ */
58
+ export interface AiProvider {
59
+ /**
60
+ * The provider's name, as privacy 5.3 names it.
61
+ */
62
+ readonly name: string;
63
+ }
64
+
65
+ /**
66
+ * Fact is the type of admission-table.schema.json#/$defs/fact.
67
+ *
68
+ * The code of a deployment fact, in snake_case: data_processing_agreement.
69
+ */
70
+ export type Fact = string;
71
+
72
+ /**
73
+ * DeploymentFact is the type of admission-table.schema.json#/$defs/deployment_fact.
74
+ *
75
+ * A deployment fact of the dictionary: what the operator of a deployment declares by it.
76
+ */
77
+ export interface DeploymentFact {
78
+ /**
79
+ * What the operator of a deployment declares by the fact, and when it holds.
80
+ */
81
+ readonly description: string;
82
+ }
83
+
84
+ /**
85
+ * CapabilityRule is the type of admission-table.schema.json#/$defs/capability_rule.
86
+ *
87
+ * The rule of a capability of AI for an age category.
88
+ */
89
+ export interface CapabilityRule {
90
+ /**
91
+ * The capability of AI.
92
+ */
93
+ readonly capability: Capability;
94
+ /**
95
+ * The age category.
96
+ */
97
+ readonly age_category: AgeCategory;
98
+ /**
99
+ * Whether the capability may serve a learner of the category: open, or closed.
100
+ */
101
+ readonly admission: CapabilityRuleAdmission;
102
+ /**
103
+ * What the rule rests on.
104
+ */
105
+ readonly basis: Basis;
106
+ }
107
+
108
+ /**
109
+ * Capability is the type of admission-table.schema.json#/$defs/capability.
110
+ *
111
+ * A capability of AI (concepts 10): reading handwriting, reading text, the analysis of a solution's
112
+ * steps, the assessment by a rubric, the hint, and voice — the voicing of the tutor by a provider
113
+ * and the learner's voice input, which are one capability for now.
114
+ */
115
+ export type Capability = "handwriting_reading" | "text_reading" | "solution_analysis" | "rubric_assessment" | "hint" | "voice";
116
+
117
+ /**
118
+ * AgeCategory is the type of admission-table.schema.json#/$defs/age_category.
119
+ *
120
+ * An age category, by its code (R46): under 13; from 13 to the age of digital consent in the
121
+ * learner's country; from that age to 18; 18 and over.
122
+ */
123
+ export type AgeCategory = "under_13" | "from_13_to_consent" | "from_consent_to_18" | "adult";
124
+
125
+ /**
126
+ * CapabilityRuleAdmission is the type of
127
+ * admission-table.schema.json#/$defs/capability_rule/properties/admission.
128
+ *
129
+ * Whether the capability may serve a learner of the category: open, or closed.
130
+ */
131
+ export type CapabilityRuleAdmission = "open" | "closed";
132
+
133
+ /**
134
+ * Basis is the type of admission-table.schema.json#/$defs/basis.
135
+ *
136
+ * What the rule or the cell rests on, in spec's documents.
137
+ */
138
+ export type Basis = readonly Citation[];
139
+
140
+ /**
141
+ * Citation is the type of admission-table.schema.json#/$defs/citation.
142
+ *
143
+ * What a rule or a cell rests on, in spec's documents: a decision, R47; an open question of a
144
+ * register, П-4; or a section of a document, privacy 5.3.
145
+ */
146
+ export type Citation = string;
147
+
148
+ /**
149
+ * Cell is the type of admission-table.schema.json#/$defs/cell.
150
+ *
151
+ * A cell of the table: an AI provider, an AI route and an age category, and whether the work of a
152
+ * learner of the category may go to the provider on the route.
153
+ */
154
+ export interface Cell {
155
+ /**
156
+ * The AI provider, by its code in providers.
157
+ */
158
+ readonly provider: Provider;
159
+ /**
160
+ * The AI route.
161
+ */
162
+ readonly ai_route: AiRoute;
163
+ /**
164
+ * The age category.
165
+ */
166
+ readonly age_category: AgeCategory;
167
+ /**
168
+ * Whether the provider, on the route, may receive the work of a learner of the category: closed;
169
+ * open; or open with facts — only when every deployment fact in facts holds for the provider and
170
+ * the category. On the own key a cell is closed or open, never open with facts: the agreement
171
+ * with the provider is the key owner's, and a deployment declares nothing of it (privacy 5.2).
172
+ */
173
+ readonly admission: CellAdmission;
174
+ /**
175
+ * The deployment facts that open the cell, by code in facts, in the order the admission function
176
+ * checks them. Only a cell open with facts has them.
177
+ */
178
+ readonly facts?: readonly Fact[];
179
+ /**
180
+ * The provider's terms that the cell reads: each its row of privacy 5.3 and the date it was read.
181
+ */
182
+ readonly terms: readonly Terms[];
183
+ /**
184
+ * What the cell rests on besides the provider's terms.
185
+ */
186
+ readonly basis: Basis;
187
+ }
188
+
189
+ /**
190
+ * AiRoute is the type of admission-table.schema.json#/$defs/ai_route.
191
+ *
192
+ * An AI route: platform AI, under the platform's agreements with the providers, or the own key of
193
+ * an account owner who learns, at the profile of the category adult (concepts 14).
194
+ */
195
+ export type AiRoute = "platform_ai" | "own_key";
196
+
197
+ /**
198
+ * CellAdmission is the type of admission-table.schema.json#/$defs/cell/properties/admission.
199
+ *
200
+ * Whether the provider, on the route, may receive the work of a learner of the category: closed;
201
+ * open; or open with facts — only when every deployment fact in facts holds for the provider and
202
+ * the category. On the own key a cell is closed or open, never open with facts: the agreement with
203
+ * the provider is the key owner's, and a deployment declares nothing of it (privacy 5.2).
204
+ */
205
+ export type CellAdmission = "closed" | "open" | "open_with_facts";
206
+
207
+ /**
208
+ * Terms is the type of admission-table.schema.json#/$defs/terms.
209
+ *
210
+ * The provider's terms that a cell reads, by its row of privacy 5.3 and the date they were read.
211
+ */
212
+ export interface Terms {
213
+ /**
214
+ * The provider's row in the table of privacy 5.3, as its first column names it: OpenAI, Google
215
+ * Cloud, Vertex AI.
216
+ */
217
+ readonly row: string;
218
+ /**
219
+ * The date the provider's terms that the row quotes were last read, YYYY-MM-DD.
220
+ */
221
+ readonly read: string;
222
+ }
223
+
224
+ // The types of answer-vector.schema.json.
225
+
226
+ /**
227
+ * AnswerVector is the type of answer-vector.schema.json.
228
+ *
229
+ * A test vector of answers (section 9 of the admission text): a table of its own and requests to
230
+ * the admission function, each with the deployment facts declared and the answer that sections 5
231
+ * and 6 give. An implementation computes each answer and gets exactly this one.
232
+ */
233
+ export interface AnswerVector {
234
+ /**
235
+ * The table the function reads, which breaks no rule of a table.
236
+ */
237
+ readonly table: AdmissionTable;
238
+ /**
239
+ * The requests, each with the facts declared and its answer.
240
+ */
241
+ readonly cases: readonly Case[];
242
+ }
243
+
244
+ /**
245
+ * Case is the type of answer-vector.schema.json#/$defs/case.
246
+ *
247
+ * A request to the admission function and its answer.
248
+ */
249
+ export interface Case {
250
+ /**
251
+ * What the function is asked.
252
+ */
253
+ readonly request: Request;
254
+ /**
255
+ * The deployment facts declared, which the function gets as a value; none when left out.
256
+ */
257
+ readonly facts?: DeclaredFacts;
258
+ /**
259
+ * The function's answer, by the table alone: the check of the model comes after it, and is
260
+ * tutor's.
261
+ */
262
+ readonly answer: Answer;
263
+ }
264
+
265
+ /**
266
+ * Request is the type of answer-vector.schema.json#/$defs/request.
267
+ *
268
+ * A request to the admission function, but for the model.
269
+ */
270
+ export interface Request {
271
+ /**
272
+ * The capability of AI the call serves.
273
+ */
274
+ readonly capability: Capability;
275
+ /**
276
+ * The AI route of the call.
277
+ */
278
+ readonly ai_route: AiRoute;
279
+ /**
280
+ * The AI provider of the call, by its code.
281
+ */
282
+ readonly provider: Provider;
283
+ /**
284
+ * The age category of the learner whose work the call carries.
285
+ */
286
+ readonly age_category: AgeCategory;
287
+ }
288
+
289
+ /**
290
+ * DeclaredFacts is the type of answer-vector.schema.json#/$defs/declared_facts.
291
+ *
292
+ * The deployment facts declared, by provider: what the function gets by value from the file of a
293
+ * deployment's configuration (section 5 of the admission text).
294
+ */
295
+ export type DeclaredFacts = Readonly<Record<Provider, ProviderFacts>>;
296
+
297
+ /**
298
+ * ProviderFacts is the type of answer-vector.schema.json#/$defs/provider_facts.
299
+ *
300
+ * The deployment facts declared for one provider, each with the age categories for which it holds.
301
+ */
302
+ export type ProviderFacts = Readonly<Record<Fact, readonly AgeCategory[]>>;
303
+
304
+ /**
305
+ * Answer is the type of answer-vector.schema.json#/$defs/answer.
306
+ *
307
+ * The answer of the admission function by the table: admitted with the cell, or refused with the
308
+ * reason, the rule or cell that refuses it when there is one, and the missing fact.
309
+ */
310
+ export interface Answer {
311
+ /**
312
+ * Whether the table admits the request.
313
+ */
314
+ readonly admitted: boolean;
315
+ /**
316
+ * Why the table refuses it: the capability's rule is closed or missing; the cell is closed or
317
+ * missing; a fact the cell needs is not declared.
318
+ */
319
+ readonly reason?: AnswerReason;
320
+ /**
321
+ * The rule of the capability that refuses the request, when the table has one.
322
+ */
323
+ readonly capability_rule?: CapabilityRuleKey;
324
+ /**
325
+ * The cell that admits or refuses the request, when the table has one.
326
+ */
327
+ readonly cell?: CellKey;
328
+ /**
329
+ * The first fact of the cell, in its order, that is not declared for the provider and the age
330
+ * category.
331
+ */
332
+ readonly fact?: Fact;
333
+ }
334
+
335
+ /**
336
+ * AnswerReason is the type of answer-vector.schema.json#/$defs/answer/properties/reason.
337
+ *
338
+ * Why the table refuses it: the capability's rule is closed or missing; the cell is closed or
339
+ * missing; a fact the cell needs is not declared.
340
+ */
341
+ export type AnswerReason = "capability_closed" | "cell_closed" | "fact_missing";
342
+
343
+ /**
344
+ * CapabilityRuleKey is the type of answer-vector.schema.json#/$defs/capability_rule_key.
345
+ *
346
+ * A rule of a capability of AI, by its capability and age category.
347
+ */
348
+ export interface CapabilityRuleKey {
349
+ /**
350
+ * The rule's capability of AI.
351
+ */
352
+ readonly capability: Capability;
353
+ /**
354
+ * The rule's age category.
355
+ */
356
+ readonly age_category: AgeCategory;
357
+ }
358
+
359
+ /**
360
+ * CellKey is the type of answer-vector.schema.json#/$defs/cell_key.
361
+ *
362
+ * A cell of the table, by its provider, AI route and age category.
363
+ */
364
+ export interface CellKey {
365
+ /**
366
+ * The cell's AI provider.
367
+ */
368
+ readonly provider: Provider;
369
+ /**
370
+ * The cell's AI route.
371
+ */
372
+ readonly ai_route: AiRoute;
373
+ /**
374
+ * The cell's age category.
375
+ */
376
+ readonly age_category: AgeCategory;
377
+ }
package/canvas/index.d.ts CHANGED
@@ -10,10 +10,12 @@
10
10
  * types of the task, of the worked example and of the manifest are the module format's open views,
11
11
  * formatv0/open.
12
12
  *
13
- * The tutor's marks — the property `marks` and the types of a mark — wait for the contract of epic
14
- * E3, and are canvas's own until then. The element's members beyond this contract — its commands
15
- * undo() and clear(), which its own buttons call — and its place in the DOM's maps of tags and
16
- * events are canvas's too: its package registers the element. The declarations take the DOM's
13
+ * It takes the tutor's marks of a submission too, by a property, with the submission's context:
14
+ * their kind and their place come from the contract between app and api, novatrail.api.v1, whose
15
+ * message `Mark` these types are checked against, and their names from app (contracts/README.md,
16
+ * section 15; R83). The element's members beyond this contract — its commands undo() and clear(),
17
+ * which its own buttons call — and its place in the DOM's maps of tags and events are canvas's:
18
+ * its package registers the element. The declarations take the DOM's
17
19
  * types: Blob, CustomEvent and HTMLElement.
18
20
  *
19
21
  * @packageDocumentation
@@ -268,6 +270,39 @@ export interface ExportedWorkbook {
268
270
  /** The work for checking, of a sheet or of a workbook: its key, `png` or `cells`, tells which. */
269
271
  export type ExportedWork = ExportedSheet | ExportedWorkbook;
270
272
 
273
+ /**
274
+ * Where a tutor's mark is: a group of strokes by its label, an answer cell by its place, or a box on
275
+ * the crop the model saw, as the contract's mark has its place (contracts/README.md, section 15). On
276
+ * a workbook a mark stands on a cell alone. A group's label comes from api only if the frames of the
277
+ * groups go with the work (repositories 8, Т-31).
278
+ */
279
+ export type Anchor =
280
+ | { readonly group: string }
281
+ | { readonly cell: CellPlace }
282
+ /** [ymin, xmin, ymax, xmax] in whole thousandths of the crop's height and width; min < max. */
283
+ | { readonly box: readonly [number, number, number, number] };
284
+
285
+ /** A mark of the tutor's layer: a frame, so far, with where it is and its name. */
286
+ export interface Mark {
287
+ readonly kind: "frame";
288
+ readonly at: Anchor;
289
+ /**
290
+ * What a screen reader names it, in app's words, in the language of its screen: "Tutor's mark 1
291
+ * of 2". The element words nothing, and a name empty or of white space alone is a TypeError.
292
+ */
293
+ readonly name: string;
294
+ }
295
+
296
+ /**
297
+ * The tutor's marks of one submission, with the context of the submission that the element gave
298
+ * with its work and app kept: a sheet's or a workbook's. The marks are those of one answer of
299
+ * api, in its order.
300
+ */
301
+ export interface Marks {
302
+ readonly submission: Submission;
303
+ readonly marks: readonly Mark[];
304
+ }
305
+
271
306
  /** The events of the element, by their names, for a consumer's map of events. */
272
307
  export interface CanvasEventMap {
273
308
  historychange: HistoryChangeEvent;
@@ -341,6 +376,22 @@ export interface CanvasElement extends HTMLElement {
341
376
  */
342
377
  get history(): readonly HistoryEvent[];
343
378
  set history(history: readonly HistoryEvent[] | undefined);
379
+ /**
380
+ * The tutor's marks of one submission, on the tutor's layer, given after the task and the
381
+ * history they hold on to. A mark holds on to the strokes the model saw at its place and is drawn
382
+ * around those of them the sheet shows, as they are now: a box on the crop takes the strokes by
383
+ * the rule of snapping (contracts/README.md, section 12), and a cell of a workbook is framed with
384
+ * its box — round the box alone when the box was empty. A cell on a sheet, and a box that comes
385
+ * near no stroke, have no frame: the question is asked without one. A submission goes back to the
386
+ * sheet or the page it was made on, as its digest tells: one of other strokes or other boxes is a
387
+ * TypeError, and so are marks given before the task and the history, a mark of another kind, a
388
+ * name empty or of white space alone, a group's label the submission has not, a box that is not
389
+ * whole thousandths with min < max, and on a workbook any place but a cell. A new history puts the
390
+ * marks back on their strokes, or takes them off. `undefined` takes the marks off. A worked
391
+ * example's sheet has nothing to mark: marks are a TypeError there.
392
+ */
393
+ get marks(): Marks | undefined;
394
+ set marks(marks: Marks | undefined);
344
395
  /**
345
396
  * Which answer slots are filled, frozen: a workbook's boxes, and on a sheet the task's one slot
346
397
  * bound `anywhere` or `sheet`. `null` on a sheet whose slots are bound `choice`, whose options app
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@altnovatrail/spec",
3
- "version": "0.7.9",
4
- "description": "The types of NovaTrail's module format for TypeScript, generated from its schemas: the parts of a module and their open views, the canonical view, the inventory, the module index and the test vectors. And the types of the element <novatrail-canvas>, the contract of the canvas and the app.",
3
+ "version": "0.8.1",
4
+ "description": "The types of NovaTrail's module format for TypeScript, generated from its schemas: the parts of a module and their open views, the canonical view, the inventory, the module index and the test vectors. And the types of the element <novatrail-canvas>, the contract of the canvas and the app. And the types of the admission table, which says which AI provider may serve which age category.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
7
7
  "type": "git",
@@ -18,11 +18,15 @@
18
18
  "./canvas": {
19
19
  "types": "./canvas/index.d.ts"
20
20
  },
21
+ "./admissionv0": {
22
+ "types": "./admissionv0/index.d.ts"
23
+ },
21
24
  "./package.json": "./package.json"
22
25
  },
23
26
  "files": [
24
27
  "formatv0",
25
- "canvas"
28
+ "canvas",
29
+ "admissionv0"
26
30
  ],
27
31
  "sideEffects": false
28
32
  }