Commit f41e03e
feat: add telemetry intelligence signals for debugging and improvements (#564)
* feat: add implicit quality signal telemetry event
Add `task_outcome_signal` event that maps agent outcomes to behavioral
signals (accepted/error/abandoned/cancelled). Emitted alongside
`agent_outcome` at session end with zero user cost — pure client-side
computation from data already in memory.
- New event type with `signal`, `tool_count`, `step_count`, `duration_ms`,
`last_tool_category` fields
- Exported `deriveQualitySignal()` for testable outcome→signal mapping
- MCP tool detection via `mcp__` prefix for accurate categorization
- 8 unit tests covering all signal derivations and event shape
Closes AI-6028
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* feat: add task intent classification telemetry event
Add `task_classified` event emitted at session start with keyword/regex
classification of the first user message. Categories: debug_dbt, write_sql,
optimize_query, build_model, analyze_lineage, explore_schema, migrate_sql,
manage_warehouse, finops, general.
- `classifyTaskIntent()` — pure regex matcher, zero LLM cost, <1ms
- Includes warehouse type from fingerprint cache
- Strong/weak confidence levels (1.0 vs 0.5)
- 15 unit tests covering all intent categories + edge cases
Closes AI-6029
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* feat: emit aggregated tool chain outcome at session end
Add `tool_chain_outcome` event that captures the ordered tool sequence,
error count, recovery count, and final outcome at session end. Only
emitted when tools were actually used (non-empty chain).
- Tracks up to 50 tool names in execution order
- Detects error→success recovery patterns for auto-fix insights
- Aggregates existing per-tool-call data — near-zero additional cost
- 3 unit tests for event shape and error/recovery tracking
Closes AI-6030
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* feat: link error-recovery pairs with hashed fingerprint
Add `error_fingerprint` event emitted per unique error at session end.
SHA256-hashes normalized error messages for anonymous grouping, links
each error to its recovery tool (if the next tool succeeded).
- `hashError()` — 16-char hex hash of masked error messages
- Tracks error→recovery pairs during tool chain execution
- Capped at 20 fingerprints per session to bound telemetry volume
- 4 unit tests for hashing, event shape, and recovery tracking
Closes AI-6031
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* feat: emit SQL structure fingerprint using altimate-core
Add `sql_fingerprint` event emitted after successful SQL execution via
`sql_execute`. Uses `extractMetadata()` + `getStatementTypes()` from
altimate-core NAPI — local parsing, no API calls, ~1-5ms.
- Captures: statement types, categories, table/function count,
subqueries, aggregation, window functions, AST node count
- No table/column names or SQL content — PII-safe by design
- Wrapped in try/catch so fingerprinting never breaks query execution
- `computeSqlFingerprint()` exported from sql-classify for reuse
- 6 unit tests including PII safety verification
Closes AI-6032
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* feat: expand environment_census with dbt project fingerprint
Add optional dbt project metrics to the existing `environment_census`
event: snapshot/seed count buckets, materialization distribution
(table/view/incremental/ephemeral counts). Data already parsed at
startup — just extracts more fields from the same manifest parse.
- Backward compatible — new fields are optional
- No extra file reads or API calls
Closes AI-6033
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* feat: emit schema complexity signal during warehouse introspection
Add `schema_complexity` event emitted alongside `warehouse_introspection`
after successful schema indexing. Uses data already computed during
introspection — no extra warehouse queries.
- Bucketed table/column/schema counts + avg columns per table
- Division-by-zero guard for empty warehouses
- Emitted inside existing try/catch — never breaks introspection
Closes AI-6034
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* docs: update telemetry reference with 7 new intelligence signals
Add task_outcome_signal, task_classified, tool_chain_outcome,
error_fingerprint, sql_fingerprint, schema_complexity to the event
catalog. Update environment_census description for new dbt fields.
Update naming convention section.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* test: add comprehensive integration tests for telemetry signals
Add 38 integration tests that verify all 7 telemetry signals fire
through real code paths with spy on Telemetry.track():
- Signal 1: quality signal derivation + error/abandoned/cancelled cases
- Signal 2: intent classifier with 10 real DE prompts + PII safety
- Signal 3: tool chain collection with error recovery state machine
- Signal 4: error fingerprint hashing + consecutive error flush
- Signal 5: SQL fingerprint via altimate-core (aggregation, CTE, DDL)
- Signal 6: environment_census expansion + backward compatibility
- Signal 7: schema complexity bucketing + zero-table edge case
- Full E2E: complete session simulation with all 7 signals in order
Also fixes regex patterns for natural language flexibility:
- dbt debug: allows words between "dbt" and error keywords
- migrate: allows words between "to/from" and warehouse name
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* test: add altimate-core failure isolation tests
Verify computeSqlFingerprint resilience when altimate-core NAPI:
- throws (segfault, OOM) — returns null, never leaks exception
- returns undefined — uses safe defaults (empty arrays, 0 counts)
- returns garbage data — handled gracefully via ?? fallbacks
Also verifies sql-execute.ts code structure ensures fingerprinting
runs AFTER query result and is wrapped in isolated try/catch.
Tests crash-resistant SQL inputs (control chars, empty, incomplete,
very wide queries) and deterministic output.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: address stakeholder review findings
Fixes from 5-stakeholder review (architect, privacy, perf, markers, tests):
- Marker fix: remove nested altimate_change start/end, fold new variables
into existing session telemetry tracking block
- Performance: cap errorRecords at 200 entries (prevent unbounded growth)
- Performance: slice intent classifier input to 2000 chars (bound regex)
- Architecture: fix import path in sql-execute.ts (../telemetry not ../../altimate/telemetry)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* chore: bump altimate-core to 0.2.6
Picks up extractMetadata fixes:
- Aggregate function names (COUNT, SUM, AVG, etc.) now in functions array
- IN (SELECT ...) and EXISTS (SELECT ...) subquery detection
- Any/All quantified comparison subquery detection (guarded)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 22c9c38 commit f41e03e
File tree
12 files changed
+1772
-23
lines changed- .github/meta
- docs/docs/reference
- packages/opencode
- src
- altimate
- native/schema
- telemetry
- tools
- session
- test
- altimate
- telemetry
12 files changed
+1772
-23
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | | - | |
4 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
5 | 7 | | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
10 | 12 | | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
| 13 | + | |
16 | 14 | | |
17 | 15 | | |
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
42 | 48 | | |
43 | 49 | | |
44 | 50 | | |
| |||
129 | 135 | | |
130 | 136 | | |
131 | 137 | | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
132 | 143 | | |
133 | 144 | | |
134 | 145 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
81 | | - | |
| 81 | + | |
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
49 | 63 | | |
50 | 64 | | |
51 | 65 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
212 | 212 | | |
213 | 213 | | |
214 | 214 | | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
215 | 222 | | |
216 | 223 | | |
217 | 224 | | |
| |||
445 | 452 | | |
446 | 453 | | |
447 | 454 | | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
448 | 568 | | |
449 | 569 | | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
450 | 658 | | |
451 | 659 | | |
452 | 660 | | |
| |||
0 commit comments