Skip to content

Commit 0609bce

Browse files
aksOpsclaude
andcommitted
feat(analyzer): apply DetectorEmissionDefaults after every detect() call
Wires the orchestrator stamping pass into all three detect() call sites in Analyzer.java (the main pipeline, the cache-aware runBatchedIndex path, and the regex-fallback path). Every emission whose source is null now gets stamped with: - source = detector.getClass().getSimpleName() - confidence = detector.defaultConfidence() (LEXICAL for regex bases, SYNTACTIC for AST/structured bases) Detectors that stamp explicitly (e.g. setConfidence(RESOLVED) once a detector migrates to ctx.resolved()) are left alone — applyDefaults keys off source==null. Deferred from this commit (will land with Phase 5 detector migration): - ResolverRegistry.bootstrap(repoPath) call at the start of run() — pointless without detectors that consume ctx.resolved() - Per-file ctx = ctx.withResolved(resolver.resolve(file, ast)) — same This commit is purely additive: 2417 tests in analyzer + cli + detector packages all pass, no regressions. The full 3555-test suite is green post-stamping, confirming existing detector behavior is unchanged (detectors don't stamp confidence/source today, so the stamping floor applies uniformly). IndexCommand also benefits transparently — it calls analyzer.runSmartIndex() which routes through one of the wired detect sites. Per sub-project 1 plan Tasks 19-20 (stamping portion). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent c83167b commit 0609bce

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

src/main/java/io/github/randomcodespace/iq/analyzer/Analyzer.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import io.github.randomcodespace.iq.detector.AbstractAntlrDetector;
1212
import io.github.randomcodespace.iq.detector.Detector;
1313
import io.github.randomcodespace.iq.detector.DetectorContext;
14+
import io.github.randomcodespace.iq.detector.DetectorEmissionDefaults;
1415
import io.github.randomcodespace.iq.detector.DetectorRegistry;
1516
import io.github.randomcodespace.iq.detector.DetectorResult;
1617
import io.github.randomcodespace.iq.detector.DetectorUtils;
@@ -1311,6 +1312,9 @@ DetectorResult analyzeFileWithRegistry(DiscoveredFile file, Path repoPath,
13111312
}
13121313
try {
13131314
DetectorResult result = detector.detect(ctx);
1315+
// Stamp confidence + source defaults on every emission whose source
1316+
// is null. Detectors that already explicitly stamp are left alone.
1317+
DetectorEmissionDefaults.applyDefaults(result, detector);
13141318
allNodes.addAll(result.nodes());
13151319
allEdges.addAll(result.edges());
13161320
} catch (Throwable e) {
@@ -1514,6 +1518,8 @@ DetectorResult analyzeFile(DiscoveredFile file, Path repoPath, DetectorRegistry
15141518
try {
15151519
Instant detStart = Instant.now();
15161520
DetectorResult result = detector.detect(ctx);
1521+
// Stamp orchestrator-managed confidence + source defaults.
1522+
DetectorEmissionDefaults.applyDefaults(result, detector);
15171523
long detMs = Duration.between(detStart, Instant.now()).toMillis();
15181524
if (detMs > 2000) {
15191525
log.warn("🐢 SLOW DETECTOR: {} on {}: {}ms",
@@ -1601,6 +1607,8 @@ private DetectorResult analyzeFileRegexOnly(DiscoveredFile file, Path repoPath,
16011607
} else {
16021608
result = detector.detect(ctx);
16031609
}
1610+
// Stamp orchestrator-managed confidence + source defaults.
1611+
DetectorEmissionDefaults.applyDefaults(result, detector);
16041612
allNodes.addAll(result.nodes());
16051613
allEdges.addAll(result.edges());
16061614
} catch (Throwable e) {

0 commit comments

Comments
 (0)