docs: update agent rules and add latest e2e reports
Some checks failed
CI / build_test_package (push) Has been cancelled
CI / auto_merge (push) Has been cancelled

This commit is contained in:
Your Name
2026-03-23 19:32:24 +08:00
parent 8d0f590264
commit e5b0f65156
5 changed files with 421 additions and 87 deletions

View File

@@ -1,47 +1,43 @@
# Repository Guidelines
# 蚊子项目智能体执行规则
## Project Structure & Module Organization
- Spring Boot 3 (Java 17) Maven app.
- Key paths:
- `src/main/java` — root package `com.mosquito.project` (modules: `controller`, `service`, `domain`, `dto`, `job`, `exception`).
- `src/main/resources` — app config (`application.properties`), Flyway migrations in `db/migration`.
- `src/test/java` — JUnit 5 tests mirroring `main` packages.
- `docs/`, `specs/` — documentation and specifications.
- `target/` — build outputs (generated).
## 1. 项目事实(必须遵守)
- 后端:Spring Boot 3 + Java 17 + Maven
- 目标数据库方言PostgreSQL统一标准不再按 MySQL 语义新增迁移)。
- 数据库变更:仅通过 Flyway 脚本(`src/main/resources/db/migration`)。
- Flyway 历史迁移修复策略:仅限“未发布环境”允许直接改历史迁移;已发布环境必须新增补丁迁移。
## Build, Test, and Development Commands
- Build: `mvn clean package` — compile, test, and create JAR in `target/`.
- Run (dev): `mvn spring-boot:run` — start app with live reload of resources.
- Run (JAR): `java -jar target/mosquito-0.0.1-SNAPSHOT.jar`.
- Test all: `mvn test`.
- Test one: `mvn -Dtest=ActivityServiceTest test`.
- Verify: `mvn verify` — full lifecycle checks.
## 2. 仓库结构与整洁规则
- 根目录只保留入口文件与工程配置,阶段性报告统一放到 `docs/reports/<category>/`
- 运行日志统一在 `logs/`,历史日志归档到 `logs/archive/<tag>/`
- 禁止测试报告/截图回流到仓库根目录(通过 `.gitignore` + CI 门禁控制)。
- 构建与测试产物(如 `target/``frontend/*/dist``frontend/e2e/*results*`)默认视为可清理对象。
## Coding Style & Naming Conventions
- Java 17; 4-space indentation; one class per file; braces on same line.
- Packages: lowercase under `com.mosquito.project`.
- Classes: `PascalCase`; methods/fields: `camelCase`; constants: `UPPER_SNAKE_CASE`.
- DTOs end with `Request`/`Response`; exceptions end with `Exception`.
- Use Lombok where present (e.g., `@Getter`, `@Builder`); avoid wildcard imports.
- Validate inputs with Bean Validation annotations (e.g., `@NotNull`, `@Size`).
## 3. CI 与验证规则
- 在宣称“完成/通过”前,至少执行项目已有验证脚本或等效命令并记录结果。
- 当前核心链路:
- `./scripts/ci/logs-health-check.sh`(非阻断健康检查)
- `./scripts/ci/clean-artifacts.sh --include-build-outputs --fail-on-found`(阻断污染回流)
- `./scripts/ci/backend-verify.sh`
- `./scripts/ci/assert-migration-not-skipped.sh`
- 归档维护命令:
- `npm run logs:archive:check`
- `npm run logs:archive:apply`
- `npm run logs:archive:index`
## Testing Guidelines
- Frameworks: JUnit 5, Spring Boot Test, WebMvcTest/MockMvc; H2 and Embedded Redis for tests; Testcontainers available when needed.
- Location: `src/test/java` with names `*Test.java`; mirror package of code under test.
- Conventions: method names like `shouldDoX_whenY()`; prefer fast slice tests for controllers, `@SpringBootTest` for integration.
- Run: `mvn test` or a focused run via `-Dtest=...`.
## 4. 发布与分支策略Gitea
- 优先推送到开发分支(如 `task-1-exception-handling`)并走 PR 合并。
- `main` 若受保护,禁止强推覆盖;需要仓库管理员临时放开保护或通过 PR 合并。
- 用户要求“本地覆盖远端”时,先明确目标分支与保护策略,再执行提交/推送。
## Commit & Pull Request Guidelines
- Use Conventional Commits: `feat|fix|docs|test|refactor|chore(scope): message`.
- Example: `feat(activity): add graph endpoint with validation`.
- PRs: include purpose, linked issues, API examples or reproduction steps, updated tests/docs, and ensure `mvn -q verify` passes.
## Security & Configuration Tips
- App config in `src/main/resources/application.properties` (e.g., `spring.redis.host/port`); DB via `SPRING_DATASOURCE_*` env vars.
- Never commit secrets; prefer environment variables or an untracked `application-local.properties`.
- Database schema changes go through Flyway migrations in `src/main/resources/db/migration`.
## Agent-Specific Notes
- Keep changes minimal and localized; match the existing package layout.
- Avoid introducing new dependencies without discussion; update tests and docs with behavior changes.
## 5. 开发与修改原则
- 先读后改,最小化变更面,避免无关重构。
- 新增行为必须同步补充测试或最小验证步骤。
- 文档与代码必须同步更新尤其是脚本路径、报告路径、CI 命令。
- 默认优先“归档”而非“删除”;删除动作需用户明确确认。
## 6. 常用命令
- 全量验证:`./scripts/ci/backend-verify.sh`
- 工作区污染检查:`npm run clean:workspace:check`
- 工作区归档清理:`npm run clean:workspace:apply`
- 日志健康检查:`npm run logs:health:check`
- 日志归档索引刷新:`npm run logs:archive:index`