@ftrdotdev/pi-tracker 0.8.0 → 0.9.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/src/index.ts CHANGED
@@ -2,10 +2,8 @@ import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-a
2
2
  import { getAgentDir } from "@earendil-works/pi-coding-agent";
3
3
  import { Text } from "@earendil-works/pi-tui";
4
4
  import { makeBorderedBox, VimRouter } from "@ftrdotdev/pi-tui";
5
- import * as NodeFileSystem from "@effect/platform-node/NodeFileSystem";
6
- import { Effect, Layer, ManagedRuntime, Option, Result } from "effect";
5
+ import { Effect, Option, Result } from "effect";
7
6
  import { join } from "node:path";
8
- import { ClassifierGateway } from "./compaction/classifier.ts";
9
7
  import { CompletionObserver } from "./compaction/completion.ts";
10
8
  import { DECISION_CUSTOM_TYPE, encodeDecisionRecord } from "./compaction/decision-record.ts";
11
9
  import { FootprintRecorder, productionProbe, type ToolEvent } from "./compaction/footprint.ts";
@@ -18,10 +16,7 @@ import {
18
16
  import { TodoItem, TodoList, TrackerState, emptyState, encodeState } from "./core/domain.ts";
19
17
  import { TrackerPersistence } from "./core/persistence.ts";
20
18
  import { SMART_COMPACTION_CUSTOM_TYPE } from "./compaction/pointer.ts";
21
- import {
22
- SMART_COMPACTION_CONFIG_FILE,
23
- SmartCompactionSettingsService,
24
- } from "./compaction/settings.ts";
19
+ import { SMART_COMPACTION_CONFIG_FILE } from "./compaction/settings.ts";
25
20
  import { SettleDecider } from "./compaction/settle.ts";
26
21
  import { TrackerError, TrackerStore, type ItemSpec, type UpdateItemPatch } from "./core/store.ts";
27
22
  import {
@@ -43,9 +38,7 @@ import {
43
38
  type TrackerUiAction,
44
39
  } from "./presentation/ui.ts";
45
40
  import { VimSettingsService } from "./presentation/vim-settings.ts";
46
-
47
- /** Custom-entry type used to persist the tracker state in the session. */
48
- const CUSTOM_TYPE = "tracker/state";
41
+ import { CUSTOM_TYPE, makeTrackerRuntime } from "./layers.ts";
49
42
 
50
43
  // --------------------------------------------------------------------------
51
44
  // Effect bridge
@@ -105,6 +98,18 @@ const requireParam = <T>(value: T | undefined, name: string): T => {
105
98
  return value;
106
99
  };
107
100
 
101
+ /**
102
+ * Render one loose `title` field for the call summary. Args can come from failed
103
+ * validation, so a non-string title renders empty instead of `[object Object]`.
104
+ */
105
+ const looseTitle = (entry: unknown): string => {
106
+ if (typeof entry === "object" && entry !== null) {
107
+ const title = (entry as { readonly title?: unknown }).title;
108
+ return typeof title === "string" || typeof title === "number" ? String(title) : "";
109
+ }
110
+ return typeof entry === "string" ? entry : "";
111
+ };
112
+
108
113
  /** Project the tool's item objects onto the store's item specs. */
109
114
  const toItemSpecs = (items: readonly TrackerItemSpec[]): ItemSpec[] =>
110
115
  items.map((item) => ({
@@ -126,23 +131,11 @@ export default function (pi: ExtensionAPI): void {
126
131
  // One shared config path: the smart-compaction reader and the vim reader both
127
132
  // read `tui.json`, owned by the TUI package.
128
133
  const configPath = join(getAgentDir(), SMART_COMPACTION_CONFIG_FILE);
129
- const decisionServices = Layer.mergeAll(
130
- CompletionObserver.layer,
131
- ClassifierGateway.layer,
132
- FootprintRecorder.layer(probe),
133
- SmartCompactionSettingsService.make(configPath),
134
- VimSettingsService.make(configPath),
135
- );
136
-
137
- const runtime = ManagedRuntime.make(
138
- SettleDecider.layer(probe).pipe(
139
- Layer.provideMerge(Layer.mergeAll(TrackerStore.layer, decisionServices)),
140
- Layer.provideMerge(
141
- TrackerPersistence.layer((encoded) => pi.appendEntry(CUSTOM_TYPE, encoded)),
142
- ),
143
- Layer.provide(NodeFileSystem.layer),
144
- ),
145
- );
134
+ const runtime = makeTrackerRuntime({
135
+ appendEntry: (type, data) => pi.appendEntry(type, data),
136
+ configPath,
137
+ probe,
138
+ });
146
139
 
147
140
  /** Mirror of the store state, read by the widget and tool renderers. */
148
141
  let state: TrackerState = emptyState();
@@ -324,7 +317,7 @@ export default function (pi: ExtensionAPI): void {
324
317
  ctx.ui.notify("tracker: saved state could not be decoded — starting empty", "warning");
325
318
  state = emptyState();
326
319
  } else {
327
- state = Option.getOrThrow(Result.getSuccess(result));
320
+ state = Result.getSuccess(result).pipe(Option.getOrThrow);
328
321
  }
329
322
  }
330
323
  await runtime.runPromise(withStore((store) => store.reset(state)));
@@ -408,7 +401,7 @@ export default function (pi: ExtensionAPI): void {
408
401
  if (decision.kind !== "compact") return;
409
402
  // The run signal can fire after the verdict, while the classifier is the
410
403
  // last thing between here and compaction. An abort keeps the context.
411
- if (ctx.signal?.aborted) return;
404
+ if (ctx.signal?.aborted ?? false) return;
412
405
  const pointer = decision.pointer;
413
406
  // Delivery comes from pi's completion contract, which fires only after
414
407
  // compaction has finished. `deliver` is idempotent, so a double callback
@@ -550,7 +543,7 @@ export default function (pi: ExtensionAPI): void {
550
543
  text = "Active list cleared (widget hidden)";
551
544
  } else {
552
545
  const list = current.lists.find((l) => l.id === params.list_id);
553
- text = `Active list: ${list ? list.name : `#${params.list_id}`}`;
546
+ text = `Active list: ${list !== undefined ? list.name : `#${params.list_id}`}`;
554
547
  }
555
548
  break;
556
549
  }
@@ -559,7 +552,7 @@ export default function (pi: ExtensionAPI): void {
559
552
  const list = current.lists.find((l) => l.id === params.list_id);
560
553
  details.list = list;
561
554
  details.items = items;
562
- const listName = list ? list.name : `#${params.list_id}`;
555
+ const listName = list !== undefined ? list.name : `#${params.list_id}`;
563
556
  // The store assigned each new item its id; report those.
564
557
  const ids = items.map((item) => `${listName}:${item.id}`);
565
558
  text =
@@ -584,18 +577,18 @@ export default function (pi: ExtensionAPI): void {
584
577
  batch !== undefined
585
578
  ? batch.map((p) => ({
586
579
  id: p.item_id,
587
- title: p.title,
588
- description: p.description,
589
- done: p.done,
590
- deps: p.deps,
580
+ ...(p.title === undefined ? {} : { title: p.title }),
581
+ ...(p.description === undefined ? {} : { description: p.description }),
582
+ ...(p.done === undefined ? {} : { done: p.done }),
583
+ ...(p.deps === undefined ? {} : { deps: p.deps }),
591
584
  }))
592
585
  : [
593
586
  {
594
587
  id: params.item_id ?? "?",
595
- title: typeof params.title === "string" ? params.title : undefined,
596
- description: params.description,
597
- done: params.done,
598
- deps: params.deps,
588
+ ...(typeof params.title === "string" ? { title: params.title } : {}),
589
+ ...(params.description === undefined ? {} : { description: params.description }),
590
+ ...(params.done === undefined ? {} : { done: params.done }),
591
+ ...(params.deps === undefined ? {} : { deps: params.deps }),
599
592
  },
600
593
  ];
601
594
  const parts = items.map((item, i) => {
@@ -647,7 +640,7 @@ export default function (pi: ExtensionAPI): void {
647
640
  pi.registerTool({
648
641
  ...TRACKER_TOOL_METADATA,
649
642
 
650
- async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
643
+ async execute(_toolCallId, params: TrackerToolParams, _signal, _onUpdate, ctx) {
651
644
  const action = params.action;
652
645
  // Error-nudging gate: reject incorrect calls (missing required fields,
653
646
  // unknown fields, mixed update_items forms) with a precise message that
@@ -672,10 +665,10 @@ export default function (pi: ExtensionAPI): void {
672
665
 
673
666
  const result = await runtime.runPromise(Effect.result(program));
674
667
  if (Result.isFailure(result)) {
675
- const failure = Option.getOrThrow(Result.getFailure(result));
668
+ const failure = Result.getFailure(result).pipe(Option.getOrThrow);
676
669
  return toolError(action, failure.message);
677
670
  }
678
- const value = Option.getOrThrow(Result.getSuccess(result));
671
+ const value = Result.getSuccess(result).pipe(Option.getOrThrow);
679
672
  // `list` reports the store state it just read; a mutation reports the
680
673
  // state it persisted. Both are authoritative, so no result depends on
681
674
  // the widget mirror.
@@ -686,34 +679,19 @@ export default function (pi: ExtensionAPI): void {
686
679
  renderCall(args, theme, _context) {
687
680
  // Args can come from failed validation too, so read them loosely.
688
681
  const raw = args as unknown as Record<string, unknown>;
689
- const action = String(raw.action ?? "list");
682
+ const action = typeof raw.action === "string" ? raw.action : "list";
690
683
  let text =
691
684
  theme.style("tracker ", { fg: "toolTitle", bold: true }) + theme.fg("muted", action);
692
685
  if (typeof raw.name === "string") text += ` ${theme.fg("dim", `"${raw.name}"`)}`;
693
686
  if (typeof raw.title === "string") {
694
687
  text += ` ${theme.fg("dim", `"${raw.title}"`)}`;
695
688
  } else if (Array.isArray(raw.title)) {
696
- text += ` ${theme.fg(
697
- "dim",
698
- raw.title
699
- .map((entry) =>
700
- typeof entry === "string"
701
- ? `"${entry}"`
702
- : `"${String((entry as { title?: unknown }).title ?? "")}"`,
703
- )
704
- .join(" "),
705
- )}`;
689
+ text += ` ${theme.fg("dim", raw.title.map((entry) => `"${looseTitle(entry)}"`).join(" "))}`;
706
690
  }
707
691
  if (Array.isArray(raw.initial_items)) {
708
692
  text += ` ${theme.fg(
709
693
  "dim",
710
- raw.initial_items
711
- .map((entry) =>
712
- typeof entry === "string"
713
- ? `"${entry}"`
714
- : `"${String((entry as { title?: unknown }).title ?? "")}"`,
715
- )
716
- .join(" "),
694
+ raw.initial_items.map((entry) => `"${looseTitle(entry)}"`).join(" "),
717
695
  )}`;
718
696
  }
719
697
  if (Array.isArray(raw.items)) text += ` ${theme.fg("accent", `${raw.items.length} items`)}`;
@@ -725,16 +703,16 @@ export default function (pi: ExtensionAPI): void {
725
703
 
726
704
  renderResult(result, { expanded }, theme, _context) {
727
705
  const details = result.details as TrackerToolDetails | undefined;
728
- if (!details) {
706
+ if (details === undefined) {
729
707
  const text = result.content[0];
730
708
  return new Text(text?.type === "text" ? text.text : "", 0, 0);
731
709
  }
732
- if (details.error) {
710
+ if (details.error !== undefined && details.error !== "") {
733
711
  return new Text(theme.fg("error", `Error: ${details.error}`), 0, 0);
734
712
  }
735
713
  if (details.action === "list") {
736
714
  const snapshot = details.snapshot;
737
- if (!snapshot || snapshot.lists.length === 0) {
715
+ if (snapshot === undefined || snapshot.lists.length === 0) {
738
716
  return new Text(theme.fg("dim", "No lists"), 0, 0);
739
717
  }
740
718
  const parts: string[] = [];
@@ -781,7 +759,7 @@ export default function (pi: ExtensionAPI): void {
781
759
  ): Promise<string | null> => {
782
760
  const result = await runtime.runPromise(Effect.result(uiActionProgram(action)));
783
761
  if (Result.isFailure(result)) {
784
- return Option.getOrThrow(Result.getFailure(result)).message;
762
+ return Result.getFailure(result).pipe(Option.getOrThrow).message;
785
763
  }
786
764
  await applyMutation(ctx);
787
765
  return null;
@@ -799,8 +777,9 @@ export default function (pi: ExtensionAPI): void {
799
777
  // overlay's help line reports which keys are live.
800
778
  const vimEnabled = await runtime.runPromise(withVimSettings((settings) => settings.load));
801
779
  const vim = {
802
- router: Effect.runSync(
803
- Effect.service(VimRouter).pipe(Effect.provide(VimRouter.make(() => vimEnabled))),
780
+ router: Effect.service(VimRouter).pipe(
781
+ Effect.provide(VimRouter.make(() => vimEnabled)),
782
+ Effect.runSync,
804
783
  ),
805
784
  enabled: vimEnabled,
806
785
  };
@@ -0,0 +1,101 @@
1
+ import { assert, it } from "@effect/vitest";
2
+ import { Effect } from "effect";
3
+ import { containsSymbol, type FileProbe } from "./compaction/observations.ts";
4
+ import { emptyState, encodeState } from "./core/domain.ts";
5
+ import { TrackerPersistence } from "./core/persistence.ts";
6
+ import { TrackerStore } from "./core/store.ts";
7
+ import { CUSTOM_TYPE, makeTrackerRuntime, type TrackerRuntimeDeps } from "./layers.ts";
8
+
9
+ // ---------------------------------------------------------------------------
10
+ // makeTrackerRuntime — the tracker package's one composition point. Moving the
11
+ // graph out of the bridge must not change what it serves (Slice 7).
12
+ // ---------------------------------------------------------------------------
13
+
14
+ /** A probe over a path-to-text map, the same double the settle tests use. */
15
+ const probeOf = (files: Readonly<Record<string, string>>): FileProbe => ({
16
+ read: (path) => files[path],
17
+ findSymbol: (symbol) =>
18
+ Object.entries(files)
19
+ .filter(([, text]) => containsSymbol(text, symbol))
20
+ .map(([path]) => path),
21
+ });
22
+
23
+ const depsOver = (
24
+ appendEntry: (type: string, data: unknown) => void,
25
+ probe: FileProbe = probeOf({}),
26
+ ): TrackerRuntimeDeps => ({
27
+ appendEntry,
28
+ configPath: "/tmp/x/compaction.json",
29
+ probe,
30
+ });
31
+
32
+ it.effect("the composed runtime serves the store and the decision services", () => {
33
+ // Arrange
34
+ const runtime = makeTrackerRuntime(depsOver(() => {}));
35
+
36
+ // Act
37
+ const program = Effect.flatMap(TrackerStore, (store) => store.createList("Work"));
38
+
39
+ // Assert
40
+ return Effect.promise(() => runtime.runPromise(program)).pipe(
41
+ Effect.tap((list) => Effect.sync(() => assert.strictEqual(list.id, 1))),
42
+ Effect.asVoid,
43
+ );
44
+ });
45
+
46
+ it.effect("the persistence layer keeps its injected append boundary", () => {
47
+ // Arrange: a recording append, one state to round-trip.
48
+ const appends: Array<{ type: string; data: unknown }> = [];
49
+ const runtime = makeTrackerRuntime(
50
+ depsOver((type, data) => {
51
+ appends.push({ type, data });
52
+ }),
53
+ );
54
+ const state = emptyState();
55
+
56
+ // Act
57
+ const program = Effect.gen(function* () {
58
+ const persistence = yield* TrackerPersistence;
59
+ yield* persistence.save(state);
60
+ return yield* persistence.restore(encodeState(state));
61
+ });
62
+
63
+ // Assert: exactly one append, and the restored state matches.
64
+ return Effect.promise(() => runtime.runPromise(program)).pipe(
65
+ Effect.tap((restored) =>
66
+ Effect.sync(() => {
67
+ assert.strictEqual(appends.length, 1);
68
+ assert.strictEqual(appends[0]?.type, CUSTOM_TYPE);
69
+ assert.deepStrictEqual(restored, state);
70
+ }),
71
+ ),
72
+ Effect.asVoid,
73
+ );
74
+ });
75
+
76
+ it("the factory builds nothing until first use", () => {
77
+ // Arrange: recording boundary doubles, but no runPromise.
78
+ const calls: string[] = [];
79
+ const appends: string[] = [];
80
+ const probe: FileProbe = {
81
+ read: (path) => {
82
+ calls.push(path);
83
+ return undefined;
84
+ },
85
+ findSymbol: (symbol) => {
86
+ calls.push(symbol);
87
+ return [];
88
+ },
89
+ };
90
+
91
+ // Act
92
+ makeTrackerRuntime(
93
+ depsOver((type) => {
94
+ appends.push(type);
95
+ }, probe),
96
+ );
97
+
98
+ // Assert: the runtime is lazy, so construction touched nothing.
99
+ assert.deepStrictEqual(calls, []);
100
+ assert.deepStrictEqual(appends, []);
101
+ });
package/src/layers.ts ADDED
@@ -0,0 +1,46 @@
1
+ import * as NodeFileSystem from "@effect/platform-node/NodeFileSystem";
2
+ import { Layer, ManagedRuntime } from "effect";
3
+ import { ClassifierGateway } from "./compaction/classifier.ts";
4
+ import { CompletionObserver } from "./compaction/completion.ts";
5
+ import { FootprintRecorder } from "./compaction/footprint.ts";
6
+ import type { FileProbe } from "./compaction/observations.ts";
7
+ import { SmartCompactionSettingsService } from "./compaction/settings.ts";
8
+ import { SettleDecider } from "./compaction/settle.ts";
9
+ import { TrackerPersistence } from "./core/persistence.ts";
10
+ import { TrackerStore } from "./core/store.ts";
11
+ import { VimSettingsService } from "./presentation/vim-settings.ts";
12
+
13
+ /** Custom-entry type used to persist the tracker state in the session. */
14
+ export const CUSTOM_TYPE = "tracker/state";
15
+
16
+ /** The boundary inputs the tracker bridge supplies (append, config path, probe). */
17
+ export interface TrackerRuntimeDeps {
18
+ readonly appendEntry: (type: string, data: unknown) => void;
19
+ readonly configPath: string;
20
+ readonly probe: FileProbe;
21
+ }
22
+
23
+ /** Every decision service, composed once from the bridge's boundary inputs. */
24
+ const decisionServices = (deps: TrackerRuntimeDeps) =>
25
+ Layer.mergeAll(
26
+ CompletionObserver.layer,
27
+ ClassifierGateway.layer,
28
+ FootprintRecorder.layer(deps.probe),
29
+ SmartCompactionSettingsService.make(deps.configPath),
30
+ VimSettingsService.make(deps.configPath),
31
+ );
32
+
33
+ /**
34
+ * The tracker package's one composition point: the store, the decision services
35
+ * and the injected persistence append, built lazily on first use.
36
+ */
37
+ export const makeTrackerRuntime = (deps: TrackerRuntimeDeps) =>
38
+ ManagedRuntime.make(
39
+ SettleDecider.layer(deps.probe).pipe(
40
+ Layer.provideMerge(Layer.mergeAll(TrackerStore.layer, decisionServices(deps))),
41
+ Layer.provideMerge(
42
+ TrackerPersistence.layer((encoded) => deps.appendEntry(CUSTOM_TYPE, encoded)),
43
+ ),
44
+ Layer.provide(NodeFileSystem.layer),
45
+ ),
46
+ );
@@ -1,6 +1,6 @@
1
1
  import { describe, expect, it } from "vitest";
2
- import { Value } from "typebox/value";
3
- import { TodoItem, TodoList, TrackerState, emptyState } from "../core/domain.ts";
2
+ import { compile } from "@earendil-works/pi-schema";
3
+ import { TodoItem, TodoList, TrackerState } from "../core/domain.ts";
4
4
  import {
5
5
  TOOL_ACTIONS,
6
6
  TRACKER_TOOL_METADATA,
@@ -12,6 +12,8 @@ import {
12
12
  validateTrackerCall,
13
13
  } from "./tool-metadata.ts";
14
14
 
15
+ const paramsCheck = compile(TrackerToolParams);
16
+
15
17
  describe("tracker tool parameter schema", () => {
16
18
  it("accepts valid parameters for every action", () => {
17
19
  const valid: Array<Record<string, unknown>> = [
@@ -48,59 +50,55 @@ describe("tracker tool parameter schema", () => {
48
50
  { action: "remove_item", item_id: "Work:2" },
49
51
  ];
50
52
  for (const params of valid) {
51
- expect(Value.Check(TrackerToolParams, params), JSON.stringify(params)).toBe(true);
53
+ expect(paramsCheck.check(params), JSON.stringify(params)).toBe(true);
52
54
  }
53
55
  });
54
56
 
55
57
  it("rejects unknown actions", () => {
56
- expect(Value.Check(TrackerToolParams, { action: "bogus" })).toBe(false);
57
- expect(Value.Check(TrackerToolParams, {})).toBe(false);
58
+ expect(paramsCheck.check({ action: "bogus" })).toBe(false);
59
+ expect(paramsCheck.check({})).toBe(false);
58
60
  });
59
61
 
60
62
  it("rejects wrong parameter types", () => {
61
63
  expect(
62
- Value.Check(TrackerToolParams, {
64
+ paramsCheck.check({
63
65
  action: "add_items",
64
66
  list_id: "one",
65
67
  items: [{ title: "x" }],
66
68
  }),
67
69
  ).toBe(false);
68
- expect(Value.Check(TrackerToolParams, { action: "create_list", name: 42 })).toBe(false);
69
- expect(Value.Check(TrackerToolParams, { action: "create_list", activate: "yes" })).toBe(false);
70
- expect(Value.Check(TrackerToolParams, { action: "update_items", done: "yes" })).toBe(false);
71
- expect(
72
- Value.Check(TrackerToolParams, { action: "add_items", list_id: 1, items: [1, "x"] }),
73
- ).toBe(false);
70
+ expect(paramsCheck.check({ action: "create_list", name: 42 })).toBe(false);
71
+ expect(paramsCheck.check({ action: "create_list", activate: "yes" })).toBe(false);
72
+ expect(paramsCheck.check({ action: "update_items", done: "yes" })).toBe(false);
73
+ expect(paramsCheck.check({ action: "add_items", list_id: 1, items: [1, "x"] })).toBe(false);
74
74
  expect(
75
- Value.Check(TrackerToolParams, {
75
+ paramsCheck.check({
76
76
  action: "update_items",
77
77
  list_id: 1,
78
78
  items: [{ item_id: 1, done: "yes" }],
79
79
  }),
80
80
  ).toBe(false);
81
81
  expect(
82
- Value.Check(TrackerToolParams, {
82
+ paramsCheck.check({
83
83
  // index inside the batch is the old positional field; patch objects are strict.
84
84
  action: "update_items",
85
85
  list_id: 1,
86
86
  items: [{ index: 1, done: true }],
87
87
  }),
88
88
  ).toBe(false);
89
- expect(Value.Check(TrackerToolParams, { action: "update_items", item_id: 2 })).toBe(false); // ids are strings
89
+ expect(paramsCheck.check({ action: "update_items", item_id: 2 })).toBe(false); // ids are strings
90
90
  });
91
91
 
92
92
  it("rejects empty batch arrays", () => {
93
- expect(Value.Check(TrackerToolParams, { action: "add_items", list_id: 1, items: [] })).toBe(
93
+ expect(paramsCheck.check({ action: "add_items", list_id: 1, items: [] })).toBe(false);
94
+ expect(paramsCheck.check({ action: "update_items", items: [] })).toBe(false);
95
+ expect(paramsCheck.check({ action: "create_list", name: "Work", initial_items: [] })).toBe(
94
96
  false,
95
97
  );
96
- expect(Value.Check(TrackerToolParams, { action: "update_items", items: [] })).toBe(false);
97
- expect(
98
- Value.Check(TrackerToolParams, { action: "create_list", name: "Work", initial_items: [] }),
99
- ).toBe(false);
100
- expect(
101
- Value.Check(TrackerToolParams, { action: "create_list", name: "Work", initial_items: [1] }),
102
- ).toBe(false);
103
- expect(Value.Check(TrackerToolParams, { action: "set_active", list_id: "one" })).toBe(false);
98
+ expect(paramsCheck.check({ action: "create_list", name: "Work", initial_items: [1] })).toBe(
99
+ false,
100
+ );
101
+ expect(paramsCheck.check({ action: "set_active", list_id: "one" })).toBe(false);
104
102
  });
105
103
  });
106
104
 
@@ -376,7 +374,7 @@ describe("validateTrackerCall (error-nudging layer)", () => {
376
374
  },
377
375
  ];
378
376
  for (const call of calls) {
379
- expect(Value.Check(TrackerToolParams, call), JSON.stringify(call)).toBe(true);
377
+ expect(paramsCheck.check(call), JSON.stringify(call)).toBe(true);
380
378
  expect(validateTrackerCall(call).ok, JSON.stringify(call)).toBe(true);
381
379
  }
382
380
  });
@@ -420,7 +418,7 @@ describe("validateTrackerCall (error-nudging layer)", () => {
420
418
  { action: "update_items", list_id: 1, items: [{ item_id: "Work:2", deps: ["Work:1"] }] },
421
419
  ];
422
420
  for (const call of valid) {
423
- expect(Value.Check(TrackerToolParams, call), JSON.stringify(call)).toBe(true);
421
+ expect(paramsCheck.check(call), JSON.stringify(call)).toBe(true);
424
422
  const result = validateTrackerCall(call);
425
423
  expect(result.ok, JSON.stringify(call)).toBe(true);
426
424
  }
@@ -448,7 +446,7 @@ describe("validateTrackerCall (error-nudging layer)", () => {
448
446
 
449
447
  it("rejects a batch entry that carries both an item_id and a stray index", () => {
450
448
  expect(
451
- Value.Check(TrackerToolParams, {
449
+ paramsCheck.check({
452
450
  action: "update_items",
453
451
  list_id: 1,
454
452
  items: [{ item_id: "Work:1", index: 1, deps: [] }],
@@ -490,24 +488,24 @@ describe("blockedDoneNote (advisory done-blocked guard)", () => {
490
488
  deps: ReadonlyArray<readonly string[]>,
491
489
  done: readonly number[],
492
490
  ): TrackerState =>
493
- new TrackerState({
494
- ...emptyState(),
491
+ TrackerState.make({
495
492
  lists: [
496
- new TodoList({
493
+ TodoList.make({
497
494
  id: 1,
498
495
  name: "Work",
499
496
  nextItemId: deps.length + 1,
500
- items: deps.map(
501
- (itemDeps, index) =>
502
- new TodoItem({
503
- id: index + 1,
504
- title: `item ${index + 1}`,
505
- done: done.includes(index),
506
- deps: itemDeps,
507
- }),
497
+ items: deps.map((itemDeps, index) =>
498
+ TodoItem.make({
499
+ id: index + 1,
500
+ title: `item ${index + 1}`,
501
+ done: done.includes(index),
502
+ deps: itemDeps,
503
+ }),
508
504
  ),
509
505
  }),
510
506
  ],
507
+ activeListId: null,
508
+ nextListId: 1,
511
509
  });
512
510
 
513
511
  it("notes the done dependents of a reopened item", () => {