F42: Add session_id support for agent/session cost tracking#7
Open
peterkacerik wants to merge 1 commit into
Open
F42: Add session_id support for agent/session cost tracking#7peterkacerik wants to merge 1 commit into
peterkacerik wants to merge 1 commit into
Conversation
- Add session_id to AllowedTagKey union and ALLOWED_TAGS set - Add CreateSessionConfig type for createSession() factory - Extend SessionBudget with optional sessionId config that auto-injects session_id tag into all tracked events - Add createSession() factory that generates sess_<random> IDs - Use crypto.randomBytes for Node 18 compatibility (not randomUUID) - Include session_id in enforcement events when configured - Add 7 new tests covering auto-tagging, override behavior, factory Part of F42: Agent/session cost tracking with per-run budgets. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
Author
Sentinel Code Review — APPROVEDAll planned SDK changes implemented correctly:
Security: Tag validation preserved, privacy invariant maintained, no injection vectors. CI green on Node 18/20/22. No blocking findings. Ready to merge. |
Contributor
Author
Code Review — APPROVED (Sentinel)PR #7 — F42: session_id support in SDK Mandatory Scans
Security: CLEAN
Non-blocking Findings
Tests: 7 new test cases. PASS.Merge blocked by B30. |
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.
Summary
session_idtoAllowedTagKeyandALLOWED_TAGSfor first-class session tracking supportSessionBudgetwith optionalsessionIdconfig that auto-injectssession_idtag into all tracked eventscreateSession()factory that generatessess_<random>IDs usingcrypto.randomBytes(Node 18 compatible)session_idin enforcement events when configuredTask
Task file:
aispendguard-tasks/active/features/F42-agent-session-cost-tracking.mdChanges
src/types.tssession_idtoAllowedTagKey, addedCreateSessionConfigtypesrc/validate.tssession_idtoALLOWED_TAGSsetsrc/session-budget.tssessionIdconfig, auto-tag injection intrackUsage(), session_id in enforcement eventssrc/index.tscreateSession()factory export,CreateSessionConfigtype exporttests/session-budget.test.mjsImplementation Coverage
src/types.tsAllowedTagKey + CreateSessionConfig,src/validate.tsALLOWED_TAGSsrc/session-budget.tssessionId field, auto-injection, enforcement eventssrc/index.tscreateSession() + exportstests/session-budget.test.mjs— 7 new test casesTesting
npm run buildpassesSentinel Findings Addressed
crypto.randomBytes(6).toString('hex')instead ofcrypto.randomUUID()for Node 18 compat🤖 Generated with Claude Code