{
  "$id": "https://sonny.sh/schemas/analysis.schema.json",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "additionalProperties": false,
  "description": "An analysis block, not a project document. Omitted fields inherit; null resets to built-in defaults without widening inherited policy. Run Sonny config validation for graph, duration, policy and live route admission checks.",
  "properties": {
    "access": {
      "anyOf": [
        {
          "additionalProperties": false,
          "properties": {
            "path_prefixes": {
              "anyOf": [
                {
                  "items": {
                    "type": "string"
                  },
                  "maxItems": 64,
                  "type": "array"
                },
                {
                  "type": "null"
                }
              ]
            },
            "route_classes": {
              "anyOf": [
                {
                  "items": {
                    "type": "string"
                  },
                  "maxItems": 16,
                  "type": "array"
                },
                {
                  "type": "null"
                }
              ]
            }
          },
          "type": "object"
        },
        {
          "type": "null"
        }
      ]
    },
    "budget": {
      "anyOf": [
        {
          "additionalProperties": false,
          "properties": {
            "currency": {
              "anyOf": [
                {
                  "enum": [
                    "USD"
                  ],
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            },
            "inherit_parent": {
              "anyOf": [
                {
                  "type": "boolean"
                },
                {
                  "type": "null"
                }
              ]
            },
            "priority_class": {
              "anyOf": [
                {
                  "enum": [
                    "background"
                  ],
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            },
            "request_max": {
              "anyOf": [
                {
                  "anyOf": [
                    {
                      "pattern": "^[0-9]{1,7}(\\.[0-9]{1,9})?$",
                      "type": "string"
                    },
                    {
                      "maximum": 1000000,
                      "minimum": 0,
                      "type": "number"
                    }
                  ],
                  "description": "Exact currency units with up to nine decimal places, no exponent or rounding. Canonical output is a string; the strict loader preserves numeric input lexemes.",
                  "x-max-currency-nanos": 1000000000000000,
                  "x-min-currency-nanos": 0
                },
                {
                  "type": "null"
                }
              ]
            },
            "session_max": {
              "anyOf": [
                {
                  "anyOf": [
                    {
                      "pattern": "^[0-9]{1,7}(\\.[0-9]{1,9})?$",
                      "type": "string"
                    },
                    {
                      "maximum": 1000000,
                      "minimum": 0,
                      "type": "number"
                    }
                  ],
                  "description": "Exact currency units with up to nine decimal places, no exponent or rounding. Canonical output is a string; the strict loader preserves numeric input lexemes.",
                  "x-max-currency-nanos": 1000000000000000,
                  "x-min-currency-nanos": 0
                },
                {
                  "type": "null"
                }
              ]
            }
          },
          "type": "object"
        },
        {
          "type": "null"
        }
      ]
    },
    "cache": {
      "anyOf": [
        {
          "additionalProperties": false,
          "properties": {
            "compiled_prefix": {
              "anyOf": [
                {
                  "type": "boolean"
                },
                {
                  "type": "null"
                }
              ]
            },
            "exact_results": {
              "anyOf": [
                {
                  "type": "boolean"
                },
                {
                  "type": "null"
                }
              ]
            },
            "idle_warmup": {
              "anyOf": [
                {
                  "type": "boolean"
                },
                {
                  "type": "null"
                }
              ]
            },
            "max_bytes": {
              "anyOf": [
                {
                  "maximum": 1073741824,
                  "minimum": 0,
                  "type": "integer"
                },
                {
                  "type": "null"
                }
              ]
            },
            "namespace": {
              "anyOf": [
                {
                  "enum": [
                    "authorized_scope"
                  ],
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            },
            "provider_prefix": {
              "anyOf": [
                {
                  "enum": [
                    "auto",
                    "off"
                  ],
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            },
            "ttl": {
              "anyOf": [
                {
                  "description": "Explicit duration (Go units or whole days), subject to field bounds; zero is 0s.",
                  "maxLength": 64,
                  "minLength": 1,
                  "type": "string",
                  "x-max-nanoseconds": 86400000000000,
                  "x-min-nanoseconds": 1
                },
                {
                  "type": "null"
                }
              ]
            }
          },
          "type": "object"
        },
        {
          "type": "null"
        }
      ]
    },
    "enabled": {
      "anyOf": [
        {
          "type": "boolean"
        },
        {
          "type": "null"
        }
      ]
    },
    "feedback": {
      "anyOf": [
        {
          "enum": [
            "shadow",
            "advisory",
            "enforced"
          ],
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "feedback_limits": {
      "anyOf": [
        {
          "additionalProperties": false,
          "properties": {
            "checkpoint": {
              "anyOf": [
                {
                  "enum": [
                    "next_safe_boundary"
                  ],
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            },
            "max_findings_per_delivery": {
              "anyOf": [
                {
                  "maximum": 100,
                  "minimum": 0,
                  "type": "integer"
                },
                {
                  "type": "null"
                }
              ]
            },
            "max_summary_tokens": {
              "anyOf": [
                {
                  "maximum": 16384,
                  "minimum": 0,
                  "type": "integer"
                },
                {
                  "type": "null"
                }
              ]
            },
            "minimum_severity": {
              "anyOf": [
                {
                  "enum": [
                    "info",
                    "low",
                    "medium",
                    "high",
                    "critical"
                  ],
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            },
            "parent_delivery": {
              "anyOf": [
                {
                  "enum": [
                    "summary",
                    "none"
                  ],
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            }
          },
          "type": "object"
        },
        {
          "type": "null"
        }
      ]
    },
    "lifecycle": {
      "anyOf": [
        {
          "enum": [
            "session"
          ],
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "limits": {
      "anyOf": [
        {
          "additionalProperties": false,
          "properties": {
            "drain_timeout": {
              "anyOf": [
                {
                  "description": "Explicit duration (Go units or whole days), subject to field bounds; zero is 0s.",
                  "maxLength": 64,
                  "minLength": 1,
                  "type": "string",
                  "x-max-nanoseconds": 300000000000,
                  "x-min-nanoseconds": 1
                },
                {
                  "type": "null"
                }
              ]
            },
            "max_attempts": {
              "anyOf": [
                {
                  "maximum": 5,
                  "minimum": 1,
                  "type": "integer"
                },
                {
                  "type": "null"
                }
              ]
            },
            "max_calls_per_critic": {
              "anyOf": [
                {
                  "maximum": 64,
                  "minimum": 1,
                  "type": "integer"
                },
                {
                  "type": "null"
                }
              ]
            },
            "max_concurrent_calls": {
              "anyOf": [
                {
                  "maximum": 256,
                  "minimum": 1,
                  "type": "integer"
                },
                {
                  "type": "null"
                }
              ]
            },
            "max_concurrent_requests": {
              "anyOf": [
                {
                  "maximum": 256,
                  "minimum": 1,
                  "type": "integer"
                },
                {
                  "type": "null"
                }
              ]
            },
            "max_context_expansions": {
              "anyOf": [
                {
                  "maximum": 4,
                  "minimum": 0,
                  "type": "integer"
                },
                {
                  "type": "null"
                }
              ]
            },
            "max_cycle_depth": {
              "anyOf": [
                {
                  "maximum": 16,
                  "minimum": 0,
                  "type": "integer"
                },
                {
                  "type": "null"
                }
              ]
            },
            "max_files_per_snapshot": {
              "anyOf": [
                {
                  "maximum": 4096,
                  "minimum": 1,
                  "type": "integer"
                },
                {
                  "type": "null"
                }
              ]
            },
            "max_inflight_bytes": {
              "anyOf": [
                {
                  "maximum": 1073741824,
                  "minimum": 1,
                  "type": "integer"
                },
                {
                  "type": "null"
                }
              ]
            },
            "max_input_tokens_per_call": {
              "anyOf": [
                {
                  "maximum": 1048576,
                  "minimum": 1,
                  "type": "integer"
                },
                {
                  "type": "null"
                }
              ]
            },
            "max_output_tokens_per_call": {
              "anyOf": [
                {
                  "maximum": 65536,
                  "minimum": 1,
                  "type": "integer"
                },
                {
                  "type": "null"
                }
              ]
            },
            "max_partitions_per_request": {
              "anyOf": [
                {
                  "maximum": 128,
                  "minimum": 1,
                  "type": "integer"
                },
                {
                  "type": "null"
                }
              ]
            },
            "max_queued_bytes": {
              "anyOf": [
                {
                  "maximum": 1073741824,
                  "minimum": 1,
                  "type": "integer"
                },
                {
                  "type": "null"
                }
              ]
            },
            "max_queued_requests": {
              "anyOf": [
                {
                  "maximum": 65536,
                  "minimum": 1,
                  "type": "integer"
                },
                {
                  "type": "null"
                }
              ]
            },
            "max_snapshot_bytes": {
              "anyOf": [
                {
                  "maximum": 16777216,
                  "minimum": 1,
                  "type": "integer"
                },
                {
                  "type": "null"
                }
              ]
            },
            "max_total_tokens_per_request": {
              "anyOf": [
                {
                  "maximum": 16777216,
                  "minimum": 1,
                  "type": "integer"
                },
                {
                  "type": "null"
                }
              ]
            },
            "request_timeout": {
              "anyOf": [
                {
                  "description": "Explicit duration (Go units or whole days), subject to field bounds; zero is 0s.",
                  "maxLength": 64,
                  "minLength": 1,
                  "type": "string",
                  "x-max-nanoseconds": 3600000000000,
                  "x-min-nanoseconds": 1
                },
                {
                  "type": "null"
                }
              ]
            }
          },
          "type": "object"
        },
        {
          "type": "null"
        }
      ]
    },
    "mode": {
      "anyOf": [
        {
          "enum": [
            "full",
            "pass_through",
            "short_circuit"
          ],
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "pipelines": {
      "anyOf": [
        {
          "items": {
            "additionalProperties": false,
            "properties": {
              "aggregate": {
                "additionalProperties": false,
                "properties": {
                  "cancel_optional_on_trigger": {
                    "type": "boolean"
                  },
                  "early_notify_severity": {
                    "enum": [
                      "info",
                      "low",
                      "medium",
                      "high",
                      "critical"
                    ],
                    "type": "string"
                  },
                  "policy": {
                    "enum": [
                      "all",
                      "first_actionable",
                      "quorum"
                    ],
                    "type": "string"
                  },
                  "quorum": {
                    "maximum": 64,
                    "minimum": 0,
                    "type": "integer"
                  }
                },
                "required": [
                  "policy",
                  "early_notify_severity"
                ],
                "type": "object"
              },
              "id": {
                "maxLength": 128,
                "minLength": 1,
                "type": "string"
              },
              "nodes": {
                "items": {
                  "additionalProperties": false,
                  "properties": {
                    "critic_id": {
                      "maxLength": 128,
                      "type": "string"
                    },
                    "depends_on": {
                      "items": {
                        "type": "string"
                      },
                      "maxItems": 64,
                      "type": "array"
                    },
                    "id": {
                      "maxLength": 128,
                      "minLength": 1,
                      "type": "string"
                    },
                    "kind": {
                      "enum": [
                        "deterministic_filter",
                        "critic"
                      ],
                      "type": "string"
                    },
                    "missing_metadata": {
                      "enum": [
                        "not_applicable",
                        "needs_context"
                      ],
                      "type": "string"
                    },
                    "pack_ref": {
                      "maxLength": 128,
                      "type": "string"
                    },
                    "path_regex": {
                      "maxLength": 1024,
                      "type": "string"
                    },
                    "required": {
                      "type": "boolean"
                    },
                    "rules": {
                      "items": {
                        "type": "string"
                      },
                      "maxItems": 16,
                      "type": "array"
                    }
                  },
                  "required": [
                    "id",
                    "kind"
                  ],
                  "type": "object"
                },
                "maxItems": 64,
                "type": "array"
              },
              "partition": {
                "additionalProperties": false,
                "properties": {
                  "kind": {
                    "enum": [
                      "changed_symbols",
                      "changed_files",
                      "document_sections"
                    ],
                    "type": "string"
                  },
                  "overflow": {
                    "enum": [
                      "needs_context",
                      "reject"
                    ],
                    "type": "string"
                  },
                  "supporting_context": {
                    "enum": [
                      "direct_dependencies",
                      "none"
                    ],
                    "type": "string"
                  }
                },
                "required": [
                  "kind",
                  "supporting_context",
                  "overflow"
                ],
                "type": "object"
              },
              "sinks": {
                "items": {
                  "additionalProperties": false,
                  "properties": {
                    "kind": {
                      "enum": [
                        "findings_store",
                        "agent_feedback",
                        "eval_candidates",
                        "background_optimizer"
                      ],
                      "type": "string"
                    },
                    "promotion": {
                      "enum": [
                        "review_required"
                      ],
                      "type": "string"
                    }
                  },
                  "required": [
                    "kind"
                  ],
                  "type": "object"
                },
                "maxItems": 16,
                "minItems": 1,
                "type": "array"
              },
              "sources": {
                "items": {
                  "additionalProperties": false,
                  "properties": {
                    "changed_only": {
                      "type": "boolean"
                    },
                    "event": {
                      "enum": [
                        "tool_effect",
                        "code_changed",
                        "document_changed",
                        "requirements_changed",
                        "plan_changed",
                        "diagnostics_complete",
                        "test_complete",
                        "agent_checkpoint",
                        "subagent_checkpoint",
                        "explicit_request",
                        "timer"
                      ],
                      "type": "string"
                    },
                    "interval": {
                      "description": "Explicit duration (Go units or whole days), subject to field bounds; zero is 0s.",
                      "maxLength": 64,
                      "minLength": 1,
                      "type": "string",
                      "x-max-nanoseconds": 86400000000000,
                      "x-min-nanoseconds": 0
                    },
                    "jitter": {
                      "description": "Explicit duration (Go units or whole days), subject to field bounds; zero is 0s.",
                      "maxLength": 64,
                      "minLength": 1,
                      "type": "string",
                      "x-max-nanoseconds": 86400000000000,
                      "x-min-nanoseconds": 0
                    },
                    "last_reviewed_subject": {
                      "maxLength": 128,
                      "type": "string"
                    },
                    "min_interval": {
                      "description": "Explicit duration (Go units or whole days), subject to field bounds; zero is 0s.",
                      "maxLength": 64,
                      "minLength": 1,
                      "type": "string",
                      "x-max-nanoseconds": 86400000000000,
                      "x-min-nanoseconds": 0
                    }
                  },
                  "required": [
                    "event"
                  ],
                  "type": "object"
                },
                "maxItems": 32,
                "minItems": 1,
                "type": "array"
              }
            },
            "required": [
              "id",
              "sources",
              "partition",
              "nodes",
              "aggregate",
              "sinks"
            ],
            "type": "object"
          },
          "maxItems": 16,
          "type": "array"
        },
        {
          "type": "null"
        }
      ]
    },
    "queue": {
      "anyOf": [
        {
          "additionalProperties": false,
          "properties": {
            "coalesce": {
              "anyOf": [
                {
                  "enum": [
                    "changed_subject",
                    "none"
                  ],
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            },
            "debounce": {
              "anyOf": [
                {
                  "description": "Explicit duration (Go units or whole days), subject to field bounds; zero is 0s.",
                  "maxLength": 64,
                  "minLength": 1,
                  "type": "string",
                  "x-max-nanoseconds": 60000000000,
                  "x-min-nanoseconds": 0
                },
                {
                  "type": "null"
                }
              ]
            },
            "max_debounce": {
              "anyOf": [
                {
                  "description": "Explicit duration (Go units or whole days), subject to field bounds; zero is 0s.",
                  "maxLength": 64,
                  "minLength": 1,
                  "type": "string",
                  "x-max-nanoseconds": 60000000000,
                  "x-min-nanoseconds": 0
                },
                {
                  "type": "null"
                }
              ]
            },
            "overflow": {
              "anyOf": [
                {
                  "enum": [
                    "reject",
                    "supersede_redundant"
                  ],
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            }
          },
          "type": "object"
        },
        {
          "type": "null"
        }
      ]
    },
    "storage": {
      "anyOf": [
        {
          "additionalProperties": false,
          "properties": {
            "journal": {
              "anyOf": [
                {
                  "enum": [
                    "runtime"
                  ],
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            },
            "remote_export": {
              "anyOf": [
                {
                  "type": "boolean"
                },
                {
                  "type": "null"
                }
              ]
            },
            "result_retention": {
              "anyOf": [
                {
                  "description": "Explicit duration (Go units or whole days), subject to field bounds; zero is 0s.",
                  "maxLength": 64,
                  "minLength": 1,
                  "type": "string",
                  "x-max-nanoseconds": 2592000000000000,
                  "x-min-nanoseconds": 1
                },
                {
                  "type": "null"
                }
              ]
            },
            "snapshot_retention": {
              "anyOf": [
                {
                  "description": "Explicit duration (Go units or whole days), subject to field bounds; zero is 0s.",
                  "maxLength": 64,
                  "minLength": 1,
                  "type": "string",
                  "x-max-nanoseconds": 604800000000000,
                  "x-min-nanoseconds": 1
                },
                {
                  "type": "null"
                }
              ]
            }
          },
          "type": "object"
        },
        {
          "type": "null"
        }
      ]
    },
    "strategy": {
      "anyOf": [
        {
          "enum": [
            "sequential",
            "pipelined"
          ],
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "version": {
      "maximum": 1,
      "minimum": 1,
      "type": "integer"
    }
  },
  "required": [
    "version"
  ],
  "title": "Sonny analysis configuration version 1",
  "type": "object"
}
