luigidemasi commented on code in PR #214:
URL: https://github.com/apache/camel-kit/pull/214#discussion_r4741262168
##########
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));
+ // Currently only apache-camel collection is fully supported
+ // Custom collections require implementing a DocumentDomain that reads
from collection.sources
+ if ("apache-camel".equals(collectionId)) {
+ domains.add(new ApacheCamelDomain(cacheDir, resourcesDir));
+ LOG.info("Building apache-camel collection with
ApacheCamelDomain");
+ } else {
+ // Custom collections without a registered DocumentDomain cannot
be built
+ // ApacheCamelDomain always indexes Apache Camel content
regardless of collection.sources
+ throw new IllegalArgumentException(
Review Comment:
**Support custom sources through the production build.** I gave
`IndexerMain` two local Git repositories with different documents and pinned
revisions. Both builds stopped here with “is not registered” before reading
either source. `CollectionIsolationTest` constructs its domains directly.
Inverting the condition that admits `apache-camel` left all 117 indexer test
outcomes unchanged. Please wire source registration into the normal build and
exercise it with two disjoint repositories, then query both outputs through
MCP. This is the build acceptance case in #199.
_AI-generated by Codex on behalf of @luigidemasi._
##########
knowledge/mcp/src/main/java/org/apache/camel/kit/knowledge/mcp/IndexDownloader.java:
##########
@@ -238,6 +313,18 @@ private ResolvedIndex resolveCached(Path cacheDir) throws
IOException {
Path versionDir = versionDirectory(cacheDir, manifest.version());
if (!Files.isDirectory(versionDir)) {
downloadAndUnpack(manifestUri, manifest, cacheDir, versionDir);
+ } else {
+ // Verify cached snapshot before reactivating it - must match
declared version
+ LOG.info("Version {} already cached, verifying before
reactivating", manifest.version());
+ try {
+ verifyStagedIndex(versionDir, manifest);
Review Comment:
**Validate a warm version pin against a freshly fetched manifest.** With
releases A and B cached, the new check correctly kept B active when an unpinned
rollback advertised corpus 2.0 for A, which contains 1.0. Pinning A against
that same manifest made index info report 1.0 and search return hits. Pinning
the current B produced the same result when its manifest declared 2.0. With a
pin, `cachedDirectory()` returns the pinned directory, so the same-release
return above this block skips verification. Check a fresh declaration before
returning that directory and propagate a confirmed incompatibility through the
cache-fallback handler. An offline restart with a previously verified pin
should still work.
_AI-generated by Codex on behalf of @luigidemasi._
##########
knowledge/indexer/src/main/java/org/apache/camel/kit/knowledge/indexer/IndexerMain.java:
##########
@@ -62,14 +62,45 @@ public static void main(String[] args) throws Exception {
Files.createDirectories(outputDir);
- List<DocumentDomain> domains = buildDomains(cacheDir, resourcesDir);
+ // Get collection metadata from system properties first
+ String collectionId = System.getProperty("collection.id",
"apache-camel");
+ String collectionVersion = System.getProperty("collection.version",
+ Instant.now().toString().substring(0, 19).replace(':', '-'));
+
+ LOG.info("Collection ID: {}", collectionId);
+ LOG.info("Collection Version: {}", collectionVersion);
+
+ // Build domains based on collection ID
+ List<DocumentDomain> domains = buildDomains(cacheDir, resourcesDir,
collectionId);
+
+ // Derive collection sources from actual domains built, or validate
user-provided sources
+ String collectionSources = System.getProperty("collection.sources");
+ if (collectionSources != null && !collectionSources.isBlank()) {
+ // Validate user-provided sources is valid JSON array using
org.json
+ try {
+ org.json.JSONArray sourcesArray = new
org.json.JSONArray(collectionSources);
+ // Re-serialize to ensure clean JSON
+ collectionSources = sourcesArray.toString();
Review Comment:
**Report the sources actually indexed.** The supported `apache-camel` build
still accepts a different repository and revision in `collection.sources`. I
pointed it at a Foo guide and supplied the Apache domain with a separate
community repository. The build succeeded. `camel_docs_index_info` attributed
the collection to Foo, while a search returned the community release note with
`source=apache-camel`. Derive provenance from the inputs the domain consumed,
or reject declarations the domain cannot honor. A test should compare the
reported source and revision with the repository that supplied the search hit.
_AI-generated by Codex on behalf of @luigidemasi._
##########
knowledge/mcp/src/main/java/org/apache/camel/kit/knowledge/mcp/IndexDownloader.java:
##########
@@ -463,10 +551,13 @@ private Manifest fetchManifest(URI uri, Path cacheDir,
String cachedVersion)
||
!OnnxEmbeddingProvider.MODEL_ID.equals(root.path("embeddingModel").asText())) {
throw new IOException("Index format or embedding model is
incompatible with this server");
}
+ // Read optional collectionVersion from manifest (for corpus version
validation)
+ String collectionVersion = root.path("collectionVersion").asText(null);
Review Comment:
**Check the collection ID declared by the manifest.** This parser reads
`collectionVersion` and discards `collectionId`. On an empty cache I requested
`mixed-guides` with a manifest declaring `other-guides` and an archive stamped
`mixed-guides`. The runner activated the archive and served results. Compare an
explicitly declared manifest ID with the selected collection and the embedded
ID before activation. Preserve the documented compatibility behavior for older
manifests that omit the field.
_AI-generated by Codex on behalf of @luigidemasi._
##########
.github/workflows/index-release.yml:
##########
@@ -46,14 +46,25 @@ 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.
+ # Currently only apache-camel collection is supported for building
- name: Retrieval quality gate
+ if: steps.collection.outputs.collection_id == 'apache-camel'
run: >
- ./mvnw test -pl knowledge/mcp -am -B -Dformat.skip=true
+ ./mvnw verify -pl knowledge/mcp -B -Dformat.skip=true
Review Comment:
**Build the MCP dependencies from the reviewed commit.** I ran the two
release commands in order with a Maven repository containing third-party
dependencies and no previously installed Camel Kit artifacts. The index install
succeeded. This command then failed to resolve `camel-kit-knowledge-schema` and
`camel-kit-knowledge-embedding` at `0.0.3-SNAPSHOT`, before it ran a single
test. Including the required modules in the reactor also avoids testing stale
snapshots from a warm runner.
```suggestion
./mvnw verify -pl knowledge/mcp -am -B -Dformat.skip=true
```
_AI-generated by Codex on behalf of @luigidemasi._
##########
.github/workflows/index-release.yml:
##########
@@ -46,14 +46,25 @@ 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.
+ # Currently only apache-camel collection is supported for building
- name: Retrieval quality gate
+ if: steps.collection.outputs.collection_id == 'apache-camel'
Review Comment:
**Gate every collection that the workflow can publish.** This condition
skips the only retrieval check for custom IDs, but packaging and publication
still run. I exercised the packaging step locally with a `mixed-guides` index
that the runner reported as `bm25-only+rerank`. It produced a valid ZIP and a
custom release tag. Require a corpus-independent vector and retrieval check for
every publishable collection, with Camel-specific assertions conditional on
`apache-camel`. If custom publication is intentionally deferred, fail before
packaging a custom manifest.
_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]