@vellumai/assistant 0.9.0-dev.202606180303.c59b38a → 0.9.0-dev.202606180546.485697b
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/openapi.yaml +75 -0
- package/package.json +1 -1
- package/src/__tests__/conversation-lifecycle.test.ts +7 -9
- package/src/__tests__/credential-execution-shell-lockdown.test.ts +16 -13
- package/src/__tests__/provider-send-message-override-profile.test.ts +76 -0
- package/src/cli/commands/__tests__/memory-v3.test.ts +1 -1
- package/src/cli/commands/memory-v3.ts +93 -0
- package/src/config/bundled-skills/messaging/tools/messaging-archive-by-sender.ts +3 -1
- package/src/context/compactor.ts +3 -5
- package/src/daemon/__tests__/conversation-lifecycle-auto-analyze.test.ts +3 -2
- package/src/daemon/conversation-agent-loop.ts +3 -3
- package/src/daemon/conversation-lifecycle.ts +3 -5
- package/src/daemon/conversation-runtime-assembly.ts +5 -5
- package/src/daemon/conversation.ts +12 -13
- package/src/daemon/disk-pressure-policy.ts +4 -2
- package/src/daemon/handlers/conversations.ts +2 -2
- package/src/ipc/__tests__/binary-result-ipc.test.ts +81 -0
- package/src/ipc/assistant-server.ts +37 -4
- package/src/memory/__tests__/auto-analysis-enqueue.test.ts +5 -16
- package/src/memory/__tests__/jobs-store-enqueue-gate.test.ts +0 -5
- package/src/memory/__tests__/memory-retrospective-enqueue.test.ts +0 -7
- package/src/memory/auto-analysis-enqueue.ts +3 -5
- package/src/memory/embedding-backend.ts +15 -1
- package/src/memory/memory-retrospective-enqueue.ts +3 -5
- package/src/memory/v3-eval/__tests__/eval-packets.test.ts +248 -0
- package/src/memory/v3-eval/eval-packets.ts +546 -0
- package/src/plugin-api/index.ts +5 -1
- package/src/plugins/defaults/memory-retrieval/unified-turn-context.ts +29 -24
- package/src/plugins/defaults/memory-v3-shadow/__tests__/maintain-job.test.ts +61 -0
- package/src/plugins/defaults/memory-v3-shadow/maintain-job.ts +33 -0
- package/src/prompts/templates/system-sections.ts +7 -2
- package/src/providers/provider-send-message.ts +11 -3
- package/src/runtime/actor-trust-resolver.ts +0 -12
- package/src/runtime/capabilities.test.ts +120 -0
- package/src/runtime/capabilities.ts +194 -0
- package/src/runtime/confirmation-request-guardian-bridge.ts +6 -5
- package/src/runtime/routes/guardian-approval-interception.ts +6 -5
- package/src/runtime/routes/index.ts +2 -0
- package/src/runtime/routes/memory-eval-routes.ts +87 -0
- package/src/runtime/trust-context-resolver.ts +3 -4
- package/src/tools/document/document-tool.ts +3 -1
- package/src/tools/executor.ts +2 -2
- package/src/tools/host-terminal/host-shell.ts +2 -2
- package/src/tools/memory/register.ts +2 -2
- package/src/tools/permission-checker.ts +3 -2
- package/src/tools/schedule/create.ts +4 -3
- package/src/tools/schedule/update.ts +2 -1
- package/src/tools/terminal/shell.ts +2 -2
- package/src/tools/tool-approval-handler.ts +9 -5
- package/src/tools/verification-control-plane-policy.ts +3 -1
package/openapi.yaml
CHANGED
|
@@ -15210,6 +15210,81 @@ paths:
|
|
|
15210
15210
|
additionalProperties: false
|
|
15211
15211
|
"409":
|
|
15212
15212
|
description: Another memory item with this content already exists
|
|
15213
|
+
/v1/memory/eval/run:
|
|
15214
|
+
post:
|
|
15215
|
+
operationId: memory_eval_run_post
|
|
15216
|
+
summary: Build blinded A/B retrieval-eval packets over two concept corpora (snapshot vs staged wiki)
|
|
15217
|
+
tags:
|
|
15218
|
+
- memory
|
|
15219
|
+
requestBody:
|
|
15220
|
+
required: true
|
|
15221
|
+
content:
|
|
15222
|
+
application/json:
|
|
15223
|
+
schema:
|
|
15224
|
+
type: object
|
|
15225
|
+
properties:
|
|
15226
|
+
stagingDir:
|
|
15227
|
+
type: string
|
|
15228
|
+
minLength: 1
|
|
15229
|
+
snapshotDir:
|
|
15230
|
+
type: string
|
|
15231
|
+
minLength: 1
|
|
15232
|
+
outDir:
|
|
15233
|
+
type: string
|
|
15234
|
+
minLength: 1
|
|
15235
|
+
turns:
|
|
15236
|
+
type: integer
|
|
15237
|
+
exclusiveMinimum: 0
|
|
15238
|
+
maximum: 9007199254740991
|
|
15239
|
+
perConversationCap:
|
|
15240
|
+
type: integer
|
|
15241
|
+
exclusiveMinimum: 0
|
|
15242
|
+
maximum: 9007199254740991
|
|
15243
|
+
k:
|
|
15244
|
+
type: integer
|
|
15245
|
+
exclusiveMinimum: 0
|
|
15246
|
+
maximum: 9007199254740991
|
|
15247
|
+
dense:
|
|
15248
|
+
type: boolean
|
|
15249
|
+
seed:
|
|
15250
|
+
type: integer
|
|
15251
|
+
minimum: -9007199254740991
|
|
15252
|
+
maximum: 9007199254740991
|
|
15253
|
+
required:
|
|
15254
|
+
- stagingDir
|
|
15255
|
+
- snapshotDir
|
|
15256
|
+
- outDir
|
|
15257
|
+
responses:
|
|
15258
|
+
"200":
|
|
15259
|
+
description: Successful response
|
|
15260
|
+
content:
|
|
15261
|
+
application/json:
|
|
15262
|
+
schema:
|
|
15263
|
+
type: object
|
|
15264
|
+
properties:
|
|
15265
|
+
turnsMined:
|
|
15266
|
+
type: number
|
|
15267
|
+
packetsWritten:
|
|
15268
|
+
type: number
|
|
15269
|
+
packetsPath:
|
|
15270
|
+
type: string
|
|
15271
|
+
keyPath:
|
|
15272
|
+
type: string
|
|
15273
|
+
snapshotPages:
|
|
15274
|
+
type: number
|
|
15275
|
+
stagingPages:
|
|
15276
|
+
type: number
|
|
15277
|
+
dense:
|
|
15278
|
+
type: boolean
|
|
15279
|
+
required:
|
|
15280
|
+
- turnsMined
|
|
15281
|
+
- packetsWritten
|
|
15282
|
+
- packetsPath
|
|
15283
|
+
- keyPath
|
|
15284
|
+
- snapshotPages
|
|
15285
|
+
- stagingPages
|
|
15286
|
+
- dense
|
|
15287
|
+
additionalProperties: false
|
|
15213
15288
|
/v1/memory/v2/backfill:
|
|
15214
15289
|
post:
|
|
15215
15290
|
operationId: memory_v2_backfill_post
|
package/package.json
CHANGED
|
@@ -674,15 +674,13 @@ describe("loadFromDb metadata injection rehydration", () => {
|
|
|
674
674
|
});
|
|
675
675
|
|
|
676
676
|
test("internal-channel trusted_contact view still rehydrates memoryV2StaticBlock", async () => {
|
|
677
|
-
//
|
|
678
|
-
//
|
|
679
|
-
//
|
|
680
|
-
// arriving over the internal `"vellum"` channel
|
|
681
|
-
//
|
|
682
|
-
//
|
|
683
|
-
//
|
|
684
|
-
// rehydrate gate must match so a daemon-restart reload of the same
|
|
685
|
-
// conversation produces an identical prefix.
|
|
677
|
+
// Rehydration keys on `sourceChannel`, not `trustClass`: injection uses
|
|
678
|
+
// `shouldExposePersonalMemory`, which exposes personal memory whenever
|
|
679
|
+
// `sourceChannel === "vellum"` regardless of actor trust class. So a
|
|
680
|
+
// trusted_contact view arriving over the internal `"vellum"` channel
|
|
681
|
+
// rehydrates `memoryV2StaticBlock`. The rehydrate gate must match
|
|
682
|
+
// injection so a daemon-restart reload of the same conversation produces
|
|
683
|
+
// an identical prefix.
|
|
686
684
|
mockConversation = defaultConv();
|
|
687
685
|
mockDbMessages = [
|
|
688
686
|
{
|
|
@@ -11,31 +11,33 @@
|
|
|
11
11
|
|
|
12
12
|
import { describe, expect, test } from "bun:test";
|
|
13
13
|
|
|
14
|
-
import {
|
|
14
|
+
import { resolveCapabilities } from "../runtime/capabilities.js";
|
|
15
15
|
|
|
16
16
|
// ---------------------------------------------------------------------------
|
|
17
17
|
// Trust class categorization (foundational for lockdown decisions)
|
|
18
18
|
// ---------------------------------------------------------------------------
|
|
19
19
|
|
|
20
20
|
describe("trust class categorization for CES lockdown", () => {
|
|
21
|
-
test("guardian
|
|
22
|
-
expect(
|
|
21
|
+
test("guardian runs an unsandboxed shell", () => {
|
|
22
|
+
expect(resolveCapabilities("guardian").canRunUnsandboxedShell).toBe(true);
|
|
23
23
|
});
|
|
24
24
|
|
|
25
|
-
test("trusted_contact is
|
|
26
|
-
expect(
|
|
25
|
+
test("trusted_contact shell is sandboxed", () => {
|
|
26
|
+
expect(resolveCapabilities("trusted_contact").canRunUnsandboxedShell).toBe(false);
|
|
27
27
|
});
|
|
28
28
|
|
|
29
|
-
test("unverified_contact is
|
|
30
|
-
expect(
|
|
29
|
+
test("unverified_contact shell is sandboxed", () => {
|
|
30
|
+
expect(resolveCapabilities("unverified_contact").canRunUnsandboxedShell).toBe(
|
|
31
|
+
false,
|
|
32
|
+
);
|
|
31
33
|
});
|
|
32
34
|
|
|
33
|
-
test("unknown is
|
|
34
|
-
expect(
|
|
35
|
+
test("unknown shell is sandboxed", () => {
|
|
36
|
+
expect(resolveCapabilities("unknown").canRunUnsandboxedShell).toBe(false);
|
|
35
37
|
});
|
|
36
38
|
|
|
37
|
-
test("undefined is
|
|
38
|
-
expect(
|
|
39
|
+
test("undefined shell is sandboxed", () => {
|
|
40
|
+
expect(resolveCapabilities(undefined).canRunUnsandboxedShell).toBe(false);
|
|
39
41
|
});
|
|
40
42
|
});
|
|
41
43
|
|
|
@@ -95,7 +97,7 @@ describe("VELLUM_UNTRUSTED_SHELL env flag", () => {
|
|
|
95
97
|
describe("CES shell lockdown activation", () => {
|
|
96
98
|
test("lockdown is active only when both flag is enabled AND actor is untrusted", () => {
|
|
97
99
|
// Simulates the condition used in shell.ts:
|
|
98
|
-
// const shellLockdownActive = isCesShellLockdownEnabled(config) &&
|
|
100
|
+
// const shellLockdownActive = isCesShellLockdownEnabled(config) && !resolveCapabilities(context.trustClass).canRunUnsandboxedShell;
|
|
99
101
|
const cases: Array<{
|
|
100
102
|
flagEnabled: boolean;
|
|
101
103
|
trustClass: "guardian" | "trusted_contact" | "unknown";
|
|
@@ -110,7 +112,8 @@ describe("CES shell lockdown activation", () => {
|
|
|
110
112
|
];
|
|
111
113
|
|
|
112
114
|
for (const { flagEnabled, trustClass, expected } of cases) {
|
|
113
|
-
const active =
|
|
115
|
+
const active =
|
|
116
|
+
flagEnabled && !resolveCapabilities(trustClass).canRunUnsandboxedShell;
|
|
114
117
|
expect(active).toBe(expected);
|
|
115
118
|
}
|
|
116
119
|
});
|
|
@@ -261,3 +261,79 @@ describe("SendMessageOptions.config.overrideProfile", () => {
|
|
|
261
261
|
expect(captured?.overrideProfile).toBeUndefined();
|
|
262
262
|
});
|
|
263
263
|
});
|
|
264
|
+
|
|
265
|
+
describe("SendMessageOptions.config.forceOverrideProfile", () => {
|
|
266
|
+
test("CallSiteConfiguredProvider forwards forceOverrideProfile into the send config", async () => {
|
|
267
|
+
let captured: SendMessageOptions | undefined;
|
|
268
|
+
const inner: Provider = {
|
|
269
|
+
name: "anthropic",
|
|
270
|
+
async sendMessage(
|
|
271
|
+
_messages: Message[],
|
|
272
|
+
options?: SendMessageOptions,
|
|
273
|
+
): Promise<ProviderResponse> {
|
|
274
|
+
captured = options;
|
|
275
|
+
return makeResponse("anthropic");
|
|
276
|
+
},
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
const provider = new CallSiteConfiguredProvider(
|
|
280
|
+
inner,
|
|
281
|
+
"inference",
|
|
282
|
+
"strong",
|
|
283
|
+
true,
|
|
284
|
+
);
|
|
285
|
+
await provider.sendMessage(DUMMY_MESSAGES, {});
|
|
286
|
+
|
|
287
|
+
expect(captured?.config).toMatchObject({
|
|
288
|
+
callSite: "inference",
|
|
289
|
+
overrideProfile: "strong",
|
|
290
|
+
forceOverrideProfile: true,
|
|
291
|
+
});
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
test("forceOverrideProfile floats the override above a call-site profile pin", async () => {
|
|
295
|
+
// The advisor scenario in miniature: the `inference` call site is pinned to
|
|
296
|
+
// a cheap profile, but a caller forces a stronger profile for its own send.
|
|
297
|
+
setLlmConfig({
|
|
298
|
+
default: { provider: "anthropic", model: "claude-opus-4-7" },
|
|
299
|
+
profiles: {
|
|
300
|
+
cheap: { provider: "anthropic", model: "claude-haiku-4-5-20251001" },
|
|
301
|
+
strong: { provider: "anthropic", model: "claude-opus-4-8" },
|
|
302
|
+
},
|
|
303
|
+
callSites: { inference: { profile: "cheap" } },
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
const send = async (force: boolean) => {
|
|
307
|
+
let captured: Record<string, unknown> | undefined;
|
|
308
|
+
const inner: Provider = {
|
|
309
|
+
name: "anthropic",
|
|
310
|
+
async sendMessage(
|
|
311
|
+
_messages: Message[],
|
|
312
|
+
options?: SendMessageOptions,
|
|
313
|
+
): Promise<ProviderResponse> {
|
|
314
|
+
captured = options?.config as Record<string, unknown> | undefined;
|
|
315
|
+
return makeResponse("anthropic");
|
|
316
|
+
},
|
|
317
|
+
};
|
|
318
|
+
const provider = new RetryProvider(inner);
|
|
319
|
+
await provider.sendMessage(DUMMY_MESSAGES, {
|
|
320
|
+
config: {
|
|
321
|
+
callSite: "inference",
|
|
322
|
+
overrideProfile: "strong",
|
|
323
|
+
...(force ? { forceOverrideProfile: true } : {}),
|
|
324
|
+
},
|
|
325
|
+
});
|
|
326
|
+
return captured;
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
// Without the flag, the call-site pin (`cheap`) outranks `overrideProfile`.
|
|
330
|
+
expect((await send(false))?.model).toBe("claude-haiku-4-5-20251001");
|
|
331
|
+
|
|
332
|
+
// With the flag, the forced `strong` profile wins over the call-site pin.
|
|
333
|
+
const forced = await send(true);
|
|
334
|
+
expect(forced?.model).toBe("claude-opus-4-8");
|
|
335
|
+
// The routing keys are stripped before the provider wire request.
|
|
336
|
+
expect(forced?.overrideProfile).toBeUndefined();
|
|
337
|
+
expect(forced?.forceOverrideProfile).toBeUndefined();
|
|
338
|
+
});
|
|
339
|
+
});
|
|
@@ -144,7 +144,7 @@ describe("subcommand registration", () => {
|
|
|
144
144
|
const v3 = memory!.commands.find((c) => c.name() === "v3");
|
|
145
145
|
expect(v3).toBeDefined();
|
|
146
146
|
const subcommandNames = v3!.commands.map((c) => c.name()).sort();
|
|
147
|
-
expect(subcommandNames).toEqual(["backfill-sections", "rebuild-index"]);
|
|
147
|
+
expect(subcommandNames).toEqual(["backfill-sections", "eval", "rebuild-index"]);
|
|
148
148
|
});
|
|
149
149
|
});
|
|
150
150
|
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
import type { Command } from "commander";
|
|
19
19
|
|
|
20
20
|
import { cliIpcCall } from "../../ipc/cli-client.js";
|
|
21
|
+
import type { MemoryEvalRunResult } from "../../runtime/routes/memory-eval-routes.js";
|
|
21
22
|
import type {
|
|
22
23
|
MemoryV3BackfillSectionsResult,
|
|
23
24
|
MemoryV3RebuildIndexResult,
|
|
@@ -34,6 +35,13 @@ import { log } from "../logger.js";
|
|
|
34
35
|
*/
|
|
35
36
|
const BACKFILL_IPC_TIMEOUT_MS = 30 * 60 * 1000;
|
|
36
37
|
|
|
38
|
+
/**
|
|
39
|
+
* IPC timeout for `eval`. Embedding both corpora's sections runs through the
|
|
40
|
+
* embedder and easily outlasts the default 60s, so allow the same generous
|
|
41
|
+
* ceiling as the backfill.
|
|
42
|
+
*/
|
|
43
|
+
const EVAL_IPC_TIMEOUT_MS = 30 * 60 * 1000;
|
|
44
|
+
|
|
37
45
|
export function registerMemoryV3Command(program: Command): void {
|
|
38
46
|
// Reuse an existing `memory` parent if some other registrar attached to it
|
|
39
47
|
// first; otherwise create one. This keeps the registration order between
|
|
@@ -134,6 +142,91 @@ Examples:
|
|
|
134
142
|
: "."),
|
|
135
143
|
);
|
|
136
144
|
});
|
|
145
|
+
|
|
146
|
+
// ── eval ──────────────────────────────────────────────────────────────
|
|
147
|
+
|
|
148
|
+
v3.command("eval")
|
|
149
|
+
.description(
|
|
150
|
+
"Build blinded A/B retrieval-eval packets (snapshot corpus vs staged wiki)",
|
|
151
|
+
)
|
|
152
|
+
.requiredOption(
|
|
153
|
+
"--staging <dir>",
|
|
154
|
+
"Staged v3 wiki dir (relative to the workspace, or absolute)",
|
|
155
|
+
)
|
|
156
|
+
.requiredOption(
|
|
157
|
+
"--snapshot <dir>",
|
|
158
|
+
"Read-only v2 snapshot dir (relative to the workspace, or absolute)",
|
|
159
|
+
)
|
|
160
|
+
.requiredOption("--out <dir>", "Output dir for packets.json + key.json")
|
|
161
|
+
.option("--turns <n>", "Number of recent turns to mine", "30")
|
|
162
|
+
.option("--k <n>", "Pages per memory set", "8")
|
|
163
|
+
.option(
|
|
164
|
+
"--seed <n>",
|
|
165
|
+
"Blinding seed (reproducible A/B assignment)",
|
|
166
|
+
"1",
|
|
167
|
+
)
|
|
168
|
+
.option(
|
|
169
|
+
"--no-dense",
|
|
170
|
+
"Needle-only: skip section embedding (fast, cheaper, lower fidelity)",
|
|
171
|
+
)
|
|
172
|
+
.option("--json", "Emit raw JSON instead of a formatted summary")
|
|
173
|
+
.addHelpText(
|
|
174
|
+
"after",
|
|
175
|
+
`
|
|
176
|
+
Mines recent user turns, retrieves the top pages from each corpus per turn, and
|
|
177
|
+
writes blinded A/B packets (plus a separate unblinding key) for a blind-judge
|
|
178
|
+
workflow. Both corpora are read in memory — nothing in the live lanes or Qdrant
|
|
179
|
+
is touched. With the dense lane on (default) it embeds every section of both
|
|
180
|
+
corpora, which can take a while on a large corpus; use --no-dense for a fast
|
|
181
|
+
lexical-only pass.
|
|
182
|
+
|
|
183
|
+
Examples:
|
|
184
|
+
$ assistant memory v3 eval --snapshot .mv3/snapshot/concepts --staging .mv3/staging --out .mv3/eval
|
|
185
|
+
$ assistant memory v3 eval --snapshot .mv3/snapshot/concepts --staging .mv3/staging --out .mv3/eval --turns 50 --no-dense`,
|
|
186
|
+
)
|
|
187
|
+
.action(
|
|
188
|
+
async (opts: {
|
|
189
|
+
staging: string;
|
|
190
|
+
snapshot: string;
|
|
191
|
+
out: string;
|
|
192
|
+
turns: string;
|
|
193
|
+
k: string;
|
|
194
|
+
seed: string;
|
|
195
|
+
dense: boolean;
|
|
196
|
+
json?: boolean;
|
|
197
|
+
}) => {
|
|
198
|
+
const result = await cliIpcCall<MemoryEvalRunResult>(
|
|
199
|
+
"memory_eval_run",
|
|
200
|
+
{
|
|
201
|
+
body: {
|
|
202
|
+
stagingDir: opts.staging,
|
|
203
|
+
snapshotDir: opts.snapshot,
|
|
204
|
+
outDir: opts.out,
|
|
205
|
+
turns: Number(opts.turns),
|
|
206
|
+
k: Number(opts.k),
|
|
207
|
+
seed: Number(opts.seed),
|
|
208
|
+
dense: opts.dense,
|
|
209
|
+
},
|
|
210
|
+
},
|
|
211
|
+
{ timeoutMs: EVAL_IPC_TIMEOUT_MS },
|
|
212
|
+
);
|
|
213
|
+
if (!result.ok) {
|
|
214
|
+
log.error(result.error ?? "Failed to build eval packets");
|
|
215
|
+
process.exitCode = 1;
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
const payload = result.result!;
|
|
219
|
+
if (opts.json === true) {
|
|
220
|
+
log.info(JSON.stringify(payload, null, 2));
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
log.info(
|
|
224
|
+
`Wrote ${payload.packetsWritten} packets from ${payload.turnsMined} turns ` +
|
|
225
|
+
`(snapshot ${payload.snapshotPages} pages vs staged ${payload.stagingPages} pages, ` +
|
|
226
|
+
`dense=${payload.dense}).\n packets: ${payload.packetsPath}\n key: ${payload.keyPath}`,
|
|
227
|
+
);
|
|
228
|
+
},
|
|
229
|
+
);
|
|
137
230
|
},
|
|
138
231
|
});
|
|
139
232
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { resolveCapabilities } from "../../../../runtime/capabilities.js";
|
|
1
2
|
import type {
|
|
2
3
|
ToolContext,
|
|
3
4
|
ToolExecutionResult,
|
|
@@ -9,7 +10,8 @@ export async function run(
|
|
|
9
10
|
context: ToolContext,
|
|
10
11
|
): Promise<ToolExecutionResult> {
|
|
11
12
|
const userApproved =
|
|
12
|
-
input.user_approved === true &&
|
|
13
|
+
input.user_approved === true &&
|
|
14
|
+
resolveCapabilities(context.trustClass).canSelfAuthorizeArchiveBySender;
|
|
13
15
|
if (
|
|
14
16
|
!context.triggeredBySurfaceAction &&
|
|
15
17
|
!context.batchAuthorizedByTask &&
|
package/src/context/compactor.ts
CHANGED
|
@@ -37,10 +37,8 @@ import type {
|
|
|
37
37
|
ProviderResponse,
|
|
38
38
|
ToolDefinition,
|
|
39
39
|
} from "../providers/types.js";
|
|
40
|
-
import {
|
|
41
|
-
|
|
42
|
-
type TrustClass,
|
|
43
|
-
} from "../runtime/actor-trust-resolver.js";
|
|
40
|
+
import { type TrustClass } from "../runtime/actor-trust-resolver.js";
|
|
41
|
+
import { resolveCapabilities } from "../runtime/capabilities.js";
|
|
44
42
|
import { getLogger } from "../util/logger.js";
|
|
45
43
|
import { stripInjectionsForCompaction } from "./strip-injections.js";
|
|
46
44
|
import {
|
|
@@ -387,7 +385,7 @@ export function collectImageManifest(
|
|
|
387
385
|
actorTrustClass?: TrustClass,
|
|
388
386
|
): ManifestEntry[] {
|
|
389
387
|
const allRows = getMessages(conversationId);
|
|
390
|
-
const rows =
|
|
388
|
+
const rows = !resolveCapabilities(actorTrustClass).canAccessMemory
|
|
391
389
|
? filterMessagesForUntrustedActor(allRows)
|
|
392
390
|
: allRows;
|
|
393
391
|
const entries: ManifestEntry[] = [];
|
|
@@ -236,8 +236,9 @@ describe("disposeConversation — auto-analysis enqueue", () => {
|
|
|
236
236
|
|
|
237
237
|
test("untrusted conversation — enqueues neither graph_extract nor conversation_analyze", () => {
|
|
238
238
|
// `unknown` is the trust class used for untrusted actors. The disposal
|
|
239
|
-
// code short-circuits
|
|
240
|
-
// path should fire. This preserves the
|
|
239
|
+
// code short-circuits when `resolveCapabilities(trustClass).canAccessMemory`
|
|
240
|
+
// is false, so neither enqueue path should fire. This preserves the
|
|
241
|
+
// memory trust boundary.
|
|
241
242
|
const ctx = makeDisposeContext({
|
|
242
243
|
conversationId: "conv-untrusted",
|
|
243
244
|
trustClass: "unknown",
|
|
@@ -70,9 +70,9 @@ import type { UserPromptSubmitContext } from "../plugin-api/types.js";
|
|
|
70
70
|
import { runHook } from "../plugins/pipeline.js";
|
|
71
71
|
import type { ContentBlock, Message } from "../providers/types.js";
|
|
72
72
|
import type { Provider } from "../providers/types.js";
|
|
73
|
-
import { isUntrustedTrustClass } from "../runtime/actor-trust-resolver.js";
|
|
74
73
|
import { broadcastMessage } from "../runtime/assistant-event-hub.js";
|
|
75
74
|
import { DAEMON_INTERNAL_ASSISTANT_ID } from "../runtime/assistant-scope.js";
|
|
75
|
+
import { resolveCapabilities } from "../runtime/capabilities.js";
|
|
76
76
|
import { publishConversationMessagesChanged } from "../runtime/sync/resource-sync-events.js";
|
|
77
77
|
import type { ActivationMomentParam } from "../telemetry/activation-funnel.js";
|
|
78
78
|
import type { UsageActor } from "../usage/actors.js";
|
|
@@ -1604,9 +1604,9 @@ export async function applyCompactionResult(
|
|
|
1604
1604
|
// in-context boundary rather than the raw mirror so the persisted count
|
|
1605
1605
|
// stays consistent with what the new summary represents and never
|
|
1606
1606
|
// double-counts an unsliced untrusted view.
|
|
1607
|
-
const inContextCompactedCount =
|
|
1607
|
+
const inContextCompactedCount = !resolveCapabilities(
|
|
1608
1608
|
ctx.trustContext?.trustClass,
|
|
1609
|
-
)
|
|
1609
|
+
).canAccessMemory
|
|
1610
1610
|
? 0
|
|
1611
1611
|
: ctx.contextCompactedMessageCount;
|
|
1612
1612
|
ctx.contextCompactedMessageCount =
|
|
@@ -16,10 +16,8 @@ import type { PermissionPrompter } from "../permissions/prompter.js";
|
|
|
16
16
|
import type { SecretPrompter } from "../permissions/secret-prompter.js";
|
|
17
17
|
import { disposeContextWindowManager } from "../plugins/defaults/compaction/manager-store.js";
|
|
18
18
|
import type { ContentBlock, Message } from "../providers/types.js";
|
|
19
|
-
import {
|
|
20
|
-
|
|
21
|
-
type TrustClass,
|
|
22
|
-
} from "../runtime/actor-trust-resolver.js";
|
|
19
|
+
import { type TrustClass } from "../runtime/actor-trust-resolver.js";
|
|
20
|
+
import { resolveCapabilities } from "../runtime/capabilities.js";
|
|
23
21
|
import { unregisterConversationSender } from "../tools/browser/browser-screencast.js";
|
|
24
22
|
import { type AbortReason, createAbortReason } from "../util/abort-reasons.js";
|
|
25
23
|
import { getLogger } from "../util/logger.js";
|
|
@@ -147,7 +145,7 @@ export function disposeConversation(ctx: DisposeContext): void {
|
|
|
147
145
|
// Trigger graph extraction for end-of-conversation sweep.
|
|
148
146
|
// Only extract from guardian conversations to preserve the memory trust
|
|
149
147
|
// boundary — untrusted content must not influence future memory retrieval.
|
|
150
|
-
if (
|
|
148
|
+
if (resolveCapabilities(ctx.trustContext?.trustClass).canAccessMemory) {
|
|
151
149
|
// Recursion guard: skip graph_extract for auto-analysis conversations.
|
|
152
150
|
// The analysis agent writes memory directly via tools, so extracting
|
|
153
151
|
// from its reflective musings would double-write into the memory graph.
|
|
@@ -62,11 +62,11 @@ import type {
|
|
|
62
62
|
import type { ContentBlock, Message } from "../providers/types.js";
|
|
63
63
|
import {
|
|
64
64
|
type ActorTrustContext,
|
|
65
|
-
isUntrustedTrustClass,
|
|
66
65
|
resolveActorTrust,
|
|
67
66
|
type TrustClass,
|
|
68
67
|
} from "../runtime/actor-trust-resolver.js";
|
|
69
68
|
import { DAEMON_INTERNAL_ASSISTANT_ID } from "../runtime/assistant-scope.js";
|
|
69
|
+
import { resolveCapabilities } from "../runtime/capabilities.js";
|
|
70
70
|
import { channelStatusToMemberStatus } from "../runtime/routes/inbound-stages/acl-enforcement.js";
|
|
71
71
|
import { getSubagentManager } from "../subagent/index.js";
|
|
72
72
|
import type { SubagentState } from "../subagent/types.js";
|
|
@@ -916,7 +916,7 @@ function filterSlackConversationRowsForActor(
|
|
|
916
916
|
rows: MessageRow[],
|
|
917
917
|
trustClass: TrustClass | undefined,
|
|
918
918
|
): MessageRow[] {
|
|
919
|
-
if (
|
|
919
|
+
if (resolveCapabilities(trustClass).canAccessMemory) return rows;
|
|
920
920
|
const nonSlackVisibleRows = filterMessagesForUntrustedActor(rows);
|
|
921
921
|
const nonSlackVisibleIds = new Set(nonSlackVisibleRows.map((row) => row.id));
|
|
922
922
|
return rows.filter((row) => {
|
|
@@ -1323,9 +1323,9 @@ export function loadSlackChronologicalContext(
|
|
|
1323
1323
|
options,
|
|
1324
1324
|
);
|
|
1325
1325
|
return assembleSlackChronologicalContext(rows, capabilities, {
|
|
1326
|
-
contextSummary:
|
|
1327
|
-
?
|
|
1328
|
-
:
|
|
1326
|
+
contextSummary: resolveCapabilities(options.trustClass).canAccessMemory
|
|
1327
|
+
? options.contextSummary
|
|
1328
|
+
: null,
|
|
1329
1329
|
});
|
|
1330
1330
|
}
|
|
1331
1331
|
|
|
@@ -80,12 +80,10 @@ import {
|
|
|
80
80
|
} from "../prompts/system-prompt.js";
|
|
81
81
|
import type { ContentBlock, Message } from "../providers/types.js";
|
|
82
82
|
import type { Provider } from "../providers/types.js";
|
|
83
|
-
import {
|
|
84
|
-
isUntrustedTrustClass,
|
|
85
|
-
type TrustClass,
|
|
86
|
-
} from "../runtime/actor-trust-resolver.js";
|
|
83
|
+
import { type TrustClass } from "../runtime/actor-trust-resolver.js";
|
|
87
84
|
import { broadcastMessage } from "../runtime/assistant-event-hub.js";
|
|
88
85
|
import type { AuthContext } from "../runtime/auth/types.js";
|
|
86
|
+
import { resolveCapabilities } from "../runtime/capabilities.js";
|
|
89
87
|
import type { InteractiveUiResult } from "../runtime/interactive-ui.js";
|
|
90
88
|
import { publishSyncInvalidation } from "../runtime/sync/sync-publisher.js";
|
|
91
89
|
import {
|
|
@@ -854,10 +852,11 @@ export class Conversation {
|
|
|
854
852
|
|
|
855
853
|
async loadFromDb(): Promise<void> {
|
|
856
854
|
const trustClass = this.trustContext?.trustClass;
|
|
855
|
+
const canAccessMemory = resolveCapabilities(trustClass).canAccessMemory;
|
|
857
856
|
const allDbMessages = getMessages(this.conversationId);
|
|
858
|
-
const dbMessages =
|
|
859
|
-
?
|
|
860
|
-
: allDbMessages;
|
|
857
|
+
const dbMessages = canAccessMemory
|
|
858
|
+
? allDbMessages
|
|
859
|
+
: filterMessagesForUntrustedActor(allDbMessages);
|
|
861
860
|
|
|
862
861
|
// Rehydrate the in-memory turn counter from persisted history. `turnCount`
|
|
863
862
|
// is otherwise a fresh-zero field, so a reloaded conversation (eviction,
|
|
@@ -899,12 +898,12 @@ export class Conversation {
|
|
|
899
898
|
// than exist. Slack chronological context is a separate consumer that
|
|
900
899
|
// applies its own trust filtering downstream, so it reads the raw
|
|
901
900
|
// mirrored count rather than this in-context boundary.
|
|
902
|
-
const inContextCompactedCount =
|
|
903
|
-
?
|
|
904
|
-
:
|
|
905
|
-
const contextSummaryForHistory =
|
|
906
|
-
? null
|
|
907
|
-
:
|
|
901
|
+
const inContextCompactedCount = canAccessMemory
|
|
902
|
+
? Math.min(this.contextCompactedMessageCount, dbMessages.length)
|
|
903
|
+
: 0;
|
|
904
|
+
const contextSummaryForHistory = canAccessMemory
|
|
905
|
+
? this.contextSummary?.trim() || null
|
|
906
|
+
: null;
|
|
908
907
|
|
|
909
908
|
// Every injection-strip event (`/clean` or compaction) updates
|
|
910
909
|
// `historyStrippedAt`. Messages older than this should skip metadata
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { InterfaceId } from "../channels/types.js";
|
|
2
2
|
import type { LLMCallSite } from "../config/schemas/llm.js";
|
|
3
|
+
import { resolveCapabilities } from "../runtime/capabilities.js";
|
|
3
4
|
import type { DiskPressureStatus } from "./disk-pressure-guard.js";
|
|
4
5
|
import type { ConversationType } from "./message-types/shared.js";
|
|
5
6
|
import type { TrustContext } from "./trust-context.js";
|
|
@@ -74,7 +75,7 @@ export function classifyDiskPressureTurnPolicy(
|
|
|
74
75
|
}
|
|
75
76
|
|
|
76
77
|
const trustClass = metadata.trustContext?.trustClass;
|
|
77
|
-
if (trustClass
|
|
78
|
+
if (resolveCapabilities(trustClass).canActUnderDiskPressureCleanup) {
|
|
78
79
|
return { action: "allow-cleanup-mode", reason: "guardian" };
|
|
79
80
|
}
|
|
80
81
|
|
|
@@ -156,6 +157,7 @@ function isExplicitLocalOwnerCleanupTurn(
|
|
|
156
157
|
}
|
|
157
158
|
return (
|
|
158
159
|
metadata.trustContext == null ||
|
|
159
|
-
metadata.trustContext.trustClass
|
|
160
|
+
resolveCapabilities(metadata.trustContext.trustClass)
|
|
161
|
+
.canActUnderDiskPressureCleanup
|
|
160
162
|
);
|
|
161
163
|
}
|
|
@@ -2,8 +2,8 @@ import { v4 as uuid } from "uuid";
|
|
|
2
2
|
|
|
3
3
|
import { clearAll, getConversation } from "../../memory/conversation-crud.js";
|
|
4
4
|
import { resolveConversationId } from "../../memory/conversation-key-store.js";
|
|
5
|
-
import { isUntrustedTrustClass } from "../../runtime/actor-trust-resolver.js";
|
|
6
5
|
import { broadcastMessage } from "../../runtime/assistant-event-hub.js";
|
|
6
|
+
import { resolveCapabilities } from "../../runtime/capabilities.js";
|
|
7
7
|
import { getSubagentManager } from "../../subagent/index.js";
|
|
8
8
|
import { createAbortReason } from "../../util/abort-reasons.js";
|
|
9
9
|
import { UserError } from "../../util/errors.js";
|
|
@@ -184,7 +184,7 @@ export async function resolveMetaSlashCommand(
|
|
|
184
184
|
// Temporarily apply the guardian context for hydration and restore it
|
|
185
185
|
// afterward so the elevated class never leaks into a later turn's snapshot.
|
|
186
186
|
const priorTrustContext = conversation.trustContext;
|
|
187
|
-
if (
|
|
187
|
+
if (!resolveCapabilities(priorTrustContext?.trustClass).canAccessMemory) {
|
|
188
188
|
conversation.setTrustContext(INTERNAL_GUARDIAN_TRUST_CONTEXT);
|
|
189
189
|
}
|
|
190
190
|
try {
|