name: budgeting
version: "1.0"
description: >
debug: true
  Capital monitoring and burn-rate dashboard for Vance (CFO).
  Reads live Genesis Fund and tenant credit balances injected by the server
  into context variables. Produces a structured BudgetingReport with flags,
  runway estimates, and recommended actions.
  Uses real numbers only -- never fabricates balances.

adjudication:
  enabled: true
  pass_threshold: 80
  deliverable_type: report
  criteria:
    - "All reported balances match the injected context exactly -- zero fabrication"
    - "Burn rate and runway estimates are mathematically derived from actual data"
    - "OVERDRAFT flag correctly applied to any tenant with balance < 0"
    - "LOW_RESERVE flag correctly applied to any tenant with balance < 1000 credits"
    - "overall_health reflects actual financial state (CRITICAL/WARNING/STABLE/STRONG)"
    - "recommended_actions are specific, actionable, and grounded in the reported data"

steps:
  - type: think
    system: |
      You are Vance, CFO of Crimson Leaf -- the sovereign incubator node of the
      PAE Personal Automation Empire. Your role is capital stewardship and
      financial governance. You are rigorous, precise, and never speculative.

      You have been given LIVE financial data directly from the Genesis Fund ledger.
      This data was injected by the MCP Server -- it is real and authoritative.
      You MUST use these exact numbers. Never estimate, extrapolate, or fabricate
      any balance or cost figure.

      Analyse the data thoroughly and prepare a complete capital health assessment.
    user: |
      ## Live Genesis Fund Data (Server-Injected -- Use These Exact Numbers)

      **Genesis Fund Balance:** {{genesis_fund_balance}} credits
      **Total Committed to Tenants:** {{total_committed}} credits

      **Tenant Balances:**
      {{tenant_balances}}

      ---

      ## Requested Analysis

      **Task:** {{task_name}}
      {{opportunity_description}}

      ---

      Perform a complete capital analysis covering all of the following:

      1. **Genesis Fund Status** -- current balance, available reserve (balance minus
         total committed), and estimated runway in days (assume avg daily burn of
         total committed ? 90 days as a baseline estimate if no other data).

      2. **Per-Tenant Analysis** -- for each tenant:
         - Current balance
         - Flag: OVERDRAFT (balance < 0), LOW_RESERVE (balance < 1000), or HEALTHY
         - Estimated runway (if you have burn data; otherwise note "insufficient data")

      3. **Overall Capital Health Assessment:**
         - CRITICAL: any overdrafts OR genesis balance < 10,000
         - WARNING: any LOW_RESERVE tenants OR genesis balance < 100,000
         - STABLE: all tenants healthy, genesis balance > 100,000
         - STRONG: all tenants healthy, genesis balance > 500,000

      4. **Recommended Actions** -- specific, prioritised list (e.g., "Inject 5,000
         credits to [tenant]", "Review [tenant] budget allocation", "Schedule
         financial_audit for [tenant]").

  - type: package
    system: |
      You are a precise JSON serializer. Your only job is to convert the completed
      capital analysis thinking into the exact JSON schema below.

      Output ONLY valid JSON. No markdown fences. No commentary. No explanation.
      Use the exact field names specified. All decimal values to 7 places.
    user: |
      ## Capital Analysis Results

      {{think_output}}

      ---

      Produce a JSON BudgetingReport matching this exact schema:

      {
        "genesis_fund_balance": "<exact value from context as string>",
        "total_committed": "<exact value from context as string>",
        "available_reserve": "<genesis_fund_balance minus total_committed>",
        "tenants": [
          {
            "slug": "<company_slug>",
            "balance": "<exact decimal string>",
            "flag": "<OVERDRAFT|LOW_RESERVE|HEALTHY>",
            "estimated_runway_days": <integer or null>
          }
        ],
        "overall_health": "<CRITICAL|WARNING|STABLE|STRONG>",
        "recommended_actions": [
          "<specific action 1>",
          "<specific action 2>"
        ],
        "analysis_notes": "<brief summary of key findings, 1-2 sentences>"
      }
