feat(event-log): tag task_id / workflow_id from Loom env#51
Merged
Conversation
Additive, backward-compatible: when a session is launched by the Loom host (LOOM_TASK_ID / LOOM_WORKFLOW_ID set), hook events get tagged so token savings can be attributed to a Loom task exactly. - HookEvent gains optional task_id. - appendEvent auto-tags task_id from LOOM_TASK_ID and extends the workflow_id source chain with LOOM_WORKFLOW_ID (alongside the existing TOKEN_PILOT_WORKFLOW_ID / CLAUDE_CODE_WORKFLOW_ID). Outside Loom (no env) events are byte-identical to before. 1402 tests pass (3 pre-existing env-only failures in context-mode-detector are unrelated — confirmed by stashing this change); tsc clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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
When a session is launched by the Loom host, hook events get tagged with the Loom task so token savings can be attributed to a task exactly (the shared-ID "spine").
HookEventgains optionaltask_id.appendEventauto-tagstask_idfromLOOM_TASK_IDand extends theworkflow_idsource chain withLOOM_WORKFLOW_ID(alongside existingTOKEN_PILOT_WORKFLOW_ID/CLAUDE_CODE_WORKFLOW_ID).Backward compatibility
Env-driven and additive. Outside Loom (no env) the emitted event is byte-identical to before — covered by a test asserting
task_idis absent whenLOOM_TASK_IDis unset.Verification
npx vitest run→ 1402 pass (added 3 tests). The only 3 failures are pre-existing, environment-only (context-mode-detectorfinds a real~/.mcp.json) and unrelated — confirmed by stashing this change and re-running.npx tsc --noEmit→ clean🤖 Generated with Claude Code