NO MERCY

DOCTRINE

NO MERCY

Overview

NO MERCY is the enforcement arm of the Prismatic Platform doctrine. It establishes absolute, non-negotiable quality standards that apply to every line of code, every agent operation, and every platform decision across the entire 2.8 million line codebase. Where NO DOUBTS governs the epistemology of decision-making, NO MERCY governs the execution standard: complete delivery or no delivery.

The doctrine emerged from a pragmatic observation: technical debt compounds faster than financial debt. A single TODO comment becomes ten. A stub function becomes a pattern. An untested module becomes an untestable subsystem. NO MERCY prevents the first crack from forming by enforcing absolute quality standards at every checkpoint in the development lifecycle, from the first keystroke to production deployment.

NO MERCY is not aspirational. It is enforced through automated pre-commit hooks, CI pipeline gates, Quality Gates, and agent operational constraints. The platform's current quality score of 100/100 across all 13 quality domains with zero warnings, zero debt, and zero violations is the direct result of NO MERCY enforcement applied consistently across 99 umbrella applications.

Core Principles

The NO MERCY doctrine comprises four foundational principles, each addressing a specific category of quality failure that plagues conventional software development.

Principle 1: Zero Incomplete Implementations

Every feature, fix, or change must be 100% complete before delivery. The platform does not accept "Phase 1" implementations that defer critical functionality, feature flags hiding incomplete code, or partial migrations that leave the codebase in a mixed state.

Forbidden PracticeRequired Practice
Partial implementations shipped as "v1"Full feature completion before merge
"Phase 1" with documented missing partsComplete MVP or defer entirely
"Will fix later" annotationsFix now or do not ship
Feature flags hiding incomplete codeWorking code only in production
Dead code from abandoned approachesClean removal of superseded code
Commented-out code "for reference"Version control provides history

The enforcement mechanism validates completeness at the pre-commit level:

defmodule PrismaticSafety.CompletenessValidator do
  @moduledoc """
  Validates that all code changes are complete before allowing commit.
  Enforces NO MERCY Principle 1: Zero Incomplete Implementations.
  """

  @forbidden_patterns [
    ~r/# TODO:/i,
    ~r/# FIXME:/i,
    ~r/# HACK:/i,
    ~r/# XXX:/i,
    ~r/:not_implemented/,
    ~r/raise "Not implemented"/,
    ~r/raise "TODO"/,
    ~r/fn _ -> :stub end/
  ]

  @spec validate_changeset(changeset :: list(String.t())) ::
    :ok | {:error, :incomplete, list(String.t())}
  def validate_changeset(changed_files) do
    violations =
      changed_files
      |> Enum.flat_map(&scan_file_for_violations/1)
      |> Enum.reject(&false_positive?/1)

    case violations do
      [] -> :ok
      found -> {:error, :incomplete, found}
    end
  end

  defp scan_file_for_violations(file_path) do
    file_path
    |> File.read!()
    |> String.split("\n")
    |> Enum.with_index(1)
    |> Enum.flat_map(fn {line, line_num} ->
      @forbidden_patterns
      |> Enum.filter(&Regex.match?(&1, line))
      |> Enum.map(fn pattern ->
        "#{file_path}:#{line_num} - Forbidden pattern: #{inspect(pattern)}"
      end)
    end)
  end

  defp false_positive?(violation) do
    # Test files may reference TODO patterns in assertions
    String.contains?(violation, "_test.exs")
  end
end

Principle 2: Zero Stubs, Mocks, and Placeholders

Production code contains only production-ready implementations. This extends beyond obvious TODO comments to include any code that exists as a placeholder for future work.

Violation TypeDetectionStatus
# TODO: implement laterRegex scan in pre-commitBLOCKED
# FIXME: known bugRegex scan in pre-commitBLOCKED
def placeholder_function, do: :not_implementedAST analysisBLOCKED
raise "Not implemented"AST analysisBLOCKED
Mock objects in production codeModule analysisBLOCKED
Empty function bodies (no-ops)AST analysisWARNING
Stub modules with minimal implementationCoverage analysisBLOCKED

The automated detection system scans every commit for prohibited patterns:

# Automated scanning integrated into pre-commit hooks
# Scans all staged Elixir files for forbidden patterns
# Exit code 1 if any matches found = commit blocked

# Pre-commit hook excerpt (.githooks/pre-commit)
# Phase: NO MERCY stub detection
mix compile --warnings-as-errors --force
mix credo --strict

Principle 3: Comprehensive Test Coverage

Every line of code must have corresponding test coverage. The platform enforces multiple levels of test coverage to ensure that code is not merely executed during tests but meaningfully verified.

Coverage TypeTargetEnforcement Level
Line coverage100%HARD - commit blocked
Branch coverage100%HARD - commit blocked
Function coverage100%HARD - commit blocked
Regression tests per bug fixMandatoryHARD - commit blocked
Property-based tests for business logicRequiredHARD - PR blocked
Integration tests for cross-module flowsRequiredHARD - PR blocked

Every public function requires a minimum set of test scenarios:

defmodule Prismatic.Perimeter.SecurityRatingTest do
  use ExUnit.Case, async: true
  use ExUnit.Parameterized

  alias Prismatic.Perimeter.SecurityRating

  # 1. Happy path test - core functionality works
  describe "calculate/1 with valid input" do
    test "calculates security rating for domain with full data" do
      evidence = build_evidence("example.com", findings: 3, critical: 0)
      assert {:ok, rating} = SecurityRating.calculate(evidence)
      assert rating.grade in [:A, :B, :C, :D, :F]
      assert rating.score >= 300 and rating.score <= 900
    end
  end

  # 2. Error case tests - failures handled gracefully
  describe "calculate/1 with invalid input" do
    test "rejects nil evidence" do
      assert {:error, :invalid_evidence} = SecurityRating.calculate(nil)
    end

    test "rejects evidence without required fields" do
      assert {:error, :missing_fields} = SecurityRating.calculate(%{})
    end

    test "rejects negative finding counts" do
      evidence = build_evidence("test.com", findings: -1)
      assert {:error, :invalid_findings} = SecurityRating.calculate(evidence)
    end
  end

  # 3. Edge case tests - boundary conditions
  describe "calculate/1 edge cases" do
    test "handles domain with zero findings (perfect score)" do
      evidence = build_evidence("clean.com", findings: 0, critical: 0)
      assert {:ok, %{grade: :A}} = SecurityRating.calculate(evidence)
    end

    test "handles domain with maximum findings" do
      evidence = build_evidence("bad.com", findings: 10_000, critical: 500)
      assert {:ok, %{grade: :F}} = SecurityRating.calculate(evidence)
    end
  end

  # 4. Property-based test - invariants hold across all inputs
  describe "calculate/1 properties" do
    property "score always within valid range" do
      check all findings <- StreamData.integer(0..1000),
                critical <- StreamData.integer(0..findings) do
        evidence = build_evidence("prop.com", findings: findings, critical: critical)
        {:ok, rating} = SecurityRating.calculate(evidence)
        assert rating.score >= 300 and rating.score <= 900
      end
    end

    property "more critical findings never improve grade" do
      check all base_critical <- StreamData.integer(0..50),
                additional <- StreamData.integer(1..50) do
        base = build_evidence("prop.com", findings: 100, critical: base_critical)
        worse = build_evidence("prop.com", findings: 100, critical: base_critical + additional)

        {:ok, base_rating} = SecurityRating.calculate(base)
        {:ok, worse_rating} = SecurityRating.calculate(worse)

        assert worse_rating.score <= base_rating.score
      end
    end
  end

  defp build_evidence(domain, opts) do
    %{
      domain: domain,
      findings: Keyword.get(opts, :findings, 0),
      critical: Keyword.get(opts, :critical, 0),
      timestamp: DateTime.utc_now()
    }
  end
end

Principle 4: Zero Warnings in Production

The codebase compiles and runs with zero warnings across all analysis tools. Warnings are treated as errors at every level, from the Elixir compiler to Dialyzer static analysis to Credo code quality checks.

Warning SourceEnforcement ModeCurrent Status
Compiler warnings--warnings-as-errors flag0 violations
Dialyzer type warningsZero tolerance, PLT cached0 violations
Credo issues--strict mode0 violations
Runtime warningsLogged, investigated, fixed0 violations
Deprecation warningsImmediate migration required0 violations
Unused variable warningsCompilation blocked0 violations
Missing @spec annotationsCredo check enforced0 violations
Missing @impl annotationsCustom check (709 verified)0 violations
# Required verification for every commit
mix compile --warnings-as-errors --force   # Zero compiler warnings
mix dialyzer --format dialyxir             # Zero type analysis warnings
mix credo --strict                         # Zero code quality issues
mix test --cover                           # All tests passing with coverage

Violation Protocol

The NO MERCY violation protocol defines escalation levels and mandatory responses for quality standard breaches. The protocol is automated wherever possible and enforced by both technical gates and organizational policy.

Severity Levels

LevelDescriptionExampleResponseAutomation
L1Minor deviationStyle inconsistency, naming conventionWarning + immediate correctionPre-commit auto-format
L2Quality violationMissing test, uncovered branchBlock + required correctionCI pipeline gate
L3Incomplete deliveryPartial feature, TODO in codeRejection + restart requiredMerge gate rejection
L4Repeated violationsPattern of quality lapsesEscalation + supreme reviewAudit trail trigger

Enforcement Pipeline

The enforcement pipeline ensures that NO MERCY violations are caught at the earliest possible stage, minimizing the cost of correction:

Code Change --> Pre-commit Hooks --> Quality Gates --> CI Pipeline --> Merge Gate --> Production
     |                |                   |                |               |             |
  Authored       Format check         Full compile     All tests      Code review    Monitoring
  locally        Credo strict         Dialyzer         Coverage       Quality score  Alerts
                 Quick tests          TODO scan        Security       Approval       Self-heal
                 TODO scan            Pattern check    Benchmarks     Final gate     Guardian

Each stage is a hard gate: failure at any stage blocks progression to the next. There are no override mechanisms, no bypass flags, and no exceptions for urgency or deadline pressure.

Quality Score Framework

The platform maintains a comprehensive quality score that aggregates all NO MERCY enforcement dimensions into a single metric:

DomainWeightCurrent ScoreEnforcement
Compilation (zero warnings)10%100%--warnings-as-errors
Dialyzer (zero type errors)10%100%PLT analysis
Credo (zero issues)10%100%--strict mode
Test coverage (line + branch)15%100%ExCoveralls
Regression test compliance10%100%Mandatory protocol
@impl annotation coverage5%100%709 verified
@spec type annotation coverage10%100%Custom check
TODO/FIXME absence5%100%Regex scanner
Memory safety5%100%Pattern analysis
Performance compliance5%100%Benchee gates
DateTime precision5%100%Pattern check
Guard function usage5%100%AST analysis
Unsafe map access absence5%100%Pattern detection

Current Platform Quality Score: 100/100 (PERFECT) across all 13 domains.

CASCADE Pattern Elimination

NO MERCY includes a systematic approach to eliminating recurring anti-patterns through the CASCADE (Comprehensive Automated Scan and Correction of Anti-pattern Deficiency Elimination) system. Five core CASCADE patterns have been identified and eliminated platform-wide:

CASCADE PatternDescriptionInstances Eliminated
Type MismatchIncorrect type annotations in @spec127
Dead CodeUnreachable code paths and unused functions203
Empty CheckMissing empty collection guards89
Timer ReplacementUnsafe Process.sleep usage34
Nuclear CacheStale compilation artifacts causing false errors452

The Nuclear Cache fix remains a critical maintenance tool:

# Nuclear Cache resolution - eliminates stale BEAM artifacts
rm -rf _build/dev/lib/prismatic_claude/ebin && rm -rf priv/plts/dialyzer.plt
mix compile --warnings-as-errors --force

Platform Integration

NO MERCY integrates with every enforcement layer of the Prismatic Platform to create a defense-in-depth quality assurance system:

Metrics and Results

The NO MERCY doctrine has produced measurable, auditable results across the platform:

MetricBefore NO MERCYAfter NO MERCYImprovement
Quality scoreVariable (60-85)100/100 constantPerfect score
QDP (Quality Debt Points)905 accumulated0 (complete elimination)100% reduction
Compiler warnings50-100 per build0 per build100% elimination
Dialyzer violations30+ per analysis0 per analysis100% elimination
Credo issues200+ per scan0 per scan100% elimination
Production incidents~8 per month< 1 per month88% reduction
Post-deploy rollbacks~3 per month0 per month100% elimination
Developer confidenceSurvey: 6.2/10Survey: 9.4/1052% improvement

Commands

CommandPurposeAuthority
/quality-gatesRun all NO MERCY quality checksUniversal
/quality-enforceSystematic enforcement across codebaseSystem
/cascadeExecute CASCADE pattern eliminationSystem
mix quality.gatesFull quality gate pipelineCI/CD
mix compile --warnings-as-errorsZero-warning compilationPre-commit
mix credo --strictZero-issue code qualityPre-commit

Connect & Contribute

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