Status: Active planning document
The completed v1.1 operationalization work is preserved in the repository at
docs/archive/MCP_operationalization.md. This document defines the next priorities rather than reopening completed foundation work.
KnowCode already has the core operational foundations: a canonical MCP
contract, freshness reporting, supported-language checks, knowcode doctor,
local telemetry, and an MCP handshake check. The next release should turn
those foundations into a calibrated, verifiable, and easy-to-adopt product.
The most important open evidence is retrieval routing quality. The committed 60-record corpus is now explicitly calibration-only, with atomic facts, prohibited claims, and AST-resolved source citations. It is not a locked holdout and cannot enable local answering. Runtime routing therefore defaults to an empty task allowlist until independent machine adjudication and the blocking Python external gates pass. See Testing & Evaluation for the evidence contract.
- Correctness is the release gate. Token savings, consumer installers, and lifecycle convenience must not make stale or uncalibrated answers appear trustworthy.
- A green
knowcode doctor --mcpis necessary but not sufficient. It proves local artifacts and the MCP transport are healthy; retrieval evaluation and freshness/coverage tests prove that the answer path is trustworthy. - The canonical MCP contract remains the single policy source. Runtime code, agent rules, setup documentation, and tests must agree on it.
- Preserve compatibility deliberately. Changes to MCP tool names or response shapes require a documented migration path and regression coverage.
- Keep telemetry local by default, make its retention and privacy tradeoffs explicit, and use measured data before changing thresholds or budgets.
| Foundation | Current evidence | Ongoing regression gate |
|---|---|---|
| MCP operating contract | MCP Contract documents minimal-first retrieval and the escalation ladder. | Contract tests must exercise production-like minimal responses. |
| Freshness and coverage safety | The scanner, watcher, and doctor validate source coverage and stale artifacts. |
Modify/create/delete/rename tests and doctor freshness checks remain required. |
| Local readiness verification | knowcode doctor --mcp checks config, artifacts, disk use, agent rules, and an MCP handshake. |
Doctor must stay fast, deterministic, and actionable. |
| Local telemetry | JSONL events record retrieval, agent-routing, and MCP tool activity. | Event-schema compatibility and failure isolation tests remain required. |
Goal: turn the existing evaluation harness into a release-quality source of truth for local-answer routing.
Why first: the current evaluation data says a score of 0.8 is
over-confident. No payload, onboarding, or automation improvement can make an
uncalibrated local-answer gate safe.
Work:
- Run the real
Agent.smart_answerescalation path over source-cited records. Require two independently configured judge providers to return strict claim verdicts with valid citations, three times each; disagreement, partial support, malformed output, missing evidence, or provider failure is a fail. - Validate the judges with mechanically generated true/false source mutations.
Require macro F1 of at least
0.95and zero false acceptance of critical negative canaries. - Select a global threshold from
0.50through1.00. Enable a task type only when a locked holdout has at least 29 routed cases, zero critical failures, and a one-sided exact-binomial 95% correctness lower bound of at least0.90. - Make Python RepoBench-R archive/v0 and RepoQA blocking. Compare KnowCode with
BM25 over the identical candidate corpus and token budget; every primary
metric's seeded paired-bootstrap lower bound must be at least
-0.02. - Track fixed CrossCodeEval-100 and SWE-bench-Lite-50 A/B suites as non-blocking downstream evidence until three consecutive runs support an explicit promotion decision.
- Publish a versioned machine-verification artifact with the selected policy, floors, source hashes, dataset revisions, provider/model identities, prompt hashes, and canary results. Never describe it as human-reviewed.
Exit criteria: the routing policy is source-verified, independently machine-adjudicated, externally benchmarked, versioned, and enforced by CI. Missing credentials, source or dataset drift, judge instability, BM25 inferiority, and blessed-baseline regression all fail closed.
Progress (2026-07-31): the proof and validation harness has moved to the
independent knowcode-evals repository. KnowCode now contains only a
checksum-pinned, source-bound schema 1.1 policy consumer and runtime
enforcement tests. The evaluator owns the datasets, judges, benchmark adapters,
statistics, workflow, and artifact issuance. P1 remains deliberately unblessed
because the 60 records are calibration data and no qualifying locked holdout
plus full external baseline has yet passed.
Goal: prove the canonical MCP policy is what production code actually does.
Why now: the documentation and runtime had drifted: the direct LLM agent requested the default minimal projection while still reading metadata that minimal responses omit. Contract tests must keep covering the real projection, not only mocks that return diagnostic-style payloads.
Work:
- Make
Agent.answerandAgent.smart_answerexplicitly request the metadata they need, or derive task metadata without relying on omitted fields. - Add end-to-end tests for minimal retrieval, budget/verbosity escalation, and local-versus-LLM routing using the actual orchestrator response shape.
- Make
knowcode doctor --mcpand the release checklist reference the same tool, defaults, threshold ownership, and response guarantees as the canonical contract.
Exit criteria: agent, MCP, CLI, docs, and tests use one contract with no implicit reliance on fields hidden by minimal mode.
Progress (2026-08-11):
Agent.answerandAgent.smart_answernow request the minimal projection with the task metadata they consume.smart_answerfollows the contract escalation ladder: narrow minimal, broader minimal, then standard detail before LLM fallback, while reusing the final retrieval instead of querying a fourth time.- Integration coverage now exercises local and LLM routing against the actual
RetrievalOrchestratorprojection. - Done:
knowcode doctor --mcpand thedocs/engineering/release.mdconformance audit are completed, validating the canonical toolretrieve_context_for_queryand minimal projection response formatting.
Goal: reduce recurring MCP schema and context costs without weakening the calibrated correctness floor.
Dependencies: P1 and P2. Evaluate every change against the blessed golden baseline and routing-quality gate.
Work:
- Prototype one
knowcodeMCP tool with anactionenum forsearch,context,trace,query, andquality. Keep the existing five tools available behind an explicit compatibility option for one release. - Define response profiles that are summary-first for exploratory work and expose raw source only for explicit source requests or task types that need it, such as debugging and review.
- Add byte/token caps per action to regression tests and record payload-size distributions in local telemetry.
Exit criteria: default tool/result payloads are measurably smaller, golden retrieval and routing quality do not regress, and migration guidance is published before the legacy tool surface changes.
Goal: make the canonical MCP policy and connection setup installable rather than a collection of hand-maintained per-agent files.
Dependencies: P2; P3 if the consolidated tool becomes the default surface.
Work:
- Add a product-owned
.knowcode/agent-rules.mdthat references the canonical contract and distinguishes semantic queries from direct file/grep work. - Add an idempotent
knowcode install-agent <consumer>flow for verified MCP consumers, beginning with the clients actively supported by the project. - Add
knowcode doctor --agent <consumer>checks for generated configuration, rule inclusion, and an end-to-end tool invocation where the client supports programmatic verification. - Treat each client configuration as an explicit compatibility target. Do not claim support for a consumer until its current configuration syntax and runtime behavior are verified.
Exit criteria: a supported consumer can be configured predictably from one command, its rules point to the canonical policy, and doctor can identify a broken setup with an actionable fix.
Goal: reduce the chance that ordinary repository changes leave KnowCode artifacts stale while preserving explicit user control.
Dependencies: P2. The existing freshness safety remains the fallback if automation is unavailable or fails.
Work:
- Add an optional repo-local freshness manifest that records the source state used to build the store and index, including Git state where available.
- Offer opt-in post-commit and background refresh helpers. They must never block a commit, silently modify unrelated configuration, or hide a refresh failure.
- Document optional always-on watch-service templates for supported local environments, with a normal foreground fallback.
Exit criteria: users can opt into low-friction refresh automation, while
every failure path remains visible through freshness metadata and doctor.
Goal: turn existing JSONL telemetry into a local decision tool.
Dependencies: P1 and P2, so summary metrics use calibrated routing terms.
Work:
- Add
knowcode stats --usage [--since <duration>]backed by the existing telemetry summary support. - Report calls per day, routing rate, mean sufficiency, stale-response count, payload-size distribution, and available per-consumer attribution.
- Add clear retention, redaction, and deletion guidance for local query logs.
Exit criteria: a developer can understand whether KnowCode is used, trusted, fresh, and cost-effective without manually parsing JSONL.
P1 and the implementation work in P2 can proceed in parallel, but the
release-candidate evaluation must run against the P2 production response
shape. P3 follows once the correctness baseline and contract are stable.
P4, P5, and P6 can proceed independently after their listed dependencies
are met.
The next trust release ships only when all of the following are true:
- P1 and P2 exit criteria are met.
- The full test suite, including the server-extra API contract suite, passes.
knowcode doctor --mcppasses for the supported local configuration.- Freshness and language-coverage checks report no unresolved correctness warnings for the target repository.
P3 through P6 improve efficiency and adoption, but they are not permitted to weaken these release gates.
- A shared or hosted multi-tenant knowledge service.
- Making the HTTP gateway the primary path for this roadmap.
- Automatically rewriting agent configuration without an explicit user command.
- Declaring compatibility for an agent consumer before its current setup and invocation behavior are verified.
- Cost optimization that bypasses the retrieval and routing-quality gates.