Files
seal-use/skills/seal-use/references/rule-lint.md
T

3.2 KiB

Seal Approval Rule Linter & Quality Validation

Use this reference when analyzing, validating, or linting Seal AI approval rules to detect vague phrasing, missing exception evidence, or formatting defects before publishing.

Key Principles

  • Default State: Linter is disabled by default in global configuration (lint.enabled: false) to avoid unsolicited noise during standard operations.
  • Explicit Triggering: seal-use rules lint always runs regardless of global configuration.
  • Draft Hook: When seal-use config lint enable is set, seal_approval_rule_update outputs real-time diagnostic warnings to stderr without mutating stdout payloads.
  • Fault-Tolerant Fallback: If a custom .ts linter file has syntax errors, runtime exceptions, or is missing, the engine logs a warning to stderr and silently falls back to the built-in heuristic linter without failing.

CLI Commands

1. Lint Current Draft Rules (Whole-RuleSet Scan)

seal-use rules lint --corp <corpId>

2. Lint Specific Historical Version or Single Rule

# Lint rules in published version 16
seal-use rules lint --version 16 --corp <corpId>

# Lint a specific rule by code (#0038)
seal-use rules lint --code '#0038' --corp <corpId>

# Summary mode (only show rules with issues)
seal-use rules lint --summary --corp <corpId>

3. Quality Gate for CI / Release

# If overall score is below 85, terminates with exit code 1
seal-use rules lint --min-score 85 --level error --corp <corpId>

4. Configure Global Linter Settings

# Check status
seal-use config lint status

# Enable auto lint on rule updates
seal-use config lint enable --linter builtin --min-score 80

# Disable auto lint
seal-use config lint disable

Built-In Detection Rules

Code Level Description Recommendation
TOO_SHORT error Rule description is under 5 characters. Add concrete conditions and criteria.
VAGUE_WORD error Contains subjective/fuzziness words (原则上, 尽量, 适当, 酌情, 一般情况下, 合理控制). Replace with rigid thresholds, enums, or criteria.
HANGING_EXCEPTION warning Exception trigger found (除非, 特殊情况, 经批准) without verifiable evidence keyword (备注, 附件, 证明, 邮件, 截图). Specify exact evidence source in invoice/document.

Custom TS Linters (Plugin-as-Code)

Place custom TypeScript linter functions in ~/.config/seal-use/linters/<name>.ts or ./linters/<name>.ts:

// ~/.config/seal-use/linters/finance-strict.ts
export default function customLinter(rule: { description: string }) {
  const issues = [];
  if (rule.description.includes("商务舱") && !rule.description.includes("副总裁")) {
    issues.push({
      level: "error",
      code: "FLIGHT_CABIN_RESTRICTION",
      snippet: "商务舱",
      message: "乘坐商务舱必须限定副总裁及以上级别",
      suggestion: "补充限制: '仅副总裁及以上职级允许报销商务舱'"
    });
  }
  return {
    score: issues.length === 0 ? 100 : 60,
    passed: issues.length === 0,
    issues
  };
}

Run with custom linter:

seal-use rules lint --linter finance-strict --corp <corpId>