# Generated by Django 5.2.7 on 2026-02-15 16:55

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ('core', '0023_message_delivered_ts_message_read_by_identifier_and_more'),
    ]

    operations = [
        migrations.CreateModel(
            name='WorkspaceMetricSnapshot',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('computed_at', models.DateTimeField(auto_now_add=True, db_index=True, help_text='When this snapshot was persisted.')),
                ('source_event_ts', models.BigIntegerField(blank=True, help_text='Latest message timestamp used during this metric computation.', null=True)),
                ('stability_state', models.CharField(choices=[('calibrating', 'Calibrating'), ('stable', 'Stable'), ('watch', 'Watch'), ('fragile', 'Fragile')], default='calibrating', help_text='Stability state at computation time.', max_length=32)),
                ('stability_score', models.FloatField(blank=True, help_text='Stability score (0-100).', null=True)),
                ('stability_confidence', models.FloatField(default=0.0, help_text='Confidence in stability score (0.0-1.0).')),
                ('stability_sample_messages', models.PositiveIntegerField(default=0, help_text='How many messages were in the sampled window.')),
                ('stability_sample_days', models.PositiveIntegerField(default=0, help_text='How many days were in the sampled window.')),
                ('commitment_inbound_score', models.FloatField(blank=True, help_text='Commitment estimate counterpart -> user (0-100).', null=True)),
                ('commitment_outbound_score', models.FloatField(blank=True, help_text='Commitment estimate user -> counterpart (0-100).', null=True)),
                ('commitment_confidence', models.FloatField(default=0.0, help_text='Confidence in commitment scores (0.0-1.0).')),
                ('inbound_messages', models.PositiveIntegerField(default=0, help_text='Inbound message count in the sampled window.')),
                ('outbound_messages', models.PositiveIntegerField(default=0, help_text='Outbound message count in the sampled window.')),
                ('reciprocity_score', models.FloatField(blank=True, help_text='Balance component used for stability.', null=True)),
                ('continuity_score', models.FloatField(blank=True, help_text='Continuity component used for stability.', null=True)),
                ('response_score', models.FloatField(blank=True, help_text='Response-time component used for stability.', null=True)),
                ('volatility_score', models.FloatField(blank=True, help_text='Volatility component used for stability.', null=True)),
                ('inbound_response_score', models.FloatField(blank=True, help_text='Inbound response-lag score used for commitment.', null=True)),
                ('outbound_response_score', models.FloatField(blank=True, help_text='Outbound response-lag score used for commitment.', null=True)),
                ('balance_inbound_score', models.FloatField(blank=True, help_text='Inbound balance score used for commitment.', null=True)),
                ('balance_outbound_score', models.FloatField(blank=True, help_text='Outbound balance score used for commitment.', null=True)),
                ('conversation', models.ForeignKey(help_text='Workspace conversation this metric snapshot belongs to.', on_delete=django.db.models.deletion.CASCADE, related_name='metric_snapshots', to='core.workspaceconversation')),
            ],
            options={
                'ordering': ('-computed_at',),
                'indexes': [models.Index(fields=['conversation', 'computed_at'], name='core_worksp_convers_4ee793_idx')],
            },
        ),
    ]
