Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

test: pair each RPC method with its controller namespace

lord_Tyriond0d3bf0348d8
diff --git a/app/src/services/__tests__/rpcMethods.test.ts b/app/src/services/__tests__/rpcMethods.test.ts
index 939ff8233b..70701baf7c 100644
--- a/app/src/services/__tests__/rpcMethods.test.ts
+++ b/app/src/services/__tests__/rpcMethods.test.ts
@@ -4,6 +4,53 @@ import { describe, expect, test } from 'vitest';
import { CORE_RPC_METHODS, LEGACY_METHOD_ALIASES, normalizeRpcMethod } from '../rpcMethods';
+// Controller identity comes from the namespace/function fields on one literal.
+// Matching adjacent fields also keeps declarations in separate blocks apart.
+function schemaMethodPairs(source: string): Set<string> {
+ const pairs = source.matchAll(
+ /\b(?:Channel)?ControllerSchema\s*\{\s*namespace:\s*"([a-z0-9_]+)"\s*,\s*function:\s*"([a-z0-9_]+)"/g
+ );
+ return new Set(Array.from(pairs, ([, namespace, fn]) => `openhuman.${namespace}_${fn}`));
+}
+
+describe('schema method pairing', () => {
+ test('keeps shared function names scoped to their controller namespace', () => {
+ const methods = schemaMethodPairs(`
+ ControllerSchema { namespace: "config", function: "update", description: "config" }
+ ControllerSchema { namespace: "health", function: "get", description: "health" }
+ `);
+ expect(methods.has('openhuman.config_update')).toBe(true);
+ expect(methods.has('openhuman.health_get')).toBe(true);
+ expect(methods.has('openhuman.config_get')).toBe(false);
+ });
+
+ test('detects a removed controller while the namespace and function still exist', () => {
+ const declaration =
+ 'ControllerSchema { namespace: "config", function: "get", description: "read" }';
+ const source = `${declaration}
+ ControllerSchema { namespace: "config", function: "update", description: "write" }
+ ChannelControllerSchema { namespace: "channels", function: "get", description: "channel" }
+ `;
+ expect(schemaMethodPairs(source).has(CORE_RPC_METHODS.configGet)).toBe(true);
+ const removed = source.replace(declaration, '');
+ expect(removed).toContain('namespace: "config"');
+ expect(removed).toContain('function: "get"');
+ expect(schemaMethodPairs(removed).has(CORE_RPC_METHODS.configGet)).toBe(false);
+ });
+
+ test('reads multiline and channel schema literals and ignores unrelated fields', () => {
+ const methods = schemaMethodPairs(`
+ ChannelControllerSchema {
+ namespace: "channels",
+ function: "list",
+ description: "List channels",
+ }
+ FieldSchema { namespace: "config", function: "get" }
+ `);
+ expect([...methods]).toEqual(['openhuman.channels_list']);
+ });
+});
+
describe('rpcMethods catalog', () => {
describe('normalizeRpcMethod', () => {
test('resolves all legacy aliases to their canonical core method', () => {
@@ -130,9 +177,8 @@ describe('rpcMethods catalog', () => {
// inference/schemas.rs → schemas_part_01.rs, …), and each split silently
// moved the `function: "…"` literals this guard greps out of the file it
// was reading. Sweeping the siblings makes the corpus follow the splits.
- // Over-inclusion is harmless — the guard only searches for substrings —
- // and `readFileSync` still throws if a listed base file moves entirely,
- // which is the loud failure we want.
+ // Each namespace/function pair is read from a single controller literal.
+ // `readFileSync` throws if a listed base file moves entirely.
const readRustTree = (dir: string): string[] =>
fs.readdirSync(dir, { withFileTypes: true }).flatMap(entry => {
const entryPath = path.join(dir, entry.name);
@@ -192,32 +238,16 @@ describe('rpcMethods catalog', () => {
),
].join('\n');
+ const registeredMethods = schemaMethodPairs(schemaSources);
for (const method of Object.values(CORE_RPC_METHODS)) {
// core.* methods (e.g. core.ping) are special dispatch methods, not in the schema catalog.
if (!method.startsWith('openhuman.')) continue;
const methodRoot = method.slice('openhuman.'.length);
// Memory v2 methods have their own guard below.
if (methodRoot.startsWith('memory_')) continue;
- const namespace = methodRoot.startsWith('auth_')
- ? 'auth'
- : methodRoot.startsWith('inference_')
- ? 'inference'
- : methodRoot.startsWith('embeddings_')
- ? 'embeddings'
- : methodRoot.startsWith('providers_')
- ? 'providers'
- : methodRoot.startsWith('mcp_clients_')
- ? 'mcp_clients'
- : methodRoot.startsWith('health_')
- ? 'health'
- : methodRoot.startsWith('channels_')
- ? 'channels'
- : methodRoot.startsWith('tool_registry_')
- ? 'tool_registry'
- : 'config';
- const fnName = methodRoot.slice(`${namespace}_`.length);
- expect(schemaSources).toContain(`namespace: "${namespace}"`);
- expect(schemaSources).toContain(`function: "${fnName}"`);
+ expect(registeredMethods, `${method} must have a complete controller declaration`).toContain(
+ method
+ );
}
});
// Memory v2 (docs/specs/memory-v2.md): every `openhuman.memory_*` method the