Skip to content

feat: 村の訂正を curated ナレッジとして発行できるようにする - #1117

Draft
owk-owk130 wants to merge 14 commits into
feat/hil-3-review-uifrom
feat/hil-4-curated-correction
Draft

feat: 村の訂正を curated ナレッジとして発行できるようにする#1117
owk-owk130 wants to merge 14 commits into
feat/hil-3-review-uifrom
feat/hil-4-curated-correction

Conversation

@owk-owk130

@owk-owk130 owk-owk130 commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

概要

ナレッジ HIL 基盤(計画: .brain/plans/knowledge-hil-foundation.md)の PR 4。Issue #1082 × #1083
原本ミラーを書き換えずに、村職員が管理画面から訂正を発行し、次回以降の回答へ決定的に反映させる。

変更内容

発行フロー

  • knowledge_corrections テーブル(正本、migration 0031)。R2 curated/corrections/*.md は D1 からの生成物
  • HIL レビュー詳細から「訂正を作成」→ 対象ソース選択 + 訂正文入力 → 発行。feat(knowledge): curated 区分を新設し検証用ナレッジを追加 #1083 の curated 契約(source_type / source_authority: 2 / verified_at)+ corrects: frontmatter で既存 chunk/embed パイプラインに乗る
  • 「訂正」タブ: 一覧・廃止・要再確認の維持操作。POST /admin/corrections/republish で R2 再構築時の一括再発行(UI なし、運用 API)

Correction Resolver(原則 6: 決定的な反映)

  • searchKnowledge の rerank 後、最終結果の source に対する published 訂正を D1 から引いて必ず注入(Vectorize 往復なし、失敗時は元結果へフォールバック)
  • 計画の図は「Vectorize → Resolver → rerank」だったが、rerank 前の注入では topK=5 で訂正が切られ得るため rerank 後の注入に変更(決定性の保証を優先)
  • knowledge-agent instructions の「訂正を優先」は補助

再クロール耐性

  • 元ファイルの source_hash 変化を index ゲートが検知 → 紐づく published 訂正に要再確認フラグ
  • 「訂正」タブで 維持(確認日を更新して再発行)/ 廃止(R2・Vectorize 削除 → D1 retired)を選択

その他

  • review_decisions に保持期間 1095 日を追加
  • getRequestDb / FilterTabs の共通化

設計メモ

  • 50 文字未満の訂正本文は MIN_CHUNK_LENGTH により embedding されないが、Resolver が D1 から直接注入するため反映は保証される
  • requestContext に db が無い経路(eval スクリプト等)では Resolver は効かない
  • 訂正は trace の hits には載らない(trace は検索の生の結果、Resolver 注入は検索後)
  • AI 下書きは未実装(計画では「可」の扱い。必要になったら追加)

🤖 Generated with Claude Code

https://claude.ai/code/session_018BjNFvQjDzMwF8HaZHnJjP

owk-owk130 and others added 9 commits September 1, 2026 22:06
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018BjNFvQjDzMwF8HaZHnJjP
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018BjNFvQjDzMwF8HaZHnJjP
@owk-owk130 owk-owk130 changed the title feat/hil 4 curated correction feat: 村の訂正を curated ナレッジとして発行できるようにする Sep 1, 2026
@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Coverage Report for server

Status Category Percentage Covered / Total
🟢 Lines 98.12% (🎯 97%) 3769 / 3841
🟢 Statements 97.58% (🎯 96%) 3953 / 4051
🟢 Functions 98.19% (🎯 97%) 709 / 722
🟢 Branches 89.68% (🎯 87%) 1556 / 1735
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
server/src/db/schema.ts 100% 100% 100% 100%
server/src/mastra/request-context.ts 90.9% 87.5% 100% 90.9%
server/src/repository/knowledge-correction-repository.ts 89.47% 75% 85.71% 88.88%
server/src/repository/review-repository.ts 80% 85.71% 71.42% 79.16%
server/src/routes/admin/corrections.ts 100% 87.5% 100% 100%
server/src/services/data-retention.ts 100% 100% 100% 100%
server/src/services/analytics/llm-usage.ts 86.48% 100% 90% 84.84%
server/src/services/knowledge/corrections.ts 100% 100% 100% 100%
server/src/services/knowledge/indexing.ts 100% 100% 100% 100%
server/src/services/knowledge/retrieval-trace.ts 100% 100% 100% 100%
server/src/services/knowledge/search.ts 94.11% 100% 85.71% 93.75%
Generated in workflow #2110 for commit 5aecc20 by the Vitest Coverage Report Action

@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Coverage Report for shared

Status Category Percentage Covered / Total
🟢 Lines 99.23% (🎯 98%) 258 / 260
🟢 Statements 80.7% (🎯 80%) 276 / 342
🟢 Functions 100% (🎯 98%) 88 / 88
🟢 Branches 63.29% (🎯 62%) 119 / 188
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
shared/src/api/types.ts 100% 100% 100% 100%
shared/src/api/repository/correction-repository.ts 77.77% 50% 100% 100%
Generated in workflow #2110 for commit 5aecc20 by the Vitest Coverage Report Action

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Coverage Report for web

Status Category Percentage Covered / Total
🟢 Lines 97.59% (🎯 96%) 1783 / 1827
🟢 Statements 96.43% (🎯 95%) 1895 / 1965
🟢 Functions 96.35% (🎯 95%) 766 / 795
🟢 Branches 89.65% (🎯 88%) 1230 / 1372
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
web/src/app/dashboard/components/CorrectionsPanel.tsx 96.42% 89.18% 100% 100%
web/src/app/dashboard/components/ReviewPanel.tsx 100% 84% 100% 100%
web/src/app/dashboard/components/review/CorrectionForm.tsx 100% 81.81% 100% 100%
web/src/app/dashboard/components/review/ReviewDetailModal.tsx 100% 84.21% 100% 100%
web/src/app/dashboard/hooks/keys.ts 93.33% 100% 92.85% 93.33%
web/src/app/dashboard/hooks/useCorrections.ts 100% 100% 100% 100%
web/src/components/ui/FilterTabs.tsx 100% 100% 100% 100%
web/src/lib/api/repository.ts 100% 100% 100% 100%
Generated in workflow #2110 for commit 5aecc20 by the Vitest Coverage Report Action

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Coverage Report for widget

Status Category Percentage Covered / Total
🟢 Lines 99.62% (🎯 98%) 265 / 266
🟢 Statements 97.94% (🎯 96%) 286 / 292
🟢 Functions 98.11% (🎯 98%) 52 / 53
🟢 Branches 93.28% (🎯 92%) 139 / 149
File CoverageNo changed files found.
Generated in workflow #2110 for commit 5aecc20 by the Vitest Coverage Report Action

owk-owk130 and others added 2 commits September 2, 2026 11:56
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014kkNoEdkn1kVK4La79XFpc
review_decisions の保持期間削除を repository 経由に揃える

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014kkNoEdkn1kVK4La79XFpc
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