feat(sense): T-G0 语义分析器骨架(包结构/DDL/灰度门控挂载)

- gateway/sense/:config(SenseConfig:mode 灰度三态/特征门/conformal/consumers
  档位映射,mode 非法回落 collect)、errors(EmbedderDown/ArtifactMissing,D-G4 降级)、
  store(tier_observations + sense_artifacts DDL,WAL;观察写入/标签回填/
  labeled 查询/180d 清理/工件登记与 active 切换)、routes(/sense/health 透出灰度状态)
- settings DEFAULTS 增 sense 段(enabled 默认 False,mode 默认 collect——D-G7)
- api.py include_router 门控(装配失败不拖垮主应用)
- 测试 +5:门控 404/DDL 幂等/配置缺省与 mode 回落/独立挂载 health/
  观察写入-回填-计数-清理链路,全量 375 passed
This commit is contained in:
tzt
2026-09-05 11:07:04 +08:00
parent 3e1f187380
commit c3efa70da2
9 changed files with 426 additions and 0 deletions
+10
View File
@@ -214,6 +214,16 @@ try:
except Exception as _pe: # pragma: no cover - 代理层装配失败不拖垮主应用
print(f"[gateway] 代理层未启用({_pe}")
# 语义分析器(T-G0D-G7sense.enabled=False 时不注册任何路由)
try:
from gateway.sense import build_sense_router
from gateway.sense.config import build_sense_config
_sense_cfg = build_sense_config(settings_store().to_dict())
if _sense_cfg.enabled:
app.include_router(build_sense_router(_sense_cfg))
except Exception as _se: # pragma: no cover
print(f"[gateway] 语义分析器未启用({_se}")
@app.get("/", response_class=HTMLResponse, tags=["ui"])
async def index():
"""Vue SPA 的 index.htmlFastAPI API 路由优先,此处仅作 fallback)。"""