文档
03 平台04 媒体供应03_设计

MG-03-012 领域模型(续)

领域模型(续);原页拆分后的下半部分

本页是 领域模型的前半部分 的续篇,2026-10-18 按章节拆分;上半部分仍在原页。

5. 公开模型

PublicModel

id
name
media_type
title
description
enabled
execution_modes
public_capability
degradation_disclosure

模型广场只展示 Public Model,不展示 Channel、Provider Credential 或内部成本。

CustomerGroupModelAccess

customer_group_id
public_model_id
enabled

SupplyBinding

id
public_model_id
supply_id
role                   exact / fallback / degraded
enabled

Binding 不保存 Supply 的能力、协议、成本和容量。

DispatchPolicy

public_model_id
strategy               stable_first / cost_first
minimum_success_rate
stable_cost_multiplier_limit
fallback_cost_multiplier_limit
fallback_absolute_cost_limit
max_attempts
retry_deadline_seconds
fallback_mode          strict / best_effort

DegradationRule

id
public_model_id
source_requirement
target_supply_id
step
transformations
max_cost
enabled
verified_at

允许的 Transformation 必须是有限枚举,例如:

  • drop_reference_audios
  • drop_reference_videos
  • limit_reference_images
  • lower_resolution
  • shorten_duration

每项必须保存变换前后值,不能使用任意脚本。

6. 运行状态

ChannelHealth

影响整个 Channel:

  • 网络、DNS、TLS;
  • Credential 失效;
  • 账户余额不足;
  • Provider 整体不可用。

SupplyHealth

影响单个 Supply:

  • 模型不存在;
  • 模型级限流或库存;
  • 模型、分辨率或协议持续错误;
  • Supply 独立熔断。

有效可用状态:

channel.enabled
AND channel_health allows_new_attempt
AND supply.enabled
AND supply.production_ready
AND supply_health allows_new_attempt
AND capacity_available

Capacity

容量同时受到 Channel 和 Supply 限制:

channel_concurrency_limit
supply_concurrency_limit
provider_rate_limit
customer_sync_limit
customer_async_limit

调度前必须获得 Capacity Lease。释放必须幂等,并支持 Worker 崩溃后的租约过期。

7. 请求、任务和尝试

MediaRequest

所有请求都有一条统一记录:

id
request_id
user_id
api_key_id
customer_group_id
media_type
execution_mode         sync / async
public_model_id
normalized_request
status
degraded
created_at
completed_at

AsyncTask

只有异步请求创建:

id
media_request_id
status
retry_deadline_at
max_attempts
next_action_at
created_at
completed_at

Attempt

id
media_request_id
async_task_id          nullable
supply_id
channel_id
credential_version_id
cost_rule_version_id
upstream_task_id       nullable
status
request_snapshot
routing_snapshot
estimated_cost
actual_cost
error_category
error_code
started_at
finished_at

MediaOutput

id
media_request_id
output_index
media_type
asset_id
metadata
created_at

Provider 临时 URL 不作为用户长期结果。

8. 渠道模型运营统计

统计以 Attempt 为权威事实,按 Channel 和 Supply 聚合:

calls
succeeded
failed
success_rate
error_category + error_code + count
last_attempt_at
recent_failures
time_series             hour / day bucket

submitted、polling 等未终态 Attempt 计入调用量但不计入成功或失败;成功率分母只使用 已终态的 succeeded/failed/submission_uncertain/cancelled Attempt。无终态样本时成功率为 null,不能显示为 100%。图像与视频统计分别查询和展示,不用 Channel/Supply Health 的 短窗口计数替代历史调用统计。

On this page