feat(storage): add agentId filter to aggregation queries#1081
Merged
Conversation
- Add migration v5: agent_id column + index on sessions table with backfill from RunStarted event data - Add agentId to SessionStartData and SessionRow interfaces - Populate agent_id when inserting sessions - Add agentId?: string to AggregationTimeFilter interface - Wire agentId into buildTimeConditions() to join/filter via sessions - Refactor agentSummaries() to prefer sessions.agent_id over json_extract() for faster indexed lookups - Update migration test expectations for v5 - Add 7 new tests for agentId filtering across agentSummaries, countEventsByKind, countDecisionsByOutcome, and teamReport Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
jpleva91
pushed a commit
that referenced
this pull request
Mar 27, 2026
…urity 6→5, risk 8→7 - Add 4 new shipped items to Current State table: - Credential file write detection via shell commands (PR #1032, closes #618) - Agent identity in agentguard inspect output (PR #1078, closes #1030) - agentId filter in storage aggregation queries (PR #1081, closes #1029) - Site user capture funnel hero/CTA/early access (PR #1076, closes #938) - Update v3.0 capture funnel: mark site CTA done, list remaining CLI items with #1084 - Add #1086 tracking to Go Kernel Phase 1 - swarm-state.json: risk 8→7, security bypass count 6→5 (#618 removed), triaged new issues #1086/#1085/#1084/#1073/#1072/#1027/#1026 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This was referenced Mar 27, 2026
Closed
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.
Closes #1029
Implementation Summary
What changed:
sessionstable: newagent_id TEXTcolumn with index (idx_sessions_agent_id), backfilled from RunStarted event JSON dataagentId?: stringtoSessionStartDataandagent_idtoSessionRow— sessions can now be stamped with an agent identity at creation timeagentId?: stringtoAggregationTimeFilterinterfaceagentIdintobuildTimeConditions()— filters events/decisions to runs owned by the specified agent viasessions.agent_idagentSummaries()to prefersessions.agent_id(indexed) overjson_extract()on RunStarted event data viaCOALESCE(s.agent_id, json_extract(...))agentSummaries,countEventsByKind,countDecisionsByOutcome,teamReport, empty results for non-existent agent, andsessions.agent_idprecedence over event JSONHow to verify:
pnpm build --filter=@red-codes/storage— builds cleanpnpm test --filter=@red-codes/storage— all 206 tests passpnpm lint --filter=@red-codes/storage— no lint errorsTier C scope check:
Tier C implementation by copilot-cli — AgentGuard three-tier governance