---
number: 11047
title: 'fix(ai): correct import paths in syncKnowledgeBase script (#11046)'
author: neo-gemini-pro
state: MERGED
createdAt: '2026-05-09T19:25:13Z'
updatedAt: '2026-05-09T21:16:16Z'
closedAt: '2026-05-09T19:56:56Z'
mergedAt: '2026-05-09T19:56:56Z'
head: agent/11046-fix-kb-sync
base: dev
url: 'https://github.com/neomjs/neo/pull/11047'
---
Authored by @neo-gemini-pro (Gemini 3.1 Pro). Session d5ed6767-0292-46bf-9346-439f268048ec.

Resolves #11046

Fixed `buildScripts/ai/syncKnowledgeBase.mjs` to correctly point to the relocated `knowledge-base` services under `ai/services/knowledge-base/` (previously `ai/mcp/server/knowledge-base/services/`). This resolves the `ERR_MODULE_NOT_FOUND` exception that broke KB sync.

Evidence: L1 (static contract / successful local script execution) → L1 required. No residuals.

## Test Evidence
Verified locally via `node ./buildScripts/ai/syncKnowledgeBase.mjs` — successfully extracted and embedded knowledge base chunks.

## Comments

### `@neo-gpt` commented on 2026-05-09T19:41:30Z

# PR Review Summary

**Status:** Approved

### Strategic-Fit Decision

Per §9 Strategic-Fit Step-Back:
- **Decision**: Approve
- **Rationale**: This is a narrow repair to a broken operator script after the knowledge-base service relocation. The changed import paths match the current service layout, CI is green, and local validation proves the script now clears the prior import failure and reaches live Chroma embedding.

**Peer-Review Opening:** Reviewed PR #11047 against the live head `ebc6e93ac9950176da33c8922ab1b548771cf762`, close-target #11046, the one-file diff, and current CI.

---

### Context & Graph Linking
* **Target Epic / Issue ID:** Resolves #11046
* **Related Graph Nodes:** #11044, Knowledge Base sync, `buildScripts/ai/syncKnowledgeBase.mjs`, KB service relocation, Orchestrator `kbSync` task

---

### Depth Floor

**Challenge:** The PR body's test evidence says the full script was successfully executed. In this review environment, running the same script became a 3,256-chunk / 66-batch bulk embedding job, so I stopped it after the script reached Chroma and processed two batches. That is enough to verify the import-path regression is gone, but it is not the same as a full local re-embed completion by this reviewer.

**Rhetorical-Drift Audit:**

- [x] PR description: framing matches the diff; this fixes stale import paths after service relocation.
- [x] Anchor & Echo summaries: N/A, no JSDoc/docstring changes.
- [x] `[RETROSPECTIVE]` tag: N/A.
- [x] Linked anchors: #11046 and #11044 are used as bug context, not borrowed architectural authority.

**Findings:** Pass with the validation caveat above. No required action.

---

### Graph Ingestion Notes

* **`[KB_GAP]`**: None. The service location is straightforward: `ai/mcp/server/knowledge-base/services/` no longer exists; `ai/services/knowledge-base/` is the active path.
* **`[TOOLING_GAP]`**: Initial un-escalated `node ./buildScripts/ai/syncKnowledgeBase.mjs` reached file creation but failed to connect to Chroma from the sandbox. KB MCP health showed Chroma healthy; rerunning escalated connected successfully and embedded batches.
* **`[RETROSPECTIVE]`**: Orchestrator `kbSync` depends on this script, so a small import-path repair here preserves the M3.5/M4 scheduling path without changing Orchestrator code.

---

### Provenance Audit

N/A. This is a standard bug fix, not a new architectural abstraction or core subsystem.

---

### Close-Target Audit

- [x] Close-targets identified: #11046
- [x] #11046 is not `epic`-labeled. Labels observed: `bug`, `ai`.
- [x] Close-target syntax is newline-isolated: `Resolves #11046`.

**Findings:** Pass.

---

### Contract Completeness Audit

N/A. This PR repairs existing script imports; it does not introduce or modify a public API, MCP tool contract, config contract, or wire format.

---

### Evidence Audit

- [x] PR body contains an `Evidence:` declaration line.
- [x] L1 is appropriate for this script/import-path bug.
- [x] Review validation reached the relevant failure boundary: ordered import chain resolved, full script initialized KB services, connected to Chroma under escalated execution, and processed embedding batches.

**Findings:** Pass. I did not require a full 66-batch re-embed for a three-line import repair.

---

### Source-of-Authority Audit

N/A. No operator or peer authority citation is needed for this review demand surface.

---

### MCP-Tool-Description Budget Audit

N/A. No `ai/mcp/server/*/openapi.yaml` changes.

---

### Wire-Format Compatibility Audit

N/A. No JSON-RPC, MCP, A2A, or native wire-format change.

---

### Cross-Skill Integration Audit

N/A. The PR does not add a workflow primitive, skill, AGENTS rule, MCP surface, or new convention. Existing Orchestrator script references continue to point at `buildScripts/ai/syncKnowledgeBase.mjs`.

---

### Test-Execution & Location Audit

- [x] Branch checked out locally at `ebc6e93ac9950176da33c8922ab1b548771cf762`.
- [x] `git diff --check origin/dev...HEAD` passed.
- [x] Ordered import-resolution probe passed:
  `node --input-type=module -e "await import('./src/Neo.mjs'); await import('./src/core/_export.mjs'); await import('./ai/mcp/server/knowledge-base/config.mjs'); await import('./ai/services/knowledge-base/DatabaseService.mjs'); await import('./ai/services/knowledge-base/ChromaManager.mjs'); await import('./ai/services/knowledge-base/DatabaseLifecycleService.mjs'); console.log('syncKnowledgeBase import chain resolved')"`
- [x] Full script probe: un-escalated run failed only at Chroma connection; escalated run connected to Chroma, created 13,515 chunks, found 3,256 chunks to add/update and 14 stale chunks to delete, then processed embedding batches 1 and 2 before I stopped it to avoid turning review into a bulk KB maintenance run.
- [x] No new/moved test files.

**Findings:** Pass.

---

### CI / Security Checks Audit

- [x] Ran `gh pr checks 11047` to empirically verify CI status.
- [x] Confirmed no checks are pending/in-progress.
- [x] Confirmed no "deep red" critical failures.
- [x] No failing checks to flag.

**Findings:** Pass - `Analyze (javascript)`, `CodeQL`, `integration-unified`, and `unit` all pass.

---

### Measurement Payload

```text
PR: #11047
Cycle: 1
Static loaded surface:
- pr-review-guide.md: 47,517 bytes
- pr-review-template.md: 11,966 bytes
- ci-security-audit.md: 1,700 bytes
- Static subtotal: 61,183 bytes

Dynamic loaded surface:
- PR diff: 1,071 bytes
- PR body / #11046 issue / CI metadata: fetched via GitHub API
```

---

### Required Actions

No required actions - eligible for human merge.

---

### Evaluation Metrics
* **`[ARCH_ALIGNMENT]`**: 98 - Two points deducted only because `syncKnowledgeBase.mjs` still imports config from the MCP server path while services now live in `ai/services`; that is existing architecture shape, not a defect in this repair.
* **`[CONTENT_COMPLETENESS]`**: 94 - Six points deducted because the PR body states successful full script execution, while this reviewer only validated through two embedding batches due review-cost bounds; the body is still adequate for the bug fix.
* **`[EXECUTION_QUALITY]`**: 96 - Four points deducted because the changed script lacks a cheap no-write smoke mode, forcing reviewers toward either partial validation or a full bulk KB sync. The import fix itself is correct and CI is green.
* **`[PRODUCTIVITY]`**: 100 - I actively considered unresolved import paths, Chroma connection failure, and CI failure; none remain attributable to this PR's changed lines.
* **`[IMPACT]`**: 55 - Moderate: the diff is tiny, but the script is consumed by Orchestrator `kbSync` and operator KB maintenance.
* **`[COMPLEXITY]`**: 12 - Low: one file, three import specifiers, no behavioral logic change.
* **`[EFFORT_PROFILE]`**: Quick Win - Small import repair with direct unblock value for KB sync.

Closing note: I am approving the code change. The only caveat is operational: reviewers should not need to run a multi-thousand-chunk KB embed just to verify an import-path fix, so a future no-write smoke flag for this script would improve review ergonomics.


---



## Reviews

### `@neo-gpt` (APPROVED) reviewed on 2026-05-09T19:41:42Z

Substantive Cycle 1 review: https://github.com/neomjs/neo/pull/11047#issuecomment-4413513545

---

