Skip to content

refactor(knowledge_engine): extract Config load + prepare_repos, eliminate loop-level I/O#16

Merged
juice094 merged 3 commits into
mainfrom
refactor/knowledge-engine-config
May 11, 2026
Merged

refactor(knowledge_engine): extract Config load + prepare_repos, eliminate loop-level I/O#16
juice094 merged 3 commits into
mainfrom
refactor/knowledge-engine-config

Conversation

@juice094
Copy link
Copy Markdown
Owner

Summary

Phase C-1:知识引擎结构重构 + 性能优化。

Changes

  • index_repo: 改为通过参数接收 Config,不再内部调用 Config::load()
  • daemon.rs: 在索引循环前一次性加载 Config
  • run_index_with_progress: 将 Config::load() 从循环内提取到循环外
  • 提取 prepare_repos() 纯辅助函数,负责路径解析与自动注册

Verification

  • cargo check / cargo fmt / cargo clippy -W warnings
  • 427 tests all pass ✅

juice094 added 3 commits May 11, 2026 20:46
- Extend RegistryClient with save_relation, query_relations, delete_relations, list_vault_notes
- Add WorkflowClient trait (list_workflows, get_workflow, run_workflow, get_execution)
- Add VaultClient trait (list_vault_notes, read_vault_note, get_backlinks, build_vault_graph)
- Implement all traits on AppContext (registry.rs, workflow/mod.rs, vault/mod.rs)
- Enable AppContext Clone via Arc<Mutex<EnvVersionCache>> for spawn_blocking safety
- Refactor relations.rs, workflow.rs, vault.rs to use trait calls exclusively
- Eliminate all production-code inline crate:: calls in mcp/tools/ relations|workflow|vault
…inate loop-level I/O

- index_repo: accept Config by parameter instead of loading internally
- daemon.rs: load Config once before indexing loop
- run_index_with_progress: hoist Config::load() out of repo loop
- Extract prepare_repos() pure helper for path resolution / auto-registration
- Result: ~20 fewer inline crate:: calls, eliminated repeated disk I/O in hot loop
@juice094 juice094 merged commit 210a0ae into main May 11, 2026
6 checks passed
juice094 pushed a commit that referenced this pull request May 17, 2026
…rf baselines, Tantivy consistency

端到端 workflow 测试 (Task #16):
- Add MCP-tool-level DAG workflow integration tests:
  test_workflow_run_dag_success: 3-step Condition chain via
  DevkitWorkflowRunTool -> DevkitWorkflowStatusTool round-trip
  test_workflow_run_failure_propagation: verifies ErrorPolicy::Fail
  status propagation to execution record

性能回归基线校准 (Task #17):
- Fix schema bug in perf tests (missing `signature` column caused panic)
- Add profile-aware thresholds via cfg!(debug_assertions):
  release 1k<200ms/10k<500ms; debug 1k<800ms/10k<2000ms
- Add latency eprintln reporting for CI observability

RF-7 路径隐私修复 (Task #18):
- Add sanitize_path() helper: replaces home dir prefix with ~,
  normalizes \ to /
- Apply across project_context output: repo.path, modules.path,
  symbols.file, calls.caller_file, assets.path
- Add 5 unit tests for path desensitization logic

Tantivy 一致性强化 (Task #19):
- Fix AppContext to use actual storage backend's index_path for
  repair_tantivy_consistency_at and sync_index_to_db_at (was
  hardcoded to DefaultStorageBackend, breaking TempStorageBackend)
- Fix repair_tantivy_consistency_at early-return bug: now loads
  SQLite IDs first; on Tantivy read failure reports
  missing_from_index = sqlite_ids.len() instead of silently 0
- Add tests: fresh_workspace consistency, empty-index+DB-repos
  detection, AppContext correct index path verification

Formatting:
- Run cargo fmt across workspace to satisfy CI fmt --check

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
juice094 added a commit that referenced this pull request May 18, 2026
…selines, Tantivy consistency

* docs: 精简 AGENTS.md + 生产就绪检查清单

- AGENTS.md: 705→258 行,保留核心约束(环境指引/关键约定/安全原则/架构红线/禁止事项)
- docs/AGENTS-full.md: 保留完整版(历史记录/路线图/详细讨论)
- docs/production-readiness.md: 新增生产就绪检查清单
  - 6 大维度:稳定性/性能/MCP/Agent集成/文档/发布流程
  - 4 阶段推进计划:Phase0(当前)→Phase1(稳定化)→Phase2(Agent试点)→Phase3(v1.0)
  - 所有条目客观可验证,禁止主观描述

* chore: code health maintenance across workspace

- Add description fields to 12 crates missing them in Cargo.toml
- Remove dead code: sync_skills_to_clarity (Client-Agnostic violation),
  update_repo_last_synced_at, list_workspaces_by_tier
- Add SAFETY comments to 4 unsafe env var blocks in mcp/tests.rs
- RepairResult caller now logs orphan/missing counts; remove allow(dead_code)
- Remove unused FolderScheduler::new, add NOTE for retained dead_code

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

* test(registry): Wave 1 coverage for relation + health modules

- relation: add test_list_relations, test_find_related_entities_bidirectional,
  test_save_relation_upsert (was only 1 smoke test)
- health: add test_get_health_batch covering batch query, empty input,
  and partial miss scenarios
- 5 tested crates now at 88-97% region coverage

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

* feat(sync): managed flag transparency and repo status commands

- Add MANAGED_TAGS constant and RepoEntry::is_managed() in registry.rs
  Document that managed lives in repo_tags (queryable) not metadata
- Replace inline MANAGED_TAGS check in sync/tasks.rs with repo.is_managed()
- Add devbase repo list: shows managed flag, type, tier, path
- Add devbase repo status: batch git health (ahead/behind/dirty/managed)
  with health cache TTL reuse and --json support
- Enhance sync output: categorize skipped repos by reason with counts

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

* docs(mcp): freeze 5 Stable Tools schemas with dedicated reference docs

- Promote devkit_hybrid_search from Beta to Stable
- Add docs/reference/stable-tools/{health,project_brief,hybrid_search,
  vault_search,session_recall}.md with frozen input/output schemas,
  example requests/responses, and error catalogs
- Add stable-tools/README.md with stability guarantee contract
- Update mcp-tools.md cross-links and tier markings
- Add docs/clients/claude/scenarios.md with 5 usage scenarios

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

* test(registry): Wave 2 coverage for code-symbols, call-graph, dead-code

- code-symbols: 9 tests covering query_all, type filter, name filter,
  file_path filter, combined filters, limit, cross-repo isolation,
  optional field preservation
- call-graph: 8 tests covering all_edges, callee/caller/file filters,
  combined filters, limit, cross-repo isolation
- dead-code: 6 tests covering include_pub/exclude_pub, caller exclusion,
  tests.rs exclusion, limit, empty repo
- All 3 crates raised from 0% to functional coverage

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

* feat(mcp): scenario E2E tests, oplog tracing, and vault_search fix

Scenario validation tests for Claude onboarding and semantic code
exploration revealed a production-grade silent-failure bug in
devkit_vault_search: VaultNote deserialization from partial JSON
failed and was masked by unwrap_or_default(), causing all queries
to return empty results.

- Add append_mcp_oplog() NDJSON tracing for tool call latency
  and error classification
- Add seed_scenario_data() + two scenario integration tests
- Fix vault_search to operate on serde_json::Value directly,
  eliminating the deserialization trap

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

* feat(mcp): add MCP oplog analytics to devkit_oplog_query

Extend devkit_oplog_query with an `analytics` flag that reads
mcp-oplog.ndjson and returns statistical reports:
- tool call frequency and success rate per tool
- latency percentiles (P50, P95, P99)
- error classification breakdown
- time range coverage

Also fixes clippy lint issues in sort_by closures.

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

* feat(tests,security,perf): Phase 1 hardening — workflow E2E, RF-7, perf baselines, Tantivy consistency

端到端 workflow 测试 (Task #16):
- Add MCP-tool-level DAG workflow integration tests:
  test_workflow_run_dag_success: 3-step Condition chain via
  DevkitWorkflowRunTool -> DevkitWorkflowStatusTool round-trip
  test_workflow_run_failure_propagation: verifies ErrorPolicy::Fail
  status propagation to execution record

性能回归基线校准 (Task #17):
- Fix schema bug in perf tests (missing `signature` column caused panic)
- Add profile-aware thresholds via cfg!(debug_assertions):
  release 1k<200ms/10k<500ms; debug 1k<800ms/10k<2000ms
- Add latency eprintln reporting for CI observability

RF-7 路径隐私修复 (Task #18):
- Add sanitize_path() helper: replaces home dir prefix with ~,
  normalizes \ to /
- Apply across project_context output: repo.path, modules.path,
  symbols.file, calls.caller_file, assets.path
- Add 5 unit tests for path desensitization logic

Tantivy 一致性强化 (Task #19):
- Fix AppContext to use actual storage backend's index_path for
  repair_tantivy_consistency_at and sync_index_to_db_at (was
  hardcoded to DefaultStorageBackend, breaking TempStorageBackend)
- Fix repair_tantivy_consistency_at early-return bug: now loads
  SQLite IDs first; on Tantivy read failure reports
  missing_from_index = sqlite_ids.len() instead of silently 0
- Add tests: fresh_workspace consistency, empty-index+DB-repos
  detection, AppContext correct index path verification

Formatting:
- Run cargo fmt across workspace to satisfy CI fmt --check

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

* chore(release): bump version to 0.20.1

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

* fix(ci): invariant checker should skip tests.rs files

The G5 RF-6 rule was flagging  in
as production code because the skip regex  did not match
 (no trailing slash).  in test modules is
idiomatic Rust and should not be flagged.

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

* chore(release): update Cargo.lock for v0.20.1

The release workflow uses --locked which requires Cargo.lock
to be in sync with Cargo.toml version bumps.

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

---------

Co-authored-by: juice094 <juice094@outlook.com>
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
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