refactor(arch): inline RulesEngine pass-through into Pipeline classify - #10
Merged
Conversation
ruff format --check was failing on main for these two files adopted in d6ecf06; formatting them here so the local gate is fully green. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017p6obt6Ua7nB96YTG2XFKf
…engine-classify Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017p6obt6Ua7nB96YTG2XFKf
rules_engine.py was a shallow pass-through: classify() only sequenced the three rule loaders (YAML DSL > Python > NL) with logging glue, and get_nl_context() forwarded a single call. Deleting it concentrates the classify sequence in the Pipeline, where the surrounding orchestration (LLM fallback, folder policy, moves) already lives: - Pipeline loads the three rule sources in __init__ and evaluates them in classify_with_rules(); log messages and priority are unchanged - NL prompt context comes straight from nl_rules.nl_rules_context() - the classify CLI command uses the Pipeline instead of a private RulesEngine; loaders/stubs are now mockable directly in tests - rules_engine_test.py becomes rules_test.py (loader tests unchanged); the priority-order test moved to pipeline_test.py No behavior change. Spec: docs/specifications/ACTIVE/inline-rules-engine-classify.md Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017p6obt6Ua7nB96YTG2XFKf
br4vesirrobin
force-pushed
the
improve-arch/inline-rules-engine
branch
from
July 7, 2026 04:28
2825d16 to
ee021ce
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
src/kontor_cli/rules_engine.py(77 lines) was a shallow pass-through:RulesEngine.classify()only sequenced the three rule loaders (YAML DSL > Python > NL) with logging glue, andget_nl_context()forwarded a single call tonl_rules.nl_rules_context(). Its interface was as complex as its implementation — every caller already had to know the three rule formats, their priority, and the LLM fallback.It fails the deletion test in the good direction, so this PR deletes it:
Pipeline.classify_with_rules()/Pipeline._classify(), next to the orchestration that consumes it (folder policy, moves, triage).kontor_cli.rulesare called directly, so tests mock/stub them (or the singleclassify_with_rulesseam) without an intermediary object.classifycommand now goes through the Pipeline.Changes
Pipeline.__init__loads the three rule sources;classify_with_rules()holds the moved evaluation sequence;_llm_classify()takes NL context straight fromnl_rules.nl_rules_context();rules_engine.pydeleted.kontor-cli classifyusesPipeline.classify_with_rules().rules_engine_test.py->rules_test.py(loader tests unchanged), the priority-order test moved topipeline_test.py::TestClassifyWithRules,coverage_gaps_test.pyRulesEngine gaps now exercise the Pipeline,cli_test.pypatcheskontor_cli.cli.Pipeline.ruff formatapplied tomd_to_docx.py/md_to_docx_test.py(pre-existingformat --checkfailures on main), separate commit.Governance
docs/specifications/ACTIVE/inline-rules-engine-classify.md.ai/work-intake/inline-rules-engine-classify.md.ai/handoff/northstar-inline-rules-engine-classify.md(autobahn prereq-check passes)Verification
uv run pytest tests/unit/ -v— 245 passeduv run ruff check src/ tests/— cleanuv run ruff format --check src/ tests/— cleanuv run mypy src/ --ignore-missing-imports— no issues🤖 Generated with Claude Code
https://claude.ai/code/session_017p6obt6Ua7nB96YTG2XFKf