This is an automated email from the ASF dual-hosted git repository. warren pushed a commit to branch feat/q-dev-logging-enrich-dashboards in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
commit 7752a6b5f27bc1b34580a5658c82b0e1fa06f278 Author: warren <[email protected]> AuthorDate: Sun Mar 22 01:14:46 2026 +0800 docs: add AI-era productivity analysis assessment and implementation plan --- logs/ai-era-productivity-analysis.md | 146 +++++++++++++++++++++++++++++++++++ logs/ai-era-productivity-plan.md | 140 +++++++++++++++++++++++++++++++++ 2 files changed, 286 insertions(+) diff --git a/logs/ai-era-productivity-analysis.md b/logs/ai-era-productivity-analysis.md new file mode 100644 index 000000000..58d18868f --- /dev/null +++ b/logs/ai-era-productivity-analysis.md @@ -0,0 +1,146 @@ +# AI 时代效能分析 — 现状评估与优化方向 + +日期: 2026-03-20 + +## 一、现有数据资产全景 + +### Kiro (Q-Dev) 插件 +| 表名 | 数据内容 | 粒度 | +|---|---|---| +| `_tool_q_dev_user_report` | credits, messages, conversations, subscription tier, overage | 每天/每用户/每 client_type | +| `_tool_q_dev_user_data` | 旧格式 43 个 feature-level 指标 (inline, chat, code fix, code review, dev, doc gen, test gen, transformation) | 每天/每用户 | +| `_tool_q_dev_chat_log` | 逐条 chat 交互 (prompt/response 长度, model, conversation, steering, spec mode, code refs, web links) | 秒级/每请求 | +| `_tool_q_dev_completion_log` | 逐条 inline completion (file, context length, completions count) | 秒级/每请求 | + +### GitHub Copilot 插件 +| 表名 | 数据内容 | 粒度 | +|---|---|---| +| `_tool_copilot_enterprise_daily_metrics` | DAU/WAU/MAU, code gen/acceptance activity, LOC suggested/added, PR created/reviewed by Copilot | 每天/企业级 | +| `_tool_copilot_user_daily_metrics` | user_login, code gen/acceptance activity | 每天/每用户 | +| `_tool_copilot_metrics_by_ide` | 按 IDE 分的使用量 | 每天 | +| `_tool_copilot_metrics_by_feature` | 按功能 (chat_panel, inline_chat 等) 分 | 每天 | +| `_tool_copilot_metrics_by_language_feature` | 按编程语言+功能分 | 每天 | +| `_tool_copilot_seats` | license 分配和最后活跃时间 | 快照 | + +### 传统 DevOps 数据 (Domain Layer) +| 数据域 | 表数 | 关键表 | +|---|---|---| +| Code | 11 | repos, commits, commit_files, pull_requests, refs | +| DevOps/CICD | 8 | cicd_pipelines, cicd_deployments, cicd_deployment_commits | +| Tickets | 18 | issues, boards, sprints | +| Code Quality | 5 | cq_projects, cq_issues, cq_file_metrics | +| QA | 4 | qa_test_cases, qa_test_case_executions | +| Cross-domain | 18 | users, accounts, project_pr_metrics | + +### 已有 Dashboard (50+) +- DORA 系列 (5 个): 四指标 + 明细 +- Copilot 系列 (2 个): Adoption + DORA Correlation +- Kiro 系列 (4 个): Usage, Legacy Feature, Logging, Executive +- 传统 DevOps: GitHub, GitLab, Jira, Jenkins, SonarQube 等 + +--- + +## 二、现有能力 vs AI 时代效能分析的差距 + +### 已经有的 +- Kiro 使用数据 (credits, messages, feature-level metrics, prompt logs) +- GitHub Copilot 采纳数据 (seats, acceptance rates, LOC) +- Copilot + DORA 关联分析 (已有 dashboard, 含 Pearson's r 相关系数) +- 传统 DevOps 指标 (commits, PRs, DORA 四指标, SonarQube) + +### 关键缺失:AI 对结果的影响闭环 + +目前所有 AI 指标都是"输入侧"的 — 用了多少、接受了多少。但缺乏"输出侧"的闭环: + +| 维度 | 现状 | 缺失 | +|---|---|---| +| AI 代码命运追踪 | 知道 acceptance rate | 不知道接受后是否被 revert、是否引入 bug | +| AI 对代码质量的影响 | 有 SonarQube 数据 | 没有 AI 使用量 vs code smell 的关联 | +| AI 对效率的因果关系 | Copilot+DORA 有相关性(r值) | Kiro 没有同等的 DORA 关联 | +| 多 AI 工具统一视图 | Copilot 和 Kiro 各自独立 | 无法对比/汇总跨工具的 AI 总效能 | +| AI ROI (成本效益) | 有 credits_used | 没有 credits per PR merged / per deployment | +| 用户身份统一 | 各插件独立 user_id | Kiro userId -> git author -> Copilot userLogin 无法打通 | + +--- + +## 三、优化方向 (按优先级) + +### P0 — 短期可做 (利用现有数据,无需新数据源) + +#### 1. Kiro + DORA 关联 Dashboard +- 类似已有的 Copilot+DORA correlation dashboard +- 将 Kiro credits/messages 与 PR cycle time 关联 +- 按周聚合,计算 Pearson's r 相关系数 +- 分桶对比:AI 重度使用周 vs 轻度使用周的 DORA 表现 +- 数据来源: `_tool_q_dev_user_report` + `project_pr_metrics` + +#### 2. AI 成本效益 Dashboard +- Credits per PR merged +- Credits per deployment +- Credits per accepted line of code (已有) +- Credits per issue resolved +- 趋势:成本效益是否随时间改善 +- 数据来源: `_tool_q_dev_user_report` + `pull_requests` + `cicd_deployments` + `issues` + +#### 3. 多 AI 工具对比 Dashboard +- Copilot vs Kiro 并排对比 +- 统一指标: adoption rate, acceptance rate, LOC generated, active users +- 趋势对比: 两个工具的采纳曲线 +- 数据来源: `_tool_copilot_enterprise_daily_metrics` + `_tool_q_dev_user_report` + +### P1 — 中期 (需要新的数据打通) + +#### 4. AI Code Quality 闭环 +- SonarQube findings 按 "AI 重度用户 vs 轻度用户" 分组 +- AI 辅助 code review vs 人工 review 的 finding 数量对比 +- 需要打通: AI 使用量 -> commit author -> SonarQube findings +- 数据来源: `_tool_q_dev_user_data` + `commits` + `cq_issues` + +#### 5. 用户身份统一层 +- 建立 Kiro userId -> domain users -> Copilot userLogin 的映射 +- 可以通过 email 或 display name 做 fuzzy matching +- 一旦打通,所有 AI 指标都可以跟 git/PR/issue 指标关联 +- 实现方式: 新的 cross-domain 映射表或扩展现有 user_accounts 表 + +### P2 — 长期 (需要新数据源或复杂分析) + +#### 6. AI 代码存活率 +- 追踪 AI 生成代码从接受到被修改/删除的时间 +- 需要: commit diff 分析 + AI acceptance 时间戳关联 +- 指标: AI 代码平均存活天数, AI 代码 revert 率 + +#### 7. AI 辅助 Code Review 效能 +- 衡量 AI 对 review 速度和质量的影响 +- 有 AI review (Kiro code review) vs 纯人工 review 的对比 +- 指标: review time, comments count, approval rate, rework rate + +#### 8. Developer Flow 与 AI 的关系 +- 分析开发者何时使用 AI (时段、任务类型) +- AI 使用的上下文切换频率 +- AI prompt 复杂度随时间的演变 (学习曲线) +- 数据来源: `_tool_q_dev_chat_log` (已有 timestamp, prompt_length, model_id) + +--- + +## 四、可连接的数据节点 + +``` +Kiro user_id ──────┐ + ├──> domain users.id ──> commits.author_id ──> PR, Issues, DORA +Copilot user_login ─┘ ──> cq_issues (SonarQube) + ──> cicd_deployments + ──> qa_test_case_executions + +_tool_q_dev_user_report.date ──> project_pr_metrics (weekly join for DORA correlation) +_tool_q_dev_chat_log.timestamp ──> commits.created_date (intra-day correlation) +_tool_copilot_enterprise_daily_metrics.day ──> project_pr_metrics (already done in copilot_impact) +``` + +--- + +## 五、技术实现建议 + +1. P0 的三个 dashboard 可以纯 Grafana SQL 实现,无需后端改动 +2. P1 的用户身份统一需要一个新的 convertor subtask 或者 domain layer 扩展 +3. P2 的代码存活率需要 git diff 分析能力 (git extractor 已有 commit_files 数据) +4. 建议先做 P0 中的 "Kiro + DORA 关联",因为已有 Copilot+DORA 的模板可以参考 diff --git a/logs/ai-era-productivity-plan.md b/logs/ai-era-productivity-plan.md new file mode 100644 index 000000000..1e897aec4 --- /dev/null +++ b/logs/ai-era-productivity-plan.md @@ -0,0 +1,140 @@ +# Plan: AI 时代效能分析增强 + +## Context + +DevLake 已有 Kiro (Q-Dev) 和 GitHub Copilot 两套 AI 工具的数据采集,也有 Copilot+DORA 的关联分析 dashboard。但存在三个关键缺口: +1. Kiro 的新格式数据(credits/messages)没有和 DORA 关联 +2. 没有跨 AI 工具的统一对比视图 +3. 没有 AI 成本效益指标(credits per PR/deployment) + +本计划分三个阶段实现,P0 纯 Grafana dashboard 不改后端。 + +## Phase 1 (P0): 三个新 Grafana Dashboard — 无后端改动 + +### Dashboard A: `grafana/dashboards/KiroCreditsDORA.json` +**Kiro Credits + DORA Correlation** + +复用 `GithubCopilotDORACorrelation.json` 的模式(周级聚合 JOIN + Pearson's r)。 + +关键面板: +- Weekly Credits vs PR Cycle Time(双轴时序图) +- Pearson's r 相关系数(stat panel) +- High AI Usage vs Low AI Usage 周的 cycle time 对比 +- Credits vs Deployment Frequency / CFR / MTTR + +数据源:`_tool_q_dev_user_report`(周聚合 credits)JOIN `project_pr_metrics`(周聚合 cycle time)on `week_start` + +模板变量:`project` (from `project_pr_metrics`) + +### Dashboard B: `grafana/dashboards/AICostEfficiency.json` +**AI Cost-Efficiency** + +关键面板: +- Credits per Merged PR(周趋势) +- Credits per Deployment(周趋势) +- Credits per Issue Resolved(周趋势) +- Summary Stats(总计 credits, credits/PR, credits/deploy) + +数据源:`_tool_q_dev_user_report` 周聚合 LEFT JOIN `pull_requests` / `cicd_deployment_commits` / `issues` 周聚合 on `week_start` + +### Dashboard C: `grafana/dashboards/MultiAIComparison.json` +**Multi-AI Tool Comparison (Copilot vs Kiro)** + +关键面板: +- Active Users 并排对比(周趋势) +- Code Generation Activity 对比 +- LOC Accepted 对比 +- Acceptance Rate 对比(柱状图/表格) + +数据源:`_tool_q_dev_user_report` + `_tool_q_dev_user_data` vs `_tool_copilot_enterprise_daily_metrics` + +模板变量:`project`, `connection_id`/`scope_id`(Copilot 侧) + +## Phase 2 (P1): 用户身份映射 — 需要后端改动 + +### 核心问题:Kiro userId 如何绑定 PR author + +**Kiro 侧数据:** +- `user_id`: AWS Identity Store UUID(如 `6478a4a8-60a1-70d9-37bc-6aae85f6746a`) +- `display_name`: 通过 AWS Identity Store API 解析的名字(如 `Yingchu Chen`) + +**PR 侧数据:** +- `author_name`: git 提交者名字(如 `Yingchu Chen`) +- `author_id`: 平台格式(如 `github:GithubAccount:1:12345`) + +**可行方案:** + +| 方案 | 做法 | 优点 | 缺点 | +|---|---|---|---| +| A: DisplayName 匹配 | Kiro display_name == PR author_name | 简单 | 名字可能不一致,多人同名 | +| B: 手动配置映射 | 在 connection/scope config 里让用户配置映射 | 精确 | 需要手动维护 | +| C: AWS SSO → 邮箱 | 扩展 Identity Client 获取用户邮箱,匹配 git commit 邮箱 | 自动且精确 | 需要额外 AWS API 权限 | +| D: 聚合级别(不绑定用户) | P0 已用的方式:按周聚合整个团队 | 零改动 | 无法做 per-developer 分析 | + +**推荐路线:D(P0 先上)→ B+C(P1 实现)** + +### 新模型 +- `backend/core/models/domainlayer/crossdomain/ai_tool_user_mapping.go` — 映射 Kiro userId/DisplayName ↔ git AuthorName ↔ Copilot UserLogin + +### 新 Migration +- `backend/core/models/migrationscripts/20260321_add_ai_tool_user_mapping.go` + +### 新 Task +- `backend/plugins/q_dev/tasks/identity_mapper.go` — 从 `_tool_q_dev_user_report.display_name` 匹配 `pull_requests.author_name`(精确 + 模糊) +- `backend/plugins/gh-copilot/tasks/identity_mapper.go` — 类似逻辑 + +### 新 Dashboard +- `grafana/dashboards/KiroUserProductivity.json` — 基于映射表的 per-developer AI productivity vs PR metrics + +## Phase 3 (P2): AI + Code Quality 关联 + +### 新 Dashboard +- `grafana/dashboards/AICodeQuality.json` +- AI Usage Intensity vs 新增 Code Issues(周趋势) +- Per-Developer AI Usage vs Code Quality(需 P1 映射表) +- AI Code "Survival Rate"(高 AI 使用周 vs 低使用周的 PR revert 率) + +数据源:`cq_issues`(有 `commit_author_email` 可作为 join key) + +## 关键参考文件 + +| 用途 | 文件路径 | +|---|---| +| Copilot+DORA 模板 | `grafana/dashboards/GithubCopilotDORACorrelation.json` | +| QDev+DORA 现有 | `grafana/dashboards/QDevDORA.json` | +| Kiro credits 模型 | `backend/plugins/q_dev/models/user_report.go` | +| PR metrics 模型 | `backend/core/models/domainlayer/crossdomain/project_pr_metric.go` | +| 身份解析参考 | `backend/plugins/q_dev/tasks/identity_client.go` | +| 用户映射表参考 | `backend/core/models/domainlayer/crossdomain/user_account.go` | + +## 实施顺序 + +| Step | Phase | 产出 | 依赖 | +|------|-------|------|------| +| 1 | P0 | `KiroCreditsDORA.json` | 无 | +| 2 | P0 | `AICostEfficiency.json` | 无 | +| 3 | P0 | `MultiAIComparison.json` | Copilot + Kiro 数据 | +| 4 | P1 | `ai_tool_user_mapping.go` 模型 + migration | 无 | +| 5 | P1 | `q_dev/tasks/identity_mapper.go` | Step 4 | +| 6 | P1 | `gh-copilot/tasks/identity_mapper.go` | Step 4 | +| 7 | P1 | `KiroUserProductivity.json` | Steps 5-6 | +| 8 | P2 | `AICodeQuality.json` | Steps 5-6 + SonarQube 数据 | + +Steps 1-3 可并行。 + +## 验证方法 + +### P0 验证 +1. Import dashboard JSON 到 Grafana +2. 确认 `$project` 变量从 `project_pr_metrics` 正确加载 +3. 确认 Pearson's r 值在 [-1, 1] 范围且至少有 4 个数据点 +4. Playwright E2E 截图每个 dashboard + +### P1 验证 +1. 单元测试精确匹配和模糊匹配逻辑 +2. 集成测试:插入测试数据 → 运行 mapper → 验证映射表 +3. 验证 per-developer dashboard 数据正确 + +### P2 验证 +1. 需要 SonarQube 数据在 `cq_issues` 中 +2. 验证 `commit_author_email` 与映射表匹配
