Skip to content

Add Skills-based sandboxed code review agent example#141

Open
xyxhhhhh wants to merge 3 commits into
trpc-group:mainfrom
xyxhhhhh:issue-92-skills-sandbox-db-code-review-agent
Open

Add Skills-based sandboxed code review agent example#141
xyxhhhhh wants to merge 3 commits into
trpc-group:mainfrom
xyxhhhhh:issue-92-skills-sandbox-db-code-review-agent

Conversation

@xyxhhhhh

@xyxhhhhh xyxhhhhh commented Jul 8, 2026

Copy link
Copy Markdown

概述

Resolves #92
基于 Skills、沙箱执行、Filter 治理和 SQLite 持久化,新增自动代码评审 Agent 原型,把 diff 解析、规则审查、沙箱检查、结构化finding、脱敏、落库、监控审计和报告输出串成可测试链路。

主要变更

  • 新增 examples/skills_code_review_agent/ 示例目录
    • 支持 --diff-file--patch-file--repo-path--file-list--fixture
    • 输出 review_report.jsonreview_report.md
    • 支持 dry-run / fake sandbox,无模型 API Key 也能完整测试流程
  • 新增示例内 skills/code-review/
    • 包含 SKILL.md、规则文档、Filter policy、沙箱脚本和 scanner probe
    • 规则覆盖安全风险、异步错误、资源泄漏、测试缺失、敏感信息泄漏、数据库事务和连接生命周期
  • 新增沙箱执行编排
    • 默认 fake/dry-run,生产路径支持 Container workspace runtime
    • 提供 Cube/E2B workspace runtime adapter/factory,方便接入远端沙箱
    • local 仅作为显式开发 fallback
  • 新增 Filter 治理
    • 前置拦截高风险命令、敏感路径、非白名单网络访问、超预算执行
    • deny / needs_human_review 决策会写入报告和数据库,且不会进入沙箱执行
  • 新增 SQLite 存储
    • 保存 review task、input diff summary、sandbox run、filter decision、finding、monitoring summary 和 final report
    • 提供 ReviewStore.from_url(),默认支持 SQLite,并保留 SQL 后端扩展点
  • 新增结构化报告与监控审计
    • findings 字段包含 severity、category、file、line、title、evidence、recommendation、confidence、source
    • 报告包含 severity 统计、人工复核项、Filter 拦截摘要、沙箱执行摘要、监控指标和修复建议
  • 新增脱敏、去重和降噪
    • 报告和数据库写入前脱敏 API Key、token、password、JWT、AWS key 等敏感信息
    • 同文件同一行同一类别 finding 去重
    • 低置信度问题进入 warnings 或 needs_human_review,不混入高置信 findings
  • 新增公开 fixture 和回归测试
    • 覆盖无问题 diff、安全问题、异步资源泄漏、数据库生命周期、测试缺失、重复 finding、沙箱失败、敏感信息脱敏等场景

关于 Skill 和沙箱链路

主审查流水线使用确定性规则引擎和沙箱 request 编排来保证 dry-run 可重复、无模型 Key 可测试。同时提供 --skill-smoke,会真实调用 SDK 的 skill_load(skill_name="code-review")skill_run 执行 Skill 脚本,用于验证示例内 Skill 可被 tRPC-Agent 原生工具链加载和运行。

Container runtime 已通过 Docker smoke 测试验证。Cube/E2B 部分提供 workspace runtime adapter/factory 和 mock 级测试,用于说明远端沙箱接入边界。

验证

示例测试:

python -m pytest -q tests/examples/test_skills_code_review_agent.py

结果:

68 passed

Fixture 评测:

python examples/skills_code_review_agent/evaluate_fixtures.py --json

结果摘要:

fixture_count=13
precision=1.0
recall=1.0
false_positive=0
false_negative=0

Container smoke:

python -m pytest -q tests/examples/test_skills_code_review_agent.py::test_container_runtime_smoke_executes_skill_script

结果:

1 passed

全量测试:

python -m pytest -q

结果:

all passed

@xyxhhhhh xyxhhhhh force-pushed the issue-92-skills-sandbox-db-code-review-agent branch 3 times, most recently from 199ce9f to 6bc0a24 Compare July 8, 2026 06:54
@codecov

codecov Bot commented Jul 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@73655ab). Learn more about missing BASE report.

Additional details and impacted files
@@            Coverage Diff             @@
##             main        #141   +/-   ##
==========================================
  Coverage        ?   87.72548%           
==========================================
  Files           ?         467           
  Lines           ?       44018           
  Branches        ?           0           
==========================================
  Hits            ?       38615           
  Misses          ?        5403           
  Partials        ?           0           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@xyxhhhhh xyxhhhhh force-pushed the issue-92-skills-sandbox-db-code-review-agent branch from 6bc0a24 to a6f0895 Compare July 8, 2026 07:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

基于 Skills + 沙箱 + 数据库存储构建自动代码评审 Agent

1 participant