# Generated by Django 5.2 on 2025-11-07 00:43

import django.core.validators
from decimal import Decimal
from django.db import migrations, models


def seed_config(apps, schema_editor):
    DailyCreditConfig = apps.get_model('api', 'DailyCreditConfig')
    if not DailyCreditConfig.objects.exists():
        DailyCreditConfig.objects.create(
            slider_min=Decimal('0'),
            slider_max=Decimal('50'),
            slider_step=Decimal('1'),
            burn_rate_threshold_per_hour=Decimal('3'),
            burn_rate_window_minutes=60,
            hard_limit_multiplier=Decimal('2'),
        )


class Migration(migrations.Migration):

    dependencies = [
        ('api', '0181_persistentagent_daily_credit_soft_target'),
    ]

    operations = [
        migrations.CreateModel(
            name='DailyCreditConfig',
            fields=[
                ('singleton_id', models.PositiveSmallIntegerField(default=1, editable=False, primary_key=True, serialize=False)),
                ('slider_min', models.DecimalField(decimal_places=2, default=Decimal('0'), help_text='Lowest selectable soft target value.', max_digits=12, validators=[django.core.validators.MinValueValidator(Decimal('0'))])),
                ('slider_max', models.DecimalField(decimal_places=2, default=Decimal('50'), help_text='Highest selectable soft target value.', max_digits=12, validators=[django.core.validators.MinValueValidator(Decimal('0'))])),
                ('slider_step', models.DecimalField(decimal_places=2, default=Decimal('1'), help_text='Increment applied to the soft target slider/input.', max_digits=6, validators=[django.core.validators.MinValueValidator(Decimal('0.01'))])),
                ('burn_rate_threshold_per_hour', models.DecimalField(decimal_places=3, default=Decimal('3'), help_text='Preferred maximum credits consumed per hour before agents are asked to slow down.', max_digits=12, validators=[django.core.validators.MinValueValidator(Decimal('0'))])),
                ('burn_rate_window_minutes', models.PositiveIntegerField(default=60, help_text='Window (in minutes) used to compute the rolling burn rate.', validators=[django.core.validators.MinValueValidator(1), django.core.validators.MaxValueValidator(1440)])),
                ('hard_limit_multiplier', models.DecimalField(decimal_places=2, default=Decimal('2'), help_text='Multiplier applied to the soft target to derive the enforced hard limit.', max_digits=6, validators=[django.core.validators.MinValueValidator(Decimal('1'))])),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
            ],
            options={
                'verbose_name': 'Daily credit pacing configuration',
                'verbose_name_plural': 'Daily credit pacing configuration',
            },
        ),
        migrations.RunPython(seed_config, migrations.RunPython.noop),
    ]
