From 65ba0ae9e4e78c82265d6a6b23976cff4d50b571 Mon Sep 17 00:00:00 2001 From: EMRG Evolution Date: Fri, 14 Aug 2026 15:56:59 +0800 Subject: [PATCH] emrg: open_source_prompt requires full-code study before contributing (rant 2026-08-14T15:53:39) --- Agent.md | 2 +- emrg/server/open_source_prompt.md | 15 +++++++++++++++ tests/test_scheduler.py | 31 +++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 1 deletion(-) diff --git a/Agent.md b/Agent.md index 9deee6fd..9643c407 100644 --- a/Agent.md +++ b/Agent.md @@ -118,7 +118,7 @@ Community needs voiced in HN agent-UI discussions map directly to EMRG's design: pkill -f "emrg.server"; rm -f ~/.emrg/emrgd.port; python -m emrg ``` -Python: `uv run pytest tests/ -v` (805) — import check: `uv run python -c "from emrg.client.app import run_client"` +Python: `uv run pytest tests/ -v` (806) — import check: `uv run python -c "from emrg.client.app import run_client"` GUI: `cd emrg/gui && npm test` (246: 44 daemon_client + 19 conn-manager + 22 app-commands + 121 renderer smoke + 16 i18n + 7 integration + 3 commands + 5 build-config + 7 gui-state + 2 tool-group) — syntax: `node --check main.js preload.js daemon_client.js renderer/js/*.js` CI: `uv run pytest` (ubuntu + **windows-2025 matrix** — Windows pytest 回归在 PR CI 即失败,v0.2.29 教训 #725) + GUI tests + **actionlint workflow lint** (`rhysd/actionlint@v1.7.12` gate, #444 — workflow 解析错误在 PR CI 即失败,如 `if:` secrets 上下文) Re-trigger: `scripts/re-trigger-ci.sh [branch]` (workflow_dispatch, #527 — 替代空 commit 重触发:Actions outage 会整段丢弃 push 事件,dispatch 走 API 路径不受影响) diff --git a/emrg/server/open_source_prompt.md b/emrg/server/open_source_prompt.md index c6f4b756..1cbc99d7 100644 --- a/emrg/server/open_source_prompt.md +++ b/emrg/server/open_source_prompt.md @@ -280,6 +280,21 @@ Extract from these files and strictly follow: **Submitting without reading the conventions = wasted time.** Requirements found in the conventions override this prompt's defaults (e.g., if the project requires PRs to target `dev`, follow the project convention). +#### B.2b Read the full codebase (MUST before contributing) + +> ⚠️ 前提:**每次贡献前都重新读取最新代码**(0.3 Source sync 已保证 `git pull` 到最新;任何贡献思路都建立在你刚拉取的最新代码上,不得用记忆/旧版本代码做判断)。 + +**读完整代码**(不止是目标文件): +- 先看仓库根:README / docs / 目录结构 → 理解项目定位、模块划分 +- 通读核心模块源码(按目录树从上到下,理解每个模块职责) +- 定位到与本次 Issue/目标相关的代码时,**精读相关文件全文**(不只看改动点附近) + +**以 repository 作者的视角理解设计意图**: +- 问自己:作者为什么这样设计?这个函数/模块解决什么问题?为什么用这个模式(而非别的方式)? +- 读提交历史 / git blame:理解代码演化脉络,不臆测作者意图 +- 设计意图不明 → 读测试(测试即文档),读 Issue/讨论记录 +- **只有当你理解了作者的设计意图,才考虑怎么贡献** —— 贡献必须顺应既有设计,而不是另起炉灶 + #### B.3 Fork and branch ```bash diff --git a/tests/test_scheduler.py b/tests/test_scheduler.py index c1e6bbe2..0c61591f 100644 --- a/tests/test_scheduler.py +++ b/tests/test_scheduler.py @@ -646,6 +646,37 @@ def test_open_source_template_allow_self_merge_conditional(): assert "**overridden**" not in out_false +def test_open_source_template_full_code_study_b2b(): + """open_source_prompt.md B.2b requires full-code study before contributing + (rant 2026-08-14T15:53:39).""" + import jinja2 + + template_path = ( + Path(__file__).resolve().parent.parent + / "emrg" / "server" / "open_source_prompt.md" + ) + env = jinja2.Environment(undefined=jinja2.Undefined) + template = env.from_string(template_path.read_text(encoding="utf-8")) + out = template.render( + instance_id="test", host_name="host", uptime="0h 0m", + repo_url="https://github.com/x/y.git", owner="x", repo="y", + local_source="/tmp/os", source_dir="/tmp/os", session_id="s1", + evolution_cwd="/tmp/evo", timestamp="20260814", + task={"role": "committer", "project": "aitokenpool"}, + project={}, evolution_count=0, git_path="git", gh_path="gh", + ) + # 1) the new section exists (positive discrimination: absent section → red) + assert "B.2b Read the full codebase" in out, "B.2b 全代码研读节应渲染" + # 2) must read the complete codebase, not just the target file + assert "读完整代码" in out, "读完整代码要求应渲染" + # 3) must always re-read the latest code before each contribution + assert "每次贡献前都重新读取最新代码" in out, "每次读取最新代码要求应渲染" + # 4) understand design intent from the repository author's perspective + assert "以 repository 作者的视角理解设计意图" in out, "作者视角设计意图要求应渲染" + # 5) only after understanding the design may one contribute — align with it + assert "只有当你理解了作者的设计意图" in out, "理解设计意图后才可贡献应渲染" + + # ── Evolution workspace self-heal (rant 2026-08-06T20:42:05, 方案 C) ──────