ln-622-build-auditor
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseBuild Health Auditor (L3 Worker)
Build Health Auditor (L3 Worker)
Specialized worker auditing build health and code quality tooling.
专注于审计构建健康与代码质量工具的工作器。
Purpose & Scope
目标与范围
- Worker in ln-620 coordinator pipeline - invoked by ln-620-codebase-auditor
- Audit codebase for build health issues (Category 2: Critical Priority)
- Check compiler/linter errors, deprecation warnings, type errors, failed tests, build config
- Return structured findings to coordinator with severity, location, effort, recommendations
- Calculate compliance score (X/10) for Build Health category
- ln-620协调器流水线中的工作器 - 由ln-620-codebase-auditor调用
- 审计代码库中的构建健康问题(类别2:最高优先级)
- 检查编译器/代码检查器错误、弃用警告、类型错误、测试失败、构建配置
- 向协调器返回包含严重程度、位置、修复工作量及建议的结构化检测结果
- 计算构建健康类别的合规分数(X/10)
Inputs (from Coordinator)
输入(来自协调器)
MANDATORY READ: Load for contextStore structure.
shared/references/task_delegation_pattern.md#audit-coordinator--worker-contractReceives with: (including build_tool, test_framework), , , .
contextStoretech_stackbest_practicesprinciplescodebase_root必读: 加载以了解contextStore结构。
shared/references/task_delegation_pattern.md#audit-coordinator--worker-contract接收包含以下内容的:(包括build_tool、test_framework)、、、。
contextStoretech_stackbest_practicesprinciplescodebase_rootWorkflow
工作流程
- Parse Context: Extract tech stack, build tools, test framework from contextStore
- Run Build Checks: Execute compiler, linter, type checker, tests (see Audit Rules below)
- Collect Findings: Record each violation with severity, location, effort, recommendation
- Calculate Score: Count violations by severity, calculate compliance score (X/10)
- Return Results: Return JSON with category, score, findings to coordinator
- 解析上下文: 从contextStore中提取技术栈、构建工具、测试框架
- 运行构建检查: 执行编译器、代码检查器、类型检查器、测试(见下方审计规则)
- 收集检测结果: 记录每个违规项,包含严重程度、位置、修复工作量及建议
- 计算分数: 按严重程度统计违规项,计算合规分数(X/10)
- 返回结果: 向协调器返回包含类别、分数、检测结果的JSON
Audit Rules (Priority: CRITICAL)
审计规则(优先级:CRITICAL)
1. Compiler/Linter Errors
1. 编译器/代码检查器错误
What: Syntax errors, compilation failures, linter rule violations
Detection by Stack:
| Stack | Command | Error Detection |
|---|---|---|
| Node.js/TypeScript | | Check exit code, parse stderr for errors |
| Python | | Check exit code, parse stderr |
| Go | | Check exit code, parse stderr |
| Rust | | Check exit code, parse stderr |
| Java | | Check exit code, parse build log |
Linters:
- ESLint (JS/TS): → parse JSON for errors
npx eslint . --format json - Pylint (Python):
pylint **/*.py --output-format=json - RuboCop (Ruby):
rubocop --format json - golangci-lint (Go):
golangci-lint run --out-format json
Severity:
- CRITICAL: Compilation fails, cannot build project
- HIGH: Linter errors (not warnings)
- MEDIUM: Linter warnings
- LOW: Stylistic linter warnings (formatting)
Recommendation: Fix errors before proceeding, configure linter rules, add pre-commit hooks
Effort: S-M (fix syntax error vs refactor code structure)
检查内容: 语法错误、编译失败、代码检查器规则违规
按技术栈检测:
| 技术栈 | 命令 | 错误检测方式 |
|---|---|---|
| Node.js/TypeScript | | 检查退出码,解析stderr获取错误 |
| Python | | 检查退出码,解析stderr |
| Go | | 检查退出码,解析stderr |
| Rust | | 检查退出码,解析stderr |
| Java | | 检查退出码,解析构建日志 |
代码检查器:
- ESLint (JS/TS):→ 解析JSON获取错误
npx eslint . --format json - Pylint (Python):
pylint **/*.py --output-format=json - RuboCop (Ruby):
rubocop --format json - golangci-lint (Go):
golangci-lint run --out-format json
严重程度:
- CRITICAL: 编译失败,无法构建项目
- HIGH: 代码检查器错误(非警告)
- MEDIUM: 代码检查器警告
- LOW: 代码检查器风格警告(格式问题)
建议: 先修复错误,配置代码检查器规则,添加提交前钩子
修复工作量: 小-中(修复语法错误 vs 重构代码结构)
2. Deprecation Warnings
2. 弃用警告
What: Usage of deprecated APIs, libraries, or language features
Detection:
- Compiler warnings: ,
DeprecationWarningin stack trace@deprecated - Dependency warnings: ,
npm outdatedpip list --outdated - Static analysis: Grep for annotations
@deprecated
Severity:
- CRITICAL: Deprecated API removed in next major version (imminent breakage)
- HIGH: Deprecated with migration path available
- MEDIUM: Deprecated but still supported for 1+ year
- LOW: Soft deprecation (no removal timeline)
Recommendation: Migrate to recommended API, update dependencies, refactor code
Effort: M-L (depends on API complexity and usage frequency)
检查内容: 已弃用的API、库或语言特性的使用
检测方式:
- 编译器警告:栈追踪中的、
DeprecationWarning@deprecated - 依赖警告:、
npm outdatedpip list --outdated - 静态分析:搜索注解
@deprecated
严重程度:
- CRITICAL: 已弃用API将在下一主版本移除(即将出现故障)
- HIGH: 已弃用但有迁移路径
- MEDIUM: 已弃用但仍支持1年以上
- LOW: 软弃用(无移除时间表)
建议: 迁移至推荐API,更新依赖,重构代码
修复工作量: 中-高(取决于API复杂度和使用频率)
3. Type Errors
3. 类型错误
What: Type mismatches, missing type annotations, type checker failures
Detection by Stack:
| Stack | Tool | Command |
|---|---|---|
| TypeScript | tsc | |
| Python | mypy | |
| Python | pyright | |
| Go | go vet | |
| Rust | cargo | |
Severity:
- CRITICAL: Type error prevents compilation (fails,
tscfails)cargo check - HIGH: Runtime type error likely (implicit , missing type guards)
any - MEDIUM: Missing type annotations (code works but untyped)
- LOW: Overly permissive types (,
anywithout narrowing)unknown
Recommendation: Add type annotations, enable strict mode, use type guards
Effort: S-M (add types to single file vs refactor entire module)
检查内容: 类型不匹配、缺失类型注解、类型检查器失败
按技术栈检测:
| 技术栈 | 工具 | 命令 |
|---|---|---|
| TypeScript | tsc | |
| Python | mypy | |
| Python | pyright | |
| Go | go vet | |
| Rust | cargo | |
严重程度:
- CRITICAL: 类型错误导致编译失败(失败、
tsc失败)cargo check - HIGH: 可能出现运行时类型错误(隐式、缺失类型守卫)
any - MEDIUM: 缺失类型注解(代码可运行但无类型)
- LOW: 类型过于宽松(、未收窄的
any)unknown
建议: 添加类型注解,启用严格模式,使用类型守卫
修复工作量: 小-中(为单个文件添加类型 vs 重构整个模块)
4. Failed or Skipped Tests
4. 测试失败或跳过
What: Test suite failures, skipped tests, missing test coverage
Detection by Stack:
| Stack | Framework | Command |
|---|---|---|
| Node.js | Jest | |
| Node.js | Mocha | |
| Python | Pytest | |
| Go | go test | |
| Rust | cargo test | |
Severity:
- CRITICAL: Test failures in CI/production code
- HIGH: Skipped tests for critical features (payment, auth)
- MEDIUM: Skipped tests for non-critical features
- LOW: Skipped tests with "TODO" comment (acknowledged debt)
Recommendation: Fix failing tests, remove skip markers, add missing tests
Effort: S-M (update test assertion vs redesign test strategy)
检查内容: 测试套件失败、跳过测试、测试覆盖率缺失
按技术栈检测:
| 技术栈 | 框架 | 命令 |
|---|---|---|
| Node.js | Jest | |
| Node.js | Mocha | |
| Python | Pytest | |
| Go | go test | |
| Rust | cargo test | |
严重程度:
- CRITICAL: CI/生产代码中的测试失败
- HIGH: 关键功能(支付、认证)的测试被跳过
- MEDIUM: 非关键功能的测试被跳过
- LOW: 带有"TODO"注释的跳过测试(已确认的技术债务)
建议: 修复失败的测试,移除跳过标记,添加缺失的测试
修复工作量: 小-中(更新测试断言 vs 重新设计测试策略)
5. Build Configuration Issues
5. 构建配置问题
What: Misconfigured build tools, missing scripts, incorrect paths
Detection:
- Missing build scripts in ,
package.json,Makefilebuild.gradle - Incorrect paths in ,
tsconfig.json,webpack.config.jsCargo.toml - Missing environment-specific configs (dev, staging, prod)
- Unused or conflicting build dependencies
Severity:
- CRITICAL: Build fails due to misconfiguration
- HIGH: Build succeeds but outputs incorrect artifacts (wrong target, missing assets)
- MEDIUM: Suboptimal config (no minification, missing source maps)
- LOW: Unused config options
Recommendation: Fix config paths, add missing build scripts, optimize build settings
Effort: S-M (update config file vs redesign build pipeline)
检查内容: 构建工具配置错误、缺失脚本、路径错误
检测方式:
- 、
package.json、Makefile中缺失构建脚本build.gradle - 、
tsconfig.json、webpack.config.js中的路径错误Cargo.toml - 缺失环境特定配置(开发、预发布、生产)
- 未使用或冲突的构建依赖
严重程度:
- CRITICAL: 配置错误导致构建失败
- HIGH: 构建成功但输出不正确的产物(错误目标、缺失资源)
- MEDIUM: 配置不够优化(无压缩、缺失源映射)
- LOW: 未使用的配置选项
建议: 修复配置路径,添加缺失的构建脚本,优化构建设置
修复工作量: 小-中(更新配置文件 vs 重新设计构建流水线)
Scoring Algorithm
评分算法
See for unified formula and score interpretation.
shared/references/audit_scoring.md参见了解统一公式及分数解读。
shared/references/audit_scoring.mdOutput Format
输出格式
MANDATORY READ: Load for JSON structure.
shared/references/audit_output_schema.mdReturn JSON with and checks: compilation_errors, linter_warnings, type_errors, test_failures, build_config.
category: "Build Health"必读: 加载了解JSON结构。
shared/references/audit_output_schema.md返回包含及以下检查项的JSON:compilation_errors、linter_warnings、type_errors、test_failures、build_config。
category: "Build Health"Critical Rules
关键规则
- Do not auto-fix: Report violations only; coordinator creates task for user to fix
- Tech stack aware: Use contextStore to run appropriate build commands (npm vs cargo vs gradle)
- Exit code checking: Always check exit code (0 = success, non-zero = failure)
- Timeout handling: Set timeout for build/test commands (default 5 minutes)
- Environment aware: Run in CI mode if detected (no interactive prompts)
- 请勿自动修复: 仅报告违规项;由协调器创建任务供用户修复
- 感知技术栈: 使用contextStore运行合适的构建命令(npm vs cargo vs gradle)
- 检查退出码: 始终检查退出码(0=成功,非0=失败)
- 超时处理: 为构建/测试命令设置超时(默认5分钟)
- 感知环境: 如果检测到CI模式则以该模式运行(无交互式提示)
Definition of Done
完成标准
- contextStore parsed successfully
- All 5 build checks completed (compiler, linter, type checker, tests, config)
- Findings collected with severity, location, effort, recommendation
- Score calculated using penalty algorithm
- JSON result returned to coordinator
- 成功解析contextStore
- 完成全部5项构建检查(编译器、代码检查器、类型检查器、测试、配置)
- 收集到的检测结果包含严重程度、位置、修复工作量及建议
- 使用惩罚算法计算分数
- 向协调器返回JSON结果
Reference Files
参考文件
- Audit scoring formula:
shared/references/audit_scoring.md - Audit output schema:
shared/references/audit_output_schema.md - Build audit rules: references/build_rules.md
Version: 3.0.0
Last Updated: 2025-12-23
- 审计评分公式:
shared/references/audit_scoring.md - 审计输出 schema:
shared/references/audit_output_schema.md - 构建审计规则:references/build_rules.md
版本: 3.0.0
最后更新: 2025-12-23",