# rye:signed:2026-04-10T04:15:33Z:e5d604f2b2f1f663f11005fd05eb98b096b73084a16a8b965baf59d749176fd1:Mhl3mmnhsBCrSTaL5CToPFeSmT2ItEPUb-i7XMYhcWrOlol7DgraZkVQus8nVIiB-45D0zRx8oMvW7bcnbQ6Bg:6ea18199041a1ea8
# config/budget_ledger_schema.yaml
category: "agent"
tool_type: "config"
version: "1.0.0"
description: "Schema definition for the budget ledger table used to track thread spending"
schema_version: "1.0.0"

table:
  name: "budget_ledger"
  columns:
    - name: thread_id
      type: TEXT
      primary_key: true

    - name: parent_thread_id
      type: TEXT
      nullable: true

    - name: reserved_spend
      type: REAL
      default: 0.0

    - name: actual_spend
      type: REAL
      default: 0.0

    - name: max_spend
      type: REAL
      nullable: true

    - name: status
      type: TEXT
      default: "active"

    - name: created_at
      type: TEXT

    - name: updated_at
      type: TEXT

  indexes:
    - name: idx_budget_parent
      columns: [parent_thread_id]
    - name: idx_budget_status
      columns: [status]

operations:
  reserve:
    isolation: "IMMEDIATE"
    check_remaining: true

  report_actual:
    clamp_to_reserved: true

  release:
    on_status: ["completed", "cancelled", "error"]

cleanup:
  archive_after_days: 30
  vacuum_interval_days: 7
