feat(ingest): add the pure AI span classifier and registry loader - #432
Closed
JeremyFunk wants to merge 1 commit into
Closed
feat(ingest): add the pure AI span classifier and registry loader#432JeremyFunk wants to merge 1 commit into
JeremyFunk wants to merge 1 commit into
Conversation
JeremyFunk
force-pushed
the
ai/03-rust-classifier-core
branch
from
August 12, 2026 20:04
43644e6 to
3a22d60
Compare
Adds three self-contained Rust modules: `ai_registry` (loads and validates the vendored `registry.json` at first use, rejecting a bad artifact at load rather than at classification), `ai_classifier` (per-span vendor and session-key resolution over the registry's four-op algebra, with a resource/scope context hoisted per batch), and `cityhash102` (the CityHash64 v1.0.2 variant ClickHouse's `cityHash64` implements, so Rust and SQL hash identically). Nothing calls this yet — it is pure CPU with no pipeline wiring, which is what makes it reviewable on its own. The only edit outside the new files is widening `telemetry::any_value_string` to `pub(crate)` so the classifier canonicalizes attribute values through the exact function the row writer uses. The corpus replay test (`ai_classifier_corpus_test.rs`) is an on-demand local gate driven by `TRACE_CAPTURE_DIR`; it needs `serde_yaml` as a dev-dependency to read trace-capture's seed goldens, and is skipped when the variable is unset. The criterion group measures classification in isolation. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
JeremyFunk
changed the base branch from
ai/02-org-session-salt
to
ai/01-registry-artifact
August 12, 2026 21:04
JeremyFunk
force-pushed
the
ai/03-rust-classifier-core
branch
from
August 12, 2026 21:05
3a22d60 to
a8baf21
Compare
Collaborator
Author
🍁 Maple PR previewNote Preview resources were removed when this pull request closed. Final commit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this layer contains
Three self-contained Rust modules in
apps/ingest, plus their tests and benchmark:ai_registry.rs— loads and validatesregistry.json(viainclude_str!) at first use.ai_classifier.rs— per-span vendor and session-key resolution over the registry's four-operator algebra, with the resource/scope context hoisted once per batch.cityhash102.rs— the CityHash64 v1.0.2 variant ClickHouse'scityHash64implements.ai_classifier_corpus_test.rs, a criterion group, andserde_yamlas a dev-dependency.The only edit outside new files is widening
telemetry::any_value_stringtopub(crate).Why it is shaped this way
Nothing calls any of this yet. It is pure CPU with no pipeline wiring, no I/O and no schema change, which is exactly what makes a 3,000-line classifier reviewable — its behaviour is fully determined by the registry plus its inputs. The registry is validated at load rather than at classification so a bad resync fails the process start, not the first AI span. The
pub(crate)widening is the one deliberate coupling: the classifier must canonicalize attribute values through the same function the row writer uses, or the Rust and SQL evaluators cannot be proven equivalent later.The corpus replay is an on-demand local gate driven by
TRACE_CAPTURE_DIRand skips when the variable is unset, because the ~60 OTLP capture directories are deliberately not vendored.Gates run at this level
cargo test --locked— 125 lib tests, 69 bin tests, 0 failures.cargo test --lockedwithTRACE_CAPTURE_DIR— corpus replay green: 41/41 goldens over 41 captures, 1,514 spans.cargo clippy --all-targets— no new warnings; every remaining warning traces to a file this PR does not add (main.rs,telemetry.rs,autumn.rs,otel.rs,usage_metrics.rs).Dependencies
Requires #430 —
ai_registry.rsinclude_str!spackages/domain/src/ai-registry/registry.json.Partition note: the criterion bench's
accept_tracescall stays atmain's signature here. Its extra&AiClassificationSettings::disabled()argument depends on atelemetry.rstype that does not exist until the write-path PR, so that one hunk of the bench file lands there instead. The newai_classifierbench group is complete in this PR.🤖 Generated with Claude Code
Stack created with GitHub Stacks CLI • Give Feedback 💬
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.