@mmon-co/ncept-default-theory 0.0.0-stage → 1.1.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.
Files changed (53) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +73 -2
  3. package/dist/catalog-contract.d.ts +102 -0
  4. package/dist/catalog-contract.js +75 -0
  5. package/dist/catalog.d.ts +14 -0
  6. package/dist/catalog.js +164 -0
  7. package/dist/chat.d.ts +171 -0
  8. package/dist/chat.js +232 -0
  9. package/dist/completion.d.ts +74 -0
  10. package/dist/completion.js +277 -0
  11. package/dist/dependent-cone.d.ts +3 -0
  12. package/dist/dependent-cone.js +26 -0
  13. package/dist/diagnosis.d.ts +9 -0
  14. package/dist/diagnosis.js +1 -0
  15. package/dist/diagnostics.d.ts +25 -0
  16. package/dist/diagnostics.js +34 -0
  17. package/dist/evaluation.d.ts +33 -0
  18. package/dist/evaluation.js +376 -0
  19. package/dist/event.d.ts +7 -0
  20. package/dist/event.js +405 -0
  21. package/dist/history.d.ts +4 -0
  22. package/dist/history.js +61 -0
  23. package/dist/implementation.d.ts +184 -0
  24. package/dist/implementation.js +31 -0
  25. package/dist/index.d.ts +200 -0
  26. package/dist/index.js +27 -0
  27. package/dist/messages.d.ts +167 -0
  28. package/dist/messages.js +56 -0
  29. package/dist/opening.d.ts +20 -0
  30. package/dist/opening.js +33 -0
  31. package/dist/outcomes.d.ts +143 -0
  32. package/dist/outcomes.js +323 -0
  33. package/dist/path.d.ts +19 -0
  34. package/dist/path.js +293 -0
  35. package/dist/reading.d.ts +12 -0
  36. package/dist/reading.js +75 -0
  37. package/dist/release.d.ts +1 -0
  38. package/dist/release.js +1 -0
  39. package/dist/roleplay.d.ts +17 -0
  40. package/dist/roleplay.js +2 -0
  41. package/dist/skills/sources.d.ts +12 -0
  42. package/dist/skills/sources.js +13 -0
  43. package/dist/skills.d.ts +12 -0
  44. package/dist/skills.js +70 -0
  45. package/dist/state.d.ts +316 -0
  46. package/dist/state.js +1309 -0
  47. package/dist/tags.d.ts +34 -0
  48. package/dist/tags.js +306 -0
  49. package/dist/timing.d.ts +21 -0
  50. package/dist/timing.js +79 -0
  51. package/dist/tools.d.ts +394 -0
  52. package/dist/tools.js +872 -0
  53. package/package.json +52 -4
@@ -0,0 +1,316 @@
1
+ import type { Speaker } from "@mmon-co/ncept-core/theory/speaker";
2
+ import { type TheoryState } from "@mmon-co/ncept-core/theory";
3
+ import { type Completion, type CompletionProgress } from "./completion.js";
4
+ import { type ExactPatchRef, type MetadataSet, type NodeId, type ResolvedGraph } from "@mmon-co/ncept-core/patch";
5
+ import { type LearnerDay, type Observation, type ObservationId, type SurfaceId } from "@mmon-co/ncept-core/observations";
6
+ export declare const DEFAULT_THEORY_ID = "default";
7
+ export declare const DEFAULT_THEORY_REF: {
8
+ readonly theory: "default";
9
+ readonly version: "1.0.0";
10
+ };
11
+ export interface NodeRef {
12
+ readonly node: NodeId;
13
+ readonly provenance: ExactPatchRef;
14
+ }
15
+ export type CompletionScope = null | boolean | number | string | readonly CompletionScope[] | {
16
+ readonly [key: string]: CompletionScope;
17
+ };
18
+ export interface CompletionOutcome {
19
+ readonly playground: string;
20
+ readonly scope: CompletionScope;
21
+ readonly kind: "completion";
22
+ readonly node: NodeRef;
23
+ readonly state: "complete" | "incomplete";
24
+ readonly validUntil?: string;
25
+ }
26
+ export interface Demonstration {
27
+ readonly kind: "demonstration";
28
+ readonly material?: {
29
+ readonly playground: string;
30
+ readonly id: string;
31
+ };
32
+ readonly item?: string;
33
+ readonly node: NodeRef;
34
+ readonly outcome: "success" | "failure" | "dont-know";
35
+ readonly unaided: boolean;
36
+ readonly grader: "mechanical" | "tutor" | "learner" | "decision";
37
+ readonly task: string;
38
+ readonly response: string;
39
+ readonly evaluation?: {
40
+ readonly grader: import("@mmon-co/ncept-core/observations").Grader;
41
+ readonly criteria: readonly {
42
+ readonly criterion: string;
43
+ readonly probability: number;
44
+ }[];
45
+ readonly message?: string;
46
+ readonly watch?: ObservationId;
47
+ readonly override?: {
48
+ readonly of: ObservationId;
49
+ readonly reason: string;
50
+ };
51
+ } | {
52
+ readonly override: {
53
+ readonly of: ObservationId;
54
+ readonly reason: string;
55
+ };
56
+ };
57
+ /** Set only by the explicit lesson-opening retrieval recording tool. */
58
+ readonly recording?: "retrieval-opener";
59
+ }
60
+ /** Diagnosed regression affects retention, never the acquisition window. */
61
+ export interface Lapse {
62
+ readonly kind: "lapse";
63
+ readonly node: NodeRef;
64
+ /** The same lesson's already-recorded slip or diagnosis, if any. */
65
+ readonly of?: ObservationId;
66
+ }
67
+ /** One whole-day retention judgment; support lives in the Record envelope. */
68
+ export interface Grade {
69
+ readonly kind: "grade";
70
+ readonly node: NodeRef;
71
+ readonly day: LearnerDay;
72
+ readonly rating: "Again" | "Hard" | "Good" | "Easy";
73
+ }
74
+ /** A passed Review clears the path until a grade covering that Review sets retention. */
75
+ export interface ReviewPass {
76
+ readonly kind: "review-pass";
77
+ readonly node: NodeRef;
78
+ }
79
+ export type RetrievalOpenerDemonstration = Demonstration & {
80
+ readonly recording: "retrieval-opener";
81
+ };
82
+ /** An accepted operation, not a demonstration of every clause of a Node's criterion. */
83
+ export interface FeatureUse {
84
+ readonly kind: "feature-use";
85
+ readonly operation: string;
86
+ }
87
+ /** An explicit teaching act, separate from competence evidence. */
88
+ export interface Teaching {
89
+ readonly kind: "teaching";
90
+ readonly node: NodeRef;
91
+ readonly explanation: string;
92
+ }
93
+ export interface Claim {
94
+ readonly kind: "claim";
95
+ readonly statement: string;
96
+ readonly prompt?: string;
97
+ readonly stance: "knows" | "forgotten" | "unfamiliar";
98
+ }
99
+ export interface Retraction {
100
+ readonly kind: "retraction";
101
+ readonly of: ObservationId;
102
+ }
103
+ export interface Homing {
104
+ readonly kind: "homing";
105
+ readonly of: ObservationId;
106
+ readonly homes: readonly NodeId[];
107
+ readonly pending?: boolean;
108
+ readonly revision: ExactPatchRef;
109
+ }
110
+ export type MemorySource = {
111
+ readonly kind: "observation";
112
+ readonly observation: ObservationId;
113
+ } | {
114
+ readonly kind: "transcript";
115
+ readonly surface: SurfaceId;
116
+ readonly from: string;
117
+ readonly to: string;
118
+ };
119
+ export interface MemoryAttachment {
120
+ readonly speaker: Speaker;
121
+ readonly text: string;
122
+ readonly at: string;
123
+ readonly source: MemorySource;
124
+ }
125
+ export interface Memory {
126
+ readonly kind: "memory";
127
+ readonly entries: readonly MemoryAttachment[];
128
+ }
129
+ export interface MemorySummaryPayload {
130
+ readonly kind: "memory-summary";
131
+ readonly materialSources: readonly Extract<Speaker, {
132
+ kind: "material";
133
+ }>[];
134
+ readonly text: string;
135
+ readonly sources: readonly ObservationId[];
136
+ /** Every observation consumed, including sources inside attachment batches. */
137
+ readonly dependencies: readonly ObservationId[];
138
+ }
139
+ /** Retrieval prose about prior work. Tags classify retrieval, not truth or learner labels. Scope is the
140
+ * observation's `nodes`, support its `cites`; neither the interpretation nor a summary is learner-state evidence.
141
+ */
142
+ export interface Interpretation {
143
+ readonly kind: "interpretation";
144
+ readonly text: string;
145
+ readonly tags: readonly string[];
146
+ }
147
+ export type DefaultPayload = CompletionOutcome | Demonstration | Lapse | Grade | ReviewPass | FeatureUse | Teaching | Claim | Retraction | Homing | Memory | MemorySummaryPayload | Interpretation;
148
+ export type HomedRecord = Observation<Demonstration | Claim>;
149
+ export interface MemoryEntry extends MemoryAttachment {
150
+ readonly kind: "entry";
151
+ readonly observation: ObservationId;
152
+ readonly position: number;
153
+ }
154
+ export interface MemorySummary {
155
+ readonly kind: "summary";
156
+ readonly materialSources: readonly Extract<Speaker, {
157
+ kind: "material";
158
+ }>[];
159
+ readonly observation: ObservationId;
160
+ readonly text: string;
161
+ readonly at: string;
162
+ readonly sources: readonly ObservationId[];
163
+ readonly dependencies: readonly ObservationId[];
164
+ }
165
+ export interface NodeMemory {
166
+ readonly node: NodeId;
167
+ readonly entries: readonly (MemoryEntry | MemorySummary)[];
168
+ readonly originals: readonly MemoryEntry[];
169
+ }
170
+ /** The overlay of one exact graph revision: only placements decided for it, and unresolved records. */
171
+ export interface DefaultHoming {
172
+ readonly homes: Readonly<Partial<Record<ObservationId, readonly NodeId[]>>>;
173
+ readonly claims: Readonly<Partial<Record<ObservationId, readonly NodeId[]>>>;
174
+ readonly pending: readonly ObservationId[];
175
+ }
176
+ export interface DefaultState {
177
+ readonly nodes: Readonly<Partial<Record<NodeId, NodeState>>>;
178
+ readonly observations: readonly Observation[];
179
+ readonly records: readonly HomedRecord[];
180
+ readonly homing: DefaultHoming;
181
+ readonly homeless: readonly HomedRecord[];
182
+ readonly memories: Readonly<Partial<Record<NodeId, NodeMemory>>>;
183
+ /** Supported, uncorrected interpretations in acceptance order. */
184
+ readonly interpretations: readonly Observation<Interpretation>[];
185
+ }
186
+ export declare function isCompletionOutcome(value: unknown): value is CompletionOutcome;
187
+ export declare function isDemonstration(value: unknown): value is Demonstration;
188
+ export declare function isLapse(value: unknown): value is Lapse;
189
+ export declare function isGrade(value: unknown): value is Grade;
190
+ export declare function isReviewPass(value: unknown): value is ReviewPass;
191
+ export declare function isRetrievalOpenerDemonstration(value: unknown): value is RetrievalOpenerDemonstration;
192
+ export declare function isFeatureUse(value: unknown): value is FeatureUse;
193
+ export declare function isTeaching(value: unknown): value is Teaching;
194
+ export declare function isClaim(value: unknown): value is Claim;
195
+ export declare function isRetraction(value: unknown): value is Retraction;
196
+ export declare function isHoming(value: unknown): value is Homing;
197
+ export declare function isMemory(value: unknown): value is Memory;
198
+ export declare function isDefaultObservation(observation: Observation): boolean;
199
+ /** Retractions never retract retractions. Excluded sources do not make residual interpretations into evidence.
200
+ * Records rank by the instant the learner produced them, deterministically, which is a different question
201
+ * from the order observations were accepted in: decisions and memory read the supplied sequence instead.
202
+ */
203
+ export declare function activeDefaultRecords(observations: readonly Observation[]): readonly HomedRecord[];
204
+ export declare function assertDefaultRetraction(of: ObservationId, observations: readonly Observation[]): void;
205
+ /** Whole-day support uses the same active, re-homed demonstrations as acquisition.
206
+ * Diagnoses are retention evidence only; retracted attempts never support a grade. */
207
+ export declare function nodeDayEvidence(state: DefaultState, node: NodeId): readonly Observation<Demonstration | Lapse>[];
208
+ /** A grade stops being active if any cited attempt is retracted, abandoned or superseded.
209
+ * It never becomes acquisition/completion evidence. The scheduler consumes this projection. */
210
+ export declare function activeDefaultGrades(state: DefaultState): readonly Observation<Grade>[];
211
+ /** Original strings stay citable; a summary is only usable while all its original sources remain effective. */
212
+ export declare function expandNodeMemory(memory: NodeMemory, summary: MemorySummary): readonly MemoryEntry[];
213
+ export declare function memoryDefault(memory: NodeMemory): {
214
+ marker?: "unsummarized activity exists" | undefined;
215
+ node: `node-${string}`;
216
+ entries: readonly (MemoryEntry | MemorySummary)[];
217
+ };
218
+ export declare function emptyNodeMemory(node: NodeId): NodeMemory;
219
+ export interface HomingCandidate {
220
+ readonly node: NodeId;
221
+ readonly statement: string;
222
+ }
223
+ export declare function homingCandidates(graph: ResolvedGraph): readonly HomingCandidate[];
224
+ /** Provisional interpretations for a graph edit: the target revision restates every decision in force. */
225
+ export declare function projectGraphChange(state: Pick<DefaultState, "records" | "homing">, graph: ResolvedGraph, next: ResolvedGraph, successors?: Readonly<Partial<Record<NodeId, readonly NodeId[]>>>): readonly Homing[];
226
+ export type NodeLabel = "demonstrated" | "probably-known" | "unknown";
227
+ export type DefaultParameters = Readonly<{
228
+ retention: Readonly<{
229
+ due: number;
230
+ fading: number;
231
+ claimStabilityDays: number;
232
+ }>;
233
+ }>;
234
+ export declare const DEFAULT_PARAMETERS: DefaultParameters;
235
+ export interface NodeSchedule {
236
+ readonly stability: number;
237
+ readonly difficulty: number;
238
+ readonly reps: number;
239
+ readonly lapses: number;
240
+ readonly lastReview: string;
241
+ readonly retrievability: number;
242
+ /** Observed forgetting stays due until a later non-Again day grade, independently of FSRS R. */
243
+ readonly lapsed: boolean;
244
+ readonly citations: readonly ObservationId[];
245
+ }
246
+ export interface NodeState {
247
+ readonly completion: CompletionProgress & {
248
+ readonly query?: Completion;
249
+ };
250
+ /** Effective operation receipts; these do not change competence labels or schedules. */
251
+ readonly featureUses: readonly Observation<FeatureUse>[];
252
+ readonly label: NodeLabel;
253
+ readonly lastSuccess?: string;
254
+ readonly aidedPractice: number;
255
+ readonly citations: readonly ObservationId[];
256
+ /** Original active evidence in chronological order; never memory or summaries. */
257
+ readonly records: readonly HomedRecord[];
258
+ readonly schedule?: NodeSchedule;
259
+ /** A successful Review awaiting its day grade; not a change to the FSRS card. */
260
+ readonly reviewCleared?: boolean;
261
+ }
262
+ /** Acquisition reads only this Node's own active, time-ordered evidence, without a horizon. */
263
+ export declare function labelDefaultNode(input: {
264
+ readonly records: readonly HomedRecord[];
265
+ readonly completion?: CompletionProgress & {
266
+ readonly query: Completion;
267
+ };
268
+ }): NodeState;
269
+ /** Resolved Node and tag metadata share the ordinary Patch precedence. */
270
+ export declare function defaultNodeCompletion(graph: ResolvedGraph, node: NodeId, index?: Pick<DefaultGraphIndex, "metadata" | "patchOrder">): Completion | undefined;
271
+ /** Stable authoring provenance, rather than the terminal of an unrelated graph edit. */
272
+ export declare function completionNodeRef(graph: ResolvedGraph, node: NodeId, nodeIds?: ReadonlySet<NodeId>): NodeRef;
273
+ /** Graph edges point from prerequisite to dependent; the strict cone excludes the queried Node. */
274
+ export declare function defaultDependentCone(graph: ResolvedGraph, node: NodeId): readonly NodeId[];
275
+ /** Graph facts are shared by every Node reduction, and can survive evidence-only updates. */
276
+ interface DefaultGraphIndex {
277
+ readonly nodeIds: ReadonlySet<NodeId>;
278
+ readonly nodeOrder: ReadonlyMap<NodeId, number>;
279
+ readonly dependents: ReadonlyMap<NodeId, readonly NodeId[]>;
280
+ readonly prerequisites: ReadonlyMap<NodeId, readonly NodeId[]>;
281
+ readonly metadata: ReadonlyMap<NodeId, readonly MetadataSet[]>;
282
+ readonly patchOrder: ReadonlyMap<string, number>;
283
+ }
284
+ export type InterpretationQuery = Readonly<{
285
+ nodes?: readonly NodeId[];
286
+ tag?: string;
287
+ surface?: SurfaceId;
288
+ }>;
289
+ /** Deterministic lookup: supplied filters intersect; results keep acceptance order. */
290
+ export declare function interpretationsDefault(state: DefaultState, query?: InterpretationQuery): readonly Observation<Interpretation>[];
291
+ /** Default policy: retain history in the host, but ignore abandoned evidence here. */
292
+ export declare function electedObservations(observations: readonly Observation[]): readonly Observation[];
293
+ /** Homing needs historical structure, not the acquisition vocabulary that revision was authored under. */
294
+ export declare function homeDefaultRecords(graph: ResolvedGraph, supplied: readonly Observation[], now: string): {
295
+ observations: readonly Observation<unknown>[];
296
+ records: readonly HomedRecord[];
297
+ homed: Readonly<Partial<Record<`node-${string}`, readonly HomedRecord[]>>>;
298
+ homeless: readonly HomedRecord[];
299
+ placed: ReadonlyMap<`obs-${string}`, readonly `node-${string}`[]>;
300
+ current: ReadonlyMap<`obs-${string}`, ReadonlySet<`node-${string}`>>;
301
+ homing: DefaultHoming;
302
+ nodeIds: Set<`node-${string}`>;
303
+ };
304
+ /** Snapshot-associated keys are private preparation, not serialized state or a cross-context cache.
305
+ * A plain DefaultState has no key and remains fully projectable. */
306
+ interface ProjectionBasis {
307
+ readonly graph: ResolvedGraph;
308
+ readonly graphKey: object;
309
+ readonly evidenceKey: object;
310
+ readonly indicatorKey: object;
311
+ }
312
+ export declare function defaultProjectionBasis(state: DefaultState): ProjectionBasis | undefined;
313
+ export declare function initDefaultState(graph: ResolvedGraph): TheoryState<DefaultState>;
314
+ /** Pure default policy, derived from the same reducer used by retained replays. */
315
+ export declare function stateDefault(graph: ResolvedGraph, supplied: readonly Observation[], now: string): DefaultState;
316
+ export {};