AirPlan V2 initial release — unified scheduler with 12 sub-modes
Merges 8 V1 plugins into 1 unified plugin, adds 4 new components (dep, tst, sec, rvr). 12 sub-modes: arc, eng, do, dbg, xdb, sdb, ndb, ctx, dep, tst, sec, rvr. L1 code-level guarantees: atomic writes, file locks, evidence gating, forced debug routing, 3-phase arc gate, evidence-first debug gate, Chinese language lock, scheduler boundary. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
63
lib/air_runtime/modes/sdb_mode.py
Normal file
63
lib/air_runtime/modes/sdb_mode.py
Normal 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