mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-06-15 05:47:18 -07:00
ae899acad5
This commit serves as the final polish for the context architecture unification.
Key Changes:
- **Lexical Cleansing:** Swept the entire `context` module (including tests, documentation, and snapshot configurations) to replace all legacy terms ('worker', 'ContextWorker', 'StateSnapshotWorker') with their modern unified equivalents ('async pipeline', 'AsyncContextProcessor', 'StateSnapshotAsyncProcessor').
- **Registry Cleanup:** Stripped `registry.ts` of `ContextWorkerDef` maps, unifying around a single, clean processor definition registry.
- **File Reorganization:** Dismantled the monolithic `sidecar/` directory (which initially housed both engine machinery and configuration loaders).
- `pipeline/`: Now houses the core execution engine (`orchestrator`, `inbox`, `contextWorkingBuffer`, `environment`).
- `config/`: Now exclusively contains the dynamic JSON configuration logic (`SidecarLoader`, `profiles`, `schema`, `registry`).
49 lines
1.7 KiB
TypeScript
49 lines
1.7 KiB
TypeScript
/**
|
|
* @license
|
|
* Copyright 2026 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
import { describe, it, expect } from 'vitest';
|
|
import { LiveInbox, InboxSnapshotImpl } from './inbox.js';
|
|
import { DeterministicIdGenerator } from '../system/DeterministicIdGenerator.js';
|
|
|
|
describe('Inbox', () => {
|
|
it('should publish messages and provide snapshots', () => {
|
|
const inbox = new LiveInbox();
|
|
const idGenerator = new DeterministicIdGenerator('mock-uuid-');
|
|
|
|
inbox.publish('test-topic', { data: 'hello' }, idGenerator);
|
|
inbox.publish('other-topic', { data: 'world' }, idGenerator);
|
|
|
|
const messages = inbox.getMessages();
|
|
expect(messages.length).toBe(2);
|
|
expect(messages[0].topic).toBe('test-topic');
|
|
expect(messages[0].payload).toEqual({ data: 'hello' });
|
|
});
|
|
|
|
it('should drain consumed messages from the snapshot', () => {
|
|
const inbox = new LiveInbox();
|
|
const idGenerator = new DeterministicIdGenerator('mock-uuid-');
|
|
|
|
inbox.publish('test-topic', { data: 'hello' }, idGenerator);
|
|
inbox.publish('other-topic', { data: 'world' }, idGenerator);
|
|
|
|
const messages = inbox.getMessages();
|
|
const snapshot = new InboxSnapshotImpl(messages);
|
|
|
|
const filtered = snapshot.getMessages<{ data: string }>('test-topic');
|
|
expect(filtered.length).toBe(1);
|
|
expect(filtered[0].payload.data).toBe('hello');
|
|
|
|
// Consume the message
|
|
snapshot.consume(filtered[0].id);
|
|
|
|
// Provide the consumed IDs to the real inbox to drain them
|
|
inbox.drainConsumed(snapshot.getConsumedIds());
|
|
|
|
const finalMessages = inbox.getMessages();
|
|
expect(finalMessages.length).toBe(1);
|
|
expect(finalMessages[0].topic).toBe('other-topic');
|
|
});
|
|
});
|