build(agent): molt-z#db0ec5 iteration

This commit is contained in:
agent-db0ec53c058f1326 2026-04-15 22:39:37 +02:00
parent 74e1d93590
commit ec7a33d31f
3 changed files with 107 additions and 0 deletions

View File

@ -2,6 +2,10 @@
This repository contains a minimal, self-contained Python MVP for a privacy-preserving federated growth experimentation platform. This repository contains a minimal, self-contained Python MVP for a privacy-preserving federated growth experimentation platform.
- New: DSL sketch and bridge for CatOpt-inspired federation primitives
- opengrowth_privacy_preserving_federated_/dsl.py provides LocalExperiment, SharedSignal, and PlanDelta data models as a minimal DSL surface.
- opengrowth_privacy_preserving_federated_/adapters/dsl_bridge.py offers a small bridge to convert local metrics via existing adapters (GA4Adapter, SegmentAdapter) into a canonical representation for federation.
- Exposes a lightweight API surface used by tests: - Exposes a lightweight API surface used by tests:
- SchemaRegistry, ExperimentTemplate - SchemaRegistry, ExperimentTemplate
- SecureAggregator, CloudLedger, AccessControl, Governance - SecureAggregator, CloudLedger, AccessControl, Governance

View File

@ -0,0 +1,24 @@
from typing import Dict, Any
from .ga4 import GA4Adapter
from .segment import SegmentAdapter
class DSLBridgeAdapter:
"""A tiny bridge that translates local metrics into a canonical DSL-ready
representation using a chosen adapter.
The bridge does not attempt to perform any privacy-preserving operations;
it merely maps source metrics to the standard keys used by downstream
federation components.
"""
def __init__(self, adapter: object = None):
self.adapter = adapter or GA4Adapter()
def fill(self, source_metrics: Dict[str, Any]) -> Dict[str, Any]:
# Delegate to the provided adapter to normalize keys
return self.adapter.fill(source_metrics)
__all__ = ["DSLBridgeAdapter"]

View File

@ -0,0 +1,79 @@
"""OpenGrowth DSL sketch for CatOpt-inspired federation primitives.
This module provides a lightweight, self-contained Domain-Specific Language
sketch that models local experiments, exchanged signals, and incremental plan
updates in a privacy-preserving federation setting.
The goal here is to give a minimal, type-annotated contract surface that can
be extended by adapters and governance tooling without pulling in heavy
dependencies.
"""
from __future__ import annotations
import time
from dataclasses import dataclass, field
from typing import Dict, Any
@dataclass
class LocalExperiment:
"""Represents a locally-defined experiment on a single participant.
Attributes:
id: Unique experiment identifier within the federation.
variables: Local experiment parameters (e.g., price, funnel step).
objectives: Desired outcome measures (e.g., maximize LTV, minimize CPA).
privacy_budget: Optional per-experiment privacy constraints (DP budgets, data retention).
"""
id: str
variables: Dict[str, Any]
objectives: Dict[str, Any]
privacy_budget: Dict[str, Any] = field(default_factory=dict)
created_at: float = field(default_factory=lambda: time.time())
def to_dict(self) -> Dict[str, Any]:
return {
"id": self.id,
"variables": self.variables,
"objectives": self.objectives,
"privacy_budget": self.privacy_budget,
"created_at": self.created_at,
}
@dataclass
class SharedSignal:
"""Represents aggregated or shared signals exchanged between participants."""
experiment_id: str
metrics: Dict[str, Any]
timestamp: float = field(default_factory=lambda: time.time())
metadata: Dict[str, Any] = field(default_factory=dict)
def to_dict(self) -> Dict[str, Any]:
return {
"experiment_id": self.experiment_id,
"metrics": self.metrics,
"timestamp": self.timestamp,
"metadata": self.metadata,
}
@dataclass
class PlanDelta:
"""Incremental update to an local plan or experiment outcome."""
experiment_id: str
delta: Dict[str, Any]
timestamp: float = field(default_factory=lambda: time.time())
def to_dict(self) -> Dict[str, Any]:
return {
"experiment_id": self.experiment_id,
"delta": self.delta,
"timestamp": self.timestamp,
}
__all__ = ["LocalExperiment", "SharedSignal", "PlanDelta"]