跳转到主要内容
# =============================================================
# 1. MANIFEST (协议名片)
# 确权、版本管理与全球唯一标识
# =============================================================
manifest:
  urn: "urn:runly:ecommerce:amazon:selection-expert:v1.0.0"
  title: "ACME Amazon Selection Expert"
  description: "基于业务 AI 化场景的深度选品决策 SOP 标准"
  version: "1.0.0"
  status: "stable"
  creator:
    me_id: "me_arch_dow_001"
    name: "Solo Arch Lab"
    pub_key: "ed25519:0x8e5c...a12b"
  created_at: "2026-02-07T10:00:00Z"
  updated_at: "2026-02-07T22:00:00Z"
  min_runtime: "v1.0"

# =============================================================
# 2. KNOWLEDGE (知识契约)
# 定义 AI 节点所需的背景知识挂载标准
# =============================================================
knowledge:
  - id: "market_trends_kb"
    description: "亚马逊全球市场趋势知识库"
    
    # [模式声明] 
    # VDB_DIRECT: 引擎负责向量化及物理检索
    # SEMANTIC_API: 引擎发送文本,服务商返回聚合后的文本
    provider_type: "SEMANTIC_API" 

    # [连接与认证配置]
    config:
      endpoint: "https://api.acme.com/v1/knowledge/search" # 接口 URL 或 VDB 物理地址
      method: "POST"
      timeout: 15
      # 鉴权定义 (秘密注入)
      headers:
        Authorization: "Bearer {{env.KB_SERVICE_TOKEN}}"
      
      # [模式特定参数] - 仅在 VDB_DIRECT 时生效
      vdb_params:
        index_name: "global-trends-idx"
        top_k: 5
        threshold: 0.85
        embedding_model: "text-embedding-3-small"

    # [注入契约]
    injection:
      target_variable: "context_knowledge" # Prompt 中引用的变量名
      max_tokens: 1500                    # 强制截断,防止 Token 溢出
      format: "markdown"                  # 注入格式: text | markdown | json

# =============================================================
# 3. SKILLS (技能契约)
# 定义外部数据调用与动作执行的报文契约(Skill Packet Standard)
# =============================================================
skills:
  - id: "amazon_realtime_data"
    type: "ACTION_HTTP"
    description: "获取亚马逊实时核心竞争数据"
    config:
      endpoint: "https://api.acme.com/v1/market/fetch"
      method: "POST"
      timeout: 15
	  max_retries: 3
      cache_ttl: 3600
      headers:
        Authorization: "Bearer {{env.MARKET_API_TOKEN}}"
    # 报文契约:确保执行层与技能层的数据对齐
    contract:
      request:
        payload:
          asin: "{{inputs.target_asin}}"
          region: "US"
      response:
        strict_mode: true
        schema:
          type: "object"
          properties:
            price: { "type": "number" }
            bsr_rank: { "type": "integer" }
            stock_level: { "type": "string" }

# =============================================================
# 4. DICTIONARY (数据字典)
# 定义协议的准入边界与产出物数据结构(Artifacts)
# =============================================================
dictionary:
  # Ingress: 输入准入规则
  inputs:
    - name: "target_asin"
      type: "string"
      pattern: "^[A-Z0-9]{10}$"
      required: true
    - name: "priority"
      type: "enum"
      values: ["standard", "high"]
      default: "standard"

  # Artifacts: 交付资产声明(协议仅定义数据契约,不定义交付方式)
  artifacts:
    - id: "selection_report_data"
      type: "DATA_OBJECT"
      description: "选品最终评估核心数据集"
      schema:
        type: "object"
        required: ["decision", "confidence"]
        properties:
          decision: { "type": "string", "enum": ["GO", "NO_GO"] }
          confidence: { "type": "number", "minimum": 0, "maximum": 1 }
          analysis_summary: { "type": "string" }
          estimated_roi: { "type": "number" }

# =============================================================
# 5. TOPOLOGY (拓扑逻辑)
# 引用资源契约,编排 AI Native 业务流转状态机
# =============================================================
topology:
  start_at: "node_validate"
  
  nodes:
    # 节点 1: 逻辑校验门
    - id: "node_validate"
      type: "LOGIC_GATE"
      rules:
        - { condition: "inputs.target_asin.length == 10", next: "call_market_skill" }
        - { condition: "default", next: "terminate_error" }

    # 节点 2: 执行技能(引用 Skills 域)
    - id: "call_market_skill"
      type: "SKILL_CALL"
      config:
        skill_ref: "amazon_realtime_data"
      on_success: "node_ai_reasoning"
      on_failure: "node_retry_logic"

    # 节点 3: AI 推理(挂载 Knowledge 域)
    - id: "node_ai_reasoning"
      type: "AI_TASK"
      config:
        model: "gemini-2.0-flash"
        knowledge_ref: "internal_market_trends"
        prompt: |
          结合知识库背景及实时数据 {{steps.call_market_skill.output}},
          深度评估 ASIN {{inputs.target_asin}} 的市场机会。
      on_success: "node_expert_hitl"

    # 节点 4: HITL 人工审批(专家确权)
    - id: "node_expert_hitl"
      type: "HITL"
      config:
        assignee: "{{manifest.creator.me_id}}"
        instruction: "AI 已完成逻辑推理,请针对 ROI 预测完成最终业务授权。"
        ui_snapshot:
          - "steps.node_ai_reasoning.output"
          - "steps.call_market_skill.output.price"
      on_success: "node_terminus"

    # 节点 5: 逻辑终点
    - id: "node_terminus"
      type: "TERMINUS"
      config:
        artifact_ref: "selection_report_data"
        data_source: "steps.node_ai_reasoning.output"

# =============================================================
# 6. COMMERCE (商业分账)
# 协议内置的价值分配契约
# =============================================================
commerce:
  pricing:
    mode: "UNIT_PAYMENT"
    amount: 1.50
    currency: "USD"
  royalty:
    creator_share: 0.75
    platform_share: 0.15
	referral_share: 0.15
  settlement:
    trigger: "node_terminus"
	auto_payout: true

# =============================================================
# 7. SECURITY (安全指纹)
# 资产封条,确保逻辑不可篡改
# =============================================================
security:
  hash_algo: "SHA-256"
  signature: "0x8f2a...e41c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9"