Development Standards
For repository responsibilities and rules for agents, see Repository and Agent Rules.
Git Branches
1. Main Branch
- Branch name:
main - Description: stores stable code. All features should be stable and runnable.
- Rules:
force pushand directpushare not allowed. It accepts only pull requests fromdev, not pull requests from development branches.
2. Main Development Branch
- Branch name:
dev - Description: stores the latest feature code. It only guarantees that the project can run.
- Rules: maintainers may maintain
devdirectly according to permission. External contributors should create development branches from upstreamdevand merge through Pull Requests toAUTO-MAS-Project/AUTO-MAS:dev. Larger features should use development branches and be merged after testing.
3. Release Branch
Branch name:
release/{version}Description: stores the latest backend code for each release. It is created automatically by the release workflow. Each released app pulls the latest backend code from its corresponding release branch to support hot updates for some features and fixes.
Rules: after submitting feature updates or fixes to
dev, synchronize changes to release branches throughcherry-pick.Cherry-pick rules: AUTO-MAS separates its frontend and backend, and released apps hot-update backend code from the
release/{version}branch, while the frontend ships inside the installer and cannot be hot-updated through that branch. Only smalldevfixes that are pure backend (unrelated to any frontend code) may be cherry-picked to an already releasedrelease/{version}branch. Cherry-picking a commit that carries frontend logic is a violation.Handle a violation as follows, with no exemption for the change being otherwise correct:
- Close the related PR.
- Revert the related commit.
- If the violating commit has already shipped in a release, roll the released code back and explain the situation to users.
Judge by the files the commit actually touches, not by the
typeorscopein its message: a commit that touches both frontend paths (such asfrontend/) and backend paths (such asapp/) carries frontend logic and must not be cherry-picked to a release branch.
4. Development Branch
- Branch name: any name that does not conflict with other branches or tags
- Description: used by core developers to store features in development. It may not run. After development is complete, it is merged into
dev. - Rules: delete the branch after development and merge are complete.
Git Commit Messages
Git commits use the Conventional Commits standard:
<type>(<scope>): <subject>1. type
| Type | Description |
|---|---|
| feat | New feature |
| fix | Bug fix |
| docs | Documentation changes, such as README |
| style | Code style changes that do not affect logic, such as spacing or indentation |
| refactor | Refactoring that is neither a feature nor a fix |
| perf | Performance optimization |
| test | Add or modify tests |
| chore | Build process or dependency management changes |
| build | Changes affecting the build system or external dependencies |
| ci | CI/CD configuration changes |
2. scope
Only one file is modified
Use the modified file name without extension, preserving case.
Example: when modifying
logger.py, useloggertextfix(logger): adjust logger level
Multiple files are modified
Prefer the common parent folder name of the modified files. If multiple directories are involved, choose the business scope that best represents the intent of the change. Do not mechanically concatenate unrelated directories into the scope.
Example: when modifying
app/api/a.pyandapp/api/b.py, useapitextfix(api): adjust api module
3. subject
Use one sentence to summarize the change. Detailed changes may be written after a blank line.
feat(core): improve database connection module
- Optimize connection pool initialization
- Reduce startup time by about 30%
- Fix a possible connection leakTest Submission and Maintenance
Automated tests are reviewable evidence for code changes. Deterministic, isolated tests that protect user-visible behavior or public contracts should live in the same repository and pull request as the change, and remain maintained with the product code.
Test Categories
- Long-lived automated tests: Put deterministic, isolated, repeatable unit, contract, and regression tests in the appropriate test directory or near the code under test, and submit them with the implementation they cover. Prefer assertions on user-visible behavior or public contracts over private call order and internal data layout.
- Author-local real flows: Run flows that require real accounts, games, script installations, or emulators in the author's environment, following
docs/testing/e2e.mdin the main repository. Include the command and reviewed, sanitized evidence in the PR. Do not submit credentials, account data, game assets, or machine-specific configuration. - Temporary diagnostics: Keep one-off probes and scripts local or in an ignored
.dev/directory. Add a diagnostic tool toscripts/only when it has clear repeated-use value.
PR Verification Record
- Record the test command, pass/fail result, tested commit SHA, environment, and uncovered areas. For real flows, also record required preconditions and selected evidence.
- When a bug has a stable reproduction, its regression test should fail before the fix, pass after the fix, and remain in the PR. If it cannot be reproduced reliably or automated, explain why and provide alternative verification; a pass count from an unsubmitted test is not enough.
- When no automated test is added or changed, explain why and provide alternative verification. Documentation, CI, and test-maintenance changes may mark testing as not applicable.
Revising, Removing, and Quarantining Tests
- Update relevant expectations when behavior or a public contract changes. When deleting a test, explain whether the behavior was removed, stronger coverage replaces it, the test was redundant, or its reliability cannot be maintained at reasonable cost; describe replacement coverage where applicable.
- Track flaky tests with an issue, an owner, and a review date, then quarantine them temporarily. They must later be fixed, replaced, or removed. Do not use automatic retries to hide failures or leave quarantines and
xfailmarkers without ownership and review dates. - Maintain tests using failure rate, diagnosis cost, and runtime. Test line count, file count, and the ratio of test code to product code are not quality gates; investigate slow tests and shared setup when runtime grows.
Local and CI Commands
pytest is a main-repository development dependency. Run tests in the locked environment:
uv sync --locked --group dev
uv run --no-sync python -m pytest tests/<path> -q
uv run --no-sync python -m pytest tests -qPRs targeting dev run the full pytest suite on Windows and Ubuntu. A full run includes test collection, so a separate --collect-only merge gate is unnecessary. Real game, account, and emulator flows continue to follow the author-local E2E policy and stay out of pytest CI.
Version Records
A PR with user-visible changes adds one fragment under changelog.d/: <PR number or branch>.<category>.md. Put project: <key> on the first line (optional only for dev fragments), followed by one user-facing line of at most 50 characters. Use python scripts/changelog.py add <category> <project> "<summary>" or write the file directly. Describe the observable change without a project prefix, PR number, attribution, or implementation details.
Pure documentation, CI, tests, and internal refactors use the skip-changelog PR label. For a feature first introduced in the current release cycle, changes within the same beta need no fragment; changes across betas use beta-only: true and are omitted from the stable summary. See the fragment guide for project keys, categories, attribution, and exceptions.
The nightly workflow (23:30 Beijing time) compiles merged fragments into the Unreleased section of CHANGELOG.md. Release preparation also compiles remaining fragments. Ordinary PRs do not edit CHANGELOG.md, res/version.json, or version numbers; the release PR sets the version.
Backend Comments
Overview
Backend comments should follow Google Python Style Guide - Docstring Conventions, also called Google Docstring.
Method Comments
def add_numbers(a: int, b: int) -> int:
"""Add two numbers and return their sum.
Args:
a: The first number.
b: The second number.
Returns:
The sum of the numbers.
Raises:
ValueError: The input arguments are not integers.
"""
if not all(isinstance(x, int) for x in (a, b)):
raise ValueError("arguments must be integers.")
return a + bConfiguration Class Comments
Configuration objects inherit from ConfigEntry, and semantic field blocks inherit from ConfigGroup. Type annotations define field types, while Field describes defaults, constraints, and Chinese descriptions. Use default_factory so groups and lists are independent for each instance.
from typing import Literal
from pydantic import Field
from app.config import ConfigEntry, ConfigGroup
class GlobalConfig(ConfigEntry):
"""Example declaration of global configuration."""
class FunctionFields(ConfigGroup):
HistoryRetentionTime: Literal[7, 15, 30, 60, 90, 180, 365, 0] = Field(
default=0, description="History retention in days; 0 means no cleanup"
)
IfAllowSleep: bool = Field(default=False, description="Whether sleep is allowed")
IfSilence: bool = Field(default=False, description="Whether silent mode is enabled")
class NotifyFields(ConfigGroup):
IfSendStatistic: bool = Field(default=False, description="Whether to send runtime results")
Function: FunctionFields = Field(default_factory=FunctionFields)
Notify: NotifyFields = Field(default_factory=NotifyFields)Configuration fields and their validation rules are declared once in the configuration model. API input and output contracts are derived from that model. Runtime private state is not persisted. See Configuration Framework for field types and calling conventions.
Backend Function Calls
Overview
Use positional arguments only when the meaning is obvious at a glance. Otherwise, use keyword arguments. Boolean and multi-argument calls must use keyword arguments.
To improve readability, reduce misuse, and improve collaboration efficiency, follow these function-call rules:
1. Simple functions with clear meaning -> use positional arguments
When there are few parameters, usually no more than two, and the meaning is clear, positional arguments are acceptable.
Example:
add(1, 2)
math.sqrt(4)2. Less obvious, many-parameter, or easily confused functions -> use keyword arguments
Keyword arguments improve readability, do not rely on positional order, and are safer.
Example:
UserItem(user_id=str(uid), name=config.get("Info", "Name"), status="waiting")3. All boolean parameters must use keyword arguments
Avoid unreadable calls.
Not recommended:
send_notification(True, False)Recommended:
send_notification(enable=True, urgent=False)4. When there are more than two arguments, prefer keyword arguments
This improves maintainability and reduces the risk of order mistakes.
Example:
connect(host="localhost", port=3306, timeout=5)