diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 14421f6b..aebba61e 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -38,6 +38,8 @@ Closes # - [ ] This branch is based on the current main - [ ] I ran the repository's gates and recorded the results in Verified - [ ] Each commit is one coherent change +- [ ] AI helped write this change +- [ ] No AI was used for this change - [ ] If I changed code, `just fmt`, `just lint` and `just test-ci` pass - [ ] If this changes held-packet handling, `just test-netns` passes using the disposable VM gate - [ ] If this touches a CONTRIBUTING.md §2 area, the change is human-originated or the §11 domain-expert exception applies diff --git a/.github/scripts/template-check.sh b/.github/scripts/template-check.sh index 66dde08d..bed031c3 100755 --- a/.github/scripts/template-check.sh +++ b/.github/scripts/template-check.sh @@ -9,11 +9,13 @@ understand='I understand this change and answer for every line' main='This branch is based on the current main' gates="I ran the repository's gates and recorded the results in Verified" commits='Each commit is one coherent change' +ai_yes='AI helped write this change' +ai_no='No AI was used for this change' check_body() { jq -Rs --arg kind "$1" --arg search "$search" --arg trap "$trap_box" \ --arg agent "$agent_box" --arg understand "$understand" --arg main "$main" \ - --arg gates "$gates" --arg commits "$commits" ' + --arg gates "$gates" --arg commits "$commits" --arg ai_yes "$ai_yes" --arg ai_no "$ai_no" ' def trim: gsub("^\\s+|\\s+$"; ""); def boxes($text): [split("\n")[] | capture("^\\s*[-*] \\[(?[ x])\\] " + $text + "(?:\\s*/[^\\n]*)?\\s*$"; "i") | .mark | ascii_downcase]; @@ -35,6 +37,8 @@ check_body() { {test: ($kind == "pr" and ([$understand, $main, $gates, $commits] | any(. as $box | $body | kept($box) | not))), en: "Keep and check all four unconditional PR boxes.", zh: "请保留并勾选 PR 的四项必选选项。"}, + {test: ($kind == "pr" and (checked($ai_yes) == checked($ai_no))), + en: "Check exactly one of the two AI boxes.", zh: "请在两个 AI 选项中勾选一项,且只能勾选一项。"}, {test: ($kind == "issue" and (kept($search) | not)), en: "Keep and check the existing-issue search box.", zh: "请保留并勾选“我已搜索过现有 issue”。"} ] | map(select(.test) | {en, zh}) end' diff --git a/AGENTS.md b/AGENTS.md index 027f8c23..3b1cb229 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -204,7 +204,7 @@ size observations are historical, not a maintained target allowlist. - **Comment discipline (feat/analyze-dns): readable code; comments explain "why", never "what".** Allow module `//!` purpose/non-obvious architecture, public-item `///`, and short rationale/invariant/wire-format/upstream-parity/past-bug comments. Narrating/restating code is a defect. Ordinary logic should have near-zero comments (see `crates/honk-core/src/dns/runtime.rs`); prefer descriptive names/small functions. **Before closing each work phase, review touched comments and delete/rewrite stale behavior descriptions**; stale comments are defects. - **Commits:** `type(scope): one short imperative line` — `feat|fix|refactor|perf|test|docs|style|bench()`, no body, no markdown. Each commit stands alone and leaves the tree building; multi-part work is more commits, and fixups are squashed before pushing rather than pushed. - **Changelog:** a PR touching `crates/`, `Cargo.toml`, `Cargo.lock`, `ci/fetch-doona.sh` or `.github/ci/pins.env` adds `changes/.md`; format and exemptions are in [changes/README.md](changes/README.md). CI fails without it unless a maintainer applies the `no-changelog` label. -- **PR bodies:** English or Simplified Chinese, one short paragraph under each of `## Problem / 问题`, `## How I fixed it / 解决方法` and `## Verified / 验证`, in that order: what is wrong, what changed, what was checked. Follow the single bilingual `.github/pull_request_template.md` and link long evidence; do not paste it. Start the pull request body from that template, also when you open it with `gh pr create --body` or the API, which do not fill it in. Keep its checklist and check only true boxes. For an outside contributor, `template-check` closes a pull request that drops a required box or checks the unread or AI-agent box, and reopens it once the body is fixed. +- **PR bodies:** English or Simplified Chinese, one short paragraph under each of `## Problem / 问题`, `## How I fixed it / 解决方法` and `## Verified / 验证`, in that order: what is wrong, what changed, what was checked. Follow the single bilingual `.github/pull_request_template.md` and link long evidence; do not paste it. Start the pull request body from that template, also when you open it with `gh pr create --body` or the API, which do not fill it in. Keep its checklist and check only true boxes. For an outside contributor, `template-check` closes a pull request that drops a required box, does not check exactly one of the two AI boxes, or checks the unread or AI-agent box, and reopens it once the body is fixed. - Prefer `anyhow::Result` for application/binary code and `thiserror` for library error types. - Use `tracing` macros for logging; prefer structured fields (`info!(network = "tcp", outbound = %name, ...)`). Levels follow frequency × actionability: ERROR only when configured function is lost until an operator acts (committed-degraded activation, process exit, permanent subsystem death, invariant breach); WARN once per entered degraded state (fallback, ceiling, node/group unavailable, rejected candidate with the old config intact); INFO for low-rate lifecycle, operator outcomes and recovery; DEBUG for single connection/request/query outcomes and periodic maintenance. Log a failure once, at the layer that owns its stats/Score/recovery; repeat a persisting state at DEBUG, not per tick. A failure that repeats per query with no episode boundary (DNS SERVFAIL, singleflight saturation) uses `logging::warn_throttled!`: WARN at most every 10 s per site. Native `/api/v1/logs`, Clash `/logs` and the console all receive these levels. - Use `tokio` async/await and `tokio::select!` for long-lived loops. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 86423570..cf505c71 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -42,7 +42,7 @@ LLM-generated code is welcome in: **Conditions (all mandatory):** 1. **Pre-arranged.** The change fits an agreed division of labor, not a drive-by PR. -2. **Disclosed.** The PR description must state which files/areas are LLM-generated (see §5). Undisclosed LLM authorship is grounds for closing. +2. **Disclosed.** The PR description states whether AI was used (see §5). Undisclosed AI use is grounds for closing. 3. **Tested.** Any LLM-created production-adjacent code (fixtures, mocks that other tests depend on) must itself be exercised by CI. Benchmarks must carry their contract assertions in-tree. 4. **Human-reviewed.** A human maintainer has read the diff. LLM review never substitutes for human review or self-review. 5. **Invariants respected.** LLM-created code must obey every contract in `AGENTS.md` (e.g. never call `clear_routes` on the push path; generation-bound ownership; no new lock edges). Reviewers should assume the generator generalized the contract imperfectly and check the seams. @@ -57,9 +57,9 @@ LLM-generated code is welcome in: ## 5. Responsibility for AI-assisted work -AI may help with writing, analysis and review. Before submitting, the submitter must have read and tested everything, understand every line, and answer for it. No per-file AI disclosure is required. +AI may help with writing, analysis and review. Before submitting, the submitter must have read and tested everything, understand every line, and answer for it. State in the pull request whether AI helped write it; which files it wrote need not be listed. -Start the pull request body from `.github/pull_request_template.md`, also when you open it with `gh pr create --body` or the API, which do not fill it in. Keep its checklist and check only true boxes. For an outside contributor, `template-check` closes a pull request that drops a required box or checks the unread or AI-agent box, and reopens it once the body is fixed. +Start the pull request body from `.github/pull_request_template.md`, also when you open it with `gh pr create --body` or the API, which do not fill it in. Keep its checklist and check only true boxes. For an outside contributor, `template-check` closes a pull request that drops a required box, does not check exactly one of the two AI boxes, or checks the unread or AI-agent box, and reopens it once the body is fixed. ## 6. Adversarial deep review