Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

13. pmat Compliance & Quality Gates

13.1 Scope: Where Quality Applies

Albor is a project repo (configs, scripts, contracts, docs). It produces no Rust library code. All quality gates apply to upstream Rust changes made in service of Albor’s gaps — not to albor’s shell scripts or YAML configs.

# Run on all modified stack components (NOT on albor itself)
pmat comply check --strict ../aprender      # ALB-001, 006, 009, 011
pmat comply check --strict ../entrenar      # ALB-003, 004
pmat comply check --strict ../trueno        # ALB-005
pmat comply check --strict ../realizar      # ALB-010
pmat comply check --strict ../alimentar     # ALB-007, 018, 019, 020
pmat comply check --strict ../repartir      # ALB-002, 008

13.2 Quality Gate Thresholds (Upstream Rust Code)

GateThresholdApplies ToEnforcement
TDG GradeA (score ≤ 1.0)Upstream Rustpmat analyze tdg --include-components
Test Coverage≥ 95% line coverageUpstream Rustcargo llvm-cov --summary-only
Mutation Score≥ 85%Upstream Rustcargo mutants --no-times
Cyclomatic Complexity≤ 15 per functionUpstream Rustpmat analyze complexity
File Length≤ 500 linesAll Rust files (upstream)find . -name '*.rs' | xargs wc -l
SATDZero (no TODO/FIXME/HACK)Upstream Rustpmat analyze satd
Unwrap CallsZero in new codeUpstream Rustpmat query --literal "unwrap()" --faults
ClippyZero warningsUpstream Rustcargo clippy -- -D warnings

13.3 Quality Gate Thresholds (Albor Repo)

GateThresholdApplies ToEnforcement
File Length≤ 500 linesScripts, YAML, contracts (not specs/docs)wc -l on non-doc tracked files
FALSIFY-ALBOR testsAll 9 passPipeline end-to-endbatuta falsify .
Contract completenessAll 5 new contracts at Level 3+contracts/pv status contracts/
Config validityAll YAML parses and plan passesconfigs/apr pipeline plan (validates all configs in one DAG pass)
ReproducibilitySame seed → same checkpoint hashFull pipelineFALSIFY-ALBOR-003

13.3 pmat Quality Commands for Albor

# TDG analysis of all Albor-touched code
pmat analyze tdg ../aprender --include-components
pmat analyze tdg ../entrenar --include-components

# Find coverage gaps (highest ROI targets)
pmat query --coverage-gaps --limit 30 --exclude-tests

# Fault pattern audit (unwrap, panic, unsafe)
pmat query "training" --faults --exclude-tests

# Full quality audit on distillation code
pmat query "distill" --churn --duplicates --entropy --faults -G

# Complexity check on new kernels
pmat query "knowledge_distillation" --max-complexity 15 --include-source

# Create quality baseline before Albor work begins
pmat tdg baseline create

# Check for regressions after each phase
pmat tdg check-regression --baseline

13.5 Certeza Three-Tier Testing (Upstream Repos)

When modifying upstream Rust code for gap fixes, follow certeza tiers:

Tier 1: On-Save (sub-second)

cargo check && cargo test --lib -- --quiet    # Type check + unit tests

Tier 2: On-Commit (1-5 minutes)

cargo test                                     # Full test suite
cargo llvm-cov --summary-only                  # Coverage ≥ 95%
pmat analyze tdg                               # TDG regression check
pv audit contracts/ --binding                  # Contract compliance

Tier 3: On-Merge / Nightly (hours)

cargo mutants --no-times                       # Mutation score ≥ 85%
cargo kani                                     # Formal verification
batuta falsify . --min-grade toyota-standard   # 108-item checklist
pmat rust-project-score --full                 # Comprehensive quality score

13.6 Albor Pipeline Commands

Since albor is a project repo, its primary interface is apr pipeline. No Makefiles, no shell scripts. One manifest, one DAG.

# ── Pipeline (the only entry point you need) ──
apr pipeline plan configs/pipeline/albor.yaml     # Full DAG dry-run (no GPU, no writes)
apr pipeline apply configs/pipeline/albor.yaml    # Execute everything (resumable)
apr pipeline status                               # What's converged / pending / failed
apr pipeline drift                                # Detect unauthorized state changes

# ── Targeted execution (run one step + its dependencies) ──
apr pipeline apply configs/pipeline/albor.yaml --target train-350m
apr pipeline apply configs/pipeline/albor.yaml --target eval-code
apr pipeline apply configs/pipeline/albor.yaml --target publish

# ── Force re-run (ignore converged state) ──
apr pipeline apply configs/pipeline/albor.yaml --target distill --force

# ── Individual subcommands (for development / debugging) ──
apr train plan configs/train/pretrain-350m.yaml   # Plan one step standalone
apr train apply configs/train/pretrain-350m.yaml --seed 42
apr monitor ./checkpoints/albor-base-350m/        # Live TUI
apr experiment view --db .entrenar/experiments.db  # Browse experiments

# ── Quality (upstream repos — run independently of pipeline) ──
pmat tdg baseline create                          # TDG baseline across all components
pmat comply check --strict ../aprender
pmat comply check --strict ../entrenar
pv validate contracts/*.yaml                      # Contract schema validation
pv status contracts/                              # Contract completeness
batuta falsify . --min-grade toyota-standard      # 108-item falsification checklist
# Current score: 100.0% (108/108 PASS) — achieved 2026-03-04