feat(envelope): carry execution-environment identity and sandbox LLM usage on exported spans - #80
Merged
Merged
Conversation
…exported spans SessionEnvironment (image, imageDigest, sandboxId, cwd, gitCommit) rides SessionRef, is stamped onto every span, and survives into the OTLP resource block. sandbox-events imports recover it from the wrapper context or the stream's runtime.ready event. Absent fields stay absent: 'environment not captured' remains distinguishable from any captured value, which is what downstream replay eligibility keys on.
…ported spans sandbox-events recordings put usage on the llm event row (OpenAI usage.prompt_tokens, opencode tokenUsage.inputTokens, bare snake_case); the converter dropped all of them, so an imported sandbox session lost token accounting and cost attribution at export time. LLM-kind rows now map model + input/output tokens + cost onto the span's canonical attributes. Absent counts stay absent — no invented zeros.
tangletools
approved these changes
Aug 5, 2026
tangletools
left a comment
There was a problem hiding this comment.
✅ Auto-approved drewstone PR — 7859d0b1
This PR was opened by the trusted drewstone account.
The full PR reviewer audit still runs separately and will publish findings if it detects issues.
tangletools · auto-approval · reason: drewstone_author · 2026-08-05T18:49:23Z
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
Two commits that make an exported trace carry the identity of the environment it ran in and the LLM usage it consumed:
b18292a—SessionEnvironmentonSessionRef; environment attributes stamped on spans and lifted into the OTLP resource block (container.image.name,container.image.digest,tangle.sandbox.id,tangle.environment.cwd); the sandbox-events importer recovers identity from wrapper context orruntime.ready.7859d0b— sandbox LLM-event model + token usage mapped onto exported spans.Why
A finding about a trace is only replayable if the trace names the exact image and cwd it ran in. This is the capture half of the proof-carrying findings loop: analyst findings over these spans can now be re-executed in the pinned image and receipted.
Proof (executed, not claimed)
Exercised end-to-end on a real glm-5.2 debugging session in
ctb-replay:a381a92725e8-uid1000(2026-08-04/05):sha256:b482f70f5df0e69ef630fbee6cf8cb2af39917aa7abd193d8ef91ee90eb680d5.~/bench-cache/ctb-20260801/goal1/goal2/receipts/).Branch is 2 commits ahead of
main, behind 0.