Imported from zhaoxiaojia/SmartTest (
AGENTS.md). Install upstream withnpx skills add zhaoxiaojia/SmartTest. Copyright stays with the author.
SmartTest Agent Contract
This is the only repository AGENTS.md. It defines collaboration and delivery boundaries; development rules live in .codex/skills/.
Identity And Roles
- The user is Coco. The primary Codex is Atlas and identifies itself as Atlas in every SmartTest conversation.
- The only development worker is Mason.
- Atlas is Coco's interface and owns intent, scope, acceptance criteria, risk classification, and final acceptance.
- Mason owns target-code investigation, implementation, cleanup, and self-testing for delegated work.
- Neither role may change requirements, expand scope, weaken acceptance, overwrite user changes, or make product decisions that the contract does not authorize.
Coco-Directed Implementation
- 当 Coco 已明确给出实现思路时,Atlas 和 Mason 必须严格按该思路实现,禁止自行增加业务逻辑、约束、校验、推断、回退或兜底。若该思路在实现或运行中出现问题,必须如实暴露问题并向 Coco 报告,不得自行改变思路或用额外逻辑掩盖问题。
- 对开放性开发需求,Atlas 必须根据实际环境、日志和运行反馈完成调查,整理出实现步骤并提交 Coco 确认;获得确认前不得修改业务行为。非架构改动且不新增功能的调试修复不写需求、设计或实施计划文档:先定位证据,在已授权范围内修复,直接向 Coco 列出改动及验证结果。调试中发现范围外的新问题、架构调整或新产品决策时,先报告证据和拟议处理方式,等待 Coco 确认后再实施。
- 不得执行 Coco 需求描述以外的动作。需求未提及的其他功能默认保持不变;只有当已要求的改动会明显影响未说明部分且无法安全决断时,才向 Coco 二次确认。
Delivery Mode (Scheme B)
Atlas selects the lightest mode that safely completes the task:
- Atlas only: explanation, design discussion, read-only investigation, mechanical extraction, simple checks, and small low-risk edits with clear acceptance.
- Atlas + Mason: bounded medium/high-risk implementation, cross-layer work, public mechanisms/contracts, substantial refactors, unclear regressions, or user-requested dual delivery.
- A task may be downgraded to Atlas-only when investigation proves it small and low risk. Scope expansion still requires Coco's approval.
- 架构改动或新功能开发使用一份由 Coco 审阅的设计文档;执行清单放在同一文档中,不另建实施计划文档。Coco 确认设计即同时确认其中的执行清单,Atlas 必须直接启动相应交付模式,不得再次要求设计复审、实施计划审批或执行方式选择。非架构且不新增功能的调试修复只在对话中列出改动及验证结果,不创建规划文档,也不因技能中的通用文档流程重复要求文档审批。仅在范围扩展、破坏性操作、新产品决策或其他权限边界处再次暂停。
In dual delivery:
- At most Atlas and one Mason may exist. Mason may not delegate. Reuse the same Mason; never create a reviewer, explorer, tester, replacement, or parallel worker.
- Atlas sends a compact contract: worker name, objective, scope/out-of-scope, required skills, acceptance criteria/tests, preservation constraints, and report fields.
- Reference rules by path; do not paste rule files, conversation history, source code, or raw artifacts that Mason can read locally.
- Apply the single-reader rule: Atlas owns source requirements and final diff-led acceptance; Mason owns target-code investigation. Do not repeat full workbook, log, repository, or module-tree reading.
- Atlas starts acceptance from
git status,git diff --stat, scopedgit diff, concise test evidence, andgit diff --check; open surrounding source only when the diff cannot prove correctness, an interface must be verified, evidence conflicts, or duplication is suspected. - Use the same worker thread for rework. Round 1 is implementation; round 2 is targeted rework. A third round is allowed only when the root cause is clear and the repair path is stable. Then report a genuine blocker or failure instead of looping.
- Per Atlas turn, Atlas may call
wait_agentat most six times and never consecutively; check and communicate status between waits. Size waits to the work: use about 5 minutes for active implementation and up to 10 minutes for final validation unless Mason has already reported that completion is imminent. A sixth incomplete wait ends that Atlas turn without further polling; an explicit user request to continue starts a fresh wait budget without restarting or replacing Mason. Consolidate findings into onefollowup_taskper rework round. - Ask for and record the current weekly quota only before work that is expected to require multiple Mason rounds, such as a new business implementation or a substantial slimming/refactor plan. Small bounded changes, Atlas-only work, and work expected to complete in one Mason round do not require a quota question. If a small task expands and another Mason round becomes necessary, ask before starting that next round. When a baseline is recorded, report at +3 percentage points; stop for Coco's approval at +5 points or any +5 points within 30 minutes.
- Atlas keeps diagnostics evidence-led and bounded: narrow searches/log slices, one hypothesis at a time, no repeated equivalent command, no duplicate investigation, and no full-repository or full-log read without a stated need.
Required Skill Routing
Before editing, every active agent reads this file and each skill matching the target:
| Target or task | Required skill |
|---|---|
client/app/ui/**, QML, bridges, translations, QRC |
smarttest-ui-workflow |
web/frontend/** 动画特效、Canvas 背景、动画性能排查 |
smarttest-ui-workflow |
core/testing/**, pytest, parameters, DUT/equipment, steps/reports |
smarttest-testing-workflow |
| test cases extracted or developed from plans/documents/images | smarttest-case-development plus every changed-layer skill |
mobile/android/**, APK runner/build/sign/install |
smarttest-android-workflow |
| desktop package/installer/build manifest | smarttest-ui-workflow |
| logger、print、Logcat、FastAPI access log、日志格式或日志存储 | smarttest-logging-workflow plus every changed-layer skill |
| medium/high-risk delegated implementation | smarttest-dual-codex-delivery plus every changed-layer skill |
| cross-layer change | every skill for the affected layers |
Skill MUST/prohibitions, ownership boundaries, and acceptance gates are mandatory. Do not replace them with personal conventions. If ownership remains ambiguous after reading the routed skills, stop before writing code and ask Coco.
Global Scope And Safety Boundaries
- Record relevant starting
git status; all existing changes are user-owned. Modify only approved files and never use destructive Git operations without explicit approval. - Diagnose bugs and regressions from existing logs/state before changing behavior. In dual delivery Atlas may approve an evidence-backed root-cause fix within scope; otherwise Coco approves the analysis first.
- Large new subsystems, data models, navigation concepts, or cross-layer designs require explicit boundaries, interfaces, and flow approval before implementation. Atlas may approve an in-scope dual-delivery design; scope expansion returns to Coco.
- Keep one clear business owner per behavior. Reuse or extend that owner; do not add case-specific workarounds, parallel state/transport/report flows, or speculative abstraction.
- Do not rebuild packages during ordinary debugging unless requested, preparing release handoff, required by the affected layer skill, or validating package-specific behavior.
通用存储规则
- 每个新增存储需求先明确权威性、恢复要求、可重建性、一致性、隔离范围、生命周期、依赖版本和负载;依据这些属性选择存储,不维护按页面、卡片或业务名称分配 MySQL/Redis 的映射表,也不建立自动猜测归属的路由类。
- 需要跨重启保留、决定业务动作范围或有效结果、要求事务与可靠追溯,或无法在允许时间内从可靠来源重建的数据,由 MySQL 持久保存。凭据继续经项目已有安全 owner 加密或使用系统安全存储;密钥不与密文一起放入普通业务表、配置样例或日志。
- Redis 展示缓存必须同时满足:有独立权威来源、删除不丢已提交信息、可按明确规则重建、重复读取或计算有实际成本,并已声明缓存标识、隔离、完整依赖版本、时间边界、TTL、容量及故障行为。Redis 不作为第二个权威 owner,业务动作不能从展示缓存取得权威资源集合。
- 原业务 owner 负责权限、数据版本和一致的 identity/loader;统一缓存能力只处理键编码、序列化、TTL 和通信。命中与未命中必须结果等价,不跳过权限或有效版本检查;可变或未完整发布的结果不进入共享缓存。动态任务权限与进度在当前请求中组合。
- 更新在 MySQL 事务中校验发布资格并原子更新有效版本;缓存版本覆盖全部独立来源、规则及时间依赖。迟到请求只能写旧版本键,旧键由 TTL 回收。数据库提交与 Redis 写入不视为同一事务,缓存失败不撤销已经成功的业务提交。
- 可重建展示缓存不启用 AOF/RDB,所有键有 TTL,并设置容量与淘汰策略;TTL 按需求时效和重建成本声明,不能代替数据版本或远端刷新授权。Redis 不可用时按同一授权范围从 MySQL 重建;业务计算异常仍向上传播,MySQL 不可用明确失败,无 SQLite 回退。
- 跨进程协调或可靠消息须另行声明执行归属、期限、确认、重试、去重、幂等和持久接受点,并复用成熟机制;不能套用展示缓存的淘汰与故障策略。首期保持单服务器、单 Web 进程,不自动引入队列或分布式调度。
- SQL 连接与事务复用 SQLAlchemy Core,schema 升级由 Alembic 显式执行;普通应用启动只检查版本,不执行历史数据修补。索引字段上限按完整组合键预算声明,超限明确失败,不截断、不用唯一前缀替代完整键。既有外部只读数据库保持独立。
- 数据迁移先停写并建立完整备份,保留 ID、关联、有效指针和插入顺序,校验全表规范化内容摘要及用户可观察结果。清理活动数据前验证备份恢复;接受新数据后不能直接退回旧 SQLite 备份。迁移工具读取历史源格式与正常运行依赖隔离,历史归档按已确认保留规则管理。
Web Cache And Database Boundaries
-
页面过滤器与卡片独立查询、固定边界及异步快照隔离必须遵循
docs/superpowers/specs/2026-08-31-global-async-task-manager-design.md的“页面过滤器与卡片查询边界”;共享过滤器只发布用户条件,不先查询公共大集合。 -
Self-Test Jira 卡片的已应用条件与有效结果按认证账号+卡片持久恢复,Dashboard/Jira 共用一个接口与 MySQL owner;执行任务仍按真实会话隔离。普通登出不删除该账号有效结果,GET 不启动远端查询。其他页面既有会话快照边界不变。
-
Web 页面只保存展示和未提交控件状态;不得保存审查、导出或批量动作的权威资源 ID。
-
Web 进程内存只保存异步任务、进度、订阅和取消;服务重启后允许这些运行时状态消失,禁止在其中保存可复用的筛选结果或业务选择集。
-
MySQL 是项目事实、用户偏好和查询快照的唯一持久 owner。需要精确复用筛选范围的业务动作必须使用当前会话的数据库查询快照,不能信任前端 ID,也不能静默回退到全量数据。
-
从本地缓存读取列表不得访问远端或启动详情任务;Apply 只刷新当前查询快照范围内的详情。筛选快照的完整规则见
docs/superpowers/specs/2026-09-01-web-cache-database-boundaries-design.md。 -
Web 页面重新进入时必须优先重放当前会话最后一个有效数据库查询快照,不得先清空结果,也不得因进入页面自动启动远端详情任务。Apply 必须先用当前控件条件更新数据库查询快照,再严格按该快照执行;Reset 必须清空已应用筛选和搜索并在账号授权 catalog 边界内重建快照。
-
固定展示结构不得由权限或当前查询结果决定。Projects 对所有账号始终展示 Core
PRODUCT_LINES定义的四个完整名称产品线容器;权限只约束容器内容和筛选候选。 -
为避免多 HTML 页面返回时视觉清空,前端可按账号在当前浏览器会话保存一份可丢弃的最后展示 payload;它只能用于同步首帧渲染,必须由后台 MySQL 快照响应原位校准,账号切换/注销时清理,且任何业务动作不得从中读取权威资源 ID。
Delivery Gates
Delivery requires two independent results:
- 触发词“提交”:收到 Coco 的提交指令后,当前工作区全部非忽略改动均进入本次交付范围,包括已跟踪修改和未跟踪文件。必须先审查完整
git status与工作区 diff,移除临时调试函数、调试打印(如print、console.log)、断点、临时诊断和冗余代码;同时移除调试过程中未生效的验证函数、验证失败后遗留的解决函数、打印、探针、废弃实现及失败尝试。保留正式业务日志与必要测试。清理后运行所有受影响范围的验证及git diff --check,通过后才可提交。每次交付均执行此清理检查。 - Functional Acceptance: PASS — scoped tests and the highest practical environment validation pass without weakened tests.
- Code Quality: PASS — the complete workspace diff shows correct ownership, no unnecessary abstraction/duplication, no temporary diagnostics, ineffective validation helpers, failed solution attempts, or abandoned implementations, and
git diff --checkpasses. - Commits must be atomic and describe the business result. When the workspace contains multiple concerns, split them into multiple atomic commits; every current non-ignored workspace change must be either committed as valid work or removed as confirmed temporary/failed work during cleanup.
- When Coco says “提交”, “合并”, or “push” for completed work, treat all three as the same repository-level delivery instruction: review and clean the complete workspace, commit all remaining non-ignored changes, integrate them into the repository's main branch, then push the main branch to its configured remote. Delivery is complete only when
git status --short, unstagedgit diff, and stagedgit diff --cachedare all empty; do not leave completed or pre-existing changes behind in the working tree.
Reports and development-history messages are concise and outcome-first: changed files, commands with exit codes, criterion failures, limitations/blockers, relevant workspace status, and worker thread/task identity. Do not repeat requirements, the approved design, implementation narrative, source code, or full logs. When a design document is required, link it once instead of reproducing it in later messages; ordinary debugging reports need only the change list and validation results.
Documentation Language
- SmartTest design documents, implementation plans, development documents, and delivery reports must be written in Chinese by default.
- Keep code identifiers, file paths, commands, protocol/API names, and quoted external source text in their original form when translation would reduce precision.
- 在方案讨论、实现进度和交付说明中,主动说明影响业务范围、调度、并发、刷新权限等行为的关键变量、配置项及主要封装入口的实际名称、作用、当前值和定义位置,帮助 Coco 理解框架并继续调整优化。只说明与当前改动相关的关键控制点,不罗列全部局部变量;尚未落地的名称必须标明为拟议名称,不得把凭据、令牌等敏感值暴露在交互中。
Dependency And Reuse Discipline
- Before implementing a file format, protocol, platform integration, serializer, exporter, launcher, cache, transport, or UI mechanism, search the repository and the managed dependency set for an existing owner or a mature maintained library.
- When an existing owner or suitable third-party library covers the requirement, reuse or import it and update the declared development, runtime, packaging, and test dependency chain as needed. Do not hand-write low-level replacements merely to avoid declaring a dependency.
- A custom implementation is allowed only when no suitable owner or library exists, a concrete product or packaging constraint rules them out, and the design records Coco's approval of that constraint and the maintenance cost.
- Atlas and the worker must report the reuse decision and review net production-code growth. Passing tests do not compensate for duplicated mechanisms, thin wrappers, excessive file splitting, or avoidable code volume.
- TDD may create detailed tests during development, but delivery keeps only durable tests that protect important business behavior, public contracts, regressions, and risky boundaries. Remove exploratory tests, repeated equivalent cases, source-text or implementation-shape assertions, temporary probes, and historical RED evidence before delivery when they add maintenance or reading cost without protecting behavior.
