--- id: add-caller-account-id name: Add callerAccountId to Call Graph Nodes status: completed depends_on: [] scope: narrow risk: low impact: component level: implementation --- ## Description W19: `call_graph_nodes.identity` stores `{ id, scopes, resources }` as a JSONB snapshot, but there's no FK to `accounts.id`. Querying "all calls made by account X" requires JSONB containment, which is slow without a GIN index. Add a `callerAccountId` text column with FK → accounts.id (SET NULL) for efficient querying, or add a GIN index on `identity` if JSONB queries are the intended access pattern. ## Acceptance Criteria - [ ] `call-graph.md` adds `callerAccountId` column (text, nullable, FK → accounts.id, ON DELETE SET NULL), OR - [ ] Alternative documented: GIN index on `identity` column with justification - [ ] If `callerAccountId` added: `table-reference.md` cascade table updated with the new FK - [ ] Query pattern documented: "all calls by account X" uses `callerAccountId` ## References - docs/reviews/storage-architecture-review-2026-04-21.md#W19 - docs/architecture/storage/call-graph.md:20 ## Notes > To be filled by implementation agent ## Summary > To be filled on completion