mirror of
https://github.com/abhigyanpatwari/GitNexus.git
synced 2026-11-18 09:43:04 +00:00
fix(query): send hub content once across process_symbols rows
With include_content, a symbol in several execution flows carried its full source text on every (id, process_id) row. Keep content on the first row for each symbol id and omit it from later rows. Membership fields, is_entry_point, and symbol_count are unchanged. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
49c37092da
commit
c1903709b9
4 changed files with 21 additions and 8 deletions
|
|
@ -5,6 +5,8 @@
|
|||
* Aggregation already pushes a hub onto every owning process. This helper
|
||||
* is the last shaping step: slice each process to `max_symbols`, keep one
|
||||
* row per `(id, process_id)`, then set `symbol_count` from those rows.
|
||||
* `content` stays only on the first row for each symbol id so a hub in
|
||||
* many flows does not repeat its source text.
|
||||
*/
|
||||
|
||||
export type QueryProcessAttach = {
|
||||
|
|
@ -55,6 +57,7 @@ export function shapeQueryProcessAttaches<S extends QueryProcessAttach>(
|
|||
): { processes: QueryProcessCard[]; process_symbols: S[] } {
|
||||
const { maxSymbolsPerProcess, chainByProcessId } = options;
|
||||
const seen = new Set<string>();
|
||||
const contentSeen = new Set<string>();
|
||||
const process_symbols: S[] = [];
|
||||
const countByProcess = new Map<string, number>();
|
||||
|
||||
|
|
@ -63,8 +66,16 @@ export function shapeQueryProcessAttaches<S extends QueryProcessAttach>(
|
|||
const key = attachPairKey(s.id, s.process_id);
|
||||
if (seen.has(key)) continue;
|
||||
seen.add(key);
|
||||
const row =
|
||||
p.entryPointId && s.id === p.entryPointId ? ({ ...s, is_entry_point: true } as S) : s;
|
||||
let row: S = s;
|
||||
if (s.content !== undefined) {
|
||||
if (contentSeen.has(s.id)) {
|
||||
const { content: _content, ...rest } = s;
|
||||
row = rest as S;
|
||||
} else {
|
||||
contentSeen.add(s.id);
|
||||
}
|
||||
}
|
||||
if (p.entryPointId && s.id === p.entryPointId) row = { ...row, is_entry_point: true };
|
||||
process_symbols.push(row);
|
||||
countByProcess.set(s.process_id, (countByProcess.get(s.process_id) ?? 0) + 1);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ AFTER THIS: Use context() on a specific symbol for 360-degree view (callers, cal
|
|||
|
||||
Returns results grouped by process (execution flow):
|
||||
- processes: ranked execution flows with relevance priority. When a process has an HTTP endpoint, each item includes route and method string aliases plus routes: [{ url, method? }] (same shape as context). When chain_depth > 0, each item also includes chain — layered upstream callers + downstream callees from the process entry symbol (same BFS as context({chain_depth})).
|
||||
- process_symbols: search-hit symbols in those flows with file locations and module (functional area). On the single-repo envelope { processes, process_symbols, definitions }: One row per (id, process_id) — the same symbol id may appear under more than one process. Join a process to its rows by process_id; symbol_count is the number of those rows. When the process entry is among those hits, it is marked is_entry_point: true. A repo of "@<group>" returns { group, query, results, per_repo } and does not include process_symbols. results[].symbol_count is the member's post-slice attach count; when service is set, it counts only attaches under that prefix. To get process_symbols for one member, query again with repo "@<group>/<memberPath>" (member path from group.yaml, or results[]._repo).
|
||||
- process_symbols: search-hit symbols in those flows with file locations and module (functional area). On the single-repo envelope { processes, process_symbols, definitions }: One row per (id, process_id) — the same symbol id may appear under more than one process. Join a process to its rows by process_id; symbol_count is the number of those rows. When the process entry is among those hits, it is marked is_entry_point: true. With include_content, content appears only on the first row for each symbol id; later rows for that id omit it. A repo of "@<group>" returns { group, query, results, per_repo } and does not include process_symbols. results[].symbol_count is the member's post-slice attach count; when service is set, it counts only attaches under that prefix. To get process_symbols for one member, query again with repo "@<group>/<memberPath>" (member path from group.yaml, or results[]._repo).
|
||||
- definitions: standalone types/interfaces not in any process. Keyword hits on Route URLs (route_fts) are bridged to their handler via HANDLES_ROUTE (handlerSymbolId, routes) when the edge exists; use route_map({route}) for the full HTTP surface.
|
||||
|
||||
Hybrid ranking: BM25 keyword + semantic vector search, ranked by Reciprocal Rank Fusion.
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ describe('shapeQueryProcessAttaches', () => {
|
|||
expect(processes[0]?.symbol_count).toBe(1);
|
||||
});
|
||||
|
||||
it('keeps include_content on every emitted hub attach (KTD5)', () => {
|
||||
it('keeps include_content only on the first row for a hub id', () => {
|
||||
const { process_symbols } = shapeQueryProcessAttaches(
|
||||
[
|
||||
ranked('proc:login-flow', [
|
||||
|
|
@ -115,10 +115,9 @@ describe('shapeQueryProcessAttaches', () => {
|
|||
{ maxSymbolsPerProcess: 25 },
|
||||
);
|
||||
|
||||
expect(process_symbols.map((s) => s.content)).toEqual([
|
||||
'function validate() {}',
|
||||
'function validate() {}',
|
||||
]);
|
||||
expect(process_symbols.map((s) => s.process_id)).toEqual(['proc:login-flow', 'proc:beta-flow']);
|
||||
expect(process_symbols[0]?.content).toBe('function validate() {}');
|
||||
expect(process_symbols[1]).not.toHaveProperty('content');
|
||||
});
|
||||
|
||||
it('marks the entry-point hit and preserves process card extras', () => {
|
||||
|
|
|
|||
|
|
@ -136,6 +136,9 @@ describe('GITNEXUS_TOOLS', () => {
|
|||
'when service is set, it counts only attaches under that prefix',
|
||||
);
|
||||
expect(queryTool.description).toContain('query again with repo "@<group>/<memberPath>"');
|
||||
expect(queryTool.description).toContain(
|
||||
'content appears only on the first row for each symbol id',
|
||||
);
|
||||
});
|
||||
|
||||
it('query tool requires "search_query" parameter (renamed from "query" for #2175)', () => {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue