Skip to content

feat(observability): trace retrieval evidence - #29

Open
DivyamTalwar wants to merge 1 commit into
mainfrom
codex/retrieval-observability-20260824
Open

feat(observability): trace retrieval evidence#29
DivyamTalwar wants to merge 1 commit into
mainfrom
codex/retrieval-observability-20260824

Conversation

@DivyamTalwar

Copy link
Copy Markdown
Owner

Why

JITMIND combines sparse, dense, graph, temporal, and reranking stages, but operators currently have to infer failures and latency from console prints. There is no structured answer to “which retriever contributed this evidence?”, “where were candidates removed?”, or “which stage got slow?”.

What changed

  • adds a dependency-free RetrievalTrace contract with per-stage duration, input/output counts, status, and error type
  • instruments keyword, vector, page-index, and graph retrieval in both sync and async paths
  • records fusion channels, deduplicated candidate count, temporal rejections, and score-only top-evidence metadata
  • exposes the completed trace in ResearchOutput.raw_memory and through explain_last_retrieval()
  • adds pluggable TraceSink, an in-memory sink, and a process-safe JSONL sink
  • hashes query text by default; raw content capture requires explicit opt-in
  • keeps export failures non-blocking so telemetry cannot break a valid answer

Competitive rationale / provenance

Arize Phoenix demonstrates the value of OpenTelemetry-based tracing plus retrieval evaluation for debugging AI systems: https://github.com/Arize-ai/phoenix

This PR is an original, intentionally small JITMIND trace contract. It does not vendor Phoenix/OpenTelemetry code or add a heavy runtime dependency; adapters can translate the stable trace dictionary at the boundary.

Evidence

  • python -m pytest -q42 passed
  • python -m compileall -q jitmind → pass
  • trace microbenchmark: 10,000 events in 94.034 ms (9.403 µs/event) on the development runner
  • new tests cover default query redaction, stage exception evidence, parseable locked JSONL export, retrieval timings, fusion evidence, sink delivery, and the public explanation API

Review notes

This is an independent proposal targeting main; it does not depend on PR #27 or #28. Please leave it open for review and comparative evaluation.

Copy link
Copy Markdown
Owner Author

Verification checkpoint

  • Exact head: 92b7fcaf529dba758407ea248af97e292cbbd48e
  • GitHub Actions CI run: 32663310658success
  • Matrix: Python 3.10 (97252652636), 3.11 (97252652916), and 3.12 (97252652765) all passed install, pytest, and compileall
  • Local suite: 42 passed
  • Trace recorder microbenchmark: 10,000 events in 94.034 ms (9.403 µs/event) on the development runner

Privacy review focus: raw query text is absent by default; traces carry only SHA-256 + length and score-only evidence metadata. Export failures are non-blocking. This PR remains intentionally open and unmerged.

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