Skip to content

refactor: 休眠 LLM プロバイダ抽象化と関連資産を撤去(ADR-0008)#299

Merged
yusuke0610 merged 1 commit into
mainfrom
refactor/remove-dormant-llm
Jun 1, 2026
Merged

refactor: 休眠 LLM プロバイダ抽象化と関連資産を撤去(ADR-0008)#299
yusuke0610 merged 1 commit into
mainfrom
refactor/remove-dormant-llm

Conversation

@yusuke0610

@yusuke0610 yusuke0610 commented Jun 1, 2026

Copy link
Copy Markdown
Owner

概要

LLM をサービス内で使う見込みが低く、ルールベース(決定論的パイプライン)設計に統一したため、本番フローから到達しない休眠 LLM 関連コード・環境変数・依存・公開 ErrorCode を全撤去し、設計判断を ADR-0008 として記録した。

背景

  • LLM を利用していた機能(キャリア分析 AI・職務経歴書 PDF の AI 抽出)は既に削除済みで、サービスはルールベース設計に統一されている。
  • 残っていた services/intelligence/llm/(Ollama/Vertex AI 抽象化)等は、ルーター・タスクハンドラ・サービスから一切呼ばれていない休眠コードだった。

変更内容

ADR

  • docs/adr/0008-remove-llm-to-rule-based-design.md を Accepted で新規作成
  • docs/adr/0004(LLM プロバイダ抽象化)を Superseded by ADR-0008 に変更、CONTRIBUTING の一覧を更新

コード削除

  • services/intelligence/llm/services/llm/(sanitizer)、utils/prompt_loader.pyapp/prompts/scripts/measure_career_analysis.py
  • settings.py の LLM ゲッター 4 関数、env_keys.py の LLM セクション

公開 ErrorCode

  • LLM_TIMEOUT / LLM_UNAVAILABLE を backend errors.py(enum・分類ロジック)と frontend errorCodes.ts / errorMessages.ts から削除
  • OpenAPI 生成物への影響なしを定量確認make codegen-types 再生成で generated.ts 差分ゼロ。ErrorCode は response model 未宣言のため schema に元々非出力)

env / 依存 / インフラ

  • 環境変数 7 種(LLM_PROVIDER / VERTEX_* / OLLAMA_*)を env_keys / settings / cloud_run / docker-compose / docs/api.md / conftest / ENV_CHECKLIST / .env.example から削除
  • google-genai 依存、docker-compose の ollama サービス・volume、entrypoint.sh の Ollama 起動処理を削除

ドキュメント / ルール

  • README の実体のない AI 機能記述(AIキャリアパス分析・AIによるブログ活動要約)を整理
  • docs/development.md.claude/rules/{architecture,security,auth-security,test}.claude/skills/{SEC_review,SEC_apply,BE_refacter} の LLM 記述を更新(削除済みファイルへの参照を解消)

検証

  • make ci ✅(backend lint/test → frontend test 195 passed → build 成功)
  • make infra-validate ✅(dev/stg/prod すべて valid)
  • E2E(Playwright)✅(初回 2 失敗は並列時の dev server 接続断によるフレーキー。単独再実行で green、変更と無関係)
  • make codegen-types 差分ゼロ ✅

破壊的変更の注記

  • 公開 ErrorCode 2 種の削除(生成物影響なしを確認済み、消費者は frontend のみで追従済み)
  • 環境変数 7 種・google-genai 依存の削除、ADR-0004 の Superseded 化

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Breaking Changes

    • Removed LLM error codes (LLM_TIMEOUT, LLM_UNAVAILABLE) from the public API.
  • Refactor

    • Removed Ollama and Vertex AI LLM integrations, transitioning to rule-based processing.
    • Eliminated LLM service layer and related configuration.
  • Chores

    • Removed LLM environment variables from configuration.
    • Simplified Docker Compose setup by removing Ollama service.
    • Updated dependencies by removing google-genai package.

LLM をサービス内で使う見込みが低くルールベース設計に統一したため、
本番フローから到達しない休眠 LLM 関連コード・環境変数・依存・公開
ErrorCode を全撤去し、設計判断を ADR-0008 として記録した。

- ADR: 0008 を Accepted で起票、0004 を Superseded 化、CONTRIBUTING 更新
- コード: services/intelligence/llm, services/llm(sanitizer),
  utils/prompt_loader, app/prompts, scripts/measure_career_analysis,
  settings.py の LLM ゲッター, env_keys.py の LLM セクションを削除
- ErrorCode: LLM_TIMEOUT / LLM_UNAVAILABLE を BE/FE から削除
  (OpenAPI 生成物への影響なしを確認済み)
- env/依存: LLM_PROVIDER/VERTEX_*/OLLAMA_* 7 種、google-genai、
  docker-compose の ollama サービス、entrypoint.sh の Ollama 起動処理を削除
- ドキュメント: README の実体なき AI 機能記述、docs/api.md・development.md・
  ENV_CHECKLIST・.claude rules/skills の LLM 記述を整理

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 1, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This PR removes LLM integration across the entire codebase and documentation, transitioning from a hybrid LLM-augmented intelligence service to a purely deterministic rule-based design. Backend LLM clients (Ollama and Vertex AI), environment configuration, error codes, infrastructure dependencies, and related tests are completely eliminated.

Changes

Remove LLM Integration, Adopt Rule-Based Design (ADR-0008)

Layer / File(s) Summary
Architecture Decision and Rule Updates
docs/adr/0008-remove-llm-to-rule-based-design.md, docs/adr/0004-llm-provider-abstraction.md, CONTRIBUTING.md, .claude/rules/backend/architecture.md, .claude/rules/backend/auth-security.md, .claude/rules/backend/test.md, .claude/rules/security.md, .claude/skills/BE_refacter/SKILL.md, .claude/skills/SEC_apply/SKILL.md, .claude/skills/SEC_review/SKILL.md, AGENTS.md
ADR-0008 documents the removal decision; ADR-0004 is marked Superseded. Rule and skill documents remove LLM references and adjust review boundaries, test acceptance criteria, and API mock targets.
Backend LLM Service Modules Deletion
backend/app/services/llm/, backend/app/services/intelligence/llm/
Complete removal: LLMClient abstract base class, OllamaClient, VertexClient, factory routing, module exports, and SanitizeContext/sanitize_text/sanitize_project_name/strip_prohibited_fields utilities are deleted.
Configuration, Environment Variables, and Dependencies
backend/app/core/env_keys.py, backend/app/core/settings.py, backend/.env.example, backend/tests/conftest.py, backend/requirements.txt
LLM environment constant definitions, getter functions, example entries, test fixture defaults, and google-genai==1.46.0 dependency are removed.
Error Code Enum and Inference Logic Updates
backend/app/core/errors.py, backend/app/core/logging_utils.py, backend/app/core/metrics.py
Error codes LLM_TIMEOUT and LLM_UNAVAILABLE are removed from the enum and inference function. Documentation examples and docstrings are updated from LLM operation names to GitHub collector operation names.
Infrastructure, Deployment, and Startup Script Updates
docker-compose.yml, backend/scripts/entrypoint.sh, Makefile, docs/development.md, infra/modules/cloud_run/main.tf
Ollama service definition, ollama_data volume, and service dependencies are removed from docker-compose. Entrypoint script removes Ollama model sync/warm-up logic. Makefile and docs remove Ollama references. Cloud Run Terraform removes LLM environment variable injection.
Frontend Error Codes and Messages Alignment
frontend/src/constants/errorCodes.ts, frontend/src/constants/errorMessages.ts, frontend/src/api/client.test.ts, frontend/src/components/github-link/GitHubLinkDashboard.test.tsx, frontend/src/hooks/useTaskPolling.test.ts, frontend/src/test/handlers.ts
LLM error codes are removed from the exported constant; corresponding message mappings are deleted. Test expectations are updated to use new error codes and external-service connectivity messages instead of LLM-specific wording.
Test File and Fixture Cleanup
backend/tests/test_llm_clients.py, backend/tests/services/llm/test_sanitizer.py, backend/tests/test_prompt_loader.py, backend/tests/conftest.py
Entire test modules for LLM clients, sanitizer, and prompt loader are deleted. Test fixture updates add CORS_ORIGINS and TASK_RUNNER defaults while removing LLM-related defaults; docstring is updated to reference external API calls instead of LLM.
Documentation and Data Policy Removal
backend/docs/llm_data_policy.md, docs/api.md, infra/environments/prod/ENV_CHECKLIST.md, infra/environments/stg/ENV_CHECKLIST.md, README.md, backend/scripts/measure_career_analysis.py
LLM data policy document is deleted. API documentation removes LLM environment variable section. Environment checklists remove LLM configuration entries. README removes LLM from tech stack and removes measurement script. Task handler docstrings reference external API calls instead of LLM.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • yusuke0610/devforge#245: Introduces LLM-dependent intelligence handling (e.g., run_github_analysis, llm_summarizer, career analysis) that directly contradicts this PR's removal of LLM integration from the intelligence pipeline.

Poem

🐇 Farewell, Ollama and Vertex dreams,
Rules now reign where LLMs once gleamed,
No more tokens, prompts, or abstraction's call—
Deterministic logic conquers all!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately describes the primary change: removal of dormant LLM provider abstraction and related assets as per ADR-0008. The title is concise, specific, and directly reflects the main objective of the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/remove-dormant-llm

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
.claude/rules/backend/test.md (1)

40-40: ⚡ Quick win

**This test-policy addition is in-scope for the ADR-0008 (LLM removal) refactor; no split needed

  • .claude/rules/backend/test.md の「失敗パスを明示的に検証/silent return 許容禁止」(39行目付近)と「モックは最小限」(40行目)は、LLM 関連資産撤去(ADR-0008)のコミット(c1d3858)で追加された。
  • 内容はすでに .claude/CLAUDE.md にある既存方針(test_no_cache_returns_early などの silent-return を残さない/タスクハンドラの「黙って return」禁止)を明文化したもの。
  • PR 目的にこのテスト方針の追加が未記載なら、PR/ADR に一言リンクを足す程度で十分。**
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.claude/rules/backend/test.md at line 40, 追加されたテスト方針「失敗パスを明示的に検証/silent
return 許容禁止」と「モックは最小限」は既に存在する方針(test_no_cache_returns_early
等)と重複しているので、重複を解消してください:差分で追加された見出し(「失敗パスを明示的に検証/silent return
許容禁止」「モックは最小限」)を削除するか簡潔に要約して残し、その代わりに既存方針(参照:
test_no_cache_returns_early)への明示的なリンクをPR/ADRの説明(またはコミット c1d3858
に言及)に追加して一貫性を保つように修正してください。
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In @.claude/rules/backend/test.md:
- Line 40: 追加されたテスト方針「失敗パスを明示的に検証/silent return
許容禁止」と「モックは最小限」は既に存在する方針(test_no_cache_returns_early
等)と重複しているので、重複を解消してください:差分で追加された見出し(「失敗パスを明示的に検証/silent return
許容禁止」「モックは最小限」)を削除するか簡潔に要約して残し、その代わりに既存方針(参照:
test_no_cache_returns_early)への明示的なリンクをPR/ADRの説明(またはコミット c1d3858
に言及)に追加して一貫性を保つように修正してください。

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 439b3065-30d0-4917-8b86-8461678e443d

📥 Commits

Reviewing files that changed from the base of the PR and between ef76408 and c1d3858.

📒 Files selected for processing (52)
  • .claude/rules/backend/architecture.md
  • .claude/rules/backend/auth-security.md
  • .claude/rules/backend/llm.md
  • .claude/rules/backend/test.md
  • .claude/rules/security.md
  • .claude/skills/BE_refacter/SKILL.md
  • .claude/skills/SEC_apply/SKILL.md
  • .claude/skills/SEC_review/SKILL.md
  • AGENTS.md
  • CONTRIBUTING.md
  • Makefile
  • README.md
  • backend/.env.example
  • backend/app/core/env_keys.py
  • backend/app/core/errors.py
  • backend/app/core/logging_utils.py
  • backend/app/core/metrics.py
  • backend/app/core/settings.py
  • backend/app/prompts/.gitkeep
  • backend/app/services/intelligence/llm/__init__.py
  • backend/app/services/intelligence/llm/base.py
  • backend/app/services/intelligence/llm/factory.py
  • backend/app/services/intelligence/llm/ollama_client.py
  • backend/app/services/intelligence/llm/vertex_client.py
  • backend/app/services/llm/__init__.py
  • backend/app/services/llm/sanitizer.py
  • backend/app/services/tasks/exceptions.py
  • backend/app/services/tasks/handlers/base.py
  • backend/app/utils/prompt_loader.py
  • backend/docs/llm_data_policy.md
  • backend/requirements.txt
  • backend/scripts/entrypoint.sh
  • backend/scripts/measure_career_analysis.py
  • backend/tests/conftest.py
  • backend/tests/services/llm/__init__.py
  • backend/tests/services/llm/test_sanitizer.py
  • backend/tests/test_llm_clients.py
  • backend/tests/test_prompt_loader.py
  • docker-compose.yml
  • docs/adr/0004-llm-provider-abstraction.md
  • docs/adr/0008-remove-llm-to-rule-based-design.md
  • docs/api.md
  • docs/development.md
  • frontend/src/api/client.test.ts
  • frontend/src/components/github-link/GitHubLinkDashboard.test.tsx
  • frontend/src/constants/errorCodes.ts
  • frontend/src/constants/errorMessages.ts
  • frontend/src/hooks/useTaskPolling.test.ts
  • frontend/src/test/handlers.ts
  • infra/environments/prod/ENV_CHECKLIST.md
  • infra/environments/stg/ENV_CHECKLIST.md
  • infra/modules/cloud_run/main.tf
💤 Files with no reviewable changes (29)
  • backend/app/services/intelligence/llm/init.py
  • backend/app/services/intelligence/llm/base.py
  • backend/app/core/logging_utils.py
  • backend/app/services/llm/init.py
  • docs/api.md
  • frontend/src/constants/errorCodes.ts
  • backend/app/services/intelligence/llm/factory.py
  • .claude/rules/backend/llm.md
  • backend/requirements.txt
  • infra/modules/cloud_run/main.tf
  • backend/tests/services/llm/test_sanitizer.py
  • infra/environments/prod/ENV_CHECKLIST.md
  • backend/app/core/env_keys.py
  • backend/tests/test_llm_clients.py
  • AGENTS.md
  • backend/app/utils/prompt_loader.py
  • backend/docs/llm_data_policy.md
  • backend/app/services/intelligence/llm/vertex_client.py
  • backend/tests/test_prompt_loader.py
  • infra/environments/stg/ENV_CHECKLIST.md
  • backend/app/core/errors.py
  • backend/scripts/entrypoint.sh
  • backend/app/services/llm/sanitizer.py
  • backend/app/core/settings.py
  • backend/app/services/intelligence/llm/ollama_client.py
  • backend/.env.example
  • frontend/src/constants/errorMessages.ts
  • backend/scripts/measure_career_analysis.py
  • docker-compose.yml

@yusuke0610
yusuke0610 merged commit 94be2e2 into main Jun 1, 2026
18 checks passed
@yusuke0610
yusuke0610 deleted the refactor/remove-dormant-llm branch June 1, 2026 10:05
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