Conversation
Replace llm_chat shim with direct Legion::LLM.chat call matching the rest of the codebase convention.
…ire tag, error logging - Fix 1: ingest_to_apollo sends context: instead of metadata: so chunk provenance (source_file, heading, section_path, chunk_index, token_count) is correctly stored in apollo_entries.source_context - Fix 2: llm_embed_available? now also accepts Legion::LLM.embed (single-item); build_embed_map falls back to per-chunk embed when embed_batch is unavailable - Fix 3: retire_file uses content_type 'observation' + tags ['retired'] instead of unknown type 'document_retired'; switches metadata: to context: - Fix 4: retrieve_chunks logs retrieval errors at warn level instead of silently swallowing them - Fix 5: synthesize_answer returns nil (not error string) on LLM failure and logs at warn level - Fix 6: MaintenanceRunner#enabled? also returns true when monitors config is present (no corpus_path required); args falls back to monitors.first[:path] in that case - Fix 7: query_count queries action: 'query' (lex-apollo log value) instead of 'knowledge_query' which always returned 0 - Add log helper to Runners::Query to satisfy Legion/HelperMigration rubocop cop
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
$(cat <<'EOF'
Summary
Seven correctness fixes across
runners/ingest.rb,runners/query.rb,runners/maintenance.rb, andactors/maintenance_runner.rb.Fix 1 —
metadata:→context:iningest_to_apollo(CRITICAL): chunk provenance (source_file,heading,section_path,chunk_index,token_count) was silently dropped by Ruby's double-splat becausehandle_ingestexpectscontext:. Every lex-knowledge chunk stored'{}'inapollo_entries.source_context, breaking all maintenance queries that usesource_context->>'source_file'.Fix 2 —
llm_embed_available?now accepts single-embed providers: previously only checked forLegion::LLM.embed_batch; any LLM that only exposesLegion::LLM.embedcaused all chunks to be stored without embeddings.build_embed_mapnow falls back to per-chunkembedcalls whenembed_batchis unavailable.Fix 3 —
retire_fileuses valid content type andcontext:key: changedcontent_type: 'document_retired'(unknown to lex-apollo, silently stored as:observationwith no signal) tocontent_type: 'observation'withtags: [..., 'retired', ...]for an explicit retirement signal. Also switchedmetadata:→context:to matchhandle_ingestsignature.Fix 4 —
retrieve_chunkslogs errors instead of swallowing them: the anonymousrescue => _e; []pattern silently hid DB/connection errors, causingsynthesize_answerto generate hallucinated answers with no context. Now logs at warn level.Fix 5 —
synthesize_answerreturnsnilon LLM error: previously returned the error message string (e.g."Error generating answer: connection refused") as theanswer:field, which callers presented to users as a real answer. Now returnsniland logs at warn level.Fix 6 —
MaintenanceRunner#enabled?works for monitors-only installs:enabled?previously returned false whencorpus_pathwas nil, so the maintenance actor was never scheduled for installs that usemonitors:config. Now returns true whenRunners::Monitor.resolve_monitors.any?.argsfalls back tomonitors.first[:path]in that case.Fix 7 —
query_countuses correct action string:ApolloAccessLogrecords useaction: 'query'(set by lex-apollo), not'knowledge_query'. The old value always returned 0, makingquality_reporttotals useless.Test plan
source_contextinapollo_entriescontainssource_file,heading,section_path,chunk_index,token_countembed(notembed_batch) and confirm chunks are stored with embeddingscontent_type: 'observation'and tags include'retired'answer:isnilin the response, not an error stringmonitors:only (nocorpus_path) and confirmMaintenanceRunneris enabled and scheduledquality_reporttotal_queriesreturns a non-zero value after running queriesEOF
)