feat(assessment): report planned bank coverage
This commit is contained in:
1 parent
76d32bb79f
commit
a69b1a79bb
10 files changed
+1211
-288
No files matched your search
@@ -0,0 +1,535 @@
|
||||
package assessment
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"lincodex/backend/internal/domain"
|
||||
)
|
||||
|
||||
const (
|
||||
maxBankManifestBytes = 1 << 20
|
||||
bankCoverageManifestVersion = 1
|
||||
maximumDifficultySpreadLogits = 0.3
|
||||
minimumItemDiscrimination = 0.5
|
||||
minimumPointBiserial = 0.2
|
||||
)
|
||||
|
||||
var requiredBankPlan = map[string]map[string]int{
|
||||
"backend": {
|
||||
"algorithms": 5, "data-structures": 4, "http-api": 4,
|
||||
"sql-transactions": 4, "concurrency": 4, "debugging-testing": 4,
|
||||
},
|
||||
"network": {
|
||||
"addressing-subnetting": 3, "ethernet-vlan": 3, "routing-ospf": 3,
|
||||
"dns-dhcp-tcp": 3, "configuration-diagnostics": 3,
|
||||
},
|
||||
}
|
||||
|
||||
var requiredBankLanguages = map[string][]string{
|
||||
"backend": {"go", "python"},
|
||||
"network": nil,
|
||||
}
|
||||
|
||||
var requiredBankContent = []string{"answer_key", "rubric", "seed_generator"}
|
||||
var requiredBankEvidence = []string{"grade_coverage", "independent_review", "reference_seeds"}
|
||||
|
||||
// BankCoverageManifest describes the planned bank inventory. It does not mark
|
||||
// any family as reviewed, calibrated, published, or available to candidates.
|
||||
type BankCoverageManifest struct {
|
||||
Version int `json:"version"`
|
||||
Categories []BankCoverageCategoryPlan `json:"categories"`
|
||||
RequiredContent []string `json:"required_content"`
|
||||
RequiredEvidence []string `json:"required_evidence"`
|
||||
CalibrationGates BankCalibrationGatePlan `json:"calibration_gates"`
|
||||
}
|
||||
|
||||
type BankCoverageCategoryPlan struct {
|
||||
Code string `json:"code"`
|
||||
RequiredFamilyCount int `json:"required_family_count"`
|
||||
RequiredLanguages []string `json:"required_languages"`
|
||||
ImplementationsDir string `json:"implementations_dir"`
|
||||
Topics []BankCoverageTopicPlan `json:"topics"`
|
||||
}
|
||||
|
||||
type BankCoverageTopicPlan struct {
|
||||
Name string `json:"name"`
|
||||
RequiredFamilyCount int `json:"required_family_count"`
|
||||
FamilyKeys []string `json:"family_keys"`
|
||||
}
|
||||
|
||||
type BankCalibrationGatePlan struct {
|
||||
ExternalMeasurementRequired bool `json:"external_measurement_required"`
|
||||
MaximumDifficultySpreadLogits float64 `json:"maximum_difficulty_spread_logits"`
|
||||
MinimumDiscrimination float64 `json:"minimum_discrimination"`
|
||||
MinimumPointBiserial float64 `json:"minimum_point_biserial"`
|
||||
}
|
||||
|
||||
// BankCoverageInventory contains validated family drafts and artifact paths
|
||||
// collected by a caller such as the assessment operator command.
|
||||
type BankCoverageInventory struct {
|
||||
Families []BankCoverageFamilyRecord
|
||||
ImplementationFiles []string
|
||||
InvalidBundleFiles []string
|
||||
}
|
||||
|
||||
type BankCoverageFamilyRecord struct {
|
||||
Key string
|
||||
Category string
|
||||
Version int32
|
||||
Author string
|
||||
Reviewer string
|
||||
ReviewStatus string
|
||||
Source string
|
||||
}
|
||||
|
||||
type BankCoverageCategoryReport struct {
|
||||
Code string
|
||||
PlannedFamilies int
|
||||
PresentFamilies int
|
||||
InventoriedFamilies int
|
||||
RequiredImplementationFiles int
|
||||
PresentImplementationFiles int
|
||||
}
|
||||
|
||||
// BankCoverageReport is a snapshot of planned family keys and artifact paths.
|
||||
// Review status is reported as bundle metadata only; this report never
|
||||
// authorizes publication or candidate availability.
|
||||
type BankCoverageReport struct {
|
||||
Categories []BankCoverageCategoryReport
|
||||
InventoriedFamilies int
|
||||
DeclaredApprovedReviews int
|
||||
PendingReviewDeclarations int
|
||||
RejectedReviewDeclarations int
|
||||
MissingFamilyKeys []string
|
||||
MissingIndependentReviews []string
|
||||
CategoryMismatches []string
|
||||
UnassignedFamilyKeys []string
|
||||
UnassignedCategories []string
|
||||
MissingImplementationFiles []string
|
||||
InvalidBundleFiles []string
|
||||
UnverifiableEvidence []string
|
||||
CalibrationMeasurementRequired bool
|
||||
}
|
||||
|
||||
type bankManifestFamily struct {
|
||||
category string
|
||||
implementationsDir string
|
||||
languages []string
|
||||
}
|
||||
|
||||
// ParseBankCoverageManifest strictly decodes and validates the planned bank
|
||||
// inventory. Its 25 Backend and 15 Network family counts are the initial
|
||||
// authoring floor within the PRD's wider target ranges.
|
||||
func ParseBankCoverageManifest(content []byte) (BankCoverageManifest, error) {
|
||||
const location = "assessment.ParseBankCoverageManifest"
|
||||
if len(content) > maxBankManifestBytes {
|
||||
return BankCoverageManifest{}, fmt.Errorf("%s - manifest exceeds %d bytes: %w", location, maxBankManifestBytes, domain.ErrInvalidAssessmentFamily)
|
||||
}
|
||||
decoder := json.NewDecoder(bytes.NewReader(content))
|
||||
decoder.DisallowUnknownFields()
|
||||
var manifest BankCoverageManifest
|
||||
if err := decoder.Decode(&manifest); err != nil {
|
||||
return BankCoverageManifest{}, fmt.Errorf("%s - decode manifest: %w: %w", location, domain.ErrInvalidAssessmentFamily, err)
|
||||
}
|
||||
var trailing any
|
||||
if err := decoder.Decode(&trailing); !errors.Is(err, io.EOF) {
|
||||
if err == nil {
|
||||
return BankCoverageManifest{}, fmt.Errorf("%s - trailing data after manifest: %w", location, domain.ErrInvalidAssessmentFamily)
|
||||
}
|
||||
return BankCoverageManifest{}, fmt.Errorf("%s - read after manifest: %w: %w", location, domain.ErrInvalidAssessmentFamily, err)
|
||||
}
|
||||
if err := validateBankCoverageManifest(manifest); err != nil {
|
||||
return BankCoverageManifest{}, fmt.Errorf("%s - validate manifest: %w", location, err)
|
||||
}
|
||||
return manifest, nil
|
||||
}
|
||||
|
||||
// BuildBankCoverageReport matches validated bundle inventory against the
|
||||
// planned family keys. Missing content and artifact paths are report data, not
|
||||
// errors, so incomplete authoring does not fail ordinary backend checks.
|
||||
func BuildBankCoverageReport(manifest BankCoverageManifest, inventory BankCoverageInventory) (BankCoverageReport, error) {
|
||||
const location = "assessment.BuildBankCoverageReport"
|
||||
if err := validateBankCoverageManifest(manifest); err != nil {
|
||||
return BankCoverageReport{}, fmt.Errorf("%s - validate manifest: %w", location, err)
|
||||
}
|
||||
build := newBankCoverageBuild(manifest, inventory)
|
||||
build.addFamilyRecords(inventory.Families)
|
||||
build.countObservedFamilies()
|
||||
build.countMissingRequirements(inventory.ImplementationFiles)
|
||||
return build.finish(), nil
|
||||
}
|
||||
|
||||
type bankCoverageBuild struct {
|
||||
report BankCoverageReport
|
||||
planned map[string]bankManifestFamily
|
||||
observed map[string]BankCoverageFamilyRecord
|
||||
unassignedKeys map[string]struct{}
|
||||
unassignedCategory map[string]struct{}
|
||||
categoryReports map[string]*BankCoverageCategoryReport
|
||||
}
|
||||
|
||||
func newBankCoverageBuild(manifest BankCoverageManifest, inventory BankCoverageInventory) bankCoverageBuild {
|
||||
build := bankCoverageBuild{
|
||||
report: newBankCoverageReport(manifest),
|
||||
planned: indexBankManifestFamilies(manifest),
|
||||
observed: make(map[string]BankCoverageFamilyRecord, len(inventory.Families)),
|
||||
unassignedKeys: make(map[string]struct{}),
|
||||
unassignedCategory: make(map[string]struct{}),
|
||||
categoryReports: make(map[string]*BankCoverageCategoryReport, len(manifest.Categories)),
|
||||
}
|
||||
build.report.InvalidBundleFiles = slices.Clone(inventory.InvalidBundleFiles)
|
||||
for index := range build.report.Categories {
|
||||
build.categoryReports[build.report.Categories[index].Code] = &build.report.Categories[index]
|
||||
}
|
||||
return build
|
||||
}
|
||||
|
||||
func (build *bankCoverageBuild) addFamilyRecords(families []BankCoverageFamilyRecord) {
|
||||
for _, family := range families {
|
||||
if !validBankCoverageFamilyRecord(family) {
|
||||
build.report.InvalidBundleFiles = append(build.report.InvalidBundleFiles,
|
||||
fmt.Sprintf("%s: invalid family record %q", family.Source, family.Key))
|
||||
continue
|
||||
}
|
||||
build.classifyFamily(family)
|
||||
build.recordFamilyVersion(family)
|
||||
}
|
||||
}
|
||||
|
||||
func (build *bankCoverageBuild) classifyFamily(family BankCoverageFamilyRecord) {
|
||||
plannedFamily, isPlanned := build.planned[family.Key]
|
||||
if !isPlanned {
|
||||
build.unassignedKeys[family.Key] = struct{}{}
|
||||
}
|
||||
if build.categoryReports[family.Category] == nil {
|
||||
build.unassignedCategory[family.Category] = struct{}{}
|
||||
}
|
||||
if isPlanned && family.Category != plannedFamily.category {
|
||||
build.report.CategoryMismatches = append(build.report.CategoryMismatches,
|
||||
fmt.Sprintf("%s: expected %s, found %s", family.Key, plannedFamily.category, family.Category))
|
||||
}
|
||||
}
|
||||
|
||||
func (build *bankCoverageBuild) recordFamilyVersion(family BankCoverageFamilyRecord) {
|
||||
current, exists := build.observed[family.Key]
|
||||
if exists && current.Category != family.Category {
|
||||
build.report.InvalidBundleFiles = append(build.report.InvalidBundleFiles,
|
||||
fmt.Sprintf("%s: family %s appears under categories %s and %s", family.Source, family.Key, current.Category, family.Category))
|
||||
return
|
||||
}
|
||||
if !exists || family.Version > current.Version {
|
||||
build.observed[family.Key] = family
|
||||
return
|
||||
}
|
||||
if family.Version == current.Version {
|
||||
build.report.InvalidBundleFiles = append(build.report.InvalidBundleFiles,
|
||||
fmt.Sprintf("%s: family %s version %d appears in more than one bundle", family.Source, family.Key, family.Version))
|
||||
}
|
||||
}
|
||||
|
||||
func (build *bankCoverageBuild) countObservedFamilies() {
|
||||
for key, family := range build.observed {
|
||||
build.report.InventoriedFamilies++
|
||||
if categoryReport := build.categoryReports[family.Category]; categoryReport != nil {
|
||||
categoryReport.InventoriedFamilies++
|
||||
}
|
||||
build.countReviewDeclaration(family)
|
||||
plannedFamily, isPlanned := build.planned[key]
|
||||
if !isPlanned || family.Category != plannedFamily.category {
|
||||
continue
|
||||
}
|
||||
build.categoryReports[plannedFamily.category].PresentFamilies++
|
||||
if family.ReviewStatus != string(domain.AssessmentReviewApproved) || family.Reviewer == "" || family.Reviewer == family.Author {
|
||||
build.report.MissingIndependentReviews = append(build.report.MissingIndependentReviews, key)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (build *bankCoverageBuild) countReviewDeclaration(family BankCoverageFamilyRecord) {
|
||||
switch family.ReviewStatus {
|
||||
case string(domain.AssessmentReviewApproved):
|
||||
if family.Reviewer != "" && family.Reviewer != family.Author {
|
||||
build.report.DeclaredApprovedReviews++
|
||||
}
|
||||
case string(domain.AssessmentReviewRejected):
|
||||
build.report.RejectedReviewDeclarations++
|
||||
default:
|
||||
build.report.PendingReviewDeclarations++
|
||||
}
|
||||
}
|
||||
|
||||
func (build *bankCoverageBuild) countMissingRequirements(paths []string) {
|
||||
implementationFiles := make(map[string]struct{}, len(paths))
|
||||
for _, path := range paths {
|
||||
implementationFiles[filepath.ToSlash(filepath.Clean(path))] = struct{}{}
|
||||
}
|
||||
for key, family := range build.planned {
|
||||
observedFamily, exists := build.observed[key]
|
||||
if !exists || observedFamily.Category != family.category {
|
||||
build.report.MissingFamilyKeys = append(build.report.MissingFamilyKeys, key)
|
||||
}
|
||||
build.countMissingImplementations(key, family, implementationFiles)
|
||||
}
|
||||
}
|
||||
|
||||
func (build *bankCoverageBuild) countMissingImplementations(key string, family bankManifestFamily, present map[string]struct{}) {
|
||||
for _, language := range family.languages {
|
||||
relative := filepath.ToSlash(filepath.Join(family.implementationsDir, key+implementationExtension(language)))
|
||||
if _, exists := present[relative]; !exists {
|
||||
build.report.MissingImplementationFiles = append(build.report.MissingImplementationFiles, relative)
|
||||
continue
|
||||
}
|
||||
build.categoryReports[family.category].PresentImplementationFiles++
|
||||
}
|
||||
}
|
||||
|
||||
func (build *bankCoverageBuild) finish() BankCoverageReport {
|
||||
for key := range build.unassignedKeys {
|
||||
build.report.UnassignedFamilyKeys = append(build.report.UnassignedFamilyKeys, key)
|
||||
}
|
||||
for category := range build.unassignedCategory {
|
||||
build.report.UnassignedCategories = append(build.report.UnassignedCategories, category)
|
||||
}
|
||||
slices.Sort(build.report.MissingFamilyKeys)
|
||||
slices.Sort(build.report.MissingIndependentReviews)
|
||||
slices.Sort(build.report.CategoryMismatches)
|
||||
slices.Sort(build.report.UnassignedFamilyKeys)
|
||||
slices.Sort(build.report.UnassignedCategories)
|
||||
slices.Sort(build.report.MissingImplementationFiles)
|
||||
slices.Sort(build.report.InvalidBundleFiles)
|
||||
return build.report
|
||||
}
|
||||
|
||||
// StrictError reports missing inventory requirements that the checker can
|
||||
// verify. It does not certify the external review, calibration, or semantic
|
||||
// equivalence of reference implementations.
|
||||
func (report BankCoverageReport) StrictError() error {
|
||||
const location = "assessment.BankCoverageReport.StrictError"
|
||||
if len(report.MissingFamilyKeys) == 0 && len(report.MissingIndependentReviews) == 0 &&
|
||||
len(report.MissingImplementationFiles) == 0 && len(report.InvalidBundleFiles) == 0 &&
|
||||
len(report.CategoryMismatches) == 0 {
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("%s - planned bank inventory has %d missing families, %d missing review declarations, %d missing implementation paths, and %d invalid bundle records", location,
|
||||
len(report.MissingFamilyKeys), len(report.MissingIndependentReviews), len(report.MissingImplementationFiles), len(report.InvalidBundleFiles)+len(report.CategoryMismatches))
|
||||
}
|
||||
|
||||
func validateBankCoverageManifest(manifest BankCoverageManifest) error {
|
||||
const location = "assessment.validateBankCoverageManifest"
|
||||
if manifest.Version != bankCoverageManifestVersion {
|
||||
return fmt.Errorf("%s - version must be %d: %w", location, bankCoverageManifestVersion, domain.ErrInvalidAssessmentFamily)
|
||||
}
|
||||
if len(manifest.Categories) != len(requiredBankPlan) {
|
||||
return fmt.Errorf("%s - exactly backend and network categories are required: %w", location, domain.ErrInvalidAssessmentFamily)
|
||||
}
|
||||
if err := validateBankCoverageCategories(manifest.Categories); err != nil {
|
||||
return fmt.Errorf("%s - validate category plans: %w", location, err)
|
||||
}
|
||||
if !sameStringSet(manifest.RequiredContent, requiredBankContent) {
|
||||
return fmt.Errorf("%s - required content must include seed_generator, answer_key, and rubric: %w", location, domain.ErrInvalidAssessmentFamily)
|
||||
}
|
||||
if !sameStringSet(manifest.RequiredEvidence, requiredBankEvidence) {
|
||||
return fmt.Errorf("%s - required evidence must include grade_coverage, reference_seeds, and independent_review: %w", location, domain.ErrInvalidAssessmentFamily)
|
||||
}
|
||||
gates := manifest.CalibrationGates
|
||||
if !gates.ExternalMeasurementRequired || gates.MaximumDifficultySpreadLogits != maximumDifficultySpreadLogits ||
|
||||
gates.MinimumDiscrimination != minimumItemDiscrimination || gates.MinimumPointBiserial != minimumPointBiserial {
|
||||
return fmt.Errorf("%s - calibration thresholds must remain external gates at 0.3, 0.5, and 0.2: %w", location, domain.ErrInvalidAssessmentFamily)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func validateBankCoverageCategories(categories []BankCoverageCategoryPlan) error {
|
||||
const location = "assessment.validateBankCoverageCategories"
|
||||
seenCategories := make(map[string]struct{}, len(categories))
|
||||
seenFamilyKeys := make(map[string]struct{})
|
||||
for _, category := range categories {
|
||||
expectedTopics, ok := requiredBankPlan[category.Code]
|
||||
if !ok {
|
||||
return fmt.Errorf("%s - unknown category %q: %w", location, category.Code, domain.ErrInvalidAssessmentFamily)
|
||||
}
|
||||
if _, exists := seenCategories[category.Code]; exists {
|
||||
return fmt.Errorf("%s - category %q appears twice: %w", location, category.Code, domain.ErrInvalidAssessmentFamily)
|
||||
}
|
||||
seenCategories[category.Code] = struct{}{}
|
||||
if err := validateBankCoverageCategory(category, expectedTopics, seenFamilyKeys); err != nil {
|
||||
return fmt.Errorf("%s - category %s: %w", location, category.Code, err)
|
||||
}
|
||||
}
|
||||
for category := range requiredBankPlan {
|
||||
if _, ok := seenCategories[category]; !ok {
|
||||
return fmt.Errorf("%s - category %s is missing: %w", location, category, domain.ErrInvalidAssessmentFamily)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func validateBankCoverageCategory(category BankCoverageCategoryPlan, expectedTopics map[string]int, seenFamilyKeys map[string]struct{}) error {
|
||||
const location = "assessment.validateBankCoverageCategory"
|
||||
if category.RequiredFamilyCount != sumTopicCounts(expectedTopics) {
|
||||
return fmt.Errorf("%s - requires %d planned families: %w", location, sumTopicCounts(expectedTopics), domain.ErrInvalidAssessmentFamily)
|
||||
}
|
||||
if !sameStringSet(category.RequiredLanguages, requiredBankLanguages[category.Code]) {
|
||||
return fmt.Errorf("%s - has unsupported required languages: %w", location, domain.ErrInvalidAssessmentFamily)
|
||||
}
|
||||
if len(category.RequiredLanguages) > 0 {
|
||||
if err := validateImplementationDir(category.ImplementationsDir); err != nil {
|
||||
return fmt.Errorf("%s - implementation directory: %w", location, err)
|
||||
}
|
||||
} else if category.ImplementationsDir != "" {
|
||||
return fmt.Errorf("%s - must not declare implementation files: %w", location, domain.ErrInvalidAssessmentFamily)
|
||||
}
|
||||
return validateBankCoverageTopics(category.Code, category.Topics, expectedTopics, seenFamilyKeys)
|
||||
}
|
||||
|
||||
func validateBankCoverageTopics(category string, topics []BankCoverageTopicPlan, expectedTopics map[string]int, seenFamilyKeys map[string]struct{}) error {
|
||||
const location = "assessment.validateBankCoverageTopics"
|
||||
if len(topics) != len(expectedTopics) {
|
||||
return fmt.Errorf("%s - category %s has an unexpected topic set: %w", location, category, domain.ErrInvalidAssessmentFamily)
|
||||
}
|
||||
seenTopics := make(map[string]struct{}, len(topics))
|
||||
for _, topic := range topics {
|
||||
requiredCount, ok := expectedTopics[topic.Name]
|
||||
if !ok {
|
||||
return fmt.Errorf("%s - category %s has unknown topic %q: %w", location, category, topic.Name, domain.ErrInvalidAssessmentFamily)
|
||||
}
|
||||
if _, exists := seenTopics[topic.Name]; exists {
|
||||
return fmt.Errorf("%s - category %s topic %q appears twice: %w", location, category, topic.Name, domain.ErrInvalidAssessmentFamily)
|
||||
}
|
||||
seenTopics[topic.Name] = struct{}{}
|
||||
if err := validateBankCoverageTopic(category, topic, requiredCount, seenFamilyKeys); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
for name := range expectedTopics {
|
||||
if _, ok := seenTopics[name]; !ok {
|
||||
return fmt.Errorf("%s - category %s is missing topic %q: %w", location, category, name, domain.ErrInvalidAssessmentFamily)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func validateBankCoverageTopic(category string, topic BankCoverageTopicPlan, requiredCount int, seenFamilyKeys map[string]struct{}) error {
|
||||
const location = "assessment.validateBankCoverageTopic"
|
||||
if topic.RequiredFamilyCount != requiredCount || len(topic.FamilyKeys) != requiredCount {
|
||||
return fmt.Errorf("%s - category %s topic %q requires %d family keys: %w", location, category, topic.Name, requiredCount, domain.ErrInvalidAssessmentFamily)
|
||||
}
|
||||
for _, key := range topic.FamilyKeys {
|
||||
if _, err := domain.ParseAssessmentFamilyKey(key); err != nil {
|
||||
return fmt.Errorf("%s - category %s topic %s has an invalid family key %q: %w", location, category, topic.Name, key, err)
|
||||
}
|
||||
if _, exists := seenFamilyKeys[key]; exists {
|
||||
return fmt.Errorf("%s - family key %q appears more than once: %w", location, key, domain.ErrInvalidAssessmentFamily)
|
||||
}
|
||||
seenFamilyKeys[key] = struct{}{}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func validateImplementationDir(value string) error {
|
||||
if value == "" || filepath.IsAbs(value) {
|
||||
return fmt.Errorf("must be a non-empty relative path: %w", domain.ErrInvalidAssessmentFamily)
|
||||
}
|
||||
for _, part := range strings.Split(filepath.Clean(value), string(filepath.Separator)) {
|
||||
if part == ".." || part == "." || part == "" {
|
||||
return fmt.Errorf("must not escape the bundle directory: %w", domain.ErrInvalidAssessmentFamily)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func validBankCoverageFamilyRecord(family BankCoverageFamilyRecord) bool {
|
||||
if _, err := domain.ParseAssessmentFamilyKey(family.Key); err != nil || family.Version < 1 {
|
||||
return false
|
||||
}
|
||||
if _, err := domain.ParseAssessmentCategory(family.Category); err != nil {
|
||||
return false
|
||||
}
|
||||
if _, err := domain.ParseAssessmentAuthor(family.Author); err != nil {
|
||||
return false
|
||||
}
|
||||
status, err := domain.ParseAssessmentReviewStatus(family.ReviewStatus)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
if status == domain.AssessmentReviewPending {
|
||||
return family.Reviewer == ""
|
||||
}
|
||||
if _, err := domain.ParseAssessmentOperator(family.Reviewer); err != nil {
|
||||
return false
|
||||
}
|
||||
return family.Reviewer != family.Author
|
||||
}
|
||||
|
||||
func implementationExtension(language string) string {
|
||||
if language == "python" {
|
||||
return ".py"
|
||||
}
|
||||
return ".go"
|
||||
}
|
||||
|
||||
func sameStringSet(actual, expected []string) bool {
|
||||
if len(actual) != len(expected) {
|
||||
return false
|
||||
}
|
||||
left := slices.Clone(actual)
|
||||
right := slices.Clone(expected)
|
||||
slices.Sort(left)
|
||||
slices.Sort(right)
|
||||
return slices.Equal(left, right)
|
||||
}
|
||||
|
||||
func sumTopicCounts(topics map[string]int) int {
|
||||
total := 0
|
||||
for _, count := range topics {
|
||||
total += count
|
||||
}
|
||||
return total
|
||||
}
|
||||
|
||||
func indexBankManifestFamilies(manifest BankCoverageManifest) map[string]bankManifestFamily {
|
||||
families := make(map[string]bankManifestFamily)
|
||||
for _, category := range manifest.Categories {
|
||||
for _, topic := range category.Topics {
|
||||
for _, key := range topic.FamilyKeys {
|
||||
families[key] = bankManifestFamily{
|
||||
category: category.Code,
|
||||
implementationsDir: category.ImplementationsDir,
|
||||
languages: slices.Clone(category.RequiredLanguages),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return families
|
||||
}
|
||||
|
||||
func newBankCoverageReport(manifest BankCoverageManifest) BankCoverageReport {
|
||||
report := BankCoverageReport{
|
||||
Categories: make([]BankCoverageCategoryReport, 0, len(manifest.Categories)),
|
||||
CalibrationMeasurementRequired: manifest.CalibrationGates.ExternalMeasurementRequired,
|
||||
UnverifiableEvidence: []string{
|
||||
"grade_coverage is not stored in the bundle format",
|
||||
"reference_seeds are not stored in the bundle format",
|
||||
"independent_review is declared by the bundle and is not authenticated here",
|
||||
"implementation files are checked for presence only; semantic parity is not tested here",
|
||||
},
|
||||
}
|
||||
for _, category := range manifest.Categories {
|
||||
requiredImplementationFiles := 0
|
||||
for _, topic := range category.Topics {
|
||||
requiredImplementationFiles += len(topic.FamilyKeys) * len(category.RequiredLanguages)
|
||||
}
|
||||
report.Categories = append(report.Categories, BankCoverageCategoryReport{
|
||||
Code: category.Code, PlannedFamilies: category.RequiredFamilyCount,
|
||||
RequiredImplementationFiles: requiredImplementationFiles,
|
||||
})
|
||||
}
|
||||
return report
|
||||
}
|
||||
Reference in new issue
Block a user