✨ feat: WP-14 运营收口——诊断双授权、管理面治理、支持包、观测与自托管
- 迁移 16:diagnostic_grant(token 哈希唯一、15 分钟、单次、绑定 Run)+ user.role(user/admin 检查约束) - 诊断双授权(ADR-004):本人签发 grant(明文 token 只返回一次,库存 SHA-256);读取需登录态 + Hunjing-Diagnostic-Token + Purpose 三重匹配;单次消耗(重放 401)、用途不符 403、响应 no-store/private;返回观测摘要(usage/TTFT/工具轨迹)不含消息正文 - 管理面:pending 司议案列表与处置(content_removed 联动下架目标内容——治理闭环);非管理员 403 - 脱敏支持包:统计聚合(runs/messages/tool/media 按状态),无正文无密钥 - 观测:GET /readyz(DB 连通)与 GET /metrics(Prometheus 文本,真实 SQL 聚合) - 自托管:docker/Dockerfile.backend(uv 构建)+ docker-compose.app.yml(hunjing-api + hunjing-postgres 健康依赖、密码经 .env);Makefile 新增 selfhost-up/down、db-dump/db-restore(备份到 backups/) - 测试 94 项全绿(+3):诊断全路径(无令牌/用途不符/成功/单次重放)、管理面处置联动、支持包与指标
This commit is contained in:
1 parent
701c20c783
commit
21eacc8c75
10 files changed
+643
No files matched your search
@@ -0,0 +1,17 @@
|
||||
# Hunjing backend 镜像(uv + slim)
|
||||
FROM python:3.12-slim AS base
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
|
||||
|
||||
# 先装依赖(层缓存)
|
||||
COPY pyproject.toml uv.lock ./
|
||||
RUN uv sync --frozen --no-install-project
|
||||
|
||||
# 源码与引擎绑定(绑定随源构建)
|
||||
COPY . .
|
||||
RUN uv sync --frozen
|
||||
|
||||
EXPOSE 8000
|
||||
CMD ["uv", "run", "uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
|
||||
@@ -0,0 +1,37 @@
|
||||
# 自托管编排(标准服务器档,ADR-024 统一 PostgreSQL)
|
||||
# 用法:docker compose -f docker/docker-compose.app.yml up -d --build
|
||||
services:
|
||||
hunjing-postgres:
|
||||
image: pgvector/pgvector:pg17
|
||||
container_name: hunjing-postgres
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
POSTGRES_USER: hunjing
|
||||
POSTGRES_PASSWORD: ${HUNJING_DB_PASSWORD:?请在 .env 设置 HUNJING_DB_PASSWORD}
|
||||
POSTGRES_DB: hunjing
|
||||
volumes:
|
||||
- hunjing-pgdata:/var/lib/postgresql/data
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U hunjing -d hunjing"]
|
||||
interval: 5s
|
||||
timeout: 3s
|
||||
retries: 12
|
||||
|
||||
hunjing-api:
|
||||
build:
|
||||
context: ../backend
|
||||
dockerfile: ../docker/Dockerfile.backend
|
||||
container_name: hunjing-api
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
hunjing-postgres:
|
||||
condition: service_healthy
|
||||
environment:
|
||||
DATABASE_URL: postgresql+asyncpg://hunjing:${HUNJING_DB_PASSWORD}@hunjing-postgres:5432/hunjing
|
||||
HUNJING_ENV: production
|
||||
HUNJING_LOG_LEVEL: info
|
||||
ports:
|
||||
- "127.0.0.1:8000:8000"
|
||||
|
||||
volumes:
|
||||
hunjing-pgdata:
|
||||
Reference in new issue
Block a user