feat(lib-ollama-client): num_ctx overflow detection diagnostic warn log (Phase A / 順位 98)#142
Conversation
…nt 構造に書き換え (Phase A〜E)
…og + 順位 98 cleanup + analysis.md Phase A完了/B真因確定 (Phase A)
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
✅ Files skipped from review due to trivial changes (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthrough本PRは Ollama クライアントの JSON 解析失敗時に num_ctx overflow を診断する型・メソッド・ロジックを追加し、Phase A〜E の段階的修復スケジュールをドキュメント化する。生レスポンスメタデータから閾値ベースの hint を算出して stderr に出力し、関連タスクを task roadmap に登録する。 ChangesOverflow Diagnosis & Repair
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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.
Inline comments:
In `@docs/local-llm-offload-analysis.md`:
- Line 200: The markdown link
"[docs-governance.md](https://github.com/aloekun/claude-code-hook-test/blob/master/docs/adr/)"
is pointing to the wrong URL; update the link in
docs/local-llm-offload-analysis.md (the retirement workflow line) so the link
target matches the link text (docs-governance.md) and points to the actual
governance document location (replace the "/docs/adr/" URL with the correct path
to docs-governance.md in the repo).
In `@docs/todo-summary.md`:
- Around line 75-77: The table rows currently point to todo5.md but the
file-wide policy in the intro says new details should go to docs/todo6.md; pick
one canonical target and make the file consistent: either change the three table
entries that reference "todo5.md" to "docs/todo6.md" (or vice‑versa), and update
the introductory policy text to match that choice; also search for other
occurrences of "todo5.md" or "docs/todo6.md" in this document and adjust
cross‑references so all links and the intro policy are consistent with the
selected canonical file.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 2ec3bd1e-646f-481f-9d43-565d4df2da72
📒 Files selected for processing (5)
docs/local-llm-offload-analysis.mddocs/todo-summary.mddocs/todo5.mddocs/todo6.mdsrc/lib-ollama-client/src/lib.rs
…8 を todo5→todo6 に戻し policy 整合
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
…4) + workflow gap 反映 Phase D dogfood の 1 本目 (D-1)。3 件 ADR 採用 + Phase D 計画 land + workflow gap 反映を bundled。 順位 112 (PR #142 T3-#3): ADR-038 に 2 section 追記 - Diagnostic logging scope: eprintln (CLI 前提) と structured logging 移行条件 - 90% 閾値 rationale: 保守採用根拠 + Phase D 完了時の precision/recall 評価方針 順位 113 (PR #142 T3-#4): ADR-027 に metrics override 判断基準追記 - Incidental change vs Responsibility change の線引き - Override 記述様式 (Override / Reason / Rationale の 3 項目) 順位 114 (PR #143 T3-#1): ADR-040 新規作成 - mistral:7b context size 実測値 (8K 512MB 5-20s ↔ 32K 2GB 30-90s) - step_timeout 3.33x 比例係数の根拠 - num_ctx 選定 flow chart - CLAUDE.md ADR index 追加 - lib-ollama-client/src/lib.rs L128-139 dogfood evolution コメントを 4 行参照に短縮 Phase D 計画 land + workflow gap (新規): - analysis.md に D-1/D-2/D-3 PR 構成 + 計測手順 + 想定リスクを追加 - D-1 着手時に判明した workflow gap (jj auto-snapshot vs session-only opt-in) を計測手順に反映 - env var override (LINT_SCREEN_ENABLED) を todo8.md / todo-summary.md (順位 115) に backlog 登録 - D-1 自身は dogfood skip、env var override land 後に D-2 / D-3 で実 dogfood 実施 D-1 lint_screen 状態: skipped。Phase D guide §1 session-only opt-in workflow が jj auto-snapshot と 本質的に衝突するため、配列 env var override の cli-push-runner 実装 (順位 115) を D-2 前に land 必須。
Summary
Phase d retirement への critical path Phase A (順位 98 =
num_ctxoverflow detection diagnostic warn log) を land。Phase A 実装と同時の dogfood で Phase B 真因 (num_ctx truncation = 100% 到達) を確定。次の next action は Phase C (DEFAULT_NUM_CTX = 8192 → 16384増加) で確定。lib-ollama-clientのgenerate_jsonヘルパーが serde parse error 時に stderr へ診断 log emitOllamaMetadatastruct (prompt_eval_count / eval_count / num_ctx)OllamaApi::generate_with_metadata(default fallback で既存 stub impl 影響なし)prompt_eval_count: 8192 (vs num_ctx: 8192)= 100% 到達を実機確認、真因 decisive 判定変更内容
Commit 1: docs only (前 turn carry-over)
順位 106-108 (PR #141 post-merge-feedback 採用分) を docs/todo5.md + docs/todo-summary.md に登録 + analysis.md の「次に何をするか」を critical path to retirement 構造 (Phase A〜E) に書き換え。retirement 条件 (本ファイル削除) を明示、旧 dogfood outcome を 1 行 table に圧縮、Bundle c-1 等を critical path 外 section に分離。
Commit 2: Phase A 実装 + 順位 98 cleanup + analysis.md Phase A/B 結果反映
src/lib-ollama-client/src/lib.rs(+198 行)新 API:
generate_jsonヘルパー (型付き parse) はgenerate_with_metadataを経由するよう変更。parse error 時にemit_overflow_diagnosticを呼び、overflow_hint(純粋関数、testable) が prompt_eval_count >= 90% num_ctx 時に hint を返す。OllamaClient::generate_with_metadataを override:request_envelopeヘルパーで envelope 全体を取得し、prompt_eval_count/eval_countを metadata に流す。num_ctxは client の setting を埋める。warn log format (stderr):
Tests (16/16 pass)
新規 5 件 + 既存 11 件:
metadata_carries_prompt_eval_count_when_provided: mockito で envelope にprompt_eval_count: 1234を含めて流し、metadata に伝搬されることを assertmetadata_handles_missing_eval_counts_gracefully: prompt_eval_count 欠落時に None になることを assert + num_ctx は client setting を反映stub_trait_default_returns_empty_metadata: trait の default impl で metadata がDefault::default()になることを assert (StubOllama 互換性)emit_overflow_diagnostic_includes_hint_when_prompt_eval_count_near_cap: prompt_eval_count 7400 / num_ctx 8192 (90.3%) で hint emit を確認emit_overflow_diagnostic_skips_hint_when_metadata_absent: metadata default で hint なしtodo cleanup
docs/todo6.md: 順位 98 detail entry 削除 (-54 行)docs/todo-summary.md: 順位 98 row 削除analysis.md Phase A完了 + Phase B 真因確定 を反映
Phase B dogfood result (実機確認、本 PR commit 2 land の smoke で取得)
PR #141 (P-3 = 187 行 mixed diff) を deployed cli-finding-classifier に replay:
真因 decisive 判定: prompt_eval_count = num_ctx = 8192 で完全 truncation 発生 → mistral が JSON output を完成できず
screen_decisionfield 欠落の症状。lint-screen prompt + 187 行 diff で context が完全に埋まる。Test plan
cargo test -p lib-ollama-client— 16/16 pass (5 新規 + 11 既存)cargo build --release -p lib-ollama-clientcleancargo build --release -p cli-finding-classifierclean (依存 crate)pnpm deploy:hooksで linter / 関連 hook を更新.claude/に再 deploy (target/release/cli-finding-classifier.exe→.claude/cli-finding-classifier.exe)prompt_eval_count: 8192 (vs num_ctx: 8192)= 100% を実機確認Out of scope (Phase C 以降で対応)
DEFAULT_NUM_CTX = 8192 → 16384増加): 真因確定により本 PR 別で実施。 RAM 影響評価 + lint-screen evals 15 件 regression test + smoke dogfood で fallback rate 低下確認src/cli-push-runner/src/stages/lint_screen.rs) は classifier exit が 0 のとき stderr を.takt/lint-screen-report.mdに出さない。push-runner 経由でも warn log を見るには別 PR で取込対応必要 (今回は manual 呼出で diagnostic 機能を確認)lib-ollama-clientは本リポ専用、現状 deploy 不要関連
Summary by CodeRabbit
リリースノート
New Features
Documentation