ALEF-PAT-004

verifier-source-mismatch

observe × drift · severity 7 · confidence 0.77 · ref: auditor_must_not_match_own_source (ALEF)

verifier reads from stale local state while the canonical write went to a different source — produces contradictory "success then failure" tails about the same action

diagnosed in the wild

·

loading…

healed by ALEF

·

loading…

cited in posts

·

loading…

observable signature

{
  "log_regex": "\\b(MERGED|SUCCESS|OK)\\s*[\":]\\s*[\\s\\S]{0,200}\\b(ORPHAN|FAIL|ERROR)\\b",
  "context_exclusions": [
    {
      "name": "typescript_union_type_alias",
      "match": "(?:type|interface)\\s+\\w+\\s*=\\s*[^;]{0,500}\\|",
      "rationale": "TypeScript discriminated unions like `type Result = \"OK\" | \"FAIL\"` are STATIC TYPE LABELS, not runtime verifier-source events. Lines containing `|` between the SUCCESS-half and FAIL-half tokens AND inside a `type`/`interface` block are unions, not log streams."
    },
    {
      "name": "enum_or_const_array",
      "match": "(?:enum|as\\s+const|const\\s+\\w+\\s*=\\s*\\[)",
      "rationale": "Enum values and as-const arrays enumerate the status SPACE, not specific events. PAT-004 fires on RUNTIME contradiction (one event says SUCCESS, a later event says FAIL on the same action), not on the existence of the enum."
    },
    {
      "name": "ternary_return_type",
      "match": "[?:]\\s*[\"'](OK|SUCCESS|MERGED)[\"']\\s*:\\s*[\"'](FAIL|ERROR|ORPHAN)[\"']",
      "rationale": "Ternary expressions like `ok ? \"OK\" : \"FAIL\"` are RETURN-TYPE-WRITERS, the canonical writer itself, not the contradicted reader. PAT-004 requires TWO independent readers disagreeing."
    },
    {
      "name": "single_reader_if_else_branch",
      "match": "(?:if\\s*\\([^)]*(?:includes|equals|match|test|startsWith|endsWith|===|==)[^)]*[\"'](?:OK|SUCCESS|MERGED|PASS)[\"'][^)]*\\)|console\\.(?:log|info)\\s*\\([^)]*[\"']\\s*PASS)",
      "rationale": "Smoke-test if/else patterns like `if (output.includes(\"OK\")) { ...PASS... } else { ...FAIL... }` are ONE reader making ONE branched decision on a string. PAT-004 requires TWO INDEPENDENT READERS contradicting each other on the same fact (e.g. an upstream verifier saying MERGED while a downstream verifier later says FAIL on the same action). A single if/else does not fit the pattern."
    }
  ]
}

verified instances (2) — from the catalog

fix archetypes

  • re-query-at-verify-timecost: small

    late-tail verifier MUST re-query ground truth; do not trust intermediate flags

  • single-canonical-status-linecost: tiny

    emit one final canonical status at exit; downstream reads only that

cite as

# In a PR description / issue / RFC:
fixes pattern ALEF-PAT-004 (verifier-source-mismatch)
ref: https://n50.io/patterns/004

# Machine query:
GET https://n50.io/api/patterns/004

# Scan your repo for this pattern:
npx @alef-prime/audit-agent-system . --pattern=004