Documentation
¶
Overview ¶
Package grader implements automated grading of contextception analysis output against the testing-tracker rubric.
Index ¶
Constants ¶
const ( // Core archetypes (original 10). ArchService = "Service/Controller" ArchModel = "Model/Schema" ArchMiddleware = "Middleware/Plugin" ArchHighFanIn = "High Fan-in Utility" ArchPage = "Page/Route/Endpoint" ArchAuth = "Auth/Security" ArchLeaf = "Leaf Component" ArchConfig = "Config/Constants" ArchBarrel = "Barrel/Index" ArchTest = "Test File" // Extended archetypes (new). ArchDBMigration = "Database/Migration" ArchValidation = "Serialization/Validation" ArchErrorHandling = "Error Handling" ArchCLICommand = "CLI/Command" ArchEventMessage = "Event/Message" ArchInterface = "Interface/Contract" ArchOrchestrator = "Orchestrator" ArchHotspot = "Hotspot" )
Archetype category names.
Variables ¶
This section is empty.
Functions ¶
func AllArchetypeNames ¶
func AllArchetypeNames() []string
AllArchetypeNames returns all available archetype category names in detection order.
func ComputeReportOverall ¶
ComputeReportOverall computes the overall grade for a full report.
func LetterGradeFromScore ¶
LetterGradeFromScore converts a numeric grade (1-4) to a letter grade.
Types ¶
type ArchetypeCandidate ¶
type ArchetypeCandidate struct {
Archetype string `json:"archetype"`
File string `json:"file"`
Indegree int `json:"indegree"`
Outdegree int `json:"outdegree"`
Role string `json:"role,omitempty"`
}
ArchetypeCandidate represents a detected file for an archetype slot.
func DetectArchetypes ¶
func DetectArchetypes(idx *db.Index, categories []string) ([]ArchetypeCandidate, error)
DetectArchetypes selects representative files across architectural layers. If categories is nil or empty, all available archetypes are detected. If categories contains specific names, only those are detected. Unknown category names are silently skipped.
type FeatureTest ¶
type FeatureTest struct {
Group string `json:"group"` // e.g., "modes", "token_budget", "caps"
Name string `json:"name"`
Status string `json:"status"` // "pass", "fail", "skip"
Expected string `json:"expected,omitempty"`
Actual string `json:"actual,omitempty"`
Duration int64 `json:"duration_ms"`
Error string `json:"error,omitempty"`
}
FeatureTest represents a single feature matrix test result.
func RunFeatureTests ¶
RunFeatureTests executes the feature matrix against the given index and file. Returns results for 7 test groups: modes, token_budget, caps, flags, ci, discovery, schema.
type FileGrade ¶
type FileGrade struct {
File string `json:"file"`
Archetype string `json:"archetype"`
MustRead float64 `json:"must_read"` // 1-4
LikelyModify float64 `json:"likely_modify"` // 1-4
Tests float64 `json:"tests"` // 1-4
Related float64 `json:"related"` // 1-4
BlastRadius float64 `json:"blast_radius"` // 1-4
Overall float64 `json:"overall"` // weighted average
Notes []string `json:"notes,omitempty"` // explanation for each grade
}
FileGrade holds per-file grading results across all rubric sections.
func GradeFile ¶
func GradeFile(output *model.AnalysisOutput, archetype string) FileGrade
GradeFile applies the testing-tracker rubric to a single AnalysisOutput. The archetype name is for labeling only and does not affect scoring.
func (*FileGrade) ComputeOverall ¶
func (fg *FileGrade) ComputeOverall()
ComputeOverall computes the weighted overall score for a file grade. Weights: must_read=0.40, likely_modify=0.20, tests=0.15, related=0.15, blast_radius=0.10.
type Issue ¶
type Issue struct {
Severity string `json:"severity"` // "error", "warning", "info"
File string `json:"file,omitempty"`
Section string `json:"section,omitempty"`
Message string `json:"message"`
}
Issue represents an auto-detected problem in analysis output.
func DetectIssues ¶
func DetectIssues(out *model.AnalysisOutput) []Issue
DetectIssues scans analysis output for common problems.
type SectionGrades ¶
type SectionGrades struct {
MustRead float64 `json:"must_read"`
LikelyModify float64 `json:"likely_modify"`
Tests float64 `json:"tests"`
Related float64 `json:"related"`
BlastRadius float64 `json:"blast_radius"`
}
SectionGrades holds per-section averages across all files.
func ComputeSections ¶
func ComputeSections(files []FileGrade) SectionGrades
ComputeSections computes section averages from file grades.
type TestReport ¶
type TestReport struct {
RepoID string `json:"repo_id"`
RepoURL string `json:"repo_url"`
Timestamp time.Time `json:"timestamp"`
Language string `json:"language"`
FileCount int `json:"file_count"`
EdgeCount int `json:"edge_count"`
IndexTimeMs int64 `json:"index_time_ms"`
Files []FileGrade `json:"files"`
Sections SectionGrades `json:"sections"`
Overall float64 `json:"overall"`
LetterGrade string `json:"letter_grade"`
Issues []Issue `json:"issues"`
FeatureTests []FeatureTest `json:"feature_tests,omitempty"`
Archetypes []ArchetypeCandidate `json:"archetypes,omitempty"`
}
TestReport is the top-level report for a full test suite run.