Skip to content

Commit 009807b

Browse files
Sodawyxclaude
andcommitted
docs(runtime): add bilingual YAML field reference, sample, CI gate notes
Three documentation gaps surfaced while landing the PR4-6 runtime work: 1. The YAML schema chapter in docs/{en,zh}/runtime.md only pointed at an external design doc (projects/.../runtime-cli-design.md), which is useless to end users reading the published reference. 2. There was no copy-pasteable starter spec to pair with `ar runtime apply`. 3. AGENTS.md only mentioned `make lint`; the actual CI gate also runs ruff format --check, mypy, and the 95%-coverage pytest job — local contributors had no signal that those were blocking. Changes: - docs/{en,zh}/runtime-yaml.md (new): field-level reference covering every key the parser accepts. Sections for metadata, container, registryConfig, resources, protocol, network, healthCheck, log, env, nas, ossMount, endpoints/scaling; CLI auto-injection rules (system_tags, artifact_type, default endpoint); exhaustive validation table mirroring agentruntime_yaml.py; runnable minimal / production (ACREE + private network + NAS + canary) / custom-registry examples; YAML -> SDK field map. EN/ZH mirrored 1:1 per AGENTS.md doc parity. diskSize is documented as MB (not GB, which the design doc had wrong). - docs/{en,zh}/runtime.md: replace the external design-doc pointer with a link to runtime-yaml.md. - docs/{en,zh}/index.md: add the YAML reference next to runtime.md in the command-groups table. - agentruntime.yaml (new, repo root): runnable starter spec mirroring superagent.yaml's placement. Renders cleanly via `ar runtime render -f agentruntime.yaml`. Commented-out blocks point at the common optional knobs (VPC, SLS log, scaling). - AGENTS.md: - "CI Lint Gate" section listing all four blocking checks (ruff check, ruff format --check, mypy, pytest --cov-fail-under=95) with the local commands and Make targets that reproduce CI. - Commands block updated with make format-check, `mypy src/agentrun_cli`, and `make coverage`. - Docs layout diagram updated to include runtime.md / runtime-yaml.md. Signed-off-by: Sodawyx <sodawyx@126.com> Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Signed-off-by: Sodawyx <sodawyx@126.com>
1 parent 9e2a966 commit 009807b

8 files changed

Lines changed: 957 additions & 6 deletions

File tree

AGENTS.md

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,12 @@ make dev # Create venv + install editable with dev deps
1414
make install # Install without dev deps
1515

1616
# Development
17-
make lint # Run ruff linter
17+
make lint # Run ruff linter (ruff check)
18+
make format-check # Verify code is ruff-formatted (no rewrite)
19+
.venv/bin/ruff format src/ tests/ # Apply ruff formatting in place
20+
.venv/bin/mypy src/agentrun_cli # Static type check (CI runs this verbatim)
1821
make test # Run all tests
22+
make coverage # Run tests with the >=95% coverage gate (matches CI)
1923
.venv/bin/pytest tests/test_cli_basic.py -v # Run a single test file
2024
.venv/bin/pytest tests/test_cli_basic.py::TestConfigCommands::test_set_and_get -v # Single test
2125

@@ -41,6 +45,42 @@ make build-all # macOS + Linux (via Docker)
4145

4246
**Error handling** (`_utils/error.py`): The `@handle_errors` decorator catches SDK exceptions by class name pattern (no hard import) and maps them to deterministic exit codes (0=success, 1=not found, 2=bad input, 3=auth, 4=server). Errors go to stderr as JSON.
4347

48+
## CI Lint Gate (must pass locally before pushing)
49+
50+
The GitHub Actions `CI` workflow (`.github/workflows/ci.yml`) blocks merges on
51+
**all four** of these checks, run in dedicated jobs against Python 3.10–3.13.
52+
Run them locally before pushing — failing any one of them produces a red PR.
53+
54+
| CI job | Command (run from repo root) | Make target |
55+
|---|---|---|
56+
| Lint (ruff) — lint rules | `ruff check src/ tests/` | `make lint` |
57+
| Lint (ruff) — format check | `ruff format --check src/ tests/` | `make format-check` |
58+
| Type check (mypy) | `mypy src/agentrun_cli` | *(no make target — run directly)* |
59+
| Test + coverage | `pytest tests/unit tests/integration --cov=agentrun_cli --cov-fail-under=95` | `make coverage` |
60+
61+
Rules:
62+
63+
- **Ruff format is non-negotiable.** CI runs `ruff format --check`, not
64+
`ruff format` — it will not auto-fix. Run `ruff format src/ tests/` locally
65+
(or `make format-check` to verify) before every commit. Configuration lives
66+
in `pyproject.toml` under `[tool.ruff]`.
67+
- **Mypy must stay green.** Mypy config is in `pyproject.toml` under
68+
`[tool.mypy]` (`python_version = "3.10"`, `warn_unreachable = true`,
69+
`ignore_missing_imports = true`). Prefer narrowing types (`cast`, explicit
70+
annotations) over `# type: ignore`; suppressions need a `[code]` selector
71+
and a one-line comment justifying them.
72+
- **Coverage threshold is 95%.** Every code change must keep incremental
73+
coverage at or above 95% — `make coverage` enforces it. A Claude Code hook
74+
(`.claude/settings.json`) also runs this automatically after edits to
75+
`src/` files. See [Integration Test Requirement](#integration-test-requirement)
76+
for the test-coverage rules that feed this gate.
77+
- **No `--no-verify` / `--no-gpg-sign` shortcuts.** If a hook or lint check
78+
fails, fix the underlying issue and create a new commit.
79+
80+
The CI workflow also runs a Smoke job on macOS + Windows (`make build` of the
81+
PyInstaller binary) and a `pip-audit` security scan — both are advisory but
82+
should not regress.
83+
4484
## Testing
4585

4686
Tests use `click.testing.CliRunner` and `unittest.mock.patch` to swap `CONFIG_FILE`/`CONFIG_DIR` with `tmp_path` fixtures, so no real `~/.agentrun/` is touched. Model commands that hit the SDK are not tested in the basic suite — they require credentials.
@@ -83,6 +123,8 @@ docs/
83123
│ ├── index.md # install / auth / global options / output / exit codes / group nav
84124
│ ├── config.md # one file per command group
85125
│ ├── model.md
126+
│ ├── runtime.md
127+
│ ├── runtime-yaml.md # detailed YAML field reference for `ar runtime apply`
86128
│ ├── sandbox.md
87129
│ ├── skill.md
88130
│ ├── super-agent.md

agentruntime.yaml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Sample AgentRuntime spec for `ar runtime apply -f agentruntime.yaml`.
2+
# Full field reference: docs/en/runtime-yaml.md (zh: docs/zh/runtime-yaml.md)
3+
#
4+
# Quick usage:
5+
# ar runtime render -f agentruntime.yaml # dry-run, prints SDK input
6+
# ar runtime apply -f agentruntime.yaml # create-or-update, waits to READY
7+
#
8+
# The CLI auto-injects system_tags=["x-agentrun-cli"] and artifact_type=Container.
9+
# When spec.endpoints is omitted, a default endpoint (targetVersion=LATEST) is
10+
# also injected — this sample defines an explicit one to make the shape clear.
11+
12+
apiVersion: agentrun/v1
13+
kind: AgentRuntime
14+
15+
metadata:
16+
name: my-agent # required, matches [a-z0-9-]{1,63}
17+
description: "Example AgentRuntime"
18+
# workspace: default # optional; mutually exclusive with workspaceId
19+
20+
spec:
21+
container:
22+
image: registry.cn-hangzhou.aliyuncs.com/my-ns/my-agent:v1
23+
# command: ["python", "app.py"] # optional, overrides image CMD/ENTRYPOINT
24+
# port: 9000 # optional; spec.port below also works
25+
26+
# ───── resources ─────
27+
cpu: 2 # default 2 cores
28+
memory: 4096 # default 4096 MB
29+
# diskSize: 10240 # optional, MB (10 GiB)
30+
31+
# ───── network (default PUBLIC; uncomment for VPC) ─────
32+
# network:
33+
# mode: PUBLIC_AND_PRIVATE
34+
# vpcId: vpc-xxxxxxxx
35+
# vswitchIds: [vsw-xxxxxxxx]
36+
# securityGroupId: sg-xxxxxxxx
37+
38+
# ───── log to SLS (project + logstore must be set together) ─────
39+
# log:
40+
# project: my-agent-logs
41+
# logstore: runtime
42+
43+
# ───── environment variables ─────
44+
env:
45+
LOG_LEVEL: info
46+
47+
# ───── endpoints (omit to auto-inject `default` / LATEST) ─────
48+
endpoints:
49+
- name: default
50+
targetVersion: LATEST
51+
# scaling:
52+
# minInstances: 1

docs/en/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,5 +199,5 @@ Errors are written to stderr as JSON:
199199
| `sandbox` | `sb` | Sandboxes plus file, process, context, template and browser sub-groups | [sandbox.md](./sandbox.md) |
200200
| `tool` | | MCP and FunctionCall tools + sub-tool invocation | [tool.md](./tool.md) |
201201
| `skill` | | Platform skill packages + local scan/load/exec | [skill.md](./skill.md) |
202-
| `runtime` | `rt` | Declarative Agent Runtime deploy (container mode) | [runtime.md](./runtime.md) |
202+
| `runtime` | `rt` | Declarative Agent Runtime deploy (container mode) | [runtime.md](./runtime.md) · [YAML reference](./runtime-yaml.md) |
203203
| `super-agent` | `sa` | Quickstart REPL, declarative deploy, CRUD, conversations | [super-agent.md](./super-agent.md) |

0 commit comments

Comments
 (0)