Add type inference test for router context variables#106
Conversation
- Test validates thread, session, sessionId are typed correctly - Ensures context variables are not typed as 'any'
|
Warning Rate limit exceeded@jhaynie has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 12 minutes and 7 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (2)
WalkthroughA new test suite is added to validate compile-time type inference for router context variables, verifying that context properties like Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/runtime/test/router-type-inference.test.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{ts,tsx,js,jsx,json}
📄 CodeRabbit inference engine (AGENTS.md)
Format code with Prettier using tabs (width 3), single quotes, semicolons, and 100 character line width
Files:
packages/runtime/test/router-type-inference.test.ts
packages/*/test/**/*.test.ts
📄 CodeRabbit inference engine (AGENTS.md)
packages/*/test/**/*.test.ts: Place all tests intest/folder parallel tosrc/folder, never use__tests__/,__test__/, or*.test.tsfiles insrc/folder
Tests intest/folder must import from../src/relative path, not from package distribution
Use@agentuity/test-utilspackage for reusable test helpers likecreateMockLogger(),mockFetch(), andcreateMockAdapter()
Files:
packages/runtime/test/router-type-inference.test.ts
packages/**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
packages/**/*.{ts,tsx}: Always useInferInputandInferOutputfrom@agentuity/corefor schema type inference, notStandardSchemaV1.InferOutput
StructuredError properties are directly on the error instance, not under a.dataproperty
Files:
packages/runtime/test/router-type-inference.test.ts
packages/runtime/test/**/*.test.ts
📄 CodeRabbit inference engine (AGENTS.md)
packages/runtime/test/**/*.test.ts: When testing agents and routes, do NOT add type annotations to handler parameters; let TypeScript infer types from agent schema
For route testing in @agentuity/runtime, useapp.request()instead of Hono'stestClient()to avoid type inference issues
packages/runtime/test/**/*.test.ts: Use app.request() for testing routes, NOT testClient() due to Hono's type inference limitations
Do NOT add type annotations to agent handler parameters in tests - let TypeScript infer types
Import test helpers from ../src/ not ../
Use TestAgentContext from test/helpers/test-context.ts for mocking agent contexts
Use mock storage interfaces (kv, stream, vector) for testing instead of real implementations
Files:
packages/runtime/test/router-type-inference.test.ts
packages/runtime/**/*.{ts,tsx}
📄 CodeRabbit inference engine (packages/runtime/AGENTS.md)
Use extensive TypeScript generics for type safety
Files:
packages/runtime/test/router-type-inference.test.ts
🧬 Code graph analysis (1)
packages/runtime/test/router-type-inference.test.ts (1)
apps/testing/integration-suite/src/test/suite.ts (1)
test(155-157)
🔇 Additional comments (3)
packages/runtime/test/router-type-inference.test.ts (3)
1-9: LGTM! Clean imports and appropriate test structure.The imports follow the coding guidelines correctly, using relative paths from
../src/and importing type definitions needed for compile-time type validation.
11-34: LGTM! Effective compile-time type validation.This test correctly validates that
c.var.threadis typed asThreadthrough type assertions and property access. The approach of usingexpect(true).toBe(true)is appropriate for compile-time type checks where the value is in successful TypeScript compilation.
36-72: LGTM! Consistent type validation approach.Tests 2 and 3 follow the same effective pattern as test 1, validating Session and sessionId types through compile-time type assertions and property/method access.
- Add type-validation.test.ts with 12 comprehensive tests - Validate Thread, Session, Variables, and Env types - Confirm proper type inference in route handlers - Add TYPE_VALIDATION_REPORT.md documenting type correctness - All 191 tests passing, 0 type errors, 0 lint errors
Purpose
Validates that
createRouter()properly types context variables likethread,session, andsessionId- ensuring they're not typed asany.Changes
Testing
anytypes in context variablesRelated PR
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.