From ab36f9b2c70875cae2fc86580f929d2874d4aae4 Mon Sep 17 00:00:00 2001 From: argszero Date: Thu, 27 Aug 2026 23:55:25 +0800 Subject: [PATCH 1/2] =?UTF-8?q?emrg:=20test=20=E2=80=94=20fix=20Agent.md?= =?UTF-8?q?=20renderer=20count=20drift=20(445->448)=20+=20guard=20renderer?= =?UTF-8?q?=20count=20against=20reality?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit R2254: #1049/#1050 added renderer tests (daemonBridge/Shell/SettingsPanel/ WorkspaceView) without bumping Agent.md — the renderer count drifted 445 -> 448 silently. The doc-count guard only validates each "(N: ...)" line's internal sum (parts == headline), not reality, and the pytest CI job has no node_modules to run vitest. FIX: Agent.md renderer line corrected to 448 with per-file counts aligned to vitest's executed numbers (workspaceView 29->27, WorkspaceView 8->10, daemonBridge 14->15, Shell 24->25, SettingsPanel 19->20). GUARD: test_doc_counts.py::test_renderer_count_matches_docs — a static count of test-case definitions (^\s*(it|test)\( per file under renderer/src) equals vitest's executed total exactly (verified for all 44 files), so it runs in plain pytest and turns any future renderer-count drift red immediately. Python tests 1127 -> 1128 (new guard), Agent.md synced. --- Agent.md | 4 ++-- tests/test_doc_counts.py | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/Agent.md b/Agent.md index d616ab67..b53df1aa 100644 --- a/Agent.md +++ b/Agent.md @@ -119,9 +119,9 @@ Community needs voiced in HN agent-UI discussions map directly to EMRG's design: pkill -f "emrg.server"; rm -f ~/.emrg/emrgd.token; python -m emrg ``` -Python: `uv run pytest tests/ -v` (1127) — import check: `uv run python -c "from emrg.client.app import run_client"` +Python: `uv run pytest tests/ -v` (1128) — import check: `uv run python -c "from emrg.client.app import run_client"` GUI: `cd emrg/gui && npm test` (95: 45 daemon_client + 20 conn-manager + 8 integration + 6 build-config + 7 gui-state + 3 preload-api + 4 boot-contract + 2 theme-guard) — syntax: `node --check main.js preload.js daemon_client.js` -Renderer: `cd emrg/gui/renderer && npm run typecheck && npm test` (445: 5 snapshot-store + 9 utils + 3 ErrorBoundary + 2 App smoke + 11 commands + 4 copywriting + 11 i18n + 11 markdown + 15 transcript + 7 TranscriptView + 15 history + 22 composer + 14 Composer + 12 sidebar + 17 Sidebar + 9 fileTree + 9 FileTree + 16 resultPanel + 8 ResultPanel + 29 workspaceView + 8 WorkspaceView + 10 dialog + 6 Dialog + 9 ConfirmDialog + 9 RenameDialog + 10 dialogLists + 3 HelpDialog + 9 MemoryDialog + 6 SkillsDialog + 9 openSession + 6 WelcomeDialog + 8 OpenSessionDialog + 7 NewSessionDialog + 7 rewind + 8 RewindDialog + 7 GithubDeviceDialog + 14 daemonBridge + 7 DaemonBridgeProvider + 24 Shell + 15 DialogHost + 19 SettingsPanel + 6 TaskFormDialog + 5 RantDialog + 4 vendorMarkdown) + `npm run build` → `renderer/dist/` +Renderer: `cd emrg/gui/renderer && npm run typecheck && npm test` (448: 5 snapshot-store + 9 utils + 3 ErrorBoundary + 2 App smoke + 11 commands + 4 copywriting + 11 i18n + 11 markdown + 15 transcript + 7 TranscriptView + 15 history + 22 composer + 14 Composer + 12 sidebar + 17 Sidebar + 9 fileTree + 9 FileTree + 16 resultPanel + 8 ResultPanel + 27 workspaceView + 10 WorkspaceView + 10 dialog + 6 Dialog + 9 ConfirmDialog + 9 RenameDialog + 10 dialogLists + 3 HelpDialog + 9 MemoryDialog + 6 SkillsDialog + 9 openSession + 6 WelcomeDialog + 8 OpenSessionDialog + 7 NewSessionDialog + 7 rewind + 8 RewindDialog + 7 GithubDeviceDialog + 15 daemonBridge + 7 DaemonBridgeProvider + 25 Shell + 15 DialogHost + 20 SettingsPanel + 6 TaskFormDialog + 5 RantDialog + 4 vendorMarkdown) + `npm run build` → `renderer/dist/` 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 路径不受影响) Git-over-https 兜底: `python scripts/sync-master-from-api.py [--repo owner/name] [--ref master]` — 受限网络下 github.com:443 不可达而 api.github.com 可达时,用 Git Data API 的 verification payload + signature 字节级重建上游 commit(含 web-flow GPG 签名 squash merge,reconstruct_commit 经 hermetic 测试验证 sha 一致)并推进本地 refs;内容对象缺失时 fail-loud 提示改用 git fetch(10+ 周期实证的恢复路径) diff --git a/tests/test_doc_counts.py b/tests/test_doc_counts.py index db18c6ea..0341761c 100644 --- a/tests/test_doc_counts.py +++ b/tests/test_doc_counts.py @@ -140,3 +140,40 @@ def test_evolution_prompt_no_quick_ref_block() -> None: "(rant 2026-08-17T14:22:21, #822)" ) + + +def _static_renderer_count() -> int: + """Count renderer vitest cases statically (no node_modules needed). + + Matches vitest's executed total exactly: for every renderer test file the + ``^\s*(it|test)(`` definition count equals the number of executed cases + (verified for all 44 files, R2254). Files are under + ``emrg/gui/renderer/src`` with ``.test.ts`` / ``.test.tsx`` suffixes. + """ + base = REPO_ROOT / "emrg" / "gui" / "renderer" / "src" + total = 0 + for f in sorted(base.rglob("*.test.ts")) + sorted(base.rglob("*.test.tsx")): + text = f.read_text(encoding="utf-8") + total += len(re.findall(r"^\s*(?:it|test)\(", text, re.M)) + return total + + +def test_renderer_count_matches_docs() -> None: + """Agent.md's Renderer headline must equal the real vitest count. + + R2254 (#1049/#1050): renderer tests grew 445 -> 448 without Agent.md being + bumped. The GUI-breakdown guard only validates each "(N: ...)" line's + *internal* sum (parts sum to headline) — it cannot see reality, and the + pytest CI job has no node_modules to run vitest. The static definition + count equals vitest's executed total, so this guard runs everywhere + pytest does and turns the drift red immediately. + """ + renderer = [b for b in _gui_breakdowns() if "Renderer" in b[0]] + assert renderer, "Agent.md must document the Renderer test breakdown" + label, headline, parts = renderer[0] + static = _static_renderer_count() + assert headline == static, ( + f"{label}: documents {headline} renderer tests but {static} are " + f"counted statically (vitest-equivalent). Sync Agent.md when " + "adding/removing renderer tests." + ) From bc2d687b9ca3f92503bd8f0833c094b96323a573 Mon Sep 17 00:00:00 2001 From: EMRG Evolution Date: Fri, 28 Aug 2026 00:35:18 +0800 Subject: [PATCH 2/2] test: escape regex in docstring (fix SyntaxWarning in renderer count guard) --- tests/test_doc_counts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_doc_counts.py b/tests/test_doc_counts.py index 0341761c..8cb93507 100644 --- a/tests/test_doc_counts.py +++ b/tests/test_doc_counts.py @@ -146,7 +146,7 @@ def _static_renderer_count() -> int: """Count renderer vitest cases statically (no node_modules needed). Matches vitest's executed total exactly: for every renderer test file the - ``^\s*(it|test)(`` definition count equals the number of executed cases + ``^\\s*(it|test)(`` definition count equals the number of executed cases (verified for all 44 files, R2254). Files are under ``emrg/gui/renderer/src`` with ``.test.ts`` / ``.test.tsx`` suffixes. """