feat: AirPlan V2 — 全专家插件强制路由 + 事件系统规范化
P0-8 扩大: do_mode.py finish_worker 全专家插件强制路由 - GUI→XDB, network→NDB, C/C++→SDB, done→Rvr, blocked/failed→Dbg - 证据去重: 已有 xdbSessions/ndbSessions/sdbReports/rvrReviewed 则跳过 P1-GAP17: 事件 emit 规范化 - 新增 7 个事件常量 (TASK_ENTERED, TASK_FINISHED, ENGINE_ENTERED 等) - 全部 emit 调用替换字符串字面量为常量,零残留 - 30 个事件类型常量全部定义且唯一 P1-GAP18: 事件日志原子轮转 - emit 计数器每 128 次检查轮转,避免每次 emit 读文件 - 清除未使用的 _emit_with_completion/_pending_merge_complete - 原子轮转: tempfile+os.replace 保证不损坏 eng 极端接管: 强制调用全部专家插件 (Dbg/XDB/NDB/SDB/Rvr) commands/do.md: 更新为全专家插件路由文档 全量测试: 69 通过, 0 失败 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
63
lib/air_runtime/modes/sdb_mode.py
Executable file
63
lib/air_runtime/modes/sdb_mode.py
Executable file
@@ -0,0 +1,63 @@
|
||||
"""AirSDB mode — V2 静态分析器模式。
|
||||
|
||||
多后端静态分析 (cppcheck / clang-tidy / clippy / go-vet / tsc)
|
||||
以及 diff 模式(对比两次扫描结果)。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from air_runtime.sdb_backends import (
|
||||
BACKENDS,
|
||||
AnalysisDiff,
|
||||
AnalysisResult,
|
||||
)
|
||||
|
||||
|
||||
def run_static_analysis(
|
||||
project_root: Path,
|
||||
backend_name: str,
|
||||
target: Path | None = None,
|
||||
) -> list[AnalysisResult]:
|
||||
"""Run a single static-analysis backend and return findings."""
|
||||
if backend_name not in BACKENDS:
|
||||
raise ValueError(
|
||||
f"unknown backend: {backend_name}, available: {list(BACKENDS.keys())}"
|
||||
)
|
||||
return BACKENDS[backend_name].analyze(project_root, target)
|
||||
|
||||
|
||||
def diff_analysis(
|
||||
before: list[AnalysisResult],
|
||||
after: list[AnalysisResult],
|
||||
) -> dict:
|
||||
"""Compare two scan results and return new / resolved / unchanged."""
|
||||
return AnalysisDiff().diff(before, after)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# CLI entry point
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
def main(args) -> None:
|
||||
project_root = Path(args.project).expanduser().resolve()
|
||||
backend = getattr(args, "backend", None) or "cppcheck"
|
||||
target = Path(args.target).expanduser().resolve() if getattr(args, "target", None) else None
|
||||
|
||||
try:
|
||||
results = run_static_analysis(project_root, backend, target)
|
||||
except RuntimeError as exc:
|
||||
# Tool not installed — print hint and exit gracefully
|
||||
print(f"airplan_mode=sdb")
|
||||
print(f"backend={backend}")
|
||||
print(f"findings=0")
|
||||
print(f"error={exc}")
|
||||
return
|
||||
|
||||
print(f"airplan_mode=sdb")
|
||||
print(f"backend={backend}")
|
||||
print(f"findings={len(results)}")
|
||||
for r in results[:10]:
|
||||
loc = f"{r.file}:{r.line}" if r.line is not None else r.file
|
||||
print(f"{loc}: {r.severity}: {r.message}")
|
||||
Reference in New Issue
Block a user