From 1627b6152bdc7a9a3d20cb3fdc70097fe6d3b6fc Mon Sep 17 00:00:00 2001 From: Test Operator Date: Sun, 17 May 2026 10:04:28 +0800 Subject: [PATCH] Fix weekly repo hygiene TODO false positive --- .../weekly-repo-hygiene-review-2026-05-17.md | 73 +++++++++++++++++++ .../services/scheduling/repo_hygiene_scan.py | 13 +++- tests/test_weekly_repo_hygiene_review.py | 22 ++++++ 3 files changed, 107 insertions(+), 1 deletion(-) create mode 100644 docs/archive/evidence/weekly-repo-hygiene-review-2026-05-17.md diff --git a/docs/archive/evidence/weekly-repo-hygiene-review-2026-05-17.md b/docs/archive/evidence/weekly-repo-hygiene-review-2026-05-17.md new file mode 100644 index 00000000..1e9f8c1d --- /dev/null +++ b/docs/archive/evidence/weekly-repo-hygiene-review-2026-05-17.md @@ -0,0 +1,73 @@ +--- +id: weekly-repo-hygiene-review-2026-05-17 +title: Weekly Repo Hygiene Review Evidence 2026-05-17 +role: dev_rel +status: ready +created_at: 2026-05-17 +updated_at: 2026-05-17 +author: codex +target_repo: Synapse-Network-Growing +--- + +# Weekly Repo Hygiene Review Evidence + +## Scope + +- Automation: `weekly_repo_hygiene_review` +- Date: `2026-05-17` +- Worktree: `/Users/cliff/.codex/worktrees/bb4b/Synapse-Network-Growing-agent-b` +- Week key: `2026-W20` + +## Repo Scan Findings + +The read-only scan reproduced the repo's weekly hygiene findings under the documented local PostgreSQL dev environment. + +- Root markdown review items remain: `CLAUDE.md`, `GEMINI.md`, `harness-engineering.md` +- Docs metadata items remain: missing frontmatter in + `docs/design-docs/company-ops-latest-architecture.md`, + `docs/design-docs/context-loading-map.md`, + `docs/design-docs/current-feature-inventory.md`, + `docs/design-docs/system-design-principles.md`, + `docs/plans/README.md` +- PR template newline hygiene is already present +- Ops stale-state findings: none in the local database snapshot + +## Safe Cleanup Selected + +One low-risk mechanical cleanup item was safe to apply: + +- Fix `server/services/scheduling/repo_hygiene_scan.py` so TODO/FIXME detection only matches actual source comments, not embedded string literals in scanner code. + +Why this item: + +- It removed a self-referential false positive from the weekly scan. +- It did not touch production resources, secrets, auth, deployments, Docker, caches, funds, or settlement flows. +- No duplicate weekly cleanup candidate or requirement existed for `2026-W20` in the local Ops database. + +## Verification + +Commands run: + +```bash +export OPS_DATABASE_URL="postgresql+psycopg://synapse_growing:synapse_growing_dev@127.0.0.1:54329/synapse_growing_local" +export PYTHONPATH=. +/Users/cliff/workspace/agent/.venv/bin/python -m pytest -q tests/test_weekly_repo_hygiene_review.py +/Users/cliff/workspace/agent/.venv/bin/python - <<'PY' +from server.services.scheduling.repo_hygiene_scan import scan_repo_hygiene_payload +import json +print(json.dumps(scan_repo_hygiene_payload(), ensure_ascii=False, indent=2, default=str)) +PY +git diff --check +``` + +Results: + +- `tests/test_weekly_repo_hygiene_review.py`: `8 passed` +- `git diff --check`: clean +- Weekly scan finding count dropped from `9` to `8` +- Removed false-positive finding: `todo:server/services/scheduling/repo_hygiene_scan.py` + +## Delivery + +- Publish path: small cleanup PR only +- Auto-merge: disabled diff --git a/server/services/scheduling/repo_hygiene_scan.py b/server/services/scheduling/repo_hygiene_scan.py index f03970f0..159d4020 100644 --- a/server/services/scheduling/repo_hygiene_scan.py +++ b/server/services/scheduling/repo_hygiene_scan.py @@ -3,12 +3,19 @@ from __future__ import annotations from pathlib import Path +import re from typing import Any from server import config ROOT_MARKDOWN_ALLOWLIST = {"AGENTS.md", "ARCHITECTURE.md", "README.md", "llms.txt"} +TODO_COMMENT_PATTERNS = ( + re.compile(r"#\s*(TODO|FIXME)\b"), + re.compile(r"//\s*(TODO|FIXME)\b"), + re.compile(r"/\*\s*(TODO|FIXME)\b"), + re.compile(r"\*\s*(TODO|FIXME)\b"), +) def _repo_rel(path: Path) -> str: @@ -114,6 +121,10 @@ def _pr_template_findings(root: Path) -> list[dict[str, Any]]: ] +def _has_todo_comment(text: str) -> bool: + return any(pattern.search(text) for pattern in TODO_COMMENT_PATTERNS) + + def _todo_findings(root: Path, *, limit: int = 8) -> list[dict[str, Any]]: findings: list[dict[str, Any]] = [] for base in [root / "server", root / "scripts", root / "dashboard" / "src"]: @@ -126,7 +137,7 @@ def _todo_findings(root: Path, *, limit: int = 8) -> list[dict[str, Any]]: text = path.read_text(encoding="utf-8", errors="replace") except OSError: continue - if "TODO" not in text and "FIXME" not in text: + if not _has_todo_comment(text): continue findings.append( _finding( diff --git a/tests/test_weekly_repo_hygiene_review.py b/tests/test_weekly_repo_hygiene_review.py index f2946a8e..7a4b374d 100644 --- a/tests/test_weekly_repo_hygiene_review.py +++ b/tests/test_weekly_repo_hygiene_review.py @@ -228,6 +228,28 @@ def test_weekly_repo_hygiene_scanner_detects_repo_entropy(tmp_path, monkeypatch) assert payload["auto_fixable_count"] == 2 +def test_weekly_repo_hygiene_scanner_ignores_todo_strings_inside_code( + tmp_path, monkeypatch +): + monkeypatch.setattr(repo_hygiene_scan.config, "PROJECT_ROOT", tmp_path) + server_dir = tmp_path / "server" + server_dir.mkdir() + (server_dir / "embedded_string.py").write_text( + 'MESSAGE = "TODO should not count when it is only a string literal."\n', + encoding="utf-8", + ) + (server_dir / "real_comment.py").write_text( + "# TODO: tracked cleanup item\n", + encoding="utf-8", + ) + + payload = repo_hygiene_scan.scan_repo_hygiene_payload(root=tmp_path) + + ids = {item["id"] for item in payload["repo_findings"]} + assert "todo:server/real_comment.py" in ids + assert "todo:server/embedded_string.py" not in ids + + def test_weekly_repo_hygiene_high_risk_or_duplicate_noops(db_session): high_risk = _finding(id="auth:secret-cleanup", risk_level="high", auto_fixable=True)