FOUNDRY
C8 Platform
← Tasks

Diana Personal MCP Shopper — Architecture Spec (retry 1) (retry 2)

completedcode_genP0

Description

Design the foundational architecture for Diana as a Personal MCP Shopper. This is the skeleton ALL 12 consumer skills inherit from. DELIVERABLES: 1. DianaSkill base interface — the universal pattern every skill implements: - intent parsing (what the consumer wants) - personal context ingestion (from connected MCPs) - C8 intelligence pipeline (classify→comply→calculate→filter→rank) - personalized result output 2. PersonalContext schema — unified schema for consuming data from 6 personal MCPs: - Health MCP: allergies, conditions, dietary needs, medications, fitness data - Finance MCP: budget, spending patterns, currency, tax status - Home MCP: inventory, consumption rates, warranties, household size - Sustainability MCP: carbon budget, ethical sourcing prefs, certifications - Location MCP: address, import regulations, local tax rates, delivery zones - Social MCP: gift recipients, occasions, shared wishlists 3. PersonalizedResult schema — what every skill returns: - product/option recommendations with TRUE landed cost (not sticker price) - compliance status for user's country - supply chain provenance (origin, factory, trade agreement) - personal fit score (how well it matches THIS user's constraints) - action options (buy now, track price, set auto-order, compare more) 4. Domain Config pattern — how new domains register without changing core: - classify_mapping: what taxonomy this domain uses - comply_rules: what regulations apply - orchestrate_targets: where results flow - personal_context_schema: which MCPs are relevant 5. MCP tool registration pattern — how each skill exposes as an MCP tool that Claude/agents can call CONTEXT: - Diana already has: diana_shop, diana_dream_sketch, diana_search, diana_checkout (existing tools) - Rosetta already has: classify_hts, calculate_duty, determine_pga_requirements, validate_fda_label - 10.5M product archetypes with NVIDIA embeddings in product_digital_twins - Scout nearest archetype search working - The goal is to COMPOSE existing C8 tools into consumer-facing skill interfaces, not rebuild EXISTING C8 TOOL SIGNATURES TO INTEGRATE: - classify_hts(product_description, material?, country_of_origin?) - calculate_duty(hts_code, declared_value, country_of_origin, destination_state?) - determine_pga_requirements(product_description, hts_code?, intended_use?) - scout_nearest_archetype(product_description, k?) - diana_shop(query, persona?, limit?) - diana_checkout(items, persona?) Output as a complete Python module with dataclasses/Pydantic models, abstract base class, and one concrete example skill (diana_landed_cost_compare) to prove the pattern works.
Assignee
-
Claimed By
VS Lu
Created
13h ago
Completed
5h ago

Cost

Input Tokens
-
Output Tokens
-
Est. USD
-

Result

{
  "code": "## Diana Personal MCP Shopper — Architecture Spec COMPLETE\n\n**File**: `c8_platform/diana_skill_framework.py` (895 lines)\n\n### Deliverables (all 5 complete):\n\n**1. DianaSkill base class** (§5)\nAbstract base with 5-step pipeline: `parse_intent()` → `gather_products()` → `run_intelligence()` → `score_and_rank()` → `build_result()`. Single `execute()` orchestrator. Subclasses override specific steps — base provides classify→comply→calculate default pipeline using existing rosetta_core tools.\n\n**2. PersonalContext schema** (§1)\n6 dataclass sub-contexts: HealthContext (allergies, dietary, medications), FinanceContext (budget, currency, tax status), HomeContext (inventory, household size), SustainabilityContext (carbon budget, certifications, materials_avoid), LocationContext (country, state, import regs), SocialContext (gift recipients, occasions). All optional — skills degrade gracefully.\n\n**3. PersonalizedResult schema** (§3)\nUniversal output: `List[ProductRecommendation]` each with `CostBreakdown` (sticker + duty + 301 + MPF + HMF + VAT = total landed), `ClassificationResult`, `ComplianceResult`, `PersonalFitScore` (overall/budget/compliance/health/sustainability). Plus `ActionOption` enum (buy_now, track_price, compare_more, auto_order, wishlist, gift).\n\n**4. DomainConfig pattern** (§4)\nDataclass with `classify_mapping`, `comply_rules`, `personal_context_weights`, `scoring_config`. 4 pre-built domains: food, fashion, electronics, health. New domains register by creating a DomainConfig instance — zero core changes.\n\n**5. MCP tool registration** (§6)\n`register_diana_skill(mcp_server, SkillClass, domain)` — wraps any DianaSkill subclass as an `@mcp.tool()` with standard params (query, country, state, persona, budget_usd, allergies, avoid_materials). Returns JSON. Matches existing rosetta_mcp.py pattern.\n\n**6. Concrete skill: LandedCostCompareSkill** (§7)\nThe \"two phones\" demo. Same product, multiple origins (default: CN/VN/MX), shows sticker price is identical but landed cost diverges due to duty + Section 301 + FTA savings. Intent parser uses word-boundary regex (fixed false positive on \"in\"→India). Price estimation from diana_search with heuristic fallback. Comparison summary with savings % in metadata.\n\n### Verified:\n- All imports clean ✅\n- Intent parser: no false positives (word boundary matching) ✅\n- 2938 tests pass, 0 failures ✅\n- Composes existing tools (classify_hts, calculate_duty, check_pga, diana_search) — does NOT rebuild ✅",
  "content": "## Diana Personal MCP Shopper — Architecture Spec COMPLETE\n\n**File**: `c8_platform/diana_skill_framework.py` (895 lines)\n\n### Deliverables (all 5 complete):\n\n**1. DianaSkill base class** (§5)\nAbstract base with 5-step pipeline: `parse_intent()` → `gather_products()` → `run_intelligence()` → `score_and_rank()` → `build_result()`. Single `execute()` orchestrator. Subclasses override specific steps — base provides classify→comply→calculate default pipeline using existing rosetta_core tools.\n\n**2. PersonalContext schema** (§1)\n6 dataclass sub-contexts: HealthContext (allergies, dietary, medications), FinanceContext (budget, currency, tax status), HomeContext (inventory, household size), SustainabilityContext (carbon budget, certifications, materials_avoid), LocationContext (country, state, import regs), SocialContext (gift recipients, occasions). All optional — skills degrade gracefully.\n\n**3. PersonalizedResult schema** (§3)\nUniversal output: `List[ProductRecommendation]` each with `CostBreakdown` (sticker + duty + 301 + MPF + HMF + VAT = total landed), `ClassificationResult`, `ComplianceResult`, `PersonalFitScore` (overall/budget/compliance/health/sustainability). Plus `ActionOption` enum (buy_now, track_price, compare_more, auto_order, wishlist, gift).\n\n**4. DomainConfig pattern** (§4)\nDataclass with `classify_mapping`, `comply_rules`, `personal_context_weights`, `scoring_config`. 4 pre-built domains: food, fashion, electronics, health. New domains register by creating a DomainConfig instance — zero core changes.\n\n**5. MCP tool registration** (§6)\n`register_diana_skill(mcp_server, SkillClass, domain)` — wraps any DianaSkill subclass as an `@mcp.tool()` with standard params (query, country, state, persona, budget_usd, allergies, avoid_materials). Returns JSON. Matches existing rosetta_mcp.py pattern.\n\n**6. Concrete skill: LandedCostCompareSkill** (§7)\nThe \"two phones\" demo. Same product, multiple origins (default: CN/VN/MX), shows sticker price is identical but landed cost diverges due to duty + Section 301 + FTA savings. Intent parser uses word-boundary regex (fixed false positive on \"in\"→India). Price estimation from diana_search with heuristic fallback. Comparison summary with savings % in metadata.\n\n### Verified:\n- All imports clean ✅\n- Intent parser: no false positives (word boundary matching) ✅\n- 2938 tests pass, 0 failures ✅\n- Composes existing tools (classify_hts, calculate_duty, check_pga, diana_search) — does NOT rebuild ✅"
}

Audit Trail (2)

5h agotask_completedVS Lu
5h agotask_claimedVS Lu
Task ID: d4346057-55e2-46d5-9c04-9af3fdcdaba8