Skip to content

feat(ti): hertz ↔ Lume OTLP discovery, body unwrapping, JSON UDFs, and docs_kinds schema - #87

Open
kordless wants to merge 3 commits into
mainfrom
feat/hertz-otlp
Open

kordless wants to merge 3 commits into
mainfrom
feat/hertz-otlp

Conversation

@kordless

@kordless kordless commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Implements items a, b, c, d1, d2, e, and f for hertz ↔ Lume OTLP integration and document/logbook querying, plus updating stale semantic-search warning/error messages:

  • a (/health identity): GET /health and HEAD /health return 200. When no authentication is configured, or when a valid HTTP/Nuts/OTLP bearer is supplied, GET /health returns {"service":"lume","version":"<CARGO_PKG_VERSION + commit>","otlp":<bool>,"auth":<bool>}. When authentication is required (--http-token-file, --nuts-auth, or --otlp-token-file) and the request has no valid bearer, GET /health returns only {"service":"lume","auth":true} without leaking version or OTLP details (HEAD /health remains 200).
  • b (serve.json discovery file): lume serve and lume ti ingest --serve write serve.json atomically (0600 on Unix) on bind with {service, url, port, pid, version, otlp, token_file, started} (never the token string), defaulting to ~/.lume/serve.json with --discovery-file <path> and --no-discovery-file, and remove it on clean shutdown when pid matches. Documents multi-instance and Windows Ctrl-C stale-file edge cases (--help, README.md, REFERENCE.md, CHANGELOG.md).
  • c (Plugin OTLP switch): Adds otlpEnabled (bool, default false, "Accept radio and agent logs from hertz (OTLP)") to plugins/signalk-lume-ti. When enabled, creates <plugin-config-data>/otlp.token (32 random bytes hex, mode 0600) if missing, passes --otlp --otlp-token-file <path> --discovery-file <path> to lume, exposes OTLP receiver status and token file path (never contents) in /api/status and the web UI, and ignores empty "***" secret placeholders on config save.
  • d1 (OTLP log AnyValue unwrapping): parse_logs_json unwraps stringValue, intValue, doubleValue, boolValue, arrayValue, kvlistValue, and bytesValue recursively so docs.body stores plain JSON values (e.g., {"body":"...","channel":"WX3","freq_mhz":162.475}). Note: only newly ingested OTLP log rows are unwrapped; existing rows in previously built stores retain their original shape.
  • d2 (json_str and json_num SQL functions): Adds json_str(expr, 'key') (returning Text or Null) and json_num(expr, 'key') (returning Float or Null, parsing numeric strings when needed) in WHERE, SELECT, GROUP BY, and ORDER BY across ti-sql and lume sql.
  • e & f (Agent prompt & schema guidance for docs + CHANGELOG.md):
    • ti_schema (when docs is non-empty) includes document_titles (title, count, min_ts, max_ts) and a compact document_guide note explaining how to query docs by title = '<title>' (ORDER BY ts_start DESC) and extract JSON fields with json_str/json_num instead of exact-spelling LIKE when transcripts may contain ASR/Whisper spelling errors.
    • src/agent.rs and src/chat_sql.rs prompts include a compact note to check ti_schema for docs titles (radio.weather, radio.transcript, logbook, etc.) when telemetry series have no match, and chat_sql.rs renders docs rows (ts_start, title, source, body) cleanly alongside telemetry series results.
    • Additional chat_sql.rs hardening:
      1. ti_schema / ti_query tool args tolerate LLM hallucinated "store" strings (falling back to the bound store when the path does not exist) and coerce stringified "width_seconds" (e.g. "300").
      2. When an Ollama model outputs a SELECT/WITH query inside a ```sql fenced block without emitting a structured tool_calls entry (needed by qwen2.5:7b during the acceptance run when it emits SQL in a fenced ```sql block), synthesize_unexecuted_sql_tool_call synthesizes at most one ti_query/lume_sql call per turn for the first unexecuted SQL block, skips already-executed SQL, and returns None when a final answer merely quotes already-executed SQL so the loop terminates cleanly (covered by unit test fenced_sql_synthesis_runs_at_most_once_and_skips_already_executed_sql).
  • Semantic search unavailable message (src/search.rs): Replaces the stale "no semantic session — index with -s" text in both HybridStrict error and fallback warning with "Semantic search unavailable for this index (no vectors — reindex with --embed-model embeddinggemma-2, Shivvr at --shivvr-url, default http://localhost:8085)" (keeping "; falling back to lexical BM25." on the warning) and updates unit tests and tests/search_golden/*.stdout.

Verification

  • cargo fmt --check (TI crates) & rustfmt --check --edition 2021 (touched files + build.rs): exit 0
  • CARGO_INCREMENTAL=0 cargo clippy --locked -p ti-contracts -p ti-core -p ti-store -p ti-ingest -p ti-sql -p ti-sync -p ti-bench -p ti-geo -p lume --features lume/ti --all-targets -- -D warnings: exit 0
  • CARGO_INCREMENTAL=0 cargo test --locked --features ti: exit 0
  • cd plugins/signalk-lume-ti && node --check index.js lib/supervisor.js public/app.js test/otlp.test.js && npm test: exit 0 (99/99 pass)
  • Hand acceptance check (lume serve --ti-store <tmp> --otlp + hertz OTLP logs + lume agent --ti-store <tmp> --ollama-model qwen2.5:7b "What was the temperature in New Braunfels on the last NOAA weather broadcast?"): exit 0 (discovers radio.weather via ti_schema, runs SELECT title, body, ts_start FROM docs WHERE title = 'radio.weather' ORDER BY ts_start DESC LIMIT 1, and answers 89 degrees from the newest broadcast despite Whisper's "Newbrand Fulls" spelling).

@kordless

Copy link
Copy Markdown
Contributor Author

Lead review: approved at 0f92d8b. All four review items are addressed: /health returns minimal identity to unauthenticated callers when auth is on, the fenced-SQL synthesis has tests, the discovery-file caveats are documented, and the build.rs overlap with #84 is deferred to a rebase. CI 16/16 green. Merge after #82–#86, rebasing onto #84 first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant