Repository navigation
fix(identity): the trail can say who ran the agent, and configuring it works - #206
Merged
Merged
Conversation
…t works Every event recorded the operator as `local` (#168). Worse than the issue said: the hook hardcoded "operator_id": "local" in twenty-four payloads and the orchestrator keeps any value a client sends, so AGENTMETRY_OPERATOR_ID never reached a single hook event even when set. On the maintainer's machine, with it set, 2,620 of the last 3,761 hook events said `local`. The hook now resolves the account, because it runs as the developer and a fleet orchestrator runs as a service account: AGENTMETRY_OPERATOR_ID, else the OS account, domain-qualified on Windows. Stamped at capture, so a spooled event keeps the account that captured it. The resolver is stdlib-only, so it adds no pydantic to the hook (#171). The orchestrator resolves in order: the developer's configured id, its own AGENTMETRY_OPERATOR_ID as an admin override, the hook's OS account, an unlabelled client id, its own account, `local`. Legacy `local` from hooks up to 0.9.0 counts as not stated. initiator.operator_source records who resolved it (additive, schema stays 1.2.0), and a client cannot get its claim labelled as the recorder's own. The README said ingest takes no identity from the caller, and a test enforced it by top-level field name. Machine identity is still never taken from the caller. The person now is, as a labelled claim, and the README says so. initiator.operator_id was caller-supplied all along; the test could not see a nested field. Triage records had the same hole: decided_by was empty with nothing configured. The disposition CLI now sends the account running it. Account names now reach the trail and forwarded events. Set AGENTMETRY_OPERATOR_ID to a pseudonym to keep them out of a SIEM. Nothing reads another vendor's credential store. Fingerprint unchanged (15846a0915769d4a). 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.
Closes #168.
The bug, and a worse one under it
Every event recorded the operator as
local. The issue blamed the orchestrator's fallback, but the hook was the bigger problem: it hardcoded"operator_id": "local"in 24 payloads, andexternal.pykeeps any value a client sends. SoAGENTMETRY_OPERATOR_IDnever reached a single hook event, even when it was set. On the maintainer's machine, with it set in.env, 2,620 of the last 3,761 hook events saylocal. The other 1,141 carried no initiator, so the orchestrator filled in the setting.A trail that is hash-chained and publicly anchored could prove a record wasn't altered, and couldn't say who it was about.
Where identity is resolved
In the hook, because the hook runs as the developer inside their agent. A fleet orchestrator runs as a Windows service, so resolving there (the issue's proposed scope) would attribute every developer's work to the service account.
core/operator_identity.py, stdlib only, so the hook loads no pydantic for it (hooks: the hook costs 730ms, and 210ms of it is importing pydantic to read env vars #171).AGENTMETRY_OPERATOR_ID, else the OS account. On Windows that'sCORP\jdoefor a domain or Entra account, and barejdoefor a local one (a local account's machine name is dropped). It never raises.operator: {id, source}inpost_ingest, at capture, so a spooled event keeps the account that captured it.ExternalIngestBody.operatoris declared, so pydantic doesn't drop it.Precedence on the orchestrator (
run_context.resolve_operator)hook_configuredAGENTMETRY_OPERATOR_IDon the orchestrator (admin override)orchestrator_configuredhook_osclientorchestrator_oslocal/defaultinitiator.operator_sourceis additive, so the schema stays 1.2.0. Legacylocalfrom hooks up to 0.9.0 counts as not stated. A client that sendssource: "orchestrator_os"is recorded asclient: a test checks that a caller's claim is never labelled as the recorder's own.The README claim this changes
The README said "Ingest takes no identity from the caller", and
test_ingest_body_takes_no_identity_from_the_callerbanned any user-shaped field. Machine identity is still never taken from the caller: nohost_idorfleet_idfield, and the receiver stamps both. That's unchanged and still tested.The person now has to come from the capture side, so the paragraph now says ingest takes one claim about the person, labelled as one. The old sentence was already slightly untrue:
initiator.operator_idwas caller-supplied all along, and the test only checked top-level field names. The test now allows exactlyoperator, and fails if a second identity field appears.Also fixed
decided_by: ""with nothing configured. ThedispositionCLI sends the account running it, and the event falls back to the resolved operator.settings.operator_id or "local".conftest.pynow isolatesoperator_id, and the hook's once-per-process cache, so a developer's.envcan't change test results.Privacy
Account names now reach the trail and forwarded events, where there used to be a constant. The changelog says so plainly. Setting
AGENTMETRY_OPERATOR_IDto a pseudonym keeps them out of a SIEM. Nothing reads another vendor's credential store, per the "What NOT to do" section of #168.Not in scope
This is attribution by claim: a key holder can claim any operator, as they can already inject any event. Making it provable on a fleet is per-host signing (enterprise #1), sequenced after a pilot conversation.
Verification
pytest -q: 1375 passed, 1 skipped (32 new intest_operator_attribution.py, including the issue's two acceptance tests: a fresh install no longer recordslocal, and a configured ID wins)ruff check agentmetry tests: cleanbenchmark: all cases behaved as recorded15846a0915769d4a, unchanged. No frozen file reads identity; the rules only useactor_type.🤖 Generated with Claude Code