notesoup 0.39.0 → 0.41.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 (91) hide show
  1. package/README.md +5 -2
  2. package/dist/src/boot/render.js +2 -2
  3. package/dist/src/boot/text.d.ts +0 -4
  4. package/dist/src/boot/text.js +18 -14
  5. package/dist/src/budget/policy.js +1 -1
  6. package/dist/src/budget/text.js +1 -1
  7. package/dist/src/dream/doctor.js +2 -1
  8. package/dist/src/dream/git.js +2 -1
  9. package/dist/src/dream/report.js +3 -2
  10. package/dist/src/error-message.d.ts +2 -0
  11. package/dist/src/error-message.js +4 -0
  12. package/dist/src/history/history.d.ts +23 -18
  13. package/dist/src/history/history.js +37 -20
  14. package/dist/src/history/query.d.ts +37 -49
  15. package/dist/src/history/query.js +114 -56
  16. package/dist/src/notes/store.d.ts +3 -4
  17. package/dist/src/notes/store.js +12 -16
  18. package/dist/src/pi/anchored.d.ts +16 -0
  19. package/dist/src/pi/anchored.js +55 -0
  20. package/dist/src/pi/budget.d.ts +1 -1
  21. package/dist/src/pi/budget.js +33 -28
  22. package/dist/src/pi/dream/cli.js +3 -2
  23. package/dist/src/pi/dream/runner.js +2 -1
  24. package/dist/src/pi/history-tools.d.ts +1 -1
  25. package/dist/src/pi/history-tools.js +2 -3
  26. package/dist/src/pi/reset/lifecycle.d.ts +1 -1
  27. package/dist/src/pi/reset/lifecycle.js +4 -3
  28. package/dist/src/pi/reset/text.d.ts +3 -3
  29. package/dist/src/pi/reset/text.js +2 -2
  30. package/dist/src/pi/runtime.js +12 -15
  31. package/dist/src/pi/thresholds.js +2 -1
  32. package/dist/src/pi/tool-names.d.ts +0 -4
  33. package/dist/src/pi/tool-names.js +0 -4
  34. package/dist/src/tools/history.d.ts +24 -33
  35. package/dist/src/tools/history.js +57 -98
  36. package/dist/src/tools/notes.d.ts +26 -58
  37. package/dist/src/tools/notes.js +85 -103
  38. package/dist/src/tools/result.d.ts +16 -13
  39. package/dist/src/tools/result.js +24 -50
  40. package/dist/src/tools/schema.d.ts +2 -2
  41. package/dist/src/tools/schema.js +3 -3
  42. package/dist/test/agent-loop.test.js +79 -29
  43. package/dist/test/boot.integration.test.js +6 -6
  44. package/dist/test/budget-settings.integration.test.js +9 -8
  45. package/dist/test/claude-mod.test.js +11 -11
  46. package/dist/test/dependencies.test.js +1 -1
  47. package/dist/test/helpers/extension.js +2 -3
  48. package/dist/test/history.integration.test.js +200 -123
  49. package/dist/test/host-neutral.test.js +32 -58
  50. package/dist/test/notes-library.test.js +8 -8
  51. package/dist/test/notes.integration.test.js +75 -57
  52. package/dist/test/notes.test.js +44 -42
  53. package/dist/test/reset-lifecycle.test.js +2 -2
  54. package/docs/architecture.md +3 -3
  55. package/docs/notes-library.md +6 -6
  56. package/docs/tool-results.md +15 -25
  57. package/mods/notesoup/.claude-plugin/plugin.json +1 -1
  58. package/mods/notesoup/dist/claude/helper.js +128 -179
  59. package/mods/notesoup/hooks/register.ts +19 -25
  60. package/mods/notesoup/playbook.md +10 -10
  61. package/mods/notesoup/skills/dream/SKILL.md +1 -1
  62. package/package.json +1 -1
  63. package/playbook.md +10 -10
  64. package/skills/dream/SKILL.md +1 -1
  65. package/skills/memory/SKILL.md +11 -9
  66. package/src/boot/render.ts +2 -2
  67. package/src/boot/text.ts +18 -18
  68. package/src/budget/policy.ts +1 -1
  69. package/src/budget/text.ts +1 -1
  70. package/src/dream/doctor.ts +2 -1
  71. package/src/dream/git.ts +2 -1
  72. package/src/dream/report.ts +3 -2
  73. package/src/error-message.ts +4 -0
  74. package/src/history/history.ts +36 -20
  75. package/src/history/query.ts +130 -55
  76. package/src/notes/store.ts +15 -18
  77. package/src/pi/anchored.ts +62 -0
  78. package/src/pi/budget.ts +27 -26
  79. package/src/pi/dream/cli.ts +3 -2
  80. package/src/pi/dream/runner.ts +2 -1
  81. package/src/pi/history-tools.ts +2 -3
  82. package/src/pi/reset/lifecycle.ts +5 -4
  83. package/src/pi/reset/text.ts +2 -2
  84. package/src/pi/runtime.ts +12 -15
  85. package/src/pi/thresholds.ts +2 -1
  86. package/src/pi/tool-names.ts +0 -4
  87. package/src/tools/history.ts +61 -100
  88. package/src/tools/notes.ts +84 -97
  89. package/src/tools/result.ts +24 -49
  90. package/src/tools/schema.ts +3 -3
  91. package/mods/pi-context/dist/claude/helper.js +0 -9324
@@ -42,7 +42,7 @@ test("notes and history tools are grouped under their own namespaces", () => {
42
42
  for (const name of ["notes_write", "notes_update", "notes_read", "notes_list", "notes_search"]) {
43
43
  assert.equal(captured.tools.get(name)?.namespace?.name, "notes", `${name} is in notes`);
44
44
  }
45
- for (const name of ["history_windows", "history_list", "history_read", "history_search"]) {
45
+ for (const name of ["history_windows", "history_list", "history_read"]) {
46
46
  assert.equal(captured.tools.get(name)?.namespace?.name, "history", `${name} is in history`);
47
47
  }
48
48
  });
@@ -65,7 +65,7 @@ test("every notes tool declares a result schema that accepts its own structured
65
65
  assert.equal(Check(schema, result.structuredContent), true, `${name} structured payload matches its declared schema`);
66
66
  }
67
67
  });
68
- test("note schemas drop status/stale and expose crumpled plus wastebasket", () => {
68
+ test("note schemas drop status/stale and expose crumpled listing", () => {
69
69
  const captured = makeExtension(manager());
70
70
  const schema = (name) => captured.tools.get(name).parameters;
71
71
  const write = schema("notes_write");
@@ -78,8 +78,12 @@ test("note schemas drop status/stale and expose crumpled plus wastebasket", () =
78
78
  assert.equal(Check(edit, { address: "a.md", status: "archived" }), false, "status is gone");
79
79
  for (const name of ["notes_list", "notes_search"]) {
80
80
  const base = name === "notes_search" ? { query: "x" } : {};
81
- assert.equal(Check(schema(name), { ...base, wastebasket: true }), true, `${name} accepts wastebasket`);
81
+ assert.equal(Check(schema(name), { ...base, crumpled: true }), true, `${name} accepts crumpled`);
82
82
  assert.equal(Check(schema(name), { ...base, status: "active" }), false, `${name} rejects status`);
83
+ // The retired names are unknown parameters, refused like any other: `additionalProperties: false`.
84
+ for (const retired of [{ wastebasket: true }, { pattern: "**" }]) {
85
+ assert.equal(Check(schema(name), { ...base, ...retired }), false, `${name} refuses the retired ${Object.keys(retired)[0]} as an unknown parameter`);
86
+ }
83
87
  }
84
88
  });
85
89
  test("write lands a real markdown file with harness frontmatter and a pure body", async () => {
@@ -233,19 +237,18 @@ test("edit is body-scoped with named failures and a replace_all escape hatch", a
233
237
  const ambiguous = resultError(await call(captured, "notes_update", { address: "edit.md", edits: [{ oldText: "beta", newText: "B" }] }, ctx));
234
238
  assert.match(ambiguous.message, /occurs 2 times/);
235
239
  assert.equal(ambiguous.code, "ambiguous_edit");
236
- assert.deepEqual(ambiguous.details?.line_numbers, [2, 3], "the multi-match error carries every match line number");
240
+ assert.match(ambiguous.message, /edit 0: oldText occurs 2 times \(lines 2, 3\)/, "the message names the failing edit index and every match line");
237
241
  const missing = resultError(await call(captured, "notes_update", { address: "edit.md", edits: [{ oldText: "absent", newText: "x" }] }, ctx));
238
242
  assert.equal(missing.code, "no_match");
239
- assert.equal(missing.details?.edit_index, 0, "a zero-match anchor names the failing edit index");
243
+ assert.match(missing.message, /^edit 0:/, "a zero-match anchor names the failing edit index");
240
244
  const all = resultData(await call(captured, "notes_update", { address: "edit.md", edits: [{ oldText: "beta", newText: "B" }], replace_all: true }, ctx));
241
- assert.equal(all.applied, 1);
242
245
  assert.equal(all.address, "edit.md");
243
246
  assertReceiptIdentity(all, "edit.md", "session", ctx);
244
247
  assert.equal(all.change_kind, "body");
245
248
  assert.equal(resultRead(await call(captured, "notes_read", { address: "edit.md" }, ctx)).content, "alpha\nB\nB\ngamma", "replace_all replaces every occurrence");
246
249
  // An anchor that occurs only in frontmatter is not matched: edits are body-only.
247
250
  const frontmatterOnly = resultError(await call(captured, "notes_update", { address: "edit.md", edits: [{ oldText: "origin", newText: "x" }] }, ctx));
248
- assert.equal(frontmatterOnly.details?.edit_index, 0, "a frontmatter-only anchor is not a body match");
251
+ assert.match(frontmatterOnly.message, /^edit 0:/, "a frontmatter-only anchor is not a body match");
249
252
  });
250
253
  test("nothing-to-do, not-found, atomic batches, and replace_all zero-match are named", async () => {
251
254
  freshRoot();
@@ -262,17 +265,17 @@ test("nothing-to-do, not-found, atomic batches, and replace_all zero-match are n
262
265
  const readMissing = resultError(await call(captured, "notes_read", { address: "missing.md" }, ctx));
263
266
  assert.equal(readMissing.message, "note not found");
264
267
  assert.equal(readMissing.code, "not_found");
265
- assert.equal(readMissing.details, undefined, "a plain refusal carries no edit details");
268
+ assert.deepEqual(Object.keys(readMissing).sort(), ["code", "message"], "a plain refusal carries only a code and message");
266
269
  const file = physicalPath("session", "edit.md", ctx);
267
270
  const before = readFileSync(file, "utf8");
268
271
  const failed = resultError(await call(captured, "notes_update", { address: "edit.md", edits: [{ oldText: "alpha", newText: "A" }, { oldText: "absent", newText: "x" }] }, ctx));
269
- assert.equal(failed.details?.edit_index, 1, "the failing edit is named");
272
+ assert.match(failed.message, /^edit 1:/, "the failing edit is named");
270
273
  assert.equal(readFileSync(file, "utf8"), before, "a failing batch leaves the file byte-identical, frontmatter included");
271
274
  const applied = resultData(await call(captured, "notes_update", { address: "edit.md", edits: [{ oldText: "alpha", newText: "A" }, { oldText: "beta", newText: "B" }] }, ctx));
272
- assert.equal(applied.applied, 2);
275
+ assert.equal(applied.change_kind, "body");
273
276
  assert.equal(resultRead(await call(captured, "notes_read", { address: "edit.md" }, ctx)).content, "A\nB");
274
277
  const zero = resultError(await call(captured, "notes_update", { address: "edit.md", edits: [{ oldText: "zzz", newText: "y" }], replace_all: true }, ctx));
275
- assert.equal(zero.details?.edit_index, 0, "replace_all with zero matches is the same zero-match error, not a silent no-op");
278
+ assert.match(zero.message, /^edit 0:/, "replace_all with zero matches is the same zero-match error, not a silent no-op");
276
279
  });
277
280
  test("notes_update rename_to moves a note and refuses combinations and live targets", async () => {
278
281
  freshRoot();
@@ -288,17 +291,16 @@ test("notes_update rename_to moves a note and refuses combinations and live targ
288
291
  const renamed = resultData(await call(captured, "notes_update", { address: "move-me.md", rename_to: "moved.md" }, ctx));
289
292
  assertReceiptIdentity(renamed, "moved.md", "session", ctx);
290
293
  assert.equal(renamed.rename_from, "move-me.md");
291
- assert.equal(renamed.change_kind, "file");
294
+ assert.equal(renamed.change_kind, "moved");
292
295
  assert.equal(renamed.address, "moved.md");
293
- assert.equal(renamed.replaced_crumpled_target, false);
294
296
  const gone = resultError(await call(captured, "notes_read", { address: "move-me.md" }, ctx));
295
297
  assert.equal(gone.message, "note not found", "the old address is gone");
296
298
  assert.equal(resultRead(await call(captured, "notes_read", { address: "moved.md" }, ctx)).content, "body");
297
299
  // Empty filler values are not a combination: a model passing every parameter still gets its crumple.
298
300
  const crumpled = resultData(await call(captured, "notes_update", { address: "moved.md", crumpled: true, edits: [], origin: "self", rename_to: "", replace_all: false }, ctx));
299
301
  assert.equal(crumpled.address, "moved.md", "an empty rename_to is ignored as if omitted");
300
- const basket = resultData(await call(captured, "notes_list", { wastebasket: true }, ctx));
301
- assert.equal(basket.files.some((file) => file.address === "moved.md"), true, "the note was crumpled");
302
+ const listedCrumpled = resultData(await call(captured, "notes_list", { crumpled: true }, ctx));
303
+ assert.equal(listedCrumpled.files.some((file) => file.address === "moved.md"), true, "the note was crumpled");
302
304
  const fillerRename = resultData(await call(captured, "notes_update", { address: "moved.md", rename_to: "moved-again.md", edits: [], replace_all: false }, ctx));
303
305
  assert.equal(fillerRename.address, "moved-again.md", "empty edits and replace_all: false ride along with a rename");
304
306
  const realCombo = resultError(await call(captured, "notes_update", { address: "moved-again.md", rename_to: "nope.md", replace_all: true }, ctx));
@@ -316,32 +318,36 @@ test("write and update receipts distinguish outcomes and no-op edits", async ()
316
318
  await call(captured, "notes_update", { address: "@self/alias", crumpled: true }, ctx);
317
319
  assert.equal(resultData(await call(captured, "notes_write", { address: "@self/alias", content: "restored" }, ctx)).outcome, "uncrumpled");
318
320
  const noChange = resultData(await call(captured, "notes_update", { address: "@self/alias", edits: [{ oldText: "restored", newText: "restored" }], crumpled: false }, ctx));
319
- assert.deepEqual([noChange.applied, noChange.change_kind, noChange.diff], [0, "none", ""]);
321
+ assert.deepEqual([noChange.change_kind, noChange.diff], ["none", ""]);
320
322
  const mixed = resultData(await call(captured, "notes_update", { address: "@self/alias", edits: [{ oldText: "restored", newText: "restored" }, { oldText: "restored", newText: "changed" }] }, ctx));
321
- assert.equal(mixed.applied, 1);
322
323
  assert.equal(mixed.change_kind, "body");
324
+ assert.equal(mixed.change_kind, "body");
325
+ // A body edit that also rewrites frontmatter is still a body change; the diff carries the rest.
326
+ const combined = resultData(await call(captured, "notes_update", { address: "@self/alias", edits: [{ oldText: "changed", newText: "changed once more" }], origin: "user" }, ctx));
327
+ assert.equal(combined.change_kind, "body", "an edit that also rewrites frontmatter is a body change, not a whole file");
328
+ assert.match(combined.diff, /origin/, "the diff still carries the frontmatter part");
323
329
  });
324
330
  test("empty results distinguish hidden notes and unavailable homes", async () => {
325
331
  freshRoot();
326
332
  const session = manager();
327
333
  const captured = makeExtension(session);
328
334
  const ctx = context(session);
329
- const empty = resultData(await call(captured, "notes_list", { pattern: "@human/**" }, ctx));
330
- assert.deepEqual(empty, { files: [], more: 0, crumpled_excluded: 0, homes_unavailable: [] });
335
+ const empty = resultData(await call(captured, "notes_list", { glob: "@human/**" }, ctx));
336
+ assert.deepEqual(empty, { files: [], more: 0, homes_unavailable: [] });
331
337
  await call(captured, "notes_write", { address: "@human/hidden.md", content: "needle" }, ctx);
332
338
  await call(captured, "notes_update", { address: "@human/hidden.md", crumpled: true }, ctx);
333
- const hidden = resultData(await call(captured, "notes_search", { query: "needle", pattern: "@human/**" }, ctx));
334
- assert.equal(hidden.crumpled_excluded, 1);
339
+ const hidden = resultData(await call(captured, "notes_search", { query: "needle", glob: "@human/**" }, ctx));
340
+ assert.deepEqual(hidden.files, [], "a crumpled note is hidden from search");
335
341
  const broken = scopeDir("project", ctx);
336
342
  mkdirSync(join(broken, ".."), { recursive: true });
337
343
  writeFileSync(broken, "not a directory");
338
- const partial = resultData(await call(captured, "notes_list", { pattern: "**" }, ctx));
344
+ const partial = resultData(await call(captured, "notes_list", { glob: "**" }, ctx));
339
345
  assert.deepEqual(partial.homes_unavailable, ["@project"]);
340
346
  assert.deepEqual(partial.files, []);
341
- const searched = resultData(await call(captured, "notes_search", { query: "needle", pattern: "**" }, ctx));
347
+ const searched = resultData(await call(captured, "notes_search", { query: "needle", glob: "**" }, ctx));
342
348
  assert.deepEqual(searched.homes_unavailable, ["@project"]);
343
349
  writeFileSync(join(process.env.PI_NOTES_HOME, "agents"), "not a directory");
344
- const namespace = resultData(await call(captured, "notes_list", { pattern: "@agents/*/note.md" }, ctx));
350
+ const namespace = resultData(await call(captured, "notes_list", { glob: "@agents/*/note.md" }, ctx));
345
351
  assert.deepEqual(namespace.homes_unavailable, ["@agents"]);
346
352
  });
347
353
  test("notes receipts report resolved identity across scopes", async () => {
@@ -367,11 +373,11 @@ test("notes receipts report resolved identity across scopes", async () => {
367
373
  assert.equal(read.metadata.project !== undefined, note.scope === "session", "stored project ownership is exposed as metadata");
368
374
  assert.equal(rawRead.content[0].type === "text" && rawRead.content[0].text.includes("---"), false, "the rendered read carries no frontmatter block");
369
375
  }
370
- const listed = resultData(await call(captured, "notes_list", { pattern: "**" }, ctx));
376
+ const listed = resultData(await call(captured, "notes_list", { glob: "**" }, ctx));
371
377
  assert.deepEqual(listed.files.map((file) => file.address).sort(), notes.map((note) => note.address).sort(), "notes_list returns each full address");
372
378
  for (const row of listed.files)
373
379
  assertReceiptIdentity(row, row.address, notes.find((note) => note.address === row.address).scope, ctx);
374
- const searched = resultData(await call(captured, "notes_search", { query: "match", pattern: "**" }, ctx));
380
+ const searched = resultData(await call(captured, "notes_search", { query: "match", glob: "**" }, ctx));
375
381
  assert.deepEqual(searched.files.map((file) => file.address), notes.map((note) => note.address).sort(), "notes_search returns each full address");
376
382
  for (const row of searched.files)
377
383
  assertReceiptIdentity(row, row.address, notes.find((note) => note.address === row.address).scope, ctx);
@@ -389,19 +395,18 @@ test("list and search merge scopes and carry addresses; the path jail rejects es
389
395
  for (const row of listed.files) {
390
396
  assert.deepEqual(Object.keys(row).sort(), ["address", "updated_at", ...(row.address.startsWith("@project/") ? ["project_key"] : [])].sort());
391
397
  }
392
- const scoped = resultData(await call(captured, "notes_list", { pattern: "@human/**" }, ctx));
393
- assert.deepEqual(scoped.files.map((file) => file.address), ["@human/three.md"], "an address-pattern filter narrows the set");
398
+ const scoped = resultData(await call(captured, "notes_list", { glob: "@human/**" }, ctx));
399
+ assert.deepEqual(scoped.files.map((file) => file.address), ["@human/three.md"], "an address glob filter narrows the set");
394
400
  const searched = resultData(await call(captured, "notes_search", { query: "needle" }, ctx));
395
401
  assert.equal(searched.files.length, 3, "literal search finds matches in every scope");
396
402
  assert.deepEqual([...searched.files].map((file) => file.address).sort(), ["@human/three.md", "@project/two.md", "one.md"]);
397
403
  for (const row of [...listed.files, ...searched.files])
398
404
  assert.equal("scope" in row, false, "scope is derivable from the address and never echoed");
399
- assert.equal(searched.files.every((file) => file.matches_total === 1), true);
405
+ assert.equal(searched.files.every((file) => file.matches.length === 1), true);
400
406
  const hit = searched.files[0].matches[0];
401
407
  assert.equal(hit.line, 1);
402
408
  assert.equal(hit.offset_chars, 0, "the offset counts into the note body, so it does not include serialized frontmatter");
403
- assert.equal(hit.truncated, false);
404
- assert.deepEqual(Object.keys(hit).sort(), ["line", "offset_chars", "text", "truncated"]);
409
+ assert.deepEqual(Object.keys(hit).sort(), ["line", "offset_chars", "text"]);
405
410
  assert.equal(resultRead(await call(captured, "notes_read", { address: searched.files[0].address, offset_chars: hit.offset_chars }, ctx)).content.startsWith("needle"), true, "the search offset starts a read at the match");
406
411
  const escaped = ["../evil", "/abs", "a\\b"];
407
412
  for (const tool of ["notes_write", "notes_update", "notes_read"]) {
@@ -411,8 +416,8 @@ test("list and search merge scopes and carry addresses; the path jail rejects es
411
416
  }
412
417
  assert.equal(resultError(await call(captured, "notes_search", { query: "" }, ctx)).code, "invalid_query");
413
418
  assert.equal(resultError(await call(captured, "notes_read", { address: "one.md", offset_chars: 99999 }, ctx)).code, "invalid_offset");
414
- assert.equal(resultError(await call(captured, "notes_list", { pattern: "bad\\glob" }, ctx)).code, "invalid_pattern");
415
- assert.equal(resultError(await call(captured, "notes_search", { query: "needle", pattern: "bad\\glob" }, ctx)).code, "invalid_pattern");
419
+ assert.equal(resultError(await call(captured, "notes_list", { glob: "bad\\glob" }, ctx)).code, "invalid_pattern");
420
+ assert.equal(resultError(await call(captured, "notes_search", { query: "needle", glob: "bad\\glob" }, ctx)).code, "invalid_pattern");
416
421
  });
417
422
  test("a read offsets the body in code points, not bytes or frontmatter", async () => {
418
423
  freshRoot();
@@ -420,22 +425,19 @@ test("a read offsets the body in code points, not bytes or frontmatter", async (
420
425
  const captured = makeExtension(session);
421
426
  const ctx = context(session);
422
427
  await call(captured, "notes_write", { address: "emoji.md", content: "🐑字\nneedle tail" }, ctx);
423
- const search = resultData(await call(captured, "notes_search", { query: "needle", pattern: "emoji.md" }, ctx));
428
+ const search = resultData(await call(captured, "notes_search", { query: "needle", glob: "emoji.md" }, ctx));
424
429
  const match = search.files[0].matches[0];
425
430
  assert.equal(match.line, 2);
426
431
  assert.equal(match.offset_chars, 3, "the emoji and CJK line above contribute two code points plus the newline, not their bytes");
427
432
  const atMatch = resultRead(await call(captured, "notes_read", { address: "emoji.md", offset_chars: match.offset_chars }, ctx));
428
- assert.equal(atMatch.offset_chars, match.offset_chars);
429
433
  assert.equal(atMatch.text.startsWith("needle"), true, "the offset lands on the match even with multi-byte characters above it");
430
434
  assert.equal(atMatch.total_chars, Array.from("🐑字\nneedle tail").length);
431
435
  const negative = resultRead(await call(captured, "notes_read", { address: "emoji.md", offset_chars: -4 }, ctx));
432
436
  assert.equal(negative.text, "tail", "a negative offset counts back from the end of the body");
433
437
  assert.equal(negative.next_offset_chars, null, "a tail read has no continuation");
434
- assert.equal(negative.limited_by, null);
435
- const start = resultRead(await call(captured, "notes_read", { address: "emoji.md", limit_chars: 3 }, ctx));
438
+ const start = resultRead(await call(captured, "notes_read", { address: "emoji.md", max_chars: 3 }, ctx));
436
439
  assert.equal(start.text, "🐑字\n");
437
440
  assert.equal(start.next_offset_chars, 3);
438
- assert.equal(start.limited_by, "limit", "the requested count is what stopped this window");
439
441
  assert.equal(resultRead(await call(captured, "notes_read", { address: "emoji.md", offset_chars: 14 }, ctx)).text, "", "the exact end is an empty window, not a refusal");
440
442
  });
441
443
  test("a read keeps its body window verbatim under the new presentation", async () => {
@@ -444,11 +446,11 @@ test("a read keeps its body window verbatim under the new presentation", async (
444
446
  const captured = makeExtension(session);
445
447
  const ctx = context(session);
446
448
  await call(captured, "notes_write", { address: "present.md", content: "0123456789" }, ctx);
447
- const limited = await call(captured, "notes_read", { address: "present.md", limit_chars: 4 }, ctx);
449
+ const limited = await call(captured, "notes_read", { address: "present.md", max_chars: 4 }, ctx);
448
450
  const text = limited.content[0].type === "text" ? limited.content[0].text : "";
449
451
  assert.equal(text.includes("READ WINDOW"), false, "the old READ WINDOW block is gone");
450
452
  assert.equal(text.includes("chars: ["), false, "no parsed range block stands between the header and the body");
451
- assert.equal(text.endsWith("\n\n[6 more characters. Use offset_chars=4 to continue.]"), true, "a limit-stopped window names the resume cursor");
453
+ assert.equal(text.endsWith("\n\n[truncated; continue at offset_chars=4]"), true, "a limit-stopped window names the resume cursor");
452
454
  const header = text.slice(0, text.indexOf("\n\n"));
453
455
  assert.match(header, /^present\.md\norigin self \| created \d{4}-/, "identity and metadata lead, body first in the window itself");
454
456
  const whole = await call(captured, "notes_read", { address: "present.md" }, ctx);
@@ -481,8 +483,8 @@ test("Pi adapter defaults to anonymous agent identity", async () => {
481
483
  await call(captured, "notes_write", { address: "@self/private.md", content: "anonymous agent note" }, ctx);
482
484
  const listed = resultData(await call(captured, "notes_list", {}, ctx));
483
485
  assert.deepEqual(listed.files.map((row) => row.address), ["@self/private.md"]);
484
- const explicit = resultData(await call(captured, "notes_list", { pattern: "@agents/*/private.md" }, ctx));
485
- assert.deepEqual(explicit.files.map((row) => row.address), ["@self/private.md"], "explicit-id patterns still match the current home");
486
+ const explicit = resultData(await call(captured, "notes_list", { glob: "@agents/*/private.md" }, ctx));
487
+ assert.deepEqual(explicit.files.map((row) => row.address), ["@self/private.md"], "explicit-id globs still match the current home");
486
488
  assert.equal(existsSync(join(root, "agents", "anonymous", "private.md")), true);
487
489
  });
488
490
  });
@@ -271,8 +271,8 @@ test("reset construction failure preserves incoming and budget drafts without co
271
271
  assert.deepEqual(result.entries, [incoming, budgetDraft], "already-built drafts survive reset construction failure");
272
272
  assert.equal(result.continue, false, "a failed reset does not request continuation");
273
273
  assert.equal(notices.at(-1)?.type, "warning");
274
- assert.match(notices.at(-1)?.message ?? "", /could not build reset/);
275
- assert.match(notices.at(-1)?.message ?? "", /follow-up prompt was not executed/);
274
+ assert.match(notices.at(-1)?.message ?? "", /Couldn't clear memory/);
275
+ assert.match(notices.at(-1)?.message ?? "", /your prompt was not sent/);
276
276
  });
277
277
  test("a stale async reset is discarded after a lifecycle switch without staging a notice", async () => {
278
278
  const sessionManager = Manager.inMemory("/private/tmp/notesoup-stale-reset-test");
@@ -11,7 +11,7 @@ notesoup uses Pi's session branch as the durable source of truth. It does not ma
11
11
  | `boot/snapshot.ts` | Load each of the closed five homes once; isolate filesystem errno failures | Explicit identity, captured time and optional scope loader |
12
12
  | `boot/render.ts`, `boot/text.ts` | Render identity, protocol, maps and recent-note metadata | Explicit snapshot and logical tool-name bindings; no I/O or clock |
13
13
  | `history/history.ts` | Project decoded events and pair tool calls/results, preserving supplied addresses | Decoded items and branch visibility; never inference messages |
14
- | `history/query.ts` | Stable-anchor paging, folding and bounded preview rendering | Query projection only; no native session traversal |
14
+ | `history/query.ts` | Bounded paging, `from` selection, literal matching, folding and preview rendering | Query projection only; no native session traversal |
15
15
  | `budget/constants.ts`, `budget/policy.ts`, `budget/text.ts` | Pure thresholds, unknown/clamped countdown and reminder text | Values supplied by the caller; no settings reads or scheduling |
16
16
  | `tools/notes.ts`, `tools/history.ts`, `tools/schema.ts`, `tools/result.ts`, `tools/output.ts` | Schema-derived outcomes, note/history operations, bounded result selection and pure text rendering | Explicit identity/projection; one bounded result feeds both text and structured output |
17
17
  | `settings.ts`, `dream/settings.ts` | Settings keys, per-key merge and dreamer validation | Parsed values only; no SDK or I/O |
@@ -44,7 +44,7 @@ Manual `/clear-memory` arms a close-out and always sends the hidden checkpoint p
44
44
 
45
45
  Boot is a fixed snapshot for its window, stored as an extension custom message and converted by Pi to a user-role model message. History internally distinguishes native system summaries and extension-authored custom messages; its public `context` event groups both without implying provider instruction priority. A system-role projection is technically possible through `context_with_system`, but would change the authority of the mixed protocol/MAP content and provider-specific prompt/cache behavior; it is not a prerequisite for persistence. Boot injection is silent, including startup, reload, and boot repair. Only an actual context reset produces `notesoup: memory cleared · <windowId>` through `ctx.ui.notify`, after the verified checkpoint, marker, boot, and continuation are present in the session. Committed resets are checked at the next turn start or final settlement. `pi/reset/committed.ts` confirms an ordered hidden boot/continuation after a checkpoint-backed marker even when later conversation exists. That is distinct from `inspectResetTail`, which refuses suffix repair after real work or malformed ordering. Uncommitted reset drafts never announce success. Boot and continuation messages retain `display: false`.
46
46
 
47
- The Pi history adapter decodes the selected raw session branch on demand without a cache. It allocates stable seq values from the session's append-order entry list, then selects current-branch-only visibility, so navigation cannot expose a sibling's history. Shared history pairs and queries those decoded events; it neither traverses SessionReader nor reconstructs inference messages. The public stream combines each tool call with its result at the call seq; paired result slots are not public event addresses, and unpaired results retain their own seq. Summaries and injected messages project as `context`. List and search page chronologically with seq anchors. Tool executions retain structured call/result facts and any native nested-call metadata. A deterministic event document supplies both search positions and read windows. Nested calls have no independent seq and never imply that unrecorded child outputs are available.
47
+ The Pi history adapter decodes the selected raw session branch on demand without a cache. It allocates stable seq values from the session's append-order entry list, then selects current-branch-only visibility, so navigation cannot expose a sibling's history. Shared history pairs and queries those decoded events; it neither traverses SessionReader nor reconstructs inference messages. The public stream combines each tool call with its result at the call seq; paired result slots are not public event addresses, and unpaired results retain their own seq. Summaries and injected messages project as `context`. List pages chronologically with seq anchors and an explicit `from`. Tool executions retain structured call/result facts and any native nested-call metadata. A deterministic event document supplies both query-match positions and read windows. Nested calls have no independent seq and never imply that unrecorded child outputs are available.
48
48
 
49
49
  The boot notes index in `boot/snapshot.ts` is a closed snapshot: the current session, project, human, agent, and model homes are each loaded at most once while constructing a boot. `boot/snapshot.ts` takes explicit `NotesIdentity`, captured `openedAt` and an optional home loader; `boot/render.ts` renders that snapshot and explicit tool bindings without reading the filesystem or consulting the clock. Pi supplies its unchanged tool names. MAP bodies and pocket metadata are derived from the same snapshot, so a boot cannot mix two filesystem reads. Note storage and home traversal use `node:fs/promises`; same-file operations queue by absolute physical filename across store instances in this process, without promising symlink/case-alias or cross-process locking. Known persisted metadata is camelCase. Old snake_case keys are unrecognized extras, not interpreted or migrated; startup does not migrate notes. A missing home (`ENOENT`) is normal. A real read failure omits only that home's index, preserves healthy homes, adds a model-facing `notes_list` recovery notice, and notifies the human once for that window. Boot/reset construction captures session, agent, and model identity before awaiting the snapshot, then checks lifecycle generation, active window, enabled state, and abort status before sending or returning artifacts; stale completions cannot commit into a switched or shut-down session. Boot acquisition uses listing and never updates access metadata. Explicit note reads update `lastAccessed` and `accessCount`; no fallback state is created.
50
50
 
@@ -56,7 +56,7 @@ The `/clear-memory` command only waits for idle when the session is busy with no
56
56
 
57
57
  ## Evidence and limits
58
58
 
59
- The retained integration tests use real SessionManager and SettingsManager instances. They check reset-window history retention, seq-addressed and anchor-paged history, bounded history/notes reads with resumable character windows, notes-home isolation, and settings precedence. The suite is representative rather than exhaustive. Focused host-neutral tests additionally run boot/tool/history/budget logic with explicit inputs and no SDK context; resolved-AST guards enforce the dependency boundary.
59
+ The retained integration tests use real SessionManager and SettingsManager instances. They check reset-window history retention, seq-addressed and cursor-paged history, bounded history/notes reads with resumable character windows, notes-home isolation, and settings precedence. The suite is representative rather than exhaustive. Focused host-neutral tests additionally run boot/tool/history/budget logic with explicit inputs and no SDK context; resolved-AST guards enforce the dependency boundary.
60
60
 
61
61
  Scripted SDK tests execute the real Pi agent loop with no model/network request. They inspect provider contexts and durable entries for idle and streaming manual requests, budget close-out, explicit and normal-stop commits, abort/error cleanup, same-window command deduplication, queued steering/follow-up delivery, retain-none checkpoints across two resets and disk reopen, bounded overflow recovery, and settings authority. Smaller dream tests retain lock exclusion/ownership, jailed writes, CLI audit/report failure propagation, and read-only doctor behavior. Removing duplicate scenarios and edge-case matrices reduces coverage; the remaining tests do not establish every malformed-input case, branch interleaving, external-provider behavior, or filesystem failure mode.
62
62
 
@@ -22,7 +22,7 @@ await notes.update("@project/decisions.md", [
22
22
  { oldText: "shared", newText: "host-independent" },
23
23
  ]);
24
24
  const note = await notes.read("@project/decisions.md"); // body and metadata, or undefined
25
- const files = await notes.list({ pattern: "@project/**" });
25
+ const files = await notes.list({ glob: "@project/**" });
26
26
  const matches = await notes.search(["library"]);
27
27
  ```
28
28
 
@@ -34,16 +34,16 @@ const matches = await notes.search(["library"]);
34
34
 
35
35
  - `write(address, content, { origin? }?)` returns `Promise<{ meta, outcome }>` (`created`, `overwritten` or `uncrumpled`). Default origin is `self`; overwriting preserves creation time, existing project ownership, and unknown metadata, and always produces an uncrumpled note (it clears any `crumpledAt`).
36
36
  - `read(address)` returns `Promise<{ meta, body, resolvedScope } | undefined>`. **Reads update** `lastAccessed` and `accessCount` on disk. The body is separate from metadata; the serialized frontmatter is not part of the read API.
37
- - `update(address, edits?, { origin?, crumpled?, replaceAll? }?)` returns `Promise<{ meta, applied, resolvedScope, change }>`. Edits affect the body; metadata-only changes need no edits, but must supply `origin` or `crumpled`. `crumpled: true` records `crumpledAt` (keeping the original time if already set); `crumpled: false` removes it; omitted leaves it unchanged. Crumpling and smoothing never change `updatedAt`, which tracks body or origin changes only. Each replacement uses the evolving body in array order; the complete batch is written atomically only after every edit succeeds. `change` is a typed `{ kind, before, after }`: `kind` is `body`, `metadata`, or `file` to identify the diff inputs, or `none` with empty strings when neither body, origin, nor `crumpledAt` changed. It is not a rendered diff.
37
+ - `update(address, edits?, { origin?, crumpled?, replaceAll? }?)` returns `Promise<{ meta, applied, resolvedScope, change }>`. Edits affect the body; metadata-only changes need no edits, but must supply `origin` or `crumpled`. `crumpled: true` records `crumpledAt` (keeping the original time if already set); `crumpled: false` removes it; omitted leaves it unchanged. Crumpling and smoothing never change `updatedAt`, which tracks body or origin changes only. Each replacement uses the evolving body in array order; the complete batch is written atomically only after every edit succeeds. `change` is a typed `{ kind, before, after }`: `kind` is `body`, `metadata`, or `none` with empty strings when neither body, origin, nor `crumpledAt` changed. A body change that also rewrites frontmatter is still `body`, and its diff inputs then span the whole serialized file. It is not a rendered diff.
38
38
  - `rename(fromAddress, toAddress)` returns `Promise<{ meta, replacedCrumpledTarget }>`. The note moves with every metadata key preserved (`updatedAt` is bumped); a live note at the target refuses with `already_exists`, a crumpled target is replaced, and renaming onto the same resolved path is `nothing_to_do`.
39
- - `list({ pattern?, scope?, who?, wastebasket? }?)` returns `Promise<NoteRow[]>`, sorted by update time descending with address tie-breaking. Rows contain address, scope, virtual path, metadata, body, and body byte size. `scope` narrows the five-home view; `who` names a concrete agent/model home. By default crumpled notes are excluded; `wastebasket: true` returns only crumpled notes instead.
40
- - `search(queries: string[], { pattern?, scope?, who?, wastebasket? }?)` returns `Promise<NoteSearchRow[]>`, sorted by address, with the same crumpled-note rule as `list`. Matching is case-insensitive literal OR over body lines; matches contain one-based `line`, `text`, and `offsetChars` into the body, excluding frontmatter. Neither listing nor search increments access metadata.
39
+ - `list({ glob?, scope?, who?, crumpled? }?)` returns `Promise<NoteRow[]>`, sorted by update time descending with address tie-breaking. Rows contain address, scope, virtual path, metadata, body, and body byte size. `scope` narrows the five-home view; `who` names a concrete agent/model home. By default crumpled notes are excluded; `crumpled: true` returns only crumpled notes instead.
40
+ - `search(queries: string[], { glob?, scope?, who?, crumpled? }?)` returns `Promise<NoteSearchRow[]>`, sorted by address, with the same crumpled-note rule as `list`. Matching is case-insensitive literal OR over body lines; matches contain one-based `line`, `text`, and `offsetChars` into the body, excluding frontmatter. Neither listing nor search increments access metadata.
41
41
 
42
- `list` and `search` share the `NotesQuery` type. A merged query uses `{ pattern?, wastebasket? }`; a single-home query adds `scope`. Only `scope: "agent" | "model"` accepts `who`. TypeScript rejects combinations such as `{ scope: "project", who: "root" }`, and JavaScript callers receive a runtime refusal.
42
+ `list` and `search` share the `NotesQuery` type. A merged query uses `{ glob?, crumpled? }`; a single-home query adds `scope`. Only `scope: "agent" | "model"` accepts `who`. TypeScript rejects combinations such as `{ scope: "project", who: "root" }`, and JavaScript callers receive a runtime refusal.
43
43
 
44
44
  The library returns full data, not tool envelopes or paginated/truncated output. `NoteError` exposes the existing named store refusals through `code`, with `lineNumbers` for ambiguous edits and `editIndex` for a failed edit. Runtime API fields and known persisted note metadata use camelCase; Pi tool wire fields such as `updated_at`, `offset_chars`, and `replace_all` retain their established names. Unrecognized frontmatter keys, including old snake_case metadata, are preserved as ordinary extras; they are not interpreted as current camelCase fields or migrated automatically. Invalid addresses/identities and filesystem failures reject; only a missing `read` returns `undefined`. Notes remain markdown files with the existing size limits and same-directory atomic rename. Same-file read/modify/write work is serialized by absolute physical filename across all store instances in this process (including `.md` address aliases); symlink/case aliases and cross-process locking are not guaranteed. `list` and `search` asynchronously traverse homes and serialize each discovered file read against pending mutations, but are not global snapshots and may not discover a file created after traversal. Foreign named homes can be read (including the access-metadata update), but their bodies cannot be written or edited through the store. These are cooperative address rules, not an OS security sandbox.
45
45
 
46
- Addresses are a path with no `@` (a session note), `@project/`, `@human/`, `@self/`, `@model/`, or explicit `@agents/<slug>/` and `@models/<slug>/`. Relative self/model addresses resolve to the supplied identity. Results show the current agent's and model's notes as `@self/` and `@model/`; only other agents' or models' notes carry an explicit `@agents/<slug>/` or `@models/<slug>/`. Patterns accept either form. The disk layout remains `pi/session/<sessionId>/`, `project/<projectKey>/`, `human/`, `agents/<agent>/`, and `models/<model>/`. No data migration happens on library import or construction. Notes already using camelCase metadata retain their metadata; old snake_case keys are preserved as unrecognized extras, not interpreted or migrated. New session notes record the supplied project key.
46
+ Addresses are a path with no `@` (a session note), `@project/`, `@human/`, `@self/`, `@model/`, or explicit `@agents/<slug>/` and `@models/<slug>/`. Relative self/model addresses resolve to the supplied identity. Results show the current agent's and model's notes as `@self/` and `@model/`; only other agents' or models' notes carry an explicit `@agents/<slug>/` or `@models/<slug>/`. Globs accept either form. The disk layout remains `pi/session/<sessionId>/`, `project/<projectKey>/`, `human/`, `agents/<agent>/`, and `models/<model>/`. No data migration happens on library import or construction. Notes already using camelCase metadata retain their metadata; old snake_case keys are preserved as unrecognized extras, not interpreted or migrated. New session notes record the supplied project key.
47
47
 
48
48
  ## Library and plugin boundary
49
49
 
@@ -1,24 +1,24 @@
1
1
  # Notes and history tool results
2
2
 
3
- The nine notes/history tools have one business result model. Pi exposes compact results as `structuredContent` to codemode and renders them as `content` for ordinary model calls. Claude uses the same business handlers and text rendering. Neither host re-runs a query, truncates a different page, or parses formatted text to recover data.
3
+ The eight notes/history tools have one business result model. Pi exposes compact results as `structuredContent` to codemode and renders them as `content` for ordinary model calls. Claude uses the same business handlers and text rendering. Neither host re-runs a query, truncates a different page, or parses formatted text to recover data.
4
4
 
5
5
  This is a breaking tool protocol change: successes no longer have `ok/data` wrappers, errors are flat, and read fields no longer sit under `window`. History execution details live once in the pageable document. Stored notes and raw Pi session entries are not deleted or rewritten by this change. `clear_memory` and `get_context_remaining` are outside this protocol.
6
6
 
7
7
  ## Results
8
8
 
9
9
  ```ts
10
- type Result<T> = T | { error: string; code: string; details?: Record<string, unknown> };
10
+ type Result<T> = T | { error: string; code: string };
11
11
  ```
12
12
 
13
- Each operation declares its concrete success schema; `error` is reserved for a refusal message. Success and expected failure both have a structured result; Pi's `isError` follows the outcome. Host-level argument validation, blocked execution and transport errors remain host failures. Shared handlers and the private Claude helper transport retain an internal `Outcome<T>` (`{ ok: true, data }` or `{ ok: false, error: { code, message, details? } }`); this envelope is not the Pi wire result. The Claude hook returns rendered text as a string result and sets `isError: true` only on a refusal.
13
+ Each operation declares its concrete success schema; `error` is reserved for a refusal message. Success and expected failure both have a structured result; Pi's `isError` follows the outcome. Host-level argument validation, blocked execution and transport errors remain host failures. Shared handlers and the private Claude helper transport retain an internal `Outcome<T>` (`{ ok: true, data }` or `{ ok: false, error: { code, message } }`); this envelope is not the Pi wire result. The Claude hook returns rendered text as a string result and sets `isError: true` only on a refusal.
14
14
 
15
15
  ```js
16
- const result = await tools.notes_list({ pattern: "@project/**" });
16
+ const result = await tools.notes_list({ glob: "@project/**" });
17
17
  if ("error" in result) return result.error;
18
18
  return result.files;
19
19
  ```
20
20
 
21
- The text representation uses short mutation receipts, lists, search hits or raw text windows. It reports omissions and errors rather than hiding them. `details` contains error context, not a second copy of the payload.
21
+ The text representation uses short mutation receipts, lists, search hits or raw text windows. It reports omissions and errors rather than hiding them. A refusal renders as one line, `error: <code>: <message>`, and the message carries every fact a caller needs to recover: the known window ids for `unknown_window_id`, the edit index and match lines for a note edit refusal.
22
22
 
23
23
  ## Read windows
24
24
 
@@ -27,30 +27,22 @@ Both read operations return these fields at the result root, alongside identity
27
27
  ```ts
28
28
  {
29
29
  text: string;
30
- offset_chars: number;
31
30
  total_chars: number;
32
31
  next_offset_chars: number | null;
33
- limited_by: "limit" | "bytes" | null;
34
32
  }
35
33
  ```
36
34
 
37
- Positions count Unicode code points, not UTF-16 units or UTF-8 bytes. The echoed offset is absolute even when a negative input selects a tail. The returned text is a contiguous unmodified prefix of the requested range, without ellipsis markers. `next_offset_chars` names the first undelivered character, or is null at the true end.
35
+ Positions count Unicode code points, not UTF-16 units or UTF-8 bytes. The returned text is a contiguous unmodified prefix of the requested range, without ellipsis markers. `next_offset_chars` names the first undelivered character, or is null at the true end. A negative input offset selects a tail; the delivered window does not echo the offset it resolved.
38
36
 
39
37
  - `notes_read`: `address`, optional `project_key`, and `metadata` accompany the text fields. Positions address only the note **body**. Access counts and last-access times remain stored but are omitted from results.
40
- - `history_read`: `seq`, `window_id`, `role`, `created_at`, and a tool summary accompany the text fields. Positions address one deterministic document derived from the event's facts. Search matches address that same document, not its decorated presentation.
38
+ - `history_read`: `seq`, `window_id`, `role`, `created_at`, and a tool summary accompany the text fields. Positions address one deterministic document derived from the event's facts. Query matches address that same document, not its decorated presentation.
41
39
 
42
40
  Repeated note reads observe the current file; this is not a retained snapshot service. A concurrent body edit can change positions. History reflects the active branch and recorded facts, including a result that may arrive after a pending call was first observed.
43
41
 
44
- Text rendering puts identity and relevant metadata above the payload. Only an incomplete read receives a native-Pi-style suffix:
42
+ Text rendering puts identity and relevant metadata above the payload. Only an incomplete read receives a continuation suffix, which says where to continue and nothing about why the window stopped:
45
43
 
46
44
  ```text
47
- [12000 more characters. Use offset_chars=12000 to continue.]
48
- ```
49
-
50
- If the output byte budget, rather than the requested character count, stops the window:
51
-
52
- ```text
53
- [Showing chars [0, 11000) of 24000 (32KB limit). Use offset_chars=11000 to continue.]
45
+ [truncated; continue at offset_chars=12000]
54
46
  ```
55
47
 
56
48
  The suffix and presentation header are never part of `text`, search offsets or total character counts. At the end there is no completion footer.
@@ -59,29 +51,27 @@ The suffix and presentation header are never part of `text`, search offsets or t
59
51
 
60
52
  The native adapter allocates seqs from session append order, selects the active branch and decodes facts. Shared history pairs calls and results without allocating a second transcript. A paired execution is addressed by its call seq. Its result's raw slot is not a public event address; list/search provide the canonical seq. Unpaired results remain independently addressable. Inactive-branch addresses are not readable.
61
53
 
62
- Tool events expose `tool`, `tool_status`, and, when recorded, `output_truncated`, `full_output_path`, and `nested_calls`. Full arguments and nested-call records live only in the searchable/readable document, avoiding a second structured copy on every read.
54
+ Tool events expose `tool`, `tool_status`, and, when recorded, `output_truncated` and `full_output_path`; a truncated run is named even when the host recorded no path, and the full text path is named only when it exists. `history_read` also reports `nested_calls`; a page row does not. Full arguments and nested-call records live only in the searchable/readable document, avoiding a second structured copy on every read.
63
55
 
64
56
  Pi's nested records contain child ID, name, optional arguments, status, timing and error, plus completeness. They contain **no child result bodies**. Absent records do not establish that no nested work occurred. Host-omitted arguments and unfinished calls remain visible as incomplete evidence. Child records belong to their parent event and do not consume seqs.
65
57
 
66
- List, search and read report `nested_calls.call_count` and `nested_calls.complete` exactly as recorded: the count is every record the host stored, even if the current text slice contains none of them. Continue with `next_offset_chars` to recover the entire recorded document. Both a call's result and an unpaired result carry their recorded evidence; neither invents the call the other one is missing. Search results contain event rows only; folded rows exist only in list results.
58
+ `history_read` reports `nested_calls.call_count` and `nested_calls.complete` exactly as recorded: the count is every record the host stored, even if the current text slice contains none of them. Continue with `next_offset_chars` to recover the entire recorded document. Both a call's result and an unpaired result carry their recorded evidence; neither invents the call the other one is missing. Query results contain event rows only; folded rows exist only in the browse view.
67
59
 
68
60
  ## Bounds and continuation
69
61
 
70
62
  One selection determines the structured result and its text. Both complete representations must fit the 32 KiB output budget, including metadata, cursor and rendered notice. A programmatic caller does not receive an unbounded hidden payload beside a truncated textual one.
71
63
 
72
- History pages use `older_before` and `newer_after` anchors. Notes listings/search are snapshots with a `more` count and can be narrowed by `pattern`; they are not falsely advertised as paginated. `history_windows` is a snapshot too: its `more` counts the windows the budget left out and there is no window cursor, because `history_list` rows also expose `window_id`. A read can stop anywhere in the event document, including inside serialized arguments; concatenate its verbatim text slices before parsing any arguments. There is no separately truncated arguments object.
73
-
74
- A note read reports unrecognized frontmatter under `metadata.extra`, and any entry too large to show is counted in `metadata.omitted_extra` instead of being listed. The omitted values stay in the note file. A rename receipt uses `address` for the destination and `rename_from` for the source; it has no duplicate `rename_to` field.
64
+ History pages carry `page_older` and `page_newer`, the exact params to merge into the next call; `from` picks which end of a bounded range `limit` counts from, `since`/`until` narrow that range by event `created_at`, and only a call without roles or query folds tool/context runs. Notes listings/search are snapshots with a `more` count and can be narrowed by `glob`; they are not falsely advertised as paginated. `history_windows` is a snapshot too: its `more` counts the windows the budget left out and there is no window cursor, because `history_list` rows also expose `window_id`. A read can stop anywhere in the event document, including inside serialized arguments; concatenate its verbatim text slices before parsing any arguments. There is no separately truncated arguments object.
75
65
 
76
- Error `details` is sanitized context with its own bound: a stable refusal code is an internal identifier and is never clipped, a runaway message is clipped with its lost length, and details that would exceed their budget are replaced by `{ truncated: true, details_bytes }` rather than partly serialized. Context that cannot be serialized at all is a defect in the operation, and surfaces as one rather than as a bounded refusal. A refusal never enumerates the keys it could not report.
66
+ A note read reports unrecognized frontmatter under `metadata.extra`; a value too large to carry, or past the verbatim budget, is named in place as `[omitted: too large]` under its key rather than delivered in part, and the value itself stays in the note file. A rename receipt uses `address` for the destination and `rename_from` for the source; it has no duplicate `rename_to` field.
77
67
 
78
- `output_too_large` is not one failure, and a refusal does not mean nothing happened. Each operation's own message says what it means: a `notes_update` whose receipt cannot fit reports that the update was already applied, so read the note before retrying, and a read that cannot deliver a single advancing character is refused rather than answered with an empty window. Narrowing helps only where a parameter genuinely reduces the selection — `pattern`, `roles`, `window_id`, `limit`, `max_chars_per_item`, or a `before`/`after` range — and cannot help a read whose own metadata is what overflows. History pages refuse with `page_too_large` for the same reason. Nothing is ever quietly delivered short: every other omission is reported on the successful result that carries it.
68
+ `output_too_large` is not one failure, and a refusal does not mean nothing happened. Each operation's own message says what it means: a `notes_update` whose receipt cannot fit reports that the update was already applied, so read the note before retrying, and a read that cannot deliver a single advancing character is refused rather than answered with an empty window. A receipt whose diff or search-match line cannot fit is cut to the longest prefix that does, and its own text ends with the marker: `[diff truncated; update applied]` for a diff, ` [truncated]` for a match line. Narrowing helps only where a parameter genuinely reduces the selection — `glob` or `query`, `roles`, `window_id`, `limit`, `max_chars_per_item`, a `before_seq`/`after_seq` range, or a `since`/`until` time window — and cannot help a read whose own metadata is what overflows. History pages refuse with `page_too_large` for the same reason. Nothing is ever quietly delivered short: every other omission is reported on the successful result that carries it.
79
69
 
80
70
  ## Ownership
81
71
 
82
72
  - The notes store owns addressing, file contents, metadata and mutations.
83
73
  - The history adapter owns native decoding, seq allocation and branch visibility.
84
- - Shared operations own the typed result, filtering, paging, character windows and error data.
74
+ - Shared operations own the typed result, filtering, paging, character windows and refusal messages.
85
75
  - Shared renderers derive text from that result.
86
76
  - Pi/Claude adapters supply host identity, projections and transport packaging only.
87
77
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "notesoup",
3
- "version": "0.37.1",
3
+ "version": "0.41.0",
4
4
  "description": "Durable notes and a host-scoped notes boot section for Claude Code.",
5
5
  "author": {
6
6
  "name": "AstroSheep"