Skip to content

armgit / ruflo

Public Imported from GitHub
0

🌊 The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated

Merge origin/main into fix/analyze-content-classification: reconcile term matching with #4169

RuFlof3fbf8267a8a
diff --cc v3/@claude-flow/cli/src/ruvector/diff-classifier.ts
index a70296ebe3,094acad896..39a805cfbe
--- a/v3/@claude-flow/cli/src/ruvector/diff-classifier.ts
+++ b/v3/@claude-flow/cli/src/ruvector/diff-classifier.ts
@@@ -75,35 -74,26 +75,50 @@@ const COMMIT_CLASSIFICATION_PATTERNS: R
style: [/^style/, /format/, /lint/, /prettier/, /eslint/],
};
+// File paths and commit subjects are different signals. Prefixes such as
+// "fix" and words such as "bug" are useful in subjects, but match unrelated
+// paths like src/debug/logger.ts and src/dispatcher.ts.
+const PATH_CLASSIFICATION_PATTERNS: Record<string, RegExp[]> = {
+ docs: [/(^|\/)docs?\//i, /(^|\/)readme(?:\.[^/]*)?$/i, /\.mdx?$/i],
+ test: [/(^|\/)(?:__tests__|tests?|specs?)\//i, /\.(?:test|spec)\.[^/]+$/i],
+ config: [/(^|\/)(?:configs?\/|config(?:\.[^/]*)?$)/i, /\.config\.[^/]+$/i,
+ /(^|\/)(?:package|tsconfig)(?:\.[^/]*)?\.json$/i, /(^|\/)\.env(?:\.[^/]*)?$/i],
+ style: [/\.(?:css|scss|sass|less)$/i],
+};
+
const IMPACT_KEYWORDS: Record<string, number> = {
- security: 3, auth: 3, payment: 3, database: 2, api: 2, core: 2,
+ payment: 3, database: 2, api: 2, core: 2,
util: 1, helper: 1, test: 0, mock: 0, fixture: 0,
};
+function pathHasTerm(path: string, term: string): boolean {
+ const tokens = path.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase().split(/[^a-z0-9]+/);
+ const aliases: Record<string, string[]> = {
+ auth: ['auth', 'authentication', 'authorization', 'authenticator', 'oauth'],
+ util: ['util', 'utils', 'utility', 'utilities'],
+ test: ['test', 'tests'],
+ mock: ['mock', 'mocks'],
+ fixture: ['fixture', 'fixtures'],
+ config: ['config', 'configuration'],
+ };
+ return (aliases[term] ?? [term]).some(value => tokens.includes(value));
+}
+
+ // Match path terms rather than substrings: `encryption` must trigger review,
+ // while unrelated names such as `author` and `tokenizer` must not.
+ const SECURITY_PATH_TERMS = new Set([
+ 'security', 'secure', 'auth', 'oauth', 'authenticate', 'authentication',
+ 'authorization', 'authorized', 'authenticator', 'crypto', 'cryptography',
+ 'encrypt', 'encryption', 'encrypted', 'decrypt', 'decryption', 'decrypted',
+ 'cipher', 'secret', 'secrets', 'password', 'passwords', 'token', 'tokens',
+ 'vault', 'kms',
+ ]);
+
+ function isSecuritySensitivePath(path: string): boolean {
+ const terms = path.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase().split(/[^a-z0-9]+/);
+ return terms.some(term => SECURITY_PATH_TERMS.has(term));
+ }
+
export class DiffClassifier {
private config: DiffClassifierConfig;
private ruvectorEngine: unknown = null;
@@@ -293,7 -245,9 +308,8 @@@
private determineImpactLevel(path: string, hunks: DiffHunk[]): DiffClassification['impactLevel'] {
let score = 0;
- const lowerPath = path.toLowerCase();
- for (const [keyword, weight] of Object.entries(IMPACT_KEYWORDS)) { if (lowerPath.includes(keyword)) score = Math.max(score, weight); }
+ for (const [keyword, weight] of Object.entries(IMPACT_KEYWORDS)) { if (pathHasTerm(path, keyword)) score = Math.max(score, weight); }
+ if (isSecuritySensitivePath(path)) score = Math.max(score, 3);
const totalChanges = hunks.reduce((sum, h) => sum + h.changes.filter(c => c.type !== 'context').length, 0);
if (totalChanges > 100) score = Math.max(score, 2);
if (totalChanges > 300) score = Math.max(score, 3);
@@@ -308,8 -262,8 +324,8 @@@
const typeReviewers: Record<string, string[]> = { feature: ['tech-lead', 'product-owner'], bugfix: ['qa-engineer', 'developer'], refactor: ['senior-developer', 'architect'], docs: ['tech-writer', 'developer'], test: ['qa-engineer', 'developer'], config: ['devops', 'tech-lead'], style: ['developer'], unknown: ['developer'] };
reviewers.push(...(typeReviewers[primary] || typeReviewers.unknown));
if (impact === 'critical' || impact === 'high') reviewers.push('security-reviewer');
- if (pathHasTerm(path, 'security') || pathHasTerm(path, 'auth')) reviewers.push('security-team');
+ if (isSecuritySensitivePath(path)) reviewers.push('security-team');
- if (/database|migration/.test(path)) reviewers.push('dba');
+ if (pathHasTerm(path, 'database') || pathHasTerm(path, 'migration')) reviewers.push('dba');
return [...new Set(reviewers)].slice(0, 4);
}
@@@ -318,8 -272,8 +334,8 @@@
if (primary !== 'test') strategies.push('unit-tests');
if (primary === 'feature') strategies.push('integration-tests');
if (impact === 'high' || impact === 'critical') { strategies.push('regression-tests'); strategies.push('e2e-tests'); }
- if (/api|endpoint|route|handler/.test(path)) strategies.push('api-contract-tests');
+ if (['api', 'endpoint', 'route', 'handler'].some(term => pathHasTerm(path, term))) strategies.push('api-contract-tests');
- if (['security', 'auth', 'crypto'].some(term => pathHasTerm(path, term))) strategies.push('security-audit');
+ if (isSecuritySensitivePath(path)) strategies.push('security-audit');
return strategies.slice(0, 5);
}
@@@ -329,9 -283,9 +345,9 @@@
if (totalChanges > 200) risks.push('Large change set - increased review time needed');
if (impact === 'critical') risks.push('Critical system component - requires careful review');
if (impact === 'high') risks.push('High-impact area - monitor after deployment');
- if (pathHasTerm(path, 'security') || pathHasTerm(path, 'auth')) risks.push('Security-sensitive code');
+ if (isSecuritySensitivePath(path)) risks.push('Security-sensitive code');
- if (/database|migration/.test(path)) risks.push('Database changes - ensure backup strategy');
- if (/config|env/.test(path)) risks.push('Configuration changes - verify all environments');
+ if (pathHasTerm(path, 'database') || pathHasTerm(path, 'migration')) risks.push('Database changes - ensure backup strategy');
+ if (pathHasTerm(path, 'config') || pathHasTerm(path, 'env')) risks.push('Configuration changes - verify all environments');
const allContent = hunks.flatMap(h => h.changes.map(c => c.content)).join('\n');
if (/TODO|FIXME|HACK/.test(allContent)) risks.push('Contains TODO/FIXME comments');
if (/password|secret|key|token/i.test(allContent)) risks.push('Potential secrets in code');
@@@ -619,7 -577,8 +639,7 @@@ export function assessFileRisk(file: Di
}
// Path-based risk
- if (['security', 'auth', 'crypto', 'password'].some(term => pathHasTerm(file.path, term))) {
- const lowerPath = file.path.toLowerCase();
+ if (isSecuritySensitivePath(file.path)) {
score += 40;
reasons.push('Security-sensitive file');
}
@@@ -769,14 -677,15 +789,14 @@@ export function suggestReviewers(files
const reviewers = new Set<string>();
for (const file of files) {
- const lowerPath = file.path.toLowerCase();
-
+ const hasAny = (...terms: string[]) => terms.some(term => pathHasTerm(file.path, term));
- if (hasAny('security', 'auth', 'crypto')) reviewers.add('security-team');
+ if (isSecuritySensitivePath(file.path)) reviewers.add('security-team');
- if (/database|migration/.test(lowerPath)) reviewers.add('dba');
- if (/api|endpoint|route/.test(lowerPath)) reviewers.add('api-owner');
- if (/test|spec/.test(lowerPath)) reviewers.add('qa-engineer');
- if (/config|deploy|ci/.test(lowerPath)) reviewers.add('devops');
- if (/ui|component|style/.test(lowerPath)) reviewers.add('frontend-lead');
- if (/model|service|repository/.test(lowerPath)) reviewers.add('backend-lead');
+ if (hasAny('database', 'migration')) reviewers.add('dba');
+ if (hasAny('api', 'endpoint', 'route')) reviewers.add('api-owner');
+ if (hasAny('test', 'spec')) reviewers.add('qa-engineer');
+ if (hasAny('config', 'deploy', 'ci')) reviewers.add('devops');
+ if (hasAny('ui', 'component', 'style')) reviewers.add('frontend-lead');
+ if (hasAny('model', 'service', 'repository')) reviewers.add('backend-lead');
}
// Add based on risk