-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Overview
The principal-bound query execution infrastructure has been added (see linked PR), but integration with existing query paths is not complete. This issue tracks the remaining work to fully adopt the QueryGateway pattern.
Background
The goal is to ensure all SQL queries execute with user credentials (not service accounts), enforced by the database—not Dataing. See docs/plans/2026-01-18-principal-bound-query-execution-design.md for the full design.
Remaining Tasks
1. Temporal Activities Integration
- Update
execute_query.pyactivity to useQueryGateway.execute()instead of direct adapter calls - Add
user_idto activity inputs that execute queries - Pass
investigation_idthroughQueryContextfor audit logging
2. API Routes Integration
- Update
POST /datasources/{id}/queryindatasources.pyto useQueryGateway - Ensure the route extracts
user_idfromApiKeyContextand creates aQueryPrincipal
3. Agent Tools Integration
- Update agent tools that execute SQL to receive principal from workflow context
- Ensure tools pass
QueryContext(source='agent')for audit attribution
4. Investigation Workflow Updates
- Store
user_idin Temporal workflow state - Thread
user_idthrough child workflows to activities - Update
InvestigationWorkflowto capture initiating user
5. Frontend Integration
- Add credentials configuration UI under datasource settings
- Show "credentials required" prompt when queries fail with
CredentialsNotConfiguredError - Display
last_used_atand connection status in datasource list
Files to Modify
dataing/src/dataing/temporal/activities/execute_query.pydataing/src/dataing/temporal/workflows/investigation.pydataing/src/dataing/entrypoints/api/routes/datasources.pydataing/src/dataing/agents/(tool definitions)frontend/src/features/datasources/(credentials UI)
Acceptance Criteria
- All SQL queries go through
QueryGateway.execute() - Every query has a
QueryPrincipalwith validuser_id -
query_audit_logtable captures all query executions - Users without configured credentials see helpful error messages
- Existing tests pass, new integration tests added
Related
- Design doc:
docs/plans/2026-01-18-principal-bound-query-execution-design.md
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels