Skip to content

feat: the agent chooses the domain folder and the save script checks it - #90

Merged
917Dhj merged 1 commit into
developfrom
feat/model-led-domain-routing
Nov 7, 2026
Merged

917Dhj merged 1 commit into
developfrom
feat/model-led-domain-routing

Conversation

@917Dhj

@917Dhj 917Dhj commented Nov 7, 2026

Copy link
Copy Markdown
Owner

Summary

Keyword routing guessed a domain name from domain_rules.yaml and created a new folder whenever the name did not literally match an existing one. That is how generic folders such as 大模型 kept appearing. The agent now chooses; the script only describes the domains and checks the choice.

 Save Target Admission (preflight)
   existing paper directory found      -> reuse it (unchanged)
-  else infer_domain_label(title, abstract)       # keyword table
-       best literal match among folders, or create the guessed name
+  else no --domain                    -> blocked: domain_required + domain_overview
+       --domain <existing or convention domain> -> admitted
+       --domain <new name> without --new-domain-reason -> new_domain_reason_required
+       --domain <bad name>            -> domain_name_invalid
 Formal Save
+  note must carry exactly one papers/<saved domain> tag
  • domain_overview comes from the user's convention in <Vault>/DeepPaperNote/domains.md (definition / includes / excludes) when it exists. Otherwise it lists each folder's paper count and up to eight sample titles. Folders where the convention and the disk disagree are marked.
  • Code:
    • _domain_routing.py holds the overview, the validation, and the tag check.
    • references/domain-routing.md is the agent's guide.
    • --subdir is replaced by --domain / --new-domain-reason.
  • Workspace mode follows the same rules, and its preflight now runs to choose the domain.
  • run_state:
    • It carries domain and new_domain_reason as run context.
    • A domain block now yields missing_context: [domain], not a user action.
  • Lint adds frontmatter_domain_tag_multiple.
  • Removed:
    • domain_rules.yaml;
    • the keyword inference;
    • the old multi-part --subdir handling (papers_dir prefixes, a subdir ending in the paper slug). A paper always lives at <domain>/<paper folder>/.

Evidence

Tests:

  • python3 -m pytest -q: 1719 passed. The baseline on develop was 1714. Twelve keyword-routing tests and five old --subdir path tests were removed, together with the behavior they covered.
  • New spec tests are in tests/test_domain_routing.py (18) and at the end of tests/test_run_state.py (4).
  • Existing tests now choose a domain and tag their notes. formal_save_args(..., domain=...) does this through tagged().

Routing acceptance (local, on a copy of the maintainer's real library):

  • The library copy has 12 domains and 102 notes.
  • The test set is 15 corpus papers that are not in the library.
  • The chooser was Codex gpt-6.1-terra; each paper was judged blind by a fresh Sonnet 5.5 reviewer.
Before (keyword) After
Reasonable placement 3/15 15/15
New folders created 5 (推荐系统, 未分类, 金融, 机器学习 ×2), all generic or unrelated 1 (大模型可信性), judged specific
Reviewer preference 0 13, with 2 ties
  • Old router failures included:
    • a coding-agent paper sent to a new 推荐系统 folder;
    • MedSAM sent to 心理健康;
    • DUSt3R sent to 大模型.
  • Guide fix between rounds: in the first round the agent filed ChatGPT is bullshit under 大模型, which only holds a video paper. The guide now says to judge a domain by its papers, not its name.

Merge Danger

Door: two-way

Blast Radius: save path

  • A new paper directory can no longer be saved until the agent supplies --domain.
  • A note whose papers/ tags do not match the saved domain is refused.
  • Reuse of existing directories is unchanged.
  • Notes already in a vault are not touched.

🤖 Generated with Claude Code

Keyword routing guessed a domain name from domain_rules.yaml and created a
new folder whenever the name did not literally match an existing one, so
generic folders such as 大模型 kept appearing. Preflight now stops a new
paper directory with domain_required and a domain_overview (the user's
domains.md convention, or each folder's paper count and sample titles).
The agent chooses with --domain; a new domain needs --new-domain-reason.
Formal Save requires exactly one papers/<domain> tag naming the saved
domain. run_state carries domain and new_domain_reason as run context.

domain_rules.yaml, the keyword inference, and the old multi-part --subdir
path handling are removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@917Dhj
917Dhj merged commit 4d6c58c into develop Nov 7, 2026
3 checks passed
@917Dhj
917Dhj deleted the feat/model-led-domain-routing branch November 9, 2026 07:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant