CodeRabbit Generated Unit Tests: Add unit tests#537
CodeRabbit Generated Unit Tests: Add unit tests#537coderabbitai[bot] wants to merge 75 commits intofix/guild-selector-categoriesfrom
Conversation
Replace the CLI subprocess model (cli-process.js + anthropicClient.js) with direct Vercel AI SDK calls via a new aiClient.js wrapper and aiCost.js for automatic token cost tracking. Key changes: - Add generate() and stream() wrappers with retry logic (3-attempt exponential backoff), timeout/abort handling, and provider caching - Automatic cost calculation via token-costs library with model ID normalization - Split triage config: separate classifier (Haiku) and responder (Sonnet) models with per-role budgets, API keys, and base URLs - Fix 19 issues found in migration review: CostClient race condition, cached token extraction, truncated classification confidence, thinkingTokens default, async onChunk safety, double-delete in automod, budget enforcement logging, timer cleanup, config validation gaps, and TypeScript type corrections - Add 17 new tests covering retry logic, error classification, abort handling, race conditions, and all fixed edge cases - Remove cli-process.js (22KB subprocess state machine) and anthropicClient.js
Any provider:model string now resolves automatically using <PROVIDER>_API_KEY and <PROVIDER>_BASE_URL env vars, with ANTHROPIC_API_KEY as fallback. Minimax and Codex work out of the box — no provider-specific code needed.
- Add MiniMax local pricing table (token-costs doesn't cover it yet) - Track cacheCreationInputTokens alongside cacheReadInputTokens - Use authToken instead of apiKey for non-Anthropic providers - Fix provider metadata extraction to check provider-specific key before falling back to anthropic - Fix MiniMax base URL to include /v1 suffix - Harden JSON fence stripping for providers that prepend whitespace - Genericize error messages from "Anthropic" to "AI provider" - Remove stale DISABLE_PROMPT_CACHING references - Update tests for all of the above
- Convert aiClient.js to lazy-load @ai-sdk/anthropic and ai modules - Add preloadSDK() for background pre-warming at startup - Add detailed timing breakdowns to generate() and stream() - Add timing instrumentation to triage classification and response - Simplify aiCost.js to use local model-pricing.json lookup - Update config to use MiniMax models and reduce contextMessages to 5 - Fix various test mocks for new SDK patterns Performance improvements: - Bot startup no longer blocked by ~6s SDK import - SDK preloads in background while Discord connects - Timing logs identify latency sources (API vs SDK vs Discord) Known issue: Response latency of 8-16s with MiniMax provider needs further optimization (API-side, not SDK).
Bumps [simple-icons](https://github.com/simple-icons/simple-icons) from 16.15.0 to 16.16.0. - [Release notes](https://github.com/simple-icons/simple-icons/releases) - [Commits](simple-icons/simple-icons@16.15.0...16.16.0) --- updated-dependencies: - dependency-name: simple-icons dependency-version: 16.16.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
Bumps [turbo](https://github.com/vercel/turborepo) from 2.9.3 to 2.9.6. - [Release notes](https://github.com/vercel/turborepo/releases) - [Changelog](https://github.com/vercel/turborepo/blob/main/RELEASE.md) - [Commits](vercel/turborepo@v2.9.3...v2.9.6) --- updated-dependencies: - dependency-name: turbo dependency-version: 2.9.6 dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com>
Bumps [@sentry/node](https://github.com/getsentry/sentry-javascript) from 10.47.0 to 10.48.0. - [Release notes](https://github.com/getsentry/sentry-javascript/releases) - [Changelog](https://github.com/getsentry/sentry-javascript/blob/develop/CHANGELOG.md) - [Commits](getsentry/sentry-javascript@10.47.0...10.48.0) --- updated-dependencies: - dependency-name: "@sentry/node" dependency-version: 10.48.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
Bumps [@biomejs/biome](https://github.com/biomejs/biome/tree/HEAD/packages/@biomejs/biome) from 2.4.10 to 2.4.11. - [Release notes](https://github.com/biomejs/biome/releases) - [Changelog](https://github.com/biomejs/biome/blob/main/packages/@biomejs/biome/CHANGELOG.md) - [Commits](https://github.com/biomejs/biome/commits/@biomejs/biome@2.4.11/packages/@biomejs/biome) --- updated-dependencies: - dependency-name: "@biomejs/biome" dependency-version: 2.4.11 dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com>
Bumps @paper-design/shaders-react from 0.0.72 to 0.0.74. --- updated-dependencies: - dependency-name: "@paper-design/shaders-react" dependency-version: 0.0.74 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com>
Bumps [pnpm/action-setup](https://github.com/pnpm/action-setup) from 5.0.0 to 6.0.0. - [Release notes](https://github.com/pnpm/action-setup/releases) - [Commits](pnpm/action-setup@v5.0.0...v6.0.0) --- updated-dependencies: - dependency-name: pnpm/action-setup dependency-version: 6.0.0 dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com>
Bumps [anthropics/claude-code-action](https://github.com/anthropics/claude-code-action) from 1.0.92 to 1.0.93. - [Release notes](https://github.com/anthropics/claude-code-action/releases) - [Commits](anthropics/claude-code-action@657fb7c...b47fd72) --- updated-dependencies: - dependency-name: anthropics/claude-code-action dependency-version: 1.0.93 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com>
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 7.0.0 to 7.0.1. - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](actions/upload-artifact@v7.0.0...v7.0.1) --- updated-dependencies: - dependency-name: actions/upload-artifact dependency-version: 7.0.1 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com>
Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 7.0.0 to 7.1.0. - [Release notes](https://github.com/docker/build-push-action/releases) - [Commits](docker/build-push-action@v7.0.0...v7.1.0) --- updated-dependencies: - dependency-name: docker/build-push-action dependency-version: 7.1.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
Bumps [mem0ai](https://github.com/mem0ai/mem0/tree/HEAD/mem0-ts) from 2.4.2 to 2.4.6. - [Release notes](https://github.com/mem0ai/mem0/releases) - [Changelog](https://github.com/mem0ai/mem0/blob/ts-v2.4.6/docs/changelog.mdx) - [Commits](https://github.com/mem0ai/mem0/commits/ts-v2.4.6/mem0-ts) --- updated-dependencies: - dependency-name: mem0ai dependency-version: 2.4.6 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com>
Bumps [diff](https://github.com/kpdecker/jsdiff) from 8.0.4 to 9.0.0. - [Changelog](https://github.com/kpdecker/jsdiff/blob/master/release-notes.md) - [Commits](kpdecker/jsdiff@8.0.4...v9.0.0) --- updated-dependencies: - dependency-name: diff dependency-version: 9.0.0 dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com>
Bumps [dotenv](https://github.com/motdotla/dotenv) from 17.4.0 to 17.4.2. - [Changelog](https://github.com/motdotla/dotenv/blob/master/CHANGELOG.md) - [Commits](motdotla/dotenv@v17.4.0...v17.4.2) --- updated-dependencies: - dependency-name: dotenv dependency-version: 17.4.2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com>
Bumps [@anthropic-ai/claude-code](https://github.com/anthropics/claude-code) from 2.1.101 to 2.1.105. - [Release notes](https://github.com/anthropics/claude-code/releases) - [Changelog](https://github.com/anthropics/claude-code/blob/main/CHANGELOG.md) - [Commits](anthropics/claude-code@v2.1.101...v2.1.105) --- updated-dependencies: - dependency-name: "@anthropic-ai/claude-code" dependency-version: 2.1.105 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com>
Bumps @paper-design/shaders-react from 0.0.74 to 0.0.75. --- updated-dependencies: - dependency-name: "@paper-design/shaders-react" dependency-version: 0.0.75 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com>
Bumps [gsap](https://github.com/greensock/GSAP) from 3.14.2 to 3.15.0. - [Commits](greensock/GSAP@3.14.2...3.15.0) --- updated-dependencies: - dependency-name: gsap dependency-version: 3.15.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
Bumps [anthropics/claude-code-action](https://github.com/anthropics/claude-code-action) from 1.0.93 to 1.0.94. - [Release notes](https://github.com/anthropics/claude-code-action/releases) - [Commits](anthropics/claude-code-action@b47fd72...1c8b699) --- updated-dependencies: - dependency-name: anthropics/claude-code-action dependency-version: 1.0.94 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com>
Bumps [next-auth](https://github.com/nextauthjs/next-auth) from 4.24.13 to 4.24.14. - [Release notes](https://github.com/nextauthjs/next-auth/releases) - [Commits](https://github.com/nextauthjs/next-auth/compare/next-auth@4.24.13...next-auth@4.24.14) --- updated-dependencies: - dependency-name: next-auth dependency-version: 4.24.14 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com>
Bumps [@anthropic-ai/claude-code](https://github.com/anthropics/claude-code) from 2.1.105 to 2.1.109. - [Release notes](https://github.com/anthropics/claude-code/releases) - [Changelog](https://github.com/anthropics/claude-code/blob/main/CHANGELOG.md) - [Commits](anthropics/claude-code@v2.1.105...v2.1.109) --- updated-dependencies: - dependency-name: "@anthropic-ai/claude-code" dependency-version: 2.1.109 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com>
…on override - biome.json: bump $schema to 2.4.12 to match @biomejs/biome ^2.4.12 devDep - package.json: drop brace-expansion override; it forced ^2.0.2 which lacks the named `expand` export that minimatch@10.2.5 imports, breaking 32+ test files via node-pg-migrate -> glob -> minimatch. Natural pnpm resolution already picks post-CVE-2025-5889 versions across the dep tree (1.1.12, 2.1.0, 5.0.5). - pnpm-lock.yaml: regenerated - src/modules/triage-respond.js: biome auto-format (single-line ternary) - tests/utils/aiCost.test.js: drop unused `key` destructuring in for-of
Bumps [typescript](https://github.com/microsoft/TypeScript) from 6.0.2 to 6.0.3. - [Release notes](https://github.com/microsoft/TypeScript/releases) - [Commits](microsoft/TypeScript@v6.0.2...v6.0.3) --- updated-dependencies: - dependency-name: typescript dependency-version: 6.0.3 dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com>
Bumps [@sentry/node](https://github.com/getsentry/sentry-javascript) from 10.48.0 to 10.49.0. - [Release notes](https://github.com/getsentry/sentry-javascript/releases) - [Changelog](https://github.com/getsentry/sentry-javascript/blob/develop/CHANGELOG.md) - [Commits](getsentry/sentry-javascript@10.48.0...10.49.0) --- updated-dependencies: - dependency-name: "@sentry/node" dependency-version: 10.49.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
Bumps [anthropics/claude-code-action](https://github.com/anthropics/claude-code-action) from 1.0.97 to 1.0.99. - [Release notes](https://github.com/anthropics/claude-code-action/releases) - [Commits](anthropics/claude-code-action@905d4eb...c3d45e8) --- updated-dependencies: - dependency-name: anthropics/claude-code-action dependency-version: 1.0.99 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com>
Bumps [@anthropic-ai/claude-code](https://github.com/anthropics/claude-code) from 2.1.110 to 2.1.112. - [Release notes](https://github.com/anthropics/claude-code/releases) - [Changelog](https://github.com/anthropics/claude-code/blob/main/CHANGELOG.md) - [Commits](anthropics/claude-code@v2.1.110...v2.1.112) --- updated-dependencies: - dependency-name: "@anthropic-ai/claude-code" dependency-version: 2.1.112 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com>
minimatch@10.x does ESM named import from brace-expansion, but brace-expansion@1.1.13 is CJS. The override forced 1.1.13 everywhere including for minimatch 10.x which expects the ESM-native v5.x. The brace-expansion ReDoS vuln only affects the old minimatch@3.1.5 path (swagger-jsdoc) which naturally resolves 1.1.12 — acceptable risk for a dev-only dependency.
004_performance_indexes is a no-op placeholder that was added to fill the gap after its indexes were merged into 001_initial-schema. However, 004_voice_sessions was also created, creating two files with the same prefix. node-pg-migrate sorts alphabetically and expects 004_performance_indexes before 004_voice_sessions, but production already ran 004_voice_sessions — causing a startup crash on every deploy. Removing the no-op placeholder fixes the ordering conflict. Real performance indexes exist in 001_initial-schema and 017_performance_indexes.
Resolved conflicts: - package.json: keep SDK deps (@ai-sdk/anthropic, ai), drop claude-code CLI, bump sentry to 10.49.0 - pnpm-lock.yaml: regenerated
- aiClient: use Number.parseFloat (lint compliance) - aiClient: fix withRetry abort listener leak (remove on timer resolve) - aiClient: fail hard when non-Anthropic provider has no baseUrl - aiClient: record streamStarted inside withRetry callback for accurate timing - triage-respond: guard redundant RECENT_LIMIT fetch when buffer empty - triage-respond: use shared parseProviderModel helper (no duplication) - modelString: extract pure provider:model parser to avoid test mock churn - .env.example: clarify that missing provider key fails at invocation, not startup - tests: update aiClient test to expect new baseUrl-required contract
- footer.test: expect [Locked] instead of OVERSIGHT_LOCKED - home.spec E2E: use 'Network Status' instead of 'Trusted by' - home.spec E2E: use 'Active Users'/'Uptime' instead of 'Commands Processed'/'Current Uptime'
The test's requestAnimationFrame mock fired callbacks synchronously via queueMicrotask, creating an infinite RAF→setState→re-render→RAF spiral that caused JavaScript heap out of memory on CI. Fix: mock useInView to return false (animation never starts) and remove the RAF mock entirely since it's no longer needed.
|
|
Important Review skippedThis PR was authored by the user configured for CodeRabbit reviews. CodeRabbit does not review PRs authored by this user. It's recommended to use a dedicated user account to post CodeRabbit review feedback. ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
|
🚅 Deployed to the volvox-bot-pr-537 environment in volvox-bot
|
|
|
| Filename | Overview |
|---|---|
| tests/utils/anthropicClient.test.js | Tests for Anthropic SDK singleton client — entire file will fail at import because src/utils/anthropicClient.js does not exist in the repository. |
| tests/modules/cli-process.test.js | Comprehensive 1,300-line test suite for CLIProcess/AsyncQueue — all tests will fail at the dynamic import because src/modules/cli-process.js is absent from the repository. |
| tests/modules/triage-config.test.js | Tests for resolveTriageConfig, isChannelEligible, getDynamicInterval — source file exists but tests assert streaming, tokenRecycleLimit, and thinkingTokens defaults that don't match the current implementation. |
| tests/api/utils/configValidation.test.js | Extensive schema validation tests — the majority are correct against the live source, but the new triage describe block tests two properties (streaming, tokenRecycleLimit) missing from CONFIG_SCHEMA.triage. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[tests/api/utils/configValidation.test.js] -->|imports| B[src/api/utils/configValidation.js ✅ exists]
C[tests/modules/triage-config.test.js] -->|imports| D[src/modules/triage-config.js ✅ exists]
E[tests/modules/cli-process.test.js] -->|imports| F[src/modules/cli-process.js ❌ missing]
G[tests/utils/anthropicClient.test.js] -->|imports| H[src/utils/anthropicClient.js ❌ missing]
B --> B1{triage.streaming in schema?}
B1 -->|No ❌| B2[triage-new-fields block FAILS]
B1 -->|Yes ✅| B3[All other configValidation tests PASS]
D --> D1{streaming / tokenRecycleLimit / thinkingTokens default correct?}
D1 -->|No ❌| D2[triage-config default tests FAIL]
D1 -->|Yes ✅| D3[channel eligibility + interval tests PASS]
F --> F1[Dynamic import throws MODULE_NOT_FOUND]
F1 --> F2[All 40+ cli-process tests FAIL]
H --> H1[Dynamic import throws MODULE_NOT_FOUND]
H1 --> H2[All 9 anthropicClient tests FAIL]
Comments Outside Diff (1)
-
tests/modules/triage-config.test.js, line 13-18 (link)Three assertions mismatch the current source implementation
The current
resolveTriageConfiginsrc/modules/triage-config.js:- Does not return a
tokenRecycleLimitfield at all — soresult.tokenRecycleLimitisundefined, not20000(line 18). - Does not return a
streamingfield — soresult.streamingisundefined, notfalse(line 22-24). - Defaults
thinkingTokensto0(triageConfig.thinkingTokens ?? 0), not4096(line 27-29).
All three assertions will fail against the live source unless the source is updated to match.
Prompt To Fix With AI
This is a comment left during a code review. Path: tests/modules/triage-config.test.js Line: 13-18 Comment: **Three assertions mismatch the current source implementation** The current `resolveTriageConfig` in `src/modules/triage-config.js`: 1. Does **not** return a `tokenRecycleLimit` field at all — so `result.tokenRecycleLimit` is `undefined`, not `20000` (line 18). 2. Does **not** return a `streaming` field — so `result.streaming` is `undefined`, not `false` (line 22-24). 3. Defaults `thinkingTokens` to `0` (`triageConfig.thinkingTokens ?? 0`), not `4096` (line 27-29). All three assertions will fail against the live source unless the source is updated to match. How can I resolve this? If you propose a fix, please make it concise.
- Does not return a
Prompt To Fix All With AI
This is a comment left during a code review.
Path: tests/utils/anthropicClient.test.js
Line: 16-18
Comment:
**Source module does not exist — all tests will fail**
`src/utils/anthropicClient.js` does not exist in the repository. The dynamic import on line 16 will throw a module-not-found error at runtime, causing every test in this file to fail before any assertion runs. The file needs to be created (or the correct path resolved) before these tests can pass.
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: tests/modules/cli-process.test.js
Line: 68-70
Comment:
**Source module does not exist — all tests will fail**
`src/modules/cli-process.js` does not exist in the repository. The dynamic import on line 68 will throw a module-not-found error, making the entire 1,300-line test file dead on arrival. All 40+ test cases will error out before any assertion is reached.
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: tests/modules/triage-config.test.js
Line: 13-18
Comment:
**Three assertions mismatch the current source implementation**
The current `resolveTriageConfig` in `src/modules/triage-config.js`:
1. Does **not** return a `tokenRecycleLimit` field at all — so `result.tokenRecycleLimit` is `undefined`, not `20000` (line 18).
2. Does **not** return a `streaming` field — so `result.streaming` is `undefined`, not `false` (line 22-24).
3. Defaults `thinkingTokens` to `0` (`triageConfig.thinkingTokens ?? 0`), not `4096` (line 27-29).
All three assertions will fail against the live source unless the source is updated to match.
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: tests/api/utils/configValidation.test.js
Line: 486-538
Comment:
**`triage.streaming` and `triage.tokenRecycleLimit` are absent from `CONFIG_SCHEMA`**
The entire `describe('triage schema — new fields (streaming, tokenRecycleLimit)', ...)` block will fail. In the current `src/api/utils/configValidation.js`, the `triage` object's `properties` map has no `streaming` or `tokenRecycleLimit` entries. As a result:
- `validateSingleValue('triage.streaming', true)` returns `['Unknown config path: triage.streaming']`, not `[]`.
- Every `validateSingleValue('triage.tokenRecycleLimit', ...)` call also returns the unknown-path error.
- `CONFIG_SCHEMA.triage.properties.streaming` is `undefined`, so the `toHaveProperty` / `toEqual` assertions on lines 530-537 fail.
The schema needs `streaming: { type: 'boolean' }` and `tokenRecycleLimit: { type: 'number', min: 0, max: 1000000 }` added to the `triage` properties before these tests can pass.
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: tests/modules/cli-process.test.js
Line: 809-819
Comment:
**Test doesn't actually verify the retry-limit behavior**
The test body only asserts `typeof cli.restart === 'function'`, which will always be true regardless of whether the max-retry cap is wired up correctly. The comment explains the real behavior but the assertion doesn't exercise it — this test can never catch a regression in the cap logic.
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "CodeRabbit Generated Unit Tests: Add uni..." | Re-trigger Greptile
| const { _setAnthropicClient, getAnthropicClient } = await import( | ||
| '../../src/utils/anthropicClient.js' | ||
| ); |
There was a problem hiding this comment.
Source module does not exist — all tests will fail
src/utils/anthropicClient.js does not exist in the repository. The dynamic import on line 16 will throw a module-not-found error at runtime, causing every test in this file to fail before any assertion runs. The file needs to be created (or the correct path resolved) before these tests can pass.
Prompt To Fix With AI
This is a comment left during a code review.
Path: tests/utils/anthropicClient.test.js
Line: 16-18
Comment:
**Source module does not exist — all tests will fail**
`src/utils/anthropicClient.js` does not exist in the repository. The dynamic import on line 16 will throw a module-not-found error at runtime, causing every test in this file to fail before any assertion runs. The file needs to be created (or the correct path resolved) before these tests can pass.
How can I resolve this? If you propose a fix, please make it concise.| const { AsyncQueue, CLIProcess, CLIProcessError } = await import( | ||
| '../../src/modules/cli-process.js' | ||
| ); |
There was a problem hiding this comment.
Source module does not exist — all tests will fail
src/modules/cli-process.js does not exist in the repository. The dynamic import on line 68 will throw a module-not-found error, making the entire 1,300-line test file dead on arrival. All 40+ test cases will error out before any assertion is reached.
Prompt To Fix With AI
This is a comment left during a code review.
Path: tests/modules/cli-process.test.js
Line: 68-70
Comment:
**Source module does not exist — all tests will fail**
`src/modules/cli-process.js` does not exist in the repository. The dynamic import on line 68 will throw a module-not-found error, making the entire 1,300-line test file dead on arrival. All 40+ test cases will error out before any assertion is reached.
How can I resolve this? If you propose a fix, please make it concise.| describe('triage schema — new fields (streaming, tokenRecycleLimit)', () => { | ||
| it('should accept valid triage.streaming boolean', () => { | ||
| expect(validateSingleValue('triage.streaming', true)).toEqual([]); | ||
| expect(validateSingleValue('triage.streaming', false)).toEqual([]); | ||
| }); | ||
|
|
||
| it('should reject non-boolean triage.streaming', () => { | ||
| const errors = validateSingleValue('triage.streaming', 1); | ||
| expect(errors).toHaveLength(1); | ||
| expect(errors[0]).toContain('expected boolean'); | ||
| }); | ||
|
|
||
| it('should accept triage.tokenRecycleLimit within valid range', () => { | ||
| expect(validateSingleValue('triage.tokenRecycleLimit', 0)).toEqual([]); | ||
| expect(validateSingleValue('triage.tokenRecycleLimit', 20000)).toEqual([]); | ||
| expect(validateSingleValue('triage.tokenRecycleLimit', 1000000)).toEqual([]); | ||
| }); | ||
|
|
||
| it('should reject triage.tokenRecycleLimit below minimum', () => { | ||
| const errors = validateSingleValue('triage.tokenRecycleLimit', -1); | ||
| expect(errors).toHaveLength(1); | ||
| expect(errors[0]).toContain('>= 0'); | ||
| }); | ||
|
|
||
| it('should reject triage.tokenRecycleLimit above maximum', () => { | ||
| const errors = validateSingleValue('triage.tokenRecycleLimit', 1000001); | ||
| expect(errors).toHaveLength(1); | ||
| expect(errors[0]).toContain('<= 1000000'); | ||
| }); | ||
|
|
||
| it('should reject non-number triage.tokenRecycleLimit', () => { | ||
| const errors = validateSingleValue('triage.tokenRecycleLimit', '20000'); | ||
| expect(errors).toHaveLength(1); | ||
| expect(errors[0]).toContain('expected finite number'); | ||
| }); | ||
|
|
||
| it('should reject NaN triage.tokenRecycleLimit', () => { | ||
| const errors = validateSingleValue('triage.tokenRecycleLimit', NaN); | ||
| expect(errors).toHaveLength(1); | ||
| expect(errors[0]).toContain('expected finite number'); | ||
| }); | ||
|
|
||
| it('should confirm triage schema contains streaming and tokenRecycleLimit properties', () => { | ||
| expect(CONFIG_SCHEMA.triage.properties).toHaveProperty('streaming'); | ||
| expect(CONFIG_SCHEMA.triage.properties.streaming).toEqual({ type: 'boolean' }); | ||
| expect(CONFIG_SCHEMA.triage.properties).toHaveProperty('tokenRecycleLimit'); | ||
| expect(CONFIG_SCHEMA.triage.properties.tokenRecycleLimit).toMatchObject({ | ||
| type: 'number', | ||
| min: 0, | ||
| max: 1000000, | ||
| }); | ||
| }); | ||
| }); |
There was a problem hiding this comment.
triage.streaming and triage.tokenRecycleLimit are absent from CONFIG_SCHEMA
The entire describe('triage schema — new fields (streaming, tokenRecycleLimit)', ...) block will fail. In the current src/api/utils/configValidation.js, the triage object's properties map has no streaming or tokenRecycleLimit entries. As a result:
validateSingleValue('triage.streaming', true)returns['Unknown config path: triage.streaming'], not[].- Every
validateSingleValue('triage.tokenRecycleLimit', ...)call also returns the unknown-path error. CONFIG_SCHEMA.triage.properties.streamingisundefined, so thetoHaveProperty/toEqualassertions on lines 530-537 fail.
The schema needs streaming: { type: 'boolean' } and tokenRecycleLimit: { type: 'number', min: 0, max: 1000000 } added to the triage properties before these tests can pass.
Prompt To Fix With AI
This is a comment left during a code review.
Path: tests/api/utils/configValidation.test.js
Line: 486-538
Comment:
**`triage.streaming` and `triage.tokenRecycleLimit` are absent from `CONFIG_SCHEMA`**
The entire `describe('triage schema — new fields (streaming, tokenRecycleLimit)', ...)` block will fail. In the current `src/api/utils/configValidation.js`, the `triage` object's `properties` map has no `streaming` or `tokenRecycleLimit` entries. As a result:
- `validateSingleValue('triage.streaming', true)` returns `['Unknown config path: triage.streaming']`, not `[]`.
- Every `validateSingleValue('triage.tokenRecycleLimit', ...)` call also returns the unknown-path error.
- `CONFIG_SCHEMA.triage.properties.streaming` is `undefined`, so the `toHaveProperty` / `toEqual` assertions on lines 530-537 fail.
The schema needs `streaming: { type: 'boolean' }` and `tokenRecycleLimit: { type: 'number', min: 0, max: 1000000 }` added to the `triage` properties before these tests can pass.
How can I resolve this? If you propose a fix, please make it concise.

Unit test generation was requested by @BillChirico.
The following files were modified:
tests/api/utils/configValidation.test.jstests/modules/cli-process.test.jstests/modules/triage-config.test.jstests/utils/anthropicClient.test.js