|
1 | 1 | # 代码-文档契约对照 |
2 | 2 |
|
3 | | -本文档把当前代码事实、生产回读状态和文档维护口径放在同一处,用于减少文档漂移。修改代码或远端配置后,先更新这里,再同步其他文档。 |
| 3 | +本文档把当前代码事实、canonical preview 回读状态和文档维护口径放在同一处,用于减少文档漂移。修改代码或远端配置后,先更新这里,再同步其他文档。 |
4 | 4 |
|
5 | 5 | 最后核对时间:2026-06-03。 |
6 | 6 |
|
7 | | -## 当前生产回读 |
| 7 | +## 当前 canonical preview 回读 |
8 | 8 |
|
9 | 9 | | 项目 | 当前状态 | 证据命令 | |
10 | 10 | | --- | --- | --- | |
|
15 | 15 | | HF Secrets | `MINIO_ROOT_USER`、`MINIO_ROOT_PASSWORD`、`OPS_TOKEN`、`ADMIN_TOKEN` 已存在;HF 不回显 value。 | `hf spaces secrets list BlueSkyXN/libreFS-HFS` | |
16 | 16 | | HF Volume | `bucket BlueSkyXN/librefs-hfs-data -> /data`,`read_only=False` | `hf spaces volumes list BlueSkyXN/libreFS-HFS` | |
17 | 17 |
|
18 | | -生产状态是快照,不是永久保证。涉及实时状态、Secret 同步、Volume 挂载或 runtime sha 时必须重新回读。 |
| 18 | +canonical preview 状态是快照,不是永久保证。涉及实时状态、Secret 同步、Volume 挂载或 runtime sha 时必须重新回读。 |
| 19 | + |
| 20 | +本项目按 HFS v2.1 登记为 `project_class=preview`,canonical Space 的角色是 `primary`。 |
| 21 | +日常 Preview 变更允许直接更新 canonical Space;candidate 只作为高风险变更的可选隔离验证, |
| 22 | +不是常规前置门禁。Secret 必须先写入 manifest 声明的 Git ignored 本地明文文件;HF Secret |
| 23 | +只能作为部署副本,不能成为唯一事实源。 |
19 | 24 |
|
20 | 25 | ## 不可漂移契约 |
21 | 26 |
|
22 | 27 | | 契约点 | 当前事实 | 权威来源 | 文档同步位置 | |
23 | 28 | | --- | --- | --- | --- | |
24 | 29 | | Space 类型 | Docker Space,`app_port: 7860`,`license: agpl-3.0` | `README.md` front matter | `README.md`, `docs/configuration.md`, `docs/deployment-huggingface.md` | |
25 | | -| HFS 范式分类 | HFS v2 Pattern A / `port` / `source`;`version_source=commit`,repo root 同时是 Space root 和 GitHub 维护 root,runtime glue 收在 `hfs/` | `hfs-dev.toml`, `README.md`, `Dockerfile`, `hfs/` | `README.md`, `docs/architecture.md`, `docs/source-walkthrough.md`, `AGENTS.md` | |
| 30 | +| HFS 范式分类 | HFS v2.1 / `preview` / `primary` / Pattern A / `port` / `source`;`version_source=commit`,repo root 同时是 Space root 和 GitHub 维护 root,runtime glue 收在 `hfs/` | `hfs-dev.toml`, `README.md`, `Dockerfile`, `hfs/` | `README.md`, `docs/architecture.md`, `docs/source-walkthrough.md`, `AGENTS.md` | |
26 | 31 | | Runtime 获取模式 | `bundle-only-build`;Docker build 只能从 clean wrapper bundle 读取 provenance,并从 libreFS upstream `git fetch` 其记录的 source commit 后编译 | `hfs-dev.toml`, `Dockerfile` | `README.md`, `docs/architecture.md`, `docs/development-plan.md` | |
27 | 32 | | Source wrapper provenance | 受控发布只上传由 clean immutable wrapper commit 导出的 allowlisted bundle;`BUILD_SOURCE.json` 和 `SHA256SUMS` 被 Docker image 保存,startup 校验 wrapper SHA、libreFS source SHA、digest 和 schema,`/_ops/version` 只返回无密 provenance 摘要 | `scripts/export-space-bundle.sh`, `scripts/verify-space-bundle.sh`, `Dockerfile`, `hfs/start.sh`, `hfs/ops_service.py` | `README.md`, `docs/deployment-huggingface.md`, `docs/operations.md`, `docs/source-walkthrough.md` | |
28 | 33 | | 外部端口 | 只暴露 `7860` | `Dockerfile` `EXPOSE 7860`,`hfs/nginx.conf` `listen 7860` | 全部 endpoint/port 文档 | |
29 | 34 | | 构建策略 | Ubuntu builder/runtime,从 `https://github.com/libreFS/libreFS.git` 拉源码编译,不使用官方 image | `Dockerfile` | `README.md`, `docs/architecture.md`, `docs/source-walkthrough.md` | |
30 | 35 | | Go 版本 | `GO_VERSION=1.26.3` | `Dockerfile` | `docs/configuration.md`, `docs/source-walkthrough.md`, `docs/deployment-huggingface.md` | |
31 | 36 | | libreFS ref | bundle-only build 必须同时使用 `HFS_RELEASE_BUILD=true`、`LIBREFS_COMMIT=<upstream commit sha>` 与 bundle 内相同的 `librefs_source_commit`;Docker build 会直接 fetch/checkout 并校验 `git rev-parse HEAD` | `Dockerfile`, `hfs-dev.toml` | `docs/configuration.md`, `docs/troubleshooting.md`, `docs/development-plan.md` | |
32 | | -| Release hardening | HFS v2 registry不复制 product pin;受控 build 通过 `HFS_RELEASE_BUILD=true` + `LIBREFS_COMMIT=<40 位 SHA>` 固定 upstream。Go tarball checksum 和 Ubuntu base image digest仍是后续 hardening,不改当前 runtime | `Dockerfile`, `hfs-dev.toml` | `docs/configuration.md`, `docs/development-plan.md` | |
| 37 | +| Release hardening | HFS v2.1 registry不复制 product pin;受控 build 通过 `HFS_RELEASE_BUILD=true` + `LIBREFS_COMMIT=<40 位 SHA>` 固定 upstream。Go tarball checksum 和 Ubuntu base image digest仍是后续 hardening,不改当前 runtime | `Dockerfile`, `hfs-dev.toml` | `docs/configuration.md`, `docs/development-plan.md` | |
33 | 38 | | Runtime packages | `bash`、`ca-certificates`、`curl`、`nginx`、`python3`、`tini` | `Dockerfile` | `docs/architecture.md`, `docs/source-walkthrough.md` | |
34 | 39 | | Runtime user | UID/GID `1000`,存在则复用,不无条件创建 | `Dockerfile` | `docs/source-walkthrough.md`, `docs/troubleshooting.md` | |
35 | 40 | | 必需启动 Secrets | 只有 `MINIO_ROOT_USER` 和 `MINIO_ROOT_PASSWORD` 缺失会让 `hfs/start.sh` 立即退出 | `hfs/start.sh` | `docs/configuration.md`, `docs/deployment-huggingface.md`, `docs/troubleshooting.md` | |
36 | | -| Ops token | `OPS_TOKEN` 默认 `librefs_ops_demo_token`,生产应使用 HF Secret 覆盖 | `hfs/start.sh`, `hfs/ops_service.py` | `README.md`, `docs/configuration.md`, `docs/operations.md` | |
37 | | -| Admin 开关 | 代码默认 `ADMIN_ENABLED=false`;当前生产回读为 `ADMIN_ENABLED=true` | `hfs/start.sh`, HF Variables | `README.md`, `docs/configuration.md`, `docs/operations.md`, `docs/troubleshooting.md` | |
| 41 | +| Ops token | `OPS_TOKEN` 默认 `librefs_ops_demo_token`;共享或长期运行的 preview 应使用本地明文先行的 HF Secret 覆盖 | `hfs/start.sh`, `hfs/ops_service.py` | `README.md`, `docs/configuration.md`, `docs/operations.md` | |
| 42 | +| Admin 开关 | 代码默认 `ADMIN_ENABLED=false`;当前 canonical preview 回读为 `ADMIN_ENABLED=true` | `hfs/start.sh`, HF Variables | `README.md`, `docs/configuration.md`, `docs/operations.md`, `docs/troubleshooting.md` | |
38 | 43 | | Admin token | 开启 admin 时必须设置 `ADMIN_TOKEN`;使用 `X-Admin-Token` 或 bearer token;代码不强制它与 `OPS_TOKEN` 不同 | `hfs/admin_service.py` | `docs/configuration.md`, `docs/operations.md`, `docs/architecture.md` | |
39 | 44 | | 公开 URL 推导 | `PUBLIC_BASE_URL` > `SPACE_HOST` > `http://localhost:7860` | `hfs/start.sh` | `docs/architecture.md`, `docs/configuration.md`, `docs/source-walkthrough.md` | |
40 | 45 | | `MINIO_SERVER_URL` | 必须有 `http://` 或 `https://`,并去掉尾部 `/` | `hfs/start.sh` | `docs/architecture.md`, `docs/configuration.md`, `docs/source-walkthrough.md` | |
|
49 | 54 | | Admin 写操作 | `reload-nginx` 是写 action,必须 JSON body `{"confirm": true}`,并写审计日志 | `hfs/admin_service.py` | `docs/architecture.md`, `docs/configuration.md`, `docs/operations.md` | |
50 | 55 | | Admin 非目标 | 没有 Web terminal、file manager、bucket/policy/root credential 管理或 `librefs` restart | `hfs/admin_service.py`, 当前路由 | `README.md`, `docs/architecture.md`, `docs/configuration.md`, `docs/usage.md`, `docs/operations.md` | |
51 | 56 | | 双语文案 | 支持 `en` 和 `zh-CN`;语言优先级为 `?lang=`、`X-Control-Language`、`Accept-Language`、`CONTROL_PLANE_DEFAULT_LANG`、默认 `en` | `hfs/ops_service.py`, `hfs/admin_service.py` | `README.md`, `docs/configuration.md`, `docs/operations.md`, `docs/architecture.md` | |
52 | | -| 数据目录 | libreFS 数据默认在 `/data`;admin audit log 默认在 `/tmp/librefs-hfs/admin-audit.jsonl`;当前生产挂载 Storage Bucket 到 `/data` | `hfs/start.sh`, `hfs/admin_service.py`, HF Volumes | `README.md`, `docs/architecture.md`, `docs/operations.md`, `docs/usage.md` | |
| 57 | +| 数据目录 | libreFS 数据默认在 `/data`;admin audit log 默认在 `/tmp/librefs-hfs/admin-audit.jsonl`;当前 canonical preview 挂载 Storage Bucket 到 `/data` | `hfs/start.sh`, `hfs/admin_service.py`, HF Volumes | `README.md`, `docs/architecture.md`, `docs/operations.md`, `docs/usage.md` | |
53 | 58 | | 持久化口径 | Volume 挂载不等于持久化验收通过;仍需上传、重启、读取、rebuild、再读取 | 运维要求 | 所有持久化说明 | |
54 | 59 | | S3 smoke | `scripts/smoke-s3-curl.sh` 会真实创建临时 bucket/object、设置 public read policy 并清理 | `scripts/smoke-s3-curl.sh` | `docs/README.md`, `docs/operations.md`, `docs/source-walkthrough.md` | |
55 | 60 | | 契约验证 | `scripts/validate-contract.sh` 检查 front matter、Dockerfile、`hfs/start.sh`、Python、Nginx、license 和可选远端 health | `scripts/validate-contract.sh` | `docs/README.md`, `docs/operations.md`, `docs/source-walkthrough.md` | |
56 | 61 |
|
57 | 62 | ## 文档维护规则 |
58 | 63 |
|
59 | | -1. 区分“代码默认值”和“当前生产配置”。例如 `ADMIN_ENABLED` 代码默认是 `false`,但当前生产是 `true`。 |
| 64 | +1. 区分“代码默认值”和“当前 canonical preview 配置”。例如 `ADMIN_ENABLED` 代码默认是 `false`,但当前 preview 快照是 `true`。 |
60 | 65 | 2. 不把 Secret 明文写入文档。HF CLI 只能证明 key 存在;value 同步必须用受保护本机 `.env` 的值调线上接口验证。 |
61 | 66 | 3. 不把 health check 写成 S3 功能验收。S3 写入、下载、policy 和匿名直链必须用凭证型 smoke test 验证。 |
62 | 67 | 4. 不把 Volume 挂载写成持久化已验收。必须完成重启和 rebuild 后读回。 |
63 | 68 | 5. 修改 `hfs/ops_service.py` 或 `hfs/admin_service.py` 时,同步检查 `docs/configuration.md`、`docs/operations.md`、`docs/architecture.md` 和本文档。 |
64 | | -6. 修改远端 HF Variables、Secrets 或 Volume 后,同步更新“当前生产回读”,并保留“代码默认值”不变。 |
| 69 | +6. 修改远端 HF Variables、Secrets 或 Volume 后,同步更新“当前 canonical preview 回读”,并保留“代码默认值”不变。 |
0 commit comments