Skip to content

Add agent service tests#748

Open
devdattatalele wants to merge 1 commit into
metorial:devfrom
devdattatalele:add-agent-service-tests
Open

Add agent service tests#748
devdattatalele wants to merge 1 commit into
metorial:devfrom
devdattatalele:add-agent-service-tests

Conversation

@devdattatalele

@devdattatalele devdattatalele commented Jun 12, 2026

Copy link
Copy Markdown

Adds vitest coverage for the agent module services.

agent.test.ts (14 tests) — listAgents (scoping, voyager search, filter passthrough), getAgentById, createAgent, updateAgent (tenant check, identity-actor flow), upsertAgent (hash hit, slug generation, P2002 race retry, error propagation), archiveAgent.

agentClient.test.ts (10 tests) — listAgentClients (scoping, whitespace search, voyager), getAgentClientById, upsertAgentClient (OAuth registration vs system_client, new-vs-existing index queue), createAgentClient.

agentInstance.test.ts (7 tests) — listAgentInstances (tenant check, filter passthrough), getAgentInstanceById, upsertAgentInstance (registration/client mismatch, tool_call constraint, hash + upsert).

Mocking pattern mirrors tenant/environment.test.ts and monitor/alert.test.ts (vi.mock @metorial-subspace/db, @lowerdeck/service, @lowerdeck/pagination). Source unchanged.

31 tests, prettier-clean.


Note

Low Risk
Test-only additions with no runtime or API behavior changes.

Overview
Adds Vitest unit tests for the agent module’s three service layers (agent, agentClient, agentInstance) with no production code changes.

agentService (~14 tests): list scoping and Voyager search/filter passthrough; get-by-id not-found handling; create/update/archive flows through identity actors and checkTenant; upsert hash short-circuit, slug generation, Prisma P2002 race retry, and error propagation.

agentClientService (~10 tests): list scoping and search (including whitespace-only search skipped); OAuth registration on mcp_client_oauth vs none for system_client; post-transaction search indexing only on new upserts; createAgentClient delegating to upsert.

agentInstanceService (~7 tests): tenant checks and filters on list/get; upsert validation (registration/client mismatch, tool_call agent type constraint); hash-based agentOid_hash upsert.

Mocks follow the same pattern as other subspace service tests (@metorial-subspace/db, @lowerdeck/service, @lowerdeck/pagination, plus module-specific deps).

Reviewed by Cursor Bugbot for commit adbd732. Bugbot is set up for automated code reviews on this repo. Configure here.

@devdattatalele

Copy link
Copy Markdown
Author

@herber are their any CLA Document to be signed before submitting pr?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant