* Find the file that holds the densest concentration of the project's * internal call graph — the "core" file. Used by context-builder to * boost ranking of symbols in that file's directory (so e.g. sinatra * queries surface `lib/sinatra/base.rb`'s `route!` instead of * `sinatra-contrib/
()
| 559 | * boosting a test file's directory would be a misfire. |
| 560 | */ |
| 561 | getDominantFile(): { filePath: string; edgeCount: number; nextEdgeCount: number } | null { |
| 562 | if (!this.stmts.getDominantFile) { |
| 563 | // Pull top 20 candidates; we then filter out test/generated files |
| 564 | // in code (regex-grade matching that SQL LIKE can't express). The |
| 565 | // generated-file filter is critical — without it, etcd's |
| 566 | // `api/etcdserverpb/rpc.pb.go` (1916 in-file edges, generated |
| 567 | // protobuf stub) outranks the real `server/etcdserver/server.go` |
| 568 | // (470 edges) by 4×, and the boost would push the agent toward |
| 569 | // generated code. |
| 570 | this.stmts.getDominantFile = this.db.prepare(` |
| 571 | SELECT n.file_path AS file_path, COUNT(*) AS edge_count |
| 572 | FROM edges e |
| 573 | JOIN nodes n ON e.source = n.id |
| 574 | JOIN nodes m ON e.target = m.id |
| 575 | WHERE n.file_path = m.file_path |
| 576 | GROUP BY n.file_path |
| 577 | ORDER BY edge_count DESC |
| 578 | LIMIT 20 |
| 579 | `); |
| 580 | } |
| 581 | const rows = this.stmts.getDominantFile.all() as Array<{ file_path: string; edge_count: number }>; |
| 582 | const filtered = rows.filter(r => !isLowValueFile(r.file_path)); |
| 583 | if (filtered.length === 0 || filtered[0]!.edge_count < 20) return null; |
| 584 | return { |
| 585 | filePath: filtered[0]!.file_path, |
| 586 | edgeCount: filtered[0]!.edge_count, |
| 587 | nextEdgeCount: filtered[1]?.edge_count ?? 0, |
| 588 | }; |
| 589 | } |
| 590 | |
| 591 | /** |
| 592 | * Find the file that holds the densest concentration of the project's |
no test coverage detected