Task — engineering-spec@1

"Structured gate-failure taxonomy"

doneTASK-IMP-011
module improvement · class product · priority p0 · created 2026-07-08 · shipped null
depends on none · blocks none

TASK-IMP-011: Structured gate-failure taxonomy

Summary

When the machine-gate floor goes RED, operators and automation today only see human prose (FAIL test, GATES: RED). This task makes every gate failure emit a structured class and a durable JSON summary so regressions can be mined without scraping logs.

Problem

run-gates.sh prints PASS/FAIL/SKIP lines but does not classify failures. Downstream tooling (auto-revert, dashboards, triage) cannot tell a lint miss from a coverage regression or an empty floor without brittle string matching.

Proposed Solution

Extend tools/install/gates/run-gates.sh so each configured gate step maps to a fixed taxonomy class. On any RED outcome, write .cyberos/last-gate-failure.json (schema gate-failure@1) listing every failed gate with class, command, and source, and emit one GATE_FAILURE_JSON:{...} line on stdout for log miners. Green runs MUST remove a stale failure file so "last failure" always means the most recent RED.

Alternatives Considered

Success Metrics

Scope

In scope: run-gates.sh taxonomy + failure artifact; install suite tests; CHANGELOG.

Out of scope / Non-Goals

Dependencies

None. Soft: TASK-IMP-026 may read the failure artifact; not required to ship 011.

AI Authorship Disclosure

§1 - Description (normative)

  1. Every gate step run-gates.sh executes (build, lint, test, coverage, caf, awh, doctor) MUST map to exactly one failure class from the closed set: build | lint | test | coverage | doctor | caf | awh | empty-floor | other.
  2. When any configured gate command exits non-zero, the runner MUST record that failure (class, gate name, command, provenance source) and continue remaining gates (today's behavior), then exit 1.
  3. On exit 1 (one or more gate failures) OR exit 3 (empty floor), the runner MUST write $root/.cyberos/last-gate-failure.json with schema gate-failure@1 containing at least: schema, exit_code, failures (array of {class,gate,cmd,source}), and for empty-floor a single failure with class: empty-floor.
  4. On those RED exits the runner MUST also print exactly one stdout line matching GATE_FAILURE_JSON: followed by the same JSON object (compact, single line).
  5. On exit 0 (GREEN or EMPTY-ACKNOWLEDGED) the runner MUST delete .cyberos/last-gate-failure.json if present.
  6. Exit codes MUST remain: 0 green/ack, 1 gate failed, 2 missing/malformed config, 3 empty floor.
  7. The taxonomy MUST be covered by tools/install/tests/test_gate_failure_taxonomy.sh with scenarios that force a failure and assert class + artifact presence.

Acceptance criteria

Test plan

bash tools/install/tests/test_gate_failure_taxonomy.sh via scripts/tests/run_all.sh glob.

Audit

TASK-IMP-011 audit

Spec authored for CyberOS 1.x payload gates. Closed failure-class set maps to real run-gates.sh steps plus empty-floor. ACs falsifiable via test_gate_failure_taxonomy.sh. Exit-code contract preserved (0/1/2/3). Out of scope correctly excludes platform llvm-cov/caf taxonomies.

SUMMARY verdict: pass issues_open: 0 next_action: none