* 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/
()
| 946 | * boosting a test file's directory would be a misfire. |
| 947 | */ |
| 948 | getDominantFile(): { filePath: string; edgeCount: number; nextEdgeCount: number } | null { |
| 949 | if (!this.stmts.getDominantFile) { |
| 950 | // Pull top 20 candidates; we then filter out test/generated files |
| 951 | // in code (regex-grade matching that SQL LIKE can't express). The |
| 952 | // generated-file filter is critical — without it, etcd's |
| 953 | // `api/etcdserverpb/rpc.pb.go` (1916 in-file edges, generated |
| 954 | // protobuf stub) outranks the real `server/etcdserver/server.go` |
| 955 | // (470 edges) by 4×, and the boost would push the agent toward |
| 956 | // generated code. |
| 957 | this.stmts.getDominantFile = this.db.prepare(` |
| 958 | SELECT n.file_path AS file_path, COUNT(*) AS edge_count |
| 959 | FROM edges e |
| 960 | JOIN nodes n ON e.source = n.id |
| 961 | JOIN nodes m ON e.target = m.id |
| 962 | WHERE n.file_path = m.file_path |
| 963 | GROUP BY n.file_path |
| 964 | ORDER BY edge_count DESC |
| 965 | LIMIT 20 |
| 966 | `); |
| 967 | } |
| 968 | const rows = this.stmts.getDominantFile.all() as Array<{ file_path: string; edge_count: number }>; |
| 969 | const generated = this.getGeneratedPathsAmong(rows.map(r => r.file_path)); |
| 970 | const filtered = rows.filter(r => !isLowValueFile(r.file_path, generated)); |
| 971 | if (filtered.length === 0 || filtered[0]!.edge_count < 20) return null; |
| 972 | return { |
| 973 | filePath: filtered[0]!.file_path, |
| 974 | edgeCount: filtered[0]!.edge_count, |
| 975 | nextEdgeCount: filtered[1]?.edge_count ?? 0, |
| 976 | }; |
| 977 | } |
| 978 | |
| 979 | /** |
| 980 | * Find the file that holds the densest concentration of the project's |
no test coverage detected