{
  "uid": "fak-guard-adjudication",
  "title": "FAK Guard \u2014 Kernel Adjudication",
  "description": "The `fak guard` session view: verdict mix (allowed/denied/repaired/quarantined), the trust floor firing by refusal reason, the NET provider-cache economics the kernel hop preserved, and history-compaction / tool-floor token shedding. The live twin of the summary `fak guard` prints on exit. Source: fak guard /metrics (start it with --addr 127.0.0.1:8080 to reuse the fak_gateway scrape job).",
  "tags": [
    "fak",
    "guard",
    "adjudication",
    "security"
  ],
  "editable": true,
  "fiscalYearStartMonth": 0,
  "graphTooltip": 1,
  "schemaVersion": 39,
  "version": 1,
  "refresh": "10s",
  "time": {
    "from": "now-1h",
    "to": "now"
  },
  "timepicker": {},
  "links": [],
  "annotations": {
    "list": [
      {
        "builtIn": 1,
        "datasource": {
          "type": "grafana",
          "uid": "-- Grafana --"
        },
        "enable": true,
        "hide": true,
        "iconColor": "rgba(0, 211, 255, 1)",
        "name": "Annotations & Alerts",
        "type": "dashboard"
      }
    ]
  },
  "templating": {
    "list": [
      {
        "name": "DS_PROMETHEUS",
        "label": "Prometheus",
        "type": "datasource",
        "query": "prometheus",
        "current": {},
        "hide": 2,
        "refresh": 1,
        "regex": "",
        "options": [],
        "includeAll": false,
        "multi": false
      }
    ]
  },
  "panels": [
    {
      "type": "row",
      "title": "Session at a glance",
      "id": 86,
      "collapsed": false,
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 0
      },
      "panels": []
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "title": "Scrape",
      "description": "Prometheus scrape health. Start guard on this port with `fak guard --addr 127.0.0.1:8080 -- claude`.",
      "type": "stat",
      "id": 87,
      "gridPos": {
        "h": 4,
        "w": 4,
        "x": 0,
        "y": 1
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [
            {
              "type": "value",
              "options": {
                "0": {
                  "text": "DOWN",
                  "color": "red",
                  "index": 0
                },
                "1": {
                  "text": "UP",
                  "color": "green",
                  "index": 1
                }
              }
            }
          ],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "red",
                "value": null
              },
              {
                "color": "green",
                "value": 1
              }
            ]
          },
          "unit": "short"
        },
        "overrides": []
      },
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "justifyMode": "auto",
        "orientation": "auto",
        "textMode": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        }
      },
      "pluginVersion": "11.5.2",
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "up{job=\"fak_gateway\"}",
          "refId": "A"
        }
      ]
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "title": "Kernel decisions",
      "description": "Every verdict the kernel reached this session (allow + deny + repair + admit).",
      "type": "stat",
      "id": 88,
      "gridPos": {
        "h": 4,
        "w": 4,
        "x": 4,
        "y": 1
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              }
            ]
          },
          "unit": "short"
        },
        "overrides": []
      },
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "justifyMode": "auto",
        "orientation": "auto",
        "textMode": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        }
      },
      "pluginVersion": "11.5.2",
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "sum(fak_gateway_operations_total) or vector(0)",
          "refId": "A"
        }
      ]
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "title": "Allowed",
      "description": "Tool calls the capability floor let through.",
      "type": "stat",
      "id": 89,
      "gridPos": {
        "h": 4,
        "w": 4,
        "x": 8,
        "y": 1
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              }
            ]
          },
          "unit": "short"
        },
        "overrides": []
      },
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "justifyMode": "auto",
        "orientation": "auto",
        "textMode": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        }
      },
      "pluginVersion": "11.5.2",
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "sum(fak_gateway_operations_total{verdict=\"ALLOW\"}) or vector(0)",
          "refId": "A"
        }
      ]
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "title": "Denied",
      "description": "Proposed tool calls the floor refused before they ran.",
      "type": "stat",
      "id": 90,
      "gridPos": {
        "h": 4,
        "w": 4,
        "x": 12,
        "y": 1
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 1
              }
            ]
          },
          "unit": "short"
        },
        "overrides": []
      },
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "justifyMode": "auto",
        "orientation": "auto",
        "textMode": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        }
      },
      "pluginVersion": "11.5.2",
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "sum(fak_gateway_operations_total{verdict=\"DENY\"}) or vector(0)",
          "refId": "A"
        }
      ]
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "title": "Repaired",
      "description": "Calls repaired in-flight (e.g. grammar) instead of costing a wasted round-trip.",
      "type": "stat",
      "id": 91,
      "gridPos": {
        "h": 4,
        "w": 4,
        "x": 16,
        "y": 1
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              }
            ]
          },
          "unit": "short"
        },
        "overrides": []
      },
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "justifyMode": "auto",
        "orientation": "auto",
        "textMode": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        }
      },
      "pluginVersion": "11.5.2",
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "sum(fak_gateway_operations_total{verdict=\"TRANSFORM\"}) or vector(0)",
          "refId": "A"
        }
      ]
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "title": "Quarantined",
      "description": "Poisoned/untrusted tool-result payloads the context-MMU paged out before the model read them.",
      "type": "stat",
      "id": 92,
      "gridPos": {
        "h": 4,
        "w": 4,
        "x": 20,
        "y": 1
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 1
              }
            ]
          },
          "unit": "short"
        },
        "overrides": []
      },
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "justifyMode": "auto",
        "orientation": "auto",
        "textMode": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        }
      },
      "pluginVersion": "11.5.2",
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "fak_gateway_context_pollutions_blocked_total or vector(0)",
          "refId": "A"
        }
      ]
    },
    {
      "type": "row",
      "title": "Trust floor \u2014 refusals by reason",
      "id": 93,
      "collapsed": false,
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 5
      },
      "panels": []
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "title": "Refusal rate by reason",
      "description": "Per-second rate of non-ALLOW verdicts grouped by the closed refusal vocabulary (internal/abi/reasons.go: TRUST_VIOLATION, SECRET_EXFIL, SELF_MODIFY, POLICY_BLOCK, DEFAULT_DENY, ...). 0 across the board means the floor refused nothing.",
      "type": "timeseries",
      "id": 94,
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 0,
        "y": 6
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "drawStyle": "line",
            "lineWidth": 1,
            "fillOpacity": 10,
            "showPoints": "never",
            "axisPlacement": "auto",
            "spanNulls": true,
            "pointSize": 5,
            "stacking": {
              "mode": "none"
            }
          },
          "unit": "short",
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              }
            ]
          }
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "displayMode": "list",
          "placement": "bottom",
          "calcs": []
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "pluginVersion": "11.5.2",
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "sum by (reason) (rate(fak_gateway_operations_total{reason!=\"\",verdict!=\"ALLOW\"}[5m]))",
          "legendFormat": "{{reason}}",
          "refId": "A"
        }
      ]
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "title": "Refusals by reason (session total)",
      "description": "Cumulative count of each structured refusal reason this session \u2014 the kernel's 'why I said no', ranked.",
      "type": "bargauge",
      "id": 95,
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 12,
        "y": 6
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 1
              }
            ]
          },
          "unit": "short"
        },
        "overrides": []
      },
      "options": {
        "displayMode": "gradient",
        "orientation": "horizontal",
        "showUnfilled": true,
        "minVizHeight": 10,
        "minVizWidth": 0,
        "valueMode": "color",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        }
      },
      "pluginVersion": "11.5.2",
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "sum by (reason) (fak_gateway_operations_total{reason!=\"\",verdict!=\"ALLOW\"})",
          "legendFormat": "{{reason}}",
          "instant": true,
          "refId": "A"
        }
      ]
    },
    {
      "type": "row",
      "title": "Verdict & disposition mix",
      "id": 96,
      "collapsed": false,
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 14
      },
      "panels": []
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "title": "Verdict mix (rate)",
      "description": "syscall/adjudicate/admit verdict rate while the wrapped agent runs.",
      "type": "timeseries",
      "id": 97,
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 0,
        "y": 15
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "drawStyle": "line",
            "lineWidth": 1,
            "fillOpacity": 10,
            "showPoints": "never",
            "axisPlacement": "auto",
            "spanNulls": true,
            "pointSize": 5,
            "stacking": {
              "mode": "none"
            }
          },
          "unit": "short",
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              }
            ]
          }
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "displayMode": "list",
          "placement": "bottom",
          "calcs": []
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "pluginVersion": "11.5.2",
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "sum by (operation, verdict) (rate(fak_gateway_operations_total[5m]))",
          "legendFormat": "{{operation}} {{verdict}}",
          "refId": "A"
        }
      ]
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "title": "Refusal disposition (rate)",
      "description": "How refusals are dispatched (DENY vs WAIT vs ...) \u2014 the action the caller should take, aggregated over all reasons.",
      "type": "timeseries",
      "id": 98,
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 12,
        "y": 15
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "drawStyle": "line",
            "lineWidth": 1,
            "fillOpacity": 10,
            "showPoints": "never",
            "axisPlacement": "auto",
            "spanNulls": true,
            "pointSize": 5,
            "stacking": {
              "mode": "none"
            }
          },
          "unit": "short",
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              }
            ]
          }
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "displayMode": "list",
          "placement": "bottom",
          "calcs": []
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "pluginVersion": "11.5.2",
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "sum by (disposition) (rate(fak_gateway_operations_total{disposition!=\"\",verdict!=\"ALLOW\"}[5m]))",
          "legendFormat": "{{disposition}}",
          "refId": "A"
        }
      ]
    },
    {
      "type": "row",
      "title": "Cache value \u2014 what the kernel hop saved",
      "id": 99,
      "collapsed": false,
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 23
      },
      "panels": []
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "title": "Net saved (tok-equiv)",
      "description": "NET realized provider-cache saving (read rebate MINUS write premium). Negative until the reads repay a cold write. Same number as `fak vcache observe`.",
      "type": "stat",
      "id": 100,
      "gridPos": {
        "h": 4,
        "w": 4,
        "x": 0,
        "y": 24
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "red",
                "value": null
              },
              {
                "color": "green",
                "value": 0
              }
            ]
          },
          "unit": "short"
        },
        "overrides": []
      },
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "justifyMode": "auto",
        "orientation": "auto",
        "textMode": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        }
      },
      "pluginVersion": "11.5.2",
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "fak_vcache_saved_token_equiv",
          "refId": "A"
        }
      ]
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "title": "Cache multiplier",
      "description": "baseline/actual token-equiv; 1.0 = no net saving.",
      "type": "stat",
      "id": 101,
      "gridPos": {
        "h": 4,
        "w": 4,
        "x": 4,
        "y": 24
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              }
            ]
          },
          "unit": "short"
        },
        "overrides": []
      },
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "justifyMode": "auto",
        "orientation": "auto",
        "textMode": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        }
      },
      "pluginVersion": "11.5.2",
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "fak_vcache_multiplier",
          "refId": "A"
        }
      ]
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "title": "Provider hit-rate",
      "description": "cache_read share of the uncached baseline.",
      "type": "stat",
      "id": 102,
      "gridPos": {
        "h": 4,
        "w": 4,
        "x": 8,
        "y": 24
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "red",
                "value": null
              },
              {
                "color": "yellow",
                "value": 0.8
              },
              {
                "color": "green",
                "value": 0.9
              }
            ]
          },
          "unit": "percentunit"
        },
        "overrides": []
      },
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "justifyMode": "auto",
        "orientation": "auto",
        "textMode": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        }
      },
      "pluginVersion": "11.5.2",
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "fak_vcache_hit_rate",
          "refId": "A"
        }
      ]
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "title": "Repaid?",
      "description": "1 once the session's observed cache reads repaid the write premium (NET positive); else 0 (cold/write-dominated).",
      "type": "stat",
      "id": 103,
      "gridPos": {
        "h": 4,
        "w": 4,
        "x": 12,
        "y": 24
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [
            {
              "type": "value",
              "options": {
                "0": {
                  "text": "NOT YET",
                  "color": "yellow",
                  "index": 0
                },
                "1": {
                  "text": "PROVEN",
                  "color": "green",
                  "index": 1
                }
              }
            }
          ],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "red",
                "value": null
              },
              {
                "color": "green",
                "value": 1
              }
            ]
          },
          "unit": "short"
        },
        "overrides": []
      },
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "justifyMode": "auto",
        "orientation": "auto",
        "textMode": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        }
      },
      "pluginVersion": "11.5.2",
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "fak_vcache_proven",
          "refId": "A"
        }
      ]
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "title": "Provider cached tokens",
      "description": "Prompt tokens the provider served from its own cache, preserved byte-for-byte through the kernel hop.",
      "type": "stat",
      "id": 104,
      "gridPos": {
        "h": 4,
        "w": 4,
        "x": 16,
        "y": 24
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              }
            ]
          },
          "unit": "short"
        },
        "overrides": []
      },
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "justifyMode": "auto",
        "orientation": "auto",
        "textMode": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        }
      },
      "pluginVersion": "11.5.2",
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "fak_gateway_inference_cached_prompt_tokens_total or vector(0)",
          "refId": "A"
        }
      ]
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "title": "Cache writes (tok)",
      "description": "cache_creation tokens \u2014 the write premium the reads repay.",
      "type": "stat",
      "id": 105,
      "gridPos": {
        "h": 4,
        "w": 4,
        "x": 20,
        "y": 24
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              }
            ]
          },
          "unit": "short"
        },
        "overrides": []
      },
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "justifyMode": "auto",
        "orientation": "auto",
        "textMode": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        }
      },
      "pluginVersion": "11.5.2",
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "fak_vcache_cache_creation_tokens_total or vector(0)",
          "refId": "A"
        }
      ]
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "title": "Cache economics over time",
      "description": "The uncached baseline vs actual token-equiv cost and the net saving between them. Series appear once a turn carries provider cache activity.",
      "type": "timeseries",
      "id": 106,
      "gridPos": {
        "h": 8,
        "w": 24,
        "x": 0,
        "y": 28
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "drawStyle": "line",
            "lineWidth": 1,
            "fillOpacity": 10,
            "showPoints": "never",
            "axisPlacement": "auto",
            "spanNulls": true,
            "pointSize": 5,
            "stacking": {
              "mode": "none"
            }
          },
          "unit": "short",
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              }
            ]
          }
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "displayMode": "list",
          "placement": "bottom",
          "calcs": []
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "pluginVersion": "11.5.2",
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "fak_vcache_baseline_token_equiv",
          "legendFormat": "baseline (uncached)",
          "refId": "A"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "fak_vcache_actual_token_equiv",
          "legendFormat": "actual (cached)",
          "refId": "B"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "fak_vcache_saved_token_equiv",
          "legendFormat": "net saved",
          "refId": "C"
        }
      ]
    },
    {
      "type": "row",
      "title": "Token shedding \u2014 compaction & tool-floor prune",
      "id": 107,
      "collapsed": false,
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 36
      },
      "panels": []
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "title": "Compaction attempts (session)",
      "description": "fired = body rewritten with the protected prefix shipped byte-identical; bailed = returned identity; off = budget unset.",
      "type": "bargauge",
      "id": 108,
      "gridPos": {
        "h": 8,
        "w": 8,
        "x": 0,
        "y": 37
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              }
            ]
          },
          "unit": "short"
        },
        "overrides": []
      },
      "options": {
        "displayMode": "gradient",
        "orientation": "horizontal",
        "showUnfilled": true,
        "minVizHeight": 10,
        "minVizWidth": 0,
        "valueMode": "color",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        }
      },
      "pluginVersion": "11.5.2",
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "sum by (outcome) (fak_gateway_compaction_attempts_total)",
          "legendFormat": "{{outcome}}",
          "instant": true,
          "refId": "A"
        }
      ]
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "title": "Compaction bail reasons",
      "description": "Why a compaction bailed. under_budget/no_breakpoint are benign; prefix_mismatch / splice_failed / redecode_failed are the only fak-fault cache signals and must stay 0.",
      "type": "bargauge",
      "id": 109,
      "gridPos": {
        "h": 8,
        "w": 8,
        "x": 8,
        "y": 37
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 1
              }
            ]
          },
          "unit": "short"
        },
        "overrides": []
      },
      "options": {
        "displayMode": "gradient",
        "orientation": "horizontal",
        "showUnfilled": true,
        "minVizHeight": 10,
        "minVizWidth": 0,
        "valueMode": "color",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        }
      },
      "pluginVersion": "11.5.2",
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "sum by (reason) (fak_gateway_compaction_bail_reason_total)",
          "legendFormat": "{{reason}}",
          "instant": true,
          "refId": "A"
        }
      ]
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "title": "Tokens shed",
      "description": "Estimated tokens fak removed from the outbound body across all fires (what fak SENT, not a provider-billing claim).",
      "type": "stat",
      "id": 110,
      "gridPos": {
        "h": 4,
        "w": 8,
        "x": 16,
        "y": 37
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              }
            ]
          },
          "unit": "short"
        },
        "overrides": []
      },
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "justifyMode": "auto",
        "orientation": "auto",
        "textMode": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        }
      },
      "pluginVersion": "11.5.2",
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "fak_gateway_compaction_shed_tokens_total or vector(0)",
          "refId": "A"
        }
      ]
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "title": "Tool defs pruned",
      "description": "Unreachable tool definitions dropped from tools[], cache-prefix-preserving. 0 on Claude Code, whose single breakpoint sits on the LAST tool.",
      "type": "stat",
      "id": 111,
      "gridPos": {
        "h": 4,
        "w": 8,
        "x": 16,
        "y": 41
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              }
            ]
          },
          "unit": "short"
        },
        "overrides": []
      },
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "justifyMode": "auto",
        "orientation": "auto",
        "textMode": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        }
      },
      "pluginVersion": "11.5.2",
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "fak_gateway_inbound_tools_pruned_total or vector(0)",
          "refId": "A"
        }
      ]
    },
    {
      "type": "row",
      "title": "Upstream health & turns saved",
      "id": 112,
      "collapsed": false,
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 45
      },
      "panels": []
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "title": "Upstream turn failures by kind",
      "description": "Why proxied turns failed (stalled / unreachable / status_4xx / status_5xx / oom / other) \u2014 the cumulative twin of the per-turn FAILED line.",
      "type": "timeseries",
      "id": 113,
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 0,
        "y": 46
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "drawStyle": "line",
            "lineWidth": 1,
            "fillOpacity": 10,
            "showPoints": "never",
            "axisPlacement": "auto",
            "spanNulls": true,
            "pointSize": 5,
            "stacking": {
              "mode": "none"
            }
          },
          "unit": "short",
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              }
            ]
          }
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "displayMode": "list",
          "placement": "bottom",
          "calcs": []
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "pluginVersion": "11.5.2",
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "sum by (kind) (rate(fak_gateway_upstream_errors_total[5m]))",
          "legendFormat": "{{kind}}",
          "refId": "A"
        }
      ]
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "title": "Turns saved by mechanism",
      "description": "vdso_dedup = a duplicate read served with no engine round-trip; grammar_repair = a malformed call repaired instead of a retry turn.",
      "type": "bargauge",
      "id": 114,
      "gridPos": {
        "h": 8,
        "w": 8,
        "x": 12,
        "y": 46
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              }
            ]
          },
          "unit": "short"
        },
        "overrides": []
      },
      "options": {
        "displayMode": "gradient",
        "orientation": "horizontal",
        "showUnfilled": true,
        "minVizHeight": 10,
        "minVizWidth": 0,
        "valueMode": "color",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        }
      },
      "pluginVersion": "11.5.2",
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "sum by (mechanism) (fak_gateway_turns_saved_total)",
          "legendFormat": "{{mechanism}}",
          "instant": true,
          "refId": "A"
        }
      ]
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "title": "Upstream retries",
      "description": "Planner 429/5xx exponential-backoff attempts this session.",
      "type": "stat",
      "id": 115,
      "gridPos": {
        "h": 8,
        "w": 4,
        "x": 20,
        "y": 46
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              }
            ]
          },
          "unit": "short"
        },
        "overrides": []
      },
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "justifyMode": "auto",
        "orientation": "auto",
        "textMode": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        }
      },
      "pluginVersion": "11.5.2",
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "expr": "fak_gateway_upstream_retries_total or vector(0)",
          "refId": "A"
        }
      ]
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "title": "Scrape a fak guard session",
      "description": "How to point Prometheus at a guard session, and where the durable record lives.",
      "type": "text",
      "id": 116,
      "gridPos": {
        "h": 6,
        "w": 24,
        "x": 0,
        "y": 54
      },
      "fieldConfig": {
        "defaults": {},
        "overrides": []
      },
      "options": {
        "mode": "markdown",
        "content": "`fak guard` binds the same gateway `fak serve` does, on a private loopback port that is torn down when the wrapped agent exits \u2014 so to chart a session, pin the port the Prometheus `fak_gateway` job already scrapes:\n\n```\nfak guard --addr 127.0.0.1:8080 -- claude\n```\n\nEvery panel here reads `fak guard`'s live `/metrics`. The durable, hash-chained **decision journal** (`guard-audit.jsonl`, on by default) is the tamper-evident record of the same verdicts \u2014 replay it with `fak audit verify <path>`. Grafana shows the verdicts and savings; it never shows raw request bodies (use `--log FILE` for the structured per-request / per-verdict stream)."
      },
      "pluginVersion": "11.5.2"
    }
  ]
}
