Skip to content

feat(agent-sessions): decide every aggregate/filter fact at ingest, the index projects the stamps - #1160

Merged
JeremyFunk merged 17 commits into
feat/ingest-usage-bucketsfrom
feat/ingest-ai-span-stamps
Sep 29, 2026
Merged

JeremyFunk merged 17 commits into
feat/ingest-usage-bucketsfrom
feat/ingest-ai-span-stamps

chore(agent-sessions): cut process notes and a duplicate test, rewrap…

38f256c
Select commit
Loading
Failed to load commit list.
Maple Review Bot / Maple / review succeeded Sep 29, 2026 in 7m 13s

Confidence 4/5 · No issues found

Confidence 4/5 · likely safe to merge
A deliberate behavior change: the span-name/model fallback for a model call now applies only to unknown: vendors, so known-vendor spans with an unrecognized op stop counting as LLM calls.
quality 100/100 · no findings · tests covered · risk medium

The ingest gateway now decides every Agent Sessions fact once per span and stamps it as maple_ai.*; ai_trace_index_mv becomes a projection of those stamps and the detail page reads the same verdicts. Contained and well tested; safe to merge once the ingest deploy ships first.

  • facts::stamps writes the gateway's verdicts, names and usage buckets on every stamped AI span
  • Migration 0035 recreates ai_trace_index_mv as a projection of maple_ai.* plus error.type and the fingerprint
  • classifyAiSpan/spanFailed/spanTokenBuckets take the gateway's verdicts for stamped spans
  • gen-ai.test.ts pins MAPLE_AI_STAMP_ATTRS against the Rust key literals

Fixed since the last review

  • F1 · Nothing pins the Rust stamp keys to MAPLE_AI_STAMP_ATTRS
What was checked
  • F1 resolved: every MAPLE_AI_STAMP_ATTRS key appears as a &str = "maple_ai..." literal in facts.rs/usage.rs, and turbo.json adds those sources as test inputs
  • The gateway's error, tool_call and model/agent/tool key lists reproduce the old view expressions, so IsError/IsToolCall/Model do not shift for stamped spans
  • No new entrypoint, outbound call or background loop: the change is a transform inside the existing ingest path plus a view recreate, so no span or metric is owed

38f256c · Updated on every push. Reply "won't fix" to dismiss a finding, or mention @maple to ask about one.