@mmon-co/ncept-default-theory 3.0.1 → 3.0.3

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.
@@ -3,7 +3,7 @@ import { event } from "./event.js";
3
3
  import { isAttemptOutcome, isQuizOutcome } from "./outcomes.js";
4
4
  import { initDefaultState, isCompletionOutcome } from "./state.js";
5
5
  import { projectDefault } from "./tags.js";
6
- import { pathDefault } from "./path.js";
6
+ import { pathDefault, preparePathDefault } from "./path.js";
7
7
  import { progressDefault, estimateDefault, prepareEstimateDefault } from "./reading.js";
8
8
  /** The single default implementation assembly. */
9
9
  export declare const implementation: {
@@ -25,6 +25,7 @@ export declare const implementation: {
25
25
  estimate: typeof estimateDefault;
26
26
  prepareEstimate: typeof prepareEstimateDefault;
27
27
  path: typeof pathDefault;
28
+ preparePath: typeof preparePathDefault;
28
29
  describeObservation: typeof describeDefaultObservation;
29
30
  tags: readonly [...string[], "item-outcomes", "instability", "unused", "coarse", "lesson-split", "self-report", "edge-contradiction", "homeless"];
30
31
  outcomes: {
@@ -5,7 +5,7 @@ import { event } from "./event.js";
5
5
  import { isAttemptOutcome, isQuizOutcome } from "./outcomes.js";
6
6
  import { DEFAULT_THEORY_REF, initDefaultState, isCompletionOutcome } from "./state.js";
7
7
  import { defaultTags, projectDefault } from "./tags.js";
8
- import { pathDefault } from "./path.js";
8
+ import { pathDefault, preparePathDefault } from "./path.js";
9
9
  import { progressDefault, estimateDefault, prepareEstimateDefault } from "./reading.js";
10
10
  /** The single default implementation assembly. */
11
11
  export const implementation = {
@@ -18,6 +18,7 @@ export const implementation = {
18
18
  estimate: estimateDefault,
19
19
  prepareEstimate: prepareEstimateDefault,
20
20
  path: pathDefault,
21
+ preparePath: preparePathDefault,
21
22
  describeObservation: describeDefaultObservation,
22
23
  tags: defaultTags,
23
24
  outcomes: {
package/dist/index.d.ts CHANGED
@@ -18,6 +18,7 @@ export declare const defaultTheory: {
18
18
  estimate: typeof import("./reading.js").estimateDefault;
19
19
  prepareEstimate: typeof import("./reading.js").prepareEstimateDefault;
20
20
  path: typeof import("./path.js").pathDefault;
21
+ preparePath: typeof import("./path.js").preparePathDefault;
21
22
  describeObservation: typeof import("./history.js").describeDefaultObservation;
22
23
  tags: readonly [...string[], "item-outcomes", "instability", "unused", "coarse", "lesson-split", "self-report", "edge-contradiction", "homeless"];
23
24
  outcomes: {
package/dist/path.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { type NodeId, type ResolvedGraph } from "@mmon-co/ncept-core/patch";
2
- import { type MissionPath, type MissionFuture, type PathContext } from "@mmon-co/ncept-core/theory";
2
+ import { type MissionPath, type MissionFuture, type PathContext, type PathInputs, type PathSelection } from "@mmon-co/ncept-core/theory";
3
+ import { type DefaultState } from "./state.js";
3
4
  import { type ReviewSchedule } from "./schedules.js";
4
5
  export { REVIEW_PROPERTY, validateReviewSchedule, type ReviewSchedule } from "./schedules.js";
5
6
  /** Default-theory authoring metadata, not Core graph vocabulary. */
@@ -14,8 +15,6 @@ export declare function nodePriority(graph: ResolvedGraph, node: NodeId): number
14
15
  * not by lesson, so a Node may be taught in more than one group.
15
16
  */
16
17
  export declare function teachingPath(graph: ResolvedGraph, targets: readonly NodeId[]): MissionPath;
17
- /** The syllabus stays addressable as progress changes; only the future is upcoming.
18
- * A trailing unnumbered review is maintenance; a review with numberOffset 1 blocks the
19
- * following teaching stop. A graph-wide reading has only maintenance, and no Mission.
20
- */
21
18
  export declare function pathDefault(context: PathContext): MissionFuture;
19
+ /** The graph and historical timing are independent of the Mission's targets and run. */
20
+ export declare function preparePathDefault(inputs: PathInputs, state?: DefaultState): (selection: PathSelection) => MissionFuture;
package/dist/path.js CHANGED
@@ -186,8 +186,7 @@ function ranked(nodes, context) {
186
186
  return [...nodes].sort((a, b) => rank(b) - rank(a) || a.localeCompare(b));
187
187
  }
188
188
  /** Nodes are indivisible: an over-budget first Node must still make progress. */
189
- function packed(candidates, context) {
190
- const estimate = prepareEstimateDefault(context);
189
+ function packed(candidates, context, estimate) {
191
190
  const nodes = [];
192
191
  for (const node of ranked(candidates, context)) {
193
192
  if (nodes.length &&
@@ -201,10 +200,9 @@ function packed(candidates, context) {
201
200
  * retrievability, so an unrounded analytic crossing would miss the first effective tick.
202
201
  * Rank changes are conservative: the order may survive one, but cannot change before it.
203
202
  */
204
- function pathValidity(context, scope) {
203
+ function pathValidity(context, scope, state) {
205
204
  const now = Date.parse(context.now);
206
205
  const boundaries = context.projection.validUntil === undefined ? [] : [Date.parse(context.projection.validUntil)];
207
- const state = stateDefault(context.graph, context.observations, context.now);
208
206
  const candidates = context.graph.nodes.flatMap(({ id }) => {
209
207
  const schedule = state.nodes[id]?.schedule;
210
208
  const rank = context.projection.nodes[id]?.find(({ tag }) => tag === "review:due")?.rank;
@@ -249,23 +247,32 @@ function pathValidity(context, scope) {
249
247
  const expiry = Math.min(...boundaries);
250
248
  return Number.isFinite(expiry) ? { validUntil: new Date(expiry).toISOString() } : {};
251
249
  }
250
+ export function pathDefault(context) {
251
+ return preparePathDefault(context)(context);
252
+ }
253
+ /** The graph and historical timing are independent of the Mission's targets and run. */
254
+ export function preparePathDefault(inputs, state) {
255
+ let estimate;
256
+ let tags;
257
+ const readState = () => (state ??= stateDefault(inputs.graph, inputs.observations, inputs.now));
258
+ return (selection) => readPath({ ...inputs, ...selection }, (tags ??= tagIndex(inputs.projection)), (estimate ??= prepareEstimateDefault(inputs)), readState);
259
+ }
252
260
  /** The syllabus stays addressable as progress changes; only the future is upcoming.
253
261
  * A trailing unnumbered review is maintenance; a review with numberOffset 1 blocks the
254
262
  * following teaching stop. A graph-wide reading has only maintenance, and no Mission.
255
263
  */
256
- export function pathDefault(context) {
264
+ function readPath(context, tags, estimate, readState) {
257
265
  if (context.retired?.outcome === "abandoned")
258
266
  return { sections: [], warnings: [], future: [] };
259
267
  const { graph, targets, projection } = context;
260
268
  const path = teachingPath(graph, targets ?? []);
261
- const tags = tagIndex(projection);
262
269
  const scope = targets === undefined
263
270
  ? new Set(graph.nodes.map(({ id }) => id))
264
271
  : new Set(path.sections.flatMap(({ lessons }) => lessons.flatMap(({ nodes }) => nodes)));
265
- const due = packed(graph.nodes.map(({ id }) => id).filter((id) => scope.has(id) && tags("review:due").has(id)), context);
272
+ const due = packed(graph.nodes.map(({ id }) => id).filter((id) => scope.has(id) && tags("review:due").has(id)), context, estimate);
266
273
  const maintenance = due.length ? [{ kind: "review", numbered: false, nodes: due }] : [];
267
274
  if (context.retired?.outcome === "achieved" || targets === undefined)
268
- return { ...path, ...pathValidity(context, scope), future: maintenance };
275
+ return { ...path, ...pathValidity(context, scope, readState()), future: maintenance };
269
276
  const progress = progressDefault(graph, projection, [...scope]);
270
277
  const next = path.sections
271
278
  .flatMap(({ lessons }) => lessons)
@@ -276,7 +283,7 @@ export function pathDefault(context) {
276
283
  }) ?? []);
277
284
  const fading = packed(graph.nodes
278
285
  .map(({ id }) => id)
279
- .filter((id) => cone.has(id) && !next?.nodes.includes(id) && tags("review:fading").has(id)), context);
286
+ .filter((id) => cone.has(id) && !next?.nodes.includes(id) && tags("review:fading").has(id)), context, estimate);
280
287
  const sections = path.sections.map((section) => ({
281
288
  ...section,
282
289
  lessons: section.lessons.flatMap((lesson) => lesson === next && fading.length
@@ -285,7 +292,7 @@ export function pathDefault(context) {
285
292
  }));
286
293
  return {
287
294
  ...path,
288
- ...pathValidity(context, scope),
295
+ ...pathValidity(context, scope, readState()),
289
296
  sections,
290
297
  future: [
291
298
  ...sections
package/dist/release.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const theoryContent = "0771caeea7459be8ecd817b2b5205bce3868fba2af7a98b055535e8c455c03d1";
1
+ export declare const theoryContent = "f2cb5b7962828288b23f25fdbf5deadd251006e57b46a579503200409471caf5";
package/dist/release.js CHANGED
@@ -1 +1 @@
1
- export const theoryContent = "0771caeea7459be8ecd817b2b5205bce3868fba2af7a98b055535e8c455c03d1";
1
+ export const theoryContent = "f2cb5b7962828288b23f25fdbf5deadd251006e57b46a579503200409471caf5";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mmon-co/ncept-default-theory",
3
- "version": "3.0.1",
3
+ "version": "3.0.3",
4
4
  "license": "FSL-1.1-ALv2",
5
5
  "repository": {
6
6
  "type": "git",