Repository navigation
feat(otel): agentmetry otel, and a receiver that works on what Claude Code sends - #203
Merged
Merged
Conversation
… Code sends
The OTel receiver moves from scripts/ into the package as
core/audit/otel_ingest.py, behind `agentmetry otel`. scripts/otel_receiver.py
becomes a shim that keeps the prototype's flags.
The prototype never worked on the stream Claude Code actually exports. Claude
Code documents `success` as the string "true"/"false" and tool_input and
tool_parameters as JSON strings. The prototype read them as Python values, so
bool("false") recorded every failed call as a success, no call was ever
enriched (no traits, no MITRE), and every call carried sha256({}) as its hash.
Replayed on a session in the documented format it fired nothing. The
CHANGELOG said credential-exfil fired end to end; that was true only of test
payloads shaped the way the code expected. The prototype was never released.
Each event now goes through the hook client's own _hash_tool_args and
post_ingest, so enrichment is the same code rather than a copy, and an
undeliverable event spools instead of being lost. A test checks one Bash call
yields identical tool fields on both paths.
tool_decision is mapped only where the trail can say something true. A
person's yes becomes an approval_response. A config or hook decision is not a
human approval and is counted. A person's no is counted, not forwarded: the
denied-then-executed rule binds by argument hash, the event carries no
arguments, and a name-only binding is the false positive 0.7.0 removed.
Binding on tool_use_id is a rule change and waits for the freeze.
The 23 documented unmapped types are still counted by name. Ruleset
fingerprint unchanged (15846a0915769d4a). Verified live on :8010 with a temp
HOME: credential-exfil fires as critical through the CLI path.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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
0.9.0 item (a). Moves the OTel receiver from
scripts/into the package ascore/audit/otel_ingest.py, addsagentmetry otel, and keepsscripts/otel_receiver.pyas a shim with the prototype's flags.AGENTMETRY_OTEL_PORTsets the port, global--port/AGENTMETRY_URLpick the orchestrator, and--keep-commandmeans whatAGENTMETRY_LOG_COMMANDS=1means for hooks. The receiver binds loopback only.The prototype did not work on real traffic
Claude Code documents
successas the string"true"/"false", andtool_input/tool_parametersas JSON strings. The prototype read them as Python values. I replayed itsmap_record(frommaster) on a session in the documented format:pytest -qtool_called/successtool_failed/errorcat ~/.aws/credentialscredential_access{})credential-exfilThe
[Unreleased]entry said it fired end to end, which was true only of test payloads shaped the way the code expected. The prototype was never released, so the entry is rewritten rather than given a "Fixed" line.Same code as the hook path, not a copy
Each event goes through the hook client's
_hash_tool_argsandpost_ingest. Enrichment is identical by construction, and an event the orchestrator can't take spools for the boot drain instead of being lost.test_an_event_matches_the_hook_path_for_the_same_callchecks that one Bash call gives the samequalified,server,input_hash,traits,mitreand correlation on both paths.tool_decision: only what the trail can say truthfullyuser_temporary,user_permanent) becomesapproval_response/successwith a human initiator. No hook can report this.configorhookdecision is not a human approval. It is counted. Recording it assuccesswould reset the unapproved-write gate on a decision nobody made.approval-denied-then-executedbinds a denial to the later call by argument hash, else command, else tool name. This event carries no arguments, so it would bind by name and flag every laterBashcall as critical. That is the false positive 0.7.0 removed. Binding ontool_use_idis a rule change, so it waits for the freeze to end.mcp_server_connectionhas no documented fingerprint, so in practice it is counted. The 23 documented unmapped types are still counted by name, and undocumented ones are counted separately. Prompts, responses and error text are never forwarded. A protobuf export gets a 415 naminghttp/json, and gzip is accepted.Verification
pytest -q: 1343 passed, 1 skipped (33 new intest_otel_ingest.py)ruff check agentmetry tests: cleanbenchmark: all cases behaved as recorded15846a0915769d4a, unchanged. No frozen file touched.HOME, the realagentmetry otelCLI on :4399, fixture POSTed over HTTP. Forwarded 4, counted 6 by name,credential-exfilcritical on the session. The orchestrator's boot hook install landed in the temp home, and the live configs were untouched.Docs
README section rewritten (and its four em-dashes gone), CLI reference row added, scripts table row updated. It now says to use one path or the other per Claude Code install, because running both records every tool call twice.
🤖 Generated with Claude Code