From 334b3f43c23dd6ed7bd2b72560629fec199c0427 Mon Sep 17 00:00:00 2001 From: Daniel Maddern Date: Sun, 16 Aug 2026 16:43:27 +0700 Subject: [PATCH] Fix thesis seed metadata serialization --- agents/venture_discovery.py | 4 +++- tests/test_venture_discovery_cohort_v02.py | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/agents/venture_discovery.py b/agents/venture_discovery.py index 59ef6df..421c186 100644 --- a/agents/venture_discovery.py +++ b/agents/venture_discovery.py @@ -657,7 +657,9 @@ class VentureDiscoveryService: for name, thesis, category, status in seeds: existing = PortfolioThesis.objects.filter(canonical_name=name).first() historical = self.historical_thesis_stats(name) - defaults = {"concise_thesis": thesis, "category": category, "status": status, "metadata": {"dogfood_seed": True, "historical": historical}} + historical_metadata = {key: value for key, value in historical.items() if key != "best_company"} + historical_metadata["best_company"] = historical["best_company"].title if historical["best_company"] else "" + defaults = {"concise_thesis": thesis, "category": category, "status": status, "metadata": {"dogfood_seed": True, "historical": historical_metadata}} if historical["proposal_count"]: defaults.update({"proposal_count": historical["proposal_count"], "best_ic_score": historical["best_ic_score"], "best_company": historical["best_company"]}) if existing is None: diff --git a/tests/test_venture_discovery_cohort_v02.py b/tests/test_venture_discovery_cohort_v02.py index a78fa33..853346e 100644 --- a/tests/test_venture_discovery_cohort_v02.py +++ b/tests/test_venture_discovery_cohort_v02.py @@ -193,6 +193,20 @@ def test_v03_thesis_registry_mandate_and_territory_allocation() -> None: assert mandate.opportunity_territories[-2:] == [OpportunityTerritory.OPEN_CATEGORY, OpportunityTerritory.OPEN_CATEGORY] +def test_v03_registry_seed_historical_metadata_is_json_serializable() -> None: + svc = service() + proposal = svc.generate_single_company(svc.create_v0_mandate()) + proposal.title = "RFP Historical Candidate" + proposal.description = "AI RFP response drafting for SaaS teams." + proposal.proposed_solution = "RFP proposal automation." + proposal.save(update_fields=["title", "description", "proposed_solution", "updated_at"]) + + svc.seed_dogfood_thesis_registry() + + thesis = PortfolioThesis.objects.get(canonical_name="AI RFP response automation for B2B SaaS") + assert isinstance(thesis.metadata["historical"]["best_company"], str) + + def test_v03_novelty_gate_blocks_hard_exclusion_and_allows_soft_exception() -> None: svc = service() cohort = svc.prepare_cohort(size=2)