Skip to content

feat(envelope): carry execution-environment identity and sandbox LLM usage on exported spans - #80

Merged
drewstone merged 2 commits into
mainfrom
feat/envelope-environment-identity
Aug 5, 2026
Merged

feat(envelope): carry execution-environment identity and sandbox LLM usage on exported spans#80
drewstone merged 2 commits into
mainfrom
feat/envelope-environment-identity

Conversation

@drewstone

Copy link
Copy Markdown
Contributor

What

Two commits that make an exported trace carry the identity of the environment it ran in and the LLM usage it consumed:

  • b18292aSessionEnvironment on SessionRef; 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 or runtime.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):

  • Exported spans carry all four resource attributes — capture proof sha256:b482f70f5df0e69ef630fbee6cf8cb2af39917aa7abd193d8ef91ee90eb680d5.
  • 7 analyst findings over the imported trajectory were then verified by sandbox replay against the image the spans named: 23/23 prefix steps, 0 divergences, returncode+output-signature match (~/bench-cache/ctb-20260801/goal1/goal2/receipts/).
  • 625-test suite green at branch tip.

Branch is 2 commits ahead of main, behind 0.

…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 tangletools left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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

@drewstone
drewstone merged commit 10c5e7c into main Aug 5, 2026
1 check passed
@drewstone
drewstone deleted the feat/envelope-environment-identity branch August 5, 2026 18:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants