/** AUTO-GENERATED by scripts/gen-error-catalog.ts — DO NOT EDIT. */
export type ErrorStratum = 'mechanical-first' | 'playbook' | 'semantic-procedure';
export type ErrorCatalogSource =
  | 'v8-syntax'
  | 'v8-runtime'
  | 'typescript'
  | 'assertion'
  | 'harness';

export interface ErrorCatalogTemplate {
  id: string;
  pattern: string;
  stratum: ErrorStratum;
  classKey: string;
  source: ErrorCatalogSource;
  fixture: string;
}

export const ERROR_CATALOG: ErrorCatalogTemplate[] = [
  {
    "id": "harness-unresolved-import",
    "pattern": "^unresolved import (.+?) \\(from (.+?)\\)$",
    "stratum": "mechanical-first",
    "classKey": "unresolved-import|$1",
    "source": "harness",
    "fixture": "unresolved import ./addr (from src/calc)"
  },
  {
    "id": "harness-transpile",
    "pattern": "^transpile ([^:]+):",
    "stratum": "mechanical-first",
    "classKey": "transpile|$1",
    "source": "harness",
    "fixture": "transpile src/a.ts: Unexpected token"
  },
  {
    "id": "harness-dynamic-eval",
    "pattern": "^dynamic-eval:",
    "stratum": "playbook",
    "classKey": "dynamic-eval|$0",
    "source": "harness",
    "fixture": "dynamic-eval: eval( is forbidden in frozen tests/impls"
  },
  {
    "id": "harness-stub",
    "pattern": "stub: not implemented",
    "stratum": "playbook",
    "classKey": "runtime|stub-not-implemented",
    "source": "harness",
    "fixture": "stub: not implemented"
  },
  {
    "id": "harness-placeholder",
    "pattern": "PLACEHOLDER|__RHA_PLACEHOLDER__",
    "stratum": "mechanical-first",
    "classKey": "transpile|placeholder",
    "source": "harness",
    "fixture": "__RHA_PLACEHOLDER__ unresolved"
  },
  {
    "id": "harness-crash-loading",
    "pattern": "^crash while loading ",
    "stratum": "mechanical-first",
    "classKey": "crash|load|$0",
    "source": "harness",
    "fixture": "crash while loading src/a.ts:1"
  },
  {
    "id": "harness-crash-exec",
    "pattern": "^crash while executing ",
    "stratum": "mechanical-first",
    "classKey": "crash|exec|$0",
    "source": "harness",
    "fixture": "crash while executing case \"adds\""
  },
  {
    "id": "harness-empty-draw",
    "pattern": "unparseable at \"\\(empty\\)\"|unparseable:.*at \"\\(empty\\)\"|^\\(empty\\)$",
    "stratum": "mechanical-first",
    "classKey": "empty-draw",
    "source": "harness",
    "fixture": "dropped — unparseable: Unexpected end of input at \"(empty)\""
  },
  {
    "id": "harness-provider-desync",
    "pattern": "provider desync|desync:|model returned empty",
    "stratum": "mechanical-first",
    "classKey": "empty-draw",
    "source": "harness",
    "fixture": "model returned empty"
  },
  {
    "id": "harness-boundary-fault",
    "pattern": "boundary-fault|seam (?:fault|mismatch)",
    "stratum": "mechanical-first",
    "classKey": "boundary-fault|$0",
    "source": "harness",
    "fixture": "boundary-fault seam mismatch"
  },
  {
    "id": "harness-vitest-surface",
    "pattern": "_vitest\\.(?:it|test|describe)\\.call\\(\\.\\.\\.\\) is not a function|(?:it|test|describe)\\.(?:each|skip|todo|only) is not a function|_vitest\\.(?:it|test|describe)\\.(?:each|skip|todo|only)",
    "stratum": "mechanical-first",
    "classKey": "harness-vitest-surface",
    "source": "harness",
    "fixture": "_vitest.it.call(...) is not a function"
  },
  {
    "id": "assert-not-toBe",
    "pattern": "expect\\(\\.\\.\\.\\)\\.not\\.toBe\\b failed",
    "stratum": "semantic-procedure",
    "classKey": "assertion|not.toBe",
    "source": "assertion",
    "fixture": "expect(...).not.toBe failed — actual: 1, expected: 2"
  },
  {
    "id": "assert-not-toEqual",
    "pattern": "expect\\(\\.\\.\\.\\)\\.not\\.toEqual\\b failed",
    "stratum": "semantic-procedure",
    "classKey": "assertion|not.toEqual",
    "source": "assertion",
    "fixture": "expect(...).not.toEqual failed — actual: 1, expected: 2"
  },
  {
    "id": "assert-not-toStrictEqual",
    "pattern": "expect\\(\\.\\.\\.\\)\\.not\\.toStrictEqual\\b failed",
    "stratum": "semantic-procedure",
    "classKey": "assertion|not.toStrictEqual",
    "source": "assertion",
    "fixture": "expect(...).not.toStrictEqual failed — actual: 1, expected: 2"
  },
  {
    "id": "assert-not-toThrow",
    "pattern": "expect\\(\\.\\.\\.\\)\\.not\\.toThrow\\b failed",
    "stratum": "semantic-procedure",
    "classKey": "throw-mismatch|not.toThrow",
    "source": "assertion",
    "fixture": "expect(...).not.toThrow failed — actual: 1, expected: 2"
  },
  {
    "id": "assert-not-toThrowError",
    "pattern": "expect\\(\\.\\.\\.\\)\\.not\\.toThrowError\\b failed",
    "stratum": "semantic-procedure",
    "classKey": "throw-mismatch|not.toThrowError",
    "source": "assertion",
    "fixture": "expect(...).not.toThrowError failed — actual: 1, expected: 2"
  },
  {
    "id": "assert-not-toMatch",
    "pattern": "expect\\(\\.\\.\\.\\)\\.not\\.toMatch\\b failed",
    "stratum": "semantic-procedure",
    "classKey": "assertion|not.toMatch",
    "source": "assertion",
    "fixture": "expect(...).not.toMatch failed — actual: 1, expected: 2"
  },
  {
    "id": "assert-not-toMatchObject",
    "pattern": "expect\\(\\.\\.\\.\\)\\.not\\.toMatchObject\\b failed",
    "stratum": "semantic-procedure",
    "classKey": "assertion|not.toMatchObject",
    "source": "assertion",
    "fixture": "expect(...).not.toMatchObject failed — actual: 1, expected: 2"
  },
  {
    "id": "assert-not-toContain",
    "pattern": "expect\\(\\.\\.\\.\\)\\.not\\.toContain\\b failed",
    "stratum": "semantic-procedure",
    "classKey": "assertion|not.toContain",
    "source": "assertion",
    "fixture": "expect(...).not.toContain failed — actual: 1, expected: 2"
  },
  {
    "id": "assert-not-toContainEqual",
    "pattern": "expect\\(\\.\\.\\.\\)\\.not\\.toContainEqual\\b failed",
    "stratum": "semantic-procedure",
    "classKey": "assertion|not.toContainEqual",
    "source": "assertion",
    "fixture": "expect(...).not.toContainEqual failed — actual: 1, expected: 2"
  },
  {
    "id": "assert-not-toHaveProperty",
    "pattern": "expect\\(\\.\\.\\.\\)\\.not\\.toHaveProperty\\b failed",
    "stratum": "semantic-procedure",
    "classKey": "assertion|not.toHaveProperty",
    "source": "assertion",
    "fixture": "expect(...).not.toHaveProperty failed — actual: 1, expected: 2"
  },
  {
    "id": "assert-not-toBeDefined",
    "pattern": "expect\\(\\.\\.\\.\\)\\.not\\.toBeDefined\\b failed",
    "stratum": "semantic-procedure",
    "classKey": "assertion|not.toBeDefined",
    "source": "assertion",
    "fixture": "expect(...).not.toBeDefined failed — actual: 1, expected: 2"
  },
  {
    "id": "assert-not-toBeUndefined",
    "pattern": "expect\\(\\.\\.\\.\\)\\.not\\.toBeUndefined\\b failed",
    "stratum": "semantic-procedure",
    "classKey": "assertion|not.toBeUndefined",
    "source": "assertion",
    "fixture": "expect(...).not.toBeUndefined failed — actual: 1, expected: 2"
  },
  {
    "id": "assert-not-toBeNull",
    "pattern": "expect\\(\\.\\.\\.\\)\\.not\\.toBeNull\\b failed",
    "stratum": "semantic-procedure",
    "classKey": "assertion|not.toBeNull",
    "source": "assertion",
    "fixture": "expect(...).not.toBeNull failed — actual: 1, expected: 2"
  },
  {
    "id": "assert-not-toBeTruthy",
    "pattern": "expect\\(\\.\\.\\.\\)\\.not\\.toBeTruthy\\b failed",
    "stratum": "semantic-procedure",
    "classKey": "assertion|not.toBeTruthy",
    "source": "assertion",
    "fixture": "expect(...).not.toBeTruthy failed — actual: 1, expected: 2"
  },
  {
    "id": "assert-not-toBeFalsy",
    "pattern": "expect\\(\\.\\.\\.\\)\\.not\\.toBeFalsy\\b failed",
    "stratum": "semantic-procedure",
    "classKey": "assertion|not.toBeFalsy",
    "source": "assertion",
    "fixture": "expect(...).not.toBeFalsy failed — actual: 1, expected: 2"
  },
  {
    "id": "assert-not-toBeGreaterThan",
    "pattern": "expect\\(\\.\\.\\.\\)\\.not\\.toBeGreaterThan\\b failed",
    "stratum": "semantic-procedure",
    "classKey": "assertion|not.toBeGreaterThan",
    "source": "assertion",
    "fixture": "expect(...).not.toBeGreaterThan failed — actual: 1, expected: 2"
  },
  {
    "id": "assert-not-toBeGreaterThanOrEqual",
    "pattern": "expect\\(\\.\\.\\.\\)\\.not\\.toBeGreaterThanOrEqual\\b failed",
    "stratum": "semantic-procedure",
    "classKey": "assertion|not.toBeGreaterThanOrEqual",
    "source": "assertion",
    "fixture": "expect(...).not.toBeGreaterThanOrEqual failed — actual: 1, expected: 2"
  },
  {
    "id": "assert-not-toBeLessThan",
    "pattern": "expect\\(\\.\\.\\.\\)\\.not\\.toBeLessThan\\b failed",
    "stratum": "semantic-procedure",
    "classKey": "assertion|not.toBeLessThan",
    "source": "assertion",
    "fixture": "expect(...).not.toBeLessThan failed — actual: 1, expected: 2"
  },
  {
    "id": "assert-not-toBeLessThanOrEqual",
    "pattern": "expect\\(\\.\\.\\.\\)\\.not\\.toBeLessThanOrEqual\\b failed",
    "stratum": "semantic-procedure",
    "classKey": "assertion|not.toBeLessThanOrEqual",
    "source": "assertion",
    "fixture": "expect(...).not.toBeLessThanOrEqual failed — actual: 1, expected: 2"
  },
  {
    "id": "assert-not-toBeCloseTo",
    "pattern": "expect\\(\\.\\.\\.\\)\\.not\\.toBeCloseTo\\b failed",
    "stratum": "semantic-procedure",
    "classKey": "assertion|not.toBeCloseTo",
    "source": "assertion",
    "fixture": "expect(...).not.toBeCloseTo failed — actual: 1, expected: 2"
  },
  {
    "id": "assert-not-toBeInstanceOf",
    "pattern": "expect\\(\\.\\.\\.\\)\\.not\\.toBeInstanceOf\\b failed",
    "stratum": "semantic-procedure",
    "classKey": "assertion|not.toBeInstanceOf",
    "source": "assertion",
    "fixture": "expect(...).not.toBeInstanceOf failed — actual: 1, expected: 2"
  },
  {
    "id": "assert-not-toHaveLength",
    "pattern": "expect\\(\\.\\.\\.\\)\\.not\\.toHaveLength\\b failed",
    "stratum": "semantic-procedure",
    "classKey": "assertion|not.toHaveLength",
    "source": "assertion",
    "fixture": "expect(...).not.toHaveLength failed — actual: 1, expected: 2"
  },
  {
    "id": "assert-not-toHaveBeenCalled",
    "pattern": "expect\\(\\.\\.\\.\\)\\.not\\.toHaveBeenCalled\\b failed",
    "stratum": "semantic-procedure",
    "classKey": "assertion|not.toHaveBeenCalled",
    "source": "assertion",
    "fixture": "expect(...).not.toHaveBeenCalled failed — actual: 1, expected: 2"
  },
  {
    "id": "assert-not-toHaveBeenCalledTimes",
    "pattern": "expect\\(\\.\\.\\.\\)\\.not\\.toHaveBeenCalledTimes\\b failed",
    "stratum": "semantic-procedure",
    "classKey": "assertion|not.toHaveBeenCalledTimes",
    "source": "assertion",
    "fixture": "expect(...).not.toHaveBeenCalledTimes failed — actual: 1, expected: 2"
  },
  {
    "id": "assert-not-toHaveBeenCalledWith",
    "pattern": "expect\\(\\.\\.\\.\\)\\.not\\.toHaveBeenCalledWith\\b failed",
    "stratum": "semantic-procedure",
    "classKey": "assertion|not.toHaveBeenCalledWith",
    "source": "assertion",
    "fixture": "expect(...).not.toHaveBeenCalledWith failed — actual: 1, expected: 2"
  },
  {
    "id": "assert-not-toHaveBeenLastCalledWith",
    "pattern": "expect\\(\\.\\.\\.\\)\\.not\\.toHaveBeenLastCalledWith\\b failed",
    "stratum": "semantic-procedure",
    "classKey": "assertion|not.toHaveBeenLastCalledWith",
    "source": "assertion",
    "fixture": "expect(...).not.toHaveBeenLastCalledWith failed — actual: 1, expected: 2"
  },
  {
    "id": "assert-not-toHaveReturned",
    "pattern": "expect\\(\\.\\.\\.\\)\\.not\\.toHaveReturned\\b failed",
    "stratum": "semantic-procedure",
    "classKey": "assertion|not.toHaveReturned",
    "source": "assertion",
    "fixture": "expect(...).not.toHaveReturned failed — actual: 1, expected: 2"
  },
  {
    "id": "assert-not-toHaveReturnedWith",
    "pattern": "expect\\(\\.\\.\\.\\)\\.not\\.toHaveReturnedWith\\b failed",
    "stratum": "semantic-procedure",
    "classKey": "assertion|not.toHaveReturnedWith",
    "source": "assertion",
    "fixture": "expect(...).not.toHaveReturnedWith failed — actual: 1, expected: 2"
  },
  {
    "id": "assert-not-toSatisfy",
    "pattern": "expect\\(\\.\\.\\.\\)\\.not\\.toSatisfy\\b failed",
    "stratum": "semantic-procedure",
    "classKey": "assertion|not.toSatisfy",
    "source": "assertion",
    "fixture": "expect(...).not.toSatisfy failed — actual: 1, expected: 2"
  },
  {
    "id": "assert-not-toMatchSnapshot",
    "pattern": "expect\\(\\.\\.\\.\\)\\.not\\.toMatchSnapshot\\b failed",
    "stratum": "semantic-procedure",
    "classKey": "assertion|not.toMatchSnapshot",
    "source": "assertion",
    "fixture": "expect(...).not.toMatchSnapshot failed — actual: 1, expected: 2"
  },
  {
    "id": "assert-not-toMatchInlineSnapshot",
    "pattern": "expect\\(\\.\\.\\.\\)\\.not\\.toMatchInlineSnapshot\\b failed",
    "stratum": "semantic-procedure",
    "classKey": "assertion|not.toMatchInlineSnapshot",
    "source": "assertion",
    "fixture": "expect(...).not.toMatchInlineSnapshot failed — actual: 1, expected: 2"
  },
  {
    "id": "assert-toBe",
    "pattern": "expect\\(\\.\\.\\.\\)\\.toBe\\b failed",
    "stratum": "semantic-procedure",
    "classKey": "assertion|toBe",
    "source": "assertion",
    "fixture": "expect(...).toBe failed — actual: 1, expected: 2"
  },
  {
    "id": "assert-toEqual",
    "pattern": "expect\\(\\.\\.\\.\\)\\.toEqual\\b failed",
    "stratum": "semantic-procedure",
    "classKey": "assertion|toEqual",
    "source": "assertion",
    "fixture": "expect(...).toEqual failed — actual: 1, expected: 2"
  },
  {
    "id": "assert-toStrictEqual",
    "pattern": "expect\\(\\.\\.\\.\\)\\.toStrictEqual\\b failed",
    "stratum": "semantic-procedure",
    "classKey": "assertion|toStrictEqual",
    "source": "assertion",
    "fixture": "expect(...).toStrictEqual failed — actual: 1, expected: 2"
  },
  {
    "id": "assert-toThrow",
    "pattern": "expect\\(\\.\\.\\.\\)\\.toThrow\\b failed",
    "stratum": "semantic-procedure",
    "classKey": "throw-mismatch|toThrow",
    "source": "assertion",
    "fixture": "expect(...).toThrow failed — actual: 1, expected: 2"
  },
  {
    "id": "assert-toThrowError",
    "pattern": "expect\\(\\.\\.\\.\\)\\.toThrowError\\b failed",
    "stratum": "semantic-procedure",
    "classKey": "throw-mismatch|toThrowError",
    "source": "assertion",
    "fixture": "expect(...).toThrowError failed — actual: 1, expected: 2"
  },
  {
    "id": "assert-toMatch",
    "pattern": "expect\\(\\.\\.\\.\\)\\.toMatch\\b failed",
    "stratum": "semantic-procedure",
    "classKey": "assertion|toMatch",
    "source": "assertion",
    "fixture": "expect(...).toMatch failed — actual: 1, expected: 2"
  },
  {
    "id": "assert-toMatchObject",
    "pattern": "expect\\(\\.\\.\\.\\)\\.toMatchObject\\b failed",
    "stratum": "semantic-procedure",
    "classKey": "assertion|toMatchObject",
    "source": "assertion",
    "fixture": "expect(...).toMatchObject failed — actual: 1, expected: 2"
  },
  {
    "id": "assert-toContain",
    "pattern": "expect\\(\\.\\.\\.\\)\\.toContain\\b failed",
    "stratum": "semantic-procedure",
    "classKey": "assertion|toContain",
    "source": "assertion",
    "fixture": "expect(...).toContain failed — actual: 1, expected: 2"
  },
  {
    "id": "assert-toContainEqual",
    "pattern": "expect\\(\\.\\.\\.\\)\\.toContainEqual\\b failed",
    "stratum": "semantic-procedure",
    "classKey": "assertion|toContainEqual",
    "source": "assertion",
    "fixture": "expect(...).toContainEqual failed — actual: 1, expected: 2"
  },
  {
    "id": "assert-toHaveProperty",
    "pattern": "expect\\(\\.\\.\\.\\)\\.toHaveProperty\\b failed",
    "stratum": "semantic-procedure",
    "classKey": "assertion|toHaveProperty",
    "source": "assertion",
    "fixture": "expect(...).toHaveProperty failed — actual: 1, expected: 2"
  },
  {
    "id": "assert-toBeDefined",
    "pattern": "expect\\(\\.\\.\\.\\)\\.toBeDefined\\b failed",
    "stratum": "semantic-procedure",
    "classKey": "assertion|toBeDefined",
    "source": "assertion",
    "fixture": "expect(...).toBeDefined failed — actual: 1, expected: 2"
  },
  {
    "id": "assert-toBeUndefined",
    "pattern": "expect\\(\\.\\.\\.\\)\\.toBeUndefined\\b failed",
    "stratum": "semantic-procedure",
    "classKey": "assertion|toBeUndefined",
    "source": "assertion",
    "fixture": "expect(...).toBeUndefined failed — actual: 1, expected: 2"
  },
  {
    "id": "assert-toBeNull",
    "pattern": "expect\\(\\.\\.\\.\\)\\.toBeNull\\b failed",
    "stratum": "semantic-procedure",
    "classKey": "assertion|toBeNull",
    "source": "assertion",
    "fixture": "expect(...).toBeNull failed — actual: 1, expected: 2"
  },
  {
    "id": "assert-toBeTruthy",
    "pattern": "expect\\(\\.\\.\\.\\)\\.toBeTruthy\\b failed",
    "stratum": "semantic-procedure",
    "classKey": "assertion|toBeTruthy",
    "source": "assertion",
    "fixture": "expect(...).toBeTruthy failed — actual: 1, expected: 2"
  },
  {
    "id": "assert-toBeFalsy",
    "pattern": "expect\\(\\.\\.\\.\\)\\.toBeFalsy\\b failed",
    "stratum": "semantic-procedure",
    "classKey": "assertion|toBeFalsy",
    "source": "assertion",
    "fixture": "expect(...).toBeFalsy failed — actual: 1, expected: 2"
  },
  {
    "id": "assert-toBeGreaterThan",
    "pattern": "expect\\(\\.\\.\\.\\)\\.toBeGreaterThan\\b failed",
    "stratum": "semantic-procedure",
    "classKey": "assertion|toBeGreaterThan",
    "source": "assertion",
    "fixture": "expect(...).toBeGreaterThan failed — actual: 1, expected: 2"
  },
  {
    "id": "assert-toBeGreaterThanOrEqual",
    "pattern": "expect\\(\\.\\.\\.\\)\\.toBeGreaterThanOrEqual\\b failed",
    "stratum": "semantic-procedure",
    "classKey": "assertion|toBeGreaterThanOrEqual",
    "source": "assertion",
    "fixture": "expect(...).toBeGreaterThanOrEqual failed — actual: 1, expected: 2"
  },
  {
    "id": "assert-toBeLessThan",
    "pattern": "expect\\(\\.\\.\\.\\)\\.toBeLessThan\\b failed",
    "stratum": "semantic-procedure",
    "classKey": "assertion|toBeLessThan",
    "source": "assertion",
    "fixture": "expect(...).toBeLessThan failed — actual: 1, expected: 2"
  },
  {
    "id": "assert-toBeLessThanOrEqual",
    "pattern": "expect\\(\\.\\.\\.\\)\\.toBeLessThanOrEqual\\b failed",
    "stratum": "semantic-procedure",
    "classKey": "assertion|toBeLessThanOrEqual",
    "source": "assertion",
    "fixture": "expect(...).toBeLessThanOrEqual failed — actual: 1, expected: 2"
  },
  {
    "id": "assert-toBeCloseTo",
    "pattern": "expect\\(\\.\\.\\.\\)\\.toBeCloseTo\\b failed",
    "stratum": "semantic-procedure",
    "classKey": "assertion|toBeCloseTo",
    "source": "assertion",
    "fixture": "expect(...).toBeCloseTo failed — actual: 1, expected: 2"
  },
  {
    "id": "assert-toBeInstanceOf",
    "pattern": "expect\\(\\.\\.\\.\\)\\.toBeInstanceOf\\b failed",
    "stratum": "semantic-procedure",
    "classKey": "assertion|toBeInstanceOf",
    "source": "assertion",
    "fixture": "expect(...).toBeInstanceOf failed — actual: 1, expected: 2"
  },
  {
    "id": "assert-toHaveLength",
    "pattern": "expect\\(\\.\\.\\.\\)\\.toHaveLength\\b failed",
    "stratum": "semantic-procedure",
    "classKey": "assertion|toHaveLength",
    "source": "assertion",
    "fixture": "expect(...).toHaveLength failed — actual: 1, expected: 2"
  },
  {
    "id": "assert-toHaveBeenCalled",
    "pattern": "expect\\(\\.\\.\\.\\)\\.toHaveBeenCalled\\b failed",
    "stratum": "semantic-procedure",
    "classKey": "assertion|toHaveBeenCalled",
    "source": "assertion",
    "fixture": "expect(...).toHaveBeenCalled failed — actual: 1, expected: 2"
  },
  {
    "id": "assert-toHaveBeenCalledTimes",
    "pattern": "expect\\(\\.\\.\\.\\)\\.toHaveBeenCalledTimes\\b failed",
    "stratum": "semantic-procedure",
    "classKey": "assertion|toHaveBeenCalledTimes",
    "source": "assertion",
    "fixture": "expect(...).toHaveBeenCalledTimes failed — actual: 1, expected: 2"
  },
  {
    "id": "assert-toHaveBeenCalledWith",
    "pattern": "expect\\(\\.\\.\\.\\)\\.toHaveBeenCalledWith\\b failed",
    "stratum": "semantic-procedure",
    "classKey": "assertion|toHaveBeenCalledWith",
    "source": "assertion",
    "fixture": "expect(...).toHaveBeenCalledWith failed — actual: 1, expected: 2"
  },
  {
    "id": "assert-toHaveBeenLastCalledWith",
    "pattern": "expect\\(\\.\\.\\.\\)\\.toHaveBeenLastCalledWith\\b failed",
    "stratum": "semantic-procedure",
    "classKey": "assertion|toHaveBeenLastCalledWith",
    "source": "assertion",
    "fixture": "expect(...).toHaveBeenLastCalledWith failed — actual: 1, expected: 2"
  },
  {
    "id": "assert-toHaveReturned",
    "pattern": "expect\\(\\.\\.\\.\\)\\.toHaveReturned\\b failed",
    "stratum": "semantic-procedure",
    "classKey": "assertion|toHaveReturned",
    "source": "assertion",
    "fixture": "expect(...).toHaveReturned failed — actual: 1, expected: 2"
  },
  {
    "id": "assert-toHaveReturnedWith",
    "pattern": "expect\\(\\.\\.\\.\\)\\.toHaveReturnedWith\\b failed",
    "stratum": "semantic-procedure",
    "classKey": "assertion|toHaveReturnedWith",
    "source": "assertion",
    "fixture": "expect(...).toHaveReturnedWith failed — actual: 1, expected: 2"
  },
  {
    "id": "assert-toSatisfy",
    "pattern": "expect\\(\\.\\.\\.\\)\\.toSatisfy\\b failed",
    "stratum": "semantic-procedure",
    "classKey": "assertion|toSatisfy",
    "source": "assertion",
    "fixture": "expect(...).toSatisfy failed — actual: 1, expected: 2"
  },
  {
    "id": "assert-toMatchSnapshot",
    "pattern": "expect\\(\\.\\.\\.\\)\\.toMatchSnapshot\\b failed",
    "stratum": "semantic-procedure",
    "classKey": "assertion|toMatchSnapshot",
    "source": "assertion",
    "fixture": "expect(...).toMatchSnapshot failed — actual: 1, expected: 2"
  },
  {
    "id": "assert-toMatchInlineSnapshot",
    "pattern": "expect\\(\\.\\.\\.\\)\\.toMatchInlineSnapshot\\b failed",
    "stratum": "semantic-procedure",
    "classKey": "assertion|toMatchInlineSnapshot",
    "source": "assertion",
    "fixture": "expect(...).toMatchInlineSnapshot failed — actual: 1, expected: 2"
  },
  {
    "id": "assert-generic",
    "pattern": "expect\\(\\.\\.\\.\\)\\.((?:not\\.)?[A-Za-z]+) failed",
    "stratum": "semantic-procedure",
    "classKey": "assertion|$1",
    "source": "assertion",
    "fixture": "expect(...).customMatcher failed — actual: false, expected: true"
  },
  {
    "id": "v8-invalid-unexpected-token",
    "pattern": "Invalid or unexpected token",
    "stratum": "mechanical-first",
    "classKey": "crash|token|Invalid or unexpected token",
    "source": "v8-syntax",
    "fixture": "Invalid or unexpected token"
  },
  {
    "id": "v8-unexpected-end",
    "pattern": "Unexpected end of input",
    "stratum": "mechanical-first",
    "classKey": "crash|token|Unexpected end of input",
    "source": "v8-syntax",
    "fixture": "Unexpected end of input"
  },
  {
    "id": "v8-unexpected-identifier",
    "pattern": "Unexpected identifier",
    "stratum": "mechanical-first",
    "classKey": "crash|token|Unexpected identifier",
    "source": "v8-syntax",
    "fixture": "Unexpected identifier"
  },
  {
    "id": "v8-unexpected-string",
    "pattern": "Unexpected string",
    "stratum": "mechanical-first",
    "classKey": "crash|token|Unexpected string",
    "source": "v8-syntax",
    "fixture": "Unexpected string"
  },
  {
    "id": "v8-unexpected-number",
    "pattern": "Unexpected number",
    "stratum": "mechanical-first",
    "classKey": "crash|token|Unexpected number",
    "source": "v8-syntax",
    "fixture": "Unexpected number"
  },
  {
    "id": "v8-reserved-strict",
    "pattern": "Unexpected reserved word",
    "stratum": "mechanical-first",
    "classKey": "crash|token|Unexpected reserved word",
    "source": "v8-syntax",
    "fixture": "Unexpected reserved word"
  },
  {
    "id": "v8-unexpected-token",
    "pattern": "Unexpected token",
    "stratum": "mechanical-first",
    "classKey": "crash|token|Unexpected token",
    "source": "v8-syntax",
    "fixture": "Unexpected token '}'"
  },
  {
    "id": "v8-invalid-regex",
    "pattern": "Invalid regular expression",
    "stratum": "mechanical-first",
    "classKey": "regex-literal|$0",
    "source": "v8-syntax",
    "fixture": "Invalid regular expression: missing /"
  },
  {
    "id": "v8-unterminated-regex",
    "pattern": "Unterminated regular expression",
    "stratum": "mechanical-first",
    "classKey": "regex-literal|$0",
    "source": "v8-syntax",
    "fixture": "Unterminated regular expression literal"
  },
  {
    "id": "v8-unterminated-template",
    "pattern": "Unterminated template",
    "stratum": "mechanical-first",
    "classKey": "crash|token|Unterminated template",
    "source": "v8-syntax",
    "fixture": "Unterminated template"
  },
  {
    "id": "v8-unterminated-string",
    "pattern": "Unterminated string",
    "stratum": "mechanical-first",
    "classKey": "crash|token|Unterminated string",
    "source": "v8-syntax",
    "fixture": "Unterminated string constant"
  },
  {
    "id": "v8-already-declared",
    "pattern": "Identifier '([^']+)' has already been declared",
    "stratum": "mechanical-first",
    "classKey": "duplicate-decl|$1",
    "source": "v8-syntax",
    "fixture": "Identifier 'Foo' has already been declared"
  },
  {
    "id": "v8-missing-paren-arglist",
    "pattern": "missing \\) after argument list",
    "stratum": "mechanical-first",
    "classKey": "crash|token|missing ) after argument list",
    "source": "v8-syntax",
    "fixture": "missing ) after argument list"
  },
  {
    "id": "v8-missing-catch-finally",
    "pattern": "Missing catch or finally after try",
    "stratum": "mechanical-first",
    "classKey": "crash|token|Missing catch or finally",
    "source": "v8-syntax",
    "fixture": "Missing catch or finally after try"
  },
  {
    "id": "v8-illegal-return",
    "pattern": "Illegal return statement",
    "stratum": "mechanical-first",
    "classKey": "crash|token|Illegal return statement",
    "source": "v8-syntax",
    "fixture": "Illegal return statement"
  },
  {
    "id": "v8-invalid-lhs",
    "pattern": "Invalid left-hand side",
    "stratum": "mechanical-first",
    "classKey": "crash|token|Invalid left-hand side",
    "source": "v8-syntax",
    "fixture": "Invalid left-hand side in assignment"
  },
  {
    "id": "v8-missing-initializer",
    "pattern": "Missing initializer in (const|let) declaration",
    "stratum": "mechanical-first",
    "classKey": "crash|token|Missing initializer",
    "source": "v8-syntax",
    "fixture": "Missing initializer in const declaration"
  },
  {
    "id": "v8-await-outside",
    "pattern": "await is only valid in async",
    "stratum": "mechanical-first",
    "classKey": "crash|token|await outside async",
    "source": "v8-syntax",
    "fixture": "await is only valid in async functions"
  },
  {
    "id": "v8-octal",
    "pattern": "Octal literals are not allowed",
    "stratum": "mechanical-first",
    "classKey": "crash|token|Octal literals",
    "source": "v8-syntax",
    "fixture": "Octal literals are not allowed in strict mode"
  },
  {
    "id": "v8-missing-colon",
    "pattern": "missing : in conditional",
    "stratum": "mechanical-first",
    "classKey": "crash|token|missing colon",
    "source": "v8-syntax",
    "fixture": "missing : in conditional expression"
  },
  {
    "id": "v8-not-defined-jest",
    "pattern": "^jest is not defined",
    "stratum": "mechanical-first",
    "classKey": "undefined-symbol|jest",
    "source": "v8-runtime",
    "fixture": "jest is not defined"
  },
  {
    "id": "v8-not-defined-fn",
    "pattern": "^fn is not defined",
    "stratum": "mechanical-first",
    "classKey": "undefined-symbol|fn",
    "source": "v8-runtime",
    "fixture": "fn is not defined"
  },
  {
    "id": "v8-not-a-function-spyOn",
    "pattern": "(?:^|\\.)spyOn is not a function|vi\\.spyOn is not a function|spyOn is not a function",
    "stratum": "mechanical-first",
    "classKey": "is-not-a-function|spyOn",
    "source": "v8-runtime",
    "fixture": "spyOn is not a function"
  },
  {
    "id": "v8-not-defined",
    "pattern": "^([A-Za-z_$][\\w$]*) is not defined",
    "stratum": "playbook",
    "classKey": "undefined-symbol|$1",
    "source": "v8-runtime",
    "fixture": "slugify is not defined"
  },
  {
    "id": "v8-before-init",
    "pattern": "Cannot access '([^']+)' before initialization",
    "stratum": "playbook",
    "classKey": "runtime|before-init|$1",
    "source": "v8-runtime",
    "fixture": "Cannot access 'x' before initialization"
  },
  {
    "id": "v8-not-a-function",
    "pattern": "([A-Za-z_$][\\w$]*(?:\\.[A-Za-z_$][\\w$]*)*) is not a function",
    "stratum": "playbook",
    "classKey": "is-not-a-function|$1",
    "source": "v8-runtime",
    "fixture": "parse is not a function"
  },
  {
    "id": "v8-nullread-undef",
    "pattern": "Cannot read propert(?:y|ies) of undefined \\(reading '([^']+)'\\)",
    "stratum": "playbook",
    "classKey": "runtime|nullread|$1",
    "source": "v8-runtime",
    "fixture": "Cannot read properties of undefined (reading 'id')"
  },
  {
    "id": "v8-nullread-null",
    "pattern": "Cannot read propert(?:y|ies) of null \\(reading '([^']+)'\\)",
    "stratum": "playbook",
    "classKey": "runtime|nullread|$1",
    "source": "v8-runtime",
    "fixture": "Cannot read properties of null (reading 'id')"
  },
  {
    "id": "v8-set-undef",
    "pattern": "Cannot set propert(?:y|ies) of undefined",
    "stratum": "playbook",
    "classKey": "runtime|nullwrite|undefined",
    "source": "v8-runtime",
    "fixture": "Cannot set properties of undefined (setting 'x')"
  },
  {
    "id": "v8-set-null",
    "pattern": "Cannot set propert(?:y|ies) of null",
    "stratum": "playbook",
    "classKey": "runtime|nullwrite|null",
    "source": "v8-runtime",
    "fixture": "Cannot set properties of null (setting 'x')"
  },
  {
    "id": "v8-class-needs-new",
    "pattern": "Class constructor (\\w+) cannot be invoked without 'new'",
    "stratum": "mechanical-first",
    "classKey": "catalog-drift|missing-new|$1",
    "source": "v8-runtime",
    "fixture": "Class constructor Widget cannot be invoked without 'new'"
  },
  {
    "id": "v8-interop-not-constructor",
    "pattern": "\\(0\\s*,\\s*_\\w+\\.(\\w+)\\)\\s+is not a constructor",
    "stratum": "mechanical-first",
    "classKey": "catalog-drift|missing-new|$1",
    "source": "v8-runtime",
    "fixture": "(0 , _widget.Widget) is not a constructor"
  },
  {
    "id": "v8-not-constructor",
    "pattern": "([A-Za-z_$][\\w$]*) is not a constructor",
    "stratum": "mechanical-first",
    "classKey": "catalog-drift|missing-new|$1",
    "source": "v8-runtime",
    "fixture": "Foo is not a constructor"
  },
  {
    "id": "v8-not-iterable",
    "pattern": "([A-Za-z_$][\\w$]*) is not iterable",
    "stratum": "playbook",
    "classKey": "runtime|not-iterable|$1",
    "source": "v8-runtime",
    "fixture": "x is not iterable"
  },
  {
    "id": "v8-object-not-iterable",
    "pattern": "object is not iterable|is not iterable \\(cannot read",
    "stratum": "playbook",
    "classKey": "runtime|not-iterable|object",
    "source": "v8-runtime",
    "fixture": "object is not iterable (cannot read property Symbol(Symbol.iterator))"
  },
  {
    "id": "v8-max-stack",
    "pattern": "Maximum call stack size exceeded",
    "stratum": "playbook",
    "classKey": "runtime|max-stack",
    "source": "v8-runtime",
    "fixture": "Maximum call stack size exceeded"
  },
  {
    "id": "v8-cannot-convert",
    "pattern": "Cannot convert undefined or null to object",
    "stratum": "playbook",
    "classKey": "runtime|cannot-convert",
    "source": "v8-runtime",
    "fixture": "Cannot convert undefined or null to object"
  },
  {
    "id": "v8-assign-const",
    "pattern": "Assignment to constant variable",
    "stratum": "playbook",
    "classKey": "runtime|assign-const",
    "source": "v8-runtime",
    "fixture": "Assignment to constant variable"
  },
  {
    "id": "v8-reduce-empty",
    "pattern": "Reduce of empty array with no initial value",
    "stratum": "playbook",
    "classKey": "runtime|reduce-empty",
    "source": "v8-runtime",
    "fixture": "Reduce of empty array with no initial value"
  },
  {
    "id": "v8-invalid-array-length",
    "pattern": "Invalid array length",
    "stratum": "playbook",
    "classKey": "runtime|invalid-array-length",
    "source": "v8-runtime",
    "fixture": "Invalid array length"
  },
  {
    "id": "v8-precision-range",
    "pattern": "precision .* out of range|toFixed\\(\\) digits argument must",
    "stratum": "playbook",
    "classKey": "runtime|range|precision",
    "source": "v8-runtime",
    "fixture": "toFixed() digits argument must be between 0 and 100"
  },
  {
    "id": "v8-in-operator",
    "pattern": "Cannot use 'in' operator",
    "stratum": "playbook",
    "classKey": "runtime|in-operator",
    "source": "v8-runtime",
    "fixture": "Cannot use 'in' operator to search for 'x' in undefined"
  },
  {
    "id": "v8-spread-non-iterable",
    "pattern": "Found non-callable @@iterator|is not iterable \\(cannot read property Symbol",
    "stratum": "playbook",
    "classKey": "runtime|spread-non-iterable",
    "source": "v8-runtime",
    "fixture": "Found non-callable @@iterator"
  },
  {
    "id": "v8-instanceof",
    "pattern": "Right-hand side of 'instanceof' is not",
    "stratum": "playbook",
    "classKey": "runtime|instanceof",
    "source": "v8-runtime",
    "fixture": "Right-hand side of 'instanceof' is not an object"
  },
  {
    "id": "v8-promise-cycle",
    "pattern": "Chaining cycle detected for promise",
    "stratum": "playbook",
    "classKey": "runtime|promise-cycle",
    "source": "v8-runtime",
    "fixture": "Chaining cycle detected for promise #<Promise>"
  },
  {
    "id": "ts-1002",
    "pattern": "TS1002\\b|error TS1002\\b|Unterminated string literal\\.",
    "stratum": "mechanical-first",
    "classKey": "transpile|TS1002",
    "source": "typescript",
    "fixture": "error TS1002: Unterminated string literal."
  },
  {
    "id": "ts-1003",
    "pattern": "TS1003\\b|error TS1003\\b|Identifier expected\\.",
    "stratum": "mechanical-first",
    "classKey": "transpile|TS1003",
    "source": "typescript",
    "fixture": "error TS1003: Identifier expected."
  },
  {
    "id": "ts-1005",
    "pattern": "TS1005\\b|error TS1005\\b",
    "stratum": "mechanical-first",
    "classKey": "transpile|TS1005",
    "source": "typescript",
    "fixture": "error TS1005: 'Foo' expected."
  },
  {
    "id": "ts-1009",
    "pattern": "TS1009\\b|error TS1009\\b|Trailing comma not allowed\\.",
    "stratum": "mechanical-first",
    "classKey": "transpile|TS1009",
    "source": "typescript",
    "fixture": "error TS1009: Trailing comma not allowed."
  },
  {
    "id": "ts-1010",
    "pattern": "TS1010\\b|error TS1010\\b|\\'\\*/\\' expected\\.",
    "stratum": "mechanical-first",
    "classKey": "transpile|TS1010",
    "source": "typescript",
    "fixture": "error TS1010: '*/' expected."
  },
  {
    "id": "ts-1012",
    "pattern": "TS1012\\b|error TS1012\\b|Unexpected token\\.",
    "stratum": "mechanical-first",
    "classKey": "transpile|TS1012",
    "source": "typescript",
    "fixture": "error TS1012: Unexpected token."
  },
  {
    "id": "ts-1068",
    "pattern": "TS1068\\b|error TS1068\\b|Unexpected token\\. A constructor, method,",
    "stratum": "mechanical-first",
    "classKey": "transpile|TS1068",
    "source": "typescript",
    "fixture": "error TS1068: Unexpected token. A constructor, method, accessor, or property was expected."
  },
  {
    "id": "ts-1109",
    "pattern": "TS1109\\b|error TS1109\\b|Expression expected\\.",
    "stratum": "mechanical-first",
    "classKey": "transpile|TS1109",
    "source": "typescript",
    "fixture": "error TS1109: Expression expected."
  },
  {
    "id": "ts-1128",
    "pattern": "TS1128\\b|error TS1128\\b|Declaration or statement expected\\.",
    "stratum": "mechanical-first",
    "classKey": "transpile|TS1128",
    "source": "typescript",
    "fixture": "error TS1128: Declaration or statement expected."
  },
  {
    "id": "ts-1160",
    "pattern": "TS1160\\b|error TS1160\\b|Unterminated template literal\\.",
    "stratum": "mechanical-first",
    "classKey": "transpile|TS1160",
    "source": "typescript",
    "fixture": "error TS1160: Unterminated template literal."
  },
  {
    "id": "ts-1161",
    "pattern": "TS1161\\b|error TS1161\\b|Unterminated regular expression literal\\.",
    "stratum": "mechanical-first",
    "classKey": "transpile|TS1161",
    "source": "typescript",
    "fixture": "error TS1161: Unterminated regular expression literal."
  },
  {
    "id": "ts-1434",
    "pattern": "TS1434\\b|error TS1434\\b|Unexpected keyword or identifier\\.",
    "stratum": "mechanical-first",
    "classKey": "transpile|TS1434",
    "source": "typescript",
    "fixture": "error TS1434: Unexpected keyword or identifier."
  },
  {
    "id": "ts-2304",
    "pattern": "TS2304\\b|error TS2304\\b|Cannot find name \\'",
    "stratum": "playbook",
    "classKey": "undefined-symbol|TS2304",
    "source": "typescript",
    "fixture": "error TS2304: Cannot find name 'Foo'."
  },
  {
    "id": "ts-2305",
    "pattern": "TS2305\\b|error TS2305\\b",
    "stratum": "playbook",
    "classKey": "unresolved-import|TS2305",
    "source": "typescript",
    "fixture": "error TS2305: Module 'Foo' has no exported member 'Bar'."
  },
  {
    "id": "ts-2306",
    "pattern": "TS2306\\b|error TS2306\\b",
    "stratum": "semantic-procedure",
    "classKey": "runtime|TS2306",
    "source": "typescript",
    "fixture": "error TS2306: File 'Foo' is not a module."
  },
  {
    "id": "ts-2307",
    "pattern": "TS2307\\b|error TS2307\\b|Cannot find module \\'",
    "stratum": "playbook",
    "classKey": "unresolved-import|TS2307",
    "source": "typescript",
    "fixture": "error TS2307: Cannot find module 'Foo' or its corresponding type declarations."
  },
  {
    "id": "ts-2322",
    "pattern": "TS2322\\b|error TS2322\\b",
    "stratum": "semantic-procedure",
    "classKey": "runtime|TS2322",
    "source": "typescript",
    "fixture": "error TS2322: Type 'Foo' is not assignable to type 'Bar'."
  },
  {
    "id": "ts-2339",
    "pattern": "TS2339\\b|error TS2339\\b",
    "stratum": "semantic-procedure",
    "classKey": "runtime|TS2339",
    "source": "typescript",
    "fixture": "error TS2339: Property 'Foo' does not exist on type 'Bar'."
  },
  {
    "id": "ts-2345",
    "pattern": "TS2345\\b|error TS2345\\b|Argument of type \\'",
    "stratum": "semantic-procedure",
    "classKey": "runtime|TS2345",
    "source": "typescript",
    "fixture": "error TS2345: Argument of type 'Foo' is not assignable to parameter of type 'Bar'."
  },
  {
    "id": "ts-2459",
    "pattern": "TS2459\\b|error TS2459\\b",
    "stratum": "playbook",
    "classKey": "unresolved-import|TS2459",
    "source": "typescript",
    "fixture": "error TS2459: Module 'Foo' declares 'Bar' locally, but it is not exported."
  },
  {
    "id": "ts-2551",
    "pattern": "TS2551\\b|error TS2551\\b",
    "stratum": "semantic-procedure",
    "classKey": "runtime|TS2551",
    "source": "typescript",
    "fixture": "error TS2551: Property 'Foo' does not exist on type 'Bar'. Did you mean '{2}'?"
  },
  {
    "id": "ts-2552",
    "pattern": "TS2552\\b|error TS2552\\b|Cannot find name \\'",
    "stratum": "playbook",
    "classKey": "undefined-symbol|TS2552",
    "source": "typescript",
    "fixture": "error TS2552: Cannot find name 'Foo'. Did you mean 'Bar'?"
  },
  {
    "id": "ts-2554",
    "pattern": "TS2554\\b|error TS2554\\b",
    "stratum": "semantic-procedure",
    "classKey": "runtime|TS2554",
    "source": "typescript",
    "fixture": "error TS2554: Expected Foo arguments, but got Bar."
  },
  {
    "id": "ts-7006",
    "pattern": "TS7006\\b|error TS7006\\b",
    "stratum": "semantic-procedure",
    "classKey": "runtime|TS7006",
    "source": "typescript",
    "fixture": "error TS7006: Parameter 'Foo' implicitly has an 'Bar' type."
  }
];

export interface CatalogClassification {
  templateId: string;
  stratum: ErrorStratum | 'catalog-drift';
  classKey: string;
}

function applyClassKey(template: string, match: RegExpExecArray, firstLine: string): string {
  let out = template;
  for (let i = 1; i < match.length; i++) {
    out = out.split('$' + i).join(match[i] ?? '');
  }
  out = out.split('$0').join(firstLine.slice(0, 40));
  if (out.startsWith('is-not-a-function|') && match[1]) {
    out = 'is-not-a-function|' + (match[1].split('.').pop() ?? match[1]);
  }
  return out;
}

/**
 * SET 39a — TOTAL classifier. Every message maps to exactly one template or
 * to catalog-drift (tripwire).
 */
export function classifyCataloged(message: string): CatalogClassification {
  const text = message ?? '';
  if (text.trim() === '') {
    return { templateId: 'harness-empty-draw', stratum: 'mechanical-first', classKey: 'empty-draw' };
  }
  const first = text.split('\n')[0] ?? '';
  for (const t of ERROR_CATALOG) {
    const re = new RegExp(t.pattern, 'i');
    let m = re.exec(first);
    if (!m) m = re.exec(text);
    if (!m) continue;
    return {
      templateId: t.id,
      stratum: t.stratum,
      classKey: applyClassKey(t.classKey, m, first),
    };
  }
  return {
    templateId: 'catalog-drift',
    stratum: 'catalog-drift',
    classKey: 'catalog-drift',
  };
}

/** Runtime tripwire string for unmatched errors (SET 39b). */
export function formatCatalogDriftTripwire(message: string): string {
  const first = ((message ?? '').split('\n')[0] ?? '').slice(0, 120);
  return 'catalog-drift: "' + first.replace(/"/g, "'") + '" matches no template';
}
