notesoup 0.53.1 → 0.53.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/plugins/claude/src/history.js +2 -3
- package/dist/plugins/claude/src/thresholds.js +4 -2
- package/dist/plugins/pi/entries.d.ts +1 -0
- package/dist/plugins/pi/entries.js +1 -0
- package/dist/plugins/pi/marker.d.ts +9 -0
- package/dist/plugins/pi/marker.js +36 -0
- package/dist/plugins/pi/reset/artifacts.d.ts +2 -2
- package/dist/plugins/pi/reset/artifacts.js +2 -2
- package/dist/plugins/pi/runtime.js +9 -6
- package/dist/plugins/pi/text.d.ts +2 -0
- package/dist/plugins/pi/text.js +4 -0
- package/dist/test/agent-loop.test.js +8 -8
- package/dist/test/boot.integration.test.js +4 -4
- package/dist/test/claude-history.test.js +26 -0
- package/dist/test/claude-mod.test.js +178 -53
- package/dist/test/marker.test.d.ts +1 -0
- package/dist/test/marker.test.js +78 -0
- package/dist/test/reset-lifecycle.test.js +12 -0
- package/docs/architecture.md +1 -1
- package/docs/claude-code-mod.md +7 -7
- package/package.json +1 -1
- package/plugins/claude/.claude-plugin/plugin.json +1 -1
- package/plugins/claude/dist/claude/helper.js +4 -2
- package/plugins/claude/hooks/register.ts +44 -56
- package/plugins/claude/src/history.ts +2 -3
- package/plugins/claude/src/thresholds.ts +4 -2
- package/plugins/pi/entries.ts +1 -0
- package/plugins/pi/marker.ts +39 -0
- package/plugins/pi/reset/artifacts.ts +2 -2
- package/plugins/pi/runtime.ts +7 -6
- package/plugins/pi/text.ts +5 -0
|
@@ -58,9 +58,8 @@ function blocksOf(value) {
|
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
60
|
function decode(row, seq) {
|
|
61
|
-
//
|
|
62
|
-
|
|
63
|
-
if (row.type === "system" && row.subtype === "turn_duration")
|
|
61
|
+
// A system record without a body is graph metadata, not a message.
|
|
62
|
+
if (row.type === "system" && row.content == null)
|
|
64
63
|
return [];
|
|
65
64
|
const common = { windowId: "", ...(typeof row.timestamp === "string" ? { createdAt: row.timestamp } : {}) };
|
|
66
65
|
let blocks, role;
|
|
@@ -118,9 +118,11 @@ export function resolveClaudeLimits(facts) {
|
|
|
118
118
|
if (window !== undefined) {
|
|
119
119
|
const configured = configuredWindow(settings, env, breakdown.model);
|
|
120
120
|
const effective = Math.min(configured ?? window, window);
|
|
121
|
+
const available = effective - CLAUDE_OUTPUT_RESERVE_TOKENS;
|
|
122
|
+
const threshold = available - CLAUDE_AUTOCOMPACT_BUFFER_TOKENS;
|
|
121
123
|
const native = autoCompact
|
|
122
|
-
?
|
|
123
|
-
:
|
|
124
|
+
? pct === undefined ? threshold : Math.min(Math.floor(available * (pct / 100)), threshold)
|
|
125
|
+
: available;
|
|
124
126
|
return tokenLimits("window", autoCompact, native, resetMargin, warningRunway);
|
|
125
127
|
}
|
|
126
128
|
// (c) Nothing usable but percentages.
|
|
@@ -7,3 +7,4 @@ export declare const CONTINUATION_TYPE = "notesoup/continuation";
|
|
|
7
7
|
export declare const RESET_LAST_WORD_TYPE = "notesoup/reset-last-word";
|
|
8
8
|
export declare const CARRIED_INPUT_TYPE = "notesoup/carried-input";
|
|
9
9
|
export declare const NEXT_WINDOW_PROMPT_TYPE = "notesoup/next-window-prompt";
|
|
10
|
+
export declare const MARKER_TYPE = "notesoup/marker";
|
|
@@ -7,3 +7,4 @@ export const CONTINUATION_TYPE = "notesoup/continuation";
|
|
|
7
7
|
export const RESET_LAST_WORD_TYPE = "notesoup/reset-last-word";
|
|
8
8
|
export const CARRIED_INPUT_TYPE = "notesoup/carried-input";
|
|
9
9
|
export const NEXT_WINDOW_PROMPT_TYPE = "notesoup/next-window-prompt";
|
|
10
|
+
export const MARKER_TYPE = "notesoup/marker";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
/** Spacing between durable seq breadcrumbs, in projected history seq. */
|
|
3
|
+
export declare const MARKER_INTERVAL = 50;
|
|
4
|
+
/**
|
|
5
|
+
* Stamp the current seq every MARKER_INTERVAL seqs. The marker names the seq it occupies, so a
|
|
6
|
+
* model paging history_list meets a breadcrumb that tells it where it is. Skipped while a reset
|
|
7
|
+
* tail still awaits boot or continuation: a foreign message there would close the repair shape.
|
|
8
|
+
*/
|
|
9
|
+
export declare function maybeSendMarker(pi: ExtensionAPI, ctx: ExtensionContext): void;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { MARKER_TYPE } from "./entries.js";
|
|
2
|
+
import { nextHistorySeq } from "./history.js";
|
|
3
|
+
import { inspectResetTail } from "./reset/artifacts.js";
|
|
4
|
+
import { markerContent } from "./text.js";
|
|
5
|
+
import { currentReset } from "./window.js";
|
|
6
|
+
/** Spacing between durable seq breadcrumbs, in projected history seq. */
|
|
7
|
+
export const MARKER_INTERVAL = 50;
|
|
8
|
+
/** Highest seq already stamped by a marker; 0 before the first. */
|
|
9
|
+
function lastMarkerSeq(ctx) {
|
|
10
|
+
let last = 0;
|
|
11
|
+
for (const entry of ctx.sessionManager.getEntries()) {
|
|
12
|
+
if (entry.type !== "custom_message" || entry.customType !== MARKER_TYPE)
|
|
13
|
+
continue;
|
|
14
|
+
const seq = entry.details?.seq;
|
|
15
|
+
if (typeof seq === "number" && seq > last)
|
|
16
|
+
last = seq;
|
|
17
|
+
}
|
|
18
|
+
return last;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Stamp the current seq every MARKER_INTERVAL seqs. The marker names the seq it occupies, so a
|
|
22
|
+
* model paging history_list meets a breadcrumb that tells it where it is. Skipped while a reset
|
|
23
|
+
* tail still awaits boot or continuation: a foreign message there would close the repair shape.
|
|
24
|
+
*/
|
|
25
|
+
export function maybeSendMarker(pi, ctx) {
|
|
26
|
+
const reset = currentReset(ctx);
|
|
27
|
+
if (reset) {
|
|
28
|
+
const tail = inspectResetTail(ctx, reset.id, reset.data.windowId);
|
|
29
|
+
if (tail && (!tail.boot || !tail.continuation))
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const seq = nextHistorySeq(ctx);
|
|
33
|
+
if (seq - lastMarkerSeq(ctx) < MARKER_INTERVAL)
|
|
34
|
+
return;
|
|
35
|
+
pi.sendMessage({ customType: MARKER_TYPE, content: markerContent(seq), display: false, details: { seq } }, { triggerTurn: false });
|
|
36
|
+
}
|
|
@@ -15,9 +15,9 @@ export declare function carriedInputDrafts(inputs: readonly CarriedInput[]): Ext
|
|
|
15
15
|
}>[];
|
|
16
16
|
export declare function isCarriedInputEntry(entry: SessionEntry): boolean;
|
|
17
17
|
/** Advertised size: the description quotes this softer limit so sloppy character counts still fit. */
|
|
18
|
-
export declare const LAST_WORD_ADVERTISED_CHARS =
|
|
18
|
+
export declare const LAST_WORD_ADVERTISED_CHARS = 300;
|
|
19
19
|
/** A sticky note, not a letter: over this, empty_brain refuses instead of truncating. */
|
|
20
|
-
export declare const MAX_LAST_WORD_CHARS =
|
|
20
|
+
export declare const MAX_LAST_WORD_CHARS = 500;
|
|
21
21
|
/** How the next window finds the note. */
|
|
22
22
|
export declare const LAST_WORD_PREFIX = "*You peel a sticky note off your forehead.*\n";
|
|
23
23
|
/** Trim a parting line; blank input leaves no last word. Length is checked by the caller. */
|
|
@@ -10,9 +10,9 @@ export function isCarriedInputEntry(entry) {
|
|
|
10
10
|
return entry.type === "custom_message" && entry.customType === CARRIED_INPUT_TYPE && entry.display === true;
|
|
11
11
|
}
|
|
12
12
|
/** Advertised size: the description quotes this softer limit so sloppy character counts still fit. */
|
|
13
|
-
export const LAST_WORD_ADVERTISED_CHARS =
|
|
13
|
+
export const LAST_WORD_ADVERTISED_CHARS = 300;
|
|
14
14
|
/** A sticky note, not a letter: over this, empty_brain refuses instead of truncating. */
|
|
15
|
-
export const MAX_LAST_WORD_CHARS =
|
|
15
|
+
export const MAX_LAST_WORD_CHARS = 500;
|
|
16
16
|
/** How the next window finds the note. */
|
|
17
17
|
export const LAST_WORD_PREFIX = "*You peel a sticky note off your forehead.*\n";
|
|
18
18
|
/** Trim a parting line; blank input leaves no last word. Length is checked by the caller. */
|
|
@@ -11,6 +11,7 @@ import { buildResetDrafts, LAST_WORD_ADVERTISED_CHARS, MAX_LAST_WORD_CHARS, repa
|
|
|
11
11
|
import { BOOT_TYPE, MANUAL_WIPE_TYPE } from "./entries.js";
|
|
12
12
|
import { commandWarningContent } from "./text.js";
|
|
13
13
|
import { buildBootMessage, sendBoot } from "./boot.js";
|
|
14
|
+
import { maybeSendMarker } from "./marker.js";
|
|
14
15
|
import { nextHistorySeq } from "./history.js";
|
|
15
16
|
import { errorMessage } from "../../src/error-message.js";
|
|
16
17
|
function readPackageVersion() {
|
|
@@ -73,13 +74,15 @@ export function registerContext(pi, settingsManager) {
|
|
|
73
74
|
if (!marker || !isCheckpointBackedReset(ctx, marker) || !resetBoundaryCommitted(ctx, marker.id, windowId))
|
|
74
75
|
continue;
|
|
75
76
|
pendingResetNotices.delete(windowId);
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
const forced = markerResetOrigin(marker) === "forced";
|
|
79
|
-
ctx.ui.notify(forced ? "🥣 Brain forcibly emptied: overflow" : "🥣 Fresh brain", forced ? "warning" : "info");
|
|
77
|
+
if (markerResetOrigin(marker) === "forced")
|
|
78
|
+
ctx.ui.notify("🥣 Brain forcibly emptied: overflow", "warning");
|
|
80
79
|
}
|
|
81
80
|
};
|
|
82
|
-
pi.on("turn_start", (_event, ctx) =>
|
|
81
|
+
pi.on("turn_start", (_event, ctx) => {
|
|
82
|
+
notifyCommittedResets(ctx);
|
|
83
|
+
if (enabled)
|
|
84
|
+
maybeSendMarker(pi, ctx);
|
|
85
|
+
});
|
|
83
86
|
pi.on("agent_settled", (_event, ctx) => {
|
|
84
87
|
notifyCommittedResets(ctx);
|
|
85
88
|
pendingResetNotices.clear();
|
|
@@ -193,7 +196,7 @@ export function registerContext(pi, settingsManager) {
|
|
|
193
196
|
cmdCtx.ui.notify("🥣 Brain already being emptied", "info");
|
|
194
197
|
return;
|
|
195
198
|
}
|
|
196
|
-
cmdCtx.ui.notify("🥣 Brain
|
|
199
|
+
cmdCtx.ui.notify("🥣 Dumping Brain", "info");
|
|
197
200
|
try {
|
|
198
201
|
pi.sendMessage({ customType: MANUAL_WIPE_TYPE, content: commandWarningContent(prompt !== undefined ? `/empty ${prompt}` : undefined), display: false }, { triggerTurn: true, deliverAs: "steer" });
|
|
199
202
|
}
|
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export declare const PI_PRE_RESET_HINTS = "Anything you say here is erased with the reset \u2014 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.";
|
|
8
8
|
export { warningNotice as warningContent } from "../../src/budget/text.js";
|
|
9
|
+
/** Odometer breadcrumb: the marker names its own seq, so history paging reads the landscape directly. */
|
|
10
|
+
export declare function markerContent(seq: number): string;
|
|
9
11
|
/** The closing model sees deferred input as a bare next-window prompt block. */
|
|
10
12
|
export declare function promptBlock(commandLine: string): string;
|
|
11
13
|
/** Approved manual close-out notices; both variants live here. */
|
package/dist/plugins/pi/text.js
CHANGED
|
@@ -8,6 +8,10 @@ import { COUNTDOWN_LINE, GUIDANCE_CLOSE_TAG, GUIDANCE_OPEN_TAG, WARNING_BODY, WA
|
|
|
8
8
|
export const 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.
|
|
9
9
|
Unless the human explicitly directs otherwise, decide for yourself when to call empty_brain. Don't keep asking them whether to reset.`;
|
|
10
10
|
export { warningNotice as warningContent } from "../../src/budget/text.js";
|
|
11
|
+
/** Odometer breadcrumb: the marker names its own seq, so history paging reads the landscape directly. */
|
|
12
|
+
export function markerContent(seq) {
|
|
13
|
+
return `<notesoup:marker seq="${seq}" />`;
|
|
14
|
+
}
|
|
11
15
|
/** The closing model sees deferred input as a bare next-window prompt block. */
|
|
12
16
|
export function promptBlock(commandLine) {
|
|
13
17
|
return `<notesoup:next_window_prompt>\n${commandLine}\n</notesoup:next_window_prompt>`;
|
|
@@ -130,7 +130,7 @@ async function openFixture(options) {
|
|
|
130
130
|
await session.bindExtensions({
|
|
131
131
|
uiContext: {
|
|
132
132
|
notify(message, type) {
|
|
133
|
-
if (message === "🥣
|
|
133
|
+
if (message === "🥣 Brain forcibly emptied: overflow") {
|
|
134
134
|
const marker = sessionManager.getBranch().filter((entry) => entry.type === "custom" && entry.customType === RESET_MARKER_TYPE).at(-1);
|
|
135
135
|
const windowId = marker?.data?.windowId;
|
|
136
136
|
assert.ok(sessionManager.getBranch().some((entry) => entry.type === "custom" && entry.customType === RESET_MARKER_TYPE && entry.data?.windowId === windowId), "notification follows the reset marker commit");
|
|
@@ -210,7 +210,7 @@ const COMMAND_WARNING_JSON = JSON.stringify(commandWarningContent()).slice(1, -1
|
|
|
210
210
|
function assertUserContent(context, content) {
|
|
211
211
|
assert.ok(context?.messages.some((message) => message.role === "user" && JSON.stringify(message.content) === JSON.stringify(content)), "carried input reaches the provider verbatim as user content");
|
|
212
212
|
}
|
|
213
|
-
/**
|
|
213
|
+
/** Recognize reset completion notices, including the removed normal-reset wording. */
|
|
214
214
|
const isResetSuccessNotice = (notice) => notice.includes("🥣 Fresh brain") || notice.includes("🥣 Brain forcibly emptied");
|
|
215
215
|
function resetMarkers(fixture) {
|
|
216
216
|
return fixture.sessionManager.getBranch().filter((entry) => entry.type === "custom" && entry.customType === RESET_MARKER_TYPE);
|
|
@@ -418,12 +418,12 @@ test("real AgentSession: final warning survives its reset boundary and notifies
|
|
|
418
418
|
assert.equal(fixture.sessionManager.getBranch().filter((entry) => entry.type === "custom_message" && entry.customType === WARNING_TYPE).length, 1);
|
|
419
419
|
assert.equal(resetMarkers(fixture).length, 1, "the reset commits in the same boundary as the final warning");
|
|
420
420
|
assert.equal(fixture.budgetNotices(), 1, "the old-window committed warning reaches the UI after reset");
|
|
421
|
-
assert.equal(fixture.notices.filter(
|
|
421
|
+
assert.equal(fixture.notices.filter(isResetSuccessNotice).length, 0, "normal reset completion stays silent");
|
|
422
422
|
assert.equal(fixture.notices.some((notice) => notice.includes("Context running low")), false, "early guidance stays silent");
|
|
423
423
|
await fixture.session.prompt("Continue after reset.");
|
|
424
424
|
await fixture.session.waitForIdle();
|
|
425
425
|
assert.equal(fixture.budgetNotices(), 1, "later turns cannot repeat the consumed final warning");
|
|
426
|
-
assert.equal(fixture.notices.filter(
|
|
426
|
+
assert.equal(fixture.notices.filter(isResetSuccessNotice).length, 0, "later turns do not announce normal reset completion");
|
|
427
427
|
}
|
|
428
428
|
finally {
|
|
429
429
|
fixture.close();
|
|
@@ -443,7 +443,7 @@ test("real AgentSession: explicit tiny-session wipe ignores keepRecentTokens and
|
|
|
443
443
|
assert.equal(fixture.notices.length, 0, "startup boot is silent");
|
|
444
444
|
await fixture.session.prompt("OLD_CONTEXT_SENTINEL: retain this only in durable history.");
|
|
445
445
|
await fixture.session.waitForIdle();
|
|
446
|
-
assert.deepEqual(fixture.notices.filter(isResetSuccessNotice), [
|
|
446
|
+
assert.deepEqual(fixture.notices.filter(isResetSuccessNotice), [], "normal reset completion stays silent");
|
|
447
447
|
assert.equal(fixture.requests.length, 2, "the tool starts exactly one continuation");
|
|
448
448
|
assert.ok(text(fixture.requests[0]).includes("OLD_CONTEXT_SENTINEL"));
|
|
449
449
|
assertFreshRequest(fixture, 1, "OLD_CONTEXT_SENTINEL");
|
|
@@ -541,7 +541,7 @@ test("real AgentSession: /empty text is carried verbatim and answered after clos
|
|
|
541
541
|
const branch = fixture.sessionManager.getBranch();
|
|
542
542
|
const continuationIndex = branch.findIndex((entry) => entry.type === "custom_message" && entry.customType === CONTINUATION_TYPE);
|
|
543
543
|
assert.deepEqual(branch.slice(continuationIndex + 1, continuationIndex + 3).map((entry) => entry.type === "custom_message" ? entry.customType : entry.type), ["notesoup/reset-last-word", CARRIED_INPUT_TYPE]);
|
|
544
|
-
assert.
|
|
544
|
+
assert.equal(fixture.notices.some(isResetSuccessNotice), false);
|
|
545
545
|
}
|
|
546
546
|
finally {
|
|
547
547
|
fixture.close();
|
|
@@ -636,7 +636,7 @@ test("real AgentSession: manual hard-reserve reset stops clean and mixed-tool tu
|
|
|
636
636
|
assert.equal(fixture.requests.length, 2);
|
|
637
637
|
assert.equal(resetMarkers(fixture).length, 1, "the safety wipe is not repeated at settlement");
|
|
638
638
|
assert.equal(JSON.stringify(fixture.sessionManager.buildSessionProjection().messages).includes("HARD_RESERVE_OLD_SENTINEL"), false);
|
|
639
|
-
assert.
|
|
639
|
+
assert.equal(fixture.notices.some(isResetSuccessNotice), !mixed, "only forced reset completion notifies");
|
|
640
640
|
if (mixed) {
|
|
641
641
|
assert.ok(existsSync(join(fixture.notesRoot, "pi", "session", fixture.sessionManager.getSessionId(), "pressure.md")), "the whole tool batch completes before the cut");
|
|
642
642
|
assert.equal(fixture.streamSignals.at(-1), true, "Pi's unavoidable tool follow-up is cancelled before provider work");
|
|
@@ -705,7 +705,7 @@ test("real AgentSession: streaming /empty steers a close-out and stops at settle
|
|
|
705
705
|
await started;
|
|
706
706
|
await fixture.session.prompt("/empty", { streamingBehavior: "steer" });
|
|
707
707
|
await fixture.session.prompt("/empty", { streamingBehavior: "followUp" });
|
|
708
|
-
assert.equal(fixture.notices.filter((notice) => notice.includes("Brain
|
|
708
|
+
assert.equal(fixture.notices.filter((notice) => notice.includes("Dumping Brain")).length, 1, "the user is notified once while output is ongoing");
|
|
709
709
|
assert.equal(resetMarkers(fixture).length, 0, "the ongoing turn is not interrupted");
|
|
710
710
|
releaseResponse();
|
|
711
711
|
await running;
|
|
@@ -85,7 +85,7 @@ test("the root boot and reset boot carry durable window identity", async () => {
|
|
|
85
85
|
assert.equal(boundary.continue, true);
|
|
86
86
|
await runHandlers(captured, "turn_start", {}, ctx);
|
|
87
87
|
await runHandlers(captured, "agent_settled", {}, ctx);
|
|
88
|
-
assert.deepEqual(noticesOf(ctx)
|
|
88
|
+
assert.deepEqual(noticesOf(ctx), [], "normal reset completion stays silent");
|
|
89
89
|
const entries = sessionManager.getBranch();
|
|
90
90
|
const marker = entries.find((entry) => entry.type === "custom" && entry.customType === RESET_MARKER_TYPE);
|
|
91
91
|
assert.ok(marker && marker.type === "custom");
|
|
@@ -332,7 +332,7 @@ test("/empty waits out non-agent busy work before starting its single-turn reque
|
|
|
332
332
|
assert.equal(waits, 1);
|
|
333
333
|
assert.equal(captured.sent.length, 1);
|
|
334
334
|
assert.equal(captured.sent[0]?.options?.triggerTurn, true);
|
|
335
|
-
assert.equal(notices.filter((message) => message.includes("Brain
|
|
335
|
+
assert.equal(notices.filter((message) => message.includes("Dumping Brain")).length, 1);
|
|
336
336
|
});
|
|
337
337
|
test("notesoup command toggles future work, /empty schedules a turn-end reset, and /compact remains disabled", async () => {
|
|
338
338
|
const sessionManager = manager();
|
|
@@ -357,7 +357,7 @@ test("notesoup command toggles future work, /empty schedules a turn-end reset, a
|
|
|
357
357
|
assert.match(notices[0]?.message ?? "", /on/);
|
|
358
358
|
notices = await runCommand(captured, "empty", "", low);
|
|
359
359
|
assert.equal(notices.length, 1, "the command acknowledges the reset request");
|
|
360
|
-
assert.match(notices[0]?.message ?? "", /Brain
|
|
360
|
+
assert.match(notices[0]?.message ?? "", /Dumping Brain/);
|
|
361
361
|
assert.equal(captured.sent.length, 2, "the command persists one hidden warning after the startup boot");
|
|
362
362
|
assert.equal(captured.sent[1]?.options?.triggerTurn, true, "the manual checkpoint prompt starts an ordinary agent turn");
|
|
363
363
|
assert.equal(captured.sent[1]?.message.customType, MANUAL_WIPE_TYPE);
|
|
@@ -396,7 +396,7 @@ test("committed reset confirmation survives later work while repair refuses that
|
|
|
396
396
|
assert.equal(resetBoundaryCommitted(ctx, marker.id, windowId), true, "later work does not undo a committed native boundary");
|
|
397
397
|
await runHandlers(captured, "agent_settled", {}, ctx);
|
|
398
398
|
await runHandlers(captured, "turn_start", {}, ctx);
|
|
399
|
-
assert.
|
|
399
|
+
assert.deepEqual(noticesOf(ctx), [], "later work does not announce normal reset completion");
|
|
400
400
|
assert.equal(resetBoundaryCommitted(ctx, marker.id, "wrong-window"), false);
|
|
401
401
|
const partial = manager();
|
|
402
402
|
const partialCtx = context(partial);
|
|
@@ -176,6 +176,32 @@ test("Claude reset crosses native turn_duration graph metadata with no message c
|
|
|
176
176
|
assert.ok((await historyRead.execute({ seq: 2 }, projection)).ok);
|
|
177
177
|
assert.ok((await historyWindows.execute({}, projection, sessionId)).ok);
|
|
178
178
|
});
|
|
179
|
+
test("Claude api_error retry metadata keeps compact ancestry without allocating seq or exposing internals", async () => {
|
|
180
|
+
const retry = { type: "system", subtype: "api_error", uuid: "retry", parentUuid: "old", sessionId, isSidechain: false,
|
|
181
|
+
level: "error", error: { message: "Connection error.", formatted: "Connection dropped (ECONNRESET)",
|
|
182
|
+
connection: { code: "ECONNRESET", message: "PRIVATE_RETRY_PAYLOAD", isSSLError: false }, isNetworkDown: false, rateLimits: null, noResponse: null },
|
|
183
|
+
retryInMs: 620, retryAttempt: 1, maxRetries: 10, source: "request_retry", timestamp: "2026-10-22T03:20:21.859Z", version: "2.1.295" };
|
|
184
|
+
const prefix = [user("u", null, "before retry"), assistant("old", "u", "finished turn")];
|
|
185
|
+
const rows = [...prefix, retry, compact("boundary", "retry"), row("boot", "boundary", "user", bootText(1)), user("after", "boot", "after reset")];
|
|
186
|
+
const projection = project(rows, "after");
|
|
187
|
+
assert.deepEqual(projection.missingAncestors, []);
|
|
188
|
+
assert.equal(projection.highestSeq, 5, "retry metadata allocates no message or seq");
|
|
189
|
+
assert.equal(projection.windows.length, 2);
|
|
190
|
+
assert.equal(projection.currentWindowOrdinal, 1);
|
|
191
|
+
assert.deepEqual(project([...prefix, { ...rows[3], logicalParentUuid: "old" }, ...rows.slice(4)], "after"), projection, "metadata leaves all addresses and windows unchanged");
|
|
192
|
+
assert.doesNotMatch(allItems(projection).map(eventDocument).join("\n"), /PRIVATE_RETRY_PAYLOAD|ECONNRESET|request_retry/);
|
|
193
|
+
assert.ok((await historyList.execute({}, projection)).ok);
|
|
194
|
+
const previous = await historyList.execute({ window_id: "@previous" }, projection);
|
|
195
|
+
assert.ok(previous.ok);
|
|
196
|
+
assert.match(JSON.stringify(previous), /before retry|finished turn/);
|
|
197
|
+
assert.ok((await historyRead.execute({ seq: 2 }, projection)).ok);
|
|
198
|
+
assert.ok((await historyWindows.execute({}, projection, sessionId)).ok);
|
|
199
|
+
assert.deepEqual(project(rows, "after"), projection, "reload preserves seq");
|
|
200
|
+
assert.deepEqual(project([...prefix, { ...retry, subtype: "future_metadata" }, ...rows.slice(3)], "after"), projection, "metadata does not depend on a subtype whitelist");
|
|
201
|
+
const withBody = project([...prefix, { ...retry, content: "visible system notice" }], "retry");
|
|
202
|
+
assert.match(allItems(withBody).map(eventDocument).join("\n"), /visible system notice/, "a body is read regardless of subtype");
|
|
203
|
+
assert.throws(() => project([...prefix, row("broken", "old", "system", { invalid: true })], "broken"), /invalid Claude transcript message content/);
|
|
204
|
+
});
|
|
179
205
|
test("Claude resolves forward persisted ancestry without renumbering or using later rewritten parent versions", () => {
|
|
180
206
|
const notice = row("notice", "attachment", "system", "hook notice");
|
|
181
207
|
const attachment = { type: "attachment", uuid: "attachment", parentUuid: "u", sessionId };
|