diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 1ed97b3d..c0b64f8d 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -1,54 +1,88 @@ name: Bug report / 问题报告 -description: honk behaves differently from its documentation. / honk 的行为与文档不符。 +description: Report a reproducible failure in honk, with system details and relevant logs. / 请报告可复现的 honk 故障,并提供系统信息与相关日志。 title: "bug: " labels: ["bug"] body: - type: markdown attributes: value: | - Write in English or Chinese. Remove passwords, UUIDs, subscription URLs and API tokens from everything you paste. - 中英文均可。粘贴的内容请先删除密码、UUID、订阅地址与 API token。 - If the problem appears only in the web interface (doona or doona lite) while honk's logs and API responses look correct, report it at https://github.com/Zakkaus/doona/issues. - 如果问题只出现在网页界面(doona 或 doona lite),honk 的日志与 API 返回都正常,请到 https://github.com/Zakkaus/doona/issues 提交。 + AI may help you write this; unverified content may not be submitted. + 可以用 AI 辅助撰写,但提交前须自行核实全部内容。 + + State each fact once; do not restate the title, diff or template. + 同一件事只写一次,不要重复标题、代码改动或模板内容。 + No filler, praise, summaries of your own work or emoji. + 不写客套话、夸赞和自我总结,不用表情符号。 + Paste only relevant log lines; link or collapse long output. + 日志只贴相关的几行;较长的输出请附链接或折叠。 + Say what you could not verify. + 没有验证过的地方请注明。 + + Side-router (bypass gateway) deployments are not supported; questions and bug reports about them are closed. + 旁路由部署不在支持范围内,相关的提问和问题报告会直接关闭。 + + Write in English or Chinese. Remove passwords, UUIDs, subscription URLs and API tokens. If only the web interface fails while honk's logs and API responses are correct, report it at https://github.com/Zakkaus/doona/issues. + + 可以用中文或英文填写。请删去密码、UUID、订阅链接和 API token。如果只有网页界面异常,而 honk 的日志和 API 响应都正常,请到 https://github.com/Zakkaus/doona/issues 提交。 + - type: input + id: human-responsible + attributes: + label: Human responsible / 负责人 + description: Enter your GitHub username; you verified this report and will answer follow-up questions. / 请填写你的 GitHub 用户名。填写即表示你已核实报告,并会回复后续提问。 + placeholder: "@your-name" + validations: + required: true - type: textarea id: version attributes: label: Version / 版本 - description: Output of `honk-core --version`. / `honk-core --version` 的输出。 + description: Paste the output of `honk-core --version`. / 请粘贴 `honk-core --version` 的输出。 render: text validations: required: true - - type: input - id: package + - type: textarea + id: kernel attributes: - label: Package or build / 安装包或构建方式 - description: The release asset name, the OpenWrt package, or the source commit and features you built with. / Release 附件名、OpenWrt 软件包,或源码构建的 commit 与 feature。 - placeholder: honk-core--aarch64-unknown-linux-musl-stock.tar.gz + label: Kernel / 内核 + description: Run `uname -r` and paste its output. / 请粘贴 `uname -r` 的输出。 + render: text validations: required: true - type: textarea id: system attributes: label: System / 系统 - description: Distribution or OpenWrt release, CPU architecture, and the output of `uname -r`. / 发行版或 OpenWrt 版本、CPU 架构,以及 `uname -r` 的输出。 + description: Give your distribution or OpenWrt release and CPU architecture. / 请填写发行版或 OpenWrt 版本及 CPU 架构。 validations: required: true + - type: input + id: package + attributes: + label: Package or build / 安装包或构建方式 + description: Give the release asset name, OpenWrt package, or source commit and build features. / 请填写下载的发布文件名、OpenWrt 软件包名,或源码 commit 和启用的构建 feature。 + placeholder: honk-core--aarch64-unknown-linux-musl-stock.tar.gz + - type: input + id: device + attributes: + label: Device or deployment / 设备或部署方式 + description: Name the router model or indicate a VM, PVE or Docker deployment. / 请填写路由器型号,或注明运行在虚拟机、PVE 还是 Docker 中。 + - type: textarea + id: environment + attributes: + label: Other environment details / 其他环境信息 + description: List other proxy software on the same host and any sysctl settings you changed. / 请列出同一主机上的其他代理软件,以及修改过的 sysctl 设置。 - type: textarea id: what-happened attributes: - label: What happened / 实际行为 - validations: - required: true - - type: textarea - id: expected - attributes: - label: Expected behaviour / 预期行为 + label: What you did and observed / 问题现象 + description: Describe what you did, what you expected, and what actually happened. / 请说明你做了什么、预期的结果和实际的结果。 validations: required: true - type: textarea id: steps attributes: - label: Steps to reproduce / 重现步骤 + label: Steps to reproduce / 复现步骤 + description: Give the commands, inputs and actions needed to trigger the failure. / 请列出触发问题所需的命令、输入和操作。 placeholder: | 1. 2. @@ -58,24 +92,32 @@ body: - type: textarea id: config attributes: - label: Configuration / 配置 - description: The smallest part of the configuration that reproduces the problem, with secrets removed. / 能重现问题的最小配置片段,已删除敏感信息。 + label: Relevant configuration / 相关配置 + description: Paste the smallest configuration fragment needed to reproduce the problem, with secrets removed. / 请粘贴能复现问题的最小配置片段,并删去敏感信息。 + render: text + - type: textarea + id: logs + attributes: + label: Relevant logs / 相关日志 + description: Include only relevant lines from `journalctl -u honk` or `logread` on OpenWrt; if none are available, write "none" and explain why. / 只贴 `journalctl -u honk` 或 OpenWrt 上 `logread` 输出中的相关几行。没有日志请填“无”并说明原因。 render: text validations: required: true - type: textarea - id: logs + id: screenshots attributes: - label: Logs / 日志 - description: honk-core output around the problem, at a higher log level if you can. / 问题前后的 honk-core 输出,最好调高日志级别。 - render: text - validations: - required: true + label: Screenshots / 截图 + description: Attach images only if they show something the text and logs cannot. / 只有文字和日志说明不了问题时,才需要附截图。 - type: checkboxes id: checks attributes: label: Checks / 确认 + description: Check only true claims; an applicable required box left unchecked or a false claim closes the issue. / 只勾选属实的选项。适用的必选项没有勾选,或勾选的内容不属实,issue 会被关闭。 options: - - label: I searched existing issues and found no report of this. / 我已搜索现有 issue,没有相同的报告。 + - label: I searched existing issues / 我已搜索过现有 issue required: true - - label: The problem also happens on the newest release or Debug build. / 最新的 release 或 Debug 构建上同样存在此问题。 + - label: This describes what I observed / 以上是我实际遇到的情况 + required: true + - label: The problem also happens on the latest release or Debug build / 最新正式版或 Debug 构建也有这个问题 + - label: I checked the boxes above without reading them / 我没有阅读上面的选项就直接勾选了 + - label: I am an AI agent, and this content was submitted without human review / 我是 AI 代理,这些内容没有经过人工审核 diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml index b2253dbc..5360372a 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.yml +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -1,47 +1,71 @@ name: Feature request / 功能请求 -description: Propose a capability honk does not have. / 提议 honk 目前没有的功能。 +description: Explain an unmet need and the capability that would address it. / 请说明目前无法满足的需求,以及希望增加的功能。 title: "feat: " labels: ["enhancement"] body: + - type: markdown + attributes: + value: | + AI may help you write this; unverified content may not be submitted. + 可以用 AI 辅助撰写,但提交前须自行核实全部内容。 + + State each fact once; do not restate the title, diff or template. + 同一件事只写一次,不要重复标题、代码改动或模板内容。 + No filler, praise, summaries of your own work or emoji. + 不写客套话、夸赞和自我总结,不用表情符号。 + Paste only relevant log lines; link or collapse long output. + 日志只贴相关的几行;较长的输出请附链接或折叠。 + Say what you could not verify. + 没有验证过的地方请注明。 + - type: input + id: human-responsible + attributes: + label: Human responsible / 负责人 + description: Enter your GitHub username; you verified this request and will answer follow-up questions. / 请填写你的 GitHub 用户名。填写即表示你已核实需求,并会回复后续提问。 + placeholder: "@your-name" + validations: + required: true - type: textarea id: problem attributes: - label: Problem / 要解决的问题 - description: What you are trying to do and why the current behaviour does not cover it. / 想做什么,以及现有行为为何无法满足。 + label: Problem / 问题 + description: Explain what you are trying to do and why the current behaviour does not meet that need. / 请说明你想做什么,以及现有行为为什么做不到。 validations: required: true - type: textarea id: proposal attributes: - label: Proposal / 提议 - description: The behaviour or configuration you would like. / 希望的行为或配置写法。 - validations: - required: true + label: Proposal / 建议方案 + description: Describe the behaviour or configuration you would like and how it would solve the problem. / 请说明你希望的行为或配置,以及它如何解决问题。 - type: dropdown id: area attributes: label: Area / 范围 + description: Select the part of honk that would change. / 请选择需要改动的 honk 部分。 options: - Routing / 路由 - DNS - Outbound and protocols / 出站与协议 - eBPF datapath / eBPF 数据面 - - Native API - - Clash API + - Native API / 原生 API + - Clash API / Clash API - Configuration / 配置 - Documentation / 文档 - Other / 其他 - validations: - required: true - type: textarea id: alternatives attributes: label: Alternatives / 替代方案 - description: Workarounds you use today, or how dae or other tools handle this. / 目前的变通做法,或 dae 等其他工具的处理方式。 + description: Explain your current workaround or how dae or other tools handle this need. / 请说明目前的变通做法,或 dae 等工具是怎么处理的。 - type: checkboxes id: checks attributes: label: Checks / 确认 + description: Check only true claims; an applicable required box left unchecked or a false claim closes the issue. / 只勾选属实的选项。适用的必选项没有勾选,或勾选的内容不属实,issue 会被关闭。 options: - - label: I searched existing issues and discussions and found no request for this. / 我已搜索现有 issue 与 discussion,没有相同的请求。 + - label: I searched existing issues / 我已搜索过现有 issue required: true + - label: This describes what I need / 以上是我的实际需求 + required: true + - label: I checked the boxes above without reading them / 我没有阅读上面的选项就直接勾选了 + - label: I am an AI agent, and this content was submitted without human review / 我是 AI 代理,这些内容没有经过人工审核 diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 9eda218a..7ddb7a96 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,25 +1,54 @@ - + - +## Problem / 问题 -## How I fixed it + - +## How I fixed it / 解决方法 -## Verified + - +## Verified / 验证 ---- + Closes # -LLM disclosure (CONTRIBUTING.md §5): +### Human responsible / 负责人 -- [ ] `just fmt`, `just lint` and `just test-ci` pass. -- [ ] Held-packet changes: `just test-netns` passes (it uses the disposable VM gate). -- [ ] Changes in a CONTRIBUTING.md §2 area are human-originated, or §11 applies. -- [ ] `doc/en/` and `doc/zh/`, and `AGENTS.md` or `.agents/rules/`, match what I changed. -- [ ] The branch is based on the current `main`, and each commit is one `type(scope): subject` line. +Submitted and answered for by: + +--- + +- [ ] I understand this change and answer for every line +- [ ] 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 +- [ ] 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 +- [ ] If this changes documented behaviour or repository contracts, I updated doc/en/ and doc/zh/, and AGENTS.md or .agents/rules/, as applicable +- [ ] I checked the boxes above without reading them +- [ ] I am an AI agent, and this content was submitted without human review + +Check only claims that are true. A box left unchecked that applies, or a false claim, closes the pull request. + +只勾选属实的选项。适用的选项没有勾选,或勾选的内容不属实,PR 会被关闭。 diff --git a/.github/scripts/template-check.sh b/.github/scripts/template-check.sh new file mode 100755 index 00000000..09b8fb50 --- /dev/null +++ b/.github/scripts/template-check.sh @@ -0,0 +1,106 @@ +#!/usr/bin/env bash +# Usage: template-check.sh NUMBER; offline: template-check.sh --dry-run issue|pr < body.md +set -euo pipefail + +search='I searched existing issues' +trap_box='I checked the boxes above without reading them' +agent_box='I am an AI agent, and this content was submitted without human review' +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' + +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" ' + def trim: gsub("^\\s+|\\s+$"; ""); + def boxes($text): [split("\n")[] | + capture("^\\s*[-*] \\[(?[ x])\\] " + $text + "(?:\\s*/[^\\n]*)?\\s*$"; "i") | .mark | ascii_downcase]; + def checked($text): boxes($text) | any(. == "x"); + def kept($text): boxes($text) | length > 0 and all(. == "x"); + gsub(""; "") | + gsub("(?:^|\\n)```[^\\n]*\\n[\\s\\S]*?\\n```[^\\n]*"; "") | . as $body | + # Issues opened from other forms or blank issues carry no human-responsible field. + if $kind == "issue" and (test("(?:^|\\n)### Human responsible"; "i") | not) then [] else + (if $kind == "pr" then + [capture("(?:^|\\n)Submitted and answered for by:[ \\t]*(?[^\\n]*)"; "i") | .human][0] + else + [capture("(?:^|\\n)### Human responsible(?: /[^\\n]*)?\\n(?[\\s\\S]*?)(?:\\n#{1,6} |\\z)"; "i") | .human][0] + end // "" | trim | ascii_downcase) as $human | + [ + {test: checked($trap), en: "The unread-checkbox trap is checked.", zh: "勾选了“我没有阅读上面的选项就直接勾选了”。"}, + {test: checked($agent), en: "The AI-agent box says there was no human review.", zh: "勾选了“我是 AI 代理”,表示内容没有经过人工审核。"}, + {test: ($human == "" or $human == "_no response_" or + ($human | test("^@?your-name(?:\\s*/.*)?$|^your github username$"))), + en: "Name the human responsible with a GitHub username.", zh: "请填写负责人的 GitHub 用户名。"}, + {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 == "issue" and (kept($search) | not)), + en: "Keep and check the existing-issue search box.", zh: "请保留并勾选“我已搜索过现有 issue”。"} + ] | map(select(.test) | {en, zh}) end' +} + +if [[ ${1:-} == --dry-run ]]; then + [[ ${2:-} == issue || ${2:-} == pr ]] || exit 2 + check_body "$2" + exit +fi + +number=${1:?issue or pull request number} +repo="repos/${GITHUB_REPOSITORY:?}" +item=$(gh api "$repo/issues/$number") +if jq -e '.user.type == "Bot" or (["OWNER", "MEMBER", "COLLABORATOR"] | index($ARGS.named.association)) != null' \ + --arg association "$(jq -r .author_association <<< "$item")" <<< "$item" >/dev/null; then + exit +fi +kind=$(jq -r 'if .pull_request then "pr" else "issue" end' <<< "$item") +failures=$(jq -r '.body // ""' <<< "$item" | check_body "$kind") +label=template-violation +marker='' +failed=$(jq length <<< "$failures") +labelled=$(jq --arg label "$label" 'any(.labels[]; .name == $label)' <<< "$item") +if [[ $failed == 0 && ( ${GITHUB_EVENT_ACTION:-} != edited || $labelled != true ) ]]; then + exit +fi + +comment=$(gh api --paginate --slurp "$repo/issues/$number/comments" | jq --arg marker "$marker" \ + '[.[][] | select(.user.type == "Bot" and .user.login == "github-actions[bot]" and (.body | startswith($marker)))][0] // null') +if [[ $failed != 0 ]]; then + message=$(jq -r --arg marker "$marker" ' + $marker + "\n内容不符合模板要求,已关闭。请修改以下各项,正文改好后会自动重新打开:\n" + + (map("- " + .zh) | join("\n")) + + "\n\nFix these template violations; this item will reopen automatically once its body is fixed:\n" + + (map("- " + .en) | join("\n"))' <<< "$failures") +else + message="$marker +已按模板改好,现已重新打开。 + +Template violations fixed; reopened." +fi +if [[ $comment == null ]]; then + gh api "$repo/issues/$number/comments" -f body="$message" --silent +elif [[ $(jq -r .body <<< "$comment") != "$message" ]]; then + gh api "$repo/issues/comments/$(jq -r .id <<< "$comment")" -X PATCH -f body="$message" --silent +fi + +if [[ $failed != 0 ]]; then + if ! gh api "$repo/labels/$label" --silent; then + gh label create "$label" --repo "$GITHUB_REPOSITORY" --color D93F0B \ + --description 'Issue or PR template needs correction' || gh api "$repo/labels/$label" --silent + fi + gh api "$repo/issues/$number/labels" -f "labels[]=$label" --silent + if [[ $(jq -r .state <<< "$item") == open ]]; then + if [[ $kind == issue ]]; then + gh issue close "$number" --repo "$GITHUB_REPOSITORY" --reason 'not planned' + else + gh pr close "$number" --repo "$GITHUB_REPOSITORY" + fi + fi +else + if [[ $(jq -r .state <<< "$item") == closed ]]; then + gh "$kind" reopen "$number" --repo "$GITHUB_REPOSITORY" + fi + gh api "$repo/issues/$number/labels/$label" -X DELETE --silent +fi diff --git a/.github/workflows/template-check.yml b/.github/workflows/template-check.yml new file mode 100644 index 00000000..5cff75c3 --- /dev/null +++ b/.github/workflows/template-check.yml @@ -0,0 +1,27 @@ +name: template-check +on: + issues: + types: [opened, edited, reopened] + pull_request_target: + types: [opened, edited, reopened] +permissions: + contents: read + issues: write + pull-requests: write +concurrency: + group: template-check-${{ github.event.issue.number || github.event.pull_request.number }} + cancel-in-progress: false +jobs: + check: + runs-on: ubuntu-latest + steps: + # pull_request_target checks out the trusted base, never PR code. + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - name: Check template and close or reopen + env: + GH_TOKEN: ${{ github.token }} + NUMBER: ${{ github.event.issue.number || github.event.pull_request.number }} + GITHUB_EVENT_ACTION: ${{ github.event.action }} + run: bash .github/scripts/template-check.sh "$NUMBER" diff --git a/AGENTS.md b/AGENTS.md index e10ed866..261931ed 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, one short paragraph under each of `## Problem`, `## How I fixed it` and `## Verified`, in that order: what is wrong, what changed, what was checked — not the reasoning that led there. Link long evidence; do not paste it. +- **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. - 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 77081ec1..adf6203c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -55,15 +55,9 @@ LLM-generated code is welcome in: 4. **Tests must attack, not mirror.** Reviewers of LLM-written tests should sample whether assertions are independently derived semantic claims (e.g. "old-generation entries survive one transition") or restatements of the implementation. Mirror tests are rejected regardless of coverage numbers. 5. **Reviewers may close non-compliant PRs** with a pointer to this document, no questions asked. -## 5. Disclosure +## 5. Responsibility for AI-assisted work -Every PR must answer, in its description or the PR template: - -- Which parts (by file or area) are LLM-generated? -- Which LLM tools/agents were used, if any, for analysis or review? -- If LLM-written tests cover human-written core code: what did the author verify beyond the tests? - -Disclosure calibrates reviewer trust. Hidden LLM involvement is treated as a breach of trust between author and reviewer, independent of code quality. +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. ## 6. Adversarial deep review