Proj/surface curate query claude#610
Conversation
Extend the `brv query --format json` envelope with `matchedDocs`, `tier`, `durationMs`, and `topScore` so downstream consumers (brv-bridge, the ByteRover Claude plugin) can surface evidence of memory retrieval to the user. The data already exists in QueryExecutor and is persisted to query-log entries — this just exposes it on the public CLI surface. Implementation: - QueryLogHandler.getTaskCompletionData() exposes the structured payload via the existing lifecycle-hook contract; TaskRouter automatically merges it into the task:completed event sent to the originating client. - task-client.ts extends TaskCompletedWithLogId and TaskCompletionResult with the new optional fields; older daemons that don't emit them degrade gracefully (fields stay undefined). - query.ts conditionally spreads the new fields into the JSON envelope so consumers don't see undefined keys for non-query tasks. Tests: - 4 new cases for getTaskCompletionData (all-fields, no-task, no-result, partial cache-hit shape). - 2 new cases for the query command's JSON envelope (fields surfaced when present; gracefully omitted when absent). Parent ticket: ENG-2537.
Three changes from PR review: 1. Drop the dead `if (timing !== undefined)` guard in QueryLogHandler.getTaskCompletionData() — `timing` is required on QueryExecutorResult (every executor branch sets it), so the guard is unreachable. Inline the assignment instead. 2. Fix the JSDoc on TaskCompletedWithLogId in task-client.ts — it listed the QueryExecutorResult-shaped names (`timing`/`searchMetadata`) but the actual type uses the flattened public-contract names (`durationMs`/`topScore`). Updated to match. 3. Refresh package-lock.json so the axios entry resolves to 1.16.0 (matching the manifest pin) instead of the 1.15.0 left behind by the rebase. Restores deterministic-install agreement.
feat: surface recall metadata in brv query --format json
|
Claude finished @danhdoan's task in 3m 53s —— View job Review summary — Score: 4 / 5Clean, focused, additive change that does exactly what ENG-2615 promises. Strict TDD is visible (failing-shape tests on both daemon and CLI sides), backward-compat is properly guarded by conditional spreads, and the new daemon-side surface reuses the existing What's strong
What could be tightened (none blocking)
Scope/architecture check (Outside-In)✅ The consumer (
Inline comments posted on:
|
These 11 entries were introduced by an earlier 'npm install' in commit 4662fb3 (PR #608) running with a different npm CLI version that re-resolves esbuild's optionalDependencies as peer entries. They are descriptive metadata only, do not affect npm ci installs, and are not present on main. Drop them so proj -> main lockfile diff is empty. Verified: 'npm ci --dry-run' passes against the reverted lockfile.
fix: drop esbuild peer:true entries from lockfile
|
Claude finished @danhdoan's task in 2m 58s —— View job Re-review (post-synchronize) — Score: 5 / 5The lockfile cleanup commits (62938cc + merge #611) close the only concrete question from the prior pass. Code-level diff is unchanged, all-additive, type-safe, and TDD-verified on both daemon and CLI sides. Ready to land. Delta since prior review
What's strong (unchanged)
Outside-In check✅ Same as prior review — consumer-driven, no premature entity work. Todo
Inline comments posted on:
|
Summary
brv query --format jsonreturned only the response text, dropping 10+ retrieval metadata signals (matched paths, scores, resolution tier, timing) that QueryExecutor already computes internally.brv-bridgeand the ByteRover Claude plugin — need this metadata to surface visible evidence of memory retrieval to the user. Today recall runs silently every turn; the user has no signal that ByteRover is working or what it retrieved. Surfacing this metadata is the foundation for the broader "Surface ByteRover in Claude Code" initiative (ENG-2537).brv query --format jsonenvelope withmatchedDocs[],tier,durationMs, andtopScore. Plumbed via the existing query-log lifecycle hook + task-completed event so older daemons degrade gracefully.--format text(default) output is byte-identical. No retrieval/scoring logic touched. No agent prompt or tool-response changes. No new fields exposed beyond the four above (richer per-doc fields likesymbolKind,backlinkCount,relatedPathsdeferred until consumers demonstrate need).Type of change
Scope (select all touched areas)
Linked issues
Root cause (bug fixes only, otherwise write
N/A)N/A — this is a feature.
Test plan
test/unit/infra/process/query-log-handler.test.ts— 4 new cases ongetTaskCompletionDatatest/commands/query.test.ts— 2 new cases on the query command's JSON envelopegetTaskCompletionDatareturns full structured payload when all fields presentgetTaskCompletionDatahandles no-task / no-result / partial cache-hit shapesbrv query --format jsonsurfaces the new fields when daemon emits thembrv query --format jsongracefully omits the fields when daemon doesn't emit them (older daemon compat)User-visible changes
None directly.
brv querytext-mode output unchanged. JSON-mode output is additive — consumers that ignore unknown fields are unaffected.This unlocks user-visible changes in downstream layers:
brv-bridgewill pass these fields through (Task 2).brv-claude-pluginwill surface a "🧠 Retrieved N memories…" line in the Claude Code chat panel via the hooksystemMessageprimitive (Task 3).Evidence
Sample output after this change:
{ "command": "query", "data": { "result": "...", "matchedDocs": [ {"path": "auth/jwt/token.md", "score": 0.92, "title": "...", "snippet": "..."} ], "tier": 2, "durationMs": 47, "topScore": 0.92 }, "success": true, "timestamp": "..." }