Source identity
| Field | Recorded value |
|---|---|
| Source type | GitHub source |
| Original record | Janady13/AI_Brain / services/seeder_api/app.py |
| Date | Not specified in source |
| Repository | Janady13/AI_Brain |
| Revision | 50285aff347685f043e7a72e4d72891eebaa6cd6 |
| Branch | codex/build-online-github-ani-hrtsoc |
| Path or archive member | services/seeder_api/app.py |
| Original SHA-256 | 0992fad4a9c91564f2146e306aec9950a7f90d05fc5d1ba0920799f40e735590 |
| Git blob SHA | 1d6ff6815eb8282d800c9ac5be332cd4947dedd4 |
| Reading-copy SHA-256 | 0992fad4a9c91564f2146e306aec9950a7f90d05fc5d1ba0920799f40e735590 |
Every recorded occurrence
These 3 records contain identical original source bytes. Their paths and revisions remain part of the archive.
| Original record | Branch or archive | Revision / identifier | Original location |
|---|---|---|---|
| Janady13/AI_Brain / services/seeder_api/app.py | codex/build-online-github-ani-hrtsoc | 50285aff347685f043e7a72e4d72891eebaa6cd6 | Open original |
| Janady13/AI_Brain / services/seeder_api/app.py | copilot/vscode1760283895982 | 9e1c1a5b171addb5bb4a83b2ea7dede50c1cc81e | Open original |
| Janady13/AI_Brain / services/seeder_api/app.py | codex/build-online-github-ani-hrtsoc | 50285aff347685f043e7a72e4d72891eebaa6cd6 | Open original |
Recovered source transcript
Download complete source text ↓1,725 lines · 55.4 KB
#!/usr/bin/env python3
import os
import time
from fastapi import FastAPI
from pydantic import BaseModel
from .intelligence import (
AmazonProductRecommendation,
AWSRevenueRecommendation,
AutomationSprint,
AutomationTask,
BudgetPlan,
CampaignMetrics,
CampaignScore,
CJAffiliateRecommendation,
CryptoMarketSnapshot,
CognitiveCapabilityPlan,
AgenticSystemPlan,
EbayRevenuePlay,
GrowthExperiment,
GoogleCampaignPerformance,
CompetitiveSignal,
InfluencerRecommendation,
LearningLoopRecommendation,
ExcellenceSummary,
ExecutivePlaybook,
StrategicDirective,
ScenarioAnalysis,
ScenarioProjection,
StockMarketForecast,
StatisticalReasoningSummary,
StatisticalEvidence,
MarketingIntelligenceEngine,
MarketingCampaign,
PromptDiagnostics,
StripeMonetizationPlan,
PayPalMonetizationPlan,
PaymentIntegrationPlan,
InvestingPlan,
KnowledgeWorkflowPlan,
LanguageCapabilityPlan,
CodeAutomationPlan,
MixtureOfExpertsPlan,
ExpertActivation,
AgenticLoopPlan,
QuantumStressTestPlan,
PhysicsEconomicsPlan,
default_marketing_engine,
)
APP_NAME = os.getenv("APP_NAME", "HiveSeedAPI")
START_TS = time.time()
app = FastAPI(title=APP_NAME)
class Health(BaseModel):
status: str
uptime_seconds: float
class Ready(BaseModel):
ready: bool
reason: str | None = None
class MarketingQuery(BaseModel):
prompt: str
limit: int = 3
class MarketingInsight(BaseModel):
channel: str
audience: str
offer: str
objective: str
rationale: str
class MarketingResponse(BaseModel):
query: str
recommendations: list[MarketingInsight]
insight: str
class StatisticalInsight(BaseModel):
channel: str
audience: str
offer: str
objective: str
expected_roi: float
expected_ctr: float
confidence: float
rationale: str
drivers: dict[str, float]
class StatisticalEvidenceInsight(BaseModel):
feature: str
feature_type: str
posterior_roi: float
posterior_ctr: float
confidence: float
lift_vs_benchmark: float
sample_size: int
weight: float
rationale: str
class StatisticalReasoningInsight(BaseModel):
expected_roi: float
expected_revenue: float
confidence: float
success_probability: float
volatility_adjustment: float
scenario_spread: dict[str, float]
driver_confidence: dict[str, float]
evidence: list[StatisticalEvidenceInsight]
narrative: str
source: str
notes: str | None = None
class PortfolioInsight(BaseModel):
expected_roi: float
expected_ctr: float
confidence: float
rationale: str
strongest_drivers: dict[str, float]
class StatisticalResponse(BaseModel):
query: str
recommendations: list[StatisticalInsight]
portfolio: PortfolioInsight
class DiagnosticResponse(BaseModel):
query: str
stage: str
urgency: str
focus: str
confidence: float
recommended_kpis: list[str]
opportunities: list[str]
risk_signals: list[str]
keyword_summary: dict[str, list[str]]
class ProcessRun(BaseModel):
process: str
recommendations: list[MarketingInsight]
summary: str
class ExperimentInsight(BaseModel):
name: str
hypothesis: str
primary_metric: str
secondary_metrics: list[str]
playbook: list[str]
confidence: float
class LearningLoopInsight(BaseModel):
play_name: str
stage: str
audience_focus: str
channel: str
learning: str
wins: list[str]
losses: list[str]
next_actions: list[str]
kpi_focus: list[str]
confidence: float
source: str
notes: str | None = None
class CompetitiveLandscapeInsight(BaseModel):
competitor: str
channel: str
summary: str
strengths: list[str]
weaknesses: list[str]
recommended_play: str
share_of_voice: float
signal_intensity: float
threat_level: str
focus_alignment: float
source: str
notes: str | None = None
class ExcellenceInsight(BaseModel):
excellence_index: float
maturity_level: str
headline: str
strengths: list[str]
watchouts: list[str]
process_coverage: dict[str, float]
notes: str | None = None
class StrategicDirectiveInsight(BaseModel):
name: str
priority: int
objective: str
primary_channel: str
supporting_channels: list[str]
investment_usd: float | None
expected_revenue_usd: float | None
confidence: float
time_horizon_hours: int
north_star_metric: str
supporting_metrics: list[str]
action_steps: list[str]
dependencies: list[str]
risk_mitigations: list[str]
inspiration: str
source: str
notes: str | None = None
class ExecutivePlaybookInsight(BaseModel):
headline: str
focus: str
urgency: str
north_star_metric: str
total_budget_usd: float | None
expected_revenue_usd: float | None
confidence: float
directives: list[StrategicDirectiveInsight]
summary: str
notes: str | None = None
class ScenarioProjectionInsight(BaseModel):
scenario: str
expected_revenue: float
expected_roi: float
probability: float
confidence: float
accelerators: list[str]
stabilizers: list[str]
watchouts: list[str]
source: str
notes: str | None = None
class ScenarioPlanningInsight(BaseModel):
headline: str
summary: str
projections: list[ScenarioProjectionInsight]
confidence: float
accelerators: list[str]
stabilizers: list[str]
source: str
notes: str | None = None
class MarketingProcessesResponse(BaseModel):
query: str
rag: ProcessRun
egg: list[ExperimentInsight]
google_ads: list["GoogleAdsInsight"]
cj_affiliate: list["CJAffiliateInsight"]
crypto_markets: list["CryptoMarketInsight"]
stock_markets: list["StockMarketInsight"]
stripe: list["StripePlanInsight"]
paypal: list["PayPalPlanInsight"]
payment_integrations: list["PaymentIntegrationInsight"]
investing: list["InvestingInsight"]
cognitive_architecture: list["CognitiveArchitectureInsight"]
agentic_systems: list["AgenticSystemInsight"]
rag_workflows: list["KnowledgeWorkflowInsight"]
knowledge_graphs: list["KnowledgeWorkflowInsight"]
language_intelligence: list["LanguageCapabilityInsight"]
code_automation: list["CodeAutomationInsight"]
mixture_of_experts: list["MixtureOfExpertsInsight"]
agentic_loops: list["AgenticLoopInsight"]
quantum_simulation: list["QuantumSimulationInsight"]
physics_economics: list["PhysicsEconomicsInsight"]
stripe: list["StripePlanInsight"]
paypal: list["PayPalPlanInsight"]
influencer_collaborations: list["InfluencerInsight"]
amazon_marketplace: list["AmazonMarketplaceInsight"]
ebay_marketplace: list["EbayMarketplaceInsight"]
aws_cloud: list["AWSRevenueInsight"]
budget_optimizer: "BudgetPlanInsight"
automation: "AutomationSprintInsight"
learning_loop: list["LearningLoopInsight"]
competitive_landscape: list["CompetitiveLandscapeInsight"]
excellence: "ExcellenceInsight"
executive_playbook: "ExecutivePlaybookInsight"
scenario_planning: "ScenarioPlanningInsight"
statistical_reasoning: "StatisticalReasoningInsight"
class GoogleAdsInsight(BaseModel):
campaign_name: str
clicks: int
impressions: int
conversions: float
cost_micros: int
ctr: float
cpc: float
roas: float
source: str
notes: str | None = None
class CJAffiliateInsight(BaseModel):
program_name: str
advertiser_id: str
category: str
commission_rate: float
epc: float
seven_day_epc: float
projected_epc: float
projected_monthly_revenue: float
network_rank: int
payout_terms: str
landing_url: str
rationale: str
source: str
notes: str | None = None
class CryptoMarketInsight(BaseModel):
asset: str
price_usd: float | None
change_24h: float | None
market_cap: float | None
volume_24h: float | None
source: str
notes: str | None = None
class StockMarketInsight(BaseModel):
symbol: str
name: str
region: str
focus: str
current_price: float
trend: str
forecast_return_30d: float
forecast_return_90d: float
forecast_revenue_multiplier: float
volatility: float
confidence: float
signal_summary: str
source: str
notes: str | None = None
class StripePlanInsight(BaseModel):
product_name: str
price_usd: float
billing_interval: str
currency: str
rationale: str
setup_steps: list[str]
source: str
notes: str | None = None
class PayPalPlanInsight(BaseModel):
product_name: str
price_usd: float
checkout_flow: str
payout_schedule: str
rationale: str
setup_steps: list[str]
source: str
notes: str | None = None
class PaymentIntegrationInsight(BaseModel):
provider: str
maturity: str
description: str
reasoning: str
integration_focus: list[str]
docs: list[str]
sdks: list[str]
setup: list[str]
troubleshooting: list[str]
codefix: list[str]
marketing_plays: list[str]
source: str
notes: str | None = None
class InvestingInsight(BaseModel):
provider: str
category: str
maturity: str
description: str
reasoning: str
asset_classes: list[str]
monetization: list[str]
onboarding: list[str]
tools: list[str]
risk_controls: list[str]
revenue_programs: list[str]
kpis: list[str]
source: str
notes: str | None = None
class CognitiveArchitectureInsight(BaseModel):
capability: str
pillar: str
maturity: str
description: str
reasoning: str
prompt_strategy: str
frameworks: list[str]
tooling: list[str]
metrics: list[str]
knowledge_assets: list[str]
orchestration_steps: list[str]
source: str
class AgenticSystemInsight(BaseModel):
system_name: str
domain: str
controller: str
maturity: str
reasoning: str
orchestration_steps: list[str]
toolchain: list[str]
data_interfaces: list[str]
knowledge_sources: list[str]
revenue_programs: list[str]
risk_controls: list[str]
metrics: list[str]
source: str
notes: str | None = None
class KnowledgeWorkflowInsight(BaseModel):
name: str
category: str
maturity: str
description: str
reasoning: str
indexing_plan: list[str]
retrieval_plan: list[str]
vector_store: str
embedding_models: list[str]
tooling: list[str]
evaluation: list[str]
governance: list[str]
caching: list[str]
source: str
class LanguageCapabilityInsight(BaseModel):
capability: str
category: str
maturity: str
description: str
reasoning: str
pipeline_components: list[str]
tooling: list[str]
datasets: list[str]
evaluation_metrics: list[str]
revenue_programs: list[str]
orchestration_steps: list[str]
source: str
notes: str | None = None
class CodeAutomationInsight(BaseModel):
capability: str
category: str
maturity: str
description: str
reasoning: str
automation_stages: list[str]
tooling: list[str]
platforms: list[str]
metrics: list[str]
revenue_programs: list[str]
guardrails: list[str]
orchestration_steps: list[str]
source: str
notes: str | None = None
class ExpertActivationInsight(BaseModel):
name: str
provider: str
role: str
confidence: float
reasoning: str
outputs: list[str]
metrics: list[str]
fallback: str
source: str
class MixtureOfExpertsInsight(BaseModel):
router_summary: str
maturity: str
activations: list[ExpertActivationInsight]
evaluation_metrics: list[str]
notes: str
source: str
class AgenticLoopStageInsight(BaseModel):
stage: str
objective: str
actions: list[str]
tools: list[str]
signals: list[str]
outputs: list[str]
metrics: list[str]
class AgenticLoopInsight(BaseModel):
name: str
goal_focus: str
summary: str
maturity: str
reasoning: str
stages: list[AgenticLoopStageInsight]
guardrails: list[str]
source: str
class QuantumStressScenarioInsight(BaseModel):
name: str
domain: str
objective: str
stressors: list[str]
metrics: list[str]
gate_sequence: list[str]
measurement_probability: float
stability_index: float
integration_points: list[str]
recommended_actions: list[str]
notes: str | None = None
class QuantumSimulationInsight(BaseModel):
simulator: str
provider: str
maturity: str
description: str
reasoning: str
training_focus: list[str]
stress_tests: list[QuantumStressScenarioInsight]
orchestration_steps: list[str]
metrics: list[str]
dependencies: list[str]
docs: list[str]
coverage_ratio: float
domain_stability: dict[str, float]
source: str
notes: str | None = None
class PhysicsEconomicsInsight(BaseModel):
capability: str
domain: str
maturity: str
description: str
rationale: str
marketing_algorithms: list[str]
physics_principles: list[str]
quantum_strategies: list[str]
economic_models: list[str]
hardware_strategies: list[str]
data_compression: list[str]
risk_controls: list[str]
metrics: list[str]
orchestration_steps: list[str]
docs: list[str]
source: str
notes: str | None = None
class InfluencerInsight(BaseModel):
name: str
platform: str
niche: str
collab_format: str
audience_size: int
engagement_rate: float
estimated_reach: int
projected_cpm: float
projected_leads: int
projected_revenue: float
projected_roi: float
rationale: str
source: str
notes: str | None = None
class AmazonMarketplaceInsight(BaseModel):
asin: str
title: str
category: str
price_usd: float
commission_rate: float
rating: float
reviews: int
estimated_monthly_sales: int
buy_box_share: float
prime_eligible: bool
fulfillment_model: str
projected_monthly_revenue: float
rationale: str
url: str
source: str
notes: str | None = None
class EbayMarketplaceInsight(BaseModel):
item_id: str
title: str
category: str
price_usd: float
affiliate_rate: float
seller_level: str
seller_rating: float
conversion_rate: float
sold_per_month: int
projected_monthly_revenue: float
projected_profit_margin: float
shipping_days: int
rationale: str
url: str
source: str
notes: str | None = None
class AWSRevenueInsight(BaseModel):
program_name: str
focus: str
description: str
revenue_motion: str
primary_service: str
secondary_services: list[str]
automation_play: str
projected_roi: float
source: str
notes: str | None = None
class BudgetAllocationInsight(BaseModel):
channel: str
audience_focus: str
offer: str
objective: str
allocation_usd: float
allocation_weight: float
expected_leads: float
expected_revenue: float
rationale: str
source: str
notes: str | None = None
class BudgetPlanInsight(BaseModel):
total_budget: float
expected_revenue: float
expected_roi: float
payback_period_weeks: float
summary: str
allocations: list[BudgetAllocationInsight]
class AutomationTaskInsight(BaseModel):
start_minute: int
end_minute: int
activity: str
outcome: str
tooling: list[str]
kpis: list[str]
automation_level: str
source: str
class AutomationSprintInsight(BaseModel):
total_minutes: int
stage: str
focus: str
summary: str
notes: str | None = None
tasks: list[AutomationTaskInsight]
source: str
try: # Pydantic v2
GoogleAdsInsight.model_rebuild()
CJAffiliateInsight.model_rebuild()
CryptoMarketInsight.model_rebuild()
StockMarketInsight.model_rebuild()
StripePlanInsight.model_rebuild()
PayPalPlanInsight.model_rebuild()
CognitiveArchitectureInsight.model_rebuild()
StripePlanInsight.model_rebuild()
PayPalPlanInsight.model_rebuild()
InfluencerInsight.model_rebuild()
AmazonMarketplaceInsight.model_rebuild()
EbayMarketplaceInsight.model_rebuild()
AWSRevenueInsight.model_rebuild()
BudgetAllocationInsight.model_rebuild()
BudgetPlanInsight.model_rebuild()
AutomationTaskInsight.model_rebuild()
AutomationSprintInsight.model_rebuild()
QuantumSimulationInsight.model_rebuild()
PhysicsEconomicsInsight.model_rebuild()
LearningLoopInsight.model_rebuild()
CompetitiveLandscapeInsight.model_rebuild()
ExcellenceInsight.model_rebuild()
StrategicDirectiveInsight.model_rebuild()
ExecutivePlaybookInsight.model_rebuild()
ScenarioProjectionInsight.model_rebuild()
ScenarioPlanningInsight.model_rebuild()
StatisticalEvidenceInsight.model_rebuild()
StatisticalReasoningInsight.model_rebuild()
MarketingProcessesResponse.model_rebuild()
except AttributeError: # pragma: no cover - pydantic v1 fallback
MarketingProcessesResponse.update_forward_refs(
GoogleAdsInsight=GoogleAdsInsight,
CJAffiliateInsight=CJAffiliateInsight,
CryptoMarketInsight=CryptoMarketInsight,
StockMarketInsight=StockMarketInsight,
StripePlanInsight=StripePlanInsight,
PayPalPlanInsight=PayPalPlanInsight,
CognitiveArchitectureInsight=CognitiveArchitectureInsight,
StripePlanInsight=StripePlanInsight,
PayPalPlanInsight=PayPalPlanInsight,
InfluencerInsight=InfluencerInsight,
AmazonMarketplaceInsight=AmazonMarketplaceInsight,
EbayMarketplaceInsight=EbayMarketplaceInsight,
AWSRevenueInsight=AWSRevenueInsight,
BudgetAllocationInsight=BudgetAllocationInsight,
BudgetPlanInsight=BudgetPlanInsight,
AutomationTaskInsight=AutomationTaskInsight,
AutomationSprintInsight=AutomationSprintInsight,
QuantumSimulationInsight=QuantumSimulationInsight,
PhysicsEconomicsInsight=PhysicsEconomicsInsight,
LearningLoopInsight=LearningLoopInsight,
CompetitiveLandscapeInsight=CompetitiveLandscapeInsight,
ExcellenceInsight=ExcellenceInsight,
StrategicDirectiveInsight=StrategicDirectiveInsight,
ExecutivePlaybookInsight=ExecutivePlaybookInsight,
ScenarioProjectionInsight=ScenarioProjectionInsight,
ScenarioPlanningInsight=ScenarioPlanningInsight,
StatisticalEvidenceInsight=StatisticalEvidenceInsight,
StatisticalReasoningInsight=StatisticalReasoningInsight,
)
@app.get("/healthz", response_model=Health)
def healthz() -> Health:
return Health(status="ok", uptime_seconds=time.time() - START_TS)
@app.get("/readyz", response_model=Ready)
def readyz() -> Ready:
# Minimal readiness: enumerations exist or DRY_RUN enabled
base = os.path.join(os.path.dirname(__file__), "..", "..", "daemon", "enumerations")
files = [
os.path.join(base, "math_model_500.txt"),
os.path.join(base, "agent_500.txt"),
os.path.join(base, "language_500.txt"),
os.path.join(base, "prophecy_500.txt"),
os.path.join(base, "marketing_500.txt"),
]
if all(os.path.isfile(p) for p in files):
return Ready(ready=True)
if os.getenv("DRY_RUN", "0") in {"1", "true", "TRUE", "yes", "on"}:
return Ready(ready=True, reason="DRY_RUN enabled")
return Ready(ready=False, reason="Enumerations missing; run make enumerations")
def _campaign_to_insight(engine: MarketingIntelligenceEngine, query: str, campaign: MarketingCampaign) -> MarketingInsight:
tokens = engine.keywords(query)
matches: list[str] = []
normalized = {
"channel": campaign.channel.lower(),
"audience": campaign.audience.lower(),
"offer": campaign.offer.lower(),
"objective": campaign.objective.lower(),
}
for token in tokens:
for feature, text in normalized.items():
if token in text and feature not in matches:
matches.append(feature)
rationale = "Matched: " + ", ".join(matches) if matches else "General fit from curated library"
return MarketingInsight(
channel=campaign.channel,
audience=campaign.audience,
offer=campaign.offer,
objective=campaign.objective,
rationale=rationale,
)
def _campaign_to_statistical_insight(
engine: MarketingIntelligenceEngine,
query: str,
scored: CampaignScore,
) -> StatisticalInsight:
matches: list[str] = []
for feature, count in scored.keyword_coverage.items():
if count:
matches.append(feature)
if matches:
rationale = f"Matched {', '.join(sorted(matches))} intent with statistical lift."
else:
rationale = "Benchmark-driven pick from marketing corpus."
strongest = sorted(scored.metrics.drivers.items(), key=lambda item: item[1], reverse=True)
if strongest:
rationale += f" Top driver: {strongest[0][0]} ROI {strongest[0][1]:.2f}."
return StatisticalInsight(
channel=scored.campaign.channel,
audience=scored.campaign.audience,
offer=scored.campaign.offer,
objective=scored.campaign.objective,
expected_roi=round(scored.metrics.expected_roi, 2),
expected_ctr=round(scored.metrics.expected_ctr, 4),
confidence=round(scored.metrics.confidence, 2),
rationale=rationale,
drivers={key: round(value, 2) for key, value in scored.metrics.drivers.items()},
)
def _portfolio_to_insight(query: str, portfolio: CampaignMetrics, tokens: list[str]) -> PortfolioInsight:
highlights = ", ".join(sorted(set(tokens))) or "broad"
strongest = sorted(portfolio.drivers.items(), key=lambda item: item[1], reverse=True)
driver_text = strongest[0][0] if strongest else "channel"
rationale = (
f"Statistical blend for '{query}' optimized for {highlights} focus; strongest lift from {driver_text}."
)
return PortfolioInsight(
expected_roi=round(portfolio.expected_roi, 2),
expected_ctr=round(portfolio.expected_ctr, 4),
confidence=round(portfolio.confidence, 2),
rationale=rationale,
strongest_drivers={key: round(value, 2) for key, value in portfolio.drivers.items()},
)
@app.post("/intelligence/marketing", response_model=MarketingResponse)
def marketing_intelligence(query: MarketingQuery) -> MarketingResponse:
engine = default_marketing_engine()
campaigns = engine.recommend(query.prompt, query.limit)
insights = [_campaign_to_insight(engine, query.prompt, campaign) for campaign in campaigns]
narrative = engine.summarize(query.prompt, campaigns)
return MarketingResponse(query=query.prompt, recommendations=insights, insight=narrative)
@app.post("/intelligence/marketing/statistical", response_model=StatisticalResponse)
def marketing_statistical_intelligence(query: MarketingQuery) -> StatisticalResponse:
engine = default_marketing_engine()
ranked = engine.recommend_statistical(query.prompt, query.limit)
insights = [
_campaign_to_statistical_insight(engine, query.prompt, scored) for scored in ranked
]
tokens = engine.keywords(query.prompt)
portfolio_metrics = engine.portfolio(query.prompt, ranked)
portfolio = _portfolio_to_insight(query.prompt, portfolio_metrics, tokens)
return StatisticalResponse(query=query.prompt, recommendations=insights, portfolio=portfolio)
def _diagnostics_payload(query: str, diagnostics: PromptDiagnostics) -> DiagnosticResponse:
return DiagnosticResponse(
query=query,
stage=diagnostics.stage,
urgency=diagnostics.urgency,
focus=diagnostics.focus,
confidence=diagnostics.confidence,
recommended_kpis=diagnostics.recommended_kpis,
opportunities=diagnostics.opportunities,
risk_signals=diagnostics.risk_signals,
keyword_summary=diagnostics.keyword_summary,
)
def _experiment_payload(experiment: GrowthExperiment) -> ExperimentInsight:
return ExperimentInsight(
name=experiment.name,
hypothesis=experiment.hypothesis,
primary_metric=experiment.primary_metric,
secondary_metrics=experiment.secondary_metrics,
playbook=experiment.playbook,
confidence=experiment.confidence,
)
def _google_ads_payload(performance: GoogleCampaignPerformance) -> "GoogleAdsInsight":
return GoogleAdsInsight(
campaign_name=performance.campaign_name,
clicks=performance.clicks,
impressions=performance.impressions,
conversions=performance.conversions,
cost_micros=performance.cost_micros,
ctr=performance.ctr,
cpc=performance.cpc,
roas=performance.roas,
source=performance.source,
notes=performance.notes,
)
def _cj_affiliate_payload(recommendation: CJAffiliateRecommendation) -> "CJAffiliateInsight":
return CJAffiliateInsight(
program_name=recommendation.program_name,
advertiser_id=recommendation.advertiser_id,
category=recommendation.category,
commission_rate=recommendation.commission_rate,
epc=recommendation.epc,
seven_day_epc=recommendation.seven_day_epc,
projected_epc=recommendation.projected_epc,
projected_monthly_revenue=recommendation.projected_monthly_revenue,
network_rank=recommendation.network_rank,
payout_terms=recommendation.payout_terms,
landing_url=recommendation.landing_url,
rationale=recommendation.rationale,
source=recommendation.source,
notes=recommendation.notes,
)
def _crypto_market_payload(snapshot: CryptoMarketSnapshot) -> "CryptoMarketInsight":
return CryptoMarketInsight(
asset=snapshot.asset,
price_usd=snapshot.price_usd,
change_24h=snapshot.change_24h,
market_cap=snapshot.market_cap,
volume_24h=snapshot.volume_24h,
source=snapshot.source,
notes=snapshot.notes,
)
def _stock_market_payload(forecast: StockMarketForecast) -> "StockMarketInsight":
return StockMarketInsight(
symbol=forecast.symbol,
name=forecast.name,
region=forecast.region,
focus=forecast.focus,
current_price=forecast.current_price,
trend=forecast.trend,
forecast_return_30d=forecast.forecast_return_30d,
forecast_return_90d=forecast.forecast_return_90d,
forecast_revenue_multiplier=forecast.forecast_revenue_multiplier,
volatility=forecast.volatility,
confidence=forecast.confidence,
signal_summary=forecast.signal_summary,
source=forecast.source,
notes=forecast.notes,
)
def _statistical_evidence_payload(evidence: StatisticalEvidence) -> StatisticalEvidenceInsight:
return StatisticalEvidenceInsight(
feature=evidence.feature,
feature_type=evidence.feature_type,
posterior_roi=evidence.posterior_roi,
posterior_ctr=evidence.posterior_ctr,
confidence=evidence.confidence,
lift_vs_benchmark=evidence.lift_vs_benchmark,
sample_size=evidence.sample_size,
weight=evidence.weight,
rationale=evidence.rationale,
)
def _statistical_reasoning_payload(
summary: StatisticalReasoningSummary,
) -> StatisticalReasoningInsight:
return StatisticalReasoningInsight(
expected_roi=summary.expected_roi,
expected_revenue=summary.expected_revenue,
confidence=summary.confidence,
success_probability=summary.success_probability,
volatility_adjustment=summary.volatility_adjustment,
scenario_spread=summary.scenario_spread,
driver_confidence=summary.driver_confidence,
evidence=[_statistical_evidence_payload(item) for item in summary.evidence],
narrative=summary.narrative,
source=summary.source,
notes=summary.notes,
)
def _stripe_plan_payload(plan: StripeMonetizationPlan) -> "StripePlanInsight":
return StripePlanInsight(
product_name=plan.product_name,
price_usd=plan.price_usd,
billing_interval=plan.billing_interval,
currency=plan.currency,
rationale=plan.rationale,
setup_steps=plan.setup_steps,
source=plan.source,
notes=plan.notes,
)
def _paypal_plan_payload(plan: PayPalMonetizationPlan) -> "PayPalPlanInsight":
return PayPalPlanInsight(
product_name=plan.product_name,
price_usd=plan.price_usd,
checkout_flow=plan.checkout_flow,
payout_schedule=plan.payout_schedule,
rationale=plan.rationale,
setup_steps=plan.setup_steps,
source=plan.source,
notes=plan.notes,
)
def _payment_integration_payload(plan: PaymentIntegrationPlan) -> "PaymentIntegrationInsight":
return PaymentIntegrationInsight(
provider=plan.provider,
maturity=plan.maturity,
description=plan.description,
reasoning=plan.reasoning,
integration_focus=plan.integration_focus,
docs=plan.docs,
sdks=plan.sdks,
setup=plan.setup,
troubleshooting=plan.troubleshooting,
codefix=plan.codefix,
marketing_plays=plan.marketing_plays,
source=plan.source,
notes=plan.notes,
)
def _investing_payload(plan: InvestingPlan) -> "InvestingInsight":
return InvestingInsight(
provider=plan.provider,
category=plan.category,
maturity=plan.maturity,
description=plan.description,
reasoning=plan.reasoning,
asset_classes=plan.asset_classes,
monetization=plan.monetization,
onboarding=plan.onboarding,
tools=plan.tools,
risk_controls=plan.risk_controls,
revenue_programs=plan.revenue_programs,
kpis=plan.kpis,
source=plan.source,
notes=plan.notes,
)
def _cognitive_architecture_payload(
plan: CognitiveCapabilityPlan,
) -> "CognitiveArchitectureInsight":
return CognitiveArchitectureInsight(
capability=plan.capability,
pillar=plan.pillar,
maturity=plan.maturity,
description=plan.description,
reasoning=plan.reasoning,
prompt_strategy=plan.prompt_strategy,
frameworks=list(plan.frameworks),
tooling=list(plan.tooling),
metrics=list(plan.metrics),
knowledge_assets=list(plan.knowledge_assets),
orchestration_steps=list(plan.orchestration_steps),
source=plan.source,
)
def _agentic_system_payload(plan: AgenticSystemPlan) -> "AgenticSystemInsight":
return AgenticSystemInsight(
system_name=plan.system_name,
domain=plan.domain,
controller=plan.controller,
maturity=plan.maturity,
reasoning=plan.reasoning,
orchestration_steps=list(plan.orchestration_steps),
toolchain=list(plan.toolchain),
data_interfaces=list(plan.data_interfaces),
knowledge_sources=list(plan.knowledge_sources),
revenue_programs=list(plan.revenue_programs),
risk_controls=list(plan.risk_controls),
metrics=list(plan.metrics),
source=plan.source,
notes=plan.notes,
)
def _knowledge_workflow_payload(plan: KnowledgeWorkflowPlan) -> "KnowledgeWorkflowInsight":
return KnowledgeWorkflowInsight(
name=plan.name,
category=plan.category,
maturity=plan.maturity,
description=plan.description,
reasoning=plan.reasoning,
indexing_plan=list(plan.indexing_plan),
retrieval_plan=list(plan.retrieval_plan),
vector_store=plan.vector_store,
embedding_models=list(plan.embedding_models),
tooling=list(plan.tooling),
evaluation=list(plan.evaluation),
governance=list(plan.governance),
caching=list(plan.caching),
source=plan.source,
)
def _language_capability_payload(
plan: LanguageCapabilityPlan,
) -> "LanguageCapabilityInsight":
return LanguageCapabilityInsight(
capability=plan.capability,
category=plan.category,
maturity=plan.maturity,
description=plan.description,
reasoning=plan.reasoning,
pipeline_components=list(plan.pipeline_components),
tooling=list(plan.tooling),
datasets=list(plan.datasets),
evaluation_metrics=list(plan.evaluation_metrics),
revenue_programs=list(plan.revenue_programs),
orchestration_steps=list(plan.orchestration_steps),
source=plan.source,
notes=plan.notes,
)
def _code_automation_payload(plan: CodeAutomationPlan) -> "CodeAutomationInsight":
return CodeAutomationInsight(
capability=plan.capability,
category=plan.category,
maturity=plan.maturity,
description=plan.description,
reasoning=plan.reasoning,
automation_stages=list(plan.automation_stages),
tooling=list(plan.tooling),
platforms=list(plan.platforms),
metrics=list(plan.metrics),
revenue_programs=list(plan.revenue_programs),
guardrails=list(plan.guardrails),
orchestration_steps=list(plan.orchestration_steps),
source=plan.source,
notes=plan.notes,
)
def _expert_activation_payload(activation: ExpertActivation) -> "ExpertActivationInsight":
return ExpertActivationInsight(
name=activation.name,
provider=activation.provider,
role=activation.role,
confidence=activation.confidence,
reasoning=activation.reasoning,
outputs=list(activation.outputs),
metrics=list(activation.metrics),
fallback=activation.fallback,
source=activation.source,
)
def _mixture_of_experts_payload(plan: MixtureOfExpertsPlan) -> "MixtureOfExpertsInsight":
return MixtureOfExpertsInsight(
router_summary=plan.router_summary,
maturity=plan.maturity,
activations=[_expert_activation_payload(act) for act in plan.activations],
evaluation_metrics=list(plan.evaluation_metrics),
notes=plan.notes,
source=plan.source,
)
def _agentic_loop_payload(plan: AgenticLoopPlan) -> "AgenticLoopInsight":
return AgenticLoopInsight(
name=plan.name,
goal_focus=plan.goal_focus,
summary=plan.summary,
maturity=plan.maturity,
reasoning=plan.reasoning,
stages=[
AgenticLoopStageInsight(
stage=stage.stage,
objective=stage.objective,
actions=list(stage.actions),
tools=list(stage.tools),
signals=list(stage.signals),
outputs=list(stage.outputs),
metrics=list(stage.metrics),
)
for stage in plan.stages
],
guardrails=list(plan.guardrails),
source=plan.source,
)
def _quantum_simulation_payload(plan: QuantumStressTestPlan) -> "QuantumSimulationInsight":
return QuantumSimulationInsight(
simulator=plan.simulator,
provider=plan.provider,
maturity=plan.maturity,
description=plan.description,
reasoning=plan.reasoning,
training_focus=list(plan.training_focus),
stress_tests=[
QuantumStressScenarioInsight(
name=test.name,
domain=test.domain,
objective=test.objective,
stressors=list(test.stressors),
metrics=list(test.metrics),
gate_sequence=list(test.gate_sequence),
measurement_probability=test.measurement_probability,
stability_index=test.stability_index,
integration_points=list(test.integration_points),
recommended_actions=list(test.recommended_actions),
notes=test.notes,
)
for test in plan.stress_tests
],
orchestration_steps=list(plan.orchestration_steps),
metrics=list(plan.metrics),
dependencies=list(plan.dependencies),
docs=list(plan.docs),
coverage_ratio=plan.coverage_ratio,
domain_stability=dict(plan.domain_stability),
source=plan.source,
notes=plan.notes,
)
def _physics_economics_payload(
plan: PhysicsEconomicsPlan,
) -> "PhysicsEconomicsInsight":
return PhysicsEconomicsInsight(
capability=plan.capability,
domain=plan.domain,
maturity=plan.maturity,
description=plan.description,
rationale=plan.rationale,
marketing_algorithms=list(plan.marketing_algorithms),
physics_principles=list(plan.physics_principles),
quantum_strategies=list(plan.quantum_strategies),
economic_models=list(plan.economic_models),
hardware_strategies=list(plan.hardware_strategies),
data_compression=list(plan.data_compression),
risk_controls=list(plan.risk_controls),
metrics=list(plan.metrics),
orchestration_steps=list(plan.orchestration_steps),
docs=list(plan.docs),
source=plan.source,
notes=plan.notes,
)
def _influencer_payload(
recommendation: InfluencerRecommendation,
) -> "InfluencerInsight":
return InfluencerInsight(
name=recommendation.name,
platform=recommendation.platform,
niche=recommendation.niche,
collab_format=recommendation.collab_format,
audience_size=recommendation.audience_size,
engagement_rate=recommendation.engagement_rate,
estimated_reach=recommendation.estimated_reach,
projected_cpm=recommendation.projected_cpm,
projected_leads=recommendation.projected_leads,
projected_revenue=recommendation.projected_revenue,
projected_roi=recommendation.projected_roi,
rationale=recommendation.rationale,
source=recommendation.source,
notes=recommendation.notes,
)
def _amazon_listing_payload(
recommendation: AmazonProductRecommendation,
) -> "AmazonMarketplaceInsight":
return AmazonMarketplaceInsight(
asin=recommendation.asin,
title=recommendation.title,
category=recommendation.category,
price_usd=recommendation.price_usd,
commission_rate=recommendation.commission_rate,
rating=recommendation.rating,
reviews=recommendation.reviews,
estimated_monthly_sales=recommendation.estimated_monthly_sales,
buy_box_share=recommendation.buy_box_share,
prime_eligible=recommendation.prime_eligible,
fulfillment_model=recommendation.fulfillment_model,
projected_monthly_revenue=recommendation.projected_monthly_revenue,
rationale=recommendation.rationale,
url=recommendation.url,
source=recommendation.source,
notes=recommendation.notes,
)
def _ebay_listing_payload(recommendation: EbayRevenuePlay) -> "EbayMarketplaceInsight":
return EbayMarketplaceInsight(
item_id=recommendation.item_id,
title=recommendation.title,
category=recommendation.category,
price_usd=recommendation.price_usd,
affiliate_rate=recommendation.affiliate_rate,
seller_level=recommendation.seller_level,
seller_rating=recommendation.seller_rating,
conversion_rate=recommendation.conversion_rate,
sold_per_month=recommendation.sold_per_month,
projected_monthly_revenue=recommendation.projected_monthly_revenue,
projected_profit_margin=recommendation.projected_profit_margin,
shipping_days=recommendation.shipping_days,
rationale=recommendation.rationale,
url=recommendation.url,
source=recommendation.source,
notes=recommendation.notes,
)
def _aws_revenue_payload(recommendation: AWSRevenueRecommendation) -> "AWSRevenueInsight":
return AWSRevenueInsight(
program_name=recommendation.program_name,
focus=recommendation.focus,
description=recommendation.description,
revenue_motion=recommendation.revenue_motion,
primary_service=recommendation.primary_service,
secondary_services=recommendation.secondary_services,
automation_play=recommendation.automation_play,
projected_roi=recommendation.projected_roi,
source=recommendation.source,
notes=recommendation.notes,
)
def _budget_plan_payload(plan: BudgetPlan) -> "BudgetPlanInsight":
allocations = [
BudgetAllocationInsight(
channel=allocation.channel,
audience_focus=allocation.audience_focus,
offer=allocation.offer,
objective=allocation.objective,
allocation_usd=allocation.allocation_usd,
allocation_weight=allocation.allocation_weight,
expected_leads=allocation.expected_leads,
expected_revenue=allocation.expected_revenue,
rationale=allocation.rationale,
source=allocation.source,
notes=allocation.notes,
)
for allocation in plan.allocations
]
return BudgetPlanInsight(
total_budget=plan.total_budget,
expected_revenue=plan.expected_revenue,
expected_roi=plan.expected_roi,
payback_period_weeks=plan.payback_period_weeks,
summary=plan.summary,
allocations=allocations,
)
def _automation_task_payload(task: AutomationTask) -> AutomationTaskInsight:
return AutomationTaskInsight(
start_minute=task.start_minute,
end_minute=task.end_minute,
activity=task.activity,
outcome=task.outcome,
tooling=task.tooling,
kpis=task.kpis,
automation_level=task.automation_level,
source=task.source,
)
def _automation_sprint_payload(sprint: AutomationSprint) -> AutomationSprintInsight:
return AutomationSprintInsight(
total_minutes=sprint.total_minutes,
stage=sprint.stage,
focus=sprint.focus,
summary=sprint.summary,
notes=sprint.notes,
tasks=[_automation_task_payload(task) for task in sprint.tasks],
source=sprint.source,
)
def _learning_loop_payload(recommendation: LearningLoopRecommendation) -> "LearningLoopInsight":
return LearningLoopInsight(
play_name=recommendation.play_name,
stage=recommendation.stage,
audience_focus=recommendation.audience_focus,
channel=recommendation.channel,
learning=recommendation.learning,
wins=recommendation.wins,
losses=recommendation.losses,
next_actions=recommendation.next_actions,
kpi_focus=recommendation.kpi_focus,
confidence=recommendation.confidence,
source=recommendation.source,
notes=recommendation.notes,
)
def _competitive_signal_payload(signal: CompetitiveSignal) -> "CompetitiveLandscapeInsight":
return CompetitiveLandscapeInsight(
competitor=signal.competitor,
channel=signal.channel,
summary=signal.summary,
strengths=signal.strengths,
weaknesses=signal.weaknesses,
recommended_play=signal.recommended_play,
share_of_voice=signal.share_of_voice,
signal_intensity=signal.signal_intensity,
threat_level=signal.threat_level,
focus_alignment=signal.focus_alignment,
source=signal.source,
notes=signal.notes,
)
def _excellence_payload(summary: ExcellenceSummary) -> ExcellenceInsight:
return ExcellenceInsight(
excellence_index=summary.excellence_index,
maturity_level=summary.maturity_level,
headline=summary.headline,
strengths=summary.strengths,
watchouts=summary.watchouts,
process_coverage=summary.process_coverage,
notes=summary.notes,
)
def _directive_payload(directive: StrategicDirective) -> StrategicDirectiveInsight:
return StrategicDirectiveInsight(
name=directive.name,
priority=directive.priority,
objective=directive.objective,
primary_channel=directive.primary_channel,
supporting_channels=directive.supporting_channels,
investment_usd=directive.investment_usd,
expected_revenue_usd=directive.expected_revenue_usd,
confidence=directive.confidence,
time_horizon_hours=directive.time_horizon_hours,
north_star_metric=directive.north_star_metric,
supporting_metrics=directive.supporting_metrics,
action_steps=directive.action_steps,
dependencies=directive.dependencies,
risk_mitigations=directive.risk_mitigations,
inspiration=directive.inspiration,
source=directive.source,
notes=directive.notes,
)
def _playbook_payload(playbook: ExecutivePlaybook) -> ExecutivePlaybookInsight:
return ExecutivePlaybookInsight(
headline=playbook.headline,
focus=playbook.focus,
urgency=playbook.urgency,
north_star_metric=playbook.north_star_metric,
total_budget_usd=playbook.total_budget_usd,
expected_revenue_usd=playbook.expected_revenue_usd,
confidence=playbook.confidence,
directives=[_directive_payload(directive) for directive in playbook.directives],
summary=playbook.summary,
notes=playbook.notes,
)
def _scenario_projection_payload(projection: ScenarioProjection) -> ScenarioProjectionInsight:
return ScenarioProjectionInsight(
scenario=projection.scenario,
expected_revenue=projection.expected_revenue,
expected_roi=projection.expected_roi,
probability=projection.probability,
confidence=projection.confidence,
accelerators=projection.accelerators,
stabilizers=projection.stabilizers,
watchouts=projection.watchouts,
source=projection.source,
notes=projection.notes,
)
def _scenario_planning_payload(analysis: ScenarioAnalysis) -> ScenarioPlanningInsight:
return ScenarioPlanningInsight(
headline=analysis.headline,
summary=analysis.summary,
projections=[_scenario_projection_payload(proj) for proj in analysis.projections],