Files
unknownandCursor 252709709c feat(mappings): 完成 M05 字段映射与规则判断
映射和判断规则共用一个不可变版本,试算可以直接取已选查询的结果。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-19 10:03:45 +08:00

3.9 KiB
Raw Permalink Blame History

Task Context Pack

Task Goal

实现 M05:查询上的字段映射、可配置身份、结构化规则,以及正常/异常/未知试算。不创建报警。

Knowledge Posture

  • Mode: standard
  • Maturity: L1

Current Slice Or Group

S6 HTML 原型已给出。S7 未批准,须先确认原型。

Gate Policy

  • Recommended: strict
  • Selected: autonomous
  • finalApprovalRequired: true
  • Policy Notes: 配置默认是 balanced。用户指定 autonomous。该选择不取消分析确认、计划 critic、risk_score >= 4、原型确认和最终验收。

Bugfix Context

本任务不是缺陷修复。

Requirement Source

.task/2026-11-18/m05-mapping-rules/requirement.md

Implementation Source

.task/2026-11-18/m05-mapping-rules/implementation-plan.md

Involved Modules Or Areas

查询定义(只调用预览)、新建映射与规则、控制台新页面、管理员门禁。

Loaded Context

Global Rules

AGENTS.md 项目本地段要求一个会话聚焦 M05,主 Agent 不代替独立审查。公司规范篇目在写代码前按切片再查最新版本。

Knowledge Map Matches

产品范围指向 docs/progress.md、docs/decisions.md。控制台界面指向 docs/current/frontend-ui.md,只在 S7 读取。

Path-Proximity Rules

目标目录下没有另外的 MODULE_RULES.md。

Excluded Context

未读阶段 B/C 文档,未读 Cron 复用文档。那些属于 M08 及以后。

Loaded Rules

  • AGENTS.md
  • .cursor/rules/sy-standards.mdc
  • .cursor/rules/workflow-rules.mdc

Loaded Docs

  • docs/tasks/INDEX.md
  • docs/decisions.md(D27)
  • 需求冻结文档_V1.1_交接稿.md 第 5~6 章
  • .task/2026-11-18/m05-mapping-rules/boundary.md

Execution Mode

  • Mode: sequential
  • Current Slice Or Group: S6
  • Parallel Members: 无
  • Fallback Order: S1 到 S8
  • Shared Files: services/watchman/migrations、auth/access.py
  • Merge Owner: 主 Agent
  • Conflict Resolution Rule: 迁移和权限串行
  • Validation Level: slice

Execution Chain

计划确认 → 计划 critic → S1 → 审查 → 因 S2 为 risk 4 而停下。后续每片按计划里的 gateClass 和 risk_score 决定是否还要单独确认。

Allowed Modification Scope

确认 S1 之后,只允许计划中 S1 的路径。当前允许的写入只有任务文档。

Forbidden Modification Scope

报警、场景、Cron、企微、查询只读边界、原型确认前的 Vue、密钥文件。

Key Existing Classes Or Entrypoints

  • 查询:services/watchman/src/watchman/api/routes/queries.py、services/watchman/src/watchman/services/queries.py
  • 权限:services/watchman/src/watchman/auth/access.py 中的 watchman-admin 与 perm:data:emp:watchman.query.*
  • 控制台查询页:web/apps/console/src/queries/

Required Behavior

以 requirement.md 的 Business Rules 和 Acceptance Criteria 为准。结论用正常、异常、未知。不勾身份列时多行取第一行并提示跳过行数。

Non-goals

报警、场景、原因分析、脚本、SQL Server 试跑。

Implementation Steps

见实现计划。当前不执行。

Validation Commands

  • 后端:在 services/watchman 运行 uv run pytest
  • 迁移:alembic upgrade head
  • 前端:在 web/apps/console 运行 pnpm test:unit
  • UI 切片另加 Playwright。未跑的命令记为未运行。

Assumptions

与 requirement.md 的 Assumptions 相同。其中版本方式、嵌套深度 4、普通试算不落库,用户还没单独点名,但是按 D26 和“试算不产生报警”写下的。

Risks

第一行依赖结果顺序。身份修订不能变成新业务事件。权限点编码实现时再核对。

Stop Conditions

  • 用户尚未确认本计划。
  • S1 前的计划 critic 尚未通过。
  • S4 前显式停下,即使 S3 已通过。判定语义不自动开写。
  • S7 前必须有原型确认。
  • 权限点规范与项目先例冲突时停下。
  • 最终 DONE_LOCAL 需要用户确认。