Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

feat: add strategy-deletion documentation hook (#3529)

LearningCircuit3c66fa0ec3c2
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 038925eb95..526b8f8ac3 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -287,6 +287,13 @@ repos:
pass_filenames: false
always_run: true
description: "Block commits with substantial new code but no tests"
+ - id: require-strategy-deletion-docs
+ name: Require docs/strategies/deleted/ note on strategy deletion
+ entry: .pre-commit-hooks/require-strategy-deletion-docs.py
+ language: script
+ pass_filenames: false
+ always_run: true
+ description: "Block commits that delete a search strategy file without adding/updating a notes file in docs/strategies/deleted/"
- id: check-unmarked-sleep
name: Check time.sleep() in tests has @pytest.mark.slow
entry: .pre-commit-hooks/check-unmarked-sleep.py
diff --git a/.pre-commit-hooks/require-strategy-deletion-docs.py b/.pre-commit-hooks/require-strategy-deletion-docs.py
new file mode 100755
index 0000000000..c86ea49390
--- /dev/null
+++ b/.pre-commit-hooks/require-strategy-deletion-docs.py
@@ -0,0 +1,188 @@
+#!/usr/bin/env python3
+"""Require a notes file when a file under ``advanced_search_system/`` is deleted.
+
+Any commit that deletes a ``.py`` file under
+``src/local_deep_research/advanced_search_system/`` — or renames one out of
+that tree, which removes it from the tracked module — must also add or
+modify a ``.md`` file under ``docs/strategies/deleted/`` in the same commit.
+Rationale and template live in ``docs/strategies/deleted/README.md``.
+
+Exempt files whose deletion does not by itself remove a component: package
+``__init__.py`` aggregators. The exemption list is intentionally narrow; if
+a new infra file is added (e.g. a base class in a new location), update
+``EXEMPT_FILENAMES`` below. ``base_*.py`` files are NOT exempt — deleting
+a base class is a significant refactor that does warrant a notes file.
+"""
+
+import subprocess
+import sys
+from pathlib import PurePosixPath
+
+SCOPE_DIR = "src/local_deep_research/advanced_search_system/"
+DOCS_DIR = "docs/strategies/deleted/"
+EXEMPT_FILENAMES = {"__init__.py"}
+
+# Suggested notes-file name format. PR number isn't known at commit time
+# so we accept a placeholder the author fills in before pushing.
+SUGGESTED_FILENAME = "pr-<number>-<short-slug>.md"
+
+TEMPLATE = """\
+# PR #<n> — <title>
+
+Components deleted in PR #<n> (see that PR for the full pre-deletion
+code — this file only summarises what was novel).
+
+## Component: `<ClassName>`
+
+- File deleted: `<path>` (<N> LOC at deletion).
+- Reachability: <e.g. "not in factory; only referenced by its own test">.
+- Closest reachable successor: `<ClassName>` (`<path>`, factory key `"<X>"`).
+
+### Useful ideas from the pre-deletion version
+
+- **<short name>** — <1-2 sentences on what it did, why it was
+ distinctive, whether it was validated>.
+- **<short name>** — <...>.
+
+### Why deletion was safe
+
+<2-3 sentences mapping distinctive features to the successor, or
+flagging at-risk items and why losing them is acceptable.>
+
+### Recovery path
+
+<1-2 sentences. Prefer "add a flag on the existing class" over
+"restore the deleted file".>
+"""
+
+
+def staged_changes():
+ """Yield ``(code, old_path, new_path)`` for each staged change.
+
+ For add/modify/delete, ``old_path == new_path``. For rename (R) and
+ copy (C), they differ; uniform unpacking lets callers use one code
+ path. See ``git diff --name-status`` for the format.
+ """
+ result = subprocess.run(
+ ["git", "diff", "--cached", "--name-status"],
+ capture_output=True,
+ text=True,
+ check=True,
+ )
+ for line in result.stdout.splitlines():
+ if not line.strip():
+ continue
+ parts = line.split("\t")
+ if len(parts) < 2:
+ continue
+ code = parts[0][
+ 0
+ ] # A / M / D / R / C (R and C carry a similarity score suffix)
+ if code in ("R", "C") and len(parts) >= 3:
+ yield code, parts[1], parts[2]
+ else:
+ yield code, parts[1], parts[1]
+
+
+def _is_exempt(path: str) -> bool:
+ # .lower() defends against case-insensitive filesystems (macOS, Windows).
+ return PurePosixPath(path).name.lower() in EXEMPT_FILENAMES
+
+
+def main() -> int:
+ deleted_files = []
+ doc_changes = []
+
+ for code, old_path, new_path in staged_changes():
+ # A rename out of SCOPE_DIR removes the component from the tracked
+ # tree even though the file survives elsewhere — treat as deletion.
+ # Renames within SCOPE_DIR are legitimate refactors; don't fire.
+ is_deletion_from_scope = (
+ code == "D" and old_path.startswith(SCOPE_DIR)
+ ) or (
+ code == "R"
+ and old_path.startswith(SCOPE_DIR)
+ and not new_path.startswith(SCOPE_DIR)
+ )
+ if (
+ is_deletion_from_scope
+ and old_path.endswith(".py")
+ and not _is_exempt(old_path)
+ ):
+ deleted_files.append(old_path)
+
+ if (
+ code in ("A", "M")
+ and new_path.startswith(DOCS_DIR)
+ and new_path.endswith(".md")
+ and PurePosixPath(new_path).name.lower() != "readme.md"
+ ):
+ doc_changes.append(new_path)
+
+ if deleted_files and not doc_changes:
+ err = sys.stderr
+ print(
+ "\n \033[31madvanced_search_system deletion without documentation\033[0m",
+ file=err,
+ )
+ print(" " + "=" * 50, file=err)
+ print(
+ "\n You are deleting (or renaming out of scope) these files:",
+ file=err,
+ )
+ for path in deleted_files:
+ print(f" - {path}", file=err)
+ print(
+ f"\n To unblock this commit, add a notes file at\n"
+ f" {DOCS_DIR}{SUGGESTED_FILENAME}\n"
+ f" (or extend an existing one under {DOCS_DIR}) with the following shape:\n",
+ file=err,
+ )
+ for line in TEMPLATE.splitlines():
+ print(f" {line}" if line else "", file=err)
+ print(
+ '\n Each bullet in "Useful ideas" should answer, in 1-2',
+ file=err,
+ )
+ print(
+ " sentences:",
+ file=err,
+ )
+ print(
+ " - what the component did that was different from the successor,",
+ file=err,
+ )
+ print(
+ " - why that difference was interesting (heuristic, tuning, prompt",
+ file=err,
+ )
+ print(
+ " trick, interface gap),",
+ file=err,
+ )
+ print(
+ " - and whether it was validated or exploratory.",
+ file=err,
+ )
+ print(
+ "\n Do NOT paste verbatim prompts, docstrings, or code blocks —",
+ file=err,
+ )
+ print(
+ " git already stores them via the deletion PR/commit. Link, don't",
+ file=err,
+ )
+ print(
+ " duplicate.",
+ file=err,
+ )
+ print(
+ f"\n Full convention + rationale: {DOCS_DIR}README.md\n",
+ file=err,
+ )
+ return 1
+ return 0
+
+
+if __name__ == "__main__":
+ sys.exit(main())
diff --git a/docs/strategies/deleted/README.md b/docs/strategies/deleted/README.md
new file mode 100644
index 0000000000..0a67af1761
--- /dev/null
+++ b/docs/strategies/deleted/README.md
@@ -0,0 +1,108 @@
+# Deleted advanced-search-system components — notes archive
+
+This directory captures the **novelty** of components deleted from
+`src/local_deep_research/advanced_search_system/` — strategies, question
+generators, constraint checkers, filters, candidate explorers, evidence
+gatherers. Git already stores the code and its history; the job of these
+notes is the prose explanation of *what was novel and why*, something
+git blame can't reconstruct.
+
+Keep files short. Link to the deletion PR or commit for the code; write
+1-2 sentences per idea, not verbatim copies.
+
+(The directory is named `docs/strategies/deleted/` for historical
+reasons — the hook started narrower. It now covers the whole
+`advanced_search_system/` module.)
+
+## When to add a file here
+
+Whenever a PR deletes one or more `.py` files anywhere under
+`src/local_deep_research/advanced_search_system/`. The
+`require-strategy-deletion-docs` pre-commit hook enforces this — a
+commit that deletes such a file without adding or updating a `.md`
+file in this directory will be blocked.
+
+Exempt: `__init__.py` aggregators anywhere in the tree — deleting one
+by itself does not remove a component. Everything else, including
+`base_strategy.py` / `base_question.py` / other `base_*.py`, requires
+a notes file because deleting a base class is a significant refactor.
+
+## Naming
+
+One file per deletion PR:
+
+```
+pr-<number>-<short-slug>.md
+```
+
+Examples: `pr-3147-dead-strategies.md`, `pr-3205-entity-aware.md`.
+
+If a single PR deletes multiple components, document all of them in
+one file with one `## Component:` section per deletion.
+
+## Template
+
+```markdown
+# PR #<n> — <title>
+
+Strategies/components deleted in PR #<n> (see that PR for the full
+pre-deletion code — this file only summarises what was novel).
+
+## Component: `<ClassName>`
+
+- File deleted: `<path>` (<N> LOC at deletion).
+- Reachability: <one line, e.g. "not in `search_system_factory.py`; only referenced by its own test">.
+- Closest reachable successor: `<SuccessorClassName>` (`<path>`, factory key `"<X>"`).
+
+### Useful ideas from the pre-deletion version
+
+- **<short name>** — <1–2 sentences describing what it did and why
+ it was distinctive, and whether it was validated>.
+- **<short name>** — <...>.
+
+### Why deletion was safe
+
+<2–3 sentences mapping distinctive features to the successor, or
+flagging at-risk items and why losing them is acceptable.>
+
+### Recovery path
+
+<1–2 sentences: prefer "add a flag on the existing class" over
+"restore the deleted file". Or: "do not restore".>
+```
+
+## The guiding principle — reference, don't duplicate
+
+Write the notes **as commentary on the code in git**, not as a mirror
+of it. Example of the shape to aim for:
+
+> `generate_creative_search_angles` asked the LLM for 30–40
+> alternate-angle queries using a detective framing (character / title /
+> genre guessing, reverse searches). Exploratory and never validated
+> against a benchmark. Not replicated in `ModularStrategy`.
+
+One paragraph conveys the idea. A reader who wants the exact prompt can
+follow the PR link or run `git show <sha>:<path>`. We are not
+re-hosting the code.
+
+## What a good bullet mentions
+
+Each novelty bullet should be **brief** and answer:
+
+- What the component did that was different from the successor.
+- Why that difference was interesting (a heuristic, a tuning choice, a
+ prompt-engineering trick, an interface gap it filled).
+- Whether it was validated or exploratory — set expectations for
+ anyone considering a revival.
+
+Bullets worth writing are the ones a future reader can't easily infer
+by diffing the deleted file against its successor.
+
+## What not to include
+
+- **Verbatim copies of prompts, docstrings, or code blocks** — the
+ deletion PR already has them; don't re-host.
+- **Line-by-line diffs against the successor** — the PR diff covers it.
+- **Discussion of review decisions** — those belong on the PR itself.
+- **Apologies or extended rationale** — the "Why deletion was safe"
+ section should be 2–3 sentences, not an essay.