audit follow-up: reduce warning debt in local model tests

This commit is contained in:
William Valentin
2026-02-15 22:53:12 -08:00
parent 8c94bb51d0
commit 803cf1da11
4 changed files with 35 additions and 28 deletions
@@ -20,7 +20,7 @@ Scope: Production-risk-first audit of bugs, code improvements, and feature oppor
- ✅ F-015 addressed: retry defaults no longer classify timeout-style failures as non-retryable, improving resilience for transient timeout conditions.
- ✅ F-011 addressed: Slack user-name resolution now uses bounded TTL+LRU caching to prevent unbounded growth.
- ✅ F-013 addressed: shared channel utilities now cover reset normalization/building plus reusable allowlist, mention-gating, and pairing-gating flows across Discord/Slack/WhatsApp adapters.
- ◑ F-004 partially addressed: lint error baseline is restored (`pnpm lint` now passes with 0 errors) and warning burn-down has progressed from `466` to `232`; additional warning debt remains.
- ◑ F-004 partially addressed: lint error baseline is restored (`pnpm lint` now passes with 0 errors) and warning burn-down has progressed from `466` to `212`; additional warning debt remains.
## Executive Summary
@@ -28,7 +28,7 @@ Current health snapshot:
- `pnpm typecheck`: passing
- `pnpm build`: passing
- `pnpm test:run`: passing (`140/140` files, `1773/1773` tests)
- `pnpm lint`: passing with warnings only (`0 errors`, `232 warnings`)
- `pnpm lint`: passing with warnings only (`0 errors`, `212 warnings`)
Top conclusions:
- A critical Web UI security issue exists in markdown rendering (unsanitized HTML insertion).
@@ -126,7 +126,7 @@ Remediation update (2026-02-16):
- Severity: Medium
- Impact: CI noise, reduced confidence in static analysis, and slower defect detection.
- Evidence:
- `pnpm -s lint` => `0 errors`, `232 warnings`
- `pnpm -s lint` => `0 errors`, `212 warnings`
- Error concentration:
- `src/daemon/models.ts` (90 errors)
- `src/cli/tui.ts` (25 errors)
@@ -145,7 +145,7 @@ Remediation update (2026-02-16):
Remediation update (2026-02-16):
- Stage 1 complete: fixed all error-level ESLint violations in impacted high-error files so `pnpm lint` now passes with `0` errors.
- Stage 2 in progress: warning-burn-down reduced to `232` warnings via targeted hotspot cleanup in:
- Stage 2 in progress: warning-burn-down reduced to `212` warnings via targeted hotspot cleanup in:
- `src/gateway/handlers/handlers.test.ts`
- `src/daemon/routing.test.ts`
- `src/frontends/tui/minimal.test.ts`
@@ -156,6 +156,8 @@ Remediation update (2026-02-16):
- `src/frontends/tui/minimal.login.test.ts`
- `src/daemon/clientFactory.test.ts`
- `src/gateway/handlers/services.test.ts`
- `src/models/local/llamacpp.test.ts`
- `src/models/local/ollama.test.ts`
### F-005 Medium: ESLint browser globals mismatch causes avoidable UI lint failures
@@ -460,7 +462,7 @@ pnpm -s lint
Observed outcomes:
- Typecheck/build/test: passing.
- Lint: passing with warnings only (`0` errors, `232` warnings).
- Lint: passing with warnings only (`0` errors, `212` warnings).
Historical pre-remediation lint error concentration snapshot:
- `src/daemon/models.ts`: 90 errors
+4 -2
View File
@@ -2652,7 +2652,7 @@
"status": "in_progress",
"date": "2026-02-16",
"updated": "2026-02-16",
"summary": "Continued stage-2 lint warning reduction with hotspot-focused cleanup in `gateway/handlers/handlers.test.ts`, `daemon/routing.test.ts`, `frontends/tui/minimal.test.ts`, `gateway/tailscale.test.ts`, `automation/webhooks.test.ts`, `automation/cron.test.ts`, `automation/heartbeat.test.ts`, `frontends/tui/minimal.login.test.ts`, `daemon/clientFactory.test.ts`, and `gateway/handlers/services.test.ts`. Replaced broad `any` casts with typed helper casts/unknown-path accessors and removed non-null assertions in high-warning tests. Warning count reduced from 466 to 232 (234 warnings burned down) with lint/test suites still green.",
"summary": "Continued stage-2 lint warning reduction with hotspot-focused cleanup in `gateway/handlers/handlers.test.ts`, `daemon/routing.test.ts`, `frontends/tui/minimal.test.ts`, `gateway/tailscale.test.ts`, `automation/webhooks.test.ts`, `automation/cron.test.ts`, `automation/heartbeat.test.ts`, `frontends/tui/minimal.login.test.ts`, `daemon/clientFactory.test.ts`, `gateway/handlers/services.test.ts`, `models/local/llamacpp.test.ts`, and `models/local/ollama.test.ts`. Replaced broad `any` casts with typed helper casts/unknown-path accessors and removed non-null assertions in high-warning tests. Warning count reduced from 466 to 212 (254 warnings burned down) with lint/test suites still green.",
"files_modified": [
"src/tools/builtin/browser/tools.test.ts",
"src/channels/telegram/adapter.test.ts",
@@ -2669,9 +2669,11 @@
"src/frontends/tui/minimal.login.test.ts",
"src/daemon/clientFactory.test.ts",
"src/gateway/handlers/services.test.ts",
"src/models/local/llamacpp.test.ts",
"src/models/local/ollama.test.ts",
"docs/plans/analysis/2026-02-16-codebase-audit-report.md"
],
"test_status": "pnpm test:run src/channels/utils.test.ts src/channels/discord/adapter.test.ts src/channels/slack/adapter.test.ts src/channels/whatsapp/adapter.test.ts src/daemon/routing.test.ts src/gateway/handlers/handlers.test.ts src/frontends/tui/minimal.test.ts src/gateway/tailscale.test.ts src/automation/webhooks.test.ts src/automation/cron.test.ts src/automation/heartbeat.test.ts src/frontends/tui/minimal.login.test.ts src/daemon/clientFactory.test.ts src/gateway/handlers/services.test.ts + pnpm lint passing (0 errors, 232 warnings)"
"test_status": "pnpm test:run src/channels/utils.test.ts src/channels/discord/adapter.test.ts src/channels/slack/adapter.test.ts src/channels/whatsapp/adapter.test.ts src/daemon/routing.test.ts src/gateway/handlers/handlers.test.ts src/frontends/tui/minimal.test.ts src/gateway/tailscale.test.ts src/automation/webhooks.test.ts src/automation/cron.test.ts src/automation/heartbeat.test.ts src/frontends/tui/minimal.login.test.ts src/daemon/clientFactory.test.ts src/gateway/handlers/services.test.ts src/models/local/llamacpp.test.ts src/models/local/ollama.test.ts + pnpm lint passing (0 errors, 212 warnings)"
}
},
"overall_progress": {
+15 -13
View File
@@ -217,7 +217,8 @@ describe('LlamaCppClient', () => {
expect(response.stopReason).toBe('tool_use');
expect(response.toolCalls).toHaveLength(1);
expect(response.toolCalls![0]).toEqual({
const firstToolCall = response.toolCalls?.[0];
expect(firstToolCall).toEqual({
id: 'call_123',
name: 'shell.exec',
args: { command: 'ls' },
@@ -404,7 +405,7 @@ describe('normalizeMessagesForLlamaCpp', () => {
content: [
{ type: 'text', text: 'Searching...' },
{ type: 'tool_use', id: 'call_1', name: 'web.search', input: { query: 'news' } },
] as any,
] as Message['content'],
},
];
@@ -432,13 +433,13 @@ describe('normalizeMessagesForLlamaCpp', () => {
role: 'assistant',
content: [
{ type: 'tool_use', id: 'call_1', name: 'web.search', input: { query: 'news' } },
] as any,
] as Message['content'],
},
{
role: 'user',
content: [
{ type: 'tool_result', tool_use_id: 'call_1', content: 'Results here', is_error: false },
] as any,
] as Message['content'],
},
];
@@ -459,22 +460,23 @@ describe('normalizeMessagesForLlamaCpp', () => {
content: [
{ type: 'tool_use', id: 'call_a', name: 'tool.a', input: {} },
{ type: 'tool_use', id: 'call_b', name: 'tool.b', input: { x: 1 } },
] as any,
] as Message['content'],
},
{
role: 'user',
content: [
{ type: 'tool_result', tool_use_id: 'call_a', content: 'A result' },
{ type: 'tool_result', tool_use_id: 'call_b', content: 'B result' },
] as any,
] as Message['content'],
},
];
const result = normalizeMessagesForLlamaCpp(undefined, messages);
expect(result[1].tool_calls).toHaveLength(2);
expect(result[1].tool_calls![0].id).toBe('call_a');
expect(result[1].tool_calls![1].function.arguments).toBe('{"x":1}');
const toolCalls = result[1].tool_calls;
expect(toolCalls).toHaveLength(2);
expect(toolCalls?.[0]?.id).toBe('call_a');
expect(toolCalls?.[1]?.function.arguments).toBe('{"x":1}');
// Multiple results merged into one user message
expect(result).toHaveLength(3);
expect(result[2]).toEqual({
@@ -490,13 +492,13 @@ describe('normalizeMessagesForLlamaCpp', () => {
role: 'assistant',
content: [
{ type: 'tool_use', id: 'call_1', name: 'file.read', input: { path: '/tmp/x' } },
] as any,
] as Message['content'],
},
{
role: 'user',
content: [
{ type: 'tool_result', tool_use_id: 'call_1', content: 'File not found', is_error: true },
] as any,
] as Message['content'],
},
];
@@ -516,13 +518,13 @@ describe('normalizeMessagesForLlamaCpp', () => {
content: [
{ type: 'text', text: 'Checking...' },
{ type: 'tool_use', id: 'tc_0', name: 'weather.get', input: { city: 'NYC' } },
] as any,
] as Message['content'],
},
{
role: 'user',
content: [
{ type: 'tool_result', tool_use_id: 'tc_0', content: 'Sunny, 72F' },
] as any,
] as Message['content'],
},
{ role: 'assistant', content: 'The weather in NYC is sunny, 72F.' },
];
+9 -8
View File
@@ -110,7 +110,8 @@ describe('OllamaClient', () => {
expect(response.stopReason).toBe('tool_use');
expect(response.toolCalls).toHaveLength(1);
expect(response.toolCalls![0]).toEqual({
const firstToolCall = response.toolCalls?.[0];
expect(firstToolCall).toEqual({
id: 'ollama_tc_0',
name: 'shell.exec',
args: { command: 'ls' },
@@ -374,7 +375,7 @@ describe('normalizeMessagesForOllama', () => {
content: [
{ type: 'text', text: 'Let me search for that.' },
{ type: 'tool_use', id: 'call_1', name: 'web.search', input: { query: 'latest news' } },
] as any,
] as Message['content'],
},
];
@@ -401,13 +402,13 @@ describe('normalizeMessagesForOllama', () => {
role: 'assistant',
content: [
{ type: 'tool_use', id: 'call_1', name: 'web.search', input: { query: 'news' } },
] as any,
] as Message['content'],
},
{
role: 'user',
content: [
{ type: 'tool_result', tool_use_id: 'call_1', content: 'Breaking news: ...', is_error: false },
] as any,
] as Message['content'],
},
];
@@ -429,14 +430,14 @@ describe('normalizeMessagesForOllama', () => {
content: [
{ type: 'tool_use', id: 'call_1', name: 'web.search', input: { query: 'a' } },
{ type: 'tool_use', id: 'call_2', name: 'web.search', input: { query: 'b' } },
] as any,
] as Message['content'],
},
{
role: 'user',
content: [
{ type: 'tool_result', tool_use_id: 'call_1', content: 'Result A' },
{ type: 'tool_result', tool_use_id: 'call_2', content: 'Result B' },
] as any,
] as Message['content'],
},
];
@@ -456,13 +457,13 @@ describe('normalizeMessagesForOllama', () => {
content: [
{ type: 'text', text: 'Let me check.' },
{ type: 'tool_use', id: 'tc_0', name: 'weather.get', input: { city: 'NYC' } },
] as any,
] as Message['content'],
},
{
role: 'user',
content: [
{ type: 'tool_result', tool_use_id: 'tc_0', content: 'Sunny, 72F' },
] as any,
] as Message['content'],
},
{ role: 'assistant', content: 'The weather in NYC is sunny, 72F.' },
];