Skip to content

feat: add billing/inferenceLog/agentChat module loaders + wire into agentic-server#1219

Merged
pyramation merged 1 commit into
mainfrom
feat/billing-loader
May 23, 2026
Merged

feat: add billing/inferenceLog/agentChat module loaders + wire into agentic-server#1219
pyramation merged 1 commit into
mainfrom
feat/billing-loader

Conversation

@pyramation
Copy link
Copy Markdown
Contributor

Summary

Adds three module loaders to express-context and wires them into agentic-server, replacing the package's internal discovery queries with the shared useModule() pattern.

express-context loaders added:

  • billing — resolves BillingConfig (public/private schema, record_usage, check_billing_quota functions) from metaschema_modules_public.billing_module
  • inferenceLog — resolves InferenceLogConfig (schema, table name) from metaschema_modules_public.inference_log_module
  • agentChat — resolves AgentChatConfig (thread/message/task table names) from metaschema_modules_public.agent_chat_module

All three are registered in createDefaultRegistry() and exported from the package index. BuiltinModuleMap is updated for type-safe useModule() calls.

agentic-server changes:

  • Router now uses ctx.useModule('agentChat') instead of getAgentDiscovery(ctx.pool, ctx.api.dbname)
  • Router now uses ctx.useModule('billing') + ctx.useModule('inferenceLog') instead of getDatabaseConfig(ctx.pool, ctx.databaseId)
  • billing.ts imports types from @constructive-io/express-context instead of local ./discovery
  • The discovery.ts module remains exported as public API (backwards compat) but is no longer used internally by the router

Tests:

  • Router tests rewritten to mock useModule instead of pool.query for discovery
  • Added supertest + @types/supertest for proper HTTP assertions
  • All 22 tests pass

Review & Testing Checklist for Human

  • Verify the SQL queries in the three loaders match the actual metaschema_modules_public table schemas (billing_module, inference_log_module, agent_chat_module)
  • Confirm the checkBillingQuotaFunction hardcoded value 'check_billing_quota' is correct for all deployments (or should come from the module row)
  • Test with a real provisioned database that the loaders resolve correctly via req.constructive.useModule('billing') etc.

Notes

  • The discovery.ts module in agentic-server is still exported but no longer used internally. It can be deprecated/removed in a follow-up.
  • TTL values: billing (5 min), inferenceLog (5 min), agentChat (1 min) — matching the existing loader patterns.

Link to Devin session: https://app.devin.ai/sessions/2b5a29d83d3f478e8d3d972653b4879c
Requested by: @pyramation

…gentic-server

- Add three module loaders to express-context/src/loaders/:
  - billing.ts: resolves BillingConfig (schema, record_usage, check_quota functions)
  - inference-log.ts: resolves InferenceLogConfig (schema, table name)
  - agent-chat.ts: resolves AgentChatConfig (thread/message/task table names)
- Register loaders in createDefaultRegistry() and export from express-context
- Add BillingConfig, InferenceLogConfig, AgentChatConfig to BuiltinModuleMap
- Update agentic-server router to use ctx.useModule() instead of getAgentDiscovery/getDatabaseConfig
- Update agentic-server billing.ts to import types from express-context
- Fix and update router tests to mock useModule instead of pool.query for discovery
- Add supertest as dev dependency for proper HTTP testing
@devin-ai-integration
Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@pyramation pyramation merged commit 250e657 into main May 23, 2026
37 checks passed
@pyramation pyramation deleted the feat/billing-loader branch May 23, 2026 06:39
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