@vellumai/assistant 0.11.10-dev.202609091315.2a4dd13 → 0.11.10-dev.202609091515.2bd0662

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.
Files changed (59) hide show
  1. package/AGENTS.md +1 -1
  2. package/openapi.yaml +4 -1
  3. package/package.json +1 -1
  4. package/src/__tests__/anthropic-provider.test.ts +60 -0
  5. package/src/__tests__/conversation-error.test.ts +38 -0
  6. package/src/__tests__/host-app-control-proxy.test.ts +2 -2
  7. package/src/__tests__/host-app-control-routes.test.ts +41 -0
  8. package/src/__tests__/host-bash-routes.test.ts +30 -1
  9. package/src/__tests__/host-browser-routes.test.ts +34 -0
  10. package/src/__tests__/host-cu-routes-targeted.test.ts +29 -0
  11. package/src/__tests__/host-file-routes-targeted.test.ts +29 -0
  12. package/src/__tests__/host-proxy-base.test.ts +1 -0
  13. package/src/__tests__/host-transfer-routes-targeted.test.ts +86 -0
  14. package/src/__tests__/memory-retrieval-hook.test.ts +15 -0
  15. package/src/__tests__/provider-catalog-visibility.test.ts +2 -2
  16. package/src/__tests__/schedule-routes.test.ts +30 -1
  17. package/src/__tests__/skills-install-extract.test.ts +26 -0
  18. package/src/__tests__/skills-install-staging.test.ts +11 -2
  19. package/src/archive/ustar-size.test.ts +32 -0
  20. package/src/archive/ustar-size.ts +23 -0
  21. package/src/cli/lib/install-from-platform.ts +8 -10
  22. package/src/config/bundled-skills/screen-annotation/SKILL.md +36 -3
  23. package/src/config/feature-flag-registry.json +8 -0
  24. package/src/daemon/conversation-error.ts +20 -7
  25. package/src/daemon/host-app-control-proxy.ts +2 -0
  26. package/src/daemon/host-bash-proxy.ts +1 -0
  27. package/src/daemon/host-cu-proxy.ts +6 -6
  28. package/src/daemon/host-file-proxy.ts +6 -6
  29. package/src/daemon/host-proxy-base.ts +10 -9
  30. package/src/daemon/host-transfer-proxy.ts +21 -24
  31. package/src/notifications/__tests__/home-feed-side-effect.test.ts +27 -0
  32. package/src/notifications/home-feed-side-effect.ts +14 -3
  33. package/src/oauth/seed-providers.ts +3 -2
  34. package/src/plugins/defaults/memory/hooks/user-prompt-submit.ts +8 -0
  35. package/src/providers/anthropic/client.ts +9 -4
  36. package/src/providers/model-catalog.ts +22 -2
  37. package/src/providers/openai/__tests__/api-error-normalization.test.ts +50 -0
  38. package/src/providers/openai/api-error-normalization.ts +18 -3
  39. package/src/runtime/__tests__/background-job-runner.test.ts +42 -4
  40. package/src/runtime/auth/__tests__/guard-tests.test.ts +0 -2
  41. package/src/runtime/auth/same-actor.ts +29 -5
  42. package/src/runtime/background-job-runner.ts +38 -29
  43. package/src/runtime/migrations/vbundle-validator.ts +3 -3
  44. package/src/runtime/pending-interactions.ts +4 -5
  45. package/src/runtime/routes/document-comments-routes.ts +8 -2
  46. package/src/runtime/routes/host-app-control-routes.ts +10 -36
  47. package/src/runtime/routes/host-bash-routes.ts +11 -45
  48. package/src/runtime/routes/host-browser-routes.ts +24 -0
  49. package/src/runtime/routes/host-cu-routes.ts +11 -45
  50. package/src/runtime/routes/host-file-routes.ts +11 -44
  51. package/src/runtime/routes/host-proxy-result-binding.ts +57 -0
  52. package/src/runtime/routes/host-transfer-routes.ts +33 -25
  53. package/src/runtime/routes/schedule-routes.ts +15 -1
  54. package/src/skills/catalog-install.ts +40 -5
  55. package/src/tools/terminal/__tests__/safe-env.test.ts +17 -0
  56. package/src/tools/terminal/safe-env.ts +3 -2
  57. package/src/util/provider-error-patterns.ts +34 -0
  58. package/src/watcher/__tests__/engine.test.ts +5 -2
  59. package/src/watcher/engine.ts +7 -4
package/AGENTS.md CHANGED
@@ -16,7 +16,7 @@ When you introduce a new env var that the assistant process needs to read at run
16
16
 
17
17
  **Default to including it.** If the var doesn't contain secrets (e.g. a URL, a feature flag, a path, a mode string), add it. Only omit it if it carries credential material (tokens, passwords, private keys) — those must stay isolated to CES.
18
18
 
19
- `CES_LOCAL_SOCKET` is intentionally included despite the socket exposing credential RPCs — assistant subprocesses are expected to reach CES. Credential protection is rules-based access control inside CES, not socket-path secrecy (see root `AGENTS.md`).
19
+ `CES_LOCAL_SOCKET` is intentionally included despite the socket exposing credential RPCs: assistant subprocesses are expected to reach CES. Credential protection is rules-based access control inside CES, not socket-path secrecy (see root `AGENTS.md`). Do not forward `CES_SERVICE_TOKEN` or `CES_CREDENTIAL_URL`: the HTTP bearer is a vault secret and must stay in the assistant process.
20
20
 
21
21
  ## Daemon startup philosophy
22
22
 
package/openapi.yaml CHANGED
@@ -29048,7 +29048,8 @@ paths:
29048
29048
  summary: Run schedule now
29049
29049
  description:
29050
29050
  Trigger an immediate execution of a schedule. A plugin-sourced schedule is rejected with a 400 when its
29051
- plugin is disabled or no longer declares it.
29051
+ plugin is disabled or no longer declares it. Returns 409 while a drain quiesce lease is active so run-now cannot
29052
+ start work the shutdown snapshot would miss.
29052
29053
  tags:
29053
29054
  - schedules
29054
29055
  parameters:
@@ -29244,6 +29245,8 @@ paths:
29244
29245
  required:
29245
29246
  - schedules
29246
29247
  additionalProperties: false
29248
+ "409":
29249
+ description: A drain quiesce lease is active, so run-now is not starting new work.
29247
29250
  /v1/schedules/{id}/runs:
29248
29251
  get:
29249
29252
  operationId: schedules_by_id_runs_get
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vellumai/assistant",
3
- "version": "0.11.10-dev.202609091315.2a4dd13",
3
+ "version": "0.11.10-dev.202609091515.2bd0662",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -3194,6 +3194,66 @@ describe("AnthropicProvider — Haiku Model Gating", () => {
3194
3194
  // to the request at all.
3195
3195
  expect(lastStreamParams!.output_config).toBeUndefined();
3196
3196
  });
3197
+
3198
+ test("effort is omitted for Sonnet 4.5, which rejects the parameter", async () => {
3199
+ const sonnet45Provider = new AnthropicProvider(
3200
+ "sk-ant-test",
3201
+ "claude-sonnet-4-5-20250929",
3202
+ );
3203
+ await sonnet45Provider.sendMessage([userMsg("Hi")], {
3204
+ systemPrompt: "You are helpful.",
3205
+ config: { effort: "high" },
3206
+ });
3207
+
3208
+ // Sonnet 4.5 400s on `output_config.effort` ("This model does not
3209
+ // support the effort parameter"), so a profile effort must be dropped
3210
+ // on the wire rather than forwarded.
3211
+ expect(lastStreamParams!.output_config).toBeUndefined();
3212
+ });
3213
+
3214
+ test("effort is omitted for OpenRouter's dotted Sonnet 4.5 id", async () => {
3215
+ // OpenRouter delegates `anthropic/*` models to this provider under
3216
+ // dotted ids, so the exclusion must survive that spelling.
3217
+ const openRouterProvider = new AnthropicProvider(
3218
+ "sk-or-test",
3219
+ "anthropic/claude-sonnet-4.5",
3220
+ );
3221
+ await openRouterProvider.sendMessage([userMsg("Hi")], {
3222
+ systemPrompt: "You are helpful.",
3223
+ config: { effort: "high" },
3224
+ });
3225
+
3226
+ expect(lastStreamParams!.output_config).toBeUndefined();
3227
+ });
3228
+
3229
+ test("effort is forwarded for Opus 4.5, which accepts the parameter", async () => {
3230
+ // Opus 4.5 shares Sonnet 4.5's generation (and its
3231
+ // adaptiveThinkingUnsupported flag) but accepts effort on the wire, so
3232
+ // the exclusion must stay narrow rather than family-wide.
3233
+ const opus45Provider = new AnthropicProvider(
3234
+ "sk-ant-test",
3235
+ "claude-opus-4-5-20251101",
3236
+ );
3237
+ await opus45Provider.sendMessage([userMsg("Hi")], {
3238
+ systemPrompt: "You are helpful.",
3239
+ config: { effort: "high" },
3240
+ });
3241
+
3242
+ expect(lastStreamParams!.output_config).toEqual({ effort: "high" });
3243
+ });
3244
+
3245
+ test("effort is forwarded for Sonnet 4.6", async () => {
3246
+ const sonnet46Provider = new AnthropicProvider(
3247
+ "sk-ant-test",
3248
+ "claude-sonnet-4-6",
3249
+ );
3250
+ await sonnet46Provider.sendMessage([userMsg("Hi")], {
3251
+ systemPrompt: "You are helpful.",
3252
+ config: { effort: "medium" },
3253
+ });
3254
+
3255
+ expect(lastStreamParams!.output_config).toEqual({ effort: "medium" });
3256
+ });
3197
3257
  });
3198
3258
 
3199
3259
  // ---------------------------------------------------------------------------
@@ -816,6 +816,44 @@ describe("classifyConversationError", () => {
816
816
  );
817
817
  });
818
818
 
819
+ it("classifies an OpenCode 401 ModelError as model-not-found, not an invalid key", () => {
820
+ providerRoutingSources.opencode = "user-key";
821
+ const err = new ProviderError(
822
+ "OpenCode API error (401): Model muse-spark-1.3-contributor is not supported [type=ModelError]",
823
+ "opencode",
824
+ 401,
825
+ { reason: "model_not_found" },
826
+ );
827
+
828
+ const result = classifyConversationError(err, {
829
+ ...baseCtx,
830
+ profileName: "custom-profile",
831
+ connectionName: "opencode-personal",
832
+ });
833
+
834
+ expect(result.code).toBe("PROVIDER_API");
835
+ expect(result.errorCategory).toBe("provider_model_not_found");
836
+ expect(result.retryable).toBe(false);
837
+ expect(result.userMessage).toContain("wasn't found by the provider");
838
+ expect(result.userMessage).not.toContain("API key");
839
+ });
840
+
841
+ it("classifies a reason-less OpenCode 401 ModelError via the message, not credentials", () => {
842
+ providerRoutingSources.opencode = "user-key";
843
+ const err = new ProviderError(
844
+ "OpenCode API error (401): Model muse-spark-1.3-contributor is not supported [type=ModelError]",
845
+ "opencode",
846
+ 401,
847
+ );
848
+
849
+ const result = classifyConversationError(err, baseCtx);
850
+
851
+ expect(result.code).toBe("PROVIDER_API");
852
+ expect(result.errorCategory).toBe("provider_model_not_found");
853
+ expect(result.retryable).toBe(false);
854
+ expect(result.userMessage).not.toContain("API key");
855
+ });
856
+
819
857
  it("classifies managed-proxy auth failures as managed credential refresh failures", () => {
820
858
  providerRoutingSources.anthropic = "managed-proxy";
821
859
  const err = new ProviderError(
@@ -1398,7 +1398,7 @@ describe("HostAppControlProxy", () => {
1398
1398
  proxy.dispose();
1399
1399
  });
1400
1400
 
1401
- test("request() without targetClientId: does not register targetActorPrincipalId", async () => {
1401
+ test("request() without targetClientId: registers the source actor principal", async () => {
1402
1402
  const proxy = new HostAppControlProxy("conv-1");
1403
1403
  const ctrl = new AbortController();
1404
1404
 
@@ -1413,7 +1413,7 @@ describe("HostAppControlProxy", () => {
1413
1413
 
1414
1414
  const sent = sentMessages[0] as Record<string, unknown>;
1415
1415
  expect(registeredInteractions[0].targetClientId).toBeUndefined();
1416
- expect(registeredInteractions[0].targetActorPrincipalId).toBeUndefined();
1416
+ expect(registeredInteractions[0].targetActorPrincipalId).toBe("user-1");
1417
1417
 
1418
1418
  proxy.resolve(sent.requestId as string, payload({ pngBase64: PNG_A }));
1419
1419
  await resultPromise;
@@ -405,6 +405,47 @@ describe("handleHostAppControlResult — same-actor guard", () => {
405
405
  expect(resolveCalls).toHaveLength(1);
406
406
  });
407
407
 
408
+ test("non-targeted with recorded source actor: rejects a different principal", () => {
409
+ const requestId = "ac-req-untargeted-actor-mismatch";
410
+ const conversationId = "conv-untargeted-actor";
411
+ pending.set(requestId, {
412
+ conversationId,
413
+ kind: "host_app_control",
414
+ targetActorPrincipalId: "user-owner",
415
+ });
416
+ const resolveCalls: Array<{ requestId: string; payload: unknown }> = [];
417
+ setupConversation(conversationId, resolveCalls);
418
+
419
+ expect(() =>
420
+ handleHostAppControlResult({
421
+ body: { requestId, state: "running" },
422
+ headers: { "x-vellum-actor-principal-id": "user-attacker" },
423
+ }),
424
+ ).toThrow(ForbiddenError);
425
+ expect(resolveCalls).toHaveLength(0);
426
+ expect(pending.has(requestId)).toBe(true);
427
+ });
428
+
429
+ test("non-targeted with recorded source actor: accepts the matching principal", async () => {
430
+ const requestId = "ac-req-untargeted-actor-match";
431
+ const conversationId = "conv-untargeted-actor-match";
432
+ pending.set(requestId, {
433
+ conversationId,
434
+ kind: "host_app_control",
435
+ targetActorPrincipalId: "user-owner",
436
+ });
437
+ const resolveCalls: Array<{ requestId: string; payload: unknown }> = [];
438
+ setupConversation(conversationId, resolveCalls);
439
+
440
+ const result = await handleHostAppControlResult({
441
+ body: { requestId, state: "running" },
442
+ headers: { "x-vellum-actor-principal-id": "user-owner" },
443
+ });
444
+
445
+ expect(result).toEqual({ accepted: true });
446
+ expect(resolveCalls).toHaveLength(1);
447
+ });
448
+
408
449
  // ── Targeted + correct headers → 200 ─────────────────────────────────
409
450
 
410
451
  test("targeted + matching client id and actor principal: returns 200", async () => {
@@ -381,7 +381,7 @@ describe("handleHostBashResult", () => {
381
381
 
382
382
  // ── Untargeted-request behavior (regression for new check) ─────────
383
383
 
384
- describe("untargeted request — actor principal check is skipped", () => {
384
+ describe("untargeted request: source actor still binds when recorded", () => {
385
385
  test("accepts even when submitting actor is absent and no target client is set", async () => {
386
386
  const requestId = "req-untargeted-no-actor";
387
387
  registerPending(requestId);
@@ -395,6 +395,35 @@ describe("handleHostBashResult", () => {
395
395
  expect(resolveSpy).toHaveLength(1);
396
396
  expect(resolvedIds).toContain(requestId);
397
397
  });
398
+
399
+ test("rejects a different actor when the pending request recorded a source actor", () => {
400
+ const requestId = "req-untargeted-actor-mismatch";
401
+ registerPending(requestId, {
402
+ targetActorPrincipalId: "principal-owner",
403
+ });
404
+
405
+ expect(() =>
406
+ handleHostBashResult({
407
+ body: bashBody(requestId),
408
+ headers: { "x-vellum-actor-principal-id": "principal-attacker" },
409
+ }),
410
+ ).toThrow(ForbiddenError);
411
+ });
412
+
413
+ test("accepts the recorded source actor on an untargeted pending request", async () => {
414
+ const requestId = "req-untargeted-actor-match";
415
+ registerPending(requestId, {
416
+ targetActorPrincipalId: "principal-owner",
417
+ });
418
+
419
+ const result = await handleHostBashResult({
420
+ body: bashBody(requestId),
421
+ headers: { "x-vellum-actor-principal-id": "principal-owner" },
422
+ });
423
+
424
+ expect(result).toEqual({ accepted: true });
425
+ expect(resolveSpy).toHaveLength(1);
426
+ });
398
427
  });
399
428
 
400
429
  // ── Error: missing header on targeted request ──────────────────────
@@ -421,5 +421,39 @@ describe("handleHostBrowserResult — same-actor guard", () => {
421
421
  expect(result).toEqual({ accepted: true });
422
422
  expect(pendingInteractions.get(requestId)).toBeUndefined();
423
423
  });
424
+
425
+ test("rejects a different actor when the pending request recorded a source actor", () => {
426
+ const requestId = "browser-req-untargeted-actor-mismatch";
427
+ pendingInteractions.register(requestId, {
428
+ conversationId: "conv-1",
429
+ kind: "host_browser",
430
+ targetActorPrincipalId: "user-owner",
431
+ });
432
+
433
+ expect(() =>
434
+ handleHostBrowserResult({
435
+ body: { requestId, content: "ok", isError: false },
436
+ headers: { "x-vellum-actor-principal-id": "user-attacker" },
437
+ }),
438
+ ).toThrow(ForbiddenError);
439
+ expect(pendingInteractions.get(requestId)).toBeDefined();
440
+ });
441
+
442
+ test("accepts the recorded source actor on an untargeted pending request", async () => {
443
+ const requestId = "browser-req-untargeted-actor-match";
444
+ pendingInteractions.register(requestId, {
445
+ conversationId: "conv-1",
446
+ kind: "host_browser",
447
+ targetActorPrincipalId: "user-owner",
448
+ });
449
+
450
+ const result = await handleHostBrowserResult({
451
+ body: { requestId, content: "ok", isError: false },
452
+ headers: { "x-vellum-actor-principal-id": "user-owner" },
453
+ });
454
+
455
+ expect(result).toEqual({ accepted: true });
456
+ expect(pendingInteractions.get(requestId)).toBeUndefined();
457
+ });
424
458
  });
425
459
  });
@@ -417,6 +417,35 @@ describe("handleHostCuResult — Phase 2 targetClientId guard", () => {
417
417
  expect(result).toEqual({ accepted: true });
418
418
  expect(cuResolveSpy).toHaveLength(1);
419
419
  });
420
+
421
+ test("rejects a different actor when the pending request recorded a source actor", () => {
422
+ const requestId = "req-cu-untargeted-actor-mismatch";
423
+ registerPending(requestId, {
424
+ targetActorPrincipalId: "principal-owner",
425
+ });
426
+
427
+ expect(() =>
428
+ handleHostCuResult({
429
+ body: cuBody(requestId),
430
+ headers: { "x-vellum-actor-principal-id": "principal-attacker" },
431
+ }),
432
+ ).toThrow(ForbiddenError);
433
+ });
434
+
435
+ test("accepts the recorded source actor on an untargeted pending request", async () => {
436
+ const requestId = "req-cu-untargeted-actor-match";
437
+ registerPending(requestId, {
438
+ targetActorPrincipalId: "principal-owner",
439
+ });
440
+
441
+ const result = await handleHostCuResult({
442
+ body: cuBody(requestId),
443
+ headers: { "x-vellum-actor-principal-id": "principal-owner" },
444
+ });
445
+
446
+ expect(result).toEqual({ accepted: true });
447
+ expect(cuResolveSpy).toHaveLength(1);
448
+ });
420
449
  });
421
450
  });
422
451
 
@@ -279,6 +279,35 @@ describe("handleHostFileResult — targetClientId guard", () => {
279
279
  expect(result).toEqual({ accepted: true });
280
280
  expect(resolveSpy).toHaveLength(1);
281
281
  });
282
+
283
+ test("rejects a different actor when the pending request recorded a source actor", () => {
284
+ const requestId = "req-file-untargeted-actor-mismatch";
285
+ registerPending(requestId, {
286
+ targetActorPrincipalId: "principal-owner",
287
+ });
288
+
289
+ expect(() =>
290
+ handleHostFileResult({
291
+ body: fileBody(requestId),
292
+ headers: { "x-vellum-actor-principal-id": "principal-attacker" },
293
+ }),
294
+ ).toThrow(ForbiddenError);
295
+ });
296
+
297
+ test("accepts the recorded source actor on an untargeted pending request", async () => {
298
+ const requestId = "req-file-untargeted-actor-match";
299
+ registerPending(requestId, {
300
+ targetActorPrincipalId: "principal-owner",
301
+ });
302
+
303
+ const result = await handleHostFileResult({
304
+ body: fileBody(requestId),
305
+ headers: { "x-vellum-actor-principal-id": "principal-owner" },
306
+ });
307
+
308
+ expect(result).toEqual({ accepted: true });
309
+ expect(resolveSpy).toHaveLength(1);
310
+ });
282
311
  });
283
312
 
284
313
  // ── 5. Targeted + matching client but mismatched actor → 403 ──────────────
@@ -9,6 +9,7 @@ mock.module("../runtime/assistant-event-hub.js", () => ({
9
9
  assistantEventHub: {
10
10
  getMostRecentClientByCapability: (cap: string) =>
11
11
  cap === "host_cu" && mockHasClient ? { id: "mock-client" } : null,
12
+ getActorPrincipalIdForClient: () => undefined,
12
13
  },
13
14
  }));
14
15
 
@@ -35,6 +35,7 @@ mock.module("../runtime/pending-interactions.js", () => ({
35
35
 
36
36
  // Per-test controls for the proxy stub
37
37
  let stubTargetClientId: string | null = null;
38
+ let stubTargetActorPrincipalId: string | undefined;
38
39
  const getTransferContentCalls: string[] = [];
39
40
  const receiveTransferContentCalls: string[] = [];
40
41
  const resolveTransferResultCalls: string[] = [];
@@ -50,6 +51,9 @@ mock.module("../daemon/host-transfer-proxy.js", () => ({
50
51
  return stubTargetClientId;
51
52
  },
52
53
  getTargetActorPrincipalIdForTransfer(_transferId: string) {
54
+ if (stubTargetActorPrincipalId !== undefined) {
55
+ return stubTargetActorPrincipalId;
56
+ }
53
57
  return stubTargetClientId
54
58
  ? clientActors.get(stubTargetClientId)
55
59
  : undefined;
@@ -139,6 +143,7 @@ describe("handleTransferContentGet — Phase 3 targetClientId guard", () => {
139
143
  beforeEach(() => {
140
144
  pendingStore.clear();
141
145
  stubTargetClientId = null;
146
+ stubTargetActorPrincipalId = undefined;
142
147
  getTransferContentCalls.length = 0;
143
148
  clientActors.clear();
144
149
  });
@@ -236,6 +241,30 @@ describe("handleTransferContentGet — Phase 3 targetClientId guard", () => {
236
241
  expect(result).toBeInstanceOf(Uint8Array);
237
242
  expect(getTransferContentCalls).toContain(TEST_TRANSFER_ID);
238
243
  });
244
+
245
+ test("rejects a different actor when the transfer recorded a source actor", () => {
246
+ stubTargetClientId = null;
247
+ stubTargetActorPrincipalId = "principal-owner";
248
+ expect(() =>
249
+ handleTransferContentGet({
250
+ pathParams: { transferId: TEST_TRANSFER_ID },
251
+ headers: { "x-vellum-actor-principal-id": "principal-attacker" },
252
+ }),
253
+ ).toThrow(ForbiddenError);
254
+ expect(getTransferContentCalls).toHaveLength(0);
255
+ });
256
+
257
+ test("accepts the recorded source actor on an untargeted transfer", async () => {
258
+ stubTargetClientId = null;
259
+ stubTargetActorPrincipalId = "principal-owner";
260
+ const result = await handleTransferContentGet({
261
+ pathParams: { transferId: TEST_TRANSFER_ID },
262
+ headers: { "x-vellum-actor-principal-id": "principal-owner" },
263
+ });
264
+
265
+ expect(result).toBeInstanceOf(Uint8Array);
266
+ expect(getTransferContentCalls).toContain(TEST_TRANSFER_ID);
267
+ });
239
268
  });
240
269
 
241
270
  // ── 5. Same-user actor binding (defense-in-depth) ─────────────────────────
@@ -289,6 +318,7 @@ describe("handleTransferContentPut — Phase 3 targetClientId guard", () => {
289
318
  beforeEach(() => {
290
319
  pendingStore.clear();
291
320
  stubTargetClientId = null;
321
+ stubTargetActorPrincipalId = undefined;
292
322
  receiveTransferContentCalls.length = 0;
293
323
  clientActors.clear();
294
324
  });
@@ -408,6 +438,38 @@ describe("handleTransferContentPut — Phase 3 targetClientId guard", () => {
408
438
  expect(result).toEqual({ accepted: true });
409
439
  expect(receiveTransferContentCalls).toContain(TEST_TRANSFER_ID);
410
440
  });
441
+
442
+ test("rejects a different actor when the transfer recorded a source actor", async () => {
443
+ stubTargetClientId = null;
444
+ stubTargetActorPrincipalId = "principal-owner";
445
+ await expect(
446
+ handleTransferContentPut({
447
+ pathParams: { transferId: TEST_TRANSFER_ID },
448
+ headers: {
449
+ "x-vellum-actor-principal-id": "principal-attacker",
450
+ "x-transfer-sha256": "abc",
451
+ },
452
+ rawBody: new Uint8Array(Buffer.from("data")),
453
+ }),
454
+ ).rejects.toBeInstanceOf(ForbiddenError);
455
+ expect(receiveTransferContentCalls).toHaveLength(0);
456
+ });
457
+
458
+ test("accepts the recorded source actor on an untargeted transfer", async () => {
459
+ stubTargetClientId = null;
460
+ stubTargetActorPrincipalId = "principal-owner";
461
+ const result = await handleTransferContentPut({
462
+ pathParams: { transferId: TEST_TRANSFER_ID },
463
+ headers: {
464
+ "x-vellum-actor-principal-id": "principal-owner",
465
+ "x-transfer-sha256": "abc",
466
+ },
467
+ rawBody: new Uint8Array(Buffer.from("data")),
468
+ });
469
+
470
+ expect(result).toEqual({ accepted: true });
471
+ expect(receiveTransferContentCalls).toContain(TEST_TRANSFER_ID);
472
+ });
411
473
  });
412
474
 
413
475
  // ── 5. Same-user actor binding (defense-in-depth) ─────────────────────────
@@ -469,6 +531,7 @@ describe("handleTransferResult — Phase 3 targetClientId guard", () => {
469
531
  beforeEach(() => {
470
532
  pendingStore.clear();
471
533
  stubTargetClientId = null;
534
+ stubTargetActorPrincipalId = undefined;
472
535
  resolveTransferResultCalls.length = 0;
473
536
  clientActors.clear();
474
537
  });
@@ -599,6 +662,29 @@ describe("handleTransferResult — Phase 3 targetClientId guard", () => {
599
662
 
600
663
  expect(result).toEqual({ accepted: true });
601
664
  });
665
+
666
+ test("rejects a different actor when the pending request recorded a source actor", () => {
667
+ registerPending({ targetActorPrincipalId: "principal-owner" });
668
+ expect(() =>
669
+ handleTransferResult({
670
+ body: resultBody(),
671
+ headers: { "x-vellum-actor-principal-id": "principal-attacker" },
672
+ }),
673
+ ).toThrow(ForbiddenError);
674
+ expect(resolveTransferResultCalls).toHaveLength(0);
675
+ expect(pendingStore.has(TEST_REQUEST_ID)).toBe(true);
676
+ });
677
+
678
+ test("accepts the recorded source actor on an untargeted pending request", async () => {
679
+ registerPending({ targetActorPrincipalId: "principal-owner" });
680
+ const result = await handleTransferResult({
681
+ body: resultBody(),
682
+ headers: { "x-vellum-actor-principal-id": "principal-owner" },
683
+ });
684
+
685
+ expect(result).toEqual({ accepted: true });
686
+ expect(resolveTransferResultCalls).toContain(TEST_REQUEST_ID);
687
+ });
602
688
  });
603
689
 
604
690
  // ── 5. Same-user actor binding (defense-in-depth) ─────────────────────────
@@ -202,6 +202,21 @@ beforeEach(() => {
202
202
  });
203
203
 
204
204
  describe("user-prompt-submit hook (memory retrieval)", () => {
205
+ test("does not run on a memory-retrospective wake", async () => {
206
+ const { memory, prepareMemoryMock, recordPkbQueryVectorsMock } =
207
+ makeFakeGraphMemory();
208
+ const conversation = installConversation(memory, { trusted: true });
209
+ conversation.currentCallSite = "memoryRetrospective";
210
+ const ctx = makeHookCtx({ conversationId: "conv-retro" });
211
+
212
+ await userPromptSubmitMemoryRetrieval(ctx);
213
+
214
+ expect(prepareMemoryMock).not.toHaveBeenCalled();
215
+ expect(recordPkbQueryVectorsMock).not.toHaveBeenCalled();
216
+ expect(applyRuntimeInjectionsMock).not.toHaveBeenCalled();
217
+ expect(updateMessageMetadataMock).not.toHaveBeenCalled();
218
+ });
219
+
205
220
  test("voice front door skips serial legacy retrieval", async () => {
206
221
  const { memory, prepareMemoryMock, recordPkbQueryVectorsMock } =
207
222
  makeFakeGraphMemory();
@@ -19,7 +19,7 @@ function makeConfig(): AssistantConfig {
19
19
  }
20
20
 
21
21
  describe("getVisibleProviderCatalog", () => {
22
- test("hides Vellum-hosted GPU models unless developer mode is on", () => {
22
+ test("hides Vellum-hosted GPU models unless hosted inference is on", () => {
23
23
  setOverridesForTesting({});
24
24
  const hidden = getVisibleProviderCatalog(makeConfig());
25
25
  expect(hidden.find((p) => p.id === "vellum")).toBeUndefined();
@@ -29,7 +29,7 @@ describe("getVisibleProviderCatalog", () => {
29
29
  .some((m) => m.id === "qwen/qwen3-8b"),
30
30
  ).toBe(false);
31
31
 
32
- setOverridesForTesting({ "settings-developer-nav": true });
32
+ setOverridesForTesting({ "vellum-hosted-inference": true });
33
33
  const visible = getVisibleProviderCatalog(makeConfig());
34
34
  const vellum = visible.find((p) => p.id === "vellum");
35
35
  expect(vellum).toBeDefined();
@@ -65,10 +65,18 @@ import {
65
65
  } from "../persistence/conversation-crud.js";
66
66
  import { getDb } from "../persistence/db-connection.js";
67
67
  import { initializeDb } from "../persistence/db-init.js";
68
+ import {
69
+ clearLifecycleQuiesce,
70
+ setLifecycleQuiesce,
71
+ } from "../persistence/lifecycle-quiesce.js";
68
72
  import { recordUsageEvent } from "../persistence/llm-usage-store.js";
69
73
  import { rawRun } from "../persistence/raw-query.js";
70
74
  import { assistantEventHub } from "../runtime/assistant-event-hub.js";
71
- import { BadRequestError, NotFoundError } from "../runtime/routes/errors.js";
75
+ import {
76
+ BadRequestError,
77
+ ConflictError,
78
+ NotFoundError,
79
+ } from "../runtime/routes/errors.js";
72
80
  import { ROUTES as HEARTBEAT_ROUTES } from "../runtime/routes/heartbeat-routes.js";
73
81
  import { ROUTES as SCHEDULE_ROUTES } from "../runtime/routes/schedule-routes.js";
74
82
  import type { RouteDefinition } from "../runtime/routes/types.js";
@@ -1670,6 +1678,27 @@ describe("plugin-sourced schedules over routes", () => {
1670
1678
 
1671
1679
  expect(existsSync(RUN_MARKER)).toBe(true);
1672
1680
  });
1681
+
1682
+ test("refuses run-now while a drain quiesce lease is active", async () => {
1683
+ const imperative = await createSchedule({
1684
+ name: "Quiesced script",
1685
+ cronExpression: "* * * * *",
1686
+ message: "",
1687
+ mode: "script",
1688
+ script: `touch ${RUN_MARKER}`,
1689
+ });
1690
+
1691
+ setLifecycleQuiesce();
1692
+ try {
1693
+ await expect(runNow(imperative.id)).rejects.toThrow(ConflictError);
1694
+ await expect(runNow(imperative.id)).rejects.toThrow(
1695
+ "The assistant is shutting down and is not starting new schedule runs.",
1696
+ );
1697
+ expect(existsSync(RUN_MARKER)).toBe(false);
1698
+ } finally {
1699
+ clearLifecycleQuiesce();
1700
+ }
1701
+ });
1673
1702
  });
1674
1703
  });
1675
1704
 
@@ -5,6 +5,8 @@ import { afterEach, beforeEach, describe, expect, test } from "bun:test";
5
5
 
6
6
  import {
7
7
  extractTarToDir,
8
+ SKILL_DEPENDENCY_INSTALL_ARGS,
9
+ SkillArchiveError,
8
10
  writeSkillFilesToDir,
9
11
  } from "../skills/catalog-install.js";
10
12
  import { makeTar } from "./helpers/tar-fixtures.js";
@@ -81,6 +83,30 @@ describe("extractTarToDir", () => {
81
83
  expect(foundSkillMd).toBe(true);
82
84
  expect(readFileSync(join(tempDir, "SKILL.md"), "utf-8")).toBe("# demo\n");
83
85
  });
86
+
87
+ test("rejects a negative octal size field instead of spinning", () => {
88
+ const header = Buffer.alloc(512, 0);
89
+ Buffer.from("SKILL.md\0", "ascii").copy(header, 0);
90
+ header[156] = "0".charCodeAt(0);
91
+ // Signed octal in the size field parses to -512 with parseInt(..., 8),
92
+ // which would cancel the 512-byte header advance and loop forever.
93
+ Buffer.from("-0000001000\0", "ascii").copy(header, 124);
94
+ const tar = Buffer.concat([header, Buffer.alloc(1024, 0)]);
95
+
96
+ expect(() => extractTarToDir(tar, tempDir)).toThrow(SkillArchiveError);
97
+ expect(() => extractTarToDir(tar, tempDir)).toThrow(
98
+ "malformed tar size field",
99
+ );
100
+ });
101
+
102
+ test("dependency install argv suppresses lifecycle scripts", () => {
103
+ expect(SKILL_DEPENDENCY_INSTALL_ARGS).toEqual([
104
+ "install",
105
+ "--omit=dev",
106
+ "--ignore-scripts",
107
+ "--no-save",
108
+ ]);
109
+ });
84
110
  });
85
111
 
86
112
  describe("writeSkillFilesToDir", () => {