@mmon-co/ncept-default-theory 1.1.0 → 3.0.0

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/dist/index.d.ts CHANGED
@@ -2,6 +2,16 @@
2
2
  export declare const defaultTheory: {
3
3
  version: string;
4
4
  id: "default";
5
+ migrations: readonly Readonly<{
6
+ from: import("@mmon-co/ncept-core").TheoryDataVersion;
7
+ to: import("@mmon-co/ncept-core").TheoryDataVersion;
8
+ migratePatch?(content: import("@mmon-co/ncept-core").PatchContent, graphs?: {
9
+ basesChanged: boolean;
10
+ resolve: (candidate?: import("@mmon-co/ncept-core").PatchContent) => import("@mmon-co/ncept-core").ResolvedGraph;
11
+ }): import("@mmon-co/ncept-core").PatchContent;
12
+ migrate?(profile: import("@mmon-co/ncept-core").Profile): import("@mmon-co/ncept-core").Profile;
13
+ migrateOutcome?(payload: unknown, profile: import("@mmon-co/ncept-core").Profile): unknown;
14
+ }>[];
5
15
  initState: typeof import("./state.js").initDefaultState;
6
16
  project: typeof import("./tags.js").projectDefault;
7
17
  progress: typeof import("./reading.js").progressDefault;
@@ -12,13 +22,12 @@ export declare const defaultTheory: {
12
22
  tags: readonly [...string[], "item-outcomes", "instability", "unused", "coarse", "lesson-split", "self-report", "edge-contradiction", "homeless"];
13
23
  outcomes: {
14
24
  completion: typeof import("./state.js").isCompletionOutcome;
15
- recall: typeof import("./outcomes.js").isRecallOutcome;
16
25
  quiz: typeof import("./outcomes.js").isQuizOutcome;
17
26
  attempt: typeof import("./outcomes.js").isAttemptOutcome;
18
27
  };
19
28
  chat: {
20
- open: (ctx: import("@mmon-co/ncept-core/theory").ChatContext<import("./state.js").DefaultState>, mode?: "empty" | "charting" | "authoring" | "lesson") => import("@mmon-co/ncept-core/observations").Program<import("@mmon-co/ncept-core/theory").ChatSetup<import("./state.js").DefaultState>>;
21
- turn: (ctx: import("@mmon-co/ncept-core/theory").ChatContext<import("./state.js").DefaultState>, mode?: "empty" | "charting" | "authoring" | "lesson") => import("@mmon-co/ncept-core/observations").Program<import("@mmon-co/ncept-core/theory").ChatSetup<import("./state.js").DefaultState>>;
29
+ open: (ctx: import("@mmon-co/ncept-core").ChatContext<import("./state.js").DefaultState>, mode?: "empty" | "charting" | "authoring" | "lesson") => import("@mmon-co/ncept-core").Program<import("@mmon-co/ncept-core").ChatSetup<import("./state.js").DefaultState>>;
30
+ turn: (ctx: import("@mmon-co/ncept-core").ChatContext<import("./state.js").DefaultState>, mode?: "empty" | "charting" | "authoring" | "lesson") => import("@mmon-co/ncept-core").Program<import("@mmon-co/ncept-core").ChatSetup<import("./state.js").DefaultState>>;
22
31
  reply: typeof import("./evaluation.js").evaluateWatchedReply;
23
32
  };
24
33
  modes: {
@@ -29,26 +38,26 @@ export declare const defaultTheory: {
29
38
  required: false;
30
39
  kinds: never[];
31
40
  };
32
- capabilities: readonly import("@mmon-co/ncept-core/theory").HostCapability[];
41
+ capabilities: readonly import("@mmon-co/ncept-core").HostCapability[];
33
42
  switches: {
34
43
  mode: string;
35
44
  then: "here";
36
45
  }[];
37
- setup: (ctx: import("@mmon-co/ncept-core/theory").ChatContext<import("./state.js").DefaultState>) => import("@mmon-co/ncept-core/observations").Program<Readonly<{
46
+ setup: (ctx: import("@mmon-co/ncept-core").ChatContext<import("./state.js").DefaultState>) => import("@mmon-co/ncept-core").Program<Readonly<{
38
47
  prompt: string;
39
48
  context?: string;
40
49
  tools: readonly Readonly<{
41
50
  name: string;
42
51
  description: string;
43
- schema: import("@mmon-co/ncept-core/observations").JsonSchema;
52
+ schema: import("@mmon-co/ncept-core").JsonSchema;
44
53
  members?: readonly Readonly</*elided*/ any>[] | undefined;
45
- run(args: unknown, ctx: import("@mmon-co/ncept-core/theory").ChatContext<import("./state.js").DefaultState>): import("@mmon-co/ncept-core/observations").Program<unknown>;
54
+ run(args: unknown, ctx: import("@mmon-co/ncept-core").ChatContext<import("./state.js").DefaultState>): import("@mmon-co/ncept-core").Program<unknown>;
46
55
  }>[];
47
56
  skills: readonly Readonly<{
48
57
  name: string;
49
58
  description: string;
50
59
  body: string;
51
- resources?: readonly import("@mmon-co/ncept-core/theory").SkillResource[];
60
+ resources?: readonly import("@mmon-co/ncept-core").SkillResource[];
52
61
  }>[];
53
62
  }>>;
54
63
  };
@@ -61,9 +70,9 @@ export declare const defaultTheory: {
61
70
  }[];
62
71
  entry: {
63
72
  required: false;
64
- kinds: ("mission" | "checkpoint" | "goal" | "target")[];
73
+ kinds: ("mission" | "checkpoint" | "target" | "goal")[];
65
74
  };
66
- capabilities: readonly import("@mmon-co/ncept-core/theory").HostCapability[];
75
+ capabilities: readonly import("@mmon-co/ncept-core").HostCapability[];
67
76
  switches: {
68
77
  mode: string;
69
78
  then: "next";
@@ -71,21 +80,21 @@ export declare const defaultTheory: {
71
80
  kind: "brief";
72
81
  };
73
82
  }[];
74
- setup: (ctx: import("@mmon-co/ncept-core/theory").ChatContext<import("./state.js").DefaultState>) => import("@mmon-co/ncept-core/observations").Program<Readonly<{
83
+ setup: (ctx: import("@mmon-co/ncept-core").ChatContext<import("./state.js").DefaultState>) => import("@mmon-co/ncept-core").Program<Readonly<{
75
84
  prompt: string;
76
85
  context?: string;
77
86
  tools: readonly Readonly<{
78
87
  name: string;
79
88
  description: string;
80
- schema: import("@mmon-co/ncept-core/observations").JsonSchema;
89
+ schema: import("@mmon-co/ncept-core").JsonSchema;
81
90
  members?: readonly Readonly</*elided*/ any>[] | undefined;
82
- run(args: unknown, ctx: import("@mmon-co/ncept-core/theory").ChatContext<import("./state.js").DefaultState>): import("@mmon-co/ncept-core/observations").Program<unknown>;
91
+ run(args: unknown, ctx: import("@mmon-co/ncept-core").ChatContext<import("./state.js").DefaultState>): import("@mmon-co/ncept-core").Program<unknown>;
83
92
  }>[];
84
93
  skills: readonly Readonly<{
85
94
  name: string;
86
95
  description: string;
87
96
  body: string;
88
- resources?: readonly import("@mmon-co/ncept-core/theory").SkillResource[];
97
+ resources?: readonly import("@mmon-co/ncept-core").SkillResource[];
89
98
  }>[];
90
99
  }>>;
91
100
  };
@@ -96,23 +105,23 @@ export declare const defaultTheory: {
96
105
  required: false;
97
106
  kinds: ("mission" | "goal")[];
98
107
  };
99
- capabilities: readonly import("@mmon-co/ncept-core/theory").HostCapability[];
108
+ capabilities: readonly import("@mmon-co/ncept-core").HostCapability[];
100
109
  switches: never[];
101
- setup: (ctx: import("@mmon-co/ncept-core/theory").ChatContext<import("./state.js").DefaultState>) => import("@mmon-co/ncept-core/observations").Program<Readonly<{
110
+ setup: (ctx: import("@mmon-co/ncept-core").ChatContext<import("./state.js").DefaultState>) => import("@mmon-co/ncept-core").Program<Readonly<{
102
111
  prompt: string;
103
112
  context?: string;
104
113
  tools: readonly Readonly<{
105
114
  name: string;
106
115
  description: string;
107
- schema: import("@mmon-co/ncept-core/observations").JsonSchema;
116
+ schema: import("@mmon-co/ncept-core").JsonSchema;
108
117
  members?: readonly Readonly</*elided*/ any>[] | undefined;
109
- run(args: unknown, ctx: import("@mmon-co/ncept-core/theory").ChatContext<import("./state.js").DefaultState>): import("@mmon-co/ncept-core/observations").Program<unknown>;
118
+ run(args: unknown, ctx: import("@mmon-co/ncept-core").ChatContext<import("./state.js").DefaultState>): import("@mmon-co/ncept-core").Program<unknown>;
110
119
  }>[];
111
120
  skills: readonly Readonly<{
112
121
  name: string;
113
122
  description: string;
114
123
  body: string;
115
- resources?: readonly import("@mmon-co/ncept-core/theory").SkillResource[];
124
+ resources?: readonly import("@mmon-co/ncept-core").SkillResource[];
116
125
  }>[];
117
126
  }>>;
118
127
  };
@@ -123,7 +132,7 @@ export declare const defaultTheory: {
123
132
  required: true;
124
133
  kinds: ("lesson" | "review")[];
125
134
  };
126
- capabilities: readonly import("@mmon-co/ncept-core/theory").HostCapability[];
135
+ capabilities: readonly import("@mmon-co/ncept-core").HostCapability[];
127
136
  metadataKeys: readonly string[] | undefined;
128
137
  switches: ({
129
138
  mode: string;
@@ -140,35 +149,35 @@ export declare const defaultTheory: {
140
149
  focus: string;
141
150
  };
142
151
  })[];
143
- setup: (ctx: import("@mmon-co/ncept-core/theory").ChatContext<import("./state.js").DefaultState>) => import("@mmon-co/ncept-core/observations").Program<Readonly<{
152
+ setup: (ctx: import("@mmon-co/ncept-core").ChatContext<import("./state.js").DefaultState>) => import("@mmon-co/ncept-core").Program<Readonly<{
144
153
  prompt: string;
145
154
  context?: string;
146
155
  tools: readonly Readonly<{
147
156
  name: string;
148
157
  description: string;
149
- schema: import("@mmon-co/ncept-core/observations").JsonSchema;
158
+ schema: import("@mmon-co/ncept-core").JsonSchema;
150
159
  members?: readonly Readonly</*elided*/ any>[] | undefined;
151
- run(args: unknown, ctx: import("@mmon-co/ncept-core/theory").ChatContext<import("./state.js").DefaultState>): import("@mmon-co/ncept-core/observations").Program<unknown>;
160
+ run(args: unknown, ctx: import("@mmon-co/ncept-core").ChatContext<import("./state.js").DefaultState>): import("@mmon-co/ncept-core").Program<unknown>;
152
161
  }>[];
153
162
  skills: readonly Readonly<{
154
163
  name: string;
155
164
  description: string;
156
165
  body: string;
157
- resources?: readonly import("@mmon-co/ncept-core/theory").SkillResource[];
166
+ resources?: readonly import("@mmon-co/ncept-core").SkillResource[];
158
167
  }>[];
159
168
  }>>;
160
169
  };
161
170
  };
162
- noEventHook: (input: import("@mmon-co/ncept-core/observations").PlatformEvent) => input is {
171
+ noEventHook: (input: import("@mmon-co/ncept-core").PlatformEvent) => input is {
163
172
  readonly kind: "surface.open";
164
- readonly surface: import("@mmon-co/ncept-core/observations").SurfaceId;
173
+ readonly surface: import("@mmon-co/ncept-core").SurfaceId;
165
174
  readonly format: string;
166
- readonly about: readonly import("@mmon-co/ncept-core/patch").NodeId[];
175
+ readonly about: readonly import("@mmon-co/ncept-core").NodeId[];
167
176
  } | {
168
177
  readonly kind: "object.put";
169
- readonly object: import("@mmon-co/ncept-core/observations").ObjectId;
170
- readonly meta: import("@mmon-co/ncept-core/observations").ObjectMeta;
171
- readonly surface?: import("@mmon-co/ncept-core/observations").SurfaceId;
178
+ readonly object: import("@mmon-co/ncept-core").ObjectId;
179
+ readonly meta: import("@mmon-co/ncept-core").ObjectMeta;
180
+ readonly surface?: import("@mmon-co/ncept-core").SurfaceId;
172
181
  } | {
173
182
  readonly kind: "mission";
174
183
  readonly text: string;
@@ -178,7 +187,7 @@ export declare const defaultTheory: {
178
187
  /** The range a new Profile accepts: the default Theory's current minor, which a patch deploy keeps. */
179
188
  export declare const DEFAULT_THEORY_REQUIREMENT: {
180
189
  readonly theory: "default";
181
- readonly range: "~1.0";
190
+ readonly range: "~1.4";
182
191
  };
183
192
  export * from "./path.js";
184
193
  export * from "./reading.js";
@@ -190,6 +199,7 @@ export * from "./state.js";
190
199
  export * from "./completion.js";
191
200
  export * from "./tags.js";
192
201
  export * from "./outcomes.js";
202
+ export { recallToAttemptMigration, reviewScheduleMigration } from "./migrations.js";
193
203
  export * from "./roleplay.js";
194
204
  export * from "./chat.js";
195
205
  export * from "./opening.js";
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ export const defaultTheory = {
6
6
  version: `${implementation.version}+${theoryContent}`,
7
7
  };
8
8
  /** The range a new Profile accepts: the default Theory's current minor, which a patch deploy keeps. */
9
- export const DEFAULT_THEORY_REQUIREMENT = { theory: defaultTheory.id, range: "~1.0" };
9
+ export const DEFAULT_THEORY_REQUIREMENT = { theory: defaultTheory.id, range: "~1.4" };
10
10
  export * from "./path.js";
11
11
  export * from "./reading.js";
12
12
  export * from "./timing.js";
@@ -17,6 +17,7 @@ export * from "./state.js";
17
17
  export * from "./completion.js";
18
18
  export * from "./tags.js";
19
19
  export * from "./outcomes.js";
20
+ export { recallToAttemptMigration, reviewScheduleMigration } from "./migrations.js";
20
21
  export * from "./roleplay.js";
21
22
  export * from "./chat.js";
22
23
  export * from "./opening.js";
@@ -0,0 +1,23 @@
1
+ import { type Profile } from "@mmon-co/ncept-core";
2
+ import { type PatchContent, type ExactPatchRef } from "@mmon-co/ncept-core/patch";
3
+ import { type TheoryMigration } from "@mmon-co/ncept-core/theory";
4
+ declare function migratePayload(payload: unknown, revision: ExactPatchRef): unknown;
5
+ declare function migrate(profile: Profile): Profile;
6
+ export declare const recallToAttemptMigration: {
7
+ from: "1.0";
8
+ to: "1.1";
9
+ migrate: typeof migrate;
10
+ migrateOutcome: (payload: unknown, profile: Profile) => unknown;
11
+ migratePayload: typeof migratePayload;
12
+ };
13
+ export declare const reviewScheduleMigration: {
14
+ from: "1.3";
15
+ to: "1.4";
16
+ migratePatch(content: PatchContent, graphs: {
17
+ basesChanged: boolean;
18
+ resolve: (candidate?: PatchContent) => import("@mmon-co/ncept-core").ResolvedGraph;
19
+ } | undefined): PatchContent;
20
+ migrate(profile: Profile): Profile;
21
+ };
22
+ export declare const migrations: readonly TheoryMigration[];
23
+ export {};
@@ -0,0 +1,152 @@
1
+ import { canonicalJson, attachmentDigest, isObservation } from "@mmon-co/ncept-core";
2
+ import { isNodeId, candidateRevision, nodeCascadedProperty, isMetadataValue, resolvePatchBundle, sameExactPatchRef, } from "@mmon-co/ncept-core/patch";
3
+ import { migrateTheoryPatchClosure } from "@mmon-co/ncept-core/theory";
4
+ import { pathProperty } from "./path.js";
5
+ import { REVIEW_PROPERTY } from "./schedules.js";
6
+ import { isAttemptOutcome } from "./outcomes.js";
7
+ function object(value) {
8
+ return typeof value === "object" && value !== null && !Array.isArray(value);
9
+ }
10
+ function isRecall(payload) {
11
+ const { card, grade } = payload;
12
+ return (object(card) &&
13
+ object(grade) &&
14
+ typeof card.id === "string" &&
15
+ typeof card.front === "string" &&
16
+ typeof card.back === "string" &&
17
+ Array.isArray(card.nodes) &&
18
+ card.nodes.every((node) => object(node) && isNodeId(node.node)) &&
19
+ typeof grade.answer === "string" &&
20
+ ["again", "hard", "good", "easy"].includes(String(grade.grade)));
21
+ }
22
+ function migratePayload(payload, revision) {
23
+ if (!object(payload) || payload.kind !== "recall")
24
+ return payload;
25
+ if (!isRecall(payload))
26
+ throw new Error("Invalid historical recall");
27
+ const { card, grade } = payload;
28
+ const body = {
29
+ about: card.nodes.map(({ node }) => node),
30
+ prompt: card.front,
31
+ answer: { kind: "short" },
32
+ grader: { by: "learner", rubric: card.back, accepted: [card.back] },
33
+ };
34
+ // Freeze the old rule once. Forward evidence uses the declared answer kind and observed assistance.
35
+ const normalize = (value) => value.trim().toLocaleLowerCase().replace(/\s+/g, " ");
36
+ const back = normalize(card.back);
37
+ const leaksAnswer = back.length > 0 && normalize(card.front).includes(back);
38
+ const offersCandidates = /(^|\n)\s*(?:[a-d][).]|[-*•])\s+/i.test(card.front) || /\bwhich of\b/i.test(card.front);
39
+ const attempt = {
40
+ kind: "attempt",
41
+ problem: { id: card.id, digest: attachmentDigest(new TextEncoder().encode(JSON.stringify(body))), ...body },
42
+ revision,
43
+ response: grade.answer,
44
+ assessment: {
45
+ correct: grade.grade !== "again",
46
+ grader: grade.answer.trim() === card.back.trim() ? "mechanical" : "learner",
47
+ ...(leaksAnswer || offersCandidates ? { aided: true } : {}),
48
+ },
49
+ };
50
+ if (!isAttemptOutcome(attempt))
51
+ throw new Error("Invalid migrated recall attempt");
52
+ return attempt;
53
+ }
54
+ function migrate(profile) {
55
+ return {
56
+ ...profile,
57
+ log: profile.log.map((entry) => isObservation(entry) ? { ...entry, payload: migratePayload(entry.payload, profile.patches.terminal) } : entry),
58
+ };
59
+ }
60
+ // The hosted release can scan just the two payload stores before committing this step's
61
+ // changed rows. Patch, Mission and derived Demonstration facts stay byte-for-byte as they were.
62
+ export const recallToAttemptMigration = {
63
+ from: "1.0",
64
+ to: "1.1",
65
+ migrate,
66
+ migrateOutcome: (payload, profile) => migratePayload(payload, profile.patches.terminal),
67
+ migratePayload,
68
+ };
69
+ export const reviewScheduleMigration = {
70
+ from: "1.3",
71
+ to: "1.4",
72
+ migratePatch(content, graphs) {
73
+ const sets = content.delta.operations.flatMap((op) => (op.kind === "add-metadata-set" ? [op.metadataSet] : []));
74
+ if (!graphs?.basesChanged &&
75
+ !sets.some(({ properties }) => typeof properties[REVIEW_PROPERTY] === "boolean") &&
76
+ typeof content.metadata.properties[REVIEW_PROPERTY] !== "boolean")
77
+ return content;
78
+ const resolve = graphs?.resolve ??
79
+ ((candidate = content) => {
80
+ const revision = candidateRevision("patch-migrating", candidate);
81
+ return resolvePatchBundle({ terminal: revision.ref, revisions: [revision] });
82
+ });
83
+ const before = resolve();
84
+ const milestone = (id) => pathProperty(before, id, "pedagogy:milestone") === true;
85
+ function rewrite(properties, subjects) {
86
+ const review = properties[REVIEW_PROPERTY];
87
+ return typeof review === "boolean"
88
+ ? {
89
+ ...properties,
90
+ [REVIEW_PROPERTY]: {
91
+ kind: review && !subjects?.every((s) => s.kind === "node" && milestone(s.id)) ? "fsrs" : "never",
92
+ },
93
+ }
94
+ : properties;
95
+ }
96
+ const rewritten = {
97
+ ...content,
98
+ metadata: { ...content.metadata, properties: rewrite(content.metadata.properties) },
99
+ delta: {
100
+ operations: content.delta.operations.map((op) => {
101
+ if (op.kind !== "add-metadata-set")
102
+ return op;
103
+ return {
104
+ ...op,
105
+ metadataSet: { ...op.metadataSet, properties: rewrite(op.metadataSet.properties, op.metadataSet.subjects) },
106
+ };
107
+ }),
108
+ },
109
+ };
110
+ // A single contribution may cover both ordinary Nodes and milestones, including
111
+ // through a tag or across Patch bases. Preserve each effective reading separately.
112
+ const after = resolve(rewritten);
113
+ const additions = [];
114
+ const ids = new Set(after.metadataSets.map((set) => set.id));
115
+ for (const { id } of before.nodes) {
116
+ const old = nodeCascadedProperty(before, id, REVIEW_PROPERTY);
117
+ const fallback = { kind: milestone(id) ? "never" : "fsrs" };
118
+ const wanted = old === false ? { kind: "never" } : old === true || old == null ? fallback : old;
119
+ const actual = nodeCascadedProperty(after, id, REVIEW_PROPERTY) ?? fallback;
120
+ if (canonicalJson(actual) === canonicalJson(wanted))
121
+ continue;
122
+ let key = `metadata-review-${id}`;
123
+ while (ids.has(key))
124
+ key = `${key}-review`;
125
+ ids.add(key);
126
+ if (!isMetadataValue(wanted))
127
+ throw new Error("Invalid inherited Review schedule");
128
+ additions.push({
129
+ kind: "add-metadata-set",
130
+ metadataSet: { id: key, subjects: [{ kind: "node", id }], properties: { [REVIEW_PROPERTY]: wanted } },
131
+ });
132
+ }
133
+ return additions.length
134
+ ? { ...rewritten, delta: { operations: [...rewritten.delta.operations, ...additions] } }
135
+ : rewritten;
136
+ },
137
+ migrate(profile) {
138
+ const { terminal, revisions } = migrateTheoryPatchClosure({ id: "default", version: "1.4.0", migrations: [reviewScheduleMigration] }, profile.patches, { theory: "default", range: "~1.3" });
139
+ return sameExactPatchRef(profile.patches.terminal, terminal.ref)
140
+ ? profile
141
+ : { ...profile, patches: { terminal: terminal.ref, revisions } };
142
+ },
143
+ };
144
+ export const migrations = [
145
+ recallToAttemptMigration,
146
+ // FSRS-6 (ts-fsrs 5) replaces FSRS-5's curve: review tags and path ranks read retrievability,
147
+ // which every Profile recomputes from its unchanged evidence.
148
+ { from: "1.1", to: "1.2" },
149
+ // FSRS-7 (ts-fsrs 6) replaces FSRS-6's single trace with slow and fast traces; likewise derived only.
150
+ { from: "1.2", to: "1.3" },
151
+ reviewScheduleMigration,
152
+ ];
package/dist/opening.d.ts CHANGED
@@ -9,7 +9,7 @@ export declare function lessonOpening(graph: ResolvedGraph, nodes: readonly Node
9
9
  node: `node-${string}`;
10
10
  label: unknown;
11
11
  }[];
12
- closes: string;
12
+ completion: string;
13
13
  follows: {
14
14
  node: `node-${string}`;
15
15
  label: unknown;
package/dist/opening.js CHANGED
@@ -7,13 +7,13 @@ export function lessonOpening(graph, nodes, mission) {
7
7
  .filter(({ from, to }) => nodes.includes(from) && !nodes.includes(to) && mission?.nodes.includes(to))
8
8
  .map(({ to }) => to));
9
9
  return {
10
- instruction: "Make and open the Lesson’s Materials first, following the focus Nodes’ guidance. Ask first only when that guidance leaves the work undecided. Then describe the Lesson as it stands: what its focus Nodes cover, its Materials in the order to use them, how it closes, and what follows. Elicit the first action, using the first Node’s authored first action if supplied. Later Nodes’ openings are for when those Nodes are reached.",
10
+ instruction: "Make and open the Lesson’s Materials first, following the focus Nodes’ guidance. Ask first only when that guidance leaves the work undecided. Then describe the Lesson as it stands: what its focus Nodes cover, its Materials in the order to use them, what counts as completing the Lesson, and what follows. Elicit the first action, using the first Node’s authored first action if supplied. Later Nodes’ openings are for when those Nodes are reached.",
11
11
  facts: {
12
12
  focus: nodes.map((node) => ({
13
13
  ...label(node),
14
14
  completion: defaultNodeCompletion(graph, node) ?? "Establish completion following this Node’s guidance.",
15
15
  })),
16
- closes: "The Lesson closes when every focus Node’s completion query holds over the evidence. Use existing queries where set; otherwise establish them following the Nodes’ guidance.",
16
+ completion: "The Lesson reads complete when every focus Node’s completion query holds over the evidence. Use existing queries where set; otherwise establish them following the Nodes’ guidance.",
17
17
  follows: [...following].map(label),
18
18
  },
19
19
  };
@@ -2,23 +2,6 @@ import type { Demonstration, NodeRef } from "./state.js";
2
2
  import type { ExactPatchRef, NodeId } from "@mmon-co/ncept-core/patch";
3
3
  export { isCompletionOutcome } from "./state.js";
4
4
  export type { CompletionOutcome } from "./state.js";
5
- /** Content captured when retrieval happened, not a pointer to an editable card. */
6
- export interface RecallOutcome {
7
- readonly kind: "recall";
8
- readonly card: {
9
- readonly id: string;
10
- readonly front: string;
11
- readonly back: string;
12
- readonly nodes: readonly NodeRef[];
13
- };
14
- readonly grade: {
15
- readonly id: string;
16
- readonly cardId: string;
17
- readonly gradedAt: string;
18
- readonly answer: string;
19
- readonly grade: "again" | "hard" | "good" | "easy";
20
- };
21
- }
22
5
  export interface QuizOutcome {
23
6
  readonly kind: "quiz";
24
7
  readonly id: string;
@@ -46,7 +29,7 @@ export interface CheckResult {
46
29
  readonly error?: string;
47
30
  }
48
31
  /**
49
- * One assessed Quizzes Playground response, with the Problem captured at open and the revision pinned there.
32
+ * One assessed Problem response, with its content and revision captured before grading.
50
33
  * Answer describes the response surface; grader records who judged it.
51
34
  */
52
35
  export interface AttemptOutcome {
@@ -91,8 +74,14 @@ export interface AttemptOutcome {
91
74
  readonly by: "mechanical";
92
75
  readonly accepted?: readonly string[];
93
76
  } | {
94
- readonly by: "tutor" | "learner";
77
+ readonly by: "program";
78
+ } | {
79
+ readonly by: "tutor";
80
+ readonly rubric?: string;
81
+ } | {
82
+ readonly by: "learner";
95
83
  readonly rubric?: string;
84
+ readonly accepted?: readonly string[];
96
85
  } | {
97
86
  readonly by: "checks";
98
87
  readonly help: "pump" | "hint" | "correct";
@@ -128,11 +117,7 @@ export interface AttemptOutcome {
128
117
  readonly revision: ExactPatchRef;
129
118
  }
130
119
  export declare function isAttemptOutcome(value: unknown): value is AttemptOutcome;
131
- /** Guards validate the supported payload, including the captured grading invariants. */
132
- export declare function isRecallOutcome(value: unknown): value is RecallOutcome;
133
120
  export declare function isQuizOutcome(value: unknown): value is QuizOutcome;
134
- /** The existing verbatim unaided-card rule, recomputed from the attempt's content. */
135
- export declare function recallUnaided(card: Pick<RecallOutcome["card"], "front" | "back">): boolean;
136
121
  export interface OriginalAttempt {
137
122
  readonly at: string;
138
123
  readonly payload: Demonstration;
@@ -140,4 +125,4 @@ export interface OriginalAttempt {
140
125
  /** One demonstration per Node and help state, pinned to the revision the Problem was opened at. */
141
126
  export declare function problemAttempts(outcome: AttemptOutcome, at: string): readonly OriginalAttempt[];
142
127
  /** Pure scoring over captured values; no current Material or graph read can rewrite an attempt. */
143
- export declare function practiceAttempts(outcome: RecallOutcome | QuizOutcome): readonly OriginalAttempt[];
128
+ export declare function practiceAttempts(outcome: QuizOutcome): readonly OriginalAttempt[];
package/dist/outcomes.js CHANGED
@@ -57,6 +57,20 @@ export function isAttemptOutcome(value) {
57
57
  (assessment.grader === "tutor" ||
58
58
  (assessment.grader === "mechanical" && chosen.correct === assessment.correct))));
59
59
  }
60
+ if (answer.kind === "short" && grader.by === "learner")
61
+ return (text(grader.rubric) &&
62
+ (grader.accepted === undefined ||
63
+ (Array.isArray(grader.accepted) && grader.accepted.length > 0 && grader.accepted.every(text))) &&
64
+ (dontKnow ||
65
+ assessment.grader === "learner" ||
66
+ (assessment.grader === "mechanical" &&
67
+ assessment.correct === true &&
68
+ (response.trim() === grader.rubric.trim() ||
69
+ (Array.isArray(grader.accepted) &&
70
+ grader.accepted.some((accepted) => accepted.normalize("NFKC").trim().replace(/\s+/gu, " ").toLocaleLowerCase() ===
71
+ response.normalize("NFKC").trim().replace(/\s+/gu, " ").toLocaleLowerCase()))))));
72
+ if (answer.kind === "short" && grader.by === "program")
73
+ return Object.keys(grader).length === 1 && (dontKnow || assessment.grader === "mechanical");
60
74
  if (answer.kind === "short")
61
75
  return (grader.by === "mechanical" &&
62
76
  Array.isArray(grader.accepted) &&
@@ -112,26 +126,6 @@ export function isAttemptOutcome(value) {
112
126
  return object(result) && result.outcome === "shown";
113
127
  }))));
114
128
  }
115
- /** Guards validate the supported payload, including the captured grading invariants. */
116
- export function isRecallOutcome(value) {
117
- if (!object(value) || value.kind !== "recall" || !object(value.card) || !object(value.grade))
118
- return false;
119
- const { card, grade } = value;
120
- return (text(card.id) &&
121
- typeof card.front === "string" &&
122
- typeof card.back === "string" &&
123
- Array.isArray(card.nodes) &&
124
- card.nodes.length > 0 &&
125
- card.nodes.every(nodeRef) &&
126
- new Set(card.nodes.map((node) => node.node)).size === card.nodes.length &&
127
- text(grade.id) &&
128
- grade.cardId === card.id &&
129
- isObservationTimestamp(grade.gradedAt) &&
130
- text(grade.answer) &&
131
- typeof grade.grade === "string" &&
132
- ["again", "hard", "good", "easy"].includes(grade.grade) &&
133
- !(grade.answer.trim() === card.back.trim() && grade.grade === "again"));
134
- }
135
129
  export function isQuizOutcome(value) {
136
130
  if (!object(value) ||
137
131
  value.kind !== "quiz" ||
@@ -171,15 +165,6 @@ export function isQuizOutcome(value) {
171
165
  : question.options.some(({ id }) => id === response.selectedOptionId)));
172
166
  }));
173
167
  }
174
- /** The existing verbatim unaided-card rule, recomputed from the attempt's content. */
175
- export function recallUnaided(card) {
176
- const normalize = (value) => value.trim().toLocaleLowerCase().replace(/\s+/g, " ");
177
- const front = normalize(card.front);
178
- const back = normalize(card.back);
179
- const leaksAnswer = back.length > 0 && front.includes(back);
180
- const offersCandidates = /(^|\n)\s*(?:[a-d][).]|[-*•])\s+/i.test(card.front) || /\bwhich of\b/i.test(card.front);
181
- return !leaksAnswer && !offersCandidates;
182
- }
183
168
  function checkNote(check, { outcome, error }) {
184
169
  if (outcome === "shown")
185
170
  return `Shown: ${check.shown}`;
@@ -200,7 +185,7 @@ export function problemAttempts(outcome, at) {
200
185
  item: problem.id,
201
186
  node: { node, provenance: { ...outcome.revision } },
202
187
  outcome: "dont-know",
203
- unaided: !assessment.aided,
188
+ unaided: problem.answer.kind !== "choice" && !assessment.aided,
204
189
  grader: "learner",
205
190
  task: problem.prompt,
206
191
  response,
@@ -255,7 +240,7 @@ export function problemAttempts(outcome, at) {
255
240
  item: problem.id,
256
241
  node: { node, provenance: { ...outcome.revision } },
257
242
  outcome: assessment.correct ? "success" : "failure",
258
- unaided: !assessment.aided,
243
+ unaided: problem.answer.kind !== "choice" && !assessment.aided,
259
244
  grader: assessment.grader,
260
245
  task: choice ? `${problem.prompt}\n${choice.map(({ label }) => `- ${label}`).join("\n")}` : problem.prompt,
261
246
  response: answer,
@@ -264,22 +249,6 @@ export function problemAttempts(outcome, at) {
264
249
  }
265
250
  /** Pure scoring over captured values; no current Material or graph read can rewrite an attempt. */
266
251
  export function practiceAttempts(outcome) {
267
- if (outcome.kind === "recall") {
268
- const { card, grade } = outcome;
269
- return card.nodes.map((node) => ({
270
- at: grade.gradedAt,
271
- payload: {
272
- kind: "demonstration",
273
- item: card.id,
274
- node: { node: node.node, provenance: { ...node.provenance } },
275
- outcome: grade.grade === "again" ? "failure" : "success",
276
- unaided: recallUnaided(card),
277
- grader: grade.answer.trim() === card.back.trim() ? "mechanical" : "learner",
278
- task: card.front,
279
- response: grade.answer,
280
- },
281
- }));
282
- }
283
252
  return outcome.questions.flatMap((question) => {
284
253
  const response = outcome.responses.find(({ questionId }) => questionId === question.id);
285
254
  if (response === undefined)
package/dist/path.d.ts CHANGED
@@ -1,8 +1,10 @@
1
1
  import { type NodeId, type ResolvedGraph } from "@mmon-co/ncept-core/patch";
2
2
  import { type MissionPath, type MissionFuture, type PathContext } from "@mmon-co/ncept-core/theory";
3
+ import { type ReviewSchedule } from "./schedules.js";
4
+ export { REVIEW_PROPERTY, validateReviewSchedule, type ReviewSchedule } from "./schedules.js";
3
5
  /** Default-theory authoring metadata, not Core graph vocabulary. */
4
6
  export declare function pathProperty(graph: ResolvedGraph, node: NodeId, key: string): unknown;
5
- /** Milestones and one-off steps keep their evidence without entering Review. */
7
+ export declare function nodeReviewSchedule(graph: ResolvedGraph, node: NodeId): ReviewSchedule;
6
8
  export declare function nodeAllowsReview(graph: ResolvedGraph, node: NodeId): boolean;
7
9
  /** Default-theory hint: an absolute integer, higher first, inherited from tags. */
8
10
  export declare function nodePriority(graph: ResolvedGraph, node: NodeId): number;