# Log10x MCP — file-mode tenx runtime config.
#
# Reads events from LOG10X_MCP_INPUT_PATH, writes templates/encoded/
# decoded/aggregated to LOG10X_MCP_OUTPUT_DIR. Override this file via
# LOG10X_MCP_FILE_CONFIG_PATH.

tenx: run
runtimeName: $=TenXEnv.get("LOG10X_MCP_RUNTIME_NAME", "mcp-file")

# Include the input/output MODULES, not their config wrappers. The
# wrappers pre-define named entries reading/writing the image's bundled
# sample, and `allowMultiple: true` would run those alongside the MCP's
# own entries below.
include:


  # Shared bootstrap (symbols, template loading, transform, etc.)
  - apps/shared

  # Input module
  - run/modules/input/file

  # Full enrichment chain.
  - run/initialize/inputField
  - run/initialize/level
  - run/initialize/group
  - run/initialize/message
  - run/initialize/httpCode
  - run/initialize/lookup
  - run/initialize/custom
  - run/initialize/k8s

  # Aggregator. Without this NO TenXSummary is produced, so the
  # `filter: isSummary` output below matches nothing and aggregated.csv
  # is a header with zero data rows. That silently strips the only
  # source of per-pattern severity, and `isReducibleSeverity(undefined)`
  # then treats every ERROR pattern as reducible. Do not remove.
  #
  # DELIBERATELY EXPLICIT. DO NOT RELY ON FLAVOR DEFAULTS. If a future
  # engine emits summary rows by default, this stays. Flavors differ:
  # the compiler-flavor image emitted neither summary rows nor anchors
  # while the edge-flavor host binary emitted both, on the same input
  # and version family. A pinned older image, or a flavor we have not
  # met, silently stops producing them, severity coverage returns to
  # 0%, every ERROR pattern is marked reducible, and NOTHING ERRORS.
  # That silence is how this defect survived unnoticed the first time.
  - run/aggregate/mcp

  # Output module
  - run/modules/output/event/file

# Template cache: in local-binary mode the runner shadows the install's
# run/template/config.yaml with files: [] so persistent state under
# data/templates/ and data/sample/output/ doesn't pre-load. Docker is
# ephemeral, so the runner skips the shadow there.

# ========================== Input options ==========================

inputFile:
  - name: mcpFileInput
    path: $=TenXEnv.get("LOG10X_MCP_INPUT_PATH")
    printProgress: false
    extractors: []
    sourcePattern: null

# ========================= Output options =========================

outputFile:

  - path: $=TenXEnv.get("LOG10X_MCP_OUTPUT_DIR") + "/templates.json"
    writeTemplates: true
    append: false

  # DELIBERATELY EXPLICIT. DO NOT RELY ON FLAVOR DEFAULTS. Asking for
  # these here is not redundant even once the engine emits them by
  # default: it is what makes the MCP independent of which flavor and
  # which image tag it happens to be talking to. See the note above.
  #
  # The four anchor fields after encode() are what carry Reporter-tier
  # identity out of the engine: `pattern=,<symbolMessage>` and
  # `patternHash=,<tenx_hash>`. cli-output-parser reads them off each
  # encoded line, and pattern-extraction joins aggregated.csv on the
  # tenx_hash to resolve severity. Drop them and every pattern loses its
  # tenxHash, the aggregated join misses, and collapseBySymbolMessage
  # becomes a no-op.
  - path: $=TenXEnv.get("LOG10X_MCP_OUTPUT_DIR") + "/encoded.log"
    fields:
      - encode()
      - patternPrefix="pattern="
      - $=yield TenXEnv.get("symbolMessageField")
      - patternHashPrefix="patternHash="
      - $=yield TenXEnv.get("symbolMessageHashField")

  - path: $=TenXEnv.get("LOG10X_MCP_OUTPUT_DIR") + "/decoded.log"
    filter: isEncoded
    fields:
      - text

  - path: $=TenXEnv.get("LOG10X_MCP_OUTPUT_DIR") + "/aggregated.csv"
    filter: isSummary
    header: $=yield TenXString.join(",", TenXEnv.get("enrichmentFields"), "summaryVolume", "summaryBytes", "summaryTotals") + "\n"
    fields:
      - $=yield TenXEnv.get("enrichmentFields")
      - summaryVolume
      - summaryBytes
      - summaryTotals
