Function bodies 401 total
LoadCheckpointState function · go · L102-L104 (3 LOC)hitl.go
func LoadCheckpointState(caseDir string, caseID int64) (*circuit.WalkerState, error) {
return engine.LoadCheckpointState(caseDir, fmt.Sprintf("case-%d", caseID))
}prepareWalker function · go · L106-L118 (13 LOC)hitl.go
func prepareWalker(cp circuit.Checkpointer, walkerID string, cfg HITLConfig) (circuit.Walker, string, error) {
loaded, _ := cp.Load(walkerID)
walker := circuit.NewProcessWalker(walkerID)
injectHITLContext(walker.State(), cfg)
startNode := "recall"
if resumed := engine.RestoreWalkerState(walker, loaded); resumed != "" {
startNode = resumed
}
return walker, startNode, nil
}injectHITLContext function · go · L120-L129 (10 LOC)hitl.go
func injectHITLContext(state *circuit.WalkerState, cfg HITLConfig) {
state.Context[KeyStore] = cfg.Store
state.Context[KeyCaseData] = cfg.CaseData
state.Context[KeyEnvelope] = cfg.Envelope
state.Context[KeyCatalog] = cfg.Catalog
state.Context[KeyCaseDir] = cfg.CaseDir
if cfg.PromptFS != nil {
state.Context[KeyPromptFS] = cfg.PromptFS
}
}buildResult function · go · L131-L133 (3 LOC)hitl.go
func buildResult(walker circuit.Walker, walkErr error) (*HITLResult, error) {
return engine.BuildHITLResult(walker, walkErr)
}Transform method · go · L24-L61 (38 LOC)hitl_transformer.go
func (t *hitlTransformerNode) Transform(_ context.Context, tc *engine.TransformerContext) (any, error) {
if input, ok := tc.WalkerState.Context["resume_input"]; ok {
delete(tc.WalkerState.Context, "resume_input")
data, err := json.Marshal(input)
if err != nil {
return nil, fmt.Errorf("hitl %s: marshal resume_input: %w", t.nodeName, err)
}
return parseArtifact(json.RawMessage(data))
}
caseDir, _ := tc.WalkerState.Context[KeyCaseDir].(string)
promptFS, _ := tc.WalkerState.Context[KeyPromptFS].(fs.FS)
params := ParamsFromContext(tc.WalkerState.Context)
params.StepName = t.nodeName
templatePath := tc.Prompt
if templatePath == "" {
return nil, fmt.Errorf("hitl %s: node %q has no prompt: field", t.nodeName, tc.NodeName)
}
prompt, err := FillTemplateFS(promptFS, templatePath, params)
if err != nil {
return nil, fmt.Errorf("hitl %s: fill template: %w", t.nodeName, err)
}
loopIter := tc.WalkerState.LoopCounts[tc.NodeName]
promptPath, err := WriteNodePrompt(cStoreHooks function · go · L15-L33 (19 LOC)hooks.go
func StoreHooks(st store.Store, caseData *store.Case) engine.HookRegistry {
reg := engine.HookRegistry{}
reg.Register(engine.NewHookFunc("store.recall", func(_ context.Context, _ string, art circuit.Artifact) error {
return applyRecallEffects(st, caseData, art.Raw())
}))
reg.Register(engine.NewHookFunc("store.triage", func(_ context.Context, _ string, art circuit.Artifact) error {
return applyTriageEffects(st, caseData, art.Raw())
}))
reg.Register(engine.NewHookFunc("store.investigate", func(_ context.Context, _ string, art circuit.Artifact) error {
return applyInvestigateEffects(st, caseData, art.Raw())
}))
reg.Register(engine.NewHookFunc("store.correlate", func(_ context.Context, _ string, art circuit.Artifact) error {
return applyCorrelateEffects(st, caseData, art.Raw())
}))
reg.Register(engine.NewHookFunc("store.review", func(_ context.Context, _ string, art circuit.Artifact) error {
return applyReviewEffects(st, caseData, art.Raw())
}))
return reg
}InjectHooks function · go · L38-L46 (9 LOC)hooks_inject.go
func InjectHooks(st store.Store, caseData *store.Case, env *rcatype.Envelope, catalog toolkit.SourceCatalog, caseDir string) engine.HookRegistry {
return InjectHooksWithOpts(InjectHookOpts{
Store: st,
CaseData: caseData,
Envelope: env,
Catalog: catalog,
CaseDir: caseDir,
})
}All rows scored by the Repobility analyzer (https://repobility.com)
InjectHooksWithOpts function · go · L49-L65 (17 LOC)hooks_inject.go
func InjectHooksWithOpts(opts InjectHookOpts) engine.HookRegistry {
reg := engine.HookRegistry{}
reg.Register(newInjectEnvelopeHook(opts.Envelope))
reg.Register(newInjectFailureHook(opts.CaseData))
reg.Register(newInjectHistoryHook(opts.Store, opts.CaseData))
reg.Register(newInjectRecallDigestHook(opts.Store))
reg.Register(newInjectSourcesHook(opts.Envelope, opts.Catalog))
reg.Register(newInjectPriorHook(opts.CaseDir))
reg.Register(newInjectTaxonomyHook())
// Circuit-composition bridge hooks.
reg.Register(newInjectCodeKeywordsHook())
reg.Register(newBridgeCodeContextHook())
return reg
}newInjectEnvelopeHook function · go · L67-L71 (5 LOC)hooks_inject.go
func newInjectEnvelopeHook(env *rcatype.Envelope) engine.Hook {
return engine.NewContextInjector("inject.envelope", func(walkerCtx map[string]any) {
injectEnvelopeData(env, walkerCtx)
})
}newInjectFailureHook function · go · L73-L77 (5 LOC)hooks_inject.go
func newInjectFailureHook(caseData *store.Case) engine.Hook {
return engine.NewContextInjector("inject.failure", func(walkerCtx map[string]any) {
injectFailureData(caseData, walkerCtx)
})
}newInjectHistoryHook function · go · L79-L83 (5 LOC)hooks_inject.go
func newInjectHistoryHook(st store.Store, caseData *store.Case) engine.Hook {
return engine.NewContextInjector("inject.history", func(walkerCtx map[string]any) {
injectHistoryData(st, caseData, walkerCtx)
})
}newInjectRecallDigestHook function · go · L85-L89 (5 LOC)hooks_inject.go
func newInjectRecallDigestHook(st store.Store) engine.Hook {
return engine.NewContextInjector("inject.recall-digest", func(walkerCtx map[string]any) {
injectRecallDigestData(st, walkerCtx)
})
}newInjectSourcesHook function · go · L91-L95 (5 LOC)hooks_inject.go
func newInjectSourcesHook(env *rcatype.Envelope, catalog toolkit.SourceCatalog) engine.Hook {
return engine.NewContextInjector("inject.sources", func(walkerCtx map[string]any) {
injectSourcesData(env, catalog, walkerCtx)
})
}newInjectPriorHook function · go · L97-L101 (5 LOC)hooks_inject.go
func newInjectPriorHook(caseDir string) engine.Hook {
return engine.NewContextInjector("inject.prior", func(walkerCtx map[string]any) {
injectPriorData(caseDir, walkerCtx)
})
}newInjectTaxonomyHook function · go · L103-L107 (5 LOC)hooks_inject.go
func newInjectTaxonomyHook() engine.Hook {
return engine.NewContextInjector("inject.taxonomy", func(walkerCtx map[string]any) {
injectTaxonomyData(walkerCtx)
})
}Repobility's GitHub App fixes findings like these · https://github.com/apps/repobility-bot
ParamsFromContext function · go · L113-L170 (58 LOC)hooks_inject.go
func ParamsFromContext(walkerCtx map[string]any) *TemplateParams {
params := &TemplateParams{}
if v, ok := walkerCtx[KeyParamsEnvelope].(*EnvelopeParams); ok {
params.Envelope = v
params.SourceID = v.RunID
}
if v, ok := walkerCtx[KeyParamsFailure].(*FailureParams); ok {
params.Failure = v
}
if v, ok := walkerCtx[KeyParamsSources].(*SourceParams); ok {
params.Sources = v
}
if v, ok := walkerCtx[KeyParamsHistory].(*HistoryParams); ok {
params.History = v
}
if v, ok := walkerCtx[KeyParamsDigest].([]RecallDigestEntry); ok {
params.RecallDigest = v
}
if v, ok := walkerCtx[KeyParamsPrior].(*PriorParams); ok {
params.Prior = v
}
if v, ok := walkerCtx[KeyParamsTaxonomy].(*TaxonomyParams); ok {
params.Taxonomy = v
}
if v, ok := walkerCtx[KeyParamsCode].(*CodeParams); ok {
params.Code = v
}
if cd, ok := walkerCtx[KeyCaseData].(*store.Case); ok {
params.CaseID = cd.ID
}
if _, ok := walkerCtx[KeyParamsEnvelope].(*EnvelopeParams); ok {
if env, ok injectEnvelopeData function · go · L174-L182 (9 LOC)hooks_inject.go
func injectEnvelopeData(env *rcatype.Envelope, walkerCtx map[string]any) {
if env == nil {
return
}
walkerCtx[KeyParamsEnvelope] = &EnvelopeParams{
Name: env.Name,
RunID: env.RunID,
}
}injectFailureData function · go · L184-L195 (12 LOC)hooks_inject.go
func injectFailureData(caseData *store.Case, walkerCtx map[string]any) {
if caseData == nil {
return
}
walkerCtx[KeyParamsFailure] = &FailureParams{
TestName: caseData.Name,
ErrorMessage: caseData.ErrorMessage,
LogSnippet: caseData.LogSnippet,
LogTruncated: caseData.LogTruncated,
Status: caseData.Status,
}
}injectHistoryData function · go · L197-L206 (10 LOC)hooks_inject.go
func injectHistoryData(st store.Store, caseData *store.Case, walkerCtx map[string]any) {
if st == nil || caseData == nil {
return
}
if caseData.SymptomID != 0 {
walkerCtx[KeyParamsHistory] = loadHistory(st, caseData.SymptomID)
} else {
walkerCtx[KeyParamsHistory] = findRecallCandidates(st, caseData.Name)
}
}injectRecallDigestData function · go · L208-L213 (6 LOC)hooks_inject.go
func injectRecallDigestData(st store.Store, walkerCtx map[string]any) {
if st == nil {
return
}
walkerCtx[KeyParamsDigest] = buildRecallDigest(st)
}injectSourcesData function · go · L215-L217 (3 LOC)hooks_inject.go
func injectSourcesData(env *rcatype.Envelope, catalog toolkit.SourceCatalog, walkerCtx map[string]any) {
walkerCtx[KeyParamsSources] = buildSourceParams(env, catalog)
}injectPriorData function · go · L219-L224 (6 LOC)hooks_inject.go
func injectPriorData(caseDir string, walkerCtx map[string]any) {
if caseDir == "" {
return
}
walkerCtx[KeyParamsPrior] = loadPriorArtifacts(caseDir)
}injectTaxonomyData function · go · L226-L228 (3 LOC)hooks_inject.go
func injectTaxonomyData(walkerCtx map[string]any) {
walkerCtx[KeyParamsTaxonomy] = DefaultTaxonomy()
}If a scraper extracted this row, it came from Repobility (https://repobility.com)
ensureCodeParams function · go · L230-L237 (8 LOC)hooks_inject.go
func ensureCodeParams(walkerCtx map[string]any) *CodeParams {
if v, ok := walkerCtx[KeyParamsCode].(*CodeParams); ok {
return v
}
code := &CodeParams{}
walkerCtx[KeyParamsCode] = code
return code
}extractSearchKeywords function · go · L239-L269 (31 LOC)hooks_inject.go
func extractSearchKeywords(walkerCtx map[string]any) []string {
var keywords []string
if fp, ok := walkerCtx[KeyParamsFailure].(*FailureParams); ok && fp != nil {
if fp.TestName != "" {
keywords = append(keywords, fp.TestName)
}
}
if prior, ok := walkerCtx[KeyParamsPrior].(*PriorParams); ok && prior != nil {
if triage := (*prior)["Triage"]; triage != nil {
if repos, ok := triage["candidate_repos"].([]any); ok {
for _, r := range repos {
if s, ok := r.(string); ok {
keywords = append(keywords, s)
}
}
}
}
if resolve := (*prior)["Resolve"]; resolve != nil {
if repos, ok := resolve["selected_repos"].([]any); ok {
for _, r := range repos {
if rm, ok := r.(map[string]any); ok {
if name, ok := rm["name"].(string); ok {
keywords = append(keywords, name)
}
}
}
}
}
}
return keywords
}newInjectCodeKeywordsHook function · go · L276-L283 (8 LOC)hooks_inject.go
func newInjectCodeKeywordsHook() engine.Hook {
return engine.NewContextInjector("inject.code-keywords", func(walkerCtx map[string]any) {
keywords := extractSearchKeywords(walkerCtx)
if len(keywords) > 0 {
walkerCtx["dsr.search_keywords"] = keywords
}
})
}newBridgeCodeContextHook function · go · L288-L353 (66 LOC)hooks_inject.go
func newBridgeCodeContextHook() engine.Hook {
return engine.NewHookFunc("bridge.code-context", func(ctx context.Context, _ string, art circuit.Artifact) error {
ws := engine.WalkerStateFromContext(ctx)
if ws == nil {
return nil
}
da, ok := art.(*engine.DelegateArtifact)
if !ok || da == nil {
return nil
}
// Find the "read" node's artifact in the delegate's inner results.
readArt, ok := da.InnerArtifacts["read"]
if !ok || readArt == nil {
return nil
}
// Decode the raw artifact via JSON roundtrip to avoid importing
// the GND package. The raw value may be a concrete struct (local
// delegate) or a map[string]any (mediator delegation).
raw := readArt.Raw()
if raw == nil {
return nil
}
data, err := json.Marshal(raw)
if err != nil {
return nil
}
var cc codeContextWire
if err := json.Unmarshal(data, &cc); err != nil {
return nil
}
code := ensureCodeParams(ws.Context)
for _, tree := range cc.Trees {
var entries []TreeETransform method · go · L18-L67 (50 LOC)investigate_heuristic.go
func (t *investigateHeuristic) Transform(_ context.Context, tc *engine.TransformerContext) (any, error) {
fp := failureFromContext(tc.WalkerState)
text := t.ht.textFromFailure(fp)
component := t.ht.identifyComponent(text)
_, defectType, _ := t.ht.classifyDefect(text)
evidenceRefs := extractEvidenceRefs(fp.errorMessage, component)
rcaParts := []string{}
if fp.errorMessage != "" {
rcaParts = append(rcaParts, fp.errorMessage)
}
if fp.name != "" {
rcaParts = append(rcaParts, fmt.Sprintf("Test: %s", fp.name))
}
if component != "unknown" {
rcaParts = append(rcaParts, fmt.Sprintf("Suspected component: %s", component))
}
rcaMessage := strings.Join(rcaParts, " | ")
if rcaMessage == "" {
rcaMessage = "investigation pending (no error message available)"
}
convergence := t.ht.computeConvergence(text, component)
gapBrief := t.ht.buildGapBrief(fp, text, component, defectType, convergence)
m := map[string]any{
"rca_message": rcaMessage,
"defect_type": defecomputeMetrics function · go · L12-L38 (27 LOC)metrics.go
func computeMetrics(scenario *Scenario, results []CaseResult, sc *cal.ScoreCard) MetricSet {
reg := cal.DefaultScorerRegistry()
batchItems, batchCtx := PrepareBatchInput(results, scenario)
values, details, err := sc.ScoreCase(batchItems, batchCtx, reg)
if err != nil {
values = make(map[string]float64)
details = make(map[string]string)
}
ms := sc.Evaluate(values, details)
if sc.Aggregate != nil {
agg, err := sc.ComputeAggregate(ms)
if err == nil {
ms.Metrics = append(ms.Metrics, agg)
}
}
m20def := sc.FindDef("M20")
if m20def != nil {
ms.Metrics = append(ms.Metrics, m20def.ToMetric(0, "single run"))
}
ApplyDryCaps(&ms, scenario.DryCappedMetrics)
return ms
}ApplyDryCaps function · go · L41-L54 (14 LOC)metrics.go
func ApplyDryCaps(ms *MetricSet, capped []string) {
if len(capped) == 0 {
return
}
set := make(map[string]bool, len(capped))
for _, id := range capped {
set[id] = true
}
for i := range ms.Metrics {
if set[ms.Metrics[i].ID] {
ms.Metrics[i].DryCapped = true
}
}
}PrepareBatchInput function · go · L60-L162 (103 LOC)metrics.go
func PrepareBatchInput(results []CaseResult, scenario *Scenario) ([]map[string]any, map[string]any) {
caseMap := make(map[string]*GroundTruthCase, len(scenario.Cases))
for i := range scenario.Cases {
caseMap[scenario.Cases[i].ID] = &scenario.Cases[i]
}
rcaMap := make(map[string]*GroundTruthRCA, len(scenario.RCAs))
for i := range scenario.RCAs {
rcaMap[scenario.RCAs[i].ID] = &scenario.RCAs[i]
}
repoRelevance := buildRepoRelevanceMap(scenario)
batch := make([]map[string]any, 0, len(results))
for _, r := range results {
item := map[string]any{
"case_id": r.CaseID,
"actual_defect_type": r.ActualDefectType,
"actual_category": r.ActualCategory,
"actual_recall_hit": r.ActualRecallHit,
"actual_skip": r.ActualSkip,
"actual_cascade": r.ActualCascade,
"actual_convergence": r.ActualConvergence,
"actual_selected_repos": r.ActualSelectedRepos,
"actual_evidence_refs": r.ActualEvidenceRefs,
"actual_rca_message": r.Repobility (the analyzer behind this table) · https://repobility.com
AggregateRunMetrics function · go · L165-L220 (56 LOC)metrics.go
func AggregateRunMetrics(runs []MetricSet, sc *cal.ScoreCard) MetricSet {
if len(runs) == 0 {
return MetricSet{}
}
if len(runs) == 1 {
return runs[0]
}
agg := cal.AggregateRunMetrics(runs, func(m Metric) bool {
if def := sc.FindDef(m.ID); def != nil {
return def.Evaluate(m.Value)
}
return m.Value >= m.Threshold
})
var m19vals []float64
for _, run := range runs {
for _, m := range run.AllMetrics() {
if m.ID == "M19" {
m19vals = append(m19vals, m.Value)
}
}
}
m19mean := cal.Mean(m19vals)
variance := cal.Stddev(m19vals)
m19threshold := 0.70
if sc.Aggregate != nil {
m19threshold = sc.Aggregate.Threshold
}
m20def := sc.FindDef("M20")
m20threshold := 0.15
if m20def != nil {
m20threshold = m20def.Threshold
}
for i := range agg.Metrics {
switch agg.Metrics[i].ID {
case "M19":
agg.Metrics[i] = Metric{
ID: "M19", Name: "overall_accuracy", Value: m19mean, Threshold: m19threshold,
Pass: m19mean >= m19threshold, Detail: fmt.SprinbuildRepoRelevanceMap function · go · L223-L232 (10 LOC)metrics.go
func buildRepoRelevanceMap(scenario *Scenario) map[string]map[string]bool {
m := make(map[string]map[string]bool)
for _, rca := range scenario.RCAs {
m[rca.ID] = make(map[string]bool)
for _, repo := range rca.RelevantRepos {
m[rca.ID][repo] = true
}
}
return m
}parseArtifact function · go · L21-L30 (10 LOC)nodes.go
func parseArtifact(data json.RawMessage) (map[string]any, error) {
result, err := parseJSON[map[string]any](data)
if err != nil {
return nil, err
}
if result == nil {
return nil, nil
}
return *result, nil
}buildSourceParams function · go · L12-L65 (54 LOC)params.go
func buildSourceParams(env *rcatype.Envelope, catalog toolkit.SourceCatalog) *SourceParams {
wsp := &SourceParams{}
if catalog != nil && len(catalog.Sources()) > 0 {
wsp.ReposStatus = Resolved
for _, s := range catalog.Sources() {
wsp.Repos = append(wsp.Repos, RepoParams{
Name: s.Name,
Path: s.URI,
Purpose: s.Purpose,
Branch: s.Branch,
})
}
} else {
wsp.ReposStatus = Unavailable
}
if env != nil && len(env.LaunchAttributes) > 0 {
wsp.AttrsStatus = Resolved
for _, a := range env.LaunchAttributes {
wsp.LaunchAttributes = append(wsp.LaunchAttributes, AttributeParams{
Key: a.Key,
Value: a.Value,
System: a.System,
})
}
} else {
wsp.AttrsStatus = Unavailable
}
if env != nil {
seen := map[string]bool{}
for _, f := range env.FailureList {
for _, ext := range f.ExternalIssues {
if ext.TicketID != "" && !seen[ext.TicketID] {
seen[ext.TicketID] = true
wsp.JiraLinks = append(wsp.JiraLinks, JiraLinkParloadPriorArtifacts function · go · L67-L80 (14 LOC)params.go
func loadPriorArtifacts(caseDir string) *PriorParams {
priorNodes := []string{"recall", "triage", "resolve", "investigate", "correlate"}
loaded := toolkit.LoadPriorArtifacts(caseDir, priorNodes, func(name string) string {
return NodeArtifactFilename(name)
})
if loaded == nil {
return nil
}
prior := make(PriorParams, len(loaded))
for k, v := range loaded {
prior[strings.ToUpper(k[:1])+k[1:]] = v
}
return &prior
}loadAlwaysReadSources function · go · L82-L106 (25 LOC)params.go
func loadAlwaysReadSources(catalog toolkit.SourceCatalog) []AlwaysReadSource {
if catalog == nil {
return nil
}
alwaysSources := catalog.AlwaysReadSources()
if len(alwaysSources) == 0 {
return nil
}
var result []AlwaysReadSource
for _, s := range alwaysSources {
if s.LocalPath == "" {
continue
}
content, err := os.ReadFile(s.LocalPath)
if err != nil || len(content) == 0 {
continue
}
result = append(result, AlwaysReadSource{
Name: s.Name,
Purpose: s.Purpose,
Content: string(content),
})
}
return result
}findRecallCandidates function · go · L111-L139 (29 LOC)params.go
func findRecallCandidates(st store.Store, testName string) *HistoryParams {
if testName == "" {
return nil
}
candidates, err := st.FindSymptomCandidates(testName)
if err != nil || len(candidates) == 0 {
return nil
}
best := candidates[0]
for _, c := range candidates[1:] {
if c.OccurrenceCount > best.OccurrenceCount {
best = c
} else if c.OccurrenceCount == best.OccurrenceCount && c.LastSeenAt > best.LastSeenAt {
best = c
}
}
history := loadHistory(st, best.ID)
if history == nil {
return nil
}
if best.Status == "dormant" && history.SymptomInfo != nil {
history.SymptomInfo.IsDormantReactivation = true
}
return history
}buildRecallDigest function · go · L141-L160 (20 LOC)params.go
func buildRecallDigest(st store.Store) []RecallDigestEntry {
rcas, err := st.ListRCAs()
if err != nil || len(rcas) == 0 {
return nil
}
digest := make([]RecallDigestEntry, 0, len(rcas))
for _, rca := range rcas {
summary := rca.Description
if len(summary) > 200 {
summary = summary[:200] + "..."
}
digest = append(digest, RecallDigestEntry{
ID: rca.ID,
Component: rca.Component,
DefectType: rca.DefectType,
Summary: summary,
})
}
return digest
}All rows scored by the Repobility analyzer (https://repobility.com)
loadHistory function · go · L162-L196 (35 LOC)params.go
func loadHistory(st store.Store, symptomID int64) *HistoryParams {
history := &HistoryParams{}
sym, err := st.GetSymptom(symptomID)
if err == nil && sym != nil {
history.SymptomInfo = &SymptomInfoParams{
Name: sym.Name,
OccurrenceCount: sym.OccurrenceCount,
FirstSeen: sym.FirstSeenAt,
LastSeen: sym.LastSeenAt,
Status: sym.Status,
}
}
links, err := st.GetRCAsForSymptom(symptomID)
if err == nil {
for _, link := range links {
rca, err := st.GetRCA(link.RCAID)
if err != nil || rca == nil {
continue
}
history.PriorRCAs = append(history.PriorRCAs, PriorRCAParams{
ID: rca.ID,
Title: rca.Title,
DefectType: rca.DefectType,
Status: rca.Status,
AffectedVersions: rca.AffectedVersions,
JiraLink: rca.JiraLink,
ResolvedAt: rca.ResolvedAt,
})
}
}
return history
}DefaultTaxonomy function · go · L228-L230 (3 LOC)params_types.go
func DefaultTaxonomy() *TaxonomyParams {
return TaxonomyFromDefectTypes(defaultDefectTypes)
}TaxonomyFromDefectTypes function · go · L235-L267 (33 LOC)params_types.go
func TaxonomyFromDefectTypes(types map[string]circuit.VocabEntry) *TaxonomyParams {
if len(types) == 0 {
return &TaxonomyParams{}
}
codes := make([]string, 0, len(types))
for code := range types {
codes = append(codes, code)
}
sort.Strings(codes)
var b strings.Builder
b.WriteString("Defect types:")
for _, code := range codes {
e := types[code]
name := e.Long
if name == "" {
name = e.Short
}
if name == "" {
name = code
}
b.WriteString("\n- ")
b.WriteString(code)
b.WriteString(": ")
b.WriteString(name)
if e.Description != "" {
b.WriteString(" — ")
b.WriteString(e.Description)
}
}
return &TaxonomyParams{DefectTypes: b.String()}
}Push method · go · L48-L50 (3 LOC)rcatype/source.go
func (DefaultDefectWriter) Push(verdict RCAVerdict) (*PushedRecord, error) {
return &PushedRecord{RunID: verdict.RunID, DefectType: verdict.DefectType}, nil
}DedupKey method · go · L77-L79 (3 LOC)rcatype/source.go
func (f *FailureInfo) DedupKey(project string) string {
return fmt.Sprintf("%s:%d:%d", project, f.RunID, f.ItemID)
}Transform method · go · L17-L38 (22 LOC)recall_heuristic.go
func (t *recallHeuristic) Transform(_ context.Context, tc *engine.TransformerContext) (any, error) {
fp := failureFromContext(tc.WalkerState)
fingerprint := ComputeFingerprint(fp.name, fp.errorMessage, "")
sym, err := t.ht.st.GetSymptomByFingerprint(fingerprint)
if err != nil || sym == nil {
return map[string]any{
"match": false, "confidence": 0.0,
"reasoning": "no matching symptom in store",
}, nil
}
links, err := t.ht.st.GetRCAsForSymptom(sym.ID)
if err != nil || len(links) == 0 {
return map[string]any{
"match": true, "symptom_id": float64(sym.ID), "confidence": 0.60,
"reasoning": fmt.Sprintf("matched symptom %q (count=%d) but no linked RCA", sym.Name, sym.OccurrenceCount),
}, nil
}
return map[string]any{
"match": true, "prior_rca_id": float64(links[0].RCAID), "symptom_id": float64(sym.ID), "confidence": 0.85,
"reasoning": fmt.Sprintf("recalled symptom %q with RCA #%d", sym.Name, links[0].RCAID),
}, nil
}formatThreshold function · go · L19-L30 (12 LOC)report_data.go
func formatThreshold(m Metric) string {
switch m.ID {
case "M4", "M20":
return fmt.Sprintf("≤%.2f", m.Threshold)
case "M17":
return "0.5–2.0"
case "M18":
return fmt.Sprintf("≤%.0f", m.Threshold)
default:
return fmt.Sprintf("≥%.2f", m.Threshold)
}
}metricGroup function · go · L32-L45 (14 LOC)report_data.go
func metricGroup(id string) string {
switch id {
case "M1", "M15", "M10":
return "outcome"
case "M2", "M3", "M5", "M6", "M7", "M8", "M12", "M13":
return "investigation"
case "M9", "M11":
return "detection"
case "M16", "M17", "M18":
return "efficiency"
default:
return "meta"
}
}Repobility's GitHub App fixes findings like these · https://github.com/apps/repobility-bot
metricRows function · go · L47-L67 (21 LOC)report_data.go
func metricRows(ms cal.MetricSet, group string) []map[string]any {
var rows []map[string]any
for _, m := range ms.Metrics {
if metricGroup(m.ID) != group {
continue
}
passMark := toolkit.BoolMark(m.Pass)
if m.DryCapped {
passMark = "~"
}
rows = append(rows, map[string]any{
"ID": m.ID,
"Metric": defaultVocab.Name(m.ID),
"Value": fmt.Sprintf("%.2f", m.Value),
"Detail": m.Detail,
"Pass": passMark,
"Threshold": formatThreshold(m),
})
}
return rows
}CalibrationReportData function · go · L71-L165 (95 LOC)report_data.go
func CalibrationReportData(r *CalibrationReport) map[string]any {
data := make(map[string]any)
data["scenario_name"] = r.CalibrationReport.Scenario
data["transformer"] = r.CalibrationReport.Transformer
data["total_cases"] = len(r.CaseResults)
passed, total := r.Metrics.PassCount()
result := "PASS"
if passed < total {
result = "FAIL"
}
data["result_text"] = fmt.Sprintf("%s (%d/%d metrics within threshold)", result, passed, total)
verifiedCount := 0
candidateCount := 0
if r.Dataset != nil {
verifiedCount = r.Dataset.VerifiedCount
candidateCount = r.Dataset.CandidateCount
}
data["verified_count"] = verifiedCount
data["candidate_count"] = candidateCount
metricGroups := map[string]string{
"outcome": "outcome_metrics",
"investigation": "investigation_metrics",
"detection": "detection_metrics",
"efficiency": "efficiency_metrics",
"meta": "meta_metrics",
}
for group, key := range metricGroups {
data[key] = metricRows(r.Metrics, grouRenderCalibrationReport function · go · L168-L175 (8 LOC)report_data.go
func RenderCalibrationReport(r *CalibrationReport, templateData []byte) (string, error) {
def, err := cal.ParseReportDef(templateData)
if err != nil {
return "", fmt.Errorf("parse calibration report template: %w", err)
}
data := CalibrationReportData(r)
return cal.Render(def, data)
}