feat(infra): 落地 M01 基础框架与本机开发环境

交付 FastAPI/Celery/Vue 薄壳、FORCE RLS、Compose 回环与 review 修复证据,关闭 M01 DONE_LOCAL。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
unknownandCursor committed 2026-11-17 15:00:39 +08:00
1 parent 8b2a809f06
commit 8fb16f4a4a
97 files changed
+8059 -22

No files matched your search

+14
View File
@@ -0,0 +1,14 @@
.venv
**/__pycache__
**/*.pyc
.git
.task
web/node_modules
**/node_modules
docs/evidence
local-data
.env.local
*.log
.pytest_cache
.mypy_cache
.ruff_cache
+26
View File
@@ -0,0 +1,26 @@
# Copy to .env.dev / .env.local and replace placeholders.
# .env.local is never committed.
# Bootstrap only (local superuser). Prefer system env or .env.local.
WATCHMAN_BOOTSTRAP_DATABASE_URL=postgresql+psycopg://postgres:CHANGE-ME@127.0.0.1:5432/postgres
# App and migrator roles (not the bootstrap superuser)
WATCHMAN_MIGRATOR_PASSWORD=CHANGE-ME
WATCHMAN_APP_PASSWORD=CHANGE-ME
DATABASE_URL=postgresql+psycopg://watchman_app:CHANGE-ME@127.0.0.1:5432/watchman
DATABASE_MIGRATOR_URL=postgresql+psycopg://watchman_migrator:CHANGE-ME@127.0.0.1:5432/watchman
# Server-injected tenant for M01; keep out of committed shared env.
WATCHMAN_TENANT_ID=dev-tenant
# Queue (host processes talk to published RabbitMQ port).
# DEV ONLY: RabbitMQ image default guest/guest — never reuse in non-local brokers.
CELERY_BROKER_URL=amqp://guest:guest@127.0.0.1:56729//
# Compose app profile overrides (gitignored .env.local only)
# DEV ONLY guest/guest for the local compose RabbitMQ service.
CELERY_BROKER_URL_DOCKER=amqp://guest:guest@rabbitmq:5672//
DATABASE_URL_DOCKER=postgresql+psycopg://watchman_app:CHANGE-ME@host.docker.internal:5432/watchman
DATABASE_MIGRATOR_URL_DOCKER=postgresql+psycopg://watchman_migrator:CHANGE-ME@host.docker.internal:5432/watchman
COMPOSE_POSTGRES_PASSWORD=CHANGE-ME
+19
View File
@@ -0,0 +1,19 @@
# Shared non-secret defaults for all environments.
# Do not put production secrets in this file.
# 1. Environment and service identity
APP_NAME=watchman
ENV_NAME=dev
# 2. Application runtime
API_HOST=127.0.0.1
API_PORT=8000
# 3. Public addresses / network (dev-only ports; never publish to 0.0.0.0)
CONSOLE_HOST=127.0.0.1
CONSOLE_PORT=5173
# 4. Database names / role names (passwords and tenant id stay in .env.local)
WATCHMAN_DATABASE_NAME=watchman
WATCHMAN_MIGRATOR_USER=watchman_migrator
WATCHMAN_APP_USER=watchman_app
+4
View File
@@ -2,7 +2,9 @@
.env
.env.*
!.env.example
!.env.shared
secrets/
*.pem
*.key
*.p12
@@ -30,6 +32,8 @@ Thumbs.db
playwright/.auth/
test-results/
playwright-report/
web/apps/console/playwright-report/
docs/evidence/M01/ui/test-results/
# Raw local artifacts can contain internal data; keep only reviewed summaries
docs/evidence/**/raw/
+1
View File
@@ -0,0 +1 @@
3.12
@@ -0,0 +1,150 @@
# Task Context Pack
## Task Goal
完成 Watchman M01 基础框架:实现 S1–S7、补齐 critic/review 必改与建议顺带项,并留下可回查证据。
## Knowledge Posture
- Mode: standard
- Maturity: L1
## Current Slice Or Group
当前:review 修复收尾已完成;等待复审结果与用户最终确认。不再扩大 M01 范围。
## Gate Policy
- Recommended: strict
- Selected: autonomous(任务局部)
- finalApprovalRequired: true
- Policy Notes: 分析→编码门禁已过。仓库 `gatePolicy.defaultMode` 保持 balanced(D17)。最终批准仍需用户确认。
## Bugfix Context
不适用(本轮为 review 修复)。
## Requirement Source
`.task/2026-11-17/m01-foundation/requirement.md`
## Implementation Source
`.task/2026-11-17/m01-foundation/implementation-plan.md`
## Involved Modules Or Areas
`services/watchman`、`web/`、`deploy/`、`docs/evidence/M01/`。
## Loaded Context
### Global Rules
AGENTS.md 托管段门禁;sy-standards;密钥不入库。
### Knowledge Map Matches
M01 基础框架。
### Path-Proximity Rules
无模块级 MODULE_RULES。
### Excluded Context
syops 业务代码、M02+、生产部署。
## Loaded Rules
- `standards://api/api-envelope?version=1.1.0`
- `standards://api/error-handling?version=1.1.1`
- `standards://engineering/code-layout?version=1.0.1`
- `standards://engineering/code-comments?version=1.1.1`
- `standards://security/red-line?version=1.1.0`
- `standards://security/env-secrets?version=1.1.1`
- `standards://frontend/frontend-stack?version=2.1.0`
- `standards://frontend/element-plus?version=1.0.2`
- D01、D04、D12–D18
## Loaded Docs
- `docs/tasks/M01.md`
- `docs/decisions.md`
- `docs/runbook.md`
- `docs/evidence/M01/*`
## Execution Mode
- Mode: sequential
- Current Slice Or Group: review-fixup(已实现)
- Parallel Members: 无
- Fallback Order: N/A
- Shared Files: N/A
- Merge Owner: 主 Agent
- Conflict Resolution Rule: 信封与 RLS 语义冻结
- Validation Level: module
## Execution Chain
实现 → 独立 review → 必改/建议修复 → Playwright/pytest → 复审 → 用户最终确认。
## Allowed Modification Scope
- `services/watchman/**`
- `web/**`
- `deploy/**`
- `.env.example`、`.env.shared`
- `docs/tasks/M01.md`、`docs/progress.md`、`docs/runbook.md`、`docs/decisions.md`、`docs/evidence/M01/**`、`docs/handoffs/**`
- `.task/2026-11-17/m01-foundation/**`
- `.gitignore`
## Forbidden Modification Scope
- 提交真实密码
- 写入 `D:\PROJECT\syops`
- 业务模块、Casdoor、vben5、Redis、生产部署
- 未经确认的门禁姿态放宽
- DONE_LOCAL/git commit(除非用户明确要求)
## Key Existing Classes Or Entrypoints
- `python -m watchman api|worker|beat`
- `web/apps/console` Vite 5173
- `/health`、`/platform/*`
## Required Behavior
- 数值信封无额外顶层字段;`/health` 不泄漏机密
- env 分层;启动缺键失败;probe/docs 非生产收口
- FORCE RLS;幂等;调用方不可传租户;commit 后租户重绑
- 前端三态 + 截图证据
## Non-goals
M02 登录、业务规则、真实企微、生产 Compose。
## Implementation Steps
1. (已完成)必改与建议修复。
2. (进行中)独立复审。
3. 用户最终确认后关 M01。
## Validation Commands
- `uv run pytest services/watchman/tests -q`
- `cd web/apps/console && pnpm test:unit && pnpm typecheck && pnpm test:e2e`
## Assumptions
- 本机 Postgres + RabbitMQ Compose 可用。
- `.env.local` 已配置且不入库。
## Risks
- 复审可能再发现残余项。
- 无 commit hash,证据与工作区绑定需靠文件路径与命令输出。
## Stop Conditions
- 复审 FAIL 或用户要求改口径时停止。
- 不自动 DONE_LOCAL/不自动 commit。
@@ -0,0 +1,497 @@
# M01 基础框架 Implementation Plan
## Requirement Source
`.task/2026-11-17/m01-foundation/requirement.md`
## Scope Summary
按已冻结的 M01 需求,顺序建立 uv 与 `web/` 工作区、环境分层、API 信封、带强制 RLS 的两张平台表、Celery 探测进程、管理台薄壳,以及只绑定本机的开发 Compose。不进入业务模块。
## Involved Modules Or Areas
Watchman M01。一个 Python 服务包,API / worker / beat 三个进程。前端是 `web/apps/console` 薄壳。
## Loaded Rules
- Marionettist:本任务 `gatePolicy.selected=autonomous`,`finalApprovalRequired=true`。分析到编码仍须用户确认。`risk_score >= 4` 和 `high-risk` 切片完成后必须停。
- `standards://engineering/code-layout?version=1.0.1`
- `standards://api/api-envelope?version=1.1.0`
- `standards://api/error-handling?version=1.1.1`
- `standards://frontend/frontend-stack?version=2.1.0`
- `standards://frontend/element-plus?version=1.0.2`
- `standards://security/red-line?version=1.1.0`
- `standards://security/env-secrets?version=1.1.1`
- `standards://engineering/code-comments?version=1.1.1`
- `standards://workflow/git-commit?version=1.1.0`
- Watchman D01、D04、D12–D15。
## Loaded Docs
- `docs/tasks/INDEX.md` M01
- `docs/development-plan.md` 技术栈;目录以 D12 为准
- `docs/decisions.md`
- syops 只用于对照,不复制 Flask、Redis worker 或字符串错误码
## Global Forbidden Scope
- `D:\PROJECT\syops` 内的任何写入。
- 业务包:数据源、查询、规则、报警、通知、场景、AI。
- Casdoor 真接入、权限点编码、vben5、Redis。
- 把 API、worker 拆成独立服务或独立数据库。
- 监听 `0.0.0.0`,或把开发端口写进任何非开发配置。
- 真实密钥、生产连接串、修改已合入迁移。
- 为列表分页做协议选择。
## Execution Strategy
- Complexity: complex
- Default Execution: sequential
- Parallel Execution: not-needed
- Fallback Execution: sequential
- Merge Owner: 主 Agent
- Conflict Resolution Rule: 工作区根、锁文件、env 样例和迁移目录由当前切片独占。后一切片不得改前一切片已经冻结的信封字段和 RLS 策略语义。
选择顺序执行,因为根工作区、环境样例和数据库会话会被多个切片碰到。
## Slice Dependency Graph
| Slice | Depends On | Can Run In Parallel With | Fallback Order | Shared Files | Merge Owner | Conflict Risk |
| --- | --- | --- | --- | --- | --- | --- |
| S1 工作区 | 无 | 无 | 1 | 根 `pyproject.toml`、`web/`、`.gitignore` | 主 Agent | high |
| S2 环境分层 | S1 | 无 | 2 | env 样例、`.gitignore` | 主 Agent | high |
| S3 信封 | S1 | 无 | 3 | `services/watchman` | 主 Agent | medium |
| S4 RLS | S2、S3 | 无 | 4 | 迁移、数据库会话 | 主 Agent | high |
| S5 队列 | S2、S4 | 无 | 5 | 同一 Python 包、Compose | 主 Agent | medium |
| S6 薄壳 | S3 | 无 | 6 | `web/` | 主 Agent | medium |
| S7 手册与总验 | S5、S6 | 无 | 7 | `deploy/`、`docs/runbook.md` | 主 Agent | medium |
S6 依赖 S3 的信封,不依赖 S4 的表。仍按上表顺序做,避免和 S5 同时改 Compose。
## Implementation Slices
### Slice 1: 工作区与工具链
#### Goal
建立可安装的 uv 工作区和 pnpm `web/` 工作区,锁定 Python 3.12 候选上的最小依赖。不写业务行为。
#### Allowed Modification Scope
- 根 `pyproject.toml`、`uv.lock`
- `services/watchman/pyproject.toml`
- `services/watchman/src/watchman/` 的空包和进程入口文件
- `web/package.json`、`web/pnpm-workspace.yaml`、`web/pnpm-lock.yaml`
- `web/apps/console` 的空 Vite 应用
- `web/packages/api`、`web/packages/ui-components`、`web/design` 的空包
- `.gitignore` 中与虚拟环境和前端依赖相关的条目
#### Forbidden Scope
- 业务模块、迁移、Compose、页面视觉、密钥文件。
#### Execution
- Mode: sequential
- Depends On: 无
- Can Run With: 无
- Must Not Run With: S2–S7
- Fallback Order: 1
- Shared Files: 根工作区
- Merge Owner: 主 Agent
- Conflict Risk: high
- Gate Class: standard
- Risk Score: 3
- Gate Reasons: new-dependencies
- Validation Level: slice
- Recommended Agent Strategy: 编码模型实现;审查用另一个模型系列
#### Steps
1. 核对 FastAPI、Pydantic v2、SQLAlchemy 2、Alembic、Celery、pytest 与 Python 3.12 的当前兼容版本,把结果写进切片记录。AGPL 依赖不引入。
2. 创建 uv 工作区。只建一个成员:`services/watchman`。入口预留 API、worker、beat,不拆服务。
3. 创建 pnpm 工作区:`web/apps/console`、`web/packages/api`、`web/packages/ui-components`、`web/design`。
4. 生成锁文件。
#### Validation
- `uv lock` 成功。
- `uv run --package watchman python -c "import watchman"` 成功。
- `pnpm install` 在 `web/` 成功,`pnpm -r list` 能看到 console 和两个包。
#### Done Criteria
- 锁文件入库所需的依赖已经固定。
- 还没有健康检查、表和页面行为。
#### Rollback Notes
删除新建的工作区文件和锁文件即可。没有数据库可回滚。
### Slice 2: 环境分层
#### Goal
按公司环境规范提供可提交的无密样例,并让进程从分层 env 读取配置。
#### Allowed Modification Scope
- `.env.shared`
- `.env.example`
- `.gitignore` 的 env 例外
- `services/watchman` 的配置读取模块
- 配置测试
#### Forbidden Scope
- `.env.local`、真实 `.env.dev`、真实密码。
- 监听地址改到非回环。
#### Execution
- Mode: sequential
- Depends On: S1
- Can Run With: 无
- Must Not Run With: S3–S7
- Fallback Order: 2
- Shared Files: `.gitignore`
- Merge Owner: 主 Agent
- Conflict Risk: high
- Gate Class: standard
- Risk Score: 3
- Gate Reasons: secrets-config
- Validation Level: slice
- Recommended Agent Strategy: 编码模型实现
#### Steps
1. `.env.shared` 只放三环境相同且非机密的值,包括开发绑定地址说明。
2. `.env.example` 列出 `.env.dev` 与 `.env.local` 要填的键,值用占位符。
3. 调整忽略规则:提交 `.env.shared` 和 `.env.example`;忽略 `.env.local`、`.env.dev`、`.env.test`、`.env.prod`。
4. 加载顺序实现为:系统环境、`.env.local`、`.env.dev`、`.env.shared`。
5. 开发端口写死为仅开发:API `127.0.0.1:8000`,控制台 `127.0.0.1:5173`,Postgres `127.0.0.1:54329`,RabbitMQ `127.0.0.1:56729`,管理端口 `127.0.0.1:15679`。
#### Validation
- 测试证明 `.env.local` 覆盖 `.env.dev`,`.env.dev` 覆盖 `.env.shared`。
- 仓库检索确认样例不含真实口令、token 或内网账号。
#### Done Criteria
- 缺配置时进程失败并给出键名,不打印其他配置值。
- 开发端口只出现在开发样例和开发 Compose 计划中。
#### Rollback Notes
恢复 `.gitignore` 并删除新的 env 样例和配置模块。
### Slice 3: API 信封与错误
#### Goal
提供健康检查和全局失败信封。路由不手写错误 JSON。
#### Allowed Modification Scope
- `services/watchman/src/watchman/api/`
- `services/watchman/src/watchman/services/` 中的健康服务
- 错误类型、响应构造、请求号中间件
- 对应 pytest
#### Forbidden Scope
- 数据库表、RLS、前端页面、队列任务。
#### Execution
- Mode: sequential
- Depends On: S1
- Can Run With: 无
- Must Not Run With: S4–S7
- Fallback Order: 3
- Shared Files: `services/watchman`
- Merge Owner: 主 Agent
- Conflict Risk: medium
- Gate Class: standard
- Risk Score: 3
- Gate Reasons: public-api-contract
- Validation Level: slice
- Recommended Agent Strategy: 编码模型实现
#### Steps
1. 成功体使用 `success`、`data`、`request_id`。失败体使用 `success=false`、`error`、`request_id`。
2. 错误码只用五段位整数。内部错误对外为 50000。
3. 尊重传入的 `X-Request-Id`;没有则生成。响应头回写同一个值。
4. `GET /health` 返回进程存活,不访问数据库,不返回租户、主机或连接串。
5. 增加一个只用于测试的参数错误路径,确认 40000 由全局处理生成。
#### Validation
- `uv run pytest services/watchman/tests/test_envelope.py`
- 断言成功与 40000、50000 的形状,并断言响应不含 traceback。
#### Done Criteria
- 健康检查和两类失败响应有测试。
- 没有信封例外出口。
#### Rollback Notes
移除 API 包中本切片新增的模块和测试。
### Slice 4: 平台表、租户会话与 RLS
#### Goal
在 PostgreSQL 建立审计事件和运行记录,应用角色被强制 RLS 限制在服务端租户内。
#### Allowed Modification Scope
- `services/watchman/migrations/`
- 数据库会话和租户上下文
- 审计、运行记录的最小写入服务
- RLS 与幂等测试
- 开发 Compose 中仅数据库服务的部分可以在本切片先写出,完整应用服务留到 S7
#### Forbidden Scope
- 报警、查询、场景等业务表。
- 从请求体、查询串或请求头读取租户。
- 用超级用户作为应用连接。
- 修改已经写好的迁移文件;纠正用新迁移。
#### Execution
- Mode: sequential
- Depends On: S2、S3
- Can Run With: 无
- Must Not Run With: S5–S7
- Fallback Order: 4
- Shared Files: 迁移目录、数据库会话
- Merge Owner: 主 Agent
- Conflict Risk: high
- Gate Class: high-risk
- Risk Score: 5
- Gate Reasons: schema, security, rls
- Validation Level: slice
- Recommended Agent Strategy: 独立实现与不同系列审查。本切片结束必须停,即使用户选择了 autonomous。
#### Steps
1. Compose 只启动 PostgreSQL,发布在 `127.0.0.1:54329`。创建迁移角色和应用角色。应用角色不是超级用户,也不是表所有者。
2. 迁移创建审计事件和运行记录。两表都有服务端写入的租户列和幂等键唯一约束。
3. 启用并强制 RLS。策略比较租户列和 `current_setting('app.tenant_id', true)`。
4. 每个应用事务在本地设置 `app.tenant_id`,值只来自服务端配置。
5. 写接口要求 `x-idempotency-key`。重复键返回第一次的结果,不插入第二行。
6. 测试覆盖:未设置租户不可读不可写;其他租户不可见;正确租户可读写;重复键不新增。
#### Validation
- 启动开发 Postgres 后执行迁移。
- `uv run pytest services/watchman/tests/test_rls.py services/watchman/tests/test_idempotency.py`
- 用应用角色手工查询确认没有租户设置时结果为空。
#### Done Criteria
- 空库迁移成功。
- RLS 正反用例通过。
- 健康检查仍然不访问这两张表。
#### Rollback Notes
停掉开发库卷并删除本切片迁移文件。若迁移已被共享环境应用,只能再写一条逆向迁移,不改原文件。
### Slice 5: 队列进程
#### Goal
API 之外的 worker 能连接 RabbitMQ,并注册一个不写业务事实的探测任务。
#### Allowed Modification Scope
- 同一 `services/watchman` 包内的 Celery 入口
- Compose 中的 RabbitMQ 服务,只绑定 `127.0.0.1:56729` 和 `127.0.0.1:15679`
- worker 启动测试
#### Forbidden Scope
- Redis result backend。
- 业务周期任务、报警计数、真实外发。
- 第二个调度框架。
#### Execution
- Mode: sequential
- Depends On: S2、S4
- Can Run With: 无
- Must Not Run With: S6、S7
- Fallback Order: 5
- Shared Files: Python 包、Compose
- Merge Owner: 主 Agent
- Conflict Risk: medium
- Gate Class: standard
- Risk Score: 3
- Gate Reasons: new-infrastructure
- Validation Level: slice
- Recommended Agent Strategy: 编码模型实现
#### Steps
1. Celery broker 指向开发 RabbitMQ。不配置 Redis。
2. 注册一个探测任务,返回静态状态,不写审计表,不增加任何业务次数。
3. beat 进程可以启动,但 M01 不注册业务日程。
#### Validation
- RabbitMQ 容器健康。
- worker 进程启动后能列出探测任务。
- 执行一次探测任务,确认审计表行数不变。
#### Done Criteria
- 三个进程入口都存在,仍然是同一个包。
- 探测任务没有业务副作用。
#### Rollback Notes
停止 RabbitMQ 容器并移除 Celery 入口。不删除 S4 的表。
### Slice 6: 管理台薄壳
#### Goal
本机控制台显示健康检查的加载、成功和失败。四语言目录齐全。不引入后台框架。
#### Allowed Modification Scope
- `web/apps/console`
- `web/packages/api` 的唯一 JSON 客户端
- `web/design/tokens.css` 的最小令牌
- `web/packages/ui-components` 保持空包或只放说明,不放 ProTable
#### Forbidden Scope
- vben5、业务菜单、列表页、第二套组件库。
- 页面内直接 `fetch`。
- 全局 `app.use(ElementPlus)`。
#### Execution
- Mode: sequential
- Depends On: S3
- Can Run With: 无
- Must Not Run With: S7
- Fallback Order: 6
- Shared Files: `web/`
- Merge Owner: 主 Agent
- Conflict Risk: medium
- Gate Class: standard
- Risk Score: 2
- Gate Reasons: none
- Validation Level: slice
- Recommended Agent Strategy: 编码模型实现,并用浏览器核对健康三态
#### Steps
1. 唯一客户端解析信封,失败抛带 `code`、`requestId` 的错误对象。
2. App 根注入一次 Element Plus 语言。页面按需引入用到的组件。
3. 建立 `locales/zh-CN`、`zh-TW`、`en`、`th`。健康文案四份都写上。
4. 页面请求 `/health`,分别呈现加载、成功和失败。
5. 开发服务器只绑 `127.0.0.1:5173`。
#### Validation
- `pnpm --filter console exec vue-tsc --noEmit`
- 浏览器打开本机控制台:API 可用时看到成功;API 停掉时看到失败;请求未完成时看到加载。
- 抽查一种非默认语言,健康文案不是硬编码中文。
#### Done Criteria
- 三态都实际看过,不只看截图。
- 四语言目录和 `errors.json` 骨架存在。
#### Rollback Notes
恢复 `web/apps/console` 到 S1 的空应用,保留工作区结构。
### Slice 7: 开发手册与总验
#### Goal
把 API、worker、beat、前端和两个基础设施服务收成一条开发手册,并跑本模块测试。
#### Allowed Modification Scope
- `deploy/compose.dev.yml`
- `docs/runbook.md`
- 根 README 里指向手册的短节
- `docs/tasks/M01.md` 的证据栏
- `docs/progress.md`
#### Forbidden Scope
- 生产 Compose、域名 443 配置、业务服务。
- 把 `0.0.0.0` 写进 Compose。
#### Execution
- Mode: sequential
- Depends On: S5、S6
- Can Run With: 无
- Must Not Run With: 无
- Fallback Order: 7
- Shared Files: `deploy/`、文档
- Merge Owner: 主 Agent
- Conflict Risk: medium
- Gate Class: standard
- Risk Score: 3
- Gate Reasons: dev-runtime
- Validation Level: final
- Recommended Agent Strategy: 主 Agent 汇总证据;测试由独立执行完成
#### Steps
1. Compose 包含 Postgres、RabbitMQ、API、worker、beat。端口只发布到 127.0.0.1,并在文件头标明仅开发。
2. 手册写明启动、迁移、测试和停止命令。
3. 跑后端测试、前端类型检查,并按 S6 再看一次健康三态。
#### Validation
- `docker compose -f deploy/compose.dev.yml config`
- 手册中的测试命令实际执行并记录退出码。
- 容器未启动时记录未运行,不记通过。
#### Done Criteria
- 手册命令和实际命令一致。
- M01 仍不声称业务模块或真实登录已经完成。
#### Rollback Notes
停止 Compose 并删除开发卷。文档可以回退到本切片之前。
## Parallel Slice Groups
没有并行组。
## Final Validation
- 信封测试、RLS 测试、幂等测试、worker 探测测试通过。
- `vue-tsc` 通过。
- 浏览器确认健康三态。
- `docker compose config` 通过,发布地址都是 127.0.0.1。
## Documentation Update Requirement
- 已在分析阶段记录 D12–D15。
- S1 记录实际锁定的版本,替换 O09 里本模块已经核实的部分。
- S7 更新 `docs/runbook.md`、`docs/progress.md` 和 `docs/tasks/M01.md`。
- 不把实现文件清单写进架构文档。
## Risks
- S4 是高风险切片。autonomous 不能越过它。
- 版本号要在 S1 查官方资料后锁定。计划里故意不预写。
- 分页协议和 vben5 仍延后。
- O08 的模型授权仍未确认。编码开始前要记下实际子 Agent 模型;不能把未执行的审查写成通过。
+43
View File
@@ -0,0 +1,43 @@
# Task Intake Result
## Task Type
feature. Watchman M01,搭建基础框架和开发环境。Tier M:一个已有任务边界的模块,含 API、壳层 UI 和本模块迁移。不是跨模块权限模型或真实外发。
## Current Understanding
用户要求先规划、不编码。范围以 `docs/tasks/INDEX.md` 的 M01 为准:后端/前端骨架、平台库迁移、任务队列与测试环境、错误/审计/运行记录基础和契约。不实现登录、业务模块或真实外发。
已确认技术方向见 `docs/decisions.md` D01:FastAPI、SQLAlchemy/Alembic、PostgreSQL、Celery/RabbitMQ、Vue 3/TS/Vite/Element Plus、Pinia/Router、pytest/Playwright、Docker Compose。不建微服务,不引入 Redis 作为任务结果库。
`D:\PROJECT\syops` 是 Flask + 自建 worker + Redis 的既有项目,Python 3.12,字符串错误码 `DOMAIN.SUBTYPE`,前端为 Vue 3.5、Element Plus、Pinia、vue-i18n、Tailwind 3。可借鉴环境文件分层、请求号和分层异常,不能把 Flask 应用或业务模块搬过来。公司现行信封已改为数值错误码。
## Gate Policy
- config/default: autonomous
- allowTaskOverride: true
- recommended: strict
- selected: autonomous
- reason or override reason: 用户于 2026-11-17 明确选择 autonomous。建议 strict 仍只作参考。
- effective: autonomous
- finalApprovalRequired: true
## Blocking Questions
无。2026-11-17 用户已选:autonomous、公司目录、薄壳、M01 实施 RLS、Compose 只绑本机。
## Non-blocking Assumptions
- 错误码按 `standards://api/api-envelope?version=1.1.0` 使用 40000/41000/42000/43000/50000。不沿用 syops 字符串码。`error-handling?version=1.1.1` 里残留的 `SYSTEM.INTERNAL_ERROR` 与信封冲突,内部错误拟用 50000。
- 四语言目录按 `frontend-stack?version=2.1.0` 建齐。M01 不交付业务列表,因此不锁定「cursor 分页」和 Element Plus 页码分页的冲突。
- 按钮图标按 `element-plus?version=1.0.2` 使用 `@element-plus/icons-vue`。
- 密钥只进 env。样例不含真实值。迁移只新增。
- 正式 Casdoor、业务表和真实发送不在 M01。
## Recommended Next Step
用户回答阻塞问题后,写 M01 实现切片。编码仍须单独确认。
## Suggested Prompt For Next Step
按已选门禁和目录,为 M01 写 implementation slices。只覆盖骨架、契约、迁移、队列和壳层。
@@ -0,0 +1,147 @@
# M01 基础框架 Requirement
## Goal
在隔离的本机开发环境里跑起 Watchman 的模块化单体骨架:统一 API 信封、平台库迁移、租户行级隔离、任务队列进程、空的管理台壳和可重复的测试命令。不交付业务预警功能。
## Background
范围来自 `docs/tasks/INDEX.md` 的 M01,技术方向来自 `docs/decisions.md` D01、D04。2026-11-17 用户确认了目录、前端厚度、RLS 和本机 Compose。公司规范以 sy-standards 当时读到的最新版本为准,篇目见 Source Notes。
`D:\PROJECT\syops` 只作为既有工程参照。它是 Flask、自建 worker 和字符串错误码,不能当作 Watchman 的实现模板。
## In Scope
- uv 工作区和 `web/` pnpm 工作区的空工程。
- 一个 Python 包同时提供 API、worker、beat 三个进程入口。
- FastAPI 健康检查、统一成功/失败信封、请求号、数值错误码。
- 环境变量按 `.env.shared`、`.env.dev`、`.env.local` 分层;机密不入库。
- PostgreSQL 上的审计事件表和运行记录表,启用并强制 RLS。
- 服务端注入租户会话。调用方不能提交 `tenant_id`。
- Celery + RabbitMQ 的空队列进程,不承载业务任务。
- 管理台薄壳:按页使用 Element Plus、Tailwind、四语言目录、一个能看见健康状态的空布局。
- 开发 Compose 只绑定 127.0.0.1。
- 依赖锁文件、迁移和测试命令。
## Out Of Scope
- Casdoor 真登录、权限点和业务授权。留到 M02。
- 数据源、查询、规则、报警、通知、Cron 场景和 AI。
- vben5、ProTable、业务列表和业务菜单。
- Redis、微服务、把 syops 业务代码拷进本仓库。
- 生产部署、对外监听、真实 MES 或企微。
- 在 M01 锁定列表分页协议。
## Current Behavior
仓库只有文档和 Git 初始化。没有 `backend/`、`frontend/`、依赖安装、数据库或容器。
## Required Behavior
- 按开发手册能在本机启动 API、worker 和前端壳。
- `GET` 健康检查返回成功信封,不返回连接串、租户标识或堆栈。
- 失败响应使用数值错误码。参数问题 40000,认证 41000,权限 42000,服务错误 50000。500 响应不包含堆栈或 SQL。
- 每个响应有 `request_id`,并与 `X-Request-Id` 对齐。
- 写操作接受 `x-idempotency-key`。同一键重复提交不产生第二条审计或运行记录。
- 应用数据库角色不是超级用户,也不是表所有者。未设置租户会话时读不到平台业务行,也不能写入。
- 设置了服务端租户后,只能读写该租户的行。
- 队列进程能连上本机 RabbitMQ 并注册一个无业务副作用的探测任务。探测任务不得写业务错误次数。
- 前端壳能显示健康检查成功、失败和加载。文案来自四语言目录。
## User Flow
开发者启动 Compose 和两个进程,打开本机管理台,看到健康状态。没有登录墙,也没有业务功能入口。
## Business Rules
- 仍是一个模块化单体。目录采用公司落位,不拆成多个可独立部署的服务。
- M01 只有一个由服务端配置的开发租户,没有租户管理功能。
- 审计和运行记录是平台基础事实,不是报警、采样或通知。
- 重试探测任务不得被记成业务异常。
## Data Rules
- M01 只建审计事件和运行记录两类平台表,外加迁移框架自身的表。
- 平台表含服务端写入的租户列,并对应用角色启用强制 RLS。
- 时间用 ISO 8601 UTC。
- 迁移只新增,不修改已经合入的迁移文件。
## API Contract
- 线格式以 `standards://api/api-envelope?version=1.1.0` 为准:`success`、`data` 与 `error` 互斥,带 `request_id`。
- `error.code` 使用 40000、41000、42000、43000、50000 段位。M01 不实现配额 43000 的业务。
- 不采用 syops 的 `DOMAIN.SUBTYPE` 字符串码。
- `error-handling?version=1.1.1` 示例里的 `SYSTEM.INTERNAL_ERROR` 与信封冲突。内部错误对外使用 50000。
- 列表分页协议不在本需求冻结。信封要求 cursor,Element Plus 规范要求页码,留到第一个列表模块再决定。
## UI Requirements
- 一个空管理台,按页引入 Element Plus,不全局注册。
- 四语言目录一次建齐:`zh-CN`、`zh-TW`、`en`、`th`。缺翻译回退 `zh-CN`。
- 健康状态有加载、成功、失败。
- 不引入 vben5,不做列表页骨架。
## Compatibility Requirements
- 前端落在 `web/`,后端落在 uv 工作区的一个服务包内,进程入口分开。
- 开发数据库和队列只监听 127.0.0.1。具体端口写在实现计划,并标明只用于开发。
- 新增第三方依赖先看许可证和维护状态。AGPL 不进入核心。
## Error Handling
- 路由不手写错误 JSON。服务层抛语义异常,全局处理成失败信封。
- 前端只有一个 JSON 客户端。页面不直接 `fetch`。
- M01 不登记信封例外出口。
## Permissions And Security
- 不读取、不提交真实密钥。样例值使用占位符。
- 调用方不能伪造租户。
- 健康检查不泄漏基础设施细节。
- 内部端口不对 `0.0.0.0` 发布。
## Assumptions
- Python 以 3.12 为候选,具体次版本和库版本在实现时按官方兼容情况锁定,不在本需求里预写版本号。
- 本机有 Docker,并能拉取 PostgreSQL 和 RabbitMQ 镜像。
- 开发租户标识放在不提交的 env 文件。
## Risks
- RLS 配错会造成要么全表可见,要么应用完全不可写。
- 公司落位规范里的目录例子来自多包平台,直接拆成多个服务会违反 D04。
- 信封 cursor 分页和 Element Plus 页码分页尚未裁决。
- 公司规范服务当前不在 Cursor 的 MCP 命名空间里,本次是经项目配置的 HTTP 端点读取的。
## Acceptance Criteria
- 新环境按手册启动后,健康检查返回成功信封且不含机密。
- 依赖有锁文件。
- 迁移可以向前应用到空库。回滚方式是新增迁移,不改已应用文件。
- RLS 有正反测试:正确租户可见,未设置租户和其他租户不可见。
- 同一幂等键不产生重复审计或运行记录。
- worker 进程可以启动并发现探测任务。
- 前端壳在成功、失败、加载三种状态下行为正确,四语言目录存在。
- 测试命令真实执行。容器或工具缺失时标未运行,不写成通过。
## Deferred Questions
- 第一个业务列表用 cursor 还是页码。
- vben5 在哪个后续模块引入。
- Casdoor 的 issuer、audience 和权限点。属于 M02 和 O10。
- O01 到 O07 的业务口径。不阻塞 M01。
## Source Notes
- 用户 2026-11-17:门禁选 autonomous;目录选公司落位;前端选薄壳;RLS 在 M01 实施;Compose 只绑本机。
- `docs/tasks/INDEX.md` M01。
- `docs/decisions.md` D01、D04。
- `standards://api/api-envelope?version=1.1.0`
- `standards://api/error-handling?version=1.1.1`
- `standards://frontend/frontend-stack?version=2.1.0`
- `standards://frontend/element-plus?version=1.0.2`
- `standards://engineering/code-layout?version=1.0.1`
- `standards://engineering/code-comments?version=1.1.1`
- `standards://security/red-line?version=1.1.0`
- `standards://security/env-secrets?version=1.1.1`
- `standards://workflow/git-commit?version=1.1.0`
@@ -0,0 +1,60 @@
# Critic Review — M01 验收预期审计
模式:acceptance-expectation audit(非 pre-done 收口)。marionettist-reviewer 为 NOT_RUN,本结论只表示「预期是否达成、能否进入 review」,不授权 DONE_LOCAL,不代表 reviewPassed。
## Verdict
PASS_WITH_WARNINGS
M01 预期结果:**大部分达成,部分未验证**。可以开始独立 review;在补齐下列验收缺口前不能关闭 M01。
## 验收条款逐项
| 验收条款 | 结论 | 依据 |
|---|---|---|
| 按手册启动后健康检查返回成功信封且不含机密 | 达成(本机已有环境) | runbook 有完整步骤;test_envelope 断言无 traceback、50000。未做「全新环境」复现 |
| 依赖有锁文件 | 达成 | `uv.lock`、`web/pnpm-lock.yaml` 存在 |
| 迁移可向前应用到空库;回滚靠新增迁移 | 基本达成 | 单一迁移 `20261117_0001`;迁移者角色拥有 schema,应用角色非所有者。空库 upgrade 无独立留证 |
| RLS 正反测试 | 部分达成 | 见 F1 |
| 同一幂等键不重复记录 | 部分达成 | 见 F2 |
| worker 可启动并发现探测任务 | 达成 | 任务注册测试 + 调用方称经 broker 执行且 audit 计数不变 |
| 前端三态行为正确、四语言目录存在 | 部分达成 | 见 F3 |
| 测试命令真实执行 | 达成(按调用方证据) | pytest 10 passed、typecheck、compose build;本次 critic 未重跑 |
## 产品/验收缺口(高信号)
- **F1 S4(high-risk / risk_score 5)RLS 证据不完整。** 已有:未设租户读不到、其他租户读不到、本租户读得到(仅 `audit_events`)。缺:
- 未设租户 **不能写入** 的反向测试(需求 Required Behavior 明确要求)。
- `run_records` 的 RLS 正反测试(仅靠同一迁移循环推断)。
- 应用角色非超级用户/非所有者/NOBYPASSRLS 的显式断言(目前只能从「读不到」间接推出)。
按 risk_score 5,S4 的验证证据应达到需求原文,而不是推断。
- **F2 幂等只测了审计事件。** `run_records` 走同样代码路径但无测试;且现有测试只比对返回 id,没有断言库内行数为 1。需求写的是「不产生第二条审计或运行记录」。
- **F3 前端三态未验证。** `App.vue` 有 loading/success/failure 分支和 i18n 键,但只有 typecheck,没有运行时断言或浏览器截图。这一条是验收条款本身,不只是流程证据。缺翻译回退 `zh-CN` 也未验证。
## 流程缺口(不影响「预期是否写出来」,但阻止关闭)
- 独立模块 review 未执行(`reviewPassed: false`,`criticPassed: false`)。
- 浏览器三态证据未归档;AGENTS 要求 UI 模块有断言+截图。
- `finalApprovalRequired: true`,需用户最终确认。
- M01.md「实施委派」仍写 `8 passed`,与证据段 `10 passed` 不一致,需主 Agent 修正。
- 无 commit;证据需按 AGENTS §9 用差异摘要或文件哈希绑定候选版本。
## 次要提示
- `WATCHMAN_TENANT_ID=dev-tenant` 放在入库的 `.env.shared`。不是密钥,但需求 Assumptions 写的是「放在不提交的 env 文件」。要么移到 `.env.local`,要么在 decisions 记一条偏差。
- `.env.dev` 文件不存在。配置代码会加载它,缺失可接受,但 runbook 最好说明它是可选层。
- `.env.local` 已被 `.env.*` 忽略且未被跟踪,符合要求。
- Compose 宿主端口均绑 127.0.0.1;容器内 `API_HOST: 0.0.0.0` 只在容器网络内,可接受。
## Gate Readiness
- 可以开始独立 review:是。
- review 后可以直接关闭:否。需先补 F1、F2(小型后端测试),补 F3(三态运行时断言或 Playwright+截图),再对受影响部分复审并重跑测试。
## Recommended Builder Action
1. 补 RLS 测试:未设租户插入应失败;`run_records` 读写隔离;查询 `pg_roles` 断言应用角色 `rolsuper=false`、`rolbypassrls=false`,且表所有者不是应用角色。
2. 补幂等测试:`run_records` 重复键;两张表都断言 `count(*) = 1`。
3. 用 Playwright 或组件测试覆盖健康三态(mock 成功、失败、挂起),截图存到 `docs/evidence/` 下非 raw 目录。
4. 修正 M01.md 中 8/10 passed 不一致;决定 `WATCHMAN_TENANT_ID` 的存放位置。
5. 之后再派独立 review(不同模型系列),通过后跑正式测试,再请求最终确认。
@@ -0,0 +1,140 @@
# Reviewer Review — M01 修复复审
模式:fuller two-stage review(沿用 S4 `gateClass: high-risk` / `risk_score: 5`)。
范围:仅复审 `.task/2026-11-17/m01-foundation/reviews/reviewer-m01.md` 的必处理项与已实现的建议项。不重审已通过切片的基线设计。
审查者不改产品代码,不授权 DONE_LOCAL。
## Recommendation
**PASS_WITH_WARNINGS**(复审当时)→ W1 已在复审后立刻收口
六条必处理项均已关闭。复审当时的非阻断残留 W1(`/openapi.json` 在 prod 仍 200)已在同会话补上:`openapi_url=None` + 测试断言 404。
可以进入用户最终确认(finalApproval)。本报告不将 M01 标为 DONE_LOCAL。
---
## 必处理项
| # | 原项 | 结论 |
|---|---|---|
| 1 | 重写配置分层测试 | **关闭** |
| 2 | Playwright 三态证据 | **关闭** |
| 3 | 启动期 `ensure_runtime_config` / `missing_required_keys` | **关闭** |
| 4 | `ENV_NAME` 收口 `/_probe` 与 `/docs` | **关闭**(见残留 W1) |
| 5 | 幂等 `IntegrityError` / 冲突回读 | **关闭** |
| 6 | 回滚 `gatePolicy` / `tier-policy` 漂移 | **关闭** |
无仍开放的必处理项。
### 1. 配置分层
`services/watchman/tests/test_config_layering.py` 用 `tmp_path` 写入三份 env 文件。`.env.local` 的 `API_PORT=8002` / `WATCHMAN_TENANT_ID=local-tenant` 覆盖 dev 与 shared;进程环境 `API_PORT=9000` 覆盖文件。`CHANGE-ME` 与空值进入缺失列表。`ensure_runtime_config` 以 `SystemExit` 退出,消息含键名,不含 `CHANGE-ME` 或 `password`。
`merge_layered_env`(`core/config.py`)只返回 dict,不再写入 `os.environ`。加载顺序是 `.env.shared` → `.env.dev` → `.env.local`,然后进程环境覆盖。
残留:现有断言只锁住「local 为最高文件层」和「进程环境最高」。若有人把 `.env.dev` 与 `.env.shared` 对调、同时保持 `.env.local` 最后,该测试仍会通过。实现顺序是对的,不构成未关闭项。
### 2. Playwright 三态
`web/apps/console/e2e/health.spec.ts` 有 loading→success、failure(含 `50000`)、`?lang=en` 三条用例,截图写入 `docs/evidence/M01/ui/`。本审查查看了四张图,与证据描述一致:
- `health-loading.png`:卡片内「健康检查加载中」
- `health-success.png`:绿色「健康检查成功」与「服务可用: watchman 0.1.0」
- `health-failure.png`:红色告警「服务不可用: 50000: Internal server error」
- `health-success-en.png`:「Health check succeeded」与「Service available: watchman 0.1.0」,无硬编码中文
用例通过 `page.route` 桩掉 `/health`,用来稳定拍出三态。这是 UI 证据,不是对活后端的联调。本审查未重跑 e2e,避免改写这些截图。
### 3. 启动缺键
`__main__.py` 在 api/worker/beat 分支之前调用 `ensure_runtime_config()`。`create_app()` 默认同样调用。必填键为 `DATABASE_URL`、`DATABASE_MIGRATOR_URL`、`WATCHMAN_TENANT_ID`;空串与含 `CHANGE-ME` 的值都算缺失。退出文本只拼接键名。
Compose 的 api/worker/beat 命令是 `python -m watchman`,走这条入口。
### 4. ENV_NAME
`is_non_production` 仅在 `env_name` 为 `dev` 或 `test` 时打开 `docs_url` 与 `/_probe/*`。`test_probe_and_docs_hidden_outside_non_production` 覆盖 prod 下 404。
本审查另起进程实测 `ENV_NAME=prod` 且 `validate_runtime=False`:
- `/docs` 404
- `/redoc` 404
- `/_probe/boom` 404
- `/openapi.json` **200**
`create_app` 只把 `docs_url` 置空,并设置 `redoc_url=None`,没有设置 `openapi_url=None`。见下方 W1。缺省 `env_name` 仍是 `dev`,未设置 `ENV_NAME` 时探针与文档保持开启;`docs/runbook.md` 已写明仅 dev/test 暴露。
### 5. 幂等
`create_audit_event` 与 `create_run_record` 在 `begin_nested()` 内 `flush`,捕获 `IntegrityError` 后按 `(tenant_id, idempotency_key)` 回读首次行;回读仍为空则原样抛出。唯一约束 `uq_audit_events_tenant_idem` / `uq_run_records_tenant_idem` 仍在迁移中。
测试含串行重复、四线程并发同键(`count == 1` 且 id 相同),以及把第一次查询打成未命中以迫使冲突回退。本次 `pytest` 这些用例通过。
### 6. 门禁漂移
工作区相对基线提交未修改 `marionettist.config.yaml` 与 `.marionettist/tier-policy.yml`。当前 `gatePolicy.defaultMode` 为 `balanced`。Tier L 为 `workflowHint: full-marionettist`、`gateHint: prefer-strict`。`docs/decisions.md` D17 记录该回滚不作为 M01 交付。D18 与 Compose 行内注释一致:容器内 `API_HOST=0.0.0.0`,宿主发布仍是 `127.0.0.1:8000:8000`。
`docs/progress.md` 与 `docs/tasks/M01.md` 写的是等待复审/最终确认,没有把 M01 标成 DONE_LOCAL。
---
## 建议项(抽查)
已在代码或证据中对上,不单列缺陷:
- 调用方 `tenant_id` 反向测试:响应与库行均为服务端租户
- Compose `0.0.0.0` 行内标注与 D18
- Tailwind v4(`@tailwindcss/vite` + `@import "tailwindcss"`)、`element-theme.css` 令牌映射、`ElConfigProvider` 随 `zh-CN` / `zh-TW` / `en` / `th` 切换
- 信封去掉顶层 `timestamp`;41000 / 42000(含 `permission_node`)/ HTTP 503 且 `retryable: true` 有断言;500 路径回写 `X-Request-Id`
- `Session.after_begin` 跳过嵌套事务;`test_tenant_rebounds_after_commit` 在同一 session 上两次 `commit()` 后仍能数到两行
- 非 JSON 响应抛 `BusinessError`(50000 + 响应头 request id)
- `mountApp("en")` 断言英文健康文案;四份 `errors.json` 已并入 i18n
- `bootstrap_local_db.py` 说明 `sql.Literal` 密码可能进入 `log_statement=all` 的服务器日志
- Dockerfile `USER watchman`(uid 10001),并在 `uv sync` 后 `chown`
- RLS fixture 按 `tracked_keys` 删除;未设租户的写入用例预期失败并 `rollback`
- `guest:guest` 仅作 Compose 开发缺省,API 服务有 DEV ONLY 注释;Settings 缺省 broker 已改为 `CHANGE-ME`
- `docs/evidence/M01/licenses.md` 的 fastapi 0.163.1、SQLAlchemy 2.0.57、Alembic 1.20.1、Celery 5.7.0、Pydantic 2.14.3 与 `uv.lock` 一致
---
## Stage 1:边界与合规
修复留在 M01 基础框架内:配置、启动、信封、RLS 会话、幂等、控制台健康壳、开发 Compose / Dockerfile、证据与 D17/D18。门禁文件已回到基线,没有把 `observed` / `target` 规则写成当前强制行为。
进度文档没有宣布 DONE_LOCAL。没有新的越权路径:租户仍只来自服务端设置,反向测试锁住了请求体里的 `tenant_id`。
W1 是收口不完整,不是对必处理项的回退。`/_probe` 与 `/docs` 的要求已经满足。
## Stage 2:实现质量
幂等冲突路径有真实数据库测试,不只是串行 check-then-insert。`after_begin` 有 commit 后重绑测试,不是只注册了监听器。信封与生产探针测试和本次抽查一致。
前端三态截图可读,英文态与中文态分开。Tailwind 布局在截图里生效(留白、浅底、单卡片)。
---
## 新发现(非阻断)
### W1(低)生产态仍提供 `/openapi.json`
`services/watchman/src/watchman/api/app.py` 在非 dev/test 时关闭 Swagger 与 ReDoc,未关闭 OpenAPI schema。本次实测 `ENV_NAME=prod` 时 `/openapi.json` 返回 200。schema 描述的是已经挂载的 `/health` 与 `/platform`,不额外泄露连接串。后续若要把文档面一并关掉,需同时设置 `openapi_url=None`。不阻塞本次最终确认。
### W2(低)分层测试没有单独锁住中间层
见必处理项 1 的残留。代码顺序正确。
---
## 本审查执行的验证
- `uv run pytest services/watchman/tests -q` → **23 passed**(1 条 Starlette/`httpx` 弃用警告)
- `web/apps/console`:`pnpm test:unit` → **8 passed**;`pnpm typecheck` → 通过
- `ENV_NAME=prod` 路由抽查:`/docs`、`/redoc`、`/_probe/boom` 为 404,`/openapi.json` 为 200
- 四张 UI 截图已查看
未重跑 `pnpm test:e2e`(会重写 `docs/evidence/M01/ui/`)。未构建镜像,未做空库全新 `alembic upgrade`。工作区仍无 commit,证据没有 git 哈希绑定;这是既有状态,用户未授权提交。
## 最终确认
M01 修复复审没有剩余阻断项。用户可以做 finalApproval。只有用户确认之后,主 Agent 才能考虑 DONE_LOCAL。本审查不授予该状态。
@@ -0,0 +1,215 @@
# Reviewer Review — M01 基础框架模块整体独立审查
模式:fuller two-stage review(含 S4 `gateClass: high-risk` / `risk_score: 5`)。
范围:S1–S7 全部已实现切片 + critic F1–F3 补齐。
审查者与实现者不同模型系列。本报告不授权 DONE_LOCAL。
## Recommendation
**PASS_WITH_WARNINGS**
未发现阻断级边界违规、租户越权或机密入库。RLS 设计是 fail-closed 的,应用角色约束正确,critic 的 F1–F3 已被实测覆盖。
但存在 1 条高信号测试失真(S2-1)和若干规范偏差,关闭 M01 前必须处理「必须修复」清单。
---
## Stage 1:边界与合规
### S1-1(中)S2 的 Done Criteria 未实现:缺配置不会在启动时失败
计划 S2 Done Criteria:「缺配置时进程失败并给出键名,不打印其他配置值。」
`services/watchman/src/watchman/core/config.py:86` 的 `missing_required_keys()` 写出来了,但全仓库无任何调用方(`__main__.py`、`api/app.py`、`jobs/celery_app.py` 都没有)。
同时 `config.py:58-65` 给 `DATABASE_URL` / `DATABASE_MIGRATOR_URL` 配了含 `CHANGE-ME` 的默认值,所以在 `.env.local` 缺失时进程能正常启动,直到第一次连库才在运行期炸,错误信息来自 psycopg 而不是键名。
建议:在 `__main__.py` 三个 role 分支前统一调用 `missing_required_keys([...])`,缺键时 `SystemExit` 并只打印键名;补一条测试。
### S1-2(中)测试专用路由与 `/docs` 无条件注册,`ENV_NAME` 没有被任何代码使用
`services/watchman/src/watchman/api/app.py:75` 与 `:82` 把 `/_probe/validation-error`、`/_probe/boom` 注册进 `create_app()` 本体,没有任何环境开关。`/_probe/boom` 会稳定产生未捕获异常 + 500 + 错误日志,是可被外部触发的噪声/轻量 DoS 面。
`app.py:34` 的 `docs_url="/docs"` 同样无条件开启。
`config.py:55` 已经有 `env_name`,但全仓库只在 `settings_as_public_dict()`(本身也无调用方)里出现过一次。
建议:`if settings.env_name == "dev"` 包住两个 `_probe` 路由与 `docs_url`;让 `ENV_NAME` 成为真正的环境判别位。这是 M01 冻结进程行为的地方,拖到 M02 之后成本更高。
### S1-3(中)前端对公司规范有三处偏差
| 偏差 | 位置 | 规范出处 |
|---|---|---|
| Element Plus locale 写死 `zhCn`,不随 i18n 切换 | `web/apps/console/src/App.vue:34` | `standards://frontend/element-plus?version=1.0.2` §1 明文「禁止写死 `zh-cn`」 |
| 未引入 Tailwind CSS v4,布局改用 `<style scoped>` 手写 | `web/apps/console/package.json`、`App.vue:77-90` | `frontend-stack?version=2.1.0` 裁定 Tailwind v4 为唯一原子样式层;D13 也点名 Tailwind |
| 无 `element-theme.css` 令牌映射,未引暗色变量 | `web/apps/console/src/main.ts:3` 只引了 `element-plus/dist/index.css` | `element-plus` §1「样式引一次」+ §2「变量先行」 |
第三项的后果是:页面背景走了 `tokens.css`,但 `ElCard`/`ElTag`/`ElAlert` 内部仍是 Element 默认配色与字号,和品牌令牌不一致。
注:ProTable / vben5 由 D13 明确延后,不计入偏差;Tailwind 与 locale 同步并未被任何决策延后。
### S1-4(中)UI 视觉验证未执行,M01 据此不能进 DONE_LOCAL
`docs/evidence/M01/health-states.md` 自述「未使用 Playwright 截图」,`state.json` S6 的 `gateReasons` 也记了 `browser-evidence-pending`。
计划 S6 Validation 要求「浏览器打开本机控制台」看三态,且「抽查一种非默认语言,健康文案不是硬编码中文」;AGENTS §5/§10 要求 UI 模块有断言+截图+视觉检查才能关闭。
当前只有 vitest 组件级断言。这不是伪造,证据写得诚实,但验收条款本身未满足。
### S1-5(低)三个文件改动不在本次声明的 allowed scope 内,其中两个放宽了门禁姿态
- `marionettist.config.yaml`:`gatePolicy.defaultMode` 由 `balanced` 改为 `autonomous`
- `.marionettist/tier-policy.yml`:Tier L 的 `workflowHint` 由 `full-marionettist` 降为 `analysis-context`,`gateHint` 由 `prefer-strict` 降为 `default`
- `docs/development-plan.md`:2.1 目录草图标注被 D12 取代(内容本身合理且保留了旧稿)
前两项影响的是后续模块:Tier L 在本仓的定义恰好覆盖「权限模型、生产外发、真实外部系统、部署变更」,也就是 M02 Casdoor 与企微真实发送。`finalApprovalRequired: true` 和 `risk_score >= 4` 的强制停顿仍在,所以不是安全漏洞,但属于需要用户明确点头的流程变更,不应混在 M01 实现里顺带落地。
`docs/progress.md` 与 `docs/handoffs/2026-11-17-002.md` 虽不在本次 allowed 列表,但计划 S7 和 AGENTS §7 要求更新,视为合规。
### S1-6(低)`API_HOST: 0.0.0.0` 写进了 Compose
`deploy/compose.dev.yml:55`。宿主发布仍是 `127.0.0.1:8000:8000`,容器内绑 `0.0.0.0` 是必要的,critic 也已接受运行时行为。
但计划 S7 Forbidden Scope 原文是「不把 `0.0.0.0` 写进 Compose」,红线 #6 要求「dev 演示临时绑 `0.0.0.0` 须显式标注」。文件头只说明了发布端口绑回环,没有就这一行做标注。
建议:在该行加一句行内注释说明「容器内监听,宿主仅回环发布,不得复用到任何部署配置」,并在 `docs/decisions.md` 补一条偏差记录。
### S1-7(低)信封多了标准未定义的顶层 `timestamp`
`services/watchman/src/watchman/core/response.py:24` 与 `:50`。
`standards://api/api-envelope?version=1.1.0` 的线格式只有 `success` / `data`|`error` / `request_id`,本篇自称「信封线格式唯一真源」。
值本身是合法的 ISO-8601 UTC,不影响消费方;但这是要被后续全部模块继承的契约,建议要么确认公司侧允许扩展字段,要么现在去掉。
### S1-8(低)依赖许可证预检无留证
红线 #8 与计划 S1 Step 1 要求新依赖先查许可证(AGPL 不进核心)。
实际锁定的版本与 `docs/decisions.md` O09 的记录完全一致(已核对 `uv.lock`:fastapi 0.163.1 / sqlalchemy 2.0.57 / alembic 1.20.1 / celery 5.7.0 / pydantic 2.14.3),版本记录可信;但没有任何文件记录许可证核查结果。实际依赖无 AGPL,补一行证据即可。
---
## Stage 2:实现质量
### S2-1(高)`test_config_layering.py` 并没有测试分层
`services/watchman/tests/test_config_layering.py`:
- `assert settings.api_host == "127.0.0.1"` 和 `settings.api_port == 8000` 与 `config.py:56-57` 的代码默认值相同,即使所有 env 文件都删掉也会通过
- `assert settings.tenant_id` 同理(默认 `dev-tenant`)
- 参数里的 `tmp_path` 根本没用,没有构造任何临时 env 文件
- 仓库里 `.env.dev` 不存在,所以「`.env.local` 覆盖 `.env.dev`、`.env.dev` 覆盖 `.env.shared`」这条中间层从未被执行过
- 唯一有效断言是 `if .env.local exists: "CHANGE-ME" not in database_url`,依赖本机文件存在,CI 上会静默跳过
计划 S2 Validation 原文是「测试证明 `.env.local` 覆盖 `.env.dev`,`.env.dev` 覆盖 `.env.shared`」。这条验收目前是假阳性。
代码本身(`config.py:29-43`)我逐行读过,优先级顺序是对的,所以这是测试缺陷不是功能缺陷——但它会让后续改动误以为有回归保护。
建议:用 `tmp_path` 造三份 env 文件、把 `_load_layered_env` 的根目录参数化(它已经接受 `root`),对同一个 key 断言三层覆盖关系。
### S2-2(中)幂等是 check-then-insert,并发重复键会返回 50000 而不是首次结果
`services/watchman/src/watchman/services/platform_records.py:40-55`(`run_records` 同构于 `:74-90`):先 `select` 再 `add`,中间没有任何防并发手段。
两个并发同键请求都查不到既有行 → 都 insert → 第二个撞 `uq_*_tenant_idem` → `IntegrityError` → 被兜底 handler 转成 50000。全仓库无 `IntegrityError` 捕获,也无 `ON CONFLICT`(已 grep 确认)。
需求写的是「重复键返回第一次的结果,不插入第二行」。现状只在串行下成立,现有两条幂等测试也都是串行的。
幂等键的全部意义就是防重试/防重发(AGENTS §8「任务重试、重复采样、消息重发不得增加业务错误次数」),这个基础设施会被 M02+ 的报警写入直接继承。
建议:`INSERT ... ON CONFLICT (tenant_id, idempotency_key) DO NOTHING RETURNING`,未返回行时回查;或捕获 `IntegrityError` 后回滚到 savepoint 再回查。
### S2-3(中)租户设置只在请求开始注入一次,`commit()` 之后即失效
`core/db.py:71-81` 的 `get_db_session` 在创建 session 后调用一次 `set_tenant`,而 `set_config(..., true)` 是事务局部的。
`api/routes/platform.py:52` 在路由里 `session.commit()`,该事务结束后 `app.tenant_id` 就没了。当前每个路由只提交一次,所以行为正确;但任何在 commit 之后继续用同一 session 的后续代码都会进入「无租户」事务,读为空、写被拒。
是 fail-closed,不是越权,但对 M02+ 是个安静的陷阱。
建议:用 SQLAlchemy `event.listens_for(Session, "after_begin")` 在每个事务开始时重新注入,而不是依赖「一个请求只提交一次」这个隐式约定。
### S2-4(中)`_load_layered_env` 永久污染 `os.environ`
`core/config.py:38-42`:把文件值 `setdefault` 进 `os.environ`。副作用是 `reload_settings()` 永远拿不到改过的文件值(第二次调用时这些 key 已经在 `os.environ` 里,被当成「进程环境优先」跳过),测试之间也会互相串。
`test_config_layering.py:14` 的 `monkeypatch.delenv` 就是在绕这个问题。
同一函数里 `__import__("os")` 内联了两次(`:40`、`:42`),`missing_required_keys` 里又 `import os`(`:88`)——顶层 import 即可,不符合 `standards://engineering/code-layout`。
建议:返回合并后的 dict 交给 pydantic-settings 消费,不要写 `os.environ`;至少提供一个显式的 `override=True` 路径给测试。
### S2-5(中)信封契约被冻结,但一半错误码没有测试
`core/errors.py` 定义了 40000/41000/42000/50000(503 retryable)五类。测试只覆盖 40000 与 50000。
未覆盖的里面有一条是标准硬性要求:`api-envelope` 规定 42000 必须回显 `permission_node`。`response.error_body` 确实只在非 None 时才放这个字段(`response.py:44-45`),逻辑是对的,但没有任何断言锁住它,M02 接权限时很容易被改掉。
建议:补一组参数化测试,断言 41000 / 42000(含 `permission_node`)/ 503(`retryable: true`)的信封形状。
### S2-6(中)「调用方不可传租户」是 S4 的核心安全不变量,但没有反向测试
`api/routes/platform.py:22-30` 的 `AuditCreateRequest` / `RunCreateRequest` 不含 `tenant_id`,Pydantic v2 默认忽略额外字段,所以外部传 `tenant_id` 确实不生效——但这是靠一个默认行为兜住的,一旦有人加了 `model_config = ConfigDict(extra="allow")` 或改成 `**kwargs` 就会破。
D14 和需求都把这条列为 M01 必须保证的行为,risk_score 5 的切片应该有显式断言。
建议:补一条「POST 带 `tenant_id: other-tenant` → 写入仍落在服务端租户」的测试。
### S2-7(低)500 响应丢失 `X-Request-Id` 响应头
`RequestIdMiddleware`(`api/app.py:20`)是用户中间件,位于 Starlette `ServerErrorMiddleware` 内层。未捕获异常会穿过它上抛,兜底 handler 返回的 `JSONResponse` 因此拿不到 `response.headers[...]` 回写。
body 里的 `request_id` 仍然正确(`request.state` 挂在共享的 scope state 上)。`AppError` 和 `RequestValidationError` 路径不受影响。
计划 S3 Step 3 要求「响应头回写同一个值」,这条在 500 路径上不成立。`test_envelope.py:34` 只断言了 body,没断言头,所以没发现。
### S2-8(低)前端客户端对非 JSON 响应抛裸错误
`web/packages/api/src/index.ts:60` 直接 `await response.json()`。遇到网关返回的 HTML 502 / 空响应时抛 `SyntaxError`,不是带 `code`/`requestId` 的 `BusinessError`,最终在 `health.ts:36` 以 `String(error)` 形式原样显示给用户。
计划 S6 Step 1 要求「失败抛带 `code`、`requestId` 的错误对象」。建议把 `json()` 包进 try,失败时抛 50000 + 头里的 request id(该分支代码已经存在于 `:62-68`,只是够不着)。
### S2-9(低)「四语言」测试实际断言的是回退中文
`web/apps/console/src/App.spec.ts:101-110` 这条用例以 `locale="th"` 挂载,但故意不注入 th 文案(`:29` 有注释说明),断言结果是「显示中文」。它证明的是 fallback 机制,不是四语言可用。
`mountApp` 里加载了 `en` 却没有任何用例用它。所以计划 S6「抽查一种非默认语言,健康文案不是硬编码中文」这条仍未验证。
另外四份 `errors.json` 已建骨架(符合计划),但 `src/i18n.ts` 没有加载它们,目前是悬空文件。
建议:加一条 `mountApp("en")` 并断言出现英文文案的用例,成本极低。
### S2-10(低)`bootstrap_local_db.py` 的 SQL 组装前后不一致,密码会进语句文本
`scripts/bootstrap_local_db.py`:`_upsert_role` 用 `psycopg.sql.Identifier`/`Literal` 正确组装(`:32-39`),但 `main()` 里 `CREATE DATABASE "{db_name}"`(`:75`)和四条 `GRANT ... TO "{user}"`(`:86-92`)是 f-string 拼接。值来自环境变量、风险低,但同一文件两套写法容易被后人照抄错的那套。
另外 `sql.Literal(password)` 会把明文密码放进语句文本,本机 Postgres 若开了 `log_statement=all` 就会落盘到服务端日志(红线 #1「密码绝不入…日志」)。本机开发可接受,建议在脚本 docstring 里显式标注这一限制。
### S2-11(低)死代码与为消除告警而写的占位
- `config.py:86 missing_required_keys`、`config.py:99 settings_as_public_dict`、`db.py:56 session_scope` 三个函数全仓库无调用方(已 grep)
- `api/app.py:88` 的 `_ = success_body` 是为了压 unused import 告警——直接删掉该 import 即可,`app.py` 本身不需要它
### S2-12(低)镜像以 root 运行;RLS 测试不清理数据
`deploy/Dockerfile` 没有 `USER` 指令。仅开发镜像,但加一个非 root 用户成本很低。
`tests/test_rls.py` 每次运行都往本机 `audit_events` / `run_records` 写入若干行且从不清理,长期会让本机库里积累测试数据,也会让「未设租户读不到」这类基于 `count(*) == 0` 的断言在未来更脆。建议用 fixture 在 teardown 里按 `idempotency_key` 前缀删除。
### S2-13(低)`guest:guest` 作为默认值写进了入库文件
`core/config.py:68` 与 `deploy/compose.dev.yml:56/80/102`。是 RabbitMQ 众所周知的开发默认账号,`docs/runbook.md:35` 也已标注「仅开发」,风险实际为零。
但红线 #1 的字面要求是密码不进代码与配置样例,建议改成无默认的必填键或占位符,避免这个写法被后续模块照抄到真实 broker 上。
---
## 做得对、不需要改的部分
- RLS 是 fail-closed 的:`current_setting('app.tenant_id', true)` 未设置时返回 NULL,比较结果为 NULL,读写都被拒;`ENABLE` + `FORCE` 都加了,`USING` 和 `WITH CHECK` 都写了,策略限定 `TO watchman_app`
- 角色分离正确:migrator 拥有 schema,app 角色 `NOSUPERUSER NOCREATEDB NOCREATEROLE NOBYPASSRLS`,`migrations/env.py` 明确走 migrator URL;`test_rls.py:29` 用 `pg_roles` + `pg_tables` 做了显式断言,不是间接推断
- 迁移单一、未被改写,符合红线 #2
- `/health` 只返回 `status`/`app`/`version`,不碰数据库、不回显租户或连接串,并有否定断言
- 兜底 handler 不泄漏堆栈,`test_envelope.py:41` 直接断言异常文本 `boom` 不出现在响应里
- Celery 无 result backend、探测任务无副作用并有计数不变的实测
- `.env.local` 未被跟踪,`.gitignore` 的 `!.env.shared` 例外加得准确,`.env.example` 全部是 `CHANGE-ME` 占位
- `uv.lock` 实际版本与 O09 记录逐项吻合,没有把未核实的版本写进文档
- critic 的 F1–F3 确实补齐了,不是改文档糊弄:未设租户写入失败、`run_records` 正反隔离、`count(*) == 1`、三态运行时断言都能在测试里找到对应代码
- 后端 13 条、前端 7 条测试与证据文档记的数量一致(已按文件逐条核对,未重跑)
---
## 关闭 M01 前必须处理
1. S2-1 —— 重写 `test_config_layering.py`,让它真的覆盖三层优先级
2. S1-4 —— 补浏览器三态证据(截图存 `docs/evidence/M01/` 非 raw 目录),或由用户明确同意以组件测试代替并记一条决策
3. S1-1 —— 启动期必填键校验接上 `missing_required_keys`
4. S1-2 —— `_probe` 路由与 `/docs` 按 `ENV_NAME` 收口
5. S2-2 —— 幂等改为 `ON CONFLICT` 或捕获 `IntegrityError`(这是会被所有业务模块继承的基础设施)
6. S1-5 —— 就 `marionettist.config.yaml` 与 `tier-policy.yml` 的门禁放宽单独向用户确认,不要夹在 M01 里
## 建议但可以排进 M02
S1-3(Tailwind / locale 同步 / element-theme.css)、S1-6、S1-7、S2-3、S2-4、S2-5、S2-6、S2-7、S2-8、S2-9、S2-10 ~ S2-13。
其中 S2-6(租户不可注入的反向测试)建议尽量不要拖——它是 S4 唯一没有测试锁住的安全不变量。
## 残余风险
- S4 是 `risk_score: 5`,但其安全保证目前靠「Pydantic 默认忽略额外字段」这一隐式行为兜底(S2-6),建议即使整体放行也先补这一条
- 本次审查未重跑任何测试命令,全部验证状态采信调用方证据;测试文件内容与声称的用例数一致,但执行结果本身未经本审查独立确认
- 空库全新 `alembic upgrade head` 没有独立留证(critic 也提过),本机库已存在,首次迁移路径未被重复验证
- 没有 commit,证据与候选版本之间缺少 hash 绑定(AGENTS §9)
@@ -0,0 +1,84 @@
{
"taskId": "2026-11-17/m01-foundation",
"type": "feature",
"phase": "finalization",
"status": "in_progress",
"allowedToCode": true,
"currentSlice": "S7",
"gatePolicy": {
"configDefault": "autonomous",
"allowTaskOverride": true,
"recommended": "strict",
"selected": "autonomous",
"reason": "User selected autonomous. Implementation slices S1-S7 complete; finalApprovalRequired remains true.",
"effective": "autonomous",
"finalApprovalRequired": true
},
"slices": [
{
"id": "S1",
"status": "completed",
"gateClass": "standard",
"risk_score": 3,
"gateReasons": ["new-dependencies"]
},
{
"id": "S2",
"status": "completed",
"gateClass": "standard",
"risk_score": 3,
"gateReasons": ["secrets-config"]
},
{
"id": "S3",
"status": "completed",
"gateClass": "standard",
"risk_score": 3,
"gateReasons": ["public-api-contract"]
},
{
"id": "S4",
"status": "completed",
"gateClass": "high-risk",
"risk_score": 5,
"gateReasons": ["schema", "security", "rls", "local-postgres"]
},
{
"id": "S5",
"status": "completed",
"gateClass": "standard",
"risk_score": 3,
"gateReasons": ["new-infrastructure"]
},
{
"id": "S6",
"status": "completed",
"gateClass": "standard",
"risk_score": 2,
"gateReasons": ["thin-shell-landed", "browser-evidence-pending"]
},
{
"id": "S7",
"status": "completed",
"gateClass": "standard",
"risk_score": 3,
"gateReasons": ["dev-runtime"]
}
],
"gates": {
"requirementFrozen": true,
"planApproved": true,
"contextPackReady": true,
"criticPassed": false,
"implementationDone": true,
"reviewPassed": false,
"validationPassed": true
},
"files": {
"intake": ".task/2026-11-17/m01-foundation/intake.md",
"requirement": ".task/2026-11-17/m01-foundation/requirement.md",
"implementationPlan": ".task/2026-11-17/m01-foundation/implementation-plan.md",
"contextPack": ".task/2026-11-17/m01-foundation/context-pack.md"
},
"updatedAt": "2026-11-17T05:20:00Z"
}
+10
View File
@@ -0,0 +1,10 @@
{
"taskId": "2026-11-17/m01-foundation",
"type": "feature",
"phase": "finalization",
"allowedToCode": true,
"currentSlice": "M01-module-review",
"lastGate": "review-m01",
"nextCommand": "fix PASS_WITH_WARNINGS must-handle items, then re-review affected parts",
"updatedAt": "2026-11-17T05:35:00Z"
}
+23
View File
@@ -0,0 +1,23 @@
# Dev/runtime image for Watchman API, worker, and beat.
FROM python:3.12-slim-bookworm
WORKDIR /app
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
UV_LINK_MODE=copy
COPY --from=ghcr.io/astral-sh/uv:0.13.7 /uv /usr/local/bin/uv
COPY pyproject.toml uv.lock .python-version ./
COPY services/watchman ./services/watchman
RUN uv sync --frozen --no-dev --package watchman \
&& useradd --create-home --uid 10001 --shell /usr/sbin/nologin watchman \
&& chown -R watchman:watchman /app
ENV PATH="/app/.venv/bin:$PATH"
USER watchman
WORKDIR /app
CMD ["python", "-m", "watchman", "api"]
+116
View File
@@ -0,0 +1,116 @@
# Dev-only Compose. All published ports bind to 127.0.0.1.
# Do not reuse these bindings in test/prod deploy configs.
# Secrets come from env_file / shell env — never commit real passwords here.
name: watchman-dev
services:
rabbitmq:
image: rabbitmq:3.13-management-alpine
container_name: watchman-dev-rabbitmq
ports:
- "127.0.0.1:56729:5672"
- "127.0.0.1:15679:15672"
healthcheck:
test: ["CMD", "rabbitmq-diagnostics", "-q", "ping"]
interval: 5s
timeout: 5s
retries: 12
volumes:
- watchman_dev_rabbitmq:/var/lib/rabbitmq
# Optional isolated Postgres for containerized runs. Host Postgres on :5432 remains the
# default for local M01 development documented in docs/runbook.md.
postgres:
profiles: ["compose-db"]
image: postgres:17-alpine
container_name: watchman-dev-postgres
environment:
POSTGRES_USER: ${COMPOSE_POSTGRES_USER:-postgres}
POSTGRES_PASSWORD: ${COMPOSE_POSTGRES_PASSWORD:?set COMPOSE_POSTGRES_PASSWORD in .env.local}
POSTGRES_DB: ${WATCHMAN_DATABASE_NAME:-watchman}
ports:
- "127.0.0.1:54329:5432"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB"]
interval: 5s
timeout: 5s
retries: 12
volumes:
- watchman_dev_postgres:/var/lib/postgresql/data
api:
profiles: ["app"]
build:
context: ..
dockerfile: deploy/Dockerfile
container_name: watchman-dev-api
command: ["python", "-m", "watchman", "api"]
env_file:
- path: ../.env.shared
required: false
- path: ../.env.local
required: true
environment:
# DEV ONLY: bind all interfaces inside the container network namespace.
# Host publish remains 127.0.0.1:8000 (see ports). Do not copy to deploy configs.
API_HOST: 0.0.0.0
# DEV ONLY: RabbitMQ image default guest/guest — local compose only.
CELERY_BROKER_URL: ${CELERY_BROKER_URL_DOCKER:-amqp://guest:guest@rabbitmq:5672//}
DATABASE_URL: ${DATABASE_URL_DOCKER:?set DATABASE_URL_DOCKER in .env.local}
DATABASE_MIGRATOR_URL: ${DATABASE_MIGRATOR_URL_DOCKER:?set DATABASE_MIGRATOR_URL_DOCKER in .env.local}
ports:
- "127.0.0.1:8000:8000"
extra_hosts:
- "host.docker.internal:host-gateway"
depends_on:
rabbitmq:
condition: service_healthy
worker:
profiles: ["app"]
build:
context: ..
dockerfile: deploy/Dockerfile
container_name: watchman-dev-worker
command: ["python", "-m", "watchman", "worker"]
env_file:
- path: ../.env.shared
required: false
- path: ../.env.local
required: true
environment:
CELERY_BROKER_URL: ${CELERY_BROKER_URL_DOCKER:-amqp://guest:guest@rabbitmq:5672//}
DATABASE_URL: ${DATABASE_URL_DOCKER:?set DATABASE_URL_DOCKER in .env.local}
DATABASE_MIGRATOR_URL: ${DATABASE_MIGRATOR_URL_DOCKER:?set DATABASE_MIGRATOR_URL_DOCKER in .env.local}
extra_hosts:
- "host.docker.internal:host-gateway"
depends_on:
rabbitmq:
condition: service_healthy
beat:
profiles: ["app"]
build:
context: ..
dockerfile: deploy/Dockerfile
container_name: watchman-dev-beat
command: ["python", "-m", "watchman", "beat"]
env_file:
- path: ../.env.shared
required: false
- path: ../.env.local
required: true
environment:
CELERY_BROKER_URL: ${CELERY_BROKER_URL_DOCKER:-amqp://guest:guest@rabbitmq:5672//}
DATABASE_URL: ${DATABASE_URL_DOCKER:?set DATABASE_URL_DOCKER in .env.local}
DATABASE_MIGRATOR_URL: ${DATABASE_MIGRATOR_URL_DOCKER:?set DATABASE_MIGRATOR_URL_DOCKER in .env.local}
extra_hosts:
- "host.docker.internal:host-gateway"
depends_on:
rabbitmq:
condition: service_healthy
volumes:
watchman_dev_rabbitmq:
watchman_dev_postgres:
+8 -1
View File
@@ -17,6 +17,13 @@
| D09 | MES 通过配置,不做客户核心定制;大屏独立、能力模块为流程/指标/视频 | 前轮用户明确答复 |
| D10 | 以功能模块为大任务,一个会话聚焦一个大任务;Agent 可自主拆小步骤逐步实现,不再由用户管理 133 小片 | 2026-11-17 用户修正 |
| D11 | Cron 编辑和调度优先复用开源库/框架,不自行开发通用编辑器和调度引擎 | 2026-11-17 用户要求及本轮公开资料核查 |
| D12 | M01 目录采用公司代码落位:`web/` pnpm 工作区,后端为 uv 工作区中的一个服务包。API、worker、beat 是同一包的三个进程,不拆微服务 | 2026-11-17 用户在 M01 规划中选择公司落位。取代开发规划 2.1 的 `backend/` `frontend/` `infra/` 草图 |
| D13 | M01 前端只做薄壳:按页使用 Element Plus、Tailwind 和四语言目录。vben5 与列表骨架留到第一个业务列表模块 | 2026-11-17 用户选择薄壳 |
| D14 | M01 的平台表启用并强制 PostgreSQL RLS。租户只由服务端配置注入,调用方不能传 `tenant_id`。M01 没有租户管理功能 | 2026-11-17 用户选择 M01 实施 RLS |
| D15 | 开发用 Docker Compose。Postgres 与 RabbitMQ 只绑定 127.0.0.1,端口仅用于开发,不写入部署配置 | 2026-11-17 用户选择本机 Compose |
| D16 | `WATCHMAN_TENANT_ID` 放在不入库的 `.env.local`(及 `.env.example` 占位),不放 `.env.shared` | 2026-11-17 critic 对照需求 Assumptions;修正落位 |
| D17 | 仓库 `gatePolicy.defaultMode` 保持 `balanced`;Tier L 保持 `prefer-strict`/`full-marionettist`。本任务曾出现的 autonomous/放宽漂移已回滚,不作为 M01 交付 | 2026-11-17 独立 review S1-5;用户授权处理必改项时回滚 |
| D18 | Compose 容器内 `API_HOST=0.0.0.0` 仅开发且必须行内标注;宿主发布端口仍绑 `127.0.0.1` | 2026-11-17 独立 review 顺带项 |
## 冻结前/相关模块实现前必须确认
@@ -32,7 +39,7 @@
| O06 | OPEN | 同周期值更正是否更新原报警、是否允许新报警? | 同一输入身份重读不重报已确认;“版本变更”不能随意当新业务事件。建议保留修订记录,不自动重发,实际规则需批准 | P-006、A-023、A-039 |
| O07 | OPEN | 停机漏跑、跨周期任务重叠、启停及改 Cron 后的旧任务 | 建议每场景不并发推进进度,逾期运行有界跳过/显式补跑且不自动补发历史消息;用户需确认具体业务行为 | P-004、A-033~A-036 |
| O08 | OPEN | Cursor/Grok 等实际服务商能处理哪些项目资料?能否跨系列子 Agent? | 先确认交接文档、未来源码、合成数据和截图授权;默认不读取原会议或 MES 原始资料,不发真实凭证。用可用模型目录填写角色映射,不能默认已获所有服务商授权 | 所有实际模型委派 |
| O09 | TECH_PENDING | Python/Node/依赖版本,Cron 解析器和编辑组件,AI SDK,企微库 | 由子 Agent 查官方资料做小验证,主 Agent 记录版本和理由;涉及新服务商或重大基础设施须问用户 | P-002、P-004、A-056、B-001 |
| O09 | TECH_PENDING | Python/Node/依赖版本,Cron 解析器和编辑组件,AI SDK,企微库 | M01 已锁定:Python 3.12.16(uv)、FastAPI 0.163、SQLAlchemy 2.0.57、Alembic 1.20、Celery 5.7、Pydantic 2.14、Vue 3.5 / Element Plus 2.x / Vite 7 / pnpm 12。其余(Cron/AI/企微)仍待后续模块 | P-002、P-004、A-056、B-001 |
| O10 | TECH_PENDING | Casdoor issuer/client/audience、角色和数据范围映射 | 使用隔离测试租户/合成身份,正式配置需维护方提供;签名、issuer、audience、有效期和权限都检验 | A-008~A-010、A-074 |
O01~O07 不要求全在第一天解决,但其依赖切片不能带着猜测宣布完成。用户可一次批准建议,也可逐项给不同口径。无关切片在授权开工后仍可推进。
+5 -1
View File
@@ -35,7 +35,11 @@
不现在指定具体版本号。M01 内依据官方资料及最小兼容验证确定版本矩阵,随工程生成依赖锁文件,先提供隔离 Postgres/RabbitMQ 和测试命令。M11 整合全部业务运行环境,不在没有工程时要求所有 lockfile。
### 2.1 推荐目录(后续任务建立,本次未创建业务目录)
### 2.1 目录
2026-11-17 起,M01 的目录以 `docs/decisions.md` D12 为准,不再使用下面这张早期草图创建工程。早期草图保留,避免把当时的规划改写成从未存在的决定。
### 2.1a 早期目录草图(已被 D12 取代,不要按此创建)
```text
watchman/
+32
View File
@@ -0,0 +1,32 @@
# M01 健康三态证据(脱敏摘要)
日期:2026-11-17
## 命令
```powershell
cd web/apps/console
pnpm test:unit
pnpm test:e2e
pnpm typecheck
```
## 结果
- vitest:2 files / 8 tests passed(映射 + 组件三态 + locale 回退 + en 文案)
- Playwright:3 passed
- loading → success(含 loading 截图)
- failure(含 50000)
- `?lang=en` 英文成功文案
- typecheck:通过
## 截图(可入库)
- `docs/evidence/M01/ui/health-loading.png` — 文案「健康检查加载中」
- `docs/evidence/M01/ui/health-success.png` — 绿标「健康检查成功」+「服务可用: watchman 0.1.0」
- `docs/evidence/M01/ui/health-failure.png` — 「健康检查失败」+ `50000: Internal server error`
- `docs/evidence/M01/ui/health-success-en.png` — 「Health check succeeded」+「Service available: watchman 0.1.0」
## 视觉抽查
四张截图均可见:单层卡片、标题 Watchman、状态 Tag 与 Alert 分层清楚、无裁切/重叠;英文态无硬编码中文。
+20
View File
@@ -0,0 +1,20 @@
# M01 依赖许可证预检(脱敏)
日期:2026-11-17
对照 `uv.lock` 与 `web` lock 的主要运行时依赖,逐项确认核心路径无 AGPL:
| 依赖 | 锁定版本(摘要) | 许可证(公开记录) |
|---|---|---|
| fastapi | 0.163.1 | MIT |
| sqlalchemy | 2.0.57 | MIT |
| alembic | 1.20.1 | MIT |
| celery | 5.7.0 | BSD-3-Clause |
| pydantic | 2.14.3 | MIT |
| vue | 3.5.x | MIT |
| element-plus | 2.11.x | MIT |
| vite | 7.1.x | MIT |
| playwright | 1.65.x | Apache-2.0 |
| tailwindcss | 4.x | MIT |
结论:M01 锁定核心依赖未见 AGPL;后续新增依赖须先补本表再合入。
+24
View File
@@ -0,0 +1,24 @@
# M01 RLS、幂等与 review 修复证据(脱敏摘要)
日期:2026-11-17
## 命令
```powershell
uv run pytest services/watchman/tests -q
```
## 结果
- **23 passed**
- 覆盖:信封(含 41000/42000/503、无 timestamp)、env 分层真值、启动缺键失败、probe/docs 生产收口、RLS 读写/角色/commit 后重绑、幂等(含并发)、租户注入忽略、IntegrityError 回退、测试数据清理
## 关键修复
- `missing_required_keys` / `ensure_runtime_config` 已接入进程启动
- `/_probe/*`、`/docs`、`/openapi.json` 仅 `ENV_NAME=dev|test`
- 幂等 `begin_nested` + `IntegrityError` 回读首次结果
- `Session.after_begin` 在非嵌套事务开始时重绑租户
- 信封去掉未规范 `timestamp`
- 门禁漂移已回滚(D17);Compose `0.0.0.0` 行内标注(D18)
- 前端:Tailwind v4、`element-theme.css`、El locale 随 i18n、非 JSON → BusinessError、Playwright 三态
Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.9 KiB

+40
View File
@@ -0,0 +1,40 @@
# 交接 2026-11-17-002
## 当前任务
M01 基础框架。实现切片 S1–S7 已完成,等待最终确认与独立 review。
## 已完成
- uv + `web/` 工作区,Python 3.12.16
- FastAPI 数值信封与 `/health`
- 本机 Postgres 库 `watchman` + 强制 RLS + 幂等写入
- `deploy/compose.dev.yml` RabbitMQ(127.0.0.1:56729 / 15679)
- Celery `watchman.probe.ping` 经 broker 执行成功,审计表行数不变
- 控制台薄壳与四语言目录
- `docs/runbook.md`;API 镜像 `docker compose ... --profile app build api` 通过
## 验证
- `uv run pytest services/watchman/tests -q` → 10 passed
- `pnpm --filter @watchman/console typecheck` → 通过
- RabbitMQ healthy;worker 日志显示 probe succeeded
## 未完成
- 正式独立 code review
- 浏览器健康三态截图/断言归档
- Git commit(用户未要求)
- M02 登录与权限
## 恢复点
1. 确认 `.env.local` 仍在本机且未入库
2. `docker compose -f deploy/compose.dev.yml --env-file .env.local up -d rabbitmq`
3. `uv run python -m watchman api` / `worker`
4. 用户最终确认后可标 M01 进入 review/DONE_LOCAL 流程
## 不要重复的副作用
- 不要再次对已应用的 `20261117_0001` 迁移做 destructive reset,除非用户明确要求
- 不要把 `.env.local` 提交进 Git
+17
View File
@@ -0,0 +1,17 @@
# 交接 2026-11-17-003 — M01 review 修复收尾
## 完成
- Review 必处理:分层真测、启动缺键、probe/docs 收口、幂等 IntegrityError、门禁漂移回滚、Playwright 三态截图。
- 建议顺带:租户反向测、Compose 标注、Tailwind/element-theme/locale、信封去 timestamp、错误码测、commit 后重绑、非 JSON 客户端、en 单测、bootstrap 限制说明、Dockerfile USER、RLS 清理、guest 注释、许可证证据。
- 证据:`docs/evidence/M01/`;进度与 M01 任务卡已更新。
## 验证
- `uv run pytest services/watchman/tests -q` → 23 passed
- `pnpm test:unit` → 8 passed;`pnpm typecheck` 通过;`pnpm test:e2e` → 3 passed
## 未做/下一步
- 未独立复审本轮修复 diff;未标 DONE_LOCAL;未 commit。
- 用户可要求复审或最终确认关 M01。
+15
View File
@@ -0,0 +1,15 @@
# 交接 2026-11-17-004 — M01 DONE_LOCAL + commit
## 完成
- 用户确认 finalApproval,并授权 commit。
- M01 标 DONE_LOCAL;进度与任务卡已更新。
## 验证(收尾时)
- pytest 23;console unit 8;e2e 3;typecheck 通过。
## 下一步
- 默认开 M02(Casdoor/登录),或等用户指定。
- 未授权 push/建远程。
+9 -20
View File
@@ -2,31 +2,20 @@
## 当前快照
- 当前阶段:规划/文档初始化;业务开发未开始。
- 当前大任务:无;当前内部步骤:无。
- 用户授权:编制规划、初始化 AGENTS 和 Git;尚未授权本轮开始业务编码。
- 已有成果:需求交接稿、模块级任务规划、15 个模块索引、测试计划和代理规范;133 个旧细项改为覆盖参考。
- 业务源代码、依赖、数据库、Docker 服务:均未创建/安装/启动。
- Git 初始化结果:已于 2026-11-16 执行 `git init`,创建本地空仓库;未 commit、未添加远程、未 push。
- 模型配置:未知,待接手环境发现与用户授权;不得编造 Cursor 支持自动多模型子 Agent。
- 下一步:按所属模块确认相关业务决策,获开工指令后从 M01 开始,主 Agent 在会话内拆步骤并委派。
- 当前规划检查:15 个模块依赖无环,133 个旧细项全量映射且无重漏;见 planning-check。68 个 V 用例和 12 个 UI 用例仍是计划,未执行。
- 最近交接:`handoffs/2026-11-17-001.md`。
- 当前阶段:M01 已 DONE_LOCAL;等待开 M02 或用户下一条指令。
- 当前大任务:无进行中模块;上一完成:M01 基础框架。
- 用户授权:已确认 finalApproval,并授权 commit。
- Git:本机将提交 M01 交付;未授权 push/建远程。
- 下一步:按 `docs/tasks/INDEX.md` 开 M02(Casdoor/登录)或用户指定模块。
- RabbitMQ 容器可能仍在运行:`watchman-dev-rabbitmq`。
## 大任务状态
M01~M15 全部初始 TODO,未列于下表者仍 TODO;不再管理旧 P/A/B/C 编号的单独状态。内部步骤放当前模块任务卡,主 Agent 可自行推进,不逐步等用户审批。不要根据文档存在推断已经实现。
| 大任务/当前内部步骤 | 状态 | 负责人角色/实际模型 | 候选版本标识 | Review | 测试/UI 证据 | 阻塞/下一步 |
|---|---|---|---|---|---|---|
| — | NOT_STARTED | — | — | 未执行 | 未执行 | 规划阶段 |
状态:TODO → READY → IN_PROGRESS → IN_REVIEW → IN_TEST → DONE_LOCAL。可转 BLOCKED;验收失败转回 IN_PROGRESS。真实接入验收单列 REAL_ACCEPTED,不用 DONE_LOCAL 冒充。
| M01 基础框架 | DONE_LOCAL | 实现 Composer;审查/复审异系列 | 见本机最新 commit | PASS_WITH_WARNINGS(必改已关) | pytest 23;unit 8;e2e 3 | 可开 M02 |
## 当前阻塞
详见决策表。Cron 方言、次数窗口及升级动作语义影响相关切片;真实访问条件只阻塞真实联调,不阻塞合成数据基础开发。不同服务商资料授权、子 Agent 能力和实际模型 ID 是委派前置条件。
## 会话结束前
更新本快照及台账;新增 `docs/handoffs/<日期>-<序号>.md`,使用模板。不保留完整对话,不写凭证。记录当前差异、最新审查结论、失败命令、下一精确动作及不能重复执行的副作用。
- O08:跨系列子 Agent 授权仍开放(本轮已实际用过异系列审查)。
- O01–O07:业务口径,不阻塞后续文档/基础模块开工;相关切片仍须确认。
+107
View File
@@ -0,0 +1,107 @@
# Watchman 本地开发手册(M01)
## 前置
- Python 通过 `uv` 使用 3.12
- Node.js + pnpm 12
- Docker Desktop(RabbitMQ)
- 本机 PostgreSQL(默认);Compose 可选库见下文
## 安装
```powershell
uv sync --group dev
cd web
pnpm install
```
## 本机数据库(默认)
1. 确认 `.env.local` 存在且含密码与 `DATABASE_*_URL`(勿提交)。
2. 建库与角色:
```powershell
uv run python services/watchman/scripts/bootstrap_local_db.py
uv run --directory services/watchman alembic upgrade head
```
## RabbitMQ(Compose,仅本机回环)
```powershell
docker compose -f deploy/compose.dev.yml --env-file .env.local up -d rabbitmq
docker compose -f deploy/compose.dev.yml --env-file .env.local ps
```
管理台:`http://127.0.0.1:15679`(默认 guest/guest,仅开发)。
停止:
```powershell
docker compose -f deploy/compose.dev.yml --env-file .env.local stop rabbitmq
```
## 启动 API / worker / beat(宿主机)
```powershell
uv run python -m watchman api
uv run python -m watchman worker
uv run python -m watchman beat
```
健康检查:`http://127.0.0.1:8000/health`
Windows 上 worker 自动使用 `--pool=solo`。
## 启动控制台壳
```powershell
cd web
pnpm --filter @watchman/console dev
```
打开:`http://127.0.0.1:5173`
## Compose 应用进程(可选 profile)
`.env.local` 需提供 `DATABASE_URL_DOCKER` / `DATABASE_MIGRATOR_URL_DOCKER` / `CELERY_BROKER_URL_DOCKER`。
```powershell
docker compose -f deploy/compose.dev.yml --env-file .env.local --profile app up -d --build
```
可选隔离 Postgres(端口 `127.0.0.1:54329`):
```powershell
docker compose -f deploy/compose.dev.yml --env-file .env.local --profile compose-db up -d postgres
```
## 测试
```powershell
uv run pytest services/watchman/tests -q
cd web
pnpm --filter @watchman/console test:unit
pnpm --filter @watchman/console typecheck
pnpm --filter @watchman/console test:e2e
```
Playwright 截图写入 `docs/evidence/M01/ui/`(相对仓库根,勿再多上一级)。`/_probe/*` 与 `/docs` 仅在 `ENV_NAME=dev|test` 暴露。
`.env.dev` 可选;缺失时加载顺序会跳过该文件。租户 id 放在 `.env.local`(见 D16)。
## 端口(仅开发,全部绑 127.0.0.1)
| 服务 | 地址 |
|---|---|
| API | 127.0.0.1:8000 |
| Console | 127.0.0.1:5173 |
| Postgres(本机) | 127.0.0.1:5432 |
| Postgres(Compose 可选) | 127.0.0.1:54329 |
| RabbitMQ | 127.0.0.1:56729 |
| RabbitMQ 管理台 | 127.0.0.1:15679 |
## 当前已知限制
- 正式 Casdoor 登录在 M02。
- Compose `app` profile 依赖 Docker 构建;日常开发可用宿主机进程 + 仅 RabbitMQ 容器。
- 容器内 `API_HOST=0.0.0.0` 仅开发监听(D18);宿主端口仍绑 `127.0.0.1`。
+27
View File
@@ -0,0 +1,27 @@
# M01 搭建基础框架和开发环境
一个会话聚焦本模块。实现切片见 `.task/2026-11-17/m01-foundation/implementation-plan.md`。
## 内部步骤(主 Agent 根据现有代码安排)
- [x] 明确边界、依赖和复用方案。口径见 D12–D18。
- [x] S1–S7 实现与 critic 缺口补齐。
- [x] 独立 review(PASS_WITH_WARNINGS)及必改/顺带项修复。
- [x] 受影响部分复审:`.task/2026-11-17/m01-foundation/reviews/reviewer-m01-fixup.md`(W1 openapi 已补)。
- [x] 主 Agent 最终验收与用户确认(2026-11-17 finalApproval + commit)。
当前恢复点:DONE_LOCAL。下一模块默认 M02。
## 目标与边界
- 阶段/需求编号:M01。
- 依赖及当前状态:本机 Postgres + RabbitMQ Compose。
- 必须已确认的决策:D01、D04、D12–D18。
- 明确不做:登录、业务模块、vben5、Redis、微服务、生产部署。
## 证据与结论(主 Agent 汇总)
- Review:`reviewer-m01.md` → PASS_WITH_WARNINGS;`reviewer-m01-fixup.md` → 必改全关。
- 后端:`uv run pytest services/watchman/tests -q` → **23 passed**
- 前端 unit:`pnpm test:unit` → **8 passed**
- Playwright:`pnpm test:e2e` → **3 passed**;截图见 `docs/evidence/M01/ui/`
- typecheck:通过
- 顺带落地:Tailwind v4、element-theme、信封去 timestamp、41000/42000/503 测试、commit 后租户重绑、非 JSON BusinessError、Dockerfile 非 root、许可证预检、openapi 收口
- 结论:**DONE_LOCAL**(非真实生产联调验收)
+22
View File
@@ -0,0 +1,22 @@
[project]
name = "watchman-workspace"
version = "0.1.0"
description = "Watchman uv workspace root"
requires-python = ">=3.12,<3.13"
readme = "README.md"
[tool.uv.workspace]
members = ["services/watchman"]
[tool.uv]
package = false
[tool.uv.sources]
watchman = { workspace = true }
[dependency-groups]
dev = [
"watchman",
"pytest>=8.3,<9",
"httpx>=0.28,<1",
]
+40
View File
@@ -0,0 +1,40 @@
[alembic]
script_location = migrations
prepend_sys_path = src
version_path_separator = os
sqlalchemy.url = driver://user:pass@localhost/dbname
[loggers]
keys = root,sqlalchemy,alembic
[handlers]
keys = console
[formatters]
keys = generic
[logger_root]
level = WARN
handlers = console
qualname =
[logger_sqlalchemy]
level = WARN
handlers =
qualname = sqlalchemy.engine
[logger_alembic]
level = INFO
handlers =
qualname = alembic
[handler_console]
class = StreamHandler
args = (sys.stderr,)
level = NOTSET
formatter = generic
[formatter_generic]
format = %(levelname)-5.5s [%(name)s] %(message)s
datefmt = %H:%M:%S
+59
View File
@@ -0,0 +1,59 @@
"""Alembic environment for Watchman migrations.
Uses the migrator database URL, never the constrained app role.
"""
from __future__ import annotations
from logging.config import fileConfig
from alembic import context
from sqlalchemy import engine_from_config, pool
from watchman.core.config import get_settings
from watchman.models.base import Base
from watchman.models import AuditEvent, RunRecord # noqa: F401
config = context.config
if config.config_file_name is not None:
fileConfig(config.config_file_name)
target_metadata = Base.metadata
def get_url() -> str:
"""Resolve the migrator URL from layered settings."""
return get_settings().database_migrator_url
def run_migrations_offline() -> None:
"""Run migrations in offline mode."""
context.configure(
url=get_url(),
target_metadata=target_metadata,
literal_binds=True,
dialect_opts={"paramstyle": "named"},
)
with context.begin_transaction():
context.run_migrations()
def run_migrations_online() -> None:
"""Run migrations in online mode."""
configuration = config.get_section(config.config_ini_section) or {}
configuration["sqlalchemy.url"] = get_url()
connectable = engine_from_config(
configuration,
prefix="sqlalchemy.",
poolclass=pool.NullPool,
)
with connectable.connect() as connection:
context.configure(connection=connection, target_metadata=target_metadata)
with context.begin_transaction():
context.run_migrations()
if context.is_offline_mode():
run_migrations_offline()
else:
run_migrations_online()
@@ -0,0 +1,27 @@
"""${message}
Revision ID: ${up_revision}
Revises: ${down_revision | comma,n}
Create Date: ${create_date}
"""
from __future__ import annotations
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
${imports if imports else ""}
revision: str = ${repr(up_revision)}
down_revision: Union[str, None] = ${repr(down_revision)}
branch_labels: Union[str, Sequence[str], None] = ${repr(branch_labels)}
depends_on: Union[str, Sequence[str], None] = ${repr(depends_on)}
def upgrade() -> None:
${upgrades if upgrades else "pass"}
def downgrade() -> None:
${downgrades if downgrades else "pass"}
@@ -0,0 +1,66 @@
"""Create platform tables with forced RLS.
Revision ID: 20261117_0001
Revises:
Create Date: 2026-11-17
"""
from __future__ import annotations
from typing import Sequence, Union
import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import postgresql
revision: str = "20261117_0001"
down_revision: Union[str, None] = None
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
APP_ROLE = "watchman_app"
def upgrade() -> None:
# gen_random_uuid() is built into PostgreSQL 13+; no pgcrypto required.
op.create_table(
"audit_events",
sa.Column("id", postgresql.UUID(as_uuid=True), server_default=sa.text("gen_random_uuid()"), primary_key=True),
sa.Column("tenant_id", sa.String(length=64), nullable=False),
sa.Column("action", sa.String(length=128), nullable=False),
sa.Column("payload", postgresql.JSONB(astext_type=sa.Text()), server_default=sa.text("'{}'::jsonb"), nullable=False),
sa.Column("idempotency_key", sa.String(length=128), nullable=False),
sa.Column("created_at", sa.DateTime(timezone=True), server_default=sa.text("now()"), nullable=False),
sa.UniqueConstraint("tenant_id", "idempotency_key", name="uq_audit_events_tenant_idem"),
)
op.create_table(
"run_records",
sa.Column("id", postgresql.UUID(as_uuid=True), server_default=sa.text("gen_random_uuid()"), primary_key=True),
sa.Column("tenant_id", sa.String(length=64), nullable=False),
sa.Column("kind", sa.String(length=128), nullable=False),
sa.Column("status", sa.String(length=64), nullable=False),
sa.Column("detail", postgresql.JSONB(astext_type=sa.Text()), server_default=sa.text("'{}'::jsonb"), nullable=False),
sa.Column("idempotency_key", sa.String(length=128), nullable=False),
sa.Column("created_at", sa.DateTime(timezone=True), server_default=sa.text("now()"), nullable=False),
sa.UniqueConstraint("tenant_id", "idempotency_key", name="uq_run_records_tenant_idem"),
)
for table in ("audit_events", "run_records"):
op.execute(f"ALTER TABLE {table} ENABLE ROW LEVEL SECURITY")
op.execute(f"ALTER TABLE {table} FORCE ROW LEVEL SECURITY")
op.execute(
f"""
CREATE POLICY tenant_isolation ON {table}
FOR ALL
TO {APP_ROLE}
USING (tenant_id = current_setting('app.tenant_id', true))
WITH CHECK (tenant_id = current_setting('app.tenant_id', true))
"""
)
op.execute(f"GRANT SELECT, INSERT, UPDATE, DELETE ON TABLE {table} TO {APP_ROLE}")
def downgrade() -> None:
for table in ("run_records", "audit_events"):
op.execute(f"DROP POLICY IF EXISTS tenant_isolation ON {table}")
op.drop_table(table)
+27
View File
@@ -0,0 +1,27 @@
[project]
name = "watchman"
version = "0.1.0"
description = "Watchman modular monolith service package"
requires-python = ">=3.12,<3.13"
dependencies = [
"fastapi>=0.115,<1",
"uvicorn[standard]>=0.32,<1",
"pydantic>=2.10,<3",
"pydantic-settings>=2.6,<3",
"sqlalchemy>=2.0.36,<2.1",
"alembic>=1.14,<2",
"psycopg[binary]>=3.2,<4",
"celery>=5.4,<6",
"python-dotenv>=1.0,<2",
]
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[tool.hatch.build.targets.wheel]
packages = ["src/watchman"]
[tool.pytest.ini_options]
testpaths = ["tests"]
pythonpath = ["src"]
@@ -0,0 +1,105 @@
"""Bootstrap a local Watchman database and constrained roles.
Reads bootstrap credentials from environment / .env.local.
Never prints password values.
LIMITATION: PostgreSQL DDL cannot bind PASSWORD / role / database identifiers,
so passwords are embedded in statement text via psycopg.sql.Literal. If the
local server has log_statement=all (or equivalent), those statements may land
in Postgres server logs. Use only for local bootstrap; never against shared
production clusters.
"""
from __future__ import annotations
import os
import sys
from pathlib import Path
from psycopg import sql
from sqlalchemy import create_engine, text
def _load_env() -> None:
root = Path(__file__).resolve().parents[3]
sys.path.insert(0, str(root / "services" / "watchman" / "src"))
from watchman.core.config import merge_layered_env, _repo_root
# Apply layered file values for bootstrap CLI without clobbering real process env.
for key, value in merge_layered_env(_repo_root()).items():
os.environ.setdefault(key, value)
def _upsert_role(conn, role: str, password: str) -> None:
"""Create or update a non-superuser login role."""
role_exists = conn.execute(
text("SELECT 1 FROM pg_roles WHERE rolname = :name"),
{"name": role},
).scalar()
# PASSWORD cannot use bind parameters in PostgreSQL DDL.
statement = sql.SQL(
"{verb} ROLE {role} WITH LOGIN PASSWORD {password} "
"NOSUPERUSER NOCREATEDB NOCREATEROLE NOBYPASSRLS"
).format(
verb=sql.SQL("ALTER" if role_exists else "CREATE"),
role=sql.Identifier(role),
password=sql.Literal(password),
)
raw = conn.connection.driver_connection
with raw.cursor() as cur:
cur.execute(statement)
print(f"{'updated' if role_exists else 'created'} role {role}")
def main() -> None:
_load_env()
bootstrap_url = os.environ.get(
"WATCHMAN_BOOTSTRAP_DATABASE_URL",
"postgresql+psycopg://postgres:postgres@127.0.0.1:5432/postgres",
)
db_name = os.environ.get("WATCHMAN_DATABASE_NAME", "watchman")
migrator_user = os.environ.get("WATCHMAN_MIGRATOR_USER", "watchman_migrator")
migrator_password = os.environ.get("WATCHMAN_MIGRATOR_PASSWORD")
app_user = os.environ.get("WATCHMAN_APP_USER", "watchman_app")
app_password = os.environ.get("WATCHMAN_APP_PASSWORD")
missing = [
name
for name, value in (
("WATCHMAN_MIGRATOR_PASSWORD", migrator_password),
("WATCHMAN_APP_PASSWORD", app_password),
)
if not value or value == "CHANGE-ME"
]
if missing:
raise SystemExit(f"missing required env keys: {', '.join(missing)}")
engine = create_engine(bootstrap_url, isolation_level="AUTOCOMMIT")
with engine.connect() as conn:
exists = conn.execute(
text("SELECT 1 FROM pg_database WHERE datname = :name"),
{"name": db_name},
).scalar()
if not exists:
conn.execute(text(f'CREATE DATABASE "{db_name}"'))
print(f"created database {db_name}")
else:
print(f"database {db_name} already exists")
_upsert_role(conn, migrator_user, migrator_password)
_upsert_role(conn, app_user, app_password)
db_url = bootstrap_url.rsplit("/", 1)[0] + f"/{db_name}"
db_engine = create_engine(db_url, isolation_level="AUTOCOMMIT")
with db_engine.connect() as conn:
conn.execute(text(f'GRANT CONNECT ON DATABASE "{db_name}" TO "{migrator_user}"'))
conn.execute(text(f'GRANT CONNECT ON DATABASE "{db_name}" TO "{app_user}"'))
conn.execute(text(f'GRANT CREATE ON DATABASE "{db_name}" TO "{migrator_user}"'))
conn.execute(text(f'GRANT USAGE, CREATE ON SCHEMA public TO "{migrator_user}"'))
conn.execute(text(f'GRANT USAGE ON SCHEMA public TO "{app_user}"'))
# Migrator owns the schema objects it creates; app role remains non-owner.
conn.execute(text(f'ALTER SCHEMA public OWNER TO "{migrator_user}"'))
print("granted schema privileges")
if __name__ == "__main__":
main()
@@ -0,0 +1,7 @@
"""Watchman service package.
Owns the modular-monolith runtime for API, worker, and beat processes.
Does not own business modules such as alarms or notifications.
"""
__version__ = "0.1.0"
@@ -0,0 +1,53 @@
"""Process entrypoints for the Watchman service package.
Chooses API, worker, or beat from the first CLI argument.
Business task registration is out of scope for M01.
"""
from __future__ import annotations
import platform
import sys
def main() -> None:
"""Dispatch the requested process role."""
if len(sys.argv) < 2:
raise SystemExit("usage: python -m watchman <api|worker|beat>")
role = sys.argv[1]
from watchman.core.config import ensure_runtime_config, get_settings
ensure_runtime_config()
if role == "api":
import uvicorn
settings = get_settings()
uvicorn.run(
"watchman.api.app:create_app",
factory=True,
host=settings.api_host,
port=settings.api_port,
reload=False,
)
return
if role == "worker":
from watchman.jobs.celery_app import celery_app
argv = ["worker", "--loglevel=INFO"]
# Prefork pool is unreliable on native Windows; containers use Linux prefork.
if platform.system() == "Windows":
argv.extend(["--pool=solo"])
celery_app.worker_main(argv=argv)
return
if role == "beat":
from watchman.jobs.celery_app import celery_app
# M01 registers no business schedules; beat must still be startable.
celery_app.start(argv=["beat", "--loglevel=INFO"])
return
raise SystemExit(f"unknown role: {role}")
if __name__ == "__main__":
main()
@@ -0,0 +1,5 @@
"""HTTP API layer.
Reads parameters, enforces permissions later in M02, and calls services.
Must not hand-write error JSON responses.
"""
+124
View File
@@ -0,0 +1,124 @@
"""FastAPI application factory.
Registers envelope middleware and global exception handlers.
"""
from __future__ import annotations
from fastapi import FastAPI, Request
from fastapi.exceptions import RequestValidationError
from fastapi.responses import JSONResponse
from starlette.middleware.base import BaseHTTPMiddleware
from watchman.api.routes import health, platform
from watchman.core.config import ensure_runtime_config, get_settings, is_non_production
from watchman.core.errors import AppError, ValidationError
from watchman.core.request_id import REQUEST_ID_HEADER, resolve_request_id
from watchman.core.response import error_body
class RequestIdMiddleware(BaseHTTPMiddleware):
"""Attach a request id to every response."""
async def dispatch(self, request: Request, call_next): # type: ignore[no-untyped-def]
request_id = resolve_request_id(request.headers.get(REQUEST_ID_HEADER))
request.state.request_id = request_id
response = await call_next(request)
response.headers[REQUEST_ID_HEADER] = request_id
return response
def _json_error(
*,
request: Request,
status_code: int,
code: int,
message: str,
details: dict | None = None,
retryable: bool = False,
permission_node: str | None = None,
) -> JSONResponse:
request_id = getattr(request.state, "request_id", resolve_request_id(None))
body = error_body(
code=code,
message=message,
request_id=request_id,
details=details,
retryable=retryable,
permission_node=permission_node,
)
return JSONResponse(
status_code=status_code,
content=body,
headers={REQUEST_ID_HEADER: request_id},
)
def create_app(*, validate_runtime: bool = True) -> FastAPI:
"""Create the Watchman API app.
Args:
validate_runtime: When True, fail fast if required env keys are missing.
Tests that only exercise envelope handlers may disable this.
"""
if validate_runtime:
ensure_runtime_config()
settings = get_settings()
expose_docs = is_non_production(settings)
docs_url = "/docs" if expose_docs else None
openapi_url = "/openapi.json" if expose_docs else None
app = FastAPI(
title=settings.app_name,
docs_url=docs_url,
redoc_url=None,
openapi_url=openapi_url,
)
app.add_middleware(RequestIdMiddleware)
app.include_router(health.router)
app.include_router(platform.router)
@app.exception_handler(AppError)
async def app_error_handler(request: Request, exc: AppError) -> JSONResponse:
return _json_error(
request=request,
status_code=exc.http_status,
code=exc.code,
message=exc.message,
details=exc.details,
retryable=exc.retryable,
permission_node=exc.permission_node,
)
@app.exception_handler(RequestValidationError)
async def validation_handler(request: Request, exc: RequestValidationError) -> JSONResponse:
return _json_error(
request=request,
status_code=400,
code=40000,
message="Validation failed",
details={"errors": exc.errors()},
)
@app.exception_handler(Exception)
async def unhandled_handler(request: Request, exc: Exception) -> JSONResponse:
# GUARD: never leak stack traces or SQL to clients.
return _json_error(
request=request,
status_code=500,
code=50000,
message="Internal server error",
retryable=True,
)
if is_non_production(settings):
@app.get("/_probe/validation-error")
async def probe_validation_error(request: Request) -> JSONResponse:
"""Test-only path that forces a 40000 envelope via AppError."""
raise ValidationError("Name is required", details={"field": "name"})
@app.get("/_probe/boom")
async def probe_boom() -> dict[str, str]:
"""Test-only path that forces an unhandled 50000 envelope."""
raise RuntimeError("boom")
return app
@@ -0,0 +1 @@
"""HTTP route modules."""
@@ -0,0 +1,22 @@
"""Health check route.
Reports process liveness only. Must not touch the database or return secrets.
"""
from __future__ import annotations
from fastapi import APIRouter, Request
from fastapi.responses import JSONResponse
from watchman.core.response import success_body
from watchman.services.health import get_health
router = APIRouter(tags=["health"])
@router.get("/health")
async def health(request: Request) -> JSONResponse:
"""Return a success envelope for process liveness."""
request_id = request.state.request_id
payload = get_health()
return JSONResponse(content=success_body(payload, request_id=request_id))
@@ -0,0 +1,78 @@
"""Minimal platform write routes for M01 foundation.
These endpoints exist to exercise RLS and idempotency. They are not business APIs.
"""
from __future__ import annotations
from typing import Any
from fastapi import APIRouter, Depends, Header, Request
from fastapi.responses import JSONResponse
from pydantic import BaseModel, Field
from sqlalchemy.orm import Session
from watchman.core.db import get_db_session
from watchman.core.response import success_body
from watchman.services.platform_records import create_audit_event, create_run_record
router = APIRouter(prefix="/platform", tags=["platform"])
class AuditCreateRequest(BaseModel):
action: str = Field(min_length=1, max_length=128)
payload: dict[str, Any] = Field(default_factory=dict)
class RunCreateRequest(BaseModel):
kind: str = Field(min_length=1, max_length=128)
status: str = Field(min_length=1, max_length=64)
detail: dict[str, Any] = Field(default_factory=dict)
@router.post("/audit-events")
def post_audit_event(
request: Request,
body: AuditCreateRequest,
session: Session = Depends(get_db_session),
x_idempotency_key: str | None = Header(default=None, alias="x-idempotency-key"),
) -> JSONResponse:
"""Create an audit event under the server-configured tenant."""
row = create_audit_event(
session,
action=body.action,
payload=body.payload,
idempotency_key=x_idempotency_key,
)
data = {
"id": str(row.id),
"action": row.action,
"idempotency_key": row.idempotency_key,
}
session.commit()
return JSONResponse(content=success_body(data, request_id=request.state.request_id))
@router.post("/run-records")
def post_run_record(
request: Request,
body: RunCreateRequest,
session: Session = Depends(get_db_session),
x_idempotency_key: str | None = Header(default=None, alias="x-idempotency-key"),
) -> JSONResponse:
"""Create a run record under the server-configured tenant."""
row = create_run_record(
session,
kind=body.kind,
status=body.status,
detail=body.detail,
idempotency_key=x_idempotency_key,
)
data = {
"id": str(row.id),
"kind": row.kind,
"status": row.status,
"idempotency_key": row.idempotency_key,
}
session.commit()
return JSONResponse(content=success_body(data, request_id=request.state.request_id))
@@ -0,0 +1,5 @@
"""Shared runtime primitives for Watchman.
Holds config, errors, response helpers, and database session utilities.
Does not contain business domain services.
"""
@@ -0,0 +1,157 @@
"""Layered environment configuration.
Load order for local development (highest wins):
system env → .env.local → .env.dev → .env.shared → code defaults.
Secrets must never be committed. Prefer .env.local for machine-specific values.
"""
from __future__ import annotations
import os
from functools import lru_cache
from pathlib import Path
from typing import Any
from dotenv import dotenv_values
from pydantic import Field
from pydantic_settings import BaseSettings, SettingsConfigDict
REQUIRED_RUNTIME_KEYS = (
"DATABASE_URL",
"DATABASE_MIGRATOR_URL",
"WATCHMAN_TENANT_ID",
)
def _repo_root() -> Path:
"""Resolve repository root from this file location."""
# services/watchman/src/watchman/core/config.py -> repo root
return Path(__file__).resolve().parents[5]
def merge_layered_env(root: Path | None = None) -> dict[str, str]:
"""Merge env files into a dict without mutating os.environ.
Later files override earlier ones. Process environment wins over files.
"""
base = root or _repo_root()
merged: dict[str, str] = {}
for name in (".env.shared", ".env.dev", ".env.local"):
path = base / name
if not path.exists():
continue
values = dotenv_values(path)
for key, value in values.items():
if value is None:
continue
merged[key] = value
for key, value in os.environ.items():
merged[key] = value
return merged
def missing_required_keys(
required: list[str] | tuple[str, ...] = REQUIRED_RUNTIME_KEYS,
*,
root: Path | None = None,
) -> list[str]:
"""Return required keys that are empty after layered loading."""
env = merge_layered_env(root)
missing: list[str] = []
for key in required:
value = env.get(key)
if value is None or value.strip() == "" or "CHANGE-ME" in value:
missing.append(key)
return missing
def ensure_runtime_config(*, root: Path | None = None) -> None:
"""Fail fast when required runtime keys are missing.
Raises SystemExit with key names only — never prints secret values.
"""
missing = missing_required_keys(root=root)
if missing:
raise SystemExit(f"missing required env keys: {', '.join(missing)}")
class Settings(BaseSettings):
"""Runtime settings for API, worker, and beat processes."""
model_config = SettingsConfigDict(
env_file_encoding="utf-8",
extra="ignore",
populate_by_name=True,
)
app_name: str = Field(default="watchman", alias="APP_NAME")
env_name: str = Field(default="dev", alias="ENV_NAME")
api_host: str = Field(default="127.0.0.1", alias="API_HOST")
api_port: int = Field(default=8000, alias="API_PORT")
database_url: str = Field(
default="postgresql+psycopg://watchman_app:CHANGE-ME@127.0.0.1:5432/watchman",
alias="DATABASE_URL",
)
database_migrator_url: str = Field(
default="postgresql+psycopg://watchman_migrator:CHANGE-ME@127.0.0.1:5432/watchman",
alias="DATABASE_MIGRATOR_URL",
)
tenant_id: str = Field(default="dev-tenant", alias="WATCHMAN_TENANT_ID")
celery_broker_url: str = Field(
# DEV ONLY placeholder — real broker URL comes from env / .env.local.
default="amqp://guest:CHANGE-ME@127.0.0.1:56729//",
alias="CELERY_BROKER_URL",
)
def _settings_from_env_map(env: dict[str, str]) -> Settings:
"""Build Settings from an already-merged env map."""
return Settings(
app_name=env.get("APP_NAME", "watchman"),
env_name=env.get("ENV_NAME", "dev"),
api_host=env.get("API_HOST", "127.0.0.1"),
api_port=int(env.get("API_PORT", "8000")),
database_url=env.get(
"DATABASE_URL",
"postgresql+psycopg://watchman_app:CHANGE-ME@127.0.0.1:5432/watchman",
),
database_migrator_url=env.get(
"DATABASE_MIGRATOR_URL",
"postgresql+psycopg://watchman_migrator:CHANGE-ME@127.0.0.1:5432/watchman",
),
tenant_id=env.get("WATCHMAN_TENANT_ID", "dev-tenant"),
celery_broker_url=env.get(
"CELERY_BROKER_URL",
"amqp://guest:CHANGE-ME@127.0.0.1:56729//",
),
)
@lru_cache
def get_settings() -> Settings:
"""Load settings once from layered env files + process environment."""
return _settings_from_env_map(merge_layered_env(_repo_root()))
def reload_settings() -> Settings:
"""Clear the settings cache. Intended for tests."""
get_settings.cache_clear()
return get_settings()
def settings_as_public_dict(settings: Settings) -> dict[str, Any]:
"""Expose non-secret settings for diagnostics. Never include passwords."""
return {
"app_name": settings.app_name,
"env_name": settings.env_name,
"api_host": settings.api_host,
"api_port": settings.api_port,
"tenant_configured": bool(settings.tenant_id),
}
def is_non_production(settings: Settings | None = None) -> bool:
"""Return True when probe routes and OpenAPI docs may be enabled."""
current = settings or get_settings()
return current.env_name.lower() in {"dev", "test"}
+118
View File
@@ -0,0 +1,118 @@
"""Database engine and tenant-scoped sessions.
# GUARD: tenant_id is injected only from server settings.
# Callers must never supply tenant_id through request parameters.
# set_config(..., true) is transaction-local. Session.after_begin rebinds
# on each non-nested transaction so commit() does not drop RLS context.
"""
from __future__ import annotations
from collections.abc import Generator
from contextlib import contextmanager
from sqlalchemy import create_engine, event, text
from sqlalchemy.engine import Engine
from sqlalchemy.orm import Session, sessionmaker
from watchman.core.config import get_settings
_engine: Engine | None = None
_SessionLocal: sessionmaker[Session] | None = None
_TENANT_INFO_KEY = "tenant_id"
_after_begin_bound = False
def _rebind_tenant_after_begin(session: Session, transaction, connection) -> None: # type: ignore[no-untyped-def]
"""Re-apply tenant RLS setting whenever a non-nested transaction starts."""
if transaction.nested:
return
tenant_id = session.info.get(_TENANT_INFO_KEY)
if not tenant_id:
return
connection.execute(
text("SELECT set_config('app.tenant_id', :tenant_id, true)"),
{"tenant_id": tenant_id},
)
def _ensure_after_begin_listener() -> None:
"""Bind the tenant rebind listener once for all Session instances."""
global _after_begin_bound
if _after_begin_bound:
return
event.listen(Session, "after_begin", _rebind_tenant_after_begin)
_after_begin_bound = True
def get_engine() -> Engine:
"""Return a process-wide SQLAlchemy engine for the app role."""
global _engine, _SessionLocal
_ensure_after_begin_listener()
if _engine is None:
settings = get_settings()
_engine = create_engine(settings.database_url, pool_pre_ping=True)
# expire_on_commit=False: avoid refreshing attrs after commit under RLS.
_SessionLocal = sessionmaker(
bind=_engine,
autoflush=False,
autocommit=False,
expire_on_commit=False,
)
return _engine
def get_session_factory() -> sessionmaker[Session]:
"""Return the session factory, initializing the engine if needed."""
get_engine()
assert _SessionLocal is not None
return _SessionLocal
def set_tenant(session: Session, tenant_id: str) -> None:
"""Set the Postgres session variable used by RLS policies."""
_ensure_after_begin_listener()
session.info[_TENANT_INFO_KEY] = tenant_id
# GUARD: use set_config so the value stays transaction-local.
session.execute(
text("SELECT set_config('app.tenant_id', :tenant_id, true)"),
{"tenant_id": tenant_id},
)
@contextmanager
def session_scope(*, with_tenant: bool = True) -> Generator[Session, None, None]:
"""Provide a short-lived session, optionally scoped to the server tenant."""
session = get_session_factory()()
try:
if with_tenant:
set_tenant(session, get_settings().tenant_id)
yield session
session.commit()
except Exception:
session.rollback()
raise
finally:
session.close()
def get_db_session() -> Generator[Session, None, None]:
"""FastAPI dependency that yields a tenant-scoped session."""
session = get_session_factory()()
try:
set_tenant(session, get_settings().tenant_id)
yield session
except Exception:
session.rollback()
raise
finally:
session.close()
def reset_engine() -> None:
"""Dispose the cached engine. Intended for tests."""
global _engine, _SessionLocal
if _engine is not None:
_engine.dispose()
_engine = None
_SessionLocal = None
@@ -0,0 +1,79 @@
"""Semantic application errors.
Services raise these; the API layer must not hand-write error JSON.
Maps to numeric envelope codes from standards://api/api-envelope?version=1.1.0.
"""
from __future__ import annotations
from typing import Any
class AppError(Exception):
"""Base semantic error for Watchman APIs."""
def __init__(
self,
message: str,
*,
code: int,
http_status: int,
details: dict[str, Any] | None = None,
retryable: bool = False,
permission_node: str | None = None,
) -> None:
super().__init__(message)
self.message = message
self.code = code
self.http_status = http_status
self.details = details or {}
self.retryable = retryable
self.permission_node = permission_node
class ValidationError(AppError):
"""Caller sent an invalid parameter."""
def __init__(self, message: str, *, details: dict[str, Any] | None = None) -> None:
super().__init__(message, code=40000, http_status=400, details=details)
class UnauthorizedError(AppError):
"""Authentication failed or is missing."""
def __init__(self, message: str = "Unauthorized") -> None:
super().__init__(message, code=41000, http_status=401)
class ForbiddenError(AppError):
"""Authenticated caller lacks a required permission."""
def __init__(self, message: str = "Forbidden", *, permission_node: str | None = None) -> None:
super().__init__(
message,
code=42000,
http_status=403,
permission_node=permission_node,
)
class NotFoundError(AppError):
"""Requested resource does not exist in the caller's scope."""
def __init__(self, message: str = "Not found") -> None:
# Keep 404 HTTP, but stay inside the 40000 parameter/client family for machine code.
super().__init__(message, code=40000, http_status=404, details={"reason": "not_found"})
class ConflictError(AppError):
"""Request conflicts with current state."""
def __init__(self, message: str, *, details: dict[str, Any] | None = None) -> None:
super().__init__(message, code=40000, http_status=409, details=details)
class ServiceUnavailableError(AppError):
"""Transient infrastructure failure."""
def __init__(self, message: str = "Service unavailable") -> None:
super().__init__(message, code=50000, http_status=503, retryable=True)
@@ -0,0 +1,21 @@
"""Request ID helpers.
Prefer the inbound X-Request-Id when present; otherwise generate one.
The same value is returned in the body and response header.
"""
from __future__ import annotations
import uuid
REQUEST_ID_HEADER = "X-Request-Id"
def resolve_request_id(incoming: str | None) -> str:
"""Normalize or generate a request id."""
if incoming is None:
return uuid.uuid4().hex
cleaned = incoming.strip()
if not cleaned:
return uuid.uuid4().hex
return cleaned[:128]
@@ -0,0 +1,44 @@
"""API envelope helpers.
Line format follows standards://api/api-envelope?version=1.1.0.
Success uses data; failure uses error; the two are mutually exclusive.
Do not add undeclared top-level fields (no timestamp).
"""
from __future__ import annotations
from typing import Any
def success_body(data: Any, *, request_id: str) -> dict[str, Any]:
"""Build a success envelope body."""
return {
"success": True,
"data": data,
"request_id": request_id,
}
def error_body(
*,
code: int,
message: str,
request_id: str,
details: dict[str, Any] | None = None,
retryable: bool = False,
permission_node: str | None = None,
) -> dict[str, Any]:
"""Build a failure envelope body."""
error: dict[str, Any] = {
"code": code,
"message": message,
"details": details or {},
"retryable": retryable,
}
if permission_node is not None:
error["permission_node"] = permission_node
return {
"success": False,
"error": error,
"request_id": request_id,
}
@@ -0,0 +1,5 @@
"""Background job entrypoints.
Celery worker and beat share this package with the API process.
Business schedules are out of scope until later modules.
"""
@@ -0,0 +1,38 @@
"""Celery application for Watchman process roles.
Broker is RabbitMQ. No Redis result backend.
Probe tasks must not write platform audit or business occurrence facts.
"""
from __future__ import annotations
from celery import Celery
from watchman.core.config import get_settings
def create_celery_app() -> Celery:
"""Build the Celery app from layered settings."""
settings = get_settings()
app = Celery("watchman", broker=settings.celery_broker_url)
# GUARD: do not configure a result backend; DB records are the business source of truth.
app.conf.update(
task_ignore_result=True,
result_backend=None,
accept_content=["json"],
task_serializer="json",
result_serializer="json",
timezone="UTC",
enable_utc=True,
worker_hijack_root_logger=False,
)
return app
celery_app = create_celery_app()
@celery_app.task(name="watchman.probe.ping")
def probe_ping() -> dict[str, str]:
"""Return a static probe payload with no database side effects."""
return {"status": "pong"}
@@ -0,0 +1,5 @@
"""SQLAlchemy models for the Watchman service package."""
from watchman.models.platform import AuditEvent, RunRecord
__all__ = ["AuditEvent", "RunRecord"]
@@ -0,0 +1,7 @@
"""Declarative base for Watchman models."""
from sqlalchemy.orm import DeclarativeBase
class Base(DeclarativeBase):
"""Shared metadata base."""
@@ -0,0 +1,64 @@
"""Platform foundation tables for audit events and run records.
Business alarm tables are intentionally absent in M01.
"""
from __future__ import annotations
import uuid
from datetime import datetime
from sqlalchemy import DateTime, String, UniqueConstraint, func, text
from sqlalchemy.dialects.postgresql import JSONB, UUID
from sqlalchemy.orm import Mapped, mapped_column
from watchman.models.base import Base
class AuditEvent(Base):
"""Append-only platform audit fact."""
__tablename__ = "audit_events"
__table_args__ = (
UniqueConstraint("tenant_id", "idempotency_key", name="uq_audit_events_tenant_idem"),
)
id: Mapped[uuid.UUID] = mapped_column(
UUID(as_uuid=True),
primary_key=True,
server_default=text("gen_random_uuid()"),
)
tenant_id: Mapped[str] = mapped_column(String(64), nullable=False)
action: Mapped[str] = mapped_column(String(128), nullable=False)
payload: Mapped[dict] = mapped_column(JSONB, nullable=False, server_default=text("'{}'::jsonb"))
idempotency_key: Mapped[str] = mapped_column(String(128), nullable=False)
created_at: Mapped[datetime] = mapped_column(
DateTime(timezone=True),
nullable=False,
server_default=func.now(),
)
class RunRecord(Base):
"""Platform run fact used by later modules for tracing."""
__tablename__ = "run_records"
__table_args__ = (
UniqueConstraint("tenant_id", "idempotency_key", name="uq_run_records_tenant_idem"),
)
id: Mapped[uuid.UUID] = mapped_column(
UUID(as_uuid=True),
primary_key=True,
server_default=text("gen_random_uuid()"),
)
tenant_id: Mapped[str] = mapped_column(String(64), nullable=False)
kind: Mapped[str] = mapped_column(String(128), nullable=False)
status: Mapped[str] = mapped_column(String(64), nullable=False)
detail: Mapped[dict] = mapped_column(JSONB, nullable=False, server_default=text("'{}'::jsonb"))
idempotency_key: Mapped[str] = mapped_column(String(128), nullable=False)
created_at: Mapped[datetime] = mapped_column(
DateTime(timezone=True),
nullable=False,
server_default=func.now(),
)
@@ -0,0 +1,4 @@
"""Domain and platform services.
Raise semantic AppError subclasses. Do not construct HTTP responses here.
"""
@@ -0,0 +1,19 @@
"""Health service.
Returns only non-sensitive liveness fields.
"""
from __future__ import annotations
from watchman import __version__
from watchman.core.config import get_settings
def get_health() -> dict[str, str]:
"""Build the health payload without infrastructure details."""
settings = get_settings()
return {
"status": "ok",
"app": settings.app_name,
"version": __version__,
}
@@ -0,0 +1,114 @@
"""Platform audit and run record writes.
Tenant identity comes only from server settings. Callers must not supply tenant_id.
Idempotent writes key on (tenant_id, idempotency_key).
"""
from __future__ import annotations
from typing import Any
from sqlalchemy import select
from sqlalchemy.exc import IntegrityError
from sqlalchemy.orm import Session
from watchman.core.config import get_settings
from watchman.core.errors import ValidationError
from watchman.models.platform import AuditEvent, RunRecord
def _require_idempotency_key(idempotency_key: str | None) -> str:
if idempotency_key is None or not idempotency_key.strip():
raise ValidationError(
"x-idempotency-key is required",
details={"field": "x-idempotency-key"},
)
return idempotency_key.strip()[:128]
def _get_audit(session: Session, *, tenant_id: str, key: str) -> AuditEvent | None:
return session.scalar(
select(AuditEvent).where(
AuditEvent.tenant_id == tenant_id,
AuditEvent.idempotency_key == key,
)
)
def _get_run(session: Session, *, tenant_id: str, key: str) -> RunRecord | None:
return session.scalar(
select(RunRecord).where(
RunRecord.tenant_id == tenant_id,
RunRecord.idempotency_key == key,
)
)
def create_audit_event(
session: Session,
*,
action: str,
payload: dict[str, Any] | None,
idempotency_key: str | None,
) -> AuditEvent:
"""Insert or return an existing audit event for the server tenant."""
key = _require_idempotency_key(idempotency_key)
if not action or not action.strip():
raise ValidationError("action is required", details={"field": "action"})
tenant_id = get_settings().tenant_id
existing = _get_audit(session, tenant_id=tenant_id, key=key)
if existing is not None:
return existing
row = AuditEvent(
tenant_id=tenant_id,
action=action.strip(),
payload=payload or {},
idempotency_key=key,
)
try:
with session.begin_nested():
session.add(row)
session.flush()
return row
except IntegrityError:
existing = _get_audit(session, tenant_id=tenant_id, key=key)
if existing is None:
raise
return existing
def create_run_record(
session: Session,
*,
kind: str,
status: str,
detail: dict[str, Any] | None,
idempotency_key: str | None,
) -> RunRecord:
"""Insert or return an existing run record for the server tenant."""
key = _require_idempotency_key(idempotency_key)
if not kind or not kind.strip():
raise ValidationError("kind is required", details={"field": "kind"})
if not status or not status.strip():
raise ValidationError("status is required", details={"field": "status"})
tenant_id = get_settings().tenant_id
existing = _get_run(session, tenant_id=tenant_id, key=key)
if existing is not None:
return existing
row = RunRecord(
tenant_id=tenant_id,
kind=kind.strip(),
status=status.strip(),
detail=detail or {},
idempotency_key=key,
)
try:
with session.begin_nested():
session.add(row)
session.flush()
return row
except IntegrityError:
existing = _get_run(session, tenant_id=tenant_id, key=key)
if existing is None:
raise
return existing
@@ -0,0 +1,79 @@
"""Environment layering and required-key validation tests."""
from __future__ import annotations
from pathlib import Path
import pytest
from watchman.core.config import (
_settings_from_env_map,
ensure_runtime_config,
merge_layered_env,
missing_required_keys,
)
def _write_env(path: Path, content: str) -> None:
path.write_text(content.strip() + "\n", encoding="utf-8")
def test_local_overrides_dev_overrides_shared(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
_write_env(tmp_path / ".env.shared", "API_PORT=8000\nWATCHMAN_TENANT_ID=shared-tenant")
_write_env(tmp_path / ".env.dev", "API_PORT=8001\nWATCHMAN_TENANT_ID=dev-tenant")
_write_env(tmp_path / ".env.local", "API_PORT=8002\nWATCHMAN_TENANT_ID=local-tenant")
monkeypatch.delenv("API_PORT", raising=False)
monkeypatch.delenv("WATCHMAN_TENANT_ID", raising=False)
env = merge_layered_env(tmp_path)
assert env["API_PORT"] == "8002"
assert env["WATCHMAN_TENANT_ID"] == "local-tenant"
settings = _settings_from_env_map(env)
assert settings.api_port == 8002
assert settings.tenant_id == "local-tenant"
def test_process_env_wins_over_files(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
_write_env(tmp_path / ".env.shared", "API_PORT=8000")
_write_env(tmp_path / ".env.local", "API_PORT=8002")
monkeypatch.setenv("API_PORT", "9000")
env = merge_layered_env(tmp_path)
assert env["API_PORT"] == "9000"
def test_missing_required_keys_detects_placeholders(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
_write_env(
tmp_path / ".env.local",
"\n".join(
[
"DATABASE_URL=postgresql+psycopg://watchman_app:CHANGE-ME@127.0.0.1:5432/watchman",
"DATABASE_MIGRATOR_URL=",
"WATCHMAN_TENANT_ID=dev-tenant",
]
),
)
for key in ("DATABASE_URL", "DATABASE_MIGRATOR_URL", "WATCHMAN_TENANT_ID"):
monkeypatch.delenv(key, raising=False)
missing = missing_required_keys(root=tmp_path)
assert "DATABASE_URL" in missing
assert "DATABASE_MIGRATOR_URL" in missing
assert "WATCHMAN_TENANT_ID" not in missing
def test_ensure_runtime_config_exits_with_key_names(
tmp_path: Path,
monkeypatch: pytest.MonkeyPatch,
) -> None:
_write_env(tmp_path / ".env.local", "WATCHMAN_TENANT_ID=dev-tenant")
for key in ("DATABASE_URL", "DATABASE_MIGRATOR_URL", "WATCHMAN_TENANT_ID"):
monkeypatch.delenv(key, raising=False)
with pytest.raises(SystemExit, match="missing required env keys") as exc:
ensure_runtime_config(root=tmp_path)
message = str(exc.value)
assert "DATABASE_URL" in message
assert "DATABASE_MIGRATOR_URL" in message
assert "CHANGE-ME" not in message
assert "password" not in message.lower()
+103
View File
@@ -0,0 +1,103 @@
"""Envelope and health-check acceptance tests."""
from __future__ import annotations
from fastapi.testclient import TestClient
from watchman.api.app import create_app
from watchman.core.config import reload_settings
from watchman.core.db import reset_engine
def test_health_success_envelope() -> None:
client = TestClient(create_app())
response = client.get("/health", headers={"X-Request-Id": "req-health-1"})
assert response.status_code == 200
body = response.json()
assert body["success"] is True
assert body["request_id"] == "req-health-1"
assert response.headers["X-Request-Id"] == "req-health-1"
assert body["data"]["status"] == "ok"
assert "database" not in body["data"]
assert "tenant" not in str(body).lower()
assert "password" not in str(body).lower()
def test_validation_error_envelope() -> None:
client = TestClient(create_app())
response = client.get("/_probe/validation-error")
assert response.status_code == 400
body = response.json()
assert body["success"] is False
assert body["error"]["code"] == 40000
assert "traceback" not in str(body).lower()
assert response.headers["X-Request-Id"]
def test_unhandled_error_envelope_hides_stack_and_keeps_request_id() -> None:
client = TestClient(create_app(), raise_server_exceptions=False)
response = client.get("/_probe/boom", headers={"X-Request-Id": "req-boom-1"})
assert response.status_code == 500
body = response.json()
assert body["success"] is False
assert body["error"]["code"] == 50000
assert body["request_id"] == "req-boom-1"
assert response.headers["X-Request-Id"] == "req-boom-1"
assert body["error"]["message"] == "Internal server error"
assert "traceback" not in str(body).lower()
assert "runtimeerror" not in str(body).lower()
def test_probe_and_docs_hidden_outside_non_production(monkeypatch) -> None: # type: ignore[no-untyped-def]
monkeypatch.setenv("ENV_NAME", "prod")
reload_settings()
reset_engine()
client = TestClient(create_app(validate_runtime=False))
assert client.get("/_probe/boom").status_code == 404
assert client.get("/docs").status_code == 404
assert client.get("/openapi.json").status_code == 404
monkeypatch.setenv("ENV_NAME", "dev")
reload_settings()
reset_engine()
def test_health_envelope_has_no_timestamp() -> None:
client = TestClient(create_app())
body = client.get("/health").json()
assert "timestamp" not in body
def test_app_error_codes_envelope_shape() -> None:
from watchman.core.errors import ForbiddenError, ServiceUnavailableError, UnauthorizedError
app = create_app(validate_runtime=False)
@app.get("/_probe/unauthorized")
async def probe_unauthorized() -> None:
raise UnauthorizedError()
@app.get("/_probe/forbidden")
async def probe_forbidden() -> None:
raise ForbiddenError(permission_node="perm:platform:audit.read")
@app.get("/_probe/unavailable")
async def probe_unavailable() -> None:
raise ServiceUnavailableError()
client = TestClient(app, raise_server_exceptions=False)
unauthorized = client.get("/_probe/unauthorized").json()
assert unauthorized["success"] is False
assert unauthorized["error"]["code"] == 41000
assert "permission_node" not in unauthorized["error"]
assert "timestamp" not in unauthorized
forbidden = client.get("/_probe/forbidden").json()
assert forbidden["error"]["code"] == 42000
assert forbidden["error"]["permission_node"] == "perm:platform:audit.read"
unavailable = client.get("/_probe/unavailable")
assert unavailable.status_code == 503
body = unavailable.json()
assert body["error"]["code"] == 50000
assert body["error"]["retryable"] is True
+172
View File
@@ -0,0 +1,172 @@
"""Idempotent platform write tests."""
from __future__ import annotations
import uuid
from concurrent.futures import ThreadPoolExecutor
from fastapi.testclient import TestClient
from sqlalchemy import create_engine, text
from watchman.api.app import create_app
from watchman.core.config import get_settings, reload_settings
from sqlalchemy.orm import Session
from watchman.core.db import get_session_factory, reset_engine, set_tenant
from watchman.models.platform import AuditEvent
from watchman.services import platform_records
from sqlalchemy import select
def _count_for_key(table: str, key: str) -> int:
settings = get_settings()
engine = create_engine(settings.database_url, pool_pre_ping=True)
with engine.connect() as conn:
conn.execute(
text("SELECT set_config('app.tenant_id', :tenant, true)"),
{"tenant": settings.tenant_id},
)
value = conn.execute(
text(f"SELECT count(*) FROM {table} WHERE idempotency_key = :key"),
{"key": key},
).scalar_one()
engine.dispose()
return int(value)
def test_duplicate_idempotency_key_returns_same_audit() -> None:
reload_settings()
reset_engine()
client = TestClient(create_app())
key = f"idem-audit-{uuid.uuid4().hex}"
headers = {"x-idempotency-key": key, "X-Request-Id": "req-idem-1"}
body = {"action": "idem-test", "payload": {"n": 1}}
first = client.post("/platform/audit-events", json=body, headers=headers)
second = client.post("/platform/audit-events", json=body, headers=headers)
assert first.status_code == 200
assert second.status_code == 200
assert first.json()["data"]["id"] == second.json()["data"]["id"]
assert _count_for_key("audit_events", key) == 1
def test_duplicate_idempotency_key_returns_same_run_record() -> None:
reload_settings()
reset_engine()
client = TestClient(create_app())
key = f"idem-run-{uuid.uuid4().hex}"
headers = {"x-idempotency-key": key, "X-Request-Id": "req-idem-2"}
body = {"kind": "idem-test", "status": "ok", "detail": {"n": 1}}
first = client.post("/platform/run-records", json=body, headers=headers)
second = client.post("/platform/run-records", json=body, headers=headers)
assert first.status_code == 200
assert second.status_code == 200
assert first.json()["data"]["id"] == second.json()["data"]["id"]
assert _count_for_key("run_records", key) == 1
def test_missing_idempotency_key_is_40000() -> None:
reload_settings()
reset_engine()
client = TestClient(create_app())
response = client.post("/platform/audit-events", json={"action": "no-key", "payload": {}})
assert response.status_code == 400
assert response.json()["error"]["code"] == 40000
def test_concurrent_duplicate_audit_returns_same_id() -> None:
reload_settings()
reset_engine()
key = f"idem-race-{uuid.uuid4().hex}"
body = {"action": "race", "payload": {}}
def _post() -> str:
client = TestClient(create_app())
response = client.post(
"/platform/audit-events",
json=body,
headers={"x-idempotency-key": key},
)
assert response.status_code == 200, response.text
return response.json()["data"]["id"]
with ThreadPoolExecutor(max_workers=4) as pool:
ids = list(pool.map(lambda _: _post(), range(4)))
assert len(set(ids)) == 1
assert _count_for_key("audit_events", key) == 1
def test_caller_tenant_id_is_ignored() -> None:
reload_settings()
reset_engine()
settings = get_settings()
client = TestClient(create_app())
key = f"tenant-inject-{uuid.uuid4().hex}"
response = client.post(
"/platform/audit-events",
json={
"action": "inject",
"payload": {},
"tenant_id": "attacker-tenant",
},
headers={"x-idempotency-key": key},
)
assert response.status_code == 200
assert "attacker" not in response.text.lower()
reload_settings()
reset_engine()
factory = get_session_factory()
session: Session = factory()
try:
set_tenant(session, settings.tenant_id)
row = session.scalar(select(AuditEvent).where(AuditEvent.idempotency_key == key))
assert row is not None
assert row.tenant_id == settings.tenant_id
assert row.tenant_id != "attacker-tenant"
finally:
session.close()
def test_integrity_fallback_returns_seeded_row(monkeypatch) -> None: # type: ignore[no-untyped-def]
reload_settings()
reset_engine()
settings = get_settings()
key = f"integrity-{uuid.uuid4().hex}"
factory = get_session_factory()
seed = factory()
try:
set_tenant(seed, settings.tenant_id)
seeded = platform_records.create_audit_event(
seed,
action="seed",
payload={},
idempotency_key=key,
)
seed.commit()
seeded_id = seeded.id
finally:
seed.close()
session = factory()
try:
set_tenant(session, settings.tenant_id)
calls = {"n": 0}
real_get = platform_records._get_audit
def fake_get(*args, **kwargs): # type: ignore[no-untyped-def]
calls["n"] += 1
if calls["n"] == 1:
return None
return real_get(*args, **kwargs)
monkeypatch.setattr(platform_records, "_get_audit", fake_get)
row = platform_records.create_audit_event(
session,
action="seed",
payload={},
idempotency_key=key,
)
assert row.id == seeded_id
assert calls["n"] >= 2
finally:
session.close()
@@ -0,0 +1,28 @@
"""Celery probe task has no platform audit side effects."""
from __future__ import annotations
from sqlalchemy import create_engine, text
from watchman.core.config import get_settings, reload_settings
from watchman.jobs.celery_app import probe_ping
def test_probe_ping_is_side_effect_free() -> None:
reload_settings()
settings = get_settings()
engine = create_engine(settings.database_url, pool_pre_ping=True)
with engine.connect() as conn:
conn.execute(text("SELECT set_config('app.tenant_id', :tenant, true)"), {"tenant": settings.tenant_id})
before = conn.execute(text("SELECT count(*) FROM audit_events")).scalar_one()
result = probe_ping()
after = conn.execute(text("SELECT count(*) FROM audit_events")).scalar_one()
engine.dispose()
assert result == {"status": "pong"}
assert after == before
def test_probe_task_is_registered() -> None:
from watchman.jobs.celery_app import celery_app
assert "watchman.probe.ping" in celery_app.tasks
+225
View File
@@ -0,0 +1,225 @@
"""RLS positive and negative tests against local Postgres."""
from __future__ import annotations
import uuid
import pytest
from sqlalchemy import create_engine, text
from sqlalchemy.exc import DBAPIError
from sqlalchemy.orm import Session, sessionmaker
from watchman.core.config import get_settings, reload_settings
from watchman.core.db import reset_engine, set_tenant
from watchman.models.platform import AuditEvent, RunRecord
@pytest.fixture()
def app_session_factory():
reload_settings()
reset_engine()
# Ensure Session.after_begin tenant rebind is registered for this process.
from watchman.core.db import _ensure_after_begin_listener
_ensure_after_begin_listener()
settings = get_settings()
engine = create_engine(settings.database_url, pool_pre_ping=True)
factory = sessionmaker(bind=engine, autoflush=False, autocommit=False, expire_on_commit=False)
tracked_keys: list[str] = []
yield factory, tracked_keys, settings
cleanup = factory()
try:
if tracked_keys:
set_tenant(cleanup, settings.tenant_id)
cleanup.execute(
text("DELETE FROM audit_events WHERE idempotency_key = ANY(:keys)"),
{"keys": tracked_keys},
)
cleanup.execute(
text("DELETE FROM run_records WHERE idempotency_key = ANY(:keys)"),
{"keys": tracked_keys},
)
cleanup.commit()
finally:
cleanup.close()
engine.dispose()
reset_engine()
def test_app_role_is_constrained() -> None:
"""Application role must not be superuser, must not bypass RLS, must not own tables."""
reload_settings()
settings = get_settings()
engine = create_engine(settings.database_url, pool_pre_ping=True)
with engine.connect() as conn:
role = conn.execute(text("SELECT current_user")).scalar_one()
flags = conn.execute(
text(
"SELECT rolsuper, rolbypassrls FROM pg_roles WHERE rolname = current_user"
)
).one()
audit_owner = conn.execute(
text(
"SELECT tableowner FROM pg_tables "
"WHERE schemaname = 'public' AND tablename = 'audit_events'"
)
).scalar_one()
run_owner = conn.execute(
text(
"SELECT tableowner FROM pg_tables "
"WHERE schemaname = 'public' AND tablename = 'run_records'"
)
).scalar_one()
engine.dispose()
assert role == "watchman_app"
assert flags.rolsuper is False
assert flags.rolbypassrls is False
assert audit_owner != "watchman_app"
assert run_owner != "watchman_app"
def test_rls_requires_tenant_for_read(app_session_factory) -> None: # type: ignore[no-untyped-def]
factory, tracked_keys, settings = app_session_factory
setup_key = f"rls-setup-{uuid.uuid4().hex}"
tracked_keys.append(setup_key)
session: Session = factory()
try:
set_tenant(session, settings.tenant_id)
session.add(
AuditEvent(
tenant_id=settings.tenant_id,
action="rls-setup",
payload={},
idempotency_key=setup_key,
)
)
session.commit()
finally:
session.close()
bare: Session = factory()
try:
count = bare.execute(text("SELECT count(*) FROM audit_events")).scalar()
assert count == 0
finally:
bare.close()
def test_rls_blocks_write_without_tenant(app_session_factory) -> None: # type: ignore[no-untyped-def]
factory, _tracked_keys, settings = app_session_factory
bare: Session = factory()
try:
bare.add(
AuditEvent(
tenant_id=settings.tenant_id,
action="rls-write-denied",
payload={},
idempotency_key=f"rls-write-{uuid.uuid4().hex}",
)
)
with pytest.raises(DBAPIError):
bare.commit()
bare.rollback()
finally:
bare.close()
def test_rls_isolates_other_tenant_on_audit_and_runs(app_session_factory) -> None: # type: ignore[no-untyped-def]
factory, tracked_keys, settings = app_session_factory
audit_key = f"rls-iso-audit-{uuid.uuid4().hex}"
run_key = f"rls-iso-run-{uuid.uuid4().hex}"
tracked_keys.extend([audit_key, run_key])
session: Session = factory()
try:
set_tenant(session, settings.tenant_id)
session.add(
AuditEvent(
tenant_id=settings.tenant_id,
action="rls-iso",
payload={},
idempotency_key=audit_key,
)
)
session.add(
RunRecord(
tenant_id=settings.tenant_id,
kind="rls-iso",
status="ok",
detail={},
idempotency_key=run_key,
)
)
session.commit()
finally:
session.close()
other: Session = factory()
try:
set_tenant(other, "other-tenant")
audit_count = other.execute(
text("SELECT count(*) FROM audit_events WHERE idempotency_key = :k"),
{"k": audit_key},
).scalar()
run_count = other.execute(
text("SELECT count(*) FROM run_records WHERE idempotency_key = :k"),
{"k": run_key},
).scalar()
assert audit_count == 0
assert run_count == 0
finally:
other.close()
same: Session = factory()
try:
set_tenant(same, settings.tenant_id)
audit_count = same.execute(
text("SELECT count(*) FROM audit_events WHERE idempotency_key = :k"),
{"k": audit_key},
).scalar()
run_count = same.execute(
text("SELECT count(*) FROM run_records WHERE idempotency_key = :k"),
{"k": run_key},
).scalar()
assert audit_count == 1
assert run_count == 1
finally:
same.close()
def test_tenant_rebounds_after_commit(app_session_factory) -> None: # type: ignore[no-untyped-def]
"""after_begin must restore tenant RLS after an explicit commit()."""
factory, tracked_keys, settings = app_session_factory
first_key = f"rls-rebind-1-{uuid.uuid4().hex}"
second_key = f"rls-rebind-2-{uuid.uuid4().hex}"
tracked_keys.extend([first_key, second_key])
session: Session = factory()
try:
set_tenant(session, settings.tenant_id)
session.add(
AuditEvent(
tenant_id=settings.tenant_id,
action="rls-rebind-1",
payload={},
idempotency_key=first_key,
)
)
session.commit()
session.add(
AuditEvent(
tenant_id=settings.tenant_id,
action="rls-rebind-2",
payload={},
idempotency_key=second_key,
)
)
session.commit()
count = session.execute(
text(
"SELECT count(*) FROM audit_events "
"WHERE idempotency_key IN (:a, :b)"
),
{"a": first_key, "b": second_key},
).scalar()
assert count == 2
finally:
session.close()
Generated
+781
View File
@@ -0,0 +1,781 @@
version = 1
revision = 5
requires-python = "==3.12.*"
[manifest]
members = [
"watchman",
"watchman-workspace",
]
[[package]]
name = "alembic"
version = "1.20.1"
source = { registry = "https://mirrors.aliyun.com/pypi/simple" }
dependencies = [
{ name = "mako" },
{ name = "sqlalchemy" },
{ name = "typing-extensions" },
]
sdist = { url = "https://mirrors.aliyun.com/pypi/packages/93/1c/00909e0fbebad2121d916fdcab044cae988146680e9ee4387ba25fef8747/alembic-1.20.1.tar.gz", hash = "sha256:83490def1f723413db5096591f7609ac52544805be93849170088ed04f5a2e0b" }
wheels = [
{ url = "https://mirrors.aliyun.com/pypi/packages/11/3c/8740f5b4e1bd57333e4f84265b9b6363da4f7cf70f5622dd1e2fde7a0bd5/alembic-1.20.1-py3-none-any.whl", hash = "sha256:9970712cfb81ea26c8658d378aaa5b8f6ff9146e5bb111d70497c164016cf598" },
]
[[package]]
name = "amqp"
version = "5.4.2"
source = { registry = "https://mirrors.aliyun.com/pypi/simple" }
dependencies = [
{ name = "vine" },
]
sdist = { url = "https://mirrors.aliyun.com/pypi/packages/4b/46/64c69cdd9705a5b312920cf76c3cb7c2c4718ffeafbfbcf87a842890765e/amqp-5.4.2.tar.gz", hash = "sha256:9362660c4a31150cf18e78cae2ce8aa1e929fc6c6739e69f6dd5dbea9c3edc82" }
wheels = [
{ url = "https://mirrors.aliyun.com/pypi/packages/e1/1d/2da3a059d2736e2ad8104762f93ad2145b6b0586aaa6be5290bab5d96c68/amqp-5.4.2-py3-none-any.whl", hash = "sha256:e6e756b15c89c86818b48a4947a424706238afbf67d457428d3269bc4590db9e" },
]
[[package]]
name = "annotated-doc"
version = "0.0.6"
source = { registry = "https://mirrors.aliyun.com/pypi/simple" }
sdist = { url = "https://mirrors.aliyun.com/pypi/packages/0f/6e/a61e86e43bb6039b31a33a8f5fba76fe1cdacf3661e7b9756d4ff1b28cdc/annotated_doc-0.0.6.tar.gz", hash = "sha256:7969bb69912085b2285849c0dcac0b4b374fd180c13cf10a87f284ffcf347bbf" }
wheels = [
{ url = "https://mirrors.aliyun.com/pypi/packages/cd/f5/3dd85d583e55be76cd02b1fc9bbec771b12d63124b01661d9535ccf8721f/annotated_doc-0.0.6-py3-none-any.whl", hash = "sha256:361ca0950cc7082f53fa69e9328409f40a62c61e57e0a47e1825a08078a58a53" },
]
[[package]]
name = "annotated-types"
version = "0.8.0"
source = { registry = "https://mirrors.aliyun.com/pypi/simple" }
sdist = { url = "https://mirrors.aliyun.com/pypi/packages/5f/56/a8120250d128bed162cd73c76d45f6ef9991f3e068f62a8ee060afa3104a/annotated_types-0.8.0.tar.gz", hash = "sha256:13b2beaad985e05e2d6407ee4c4f35590b11f8d693a258a561055cac8f64cab7" }
wheels = [
{ url = "https://mirrors.aliyun.com/pypi/packages/99/91/8acff4f5e50511b911bbccb72b8628a49c68ce14148cd9f6431094859a90/annotated_types-0.8.0-py3-none-any.whl", hash = "sha256:f072f4d804ea359e4eaf198b1af7a8b0943881a87f31bb764f8bf219bb9419e0" },
]
[[package]]
name = "anyio"
version = "4.16.0"
source = { registry = "https://mirrors.aliyun.com/pypi/simple" }
dependencies = [
{ name = "idna" },
{ name = "typing-extensions" },
]
sdist = { url = "https://mirrors.aliyun.com/pypi/packages/a1/98/7e457a3b014976887a050561955c0b76e1e7e2d6e27b78ecef2ef80518f2/anyio-4.16.0.tar.gz", hash = "sha256:59bb03251907983d1603d27c3087ddb1e93299ea2163adcdba37899a4fb12ffb" }
wheels = [
{ url = "https://mirrors.aliyun.com/pypi/packages/a9/16/7757fb84c819accc7d7e9af5291b261e4abb8627ee040f99e7d35ef2457a/anyio-4.16.0-py3-none-any.whl", hash = "sha256:c66ae634e0b8228396b801741beb3294326d4b6102f7bba4041c0dfb58c29026" },
]
[[package]]
name = "billiard"
version = "4.3.2"
source = { registry = "https://mirrors.aliyun.com/pypi/simple" }
sdist = { url = "https://mirrors.aliyun.com/pypi/packages/96/ba/4ee8c6d14b3e9b5ce89b5b070f1352e6cadefde3f6bc36afcfee5e7158a2/billiard-4.3.2.tar.gz", hash = "sha256:9eb83c99b1cf7acb1fed86c1dfd477157000a1a2c0108005c1e5837b55d2acba" }
wheels = [
{ url = "https://mirrors.aliyun.com/pypi/packages/21/05/3d445479b3f7e4ae0901cdf2c45f561b436d1a5b8ed1c5c97e260152ae50/billiard-4.3.2-py3-none-any.whl", hash = "sha256:37735a7b4117aafa73532b3b493db4c02fb85c0e69d5f3447f113fd30ff27872" },
]
[[package]]
name = "celery"
version = "5.7.0"
source = { registry = "https://mirrors.aliyun.com/pypi/simple" }
dependencies = [
{ name = "billiard" },
{ name = "click" },
{ name = "click-didyoumean" },
{ name = "click-plugins" },
{ name = "click-repl" },
{ name = "kombu" },
{ name = "python-dateutil" },
{ name = "tzlocal" },
{ name = "vine" },
]
sdist = { url = "https://mirrors.aliyun.com/pypi/packages/ef/f7/166bfd22cbd0dd4f77715ddd207881c1332cd1f304d79b1a123aff7cdf10/celery-5.7.0.tar.gz", hash = "sha256:6a5dfcf6662287204f009a02002b9e66c83d4105e47ebabdc7079108772fc6f0" }
wheels = [
{ url = "https://mirrors.aliyun.com/pypi/packages/e9/cf/cd7fcb9d8f5a21fa420ddf19ee96969e36820182275a731abdf4260ed86a/celery-5.7.0-py3-none-any.whl", hash = "sha256:18310a9c919f9029e4735367484d93e6a25cdfd30afdc474622cc263d9b35f6e" },
]
[[package]]
name = "certifi"
version = "2026.10.23"
source = { registry = "https://mirrors.aliyun.com/pypi/simple" }
sdist = { url = "https://mirrors.aliyun.com/pypi/packages/fd/11/b524cbd9bbdaca58608e4cf4053fd463417549e1959fa8d3aa18319f9555/certifi-2026.10.23.tar.gz", hash = "sha256:a9895e6e2758b371e0545e321a3a8fd1fcfd9829ada8824a936dfb16aaaf36cd" }
wheels = [
{ url = "https://mirrors.aliyun.com/pypi/packages/32/d1/a3652fe2c19134d0d15922177821d863cbd7e842d53a21bbe7e8e3a1b5ac/certifi-2026.10.23-py3-none-any.whl", hash = "sha256:e9b54de76e530bb6cf0ccd036787103acb58fd42ba930ea8bf948ddbaa2f61d1" },
]
[[package]]
name = "click"
version = "8.5.1"
source = { registry = "https://mirrors.aliyun.com/pypi/simple" }
sdist = { url = "https://mirrors.aliyun.com/pypi/packages/45/37/edbf1b0707709013c0cf2e8317e03d97ed29bf4cac709fe328904ae92a38/click-8.5.1.tar.gz", hash = "sha256:9bbfada76703fd1d784b83eea012e3e8c6a001a876543ef104fa56aaaeb072b4" }
wheels = [
{ url = "https://mirrors.aliyun.com/pypi/packages/31/7d/164b7ffc8624fe9efb4221bf9af485d5c1e41b9ae118045d2b6dc5457d8b/click-8.5.1-py3-none-any.whl", hash = "sha256:8bb5376d2006950386f8c6427613334a2acadc5f559cb80e638d00b4df957e37" },
]
[[package]]
name = "click-didyoumean"
version = "0.3.1"
source = { registry = "https://mirrors.aliyun.com/pypi/simple" }
dependencies = [
{ name = "click" },
]
sdist = { url = "https://mirrors.aliyun.com/pypi/packages/30/ce/217289b77c590ea1e7c24242d9ddd6e249e52c795ff10fac2c50062c48cb/click_didyoumean-0.3.1.tar.gz", hash = "sha256:4f82fdff0dbe64ef8ab2279bd6aa3f6a99c3b28c05aa09cbfc07c9d7fbb5a463" }
wheels = [
{ url = "https://mirrors.aliyun.com/pypi/packages/1b/5b/974430b5ffdb7a4f1941d13d83c64a0395114503cc357c6b9ae4ce5047ed/click_didyoumean-0.3.1-py3-none-any.whl", hash = "sha256:5c4bb6007cfea5f2fd6583a2fb6701a22a41eb98957e63d0fac41c10e7c3117c" },
]
[[package]]
name = "click-plugins"
version = "1.1.1.2"
source = { registry = "https://mirrors.aliyun.com/pypi/simple" }
dependencies = [
{ name = "click" },
]
sdist = { url = "https://mirrors.aliyun.com/pypi/packages/c3/a4/34847b59150da33690a36da3681d6bbc2ec14ee9a846bc30a6746e5984e4/click_plugins-1.1.1.2.tar.gz", hash = "sha256:d7af3984a99d243c131aa1a828331e7630f4a88a9741fd05c927b204bcf92261" }
wheels = [
{ url = "https://mirrors.aliyun.com/pypi/packages/3d/9a/2abecb28ae875e39c8cad711eb1186d8d14eab564705325e77e4e6ab9ae5/click_plugins-1.1.1.2-py2.py3-none-any.whl", hash = "sha256:008d65743833ffc1f5417bf0e78e8d2c23aab04d9745ba817bd3e71b0feb6aa6" },
]
[[package]]
name = "click-repl"
version = "0.4.1"
source = { registry = "https://mirrors.aliyun.com/pypi/simple" }
dependencies = [
{ name = "click" },
{ name = "prompt-toolkit" },
{ name = "typing-extensions" },
]
sdist = { url = "https://mirrors.aliyun.com/pypi/packages/28/50/bea78619ff1fc0fbd61882f64a1302a8abb2ea0b3db92907042d0e362df2/click_repl-0.4.1.tar.gz", hash = "sha256:c32a1cf6f95e5bd6e92076f81ce24eafd33f2f0ffb0135887e335b8e446d1c0b" }
wheels = [
{ url = "https://mirrors.aliyun.com/pypi/packages/a4/f6/12dc0f2e0159c2b416818b7fedcda15b520043773364a81d7389809a5af5/click_repl-0.4.1-py3-none-any.whl", hash = "sha256:5cb10881d4c5ebaa8695eceb69911af3062ee78342812b713564b17aad333eb5" },
]
[[package]]
name = "colorama"
version = "0.4.6"
source = { registry = "https://mirrors.aliyun.com/pypi/simple" }
sdist = { url = "https://mirrors.aliyun.com/pypi/packages/d8/53/6f443c9a4a8358a93a6792e2acffb9d9d5cb0a5cfd8802644b7b1c9a02e4/colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44" }
wheels = [
{ url = "https://mirrors.aliyun.com/pypi/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6" },
]
[[package]]
name = "fastapi"
version = "0.163.1"
source = { registry = "https://mirrors.aliyun.com/pypi/simple" }
dependencies = [
{ name = "annotated-doc" },
{ name = "anyio" },
{ name = "opentelemetry-api" },
{ name = "pydantic" },
{ name = "starlette" },
{ name = "typing-extensions" },
{ name = "typing-inspection" },
]
sdist = { url = "https://mirrors.aliyun.com/pypi/packages/a4/62/19000d0f3699cacaeffe8a3c4cc7046d87aac3291163ffeb2ef08b82d859/fastapi-0.163.1.tar.gz", hash = "sha256:3d364b02a68b67292e833ff2dfed3b8dc3aeadf73e271c15316c6c166668792f" }
wheels = [
{ url = "https://mirrors.aliyun.com/pypi/packages/20/b6/2424da1e40825d3fc54539621811f34e21472499677c9490e4967270e38e/fastapi-0.163.1-py3-none-any.whl", hash = "sha256:68f2d8050f5c3583121c0d203046cc7def5c16a7d6c43a0e7707a8ea610fe2d3" },
]
[[package]]
name = "greenlet"
version = "3.5.6"
source = { registry = "https://mirrors.aliyun.com/pypi/simple" }
sdist = { url = "https://mirrors.aliyun.com/pypi/packages/3e/6e/0091f175ccd02b02bc8811bbcbcc6ac2e980be116e3b2f7a736ca322bf84/greenlet-3.5.6.tar.gz", hash = "sha256:8e67c43bdfc88d5fee6db0d3e40175b362fc95fb85f0412d233b9b203c53a575" }
wheels = [
{ url = "https://mirrors.aliyun.com/pypi/packages/72/18/3fc6d951466ae9a2a688edcddde3b2e388da0a8244e0caf7117bbeb0eb95/greenlet-3.5.6-cp312-cp312-macosx_11_0_universal2.whl", hash = "sha256:a5876d0a60355af98d535c47f6cd6eb0f8a432396dab26845d380b92f8412422" },
{ url = "https://mirrors.aliyun.com/pypi/packages/27/89/366d2af5061eeefa5012f510d95a99c8620dcc457609838db4d538820318/greenlet-3.5.6-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:e85880b538e59a59f55117b81f208a6660ad5ac328aad9305f812d9b8bc67a0f" },
{ url = "https://mirrors.aliyun.com/pypi/packages/54/1c/07f133f865fd58ae593dd2bbec3144acaee9b04ffe2eb48c6e121747ceef/greenlet-3.5.6-cp312-cp312-manylinux_2_24_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:f0ba7c2a329d650628f4c8572fd1db29f0a59dd70a3e3e0710dcf18a35cce9d8" },
{ url = "https://mirrors.aliyun.com/pypi/packages/66/6a/1594f3869c57c149abdb380492529e04d4c0229b5e4d79572c5bd0aaa673/greenlet-3.5.6-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:975736b002ed080d124cf81a79cb7e05cb26d6b3f5c7a7b651c0fcce70353aa1" },
{ url = "https://mirrors.aliyun.com/pypi/packages/a2/f5/33e5c9e48178b9259fd000f8f45caa4a65036f65d3d0c06a602f570f025d/greenlet-3.5.6-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:0616b8f878098c5681fd8f0dc92d887551717402342a70f0abcbfea5f5ad8a44" },
{ url = "https://mirrors.aliyun.com/pypi/packages/ef/31/9b4e140bc24d0ad7927ebd651f5608b0acc2334d061748c3b6ad19085cfa/greenlet-3.5.6-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:3dbb4596a6a4e5d47121a33ff20533a81e60f302d9e67b69909a8bc21a43f0a7" },
{ url = "https://mirrors.aliyun.com/pypi/packages/c3/71/d79f1791f824f8ff15c2978746640467ae932a2365e0201069f7f272395f/greenlet-3.5.6-cp312-cp312-win_amd64.whl", hash = "sha256:7ac4abb3877c43af320392c664774eef6fa2cc063c79a55fc02d844a3cbe7395" },
{ url = "https://mirrors.aliyun.com/pypi/packages/63/af/42aca4d56e8cb321912203069d8d34734cb288222f10ad2ae102718cc577/greenlet-3.5.6-cp312-cp312-win_arm64.whl", hash = "sha256:301102a49120b095e72a7838792b41233975fc1c155daec6d98f81c00c9280e0" },
]
[[package]]
name = "h11"
version = "0.16.0"
source = { registry = "https://mirrors.aliyun.com/pypi/simple" }
sdist = { url = "https://mirrors.aliyun.com/pypi/packages/01/ee/02a2c011bdab74c6fb3c75474d40b3052059d95df7e73351460c8588d963/h11-0.16.0.tar.gz", hash = "sha256:4e35b956cf45792e4caa5885e69fba00bdbc6ffafbfa020300e549b208ee5ff1" }
wheels = [
{ url = "https://mirrors.aliyun.com/pypi/packages/04/4b/29cac41a4d98d144bf5f6d33995617b185d14b22401f75ca86f384e87ff1/h11-0.16.0-py3-none-any.whl", hash = "sha256:63cf8bbe7522de3bf65932fda1d9c2772064ffb3dae62d55932da54b31cb6c86" },
]
[[package]]
name = "httpcore"
version = "1.0.9"
source = { registry = "https://mirrors.aliyun.com/pypi/simple" }
dependencies = [
{ name = "certifi" },
{ name = "h11" },
]
sdist = { url = "https://mirrors.aliyun.com/pypi/packages/06/94/82699a10bca87a5556c9c59b5963f2d039dbd239f25bc2a63907a05a14cb/httpcore-1.0.9.tar.gz", hash = "sha256:6e34463af53fd2ab5d807f399a9b45ea31c3dfa2276f15a2c3f00afff6e176e8" }
wheels = [
{ url = "https://mirrors.aliyun.com/pypi/packages/7e/f5/f66802a942d491edb555dd61e3a9961140fd64c90bce1eafd741609d334d/httpcore-1.0.9-py3-none-any.whl", hash = "sha256:2d400746a40668fc9dec9810239072b40b4484b640a8c38fd654a024c7a1bf55" },
]
[[package]]
name = "httptools"
version = "0.9.0"
source = { registry = "https://mirrors.aliyun.com/pypi/simple" }
sdist = { url = "https://mirrors.aliyun.com/pypi/packages/3a/ec/deed52912ab7ca6c0b12859330c571c60c61d7267b341b28951fcbf13694/httptools-0.9.0.tar.gz", hash = "sha256:d484ebb7e3a3f3597b0f645fbd1b85633674ca808c1f5ba11c2caf7c66f5c8b6" }
wheels = [
{ url = "https://mirrors.aliyun.com/pypi/packages/da/ed/0916b8b7ebd1deeaf22acba71b68c57b4b6b69aa1918f3812dea208b4276/httptools-0.9.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:f9ccc9884241efceb4547a92955d128574c864681f11b7ea3ecbde295fafbe8b" },
{ url = "https://mirrors.aliyun.com/pypi/packages/c2/0b/9b6de4a01a563a904d0826c9069c824b330e1816df26c9bdf93f60b50857/httptools-0.9.0-cp312-cp312-macosx_11_0_x86_64.whl", hash = "sha256:45b3002392948dcf578029c89f6318e1289a993a1a5ec38a4161560fab60f811" },
{ url = "https://mirrors.aliyun.com/pypi/packages/85/3f/642113e9882f53158ecddf58003d25f18ded2c210ed23bf6eb663d4d51c3/httptools-0.9.0-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:3e3201fe4d46e0d15d7ff9fafc94a605da9eb82d2c5b9837f0368acb325481f1" },
{ url = "https://mirrors.aliyun.com/pypi/packages/95/4c/3ecc59c99c28652d8d08d9b5be65770a14d2cadc616dad94224cee2b0e7e/httptools-0.9.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:58a1b0ec4cbb930e69669f9771715b2c7898d3cdf064d9811f7a66afef96b544" },
{ url = "https://mirrors.aliyun.com/pypi/packages/43/ce/21f5b2759590b7054e38d3b704a3c6b853c3395c370b3d6f16c45aea0fc0/httptools-0.9.0-cp312-cp312-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:4c58dc91aefb31adad500aa68054334f429b840b36dd29e34e834101044cb2ef" },
{ url = "https://mirrors.aliyun.com/pypi/packages/52/c3/7c523aa8d0fa7a57010a3e1bbdebc209585009076465f3d1ae6a3f54b814/httptools-0.9.0-cp312-cp312-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:6b900073e7b8481ef1aaf4f6c1789d210a1db01a9da8789821578cfeb4c2d540" },
{ url = "https://mirrors.aliyun.com/pypi/packages/94/e2/d90d60002692b8afcbc06fb49ca3a4365b32abed6c40fb2b612c67721a00/httptools-0.9.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:6c12d0393a903b58bc5f5a7406d6c5290acfb8284290d68547ce620c06f7d133" },
{ url = "https://mirrors.aliyun.com/pypi/packages/46/c0/19172874cde0344a20c85877a0b2d0dcfca31111729ad8a79e8b4ac4e207/httptools-0.9.0-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:29b0d823e3c1e7cd1093a5dc889245db693ef13ada624cd66e2262421ef38867" },
{ url = "https://mirrors.aliyun.com/pypi/packages/1b/b8/02ea7910f69e5371986b025fb3b410592106df54e977a5732fd1d95917b5/httptools-0.9.0-cp312-cp312-musllinux_1_2_riscv64.whl", hash = "sha256:6ebd39ee26db460cfe5ab8b71a15d1149b289139a0d3981522757d6af620887e" },
{ url = "https://mirrors.aliyun.com/pypi/packages/de/97/f05eac916d44cbbfe43668a6a40ab93e7fd8f94d5120d1ce2d8e55c69871/httptools-0.9.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:4efbee349138a3fee7a4cc3a95abd2d499fae70dd5bff9fed9138d6f570f4283" },
{ url = "https://mirrors.aliyun.com/pypi/packages/b6/e9/9435dfcb7f1a1d6ebdc79a902164dfca70e33774c80bb60d25c630c31ef1/httptools-0.9.0-cp312-cp312-win32.whl", hash = "sha256:36fac804b8cfd6b935ae64f71349f833d2b6298404626d017a2c57bb942bc643" },
{ url = "https://mirrors.aliyun.com/pypi/packages/8b/69/813f1bf90be507d4166c437be1a413574d0e0abf36e2fec10c266661b0ee/httptools-0.9.0-cp312-cp312-win_amd64.whl", hash = "sha256:7e32b83bd8c2f8b6fa726ef34e63e21c4d7eddc277d40d4ef7245ea3ed28e5b6" },
{ url = "https://mirrors.aliyun.com/pypi/packages/ae/e0/1d29e328c4cafe843403341e1455e0aec18b0e6910fbb14f12b36b563f19/httptools-0.9.0-cp312-cp312-win_arm64.whl", hash = "sha256:813a32f94991b9627795528053c73a57d2ce3eb98ede89f0e1c7a31095938e81" },
]
[[package]]
name = "httpx"
version = "0.28.1"
source = { registry = "https://mirrors.aliyun.com/pypi/simple" }
dependencies = [
{ name = "anyio" },
{ name = "certifi" },
{ name = "httpcore" },
{ name = "idna" },
]
sdist = { url = "https://mirrors.aliyun.com/pypi/packages/b1/df/48c586a5fe32a0f01324ee087459e112ebb7224f646c0b5023f5e79e9956/httpx-0.28.1.tar.gz", hash = "sha256:75e98c5f16b0f35b567856f597f06ff2270a374470a5c2392242528e3e3e42fc" }
wheels = [
{ url = "https://mirrors.aliyun.com/pypi/packages/2a/39/e50c7c3a983047577ee07d2a9e53faf5a69493943ec3f6a384bdc792deb2/httpx-0.28.1-py3-none-any.whl", hash = "sha256:d909fcccc110f8c7faf814ca82a9a4d816bc5a6dbfea25d6591d6985b8ba59ad" },
]
[[package]]
name = "idna"
version = "3.20"
source = { registry = "https://mirrors.aliyun.com/pypi/simple" }
sdist = { url = "https://mirrors.aliyun.com/pypi/packages/f5/08/8eea9d4b8302028f3abb2c0813953f7aec26d33b7a8960ed760e65ff29fa/idna-3.20.tar.gz", hash = "sha256:a7db850025b95ded1eae8a46181a1a6c56c92c96f0e2b005d9ff8dc0210cab44" }
wheels = [
{ url = "https://mirrors.aliyun.com/pypi/packages/58/a2/bb081bab032533a855d44de1d56f8e8426114ff1ba5d1f07a438a0a654f8/idna-3.20-py3-none-any.whl", hash = "sha256:ab7ae7122974553370f0bdb919e1a960b2cd1bc1ef0276416d896db81c14582c" },
]
[[package]]
name = "iniconfig"
version = "2.3.1"
source = { registry = "https://mirrors.aliyun.com/pypi/simple" }
sdist = { url = "https://mirrors.aliyun.com/pypi/packages/01/e1/2069291243c926a2ff1cd706c7f3eeb9b62144bf60f77c9fb9ff2fb26bd3/iniconfig-2.3.1.tar.gz", hash = "sha256:67f4b9c50da0dedf52af349e7749a80a9057a5031199791b906c3bb3ae878960" }
wheels = [
{ url = "https://mirrors.aliyun.com/pypi/packages/56/43/4ca9e49d27a1fcf6bece6f6aec0ea46bb9112489b93d4b688fb415457bdb/iniconfig-2.3.1-py3-none-any.whl", hash = "sha256:9121e2c1fdb355232495be3194c8dfe87ccc2d5dee45947b78e68f499790d7a7" },
]
[[package]]
name = "kombu"
version = "5.7.0"
source = { registry = "https://mirrors.aliyun.com/pypi/simple" }
dependencies = [
{ name = "amqp" },
{ name = "tzdata", marker = "sys_platform == 'win32'" },
{ name = "vine" },
]
sdist = { url = "https://mirrors.aliyun.com/pypi/packages/57/31/3e632ebce43c684dcc6eead4660b33307e6153be87e33c14e1ed9875deff/kombu-5.7.0.tar.gz", hash = "sha256:31e62fdfd2381caa3422f8e02b84a491d9a2180ddda74507b57f4cb1e1c2c2c9" }
wheels = [
{ url = "https://mirrors.aliyun.com/pypi/packages/84/20/f73d8e0bff9708b0f2337220be1b5d7ebd738bc3a89b63cf44d257157014/kombu-5.7.0-py3-none-any.whl", hash = "sha256:dede73bff4c89175be382c4203d2f167cf7017c384396ec75c36a1b5678f1587" },
]
[[package]]
name = "mako"
version = "1.4.3"
source = { registry = "https://mirrors.aliyun.com/pypi/simple" }
dependencies = [
{ name = "markupsafe" },
]
sdist = { url = "https://mirrors.aliyun.com/pypi/packages/5a/09/e07c4b5579a79f4b16f8d4f29f6c54514ac787c4ad506b8c4f28a0e6b0bf/mako-1.4.3.tar.gz", hash = "sha256:cd6537fe88d5fec315c55c2f8529bc4ce7a9a352ad7db3eeaa6a66e2dd4ec37a" }
wheels = [
{ url = "https://mirrors.aliyun.com/pypi/packages/6d/a0/053d6af3e8f871e0073b4a36732d9e65be77a72e5434c31b94f6af78a6bb/mako-1.4.3-py3-none-any.whl", hash = "sha256:723296007c870bfd6b3f0c3230dba7198096e5269297ebf5e4eff9e7ffa39d4f" },
]
[[package]]
name = "markupsafe"
version = "3.0.4"
source = { registry = "https://mirrors.aliyun.com/pypi/simple" }
sdist = { url = "https://mirrors.aliyun.com/pypi/packages/38/9b/e422a865e1d5d57d0e509b4e0bf1c1a70a7f6382c29a5aa428df994c8bc8/markupsafe-3.0.4.tar.gz", hash = "sha256:2e9ad7dd851bf45fab9f75cbff4cb493fee9979e8d8c7c9c3ee119022518edd6" }
wheels = [
{ url = "https://mirrors.aliyun.com/pypi/packages/81/09/4c59d56b8461ae8eb0d8ba34bb25b7e618547044679d58a82ef9b2479fc1/markupsafe-3.0.4-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:61631e08084be9e21a8967ec3139c7616ed7c5e9368e05c86d1b39562c8a57b6" },
{ url = "https://mirrors.aliyun.com/pypi/packages/a2/f0/d6613774d86fbf6d145751d43c59875e47a6f9f17daee0aef173bd36d90e/markupsafe-3.0.4-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:0930db9bdc62d22944e10b066448bb65dc9abe9112880c7cab8da54db4284d5f" },
{ url = "https://mirrors.aliyun.com/pypi/packages/0d/f2/8f18e0b806eb13c1f8d07d917a720831ead54253a6dec011fbc78098a6f8/markupsafe-3.0.4-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:6a45c3d514f2436064db00d7fc8778d888f0236ebfed649b53d13a59e69ad51b" },
{ url = "https://mirrors.aliyun.com/pypi/packages/60/ce/fa07dbe8a5675558fa36dea033e19995bc783de2dec5f540ccb9030b06aa/markupsafe-3.0.4-cp312-cp312-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:1e1451fab512d1bcc3dc26988ec1edb0b82c2db909132872cd9356070a6b63df" },
{ url = "https://mirrors.aliyun.com/pypi/packages/85/40/be87c01f3868ec217f8a2015089d71c22c8c5a75324822e5ed1cdd87210d/markupsafe-3.0.4-cp312-cp312-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:bd3ce56ae2cbae3ba82b683bc425cd7e48d2ed8b10f3e818186b6f5646d9271c" },
{ url = "https://mirrors.aliyun.com/pypi/packages/4f/a7/aeedb5140afa41fc74c225e9184ab96723a6e873b6ee1c9fede7283456d8/markupsafe-3.0.4-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:8e124f974786f831d6043728e38296969d3579db8896fe004682f5758e613581" },
{ url = "https://mirrors.aliyun.com/pypi/packages/c3/fc/e91352bb08c6a59da3ef0909d457bf95a5f5908fbf151b30a06d9dbcfbb4/markupsafe-3.0.4-cp312-cp312-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:c02e8f18bdedba082cef725942ac823b9b60656db07f7e265cb31618dfd00d77" },
{ url = "https://mirrors.aliyun.com/pypi/packages/5d/f8/bffee5e7d2a3deb59748a797650a48af7e672025cf641a79344a771ad106/markupsafe-3.0.4-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:9f098115c247e11d138ab83a28fa0323c77015007ea2df73ba5fd714dfefd67c" },
{ url = "https://mirrors.aliyun.com/pypi/packages/ed/59/b853d6628ecb4d658e1d637224846d5e9bb4adf4f8df97f3be9f29dce2ec/markupsafe-3.0.4-cp312-cp312-musllinux_1_2_armv7l.whl", hash = "sha256:d5f93ebbeb8032d47e349328ec8662d973d9b05a70b3c35df1f91fe419b84749" },
{ url = "https://mirrors.aliyun.com/pypi/packages/09/b2/1506df394f0f075797c418d0301498f49e43be194e3ffcb49e6fe6ccf022/markupsafe-3.0.4-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:64511c54db4e4987aef4c41923235927428729e8174c5dba488429be70a998ed" },
{ url = "https://mirrors.aliyun.com/pypi/packages/c7/81/5ed69cda630ac69ef60d06c09ba5a7f84ff66a2e28cf986fd5614ab3c6e6/markupsafe-3.0.4-cp312-cp312-musllinux_1_2_riscv64.whl", hash = "sha256:e1a622f13970d81f95d0c72f9dc090dce9085fccfa4c9f2174377ee32bd15786" },
{ url = "https://mirrors.aliyun.com/pypi/packages/0c/fe/fb1e79be0fea60aa32602ebefc9c35a82bb42b4df157285ab7dfec12341a/markupsafe-3.0.4-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:c9a7f43c0b202b334cc9184af09bb8f21d3a209e038efaf106936fb69e6b026e" },
{ url = "https://mirrors.aliyun.com/pypi/packages/c8/52/7632a53360671a9b750cdbabaf9cdd89f18b42248b8e4cb42c0b0296e459/markupsafe-3.0.4-cp312-cp312-win32.whl", hash = "sha256:f0ec3b750b59375eab5b0fb2b9254810c00a3375be6d789899f1055a1d556237" },
{ url = "https://mirrors.aliyun.com/pypi/packages/3f/bf/62495e180b7000aaf30000fff849e933f74264638057176cf46852500adc/markupsafe-3.0.4-cp312-cp312-win_amd64.whl", hash = "sha256:11935df9bf455ed0c04eb87bcd720f02b1fe5e02128a9430f23aed6f93336fc7" },
{ url = "https://mirrors.aliyun.com/pypi/packages/c5/8e/4c24208776a65878d656996945aacfbfe010d3720d1a98fc0eb8491fc03b/markupsafe-3.0.4-cp312-cp312-win_arm64.whl", hash = "sha256:a4bbd2d87dd233b9fc5812160c3d0ffbe42edc22a26ce0469f58479ede633fe9" },
]
[[package]]
name = "opentelemetry-api"
version = "1.45.2"
source = { registry = "https://mirrors.aliyun.com/pypi/simple" }
dependencies = [
{ name = "typing-extensions" },
]
sdist = { url = "https://mirrors.aliyun.com/pypi/packages/19/14/cf3a6b6448849656e1e5f4e2101f3988dc6789724050096aba1bc5ccf592/opentelemetry_api-1.45.2.tar.gz", hash = "sha256:d7b0008e21e5fd61cbe7a7f34ca3b6905a78ab677d9bc395e299359c75cda6b4" }
wheels = [
{ url = "https://mirrors.aliyun.com/pypi/packages/a9/2d/610db864d7513158cebb8f36cc88e67e73bd6c7aa1905ef18d89e1281c81/opentelemetry_api-1.45.2-py3-none-any.whl", hash = "sha256:2cbd737377e710ee740d261c94e93fa0f08e6d037c18f17513cc0a2d94479a34" },
]
[[package]]
name = "packaging"
version = "26.3"
source = { registry = "https://mirrors.aliyun.com/pypi/simple" }
sdist = { url = "https://mirrors.aliyun.com/pypi/packages/7d/fa/3944b40b07da9ce895c0e6303a5ab7d53da063554f534556b134a54d6093/packaging-26.3.tar.gz", hash = "sha256:94edc256424af38762eb31306eed28beb9f0efc50a8837492c9d6fd6004aed79" }
wheels = [
{ url = "https://mirrors.aliyun.com/pypi/packages/63/34/ba1c580383c9eada3711951fef0795c80b829a078d72188184bcab9dd527/packaging-26.3-py3-none-any.whl", hash = "sha256:d7193f7c8e4e93f444fde0262bf90af30e16fa0ad0ad44cb553c87339b23cd1c" },
]
[[package]]
name = "pluggy"
version = "1.7.0"
source = { registry = "https://mirrors.aliyun.com/pypi/simple" }
sdist = { url = "https://mirrors.aliyun.com/pypi/packages/bf/db/7fc19e6f2dc92a966727031389fc2e08b558f0f25eb7403c1119ad4713cd/pluggy-1.7.0.tar.gz", hash = "sha256:d1eaa46ebb595891b860ab086b4d09c8588af65ebd4361b8e8f4bb8920b90ba8" }
wheels = [
{ url = "https://mirrors.aliyun.com/pypi/packages/40/9e/2b38731e0fc536806f16490e1a12d7f0dc2a1235aa8cc07bcc75416a7daa/pluggy-1.7.0-py3-none-any.whl", hash = "sha256:7dd7b0d8832ba3cb632c306926ded123429211b83641b35dc5c41ad2d34f9bec" },
]
[[package]]
name = "prompt-toolkit"
version = "3.0.53"
source = { registry = "https://mirrors.aliyun.com/pypi/simple" }
dependencies = [
{ name = "wcwidth" },
]
sdist = { url = "https://mirrors.aliyun.com/pypi/packages/7d/ea/39b988c938f75cb75d7045b5c69f8bfed47ee2152c8837fb403de29d6fb8/prompt_toolkit-3.0.53.tar.gz", hash = "sha256:9ec8a0ad96d5c56148b3f914aa79c1564c3fde5d2e6b876e7bc327e353cf8fa6" }
wheels = [
{ url = "https://mirrors.aliyun.com/pypi/packages/54/6f/84908cad2d6aa5144abcf7b42709fe4fdb459bc640ec7ac5786e7693dabc/prompt_toolkit-3.0.53-py3-none-any.whl", hash = "sha256:01c0891d7f9237d5e339f7d3e42cdae80b7534abb1c7c0e3352efba6231492f2" },
]
[[package]]
name = "psycopg"
version = "3.3.9"
source = { registry = "https://mirrors.aliyun.com/pypi/simple" }
dependencies = [
{ name = "typing-extensions" },
{ name = "tzdata", marker = "sys_platform == 'win32'" },
]
sdist = { url = "https://mirrors.aliyun.com/pypi/packages/b4/74/ff710399dfa9fe9b546c2f5a05ea2f9b9d1dc2145c0b59e53a3fa2013679/psycopg-3.3.9.tar.gz", hash = "sha256:87c1d85c3e0e88e811d3c0b3808f947bd967c6faf34af6cd86fd021f77793d6c" }
wheels = [
{ url = "https://mirrors.aliyun.com/pypi/packages/52/5d/a7957d1b5484f8e5094a15b1a400929324f978b670bd4a95179e1a012ec2/psycopg-3.3.9-py3-none-any.whl", hash = "sha256:d2d7d04a1ce6dab4f5b27316bea3b52585cafa2f2d631e5b09dd69823f5c26f6" },
]
[package.optional-dependencies]
binary = [
{ name = "psycopg-binary", marker = "implementation_name != 'pypy'" },
]
[[package]]
name = "psycopg-binary"
version = "3.3.9"
source = { registry = "https://mirrors.aliyun.com/pypi/simple" }
wheels = [
{ url = "https://mirrors.aliyun.com/pypi/packages/6e/0c/7fc92c3135ce195bb86052d18f9ef5f64b1592d8f3a5f1d90e9b49c72448/psycopg_binary-3.3.9-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:fcdb76adaab57fdd5b789b13b20699bffaf17000a4bbc0527327581cfdd55e3d" },
{ url = "https://mirrors.aliyun.com/pypi/packages/f0/a4/e62d11a85fc1a3a49f95b308bd5e2299dfc11125ef87043f6dfc29297d0c/psycopg_binary-3.3.9-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:08689018e9169ca8e6769f5b3f2ce748442bda95b5f1ec260995a8ff63e6d6a4" },
{ url = "https://mirrors.aliyun.com/pypi/packages/4a/89/d9ca02dfe30a6dc51e7796617dd69cc5c2e66bcc89ced44df4f4a3b5e402/psycopg_binary-3.3.9-cp312-cp312-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:e7e2e3543ac17cf5bb3eaf738606fc52bcedf993500b9fc8c55a4475a3731ef9" },
{ url = "https://mirrors.aliyun.com/pypi/packages/4d/aa/f1b6e1cd71aeafa78ab33875adf0339818fe014cde197a1c0c7c419dd0b0/psycopg_binary-3.3.9-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:a99f0b9a19ed7a56bf5d6776456b8f15f5364db8853b0f5d184db394a45c391d" },
{ url = "https://mirrors.aliyun.com/pypi/packages/ae/fe/9e967bfacdda0fef48fee1d869b13de016d82d846a805745b0985ac94a5b/psycopg_binary-3.3.9-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:b081348d8992af26e9b252f04876c286428418a6b7845d8d4caae2044b259668" },
{ url = "https://mirrors.aliyun.com/pypi/packages/cb/b3/c6a9f0bca0fdb06cf408235b698710f400a1d6376ab77e5fec887115aaa5/psycopg_binary-3.3.9-cp312-cp312-manylinux_2_38_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:66b20619acbd434e4e46d734a915768a1192db09754c2ad041d391d72f30e5eb" },
{ url = "https://mirrors.aliyun.com/pypi/packages/61/24/0443e50d382d3f6dcc03530560e02a02646af6bd8fcbd5a60add68c80208/psycopg_binary-3.3.9-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:b7c4b2039d82f635311e41e7d392ff1bddd94a2447f9668c6531489cc86a8ce2" },
{ url = "https://mirrors.aliyun.com/pypi/packages/c5/18/e576c5f50f4751ad9f1770134ad57ef216d00e5d79caa1c5b091f41275dc/psycopg_binary-3.3.9-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:3efe96cd98081b755ee3b0a50f2d35d9af55cb1ba462440a41048b9e7c6b9caa" },
{ url = "https://mirrors.aliyun.com/pypi/packages/cb/c6/434e01b19af141540147427675c116b2205ea58e3ec99e26431edf2d0714/psycopg_binary-3.3.9-cp312-cp312-musllinux_1_2_riscv64.whl", hash = "sha256:80ce081d2512ced75f1ca08ff80257a1288a3555079c5fa622164a0f9ed6533a" },
{ url = "https://mirrors.aliyun.com/pypi/packages/eb/84/0ea715e106cc80a89aca36e34dd6685fa1ee75da9546d41a1d87356efb9f/psycopg_binary-3.3.9-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:30a95cb2b00b94b4ec4fd5d41de047598c60e0db26fd43bd9154152cc380b282" },
{ url = "https://mirrors.aliyun.com/pypi/packages/81/a7/afe5fe01b4100454ea6543ac84c8b38a3713d6f27790253798ba50f2ef2a/psycopg_binary-3.3.9-cp312-cp312-win_amd64.whl", hash = "sha256:1ce1a6f04211626ca1a3deadee560235e8686e3888fb18f78d2be3e83bceabc4" },
]
[[package]]
name = "pydantic"
version = "2.14.3"
source = { registry = "https://mirrors.aliyun.com/pypi/simple" }
dependencies = [
{ name = "annotated-types" },
{ name = "pydantic-core" },
{ name = "typing-extensions" },
{ name = "typing-inspection" },
]
sdist = { url = "https://mirrors.aliyun.com/pypi/packages/b4/fc/1203d011145c98ddce3cd2f505bb54375ef8d43223053df6bfcf3c746f46/pydantic-2.14.3.tar.gz", hash = "sha256:1054f237f4d4733e5a30e1e2333bd33a2004ab9ab1510bd053a9a31bb48e232d" }
wheels = [
{ url = "https://mirrors.aliyun.com/pypi/packages/72/b8/b864503789ef5c58597d2a7b4adbee62c26440ab1e682581fc6838df8947/pydantic-2.14.3-py3-none-any.whl", hash = "sha256:3f7b347782ab7e4cf4c798496ae3a82787d9f21ec12676a9c564355eeef8daa8" },
]
[[package]]
name = "pydantic-core"
version = "2.50.4"
source = { registry = "https://mirrors.aliyun.com/pypi/simple" }
dependencies = [
{ name = "typing-extensions" },
]
sdist = { url = "https://mirrors.aliyun.com/pypi/packages/9c/0f/34f9ce4ba701dd0b815033ef94d99b56f66200e578ee6052aa3ac26f064e/pydantic_core-2.50.4.tar.gz", hash = "sha256:aead3b74b68396bf0feab5d57e050b730ded7df55853c1e048a87e00aaf033c6" }
wheels = [
{ url = "https://mirrors.aliyun.com/pypi/packages/10/bf/d1f6b81709538f831ebe1c42f50fb89db3dfda06f9e9b1ea24e90fc69209/pydantic_core-2.50.4-cp312-cp312-macosx_10_12_x86_64.whl", hash = "sha256:32a991aebd165f227b7c7c60bb9d66c2c7de9c24308552da264c9938fde0f8d6" },
{ url = "https://mirrors.aliyun.com/pypi/packages/c1/39/6618e541658d5a687a8d4962fc304350073a8f322bc4c62e8ed4c2d514d6/pydantic_core-2.50.4-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:1e20cbde2b6deb33a51d08cd168454dd9044ec7d4474056f4d98d63f51578783" },
{ url = "https://mirrors.aliyun.com/pypi/packages/d9/54/1c941fffa4e14bfc9ab0cd4977075f0e03201447856130d08a33cd45e47b/pydantic_core-2.50.4-cp312-cp312-manylinux1_i686.manylinux_2_5_i686.whl", hash = "sha256:8cceae48ae7f94990c2f4e36291e9ec9868735e8b0f19e4489a17b0422338466" },
{ url = "https://mirrors.aliyun.com/pypi/packages/61/a0/8028ef3e014be522ce43060aeac82a5be2288215e660866f5e6260acc123/pydantic_core-2.50.4-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:16902a147b3da4840612164a5e67947104d63e978f7a57c395877a5e26690b9c" },
{ url = "https://mirrors.aliyun.com/pypi/packages/c3/f2/b98bb73b1734ec4e42e786a766abc24f3c89620a0ddbaf8aa14e4b4c628c/pydantic_core-2.50.4-cp312-cp312-manylinux2014_armv7l.manylinux_2_17_armv7l.whl", hash = "sha256:d6e3485a5e5c01fb5339c1ee3d4b9e21e2135a2a9d44caafb71acd994487ee7c" },
{ url = "https://mirrors.aliyun.com/pypi/packages/f1/d1/7a7142786781400143e8806633fe5b65e2d407c311041fc9494490f05b18/pydantic_core-2.50.4-cp312-cp312-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:629eae995185540406e3635df5d5cf1d44f19ea240840b835d3f44541ff694d8" },
{ url = "https://mirrors.aliyun.com/pypi/packages/b5/34/cf710ca48d4498b04a3ea605d45892675dc2b14a94a25121a8d03f56d3e9/pydantic_core-2.50.4-cp312-cp312-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:41b2cd8b29dbb5a4c9828a70f50d1abfc92011115c813213d3a91205c6f731b3" },
{ url = "https://mirrors.aliyun.com/pypi/packages/91/23/e0c6e3cd09a0ac809953fea698c816b9f03bf0b35b6820c9553e4f5d85a8/pydantic_core-2.50.4-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:c81d98e27d9d9261909dcccab1ba5d6ea1c98b0bb9470e368604614fd1d36ddd" },
{ url = "https://mirrors.aliyun.com/pypi/packages/f9/00/292a0ed96d5d2d6edb49468ef481336e5b7e54f13435d73b7c912c891c23/pydantic_core-2.50.4-cp312-cp312-manylinux_2_31_riscv64.whl", hash = "sha256:ca83a32b2b41653d89f09a3d22b770bca96da72273bef8f7a68136bdd1e8b823" },
{ url = "https://mirrors.aliyun.com/pypi/packages/f8/36/d4690faf8c082eacf7754e52ab6bebe1bc73b167272e28699c00480ee908/pydantic_core-2.50.4-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:817953730e4a73a09008b010c4a42396cefe799616a22df2ac21d3927b3080cf" },
{ url = "https://mirrors.aliyun.com/pypi/packages/21/17/b180af6d17cf6c8e0d3d2661fc501a4a40959744ca4947d6ad0db81b1416/pydantic_core-2.50.4-cp312-cp312-musllinux_1_1_armv7l.whl", hash = "sha256:664e74848c2f5fc27db8505fe24e1ecd3ac669412913bf73d176916f86cc08e2" },
{ url = "https://mirrors.aliyun.com/pypi/packages/6e/bb/7e44d4ac6e1292f1859384c688713045bdf5448e0635c49c003d2be3bb6c/pydantic_core-2.50.4-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:219114f8dcdcbe4720d82ef016b1287ce5a0a67d7c69ca61524eb72e82aac344" },
{ url = "https://mirrors.aliyun.com/pypi/packages/d8/84/5101f35294579c4bef7dc32fd4f097d91eedac2e195894266bdabc1e6dfd/pydantic_core-2.50.4-cp312-cp312-win32.whl", hash = "sha256:67f7cc397e1d5556a801d1cba74de0d27d827eb242e6c036c0ca273c745414f1" },
{ url = "https://mirrors.aliyun.com/pypi/packages/82/88/d438a8fcf3738e9ff2670f724047ca3893ec899bcd5cdfc077a2aab133c6/pydantic_core-2.50.4-cp312-cp312-win_amd64.whl", hash = "sha256:ea2f61b0bc12f3592288503961b764579dea0658852d96a0b3d823614d808821" },
{ url = "https://mirrors.aliyun.com/pypi/packages/77/d4/4a0c73dc3ef9e50b122b8c3527afcded15a44838f1c9668d2d4b72cc09f0/pydantic_core-2.50.4-cp312-cp312-win_arm64.whl", hash = "sha256:32d6dda86383645ec428ea64dfc277036f5cbc60a72238eab28b91a3fdb9a113" },
{ url = "https://mirrors.aliyun.com/pypi/packages/9a/18/2f6a25e9104d5af713d16671711927601da1f0db74e785be67bd590385c9/pydantic_core-2.50.4-graalpy312-graalpy250_312_native-macosx_10_12_x86_64.whl", hash = "sha256:c04e9d920e2674f54651fd260a15c5d2843526c73d5242ee4311325ddc9573b3" },
{ url = "https://mirrors.aliyun.com/pypi/packages/4c/1b/ba8b721af10a7659e7fbbef320ff8eb55462557a72607858af5a9bd22cb1/pydantic_core-2.50.4-graalpy312-graalpy250_312_native-macosx_11_0_arm64.whl", hash = "sha256:5bc1811ef2b4d4ba63e8e452f6e332b6374bd1d2cbbfdf66826c8cb1f71dd10d" },
{ url = "https://mirrors.aliyun.com/pypi/packages/48/42/3f8638e7d90bdd9a7c7f3e5084723af59e7f43f15a292e242d35624073ce/pydantic_core-2.50.4-graalpy312-graalpy250_312_native-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:0b059a7968b1911be5a2d9a8234827ab0bef9d1e465d4b42da525894143550e8" },
{ url = "https://mirrors.aliyun.com/pypi/packages/e0/8d/4bfbacaf191f7939893d165e18eb301731fa3366c59a6e57336c4f168fbd/pydantic_core-2.50.4-graalpy312-graalpy250_312_native-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:bee28aab5a580eec673f7b68dfa8dece3dd37bd207ef8d22fafe23a8e9837296" },
]
[[package]]
name = "pydantic-settings"
version = "2.16.3"
source = { registry = "https://mirrors.aliyun.com/pypi/simple" }
dependencies = [
{ name = "pydantic" },
{ name = "python-dotenv" },
{ name = "typing-extensions" },
{ name = "typing-inspection" },
]
sdist = { url = "https://mirrors.aliyun.com/pypi/packages/59/28/227c843eedd29bd78e132e5aafa420d83154b10465c312f9c21ff2eaf77d/pydantic_settings-2.16.3.tar.gz", hash = "sha256:10e36f616623ebb586c05ca3d3cd22927146869db413d4f14c20c514442a1337" }
wheels = [
{ url = "https://mirrors.aliyun.com/pypi/packages/4c/26/3e68379ca313b6aa58e11fbd8b28d5c6f1b9f4428d70222ba021a76797ec/pydantic_settings-2.16.3-py3-none-any.whl", hash = "sha256:d1db16a2d34006323a1b42c0640898da58adfbad7ec30baaa9e2b18aafc08999" },
]
[[package]]
name = "pygments"
version = "2.21.0"
source = { registry = "https://mirrors.aliyun.com/pypi/simple" }
sdist = { url = "https://mirrors.aliyun.com/pypi/packages/49/2e/ced460408999b33da6b31b0021b0f37d329e202d4169aeb164493778f25b/pygments-2.21.0.tar.gz", hash = "sha256:610ca751c9bc2492b38eb9a38a7fbc93edbbb2d7182edaf34e66ae493dee5c8c" }
wheels = [
{ url = "https://mirrors.aliyun.com/pypi/packages/71/46/17f022dd3e953bf20a04a028a21ec746d942f8d2af30fa0f124fa0e6a684/pygments-2.21.0-py3-none-any.whl", hash = "sha256:2363c69b61c4a97c838da3b130dcd6468f4848992b21a82f2a63ec34377137d9" },
]
[[package]]
name = "pytest"
version = "8.4.2"
source = { registry = "https://mirrors.aliyun.com/pypi/simple" }
dependencies = [
{ name = "colorama", marker = "sys_platform == 'win32'" },
{ name = "iniconfig" },
{ name = "packaging" },
{ name = "pluggy" },
{ name = "pygments" },
]
sdist = { url = "https://mirrors.aliyun.com/pypi/packages/a3/5c/00a0e072241553e1a7496d638deababa67c5058571567b92a7eaa258397c/pytest-8.4.2.tar.gz", hash = "sha256:86c0d0b93306b961d58d62a4db4879f27fe25513d4b969df351abdddb3c30e01" }
wheels = [
{ url = "https://mirrors.aliyun.com/pypi/packages/a8/a4/20da314d277121d6534b3a980b29035dcd51e6744bd79075a6ce8fa4eb8d/pytest-8.4.2-py3-none-any.whl", hash = "sha256:872f880de3fc3a5bdc88a11b39c9710c3497a547cfa9320bc3c5e62fbf272e79" },
]
[[package]]
name = "python-dateutil"
version = "2.9.0.post0"
source = { registry = "https://mirrors.aliyun.com/pypi/simple" }
dependencies = [
{ name = "six" },
]
sdist = { url = "https://mirrors.aliyun.com/pypi/packages/66/c0/0c8b6ad9f17a802ee498c46e004a0eb49bc148f2fd230864601a86dcf6db/python-dateutil-2.9.0.post0.tar.gz", hash = "sha256:37dd54208da7e1cd875388217d5e00ebd4179249f90fb72437e91a35459a0ad3" }
wheels = [
{ url = "https://mirrors.aliyun.com/pypi/packages/ec/57/56b9bcc3c9c6a792fcbaf139543cee77261f3651ca9da0c93f5c1221264b/python_dateutil-2.9.0.post0-py2.py3-none-any.whl", hash = "sha256:a8b2bc7bffae282281c8140a97d3aa9c14da0b136dfe83f850eea9a5f7470427" },
]
[[package]]
name = "python-dotenv"
version = "1.2.4"
source = { registry = "https://mirrors.aliyun.com/pypi/simple" }
sdist = { url = "https://mirrors.aliyun.com/pypi/packages/74/26/2fbeedb218a787a5eea551c7532cac4e009f83d689dd2faa0d0353473f86/python_dotenv-1.2.4.tar.gz", hash = "sha256:f0d53e69935a851c0dcc78f3ab7aaccd8cabef0b92382b576b824212902873c0" }
wheels = [
{ url = "https://mirrors.aliyun.com/pypi/packages/60/d1/38f3a3405989a89ac18390803e70c6ad7c7760da4f9b83cbeca0c44a0c72/python_dotenv-1.2.4-py3-none-any.whl", hash = "sha256:42269a8a5b3fd54ffa6f3d84b18abed50064717576b4ecf03dc4a55d8aa04fdc" },
]
[[package]]
name = "pyyaml"
version = "6.0.3"
source = { registry = "https://mirrors.aliyun.com/pypi/simple" }
sdist = { url = "https://mirrors.aliyun.com/pypi/packages/05/8e/961c0007c59b8dd7729d542c61a4d537767a59645b82a0b521206e1e25c2/pyyaml-6.0.3.tar.gz", hash = "sha256:d76623373421df22fb4cf8817020cbb7ef15c725b9d5e45f17e189bfc384190f" }
wheels = [
{ url = "https://mirrors.aliyun.com/pypi/packages/d1/33/422b98d2195232ca1826284a76852ad5a86fe23e31b009c9886b2d0fb8b2/pyyaml-6.0.3-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:7f047e29dcae44602496db43be01ad42fc6f1cc0d8cd6c83d342306c32270196" },
{ url = "https://mirrors.aliyun.com/pypi/packages/89/a0/6cf41a19a1f2f3feab0e9c0b74134aa2ce6849093d5517a0c550fe37a648/pyyaml-6.0.3-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:fc09d0aa354569bc501d4e787133afc08552722d3ab34836a80547331bb5d4a0" },
{ url = "https://mirrors.aliyun.com/pypi/packages/ed/23/7a778b6bd0b9a8039df8b1b1d80e2e2ad78aa04171592c8a5c43a56a6af4/pyyaml-6.0.3-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:9149cad251584d5fb4981be1ecde53a1ca46c891a79788c0df828d2f166bda28" },
{ url = "https://mirrors.aliyun.com/pypi/packages/65/30/d7353c338e12baef4ecc1b09e877c1970bd3382789c159b4f89d6a70dc09/pyyaml-6.0.3-cp312-cp312-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:5fdec68f91a0c6739b380c83b951e2c72ac0197ace422360e6d5a959d8d97b2c" },
{ url = "https://mirrors.aliyun.com/pypi/packages/8b/9d/b3589d3877982d4f2329302ef98a8026e7f4443c765c46cfecc8858c6b4b/pyyaml-6.0.3-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:ba1cc08a7ccde2d2ec775841541641e4548226580ab850948cbfda66a1befcdc" },
{ url = "https://mirrors.aliyun.com/pypi/packages/05/c0/b3be26a015601b822b97d9149ff8cb5ead58c66f981e04fedf4e762f4bd4/pyyaml-6.0.3-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:8dc52c23056b9ddd46818a57b78404882310fb473d63f17b07d5c40421e47f8e" },
{ url = "https://mirrors.aliyun.com/pypi/packages/be/8e/98435a21d1d4b46590d5459a22d88128103f8da4c2d4cb8f14f2a96504e1/pyyaml-6.0.3-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:41715c910c881bc081f1e8872880d3c650acf13dfa8214bad49ed4cede7c34ea" },
{ url = "https://mirrors.aliyun.com/pypi/packages/74/93/7baea19427dcfbe1e5a372d81473250b379f04b1bd3c4c5ff825e2327202/pyyaml-6.0.3-cp312-cp312-win32.whl", hash = "sha256:96b533f0e99f6579b3d4d4995707cf36df9100d67e0c8303a0c55b27b5f99bc5" },
{ url = "https://mirrors.aliyun.com/pypi/packages/86/bf/899e81e4cce32febab4fb42bb97dcdf66bc135272882d1987881a4b519e9/pyyaml-6.0.3-cp312-cp312-win_amd64.whl", hash = "sha256:5fcd34e47f6e0b794d17de1b4ff496c00986e1c83f7ab2fb8fcfe9616ff7477b" },
{ url = "https://mirrors.aliyun.com/pypi/packages/1a/08/67bd04656199bbb51dbed1439b7f27601dfb576fb864099c7ef0c3e55531/pyyaml-6.0.3-cp312-cp312-win_arm64.whl", hash = "sha256:64386e5e707d03a7e172c0701abfb7e10f0fb753ee1d773128192742712a98fd" },
]
[[package]]
name = "six"
version = "1.17.0"
source = { registry = "https://mirrors.aliyun.com/pypi/simple" }
sdist = { url = "https://mirrors.aliyun.com/pypi/packages/94/e7/b2c673351809dca68a0e064b6af791aa332cf192da575fd474ed7d6f16a2/six-1.17.0.tar.gz", hash = "sha256:ff70335d468e7eb6ec65b95b99d3a2836546063f63acc5171de367e834932a81" }
wheels = [
{ url = "https://mirrors.aliyun.com/pypi/packages/b7/ce/149a00dd41f10bc29e5921b496af8b574d8413afcd5e30dfa0ed46c2cc5e/six-1.17.0-py2.py3-none-any.whl", hash = "sha256:4721f391ed90541fddacab5acf947aa0d3dc7d27b2e1e8eda2be8970586c3274" },
]
[[package]]
name = "sqlalchemy"
version = "2.0.57"
source = { registry = "https://mirrors.aliyun.com/pypi/simple" }
dependencies = [
{ name = "greenlet", marker = "platform_machine == 'AMD64' or platform_machine == 'WIN32' or platform_machine == 'aarch64' or platform_machine == 'amd64' or platform_machine == 'ppc64le' or platform_machine == 'win32' or platform_machine == 'x86_64'" },
{ name = "typing-extensions" },
]
sdist = { url = "https://mirrors.aliyun.com/pypi/packages/19/df/7611a37edc4cfa118c364a7f5dec4889ad0e9f84638a789bbf864c5f7a63/sqlalchemy-2.0.57.tar.gz", hash = "sha256:892e0edd06b8ca2a8a3f9107611047914fd82ccd03735efd706d12aa4da1b773" }
wheels = [
{ url = "https://mirrors.aliyun.com/pypi/packages/68/78/27f8b0f5c59006f98875b3166347615a2aaf196ccd9a400d6a95f56e0364/sqlalchemy-2.0.57-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:e33889a6f292db9ed2278d5562717c96432651ec558417a7acf17d9549fd6935" },
{ url = "https://mirrors.aliyun.com/pypi/packages/41/f3/702ae27c52acfaeb6dde5ef1a49a8fa1793e28834fe77be7c3a4cb7abfb5/sqlalchemy-2.0.57-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:75135c4c54be953730e41203f38ced685b60dfb16d61a7d4d9a7ab8d87ced6f1" },
{ url = "https://mirrors.aliyun.com/pypi/packages/df/2b/6722fc370f7cbc75fd6df6ba3d870ab4ee40a02c4875162e2bcfe4a5ad83/sqlalchemy-2.0.57-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:4ff9f7dda4d136bfd7fab44384ef7e3135c9826da815d6248f713d0035a6274b" },
{ url = "https://mirrors.aliyun.com/pypi/packages/8e/9d/4ff40e4d17c36c6b8d328ddefc66abe0b5f3b4d257a61d430a6dcded4ab5/sqlalchemy-2.0.57-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:e8d67fa9935021bdccd02d313a1b5ce92531f679b0e70ea7b9f5d651fab7f742" },
{ url = "https://mirrors.aliyun.com/pypi/packages/fc/39/6bc26429849cc799ae5a5c9c8657491eff777f50a5e38e91626d79984d68/sqlalchemy-2.0.57-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:d55ea24654f8d982c5aabd6e6779eac3ed15f420f629761c4eb627399e9d8cec" },
{ url = "https://mirrors.aliyun.com/pypi/packages/6b/b4/5c67a4c220c84ac9923bea8035e1ad6e0982191ddf56008228ad30edc974/sqlalchemy-2.0.57-cp312-cp312-win32.whl", hash = "sha256:ffaedafb38901bc72efcaf9fdf57bc363be24bd67a8bce8e3afe4ec75bc82833" },
{ url = "https://mirrors.aliyun.com/pypi/packages/c9/72/406430db968b16104bb4132fc6394d279e1e96b36994200879f76eb8da52/sqlalchemy-2.0.57-cp312-cp312-win_amd64.whl", hash = "sha256:4972e01af81b72b78e335735eddf9d4ef8980eca1e8364552715991a454eea97" },
{ url = "https://mirrors.aliyun.com/pypi/packages/fd/0e/ed54ed17987f65115360b124ab943d955c04906fd589411627805afe7b57/sqlalchemy-2.0.57-py3-none-any.whl", hash = "sha256:e31639a78045134a39e14f287b647fd9537cdd71978ea9c11bf7d905d70e473d" },
]
[[package]]
name = "starlette"
version = "1.10.0"
source = { registry = "https://mirrors.aliyun.com/pypi/simple" }
dependencies = [
{ name = "anyio" },
{ name = "typing-extensions" },
]
sdist = { url = "https://mirrors.aliyun.com/pypi/packages/48/bb/3d8757f21e9a53d9035c9eb039a777047139a16bfdbedfc7a58241c3d914/starlette-1.10.0.tar.gz", hash = "sha256:b8399098d4c1e3522734f7235dc79b1fc967f96cf139c81e0fa30479e0685f9b" }
wheels = [
{ url = "https://mirrors.aliyun.com/pypi/packages/88/2e/947cfe02def9371c07cd5bf5b6b61c829e9aecb9904db02a66cfafbc1eec/starlette-1.10.0-py3-none-any.whl", hash = "sha256:478c0ab3b4ced6e82719849c118fa406f0278a3499c1a898cd15cd31bdc38ce4" },
]
[[package]]
name = "typing-extensions"
version = "4.16.0"
source = { registry = "https://mirrors.aliyun.com/pypi/simple" }
sdist = { url = "https://mirrors.aliyun.com/pypi/packages/f6/cc/6253133b5bb138fc3306cebfbda2c520f545d36b5be2c7255cc528bb45d6/typing_extensions-4.16.0.tar.gz", hash = "sha256:dc983d19a509c94dba722ee6abd33940f7c05a89e243c47e907eb4db6f1a43e5" }
wheels = [
{ url = "https://mirrors.aliyun.com/pypi/packages/49/d3/b8441a820a491ddfc024b0b0cf0393375b75ea13866d9c66727e54c2fc80/typing_extensions-4.16.0-py3-none-any.whl", hash = "sha256:481caa481374e813c1b176ada14e97f1f67a4539ce9cfeb3f350d78d6370c2e8" },
]
[[package]]
name = "typing-inspection"
version = "0.4.5"
source = { registry = "https://mirrors.aliyun.com/pypi/simple" }
dependencies = [
{ name = "typing-extensions" },
]
sdist = { url = "https://mirrors.aliyun.com/pypi/packages/ff/50/0195198eb1d75bab716bb0a813abea4cc394bfa17a92a189f021a34859af/typing_inspection-0.4.5.tar.gz", hash = "sha256:7f16c411e7930dc79596d42ab44672a3fe5f60eb34b781a1647e7872363120c7" }
wheels = [
{ url = "https://mirrors.aliyun.com/pypi/packages/de/0c/ea2544850a7c135e15033a5c7a8e7211136184b7ae63e2239d557c2b3019/typing_inspection-0.4.5-py3-none-any.whl", hash = "sha256:bc210535442b39e1bf2805e0c7a17dfd6a4ace760c84c7f7d16245d23a6b1c39" },
]
[[package]]
name = "tzdata"
version = "2026.6"
source = { registry = "https://mirrors.aliyun.com/pypi/simple" }
sdist = { url = "https://mirrors.aliyun.com/pypi/packages/7a/29/6a1391d31cd00ff9e927215a224a880e1e84e826b64ba80a499e51c074d8/tzdata-2026.6.tar.gz", hash = "sha256:85d2cd9c09f81f0bb29db27759fc83af4f1e620efb814f8c5bf8b4cc4feece6d" }
wheels = [
{ url = "https://mirrors.aliyun.com/pypi/packages/0a/66/9a06c2227fedfd4919f0eaaa8b94377d9730882a7e4f95823c9a331ab5e1/tzdata-2026.6-py2.py3-none-any.whl", hash = "sha256:0a10eec6e13ef16b627fabed9a5f2ba61a62b1c67f327305f4e7e412a70b4aec" },
]
[[package]]
name = "tzlocal"
version = "5.4.5"
source = { registry = "https://mirrors.aliyun.com/pypi/simple" }
dependencies = [
{ name = "tzdata", marker = "sys_platform == 'win32'" },
]
sdist = { url = "https://mirrors.aliyun.com/pypi/packages/d8/89/2bd035df331499589fc92e59375c17c6cea6a500453b2c5f6a6ec9572825/tzlocal-5.4.5.tar.gz", hash = "sha256:ba976898bad27945178c9ca25c222c19e322b30c10342b9f40b46714f70d2d5f" }
wheels = [
{ url = "https://mirrors.aliyun.com/pypi/packages/7b/c1/9be4e1a8a30db8729a86628073910e56f85aaf8a659e053f376a2e6ea5a8/tzlocal-5.4.5-py3-none-any.whl", hash = "sha256:ecab534f6d65d9deb4c4ea52c121ab6dd5958e9b878e71dcb102578269752454" },
]
[[package]]
name = "uvicorn"
version = "0.54.0"
source = { registry = "https://mirrors.aliyun.com/pypi/simple" }
dependencies = [
{ name = "click" },
{ name = "h11" },
]
sdist = { url = "https://mirrors.aliyun.com/pypi/packages/da/34/30e9280707135d2cfc589dfff3cb796bd07a3aeb1a3e415ba09dd89d7bb4/uvicorn-0.54.0.tar.gz", hash = "sha256:a2e33cbfaa0306f8e6b0c13e0cb89d7d7a2da3e62b90c66e18c33d9807b28620" }
wheels = [
{ url = "https://mirrors.aliyun.com/pypi/packages/38/0c/b54a4fdd7f90a3af8b02ebc9ce6712c2c208b7926a2f7bad95c33ebbe943/uvicorn-0.54.0-py3-none-any.whl", hash = "sha256:505bdb0f318731d45f1f712071fc781a8981f6847a31c902c9f5e652d4f67faf" },
]
[package.optional-dependencies]
standard = [
{ name = "httptools" },
{ name = "python-dotenv" },
{ name = "pyyaml" },
{ name = "uvloop", marker = "platform_python_implementation != 'PyPy' and sys_platform != 'cygwin' and sys_platform != 'win32'" },
{ name = "watchfiles" },
{ name = "websockets" },
]
[[package]]
name = "uvloop"
version = "0.23.0"
source = { registry = "https://mirrors.aliyun.com/pypi/simple" }
sdist = { url = "https://mirrors.aliyun.com/pypi/packages/fa/42/02c739ce85fb2ee8d99212c61417da8140c6b87e9d97c430bea520d76044/uvloop-0.23.0.tar.gz", hash = "sha256:28d160f51ab4da3b187063652e643dea6831072add4adc1e6d62afbe73b6be27" }
wheels = [
{ url = "https://mirrors.aliyun.com/pypi/packages/05/98/04e766a6de99e6f7f955ecb7829e8d5a557de3427cb85be2236de54dda0c/uvloop-0.23.0-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:93935ab27b6eaef4c3e5489aebc84284f0644592f7ab516df60ee1b27eaf5eb3" },
{ url = "https://mirrors.aliyun.com/pypi/packages/33/8a/499e7b863a848ede009539bce39806b66205da5f8779354228e785601144/uvloop-0.23.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:4448e9124537620f9c25d004c227bb5104440b58955c19bbd312d910af919a63" },
{ url = "https://mirrors.aliyun.com/pypi/packages/3d/95/a880f8ce3b87ac5b307c354e8ee480be4658d24bf01f87921d57e3530b4a/uvloop-0.23.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:f7548ede3ee908cfabc0d068106e303a9a2d811af959cdf6ab85676344cedcda" },
{ url = "https://mirrors.aliyun.com/pypi/packages/51/27/c1d2f9fa977f8f42ea294604166df10e0027e6dc6cd17f85ede386c9bf36/uvloop-0.23.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:090865d8ce7a03986755a3ce711b7dd0d4b44eb14ab74368b717f3fad1180208" },
{ url = "https://mirrors.aliyun.com/pypi/packages/42/dd/2cb6a2c8a30ca55c07a882dd4ae4ceae0fa7d8c15b25b3b7cb9a4b6cf4ca/uvloop-0.23.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:bd6f2f81c7b9da99d301c0b16b82044e76fe887086e42e1590ecf520b94dbdac" },
{ url = "https://mirrors.aliyun.com/pypi/packages/f4/52/29989cbaa4022dc4ef35c1dd60a4ab989e4c2065f341ed483ae71d2bd950/uvloop-0.23.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:a6ac96da66c35bf789bdcde78a88dc7d56b7907d8379648c54adc1c61594575d" },
]
[[package]]
name = "vine"
version = "5.1.0"
source = { registry = "https://mirrors.aliyun.com/pypi/simple" }
sdist = { url = "https://mirrors.aliyun.com/pypi/packages/bd/e4/d07b5f29d283596b9727dd5275ccbceb63c44a1a82aa9e4bfd20426762ac/vine-5.1.0.tar.gz", hash = "sha256:8b62e981d35c41049211cf62a0a1242d8c1ee9bd15bb196ce38aefd6799e61e0" }
wheels = [
{ url = "https://mirrors.aliyun.com/pypi/packages/03/ff/7c0c86c43b3cbb927e0ccc0255cb4057ceba4799cd44ae95174ce8e8b5b2/vine-5.1.0-py3-none-any.whl", hash = "sha256:40fdf3c48b2cfe1c38a49e9ae2da6fda88e4794c810050a728bd7413811fb1dc" },
]
[[package]]
name = "watchfiles"
version = "1.3.0"
source = { registry = "https://mirrors.aliyun.com/pypi/simple" }
dependencies = [
{ name = "anyio" },
]
sdist = { url = "https://mirrors.aliyun.com/pypi/packages/b3/68/e6aa0b77d217b31f8f486ec0cdfe5e00e6e38dc0be657e7d85819b9faf0a/watchfiles-1.3.0.tar.gz", hash = "sha256:99aee4a07847c06820765fd7b1b49ceac4f3f711ccb7d104655a33231de1c207" }
wheels = [
{ url = "https://mirrors.aliyun.com/pypi/packages/68/fa/c0b840d5d8bafe640925408ce11095948c8945bb61be1e67d0ab629b872a/watchfiles-1.3.0-cp310-abi3-macosx_10_12_x86_64.whl", hash = "sha256:000b9688fc8133037a8b075c8ebf98f32844ff8964dda61e85c1db547dafc441" },
{ url = "https://mirrors.aliyun.com/pypi/packages/c7/8a/894799b485fe9473ad10422a0d9668e53fb78e3a2b5cc6061159572844ad/watchfiles-1.3.0-cp310-abi3-macosx_11_0_arm64.whl", hash = "sha256:bbc1198edfdc90fda0600f825aa94150f428dfcbf8138746f55998e0e660d64c" },
{ url = "https://mirrors.aliyun.com/pypi/packages/5a/61/f277cd5ead05f5d37b98b41fbdd0c943ee0c04d49738f62e902cb291cf43/watchfiles-1.3.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4af9c464d410e8c44b58ddf1cbec7c3a02c1cb2c6c80df9c74659ba2fbda0ab5" },
{ url = "https://mirrors.aliyun.com/pypi/packages/46/66/ea4c01382975e53b1ac1b0a0ea1b353416b8127fb6e04f5c1c313119aab6/watchfiles-1.3.0-cp310-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:eb94e40b9a0db19636b5e3fed0a9803452ecc7381df13b385272abb779ee83ca" },
{ url = "https://mirrors.aliyun.com/pypi/packages/31/c3/1a501b597817096c9831c255f6270c124ce0e2faeb74124be24dcc93b86d/watchfiles-1.3.0-cp310-abi3-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:7398930a2b76b9dc67a4e6b8bfc7baf30946892a86f417a3920c07bdd6febc30" },
{ url = "https://mirrors.aliyun.com/pypi/packages/5a/16/77352d05e152c7786a016e9f1decdb4507e8aa5bcf3343c72142a0413d14/watchfiles-1.3.0-cp310-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:025b108f2d5cc2799cb941f79380df3e8b22bfb589c218e801767fe78d598c95" },
{ url = "https://mirrors.aliyun.com/pypi/packages/95/fe/81001c55b24466fe9911135e50269fd3a29f43e446627a92adfab54553b6/watchfiles-1.3.0-cp310-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:be9ef3cd403d756a304a0a08a112163c63da7ec72c8c9d083c98818291ff8f29" },
{ url = "https://mirrors.aliyun.com/pypi/packages/8a/cf/e3ad894ed5909a7c44b0707e89bc25d19a3d78b3a7aec846119443b6ae56/watchfiles-1.3.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b5768b49e426fd5b550b012c866db347cdf15c398ef98dc557b6e6b72fa74cd1" },
{ url = "https://mirrors.aliyun.com/pypi/packages/7f/f5/2f106829e6e2bc91ad74614730f6df484202b9a4d20d927dbf2f08d37d44/watchfiles-1.3.0-cp310-abi3-manylinux_2_31_riscv64.whl", hash = "sha256:d36c72fcdc08f143d87316a4c4c3b064e340da2c7383d39803950740ed418935" },
{ url = "https://mirrors.aliyun.com/pypi/packages/15/37/2741ab776b978669c1f3bba1e573f1a184f727ab8b4d3a6d9c61090800ed/watchfiles-1.3.0-cp310-abi3-musllinux_1_1_aarch64.whl", hash = "sha256:f0c9865240e065a2247f4b5248528ae3d01e0e8ae071462c250c884dc16e3ee3" },
{ url = "https://mirrors.aliyun.com/pypi/packages/48/64/db4a4684275fe9b696ee5118c194705c1423b3d42181c3f8ee70194d5c73/watchfiles-1.3.0-cp310-abi3-musllinux_1_1_x86_64.whl", hash = "sha256:380f513d26cc2e598266b88d66456e07d67ef4be8f0f435a1154d9c44b43d509" },
{ url = "https://mirrors.aliyun.com/pypi/packages/52/80/95ddb24f6a2f595c031c24432ab7b8aa7d6d1ada0c6d63a552166e06e8d1/watchfiles-1.3.0-cp310-abi3-win32.whl", hash = "sha256:509d9f74d2bec5c1f4cd868ddcfe0c9601f7ea53066dfcb19d8ede742c4de661" },
{ url = "https://mirrors.aliyun.com/pypi/packages/48/a1/1c4a1b3c8030cd03206232612be8a6e8799093490c220b0fcb935d02b75a/watchfiles-1.3.0-cp310-abi3-win_amd64.whl", hash = "sha256:1acabde19b67e673274e89a04d613b7fb1f122e2c4b8ec9a581e59c149264b61" },
{ url = "https://mirrors.aliyun.com/pypi/packages/82/e0/d2db577c632d26d08078c4390dd870b8555c4e558df25d22270f0166c71f/watchfiles-1.3.0-cp310-abi3-win_arm64.whl", hash = "sha256:d978cc1dd7ba44f5590d7de74f7a9c8be7262d9e469c2c0efb8bbfc2574321dc" },
]
[[package]]
name = "watchman"
version = "0.1.0"
source = { editable = "services/watchman" }
dependencies = [
{ name = "alembic" },
{ name = "celery" },
{ name = "fastapi" },
{ name = "psycopg", extra = ["binary"] },
{ name = "pydantic" },
{ name = "pydantic-settings" },
{ name = "python-dotenv" },
{ name = "sqlalchemy" },
{ name = "uvicorn", extra = ["standard"] },
]
[package.metadata]
requires-dist = [
{ name = "alembic", specifier = ">=1.14,<2" },
{ name = "celery", specifier = ">=5.4,<6" },
{ name = "fastapi", specifier = ">=0.115,<1" },
{ name = "psycopg", extras = ["binary"], specifier = ">=3.2,<4" },
{ name = "pydantic", specifier = ">=2.10,<3" },
{ name = "pydantic-settings", specifier = ">=2.6,<3" },
{ name = "python-dotenv", specifier = ">=1.0,<2" },
{ name = "sqlalchemy", specifier = ">=2.0.36,<2.1" },
{ name = "uvicorn", extras = ["standard"], specifier = ">=0.32,<1" },
]
[[package]]
name = "watchman-workspace"
version = "0.1.0"
source = { virtual = "." }
[package.dev-dependencies]
dev = [
{ name = "httpx" },
{ name = "pytest" },
{ name = "watchman" },
]
[package.metadata]
[package.metadata.requires-dev]
dev = [
{ name = "httpx", specifier = ">=0.28,<1" },
{ name = "pytest", specifier = ">=8.3,<9" },
{ name = "watchman", editable = "services/watchman" },
]
[[package]]
name = "wcwidth"
version = "0.9.4"
source = { registry = "https://mirrors.aliyun.com/pypi/simple" }
sdist = { url = "https://mirrors.aliyun.com/pypi/packages/ea/01/e5ac23733628a6bbb91913a765fcf55ee8070d8d991bc88fdaaf805052c7/wcwidth-0.9.4.tar.gz", hash = "sha256:fd8d57d3cdfe570e3265c8fab1885c24e34ef40889c0759c0c304a19e9835954" }
wheels = [
{ url = "https://mirrors.aliyun.com/pypi/packages/bf/b8/d251589a100250b71a7b8e83fedfcabfd8bd60e78cd1e3329372f63bcc93/wcwidth-0.9.4-cp310-abi3-macosx_10_9_x86_64.whl", hash = "sha256:b7969c9aa258d536df54c8ac8af5cad0c74a6268c9972e1fb60a5f29feffb66d" },
{ url = "https://mirrors.aliyun.com/pypi/packages/04/e9/dfdca30ca36c472de3e260406dee29fc108499ec590c63b3fe279887ee9d/wcwidth-0.9.4-cp310-abi3-macosx_11_0_arm64.whl", hash = "sha256:f279f32c8e206a9092fa350e53ca0c2bd8072e45b1c9fd31bb6d476b59b591c4" },
{ url = "https://mirrors.aliyun.com/pypi/packages/5d/b6/d7416f38054a107d2fb17c2b73b68723c6c334f69c4e29545fb9e6df81eb/wcwidth-0.9.4-cp310-abi3-manylinux1_i686.manylinux2014_i686.manylinux_2_17_i686.manylinux_2_5_i686.whl", hash = "sha256:a1526cd25c6420e5153bb7d764c7509e692215ee3ad9b725db1ad665d47eae09" },
{ url = "https://mirrors.aliyun.com/pypi/packages/7d/5b/42bdf9a4b0e4f9126584af2ec73642de495f3bd8add907430f13c3bb98d2/wcwidth-0.9.4-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:093469e01d881bff3db93ff3f56c364dc87c441ea01f9f41c22de0c0bdf5c6ef" },
{ url = "https://mirrors.aliyun.com/pypi/packages/fa/e8/0485850748dfdba9443f4151c7b2442cfa4987ba6cd871038eb5d6b8eca9/wcwidth-0.9.4-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:b185c8b927b23af2721be1783499d1cfa5c028b098b0858951b4ae224477f1c2" },
{ url = "https://mirrors.aliyun.com/pypi/packages/e9/11/dd3d0379c6094524df6585b76ae3d9727161ff29c003177e3661c36437c1/wcwidth-0.9.4-cp310-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:17619066f95c10f44d7ae08ee456602456bc66cc9d5e91966ec73d799acebc5f" },
{ url = "https://mirrors.aliyun.com/pypi/packages/3c/48/1b5299983d9ec084be897162b7cc6014622dfe62847224fa3272b6d79ea5/wcwidth-0.9.4-cp310-abi3-musllinux_1_2_i686.whl", hash = "sha256:b52f265a694dda6b3ad9050c8bd89158ad519109ef7c5eb110b906cc49f25763" },
{ url = "https://mirrors.aliyun.com/pypi/packages/7a/be/e3097d859b075344a7be57774a58d468eafb0ca88e02aad93eb31d69f6ba/wcwidth-0.9.4-cp310-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:d8905f1390d828d745fdd1904374c90386d902d3cfa9ee88e9875099f75a4e17" },
{ url = "https://mirrors.aliyun.com/pypi/packages/5e/cd/739710c8cf0de461239db5bb6ee678c9a33d30aaa22beff55cc356781818/wcwidth-0.9.4-cp310-abi3-win32.whl", hash = "sha256:4831662c396dd4c59a016ec53c0ac96738006d653a00482777d9a2e2ea323d62" },
{ url = "https://mirrors.aliyun.com/pypi/packages/d6/f1/c123f902bc2ff9e9c2ab66241b8872204df87cbb18ecdf035e120860fedc/wcwidth-0.9.4-cp310-abi3-win_amd64.whl", hash = "sha256:f28d77153303450ee13ebbe888297e75cf532c754555b6cabafc9bdda16c421c" },
{ url = "https://mirrors.aliyun.com/pypi/packages/4b/88/1cb5ddaf5510b918e01aa95fc4b68df91dead784b63e4931037c5673e85f/wcwidth-0.9.4-cp310-abi3-win_arm64.whl", hash = "sha256:2b58fc8cf2de1bf9cdb68b8beaa5be198742414a7c8cd97aa51ec039783ffa49" },
{ url = "https://mirrors.aliyun.com/pypi/packages/6f/0c/309b1813b230d1dbbd6f2c2ab2bb21ef68992358977605d9ef289bbfedcc/wcwidth-0.9.4-py3-none-any.whl", hash = "sha256:901eace6d2dd25ebb917d0ce5db18e5c537e1504c905cf32f0d006c12098b05d" },
]
[[package]]
name = "websockets"
version = "17.4"
source = { registry = "https://mirrors.aliyun.com/pypi/simple" }
sdist = { url = "https://mirrors.aliyun.com/pypi/packages/75/79/590c5f0cc7d1661195aeefccb0e342b79f4c77d368d526d028821a390332/websockets-17.4.tar.gz", hash = "sha256:09d3939b70df0c8ad2da145ebd50978bccaee1d565e838b0e7921a34d38571eb" }
wheels = [
{ url = "https://mirrors.aliyun.com/pypi/packages/af/71/b020221345ea6c012dcf7496827a48a744b58696470b2b07fef95a32905a/websockets-17.4-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:3d512e3a6c528c42ce220ed9c3caff83c6fdcd98a1b98249f08ccfc66ad111b1" },
{ url = "https://mirrors.aliyun.com/pypi/packages/8e/84/1c372ae7c032021a84e5c9e9b76b0dddefb354e9b4af783a97efd4d80ab3/websockets-17.4-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:7390e060f830b3d132f484b21ac2783a2d227b682ef62bb8146e1c1b4ca0e45a" },
{ url = "https://mirrors.aliyun.com/pypi/packages/74/b6/cff249107473f149c6c916a49cba967379fa63b0a7d2dce6896d6848f0a3/websockets-17.4-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:bcad49104711f88b2b7c3ba166de172857d837248205e541b044a552558fecc3" },
{ url = "https://mirrors.aliyun.com/pypi/packages/77/5d/aff8ecbf1c55c4d96f6dacc46a52102895f58b85bb284c8d325aaf31606a/websockets-17.4-cp312-cp312-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:cf99debb17227a50620aee16647bb33a0387f5fa5418d628666c0f05745e0d2a" },
{ url = "https://mirrors.aliyun.com/pypi/packages/cb/18/6229d6583031ca81d092a0cd887a13a57b402fb555acc323d39b45967eb7/websockets-17.4-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:9ae1429ee9e52b139167ed0169757806a27ed7307e942e8c62037a9184e9843b" },
{ url = "https://mirrors.aliyun.com/pypi/packages/b8/61/7aba018fd53873e792a25afe1f4c005518133477b727d7455f2f7550c425/websockets-17.4-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:51adfc30f467077293a6695d8149bcef501c0728386f3a491054f835dadb60b2" },
{ url = "https://mirrors.aliyun.com/pypi/packages/fb/66/37b207df9cdacaa017aa4487f3a9f2fcd668f6f7cfbafdac5b95ea258ee0/websockets-17.4-cp312-cp312-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:c564d1e6531611bf87078c28780456ecc75459dcca189629fff2fe7c020d8e67" },
{ url = "https://mirrors.aliyun.com/pypi/packages/ad/f6/87507e11fbae53817a435945273953b5b020589e309fac4fd60527ee5999/websockets-17.4-cp312-cp312-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:4c792e6cce24d08f92199d907785c9e64f74c357deeed3dbaf7d699ed5930b64" },
{ url = "https://mirrors.aliyun.com/pypi/packages/2f/3d/90a04f0aa989b68fbd2efcd38237420afe2abe5a1cab0b5d7c2aa4f0dbb6/websockets-17.4-cp312-cp312-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:c44776f82b04e623eb9e1b81fcd17ac6e9808ae1ba5cdf8edce1f7c869a95a9b" },
{ url = "https://mirrors.aliyun.com/pypi/packages/ad/3e/50952af22b8e3e2d03f7e83f0e335851c6b484c3fd88586626fb1c2a34b3/websockets-17.4-cp312-cp312-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:4d2636a5b61c69e32db0e74b57073dd4a66f1ad195e9398c5f01bba41090deea" },
{ url = "https://mirrors.aliyun.com/pypi/packages/c4/73/2a4a5d9c6bca1127f24af7bf08f406a69052d7f341bc81f08d9e8eb446b4/websockets-17.4-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:cfbbba4597f19ad717f79fd3f2a67ae7efae647bd6a61e14554e1b5ad242a5bf" },
{ url = "https://mirrors.aliyun.com/pypi/packages/68/de/90d96a579839bfe541ef214315df81d2bd519d952847c303328518ffdd02/websockets-17.4-cp312-cp312-musllinux_1_2_armv7l.whl", hash = "sha256:c7b996c02de5e032cb63dc65482b73693b7ecaa586654126be2749ddea239c40" },
{ url = "https://mirrors.aliyun.com/pypi/packages/91/17/12c15ed446d842e40918cd16e79b56ee4422d6fbf210258cb8882f50bbd5/websockets-17.4-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:a920e99155d75d1b1c08172da8aaa7200e7b30871fb628d1631d7891a333e30e" },
{ url = "https://mirrors.aliyun.com/pypi/packages/9d/73/cb4c927e806a73a0377696e031ef3c0db409028cdb2373f96ee863e8df8e/websockets-17.4-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:8c00c5c49f80a588a2c4f99d519d2abed4ce26cdca11273041bc8b7e60af60de" },
{ url = "https://mirrors.aliyun.com/pypi/packages/33/b3/e682b3ea069933044f4bf4809eea0cd83e3a5bdbdff601d1777a9ae90795/websockets-17.4-cp312-cp312-musllinux_1_2_riscv64.whl", hash = "sha256:52c31d123f5adf14dec694c2a4036bf42c523df7cefc641d31cd05653de56e49" },
{ url = "https://mirrors.aliyun.com/pypi/packages/2d/e9/d039757260705e5a265a31c9fff36b0d4567b842ce2b54e5d14369f200bd/websockets-17.4-cp312-cp312-musllinux_1_2_s390x.whl", hash = "sha256:d0acd8191c0e5a61d1c27bfa33b6ec8431982299f5d71c02129aa4f16f182ad0" },
{ url = "https://mirrors.aliyun.com/pypi/packages/db/e7/cb9907fac6f9b28f93beded6efda2953960cd02b633d432acf3451590859/websockets-17.4-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:2a9cb5bbfc33b4ebd3c8d3714d6e09805437f60a14977774e4bd11b5ace46c23" },
{ url = "https://mirrors.aliyun.com/pypi/packages/39/99/85f6f4dd104a5d9a33a1ef272f501d0f2e8527ddf66be1b383d51f90ce56/websockets-17.4-cp312-cp312-win32.whl", hash = "sha256:c63c0d7832956d5f3bb77888b93c854569d13f806289ff75c43926d25c6e5fd2" },
{ url = "https://mirrors.aliyun.com/pypi/packages/59/31/d1636ba67ee9232a60033d90483e48686aa3856014e59110f29015f97bd2/websockets-17.4-cp312-cp312-win_amd64.whl", hash = "sha256:dde9cd67f18803949ebf96de8aba12b8ec5ee3115e34c75a2db85a3b0a6c20d5" },
{ url = "https://mirrors.aliyun.com/pypi/packages/23/aa/e3859d52188f041a5a05c9f3ac005a9c829723f521f0fe60e2c5f9c93bb9/websockets-17.4-cp312-cp312-win_arm64.whl", hash = "sha256:c634053459278cf31fb404ddb5ecd38124e4609e8b609166da621edc2d5796db" },
{ url = "https://mirrors.aliyun.com/pypi/packages/e9/a3/d8fbc72c5c0e78905caf2d6dcf806e532451e3f48e2a09a8ebe1de9ad412/websockets-17.4-pp312-pypy312_pp80-macosx_10_15_x86_64.whl", hash = "sha256:c7f66a53e9b7ec831abb15e3d9b6cee8f52d6a24cd0a374786bf46c3ec218bc6" },
{ url = "https://mirrors.aliyun.com/pypi/packages/d3/de/1bf313cd0f4662df4884a7602932cd13347090e59dd6047865eee2bb5aa5/websockets-17.4-pp312-pypy312_pp80-macosx_11_0_arm64.whl", hash = "sha256:4fb2db1f649b6464711846b5bb9c1611bd906ce939d9460cbd1fa419552cd6c3" },
{ url = "https://mirrors.aliyun.com/pypi/packages/30/e2/7912bd417511b54907853bd495aef2daee111062dbafd43d133a3f7253a7/websockets-17.4-pp312-pypy312_pp80-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:32110d954d9d0e51f36edb0396673bf4d35193a0a80ba7013bf7f7d58a33ca07" },
{ url = "https://mirrors.aliyun.com/pypi/packages/56/6f/2e8d5610f6184a2e1720bf8ce256402ed99ad30ea87c461fba5bc4d651d9/websockets-17.4-pp312-pypy312_pp80-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:88ba8a439b2bad97bb69c38db5bf0ec16a061ee834cf0f244089186ee803e899" },
{ url = "https://mirrors.aliyun.com/pypi/packages/29/3a/a05bc57eadcd7e8e072d917888128e6d22e1203984afb21a8da3198982fe/websockets-17.4-pp312-pypy312_pp80-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:868744c68e9342768888c7326604da2228c19bb6946aa46b5f9e1ac32ea8d40b" },
{ url = "https://mirrors.aliyun.com/pypi/packages/b2/49/eed86bfb8863093a82cbaa52c9159be1ce2374d5ace6fe1f8e8031567e7d/websockets-17.4-pp312-pypy312_pp80-win_amd64.whl", hash = "sha256:829bcaa90be8737c132d9515d6a466e8528e3b3d050d3f3466f36ea94d3beb48" },
{ url = "https://mirrors.aliyun.com/pypi/packages/eb/27/9db924cb0dbf22eade78d98fbae77790f9bf6bc729e6ab29aef9d68e4156/websockets-17.4-py3-none-any.whl", hash = "sha256:c6bd2c9781915592b209160d0f017d4c7c82ad53075e6b0c24d2a89299e7f9e9" },
]
+92
View File
@@ -0,0 +1,92 @@
import { expect, test } from "@playwright/test";
import path from "node:path";
import { fileURLToPath } from "node:url";
const evidenceDir = path.resolve(
path.dirname(fileURLToPath(import.meta.url)),
"../../../../docs/evidence/M01/ui",
);
test.describe("health three states", () => {
test("loading then success", async ({ page }) => {
await page.route("**/health", async (route) => {
await new Promise((resolve) => setTimeout(resolve, 800));
await route.fulfill({
status: 200,
contentType: "application/json",
body: JSON.stringify({
success: true,
data: { status: "ok", app: "watchman", version: "0.1.0" },
request_id: "pw-success",
}),
});
});
await page.goto("/");
await expect(page.getByTestId("health-loading")).toBeVisible();
await page.screenshot({
path: path.join(evidenceDir, "health-loading.png"),
fullPage: true,
});
await expect(page.getByTestId("health-success")).toBeVisible();
await expect(page.getByTestId("health-tag")).toContainText("健康检查成功");
await page.screenshot({
path: path.join(evidenceDir, "health-success.png"),
fullPage: true,
});
});
test("failure state", async ({ page }) => {
await page.route("**/health", async (route) => {
await route.fulfill({
status: 500,
contentType: "application/json",
body: JSON.stringify({
success: false,
error: {
code: 50000,
message: "Internal server error",
details: {},
retryable: true,
},
request_id: "pw-fail",
}),
});
});
await page.goto("/");
await expect(page.getByTestId("health-failure")).toBeVisible();
await expect(page.getByTestId("health-tag")).toContainText("健康检查失败");
await expect(page.getByTestId("health-failure")).toContainText("50000");
await page.screenshot({
path: path.join(evidenceDir, "health-failure.png"),
fullPage: true,
});
});
test("english locale via query override is readable", async ({ page }) => {
await page.addInitScript(() => {
window.localStorage.setItem("watchman.lang", "en");
});
await page.route("**/health", async (route) => {
await route.fulfill({
status: 200,
contentType: "application/json",
body: JSON.stringify({
success: true,
data: { status: "ok", app: "watchman", version: "0.1.0" },
request_id: "pw-en",
}),
});
});
await page.goto("/?lang=en");
await expect(page.getByTestId("health-tag")).toContainText("Health check succeeded");
await expect(page.getByTestId("health-success")).toBeVisible();
await page.screenshot({
path: path.join(evidenceDir, "health-success-en.png"),
fullPage: true,
});
});
});
+12
View File
@@ -0,0 +1,12 @@
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Watchman</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>
+10
View File
@@ -0,0 +1,10 @@
{
"appName": "Watchman",
"health": {
"loading": "Checking health",
"success": "Health check succeeded",
"failure": "Health check failed",
"successDetail": "Service available: {detail}",
"failureDetail": "Service unavailable: {detail}"
}
}
+8
View File
@@ -0,0 +1,8 @@
{
"codes": {
"40000": "Invalid parameters",
"41000": "Authentication failed",
"42000": "Permission denied",
"50000": "Service error"
}
}
+10
View File
@@ -0,0 +1,10 @@
{
"appName": "Watchman",
"health": {
"loading": "กำลังตรวจสอบสถานะ",
"success": "ตรวจสอบสถานะสำเร็จ",
"failure": "ตรวจสอบสถานะล้มเหลว",
"successDetail": "บริการพร้อมใช้งาน: {detail}",
"failureDetail": "บริการไม่พร้อมใช้งาน: {detail}"
}
}
+8
View File
@@ -0,0 +1,8 @@
{
"codes": {
"40000": "พารามิเตอร์ไม่ถูกต้อง",
"41000": "ยืนยันตัวตนล้มเหลว",
"42000": "ไม่มีสิทธิ์",
"50000": "ข้อผิดพลาดของบริการ"
}
}
@@ -0,0 +1,10 @@
{
"appName": "Watchman",
"health": {
"loading": "健康检查加载中",
"success": "健康检查成功",
"failure": "健康检查失败",
"successDetail": "服务可用:{detail}",
"failureDetail": "服务不可用:{detail}"
}
}
@@ -0,0 +1,8 @@
{
"codes": {
"40000": "参数错误",
"41000": "认证失败",
"42000": "权限不足",
"50000": "服务错误"
}
}
@@ -0,0 +1,10 @@
{
"appName": "Watchman",
"health": {
"loading": "健康檢查載入中",
"success": "健康檢查成功",
"failure": "健康檢查失敗",
"successDetail": "服務可用:{detail}",
"failureDetail": "服務不可用:{detail}"
}
}
@@ -0,0 +1,8 @@
{
"codes": {
"40000": "參數錯誤",
"41000": "認證失敗",
"42000": "權限不足",
"50000": "服務錯誤"
}
}
+34
View File
@@ -0,0 +1,34 @@
{
"name": "@watchman/console",
"private": true,
"version": "0.1.0",
"type": "module",
"scripts": {
"dev": "vite --host 127.0.0.1 --port 5173",
"build": "vue-tsc -b && vite build",
"typecheck": "vue-tsc --noEmit",
"test:unit": "vitest run",
"test:e2e": "playwright test",
"preview": "vite preview --host 127.0.0.1 --port 5173"
},
"dependencies": {
"@watchman/api": "workspace:*",
"element-plus": "^2.11.0",
"pinia": "^3.0.3",
"vue": "^3.5.22",
"vue-i18n": "^11.1.11",
"vue-router": "^4.5.1"
},
"devDependencies": {
"@playwright/test": "^1.65.1",
"@tailwindcss/vite": "^4.3.5",
"@vitejs/plugin-vue": "^6.0.1",
"@vue/test-utils": "^2.4.6",
"jsdom": "^26.1.0",
"tailwindcss": "^4.3.5",
"typescript": "~5.9.3",
"vite": "^7.1.7",
"vitest": "^3.2.4",
"vue-tsc": "^3.0.8"
}
}
+29
View File
@@ -0,0 +1,29 @@
import { defineConfig, devices } from "@playwright/test";
const evidenceDir = "../../../../docs/evidence/M01/ui";
export default defineConfig({
testDir: "./e2e",
fullyParallel: false,
forbidOnly: !!process.env.CI,
retries: 0,
reporter: [["list"], ["html", { open: "never", outputFolder: "playwright-report" }]],
use: {
baseURL: "http://127.0.0.1:5173",
trace: "on-first-retry",
locale: "zh-CN",
},
projects: [
{
name: "chromium",
use: { ...devices["Desktop Chrome"] },
},
],
webServer: {
command: "pnpm exec vite --host 127.0.0.1 --port 5173",
url: "http://127.0.0.1:5173",
reuseExistingServer: true,
timeout: 120_000,
},
outputDir: evidenceDir + "/test-results",
});
+123
View File
@@ -0,0 +1,123 @@
import { flushPromises, mount } from "@vue/test-utils";
import { beforeEach, describe, expect, it, vi } from "vitest";
import { createI18n } from "vue-i18n";
import { BusinessError } from "@watchman/api";
import App from "./App.vue";
import zhCN from "../locales/zh-CN/common.json";
import en from "../locales/en/common.json";
vi.mock("@watchman/api", async () => {
const actual = await vi.importActual<typeof import("@watchman/api")>("@watchman/api");
return {
...actual,
requestJson: vi.fn(),
};
});
import { requestJson } from "@watchman/api";
const mockedRequestJson = vi.mocked(requestJson);
function mountApp(locale = "zh-CN") {
const i18n = createI18n({
legacy: false,
locale,
fallbackLocale: "zh-CN",
messages: {
"zh-CN": zhCN,
en,
// Intentionally omit th to prove fallbackLocale=zh-CN.
},
});
return mount(App, {
global: {
plugins: [i18n],
stubs: {
ElConfigProvider: { template: "<div><slot /></div>" },
ElCard: {
template:
'<div class="el-card"><div class="el-card__header"><slot name="header" /></div><slot /></div>',
},
ElTag: {
props: ["type"],
template: '<span data-testid="health-tag"><slot /></span>',
},
ElAlert: {
props: ["title", "type"],
template:
'<div :data-testid="type === \'success\' ? \'health-success\' : \'health-failure\'">{{ title }}</div>',
},
},
},
});
}
describe("App health three states", () => {
beforeEach(() => {
mockedRequestJson.mockReset();
});
it("shows loading before the request settles", async () => {
let resolveRequest: (value: unknown) => void = () => undefined;
mockedRequestJson.mockImplementation(
() =>
new Promise((resolve) => {
resolveRequest = resolve;
}),
);
const wrapper = mountApp();
expect(wrapper.get("[data-testid=health-loading]").text()).toContain("健康检查加载中");
resolveRequest({ status: "ok", app: "watchman", version: "0.1.0" });
await flushPromises();
});
it("shows success after a healthy response", async () => {
mockedRequestJson.mockResolvedValue({
status: "ok",
app: "watchman",
version: "0.1.0",
});
const wrapper = mountApp();
await flushPromises();
expect(wrapper.get("[data-testid=health-tag]").text()).toContain("健康检查成功");
expect(wrapper.get("[data-testid=health-success]").text()).toContain("watchman 0.1.0");
});
it("shows failure after a BusinessError", async () => {
mockedRequestJson.mockRejectedValue(
new BusinessError({
code: 50000,
message: "Internal server error",
status: 500,
requestId: "req-fail",
}),
);
const wrapper = mountApp();
await flushPromises();
expect(wrapper.get("[data-testid=health-tag]").text()).toContain("健康检查失败");
expect(wrapper.get("[data-testid=health-failure]").text()).toContain("50000");
});
it("falls back to zh-CN when locale messages are missing", async () => {
mockedRequestJson.mockResolvedValue({
status: "ok",
app: "watchman",
version: "0.1.0",
});
const wrapper = mountApp("th");
await flushPromises();
expect(wrapper.get("[data-testid=health-tag]").text()).toContain("健康检查成功");
});
it("shows english health copy when locale is en", async () => {
mockedRequestJson.mockResolvedValue({
status: "ok",
app: "watchman",
version: "0.1.0",
});
const wrapper = mountApp("en");
await flushPromises();
expect(wrapper.get("[data-testid=health-tag]").text()).toContain("Health check succeeded");
expect(wrapper.get("[data-testid=health-success]").text()).toContain("Service available");
});
});
+90
View File
@@ -0,0 +1,90 @@
<script setup lang="ts">
import { computed, onMounted, ref } from "vue";
import { useI18n } from "vue-i18n";
import { ElAlert, ElCard, ElConfigProvider, ElTag } from "element-plus";
import zhCn from "element-plus/es/locale/lang/zh-cn";
import zhTw from "element-plus/es/locale/lang/zh-tw";
import en from "element-plus/es/locale/lang/en";
import th from "element-plus/es/locale/lang/th";
import { requestJson } from "@watchman/api";
import {
healthFailureView,
healthSuccessView,
type HealthPayload,
type HealthState,
} from "./health";
const { t, locale } = useI18n();
const elementLocale = computed(() => {
switch (locale.value) {
case "zh-TW":
return zhTw;
case "en":
return en;
case "th":
return th;
default:
return zhCn;
}
});
const state = ref<HealthState>("loading");
const detail = ref("");
onMounted(async () => {
try {
const data = await requestJson<HealthPayload>("/health");
const view = healthSuccessView(data);
state.value = view.state;
detail.value = view.detail;
} catch (error) {
const view = healthFailureView(error);
state.value = view.state;
detail.value = view.detail;
}
});
</script>
<template>
<ElConfigProvider :locale="elementLocale">
<main class="min-h-screen p-8 bg-[var(--bg-surface-soft)] text-[length:var(--font-size-base)] text-[var(--text-primary)]">
<ElCard>
<template #header>
<div class="flex items-center justify-between gap-4">
<span>{{ t("appName") }}</span>
<span data-testid="health-tag">
<ElTag
:type="state === 'loading' ? 'info' : state === 'success' ? 'success' : 'danger'"
>
{{
state === "loading"
? t("health.loading")
: state === "success"
? t("health.success")
: t("health.failure")
}}
</ElTag>
</span>
</div>
</template>
<ElAlert
v-if="state === 'success'"
type="success"
data-testid="health-success"
:title="t('health.successDetail', { detail })"
show-icon
:closable="false"
/>
<ElAlert
v-else-if="state === 'failure'"
type="error"
data-testid="health-failure"
:title="t('health.failureDetail', { detail })"
show-icon
:closable="false"
/>
<p v-else data-testid="health-loading">{{ t("health.loading") }}</p>
</ElCard>
</main>
</ElConfigProvider>
</template>
+39
View File
@@ -0,0 +1,39 @@
import { describe, expect, it } from "vitest";
import { BusinessError } from "@watchman/api";
import { healthFailureView, healthSuccessView } from "./health";
describe("health view mapping", () => {
it("maps success payload", () => {
const view = healthSuccessView({
status: "ok",
app: "watchman",
version: "0.1.0",
});
expect(view).toEqual({
state: "success",
detail: "watchman 0.1.0",
});
});
it("maps BusinessError failure", () => {
const view = healthFailureView(
new BusinessError({
code: 50000,
message: "Service error",
status: 500,
requestId: "req-1",
}),
);
expect(view.state).toBe("failure");
expect(view.detail).toContain("50000");
expect(view.detail).toContain("Service error");
});
it("maps unknown failure", () => {
const view = healthFailureView(new Error("network down"));
expect(view).toEqual({
state: "failure",
detail: "Error: network down",
});
});
});
+39
View File
@@ -0,0 +1,39 @@
/**
* Health check presentation helpers for the M01 thin shell.
* Keeps fetch outcome mapping testable without mounting Element Plus.
*/
import { BusinessError } from "@watchman/api";
export type HealthState = "loading" | "success" | "failure";
export type HealthView = {
state: HealthState;
detail: string;
};
export type HealthPayload = {
status: string;
app: string;
version: string;
};
export function healthSuccessView(data: HealthPayload): HealthView {
return {
state: "success",
detail: `${data.app} ${data.version}`,
};
}
export function healthFailureView(error: unknown): HealthView {
if (error instanceof BusinessError) {
return {
state: "failure",
detail: `${error.code}: ${error.message}`,
};
}
return {
state: "failure",
detail: String(error),
};
}
+38
View File
@@ -0,0 +1,38 @@
import { createI18n } from "vue-i18n";
import zhCN from "../locales/zh-CN/common.json";
import zhTW from "../locales/zh-TW/common.json";
import en from "../locales/en/common.json";
import th from "../locales/th/common.json";
import zhCNErrors from "../locales/zh-CN/errors.json";
import zhTWErrors from "../locales/zh-TW/errors.json";
import enErrors from "../locales/en/errors.json";
import thErrors from "../locales/th/errors.json";
const supported = new Set(["zh-CN", "zh-TW", "en", "th"]);
function resolveLocale(): string {
if (typeof window !== "undefined") {
const fromQuery = new URLSearchParams(window.location.search).get("lang");
if (fromQuery && supported.has(fromQuery)) {
window.localStorage.setItem("watchman.lang", fromQuery);
return fromQuery;
}
const stored = window.localStorage.getItem("watchman.lang");
if (stored && supported.has(stored)) {
return stored;
}
}
return "zh-CN";
}
export const i18n = createI18n({
legacy: false,
locale: resolveLocale(),
fallbackLocale: "zh-CN",
messages: {
"zh-CN": { ...zhCN, ...zhCNErrors },
"zh-TW": { ...zhTW, ...zhTWErrors },
en: { ...en, ...enErrors },
th: { ...th, ...thErrors },
},
});
+12
View File
@@ -0,0 +1,12 @@
import { createApp } from "vue";
import { createPinia } from "pinia";
import "element-plus/dist/index.css";
import "element-plus/theme-chalk/dark/css-vars.css";
import "./styles.css";
import App from "./App.vue";
import { i18n } from "./i18n";
const app = createApp(App);
app.use(createPinia());
app.use(i18n);
app.mount("#app");
@@ -0,0 +1,24 @@
/* Map Element Plus skin vars to web/design/tokens.css (standards://frontend/element-plus). */
:root,
html.dark {
--el-color-primary: var(--color-primary);
--el-font-size-base: var(--font-size-base);
--el-font-size-small: 13px;
--el-font-size-extra-small: 12px;
--el-text-color-primary: var(--text-primary);
--el-text-color-regular: var(--text-secondary);
--el-text-color-secondary: var(--text-muted);
--el-border-color: var(--border-default);
--el-border-color-light: var(--border-subtle);
--el-border-color-lighter: var(--border-subtle);
--el-bg-color: var(--bg-surface);
--el-fill-color-light: var(--bg-surface-soft);
--el-border-radius-base: var(--radius-control);
--el-component-size: 32px;
}
/* Tailwind preflight sets svg { display:block }; keep Element button icons inline. */
.el-button svg {
display: inline-block;
vertical-align: middle;
}
+3
View File
@@ -0,0 +1,3 @@
@import "tailwindcss";
@import "../../../design/tokens.css";
@import "./shared/styles/element-theme.css";
+12
View File
@@ -0,0 +1,12 @@
/// <reference types="vite/client" />
declare module "*.vue" {
import type { DefineComponent } from "vue";
const component: DefineComponent<Record<string, unknown>, Record<string, unknown>, unknown>;
export default component;
}
declare module "*.json" {
const value: Record<string, unknown>;
export default value;
}
+19
View File
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"target": "ES2022",
"useDefineForClassFields": true,
"module": "ESNext",
"lib": ["ES2022", "DOM", "DOM.Iterable"],
"skipLibCheck": true,
"moduleResolution": "Bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "preserve",
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src/**/*.ts", "src/**/*.vue"]
}
+15
View File
@@ -0,0 +1,15 @@
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import tailwindcss from "@tailwindcss/vite";
export default defineConfig({
plugins: [vue(), tailwindcss()],
server: {
host: "127.0.0.1",
port: 5173,
proxy: {
"/health": "http://127.0.0.1:8000",
"/platform": "http://127.0.0.1:8000",
},
},
});
+10
View File
@@ -0,0 +1,10 @@
import { defineConfig } from "vitest/config";
import vue from "@vitejs/plugin-vue";
export default defineConfig({
plugins: [vue()],
test: {
environment: "jsdom",
include: ["src/**/*.spec.ts"],
},
});
+12
View File
@@ -0,0 +1,12 @@
:root {
--color-primary: #5e6ad2;
--text-primary: #1f2328;
--text-secondary: #59636e;
--text-muted: #8b949e;
--bg-surface: #ffffff;
--bg-surface-soft: #f6f8fa;
--border-default: #d0d7de;
--border-subtle: #eaeef2;
--radius-control: 8px;
--font-size-base: 13.5px;
}
+13
View File
@@ -0,0 +1,13 @@
{
"name": "watchman-web",
"private": true,
"packageManager": "pnpm@12.21.0",
"scripts": {
"dev": "pnpm --filter @watchman/console dev",
"build": "pnpm -r build",
"typecheck": "pnpm -r typecheck"
},
"devDependencies": {
"typescript": "~5.9.3"
}
}
+16
View File
@@ -0,0 +1,16 @@
{
"name": "@watchman/api",
"private": true,
"version": "0.1.0",
"type": "module",
"exports": {
".": "./src/index.ts"
},
"scripts": {
"typecheck": "tsc --noEmit",
"build": "tsc --noEmit"
},
"devDependencies": {
"typescript": "~5.9.3"
}
}
+93
View File
@@ -0,0 +1,93 @@
/**
* Shared JSON API client.
* Parses the company success/error envelope and throws BusinessError on failure.
*/
export type ApiSuccess<T> = {
success: true;
data: T;
request_id: string;
};
export type ApiFailure = {
success: false;
error: {
code: number;
message: string;
details?: Record<string, unknown>;
retryable?: boolean;
permission_node?: string;
};
request_id: string;
};
export class BusinessError extends Error {
readonly code: number;
readonly details: Record<string, unknown>;
readonly status: number;
readonly requestId: string;
readonly retryable: boolean;
constructor(args: {
code: number;
message: string;
details?: Record<string, unknown>;
status: number;
requestId: string;
retryable?: boolean;
}) {
super(args.message);
this.name = "BusinessError";
this.code = args.code;
this.details = args.details ?? {};
this.status = args.status;
this.requestId = args.requestId;
this.retryable = args.retryable ?? false;
}
}
function requestIdFrom(response: Response): string {
return response.headers.get("X-Request-Id") ?? "unknown";
}
export async function requestJson<T>(
input: string,
init: RequestInit = {},
): Promise<T> {
const headers = new Headers(init.headers);
if (!headers.has("Accept")) {
headers.set("Accept", "application/json");
}
const response = await fetch(input, { ...init, headers });
let body: ApiSuccess<T> | ApiFailure;
try {
body = (await response.json()) as ApiSuccess<T> | ApiFailure;
} catch {
throw new BusinessError({
code: 50000,
message: "Invalid API envelope",
status: response.status,
requestId: requestIdFrom(response),
retryable: true,
});
}
if (!body || typeof body !== "object" || !("success" in body)) {
throw new BusinessError({
code: 50000,
message: "Invalid API envelope",
status: response.status,
requestId: requestIdFrom(response),
});
}
if (body.success) {
return body.data;
}
throw new BusinessError({
code: body.error.code,
message: body.error.message,
details: body.error.details,
status: response.status,
requestId: body.request_id,
retryable: body.error.retryable,
});
}
+12
View File
@@ -0,0 +1,12 @@
{
"compilerOptions": {
"target": "ES2022",
"module": "ESNext",
"moduleResolution": "Bundler",
"strict": true,
"skipLibCheck": true,
"noEmit": true,
"lib": ["ES2022", "DOM"]
},
"include": ["src"]
}
+11
View File
@@ -0,0 +1,11 @@
{
"name": "@watchman/ui-components",
"private": true,
"version": "0.1.0",
"description": "Placeholder package for shared Element Plus wrappers. Empty in M01 thin shell.",
"type": "module",
"scripts": {
"typecheck": "node -e \"process.exit(0)\"",
"build": "node -e \"process.exit(0)\""
}
}
+2677
View File
File diff suppressed because it is too large. Load diff
+5
View File
@@ -0,0 +1,5 @@
packages:
- "apps/*"
- "packages/*"
allowBuilds:
esbuild: true