Skip to content

Refactor causaliq-knowledge codebase to meet project coding policies

Please provide a plan to refactor the causaliq-knowledge code base to ensure coding policies are adhered to, in particular that scripts/check_code_rules.py reports no breaches.

Please stage the work into separate commits if you consider that desirable.

Constraints

  • Behaviour must stay byte-identical
  • Preserve import binding sites
  • No behaviour-free bulk test rewrites: add focused tests only where coverage gaps appear

Quality Gates (as in scripts/check_ci.ps1)

  • black --check src tests
  • isort --check-only src tests
  • flake8 src tests
  • mypy src/
  • python scripts/check_code_rules.py --strict src/causaliq_knowledge

Commit Scope

1 refactor(graph): split response models from parsing response.py + 2 new src modules + 3 test modules + response.md 2 refactor(graph): decompose prompt variable formatting prompts.py (_format_variable_details, build) 3 refactor(graph): dispatch LLM client creation and share query helpers generator.py (_create_client, _execute_query, _execute_pdg_query) 4 refactor(graph): extract cache metadata parsing cache.py + new cache_metadata.py 5 refactor(llm): decompose base client cache path base_client.py, cache.py 6 refactor(llm): decompose vendor completion and model listing anthropic/gemini/groq/ollama/openai_compat_client.py 7 refactor(cli): decompose cache management commands cli/cache.py + new cli/cache_helpers.py 8 refactor(cli): decompose generate and list-models commands cli/generate.py, new cli/generate_output.py, cli/models.py 9 refactor(action): decompose graph generation execution action.py 10 docs(ci): correct code-rules gate path (optional) docs/current_task.md (src/causaliq_core → src/causaliq_knowledge); optionally flip scripts/check_ci.ps1 to --strict