@mmon-co/ncept-default-theory 3.0.18 → 3.0.20

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/timing.js CHANGED
@@ -1,27 +1,29 @@
1
1
  import { isNodeId } from "@mmon-co/ncept-core/patch";
2
- import { isDemonstration, initDefaultState } from "./state.js";
2
+ import { isDemonstration, isHoming, homeDefaultRecords, initDefaultState } from "./state.js";
3
3
  export const UNMEASURED_LESSON_TIMING = { minutesPerNode: 20, rough: true };
4
4
  export const UNMEASURED_REVIEW_TIMING = { minutesPerNode: 2, rough: true };
5
5
  /** Unique unaided checks in Review Sessions; acquisition already predates these checks. */
6
- export function measuredReviewTiming(observations, activities) {
7
- const reviews = activities.filter((activity) => activity.stop?.kind === "review");
6
+ export function measuredReviewTiming(graph, observations, activities) {
7
+ const reviews = activities.filter((activity) => activity.kind === "review");
8
+ const activeMs = reviews.reduce((sum, activity) => sum + activity.activeMs, 0);
9
+ if (activeMs <= 0)
10
+ return UNMEASURED_REVIEW_TIMING;
8
11
  const surfaces = new Map(reviews.flatMap((activity) => [activity.surface, ...(activity.relatedSurfaces ?? [])].map((surface) => [surface, activity])));
9
12
  const reviewed = new Set();
10
- for (const observation of observations) {
11
- const activity = observation.surface === undefined ? undefined : surfaces.get(observation.surface);
12
- if (!activity || observation.at < activity.startedAt || observation.standing === "abandoned")
13
+ const last = observations.reduce((at, observation) => (observation.at > at ? observation.at : at), "");
14
+ const { records, current } = homeDefaultRecords(graph, observations, last);
15
+ for (const record of records) {
16
+ const activity = record.surface === undefined ? undefined : surfaces.get(record.surface);
17
+ if (!activity || record.at < activity.startedAt || !isDemonstration(record.payload) || !record.payload.unaided)
13
18
  continue;
14
- const payload = observation.payload;
15
- if (isDemonstration(payload) && payload.unaided && activity.stop?.nodes?.includes(payload.node.node))
16
- reviewed.add(activity.surface + "/" + payload.node.node);
19
+ for (const node of current.get(record.id) ?? [])
20
+ if (activity.nodes.includes(node))
21
+ reviewed.add(activity.surface + "/" + node);
17
22
  }
18
- const activeMs = reviews.reduce((sum, activity) => sum + activity.activeMs, 0);
19
- return reviewed.size && activeMs > 0
20
- ? { minutesPerNode: activeMs / 60_000 / reviewed.size, rough: false }
21
- : UNMEASURED_REVIEW_TIMING;
23
+ return reviewed.size ? { minutesPerNode: activeMs / 60_000 / reviewed.size, rough: false } : UNMEASURED_REVIEW_TIMING;
22
24
  }
23
- /** Actual demonstration transitions, not attempts or currently-known Nodes. The fold sees the
24
- * evidence at its recording time, so forgetting after a lesson does not erase the measurement.
25
+ /** Measure demonstrated transitions at recording time. Later forgetting or a change in
26
+ * Record homes does not erase work the Session did.
25
27
  */
26
28
  export function measuredLessonTiming(graph, observations, activities) {
27
29
  return prepareLessonTiming(graph, observations, activities).measure();
@@ -29,20 +31,33 @@ export function measuredLessonTiming(graph, observations, activities) {
29
31
  /** One reading's resumable recording-time scan. Roughness needs only its first transition;
30
32
  * acquisition timing needs the complete unique (teaching surface, Node) denominator. */
31
33
  export function prepareLessonTiming(graph, observations, activities) {
32
- const teaching = activities.filter((activity) => activity.stop?.kind !== "review");
33
- const lessonSurfaces = new Map(teaching.map((activity) => [activity.surface, activity]));
34
+ const teaching = activities.filter((activity) => activity.kind === "lesson");
35
+ const lessonSurfaces = new Map(teaching.flatMap((activity) => [activity.surface, ...(activity.relatedSurfaces ?? [])].map((surface) => [surface, activity])));
34
36
  const demonstrated = new Set();
35
37
  function* transitions() {
36
38
  const state = initDefaultState(graph);
37
39
  let consumed = 0;
38
40
  for (const [index, observation] of observations.entries()) {
39
- const activity = observation.surface === undefined ? undefined : lessonSurfaces.get(observation.surface);
40
- if (activity === undefined || observation.at < activity.startedAt || observation.standing === "abandoned")
41
+ if (observation.standing === "abandoned")
42
+ continue;
43
+ const payload = observation.payload;
44
+ let activity = observation.surface === undefined ? undefined : lessonSurfaces.get(observation.surface);
45
+ const homing = isHoming(payload) ? payload : undefined;
46
+ if (!homing && (!activity || observation.at < activity.startedAt))
41
47
  continue;
42
48
  // Skipped evidence still belongs to the prefix, but never to this activity's denominator.
43
49
  if (consumed < index)
44
50
  state.step(observations.slice(consumed, index));
51
+ consumed = index;
45
52
  const before = state.read(observation.at);
53
+ if (homing) {
54
+ const record = before.records.find(({ id }) => id === homing.of);
55
+ activity = record?.surface === undefined ? undefined : lessonSurfaces.get(record.surface);
56
+ if (!activity || !record || record.at < activity.startedAt)
57
+ continue;
58
+ }
59
+ if (!activity)
60
+ continue;
46
61
  state.step([observation]);
47
62
  consumed = index + 1;
48
63
  const after = state.read(observation.at);
package/dist/tools.js CHANGED
@@ -217,7 +217,7 @@ function retractionCandidates(ctx, observations) {
217
217
  }));
218
218
  }
219
219
  function lessonCompletion(ctx) {
220
- const lesson = ctx.lesson?.lesson ?? (ctx.entry?.kind === "lesson" ? ctx.entry.lesson : undefined);
220
+ const lesson = ctx.lesson?.here;
221
221
  if (ctx.mode !== "lesson" || lesson === undefined)
222
222
  return undefined;
223
223
  const nodes = lesson.nodes.map((node) => {
@@ -523,7 +523,7 @@ const recordDemonstration = {
523
523
  throw new Error("Invalid demonstration");
524
524
  const observation = { at: ctx.now, about: [...ctx.about], nodes: [node], surface: ctx.surface, payload };
525
525
  const id = yield* write(observation);
526
- const lesson = ctx.mode === "lesson" && (ctx.lesson !== undefined || ctx.entry?.kind === "lesson")
526
+ const lesson = ctx.mode === "lesson" && ctx.lesson !== undefined
527
527
  ? lessonCompletion({ ...ctx, state: stateDefault(ctx.graph, yield* read.observations({}), ctx.now) })
528
528
  : undefined;
529
529
  return { observation: { ...observation, id }, citations: [id], ...(lesson === undefined ? {} : { lesson }) };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mmon-co/ncept-default-theory",
3
- "version": "3.0.18",
3
+ "version": "3.0.20",
4
4
  "license": "FSL-1.1-ALv2",
5
5
  "repository": {
6
6
  "type": "git",