Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/builder/incremental.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { BUILTIN_RECEIVERS, readFileSafe } from './helpers.js';
* @param {Function} [options.diffSymbols] - Symbol diff function
* @returns {Promise<object|null>} Update result or null on failure
*/
export async function rebuildFile(db, rootDir, filePath, stmts, engineOpts, cache, options = {}) {
export async function rebuildFile(_db, rootDir, filePath, stmts, engineOpts, cache, options = {}) {
const { diffSymbols } = options;
const relPath = normalizePath(path.relative(rootDir, filePath));
const oldNodes = stmts.countNodes.get(relPath)?.c || 0;
Expand Down
8 changes: 8 additions & 0 deletions src/graph/classifiers/risk.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
* Risk scoring — pure logic, no DB.
*/

// Weights sum to 1.0. Complexity gets the highest weight because cognitive load
// is the strongest predictor of defect density. Fan-in and churn are next as
// they reflect coupling and volatility. Role adds architectural context, and MI
// (maintainability index) is a weaker composite signal, so it gets the least.
export const DEFAULT_WEIGHTS = {
fanIn: 0.25,
complexity: 0.3,
Expand All @@ -10,6 +14,10 @@ export const DEFAULT_WEIGHTS = {
mi: 0.1,
};

// Role weights reflect structural importance: core modules are central to the
// dependency graph, utilities are widely imported, entry points are API
// surfaces. Adapters bridge subsystems but are replaceable. Leaves and dead
// code have minimal downstream impact.
export const ROLE_WEIGHTS = {
core: 1.0,
utility: 0.9,
Expand Down
1 change: 1 addition & 0 deletions src/graph/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ export class CodeGraph {
for (const [src, targets] of this._successors) {
for (const [tgt, attrs] of targets) {
if (!this._directed) {
// \0 is safe as separator — node IDs are file paths/symbols, never contain null bytes
const key = src < tgt ? `${src}\0${tgt}` : `${tgt}\0${src}`;
if (seen.has(key)) continue;
seen.add(key);
Expand Down
Loading