luigidemasi commented on code in PR #214:
URL: https://github.com/apache/camel-kit/pull/214#discussion_r4740816394
##########
.github/workflows/index-release.yml:
##########
@@ -46,14 +46,34 @@ jobs:
- name: Build reviewed index
run: ./mvnw install -pl knowledge/index -am -B -Dformat.skip=true
+ # Read collection ID before quality gate to configure tests appropriately
+ - name: Read collection metadata
+ id: collection
+ run: |
+ COLLECTION_ID=$(jq -r '.collectionId // "apache-camel"'
knowledge/index/src/main/resources/index.json)
+ echo "collection_id=$COLLECTION_ID" >> "$GITHUB_OUTPUT"
+ echo "Collection ID: $COLLECTION_ID"
+
# Quality gate — the mcp tests evaluate the reviewed in-repo index
# (knowledge.index.path in test config points at
knowledge/index/src/main/resources/knowledge-index).
# eval.requireVectors makes a disabled vector leg (model mismatch /
failed
# embedding self-check) a hard failure instead of graceful degradation.
+ # All collections: verify vectors work
+ # apache-camel only: also run corpus-specific assertions (Camel 4.22,
Timer IDs, apache_camel domain)
- name: Retrieval quality gate
run: >
./mvnw test -pl knowledge/mcp -am -B -Dformat.skip=true
-Deval.requireVectors=true
+ -Dknowledge.index.collection-id=${{
steps.collection.outputs.collection_id }}
+ -Dtest=VectorVerificationTest,RetrievalQualityTest
Review Comment:
**P1 · Run the release checks in the modules and corpora they cover**
I ran this command for both `apache-camel` and a custom ID. Both stopped in
`camel-kit-knowledge-schema` because `-am` applies the test selector to an
upstream module containing no matching tests. The second command has the same
problem. There is also no `VectorVerificationTest` on this revision. After
allowing nonmatches upstream, a custom index that served hybrid queries still
hit `RetrievalQualityTest`’s unconditional Camel 4.22 assertion. Target the MCP
tests explicitly, keep shared vector and corpus-specific retrieval checks for
custom releases, and run the community judgments only for `apache-camel`.
Exercise both workflow commands before publication.
_AI-generated by Codex on behalf of @luigidemasi._
##########
knowledge/indexer/src/main/java/org/apache/camel/kit/knowledge/indexer/IndexerMain.java:
##########
@@ -133,12 +174,38 @@ private static Path resolvePath(String sysProp, String
argValue, String defaultV
return Path.of(defaultValue).toAbsolutePath();
}
- private static List<DocumentDomain> buildDomains(Path cacheDir, Path
resourcesDir) throws IOException {
+ private static List<DocumentDomain> buildDomains(Path cacheDir, Path
resourcesDir, String collectionId)
+ throws IOException {
List<DocumentDomain> domains = new ArrayList<>();
- // Add all registered domains here
- domains.add(new ApacheCamelDomain(cacheDir, resourcesDir));
+ // Apache Camel collection uses the built-in ApacheCamelDomain
+ // Custom collections can either:
+ // 1. Implement custom DocumentDomain and register it here
+ // 2. Use ApacheCamelDomain and override via -Dcollection.sources
+ if ("apache-camel".equals(collectionId)) {
+ domains.add(new ApacheCamelDomain(cacheDir, resourcesDir));
+ LOG.info("Building apache-camel collection with
ApacheCamelDomain");
+ } else {
+ // For custom collections without a registered domain, use
ApacheCamelDomain
+ // The collection.sources property determines what actually gets
indexed
+ LOG.info("Building custom collection '{}' with ApacheCamelDomain.
" +
+ "To index custom sources, provide -Dcollection.sources
with your repository list.",
+ collectionId);
+ domains.add(new ApacheCamelDomain(cacheDir, resourcesDir));
Review Comment:
**P1 · Build from the sources recorded in provenance**
I built two collections through `IndexerMain` with separate Git
repositories, different revisions and disjoint guide text. MCP correctly
reported each declared repository and revision, but both searches returned the
identical `apache-camel` release-note ID and content from my community fixture.
Both branches here still instantiate `ApacheCamelDomain`. `collection.sources`
is read only after domain selection and passed on as metadata. Connect the
selected inputs to ingestion, derive provenance from what was read, and test
the two builds through MCP. Keep unknown collections from publishing misleading
provenance.
_AI-generated by Codex on behalf of @luigidemasi._
##########
knowledge/mcp/src/main/java/org/apache/camel/kit/knowledge/mcp/LuceneSearchService.java:
##########
@@ -635,20 +755,41 @@ private List<SearchResult> executeSearch(Query query, int
maxResults) throws IOE
* {@link IndexDownloader}), with classpath extraction as the legacy
fallback for uber-jars bundling the index.
*/
private IndexDownloader.ResolvedIndex resolveIndex() throws IOException {
+ IOException acquisitionError = null;
try {
return indexDownloader.resolve();
} catch (IOException e) {
+ acquisitionError = e;
+ // For pinned versions or strict collection requirements, fail
immediately
if (indexDownloader.isVersionPinned()) {
throw e;
}
+ // For custom collections without fallback, fail with diagnostic
+ String requestedCollection = config.collectionId();
+ if (!"apache-camel".equals(requestedCollection) &&
!config.allowFallback()) {
+ throw new IOException(
+ String.format("Failed to resolve collection '%s': %s",
+ requestedCollection, e.getMessage()),
+ e);
+ }
LOG.warn("Index resolution failed ({}), falling back to classpath
extraction", e.getMessage());
}
- Path classpath = extractIndexFromClasspath();
- String[] files = classpath.toFile().list();
- LOG.info("LuceneSearchService: classpath fallback, path = {}, files =
{}",
- classpath, files != null ? files.length : 0);
- return new IndexDownloader.ResolvedIndex(classpath, true);
+ // Try classpath extraction as legacy fallback
+ try {
+ Path classpath = extractIndexFromClasspath();
+ String[] files = classpath.toFile().list();
+ LOG.info("LuceneSearchService: classpath fallback, path = {},
files = {}",
+ classpath, files != null ? files.length : 0);
+ return new IndexDownloader.ResolvedIndex(classpath, true);
Review Comment:
**P2 · Preserve the acquisition error when the runner has no bundled index**
The strict custom-miss diagnostic is fixed. With an empty cache and an
unreachable manifest, the standard runner still returned `no segments* file
found` in a temporary directory for both a community request and a custom
request with fallback enabled. Extraction returns an empty directory, and
`DirectoryReader.open()` fails later in `init()`, outside this catch. Check
that the extracted index can be opened before returning it, clean up
unsuccessful extraction, and preserve the original resolver error and recovery
path.
_AI-generated by Codex on behalf of @luigidemasi._
##########
knowledge/mcp/src/main/java/org/apache/camel/kit/knowledge/mcp/IndexDownloader.java:
##########
@@ -559,6 +709,11 @@ private void downloadAndUnpack(URI manifestUri, Manifest
manifest, Path cacheDir
Files.createDirectory(partDir);
partCreated = true;
unzip(zipFile, partDir);
+
+ // Verify collection metadata in staged index before activation
+ verifyStagedIndex(partDir, manifest);
Review Comment:
**P1 · Verify a retained snapshot before reactivating it**
Fresh downloads now reject a declared/embedded version mismatch and preserve
the working release. I cached releases A and B with corpus `1.0`, then served a
manifest selecting A but declaring corpus `2.0`. Because A’s directory already
existed, `resolveCached()` skipped `downloadAndUnpack()`, moved `current` from
B back to A, and MCP served `1.0`. Apply the same identity check before
switching to an existing directory. A regression test should verify that B
stays active when the manifest for the retained A disagrees with its contents.
_AI-generated by Codex on behalf of @luigidemasi._
##########
docs/modules/ROOT/pages/knowledge.adoc:
##########
@@ -114,6 +114,91 @@ root. Maintainers review generated data before manually
dispatching `Index Relea
`main`; the workflow validates retrieval with working vectors before
publication. Index
publication is independent of Kit and Knowledge server releases.
+[[collections]]
+== Custom documentation collections
+
+Knowledge supports versioned, isolated documentation collections for custom
content.
+Each collection has its own index, cache directory and GitHub release tag
namespace.
+
+=== Building a custom collection
+
+Currently, only the `apache-camel` collection is fully supported. To build a
custom
+collection using Apache Camel content with custom metadata:
+
+[source,bash]
+----
+./mvnw clean install -pl knowledge/index -am -Prebuild-index -B \
+ -Dcollection.id=my-vendor \
+ -Dcollection.version=1.0.0 \
+ -Dcollection.sources='[{"repo":"my-org/docs","branch":"main"}]'
+----
+
+The build validates `collection.sources` as a JSON array and stamps the
collection metadata
+into the index. Custom collections require implementing a `DocumentDomain`
class for your
+content sources; until then, the documented command builds with
`ApacheCamelDomain`.
+
+=== Selecting a collection
+
+[source,bash]
+----
+# Select custom collection (default: apache-camel)
+-Dknowledge.index.collection-id=my-vendor
+
+# Optional: pin to specific version
+-Dknowledge.index.version=2026.11.30-150000
+
+# Optional: allow fallback to apache-camel if custom unavailable
+-Dknowledge.index.allow-fallback=true
Review Comment:
**P2 · Make the selection example executable**
The new guide covers cache layout, provenance and fallback. Pasting its Bash
selection block exits 127 because each `-D` option is a separate command. For a
runner built from this checkout, the options belong before `-jar`.
```suggestion
# Run from the repository root after packaging the Knowledge MCP runner.
# To pin a release, add -Dknowledge.index.version=2026.11.30-150000 before
-jar.
# To allow community fallback, add -Dknowledge.index.allow-fallback=true
before -jar.
java -Dknowledge.index.collection-id=my-vendor -jar
knowledge/mcp/target/*-runner.jar
```
_AI-generated by Codex on behalf of @luigidemasi._
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]