feat: Docker 打包、交付链路与命名脱敏
镜像与构建 - 六阶段 Dockerfile(base/wheels/deps/manifest/core|guard),core 不含 torch - 构建期自证:gen_manifest --strict 拦未登记模块,core 阶段重算 sha256 - compose 四服务 host 网络(llm.url 强制回环),config.core/local 可挂载覆盖 无 docker 环境的四段链路 - pull_oci_image.py 直拉 OCI 镜像 rootfs(纯标准库,走加速器) - replay_image_build.sh 按 stage chroot 重放 Dockerfile - run_image_chroot.sh 等价 docker run(uid 10001 + 入口 + host 网络) - pack_image.py 封成 docker save 格式包,自带 diff_id 校验 交付 - make_package.sh 生成自包含目录:镜像包 + 溯源清单 + 构建输入 + 脚本 + 源码快照 - 文档:从零复现指南、docker 打包方案、镜像构建限制与替代方案、交付包 README 命名 - Qwen 品牌名统一替换为 large_model / small_model / large_model_guard, 覆盖 vLLM 服务名、模型目录、配置、脚本、测试与文档 - 模型架构字段(architectures / model_type / tokenizer_class)属上游定义, 改名会导致加载失败,保留原值;check_local_model.py 的架构判断同理 验证:smoke 6/6;test.py 20 通过 0 失败 1 警告;gen --strict 67 文件 / 22 进镜像
This commit is contained in:
1 parent
bfdc5e9168
commit
b82e44ec32
46 files changed
+10271
-484
No files matched your search
@@ -0,0 +1,45 @@
|
||||
# 编排参数:复制为仓库根的 .env 后按机器改
|
||||
#
|
||||
# cp deploy/docker/.env.example .env
|
||||
#
|
||||
# compose 会自动读取同目录的 .env;.dockerignore 已排除它,不会进镜像。
|
||||
|
||||
# --------------------------------------------------------------------------- #
|
||||
# 端口:所有服务都是 network_mode: host,端口直接监听在宿主,没有 ports: 映射。
|
||||
# 网关 → deploy/docker/config.core.yaml 的 listen_port(默认 8080)
|
||||
# vLLM → docker-compose.yml 里各自的 --port(8001 / 8003 / 8005)
|
||||
# 客户端与 APISIX 都打宿主 IP:8080。
|
||||
# --------------------------------------------------------------------------- #
|
||||
|
||||
# --------------------------------------------------------------------------- #
|
||||
# 模型根目录:下面三个模型都在它下面,按子目录名找
|
||||
# ${MODEL_DIR}/large_model 基础模型,client 侧 model=large_model
|
||||
# ${MODEL_DIR}/small_model 0.6B 守卫,一级判定
|
||||
# ${MODEL_DIR}/large_model_guard 8B 守卫(LoRA 合并版),二级复核
|
||||
# 相对路径按仓库根解析;用绝对路径更稳。
|
||||
# --------------------------------------------------------------------------- #
|
||||
MODEL_DIR=./models
|
||||
|
||||
# --------------------------------------------------------------------------- #
|
||||
# GPU 分配:填 nvidia-smi 里的编号。每个服务独占一张卡最省心。
|
||||
# 卡少时按《从零复现指南》附录 B 把 0.6B 与 8B 守卫并到同一张卡,并下调
|
||||
# docker-compose.yml 里的 --gpu-memory-utilization。
|
||||
# --------------------------------------------------------------------------- #
|
||||
GPU_UPSTREAM=0
|
||||
GPU_GUARD06=1
|
||||
GPU_GUARD8=2
|
||||
|
||||
# --------------------------------------------------------------------------- #
|
||||
# 构建参数
|
||||
# --------------------------------------------------------------------------- #
|
||||
# 1 = 额外装 LibreOffice(约 +400 MB),只有需要审 .doc 老格式附件时才开
|
||||
WITH_DOC_CONVERTER=0
|
||||
|
||||
# 溯源用:写进镜像 OCI label,不参与构建缓存
|
||||
GIT_REV=unknown
|
||||
BUILD_TIME=unknown
|
||||
|
||||
# --------------------------------------------------------------------------- #
|
||||
# 仅 --profile local(进程内 transformers 过渡形态)需要
|
||||
# --------------------------------------------------------------------------- #
|
||||
MODEL_06=./models/small_model
|
||||
@@ -0,0 +1,122 @@
|
||||
# 容器内配置(core 目标:全部判定走 vLLM HTTP)
|
||||
#
|
||||
# 挂载点固定为 /service/config.yaml,这样 plugins/ 的相对路径仍然按
|
||||
# /service/plugins 解析(load_settings 的插件路径是相对配置文件所在目录的)。
|
||||
#
|
||||
# 前提:docs/目前方案说明.md §6 的 4 处补丁已应用,否则 backend: vllm
|
||||
# 会直接过不了 config 校验(LLMConfig.backend 目前只接受 transformers)。
|
||||
#
|
||||
# 地址全部写 127.0.0.1,配套 network_mode: host。
|
||||
# 原因:middleware/config.py 的 LLMConfig 校验要求 llm.url 必须是本机回环
|
||||
# (127.0.0.1 / ::1 / localhost)——这是刻意的安全性质,判定服务不许在远端。
|
||||
# 所以编排里所有服务都跑 host 网络,容器与 vLLM 共享同一 network namespace。
|
||||
|
||||
upstream: http://127.0.0.1:8001
|
||||
listen_host: 0.0.0.0
|
||||
listen_port: 8080
|
||||
|
||||
limits:
|
||||
max_sessions: 4
|
||||
hook_timeout_seconds: 120
|
||||
upstream_timeout_seconds: 120
|
||||
max_attachment_files: 8
|
||||
max_attachment_fields: 128
|
||||
max_attachment_text_bytes: 1048576
|
||||
max_attachment_unpacked_bytes: 33554432
|
||||
max_attachment_zip_entries: 2048
|
||||
attachment_timeout_seconds: 30
|
||||
max_attachment_reads: 64
|
||||
|
||||
# 两个守卫都是独立 vLLM 服务,中间层不加载任何权重
|
||||
llm:
|
||||
- id: guard_model
|
||||
type: guard
|
||||
backend: vllm
|
||||
url: http://127.0.0.1:8003
|
||||
served_model: small_model
|
||||
limits:
|
||||
max_input_tokens: 8192
|
||||
max_new_tokens: 64
|
||||
timeout_seconds: 30
|
||||
max_concurrency: 8 # 属于 limits(LLMLimits 上限 32),写条目顶层会 extra_forbidden
|
||||
queue_size: 32
|
||||
|
||||
- id: guard_8b
|
||||
type: guard
|
||||
backend: vllm
|
||||
url: http://127.0.0.1:8005
|
||||
served_model: large_model_guard
|
||||
# 该模型 max_model_len 就是 4096,别照抄 8192
|
||||
limits:
|
||||
max_input_tokens: 4096
|
||||
max_new_tokens: 64
|
||||
timeout_seconds: 60
|
||||
max_concurrency: 8
|
||||
queue_size: 16
|
||||
|
||||
plugins:
|
||||
- id: file-content-review
|
||||
enabled: false
|
||||
file: plugins/file_content_review.lua
|
||||
match:
|
||||
paths: ["/upload"]
|
||||
config:
|
||||
model: guard_model
|
||||
allowed_extensions: [txt, doc, docx]
|
||||
max_review_bytes: 8192
|
||||
max_files: 8
|
||||
|
||||
- id: network-review
|
||||
enabled: false
|
||||
file: plugins/network_review.lua
|
||||
match:
|
||||
paths: ["/chat/stream"]
|
||||
network:
|
||||
allow:
|
||||
- domain: review.example.com
|
||||
scheme: https
|
||||
ports: [443]
|
||||
timeout_seconds: 5
|
||||
max_response_bytes: 1048576
|
||||
config:
|
||||
url: https://review.example.com/check
|
||||
fields: [messages]
|
||||
headers: {x-api-key: "injected-by-admin"}
|
||||
|
||||
- id: response-guard
|
||||
file: plugins/response_guard.lua
|
||||
match:
|
||||
paths: ["/v1/chat/completions"]
|
||||
llm:
|
||||
# 漏写 guard_8b 的话,宿主不会给它起 adapter,复核会静默退化成单级
|
||||
allow: [guard_model, guard_8b]
|
||||
config:
|
||||
model: guard_model
|
||||
review_model: guard_8b
|
||||
block_status: 400
|
||||
stream_mode: incremental
|
||||
flush_chars: 512
|
||||
force_flush_bytes: 4096
|
||||
max_buffer_bytes: 65536
|
||||
judge_chunk_bytes: 8192
|
||||
check_input: true
|
||||
check_output: true
|
||||
block_controversial: true
|
||||
multiturn_context_bytes: 2048
|
||||
|
||||
- id: stream-redact
|
||||
enabled: false
|
||||
file: plugins/stream_redact.lua
|
||||
match:
|
||||
paths: ["/v1/chat/completions"]
|
||||
config:
|
||||
content_path: choices.*.delta.content
|
||||
max_buffer_bytes: 262144
|
||||
|
||||
- id: request-rewrite
|
||||
enabled: false
|
||||
file: plugins/request_rewrite.lua
|
||||
match:
|
||||
paths: ["/v1/chat/completions"]
|
||||
config:
|
||||
prefix: "[checked] "
|
||||
@@ -0,0 +1,476 @@
|
||||
{
|
||||
"schema": 1,
|
||||
"_comment": [
|
||||
"模块溯源登记表:每个进镜像的文件都必须在这里登记,否则 gen_manifest.py --strict 会让构建失败。",
|
||||
"role 写\"这个模块对链路负什么责任\",probe 写\"怎么在容器里证明它在干活\"。",
|
||||
"新增文件时只改这里,MANIFEST.json 与 docs/模块溯源.md 都由 scripts/gen_manifest.py 生成。"
|
||||
],
|
||||
"image": {
|
||||
"name": "agent-safe-middleware",
|
||||
"version": "0.1.0",
|
||||
"console_script": "agent-safe-middleware",
|
||||
"module_entry": "middleware.cli:main",
|
||||
"targets": [
|
||||
"core",
|
||||
"guard"
|
||||
],
|
||||
"python": "3.12"
|
||||
},
|
||||
"layers": {
|
||||
"wheel": "装进 site-packages 的包代码(pip wheel 产物,镜像里没有源码树)",
|
||||
"image": "直接 COPY 进 /service 的文件(Lua 插件、运行配置)",
|
||||
"build": "只在构建期用,不进运行时镜像",
|
||||
"dev": "开发/测试/部署脚本,不进镜像",
|
||||
"excluded": "仓库里的遗留或历史产物,刻意不进镜像"
|
||||
},
|
||||
"features": [
|
||||
{
|
||||
"name": "HTTP 入口、任意路径转发",
|
||||
"modules": [
|
||||
"middleware/proxy.py",
|
||||
"middleware/cli.py"
|
||||
],
|
||||
"probe": "curl -s -o /dev/null -w '%{http_code}' -X POST :8080/v1/chat/completions -H 'content-type: application/json' -d '{}'"
|
||||
},
|
||||
{
|
||||
"name": "SSE 流式分帧与回写",
|
||||
"modules": [
|
||||
"middleware/sse.py",
|
||||
"middleware/proxy.py"
|
||||
],
|
||||
"probe": "curl -sN :8080/v1/chat/completions -d '{\"stream\":true,...}' | head -3"
|
||||
},
|
||||
{
|
||||
"name": "Lua 插件沙箱与进程隔离",
|
||||
"modules": [
|
||||
"middleware/worker.py",
|
||||
"middleware/runtime.py"
|
||||
],
|
||||
"probe": "ps -ef | grep -c '[p]ython' # 每请求多一个插件子进程"
|
||||
},
|
||||
{
|
||||
"name": "插件 hook 调度、超时、审计日志",
|
||||
"modules": [
|
||||
"middleware/runtime.py"
|
||||
],
|
||||
"probe": "日志里 grep 'plugin_hook.*hook=on_request'"
|
||||
},
|
||||
{
|
||||
"name": "内容安全判定(请求侧 / 响应侧 / 流式增量)",
|
||||
"modules": [
|
||||
"plugins/response_guard.lua"
|
||||
],
|
||||
"probe": "curl :8080/v1/chat/completions 发恶意句 → 期望 400 content_policy_violation"
|
||||
},
|
||||
{
|
||||
"name": "0.6B 判定 → 8B 二级复核",
|
||||
"modules": [
|
||||
"plugins/response_guard.lua",
|
||||
"middleware/llm.py"
|
||||
],
|
||||
"probe": "同一条恶意句连发两次,看 vllm-guard8(8005) 的 vllm:num_requests_running 是否被拉起;良性句不应触发它"
|
||||
},
|
||||
{
|
||||
"name": "判定模型接入(vLLM HTTP / 进程内 transformers)",
|
||||
"modules": [
|
||||
"middleware/llm.py",
|
||||
"middleware/llm_worker.py"
|
||||
],
|
||||
"probe": "curl -s :8080/readyz # 未就绪会一直 503"
|
||||
},
|
||||
{
|
||||
"name": "插件出口白名单(含 loopback 拒绝)",
|
||||
"modules": [
|
||||
"middleware/network.py"
|
||||
],
|
||||
"probe": "配置里给插件填 127.0.0.1 的 http 目标 → 应被拒"
|
||||
},
|
||||
{
|
||||
"name": "附件登记与文本抽取",
|
||||
"modules": [
|
||||
"middleware/attachments.py",
|
||||
"middleware/extract_worker.py"
|
||||
],
|
||||
"probe": "POST /v1/chat/completions 带 multipart 附件 → /tmp 下出现临时目录"
|
||||
},
|
||||
{
|
||||
"name": "配置加载与路径解析",
|
||||
"modules": [
|
||||
"middleware/config.py"
|
||||
],
|
||||
"probe": "故意把 upstream 写成非法值启动 → 退出码 2 且只打印通用提示(不回显敏感项)"
|
||||
},
|
||||
{
|
||||
"name": "错误契约(不泄漏 payload)",
|
||||
"modules": [
|
||||
"middleware/errors.py"
|
||||
],
|
||||
"probe": "错误响应体只含固定 message,不含插件原文"
|
||||
}
|
||||
],
|
||||
"modules": [
|
||||
{
|
||||
"path": "middleware/__init__.py",
|
||||
"layer": "wheel",
|
||||
"role": "包标记,只有一行模块 docstring,无代码",
|
||||
"config": [],
|
||||
"probe": "python -c 'import middleware; print(middleware.__doc__)'"
|
||||
},
|
||||
{
|
||||
"path": "middleware/cli.py",
|
||||
"layer": "wheel",
|
||||
"role": "进程入口:解析 --config → load_settings → create_app → uvicorn.run(access_log 关掉,避免 query 原文进日志)",
|
||||
"entry": "main",
|
||||
"config": [
|
||||
"listen_host",
|
||||
"listen_port"
|
||||
],
|
||||
"probe": "docker run --rm img --config /service/config.yaml 后看 8080 是否 listening"
|
||||
},
|
||||
{
|
||||
"path": "middleware/config.py",
|
||||
"layer": "wheel",
|
||||
"role": "配置加载与全量校验:dataclass 建树、llm/plugins 段合法性、插件路径按配置文件父目录解析",
|
||||
"config": [
|
||||
"upstream",
|
||||
"limits.*",
|
||||
"llm[]",
|
||||
"plugins[]"
|
||||
],
|
||||
"probe": "配置写错一个字段 → 启动即退出并打印通用错误(不回显敏感值)"
|
||||
},
|
||||
{
|
||||
"path": "middleware/runtime.py",
|
||||
"layer": "wheel",
|
||||
"role": "插件运行时:加载并校验 Lua、按 hook 调度、hook_timeout 超时、审计日志落盘",
|
||||
"config": [
|
||||
"limits.hook_timeout_seconds",
|
||||
"limits.max_sessions"
|
||||
],
|
||||
"probe": "grep 'hook=on_request' 审计日志"
|
||||
},
|
||||
{
|
||||
"path": "middleware/proxy.py",
|
||||
"layer": "wheel",
|
||||
"role": "HTTP 前后端:任意路径 POST 转发上游、请求/响应体装配、SSE 直通、把插件替换结果落到真实响应",
|
||||
"config": [
|
||||
"upstream",
|
||||
"limits.upstream_timeout_seconds"
|
||||
],
|
||||
"probe": "curl -s -o /dev/null -w '%{http_code}' :8080/v1/models → 200"
|
||||
},
|
||||
{
|
||||
"path": "middleware/sse.py",
|
||||
"layer": "wheel",
|
||||
"role": "SSE 字节级分帧:只切 data: 帧边界,不解析应用数据,保证增量判定能拿到整帧",
|
||||
"probe": "流式请求首帧延迟应随上游产出而不是整条结束"
|
||||
},
|
||||
{
|
||||
"path": "middleware/worker.py",
|
||||
"layer": "wheel",
|
||||
"role": "插件子进程:起 Lua 5.4 沙箱(清掉 os/io/debug),只暴露 host.* 能力,IPC 走 JSON 不用 pickle",
|
||||
"probe": "ps -ef 里每请求多一个 python 子进程;插件里 print(io) 应为 nil"
|
||||
},
|
||||
{
|
||||
"path": "middleware/llm.py",
|
||||
"layer": "wheel",
|
||||
"role": "Python 侧 LLM 注册表:按 backend 分派 transformers / vLLM adapter,管并发、队列、超时,并把输出压成 {safety,categories,refusal}",
|
||||
"config": [
|
||||
"llm[].backend",
|
||||
"llm[].url",
|
||||
"llm[].served_model",
|
||||
"llm[].limits.*",
|
||||
"llm[].load.*"
|
||||
],
|
||||
"probe": "curl :8080/readyz → ready 表示所有 llm 端点已探活"
|
||||
},
|
||||
{
|
||||
"path": "middleware/llm_worker.py",
|
||||
"layer": "wheel",
|
||||
"role": "进程内 transformers 模型进程(只 guard 目标用;core 目标永不 import,torch 不进镜像)",
|
||||
"config": [
|
||||
"llm[].file",
|
||||
"llm[].device"
|
||||
],
|
||||
"probe": "core 镜像里 python -c 'import torch' 应失败"
|
||||
},
|
||||
{
|
||||
"path": "middleware/network.py",
|
||||
"layer": "wheel",
|
||||
"role": "插件出口审批:域名/端口白名单逐项校验,loopback 一律拒绝(所以 host.http 打不到本机 vLLM)",
|
||||
"config": [
|
||||
"plugins[].network.allow"
|
||||
],
|
||||
"probe": "把插件 http 目标设成 127.0.0.1 → 被拒"
|
||||
},
|
||||
{
|
||||
"path": "middleware/attachments.py",
|
||||
"layer": "wheel",
|
||||
"role": "请求作用域附件登记表:保存 multipart 原文供插件按次读取,离开请求即销毁",
|
||||
"config": [
|
||||
"limits.max_attachment_*"
|
||||
],
|
||||
"probe": "/tmp 下每次上传出现独立临时目录,请求结束消失"
|
||||
},
|
||||
{
|
||||
"path": "middleware/extract_worker.py",
|
||||
"layer": "wheel",
|
||||
"role": "一次性子进程里做有界文本抽取(docx 等),解析器不进宿主进程,防解析漏洞波及网关",
|
||||
"config": [
|
||||
"limits.attachment_timeout_seconds"
|
||||
],
|
||||
"probe": "上传超大 docx → 应超时返回固定错误而不是 OOM"
|
||||
},
|
||||
{
|
||||
"path": "middleware/errors.py",
|
||||
"layer": "wheel",
|
||||
"role": "错误契约:PolicyBlocked / Overloaded / PluginFailure 等固定类型,保证错误体不含插件文本与 payload",
|
||||
"probe": "拦截响应体只有固定 message 与 code"
|
||||
},
|
||||
{
|
||||
"path": "middleware/scenario_runner.py",
|
||||
"layer": "wheel",
|
||||
"role": "JSON 场景回放:用真实中间层跑断言(测试工具,随包发布但不参与请求路径)",
|
||||
"probe": "python -m middleware.scenario_runner --help"
|
||||
},
|
||||
{
|
||||
"path": "middleware/lua/agent_protocol.lua",
|
||||
"layer": "wheel",
|
||||
"role": "内置协议适配器(不是规则插件):把 run_completed 等终态事件压成一条、拒绝重复终结,防宿主重复收尾;runtime.py:311 以内置 id __protocol_adapter__ 加载,随 wheel 的 package-data 安装",
|
||||
"probe": "审计日志里每个请求都有 plugin=__protocol_adapter__ hook=close 一行"
|
||||
},
|
||||
{
|
||||
"path": "plugins/response_guard.lua",
|
||||
"layer": "image",
|
||||
"role": "唯一启用的内容安全插件:请求侧判 Unsafe 后换成无害 stub(原文不出网关),响应侧把结果 replace 成 400;流式按 512 字符/4096 强制 flush 做增量判定;0.6B 判 Unsafe 再问 8B 复核",
|
||||
"config": [
|
||||
"plugins[response-guard].config.*",
|
||||
"plugins[response-guard].llm.allow"
|
||||
],
|
||||
"probe": "恶意句 → 400 content_policy_violation;良性句 → 200 且正文完整"
|
||||
},
|
||||
{
|
||||
"path": "plugins/stream_redact.lua",
|
||||
"layer": "image",
|
||||
"role": "全缓冲 SSE 的 PII 兜底脱敏(enabled: false,未启用)",
|
||||
"probe": "配置里 enabled 改 true 后验证 PII 被星号替换"
|
||||
},
|
||||
{
|
||||
"path": "plugins/file_content_review.lua",
|
||||
"layer": "image",
|
||||
"role": "附件内容审核(enabled: false;依赖宿主没有的 host.files,属于旧协议遗留)",
|
||||
"probe": "保持 false;启用会因缺少 host.files 在加载期报错"
|
||||
},
|
||||
{
|
||||
"path": "plugins/network_review.lua",
|
||||
"layer": "image",
|
||||
"role": "外部审核服务白名单转发(enabled: false,旧协议遗留)",
|
||||
"probe": "保持 false"
|
||||
},
|
||||
{
|
||||
"path": "plugins/request_rewrite.lua",
|
||||
"layer": "image",
|
||||
"role": "给最后一条 user 消息加固定前缀(enabled: false,示例插件)",
|
||||
"probe": "启用后上游收到的 transcript 带前缀"
|
||||
},
|
||||
{
|
||||
"path": "plugins/file_read_log.lua",
|
||||
"layer": "image",
|
||||
"role": "附件读取测试桩:通过 host.files 读一次并打日志(18 行,enabled: false)",
|
||||
"probe": "启用后审计日志出现读取记录"
|
||||
},
|
||||
{
|
||||
"path": "config.yaml",
|
||||
"layer": "image",
|
||||
"role": "运行配置:upstream 地址、limits、两个守卫模型端点、启用哪些插件。镜像里是版本化默认值,部署时必须挂卷覆盖(清单标记 overridable,覆盖不算篡改)",
|
||||
"probe": "docker inspect 看挂载;changing it 后 /readyz 会重新探活",
|
||||
"overridable": true
|
||||
},
|
||||
{
|
||||
"path": "pyproject.toml",
|
||||
"layer": "build",
|
||||
"role": "打包元数据:依赖版本、console script(agent-safe-middleware = middleware.cli:main)、可选 guard extra",
|
||||
"probe": "pip show agent-safe-middleware"
|
||||
},
|
||||
{
|
||||
"path": "requirements.txt",
|
||||
"layer": "build",
|
||||
"role": "core 依赖清单(7 个包,无 torch/transformers),镜像装它",
|
||||
"probe": "pip list --format=freeze 与文件逐行比对"
|
||||
},
|
||||
{
|
||||
"path": "requirements-guard.txt",
|
||||
"layer": "build",
|
||||
"role": "guard 目标额外依赖(transformers),core 不装",
|
||||
"probe": "core 镜像里 pip list 不应出现 transformers"
|
||||
},
|
||||
{
|
||||
"path": "test.py",
|
||||
"layer": "dev",
|
||||
"role": "全链路自检:P1-P6 装配 + F1-F11 请求路径 + R1 并发,共 21 项",
|
||||
"probe": "python test.py --no-start # 对容器化的 8080 直接跑"
|
||||
},
|
||||
{
|
||||
"path": "scripts/start_vllm_chain.sh",
|
||||
"layer": "dev",
|
||||
"role": "宿主机侧全链路起停:vLLM 服务 + 中间层,子命令 up/mw/all/status/check/logs/down",
|
||||
"probe": "bash scripts/start_vllm_chain.sh status"
|
||||
},
|
||||
{
|
||||
"path": "scripts/gen_manifest.py",
|
||||
"layer": "dev",
|
||||
"role": "本清单的生成器与校验器(gen / verify),镜像里也放一份以便运行时自证",
|
||||
"probe": "python scripts/gen_manifest.py verify"
|
||||
},
|
||||
{
|
||||
"path": "scripts/merge_guard_lora.py",
|
||||
"layer": "dev",
|
||||
"role": "把守卫 LoRA 合进基础 8B,产出 vLLM 可直接加载的 large_model_guard;--compare 可逐张量比对既有权重",
|
||||
"probe": "python scripts/merge_guard_lora.py --base models/large_model --adapter models/large_model_lora --out /tmp/x --dry-run"
|
||||
},
|
||||
{
|
||||
"path": "scripts/preflight.sh",
|
||||
"layer": "dev",
|
||||
"role": "空机落地预检:驱动/容器运行时/显存/磁盘/端口/仓库文件/模型就位,阻塞项非零退出",
|
||||
"probe": "bash scripts/preflight.sh"
|
||||
},
|
||||
{
|
||||
"path": "scripts/wait_ready.sh",
|
||||
"layer": "dev",
|
||||
"role": "端点就绪轮询:vLLM 加载 8B 需 60-180s,按截止时间等而不是固定 sleep",
|
||||
"probe": "bash scripts/wait_ready.sh --timeout 5 x=http://127.0.0.1:8080/readyz"
|
||||
},
|
||||
{
|
||||
"path": "scripts/smoke.sh",
|
||||
"layer": "dev",
|
||||
"role": "部署后行为冒烟:探活 + 良性放行 + 中英恶意拦截 + 流式拦截 + 拦截后恢复,共 6 项",
|
||||
"probe": "bash scripts/smoke.sh --base http://127.0.0.1:8080"
|
||||
},
|
||||
{
|
||||
"path": "scripts/pull_oci_image.py",
|
||||
"layer": "dev",
|
||||
"role": "不依赖 docker 从 OCI Registry 直拉镜像 rootfs(纯标准库),用于在无容器运行时的机器上验证 base 阶段",
|
||||
"probe": "python scripts/pull_oci_image.py --help"
|
||||
},
|
||||
{
|
||||
"path": "scripts/replay_image_build.sh",
|
||||
"layer": "dev",
|
||||
"role": "按 Dockerfile 各 stage 逐条重放到镜像 rootfs(chroot),在 docker 不可用时验证构建是否成立",
|
||||
"probe": "bash scripts/replay_image_build.sh --help"
|
||||
},
|
||||
{
|
||||
"path": "scripts/run_image_chroot.sh",
|
||||
"layer": "dev",
|
||||
"role": "无容器运行时时用 chroot 启动镜像 rootfs(uid 10001 + 入口脚本 + host 网络),等价 docker run",
|
||||
"probe": "bash scripts/run_image_chroot.sh --help"
|
||||
},
|
||||
{
|
||||
"path": "scripts/pack_image.py",
|
||||
"layer": "dev",
|
||||
"role": "把 chroot 重放的 rootfs 封成 docker save 格式镜像包(纯标准库、零特权),补上无 dockerd 时无法产出镜像的缺口;自带层 sha256 与 diff_id 比对",
|
||||
"probe": "python scripts/pack_image.py --help"
|
||||
},
|
||||
{
|
||||
"path": "scripts/make_package.sh",
|
||||
"layer": "dev",
|
||||
"role": "把交付物整理成自包含目录:镜像包 + 溯源清单 + 构建输入 + 脚本 + 文档 + 源码快照,并生成 SHA256SUMS",
|
||||
"probe": "bash scripts/make_package.sh --help"
|
||||
},
|
||||
{
|
||||
"path": "deploy/docker/modules.json",
|
||||
"layer": "dev",
|
||||
"role": "本登记表:模块职责、镜像层、配置键、探针的唯一来源",
|
||||
"probe": "python scripts/gen_manifest.py gen --strict"
|
||||
},
|
||||
{
|
||||
"path": "deploy/docker/config.core.yaml",
|
||||
"layer": "dev",
|
||||
"role": "容器化配置(core):三处地址写 127.0.0.1 配 network_mode: host,backend 走 vLLM",
|
||||
"probe": "docker compose config 校验"
|
||||
},
|
||||
{
|
||||
"path": "deploy/docker/config.local.yaml",
|
||||
"layer": "dev",
|
||||
"role": "容器化配置(guard):进程内 0.6B,模型挂 /service/models/small_model",
|
||||
"probe": "docker compose --profile local config"
|
||||
},
|
||||
{
|
||||
"path": "Dockerfile",
|
||||
"layer": "dev",
|
||||
"role": "镜像定义:base→wheels/deps→manifest→core/guard 六阶段",
|
||||
"probe": "docker build --target core ."
|
||||
},
|
||||
{
|
||||
"path": "docker-compose.yml",
|
||||
"layer": "dev",
|
||||
"role": "编排:middleware(core)/ middleware-local(guard)/ 三个可选 vLLM",
|
||||
"probe": "docker compose config"
|
||||
},
|
||||
{
|
||||
"path": ".dockerignore",
|
||||
"layer": "dev",
|
||||
"role": "构建上下文裁剪,模型与评测数据不进上下文",
|
||||
"probe": "docker build 日志里 context 传输量应远小于 20MB"
|
||||
},
|
||||
{
|
||||
"path": "tools/verify_plugins.py",
|
||||
"layer": "dev",
|
||||
"role": "插件静态校验(钩子签名、host.* 用法)",
|
||||
"probe": "python tools/verify_plugins.py"
|
||||
},
|
||||
{
|
||||
"path": "tools/check_local_model.py",
|
||||
"layer": "dev",
|
||||
"role": "检查本地模型目录是否完整可加载",
|
||||
"probe": "python tools/check_local_model.py <model_dir>"
|
||||
},
|
||||
{
|
||||
"glob": "tests/*.py",
|
||||
"layer": "dev",
|
||||
"role": "单元/集成测试(pytest),不进镜像",
|
||||
"probe": "pytest -q"
|
||||
},
|
||||
{
|
||||
"glob": "tests/scenarios/*",
|
||||
"layer": "dev",
|
||||
"role": "场景回放用例与夹具:example.json 是被断言的消息序列,fixtures/ 下是附件样例",
|
||||
"probe": "pytest -q tests/test_scenario_runner.py"
|
||||
},
|
||||
{
|
||||
"path": "scripts/verify/negative_cases.py",
|
||||
"layer": "dev",
|
||||
"role": "配置期/启动期负例校验:schema 拒绝、探活失败、llm.allow 未放开时的契约",
|
||||
"probe": "python scripts/verify/negative_cases.py"
|
||||
},
|
||||
{
|
||||
"glob": "scripts/verify/*.sh",
|
||||
"layer": "dev",
|
||||
"role": "人工验证脚本:二级复核 relax / fallback / 输出侧判定的对照实验",
|
||||
"probe": "bash scripts/verify/review_relax.sh"
|
||||
},
|
||||
{
|
||||
"path": "runtime.py",
|
||||
"layer": "excluded",
|
||||
"role": "遗留:根目录旧版错误类型副本(已被 middleware/errors.py 取代),不参与打包",
|
||||
"probe": "grep -rn 'import runtime' middleware/ 应为空"
|
||||
},
|
||||
{
|
||||
"path": "shield_check.py",
|
||||
"layer": "excluded",
|
||||
"role": "历史 ShieldAgent 离线评测脚本(方案已移除该服务)",
|
||||
"probe": "—"
|
||||
},
|
||||
{
|
||||
"path": "shieldagent_review.py",
|
||||
"layer": "excluded",
|
||||
"role": "历史 ShieldAgent 复核实验脚本",
|
||||
"probe": "—"
|
||||
},
|
||||
{
|
||||
"path": "intent_bench_test.py",
|
||||
"layer": "excluded",
|
||||
"role": "意图分类评测脚本(离线实验)",
|
||||
"probe": "—"
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in new issue
Block a user