Private
Public Access
0
0
Files
manual_slop/tests/test_tool_bias.py
T
ed 8f11340b38 refactor(consumers): migrate 85 'from src.models import' sites to direct subsystem imports
Per post_module_taxonomy_de_cruft_20260627 Phase 2 (FR7). Each
'from src.models import X' for a moved class is rewritten to
'from src.<destination> import X':

  Ticket, Track, WorkerContext, TrackState, TrackMetadata,
    ThinkingSegment, EMPTY_TRACK_STATE            -> src.mma
  ProjectContext, ProjectMeta, ProjectOutput, ProjectFiles,
    ProjectScreenshots, ProjectDiscussion, EMPTY_PROJECT_CONTEXT -> src.project
  FileItem, Preset, ContextPreset, ContextFileEntry,
    NamedViewPreset                                -> src.project_files
  Tool, ToolPreset                                 -> src.tool_presets
  BiasProfile                                      -> src.tool_bias
  TextEditorConfig, ExternalEditorConfig,
    EMPTY_TEXT_EDITOR_CONFIG                       -> src.external_editor
  Persona                                          -> src.personas
  WorkspaceProfile                                -> src.workspace_manager
  MCPServerConfig, MCPConfiguration, VectorStoreConfig,
    RAGConfig, load_mcp_config                      -> src.mcp_client

NOT touched (kept on src.models; Phase 3 or Phase 4 will move them):
  GenerateRequest, ConfirmRequest, DEFAULT_TOOL_CATEGORIES, Metadata, PROVIDERS

Migration was performed by the one-time script
scripts/tier2/artifacts/post_module_taxonomy_de_cruft_20260627/migrate_imports.py
which uses a class-to-module map and re.sub() to rewrite each
'from src.models import X' line.

Total: 85 import lines rewritten across 71 files.

Note: this commit depends on the v2 SHIPPED work
(origin/tier2/module_taxonomy_refactor_20260627) being merged into
this branch NEXT. On master (without the v2 SHIPPED commits), the
destination modules do not exist and these imports would fail.
2026-06-26 13:34:03 -04:00

52 lines
1.7 KiB
Python

import pytest
from src.tool_bias import ToolBiasEngine
from src.tool_bias import BiasProfile
from src.tool_presets import ToolPreset, Tool
def test_apply_semantic_nudges():
engine = ToolBiasEngine()
preset = ToolPreset(name="test", categories={
"General": [
Tool(name="read_file", weight=5),
Tool(name="list_directory", weight=1)
]
})
# Mock tool definitions (simplified MCP_TOOL_SPECS)
tool_defs = [
{"name": "read_file", "description": "Read file content.", "parameters": {"properties": {"path": {"description": "Path to file"}}}},
{"name": "list_directory", "description": "List dir.", "parameters": {"properties": {"path": {"description": "Path to dir"}}}}
]
nudged = engine.apply_semantic_nudges(tool_defs, preset)
assert "[HIGH PRIORITY]" in nudged[0]["description"]
assert "[LOW PRIORITY]" in nudged[1]["description"]
def test_parameter_bias_nudging():
engine = ToolBiasEngine()
preset = ToolPreset(name="test", categories={
"General": [
Tool(name="read_file", parameter_bias={"path": "PREFERRED"})
]
})
tool_defs = [
{"name": "read_file", "description": "Read file.", "parameters": {"properties": {"path": {"description": "Path."}}, "required": ["path"]}}
]
nudged = engine.apply_semantic_nudges(tool_defs, preset)
assert "[PREFERRED]" in nudged[0]["parameters"]["properties"]["path"]["description"]
def test_generate_tooling_strategy():
engine = ToolBiasEngine()
preset = ToolPreset(name="test", categories={
"General": [Tool(name="read_file", weight=5)]
})
bias = BiasProfile(name="test", category_multipliers={"General": 2.0})
strategy = engine.generate_tooling_strategy(preset, bias)
assert "Tooling Strategy" in strategy
assert "read_file" in strategy
assert "General" in strategy