From ce244912bfea86f42d03abb5707e7cf9871841e5 Mon Sep 17 00:00:00 2001 From: awork Date: Fri, 23 Oct 2026 20:07:58 +0800 Subject: [PATCH 1/4] fix(pi-subagents): watchdog timeout no longer misreports as completed; empty-reply diagnostics carry upstream terminal state (#4359) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two defects in the async delegate lifecycle: 1. Status misclassification. When the watchdog killed a non-settled child (code===null, run.timedOut set), partial progress text or stderr alone coerced effectiveExitCode to 0 and the run was marked "completed" — the parent got a success notification with no deliverable. New pure rule classifyDelegateOutcome: "completed" requires a successful effective exit AND positive completion evidence — a real non-null exit code without a watchdog timeout, OR agent_settled observed. The settled exception is kept (delivered output whose process hung in teardown/EOF still completes); with agentSettled=false the rule projects exactly onto the sync ternary, so async/sync semantics are aligned. Behavior change: watchdog kills, external null-code closes, and spawn errors of non-settled runs now report FAILED (artifacts kept for inspection) instead of completed when partial output or stderr exists. 2. Empty-reply diagnostics. Exit-0 empty replies previously got one generic "likely a thinking-only stop" message. The event applier now captures the last assistant message_end terminal state (stopReason/rawStopReason/ errorMessage + text/thinking block census + that turn's usage); the failure body, result-file backfill, and warn log carry an "upstream terminal state:" line separating upstream error/incomplete from completed-but-empty. Unobserved renders as unknown; print mode says unavailable. NO_FINAL_OUTPUT_BODY no longer asserts a cause itself. pi-subagents 0.2.2 -> 0.2.3 (+ root lockfile line). Regression coverage: terminal-state matrix incl. the two misclassified rows, async/sync parity projection, message_end extraction on issue A/B/C shapes, applier last-wins capture, formatter rendering. README: timeout-is-failure semantics plus a nested inner/outer budget-conflict hint. --- package-lock.json | 2 +- pi-subagents/README.md | 1 + pi-subagents/package.json | 2 +- pi-subagents/src/delegate-events.ts | 69 ++++++++++- pi-subagents/src/delegate-tool.ts | 115 +++++++++++++++--- .../tests/delegate-event-applier.test.ts | 54 ++++++++ pi-subagents/tests/delegate-no-output.test.ts | 47 ++++++- pi-subagents/tests/delegate-tool.test.ts | 27 +++- pi-subagents/tests/events.test.ts | 112 +++++++++++++---- 9 files changed, 383 insertions(+), 46 deletions(-) diff --git a/package-lock.json b/package-lock.json index a252c0d3f4..1e4d381e52 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9283,7 +9283,7 @@ }, "pi-subagents": { "name": "billion-context-pi-subagents", - "version": "0.2.2", + "version": "0.2.3", "dev": true, "license": "MIT", "devDependencies": { diff --git a/pi-subagents/README.md b/pi-subagents/README.md index 8cb2036d00..31ae2f7fae 100644 --- a/pi-subagents/README.md +++ b/pi-subagents/README.md @@ -61,6 +61,7 @@ Read-only roles receive a restricted tool allowlist plus ACP context tools so th - **Interactive (TUI) & RPC modes**: `async:true` (default) runs the child in the background; a short completion notification is injected into the chat when it finishes — **unless the model already read the result file after the run finished** (detected via the `read` tool or a bash command referencing the file), in which case the notification is skipped: the model already has the result, so re-injecting it would only waste context. Set `delegate: { notifyIfRead: "always" }` in `acp.json` to restore always-inject. - **Print / JSON modes** (`pi -p`, SDK): `async:true` auto-downgrades to **synchronous** — the result returns as the tool result in the same turn. - **Failures are loud, never silent.** A failed run (nonzero exit, spawn error, watchdog timeout) injects a `FAILED ⚠️` notification carrying a short error excerpt. If a notification cannot be delivered at all, a recovery notice is attached to the next delegate notification or tool result. +- **A watchdog timeout is a failure, not a partial success.** When the watchdog force-kills a run whose agent has not reached its terminal state, the run is reported `FAILED ⚠️` with the partial output kept in the result file for inspection — leftover progress text or stderr does not count as delivery. A run whose agent DID settle but whose process then hangs in teardown/EOF still counts as completed (output was delivered); this matches the sync path, where every timeout is a failure. Budget-conflict hint: a nested sync delegate whose own `timeoutMinutes` exceeds the outer run's remaining budget will be cut off by the outer watchdog first. - **Result delivery**: the full delegate output is saved to `$TMPDIR/acp-delegate/.out`; the tool result and notification carry only the **task title + file path** (no preview) — use `read` for the details. - **Live visibility (TUI)**: async runs show a status widget below the editor and a footer line with cumulative token/cost usage; a running row appends `⚠ no activity Nm` when the child has been silent for over 2 minutes. `/acp-fleet` (or the `ctrl+alt+d` shortcut) opens the interactive fleet inspector: live list + transcript overlay. Disabled automatically in RPC/print/JSON. - **Compact tool blocks (TUI)**: when the host supports custom tool rendering (pi-coding-agent ≥ 0.62; borderless self-shell since 0.67.3), `acp_delegate*` calls render as compact blocks — the call line shows agent + first task line, the result line shows a status icon, exit label, duration and up to 3 preview lines of the run's output (`Ctrl+O` expands to 40). The preview is screen-only: the model-facing text is unchanged (task title + file path). Older hosts ignore the renderers and show the default tool output. diff --git a/pi-subagents/package.json b/pi-subagents/package.json index e9c2f18990..4a7a958a52 100644 --- a/pi-subagents/package.json +++ b/pi-subagents/package.json @@ -1,6 +1,6 @@ { "name": "billion-context-pi-subagents", - "version": "0.2.2", + "version": "0.2.3", "description": "acp_delegate sub-agent tools for the Pi coding agent — split out of billion-context-pi (#612); vendored in-repo (#2384).", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/pi-subagents/src/delegate-events.ts b/pi-subagents/src/delegate-events.ts index dbf4ad54e3..584b8cf5bd 100644 --- a/pi-subagents/src/delegate-events.ts +++ b/pi-subagents/src/delegate-events.ts @@ -22,7 +22,34 @@ export interface Usage { export interface UsageUpdateEvent { kind: "usage-update"; - usage: Usage; + /** Absent when the message carried no usable usage block. */ + usage?: Usage; + /** Present when the message carried terminal-state fields (#4359). */ + terminal?: AssistantTerminalInfo; +} + +/** Terminal state of an assistant message as reported by the upstream provider + * on message_end (#4359): distinguishes an upstream error/incomplete stop from + * a completed-but-empty response. Absent fields stay undefined — the consumer + * renders them as unknown rather than guessing. */ +export interface AssistantTerminalInfo { + stopReason?: string; + rawStopReason?: string; + errorMessage?: string; + textBlocks: number; + thinkingBlocks: number; +} + +/** Merged view of the LAST assistant message_end (terminal state + that + * turn's usage) used for empty-reply diagnostics (#4359). */ +export interface EmptyReplyDiagnostics { + stopReason?: string; + rawStopReason?: string; + errorMessage?: string; + textBlocks: number; + thinkingBlocks: number; + usageIn?: number; + usageOut?: number; } export interface AgentSettledEvent { @@ -33,6 +60,34 @@ function safeNumber(v: unknown): number | undefined { return typeof v === "number" && Number.isFinite(v) ? v : undefined; } +/** Extract the terminal-state fields from an assistant message_end payload + * (#4359). Returns undefined when nothing is known (no stop reason and no + * content array) so callers can distinguish "observed" from "unknown". */ +export function extractAssistantTerminal(msg: Record): AssistantTerminalInfo | undefined { + let textBlocks = 0; + let thinkingBlocks = 0; + let hasContent = false; + if (Array.isArray(msg.content)) { + hasContent = true; + for (const b of msg.content) { + if (!b || typeof b !== "object") continue; + const t = (b as Record).type; + if (t === "text") textBlocks++; + else if (t === "thinking" || t === "reasoning") thinkingBlocks++; + } + } + const stopReason = typeof msg.stopReason === "string" ? msg.stopReason : undefined; + const rawStopReason = typeof msg.rawStopReason === "string" ? msg.rawStopReason : undefined; + const errorMessage = + typeof msg.errorMessage === "string" + ? msg.errorMessage + : typeof msg.error === "string" + ? msg.error + : undefined; + if (!hasContent && stopReason === undefined && rawStopReason === undefined && errorMessage === undefined) return undefined; + return { stopReason, rawStopReason, errorMessage, textBlocks, thinkingBlocks }; +} + export function handleMessageEnd( event: Record ): UsageUpdateEvent | null { @@ -145,7 +200,7 @@ export class ThinkingCollector { if (ev.kind === "thinking-delta") { this.push(ev.delta); } - if (ev.kind === "usage-update") { + if (ev.kind === "usage-update" && ev.usage) { this.usage = ev.usage; } } @@ -240,7 +295,15 @@ export function parseEventLine(line: string): ParsedEvent | null { }; } if (e.type === "message_end") { - return handleMessageEnd(e); + const ev = handleMessageEnd(e); + const msg = e.message as Record | undefined; + const terminal = msg && msg.role === "assistant" ? extractAssistantTerminal(msg) : undefined; + if (!ev && !terminal) return null; + if (ev) { + if (terminal) ev.terminal = terminal; + return ev; + } + return { kind: "usage-update", terminal }; } if (e.type === "agent_settled") { return { kind: "agent-settled" }; diff --git a/pi-subagents/src/delegate-tool.ts b/pi-subagents/src/delegate-tool.ts index 7b5fb99eb3..d868b88472 100644 --- a/pi-subagents/src/delegate-tool.ts +++ b/pi-subagents/src/delegate-tool.ts @@ -18,7 +18,15 @@ import type { import { debug, logError, logInfo, logWarn } from "./log.js"; import { DEFAULT_DELEGATE_POLICY, type DelegatePolicy, type DelegateRoleConfig } from "./config.js"; import { attachWatchdogs } from "./delegate-watchdog.js"; -import { parseEventLine, activityLines, newPortion, ThinkingCollector, type Usage } from "./delegate-events.js"; +import { + parseEventLine, + activityLines, + newPortion, + ThinkingCollector, + type Usage, + type AssistantTerminalInfo, + type EmptyReplyDiagnostics, +} from "./delegate-events.js"; import { isPiHost } from "./host.js"; import { exitLabel, @@ -499,6 +507,9 @@ export interface EventApplier { /** omp fallback: `-p` prints the plain reply as raw stdout; append it * straight through (no event parsing). */ appendRaw(text: string): void; + /** Terminal state of the last assistant message_end (#4359); undefined when + * none was observed (print-mode hosts, kills before any message_end). */ + getEmptyReplyDiagnostics(): EmptyReplyDiagnostics | undefined; } /** Applies parsed delegate JSON-event lines to the live reply/activity files. @@ -517,6 +528,8 @@ export function makeEventApplier( let msgWritten = 0; const lastToolText = new Map(); const thinking = new ThinkingCollector(opts.showThinking); + let lastTerminal: AssistantTerminalInfo | undefined; + let lastUsage: Usage | undefined; const flushThinking = (): void => { const line = thinking.flush(); if (line) writers.activity?.write(line); @@ -525,7 +538,11 @@ export function makeEventApplier( const ev = parseEventLine(line); if (!ev) return; if (ev.kind === "usage-update") { - opts.onUsage?.(ev.usage); + if (ev.usage) { + opts.onUsage?.(ev.usage); + lastUsage = ev.usage; + } + if (ev.terminal) lastTerminal = ev.terminal; return; } if (ev.kind === "thinking-delta") { @@ -581,6 +598,18 @@ export function makeEventApplier( replyText += text; writers.reply.write(text); }, + getEmptyReplyDiagnostics(): EmptyReplyDiagnostics | undefined { + if (!lastTerminal) return undefined; + return { + stopReason: lastTerminal.stopReason, + rawStopReason: lastTerminal.rawStopReason, + errorMessage: lastTerminal.errorMessage, + textBlocks: lastTerminal.textBlocks, + thinkingBlocks: lastTerminal.thinkingBlocks, + usageIn: lastUsage?.input, + usageOut: lastUsage?.output, + }; + }, }; } @@ -1617,6 +1646,7 @@ async function runDelegate( body = output || "(no output)"; } else if (noOutput) { const parts: string[] = [NO_FINAL_OUTPUT_BODY]; + parts.push(formatEmptyReplyDiagnostics(applier.getEmptyReplyDiagnostics()) || NO_FINAL_OUTPUT_DIAG_UNKNOWN); const err = stderrText.trim(); if (err) parts.push(`stderr:\n${err}`); const tail = activityStream ? await readActivityTail(activityFile) : ""; @@ -1657,21 +1687,22 @@ async function runDelegate( if (output === "") { if (noOutput) { const err = stderrText.trim(); - await appendFile(file, `${NO_FINAL_OUTPUT_BODY}\n${err ? `\n${err}` : ""}\n`); + const diag = formatEmptyReplyDiagnostics(applier.getEmptyReplyDiagnostics()) || NO_FINAL_OUTPUT_DIAG_UNKNOWN; + await appendFile(file, `${NO_FINAL_OUTPUT_BODY}\n${diag}${err ? `\n${err}` : ""}\n`); } else { const fallback = stderrText.trim(); await appendFile(file, fallback ? `${fallback}\n` : "(no output)\n"); } } - // EOF-watchdog finalize has no exit code; if the output was delivered, - // treat it as a completed result (the process is killed afterwards). - const effectiveCode = effectiveExitCode(code, output, stderrText); + // Watchdog/EOF finalizes arrive with code === null; classification + // decides completed vs failed from exit state + settle evidence + // (#4359) — see classifyDelegateOutcome. // Atomically flip status + result together: until this point the run // is still "running" to any observer, so a concurrent wait cannot // see "finished but result missing". run.result = { code, file, body }; - run.status = effectiveCode === 0 && !noOutput ? "completed" : "failed"; - if (noOutput) logWarn("delegate", { event: "no-final-output", runId, agent: args.agent, code }); + run.status = classifyDelegateOutcome(code, Boolean(run.timedOut), Boolean(run.agentSettled), output, stderrText); + if (noOutput) logWarn("delegate", { event: "no-final-output", runId, agent: args.agent, code, terminal: formatEmptyReplyDiagnostics(applier.getEmptyReplyDiagnostics()) || "unknown" }); run.finishedAt = Date.now(); // If a wait is parked on this run, wake it — it owns the result now // (and marks consumed so we don't double-deliver by injecting). @@ -1816,7 +1847,7 @@ async function runDelegate( body = result.stderr.trim() || "(no stderr)"; } else if (syncNoOutput) { const err = result.stderr.trim(); - body = err ? `${NO_FINAL_OUTPUT_BODY}\n\nstderr:\n${err}` : NO_FINAL_OUTPUT_BODY; + body = err ? `${NO_FINAL_OUTPUT_BODY}\n${NO_FINAL_OUTPUT_DIAG_PRINT}\n\nstderr:\n${err}` : `${NO_FINAL_OUTPUT_BODY}\n${NO_FINAL_OUTPUT_DIAG_PRINT}`; } else { body = result.stdout; } @@ -2031,23 +2062,49 @@ export function formatSyncResult(agent: string, runId: string, task: string, r: if (r.code === 0 && !r.timedOut && !noOutput) { return formatPayload(header, file, task); } - const body = r.timedOut ? "(timed out)" : r.code === 0 ? NO_FINAL_OUTPUT_BODY : (r.stderr.trim() || "(no stderr)"); + const body = r.timedOut ? "(timed out)" : r.code === 0 ? `${NO_FINAL_OUTPUT_BODY}\n${NO_FINAL_OUTPUT_DIAG_PRINT}` : (r.stderr.trim() || "(no stderr)"); return formatPayload(header, file, task, body); } /** Exit-0 runs that produced no final reply text did not deliver anything - * actionable (#506): a thinking-only stop (thinking budget exhausted) or a - * silent no-op termination must not be announced as a plain completion — the - * parent would trust the notification and never re-dispatch the task. Real - * non-zero exits and watchdog kills (code null / timedOut) are handled by the - * existing failure paths and stay excluded here. */ + * actionable (#506/#4359): a thinking-only stop, a silent no-op termination, + * or an upstream error/incomplete response must not be announced as a plain + * completion — the parent would trust the notification and never re-dispatch + * the task. Real non-zero exits and watchdog kills are handled by the failure + * paths; the appended "upstream terminal state" line separates the causes. */ export function genuineNoOutput(code: number | null, timedOut: boolean, output: string): boolean { return !timedOut && code === 0 && output.trim().length === 0; } export const NO_FINAL_OUTPUT_BODY = - "child exited 0 but produced NO final reply text — likely a thinking-only stop (thinking budget exhausted) " + - "or a no-op termination. Treat the task as NOT delivered: inspect the activity log and session file, then re-dispatch if needed."; + "child exited 0 but produced NO final reply text. Treat the task as NOT delivered: inspect the activity log and session file, then re-dispatch if needed."; + +/** Diagnostic line for empty-reply failures when no terminal state was ever + * observed in the event stream (killed before any message_end, or a host + * without json event mode). #4359 */ +export const NO_FINAL_OUTPUT_DIAG_UNKNOWN = + "upstream terminal state: unknown (no terminal assistant message observed)"; + +/** Same line for sync/print runs, which have no event stream at all. #4359 */ +export const NO_FINAL_OUTPUT_DIAG_PRINT = + "upstream terminal state: unavailable (print mode — no event stream)"; + +/** Render the captured upstream terminal state as the empty-reply diagnostic + * line (#4359): distinguishes an upstream error/incomplete stop from a + * completed-but-empty response. Unobserved fields render as unknown. "" when + * nothing was observed — callers substitute their own unavailable-note. */ +export function formatEmptyReplyDiagnostics(d: EmptyReplyDiagnostics | undefined): string { + if (!d) return ""; + const bits: string[] = []; + bits.push(`stopReason=${d.stopReason ?? "unknown"}`); + if (d.rawStopReason !== undefined) bits.push(`rawStopReason=${d.rawStopReason}`); + if (d.errorMessage !== undefined) bits.push(`errorMessage=${JSON.stringify(d.errorMessage)}`); + bits.push(`text_blocks=${d.textBlocks}`, `thinking_blocks=${d.thinkingBlocks}`); + if (d.usageIn !== undefined || d.usageOut !== undefined) { + bits.push(`last_turn_usage(in=${d.usageIn ?? "?"}, out=${d.usageOut ?? "?"})`); + } + return `upstream terminal state: ${bits.join(", ")}`; +} /** Watchdog/EOF finalize arrives with code === null (the child was killed or * never exited). If a result was delivered (non-empty reply or stderr), the @@ -2056,6 +2113,30 @@ export function effectiveExitCode(code: number | null, output: string, stderr: s return code ?? (output || stderr ? 0 : null); } +/** Terminal status of a finished async delegate run (#4359). "completed" + * requires BOTH a successful effective exit AND positive completion evidence: + * a real (non-null) exit code without a watchdog timeout, OR the agent having + * settled (agent_settled observed). A watchdog kill records timedOut ONLY + * while the agent has not settled (the onKill/onEofGrace callbacks gate on + * agentSettled), so a timed-out non-settled run is a FAILURE regardless of + * partial progress text or stderr — those prove the agent was cut off + * mid-work, they are not a delivered result. Null-code closes without settle + * evidence (external kills, spawn errors) fail too. The settled exception + * keeps its old semantics: delivered output whose process hung in teardown/EOF + * (code null, settled) still counts completed. With agentSettled=false this + * rule projects exactly onto the sync ternary, keeping async/sync aligned. */ +export function classifyDelegateOutcome( + code: number | null, + timedOut: boolean, + agentSettled: boolean, + output: string, + stderr: string, +): "completed" | "failed" { + const noOutput = genuineNoOutput(code, timedOut, output); + const effectiveCode = effectiveExitCode(code, output, stderr); + return effectiveCode === 0 && !noOutput && (agentSettled || (!timedOut && code !== null)) ? "completed" : "failed"; +} + /** Pure read-after-finish predicate: should the completion notification be * suppressed because the model already read the final result file? Only a * read at/after finishedAt counts — a read while the run was still in flight diff --git a/pi-subagents/tests/delegate-event-applier.test.ts b/pi-subagents/tests/delegate-event-applier.test.ts index 6b6c61ac64..8d005ca2fa 100644 --- a/pi-subagents/tests/delegate-event-applier.test.ts +++ b/pi-subagents/tests/delegate-event-applier.test.ts @@ -1,6 +1,7 @@ import { test } from "node:test"; import assert from "node:assert/strict"; import { makeEventApplier, type EventApplier } from "../src/delegate-tool.js"; +import type { Usage } from "../src/delegate-events.js"; class MockWriter { chunks: string[] = []; @@ -147,3 +148,56 @@ test("tool activity goes to activity file, not reply", () => { assert.equal(reply.text, "answer"); assert.match(activity.text, /\[tool\] bash echo hi/); }); + +// #4359: empty-reply diagnostics come from the LAST assistant message_end. +function messageEnd(msg: Record): string { + return `{"type":"message_end","message":${JSON.stringify(msg)}}`; +} + +test("getEmptyReplyDiagnostics: undefined until any assistant message_end arrives", () => { + const { applier } = makeHarness(); + applier.handleEventLine(delta("partial")); + assert.equal(applier.getEmptyReplyDiagnostics(), undefined); +}); + +test("getEmptyReplyDiagnostics: captures terminal state + that turn's usage (issue case A)", () => { + const usages: Usage[] = []; + const reply = new MockWriter(); + const applier = makeEventApplier({ showThinking: false, onUsage: (u) => usages.push(u) }, { reply, activity: null }); + applier.handleEventLine( + messageEnd({ + role: "assistant", + content: [], + stopReason: "error", + rawStopReason: "incomplete", + errorMessage: "Response incomplete without a provider reason", + usage: { input: 1, output: 1, cacheRead: 0, cacheWrite: 0, totalTokens: 2, cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 } }, + }), + ); + assert.deepEqual(applier.getEmptyReplyDiagnostics(), { + stopReason: "error", + rawStopReason: "incomplete", + errorMessage: "Response incomplete without a provider reason", + textBlocks: 0, + thinkingBlocks: 0, + usageIn: 1, + usageOut: 1, + }); + assert.equal(usages.length, 1, "usage callback still fires for terminal+usage events"); +}); + +test("getEmptyReplyDiagnostics: last message_end wins across turns; terminal-only events don't touch usage", () => { + const usages: Usage[] = []; + const reply = new MockWriter(); + const applier = makeEventApplier({ showThinking: false, onUsage: (u) => usages.push(u) }, { reply, activity: null }); + applier.handleEventLine( + messageEnd({ role: "assistant", content: [{ type: "text", text: "step one done" }], stopReason: "stop", usage: { input: 100, output: 10, cacheRead: 0, cacheWrite: 0, totalTokens: 110, cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 } } }), + ); + applier.handleEventLine(messageEnd({ role: "assistant", content: [], stopReason: "stop", rawStopReason: "completed" })); + const d = applier.getEmptyReplyDiagnostics(); + assert.equal(d?.stopReason, "stop"); + assert.equal(d?.rawStopReason, "completed"); + assert.equal(d?.textBlocks, 0, "last turn had no text blocks"); + assert.equal(d?.usageIn, 100, "usage stays from the last turn that carried one"); + assert.equal(usages.length, 1, "terminal-only event must not call onUsage with fake zeros"); +}); diff --git a/pi-subagents/tests/delegate-no-output.test.ts b/pi-subagents/tests/delegate-no-output.test.ts index 32168a1cd7..e754149c4c 100644 --- a/pi-subagents/tests/delegate-no-output.test.ts +++ b/pi-subagents/tests/delegate-no-output.test.ts @@ -1,6 +1,6 @@ import assert from "node:assert/strict"; import { test } from "node:test"; -import { formatSyncResult, genuineNoOutput } from "../src/delegate-tool.js"; +import { classifyDelegateOutcome, formatSyncResult, genuineNoOutput } from "../src/delegate-tool.js"; function result(over: Partial<{ code: number | null; signal: NodeJS.Signals | null; stdout: string; stderr: string; timedOut: boolean }>) { return { code: 0, signal: null as NodeJS.Signals | null, stdout: "", stderr: "", timedOut: false, ...over }; @@ -41,3 +41,48 @@ test("formatSyncResult: watchdog timeout label is untouched by the no-output rul assert.match(out, /timed out/); assert.doesNotMatch(out, /NO final reply text/); }); + +// #4359 regression matrix: async run status classification. The two rows the +// old code got wrong (watchdog kill + partial text / stderr → "completed") are +// marked. Sync parity: with agentSettled=false the async rule must project +// exactly onto the sync ternary (timedOut → failed). +const MATRIX: Array<{ + name: string; + code: number | null; + timedOut: boolean; + agentSettled: boolean; + output: string; + stderr: string; + expected: "completed" | "failed"; +}> = [ + { name: "normal success (settled)", code: 0, timedOut: false, agentSettled: true, output: "the answer", stderr: "", expected: "completed" }, + { name: "normal success (no settle event, e.g. omp plain mode)", code: 0, timedOut: false, agentSettled: false, output: "the answer", stderr: "", expected: "completed" }, + { name: "exit-0 empty output (settled) stays loud failure", code: 0, timedOut: false, agentSettled: true, output: "", stderr: "", expected: "failed" }, + { name: "exit-0 empty output (non-settled) stays loud failure", code: 0, timedOut: false, agentSettled: false, output: "", stderr: "", expected: "failed" }, + { name: "REGRESSION: timeout with only partial progress text was 'completed'", code: null, timedOut: true, agentSettled: false, output: "I will inspect the files first…", stderr: "", expected: "failed" }, + { name: "REGRESSION: timeout with only stderr was 'completed'", code: null, timedOut: true, agentSettled: false, output: "", stderr: "warning: something went sideways", expected: "failed" }, + { name: "timeout with no output at all (unchanged)", code: null, timedOut: true, agentSettled: false, output: "", stderr: "", expected: "failed" }, + { name: "settled then teardown/EOF hang keeps the success exception", code: null, timedOut: false, agentSettled: true, output: "full report delivered", stderr: "", expected: "completed" }, + { name: "race: kill recorded first, late agent_settled still counts as settled", code: null, timedOut: true, agentSettled: true, output: "partial but delivered", stderr: "", expected: "completed" }, + { name: "watchdog kill, child still exits 0 gracefully — not a success", code: 0, timedOut: true, agentSettled: false, output: "partial", stderr: "", expected: "failed" }, + { name: "nonzero exit with partial output stays failed", code: 1, timedOut: false, agentSettled: false, output: "partial", stderr: "boom", expected: "failed" }, + { name: "external kill without settle evidence is not a delivery", code: null, timedOut: false, agentSettled: false, output: "partial", stderr: "", expected: "failed" }, + { name: "spawn error (code null, stderr only) stays failed", code: null, timedOut: false, agentSettled: false, output: "", stderr: "spawn ENOENT", expected: "failed" }, +]; + +test("classifyDelegateOutcome: full terminal-state matrix (#4359)", () => { + for (const row of MATRIX) { + assert.equal( + classifyDelegateOutcome(row.code, row.timedOut, row.agentSettled, row.output, row.stderr), + row.expected, + row.name, + ); + } +}); + +test("classifyDelegateOutcome: non-settled runs match the sync ternary exactly (#4359 async/sync parity)", () => { + for (const row of MATRIX.filter((r) => !r.agentSettled)) { + const syncStatus = row.timedOut ? "failed" : row.code === 0 && !genuineNoOutput(row.code, row.timedOut, row.output) ? "completed" : "failed"; + assert.equal(classifyDelegateOutcome(row.code, row.timedOut, false, row.output, row.stderr), syncStatus, row.name); + } +}); diff --git a/pi-subagents/tests/delegate-tool.test.ts b/pi-subagents/tests/delegate-tool.test.ts index 3b75b7d2a3..08f73be36f 100644 --- a/pi-subagents/tests/delegate-tool.test.ts +++ b/pi-subagents/tests/delegate-tool.test.ts @@ -4,7 +4,7 @@ import { existsSync } from "node:fs"; import { mkdir, mkdtemp, readFile, writeFile, rm } from "node:fs/promises"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { buildChildArgs, delegateSpawnOptions, injectedWaitMessage, buildWaitResult, buildCancelResult, getDelegateUsage, resetDelegateUsage, injectResult, effectiveExitCode, formatRunResult, resolveWaitTimeoutMs, findUndeliveredRuns, undeliveredNoticeFrom, buildRecoveryNotice, makeDelegateTool, exitLabel, cancelledFileNote, delegateStdinText, readActivityTail, scheduleRunNotification, flushDelegateNotifications, formatBatchRunSection, setDelegatePolicy, delegateChildEnv, asyncWatchdogDescription, ConcurrencyGate, setDelegateDefaults, resetDelegateDefaults, isValidThinkingLevel, resolvePerCallTimeoutMs, addDelegateUsage, emitInlineUsageNote, makeDelegateWaitTool, makeDelegateCancelTool, runningRunsSnapshot } from "../src/delegate-tool.js"; +import { buildChildArgs, delegateSpawnOptions, injectedWaitMessage, buildWaitResult, buildCancelResult, getDelegateUsage, resetDelegateUsage, injectResult, effectiveExitCode, formatRunResult, resolveWaitTimeoutMs, findUndeliveredRuns, undeliveredNoticeFrom, buildRecoveryNotice, makeDelegateTool, exitLabel, cancelledFileNote, delegateStdinText, readActivityTail, scheduleRunNotification, flushDelegateNotifications, formatBatchRunSection, setDelegatePolicy, delegateChildEnv, asyncWatchdogDescription, ConcurrencyGate, setDelegateDefaults, resetDelegateDefaults, isValidThinkingLevel, resolvePerCallTimeoutMs, addDelegateUsage, emitInlineUsageNote, makeDelegateWaitTool, makeDelegateCancelTool, runningRunsSnapshot, formatEmptyReplyDiagnostics, NO_FINAL_OUTPUT_BODY, NO_FINAL_OUTPUT_DIAG_UNKNOWN, NO_FINAL_OUTPUT_DIAG_PRINT } from "../src/delegate-tool.js"; import { DEFAULT_DELEGATE_POLICY } from "../src/config.js"; import type { ExtensionContext } from "@earendil-works/pi-coding-agent"; @@ -585,6 +585,31 @@ test("effectiveExitCode: null code with delivered output counts as completed", ( assert.equal(effectiveExitCode(1, "partial", ""), 1, "real non-zero code untouched"); }); +// ─── #4359: empty-reply diagnostics separate upstream error/incomplete from +// completed-but-empty; unobserved fields render as unknown ────────────────── + +test("formatEmptyReplyDiagnostics: issue case A (upstream error/incomplete)", () => { + const line = formatEmptyReplyDiagnostics({ stopReason: "error", rawStopReason: "incomplete", errorMessage: "Response incomplete without a provider reason", textBlocks: 0, thinkingBlocks: 0, usageIn: 1, usageOut: 1 }); + assert.equal(line, 'upstream terminal state: stopReason=error, rawStopReason=incomplete, errorMessage="Response incomplete without a provider reason", text_blocks=0, thinking_blocks=0, last_turn_usage(in=1, out=1)'); +}); + +test("formatEmptyReplyDiagnostics: issue case B/C (completed-but-empty)", () => { + const line = formatEmptyReplyDiagnostics({ stopReason: "stop", rawStopReason: "completed", textBlocks: 0, thinkingBlocks: 0, usageIn: 18928, usageOut: 0 }); + assert.equal(line, "upstream terminal state: stopReason=stop, rawStopReason=completed, text_blocks=0, thinking_blocks=0, last_turn_usage(in=18928, out=0)"); +}); + +test("formatEmptyReplyDiagnostics: missing stopReason renders unknown; no usage omits the usage bit", () => { + const line = formatEmptyReplyDiagnostics({ textBlocks: 0, thinkingBlocks: 2 }); + assert.equal(line, "upstream terminal state: stopReason=unknown, text_blocks=0, thinking_blocks=2"); +}); + +test("formatEmptyReplyDiagnostics: nothing observed → caller substitutes its own note", () => { + assert.equal(formatEmptyReplyDiagnostics(undefined), ""); + assert.match(NO_FINAL_OUTPUT_DIAG_UNKNOWN, /unknown/); + assert.match(NO_FINAL_OUTPUT_DIAG_PRINT, /unavailable/); + assert.ok(!NO_FINAL_OUTPUT_BODY.includes("likely"), "base body must not assert a cause — the diagnostic line carries it"); +}); + test("injectResult null code + completed status: completed header, exit ?, no missing-result warning", () => { const sent: string[] = []; const ok = injectResult(capturePi(sent) as any, "reviewer", "del_x", "review auth", "completed", null, "/tmp/del_x.out", "output ended but process did not exit", undefined, "separate", false); diff --git a/pi-subagents/tests/events.test.ts b/pi-subagents/tests/events.test.ts index b95f77b31e..b5592fdcb9 100644 --- a/pi-subagents/tests/events.test.ts +++ b/pi-subagents/tests/events.test.ts @@ -1,6 +1,6 @@ import { test } from "node:test"; import assert from "node:assert/strict"; -import { parseEventLine, activityLines, extractContentText, newPortion, ThinkingCollector } from "../src/delegate-events.js"; +import { parseEventLine, activityLines, extractContentText, newPortion, ThinkingCollector, extractAssistantTerminal } from "../src/delegate-events.js"; test("parses text_delta and text_end from message_update", () => { const delta = parseEventLine('{"type":"message_update","assistantMessageEvent":{"type":"text_delta","contentIndex":0,"delta":"Hello "}}'); @@ -129,20 +129,21 @@ test("activityLines formats retry events", () => { }); test("parses message_end with usage data (returns UsageUpdateEvent)", () => { - const ev = parseEventLine('{"type":"message_end","message":{"role":"assistant","usage":{"input":150,"output":80,"cacheRead":0,"cacheWrite":0,"totalTokens":230,"cost":{"input":0.0015,"output":0.0008,"cacheRead":0,"cacheWrite":0,"total":0.0023}}}}') as { kind: "usage-update"; usage: Record }; - assert.equal(ev.kind, "usage-update"); - assert.equal(ev.usage.input, 150); - assert.equal(ev.usage.output, 80); - assert.equal(ev.usage.cacheRead, 0); - assert.equal(ev.usage.cacheWrite, 0); - assert.equal(ev.usage.totalTokens, 230); - assert.deepEqual(ev.usage.cost, { input: 0.0015, output: 0.0008, cacheRead: 0, cacheWrite: 0, total: 0.0023 }); + const ev = parseEventLine('{"type":"message_end","message":{"role":"assistant","usage":{"input":150,"output":80,"cacheRead":0,"cacheWrite":0,"totalTokens":230,"cost":{"input":0.0015,"output":0.0008,"cacheRead":0,"cacheWrite":0,"total":0.0023}}}}'); + assert.ok(ev && ev.kind === "usage-update"); + assert.equal(ev.usage?.input, 150); + assert.equal(ev.usage?.output, 80); + assert.equal(ev.usage?.cacheRead, 0); + assert.equal(ev.usage?.cacheWrite, 0); + assert.equal(ev.usage?.totalTokens, 230); + assert.deepEqual(ev.usage?.cost, { input: 0.0015, output: 0.0008, cacheRead: 0, cacheWrite: 0, total: 0.0023 }); }); test("message_end with optional fields returns UsageUpdateEvent with undefined", () => { - const ev = parseEventLine('{"type":"message_end","message":{"role":"assistant","usage":{"input":150,"output":80,"cacheRead":0,"cacheWrite":0,"totalTokens":230,"cost":{"input":0.0015,"output":0.0008,"cacheRead":0,"cacheWrite":0,"total":0.0023}}}}') as { kind: "usage-update"; usage: Record }; - assert.equal(ev.usage.cacheWrite1h, undefined); - assert.equal(ev.usage.reasoning, undefined); + const ev = parseEventLine('{"type":"message_end","message":{"role":"assistant","usage":{"input":150,"output":80,"cacheRead":0,"cacheWrite":0,"totalTokens":230,"cost":{"input":0.0015,"output":0.0008,"cacheRead":0,"cacheWrite":0,"total":0.0023}}}}'); + assert.ok(ev && ev.kind === "usage-update"); + assert.equal(ev.usage?.cacheWrite1h, undefined); + assert.equal(ev.usage?.reasoning, undefined); }); test("message_end with no usage object returns null", () => { @@ -151,8 +152,9 @@ test("message_end with no usage object returns null", () => { }); test("message_end with no cost object defaults cost to zeros", () => { - const ev = parseEventLine('{"type":"message_end","message":{"role":"assistant","usage":{"input":150,"output":80,"cacheRead":0,"cacheWrite":0,"totalTokens":230}}}') as { kind: "usage-update"; usage: Record }; - assert.deepEqual(ev.usage.cost, { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 }); + const ev = parseEventLine('{"type":"message_end","message":{"role":"assistant","usage":{"input":150,"output":80,"cacheRead":0,"cacheWrite":0,"totalTokens":230}}}'); + assert.ok(ev && ev.kind === "usage-update"); + assert.deepEqual(ev.usage?.cost, { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 }); }); test("message_end with non-finite number returns null when all fields invalid", () => { @@ -220,12 +222,78 @@ test("parseEventLine tolerates trailing CR (CRLF line endings)", () => { }); test("message_end with partial usage fills missing numeric fields with 0", () => { - const ev = parseEventLine('{"type":"message_end","message":{"role":"assistant","usage":{"input":150,"totalTokens":150}}}') as { kind: "usage-update"; usage: Record }; - assert.equal(ev.kind, "usage-update"); - assert.equal(ev.usage.input, 150); - assert.equal(ev.usage.output, 0); - assert.equal(ev.usage.cacheRead, 0); - assert.equal(ev.usage.cacheWrite, 0); - assert.equal(ev.usage.totalTokens, 150); - assert.deepEqual(ev.usage.cost, { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 }); + const ev = parseEventLine('{"type":"message_end","message":{"role":"assistant","usage":{"input":150,"totalTokens":150}}}'); + assert.equal(ev?.kind, "usage-update"); + assert.equal(ev?.usage?.input, 150); + assert.equal(ev?.usage?.output, 0); + assert.equal(ev?.usage?.cacheRead, 0); + assert.equal(ev?.usage?.cacheWrite, 0); + assert.equal(ev?.usage?.totalTokens, 150); + assert.deepEqual(ev?.usage?.cost, { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 }); +}); + +// #4359: terminal-state extraction for empty-reply diagnostics. The A/B/C +// shapes below mirror the real session records from the issue. +test("extractAssistantTerminal: upstream error/incomplete stop (issue case A)", () => { + const t = extractAssistantTerminal({ + role: "assistant", + content: [], + stopReason: "error", + rawStopReason: "incomplete", + errorMessage: "Response incomplete without a provider reason", + }); + assert.deepEqual(t, { + stopReason: "error", + rawStopReason: "incomplete", + errorMessage: "Response incomplete without a provider reason", + textBlocks: 0, + thinkingBlocks: 0, + }); +}); + +test("extractAssistantTerminal: completed-but-empty response (issue cases B/C)", () => { + const t = extractAssistantTerminal({ role: "assistant", content: [], stopReason: "stop", rawStopReason: "completed" }); + assert.deepEqual(t, { stopReason: "stop", rawStopReason: "completed", errorMessage: undefined, textBlocks: 0, thinkingBlocks: 0 }); +}); + +test("extractAssistantTerminal: counts text/thinking/reasoning blocks, passes through error string field", () => { + const t = extractAssistantTerminal({ + role: "assistant", + content: [{ type: "text", text: "hi" }, { type: "thinking", thinking: "hmm" }, { type: "reasoning", summary: [] }, { type: "toolCall", id: "c1" }], + stopReason: "stop", + error: "provider said no", + }); + assert.equal(t?.textBlocks, 1); + assert.equal(t?.thinkingBlocks, 2, "thinking and reasoning both count as thinking-family"); + assert.equal(t?.errorMessage, "provider said no", "string `error` field is the errorMessage fallback"); +}); + +test("extractAssistantTerminal: nothing known returns undefined (renders as unknown downstream)", () => { + assert.equal(extractAssistantTerminal({ role: "assistant" }), undefined); + assert.equal(extractAssistantTerminal({}), undefined); +}); + +test("parseEventLine: message_end carries terminal state alongside usage", () => { + const ev = parseEventLine( + '{"type":"message_end","message":{"role":"assistant","content":[],"stopReason":"error","rawStopReason":"incomplete","errorMessage":"boom","usage":{"input":18928,"output":0,"cacheRead":0,"cacheWrite":0,"totalTokens":18928,"cost":{"input":0,"output":0,"cacheRead":0,"cacheWrite":0,"total":0}}}}', + ); + assert.ok(ev && ev.kind === "usage-update"); + assert.equal(ev.usage?.input, 18928); + assert.equal(ev.terminal?.stopReason, "error"); + assert.equal(ev.terminal?.textBlocks, 0); +}); + +test("parseEventLine: message_end with terminal state but NO usage still yields the event", () => { + const ev = parseEventLine( + '{"type":"message_end","message":{"role":"assistant","content":[],"stopReason":"error","rawStopReason":"incomplete"}}', + ); + assert.deepEqual(ev, { + kind: "usage-update", + terminal: { stopReason: "error", rawStopReason: "incomplete", errorMessage: undefined, textBlocks: 0, thinkingBlocks: 0 }, + }); +}); + +test("parseEventLine: non-assistant message_end with stop fields is skipped", () => { + const ev = parseEventLine('{"type":"message_end","message":{"role":"user","content":[],"stopReason":"error"}}'); + assert.equal(ev, null); }); From 0572473028534302bf31450d32e633fc817f27ce Mon Sep 17 00:00:00 2001 From: awork Date: Fri, 23 Oct 2026 20:17:10 +0800 Subject: [PATCH 2/4] test(pi-subagents): repair pre-existing strict-tsc breaks in delegate-tool.test.ts (found while working #4359) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Six latent type errors the test file carried before this PR (test files are not strict-typechecked by CI, so they stayed invisible): - injectedWaitMessage's run parameter typed result?: { file: string } while the runtime reads run.result?.file truthy-safely and the test named "tolerates a missing file" deliberately passes result: {} — loosen to result?: { file?: string } (type-only, backward compatible). - Four local run literals in the buildWaitResult/buildCancelResult usage tests lacked usageReported, which the tests then assert flips to true — seed usageReported: false. - The wait-timeout integration test called cancelTool.execute with 2 args against the 5-arg Tool.execute signature — pass the same trailing (undefined, undefined, ctx) its sibling wait call passes. Strict tsc on the file now exits 0; all 108 delegate-tool tests pass. --- pi-subagents/src/delegate-tool.ts | 2 +- pi-subagents/tests/delegate-tool.test.ts | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pi-subagents/src/delegate-tool.ts b/pi-subagents/src/delegate-tool.ts index d868b88472..585c717421 100644 --- a/pi-subagents/src/delegate-tool.ts +++ b/pi-subagents/src/delegate-tool.ts @@ -1218,7 +1218,7 @@ function withUndeliveredNotice(result: AgentToolResult): AgentToolResult { test("buildWaitResult returns usage in merged mode", () => { resetDelegateUsage(); - const run = { runId: "del_x", agent: "reviewer", task: "test", usage: { input: 150, output: 80, cacheRead: 0, cacheWrite: 0, totalTokens: 230, cost: { input: 0.0015, output: 0.0008, cacheRead: 0, cacheWrite: 0, total: 0.0023 } } }; + const run = { runId: "del_x", agent: "reviewer", task: "test", usage: { input: 150, output: 80, cacheRead: 0, cacheWrite: 0, totalTokens: 230, cost: { input: 0.0015, output: 0.0008, cacheRead: 0, cacheWrite: 0, total: 0.0023 } }, usageReported: false }; const result = buildWaitResult(run as any, "content", "merged"); assert.ok(result.usage, "usage is present in merged mode"); assert.equal(result.usage!.input, 150); @@ -402,7 +402,7 @@ test("buildWaitResult returns usage in merged mode", () => { test("buildWaitResult accumulates usage in separate mode (default)", () => { resetDelegateUsage(); - const run = { runId: "del_x", agent: "reviewer", task: "test", usage: { input: 150, output: 80, cacheRead: 0, cacheWrite: 0, totalTokens: 230, cost: { input: 0.0015, output: 0.0008, cacheRead: 0, cacheWrite: 0, total: 0.0023 } } }; + const run = { runId: "del_x", agent: "reviewer", task: "test", usage: { input: 150, output: 80, cacheRead: 0, cacheWrite: 0, totalTokens: 230, cost: { input: 0.0015, output: 0.0008, cacheRead: 0, cacheWrite: 0, total: 0.0023 } }, usageReported: false }; const result = buildWaitResult(run as any, "content"); assert.equal(result.usage, undefined, "usage not returned in separate mode"); assert.equal(run.usageReported, true, "sets usageReported"); @@ -430,7 +430,7 @@ test("buildWaitResult returns plain result when no usage", () => { test("buildCancelResult returns usage in merged mode", () => { resetDelegateUsage(); - const run = { runId: "del_x", agent: "reviewer", task: "test", usage: { input: 150, output: 80, cacheRead: 0, cacheWrite: 0, totalTokens: 230, cost: { input: 0.0015, output: 0.0008, cacheRead: 0, cacheWrite: 0, total: 0.0023 } } }; + const run = { runId: "del_x", agent: "reviewer", task: "test", usage: { input: 150, output: 80, cacheRead: 0, cacheWrite: 0, totalTokens: 230, cost: { input: 0.0015, output: 0.0008, cacheRead: 0, cacheWrite: 0, total: 0.0023 } }, usageReported: false }; const result = buildCancelResult(run as any, "content", "merged"); assert.ok(result.usage, "usage is present in merged mode"); assert.equal(result.usage!.input, 150); @@ -439,7 +439,7 @@ test("buildCancelResult returns usage in merged mode", () => { test("buildCancelResult accumulates usage in separate mode", () => { resetDelegateUsage(); - const run = { runId: "del_x", agent: "reviewer", task: "test", usage: { input: 150, output: 80, cacheRead: 0, cacheWrite: 0, totalTokens: 230, cost: { input: 0.0015, output: 0.0008, cacheRead: 0, cacheWrite: 0, total: 0.0023 } } }; + const run = { runId: "del_x", agent: "reviewer", task: "test", usage: { input: 150, output: 80, cacheRead: 0, cacheWrite: 0, totalTokens: 230, cost: { input: 0.0015, output: 0.0008, cacheRead: 0, cacheWrite: 0, total: 0.0023 } }, usageReported: false }; const result = buildCancelResult(run as any, "content"); assert.equal(result.usage, undefined, "usage not returned in separate mode"); assert.equal(run.usageReported, true, "sets usageReported"); @@ -1333,7 +1333,7 @@ test("acp_delegate_wait timeout on a running run reports neutral text and leaves assert.ok(!("usage" in waitRes), "timeout settles no usage"); assert.ok(runningRunsSnapshot().some((r) => r.runId === runId), "the timeout did not settle the run"); // The surviving run is still cancellable; cancel reaps the sleeper child. - await cancelTool.execute("tc-wait-to-c", { runId: runId! }); + await cancelTool.execute("tc-wait-to-c", { runId: runId! }, undefined, undefined, ctx); const reapDeadline = Date.now() + 5000; while (runningRunsSnapshot().some((r) => r.runId === runId) && Date.now() < reapDeadline) { await new Promise((r) => setTimeout(r, 25)); From c6369fb6a195fbd1e8794c911adaff87d4dba0f0 Mon Sep 17 00:00:00 2001 From: ework-agent Date: Sat, 14 Nov 2026 04:35:44 +0800 Subject: [PATCH 3/4] fix(tests): pin pure-sqlite selection in notice-registry suite MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The suite baseline preload (preload-storage-baseline.mjs) pins BILI_STORAGE_UNIFIED="legacy" for the broad corpus. After #6480 flipped the storage default to pure-sqlite, the notice-registry suite's visibleNotices assertions expect the pure-sqlite default notice, which is gated on unifiedSelectionIsSqlite (unified "sqlite" or absent) — the preload's "legacy" made the notice silent, so the suite was born-red on master. Pin the selection explicitly (#4011 lesson: a test that depends on the production default passes locally but fails in CI). --- tests/notice-registry.test.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/notice-registry.test.ts b/tests/notice-registry.test.ts index 6d3b60edb4..b3b0d0e8a4 100644 --- a/tests/notice-registry.test.ts +++ b/tests/notice-registry.test.ts @@ -17,6 +17,11 @@ const cfgPath = path.join(fs.mkdtempSync(path.join(os.tmpdir(), "notice-reg-cfg- process.env.DSH_HOME = fs.mkdtempSync(path.join(os.tmpdir(), "notice-reg-dsh-")); process.env.XDG_STATE_HOME = stateDir; process.env.BILI_CONFIG_FILE = cfgPath; +// #4011 lesson: this suite asserts the pure-sqlite default notice is visible, +// which requires the pure-sqlite SELECTION (unified "sqlite" or absent — the +// gate is unifiedSelectionIsSqlite, not the resolved mode). The suite baseline +// preload pins "legacy" for the broad corpus, so pin the selection explicitly. +process.env.BILI_STORAGE_UNIFIED = "sqlite"; const { NOTICES, visibleNotices, SQLITE_DEFAULT_NOTICE_ID } = await import("../src/notices.ts"); const { IOT_INCOMPAT_NOTICE_ID, PCK_NOTICE_ID, WM_FASTPATH_INTRO_ID, dismissUpgradeNotice } = await import("../src/pck-notice.ts"); From dacaaf60eee8ded7871f9d92151abbdbb5e7583c Mon Sep 17 00:00:00 2001 From: ci-check Date: Sat, 14 Nov 2026 07:11:16 +0800 Subject: [PATCH 4/4] chore(pi-subagents): re-bump 0.2.3 -> 0.2.4 after base sync (#4411) master independently consumed 0.2.3 in #5637 (stand acp_delegate down for user-scope installs); the PR's original 0.2.2 -> 0.2.3 bump now nets to zero against master, which would trip pi-subagents-guard (src changed, no version change in the diff). Take the next patch version instead. Also syncs the component's own package-lock.json, which the original bump left stale at 0.2.2 (two-line surgical edit; a full npm regen would churn 44 lines of npm-version libc-field drift). --- package-lock.json | 2 +- pi-subagents/package-lock.json | 4 ++-- pi-subagents/package.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index e2ff6fb483..374543cafc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9283,7 +9283,7 @@ }, "pi-subagents": { "name": "billion-context-pi-subagents", - "version": "0.2.3", + "version": "0.2.4", "dev": true, "license": "MIT", "devDependencies": { diff --git a/pi-subagents/package-lock.json b/pi-subagents/package-lock.json index f8d8f21ea5..282521428a 100644 --- a/pi-subagents/package-lock.json +++ b/pi-subagents/package-lock.json @@ -1,12 +1,12 @@ { "name": "billion-context-pi-subagents", - "version": "0.2.2", + "version": "0.2.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "billion-context-pi-subagents", - "version": "0.2.2", + "version": "0.2.4", "license": "MIT", "devDependencies": { "@earendil-works/pi-coding-agent": "0.83.0", diff --git a/pi-subagents/package.json b/pi-subagents/package.json index 4a7a958a52..5e764e3c19 100644 --- a/pi-subagents/package.json +++ b/pi-subagents/package.json @@ -1,6 +1,6 @@ { "name": "billion-context-pi-subagents", - "version": "0.2.3", + "version": "0.2.4", "description": "acp_delegate sub-agent tools for the Pi coding agent — split out of billion-context-pi (#612); vendored in-repo (#2384).", "main": "dist/index.js", "types": "dist/index.d.ts",