Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

AntigravityProvider.test.ts

661 lines24.7 KB

1import { describe, expect, it } from "@effect/vitest";
2import {
3 ANTIGRAVITY_DEFAULT_MODEL,
4 AntigravitySettings,
5 ProviderDriverKind,
6 ProviderInstanceId,
7 ProviderSetupError,
8} from "@t3tools/contracts";
9import * as Deferred from "effect/Deferred";
10import * as Effect from "effect/Effect";
11import * as Fiber from "effect/Fiber";
12import * as Layer from "effect/Layer";
13import * as Ref from "effect/Ref";
14import * as Schema from "effect/Schema";
15import * as Stream from "effect/Stream";
16import * as TestClock from "effect/testing/TestClock";
17import * as EffectAcpErrors from "effect-acp/errors";
18import type * as EffectAcpSchema from "effect-acp/compat";
19​
20import * as BackgroundPolicy from "../background/BackgroundPolicy.ts";
21import * as ServerSettings from "../serverSettings.ts";
22import type { AcpSessionRuntimeStartResult } from "./acp/AcpSessionRuntime.ts";
23import {
24 buildAntigravityModelsFromSession,
25 makeAntigravityProvider,
26} from "./AntigravityProvider.ts";
27​
28const decodeSettings = Schema.decodeSync(AntigravitySettings);
29const instanceId = ProviderInstanceId.make("antigravity-test");
30const driver = ProviderDriverKind.make("antigravity");
31​
32const initializeResult = {
33 protocolVersion: 1,
34 agentCapabilities: {
35 loadSession: true,
36 promptCapabilities: { image: true, audio: true, embeddedContext: true },
37 sessionCapabilities: { list: {}, resume: {} },
38 },
39 authMethods: [{ id: "oauth-personal", name: "Log in with Google" }],
40 agentInfo: {
41 name: "antigravity-acp",
42 title: "Google Antigravity",
43 version: "agy_acp_server_20260818_01_RC01",
44 },
45} satisfies EffectAcpSchema.InitializeResponse;
46​
47const modelOptions = [
48 { value: "gemini-3.8-flash-high", name: "Gemini 3.8 Flash (High)" },
49 { value: "gemini-3.8-flash-medium", name: "Gemini 3.8 Flash (Medium)" },
50 { value: "gemini-3.8-flash-low", name: "Gemini 3.8 Flash (Low)" },
51 { value: "gemini-3.7-flash-high", name: "Gemini 3.7 Flash (High)" },
52 { value: "gemini-3.7-flash-medium", name: "Gemini 3.7 Flash (Medium)" },
53 { value: "gemini-3.7-flash-low", name: "Gemini 3.7 Flash (Low)" },
54 { value: "gemini-3.6-flash-high", name: "Gemini 3.6 Flash (High)" },
55 { value: "gemini-3.6-flash-medium", name: "Gemini 3.6 Flash (Medium)" },
56 { value: "gemini-3.6-flash-low", name: "Gemini 3.6 Flash (Low)" },
57 { value: "gemini-pro-agent", name: "Gemini 3.1 Pro (High)" },
58 { value: "gemini-3.1-pro-low", name: "Gemini 3.1 Pro (Low)" },
59];
60​
61const modelConfig = {
62 id: "model",
63 name: "Model",
64 category: "model",
65 type: "select",
66 currentValue: "gemini-3.7-flash-high",
67 options: modelOptions,
68} satisfies EffectAcpSchema.SessionConfigOption;
69​
70const sessionSetupResult = {
71 sessionId: "session-1",
72 models: {
73 currentModelId: "gemini-3.7-flash-high",
74 availableModels: modelOptions.map((option) => ({ modelId: option.value, name: option.name })),
75 },
76 configOptions: [
77 modelConfig,
78 {
79 id: "mode",
80 name: "Session Mode",
81 category: "mode",
82 type: "select",
83 currentValue: "default",
84 options: [
85 { value: "default", name: "Default" },
86 { value: "yolo", name: "YOLO" },
87 ],
88 },
89 ],
90} satisfies EffectAcpSchema.NewSessionResponse;
91​
92const started = {
93 sessionId: "session-1",
94 initializeResult,
95 sessionSetupResult,
96 modelConfigId: "model",
97} satisfies AcpSessionRuntimeStartResult;
98​
99const commands = [
100 { name: "plan", description: "Create a plan", input: { type: "text", hint: "What to plan" } },
101 { name: "logout", description: "Sign out of Google" },
102] satisfies ReadonlyArray<EffectAcpSchema.AvailableCommand>;
103​
104const expectedCommands = [
105 { name: "plan", description: "Create a plan", input: { hint: "What to plan" } },
106 { name: "logout", description: "Sign out of Google" },
107];
108​
109const layerTest = Layer.merge(
110 Layer.mock(BackgroundPolicy.BackgroundPolicy)({
111 shouldRunScopeWork: () => Effect.succeed(false),
112 }),
113 ServerSettings.layerTest(),
114);
115​
116type ProbeError = EffectAcpErrors.AcpError | ProviderSetupError;
117​
118const makeHarness = Effect.fn("makeAntigravityProviderHarness")(function* (
119 options: { readonly enabled?: boolean; readonly safe?: boolean } = {},
120) {
121 const initialProbe = yield* Deferred.make<EffectAcpSchema.InitializeResponse, ProbeError>();
122 const probeCalls = yield* Ref.make(0);
123 const safetyCalls = yield* Ref.make(0);
124 const probe = yield* Ref.make<Effect.Effect<EffectAcpSchema.InitializeResponse, ProbeError>>(
125 Deferred.await(initialProbe),
126 );
127 const safety = yield* Ref.make<Effect.Effect<boolean>>(Effect.succeed(options.safe ?? true));
128 const provider = yield* makeAntigravityProvider(
129 decodeSettings({ enabled: options.enabled ?? true, customModels: ["do-not-seed-me"] }),
130 {
131 stampIdentity: (snapshot) => Effect.succeed({ ...snapshot, instanceId, driver }),
132 probe: Ref.update(probeCalls, (count) => count + 1).pipe(
133 Effect.andThen(Ref.get(probe)),
134 Effect.flatten,
135 ),
136 supportsTextGeneration: Ref.update(safetyCalls, (count) => count + 1).pipe(
137 Effect.andThen(Ref.get(safety)),
138 Effect.flatten,
139 ),
140 },
141 );
142 const initialUpdate = yield* Stream.toPull(
143 provider.snapshot.streamChanges.pipe(
144 Stream.filter((snapshot) => snapshot.installed || snapshot.status === "error"),
145 ),
146 );
147 const initialize = Deferred.succeed(initialProbe, initializeResult).pipe(
148 Effect.andThen(initialUpdate),
149 Effect.asVoid,
150 );
151 return {
152 provider,
153 probe,
154 probeCalls,
155 safety,
156 safetyCalls,
157 initialProbe,
158 initialUpdate,
159 initialize,
160 };
161});
162​
163describe("Antigravity model catalog", () => {
164 it("keeps the captured personal catalog's IDs, labels, order, and selected default", () => {
165 const models = buildAntigravityModelsFromSession(sessionSetupResult);
166 expect(models.map((model) => [model.slug, model.name])).toEqual(
167 modelOptions.map((option) => [option.value, option.name]),
168 );
169 expect(models.filter((model) => model.isDefault).map((model) => model.slug)).toEqual([
170 "gemini-3.7-flash-high",
171 ]);
172 expect(
173 models
174 .filter((model) => model.aliases?.includes(ANTIGRAVITY_DEFAULT_MODEL))
175 .map((model) => model.slug),
176 ).toEqual(["gemini-3.7-flash-high"]);
177 expect(models.every((model) => model.capabilities?.optionDescriptors?.length === 0)).toBe(true);
178 expect(models.every((model) => !model.isCustom)).toBe(true);
179 });
180​
181 it("uses legacy session models only when model config is absent", () => {
182 const fromLegacy = buildAntigravityModelsFromSession({
183 models: sessionSetupResult.models,
184 });
185 expect(fromLegacy).toEqual(buildAntigravityModelsFromSession(sessionSetupResult));
186 expect(
187 buildAntigravityModelsFromSession({
188 ...sessionSetupResult,
189 configOptions: [{ ...modelConfig, options: [] }],
190 }),
191 ).toEqual([]);
192 });
193​
194 it("flattens native option groups without combining distinct model IDs", () => {
195 const models = buildAntigravityModelsFromSession({
196 configOptions: [
197 {
198 ...modelConfig,
199 currentValue: "gemini-pro-agent",
200 options: [
201 { groupId: "Flash", name: "Flash", options: [modelOptions[3]!, modelOptions[4]!] },
202 { groupId: "Pro", name: "Pro", options: [modelOptions[9]!, modelOptions[3]!] },
203 ],
204 },
205 ],
206 });
207 expect(models.map((model) => model.slug)).toEqual([
208 "gemini-3.7-flash-high",
209 "gemini-3.7-flash-medium",
210 "gemini-pro-agent",
211 ]);
212 expect(models.find((model) => model.isDefault)?.slug).toBe("gemini-pro-agent");
213 expect(models.find((model) => model.aliases?.includes(ANTIGRAVITY_DEFAULT_MODEL))?.slug).toBe(
214 "gemini-pro-agent",
215 );
216 });
217});
218​
219it.layer(layerTest)("Antigravity provider snapshots", (it) => {
220 it.effect("does not probe or run helper safety checks while disabled", () =>
221 Effect.scoped(
222 Effect.gen(function* () {
223 const harness = yield* makeHarness({ enabled: false });
224 const snapshot = yield* harness.provider.snapshot.refresh;
225 expect(snapshot).toMatchObject({
226 enabled: false,
227 installed: false,
228 status: "disabled",
229 auth: { status: "unknown" },
230 models: [],
231 setup: { canAuthenticate: true, canInstall: true },
232 showInteractionModeToggle: false,
233 supportsConversationRollback: false,
234 supportsTextGeneration: false,
235 });
236 expect(yield* Ref.get(harness.probeCalls)).toBe(0);
237 expect(yield* Ref.get(harness.safetyCalls)).toBe(0);
238 }),
239 ),
240 );
241​
242 it.effect("records explicit sign-in while disabled without starting a health probe", () =>
243 Effect.scoped(
244 Effect.gen(function* () {
245 const harness = yield* makeHarness({ enabled: false });
246 const signedIn = yield* Stream.toPull(
247 harness.provider.snapshot.streamChanges.pipe(
248 Stream.filter(
249 (snapshot) =>
250 snapshot.auth.status === "authenticated" && snapshot.slashCommands.length > 0,
251 ),
252 ),
253 );
254 yield* harness.provider.onSessionStarted(started);
255 yield* harness.provider.onAvailableCommands(commands);
256 const [snapshot] = yield* signedIn;
257 expect(snapshot).toMatchObject({
258 enabled: false,
259 installed: true,
260 status: "disabled",
261 auth: { status: "authenticated", type: "oauth-personal" },
262 workspaceSnapshots: [],
263 });
264 expect(snapshot.models).toEqual(buildAntigravityModelsFromSession(sessionSetupResult));
265 expect(snapshot.slashCommands).toEqual(expectedCommands);
266 expect((yield* harness.provider.snapshot.refresh).models).toEqual(snapshot.models);
267 expect(yield* Ref.get(harness.probeCalls)).toBe(0);
268 }),
269 ),
270 );
271​
272 it.effect("publishes the configured sign-in method before any account is checked", () =>
273 Effect.scoped(
274 Effect.gen(function* () {
275 const provider = yield* makeAntigravityProvider(decodeSettings({ enabled: true }), {
276 stampIdentity: (snapshot) => Effect.succeed({ ...snapshot, instanceId, driver }),
277 probe: Effect.succeed(initializeResult),
278 supportsTextGeneration: Effect.succeed(true),
279 auth: { type: "gemini-api-key", label: "Gemini API key" },
280 });
281 expect((yield* provider.snapshot.getSnapshot).auth).toEqual({
282 status: "unknown",
283 type: "gemini-api-key",
284 });
285 }),
286 ),
287 );
288​
289 it.effect("treats initialize as installation proof, not account or model discovery", () =>
290 Effect.scoped(
291 Effect.gen(function* () {
292 const harness = yield* makeHarness();
293 expect(yield* harness.provider.snapshot.getSnapshot).toMatchObject({
294 installed: false,
295 status: "warning",
296 auth: { status: "unknown" },
297 models: [],
298 });
299 yield* harness.initialize;
300 const snapshot = yield* harness.provider.snapshot.getSnapshot;
301 expect(snapshot).toMatchObject({
302 installed: true,
303 status: "warning",
304 version: "agy_acp_server_20260818_01_RC01",
305 auth: { status: "unknown" },
306 models: [],
307 });
308 expect(yield* Ref.get(harness.probeCalls)).toBe(1);
309 }),
310 ),
311 );
312​
313 it.effect("publishes session metadata and native commands without another health probe", () =>
314 Effect.scoped(
315 Effect.gen(function* () {
316 const harness = yield* makeHarness();
317 yield* harness.initialize;
318 const nextReady = yield* Stream.toPull(
319 harness.provider.snapshot.streamChanges.pipe(
320 Stream.filter(
321 (snapshot) =>
322 snapshot.auth.status === "authenticated" && snapshot.slashCommands.length > 0,
323 ),
324 ),
325 );
326 yield* harness.provider.onSessionStarted(started, "/workspace");
327 yield* harness.provider.onAvailableCommands(commands, "/workspace");
328 const [snapshot] = yield* nextReady;
329 expect(snapshot).toMatchObject({
330 status: "ready",
331 auth: { status: "authenticated", type: "oauth-personal" },
332 supportsTextGeneration: true,
333 });
334 expect(snapshot.models).toEqual(buildAntigravityModelsFromSession(sessionSetupResult));
335 expect(snapshot.slashCommands).toEqual(expectedCommands);
336 expect((yield* harness.provider.snapshotForCwd("/workspace")).slashCommands).toEqual(
337 expectedCommands,
338 );
339 expect(yield* Ref.get(harness.probeCalls)).toBe(1);
340 }),
341 ),
342 );
343​
344 it.effect("does not retain a disposable sign-in workspace", () =>
345 Effect.scoped(
346 Effect.gen(function* () {
347 const harness = yield* makeHarness();
348 yield* harness.initialize;
349 yield* harness.provider.onSessionStarted(started);
350 yield* harness.provider.onAvailableCommands(commands);
351 const snapshot = yield* harness.provider.snapshot.getSnapshot;
352 expect(snapshot.models).toHaveLength(11);
353 expect(snapshot.slashCommands).toEqual(expectedCommands);
354 expect(snapshot.workspaceSnapshots).toEqual([]);
355 }),
356 ),
357 );
358​
359 it.effect("clears all account metadata on sign-out and authentication failure", () =>
360 Effect.scoped(
361 Effect.gen(function* () {
362 const harness = yield* makeHarness();
363 yield* harness.initialize;
364 for (const clear of [harness.provider.onSignedOut, harness.provider.onAuthRequired]) {
365 yield* harness.provider.onSessionStarted(started, "/workspace");
366 yield* harness.provider.onAvailableCommands(commands, "/workspace");
367 yield* clear;
368 expect(yield* harness.provider.snapshot.getSnapshot).toMatchObject({
369 installed: true,
370 status: "warning",
371 auth: { status: "unauthenticated" },
372 models: [],
373 slashCommands: [],
374 skills: [],
375 workspaceSnapshots: [],
376 supportsTextGeneration: false,
377 });
378 yield* harness.provider.onAvailableCommands(commands, "/workspace");
379 yield* harness.provider.onConfigOptionsUpdated([modelConfig]);
380 expect((yield* harness.provider.snapshotForCwd("/workspace")).slashCommands).toEqual([]);
381 expect((yield* harness.provider.snapshot.getSnapshot).models).toEqual([]);
382 }
383 const refreshed = yield* harness.provider.snapshot.refresh;
384 expect(refreshed.auth.status).toBe("unauthenticated");
385 expect(refreshed.supportsTextGeneration).toBe(false);
386 }),
387 ),
388 );
389​
390 it.effect("replaces live model choices and accepts an empty catalog", () =>
391 Effect.scoped(
392 Effect.gen(function* () {
393 const harness = yield* makeHarness();
394 yield* harness.initialize;
395 yield* harness.provider.onSessionStarted(started, "/workspace");
396 yield* harness.provider.onAvailableCommands(commands, "/workspace");
397 const before = yield* harness.provider.snapshot.getSnapshot;
398 const configOptions = [
399 {
400 ...modelConfig,
401 currentValue: "gemini-3.8-flash-high",
402 options: modelOptions.slice(0, 3),
403 },
404 ];
405 const nextSnapshot = yield* Stream.toPull(
406 harness.provider.snapshot.streamChanges.pipe(
407 Stream.filter((snapshot) => snapshot.models.length === 3),
408 ),
409 );
410 yield* harness.provider.onConfigOptionsUpdated(configOptions);
411 expect((yield* nextSnapshot)[0]).toMatchObject({
412 models: buildAntigravityModelsFromSession({ configOptions }),
413 auth: before.auth,
414 workspaceSnapshots: before.workspaceSnapshots,
415 slashCommands: expectedCommands,
416 });
417 yield* harness.provider.onConfigOptionsUpdated([]);
418 expect((yield* harness.provider.snapshot.getSnapshot).models).toEqual([]);
419 }),
420 ),
421 );
422​
423 it.effect("replaces one account's catalog instead of combining accounts", () =>
424 Effect.scoped(
425 Effect.gen(function* () {
426 const harness = yield* makeHarness();
427 yield* harness.initialize;
428 yield* harness.provider.onSessionStarted(started);
429 yield* harness.provider.onSignedOut;
430 yield* harness.provider.onSessionStarted({
431 ...started,
432 sessionSetupResult: {
433 sessionId: "new-account-session",
434 configOptions: [
435 { ...modelConfig, currentValue: "gemini-pro-agent", options: [modelOptions[9]!] },
436 ],
437 },
438 });
439 expect(
440 (yield* harness.provider.snapshot.getSnapshot).models.map((model) => model.slug),
441 ).toEqual(["gemini-pro-agent"]);
442 }),
443 ),
444 );
445​
446 it.effect("retains known account metadata when a local health check fails", () =>
447 Effect.scoped(
448 Effect.gen(function* () {
449 const harness = yield* makeHarness();
450 yield* harness.initialize;
451 yield* harness.provider.onSessionStarted(started, "/workspace");
452 yield* harness.provider.onAvailableCommands(commands, "/workspace");
453 yield* Ref.set(
454 harness.probe,
455 Effect.fail(EffectAcpErrors.AcpRequestError.internalError("probe failed")),
456 );
457 const snapshot = yield* harness.provider.snapshot.refresh;
458 expect(snapshot).toMatchObject({
459 installed: true,
460 status: "error",
461 auth: { status: "authenticated" },
462 });
463 expect(snapshot.models).toEqual(buildAntigravityModelsFromSession(sessionSetupResult));
464 expect(snapshot.slashCommands).toEqual(expectedCommands);
465 expect(snapshot.workspaceSnapshots?.[0]?.cwd).toBe("/workspace");
466 }),
467 ),
468 );
469​
470 it.effect("allows a slow packaged runtime health check to finish", () =>
471 Effect.scoped(
472 Effect.gen(function* () {
473 const harness = yield* makeHarness();
474 yield* harness.initialize;
475 const entered = yield* Deferred.make<void>();
476 const initialized = yield* Deferred.make<EffectAcpSchema.InitializeResponse>();
477 yield* Ref.set(
478 harness.probe,
479 Deferred.succeed(entered, undefined).pipe(Effect.andThen(Deferred.await(initialized))),
480 );
481​
482 const refresh = yield* harness.provider.snapshot.refresh.pipe(Effect.forkChild);
483 yield* Deferred.await(entered);
484 yield* TestClock.adjust("47 seconds");
485 yield* Deferred.succeed(initialized, initializeResult);
486 const snapshot = yield* Fiber.join(refresh);
487​
488 expect(snapshot).toMatchObject({
489 installed: true,
490 status: "warning",
491 auth: { status: "unknown" },
492 });
493 }),
494 ),
495 );
496​
497 it.effect("closes a stalled health probe at its deadline", () =>
498 Effect.scoped(
499 Effect.gen(function* () {
500 const harness = yield* makeHarness();
501 yield* harness.initialize;
502 const entered = yield* Deferred.make<void>();
503 const closed = yield* Deferred.make<void>();
504 yield* Ref.set(
505 harness.probe,
506 Deferred.succeed(entered, undefined).pipe(
507 Effect.andThen(Effect.never),
508 Effect.ensuring(Deferred.succeed(closed, undefined)),
509 ),
510 );
511 const refresh = yield* harness.provider.snapshot.refresh.pipe(Effect.forkChild);
512 yield* Deferred.await(entered);
513 yield* TestClock.adjust("90 seconds");
514 const snapshot = yield* Fiber.join(refresh);
515 yield* Deferred.await(closed);
516 expect(snapshot.status).toBe("error");
517 expect(snapshot.message).toContain("90 seconds");
518 }),
519 ),
520 );
521​
522 it.effect("distinguishes missing executables from a failed installed executable", () =>
523 Effect.scoped(
524 Effect.gen(function* () {
525 const harness = yield* makeHarness();
526 yield* harness.initialize;
527 const failures = [
528 {
529 error: new EffectAcpErrors.AcpSpawnError({ cause: { code: "ENOENT" } }),
530 installed: false,
531 },
532 {
533 error: new EffectAcpErrors.AcpSpawnError({ cause: { code: "EACCES" } }),
534 installed: true,
535 },
536 {
537 error: new ProviderSetupError({
538 instanceId,
539 operation: "resolve",
540 detail: "Antigravity is not installed.",
541 }),
542 installed: false,
543 },
544 ];
545 for (const { error, installed } of failures) {
546 yield* harness.provider.onSessionStarted(started, "/workspace");
547 yield* harness.provider.onAvailableCommands(commands, "/workspace");
548 yield* Ref.set(harness.probe, Effect.fail(error));
549 const snapshot = yield* harness.provider.snapshot.refresh;
550 expect(snapshot).toMatchObject({
551 installed,
552 status: "error",
553 auth: { status: "authenticated" },
554 });
555 expect(snapshot.models).toHaveLength(installed ? 11 : 0);
556 expect(snapshot.slashCommands).toHaveLength(installed ? 2 : 0);
557 expect(snapshot.workspaceSnapshots).toHaveLength(installed ? 1 : 0);
558 expect(snapshot.supportsTextGeneration).toBe(installed);
559 }
560 }),
561 ),
562 );
563​
564 it.effect("does not let an old health result restore a signed-out account", () =>
565 Effect.scoped(
566 Effect.gen(function* () {
567 const harness = yield* makeHarness();
568 yield* harness.initialize;
569 yield* harness.provider.onSessionStarted(started);
570 const releaseProbe = yield* Deferred.make<EffectAcpSchema.InitializeResponse>();
571 const probeEntered = yield* Deferred.make<void>();
572 yield* Ref.set(
573 harness.probe,
574 Deferred.succeed(probeEntered, undefined).pipe(
575 Effect.andThen(Deferred.await(releaseProbe)),
576 ),
577 );
578 const refresh = yield* harness.provider.snapshot.refresh.pipe(Effect.forkChild);
579 yield* Deferred.await(probeEntered);
580 yield* harness.provider.onSignedOut;
581 yield* Deferred.succeed(releaseProbe, initializeResult);
582 const snapshot = yield* Fiber.join(refresh);
583 expect(snapshot).toMatchObject({
584 auth: { status: "unauthenticated" },
585 models: [],
586 supportsTextGeneration: false,
587 });
588 }),
589 ),
590 );
591​
592 it.effect("exposes helper support only when the supplied safety check allows it", () =>
593 Effect.scoped(
594 Effect.gen(function* () {
595 const harness = yield* makeHarness({ safe: false });
596 yield* harness.initialize;
597 yield* harness.provider.onSessionStarted(started);
598 expect((yield* harness.provider.snapshot.getSnapshot).supportsTextGeneration).toBe(false);
599 yield* Ref.set(harness.safety, Effect.succeed(true));
600 yield* harness.provider.snapshot.refresh;
601 expect((yield* harness.provider.snapshot.getSnapshot).supportsTextGeneration).toBe(true);
602 }),
603 ),
604 );
605​
606 it.effect("keeps discovered workspace skills through session and command updates", () =>
607 Effect.scoped(
608 Effect.gen(function* () {
609 const harness = yield* makeHarness();
610 yield* harness.initialize;
611 const skills = [
612 {
613 name: "deploy",
614 description: "Ship it",
615 path: "/workspace/.agent/skills/deploy",
616 enabled: true,
617 },
618 ];
619 const discovered = yield* harness.provider.snapshotForCwd("/workspace", skills);
620 expect(discovered.skills).toEqual(skills);
621 yield* harness.provider.onSessionStarted(started, "/workspace");
622 yield* harness.provider.onAvailableCommands(commands, "/workspace");
623 const after = yield* harness.provider.snapshot.getSnapshot;
624 expect(
625 after.workspaceSnapshots?.find((entry) => entry.cwd === "/workspace")?.skills,
626 ).toEqual(skills);
627 expect((yield* harness.provider.snapshotForCwd("/workspace")).skills).toEqual(skills);
628​
629 const rescanned = [
630 ...skills,
631 { name: "review", path: "/workspace/.agent/skills/review", enabled: true },
632 ];
633 yield* harness.provider.snapshotForCwd("/workspace", rescanned);
634 yield* harness.provider.onSessionStarted(started, "/workspace");
635 expect(
636 (yield* harness.provider.snapshot.getSnapshot).workspaceSnapshots?.find(
637 (entry) => entry.cwd === "/workspace",
638 )?.skills,
639 ).toEqual(rescanned);
640 }),
641 ),
642 );
643​
644 it.effect("bounds workspace metadata without starting sessions for workspace lookup", () =>
645 Effect.scoped(
646 Effect.gen(function* () {
647 const harness = yield* makeHarness();
648 yield* harness.initialize;
649 yield* harness.provider.onSessionStarted(started);
650 for (let index = 0; index < 35; index++) {
651 yield* harness.provider.onAvailableCommands(commands, `/workspace-${index}`);
652 }
653 const snapshot = yield* harness.provider.snapshotForCwd("/workspace-34");
654 expect(snapshot.workspaceSnapshots).toHaveLength(32);
655 expect(snapshot.workspaceSnapshots?.[0]?.cwd).toBe("/workspace-3");
656 expect(snapshot.slashCommands).toEqual(expectedCommands);
657 expect(yield* Ref.get(harness.probeCalls)).toBe(1);
658 }),
659 ),
660 );
661});