package click.kamil.springstatemachineexporter.analysis.enricher;

import click.kamil.springstatemachineexporter.analysis.model.AnalysisResult;
import click.kamil.springstatemachineexporter.analysis.model.CodebaseMetadata;
import click.kamil.springstatemachineexporter.analysis.model.EntryPoint;
import click.kamil.springstatemachineexporter.analysis.service.CodebaseIntelligenceProvider;
import click.kamil.springstatemachineexporter.ast.common.CodebaseContext;
import lombok.extern.slf4j.Slf4j;

import java.util.List;

@Slf4j
public class EntryPointEnricher implements AnalysisEnricher {

    @Override
    public void enrich(AnalysisResult result, CodebaseContext context, CodebaseIntelligenceProvider intelligence) {
        log.info("Enriching {} with entry points", result.getName());
        
        // Keep all entry points; machine scoping is applied after call-chain resolution
        // when source evidence (trigger type FQNs, literals, constraints) is available.
        List<EntryPoint> entryPoints = intelligence.findEntryPoints();

        result.addMetadata(CodebaseMetadata.builder()
                .entryPoints(entryPoints)
                .build());
    }
}
