notesoup 0.56.0 → 0.57.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/README.md +1 -1
- package/dist/plugins/pi/marker.d.ts +4 -2
- package/dist/plugins/pi/marker.js +18 -8
- package/dist/plugins/pi/reset/lifecycle.js +6 -0
- package/dist/plugins/pi/runtime.js +8 -8
- package/dist/plugins/pi/text.js +1 -1
- package/dist/src/history/claude.d.ts +2 -0
- package/dist/src/history/claude.js +13 -2
- package/dist/src/history/codex-transcript.d.ts +15 -3
- package/dist/src/history/codex-transcript.js +57 -21
- package/dist/src/history/codex.d.ts +4 -2
- package/dist/src/history/codex.js +3 -3
- package/dist/src/history/corpus.d.ts +8 -1
- package/dist/src/history/corpus.js +17 -1
- package/dist/src/history/history.d.ts +16 -10
- package/dist/src/history/history.js +9 -9
- package/dist/src/history/local.d.ts +2 -0
- package/dist/src/history/local.js +35 -38
- package/dist/src/history/prefilter.d.ts +5 -0
- package/dist/src/history/prefilter.js +95 -0
- package/dist/src/history/query.d.ts +29 -27
- package/dist/src/history/query.js +82 -34
- package/dist/src/history/summary-cache.d.ts +10 -0
- package/dist/src/history/summary-cache.js +129 -0
- package/dist/src/tools/history.js +31 -20
- package/dist/test/agent-loop.test.js +62 -27
- package/dist/test/codex-history.test.js +90 -4
- package/dist/test/codex-plugin.test.js +6 -2
- package/dist/test/history-corpus.test.js +221 -33
- package/dist/test/history-prefilter.test.d.ts +1 -0
- package/dist/test/history-prefilter.test.js +174 -0
- package/dist/test/history-summary-cache.test.d.ts +1 -0
- package/dist/test/history-summary-cache.test.js +297 -0
- package/dist/test/history.integration.test.js +87 -52
- package/dist/test/marker.test.js +46 -15
- package/dist/test/model-facing-text.test.js +1 -1
- package/dist/test/reset-lifecycle.test.js +4 -6
- package/docs/architecture.md +1 -1
- package/docs/history-sessions.md +26 -2
- package/docs/reset-lifecycle.md +4 -4
- package/docs/tool-results.md +4 -2
- package/package.json +1 -1
- package/plugins/claude/.claude-plugin/plugin.json +1 -1
- package/plugins/claude/dist/claude/helper.js +425 -122
- package/plugins/codex/dist/codex/notesoup.js +423 -123
- package/plugins/pi/marker.ts +18 -12
- package/plugins/pi/reset/lifecycle.ts +5 -0
- package/plugins/pi/runtime.ts +8 -8
- package/plugins/pi/text.ts +1 -1
- package/src/history/claude.ts +16 -2
- package/src/history/codex-transcript.ts +52 -17
- package/src/history/codex.ts +5 -5
- package/src/history/corpus.ts +19 -2
- package/src/history/history.ts +11 -11
- package/src/history/local.ts +34 -38
- package/src/history/prefilter.ts +86 -0
- package/src/history/query.ts +77 -33
- package/src/history/summary-cache.ts +119 -0
- package/src/tools/history.ts +33 -20
package/dist/test/marker.test.js
CHANGED
|
@@ -3,8 +3,8 @@ import test from "node:test";
|
|
|
3
3
|
import { SessionManager } from "@earendil-works/pi-coding-agent";
|
|
4
4
|
import { BOOT_TYPE, CONTINUATION_TYPE, MARKER_TYPE, RESET_MARKER_TYPE } from "../plugins/pi/entries.js";
|
|
5
5
|
import { nextHistorySeq } from "../plugins/pi/history.js";
|
|
6
|
-
import { MARKER_INTERVAL } from "../plugins/pi/marker.js";
|
|
7
|
-
import { appendText, context, installExtensionTestEnvironment, makeExtension, runCommand, runHandlers, sentOf } from "./helpers/extension.js";
|
|
6
|
+
import { buildMarkerDraft, MARKER_INTERVAL } from "../plugins/pi/marker.js";
|
|
7
|
+
import { appendText, call, commitTurnEndBoundary, context, installExtensionTestEnvironment, makeExtension, runCommand, runHandlers, sentOf } from "./helpers/extension.js";
|
|
8
8
|
const env = installExtensionTestEnvironment("notesoup-marker-test");
|
|
9
9
|
test.beforeEach(env.beforeEach);
|
|
10
10
|
test.afterEach(env.afterEach);
|
|
@@ -13,7 +13,7 @@ function beforeAgentStart(captured, ctx) {
|
|
|
13
13
|
return runHandlers(captured, "before_agent_start", { type: "before_agent_start" }, ctx);
|
|
14
14
|
}
|
|
15
15
|
test("marker stamps its own seq at run start once the interval is reached, never mid-turn", async () => {
|
|
16
|
-
const sessionManager = managerWithMessages(
|
|
16
|
+
const sessionManager = managerWithMessages(99);
|
|
17
17
|
const captured = makeExtension(sessionManager);
|
|
18
18
|
const ctx = context(sessionManager);
|
|
19
19
|
// Mid-run tool turns never inject a standalone marker message.
|
|
@@ -22,32 +22,61 @@ test("marker stamps its own seq at run start once the interval is reached, never
|
|
|
22
22
|
await beforeAgentStart(captured, ctx);
|
|
23
23
|
const sent = sentOf(captured, MARKER_TYPE);
|
|
24
24
|
assert.equal(sent.length, 1);
|
|
25
|
-
assert.deepEqual(sent[0].message.details, { seq:
|
|
25
|
+
assert.deepEqual(sent[0].message.details, { seq: 100 });
|
|
26
26
|
assert.equal(sent[0].message.display, false);
|
|
27
27
|
assert.equal(sent[0].options?.triggerTurn, false);
|
|
28
|
-
assert.equal(sent[0].message.content, '<notesoup:marker seq="
|
|
29
|
-
assert.equal(nextHistorySeq(ctx),
|
|
28
|
+
assert.equal(sent[0].message.content, '<notesoup:marker seq="100" />');
|
|
29
|
+
assert.equal(nextHistorySeq(ctx), 101, "the marker occupies the seq it names");
|
|
30
30
|
// An immediate second run is only one seq later: no new marker.
|
|
31
31
|
await beforeAgentStart(captured, ctx);
|
|
32
32
|
assert.equal(sentOf(captured, MARKER_TYPE).length, 1);
|
|
33
33
|
// The next marker lands one interval after the last.
|
|
34
34
|
appendText(sessionManager, "user", "x");
|
|
35
|
-
for (let i = 0; i <
|
|
35
|
+
for (let i = 0; i < 98; i++)
|
|
36
36
|
appendText(sessionManager, "assistant", "y");
|
|
37
37
|
await beforeAgentStart(captured, ctx);
|
|
38
38
|
const all = sentOf(captured, MARKER_TYPE);
|
|
39
39
|
assert.equal(all.length, 2);
|
|
40
|
-
assert.deepEqual(all[1].message.details, { seq:
|
|
40
|
+
assert.deepEqual(all[1].message.details, { seq: 200 });
|
|
41
|
+
});
|
|
42
|
+
test("turn-end appends a due marker without requesting continuation or duplicating it at run start", async () => {
|
|
43
|
+
const sessionManager = managerWithMessages(99);
|
|
44
|
+
const captured = makeExtension(sessionManager);
|
|
45
|
+
const ctx = context(sessionManager);
|
|
46
|
+
const boundary = await commitTurnEndBoundary(captured, sessionManager, ctx);
|
|
47
|
+
assert.equal(boundary.continue, false);
|
|
48
|
+
assert.deepEqual(boundary.entries, [{ type: "custom_message", customType: MARKER_TYPE, content: '<notesoup:marker seq="100" />', display: false, details: { seq: 100 } }]);
|
|
49
|
+
assert.equal(nextHistorySeq(ctx), 101);
|
|
50
|
+
await beforeAgentStart(captured, ctx);
|
|
51
|
+
assert.equal(sentOf(captured, MARKER_TYPE).length, 0, "the committed turn-end marker already anchored this interval");
|
|
52
|
+
});
|
|
53
|
+
test("marker seq includes incoming boundary drafts, and a drafted reset or boot suppresses another marker", () => {
|
|
54
|
+
const ctx = context(managerWithMessages(98));
|
|
55
|
+
const incoming = [{ type: "custom_message", customType: "other/context", content: "context", display: false }];
|
|
56
|
+
assert.deepEqual(buildMarkerDraft(ctx, incoming)?.details, { seq: 100 });
|
|
57
|
+
assert.equal(buildMarkerDraft(ctx, [{ type: "custom", customType: RESET_MARKER_TYPE, data: { windowId: "pcw:new" } }]), undefined);
|
|
58
|
+
assert.equal(buildMarkerDraft(ctx, [{ type: "custom_message", customType: BOOT_TYPE, content: "boot", display: false }]), undefined);
|
|
59
|
+
});
|
|
60
|
+
test("a due tool reset uses its boot instead of inserting a marker in the reset boundary", async () => {
|
|
61
|
+
const sessionManager = managerWithMessages(99);
|
|
62
|
+
const captured = makeExtension(sessionManager);
|
|
63
|
+
const ctx = context(sessionManager);
|
|
64
|
+
await call(captured, "empty_brain", {}, ctx);
|
|
65
|
+
const boundary = await commitTurnEndBoundary(captured, sessionManager, ctx);
|
|
66
|
+
assert.ok(boundary.entries.some((entry) => entry.type === "custom_message" && entry.customType === BOOT_TYPE));
|
|
67
|
+
assert.equal(boundary.entries.some((entry) => entry.type === "custom_message" && entry.customType === MARKER_TYPE), false);
|
|
68
|
+
await beforeAgentStart(captured, ctx);
|
|
69
|
+
assert.equal(sentOf(captured, MARKER_TYPE).length, 0);
|
|
41
70
|
});
|
|
42
71
|
test("no marker before the interval", async () => {
|
|
43
|
-
const sessionManager = managerWithMessages(
|
|
72
|
+
const sessionManager = managerWithMessages(98);
|
|
44
73
|
const captured = makeExtension(sessionManager);
|
|
45
74
|
await beforeAgentStart(captured, context(sessionManager));
|
|
46
75
|
assert.equal(sentOf(captured, MARKER_TYPE).length, 0);
|
|
47
|
-
assert.equal(MARKER_INTERVAL,
|
|
76
|
+
assert.equal(MARKER_INTERVAL, 100);
|
|
48
77
|
});
|
|
49
78
|
test("a reset tail awaiting repair blocks markers, and boot anchors the new window's interval", async () => {
|
|
50
|
-
const sessionManager = managerWithMessages(
|
|
79
|
+
const sessionManager = managerWithMessages(99);
|
|
51
80
|
const captured = makeExtension(sessionManager);
|
|
52
81
|
const ctx = context(sessionManager);
|
|
53
82
|
// A marker with neither boot nor continuation still expects repair; stay out of its tail.
|
|
@@ -58,23 +87,25 @@ test("a reset tail awaiting repair blocks markers, and boot anchors the new wind
|
|
|
58
87
|
sessionManager.appendCustomMessageEntry(BOOT_TYPE, "boot", false, { windowId: "pcw:test:w1" });
|
|
59
88
|
await beforeAgentStart(captured, ctx);
|
|
60
89
|
assert.equal(sentOf(captured, MARKER_TYPE).length, 0);
|
|
61
|
-
// Once the reset tail is closed, boot (seq
|
|
90
|
+
// Once the reset tail is closed, boot (seq 100) already anchored the window's start seq.
|
|
62
91
|
sessionManager.appendCustomMessageEntry(CONTINUATION_TYPE, "continued", false);
|
|
63
92
|
await beforeAgentStart(captured, ctx);
|
|
64
93
|
assert.equal(sentOf(captured, MARKER_TYPE).length, 0);
|
|
65
|
-
for (let i = 0; i <
|
|
94
|
+
for (let i = 0; i < 98; i++)
|
|
66
95
|
appendText(sessionManager, "assistant", "y");
|
|
67
96
|
await beforeAgentStart(captured, ctx);
|
|
68
97
|
const sent = sentOf(captured, MARKER_TYPE);
|
|
69
98
|
assert.equal(sent.length, 1);
|
|
70
|
-
assert.deepEqual(sent[0].message.details, { seq:
|
|
99
|
+
assert.deepEqual(sent[0].message.details, { seq: 200 });
|
|
71
100
|
});
|
|
72
101
|
test("notesoup off silences the odometer", async () => {
|
|
73
|
-
const sessionManager = managerWithMessages(
|
|
102
|
+
const sessionManager = managerWithMessages(99);
|
|
74
103
|
const captured = makeExtension(sessionManager);
|
|
75
104
|
const ctx = context(sessionManager);
|
|
76
105
|
await runCommand(captured, "notesoup", "off", ctx);
|
|
77
106
|
await beforeAgentStart(captured, ctx);
|
|
107
|
+
const boundary = await commitTurnEndBoundary(captured, sessionManager, ctx);
|
|
108
|
+
assert.equal(boundary.entries.length, 0);
|
|
78
109
|
assert.equal(sentOf(captured, MARKER_TYPE).length, 0);
|
|
79
110
|
});
|
|
80
111
|
function managerWithMessages(count) {
|
|
@@ -113,7 +113,7 @@ test("the countdown closes the second-tier notice only, in both hosts", () => {
|
|
|
113
113
|
test("only Pi's protocol explains that reset erases the human's view", () => {
|
|
114
114
|
assert.equal(PI_PRE_RESET_HINTS, "Anything you say here is erased with the reset — the human can't read it afterward either. Put the handoff in your notes; explanations belong after the reset.\nUnless the human explicitly directs otherwise, decide for yourself when to call empty_brain. Don't keep asking them whether to reset.");
|
|
115
115
|
assert.equal(COMMAND_NOTICE.bare, "The human ran /empty. Save your notes now and call `empty_brain` immediately. Anything you say here will be erased afterward — put the handoff in your notes. Anything the human sends from now on should be handled after the reset.");
|
|
116
|
-
assert.equal(COMMAND_NOTICE.prompted, "The human ran /empty. Save your notes now and call `empty_brain` immediately. Anything you say here will be erased afterward — put the handoff in your notes. The
|
|
116
|
+
assert.equal(COMMAND_NOTICE.prompted, "The human ran /empty. Save your notes now and call `empty_brain` immediately. Anything you say here will be erased afterward — put the handoff in your notes. The command below is context for your notes, not a task for the fresh window. Anything the human sends separately from now on should be handled after the reset.");
|
|
117
117
|
const pi = renderProtocolBlock({ ...DEFAULT_BOOT_TOOL_NAMES, preResetHints: PI_PRE_RESET_HINTS });
|
|
118
118
|
assert.ok(pi.includes(`\n${PI_PRE_RESET_HINTS}\n${NOTES_PROTOCOL_CLOSE_TAG}`), "both hints end the protocol, before the closing tag");
|
|
119
119
|
assert.equal(pi.split(PI_PRE_RESET_HINTS).length - 1, 1, "the hints appear once");
|
|
@@ -258,25 +258,23 @@ test("manual /empty with a prompt shows the human's command line in the close-ou
|
|
|
258
258
|
const promptLine = "/empty Continue reviewing the implementation";
|
|
259
259
|
const promptIndex = content.indexOf(promptLine);
|
|
260
260
|
assert.ok(promptIndex >= 0, "the human's raw command line reaches the closing model");
|
|
261
|
-
assert.ok(promptIndex > content.indexOf("</notesoup:budget_notice>"), "
|
|
261
|
+
assert.ok(promptIndex > content.indexOf("</notesoup:budget_notice>"), "command context is outside the notice");
|
|
262
262
|
assert.ok(content.includes("Then call `empty_brain`. Nothing in between.\n" + COUNTDOWN_LINE), "the countdown immediately follows the reset call");
|
|
263
263
|
assert.equal(content.split(COUNTDOWN_LINE).length - 1, 1, "the notice carries the countdown once");
|
|
264
|
-
//
|
|
264
|
+
// Command text is close-out context only.
|
|
265
265
|
const settle = resultEntries(await h.emit("agent_before_settle", {
|
|
266
266
|
type: "agent_before_settle",
|
|
267
267
|
entries: [],
|
|
268
268
|
outcome: "completed",
|
|
269
269
|
context: { contextEntries: [], contextMessages: [], llmMessages: [], pendingMessages: [], canContinue: true },
|
|
270
270
|
}));
|
|
271
|
-
assert.equal(settle.continue,
|
|
271
|
+
assert.equal(settle.continue, false, "a prompted close-out stops in the fresh window");
|
|
272
272
|
assert.deepEqual(settle.entries.map((entry) => entry.type === "compaction" ? "native-compaction" : entry.customType), [
|
|
273
273
|
"native-compaction",
|
|
274
274
|
RESET_MARKER_TYPE,
|
|
275
275
|
BOOT_TYPE,
|
|
276
276
|
CONTINUATION_TYPE,
|
|
277
|
-
|
|
278
|
-
], "the reset tail ends with the carried human input");
|
|
279
|
-
assert.deepEqual(settle.entries.at(-1), { type: "custom_message", customType: CARRIED_INPUT_TYPE, content: "Continue reviewing the implementation", display: true });
|
|
277
|
+
], "the reset tail contains no command argument");
|
|
280
278
|
});
|
|
281
279
|
test("input arriving during reset construction survives even when the hidden steer is never delivered", async () => {
|
|
282
280
|
const sessionManager = Manager.inMemory("/private/tmp/notesoup-late-input-test");
|
package/docs/architecture.md
CHANGED
|
@@ -43,7 +43,7 @@ For the native dsh reset transaction, prompt ordering, capability checks and lim
|
|
|
43
43
|
|
|
44
44
|
## State and persistence
|
|
45
45
|
|
|
46
|
-
`plugins/pi/reset/lifecycle.ts` is the sole `turn_end` composer: it accepts incoming drafts, drains budget-owned guidance/warning drafts, and appends a reset boundary for an explicit tool request or the hard-reserve safety path. Manual and budget close-outs stay armed across note/tool turns and commit from `agent_before_settle` after a successful stop with queued work drained; a manual close-out stops the run while a budget close-out continues in the fresh window. Repeated requests for the same window deduplicate. See [reset lifecycle](reset-lifecycle.md).
|
|
46
|
+
`plugins/pi/reset/lifecycle.ts` is the sole `turn_end` composer: it accepts incoming drafts, drains budget-owned guidance/warning drafts, and appends a reset boundary for an explicit tool request or the hard-reserve safety path. Successful non-reset turns also append a hidden seq marker once at least 100 projected seqs have elapsed since the latest boot or marker, counting incoming boundary drafts; run-start checking remains as a fallback. Markers do not request continuation or split a tool batch. Queued user messages are delivered after this boundary, so a threshold crossed only by such input is marked after its response, not before. A reset's boot anchors its interval instead of adding an old-window marker. Manual and budget close-outs stay armed across note/tool turns and commit from `agent_before_settle` after a successful stop with queued work drained; a manual close-out stops the run while a budget close-out continues in the fresh window. Repeated requests for the same window deduplicate. See [reset lifecycle](reset-lifecycle.md).
|
|
47
47
|
|
|
48
48
|
A new reset is a native empty-summary compaction checkpoint configured to retain none, followed by one `notesoup/reset-marker` custom entry with `{ windowId: string, origin: "normal" | "forced" }`, a hidden `notesoup/boot` whose `details.windowId` matches, and a hidden continuation. The checkpoint is the canonical-history cut; the marker is the durable logical window identity. Raw session entries remain available to history tools. Legacy marker-only branches keep a narrow projection fallback. `plugins/pi/window.ts` owns marker/checkpoint validation, active-branch scan, root/current IDs, and per-window message lookup; `plugins/pi/history.ts` supplies append entries and the active branch to `src/history/pi.ts`, whose structural wire decoder recognizes persisted reset markers; shared `history/history.ts` pairs only decoded, addressed data. The live scan never uses a global entry tail.
|
|
49
49
|
|
package/docs/history-sessions.md
CHANGED
|
@@ -15,7 +15,7 @@ history_read({ session: "claude:full-session-id", seq: 42 })
|
|
|
15
15
|
|
|
16
16
|
Within the requested harness an exact ID wins over prefixes. Without a harness, resolution checks the current harness first (exact ID, then prefixes); only if it has no matches are the other harnesses checked. No match returns `unknown_session`. Multiple matches return `ambiguous_session` with up to five qualified candidates; specify a harness or a longer ID rather than guessing.
|
|
17
17
|
|
|
18
|
-
Explicit targeting always returns the canonical `session: "<harness>:<full-id>"`, even when the target happens to be the current session. Headers become `session <harness>:<id> | seq <seq> | <role>`.
|
|
18
|
+
Explicit targeting always returns the canonical `session: "<harness>:<full-id>"`, even when the target happens to be the current session. Headers become `session <harness>:<id> | seq <seq> | <role>`. Paging footers, folded-row `expand`, and read `neighborhood` recipes carry that same canonical selector. Structured pages expose `has_older` and `has_newer`; use the first or last item’s seq as the next `before_seq` or `after_seq`, respectively, together with its session. The newer footer is `→ newer: {"session":"<harness>:<full-id>","after_seq":...}`. When `after_seq` is set, omitted `from` defaults to `oldest`; otherwise, it defaults to `newest`. Explicit `from` takes precedence. Copy it into subsequent `history_read` calls, including reads continued with `next_offset_chars`.
|
|
19
19
|
|
|
20
20
|
## Browse or search across sessions
|
|
21
21
|
|
|
@@ -34,7 +34,7 @@ history_list({ session: "codex:*", query: "migration", roles: ["tool"], since: "
|
|
|
34
34
|
- With a query, every role is searched, including tool arguments/output and context; `roles` can narrow this. There are no folded rows.
|
|
35
35
|
- `since` is inclusive and `until` exclusive. Time-bounded searches exclude events with no usable timestamp.
|
|
36
36
|
- Search hits are merged by event time, oldest first, with a deterministic session/seq tie-break; untimed events sort before timed events. For query searches, `limit` counts from the newest event end by default, or the oldest with `from: "oldest"`. The complete text and structured result still share the 32 KiB budget, so large previews can reduce the admitted page.
|
|
37
|
-
- Each event carries its canonical `session`. `
|
|
37
|
+
- Each event carries its canonical `session`. `has_older` and `has_newer` indicate more matching results beyond the page; an overview with unvisited sessions may have more even if those sessions have no representative. Narrow by session pattern, query, roles or time rather than trying to page across per-session seqs.
|
|
38
38
|
|
|
39
39
|
## Local discovery and limits
|
|
40
40
|
|
|
@@ -49,6 +49,30 @@ Filesystem discovery does not follow directory symlinks or recurse into Claude s
|
|
|
49
49
|
|
|
50
50
|
The default roots respect `PI_CODING_AGENT_DIR` (Pi agent directory), `CLAUDE_CONFIG_DIR` (Claude config directory), and `CODEX_HOME` (Codex home). For direct root overrides use absolute paths in `NOTESOUP_HISTORY_PI_ROOT`, `NOTESOUP_HISTORY_CLAUDE_ROOT`, and `NOTESOUP_HISTORY_CODEX_ROOT`; these name the **sessions**, **projects**, and **sessions** directories respectively, not notes storage. `NOTESOUP_HOME` only changes notes.
|
|
51
51
|
|
|
52
|
+
## Strict recent-session cache
|
|
53
|
+
|
|
54
|
+
Only an unfiltered wildcard overview uses the persistent offline representative cache: no nonempty query and no `roles`, `since`, or `until`. Empty queries still mean an overview. Explicit session reads/lists, searches, filtered overviews, DSH service descriptors and the current live binding do not use this cache. Session discovery, modified-time ordering, representative ordering, output budgeting and full event-preview limits are unchanged.
|
|
55
|
+
|
|
56
|
+
A cold miss deliberately reads and strictly decodes the whole transcript, including selected Codex ancestry. It saves only the complete selected event, canonical session identity, notice and source metadata—not a projection, header-only approximation or full-text index. Entries are versioned with the decoder/selection contract; decoder or presentation changes must bump that version. The key includes the canonical root transcript path, harness and session ID. Every source has a `dev`/`ino`/size/nanosecond mtime/ctime fingerprint taken before reading and checked after decoding. Codex records the actual root and ancestor files, and cache hits re-run native lineage discovery so newly ambiguous or missing sources cannot be hidden by unchanged file fingerprints. The fingerprint list must exactly match the root and lineage witness list.
|
|
57
|
+
|
|
58
|
+
Cache storage is `~/Library/Caches/notesoup/history` on macOS, or `$XDG_CACHE_HOME/notesoup/history` (`~/.cache/notesoup/history` by default) elsewhere. Entries use atomic temporary-file rename and are individually capped at 8 MiB, both on admission and before/after reading. Oversized representatives still use normal strict decoding and normal output budgets; they are not truncated for cache admission. Missing, corrupt or unwritable caches are transparent misses. Raced decodes are returned without persistence. Transcript failures are never cached: wildcard calls still skip those sessions, while explicit calls still refuse. There is no public cache option, background warmup, or whole-corpus index; the internal test-root seam keeps tests out of the user's cache.
|
|
59
|
+
|
|
60
|
+
### Cold and warm evidence
|
|
61
|
+
|
|
62
|
+
A November 1, 2026 local read-only measurement used a private empty cache and a fresh Node process for each pass. It ran the default 20-topic overview over offline descriptors last modified at least ten minutes earlier, excluding active work; both passes returned exactly the same serialized result. This is one local sample, not a cold-search or whole-corpus speed claim.
|
|
63
|
+
|
|
64
|
+
| Measurement | Cold cache | Warm cache |
|
|
65
|
+
| --- | ---: | ---: |
|
|
66
|
+
| Elapsed | 462.58 ms | 89.63 ms |
|
|
67
|
+
| Transcript body reads | 32 | 12 |
|
|
68
|
+
| Transcript bytes | 159,240,525 | 70,962,466 |
|
|
69
|
+
| JSON parses (including cache entries) | 10,636 | 32 |
|
|
70
|
+
| Peak process RSS | 305,200 KiB | 134,208 KiB |
|
|
71
|
+
|
|
72
|
+
All 20 unchanged supported sessions hit their summaries without body reads on the warm pass. The remaining 12 body reads in **both** passes were unavailable/unsupported sessions intentionally rechecked rather than negatively cached. Twenty entries occupied 184,431 bytes (largest 142,796 bytes). Focused hermetic tests independently prove zero second-call transcript reads for supported Pi and compressed Codex/ancestor fixtures, complete-event preview parity, invalidation, cache-growth fallback and live-binding precedence. Warm calls still pay discovery/stat/cache-validation costs; Codex lineage can require directory discovery. Cold decoding can still use substantial per-transcript memory, and rejected transcripts are retried on each browse.
|
|
73
|
+
|
|
52
74
|
Embedders/tests can use `localHistoryCorpus({ current, roots, home, env, dshSessions })` from the source module `src/history/local.ts`. Each `roots` member overrides that harness's discovery directory; `null` disables it. A supplied `home` with `env: {}` makes the defaults hermetic. These source-module helpers are not new package exports.
|
|
53
75
|
|
|
54
76
|
The shared operations still accept a bare `HistoryProjection` for current-session calls. Host adapters instead supply a `HistoryContext` with a lazy `current()` projection and a `HistoryCorpus`. Filesystem wire decoders live under `src/history/`, import no host SDK/plugin, and are shared by native adapter entries and corpus reads. DSH contributes descriptors through its public query service. Foreign reads do not require loading the current projection; Codex still validates the caller's hook binding and native identity/window before serving them.
|
|
77
|
+
|
|
78
|
+
In single-session browse pages, `items` contains events only. A folded tool/context run appears in `folded_before` on the following event, or in `folded_after` at the end of the page. Folded runs do not count toward the event limit.
|
package/docs/reset-lifecycle.md
CHANGED
|
@@ -4,18 +4,18 @@ Pi reset control lives in `plugins/pi/reset/lifecycle.ts`: the pure `reduceReset
|
|
|
4
4
|
|
|
5
5
|
## Lifecycle at a glance
|
|
6
6
|
|
|
7
|
-
**Human input not yet answered must survive a reset and be answered afterward.
|
|
7
|
+
**Human input not yet answered must survive a reset and be answered afterward. Every `/empty` or `/fresh-window` stops after resetting unless separate human input arrives during emptying.**
|
|
8
8
|
|
|
9
9
|
| Trigger | Behavior |
|
|
10
10
|
| --- | --- |
|
|
11
11
|
| `empty_brain` tool | Record the actual call and optional last word. Without command policy, reset after the whole tool batch at `turn_end` and continue. Under command policy, wait for settlement. |
|
|
12
|
-
| `/empty <text>` or `/fresh-window <text>` | Send a hidden close-out warning (trigger when idle, steer when busy),
|
|
12
|
+
| `/empty <text>` or `/fresh-window <text>` | Send a hidden close-out warning (trigger when idle, steer when busy), with the argument verbatim as context for notes, then reset and stop unless separate human input arrives during emptying. |
|
|
13
13
|
| Bare `/empty` or `/fresh-window` | Close out, reset, and stop, unless more human input arrives while close-out is pending. |
|
|
14
14
|
| Human input during command close-out | Intercept public `input` events except source `extension`, return `handled`, and stash text/images in command state. Also hidden-steer the bare `<notesoup:next_window_prompt>` block plus original images to the closing model. The originals are carried even if that steer never arrives; any carried input makes the reset continue. |
|
|
15
15
|
| Passive provider overflow / recoverable length | With automatic reset enabled, force a retain-none reset and continue once. Carry the failed logical run's human messages: starting prompt and delivered steering/follow-ups. A run started by our own continuation has no human input to carry. |
|
|
16
|
-
| Command close-out overflow | Force a reset even if automatic reset is disabled. Apply command policy: continue with
|
|
16
|
+
| Command close-out overflow | Force a reset even if automatic reset is disabled. Apply command policy: continue with separate carried input, otherwise stop. The recovery attempt is spent, so an oversized carried prompt cannot loop. |
|
|
17
17
|
| Budget warning | Stage reminders when automatic reset is enabled. Warnings alone never authorize reset. |
|
|
18
|
-
| Hard reserve | Independently reset at `turn_end` when automatic reset is enabled. A
|
|
18
|
+
| Hard reserve | Independently reset at `turn_end` when automatic reset is enabled. A command stop latch cancels empty tool follow-ups, but never real queued or carried human input. |
|
|
19
19
|
| Abort / ordinary error | Restore stashed originals as visible user-content custom messages before clearing command state. Explicit abort stays stopped; ordinary close-out errors do not force reset. |
|
|
20
20
|
| `/compact` while active | Cancel native compaction; manual attempts receive a `/fresh-window` notice. |
|
|
21
21
|
|
package/docs/tool-results.md
CHANGED
|
@@ -55,7 +55,7 @@ The suffix and presentation header are never part of `text`, search offsets or t
|
|
|
55
55
|
|
|
56
56
|
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.
|
|
57
57
|
|
|
58
|
-
Seqs address events across the whole session, including earlier windows. With `session` omitted, list and read headers use `seq <seq> | <role>`; the boot window tree supplies per-window seq ranges for narrowing a list with `before_seq` and `after_seq`. With an explicit selector, returned events/read data carry canonical `session`, headers use `session <harness>:<id> | seq <seq> | <role>`, and all paging/expand/neighborhood recipes carry that same identity. Wildcard `history_list` forbids seq bounds and
|
|
58
|
+
Seqs address events across the whole session, including earlier windows. With `session` omitted, list and read headers use `seq <seq> | <role>`; the boot window tree supplies per-window seq ranges for narrowing a list with `before_seq` and `after_seq`. With an explicit selector, returned events/read data carry canonical `session`, headers use `session <harness>:<id> | seq <seq> | <role>`, and all paging/expand/neighborhood recipes carry that same identity. Wildcard `history_list` forbids seq bounds and reports whether more results may exist beyond the page. With `query`, it returns only hits across all roles; without a non-empty query, it returns one representative event per recent session, stopping once `limit` sessions have produced an item. Individual unreadable sessions are skipped only in wildcard calls. See [cross-session history](history-sessions.md) for resolution, discovery and refusal rules.
|
|
59
59
|
|
|
60
60
|
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.
|
|
61
61
|
|
|
@@ -67,7 +67,7 @@ Pi's nested records contain child ID, name, optional arguments, status, timing a
|
|
|
67
67
|
|
|
68
68
|
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. History operations accept an optional pure text wrapper from the host: selection and read-window checks measure that wrapper around the shared rendering, and the caller must apply the same wrapper at delivery. Host prose stays in its plugin; no final clipping or separate query is involved.
|
|
69
69
|
|
|
70
|
-
History pages carry `
|
|
70
|
+
`after_seq` is a strict lower bound; `after_seq: 0` starts from the beginning. History pages carry boolean `has_older` and `has_newer` flags. For single-session pages, use the first item’s `seq` as `before_seq` to page older, and the last item’s `seq` as `after_seq` to page newer; include its `session` when present. Wildcard pages instead report more results and suggest narrowing by time, query, roles or session pattern; an overview with unvisited sessions may have more. The single-session rendered newer footer gives `→ newer: {"after_seq":...}` with an optional session. `from` picks which end of a bounded range `limit` counts from: it defaults to `oldest` when `after_seq` is set, and `newest` otherwise. Explicit `from` wins. `since`/`until` narrow that range by event `created_at`, and only a single-session call without roles or a non-empty query folds tool/context runs. Omitted queries, empty strings and empty lists all disable search filtering; empty entries in a query list are ignored. Without a query, notes search returns scoped notes with empty `matches`, not every body line. Notes listings/search are snapshots with a `more` count and can be narrowed by `glob`; they are not falsely advertised as paginated. 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.
|
|
71
71
|
|
|
72
72
|
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.
|
|
73
73
|
|
|
@@ -82,3 +82,5 @@ A note read reports unrecognized frontmatter under `metadata.extra`; a value too
|
|
|
82
82
|
- Host adapters supply base cwd, default identity, projections, optional pure text decoration and transport packaging only; they do not implement separate cwd override algorithms.
|
|
83
83
|
|
|
84
84
|
There is no second query implementation for codemode, no copy of session storage and no migration of user records.
|
|
85
|
+
|
|
86
|
+
In single-session browse pages, `items` contains events only. A folded tool/context run appears in `folded_before` on the following event, or in `folded_after` at the end of the page. Folded runs do not count toward the event limit.
|
package/package.json
CHANGED