Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions _docs/verification/asama-8539-m2/r28-live-proof.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"sourceBase": "c3a5e3ecdeebed98264c2d47a10b6e07176916b8",
"pluginSource": "bd84d414",
"provider": "codex/gpt-6-astra",
"saved": {
"summaryId": "77a5d36e-98c2-477e-9c3c-7f3e0a64121f",
"revision": 1,
"sourceAgentId": "f3670b94-fc76-48a4-ac5c-1008e45fb9d7",
"sourceTitle": "R28 real persisted summary proof",
"cutoff": "2026-10-28T20:35:01.889Z",
"savedAt": "2026-10-28T20:35:07.842Z",
"sections": {
"task": "R28 summary: preserve exact source session UUID f3670b94-fc76-48a4-ac5c-1008e45fb9d7 and four sections.",
"decisions": "Supported providers only.",
"currentState": "Ready for review.",
"nextStep": "Installed readback."
},
"text": "Task\nR28 summary: preserve exact source session UUID f3670b94-fc76-48a4-ac5c-1008e45fb9d7 and four sections.\n\nDecisions\nSupported providers only.\n\nCurrent state\nReady for review.\n\nNext step\nInstalled readback."
},
"rereadEqual": true,
"restartedLatestEqual": true,
"clipboardTransport": "macOS pbcopy/pbpaste; original plain text restored",
"clipboardSha256": "92dd29e9b4a29c772b998490ac72d82e6366096e9513fa4ea7ff0af8ce872a14",
"limits": [
"In-process API adapter, no daemon RPC or installed UI exercised",
"Native clipboard transport verified; SummarySheet copyText was not exercised",
"Idle source receives foreground turn; running source refused by AgentManager"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# R28 live provider composition and persisted-summary proof (ASMA-8539)

Candidate only: no MAIN, install, merge, daemon restart or full suite. Installed UI acceptance remains with the merge/readback owner.

## Source and behavior

Started clean and detached at `c3a5e3ecdeebed98264c2d47a10b6e07176916b8`; `git merge-base --is-ancestor b3c7a037 HEAD` succeeded. The inherited live composition is preserved. This candidate adds exact UUID request binding, rejects a resolver returning another session, checks provider eligibility before cache reuse, and propagates timeline-read failures instead of silently generating from an empty excerpt.

Production composition supports Codex and OpenCode. Only Codex was exercised against a real provider here. Claude and other unsupported providers explicitly refuse; mock/test remain dev-only. A cache hit does not bypass provider refusal.

Generation calls `AgentManager.runAgent` on the source session. An idle source receives a foreground turn that changes its history and activity timestamps. A running source is refused by the manager's active-run guard. This is not a passive concurrent read. The saved cutoff describes the source before the summary turn; reopening the UI can observe a later source cutoff because generating the summary itself adds activity.

## Real proof, 2026-10-28

[Machine-readable evidence](r28-live-proof.json) records the real Codex result, exact source UUID, summary UUID/revision/cutoff and clipboard text hash. The plugin service was loaded from an immutable archive of `bd84d414` into this checkout's ignored `.dev/r28-plugin-source`; no shared plugin source was modified.

The local harness `.dev/r28-plugin-proof.mts` used the real Codex app-server client, real AgentManager, production-mode CompactSummaryProviderRunner and file-backed generator. An in-process API adapter connected the actual pinned `createSessionSummaryService` to that generator and the manager's source lookup; no daemon or successful fake provider was started.

It verified:

- Saved plugin revision `77a5d36e-98c2-477e-9c3c-7f3e0a64121f` r1 belongs to source `f3670b94-fc76-48a4-ac5c-1008e45fb9d7`.
- `readPinnedSummary` and a newly constructed service's `latest` return the identical saved object.
- macOS `pbcopy` followed by `pbpaste` returns exactly the saved text; SHA-256 `92dd29e9b4a29c772b998490ac72d82e6366096e9513fa4ea7ff0af8ce872a14`. The prior plain-text clipboard was restored.

The retained local store is `.dev/r28-live-proof/plugin-state/kontor/session-summaries-v1`, with host generation under `.dev/r28-live-proof/kontor/compact-summary-generation-v1`. These are proof stores, not installed runtime stores. Do not copy them into production as evidence of installed behavior.

## Verification

- Focused generator/provider/binding tests: 15 passed across the three changed unit suites.
- Real test in `codex-app-server-agent.real.e2e.test.ts`, selected with `-t 'R28 generates'`: real Codex generation, running-source refusal without interrupting its original turn, four nonempty sections, reopened-store equality and another-session isolation passed. The other two tests in that file were unselected.
- `npm run build:server`: passed after building workspace dependencies.
- `npm run typecheck`: passed after applying repository dependency patches following `npm ci --ignore-scripts`.
- Changed-file npm lint: passed. Repository lint reports three errors in unchanged `provider-runtime.ts`, `host-handover/bootstrap-012-compat.ts`, and `host-handover/adoption.ts`.

## Installed readback handoff

This proof does not exercise daemon RPC transport, the installed plugin, or SummarySheet's `copyText` call. After the merge owner composes the candidate with the accepted plugin and installs it, the readback owner must select an idle supported-provider session, invoke Summarize & copy, record source UUID and saved pin/cutoff, read that pin after reopening, and compare the actual clipboard text with the stored revision. Verify an unsupported provider refusal and a running-source refusal without a success banner or replacement of the saved revision. If clipboard access fails, the saved revision must remain visible with Copy again.

Provider authentication was available; no secure input is required. OpenCode remains source-composed and adapter-tested, without a real-provider success claim in this candidate.
163 changes: 163 additions & 0 deletions packages/client/src/agents-generate-compact-summary.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
import { afterEach, expect, test, vi } from "vitest";
import { createPaseoClient } from "./index.js";
import type { PaseoClient } from "./index.js";

type FakeWebSocketHandler = (...args: unknown[]) => void;

class FakeWebSocket {
static instances: FakeWebSocket[] = [];

readyState = 1;
sent: Array<string | ArrayBuffer | Uint8Array> = [];
onopen: FakeWebSocketHandler | null = null;
onmessage: FakeWebSocketHandler | null = null;
onclose: FakeWebSocketHandler | null = null;
onerror: FakeWebSocketHandler | null = null;

constructor(
readonly url: string,
readonly protocols?: string | string[],
) {
FakeWebSocket.instances.push(this);
}

send(data: string | ArrayBuffer | Uint8Array): void {
this.sent.push(data);
}

close(): void {
this.readyState = 3;
}

open(): void {
this.onopen?.();
}

message(data: string): void {
this.onmessage?.({ data });
}
}

afterEach(() => {
vi.unstubAllGlobals();
FakeWebSocket.instances.length = 0;
});

function sessionMessage(message: object): string {
return JSON.stringify({
type: "session",
message,
});
}

function parseSentSessionMessage(data: string | ArrayBuffer | Uint8Array | undefined): {
type: string;
requestId?: string;
agentId?: string;
} {
if (typeof data !== "string") {
throw new Error("Expected string WebSocket frame");
}
return JSON.parse(data).message;
}

async function connectClient(features: Record<string, boolean>): Promise<{
client: PaseoClient;
ws: FakeWebSocket;
}> {
const client = createPaseoClient({
url: "ws://daemon.test",
webSocketFactory: (url) => new FakeWebSocket(url),
reconnect: { enabled: false },
});

const connectPromise = client.connect();
const ws = FakeWebSocket.instances[0];
ws.open();
ws.message(
sessionMessage({
type: "status",
payload: {
status: "server_info",
serverId: "srv_compact_summary",
hostname: null,
version: null,
features,
},
}),
);
await connectPromise;
return { client, ws };
}

const agentId = "00000000-0000-4000-8000-000000000001";

const sections = {
task: "Host compact summary",
decisions: "None",
currentState: "idle",
nextStep: "Review",
};

test("agents.generateCompactSummary returns correlated sections and cutoff", async () => {
const { client, ws } = await connectClient({
ownedSubscriptions: true,
agentCompactSummary: true,
});

const promise = client.agents.generateCompactSummary(agentId);
expect(parseSentSessionMessage(ws.sent.at(-1))).toMatchObject({
type: "agent.compact_summary.generate.request",
agentId,
});

const request = parseSentSessionMessage(ws.sent.at(-1));
ws.message(
sessionMessage({
type: "agent.compact_summary.generate.response",
payload: {
requestId: request.requestId,
agentId,
sections,
cutoff: "2026-10-25T10:00:00.000Z",
error: null,
},
}),
);

await expect(promise).resolves.toEqual({
sections,
cutoff: "2026-10-25T10:00:00.000Z",
});
});

test("agents.generateCompactSummary requires host agentCompactSummary capability", async () => {
const { client } = await connectClient({ ownedSubscriptions: true });
await expect(client.agents.generateCompactSummary(agentId)).rejects.toMatchObject({
code: "unsupported_capability",
});
});

test("agents.generateCompactSummary surfaces host inline errors", async () => {
const { client, ws } = await connectClient({
ownedSubscriptions: true,
agentCompactSummary: true,
});

const promise = client.agents.generateCompactSummary(agentId);
const request = parseSentSessionMessage(ws.sent.at(-1));
ws.message(
sessionMessage({
type: "agent.compact_summary.generate.response",
payload: {
requestId: request.requestId,
agentId,
sections: null,
cutoff: null,
error: "This session uses a live provider.",
},
}),
);

await expect(promise).rejects.toThrow("This session uses a live provider.");
});
55 changes: 55 additions & 0 deletions packages/client/src/daemon-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,20 @@ type ScheduleListPayload = Extract<
SessionOutboundMessage,
{ type: "schedule/list/response" }
>["payload"];
export type AgentCompactSummaryPayload = Extract<
SessionOutboundMessage,
{ type: "agent.compact_summary.generate.response" }
>["payload"];
export interface AgentCompactSummaryResult {
sections: NonNullable<AgentCompactSummaryPayload["sections"]>;
cutoff: NonNullable<AgentCompactSummaryPayload["cutoff"]>;
}
/** Options for an explicit foreground summary turn on the source session. */
export interface FetchAgentCompactSummaryOptions {
requestId?: string;
timeout?: number;
signal?: AbortSignal;
}
type ScheduleInspectPayload = Extract<
SessionOutboundMessage,
{ type: "schedule/inspect/response" }
Expand Down Expand Up @@ -6584,6 +6598,47 @@ export class DaemonClient {
});
}

requireAgentCompactSummary(): void {
this.ensureConnected();
if (!this.supportsHostFeature("agentCompactSummary")) {
throw Object.assign(new Error("Update the host to generate compact session summaries."), {
code: "unsupported_capability",
});
}
}

async generateAgentCompactSummary(
agentId: string,
options?: FetchAgentCompactSummaryOptions,
): Promise<AgentCompactSummaryResult> {
this.requireAgentCompactSummary();
options?.signal?.throwIfAborted();
const payload = await this.sendCorrelatedSessionRequest<
"agent.compact_summary.generate.response",
AgentCompactSummaryPayload
>({
requestId: options?.requestId,
timeout: options?.timeout,
message: {
type: "agent.compact_summary.generate.request",
agentId,
},
responseType: "agent.compact_summary.generate.response",
});
if (payload.error !== null) {
throw new Error(payload.error);
}
if (!payload.sections || !payload.cutoff) {
throw new Error("The host returned no compact summary payload.");
}
return { sections: payload.sections, cutoff: payload.cutoff };
}

supportsHostFeature(feature: keyof NonNullable<ServerInfoStatusPayload["features"]>): boolean {
this.ensureConnected();
return this.lastServerInfoMessage?.features?.[feature] === true;
}

async scheduleInspect(options: InspectScheduleOptions): Promise<ScheduleInspectPayload> {
return this.sendCorrelatedSessionRequest({
requestId: options.requestId,
Expand Down
17 changes: 17 additions & 0 deletions packages/client/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,21 @@ export interface PaseoAgentHandle {
subscribe(handler: (update: PaseoAgentUpdate) => void): () => void;
}

export interface PaseoCompactSummarySections {
task: string;
decisions: string;
currentState: string;
nextStep: string;
}

export interface PaseoCompactSummaryPayload {
sections: PaseoCompactSummarySections;
cutoff: string;
}

export interface PaseoAgentActions {
/** Runs a foreground summary turn on an idle source. Requires agentCompactSummary and workspace.write. */
generateCompactSummary(agentId: string): Promise<PaseoCompactSummaryPayload>;
list(options: PaseoAgentListOptions & { subscribe: {} }): Promise<
PaseoAgentListResult & {
subscriptionId: string;
Expand Down Expand Up @@ -496,6 +510,7 @@ export interface PaseoConfigActions {
}

export interface PaseoApi {
supportsHostFeature(feature: "agentCompactSummary"): boolean;
readonly hosts: PaseoHostActions;
dispose(): Promise<void>;
observeEvents: DaemonClient["observeEvents"];
Expand Down Expand Up @@ -720,6 +735,7 @@ export function createPaseoApi(
}

return {
supportsHostFeature: (feature) => daemonClient.supportsHostFeature(feature),
dispose,
hosts: createHostActions(daemonClient, { own, signal: lifetime.signal, api: createPaseoApi }),
observeEvents,
Expand Down Expand Up @@ -763,6 +779,7 @@ export function createPaseoApi(
subscribe: listenWorkspaces,
},
agents: {
generateCompactSummary: (agentId) => daemonClient.generateAgentCompactSummary(agentId),
list: listAgents,
ref: (agent) => createAgentHandle(agent),
create: (options) => createAgent(options),
Expand Down
29 changes: 29 additions & 0 deletions packages/protocol/src/kontor/compact-summary-rpc-schemas.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { z } from "zod";

const agentIdSchema = z.string().uuid();

export const CompactSummarySectionsSchema = z
.object({
task: z.string(),
decisions: z.string(),
currentState: z.string(),
nextStep: z.string(),
})
.strict();

export const AgentCompactSummaryGenerateRequestSchema = z.object({
type: z.literal("agent.compact_summary.generate.request"),
requestId: z.string(),
agentId: agentIdSchema,
});

export const AgentCompactSummaryGenerateResponseSchema = z.object({
type: z.literal("agent.compact_summary.generate.response"),
payload: z.object({
requestId: z.string(),
agentId: agentIdSchema,
sections: CompactSummarySectionsSchema.nullable(),
cutoff: z.string().nullable(),
error: z.string().nullable(),
}),
});
Loading
Loading