Remove PRD/doc paths, bead IDs, phase notes and deleted-test references from comments; drop test-only hooks left by the test deletion. Includes in-progress archied bootstrap, gateway and query changes.
65 lines
1.8 KiB
Go
65 lines
1.8 KiB
Go
package prreview
|
|
|
|
import (
|
|
"cmp"
|
|
"slices"
|
|
)
|
|
|
|
type Dimension struct {
|
|
Name string
|
|
Prompt string
|
|
TargetFiles []string
|
|
ContextFiles []string
|
|
Priority float64
|
|
}
|
|
|
|
// MergeDimensions drops duplicate dimension names across the lenses' outputs
|
|
// (keeping the higher-priority copy), sorts by priority, and cuts the tail at
|
|
// cap. Order is stable for equal priority: the input order of the first lens
|
|
// that produced the name wins, so re-running the same lenses in the same
|
|
// order always keeps the same dimensions.
|
|
func MergeDimensions(lensOutputs [][]Dimension, limit int) []Dimension {
|
|
byName := make(map[string]Dimension)
|
|
order := make([]string, 0)
|
|
for _, lens := range lensOutputs {
|
|
for _, d := range lens {
|
|
existing, ok := byName[d.Name]
|
|
if !ok {
|
|
order = append(order, d.Name)
|
|
byName[d.Name] = d
|
|
continue
|
|
}
|
|
if d.Priority > existing.Priority {
|
|
byName[d.Name] = d
|
|
}
|
|
}
|
|
}
|
|
merged := make([]Dimension, 0, len(order))
|
|
for _, name := range order {
|
|
merged = append(merged, byName[name])
|
|
}
|
|
slices.SortStableFunc(merged, func(a, b Dimension) int {
|
|
return cmp.Compare(b.Priority, a.Priority)
|
|
})
|
|
if len(merged) > limit {
|
|
merged = merged[:limit]
|
|
}
|
|
return merged
|
|
}
|
|
|
|
// Returns nil at or below AIGeneratedThreshold -- a coin-flip is not evidence,
|
|
// so it is not added.
|
|
func HallucinationDimension(aiGenerated float64) *Dimension {
|
|
if aiGenerated <= AIGeneratedThreshold {
|
|
return nil
|
|
}
|
|
return &Dimension{
|
|
Name: "hallucination-check",
|
|
Prompt: "This PR's description or commit messages read as likely machine-written. " +
|
|
"Check every claim the PR makes -- what it says it does, any cited behaviour, API, or test result -- " +
|
|
"against what the diff actually implements. Report a finding for any claim, citation, or described " +
|
|
"behaviour that the diff does not actually carry out.",
|
|
Priority: 1,
|
|
}
|
|
}
|