Function bodies 401 total
SaveRoutingLog function · go · L23-L29 (7 LOC)adapter_routing.go
func SaveRoutingLog(path string, log RoutingLog) error {
err := toolkit.SaveRoutingLog(path, log)
if err == nil {
slog.Info("routing log saved", "component", "routing", "path", path, "entries", len(log))
}
return err
}LoadRoutingLog function · go · L32-L34 (3 LOC)adapter_routing.go
func LoadRoutingLog(path string) (RoutingLog, error) {
return toolkit.LoadRoutingLog(path)
}CompareRoutingLogs function · go · L37-L39 (3 LOC)adapter_routing.go
func CompareRoutingLogs(expected, actual RoutingLog) []RoutingDiff {
return toolkit.CompareRoutingLogs(expected, actual)
}NewRoutingRecorder function · go · L51-L53 (3 LOC)adapter_routing.go
func NewRoutingRecorder(inner engine.Transformer, color string) *RoutingRecorder {
return &RoutingRecorder{inner: inner, color: color}
}Deterministic method · go · L56-L58 (3 LOC)adapter_routing.go
func (r *RoutingRecorder) Deterministic() bool {
return engine.IsDeterministic(r.inner)
}Transform method · go · L60-L77 (18 LOC)adapter_routing.go
func (r *RoutingRecorder) Transform(ctx context.Context, tc *engine.TransformerContext) (any, error) {
caseLabel, _ := tc.WalkerState.Context[KeyCaseLabel].(string)
if caseLabel == "" {
caseLabel = tc.WalkerState.ID
}
r.mu.Lock()
r.seq++
entry := RoutingEntry{
CaseID: caseLabel, Step: tc.NodeName, Color: r.color,
Timestamp: time.Now(), DispatchID: r.seq,
}
r.log = append(r.log, entry)
r.mu.Unlock()
slog.Info("dispatch", "component", "routing", "color", r.color, "case_id", caseLabel, "step", tc.NodeName)
return r.inner.Transform(ctx, tc)
}Log method · go · L79-L85 (7 LOC)adapter_routing.go
func (r *RoutingRecorder) Log() RoutingLog {
r.mu.Lock()
defer r.mu.Unlock()
out := make(RoutingLog, len(r.log))
copy(out, r.log)
return out
}Citation: Repobility (2026). State of AI-Generated Code. https://repobility.com/research/
SetRCAID method · go · L88-L92 (5 LOC)adapter_routing.go
func (r *RoutingRecorder) SetRCAID(gtID string, storeID int64) {
if im, ok := r.inner.(IDMappable); ok {
im.SetRCAID(gtID, storeID)
}
}SetSymptomID method · go · L94-L98 (5 LOC)adapter_routing.go
func (r *RoutingRecorder) SetSymptomID(gtID string, storeID int64) {
if im, ok := r.inner.(IDMappable); ok {
im.SetSymptomID(gtID, storeID)
}
}RunAnalysis function · go · L59-L89 (31 LOC)analysis.go
func RunAnalysis(st store.Store, cases []*store.Case, suiteID int64, cfg AnalysisConfig) (*AnalysisReport, error) {
transformerName := "unknown"
if len(cfg.Components) > 0 {
transformerName = cfg.Components[0].Name
}
report := &AnalysisReport{
Transformer: transformerName,
TotalCases: len(cases),
}
logger := slog.Default().With("component", "analyze")
for i, caseData := range cases {
caseLabel := fmt.Sprintf("A%d", i+1)
logger.Info("processing case",
"label", caseLabel, "index", i+1, "total", len(cases), "test", caseData.Name)
result, err := walkAnalysisCase(st, caseData, caseLabel, cfg)
if err != nil {
logger.Error("case circuit failed", "label", caseLabel, "error", err)
result = &AnalysisCaseResult{
CaseLabel: caseLabel,
TestName: caseData.Name,
StoreCaseID: caseData.ID,
}
}
report.CaseResults = append(report.CaseResults, *result)
}
return report, nil
}walkAnalysisCase function · go · L93-L167 (75 LOC)analysis.go
func walkAnalysisCase(
st store.Store,
caseData *store.Case,
caseLabel string,
cfg AnalysisConfig,
) (*AnalysisCaseResult, error) {
result := &AnalysisCaseResult{
CaseLabel: caseLabel,
TestName: caseData.Name,
StoreCaseID: caseData.ID,
}
basePath := cfg.BasePath
if basePath == "" {
basePath = DefaultBasePath
}
caseDir, _ := EnsureCaseDir(basePath, 0, caseData.ID)
hooksComp := &engine.Component{
Namespace: "store",
Name: "rca-store-hooks",
Hooks: StoreHooks(st, caseData),
}
injectComp := &engine.Component{
Namespace: "inject",
Name: "rca-inject-hooks",
Hooks: InjectHooksWithOpts(InjectHookOpts{
Store: st,
CaseData: caseData,
Envelope: cfg.Envelope,
Catalog: cfg.Catalog,
CaseDir: caseDir,
}),
}
comps := append(cfg.Components, hooksComp, injectComp)
walkCfg := WalkConfig{
Store: st,
CaseData: caseData,
Envelope: cfg.Envelope,
Catalog: cfg.Catalog,
CaseDir: caseDir,
CaseLabel: extractAnalysisStepData function · go · L170-L200 (31 LOC)analysis.go
func extractAnalysisStepData(result *AnalysisCaseResult, nodeName string, artifact any) {
m := asMap(artifact)
if m == nil {
return
}
switch nodeName {
case "recall":
result.RecallHit = mapBool(m, "match") && mapFloat(m, "confidence") >= 0.80
case "triage":
result.Category = mapStr(m, "symptom_category")
result.Skip = mapBool(m, "skip_investigation")
result.Cascade = mapBool(m, "cascade_suspected")
candidates := mapStrSlice(m, "candidate_repos")
if len(candidates) == 1 && !mapBool(m, "skip_investigation") {
result.SelectedRepos = append(result.SelectedRepos, candidates[0])
}
case "resolve":
for _, r := range mapSlice(m, "selected_repos") {
if rm, ok := r.(map[string]any); ok {
if name := mapStr(rm, "name"); name != "" {
result.SelectedRepos = append(result.SelectedRepos, name)
}
}
}
case "investigate":
result.DefectType = mapStr(m, "defect_type")
result.RCAMessage = mapStr(m, "rca_message")
result.EvidenceRefs = mapStrSlice(m, "evFormatAnalysisReport function · go · L203-L290 (88 LOC)analysis.go
func FormatAnalysisReport(report *AnalysisReport) string {
var b strings.Builder
b.WriteString("=== Asterisk Analysis Report ===\n")
if report.SourceName != "" {
b.WriteString(fmt.Sprintf("Launch: %s\n", report.SourceName))
}
b.WriteString(fmt.Sprintf("Transformer: %s\n", report.Transformer))
b.WriteString(fmt.Sprintf("Cases: %d\n\n", report.TotalCases))
recallHits := 0
skipped := 0
cascades := 0
investigated := 0
for _, cr := range report.CaseResults {
if cr.RecallHit {
recallHits++
}
if cr.Skip {
skipped++
}
if cr.Cascade {
cascades++
}
if cr.RCAID != 0 {
investigated++
}
}
b.WriteString(fmt.Sprintf("Recall hits: %d/%d\n", recallHits, report.TotalCases))
b.WriteString(fmt.Sprintf("Skipped: %d/%d\n", skipped, report.TotalCases))
b.WriteString(fmt.Sprintf("Cascades: %d/%d\n", cascades, report.TotalCases))
b.WriteString(fmt.Sprintf("Investigated: %d/%d\n\n", investigated, report.TotalCases))
b.WriteString("--- Per-case breakCaseDir function · go · L21-L23 (3 LOC)artifact.go
func CaseDir(basePath string, suiteID, caseID int64) string {
return toolkit.CaseDir(basePath, suiteID, caseID)
}EnsureCaseDir function · go · L25-L27 (3 LOC)artifact.go
func EnsureCaseDir(basePath string, suiteID, caseID int64) (string, error) {
return toolkit.EnsureCaseDir(basePath, suiteID, caseID)
}Repobility analyzer · published findings · https://repobility.com
ListCaseDirs function · go · L29-L31 (3 LOC)artifact.go
func ListCaseDirs(basePath string, suiteID int64) ([]string, error) {
return toolkit.ListCaseDirs(basePath, suiteID)
}NodeArtifactFilename function · go · L33-L38 (6 LOC)artifact.go
func NodeArtifactFilename(nodeName string) string {
if _, known := rcaNodeArtifacts[nodeName]; !known {
return ""
}
return toolkit.NodeArtifactFilename(nodeName, rcaNodeArtifacts)
}NodePromptFilename function · go · L40-L42 (3 LOC)artifact.go
func NodePromptFilename(nodeName string, loopIter int) string {
return toolkit.NodePromptFilename(nodeName, loopIter)
}ReadMapArtifact function · go · L44-L46 (3 LOC)artifact.go
func ReadMapArtifact(caseDir, filename string) (map[string]any, error) {
return toolkit.ReadMapArtifact(caseDir, filename)
}WriteArtifact function · go · L48-L50 (3 LOC)artifact.go
func WriteArtifact(caseDir, filename string, data any) error {
return toolkit.WriteArtifact(caseDir, filename, data)
}WriteNodePrompt function · go · L52-L54 (3 LOC)artifact.go
func WriteNodePrompt(caseDir string, nodeName string, loopIter int, content string) (string, error) {
return toolkit.WriteNodePrompt(caseDir, nodeName, loopIter, content)
}SetContractFields method · go · L65-L67 (3 LOC)cal_adapters.go
func (a *RCACalibrationAdapter) SetContractFields(fields []map[string]any) {
a.contractFields = fields
}Load method · go · L82-L215 (134 LOC)cal_adapters.go
func (a *RCACalibrationAdapter) Load(_ context.Context) ([]engine.BatchCase, error) {
if a.BasePath == "" {
a.BasePath = DefaultBasePath
}
a.dataset = buildDatasetHealth(a.Scenario)
st, err := store.OpenMemory()
if err != nil {
return nil, fmt.Errorf("open memory store: %w", err)
}
a.st = st
suite := &store.InvestigationSuite{Name: a.Scenario.Name, Status: "active"}
suiteID, err := st.CreateSuite(suite)
if err != nil {
return nil, fmt.Errorf("create suite: %w", err)
}
a.suiteID = suiteID
versionMap := make(map[string]int64)
for _, c := range a.Scenario.Cases {
if _, exists := versionMap[c.Version]; !exists {
v := &store.Version{Label: c.Version}
vid, err := st.CreateVersion(v)
if err != nil {
return nil, fmt.Errorf("create version %s: %w", c.Version, err)
}
versionMap[c.Version] = vid
}
}
circuitMap := make(map[pipeKey]int64)
jobMap := make(map[pipeKey]int64)
launchMap := make(map[pipeKey]int64)
for _, c := range a.Scenario.Cases {
Repobility · open methodology · https://repobility.com/research/
OnCaseComplete method · go · L219-L229 (11 LOC)cal_adapters.go
func (a *RCACalibrationAdapter) OnCaseComplete() func(int, engine.BatchWalkResult) {
if a.IDMapper == nil {
return nil
}
var mu sync.Mutex
return func(i int, _ engine.BatchWalkResult) {
mu.Lock()
defer mu.Unlock()
updateIDMaps(a.IDMapper, a.st, a.entries[i].caseData, a.entries[i].gtCase, a.Scenario)
}
}Collect method · go · L236-L291 (56 LOC)cal_adapters.go
func (a *RCACalibrationAdapter) Collect(_ context.Context, results []engine.BatchWalkResult) (map[string]float64, map[string]string, error) {
logger := slog.Default().With("component", "calibrate")
// Build a RunConfig for collectCaseResult compatibility.
cfg := RunConfig{
Scenario: a.Scenario,
BasePath: a.BasePath,
ScoreCard: a.ScoreCard,
}
caseResults := make([]CaseResult, len(a.entries))
for i, br := range results {
entry := a.entries[i]
logger.Info("processed case",
"case_id", entry.gtCase.ID, "index", i+1, "total", len(a.entries), "test", entry.gtCase.TestName)
caseResults[i] = collectCaseResult(br, entry.gtCase, entry.caseData, entry.caseDir, a.suiteID, a.st, cfg)
// Overlay contract-extracted fields when available. The contract
// provides a generic extraction path for standard fields; the
// store-based extraction in collectCaseResult handles
// RCA-specific state (RCAID, store-persisted defect type, etc.).
if i < len(a.contractFields) && a.Render method · go · L296-L305 (10 LOC)cal_adapters.go
func (a *RCACalibrationAdapter) Render(report *cal.CalibrationReport) (string, error) {
rcaReport := &CalibrationReport{
CalibrationReport: *report,
SuiteID: a.suiteID,
BasePath: a.BasePath,
CaseResults: a.caseResults,
Dataset: a.dataset,
}
return RenderCalibrationReport(rcaReport, a.ReportTemplate)
}RCAReport method · go · L310-L323 (14 LOC)cal_adapters.go
func (a *RCACalibrationAdapter) RCAReport(report *cal.CalibrationReport) *CalibrationReport {
rcaReport := &CalibrationReport{
CalibrationReport: *report,
SuiteID: a.suiteID,
BasePath: a.BasePath,
CaseResults: a.caseResults,
Dataset: a.dataset,
}
if a.TokenTracker != nil {
ts := a.TokenTracker.Summary()
rcaReport.Tokens = &ts
}
return rcaReport
}DefaultRunConfig function · go · L50-L61 (12 LOC)cal_runner.go
func DefaultRunConfig(scenario *Scenario, comps []*engine.Component, transformerName string) RunConfig {
return RunConfig{
Scenario: scenario,
Components: comps,
TransformerName: transformerName,
Runs: 1,
Thresholds: DefaultThresholds(),
BasePath: DefaultBasePath,
GapConfidentThreshold: DefaultGapConfidentThreshold,
GapInconclusiveThreshold: DefaultGapInconclusiveThreshold,
}
}ResolvedGapConfidentThreshold method · go · L65-L70 (6 LOC)cal_runner.go
func (c RunConfig) ResolvedGapConfidentThreshold() float64 {
if c.GapConfidentThreshold > 0 {
return c.GapConfidentThreshold
}
return DefaultGapConfidentThreshold
}ResolvedGapInconclusiveThreshold method · go · L74-L79 (6 LOC)cal_runner.go
func (c RunConfig) ResolvedGapInconclusiveThreshold() float64 {
if c.GapInconclusiveThreshold > 0 {
return c.GapInconclusiveThreshold
}
return DefaultGapInconclusiveThreshold
}RunCalibration function · go · L85-L143 (59 LOC)cal_runner.go
func RunCalibration(ctx context.Context, cfg RunConfig) (*CalibrationReport, error) {
if cfg.BasePath == "" {
cfg.BasePath = DefaultBasePath
}
if cfg.ScoreCard == nil {
return nil, fmt.Errorf("RunConfig.ScoreCard is required (set it directly or declare scorecard: in your circuit YAML)")
}
adapter := &RCACalibrationAdapter{
Scenario: cfg.Scenario,
Components: cfg.Components,
IDMapper: cfg.IDMapper,
BasePath: cfg.BasePath,
Thresholds: cfg.Thresholds,
ScoreCard: cfg.ScoreCard,
TokenTracker: cfg.TokenTracker,
}
def, err := LoadCircuitDef(cfg.CircuitData, cfg.Thresholds)
if err != nil {
return nil, fmt.Errorf("load circuit def: %w", err)
}
genReport, err := cal.Run(ctx, cal.HarnessConfig{
Loader: adapter,
Collector: adapter,
CircuitDef: def,
ScoreCard: cfg.ScoreCard,
Contract: cal.ContractFromDef(def.Calibration),
Scenario: cfg.Scenario.Name,
Transformer: cfg.TransformerName,
Runs: Open data scored by Repobility · https://repobility.com
applyContractFields function · go · L149-L181 (33 LOC)cal_runner.go
func applyContractFields(r *CaseResult, fields map[string]any) {
if s, ok := fields["actual_defect_type"].(string); ok && s != "" {
r.ActualDefectType = s
} else if s, ok := fields["rca_defect_type"].(string); ok && s != "" {
r.ActualDefectType = s
}
if s, ok := fields["actual_category"].(string); ok && s != "" {
r.ActualCategory = s
}
if s, ok := fields["actual_component"].(string); ok && s != "" {
r.ActualComponent = s
}
if s, ok := fields["actual_rca_message"].(string); ok && s != "" {
r.ActualRCAMessage = s
}
if v, ok := fields["actual_convergence"].(float64); ok {
r.ActualConvergence = v
}
if refs, ok := fields["actual_evidence_refs"].([]any); ok {
strs := make([]string, 0, len(refs))
for _, ref := range refs {
if s, ok := ref.(string); ok {
strs = append(strs, s)
}
}
if len(strs) > 0 {
r.ActualEvidenceRefs = strs
}
}
if path, ok := fields["_path"].([]string); ok && len(path) > 0 {
r.ActualPath = path
}
}scoreCaseResult function · go · L185-L218 (34 LOC)cal_runner.go
func scoreCaseResult(r *CaseResult, scenario *Scenario) {
var gt *GroundTruthCase
for j := range scenario.Cases {
if scenario.Cases[j].ID == r.CaseID {
gt = &scenario.Cases[j]
break
}
}
if gt == nil {
return
}
// Path accuracy
r.PathCorrect = cal.PathsEqual(r.ActualPath, gt.ExpectedPath)
// Category accuracy
if gt.ExpectedTriage != nil {
r.CategoryCorrect = (r.ActualCategory == gt.ExpectedTriage.SymptomCategory)
}
// Defect type and component — look up ground truth RCA
if gt.RCAID != "" {
for _, gtRCA := range scenario.RCAs {
if gtRCA.ID == gt.RCAID {
r.DefectTypeCorrect = (r.ActualDefectType == gtRCA.DefectType)
r.ComponentCorrect = (r.ActualComponent == gtRCA.Component) ||
(r.ActualRCAMessage != "" && strings.Contains(
strings.ToLower(r.ActualRCAMessage),
strings.ToLower(gtRCA.Component)))
break
}
}
}
}collectCaseResult function · go · L222-L297 (76 LOC)cal_runner.go
func collectCaseResult(
br engine.BatchWalkResult,
gtCase GroundTruthCase,
caseData *store.Case,
caseDir string,
suiteID int64,
st store.Store,
cfg RunConfig,
) CaseResult {
result := CaseResult{
CaseID: gtCase.ID,
TestName: gtCase.TestName,
Version: gtCase.Version,
Job: gtCase.Job,
StoreCaseID: caseData.ID,
SourceIssueType: gtCase.SourceIssueType,
SourceAutoAnalyzed: gtCase.SourceAutoAnalyzed,
}
if br.Error != nil {
result.CircuitError = br.Error.Error()
return result
}
for _, nodeName := range br.Path {
result.ActualPath = append(result.ActualPath, nodeName)
}
for nodeName, art := range br.StepArtifacts {
extractStepMetrics(&result, nodeName, art.Raw(), gtCase)
if err := WriteArtifact(caseDir, NodeArtifactFilename(nodeName), art.Raw()); err != nil {
slog.Warn("write artifact", "component", "calibrate", "node", nodeName, "error", err)
}
}
if br.State != nil {
ws := br.State
history := make([]SteextractStepMetrics function · go · L301-L354 (54 LOC)cal_runner.go
func extractStepMetrics(result *CaseResult, nodeName string, artifact any, gt GroundTruthCase) {
m := asMap(artifact)
if m == nil {
return
}
switch nodeName {
case "recall":
result.ActualRecallHit = mapBool(m, "match") && mapFloat(m, "confidence") >= 0.80
case "triage":
result.ActualCategory = mapStr(m, "symptom_category")
cat := mapStr(m, "symptom_category")
result.ActualSkip = mapBool(m, "skip_investigation") ||
cat == "infra" || cat == "flake"
result.ActualCascade = mapBool(m, "cascade_suspected")
if hyp := mapStr(m, "defect_type_hypothesis"); hyp != "" && result.ActualDefectType == "" {
result.ActualDefectType = hyp
}
candidates := mapStrSlice(m, "candidate_repos")
if len(candidates) == 1 && !mapBool(m, "skip_investigation") {
result.ActualSelectedRepos = append(result.ActualSelectedRepos, candidates[0])
}
case "resolve":
result.ActualSelectedRepos = result.ActualSelectedRepos[:0]
for _, r := range mapSlice(m, "selected_repos") {
if rm, selectRepoByHypothesis function · go · L359-L420 (62 LOC)cal_runner.go
func selectRepoByHypothesis(hypothesis string, repos []RepoConfig) []string {
if hypothesis == "" || len(repos) == 0 {
return nil
}
type rule struct {
include []string
exclude []string
}
prefix := strings.ToLower(hypothesis)
var r rule
switch {
case strings.HasPrefix(prefix, "pb"):
r = rule{
include: []string{"operator", "daemon", "product"},
exclude: []string{"test", "framework", "e2e", "deploy", "manifests"},
}
case strings.HasPrefix(prefix, "au"):
r = rule{
include: []string{"test", "framework", "e2e"},
exclude: []string{},
}
case strings.HasPrefix(prefix, "en"):
r = rule{
include: []string{"config", "infra", "ci "},
exclude: []string{},
}
default:
return nil
}
var matched []string
for _, repo := range repos {
if repo.IsRedHerring {
continue
}
purpose := strings.ToLower(repo.Purpose)
excluded := false
for _, kw := range r.exclude {
if strings.Contains(purpose, kw) {
excluded = true
break
}
}
if exupdateIDMaps function · go · L424-L439 (16 LOC)cal_runner.go
func updateIDMaps(mapper IDMappable, st store.Store, caseData *store.Case, gtCase GroundTruthCase, scenario *Scenario) {
updated, err := st.GetCase(caseData.ID)
if err != nil || updated == nil {
return
}
// Map ground truth RCA ID to store RCA ID
if updated.RCAID != 0 && gtCase.RCAID != "" {
mapper.SetRCAID(gtCase.RCAID, updated.RCAID)
}
// Map ground truth symptom ID to store symptom ID
if updated.SymptomID != 0 && gtCase.SymptomID != "" {
mapper.SetSymptomID(gtCase.SymptomID, updated.SymptomID)
}
}sanitizeBackslashes function · go · L466-L468 (3 LOC)cal_runner.go
func sanitizeBackslashes(data []byte) []byte {
return loneBackslashRe.ReplaceAll(data, []byte("$1"))
}cleanJSON function · go · L473-L492 (20 LOC)cal_runner.go
func cleanJSON(data []byte) []byte {
s := bytes.TrimSpace(data)
if len(s) == 0 {
return s
}
if bytes.HasPrefix(s, []byte("```")) {
// Strip opening fence line
if idx := bytes.IndexByte(s, '\n'); idx >= 0 {
s = s[idx+1:]
}
// Strip closing fence
if bytes.HasSuffix(s, []byte("```")) {
s = s[:len(s)-3]
}
s = bytes.TrimSpace(s)
}
return s
}Citation: Repobility (2026). State of AI-Generated Code. https://repobility.com/research/
buildDatasetHealth function · go · L496-L522 (27 LOC)cal_runner.go
func buildDatasetHealth(s *Scenario) *DatasetHealth {
rcaMap := make(map[string]*GroundTruthRCA, len(s.RCAs))
for i := range s.RCAs {
rcaMap[s.RCAs[i].ID] = &s.RCAs[i]
}
dh := &DatasetHealth{
VerifiedCount: len(s.Cases),
CandidateCount: len(s.Candidates),
}
for _, c := range s.Candidates {
ci := CandidateInfo{
CaseID: c.ID,
RCAID: c.RCAID,
}
if rcaRec, ok := rcaMap[c.RCAID]; ok {
ci.JiraID = rcaRec.JiraID
if len(rcaRec.FixPRs) == 0 {
ci.Reason = "no fix PR"
} else {
ci.Reason = "disputed/unverified"
}
}
dh.Candidates = append(dh.Candidates, ci)
}
return dh
}ParseCalibrationMode function · go · L28-L33 (6 LOC)cal_types.go
func ParseCalibrationMode(s string) CalibrationMode {
if s == "offline" {
return ModeOffline
}
return ModeOnline
}ApplyDefaults method · go · L49-L59 (11 LOC)cal_types.go
func (s *Scenario) ApplyDefaults() {
if s.Defaults == nil {
return
}
for i := range s.Cases {
mergeDefaults(&s.Cases[i], s.Defaults)
}
for i := range s.Candidates {
mergeDefaults(&s.Candidates[i], s.Defaults)
}
}mergeDefaults function · go · L62-L72 (11 LOC)cal_types.go
func mergeDefaults(dst, defaults *GroundTruthCase) {
dv := reflect.ValueOf(dst).Elem()
sv := reflect.ValueOf(defaults).Elem()
for i := 0; i < dv.NumField(); i++ {
df := dv.Field(i)
sf := sv.Field(i)
if df.IsZero() && !sf.IsZero() {
df.Set(sf)
}
}
}ScenarioToCatalog function · go · L11-L31 (21 LOC)catalog_convert.go
func ScenarioToCatalog(wc SourcePackConfig) toolkit.SourceCatalog {
var sources []toolkit.Source
for _, r := range wc.Repos {
tags := map[string]string{
"layer": "base",
}
if r.Purpose != "" {
tags["role"] = inferRole(r.Purpose)
}
sources = append(sources, toolkit.Source{
Name: r.Name,
Kind: toolkit.SourceKindRepo,
URI: r.Path,
Purpose: r.Purpose,
Branch: r.Branch,
Tags: tags,
})
}
sources = append(sources, wc.Sources...)
return &toolkit.SliceCatalog{Items: sources}
}inferRole function · go · L34-L47 (14 LOC)catalog_convert.go
func inferRole(purpose string) string {
switch {
case containsAny(purpose, "SUT", "lifecycle", "operator", "daemon"):
return "sut"
case containsAny(purpose, "test", "e2e", "framework", "gotests"):
return "test"
case containsAny(purpose, "doc", "architecture", "reference"):
return "reference"
case containsAny(purpose, "deploy", "manifests", "CI", "config"):
return "infra"
default:
return "other"
}
}containsAny function · go · L49-L57 (9 LOC)catalog_convert.go
func containsAny(s string, substrs ...string) bool {
lower := strings.ToLower(s)
for _, sub := range substrs {
if strings.Contains(lower, strings.ToLower(sub)) {
return true
}
}
return false
}SchematicResolver function · go · L20-L27 (8 LOC)circuit_def.go
func SchematicResolver() circuit.AssetResolver {
return func(name string) ([]byte, error) {
if name == "rca" {
return defaultCircuitYAML, nil
}
return nil, fmt.Errorf("unknown schematic %q", name)
}
}Repobility analyzer · published findings · https://repobility.com
ThresholdsToVars function · go · L30-L38 (9 LOC)circuit_def.go
func ThresholdsToVars(th Thresholds) map[string]any {
return map[string]any{
"recall_hit": th.RecallHit,
"recall_uncertain": th.RecallUncertain,
"convergence_sufficient": th.ConvergenceSufficient,
"max_investigate_loops": th.MaxInvestigateLoops,
"correlate_dup": th.CorrelateDup,
}
}LoadCircuitDef function · go · L44-L61 (18 LOC)circuit_def.go
func LoadCircuitDef(data []byte, th Thresholds) (*circuit.CircuitDef, error) {
if data == nil {
data = defaultCircuitYAML
}
def, err := circuit.LoadCircuitWithOverlay(data, SchematicResolver())
if err != nil {
return nil, fmt.Errorf("load circuit YAML: %w", err)
}
thVars := ThresholdsToVars(th)
if def.Vars == nil {
def.Vars = thVars
} else {
for k, v := range thVars {
def.Vars[k] = v
}
}
return def, nil
}BuildRunner function · go · L66-L79 (14 LOC)circuit_def.go
func BuildRunner(circuitData []byte, th Thresholds, comps ...*engine.Component) (*engine.Runner, error) {
def, err := LoadCircuitDef(circuitData, th)
if err != nil {
return nil, err
}
reg := engine.GraphRegistries{}
if len(comps) > 0 {
reg, err = engine.MergeComponents(reg, comps...)
if err != nil {
return nil, fmt.Errorf("merge components: %w", err)
}
}
return engine.NewRunnerWith(def, reg)
}page 1 / 9next ›