Declare non-negotiable architectural boundaries, minimum 8-dimension health thresholds, secret zero-tolerance, license allow/denylists, diff blast-radius caps, and time-bounded exception waivers either inline in eforge.config.yaml or in standalone YAML/JSON policy documents.

1. Policy Discovery Hierarchy & CLI Execution

When eforge policy check runs, it resolves the active PolicyDocument in the following precedence order: 1. Explicit CLI flag (--policy <path>) → 2. Inline policy: block in eforge.config.yaml. If neither is present, it exits with ExitCode::ConfigurationError (2).

# Evaluate inline policy: block in eforge.config.yaml
eforge policy check

# Evaluate an external YAML or JSON organization policy file
eforge policy check --policy ./policies/org-security-policy.yaml --format markdown

# Fail on Warning verdict as well when findings meet or exceed medium severity
eforge policy check --fail-on medium --format json

2. Complete Declarative Policy Schema

Below is the complete schema supported by parse_policy_yaml and load_policy (can be placed directly under policy: in eforge.config.yaml or at the root of an external policy.yaml / policy.json file):

name: enterprise-standard-gate
version: 1
organization: elcode-id

constraints:
  min_health_score: 80
  min_dimension_scores:
    architecture: 85
    security: 90
    testing: 75
    dependency_health: 80
  enforce_secret_zero_tolerance: true
  disallowed_severities:
    - critical
    - high
  forbidden_licenses:
    - GPL-3.0-only
    - AGPL-3.0-only
    - SSPL-1.0
  max_circular_dependencies: 0
  max_blast_radius_modules: 5
  max_modified_lines_without_tests: 150
  required_rule_packs:
    - recommended
    - security

waivers:
  - rule_id: security/high-entropy-secret
    path_pattern: "fixtures/**"
    expires_at: "2027-06-30T23:59:59Z"
    justification: "Synthetic test credentials used exclusively in deterministic test fixtures"

overrides:
  - rule_id: arch/no-circular-dependencies
    severity: critical
    enabled: true

3. Evaluated Constraints Reference (PolicyConstraints)

Constraint FieldTypeDeterministic Gate Evaluation Rule
min_health_scoreu8 (0..=100)Fails with a violation if the overall weighted repository HealthScore.total is below this threshold.
min_dimension_scoresMap<string, u8>Enforces per-dimension minimum scores across any of the 8 dimensions (architecture, security, maintainability, reliability, testing, dependency_health, documentation, release_readiness).
enforce_secret_zero_tolerancebooleanWhen true, immediately fails if any un-waived secret or credential finding (security/hardcoded-secret, security/private-key, security/high-entropy-secret) is present.
disallowed_severitiesSeverity[]Fails if any un-waived finding matches a listed severity (critical, high, medium, low, info).
forbidden_licensesstring[]Fails if any declared dependency uses a prohibited SPDX license identifier (e.g. GPL-3.0-only, AGPL-3.0-only).
max_circular_dependenciesusizeCaps the maximum allowable Tarjan SCC circular dependency cycles in the architecture graph (set to 0 for strict DAG enforcement).
max_blast_radius_modulesusizeCaps the maximum number of directly + transitively affected modules in the current Git working-tree diff.
max_modified_lines_without_testsusizeCaps how many modified source lines can be introduced in a diff without accompanying test file modifications.
required_rule_packsstring[]Verifies that the repository's rules.extends configuration includes all mandated rule packs.

4. Time-Bounded Exception Waivers

Each PolicyWaiver supports:

  • • rule_id: Exact rule ID or "*" wildcard.
  • • path_pattern: Optional glob (*, **, prefix/**, **/suffix).
  • • expires_at: RFC 3339 UTC timestamp (2027-01-01T00:00:00Z) or date (2027-01-01). Invalid or past dates are automatically treated as expired!
  • • justification: Mandatory audit trail explanation.

5. Gate Verdict & Exit Codes

Exit 0 • Passed All policy constraints satisfied
Exit 1 • Warning Policy warnings met --fail-on threshold
Exit 2 • Config Error Missing or malformed policy YAML/JSON
Exit 4 • Violation SecurityPolicyFailure: constraint breached