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
2. API Routes Integration
3. Agent Tools Integration
4. Investigation Workflow Updates
5. Frontend Integration
Files to Modify
dataing/src/dataing/temporal/activities/execute_query.py
dataing/src/dataing/temporal/workflows/investigation.py
dataing/src/dataing/entrypoints/api/routes/datasources.py
dataing/src/dataing/agents/ (tool definitions)
frontend/src/features/datasources/ (credentials UI)
Acceptance Criteria
Related
- Design doc:
docs/plans/2026-01-18-principal-bound-query-execution-design.md
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
QueryGatewaypattern.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.mdfor the full design.Remaining Tasks
1. Temporal Activities Integration
execute_query.pyactivity to useQueryGateway.execute()instead of direct adapter callsuser_idto activity inputs that execute queriesinvestigation_idthroughQueryContextfor audit logging2. API Routes Integration
POST /datasources/{id}/queryindatasources.pyto useQueryGatewayuser_idfromApiKeyContextand creates aQueryPrincipal3. Agent Tools Integration
QueryContext(source='agent')for audit attribution4. Investigation Workflow Updates
user_idin Temporal workflow stateuser_idthrough child workflows to activitiesInvestigationWorkflowto capture initiating user5. Frontend Integration
CredentialsNotConfiguredErrorlast_used_atand connection status in datasource listFiles 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
QueryGateway.execute()QueryPrincipalwith validuser_idquery_audit_logtable captures all query executionsRelated
docs/plans/2026-01-18-principal-bound-query-execution-design.md