Skip to content

Claude/query log collection mloy38#126

Merged
maximusunc merged 3 commits into
mainfrom
claude/query-log-collection-mloy38
Jul 13, 2026
Merged

Claude/query log collection mloy38#126
maximusunc merged 3 commits into
mainfrom
claude/query-log-collection-mloy38

Conversation

@maximusunc

Copy link
Copy Markdown
Collaborator

No description provided.

claude and others added 3 commits July 13, 2026 16:04
Query logs only reach the response when something calls save_logs(
response_id, logger) with a logger carrying the query_log_handler.
Two producers never did, so their logs were dropped:

- The server callback handler logged the result count and callback/query
  lookups but never persisted them. Add a save_logs call before returning.

- The merge_message worker: (a) the async parent hand-rolls its lifecycle
  and never calls wrap_up_task, so its "obtained lock"/"drained N"/error
  lines were lost -- add save_logs in the finally; (b) the actual merge runs
  in a ProcessPoolExecutor child whose logger has no query handler and whose
  records can't cross the process boundary, so every merge/filter/kgraph log
  vanished. Attach a call-scoped QueryLogHandler in the child, return its
  formatted entries alongside the merged ids, and fold them into the parent's
  query logger (via a new QueryLogHandler.ingest) so the single save_logs
  flushes them. Keeping all Redis log writes in the async parent avoids a
  second sync writer racing on the same response_id key.

Add tests for the child log return, handler-leak cleanup, and update the
batched-merge tests for the new (merged, log_entries) return contract.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TQwM6cHEH55jYYXRf7wtvB
…errors

Addresses review feedback on the log-collection change:

- Ordering: the stored log list reflected flush order, not event order, so
  merge/callback logs surfaced before the lookup logs that preceded them.
  get_logs now sorts by each entry's ISO8601 UTC timestamp (stable sort), so
  both the async splice in finish_query and the /response endpoint return logs
  in chronological order regardless of which worker flushed when.

- Noise: demote per-task plumbing lines that flooded the list to DEBUG --
  "Doing task" (dumped the whole payload), "Sending task to", "Finished task",
  and the merge worker's "Obtained lock" / "Drained N callback(s)". Meaningful
  lines ("Got back N results", "Sent response back to ...") stay at INFO.

- Callback errors weren't saved: the 413 (oversized) and 422 (unparseable)
  paths reject before the body's response_id is known, and their logger had no
  query handler. Attach the query handler up front (keyed on callback_id) and
  add _save_callback_error_logs, which resolves the response_id from the
  callback->query mapping and flushes -- run before remove_callback_id, which
  deletes that mapping. The two unresolvable 500 paths now at least warn.

Add tests for the timestamp sort (incl. missing-timestamp stability) and for
log persistence on the 413/422 paths.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TQwM6cHEH55jYYXRf7wtvB
@codecov

codecov Bot commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 63.63636% with 24 lines in your changes missing coverage. Please review.
✅ Project coverage is 51.24%. Comparing base (a5d0a9e) to head (97d5fcb).
⚠️ Report is 9 commits behind head on main.

Files with missing lines Patch % Lines
workers/merge_message/worker.py 64.10% 13 Missing and 1 partial ⚠️
shepherd_server/base_routes.py 63.15% 6 Missing and 1 partial ⚠️
shepherd_utils/logger.py 33.33% 2 Missing ⚠️
shepherd_utils/shared.py 66.66% 1 Missing ⚠️
Files with missing lines Coverage Δ
shepherd_utils/db.py 59.77% <100.00%> (+1.76%) ⬆️
workers/finish_query/worker.py 78.82% <100.00%> (ø)
shepherd_utils/shared.py 71.89% <66.66%> (ø)
shepherd_utils/logger.py 96.07% <33.33%> (-3.93%) ⬇️
shepherd_server/base_routes.py 39.57% <63.15%> (+6.04%) ⬆️
workers/merge_message/worker.py 66.45% <64.10%> (-0.73%) ⬇️

... and 1 file with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d495c41...97d5fcb. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@maximusunc
maximusunc merged commit d7afbf9 into main Jul 13, 2026
2 checks passed
@maximusunc
maximusunc deleted the claude/query-log-collection-mloy38 branch July 13, 2026 20:06
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.

2 participants