/mycelialize-enforced

Evolution P0 ABSOLUTE Production medium usage

/mycelialize-enforced

Overview

/mycelialize-enforced is a production command in the Evolution category of the Prismatic Platform that executes mycelial pattern propagation operations with mandatory Quality Debt Point (QDP) reduction enforcement. While the standard /mycelialize command propagates patterns across the codebase using biologically-inspired network algorithms, the enforced variant adds a non-bypassable requirement that every mycelial operation must simultaneously reduce the platform's quality debt. This coupling of pattern propagation with quality improvement ensures that the platform's codebase becomes healthier with every evolution cycle.

This command operates under the P0 ABSOLUTE authority level and is executed by the mycelial-network-coordinator agent. It is part of the platform's 216-command slash command registry, built on the AIAD (Autonomous Intelligence Agent Design) standard. The P0 ABSOLUTE authority level is the highest enforcement priority in the platform, meaning that QDP reduction requirements cannot be overridden, bypassed, or deferred under any circumstances.

The mycelial metaphor comes from the biological mycelium networks that connect plants in forests, enabling nutrient transfer and communication across vast distances. In the Prismatic Platform, mycelial operations propagate proven patterns -- code structures, architectural decisions, quality improvements -- from one part of the codebase to all other applicable locations. When a pattern is proven effective in one umbrella application, mycelial propagation identifies all locations across the 90+ umbrella apps where that pattern could be applied and executes the transformation.

The enforced variant adds QDP reduction as a hard constraint. Before any pattern propagation begins, the system must identify and eliminate a minimum number of quality debt points. After propagation completes, the system verifies that the net quality debt has decreased. If quality debt increases for any reason during propagation (for example, if a propagated pattern introduces new warnings), the entire operation is rolled back. This enforcement loop ensures that the platform's quality trajectory is monotonically improving.

Architecture

The enforced mycelial system operates as a dual-objective optimization engine that simultaneously propagates patterns and eliminates quality debt.

Enforcement Architecture

/mycelialize-enforced -> QDP Scanner -> Pattern Propagator -> Quality Verifier
                              |                |                     |
                              v                v                     v
                        Debt Catalog     Mycelial Network      Pre/Post Check
                        Debt Priority    Pattern Matching      Compilation
                        Debt Eliminator  Transformation        Credo Check
                        Quota Tracker    Propagation Engine    Warning Count
                                                               Rollback Guard

QDP Enforcement Model

PhaseActionEnforcementRollback
Pre-ScanIdentify current QDP countCount must be > 0 or no debt remainsN/A
QDP EliminationFix identified quality debtMinimum quota must be metPartial work reverted
Pattern PropagationPropagate patterns across appsQuality must not decreaseFull propagation reverted
Post-VerificationVerify net quality improvementQDP count must decreaseEntire operation reverted

Quality Debt Categories

CategoryPriorityExamplesDetection Method
Compilation WarningsP0Unused variables, deprecated callsmix compile --warnings-as-errors
Credo ViolationsP1Style violations, complexitymix credo --strict
Missing TypespecsP2Public functions without @specCustom Credo check
Unsafe PatternsP0Unsafe atom creation, nil accessCustom regression checks
Dead CodeP2Unused functions, unreachable clausesDialyzer + custom analysis
TODO/FIXMEP3Deferred work markersPattern matching scan
Missing TestsP1Untested public functionsCoverage analysis
Missing DocsP2Undocumented public functions@doc false audit

Mycelial Network Topology

LayerFunctionSpeedCoverage
Spore LayerPattern discovery and classification< 1 secondSingle module
Hypha LayerPattern matching across applications1-5 secondsSingle umbrella app
Mycelium LayerCross-application pattern propagation5-30 secondsAll umbrella apps
Fruiting LayerEmergence detection and reporting1-5 secondsPlatform-wide

Usage

# Run enforced mycelial propagation with default quota
/mycelialize-enforced

# Run with specific QDP quota
/mycelialize-enforced --qdp-quota=10

# Run targeting specific quality category
/mycelialize-enforced --qdp-category=compilation-warnings

# Run targeting specific application
/mycelialize-enforced --app=prismatic_web

# Run targeting all applications
/mycelialize-enforced --app=all --qdp-quota=5

# Dry run to preview changes
/mycelialize-enforced --dry-run

# Run with specific pattern focus
/mycelialize-enforced --pattern="type-safety" --qdp-quota=5

# Run with cascade detection
/mycelialize-enforced --detect-cascades --cascade-threshold=3

# Run with verbose output
/mycelialize-enforced --verbose

# Export propagation report
/mycelialize-enforced --report --output=mycelial-report.md

# Run in CI mode (exit code reflects success/failure)
/mycelialize-enforced --ci --qdp-quota=3

# Run with maximum parallelism
/mycelialize-enforced --parallel=auto

# View propagation history
/mycelialize-enforced --history --period=7d

# View current QDP inventory
/mycelialize-enforced --inventory

Options

OptionTypeDefaultDescription
--qdp-quotainteger3Minimum QDP reduction per execution
--qdp-categorystringautoQDP category focus: compilation-warnings, credo, typespecs, unsafe-patterns, dead-code, todo, tests, docs
--appstringautoTarget application or "all"
--patternstringautoPattern to propagate: type-safety, error-handling, supervision, testing, documentation
--dry-runflagfalsePreview changes without executing
--detect-cascadesflagtrueDetect cascade improvement patterns
--cascade-thresholdinteger3Minimum instances for cascade classification
--verboseflagfalseDetailed output including per-file changes
--reportflagfalseGenerate propagation report
--outputstringstdoutReport output path
--ciflagfalseCI mode with exit codes
--parallelinteger4Parallel processing threads
--historyflagfalseView propagation history
--periodstring30dHistory period
--inventoryflagfalseShow current QDP inventory
--rollbackflagfalseRollback last propagation
--force-categorystringnoneForce specific QDP category elimination
--max-filesinteger50Maximum files modified per execution

Execution Flow

  1. Quality Baseline Capture: The current quality state is captured as a baseline. This includes compilation warning count, Credo violation count, typespec coverage, test coverage, and all other quality domain metrics. The baseline serves as the reference for post-execution verification.

  2. QDP Inventory Analysis: The system scans the codebase to identify current quality debt points. QDP items are categorized, prioritized, and ranked by estimated fix difficulty and cross-application applicability.

  3. QDP Selection: Based on the configured quota and category focus, the system selects specific QDP items to eliminate. Selection prioritizes items that are (a) quick to fix, (b) applicable across multiple applications (cascade potential), and (c) in the highest priority categories.

  4. QDP Elimination: Selected QDP items are eliminated through automated code transformations. Compilation warnings are fixed by removing unused variables, updating deprecated function calls, and adding missing clauses. Credo violations are fixed by applying style corrections. Missing typespecs are added using inferred types from Dialyzer.

  5. Elimination Verification: After QDP elimination, the affected code is compiled and checked to verify that fixes are correct and do not introduce new issues. If any fix introduces a new warning or error, it is reverted individually.

  6. Pattern Discovery: The mycelial network scans the codebase for pattern propagation opportunities. Patterns successfully applied in one application are matched against all other applications for potential propagation.

  7. Pattern Propagation: Identified patterns are propagated to matching locations across the codebase. Each propagation is a discrete, reversible transformation. Propagations are applied in dependency order to prevent intermediate compilation failures.

  8. Cascade Detection: If --detect-cascades is enabled, the system identifies patterns that were propagated to three or more applications. These cascade patterns represent systematic improvements that have wide applicability and are recorded in the pattern library for future reference.

  9. Post-Verification: After all changes are complete, the full quality baseline is recaptured. The post-execution quality metrics are compared against the pre-execution baseline. If net QDP count has not decreased by at least the configured quota, the entire operation is rolled back.

  10. Report Generation: A propagation report is generated documenting all changes made, QDP items eliminated, patterns propagated, cascades detected, and net quality improvement achieved.

Integration Points

ComponentRelationshipDetails
Prismatic AgentsExecuted by mycelial-network-coordinatorOrchestrates propagation and enforcement
/mycelializeStandard variantNon-enforced pattern propagation
/mycelialize-formalFormal variantLean4-verified propagation
/evolveEvolution systemBroader ecosystem evolution
/quality-gatesQuality verificationPre/post quality gate checking
/quality-enforceQDP trackingQuality debt inventory
/regression-checkRegression preventionEnsures no regressions from propagation
Quality GatesGate enforcementQuality criteria validation
TelemetryExecution metricsPropagation speed, QDP elimination rate
SEADFEvolution frameworkMycelial system within SEADF ecosystem

Best Practices

Run enforced mycelialize at least once per session. The platform's mandatory session discipline requires continuous quality improvement. Running /mycelialize-enforced at least once per session ensures that quality debt never accumulates across sessions.

Start with small QDP quotas. A quota of 3-5 QDP per execution is manageable and sustainable. Large quotas risk introducing too many changes at once, making rollback more disruptive if post-verification fails.

Use dry-run before production execution. The --dry-run flag shows exactly what changes would be made without executing them. Review the dry-run output to verify that proposed changes are appropriate before committing.

Focus on cascade patterns. Patterns that propagate to 3+ applications (cascades) represent the highest-value improvements. Use --detect-cascades to identify these patterns and prioritize them for propagation.

Monitor the QDP inventory trend. Use --inventory to track the remaining QDP count over time. The trend should be monotonically decreasing. Any increase indicates that new quality debt is being introduced faster than it is being eliminated.

Commit after each successful execution. Each successful mycelialize-enforced run represents a verified quality improvement. Commit immediately to lock in the improvement and prevent drift.

Error Handling

ErrorCauseResolution
qdp_quota_not_metCould not eliminate enough QDP itemsIncrease target scope or reduce quota
quality_regressionPost-execution quality lower than baselineAutomatic rollback, investigate cause
compilation_failedPropagated pattern caused compilation errorAutomatic rollback of affected propagation
credo_regressionNew Credo violations introducedAutomatic rollback, adjust transformation
no_patterns_foundNo propagation opportunities identifiedNormal -- all patterns already propagated
rollback_failedCould not restore pre-execution stateManual intervention required, check git status
max_files_exceededChanges would affect too many filesReduce scope or increase --max-files
zero_qdp_remainingNo quality debt to eliminateSuccess -- platform at zero debt

Advanced Usage

Targeted Cascade Elimination

Focus on eliminating specific pattern categories across the entire codebase.

# Eliminate all unsafe map access patterns
/mycelialize-enforced --pattern="safe-map-access" --app=all --qdp-category=unsafe-patterns

# Eliminate all missing @impl annotations
/mycelialize-enforced --pattern="impl-coverage" --app=all --qdp-category=typespecs

# Propagate error handling patterns
/mycelialize-enforced --pattern="error-handling" --app=all --cascade-threshold=5

CI/CD Integration

Integrate enforced mycelial operations into the build pipeline.

# CI gate: require QDP reduction before merge
/mycelialize-enforced --ci --qdp-quota=1 --app=changed-apps

# Pre-commit quality improvement
/mycelialize-enforced --ci --qdp-quota=3 --max-files=10 --app=auto

Historical Analysis

Analyze mycelial propagation effectiveness over time.

# View propagation history
/mycelialize-enforced --history --period=30d --format=json

# View cascade detection history
/mycelialize-enforced --history --cascades-only --period=90d

# QDP elimination rate over time
/mycelialize-enforced --history --metric=qdp-rate --period=90d

Custom Pattern Definition

Define custom patterns for organization-specific propagation.

# Register custom pattern
/mycelialize-enforced --register-pattern --name="custom-telemetry" \
  --source-app=prismatic_telemetry --source-module=TelemetryEmitter \
  --pattern-type=structural

# Propagate custom pattern
/mycelialize-enforced --pattern="custom-telemetry" --app=all --qdp-quota=3

Doctrine Compliance

All commands operate under the NO MERCY, NO DOUBTS doctrine:

  • NO MERCY: Zero tolerance for incomplete execution or quality violations. The enforced variant is the doctrine made operational -- quality debt must decrease with every execution. No bypass, no exceptions, no deferrals. If quality regresses, the entire operation is rolled back.
  • NO DOUBTS: Full investigation before action, evidence-based results. Every QDP elimination is verified through compilation and static analysis. Every pattern propagation is validated through quality gates. Results include complete before/after metrics.

Connect & Contribute

Created by Tomáš Korcak (korczis) | Open Source under GHL