Commit 997e2b2
fix: setup_complete missing scanners_run/scanners_failed + extra test coverage
Verification audit found that the setup_complete payload was missing two
required spec fields and that the mcp_tool error category was wired
nowhere. Also expanded test coverage to validate all Phase 1 + Phase 2
payload shapes against the spec.
## Bugs fixed
1. setup_complete missing scanners_run/scanners_failed (src/cli.ts, src/tools/init.ts)
The spec requires both fields. InitResult interface gained the two
counters, initProjectWithLLM now increments scannersRun on every
non-skipped scanner Promise.allSettled result and scannersFailed on
every rejection. cli.ts setup handler reads them from the result and
threads into the sendSetupTelemetry payload.
2. mcp_tool error category not wired anywhere (src/server.ts)
reportError("mcp_tool", ...) was reserved in the bounded category
enum but no call site existed. Wrapped server.tool() with a single
monkey-patch right after McpServer construction so every registered
tool handler is auto-wrapped in a try/catch that fires reportError
with category="mcp_tool", classifyError(err), fatal=true on throw.
Verified end-to-end via smoke test: forcing axme_save_memory to throw
EACCES on a non-existent path produces a single mcp_tool error event
with error_class=permission_denied.
## Tests added (test/telemetry.test.ts)
- lifecycle strict counts: first run sends exactly 1 install + 1 startup
- lifecycle strict counts: second run sends only 1 startup, no install
- update event: previous_version field present when version changed
- processStartupSent guard: 3 sendStartupEvents calls = 1 startup
- ci=true detection in real sent payload
- ci=false default in real sent payload
- audit_complete payload shape: all 10 spec fields present
- setup_complete payload shape: all 9 spec fields present
- offline queue cap at 100 events with oldest-dropped semantics
- classifyError extra slugs: api_error, disk_full, permission_denied
- reportError payload contains only bounded fields, no message/stack
## Verification
- npm test: 475 tests, 104 suites, 0 failures
- npm run lint: clean
- npm run build: clean
- npx tsc --noEmit: clean
- E2E staging: 7/7 scenarios passed against
axme-gateway-staging Cloud Run URL (install + startup, rerun no
install, update with previous_version, opt-out AXME_TELEMETRY_DISABLED
+ DO_NOT_TRACK leaves no state, offline queue + flush, setup_complete
on auth-fail fast path)
- E2E Scenario D real audit: ran live LLM audit-session subprocess
against staging endpoint on session d5e6391c (15.5MB transcript,
verify-only mode). Result: outcome=success, durationMs=574371,
promptTokens=130731, costUsd=1.0232553, chunks=1, decisions_saved=1,
memories_saved=0, safety_saved=0, dropped_count=0. audit_complete
event landed on staging, telemetry-queue.jsonl absent post-run.
- Anti-spam check: full MCP boot lifecycle (initialize + tools/list +
3 tool calls + shutdown) produces exactly 1 install + 1 startup. No
duplicates from subprocess paths.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 914685e commit 997e2b2
4 files changed
Lines changed: 404 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
298 | 298 | | |
299 | 299 | | |
300 | 300 | | |
| 301 | + | |
| 302 | + | |
301 | 303 | | |
302 | 304 | | |
303 | 305 | | |
| |||
308 | 310 | | |
309 | 311 | | |
310 | 312 | | |
| 313 | + | |
| 314 | + | |
311 | 315 | | |
312 | 316 | | |
313 | 317 | | |
| |||
354 | 358 | | |
355 | 359 | | |
356 | 360 | | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
357 | 364 | | |
358 | 365 | | |
359 | 366 | | |
| |||
370 | 377 | | |
371 | 378 | | |
372 | 379 | | |
| 380 | + | |
| 381 | + | |
373 | 382 | | |
374 | 383 | | |
375 | 384 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
232 | 232 | | |
233 | 233 | | |
234 | 234 | | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
235 | 264 | | |
236 | 265 | | |
237 | 266 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
37 | 41 | | |
38 | 42 | | |
39 | 43 | | |
| |||
61 | 65 | | |
62 | 66 | | |
63 | 67 | | |
| 68 | + | |
64 | 69 | | |
65 | 70 | | |
66 | 71 | | |
| |||
77 | 82 | | |
78 | 83 | | |
79 | 84 | | |
| 85 | + | |
80 | 86 | | |
81 | 87 | | |
82 | 88 | | |
| |||
172 | 178 | | |
173 | 179 | | |
174 | 180 | | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
175 | 185 | | |
176 | 186 | | |
| 187 | + | |
| 188 | + | |
177 | 189 | | |
178 | 190 | | |
179 | 191 | | |
| |||
182 | 194 | | |
183 | 195 | | |
184 | 196 | | |
| 197 | + | |
185 | 198 | | |
186 | 199 | | |
187 | 200 | | |
| |||
263 | 276 | | |
264 | 277 | | |
265 | 278 | | |
| 279 | + | |
| 280 | + | |
266 | 281 | | |
267 | 282 | | |
268 | 283 | | |
| |||
352 | 367 | | |
353 | 368 | | |
354 | 369 | | |
| 370 | + | |
| 371 | + | |
355 | 372 | | |
356 | 373 | | |
357 | 374 | | |
| |||
420 | 437 | | |
421 | 438 | | |
422 | 439 | | |
| 440 | + | |
423 | 441 | | |
424 | 442 | | |
0 commit comments