ln-622-build-auditor

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Build 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
shared/references/task_delegation_pattern.md#audit-coordinator--worker-contract
for contextStore structure.
Receives
contextStore
with:
tech_stack
(including build_tool, test_framework),
best_practices
,
principles
,
codebase_root
.
必读: 加载
shared/references/task_delegation_pattern.md#audit-coordinator--worker-contract
以了解contextStore结构。
接收包含以下内容的
contextStore
tech_stack
(包括build_tool、test_framework)、
best_practices
principles
codebase_root

Workflow

工作流程

  1. Parse Context: Extract tech stack, build tools, test framework from contextStore
  2. Run Build Checks: Execute compiler, linter, type checker, tests (see Audit Rules below)
  3. Collect Findings: Record each violation with severity, location, effort, recommendation
  4. Calculate Score: Count violations by severity, calculate compliance score (X/10)
  5. Return Results: Return JSON with category, score, findings to coordinator
  1. 解析上下文: 从contextStore中提取技术栈、构建工具、测试框架
  2. 运行构建检查: 执行编译器、代码检查器、类型检查器、测试(见下方审计规则)
  3. 收集检测结果: 记录每个违规项,包含严重程度、位置、修复工作量及建议
  4. 计算分数: 按严重程度统计违规项,计算合规分数(X/10)
  5. 返回结果: 向协调器返回包含类别、分数、检测结果的JSON

Audit Rules (Priority: CRITICAL)

审计规则(优先级:CRITICAL)

1. Compiler/Linter Errors

1. 编译器/代码检查器错误

What: Syntax errors, compilation failures, linter rule violations
Detection by Stack:
StackCommandError Detection
Node.js/TypeScript
npm run build
or
tsc --noEmit
Check exit code, parse stderr for errors
Python
python -m py_compile *.py
Check exit code, parse stderr
Go
go build ./...
Check exit code, parse stderr
Rust
cargo build
Check exit code, parse stderr
Java
mvn compile
Check exit code, parse build log
Linters:
  • ESLint (JS/TS):
    npx eslint . --format json
    → parse JSON for errors
  • 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
npm run build
tsc --noEmit
检查退出码,解析stderr获取错误
Python
python -m py_compile *.py
检查退出码,解析stderr
Go
go build ./...
检查退出码,解析stderr
Rust
cargo build
检查退出码,解析stderr
Java
mvn compile
检查退出码,解析构建日志
代码检查器:
  • ESLint (JS/TS):
    npx eslint . --format json
    → 解析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:
    DeprecationWarning
    ,
    @deprecated
    in stack trace
  • Dependency warnings:
    npm outdated
    ,
    pip list --outdated
  • Static analysis: Grep for
    @deprecated
    annotations
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 outdated
    pip 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:
StackToolCommand
TypeScripttsc
tsc --noEmit --strict
Pythonmypy
mypy . --strict
Pythonpyright
pyright --warnings
Gogo vet
go vet ./...
Rustcargo
cargo check
(type checks only)
Severity:
  • CRITICAL: Type error prevents compilation (
    tsc
    fails,
    cargo check
    fails)
  • HIGH: Runtime type error likely (implicit
    any
    , missing type guards)
  • MEDIUM: Missing type annotations (code works but untyped)
  • LOW: Overly permissive types (
    any
    ,
    unknown
    without narrowing)
Recommendation: Add type annotations, enable strict mode, use type guards
Effort: S-M (add types to single file vs refactor entire module)
检查内容: 类型不匹配、缺失类型注解、类型检查器失败
按技术栈检测:
技术栈工具命令
TypeScripttsc
tsc --noEmit --strict
Pythonmypy
mypy . --strict
Pythonpyright
pyright --warnings
Gogo vet
go vet ./...
Rustcargo
cargo check
(仅类型检查)
严重程度:
  • 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:
StackFrameworkCommand
Node.jsJest
npm test -- --json --outputFile=test-results.json
Node.jsMocha
mocha --reporter json > test-results.json
PythonPytest
pytest --json-report --json-report-file=test-results.json
Gogo test
go test ./... -json
Rustcargo test
cargo test --no-fail-fast
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.jsJest
npm test -- --json --outputFile=test-results.json
Node.jsMocha
mocha --reporter json > test-results.json
PythonPytest
pytest --json-report --json-report-file=test-results.json
Gogo test
go test ./... -json
Rustcargo test
cargo test --no-fail-fast
严重程度:
  • 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
    ,
    Makefile
    ,
    build.gradle
  • Incorrect paths in
    tsconfig.json
    ,
    webpack.config.js
    ,
    Cargo.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
shared/references/audit_scoring.md
for unified formula and score interpretation.
参见
shared/references/audit_scoring.md
了解统一公式及分数解读。

Output Format

输出格式

MANDATORY READ: Load
shared/references/audit_output_schema.md
for JSON structure.
Return JSON with
category: "Build Health"
and checks: compilation_errors, linter_warnings, type_errors, test_failures, build_config.
必读: 加载
shared/references/audit_output_schema.md
了解JSON结构。
返回包含
category: "Build Health"
及以下检查项的JSON:compilation_errors、linter_warnings、type_errors、test_failures、build_config。

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",