mirror of
https://github.com/hanzoai/insights.git
synced 2026-10-30 16:15:31 +00:00
The tree was a debranded snapshot of upstream taken around 2026-02-20, and upstream has moved about five months since. This replaces it with upstream master, mechanically re-derived: bin/debrand does the rename, and the pipeline and squashed migrations are restored from the shipped tree. Not a merge. The previous import replaced the tree wholesale in a single commit, so there is no shared content history to merge against. Reproducing the rename on the new tree is what actually converges. What survives: .hanzo/workflows, the Dockerfiles and bin/docker* entrypoints, compose files, LLM.md, and insights/migrations. The squashed initial migration is load-bearing — the live database records it by name, so upstream's ~918 individual migrations cannot come back. Nine products are dropped as unreferenced. Twenty-one more that we do not run are kept anyway because the core app still imports them; unpicking those is a refactor and does not belong in a rebase. This base does not build yet, and the reasons are not in the rename: upstream now wants Python 3.13.13 against our 3.12.12 and Django 5.2 against our 4.2, and the dependency manifests still name upstream packages that we republish under our own names. Those are decisions, not renames.
104 lines
3.1 KiB
Python
104 lines
3.1 KiB
Python
"""
|
|
Facade contracts (DTOs) for experiments product.
|
|
|
|
These are framework-free frozen dataclasses that define the interface
|
|
between the experiments product and the rest of the system.
|
|
"""
|
|
|
|
from dataclasses import dataclass
|
|
from datetime import datetime
|
|
from typing import Any
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class CreateExperimentInput:
|
|
"""
|
|
Input for creating an experiment.
|
|
|
|
Note: This class is NOT hashable when dict/list fields are non-None due to
|
|
mutable types. Use only immutable fields if hashability is required.
|
|
"""
|
|
|
|
# Required fields
|
|
name: str
|
|
feature_flag_key: str
|
|
|
|
# Optional basic fields
|
|
description: str = ""
|
|
type: str = "product"
|
|
|
|
# Experiment-own parameters (variant_notes, custom_exposure_filter, prompt_metadata, ...).
|
|
# Flag config is NOT accepted here — it goes through feature_flag_config below.
|
|
parameters: dict[str, Any] | None = None
|
|
|
|
# Feature flag configuration in the flag's own write shape:
|
|
# {filters: {multivariate, groups, aggregation_group_type_index, payloads}, ensure_experience_continuity}
|
|
feature_flag_config: dict[str, Any] | None = None
|
|
|
|
# Running-time calculator state (minimum_detectable_effect, recommended_running_time,
|
|
# recommended_sample_size, exposure_estimate_config)
|
|
running_time_calculation: dict[str, Any] | None = None
|
|
|
|
# Variant keys dropped from statistical analysis
|
|
excluded_variants: list[str] | None = None
|
|
|
|
# Metrics configuration
|
|
metrics: list[dict] | None = None
|
|
metrics_secondary: list[dict] | None = None
|
|
secondary_metrics: list[dict] | None = None
|
|
metrics_ordering: tuple[str, ...] | None = None # primary_metrics_ordered_uuids
|
|
secondary_metrics_ordering: tuple[str, ...] | None = None # secondary_metrics_ordered_uuids
|
|
saved_metrics_ids: list[dict] | None = None
|
|
|
|
# Statistics and exposure configuration
|
|
stats_config: dict | None = None
|
|
exposure_criteria: dict | None = None
|
|
only_count_matured_users: bool | None = None
|
|
|
|
# Experiment lifecycle
|
|
start_date: datetime | None = None
|
|
end_date: datetime | None = None
|
|
archived: bool = False
|
|
deleted: bool = False
|
|
conclusion: str | None = None
|
|
conclusion_comment: str | None = None
|
|
# GitHub repo (`org/repo`) targeted by the flag-cleanup PR on experiment end
|
|
repository: str | None = None
|
|
|
|
# Advanced configuration
|
|
holdout_id: int | None = None # We'll pass ID, facade will load the model
|
|
filters: dict | None = None
|
|
scheduling_config: dict | None = None
|
|
create_in_folder: str | None = None
|
|
|
|
# Internal flags
|
|
allow_unknown_events: bool = False
|
|
serializer_context: dict | None = None
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class FeatureFlag:
|
|
"""Feature flag output."""
|
|
|
|
id: int
|
|
key: str
|
|
active: bool
|
|
created_at: datetime
|
|
name: str | None = None
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class Experiment:
|
|
"""Experiment output."""
|
|
|
|
id: int
|
|
name: str
|
|
feature_flag_id: int
|
|
feature_flag_key: str
|
|
is_draft: bool
|
|
created_at: datetime
|
|
description: str | None = None
|
|
start_date: datetime | None = None
|
|
end_date: datetime | None = None
|
|
updated_at: datetime | None = None
|